Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: chrome/browser/web_resource/promo_resource_service.h

Issue 8363035: NTP4/Sync Promo: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged, fixed, unit tests and quick smoke test passing Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
(...skipping 26 matching lines...) Expand all
37 DEV_BUILD = 1, 37 DEV_BUILD = 1,
38 BETA_BUILD = 1 << 1, 38 BETA_BUILD = 1 << 1,
39 STABLE_BUILD = 1 << 2, 39 STABLE_BUILD = 1 << 2,
40 CANARY_BUILD = 1 << 3, 40 CANARY_BUILD = 1 << 3,
41 ALL_BUILDS = (1 << 4) - 1, 41 ALL_BUILDS = (1 << 4) - 1,
42 }; 42 };
43 43
44 // Checks for conditions to show promo: start/end times, channel, etc. 44 // Checks for conditions to show promo: start/end times, channel, etc.
45 static bool CanShowNotificationPromo(Profile* profile); 45 static bool CanShowNotificationPromo(Profile* profile);
46 46
47 // Checks if this user is in a group for sync promo roll-out. 47 // Checks if this user is in a group for sign-in promo roll-out.
48 static bool CanShowSyncPromo(Profile* profile); 48 static bool CanShowNTPSignInPromo(Profile* profile);
49 49
50 static void RegisterPrefs(PrefService* local_state); 50 static void RegisterPrefs(PrefService* local_state);
51 51
52 static void RegisterUserPrefs(PrefService* prefs); 52 static void RegisterUserPrefs(PrefService* prefs);
53 53
54 explicit PromoResourceService(Profile* profile); 54 explicit PromoResourceService(Profile* profile);
55 55
56 static chrome::VersionInfo::Channel GetChannel(); 56 static chrome::VersionInfo::Channel GetChannel();
57 static bool IsBuildTargeted(chrome::VersionInfo::Channel, int builds_allowed); 57 static bool IsBuildTargeted(chrome::VersionInfo::Channel, int builds_allowed);
58 58
59 // Default server of dynamically loaded NTP HTML elements. 59 // Default server of dynamically loaded NTP HTML elements.
60 static const char* kDefaultPromoResourceServer; 60 static const char* kDefaultPromoResourceServer;
61 61
62 private: 62 private:
63 friend class SyncPromoTest; 63 friend class NTPSignInPromoTest;
64 FRIEND_TEST_ALL_PREFIXES(PromoResourceServiceTest, IsBuildTargetedTest); 64 FRIEND_TEST_ALL_PREFIXES(PromoResourceServiceTest, IsBuildTargetedTest);
65 FRIEND_TEST_ALL_PREFIXES(PromoResourceServiceTest, UnpackLogoSignal); 65 FRIEND_TEST_ALL_PREFIXES(PromoResourceServiceTest, UnpackLogoSignal);
66 FRIEND_TEST_ALL_PREFIXES(PromoResourceServiceTest, UnpackWebStoreSignal); 66 FRIEND_TEST_ALL_PREFIXES(PromoResourceServiceTest, UnpackWebStoreSignal);
67 FRIEND_TEST_ALL_PREFIXES( 67 FRIEND_TEST_ALL_PREFIXES(
68 PromoResourceServiceTest, UnpackPartialWebStoreSignal); 68 PromoResourceServiceTest, UnpackPartialWebStoreSignal);
69 FRIEND_TEST_ALL_PREFIXES( 69 FRIEND_TEST_ALL_PREFIXES(
70 PromoResourceServiceTest, UnpackWebStoreSignalHttpsLogo); 70 PromoResourceServiceTest, UnpackWebStoreSignalHttpsLogo);
71 FRIEND_TEST_ALL_PREFIXES( 71 FRIEND_TEST_ALL_PREFIXES(
72 PromoResourceServiceTest, UnpackWebStoreSignalHttpsLogoError); 72 PromoResourceServiceTest, UnpackWebStoreSignalHttpsLogoError);
73 FRIEND_TEST_ALL_PREFIXES( 73 FRIEND_TEST_ALL_PREFIXES(
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 // name: starts with "webstore_promo" to identify the signal. The second 202 // name: starts with "webstore_promo" to identify the signal. The second
203 // part contains the release channels targeted (bitwise or of 203 // part contains the release channels targeted (bitwise or of
204 // BuildTypes). The third part specifies what users should maximize 204 // BuildTypes). The third part specifies what users should maximize
205 // the apps section of the NTP when first loading the promo (bitwise 205 // the apps section of the NTP when first loading the promo (bitwise
206 // or of AppsPromo::UserGroup). The forth part is optional and 206 // or of AppsPromo::UserGroup). The forth part is optional and
207 // specifies the URL of the logo image. If left out, the default 207 // specifies the URL of the logo image. If left out, the default
208 // webstore logo will be used. The logo can be an HTTPS or DATA URL. 208 // webstore logo will be used. The logo can be an HTTPS or DATA URL.
209 // answer_id: the promo's id 209 // answer_id: the promo's id
210 void UnpackWebStoreSignal(const base::DictionaryValue& parsed_json); 210 void UnpackWebStoreSignal(const base::DictionaryValue& parsed_json);
211 211
212 // Unpack the sync promo. Expects JSON delivery in the following format: 212 // Unpack the NTP sign in promo. Expects JSON in the following format:
213 // { 213 // {
214 // "topic": { 214 // "topic": {
215 // "answers": [ 215 // "answers": [
216 // ... 216 // ...
217 // { 217 // {
218 // "answer_id": "XXXXXXX", 218 // "answer_id": "XXXXXXX",
219 // "name": "sync_promo", 219 // "name": "sign_in_promo",
220 // "question": "1:5" 220 // "question": "1:5"
221 // } 221 // }
222 // ] 222 // ]
223 // } 223 // }
224 // } 224 // }
225 //
226 // The question is in the form of "<build>:<group_max>". 225 // The question is in the form of "<build>:<group_max>".
227 void UnpackSyncPromoSignal(const base::DictionaryValue& parsed_json); 226 void UnpackNTPSignInPromoSignal(const base::DictionaryValue& parsed_json);
228 227
229 // NotificationPromo::Delegate override. 228 // NotificationPromo::Delegate override.
230 virtual void OnNewNotification(double start, double end) OVERRIDE; 229 virtual void OnNewNotification(double start, double end) OVERRIDE;
231 230
232 // The profile this service belongs to. 231 // The profile this service belongs to.
233 Profile* profile_; 232 Profile* profile_;
234 233
235 // Overrides the current Chrome release channel for testing purposes. 234 // Overrides the current Chrome release channel for testing purposes.
236 chrome::VersionInfo::Channel channel_; 235 chrome::VersionInfo::Channel channel_;
237 236
238 // A helper that downloads the promo logo. 237 // A helper that downloads the promo logo.
239 scoped_ptr<AppsPromoLogoFetcher> apps_promo_logo_fetcher_; 238 scoped_ptr<AppsPromoLogoFetcher> apps_promo_logo_fetcher_;
240 239
241 DISALLOW_COPY_AND_ASSIGN(PromoResourceService); 240 DISALLOW_COPY_AND_ASSIGN(PromoResourceService);
242 }; 241 };
243 242
244 #endif // CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ 243 #endif // CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698