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

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 to Provider class 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..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.

Powered by Google App Engine
This is Rietveld 408576698