| 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 // Encapsulates business logic for: | |
| 17 // - Whether to install default apps on Chrome startup | |
| 18 // - Whether to show the app launcher | |
| 19 // - Whether to show the apps promo in the launcher | |
| 20 class DefaultApps { | |
| 21 public: | |
| 22 // The maximum number of times to show the apps promo. The promo counter | |
| 23 // actually goes up to this number + 1 because we need to differentiate | |
| 24 // between the first time we overflow and subsequent times. | |
| 25 static const int kAppsPromoCounterMax; | |
| 26 | |
| 27 // Register our preferences. | |
| 28 static void RegisterUserPrefs(PrefService* prefs); | |
| 29 | |
| 30 explicit DefaultApps(PrefService* prefs, | |
| 31 const std::string& application_locale); | |
| 32 ~DefaultApps(); | |
| 33 | |
| 34 // Gets the set of default apps. | |
| 35 const ExtensionIdSet& default_apps() const; | |
| 36 | |
| 37 // Returns true if the default apps should be installed. | |
| 38 bool ShouldInstallDefaultApps(const ExtensionIdSet& installed_ids); | |
| 39 | |
| 40 // Returns true if the app launcher in the NTP should be shown. | |
| 41 bool ShouldShowAppLauncher(const ExtensionIdSet& installed_ids); | |
| 42 | |
| 43 // Returns true if the apps promo should be displayed in the launcher. | |
| 44 // | |
| 45 // NOTE: If the default apps have been installed, but |installed_ids| is | |
| 46 // different than GetDefaultApps(), this will permanently expire the promo. | |
| 47 bool ShouldShowPromo(const ExtensionIdSet& installed_ids, bool* just_expired); | |
| 48 | |
| 49 // Should be called after each app is installed. Once installed_ids contains | |
| 50 // all the default apps, GetAppsToInstall() will start returning NULL. | |
| 51 void DidInstallApp(const ExtensionIdSet& installed_ids); | |
| 52 | |
| 53 // Force the promo to be hidden. | |
| 54 void SetPromoHidden(); | |
| 55 | |
| 56 private: | |
| 57 FRIEND_TEST_ALL_PREFIXES(ExtensionDefaultApps, HappyPath); | |
| 58 FRIEND_TEST_ALL_PREFIXES(ExtensionDefaultApps, UnsupportedLocale); | |
| 59 FRIEND_TEST_ALL_PREFIXES(ExtensionDefaultApps, HidePromo); | |
| 60 FRIEND_TEST_ALL_PREFIXES(ExtensionDefaultApps, InstallingAnAppHidesPromo); | |
| 61 FRIEND_TEST_ALL_PREFIXES(ExtensionDefaultApps, | |
| 62 ManualAppInstalledWhileInstallingDefaultApps); | |
| 63 | |
| 64 bool DefaultAppSupported(); | |
| 65 bool DefaultAppsSupportedForLanguage(); | |
| 66 | |
| 67 bool NonDefaultAppIsInstalled(const ExtensionIdSet& installed_ids) const; | |
| 68 | |
| 69 bool GetDefaultAppsInstalled() const; | |
| 70 void SetDefaultAppsInstalled(bool val); | |
| 71 | |
| 72 int GetPromoCounter() const; | |
| 73 void SetPromoCounter(int val); | |
| 74 | |
| 75 // Our permanent state is stored in this PrefService instance. | |
| 76 PrefService* prefs_; | |
| 77 | |
| 78 // The locale the browser is currently in. | |
| 79 std::string application_locale_; | |
| 80 | |
| 81 // The set of default extensions. Initialized to a static list in the | |
| 82 // constructor. | |
| 83 ExtensionIdSet ids_; | |
| 84 | |
| 85 DISALLOW_COPY_AND_ASSIGN(DefaultApps); | |
| 86 }; | |
| 87 | |
| 88 #endif // CHROME_BROWSER_EXTENSIONS_DEFAULT_APPS_H_ | |
| OLD | NEW |