 Chromium Code Reviews
 Chromium Code Reviews Issue 11275069:
  Perform install tasks for newly installed or upgraded component apps/extensions.  (Closed) 
  Base URL: http://git.chromium.org/chromium/src.git@master
    
  
    Issue 11275069:
  Perform install tasks for newly installed or upgraded component apps/extensions.  (Closed) 
  Base URL: http://git.chromium.org/chromium/src.git@master| Index: chrome/browser/extensions/component_loader.cc | 
| diff --git a/chrome/browser/extensions/component_loader.cc b/chrome/browser/extensions/component_loader.cc | 
| index c0bbcf7d93510416570048d2fbdf2739eb6a76a8..692da5a01feb5ed4d755193e18544335c98c892d 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_extenstions_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,9 +321,18 @@ void ComponentLoader::AddScriptBubble() { | 
| } | 
| } | 
| +// static | 
| +void ComponentLoader::EnableBackgroundExtensionsForTesting() { | 
| + enable_background_extenstions_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 | 
| @@ -329,21 +340,6 @@ void ComponentLoader::AddDefaultComponentExtensions() { | 
| #endif | 
| #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"))); | 
| @@ -371,24 +367,11 @@ void ComponentLoader::AddDefaultComponentExtensions() { | 
| 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) | 
| - // Register access extensions only if accessibility is enabled. | 
| - if (local_state_->GetBoolean(prefs::kSpokenFeedbackEnabled)) { | 
| - FilePath path = FilePath(extension_misc::kAccessExtensionPath) | 
| - .AppendASCII(extension_misc::kChromeVoxDirectoryName); | 
| - 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 | 
| @@ -400,6 +383,41 @@ void ComponentLoader::AddDefaultComponentExtensions() { | 
| #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_extenstions_during_testing && | 
| 
Yoyo Zhou
2012/11/27 23:54:18
typo: extensions
 
tapted
2012/11/28 06:21:14
Drat. Done.
 | 
| + command_line->HasSwitch(switches::kTestType)) { | 
| + return; | 
| + } | 
| + | 
| + 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"))); | 
| + } | 
| + | 
| + // Register access extensions only if accessibility is enabled. | 
| + if (local_state_->GetBoolean(prefs::kSpokenFeedbackEnabled)) { | 
| + FilePath path = FilePath(extension_misc::kAccessExtensionPath) | 
| + .AppendASCII(extension_misc::kChromeVoxDirectoryName); | 
| + Add(IDR_CHROMEVOX_MANIFEST, path); | 
| + } | 
| +#endif | 
| + | 
| +#if defined(ENABLE_SETTINGS_APP) | 
| + Add(IDR_SETTINGS_APP_MANIFEST, FilePath(FILE_PATH_LITERAL("settings_app"))); | 
| +#endif | 
| } | 
| // static |