diff options
author | rob <rob@robwu.nl> | 2015-12-06 04:39:45 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-06 12:40:24 +0000 |
commit | cdcc4b87e40c1b783541444d9484f33e81a177ba (patch) | |
tree | f26bde41f7147e65bce02b6fbeea08e263ff6d52 /extensions/renderer | |
parent | 0142f2f3d0e3e1ac1311101fcd10e5cd83069883 (diff) | |
download | chromium_src-cdcc4b87e40c1b783541444d9484f33e81a177ba.zip chromium_src-cdcc4b87e40c1b783541444d9484f33e81a177ba.tar.gz chromium_src-cdcc4b87e40c1b783541444d9484f33e81a177ba.tar.bz2 |
Track all extension frames in ProcessManager, inspect extensionoptions
ProcessManager::GetRenderFrameHostsForExtension did not return all RFHs
for a given extension, because of two errors:
1. An extension can have multiple SiteInstances, so SiteInstances should
not be compared by pointer.
2. ExtensionWebContentsObserver failed to register RFHs after a process
swap.
I discovered this when I noticed that tests started to fail unexpectedly
after applying https://codereview.chromium.org/1413543005. That patch
changes the extension messaging API, to route messages to RFHs instead
of processes. This requires extension frames to be tracked correctly...
Extension tabs, frames, etc. are now visible at "Inspect views" in the
extensions view (when developer mode is enabled), thanks to the fact
that all extension frames are now being tracked (excluding extension
frames that are hosted in a view without classification, e.g. developer
tools and most of the GuestViews).
BUG=432875,550022
CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_site_isolation
TEST=ExtensionApiTest.MessagingNoBackground does not fail any more with
https://codereview.chromium.org/1413543005 after applying this patch.
DeveloperPrivateApiTest.InspectEmbeddedOptionsPage passes.
ProcessManagerBrowserTest.NoBackgroundPage passes.
ProcessManagerBrowserTest.FrameClassification passes with and without
OOPIF.
Review URL: https://codereview.chromium.org/1413853005
Cr-Commit-Position: refs/heads/master@{#363368}
Diffstat (limited to 'extensions/renderer')
-rw-r--r-- | extensions/renderer/extension_frame_helper.cc | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/extensions/renderer/extension_frame_helper.cc b/extensions/renderer/extension_frame_helper.cc index fe581c3..c063f84a 100644 --- a/extensions/renderer/extension_frame_helper.cc +++ b/extensions/renderer/extension_frame_helper.cc @@ -4,6 +4,7 @@ #include "extensions/renderer/extension_frame_helper.h" +#include "base/strings/string_util.h" #include "content/public/renderer/render_frame.h" #include "extensions/common/api/messaging/message.h" #include "extensions/common/constants.h" @@ -14,6 +15,7 @@ #include "extensions/renderer/dispatcher.h" #include "extensions/renderer/messaging_bindings.h" #include "extensions/renderer/script_context.h" +#include "third_party/WebKit/public/platform/WebSecurityOrigin.h" #include "third_party/WebKit/public/web/WebConsoleMessage.h" #include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" @@ -34,11 +36,22 @@ bool RenderFrameMatches(const ExtensionFrameHelper* frame_helper, if (match_view_type != VIEW_TYPE_INVALID && frame_helper->view_type() != match_view_type) return false; - GURL url = frame_helper->render_frame()->GetWebFrame()->document().url(); - if (!url.SchemeIs(kExtensionScheme)) + + // Not all frames have a valid ViewType, e.g. devtools, most GuestViews, and + // unclassified detached WebContents. + if (frame_helper->view_type() == VIEW_TYPE_INVALID) return false; - if (url.host() != match_extension_id) + + // This logic matches ExtensionWebContentsObserver::GetExtensionFromFrame. + blink::WebSecurityOrigin origin = + frame_helper->render_frame()->GetWebFrame()->securityOrigin(); + if (origin.isUnique() || + !base::EqualsASCII(base::StringPiece16(origin.protocol()), + kExtensionScheme) || + !base::EqualsASCII(base::StringPiece16(origin.host()), + match_extension_id.c_str())) return false; + if (match_window_id != extension_misc::kUnknownWindowId && frame_helper->browser_window_id() != match_window_id) return false; |