Chromium Code Reviews| Index: chrome/browser/extensions/default_apps.cc |
| diff --git a/chrome/browser/extensions/default_apps.cc b/chrome/browser/extensions/default_apps.cc |
| index 31762906b121cdb5b6cc70d9f204879bd31ced62..bcdb176d5c33914b7b0d5446e6f660cc9ee84eaf 100644 |
| --- a/chrome/browser/extensions/default_apps.cc |
| +++ b/chrome/browser/extensions/default_apps.cc |
| @@ -19,6 +19,8 @@ |
| namespace default_apps { |
| +bool isMigration; |
|
Mihai Parparita -not on Chrome
2012/08/27 23:36:21
It's a bit better now that this global is not expo
|
| + |
| bool ShouldInstallInProfile(Profile* profile) { |
| // We decide to install or not install default apps based on the following |
| // criteria, from highest priority to lowest priority: |
| @@ -33,12 +35,14 @@ bool ShouldInstallInProfile(Profile* profile) { |
| bool install_apps = |
| profile->GetPrefs()->GetString(prefs::kDefaultApps) == "install"; |
| - default_apps::InstallState state = |
| - static_cast<default_apps::InstallState>(profile->GetPrefs()->GetInteger( |
| + InstallState state = |
| + static_cast<InstallState>(profile->GetPrefs()->GetInteger( |
| prefs::kDefaultAppsInstallState)); |
| + isMigration = (state == kProvideLegacyDefaultApps); |
| + |
| switch (state) { |
| - case default_apps::kUnknown: { |
| + case kUnknown: { |
| // This is the first time the default apps feature runs on this profile. |
| // Determine if we want to install them or not. |
| chrome::VersionInfo version_info; |
| @@ -52,14 +56,14 @@ bool ShouldInstallInProfile(Profile* profile) { |
| // apps affected all users. Migrate old default apps to new mechanism where |
| // they are installed only once as INTERNAL. |
| // TODO(grv) : remove after Q1-2013. |
| - case default_apps::kProvideLegacyDefaultApps: |
| + case kProvideLegacyDefaultApps: |
| profile->GetPrefs()->SetInteger( |
| prefs::kDefaultAppsInstallState, |
| - default_apps::kAlreadyInstalledDefaultApps); |
| + kAlreadyInstalledDefaultApps); |
| break; |
| - case default_apps::kAlreadyInstalledDefaultApps: |
| - case default_apps::kNeverInstallDefaultApps: |
| + case kAlreadyInstalledDefaultApps: |
| + case kNeverInstallDefaultApps: |
| install_apps = false; |
| break; |
| default: |
| @@ -82,14 +86,14 @@ bool ShouldInstallInProfile(Profile* profile) { |
| // Default apps are only installed on profile creation or a new chrome |
| // download. |
| - if (state == default_apps::kUnknown) { |
| + if (state == kUnknown) { |
| if (install_apps) { |
| profile->GetPrefs()->SetInteger( |
| prefs::kDefaultAppsInstallState, |
| - default_apps::kAlreadyInstalledDefaultApps); |
| + kAlreadyInstalledDefaultApps); |
| } else { |
| profile->GetPrefs()->SetInteger(prefs::kDefaultAppsInstallState, |
| - default_apps::kNeverInstallDefaultApps); |
| + kNeverInstallDefaultApps); |
| } |
| } |
| @@ -124,6 +128,28 @@ void Provider::VisitRegisteredExtension() { |
| extensions::ExternalProviderImpl::VisitRegisteredExtension(); |
| } |
| +void Provider::SetPrefs(base::DictionaryValue* prefs) { |
| + if (isMigration) { |
| + // Filter out the new default apps for migrating users. |
| + for (base::DictionaryValue::key_iterator i = prefs->begin_keys(); |
| + i != prefs->end_keys(); ++i) { |
| + if (!isOldDefaultApp(*i)) { |
| + prefs->Remove(*i, NULL); |
| + } |
| + } |
| + } |
| + |
| + ExternalProviderImpl::SetPrefs(prefs); |
| +} |
| + |
| +bool isOldDefaultApp(const std::string& extension_id) { |
| + const std::string gmail_id = "pjkljhegncpnkpknbcohdijeoejaedia"; |
| + const std::string search_id = "coobgpohoikkiipiblmjeljniedjpjpf"; |
| + const std::string youtube_id = "blpcfgokakmgnkcojhhkbfbldkacnbeo"; |
| + return extension_id == gmail_id || extension_id == search_id |
| + || extension_id == youtube_id; |
| +} |
| + |
| bool isLocaleSupported() { |
| // Don't bother installing default apps in locales where it is known that |
| // they don't work. |