 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/extension_service.cc | 
| diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc | 
| index 9de535a134bc5bc16011536550786967e3ad52be..6aa9271b8e745531102ceda318197a9e1efcf0fa 100644 | 
| --- a/chrome/browser/extensions/extension_service.cc | 
| +++ b/chrome/browser/extensions/extension_service.cc | 
| @@ -2100,6 +2100,25 @@ void ExtensionService::AddExtension(const Extension* extension) { | 
| DoPostLoadTasks(extension); | 
| } | 
| +void ExtensionService::AddComponentExtension(const Extension* extension) { | 
| + const Version old_version( | 
| + extension_prefs_->GetVersionString(extension->id())); | 
| + | 
| + if (!old_version.IsValid() || !old_version.Equals(*extension->version())) { | 
| + VLOG(1) << "Component extension " << extension->name() << " (" | 
| + << extension->id() << ") installing/upgrading from " | 
| + << (old_version.IsValid() ? old_version.GetString() : "<none>") | 
| 
Yoyo Zhou
2012/11/27 23:54:18
GetVersionString gives you a string; you might as
 
tapted
2012/11/28 06:21:14
Done. (I think that's what you had in mind).
 | 
| + << " to " << extension->version()->GetString(); | 
| + | 
| + AddNewOrUpdatedExtension(extension, | 
| + syncer::StringOrdinal(), | 
| + Extension::ENABLED_COMPONENT); | 
| + return; | 
| + } | 
| + | 
| + AddExtension(extension); | 
| +} | 
| + | 
| void ExtensionService::InitializePermissions(const Extension* extension) { | 
| // If the extension has used the optional permissions API, it will have a | 
| // custom set of active permissions defined in the extension prefs. Here, | 
| @@ -2375,16 +2394,29 @@ void ExtensionService::OnExtensionInstalled( | 
| return; | 
| } | 
| + // Transfer ownership of |extension|. | 
| + AddNewOrUpdatedExtension( | 
| + scoped_extension, | 
| + page_ordinal, | 
| + initial_enable ? Extension::ENABLED : Extension::DISABLED); | 
| +} | 
| + | 
| +void ExtensionService::AddNewOrUpdatedExtension( | 
| + const Extension* extension, | 
| + const syncer::StringOrdinal& page_ordinal, | 
| + Extension::State initial_state) { | 
| + CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 
| + | 
| extension_prefs_->OnExtensionInstalled( | 
| extension, | 
| - initial_enable ? Extension::ENABLED : Extension::DISABLED, | 
| + initial_state, | 
| page_ordinal); | 
| // Unpacked extensions default to allowing file access, but if that has been | 
| // overridden, don't reset the value. | 
| if (Extension::ShouldAlwaysAllowFileAccess(extension->location()) && | 
| - !extension_prefs_->HasAllowFileAccessSetting(id)) { | 
| - extension_prefs_->SetAllowFileAccess(id, true); | 
| + !extension_prefs_->HasAllowFileAccessSetting(extension->id())) { | 
| + extension_prefs_->SetAllowFileAccess(extension->id(), true); | 
| } | 
| content::NotificationService::current()->Notify( | 
| @@ -2395,7 +2427,7 @@ void ExtensionService::OnExtensionInstalled( | 
| bool unacknowledged_external = IsUnacknowledgedExternalExtension(extension); | 
| // Transfer ownership of |extension| to AddExtension. | 
| - AddExtension(scoped_extension); | 
| + AddExtension(extension); | 
| // If this is a new external extension that was disabled, alert the user | 
| // so he can reenable it. We do this last so that it has already been |