OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_EXTENSIONS_APPS_PROMO_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_APPS_PROMO_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_APPS_PROMO_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_APPS_PROMO_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | |
10 #include <string> | 9 #include <string> |
11 | 10 |
12 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
13 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
14 #include "net/url_request/url_fetcher_delegate.h" | |
15 | 13 |
16 class PrefService; | 14 class PrefService; |
17 class Profile; | 15 class Profile; |
18 | 16 |
19 namespace net { | |
20 class URLFetcher; | |
21 } // namespace net | |
22 | |
23 // This encapsulates business logic for: | 17 // This encapsulates business logic for: |
24 // - Whether to show the apps promo in the launcher | 18 // - Whether to show the apps promo in the launcher |
25 // - Whether to expire existing default apps | 19 // - Whether to expire existing default apps |
26 class AppsPromo { | 20 class AppsPromo { |
27 public: | 21 public: |
28 // Groups users by whether they have seen a web store promo before. This is | 22 // Groups users by whether they have seen a web store promo before. This is |
29 // used for deciding to maximize the promo and apps section on the NTP. | 23 // used for deciding to maximize the promo and apps section on the NTP. |
30 enum UserGroup { | 24 enum UserGroup { |
31 // Matches no users. | 25 // Matches no users. |
32 USERS_NONE = 0, | 26 USERS_NONE = 0, |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 // Our permanent state is stored in this PrefService instance. | 132 // Our permanent state is stored in this PrefService instance. |
139 PrefService* prefs_; | 133 PrefService* prefs_; |
140 | 134 |
141 // The set of default extensions. Initialized to a static list in the | 135 // The set of default extensions. Initialized to a static list in the |
142 // constructor. | 136 // constructor. |
143 extensions::ExtensionIdSet old_default_app_ids_; | 137 extensions::ExtensionIdSet old_default_app_ids_; |
144 | 138 |
145 DISALLOW_COPY_AND_ASSIGN(AppsPromo); | 139 DISALLOW_COPY_AND_ASSIGN(AppsPromo); |
146 }; | 140 }; |
147 | 141 |
148 // Fetches logos over HTTPS, making sure we don't send cookies and that we | |
149 // cache the image until its source URL changes. | |
150 class AppsPromoLogoFetcher : public net::URLFetcherDelegate { | |
151 public: | |
152 AppsPromoLogoFetcher(Profile* profile, | |
153 const AppsPromo::PromoData& promo_data); | |
154 virtual ~AppsPromoLogoFetcher(); | |
155 | |
156 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | |
157 | |
158 private: | |
159 // Fetches the logo and stores the result as a data URL. | |
160 void FetchLogo(); | |
161 | |
162 // Checks if the logo was downloaded previously. | |
163 bool HaveCachedLogo(); | |
164 | |
165 // Sets the apps promo based on the current data and then issues the | |
166 // WEB_STORE_PROMO_LOADED notification so open NTPs can inject the promo. | |
167 void SavePromo(); | |
168 | |
169 // Checks if the promo logo matches https://*.google.com/*.png. | |
170 bool SupportsLogoURL(); | |
171 | |
172 Profile* profile_; | |
173 AppsPromo::PromoData promo_data_; | |
174 scoped_ptr<net::URLFetcher> url_fetcher_; | |
175 }; | |
176 | |
177 #endif // CHROME_BROWSER_EXTENSIONS_APPS_PROMO_H_ | 142 #endif // CHROME_BROWSER_EXTENSIONS_APPS_PROMO_H_ |
OLD | NEW |