Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Unified Diff: extensions/renderer/extension_frame_helper.cc

Issue 1413853005: Track all extension frames in ProcessManager, inspect extensionoptions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup + remove DCHECK Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/common/view_type.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/extension_frame_helper.cc
diff --git a/extensions/renderer/extension_frame_helper.cc b/extensions/renderer/extension_frame_helper.cc
index fe581c331fd845868386be85175a7fe91f97244b..c063f84a169ba2a5d6915b6cdc121647f9b93e2c 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;
« no previous file with comments | « extensions/common/view_type.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698