diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-04 23:44:30 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-04 23:44:30 +0000 |
commit | 2fc0f12698750211cedb9d0ec5bdfbfcb5724fed (patch) | |
tree | 51317951515ce9f0d302b1a7fb5a4c572ee3669d /chrome/browser/extensions/default_apps.h | |
parent | 7ca0647b818151b7483779edc65e9399cfb4bdba (diff) | |
download | chromium_src-2fc0f12698750211cedb9d0ec5bdfbfcb5724fed.zip chromium_src-2fc0f12698750211cedb9d0ec5bdfbfcb5724fed.tar.gz chromium_src-2fc0f12698750211cedb9d0ec5bdfbfcb5724fed.tar.bz2 |
More cleanup of DefaultApps code. This should also fix some issues when apps are installed in webstore-non-supported locales.
BUG=67073
Review URL: http://codereview.chromium.org/6040005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70463 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/default_apps.h')
-rw-r--r-- | chrome/browser/extensions/default_apps.h | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/chrome/browser/extensions/default_apps.h b/chrome/browser/extensions/default_apps.h index b03f6ec..a8b162c 100644 --- a/chrome/browser/extensions/default_apps.h +++ b/chrome/browser/extensions/default_apps.h @@ -13,21 +13,10 @@ class PrefService; -// Manages the installation of the set of default apps into Chrome, and the -// promotion of those apps in the launcher. -// -// It implements the following rules: -// -// - Only install default apps once per-profile. -// - Don't install default apps if any apps are already installed. -// - Do not start showing the promo until all default apps have been installed. -// - Do not show the promo if it has been hidden by the user. -// - Do not show promo after one app has been manually installed or uninstalled. -// - Do not show promo if the set of installed apps is different than the set of -// default apps. -// - Only show promo a certain amount of times. -// -// The promo can also be forced on with --force-apps-promo-visible. +// Encapsulates business logic for: +// - Whether to install default apps on Chrome startup +// - Whether to show the app launcher +// - Whether to show the apps promo in the launcher class DefaultApps { public: // The maximum number of times to show the apps promo. @@ -36,28 +25,28 @@ class DefaultApps { // Register our preferences. static void RegisterUserPrefs(PrefService* prefs); - explicit DefaultApps(PrefService* prefs); + explicit DefaultApps(PrefService* prefs, + const std::string& application_locale); ~DefaultApps(); - // Gets the list of default apps that should be installed. Can return NULL if - // no apps need to be installed. - const ExtensionIdSet* GetAppsToInstall() const; + // Gets the set of default apps. + const ExtensionIdSet& default_apps() const; - // Gets the list of default apps. - const ExtensionIdSet* GetDefaultApps() const; + // Returns true if the default apps should be installed. + bool ShouldInstallDefaultApps(const ExtensionIdSet& installed_ids); - // Returns true if the default apps have been installed. False otherwise. - bool GetDefaultAppsInstalled() 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); + // Returns true if the app launcher in the NTP should be shown. + bool ShouldShowAppLauncher(const ExtensionIdSet& installed_ids); // Returns true if the apps promo should be displayed in the launcher. // // NOTE: If the default apps have been installed, but |installed_ids| is // different than GetDefaultApps(), this will permanently expire the promo. - bool CheckShouldShowPromo(const ExtensionIdSet& installed_ids); + bool ShouldShowPromo(const ExtensionIdSet& installed_ids); + + // 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); // Should be called after each time the promo is installed. void DidShowPromo(); @@ -66,12 +55,19 @@ class DefaultApps { void SetPromoHidden(); private: - FRIEND_TEST_ALL_PREFIXES(ExtensionDefaultApps, Basics); + FRIEND_TEST_ALL_PREFIXES(ExtensionDefaultApps, HappyPath); + FRIEND_TEST_ALL_PREFIXES(ExtensionDefaultApps, UnsupportedLocale); FRIEND_TEST_ALL_PREFIXES(ExtensionDefaultApps, HidePromo); FRIEND_TEST_ALL_PREFIXES(ExtensionDefaultApps, InstallingAnAppHidesPromo); FRIEND_TEST_ALL_PREFIXES(ExtensionDefaultApps, ManualAppInstalledWhileInstallingDefaultApps); + bool DefaultAppSupported(); + bool DefaultAppsSupportedForLanguage(); + + bool NonDefaultAppIsInstalled(const ExtensionIdSet& installed_ids) const; + + bool GetDefaultAppsInstalled() const; void SetDefaultAppsInstalled(bool val); int GetPromoCounter() const; @@ -80,6 +76,9 @@ class DefaultApps { // Our permanent state is stored in this PrefService instance. PrefService* prefs_; + // The locale the browser is currently in. + std::string application_locale_; + // The set of default extensions. Initialized to a static list in the // constructor. ExtensionIdSet ids_; |