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

Unified Diff: extensions/renderer/extension_frame_helper.cc

Issue 2873503002: NOT YET READY: Improve granularity of window namespaces in Blink.
Patch Set: Rebasing... Created 3 years, 6 months 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/renderer/extension_frame_helper.h ('k') | third_party/WebKit/Source/core/exported/WebFactory.h » ('j') | 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 da47e687f5662c0d8eefb6830a860edf971c2689..6a91e015b28e65a673f9ba84220d35c67f76394c 100644
--- a/extensions/renderer/extension_frame_helper.cc
+++ b/extensions/renderer/extension_frame_helper.cc
@@ -17,6 +17,7 @@
#include "extensions/renderer/content_watcher.h"
#include "extensions/renderer/dispatcher.h"
#include "extensions/renderer/messaging_bindings.h"
+#include "extensions/renderer/renderer_extension_registry.h"
#include "extensions/renderer/script_context.h"
#include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
#include "third_party/WebKit/public/web/WebConsoleMessage.h"
@@ -139,6 +140,34 @@ content::RenderFrame* ExtensionFrameHelper::GetBackgroundPageFrame(
return nullptr;
}
+// static
+content::RenderFrame* ExtensionFrameHelper::FindFrame(
+ content::RenderFrame* relative_to_frame,
+ const std::string& name) {
+ // Only pierce browsing instance boundaries if |relative_to_frame| is an
+ // extension.
+ GURL effective_url = ScriptContext::GetEffectiveDocumentURL(
+ relative_to_frame->GetWebFrame(),
+ relative_to_frame->GetWebFrame()->GetDocument().Url(), true);
+ const Extension* extension =
+ extensions::RendererExtensionRegistry::Get()->GetExtensionOrAppByURL(
+ effective_url);
+ if (!extension)
+ return nullptr;
+
+ // Try to match all same-origin frames in this process.
+ for (const ExtensionFrameHelper* helper : g_frame_helpers.Get()) {
+ if (!relative_to_frame->GetWebFrame()->GetSecurityOrigin().CanAccess(
+ helper->render_frame()->GetWebFrame()->GetSecurityOrigin()))
+ continue;
+
+ if (helper->render_frame()->GetWebFrame()->AssignedName().Utf8() == name)
+ return helper->render_frame();
+ }
+
+ return nullptr;
+}
+
// static
bool ExtensionFrameHelper::IsContextForEventPage(const ScriptContext* context) {
content::RenderFrame* render_frame = context->GetRenderFrame();
« no previous file with comments | « extensions/renderer/extension_frame_helper.h ('k') | third_party/WebKit/Source/core/exported/WebFactory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698