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/render_process_host.h" | 8 #include "content/public/browser/render_process_host.h" |
9 #include "content/public/browser/render_view_host.h" | 9 #include "content/public/browser/render_view_host.h" |
10 #include "content/public/browser/site_instance.h" | 10 #include "content/public/browser/site_instance.h" |
11 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
12 #include "content/public/common/url_constants.h" | 12 #include "content/public/common/url_constants.h" |
13 #include "extensions/browser/extension_prefs.h" | 13 #include "extensions/browser/extension_prefs.h" |
14 #include "extensions/browser/extension_registry.h" | 14 #include "extensions/browser/extension_registry.h" |
| 15 #include "extensions/browser/mojo/service_registration_manager.h" |
15 #include "extensions/browser/view_type_utils.h" | 16 #include "extensions/browser/view_type_utils.h" |
16 #include "extensions/common/constants.h" | 17 #include "extensions/common/constants.h" |
17 #include "extensions/common/extension_messages.h" | 18 #include "extensions/common/extension_messages.h" |
18 | 19 |
19 namespace extensions { | 20 namespace extensions { |
20 | 21 |
21 ExtensionWebContentsObserver::ExtensionWebContentsObserver( | 22 ExtensionWebContentsObserver::ExtensionWebContentsObserver( |
22 content::WebContents* web_contents) | 23 content::WebContents* web_contents) |
23 : content::WebContentsObserver(web_contents), | 24 : content::WebContentsObserver(web_contents), |
24 browser_context_(web_contents->GetBrowserContext()) { | 25 browser_context_(web_contents->GetBrowserContext()) { |
25 NotifyRenderViewType(web_contents->GetRenderViewHost()); | 26 NotifyRenderViewType(web_contents->GetRenderViewHost()); |
26 } | 27 } |
27 | 28 |
28 ExtensionWebContentsObserver::~ExtensionWebContentsObserver() {} | 29 ExtensionWebContentsObserver::~ExtensionWebContentsObserver() {} |
29 | 30 |
30 void ExtensionWebContentsObserver::RenderViewCreated( | 31 void ExtensionWebContentsObserver::RenderViewCreated( |
31 content::RenderViewHost* render_view_host) { | 32 content::RenderViewHost* render_view_host) { |
32 NotifyRenderViewType(render_view_host); | 33 NotifyRenderViewType(render_view_host); |
33 | 34 |
| 35 // TODO(sammc): Call AddServicesToRenderFrame() for frames that aren't main |
| 36 // frames. |
| 37 ServiceRegistrationManager::GetSharedInstance()->AddServicesToRenderFrame( |
| 38 render_view_host->GetMainFrame()); |
| 39 |
34 const Extension* extension = GetExtension(render_view_host); | 40 const Extension* extension = GetExtension(render_view_host); |
35 if (!extension) | 41 if (!extension) |
36 return; | 42 return; |
37 | 43 |
38 content::RenderProcessHost* process = render_view_host->GetProcess(); | 44 content::RenderProcessHost* process = render_view_host->GetProcess(); |
39 | 45 |
40 // Some extensions use chrome:// URLs. | 46 // Some extensions use chrome:// URLs. |
41 // This is a temporary solution. Replace it with access to chrome-static:// | 47 // This is a temporary solution. Replace it with access to chrome-static:// |
42 // once it is implemented. See: crbug.com/226927. | 48 // once it is implemented. See: crbug.com/226927. |
43 Manifest::Type type = extension->GetType(); | 49 Manifest::Type type = extension->GetType(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // site, so we can ignore that wrinkle here. | 120 // site, so we can ignore that wrinkle here. |
115 const GURL& site = render_view_host->GetSiteInstance()->GetSiteURL(); | 121 const GURL& site = render_view_host->GetSiteInstance()->GetSiteURL(); |
116 | 122 |
117 if (!site.SchemeIs(kExtensionScheme)) | 123 if (!site.SchemeIs(kExtensionScheme)) |
118 return std::string(); | 124 return std::string(); |
119 | 125 |
120 return site.host(); | 126 return site.host(); |
121 } | 127 } |
122 | 128 |
123 } // namespace extensions | 129 } // namespace extensions |
OLD | NEW |