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

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

Issue 6040005: More cleanup of DefaultApps code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove unnecessary change, add comments Created 9 years, 12 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.h
diff --git a/chrome/browser/extensions/default_apps.h b/chrome/browser/extensions/default_apps.h
index b03f6ec16147bf44f0449f6407619ab197d08ac2..a8b162c0021cc370f1388079338baeb8921c391f 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_;

Powered by Google App Engine
This is Rietveld 408576698