| Index: chrome/browser/extensions/default_apps.cc
|
| diff --git a/chrome/browser/extensions/default_apps.cc b/chrome/browser/extensions/default_apps.cc
|
| index a9e305f4bdf176060d1fe33a718c180ec5f895a0..4afe3259ff409f36a4e1dfbf41c3af33bbf4cd4f 100644
|
| --- a/chrome/browser/extensions/default_apps.cc
|
| +++ b/chrome/browser/extensions/default_apps.cc
|
| @@ -18,55 +18,90 @@ void DefaultApps::RegisterUserPrefs(PrefService* prefs) {
|
| prefs->RegisterIntegerPref(prefs::kAppsPromoCounter, 0);
|
| }
|
|
|
| -DefaultApps::DefaultApps(PrefService* prefs)
|
| - : prefs_(prefs) {
|
| -#if !defined(OS_CHROMEOS)
|
| +DefaultApps::DefaultApps(PrefService* prefs,
|
| + const std::string& application_locale)
|
| + : prefs_(prefs), application_locale_(application_locale) {
|
| // Poppit, Entanglement
|
| ids_.insert("mcbkbpnkkkipelfledbfocopglifcfmi");
|
| ids_.insert("aciahcmjmecflokailenpkdchphgkefd");
|
| -#endif // OS_CHROMEOS
|
| }
|
|
|
| DefaultApps::~DefaultApps() {}
|
|
|
| -const ExtensionIdSet* DefaultApps::GetAppsToInstall() const {
|
| - if (GetDefaultAppsInstalled())
|
| - return NULL;
|
| - else
|
| - return &ids_;
|
| +const ExtensionIdSet& DefaultApps::default_apps() const {
|
| + return ids_;
|
| }
|
|
|
| -const ExtensionIdSet* DefaultApps::GetDefaultApps() const {
|
| - return &ids_;
|
| +bool DefaultApps::DefaultAppSupported() {
|
| + // On Chrome OS the default apps are installed via a different mechanism.
|
| +#if defined(OS_CHROMEOS)
|
| + return false;
|
| +#else
|
| + return DefaultAppsSupportedForLanguage();
|
| +#endif
|
| }
|
|
|
| -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
|
| - // been manually installed while the the default apps were installing and we
|
| - // wouldn't want to keep trying to install them in that case.
|
| - if (!GetDefaultAppsInstalled() &&
|
| - std::includes(installed_ids.begin(), installed_ids.end(),
|
| - ids_.begin(), ids_.end())) {
|
| +bool DefaultApps::DefaultAppsSupportedForLanguage() {
|
| + return application_locale_ == "en-US";
|
| +}
|
| +
|
| +bool DefaultApps::ShouldInstallDefaultApps(
|
| + const ExtensionIdSet& installed_ids) {
|
| + if (!DefaultAppSupported())
|
| + return false;
|
| +
|
| + if (GetDefaultAppsInstalled())
|
| + return false;
|
| +
|
| + // If there are any non-default apps installed, we should never try to install
|
| + // the default apps again, even if the non-default apps are later removed.
|
| + if (NonDefaultAppIsInstalled(installed_ids)) {
|
| SetDefaultAppsInstalled(true);
|
| + return false;
|
| }
|
| +
|
| + return true;
|
| }
|
|
|
| -bool DefaultApps::CheckShouldShowPromo(const ExtensionIdSet& installed_ids) {
|
| -#if defined(OS_CHROMEOS)
|
| - // Don't show the promo at all on Chrome OS.
|
| - return false;
|
| +bool DefaultApps::ShouldShowAppLauncher(const ExtensionIdSet& installed_ids) {
|
| + // On Chrome OS the default apps are installed via a separate mechanism that
|
| + // is always enabled. Therefore we always show the launcher.
|
| +#if defined(OS_CHROME)
|
| + return true;
|
| +#else
|
| + // The app store only supports en-us at the moment, so we don't show the apps
|
| + // section by default for users in other locales. But we do show it if a user
|
| + // from a non-supported locale somehow installs an app (eg by navigating
|
| + // directly to the store).
|
| + if (!DefaultAppsSupportedForLanguage())
|
| + return !installed_ids.empty();
|
| +
|
| + // For supported locales, we need to wait for all the default apps to be
|
| + // installed before showing the apps section. We also show it if any
|
| + // non-default app is installed (eg because the user installed the app in a
|
| + // previous version of Chrome).
|
| + if (GetDefaultAppsInstalled() || NonDefaultAppIsInstalled(installed_ids))
|
| + return true;
|
| + else
|
| + return false;
|
| #endif
|
| +}
|
| +
|
| +bool DefaultApps::ShouldShowPromo(const ExtensionIdSet& installed_ids) {
|
| if (CommandLine::ForCurrentProcess()->HasSwitch(
|
| switches::kForceAppsPromoVisible)) {
|
| return true;
|
| }
|
|
|
| + if (!DefaultAppSupported())
|
| + return false;
|
| +
|
| if (GetDefaultAppsInstalled() && GetPromoCounter() < kAppsPromoCounterMax) {
|
| // If we have the exact set of default apps, show the promo. If we don't
|
| // have the exact set of default apps, this means that the user manually
|
| - // installed one. The promo doesn't make sense if it shows apps the user
|
| - // manually installed, so expire it immediately in that situation.
|
| + // installed or uninstalled one. The promo doesn't make sense if it shows
|
| + // apps the user manually installed, so expire it immediately in that
|
| + // situation.
|
| if (installed_ids == ids_)
|
| return true;
|
| else
|
| @@ -76,6 +111,18 @@ bool DefaultApps::CheckShouldShowPromo(const ExtensionIdSet& installed_ids) {
|
| return false;
|
| }
|
|
|
| +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
|
| + // been manually installed while the the default apps were installing and we
|
| + // wouldn't want to keep trying to install them in that case.
|
| + if (!GetDefaultAppsInstalled() &&
|
| + std::includes(installed_ids.begin(), installed_ids.end(),
|
| + ids_.begin(), ids_.end())) {
|
| + SetDefaultAppsInstalled(true);
|
| + }
|
| +}
|
| +
|
| void DefaultApps::DidShowPromo() {
|
| if (!GetDefaultAppsInstalled()) {
|
| NOTREACHED() << "Should not show promo until default apps are installed.";
|
| @@ -99,6 +146,17 @@ void DefaultApps::DidShowPromo() {
|
| }
|
| }
|
|
|
| +bool DefaultApps::NonDefaultAppIsInstalled(
|
| + const ExtensionIdSet& installed_ids) const {
|
| + for (ExtensionIdSet::const_iterator iter = installed_ids.begin();
|
| + iter != installed_ids.end(); ++iter) {
|
| + if (ids_.find(*iter) == ids_.end())
|
| + return true;
|
| + }
|
| +
|
| + return false;
|
| +}
|
| +
|
| void DefaultApps::SetPromoHidden() {
|
| SetPromoCounter(kAppsPromoCounterMax);
|
| }
|
|
|