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

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

Issue 10496008: Purge legacy notification promo code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 months 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) 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_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 "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/web_resource/notification_promo.h" 12 #include "chrome/browser/web_resource/notification_promo.h"
13 #include "chrome/browser/web_resource/web_resource_service.h" 13 #include "chrome/browser/web_resource/web_resource_service.h"
14 #include "chrome/common/chrome_version_info.h" 14 #include "chrome/common/chrome_version_info.h"
15 15
16 namespace base { 16 namespace base {
17 class DictionaryValue; 17 class DictionaryValue;
18 } 18 }
19 19
20 class AppsPromoLogoFetcher; 20 class AppsPromoLogoFetcher;
21 class PrefService; 21 class PrefService;
22 class Profile; 22 class Profile;
23 // A PromoResourceService fetches data from a web resource server to be used to 23 // A PromoResourceService fetches data from a web resource server to be used to
24 // dynamically change the appearance of the New Tab Page. For example, it has 24 // dynamically change the appearance of the New Tab Page. For example, it has
25 // been used to fetch "tips" to be displayed on the NTP, or to display 25 // been used to fetch "tips" to be displayed on the NTP, or to display
26 // promotional messages to certain groups of Chrome users. 26 // promotional messages to certain groups of Chrome users.
27 // 27 //
28 // TODO(mirandac): Arrange for a server to be set up specifically for promo 28 // TODO(mirandac): Arrange for a server to be set up specifically for promo
Dan Beam 2012/06/04 18:20:08 this is TODONE()
achuithb 2012/06/04 19:52:59 Done.
29 // messages, which have until now been piggybacked onto the old tips server 29 // messages, which have until now been piggybacked onto the old tips server
30 // structure. (see http://crbug.com/70634 for details.) 30 // structure. (see http://crbug.com/70634 for details.)
31 class PromoResourceService 31 class PromoResourceService : public WebResourceService {
32 : public WebResourceService,
33 public NotificationPromo::Delegate {
34 public: 32 public:
35 // Identifies types of Chrome builds for promo targeting. 33 // Identifies types of Chrome builds for promo targeting.
36 enum BuildType { 34 enum BuildType {
37 NO_BUILD = 0, 35 NO_BUILD = 0,
38 DEV_BUILD = 1, 36 DEV_BUILD = 1,
39 BETA_BUILD = 1 << 1, 37 BETA_BUILD = 1 << 1,
40 STABLE_BUILD = 1 << 2, 38 STABLE_BUILD = 1 << 2,
41 CANARY_BUILD = 1 << 3, 39 CANARY_BUILD = 1 << 3,
42 ALL_BUILDS = (1 << 4) - 1, 40 ALL_BUILDS = (1 << 4) - 1,
43 }; 41 };
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 107
110 // Unpack the web resource as a custom notification signal. Expects a start 108 // Unpack the web resource as a custom notification signal. Expects a start
111 // and end signal, with the promo to be shown in the tooltip of the start 109 // and end signal, with the promo to be shown in the tooltip of the start
112 // signal field. Delivery will be in json in the form of: 110 // signal field. Delivery will be in json in the form of:
113 // { 111 // {
114 // "topic": { 112 // "topic": {
115 // "answers": [ 113 // "answers": [
116 // { 114 // {
117 // "answer_id": "1067976", 115 // "answer_id": "1067976",
118 // "name": "promo_start", 116 // "name": "promo_start",
119 // "question": "1:24:10:20:7:0", 117 // "question": "1:24:10:20:7:0",
Dan Beam 2012/06/04 18:41:04 none of this is the case any more, right?
achuithb 2012/06/04 19:52:59 Done.
120 // "tooltip": 118 // "tooltip":
121 // "Click \u003ca href=http://www.google.com\u003ehere\u003c/a\u003e!", 119 // "Click \u003ca href=http://www.google.com\u003ehere\u003c/a\u003e!",
122 // "inproduct": "10/8/09 12:00", 120 // "inproduct": "10/8/09 12:00",
123 // "inproduct_target": null 121 // "inproduct_target": null
124 // }, 122 // },
125 // { 123 // {
126 // "answer_id": "1067976", 124 // "answer_id": "1067976",
127 // "name": "promo_end", 125 // "name": "promo_end",
128 // "question": "", 126 // "question": "",
129 // "tooltip": "", 127 // "tooltip": "",
130 // "inproduct": "10/8/11 12:00", 128 // "inproduct": "10/8/11 12:00",
131 // "inproduct_target": null 129 // "inproduct_target": null
132 // }, 130 // },
133 // ... 131 // ...
134 // ] 132 // ]
135 // } 133 // }
136 // } 134 // }
137 // 135 //
138 // Because the promo signal data is piggybacked onto the tip server, the 136 // Because the promo signal data is piggybacked onto the tip server, the
139 // values don't exactly correspond with the field names: 137 // values don't exactly correspond with the field names:
140 // 138 //
141 // For "promo_start" or "promo_end", the date to start or stop showing the 139 // For "promo_start" or "promo_end", the date to start or stop showing the
142 // promotional line is given by the "inproduct" line. 140 // promotional line is given by the "inproduct" line.
143 // For "promo_start", the promotional line itself is given in the "tooltip" 141 // For "promo_start", the promotional line itself is given in the "tooltip"
144 // field. The "question" field gives the type of builds that should be shown 142 // field. The "question" field gives the type of builds that should be shown
145 // this promo (see the BuildType enum in web_resource_service.cc), the 143 // this promo (see the BuildType enum in web_resource_service.cc), the
146 // number of hours that each promo group should see it, the maximum promo 144 // number of hours that each promo group should see it, the maximum promo
147 // group that should see it, the maximum number of views of the promo,the 145 // group that should see it, the maximum number of views of the promo,the
Dan Beam 2012/06/04 18:41:04 and for the love of all things holy, if we're keep
achuithb 2012/06/04 19:52:59 Comments are no longer valid (thanks). I've delete
148 // platforms that this promo is suitable for, and a mask of features which 146 // platforms that this promo is suitable for, and a mask of features which
149 // must be present in order for the promo to be shown (0 => no feaures needed 147 // must be present in order for the promo to be shown (0 => no feaures needed
150 // 1 => user must be logged in to gplus), separated by ":". 148 // 1 => user must be logged in to gplus), separated by ":".
151 // For example, "7:24:5:10:7:0" would indicate that all groups with ids less 149 // For example, "7:24:5:10:7:0" would indicate that all groups with ids less
152 // than 5, and with dev, beta and stable builds on Windows, Mac and Linux, 150 // than 5, and with dev, beta and stable builds on Windows, Mac and Linux,
153 // should see the promo a maximum of 10 times, the promo is suitable for Mac 151 // should see the promo a maximum of 10 times, the promo is suitable for Mac
154 // Linux and Windows platforms, and no features are required to show it. The 152 // Linux and Windows platforms, and no features are required to show it. The
155 // groups ramp up so one additional group sees the promo every 24 hours. 153 // groups ramp up so one additional group sees the promo every 24 hours.
156 // 154 //
157 void UnpackNotificationSignal(const base::DictionaryValue& parsed_json); 155 void UnpackNotificationSignal(const base::DictionaryValue& parsed_json);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // name: starts with "webstore_promo" to identify the signal. The second 207 // name: starts with "webstore_promo" to identify the signal. The second
210 // part contains the release channels targeted (bitwise or of 208 // part contains the release channels targeted (bitwise or of
211 // BuildTypes). The third part specifies what users should maximize 209 // BuildTypes). The third part specifies what users should maximize
212 // the apps section of the NTP when first loading the promo (bitwise 210 // the apps section of the NTP when first loading the promo (bitwise
213 // or of AppsPromo::UserGroup). The forth part is optional and 211 // or of AppsPromo::UserGroup). The forth part is optional and
214 // specifies the URL of the logo image. If left out, the default 212 // specifies the URL of the logo image. If left out, the default
215 // webstore logo will be used. The logo can be an HTTPS or DATA URL. 213 // webstore logo will be used. The logo can be an HTTPS or DATA URL.
216 // answer_id: the promo's id 214 // answer_id: the promo's id
217 void UnpackWebStoreSignal(const base::DictionaryValue& parsed_json); 215 void UnpackWebStoreSignal(const base::DictionaryValue& parsed_json);
218 216
219 // NotificationPromo::Delegate override.
220 virtual void OnNotificationParsed(double start, double end,
221 bool new_notification) OVERRIDE;
222
223 // The profile this service belongs to. 217 // The profile this service belongs to.
224 Profile* profile_; 218 Profile* profile_;
225 219
226 // Overrides the current Chrome release channel for testing purposes. 220 // Overrides the current Chrome release channel for testing purposes.
227 chrome::VersionInfo::Channel channel_; 221 chrome::VersionInfo::Channel channel_;
228 222
229 // Allows the creation of tasks to send a notification. 223 // Allows the creation of tasks to send a notification.
230 // This allows the PromoResourceService to notify the New Tab Page immediately 224 // This allows the PromoResourceService to notify the New Tab Page immediately
231 // when a new web resource should be shown or removed. 225 // when a new web resource should be shown or removed.
232 base::WeakPtrFactory<PromoResourceService> weak_ptr_factory_; 226 base::WeakPtrFactory<PromoResourceService> weak_ptr_factory_;
233 227
234 // Notification type when an update is done. 228 // Notification type when an update is done.
235 int notification_type_; 229 int notification_type_;
236 230
237 // True if a task has been set to update the cache when a new web resource 231 // True if a task has been set to update the cache when a new web resource
238 // becomes available. 232 // becomes available.
239 bool web_resource_update_scheduled_; 233 bool web_resource_update_scheduled_;
240 234
241 // A helper that downloads the promo logo. 235 // A helper that downloads the promo logo.
242 scoped_ptr<AppsPromoLogoFetcher> apps_promo_logo_fetcher_; 236 scoped_ptr<AppsPromoLogoFetcher> apps_promo_logo_fetcher_;
243 237
244 DISALLOW_COPY_AND_ASSIGN(PromoResourceService); 238 DISALLOW_COPY_AND_ASSIGN(PromoResourceService);
245 }; 239 };
246 240
247 #endif // CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ 241 #endif // CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698