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

Unified Diff: chrome/browser/extensions/component_loader.cc

Issue 11275069: Perform install tasks for newly installed or upgraded component apps/extensions. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase and move v2 component app added in r169911 (and r170087) into background section in componen… Created 8 years, 1 month 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: chrome/browser/extensions/component_loader.cc
diff --git a/chrome/browser/extensions/component_loader.cc b/chrome/browser/extensions/component_loader.cc
index 79ab12697796cc8b11554d7e1db8a76e746291cc..282d618f8cb62c5f1b1c03f735309684c829aa58 100644
--- a/chrome/browser/extensions/component_loader.cc
+++ b/chrome/browser/extensions/component_loader.cc
@@ -44,6 +44,8 @@ namespace extensions {
namespace {
+static bool enable_background_extensions_during_testing = false;
+
std::string GenerateId(const DictionaryValue* manifest, const FilePath& path) {
std::string raw_key;
std::string id_input;
@@ -197,7 +199,7 @@ const Extension* ComponentLoader::Load(const ComponentExtensionInfo& info) {
return NULL;
}
CHECK_EQ(info.extension_id, extension->id()) << extension->name();
- extension_service_->AddExtension(extension);
+ extension_service_->AddComponentExtension(extension);
return extension;
}
@@ -319,38 +321,25 @@ void ComponentLoader::AddScriptBubble() {
}
}
+// static
+void ComponentLoader::EnableBackgroundExtensionsForTesting() {
+ enable_background_extensions_during_testing = true;
+}
+
void ComponentLoader::AddDefaultComponentExtensions() {
+ // Do not add component extensions that have background pages here -- add them
+ // to AddDefaultComponentExtensionsWithBackgroundPages.
+
#if defined(OS_CHROMEOS)
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession))
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (!command_line->HasSwitch(switches::kGuestSession))
Add(IDR_BOOKMARKS_MANIFEST,
FilePath(FILE_PATH_LITERAL("bookmark_manager")));
#else
Add(IDR_BOOKMARKS_MANIFEST, FilePath(FILE_PATH_LITERAL("bookmark_manager")));
#endif
-// Apps Debugger
-if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kAppsDebugger)) {
- Add(IDR_APPS_DEBUGGER_MANIFEST,
- FilePath(FILE_PATH_LITERAL("apps_debugger")));
-}
-
-#if defined(OS_CHROMEOS)
- Add(IDR_WALLPAPERMANAGER_MANIFEST,
- FilePath(FILE_PATH_LITERAL("chromeos/wallpaper_manager")));
-#endif
-
-#if defined(FILE_MANAGER_EXTENSION)
- AddFileManagerExtension();
-#endif
-
#if defined(OS_CHROMEOS)
- const CommandLine* command_line = CommandLine::ForCurrentProcess();
- if (command_line->HasSwitch(switches::kEnableBackgroundLoader)) {
- Add(IDR_BACKLOADER_MANIFEST,
- FilePath(FILE_PATH_LITERAL("backloader")));
- }
-
Add(IDR_MOBILE_MANIFEST,
FilePath(FILE_PATH_LITERAL("/usr/share/chromeos-assets/mobile")));
@@ -378,23 +367,11 @@ if (CommandLine::ForCurrentProcess()->HasSwitch(
Add(IDR_WEBSTORE_MANIFEST, FilePath(FILE_PATH_LITERAL("web_store")));
-#if defined(ENABLE_SETTINGS_APP)
- Add(IDR_SETTINGS_APP_MANIFEST, FilePath(FILE_PATH_LITERAL("settings_app")));
-#endif
-
#if !defined(OS_CHROMEOS)
// Cloud Print component app. Not required on Chrome OS.
Add(IDR_CLOUDPRINT_MANIFEST, FilePath(FILE_PATH_LITERAL("cloud_print")));
#endif
-#if defined(OS_CHROMEOS)
- // Load ChromeVox extension now if spoken feedback is enabled.
- if (local_state_->GetBoolean(prefs::kSpokenFeedbackEnabled)) {
- FilePath path = FilePath(extension_misc::kChromeVoxExtensionPath);
- Add(IDR_CHROMEVOX_MANIFEST, path);
- }
-#endif
-
// If a URL for the enterprise webstore has been specified, load the
// component extension. This extension might also be loaded later, because
// it is specified by policy, and on ChromeOS policies are loaded after
@@ -406,6 +383,47 @@ if (CommandLine::ForCurrentProcess()->HasSwitch(
#endif
AddScriptBubble();
+ AddDefaultComponentExtensionsWithBackgroundPages();
+}
+
+void ComponentLoader::AddDefaultComponentExtensionsWithBackgroundPages() {
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
+
+ // Component extensions with background pages are not enabled during tests
+ // because they generate a lot of background behavior that can interfere.
+ if (!enable_background_extensions_during_testing &&
+ command_line->HasSwitch(switches::kTestType)) {
+ return;
+ }
+
+ // Apps Debugger
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kAppsDebugger)) {
+ Add(IDR_APPS_DEBUGGER_MANIFEST,
+ FilePath(FILE_PATH_LITERAL("apps_debugger")));
+ }
+
+ AddFileManagerExtension();
+
+#if defined(OS_CHROMEOS)
+ Add(IDR_WALLPAPERMANAGER_MANIFEST,
+ FilePath(FILE_PATH_LITERAL("chromeos/wallpaper_manager")));
+
+ if (command_line->HasSwitch(switches::kEnableBackgroundLoader)) {
+ Add(IDR_BACKLOADER_MANIFEST,
+ FilePath(FILE_PATH_LITERAL("backloader")));
+ }
+
+ // Load ChromeVox extension now if spoken feedback is enabled.
+ if (local_state_->GetBoolean(prefs::kSpokenFeedbackEnabled)) {
+ FilePath path = FilePath(extension_misc::kChromeVoxExtensionPath);
+ Add(IDR_CHROMEVOX_MANIFEST, path);
+ }
+#endif
+
+#if defined(ENABLE_SETTINGS_APP)
+ Add(IDR_SETTINGS_APP_MANIFEST, FilePath(FILE_PATH_LITERAL("settings_app")));
+#endif
}
// static
« no previous file with comments | « chrome/browser/extensions/component_loader.h ('k') | chrome/browser/extensions/component_loader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698