New issue
Advanced search Search tips

Issue 848842 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Declarative Net Request: Collapse DOM elements for which network request is blocked.

Project Member Reported by karandeepb@chromium.org, Jun 1 2018

Issue description

DOM elements for which a network request is blocked through the declarative net request API should be automatically removed from the DOM. This is necessary since there is no easy way for extensions to do this when using DNR. 

This should probably be applicable to: - <img>, <iframe>, <object>, <embed> DOM elements. 

 
Blocking: 696822
Cc: rdevlin....@chromium.org lazyboy@chromium.org
Components: Platform>Extensions
Note: Subresource filtering does this already for <img> and <iframe> elements. But we can't directly use that since
- it blocks network requests for <img> elements directly in the renderer. Extensions block requests in the browser.
- For <iframe> elements they use  NavigationThrottle::ThrottleAction::BLOCK_REQUEST_AND_COLLAPSE, which sends an IPC over to the renderer instructing it to collapse the frame. But we would want to avoid sending an additional IPC for each blocked request.

Cc: jam@chromium.org mmenke@chromium.org
+mmenke@ and +jam@: 

Context: We block network requests when requested by extensions in the browser process. For example, this can happen for image and iframe sources. We'd like to provide the ability for these DOM elements to be automatically collapsed (think display:none). Can you advise regarding what would be a good way to plumb this info. to the renderer? 

The most simple way would be to just add another network error code (say net::ERR_CONTENT_BLOCKED or net::ERR_BLOCK_AND_COLLAPSE, currently extensions use net::ERR_BLOCKED_BY_CLIENT), but I am not sure if that's "clean" enough. Alternatively, we might be able to plumb this info. through URLLoaderCompletionStatus. Thoughts?
How extensions hook up is being completely changed, with the advent of the network service - not familiar with the new way at all.  That having been said, there's an extended error field now, and (I think) there's an enum in blink somewhere used to populate it, when the main error is ERR_BLOCKED_BY_CLIENT.
Project Member

Comment 4 by bugdroid1@chromium.org, Jun 19 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/87b9031e7435b3422369e0b01d47f5e56e89d444

commit 87b9031e7435b3422369e0b01d47f5e56e89d444
Author: Karan Bhatia <karandeepb@chromium.org>
Date: Tue Jun 19 03:54:24 2018

Declarative Net Request: Collapse blocked <img> elements.

With Declarative Net Request, there is no easy way for extensions to collapse
the DOM elements corresponding to the resources they blocked. This CL implements
the ability for the blocked <img> elements to be automatically collapsed in the
DOM. In subsequent CLs, similar function will be implemented for other DOM
elements.

To do this, following changes are made:
 - A new field called kCollapsedByClient is added to
   blink::ResourceRequestBlockedReason. Whenever an extension ruleset wants to
   collapse the DOM element corresponding to a network request, the
   extended_error_code is set to kCollapsedByClient, which is then used as a
   signal by the renderer to perform the collapsing.
 - Changes to blink::ResourceRequestBlockedReason also necessiate changes to the
   Devtools protocol. As a good side-effect, resources collapsed by extensions
   would be marked as "collapsed-by-client" by Devtools.
 - Changes are made to allow content embedders to set a
   blink::ResourceRequestBlockedReason for a request.

BUG=848842

Cq-Include-Trybots: luci.chromium.try:linux_mojo
Change-Id: I0bfd1a60bee79ef651741b7655fade6be4a7d419
Reviewed-on: https://chromium-review.googlesource.com/1088189
Commit-Queue: Matt Menke <mmenke@chromium.org>
Reviewed-by: Istiaque Ahmed <lazyboy@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Reviewed-by: Nate Chapin <japhet@chromium.org>
Reviewed-by: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Reviewed-by: Matt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568332}
[modify] https://crrev.com/87b9031e7435b3422369e0b01d47f5e56e89d444/chrome/browser/extensions/api/declarative_net_request/declarative_net_request_browsertest.cc
[modify] https://crrev.com/87b9031e7435b3422369e0b01d47f5e56e89d444/chrome/browser/net/chrome_extensions_network_delegate.cc
[add] https://crrev.com/87b9031e7435b3422369e0b01d47f5e56e89d444/chrome/test/data/extensions/declarative_net_request/image.html
[modify] https://crrev.com/87b9031e7435b3422369e0b01d47f5e56e89d444/content/browser/devtools/devtools_url_interceptor_request_job.cc
[modify] https://crrev.com/87b9031e7435b3422369e0b01d47f5e56e89d444/content/browser/devtools/protocol/network_handler.cc
[modify] https://crrev.com/87b9031e7435b3422369e0b01d47f5e56e89d444/content/browser/loader/resource_request_info_impl.cc
[modify] https://crrev.com/87b9031e7435b3422369e0b01d47f5e56e89d444/content/browser/loader/resource_request_info_impl.h
[modify] https://crrev.com/87b9031e7435b3422369e0b01d47f5e56e89d444/content/public/browser/resource_request_info.h
[modify] https://crrev.com/87b9031e7435b3422369e0b01d47f5e56e89d444/extensions/browser/api/declarative_net_request/ruleset_manager.cc
[modify] https://crrev.com/87b9031e7435b3422369e0b01d47f5e56e89d444/extensions/browser/api/declarative_net_request/ruleset_manager.h
[modify] https://crrev.com/87b9031e7435b3422369e0b01d47f5e56e89d444/extensions/browser/api/web_request/web_request_api.cc
[modify] https://crrev.com/87b9031e7435b3422369e0b01d47f5e56e89d444/extensions/browser/api/web_request/web_request_api.h
[modify] https://crrev.com/87b9031e7435b3422369e0b01d47f5e56e89d444/extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc
[modify] https://crrev.com/87b9031e7435b3422369e0b01d47f5e56e89d444/extensions/browser/api/web_request/web_request_proxying_websocket.cc
[modify] https://crrev.com/87b9031e7435b3422369e0b01d47f5e56e89d444/extensions/shell/browser/shell_network_delegate.cc
[modify] https://crrev.com/87b9031e7435b3422369e0b01d47f5e56e89d444/third_party/blink/public/platform/resource_request_blocked_reason.h
[modify] https://crrev.com/87b9031e7435b3422369e0b01d47f5e56e89d444/third_party/blink/renderer/core/inspector/browser_protocol.pdl
[modify] https://crrev.com/87b9031e7435b3422369e0b01d47f5e56e89d444/third_party/blink/renderer/core/inspector/inspector_network_agent.cc
[modify] https://crrev.com/87b9031e7435b3422369e0b01d47f5e56e89d444/third_party/blink/renderer/devtools/front_end/network/NetworkDataGridNode.js
[modify] https://crrev.com/87b9031e7435b3422369e0b01d47f5e56e89d444/third_party/blink/renderer/platform/loader/fetch/resource_error.cc
[modify] https://crrev.com/87b9031e7435b3422369e0b01d47f5e56e89d444/third_party/blink/renderer/platform/loader/fetch/resource_error.h

Project Member

Comment 5 by bugdroid1@chromium.org, Jun 26 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/6753ffc106c4c48af4eb250e08a9aa1ee8a86ade

commit 6753ffc106c4c48af4eb250e08a9aa1ee8a86ade
Author: Karan Bhatia <karandeepb@chromium.org>
Date: Tue Jun 26 04:04:35 2018

Declarative Net Request: Collapse blocked <iframe> elements.

With Declarative Net Request, there is no easy way for extensions to collapse
the DOM elements corresponding to the resources they blocked. This CL implements
the ability for the blocked <iframe> elements to be automatically collapsed in
the DOM.

BUG=848842

Change-Id: Iaf9ce75b5dc1a978a09e1ae698f2ed180351c288
Reviewed-on: https://chromium-review.googlesource.com/1111341
Commit-Queue: Karan Bhatia <karandeepb@chromium.org>
Reviewed-by: Camille Lamy <clamy@chromium.org>
Reviewed-by: Istiaque Ahmed <lazyboy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570327}
[modify] https://crrev.com/6753ffc106c4c48af4eb250e08a9aa1ee8a86ade/chrome/browser/extensions/api/declarative_net_request/declarative_net_request_browsertest.cc
[modify] https://crrev.com/6753ffc106c4c48af4eb250e08a9aa1ee8a86ade/chrome/test/data/extensions/declarative_net_request/page_with_two_frames.html
[modify] https://crrev.com/6753ffc106c4c48af4eb250e08a9aa1ee8a86ade/content/browser/frame_host/navigation_handle_impl.cc
[modify] https://crrev.com/6753ffc106c4c48af4eb250e08a9aa1ee8a86ade/content/browser/frame_host/navigation_request.cc
[modify] https://crrev.com/6753ffc106c4c48af4eb250e08a9aa1ee8a86ade/content/browser/frame_host/navigation_request.h
[modify] https://crrev.com/6753ffc106c4c48af4eb250e08a9aa1ee8a86ade/extensions/browser/api/declarative_net_request/ruleset_manager.cc

Cc: -jam@chromium.org -mmenke@chromium.org
Follow-up work is to also collapse <embed> and <object> tags. But this shouldn't be blocking issue 696822 anymore.
Labels: -Pri-2 Pri-3
Blocking: -696822
Removing issue 696822 as being blocked, as per c#6.

Sign in to add a comment