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

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

Issue 10875065: Disable install of new default_apps for existing users (Closed) Base URL: http://git.chromium.org/git/chromium.git@disable_sync_behav
Patch Set: Moved the migration logic into the default_apps Provider Created 8 years, 4 months 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/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.

Powered by Google App Engine
This is Rietveld 408576698