OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ |
6 #define CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ | 6 #define CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "chrome/browser/web_resource/web_resource_service.h" | 11 #include "chrome/browser/web_resource/web_resource_service.h" |
12 #include "chrome/common/chrome_version_info.h" | 12 #include "chrome/common/chrome_version_info.h" |
13 | 13 |
| 14 class AppsPromoLogoDownloader; |
| 15 class PrefService; |
14 class Profile; | 16 class Profile; |
15 | 17 |
16 namespace PromoResourceServiceUtil { | 18 namespace PromoResourceServiceUtil { |
17 | 19 |
18 // Certain promotions should only be shown to certain classes of users. This | 20 // Certain promotions should only be shown to certain classes of users. This |
19 // function will change to reflect each kind of promotion. | 21 // function will change to reflect each kind of promotion. |
20 bool CanShowPromo(Profile* profile); | 22 bool CanShowPromo(Profile* profile); |
21 | 23 |
22 } // namespace PromoResourceServiceUtil | 24 } // namespace PromoResourceServiceUtil |
23 | 25 |
24 class PrefService; | |
25 | |
26 // A PromoResourceService fetches data from a web resource server to be used to | 26 // A PromoResourceService fetches data from a web resource server to be used to |
27 // dynamically change the appearance of the New Tab Page. For example, it has | 27 // dynamically change the appearance of the New Tab Page. For example, it has |
28 // been used to fetch "tips" to be displayed on the NTP, or to display | 28 // been used to fetch "tips" to be displayed on the NTP, or to display |
29 // promotional messages to certain groups of Chrome users. | 29 // promotional messages to certain groups of Chrome users. |
30 // | 30 // |
31 // TODO(mirandac): Arrange for a server to be set up specifically for promo | 31 // TODO(mirandac): Arrange for a server to be set up specifically for promo |
32 // messages, which have until now been piggybacked onto the old tips server | 32 // messages, which have until now been piggybacked onto the old tips server |
33 // structure. (see http://crbug.com/70634 for details.) | 33 // structure. (see http://crbug.com/70634 for details.) |
34 class PromoResourceService | 34 class PromoResourceService |
35 : public WebResourceService { | 35 : public WebResourceService { |
36 public: | 36 public: |
37 static bool IsBuildTargeted(chrome::VersionInfo::Channel channel, | 37 static bool IsBuildTargeted(chrome::VersionInfo::Channel channel, |
38 int builds_targeted); | 38 int builds_targeted); |
39 | 39 |
40 static void RegisterPrefs(PrefService* local_state); | 40 static void RegisterPrefs(PrefService* local_state); |
41 | 41 |
42 static void RegisterUserPrefs(PrefService* prefs); | 42 static void RegisterUserPrefs(PrefService* prefs); |
43 | 43 |
44 explicit PromoResourceService(Profile* profile); | 44 explicit PromoResourceService(Profile* profile); |
45 | 45 |
46 // Default server of dynamically loaded NTP HTML elements. | 46 // Default server of dynamically loaded NTP HTML elements. |
47 static const char* kDefaultPromoResourceServer; | 47 static const char* kDefaultPromoResourceServer; |
48 | 48 |
49 private: | 49 private: |
50 FRIEND_TEST_ALL_PREFIXES(PromoResourceServiceTest, UnpackLogoSignal); | 50 FRIEND_TEST_ALL_PREFIXES(PromoResourceServiceTest, UnpackLogoSignal); |
51 FRIEND_TEST_ALL_PREFIXES(PromoResourceServiceTest, UnpackPromoSignal); | 51 FRIEND_TEST_ALL_PREFIXES(PromoResourceServiceTest, UnpackPromoSignal); |
52 FRIEND_TEST_ALL_PREFIXES(PromoResourceServiceTest, UnpackWebStoreSignal); | 52 FRIEND_TEST_ALL_PREFIXES(PromoResourceServiceTest, UnpackWebStoreSignal); |
53 FRIEND_TEST_ALL_PREFIXES( | 53 FRIEND_TEST_ALL_PREFIXES( |
54 PromoResourceServiceTest, UnpackPartialWebStoreSignal); | 54 PromoResourceServiceTest, UnpackPartialWebStoreSignal); |
| 55 FRIEND_TEST_ALL_PREFIXES( |
| 56 PromoResourceServiceTest, UnpackWebStoreSignalHttpsLogo); |
| 57 FRIEND_TEST_ALL_PREFIXES( |
| 58 PromoResourceServiceTest, UnpackWebStoreSignalHttpsLogoError); |
| 59 FRIEND_TEST_ALL_PREFIXES( |
| 60 PromoResourceServiceTest, UnpackWebStoreSignalHttpLogo); |
| 61 |
55 | 62 |
56 // Identifies types of Chrome builds for promo targeting. | 63 // Identifies types of Chrome builds for promo targeting. |
57 enum BuildType { | 64 enum BuildType { |
58 NO_BUILD = 0, | 65 NO_BUILD = 0, |
59 DEV_BUILD = 1, | 66 DEV_BUILD = 1, |
60 BETA_BUILD = 1 << 1, | 67 BETA_BUILD = 1 << 1, |
61 STABLE_BUILD = 1 << 2, | 68 STABLE_BUILD = 1 << 2, |
62 CANARY_BUILD = 1 << 3, | 69 CANARY_BUILD = 1 << 3, |
63 }; | 70 }; |
64 | 71 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 // The profile this service belongs to. | 202 // The profile this service belongs to. |
196 Profile* profile_; | 203 Profile* profile_; |
197 | 204 |
198 // Gets mutable dictionary attached to user's preferences, so that we | 205 // Gets mutable dictionary attached to user's preferences, so that we |
199 // can write resource data back to user's pref file. | 206 // can write resource data back to user's pref file. |
200 base::DictionaryValue* web_resource_cache_; | 207 base::DictionaryValue* web_resource_cache_; |
201 | 208 |
202 // Overrides the current Chrome release channel for testing purposes. | 209 // Overrides the current Chrome release channel for testing purposes. |
203 chrome::VersionInfo::Channel channel_; | 210 chrome::VersionInfo::Channel channel_; |
204 | 211 |
| 212 // A helper that downloads the promo logo. |
| 213 scoped_ptr<AppsPromoLogoDownloader> apps_promo_logo_downloader_; |
| 214 |
205 DISALLOW_COPY_AND_ASSIGN(PromoResourceService); | 215 DISALLOW_COPY_AND_ASSIGN(PromoResourceService); |
206 }; | 216 }; |
207 | 217 |
208 #endif // CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ | 218 #endif // CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ |
OLD | NEW |