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

Unified Diff: extensions/browser/renderer_startup_helper.cc

Issue 1142993002: Don't send unnecessary ExtensionMsg_Loaded IPCs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: a test Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/renderer_startup_helper.cc
diff --git a/extensions/browser/renderer_startup_helper.cc b/extensions/browser/renderer_startup_helper.cc
index 111c5e27ce4ba942187630ee3bfaf05ce805a6be..99c7b91de1cd641dc683a84ba674631b1b494dd2 100644
--- a/extensions/browser/renderer_startup_helper.cc
+++ b/extensions/browser/renderer_startup_helper.cc
@@ -34,49 +34,45 @@ void RendererStartupHelper::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
- switch (type) {
- case content::NOTIFICATION_RENDERER_PROCESS_CREATED: {
- content::RenderProcessHost* process =
- content::Source<content::RenderProcessHost>(source).ptr();
- if (!ExtensionsBrowserClient::Get()->IsSameContext(
- browser_context_, process->GetBrowserContext()))
- break;
-
- // Platform apps need to know the system font.
- // TODO(dbeam): this is not the system font in all cases.
- process->Send(new ExtensionMsg_SetSystemFont(webui::GetFontFamily(),
- webui::GetFontSize()));
-
- // Valid extension function names, used to setup bindings in renderer.
- std::vector<std::string> function_names;
- ExtensionFunctionDispatcher::GetAllFunctionNames(&function_names);
- process->Send(new ExtensionMsg_SetFunctionNames(function_names));
-
- // Scripting whitelist. This is modified by tests and must be communicated
- // to renderers.
- process->Send(new ExtensionMsg_SetScriptingWhitelist(
- extensions::ExtensionsClient::Get()->GetScriptingWhitelist()));
-
- // Loaded extensions.
- std::vector<ExtensionMsg_Loaded_Params> loaded_extensions;
- const ExtensionSet& extensions =
- ExtensionRegistry::Get(browser_context_)->enabled_extensions();
- for (ExtensionSet::const_iterator iter = extensions.begin();
- iter != extensions.end(); ++iter) {
- // Renderers don't need to know about themes.
- if (!(*iter)->is_theme()) {
- // Don't need to include tab permissions for new tabs.
- loaded_extensions.push_back(ExtensionMsg_Loaded_Params(
- iter->get(), false /* no tab permissions */));
- }
- }
- process->Send(new ExtensionMsg_Loaded(loaded_extensions));
- break;
+ DCHECK_EQ(content::NOTIFICATION_RENDERER_PROCESS_CREATED, type);
+ content::RenderProcessHost* process =
+ content::Source<content::RenderProcessHost>(source).ptr();
+ if (!ExtensionsBrowserClient::Get()->IsSameContext(
+ browser_context_, process->GetBrowserContext()))
+ return;
+
+ // Platform apps need to know the system font.
+ // TODO(dbeam): this is not the system font in all cases.
+ process->Send(new ExtensionMsg_SetSystemFont(webui::GetFontFamily(),
+ webui::GetFontSize()));
+
+ // Valid extension function names, used to setup bindings in renderer.
+ std::vector<std::string> function_names;
+ ExtensionFunctionDispatcher::GetAllFunctionNames(&function_names);
+ process->Send(new ExtensionMsg_SetFunctionNames(function_names));
+
+ // Scripting whitelist. This is modified by tests and must be communicated
+ // to renderers.
+ process->Send(new ExtensionMsg_SetScriptingWhitelist(
+ extensions::ExtensionsClient::Get()->GetScriptingWhitelist()));
+
+ // Loaded extensions.
+ std::vector<ExtensionMsg_Loaded_Params> loaded_extensions;
+ const ExtensionSet& extensions =
+ ExtensionRegistry::Get(browser_context_)->enabled_extensions();
+ for (const auto& ext : extensions) {
+ // Renderers don't need to know about themes.
+ if (!ext->is_theme()) {
+ // TODO(kalman): Only include tab specific permissions for extension
+ // processes, no other process needs it, so it's mildly wasteful.
+ // I am not sure this is possible to know this here, at such a low
+ // level of the stack. Perhaps site isolation can help.
+ bool include_tab_permissions = true;
+ loaded_extensions.push_back(
+ ExtensionMsg_Loaded_Params(ext.get(), include_tab_permissions));
}
- default:
- NOTREACHED();
- break;
}
+ process->Send(new ExtensionMsg_Loaded(loaded_extensions));
}
//////////////////////////////////////////////////////////////////////////////

Powered by Google App Engine
This is Rietveld 408576698