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_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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 // Some extensions use file:// URLs. | 83 // Some extensions use file:// URLs. |
84 if (type == Manifest::TYPE_EXTENSION || | 84 if (type == Manifest::TYPE_EXTENSION || |
85 type == Manifest::TYPE_LEGACY_PACKAGED_APP) { | 85 type == Manifest::TYPE_LEGACY_PACKAGED_APP) { |
86 ExtensionPrefs* prefs = ExtensionPrefs::Get(browser_context_); | 86 ExtensionPrefs* prefs = ExtensionPrefs::Get(browser_context_); |
87 if (prefs->AllowFileAccess(extension->id())) { | 87 if (prefs->AllowFileAccess(extension->id())) { |
88 content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme( | 88 content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme( |
89 process->GetID(), url::kFileScheme); | 89 process->GetID(), url::kFileScheme); |
90 } | 90 } |
91 } | 91 } |
92 | 92 |
93 switch (type) { | 93 // Tells the new view that it's hosted in an extension process. It would be |
94 case Manifest::TYPE_EXTENSION: | 94 // better to do this at process creation time (RendererStartupHelper), but |
95 case Manifest::TYPE_USER_SCRIPT: | 95 // the information that it's an *extension* process isn't plumbed in. |
96 case Manifest::TYPE_HOSTED_APP: | 96 // |
97 case Manifest::TYPE_LEGACY_PACKAGED_APP: | 97 // Note that because this code is run per *view* we may end up sending |
Devlin
2015/06/03 20:53:37
I think more important is that the Dispatcher is k
not at google - send to devlin
2015/06/03 21:53:03
The comment is about the fact that extension activ
| |
98 case Manifest::TYPE_PLATFORM_APP: | 98 // multiple redundant ExtensionMsg_ActivateExtension messages. For example, |
99 // Always send a Loaded message before ActivateExtension so that | 99 // opening a popup will load both the background page and the popup, 2 views. |
100 // ExtensionDispatcher knows what Extension is active, not just its ID. | 100 // |
101 // This is important for classifying the Extension's JavaScript context | 101 // All of the above said, the concept of activating an extension should be |
102 // correctly (see ExtensionDispatcher::ClassifyJavaScriptContext). | 102 // moot when site isolation is able to guarantee that no extension iframe can |
103 // We also have to include the tab-specific permissions here, since it's | 103 // live in an untrusted process. |
104 // an extension process. | 104 render_view_host->Send(new ExtensionMsg_ActivateExtension(extension->id())); |
105 render_view_host->Send( | |
106 new ExtensionMsg_Loaded(std::vector<ExtensionMsg_Loaded_Params>( | |
107 1, ExtensionMsg_Loaded_Params( | |
108 extension, true /* include tab permissions */)))); | |
109 render_view_host->Send( | |
110 new ExtensionMsg_ActivateExtension(extension->id())); | |
111 break; | |
112 | |
113 case Manifest::TYPE_UNKNOWN: | |
114 case Manifest::TYPE_THEME: | |
115 case Manifest::TYPE_SHARED_MODULE: | |
116 break; | |
117 | |
118 case Manifest::NUM_LOAD_TYPES: | |
119 NOTREACHED(); | |
120 } | |
121 } | 105 } |
122 | 106 |
123 void ExtensionWebContentsObserver::RenderFrameCreated( | 107 void ExtensionWebContentsObserver::RenderFrameCreated( |
124 content::RenderFrameHost* render_frame_host) { | 108 content::RenderFrameHost* render_frame_host) { |
125 const Extension* extension = GetExtensionForRenderFrame(render_frame_host); | 109 const Extension* extension = GetExtensionForRenderFrame(render_frame_host); |
126 if (extension) { | 110 if (extension) { |
127 ExtensionsBrowserClient::Get()->RegisterMojoServices(render_frame_host, | 111 ExtensionsBrowserClient::Get()->RegisterMojoServices(render_frame_host, |
128 extension); | 112 extension); |
129 } | 113 } |
130 } | 114 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 // site, so we can ignore that wrinkle here. | 177 // site, so we can ignore that wrinkle here. |
194 const GURL& site = render_view_host->GetSiteInstance()->GetSiteURL(); | 178 const GURL& site = render_view_host->GetSiteInstance()->GetSiteURL(); |
195 | 179 |
196 if (!site.SchemeIs(kExtensionScheme)) | 180 if (!site.SchemeIs(kExtensionScheme)) |
197 return std::string(); | 181 return std::string(); |
198 | 182 |
199 return site.host(); | 183 return site.host(); |
200 } | 184 } |
201 | 185 |
202 } // namespace extensions | 186 } // namespace extensions |
OLD | NEW |