OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_DEFAULT_APPS_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_DEFAULT_APPS_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <set> |
| 10 #include <string> |
| 11 #include "chrome/common/extensions/extension.h" |
| 12 #include "base/gtest_prod_util.h" |
| 13 |
| 14 class PrefService; |
| 15 |
| 16 // Manages the installation of the set of default apps into Chrome, and the |
| 17 // promotion of those apps in the launcher. |
| 18 // |
| 19 // It implements the following rules: |
| 20 // |
| 21 // - Only install default apps once per-profile. |
| 22 // - Don't install default apps if any apps are already installed. |
| 23 // - Do not start showing the promo until all default apps have been installed. |
| 24 // - Do not show the promo if it has been hidden by the user. |
| 25 // - Do not show promo after one app has been manually installed or uninstalled. |
| 26 // - Do not show promo if the set of installed apps is different than the set of |
| 27 // default apps. |
| 28 // - Only show promo a certain amount of times. |
| 29 // |
| 30 // The promo can also be forced on with --force-apps-promo-visible. |
| 31 class DefaultApps { |
| 32 public: |
| 33 // The maximum number of times to show the apps promo. |
| 34 static const int kAppsPromoCounterMax; |
| 35 |
| 36 // Register our preferences. |
| 37 static void RegisterUserPrefs(PrefService* prefs); |
| 38 |
| 39 explicit DefaultApps(PrefService* prefs); |
| 40 |
| 41 // Gets the list of default apps that should be installed. Can return NULL if |
| 42 // no apps need to be installed. |
| 43 const ExtensionIdSet* GetAppsToInstall() const; |
| 44 |
| 45 // Should be called after each app is installed. Once installed_ids contains |
| 46 // all the default apps, GetAppsToInstall() will start returning NULL. |
| 47 void DidInstallApp(const ExtensionIdSet& installed_ids); |
| 48 |
| 49 // Returns true if the apps promo should be displayed in the launcher. This |
| 50 // starts returning true once the default apps have all been installed and |
| 51 // stops after the promo expires. |
| 52 bool ShouldShowPromo(const ExtensionIdSet& installed_ids); |
| 53 |
| 54 // Should be called after each time the promo is installed. |
| 55 void DidShowPromo(); |
| 56 |
| 57 // Force the promo to be hidden. |
| 58 void SetPromoHidden(); |
| 59 |
| 60 private: |
| 61 FRIEND_TEST_ALL_PREFIXES(DefaultApps, Basics); |
| 62 FRIEND_TEST_ALL_PREFIXES(DefaultApps, HidePromo); |
| 63 FRIEND_TEST_ALL_PREFIXES(DefaultApps, InstallingAnAppHidesPromo); |
| 64 FRIEND_TEST_ALL_PREFIXES(DefaultApps, |
| 65 ManualAppInstalledWhileInstallingDefaultApps); |
| 66 |
| 67 bool GetDefaultAppsInstalled() const; |
| 68 void SetDefaultAppsInstalled(bool val); |
| 69 |
| 70 int GetPromoCounter() const; |
| 71 void SetPromoCounter(int val); |
| 72 |
| 73 // Our permanent state is stored in this PrefService instance. |
| 74 PrefService* prefs_; |
| 75 |
| 76 // The set of default extensions. Initialized to a static list in the |
| 77 // constructor. |
| 78 ExtensionIdSet ids_; |
| 79 |
| 80 DISALLOW_COPY_AND_ASSIGN(DefaultApps); |
| 81 }; |
| 82 |
| 83 #endif // CHROME_BROWSER_EXTENSIONS_DEFAULT_APPS_H_ |
OLD | NEW |