OLD | NEW |
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/navigation_details.h" | 8 #include "content/public/browser/navigation_details.h" |
9 #include "content/public/browser/render_frame_host.h" | 9 #include "content/public/browser/render_frame_host.h" |
10 #include "content/public/browser/render_process_host.h" | 10 #include "content/public/browser/render_process_host.h" |
11 #include "content/public/browser/render_view_host.h" | 11 #include "content/public/browser/render_view_host.h" |
12 #include "content/public/browser/site_instance.h" | 12 #include "content/public/browser/site_instance.h" |
13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
14 #include "content/public/common/url_constants.h" | 14 #include "content/public/common/url_constants.h" |
15 #include "extensions/browser/extension_api_frame_id_map.h" | 15 #include "extensions/browser/extension_api_frame_id_map.h" |
16 #include "extensions/browser/extension_prefs.h" | 16 #include "extensions/browser/extension_prefs.h" |
17 #include "extensions/browser/extension_registry.h" | 17 #include "extensions/browser/extension_registry.h" |
18 #include "extensions/browser/extensions_browser_client.h" | 18 #include "extensions/browser/extensions_browser_client.h" |
19 #include "extensions/browser/mojo/service_registration.h" | 19 #include "extensions/browser/mojo/service_registration.h" |
20 #include "extensions/browser/process_manager.h" | 20 #include "extensions/browser/process_manager.h" |
21 #include "extensions/browser/renderer_startup_helper.h" | 21 #include "extensions/browser/renderer_startup_helper.h" |
22 #include "extensions/browser/view_type_utils.h" | 22 #include "extensions/browser/view_type_utils.h" |
23 #include "extensions/common/constants.h" | 23 #include "extensions/common/constants.h" |
24 #include "extensions/common/extension.h" | 24 #include "extensions/common/extension.h" |
25 #include "extensions/common/extension_messages.h" | 25 #include "extensions/common/extension_messages.h" |
26 #include "extensions/common/view_type.h" | 26 #include "extensions/common/view_type.h" |
| 27 #include "url/origin.h" |
27 | 28 |
28 namespace extensions { | 29 namespace extensions { |
29 | 30 |
30 // static | 31 // static |
31 ExtensionWebContentsObserver* ExtensionWebContentsObserver::GetForWebContents( | 32 ExtensionWebContentsObserver* ExtensionWebContentsObserver::GetForWebContents( |
32 content::WebContents* web_contents) { | 33 content::WebContents* web_contents) { |
33 return ExtensionsBrowserClient::Get()->GetExtensionWebContentsObserver( | 34 return ExtensionsBrowserClient::Get()->GetExtensionWebContentsObserver( |
34 web_contents); | 35 web_contents); |
35 } | 36 } |
36 | 37 |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 .GetByID(extension_id); | 239 .GetByID(extension_id); |
239 if (!extension) | 240 if (!extension) |
240 return nullptr; | 241 return nullptr; |
241 | 242 |
242 if (verify_url) { | 243 if (verify_url) { |
243 const url::Origin& origin(render_frame_host->GetLastCommittedOrigin()); | 244 const url::Origin& origin(render_frame_host->GetLastCommittedOrigin()); |
244 // Without site isolation, this check is needed to eliminate non-extension | 245 // Without site isolation, this check is needed to eliminate non-extension |
245 // schemes. With site isolation, this is still needed to exclude sandboxed | 246 // schemes. With site isolation, this is still needed to exclude sandboxed |
246 // extension frames with a unique origin. | 247 // extension frames with a unique origin. |
247 if (origin.unique() || | 248 if (origin.unique() || |
248 site_url != content::SiteInstance::GetSiteForURL( | 249 site_url != content::SiteInstance::GetSiteForURL(browser_context, |
249 browser_context, GURL(origin.Serialize()))) | 250 origin.GetURL())) |
250 return nullptr; | 251 return nullptr; |
251 } | 252 } |
252 | 253 |
253 return extension; | 254 return extension; |
254 } | 255 } |
255 | 256 |
256 const Extension* ExtensionWebContentsObserver::GetExtension( | 257 const Extension* ExtensionWebContentsObserver::GetExtension( |
257 content::RenderViewHost* render_view_host) { | 258 content::RenderViewHost* render_view_host) { |
258 std::string extension_id = GetExtensionId(render_view_host); | 259 std::string extension_id = GetExtensionId(render_view_host); |
259 if (extension_id.empty()) | 260 if (extension_id.empty()) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 // Since this is called for all existing RenderFrameHosts during the | 292 // Since this is called for all existing RenderFrameHosts during the |
292 // ExtensionWebContentsObserver's creation, it's possible that not all hosts | 293 // ExtensionWebContentsObserver's creation, it's possible that not all hosts |
293 // are ready. | 294 // are ready. |
294 // We only initialize the frame if the renderer counterpart is live; otherwise | 295 // We only initialize the frame if the renderer counterpart is live; otherwise |
295 // we wait for the RenderFrameCreated notification. | 296 // we wait for the RenderFrameCreated notification. |
296 if (render_frame_host->IsRenderFrameLive()) | 297 if (render_frame_host->IsRenderFrameLive()) |
297 InitializeRenderFrame(render_frame_host); | 298 InitializeRenderFrame(render_frame_host); |
298 } | 299 } |
299 | 300 |
300 } // namespace extensions | 301 } // namespace extensions |
OLD | NEW |