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

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

Issue 1150683007: [Extensions] Use document url (not top url) for tab-specific permissions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix extension page content scripts Created 5 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 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 render_frame_host); 135 render_frame_host);
136 } 136 }
137 137
138 void ExtensionWebContentsObserver::RenderFrameHostChanged( 138 void ExtensionWebContentsObserver::RenderFrameHostChanged(
139 content::RenderFrameHost* old_host, 139 content::RenderFrameHost* old_host,
140 content::RenderFrameHost* new_host) { 140 content::RenderFrameHost* new_host) {
141 ProcessManager* process_manager = ProcessManager::Get(browser_context_); 141 ProcessManager* process_manager = ProcessManager::Get(browser_context_);
142 if (old_host) 142 if (old_host)
143 process_manager->UnregisterRenderFrameHost(old_host); 143 process_manager->UnregisterRenderFrameHost(old_host);
144 144
145 const Extension* extension = GetExtension(new_host->GetRenderViewHost()); 145 const Extension* frame_extension = GetExtensionForRenderFrame(new_host);
146 if (extension) { 146 if (frame_extension) {
147 process_manager->RegisterRenderFrameHost( 147 process_manager->RegisterRenderFrameHost(
148 web_contents(), new_host, extension); 148 web_contents(), new_host, frame_extension);
149 }
150
151 // This can be different from |frame_extension| above in the case of, e.g.,
152 // a non-extension iframe hosted in a chrome-extension:// page.
153 const Extension* tab_extension =
154 GetExtensionForRenderFrame(web_contents()->GetMainFrame());
155 if (tab_extension) {
156 new_host->Send(new ExtensionMsg_SetTabExtensionOwner(
not at google - send to devlin 2015/06/03 20:15:44 creis/nasko - Firstly, this is basically a side c
Devlin 2015/06/03 20:28:47 A bit more background - we prevent script injectio
nasko 2015/06/03 20:31:56 It isn't obvious to me that you are sending the UR
Devlin 2015/06/03 21:07:42 If (and only if) this is an extension page (i.e, a
Charlie Reis 2015/06/03 21:12:03 I don't have the full context here, but we do alre
Devlin 2015/06/03 21:23:51 Now I'm out of context. :) Looking at FrameReplic
Charlie Reis 2015/06/03 21:34:42 No, it exists on RenderFrameProxy as well, so you
157 new_host->GetRoutingID(), tab_extension->id()));
149 } 158 }
150 } 159 }
151 160
152 void ExtensionWebContentsObserver::NotifyRenderViewType( 161 void ExtensionWebContentsObserver::NotifyRenderViewType(
153 content::RenderViewHost* render_view_host) { 162 content::RenderViewHost* render_view_host) {
154 if (render_view_host) { 163 if (render_view_host) {
155 render_view_host->Send(new ExtensionMsg_NotifyRenderViewType( 164 render_view_host->Send(new ExtensionMsg_NotifyRenderViewType(
156 render_view_host->GetRoutingID(), GetViewType(web_contents()))); 165 render_view_host->GetRoutingID(), GetViewType(web_contents())));
157 } 166 }
158 } 167 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // site, so we can ignore that wrinkle here. 202 // site, so we can ignore that wrinkle here.
194 const GURL& site = render_view_host->GetSiteInstance()->GetSiteURL(); 203 const GURL& site = render_view_host->GetSiteInstance()->GetSiteURL();
195 204
196 if (!site.SchemeIs(kExtensionScheme)) 205 if (!site.SchemeIs(kExtensionScheme))
197 return std::string(); 206 return std::string();
198 207
199 return site.host(); 208 return site.host();
200 } 209 }
201 210
202 } // namespace extensions 211 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698