Chromium Code Reviews| 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/renderer_startup_helper.h" | 5 #include "extensions/browser/renderer_startup_helper.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 8 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 9 #include "content/public/browser/notification_service.h" | 9 #include "content/public/browser/notification_service.h" |
| 10 #include "content/public/browser/notification_types.h" | 10 #include "content/public/browser/notification_types.h" |
| 11 #include "content/public/browser/render_process_host.h" | 11 #include "content/public/browser/render_process_host.h" |
| 12 #include "extensions/browser/extension_function_dispatcher.h" | 12 #include "extensions/browser/extension_function_dispatcher.h" |
| 13 #include "extensions/browser/extension_registry.h" | 13 #include "extensions/browser/extension_registry.h" |
| 14 #include "extensions/browser/extensions_browser_client.h" | 14 #include "extensions/browser/extensions_browser_client.h" |
| 15 #include "extensions/browser/guest_view/web_view/web_view_guest.h" | 15 #include "extensions/browser/guest_view/web_view/web_view_guest.h" |
| 16 #include "extensions/common/extension_messages.h" | 16 #include "extensions/common/extension_messages.h" |
| 17 #include "extensions/common/extension_set.h" | 17 #include "extensions/common/extension_set.h" |
| 18 #include "extensions/common/extensions_client.h" | 18 #include "extensions/common/extensions_client.h" |
| 19 #include "extensions/common/features/feature_channel.h" | 19 #include "extensions/common/features/feature_channel.h" |
| 20 #include "extensions/common/features/feature_session_type.h" | 20 #include "extensions/common/features/feature_session_type.h" |
| 21 #include "extensions/common/permissions/permissions_data.h" | |
| 22 #include "ipc/ipc_message_attachment_set.h" | |
| 21 #include "ui/base/webui/web_ui_util.h" | 23 #include "ui/base/webui/web_ui_util.h" |
| 22 | 24 |
| 23 using content::BrowserContext; | 25 using content::BrowserContext; |
| 24 | 26 |
| 25 namespace extensions { | 27 namespace extensions { |
| 26 | 28 |
| 27 RendererStartupHelper::RendererStartupHelper(BrowserContext* browser_context) | 29 RendererStartupHelper::RendererStartupHelper(BrowserContext* browser_context) |
| 28 : browser_context_(browser_context) { | 30 : browser_context_(browser_context) { |
| 29 DCHECK(browser_context); | 31 DCHECK(browser_context); |
| 30 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, | 32 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 extensions::ExtensionsClient::Get()->GetScriptingWhitelist())); | 86 extensions::ExtensionsClient::Get()->GetScriptingWhitelist())); |
| 85 | 87 |
| 86 // If the new render process is a WebView guest process, propagate the WebView | 88 // If the new render process is a WebView guest process, propagate the WebView |
| 87 // partition ID to it. | 89 // partition ID to it. |
| 88 std::string webview_partition_id = WebViewGuest::GetPartitionID(process); | 90 std::string webview_partition_id = WebViewGuest::GetPartitionID(process); |
| 89 if (!webview_partition_id.empty()) { | 91 if (!webview_partition_id.empty()) { |
| 90 process->Send(new ExtensionMsg_SetWebViewPartitionID( | 92 process->Send(new ExtensionMsg_SetWebViewPartitionID( |
| 91 WebViewGuest::GetPartitionID(process))); | 93 WebViewGuest::GetPartitionID(process))); |
| 92 } | 94 } |
| 93 | 95 |
| 96 // Load default runtime_blocked_hosts and runtime_allowed_hosts settings, part | |
| 97 // of the ExtensionSettings policy. | |
| 98 ExtensionMsg_UpdateDefaultPolicyHostRestrictions_Params params; | |
| 99 params.default_runtime_blocked_hosts = | |
| 100 PermissionsData::default_runtime_blocked_hosts(); | |
| 101 params.default_runtime_allowed_hosts = | |
| 102 PermissionsData::default_runtime_allowed_hosts(); | |
| 103 process->Send(new ExtensionMsg_UpdateDefaultPolicyHostRestrictions(params)); | |
| 104 | |
| 94 // Loaded extensions. | 105 // Loaded extensions. |
| 95 std::vector<ExtensionMsg_Loaded_Params> loaded_extensions; | 106 std::vector<ExtensionMsg_Loaded_Params> loaded_extensions; |
| 96 const ExtensionSet& extensions = | 107 const ExtensionSet& extensions = |
| 97 ExtensionRegistry::Get(browser_context_)->enabled_extensions(); | 108 ExtensionRegistry::Get(browser_context_)->enabled_extensions(); |
| 98 for (const auto& ext : extensions) { | 109 for (const auto& ext : extensions) { |
| 99 // Renderers don't need to know about themes. | 110 // Renderers don't need to know about themes. |
| 100 if (!ext->is_theme()) { | 111 if (!ext->is_theme()) { |
| 101 // TODO(kalman): Only include tab specific permissions for extension | 112 // TODO(kalman): Only include tab specific permissions for extension |
| 102 // processes, no other process needs it, so it's mildly wasteful. | 113 // processes, no other process needs it, so it's mildly wasteful. |
| 103 // I am not sure this is possible to know this here, at such a low | 114 // I am not sure this is possible to know this here, at such a low |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 if (extension.is_theme()) | 161 if (extension.is_theme()) |
| 151 return; | 162 return; |
| 152 | 163 |
| 153 // We don't need to include tab permisisons here, since the extension | 164 // We don't need to include tab permisisons here, since the extension |
| 154 // was just loaded. | 165 // was just loaded. |
| 155 // Uninitialized renderers will be informed of the extension load during the | 166 // Uninitialized renderers will be informed of the extension load during the |
| 156 // first batch of messages. | 167 // first batch of messages. |
| 157 std::vector<ExtensionMsg_Loaded_Params> params( | 168 std::vector<ExtensionMsg_Loaded_Params> params( |
| 158 1, | 169 1, |
| 159 ExtensionMsg_Loaded_Params(&extension, false /* no tab permissions */)); | 170 ExtensionMsg_Loaded_Params(&extension, false /* no tab permissions */)); |
| 160 for (content::RenderProcessHost* process : initialized_processes_) | 171 for (content::RenderProcessHost* process : initialized_processes_) { |
| 161 process->Send(new ExtensionMsg_Loaded(params)); | 172 process->Send(new ExtensionMsg_Loaded(params)); |
| 173 } | |
|
Devlin
2017/01/26 22:47:40
why this extraneous change?
nrpeter
2017/02/03 19:32:24
Done.
| |
| 162 } | 174 } |
| 163 | 175 |
| 164 void RendererStartupHelper::OnExtensionUnloaded(const Extension& extension) { | 176 void RendererStartupHelper::OnExtensionUnloaded(const Extension& extension) { |
| 165 // Renderers don't need to know about themes. | 177 // Renderers don't need to know about themes. |
| 166 if (extension.is_theme()) | 178 if (extension.is_theme()) |
| 167 return; | 179 return; |
| 168 | 180 |
| 169 for (content::RenderProcessHost* process : initialized_processes_) | 181 for (content::RenderProcessHost* process : initialized_processes_) |
| 170 process->Send(new ExtensionMsg_Unloaded(extension.id())); | 182 process->Send(new ExtensionMsg_Unloaded(extension.id())); |
| 171 for (auto& process_extensions_pair : pending_active_extensions_) | 183 for (auto& process_extensions_pair : pending_active_extensions_) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 BrowserContext* context) const { | 216 BrowserContext* context) const { |
| 205 // Redirected in incognito. | 217 // Redirected in incognito. |
| 206 return ExtensionsBrowserClient::Get()->GetOriginalContext(context); | 218 return ExtensionsBrowserClient::Get()->GetOriginalContext(context); |
| 207 } | 219 } |
| 208 | 220 |
| 209 bool RendererStartupHelperFactory::ServiceIsCreatedWithBrowserContext() const { | 221 bool RendererStartupHelperFactory::ServiceIsCreatedWithBrowserContext() const { |
| 210 return true; | 222 return true; |
| 211 } | 223 } |
| 212 | 224 |
| 213 } // namespace extensions | 225 } // namespace extensions |
| OLD | NEW |