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> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "chrome/common/extensions/extension.h" | 13 #include "chrome/common/extensions/extension.h" |
14 #include "net/url_request/url_fetcher_delegate.h" | 14 #include "net/url_request/url_fetcher_delegate.h" |
Mihai Parparita -not on Chrome
2012/07/29 18:17:16
You can also remove this include.
| |
15 | 15 |
16 class PrefService; | 16 class PrefService; |
17 class Profile; | 17 class Profile; |
18 | 18 |
19 namespace net { | 19 namespace net { |
20 class URLFetcher; | 20 class URLFetcher; |
Mihai Parparita -not on Chrome
2012/07/29 18:17:16
And this forward declaration.
| |
21 } // namespace net | 21 } // namespace net |
22 | 22 |
23 // This encapsulates business logic for: | 23 // This encapsulates business logic for: |
24 // - Whether to show the apps promo in the launcher | 24 // - Whether to show the apps promo in the launcher |
25 // - Whether to expire existing default apps | 25 // - Whether to expire existing default apps |
26 class AppsPromo { | 26 class AppsPromo { |
27 public: | 27 public: |
28 // Groups users by whether they have seen a web store promo before. This is | 28 // 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. | 29 // used for deciding to maximize the promo and apps section on the NTP. |
30 enum UserGroup { | 30 enum UserGroup { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 // Our permanent state is stored in this PrefService instance. | 138 // Our permanent state is stored in this PrefService instance. |
139 PrefService* prefs_; | 139 PrefService* prefs_; |
140 | 140 |
141 // The set of default extensions. Initialized to a static list in the | 141 // The set of default extensions. Initialized to a static list in the |
142 // constructor. | 142 // constructor. |
143 extensions::ExtensionIdSet old_default_app_ids_; | 143 extensions::ExtensionIdSet old_default_app_ids_; |
144 | 144 |
145 DISALLOW_COPY_AND_ASSIGN(AppsPromo); | 145 DISALLOW_COPY_AND_ASSIGN(AppsPromo); |
146 }; | 146 }; |
147 | 147 |
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_ | 148 #endif // CHROME_BROWSER_EXTENSIONS_APPS_PROMO_H_ |
OLD | NEW |