| 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..394bbaa8cd9d56de744df5f8c3411f633c28f4dd 100644
|
| --- a/chrome/browser/extensions/default_apps.cc
|
| +++ b/chrome/browser/extensions/default_apps.cc
|
| @@ -19,7 +19,7 @@
|
|
|
| namespace default_apps {
|
|
|
| -bool ShouldInstallInProfile(Profile* profile) {
|
| +bool Provider::ShouldInstallInProfile() {
|
| // We decide to install or not install default apps based on the following
|
| // criteria, from highest priority to lowest priority:
|
| //
|
| @@ -31,18 +31,20 @@ bool ShouldInstallInProfile(Profile* profile) {
|
| // - The kDefaultApps preferences value in the profile. This value is
|
| // usually set in the master_preferences file.
|
| bool install_apps =
|
| - profile->GetPrefs()->GetString(prefs::kDefaultApps) == "install";
|
| + 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;
|
| - if (!profile->WasCreatedByVersionOrLater(version_info.Version().c_str()))
|
| + if (!profile_->WasCreatedByVersionOrLater(version_info.Version().c_str()))
|
| install_apps = false;
|
| break;
|
| }
|
| @@ -52,14 +54,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:
|
| - profile->GetPrefs()->SetInteger(
|
| + 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 +84,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(
|
| + profile_->GetPrefs()->SetInteger(
|
| prefs::kDefaultAppsInstallState,
|
| - default_apps::kAlreadyInstalledDefaultApps);
|
| + kAlreadyInstalledDefaultApps);
|
| } else {
|
| - profile->GetPrefs()->SetInteger(prefs::kDefaultAppsInstallState,
|
| - default_apps::kNeverInstallDefaultApps);
|
| + profile_->GetPrefs()->SetInteger(prefs::kDefaultAppsInstallState,
|
| + kNeverInstallDefaultApps);
|
| }
|
| }
|
|
|
| @@ -109,13 +111,13 @@ Provider::Provider(Profile* profile,
|
| int creation_flags)
|
| : extensions::ExternalProviderImpl(service, loader, crx_location,
|
| download_location, creation_flags),
|
| - profile_(profile) {
|
| + profile_(profile), isMigration_(false) {
|
| DCHECK(profile);
|
| set_auto_acknowledge(true);
|
| }
|
|
|
| void Provider::VisitRegisteredExtension() {
|
| - if (!profile_ || !ShouldInstallInProfile(profile_)) {
|
| + if (!profile_ || !ShouldInstallInProfile()) {
|
| base::DictionaryValue* prefs = new base::DictionaryValue;
|
| SetPrefs(prefs);
|
| return;
|
| @@ -124,6 +126,33 @@ void Provider::VisitRegisteredExtension() {
|
| extensions::ExternalProviderImpl::VisitRegisteredExtension();
|
| }
|
|
|
| +void Provider::SetPrefs(base::DictionaryValue* prefs) {
|
| + if (isMigration_) {
|
| + std::set<std::string> new_default_apps;
|
| + for (base::DictionaryValue::key_iterator i = prefs->begin_keys();
|
| + i != prefs->end_keys(); ++i) {
|
| + if (!isOldDefaultApp(*i)) {
|
| + new_default_apps.insert(*i);
|
| + }
|
| + }
|
| + // Filter out the new default apps for migrating users.
|
| + for (std::set<std::string>::iterator it = new_default_apps.begin();
|
| + it != new_default_apps.end(); ++it) {
|
| + prefs->Remove(*it, 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.
|
|
|