summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorjstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-20 18:17:19 +0000
committerjstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-20 18:17:19 +0000
commitfb27cc9687bed6ef6f8dedacf30385c2d076d6e9 (patch)
treefcbe11ba37f3d8f43dc03ac6fc3a41d70816ad76 /chrome/browser
parent325f68943ee5ae3b937651fde9f37ba6ab68a598 (diff)
downloadchromium_src-fb27cc9687bed6ef6f8dedacf30385c2d076d6e9.zip
chromium_src-fb27cc9687bed6ef6f8dedacf30385c2d076d6e9.tar.gz
chromium_src-fb27cc9687bed6ef6f8dedacf30385c2d076d6e9.tar.bz2
Uninstall default apps if user hides promo
We now uninstall the default apps if the user hides the NTP app promo. This only happens if the user hasn't already installed other apps. BUG=59453 TEST=DefaultApps. Also, clicking the 'Hide this' message on the app promo should uninstall the default apps. Review URL: http://codereview.chromium.org/3903002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63242 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/dom_ui/app_launcher_handler.cc13
-rw-r--r--chrome/browser/extensions/default_apps.cc4
-rw-r--r--chrome/browser/extensions/default_apps.h3
-rw-r--r--chrome/browser/extensions/default_apps_unittest.cc1
4 files changed, 21 insertions, 0 deletions
diff --git a/chrome/browser/dom_ui/app_launcher_handler.cc b/chrome/browser/dom_ui/app_launcher_handler.cc
index 2da2ef6..89f2863 100644
--- a/chrome/browser/dom_ui/app_launcher_handler.cc
+++ b/chrome/browser/dom_ui/app_launcher_handler.cc
@@ -268,6 +268,19 @@ void AppLauncherHandler::HandleUninstallApp(const ListValue* args) {
}
void AppLauncherHandler::HandleHideAppsPromo(const ListValue* args) {
+ // If the user has intentionally hidden the promotion, we'll uninstall all the
+ // default apps (we know the user hasn't installed any apps on their own at
+ // this point, or the promotion wouldn't have been shown).
+ DefaultApps* default_apps = extensions_service_->default_apps();
+ const ExtensionIdSet* app_ids = default_apps->GetDefaultApps();
+ DCHECK(*app_ids == extensions_service_->GetAppIds());
+
+ for (ExtensionIdSet::const_iterator iter = app_ids->begin();
+ iter != app_ids->end(); ++iter) {
+ if (extensions_service_->GetExtensionById(*iter, true))
+ extensions_service_->UninstallExtension(*iter, false);
+ }
+
extensions_service_->default_apps()->SetPromoHidden();
}
diff --git a/chrome/browser/extensions/default_apps.cc b/chrome/browser/extensions/default_apps.cc
index 7dd85aa..ad39a34a 100644
--- a/chrome/browser/extensions/default_apps.cc
+++ b/chrome/browser/extensions/default_apps.cc
@@ -34,6 +34,10 @@ const ExtensionIdSet* DefaultApps::GetAppsToInstall() const {
return &ids_;
}
+const ExtensionIdSet* DefaultApps::GetDefaultApps() const {
+ return &ids_;
+}
+
void DefaultApps::DidInstallApp(const ExtensionIdSet& installed_ids) {
// If all the default apps have been installed, stop trying to install them.
// Note that we use std::includes here instead of == because apps might have
diff --git a/chrome/browser/extensions/default_apps.h b/chrome/browser/extensions/default_apps.h
index 1f572df..767b2f3 100644
--- a/chrome/browser/extensions/default_apps.h
+++ b/chrome/browser/extensions/default_apps.h
@@ -43,6 +43,9 @@ class DefaultApps {
// no apps need to be installed.
const ExtensionIdSet* GetAppsToInstall() const;
+ // Gets the list of default apps.
+ const ExtensionIdSet* GetDefaultApps() const;
+
// Should be called after each app is installed. Once installed_ids contains
// all the default apps, GetAppsToInstall() will start returning NULL.
void DidInstallApp(const ExtensionIdSet& installed_ids);
diff --git a/chrome/browser/extensions/default_apps_unittest.cc b/chrome/browser/extensions/default_apps_unittest.cc
index 9e7b0d5..8037236 100644
--- a/chrome/browser/extensions/default_apps_unittest.cc
+++ b/chrome/browser/extensions/default_apps_unittest.cc
@@ -16,6 +16,7 @@ TEST(DefaultApps, Basics) {
ASSERT_GT(default_app_ids.size(), 0u);
EXPECT_FALSE(default_apps.GetDefaultAppsInstalled());
EXPECT_EQ(0, default_apps.GetPromoCounter());
+ EXPECT_EQ(default_app_ids, *default_apps.GetDefaultApps());
// The promo should not be shown until the default apps have been installed.
ExtensionIdSet installed_app_ids;