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(); |