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

Side by Side Diff: extensions/browser/extension_web_contents_observer.cc

Issue 1225413002: [Extensions] Fix improper extension tab ownership bug (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/browser/extension_web_contents_observer.h" 5 #include "extensions/browser/extension_web_contents_observer.h"
6 6
7 #include "content/public/browser/child_process_security_policy.h" 7 #include "content/public/browser/child_process_security_policy.h"
8 #include "content/public/browser/render_frame_host.h" 8 #include "content/public/browser/render_frame_host.h"
9 #include "content/public/browser/render_process_host.h" 9 #include "content/public/browser/render_process_host.h"
10 #include "content/public/browser/render_view_host.h" 10 #include "content/public/browser/render_view_host.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 render_frame_host->GetRoutingID(), GetViewType(web_contents()))); 54 render_frame_host->GetRoutingID(), GetViewType(web_contents())));
55 55
56 const Extension* frame_extension = GetExtensionFromFrame(render_frame_host); 56 const Extension* frame_extension = GetExtensionFromFrame(render_frame_host);
57 if (frame_extension) { 57 if (frame_extension) {
58 ExtensionsBrowserClient::Get()->RegisterMojoServices(render_frame_host, 58 ExtensionsBrowserClient::Get()->RegisterMojoServices(render_frame_host,
59 frame_extension); 59 frame_extension);
60 ProcessManager::Get(browser_context_) 60 ProcessManager::Get(browser_context_)
61 ->RegisterRenderFrameHost(web_contents(), render_frame_host, 61 ->RegisterRenderFrameHost(web_contents(), render_frame_host,
62 frame_extension); 62 frame_extension);
63 } 63 }
64
65 // This can be different from |frame_extension| above in the case of, e.g.,
66 // a non-extension iframe hosted in a chrome-extension:// page.
67 const Extension* main_frame_extension =
68 GetExtensionFromFrame(web_contents()->GetMainFrame());
69 // We notify the render frame that it's in an extension's tab, but not if this
70 // is a hosted app (we don't mind scripting on hosted apps' pages).
71 if (main_frame_extension && !main_frame_extension->is_hosted_app()) {
72 render_frame_host->Send(new ExtensionMsg_SetMainFrameExtensionOwner(
73 render_frame_host->GetRoutingID(), main_frame_extension->id()));
74 }
75 } 64 }
76 65
77 content::WebContents* ExtensionWebContentsObserver::GetAssociatedWebContents() 66 content::WebContents* ExtensionWebContentsObserver::GetAssociatedWebContents()
78 const { 67 const {
79 return web_contents(); 68 return web_contents();
80 } 69 }
81 70
82 void ExtensionWebContentsObserver::RenderViewCreated( 71 void ExtensionWebContentsObserver::RenderViewCreated(
83 content::RenderViewHost* render_view_host) { 72 content::RenderViewHost* render_view_host) {
84 // TODO(devlin): Most/all of this should move to RenderFrameCreated. 73 // TODO(devlin): Most/all of this should move to RenderFrameCreated.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 // Since this is called for all existing RenderFrameHosts during the 208 // Since this is called for all existing RenderFrameHosts during the
220 // ExtensionWebContentsObserver's creation, it's possible that not all hosts 209 // ExtensionWebContentsObserver's creation, it's possible that not all hosts
221 // are ready. 210 // are ready.
222 // We only initialize the frame if the renderer counterpart is live; otherwise 211 // We only initialize the frame if the renderer counterpart is live; otherwise
223 // we wait for the RenderFrameCreated notification. 212 // we wait for the RenderFrameCreated notification.
224 if (render_frame_host->IsRenderFrameLive()) 213 if (render_frame_host->IsRenderFrameLive())
225 InitializeRenderFrame(render_frame_host); 214 InitializeRenderFrame(render_frame_host);
226 } 215 }
227 216
228 } // namespace extensions 217 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/content_script_apitest.cc ('k') | extensions/common/extension_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698