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 #include "chrome/browser/web_resource/promo_resource_service.h" | 5 #include "chrome/browser/web_resource/promo_resource_service.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "content/common/notification_service.h" | 23 #include "content/common/notification_service.h" |
24 #include "googleurl/src/gurl.h" | 24 #include "googleurl/src/gurl.h" |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 // Delay on first fetch so we don't interfere with startup. | 28 // Delay on first fetch so we don't interfere with startup. |
29 static const int kStartResourceFetchDelay = 5000; | 29 static const int kStartResourceFetchDelay = 5000; |
30 | 30 |
31 // Delay between calls to update the cache (48 hours), and 3 min in debug mode. | 31 // Delay between calls to update the cache (48 hours), and 3 min in debug mode. |
32 static const int kCacheUpdateDelay = 48 * 60 * 60 * 1000; | 32 static const int kCacheUpdateDelay = 48 * 60 * 60 * 1000; |
33 static const int kDebugCacheUpdateDelay = 3 * 60 * 1000; | 33 static const int kTestCacheUpdateDelay = 3 * 60 * 1000; |
34 | |
35 // Users are randomly assigned to one of kNTPPromoGroupSize buckets, in order | |
36 // to be able to roll out promos slowly, or display different promos to | |
37 // different groups. | |
38 static const int kNTPPromoGroupSize = 100; | |
39 | |
40 // Maximum number of hours for each time slice (4 weeks). | |
41 static const int kMaxTimeSliceHours = 24 * 7 * 4; | |
42 | 34 |
43 // The version of the service (used to expire the cache when upgrading Chrome | 35 // The version of the service (used to expire the cache when upgrading Chrome |
44 // to versions with different types of promos). | 36 // to versions with different types of promos). |
45 static const int kPromoServiceVersion = 2; | 37 static const int kPromoServiceVersion = 2; |
46 | 38 |
47 // Properties used by the server. | 39 // Properties used by the server. |
48 static const char kAnswerIdProperty[] = "answer_id"; | 40 static const char kAnswerIdProperty[] = "answer_id"; |
49 static const char kWebStoreHeaderProperty[] = "question"; | 41 static const char kWebStoreHeaderProperty[] = "question"; |
50 static const char kWebStoreButtonProperty[] = "inproduct_target"; | 42 static const char kWebStoreButtonProperty[] = "inproduct_target"; |
51 static const char kWebStoreLinkProperty[] = "inproduct"; | 43 static const char kWebStoreLinkProperty[] = "inproduct"; |
52 static const char kWebStoreExpireProperty[] = "tooltip"; | 44 static const char kWebStoreExpireProperty[] = "tooltip"; |
53 | 45 |
54 chrome::VersionInfo::Channel GetChannel() { | |
55 // GetChannel hits the registry on Windows. See http://crbug.com/70898. | |
56 base::ThreadRestrictions::ScopedAllowIO allow_io; | |
57 return chrome::VersionInfo::GetChannel(); | |
58 } | |
59 | |
60 int GetNextQuestionValue(const std::string& question, | |
61 size_t* index, | |
62 bool* err) { | |
63 if (*err) | |
64 return 0; | |
65 | |
66 size_t new_index = question.find(':', *index); | |
67 // Note that substr correctly handles npos. | |
68 std::string fragment(question.substr(*index, new_index - *index)); | |
69 *index = new_index + 1; | |
70 | |
71 int value; | |
72 *err = !base::StringToInt(fragment, &value); | |
73 return value; | |
74 } | |
75 | |
76 const char* GetPromoResourceURL() { | 46 const char* GetPromoResourceURL() { |
77 std::string promo_server_url = CommandLine::ForCurrentProcess()-> | 47 std::string promo_server_url = CommandLine::ForCurrentProcess()-> |
78 GetSwitchValueASCII(switches::kPromoServerURL); | 48 GetSwitchValueASCII(switches::kPromoServerURL); |
79 return promo_server_url.empty() ? | 49 return promo_server_url.empty() ? |
80 PromoResourceService::kDefaultPromoResourceServer : | 50 PromoResourceService::kDefaultPromoResourceServer : |
81 promo_server_url.c_str(); | 51 promo_server_url.c_str(); |
82 } | 52 } |
83 | 53 |
| 54 bool IsTest() { |
| 55 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kPromoServerURL); |
| 56 } |
| 57 |
84 int GetCacheUpdateDelay() { | 58 int GetCacheUpdateDelay() { |
85 return CommandLine::ForCurrentProcess()->HasSwitch( | 59 return IsTest() ? kTestCacheUpdateDelay : kCacheUpdateDelay; |
86 switches::kPromoServerURL) ? kDebugCacheUpdateDelay : kCacheUpdateDelay; | |
87 } | 60 } |
88 | 61 |
89 } // namespace | 62 } // namespace |
90 | 63 |
91 // Server for dynamically loaded NTP HTML elements. | 64 // Server for dynamically loaded NTP HTML elements. |
92 const char* PromoResourceService::kDefaultPromoResourceServer = | 65 const char* PromoResourceService::kDefaultPromoResourceServer = |
93 "https://www.google.com/support/chrome/bin/topic/1142433/inproduct?hl="; | 66 "https://www.google.com/support/chrome/bin/topic/1142433/inproduct?hl="; |
94 | 67 |
95 // static | 68 // static |
96 void PromoResourceService::RegisterPrefs(PrefService* local_state) { | 69 void PromoResourceService::RegisterPrefs(PrefService* local_state) { |
97 local_state->RegisterIntegerPref(prefs::kNTPPromoVersion, 0); | 70 local_state->RegisterIntegerPref(prefs::kNTPPromoVersion, 0); |
98 local_state->RegisterStringPref(prefs::kNTPPromoLocale, std::string()); | 71 local_state->RegisterStringPref(prefs::kNTPPromoLocale, std::string()); |
99 } | 72 } |
100 | 73 |
101 // static | 74 // static |
102 void PromoResourceService::RegisterUserPrefs(PrefService* prefs) { | 75 void PromoResourceService::RegisterUserPrefs(PrefService* prefs) { |
103 prefs->RegisterDoublePref(prefs::kNTPCustomLogoStart, | 76 prefs->RegisterDoublePref(prefs::kNTPCustomLogoStart, |
104 0, | 77 0, |
105 PrefService::UNSYNCABLE_PREF); | 78 PrefService::UNSYNCABLE_PREF); |
106 prefs->RegisterDoublePref(prefs::kNTPCustomLogoEnd, | 79 prefs->RegisterDoublePref(prefs::kNTPCustomLogoEnd, |
107 0, | 80 0, |
108 PrefService::UNSYNCABLE_PREF); | 81 PrefService::UNSYNCABLE_PREF); |
109 prefs->RegisterDoublePref(prefs::kNTPPromoStart, | 82 NotificationPromo::RegisterUserPrefs(prefs); |
110 0, | 83 } |
111 PrefService::UNSYNCABLE_PREF); | 84 |
112 prefs->RegisterDoublePref(prefs::kNTPPromoEnd, | 85 // static |
113 0, | 86 chrome::VersionInfo::Channel PromoResourceService::GetChannel() { |
114 PrefService::UNSYNCABLE_PREF); | 87 // GetChannel hits the registry on Windows. See http://crbug.com/70898. |
115 prefs->RegisterStringPref(prefs::kNTPPromoLine, | 88 base::ThreadRestrictions::ScopedAllowIO allow_io; |
116 std::string(), | 89 return chrome::VersionInfo::GetChannel(); |
117 PrefService::UNSYNCABLE_PREF); | |
118 prefs->RegisterBooleanPref(prefs::kNTPPromoClosed, | |
119 false, | |
120 PrefService::UNSYNCABLE_PREF); | |
121 prefs->RegisterIntegerPref(prefs::kNTPPromoGroup, | |
122 0, | |
123 PrefService::UNSYNCABLE_PREF); | |
124 prefs->RegisterIntegerPref( | |
125 prefs::kNTPPromoBuild, | |
126 ALL_BUILDS, | |
127 PrefService::UNSYNCABLE_PREF); | |
128 prefs->RegisterIntegerPref(prefs::kNTPPromoGroupTimeSlice, | |
129 0, | |
130 PrefService::UNSYNCABLE_PREF); | |
131 prefs->RegisterIntegerPref(prefs::kNTPPromoGroupMax, | |
132 0, | |
133 PrefService::UNSYNCABLE_PREF); | |
134 } | 90 } |
135 | 91 |
136 // static | 92 // static |
137 bool PromoResourceService::IsBuildTargeted(chrome::VersionInfo::Channel channel, | 93 bool PromoResourceService::IsBuildTargeted(chrome::VersionInfo::Channel channel, |
138 int builds_allowed) { | 94 int builds_allowed) { |
139 if (builds_allowed == NO_BUILD) | 95 if (builds_allowed == NO_BUILD) |
140 return false; | 96 return false; |
141 switch (channel) { | 97 switch (channel) { |
142 case chrome::VersionInfo::CHANNEL_CANARY: | 98 case chrome::VersionInfo::CHANNEL_CANARY: |
143 return (CANARY_BUILD & builds_allowed) != 0; | 99 return (CANARY_BUILD & builds_allowed) != 0; |
(...skipping 22 matching lines...) Expand all Loading... |
166 channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) { | 122 channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) { |
167 Init(); | 123 Init(); |
168 } | 124 } |
169 | 125 |
170 PromoResourceService::~PromoResourceService() { } | 126 PromoResourceService::~PromoResourceService() { } |
171 | 127 |
172 void PromoResourceService::Init() { | 128 void PromoResourceService::Init() { |
173 ScheduleNotificationOnInit(); | 129 ScheduleNotificationOnInit(); |
174 } | 130 } |
175 | 131 |
176 bool PromoResourceService::IsThisBuildTargeted(int builds_targeted) { | 132 bool PromoResourceService::IsBuildTargeted(int builds_targeted) { |
177 if (channel_ == chrome::VersionInfo::CHANNEL_UNKNOWN) | 133 if (channel_ == chrome::VersionInfo::CHANNEL_UNKNOWN) |
178 channel_ = GetChannel(); | 134 channel_ = GetChannel(); |
179 | 135 |
180 return IsBuildTargeted(channel_, builds_targeted); | 136 return IsBuildTargeted(channel_, builds_targeted); |
181 } | 137 } |
182 | 138 |
183 void PromoResourceService::Unpack(const DictionaryValue& parsed_json) { | 139 void PromoResourceService::Unpack(const DictionaryValue& parsed_json) { |
184 UnpackLogoSignal(parsed_json); | 140 UnpackLogoSignal(parsed_json); |
185 UnpackNotificationSignal(parsed_json); | 141 UnpackNotificationSignal(parsed_json); |
186 UnpackWebStoreSignal(parsed_json); | 142 UnpackWebStoreSignal(parsed_json); |
187 } | 143 } |
188 | 144 |
| 145 void PromoResourceService::OnNewNotification(double start, double end) { |
| 146 ScheduleNotification(start, end); |
| 147 } |
| 148 |
189 void PromoResourceService::ScheduleNotification(double promo_start, | 149 void PromoResourceService::ScheduleNotification(double promo_start, |
190 double promo_end) { | 150 double promo_end) { |
191 if (promo_start > 0 && promo_end > 0) { | 151 if (promo_start > 0 && promo_end > 0) { |
192 int64 ms_until_start = | 152 int64 ms_until_start = |
193 static_cast<int64>((base::Time::FromDoubleT( | 153 static_cast<int64>((base::Time::FromDoubleT( |
194 promo_start) - base::Time::Now()).InMilliseconds()); | 154 promo_start) - base::Time::Now()).InMilliseconds()); |
195 int64 ms_until_end = | 155 int64 ms_until_end = |
196 static_cast<int64>((base::Time::FromDoubleT( | 156 static_cast<int64>((base::Time::FromDoubleT( |
197 promo_end) - base::Time::Now()).InMilliseconds()); | 157 promo_end) - base::Time::Now()).InMilliseconds()); |
198 if (ms_until_start > 0) | 158 if (ms_until_start > 0) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 return local_state->GetInteger(prefs::kNTPPromoVersion); | 193 return local_state->GetInteger(prefs::kNTPPromoVersion); |
234 } | 194 } |
235 | 195 |
236 std::string PromoResourceService::GetPromoLocale() { | 196 std::string PromoResourceService::GetPromoLocale() { |
237 PrefService* local_state = g_browser_process->local_state(); | 197 PrefService* local_state = g_browser_process->local_state(); |
238 return local_state->GetString(prefs::kNTPPromoLocale); | 198 return local_state->GetString(prefs::kNTPPromoLocale); |
239 } | 199 } |
240 | 200 |
241 void PromoResourceService::UnpackNotificationSignal( | 201 void PromoResourceService::UnpackNotificationSignal( |
242 const DictionaryValue& parsed_json) { | 202 const DictionaryValue& parsed_json) { |
243 // Check for newly received start and end values. | 203 NotificationPromo notification_promo(prefs_, this); |
244 std::string promo_start_string, promo_end_string; | 204 notification_promo.InitFromJson(parsed_json); |
245 | |
246 DictionaryValue* topic_dict; | |
247 if (parsed_json.GetDictionary("topic", &topic_dict)) { | |
248 ListValue* answer_list; | |
249 if (topic_dict->GetList("answers", &answer_list)) { | |
250 for (ListValue::const_iterator answer_iter = answer_list->begin(); | |
251 answer_iter != answer_list->end(); ++answer_iter) { | |
252 if (!(*answer_iter)->IsType(Value::TYPE_DICTIONARY)) | |
253 continue; | |
254 | |
255 ParseNotification(static_cast<DictionaryValue*>(*answer_iter), | |
256 &promo_start_string, &promo_end_string); | |
257 } | |
258 } | |
259 } | |
260 | |
261 CheckForNewNotification(promo_start_string, promo_end_string); | |
262 } | |
263 | |
264 void PromoResourceService::ParseNotification( | |
265 DictionaryValue* a_dic, | |
266 std::string* promo_start_string, | |
267 std::string* promo_end_string) { | |
268 std::string promo_signal; | |
269 if (a_dic->GetString("name", &promo_signal)) { | |
270 if (promo_signal == "promo_start") { | |
271 SetNotificationParams(a_dic); | |
272 SetNotificationLine(a_dic); | |
273 | |
274 a_dic->GetString("inproduct", promo_start_string); | |
275 } else if (promo_signal == "promo_end") { | |
276 a_dic->GetString("inproduct", promo_end_string); | |
277 } | |
278 } | |
279 } | |
280 | |
281 void PromoResourceService::SetNotificationParams(DictionaryValue* a_dic) { | |
282 std::string question; | |
283 a_dic->GetString("question", &question); | |
284 | |
285 size_t index(0); | |
286 bool err(false); | |
287 int promo_build = GetNextQuestionValue(question, &index, &err); | |
288 int time_slice = GetNextQuestionValue(question, &index, &err); | |
289 int max_group = GetNextQuestionValue(question, &index, &err); | |
290 | |
291 if (err || | |
292 promo_build < 0 || | |
293 promo_build > ALL_BUILDS || | |
294 time_slice < 0 || | |
295 time_slice > kMaxTimeSliceHours || | |
296 max_group < 0 || | |
297 max_group >= kNTPPromoGroupSize) { | |
298 // If values are not valid, do not show promo. | |
299 NOTREACHED() << "Invalid server data, question=" << question << | |
300 ", build=" << promo_build << | |
301 ", time_slice=" << time_slice << | |
302 ", max_group=" << max_group; | |
303 promo_build = NO_BUILD; | |
304 time_slice = 0; | |
305 max_group = 0; | |
306 } | |
307 | |
308 prefs_->SetInteger(prefs::kNTPPromoBuild, promo_build); | |
309 prefs_->SetInteger(prefs::kNTPPromoGroupTimeSlice, time_slice); | |
310 prefs_->SetInteger(prefs::kNTPPromoGroupMax, max_group); | |
311 } | |
312 | |
313 void PromoResourceService::SetNotificationLine(DictionaryValue* a_dic) { | |
314 std::string promo_line; | |
315 a_dic->GetString("tooltip", &promo_line); | |
316 if (!promo_line.empty()) | |
317 prefs_->SetString(prefs::kNTPPromoLine, promo_line); | |
318 } | |
319 | |
320 void PromoResourceService::CheckForNewNotification( | |
321 const std::string& promo_start_string, | |
322 const std::string& promo_end_string) { | |
323 double promo_start = 0.0, promo_end = 0.0; | |
324 ParseNewNotificationTimes(promo_start_string, promo_end_string, | |
325 &promo_start, &promo_end); | |
326 | |
327 double old_promo_start = 0.0, old_promo_end = 0.0; | |
328 GetCurrentNotificationTimes(&old_promo_start, &old_promo_end); | |
329 | |
330 // If start or end times have changed, trigger a new web resource | |
331 // notification, so that the logo on the NTP is updated. This check is | |
332 // outside the reading of the web resource data, because the absence of | |
333 // dates counts as a triggering change if there were dates before. | |
334 // Also create new promo groups, and reset the promo closed preference, | |
335 // to signal a new promo. | |
336 if (old_promo_start != promo_start || old_promo_end != promo_end) | |
337 OnNewNotification(promo_start, promo_end); | |
338 } | |
339 | |
340 void PromoResourceService::ParseNewNotificationTimes( | |
341 const std::string& promo_start_string, | |
342 const std::string& promo_end_string, | |
343 double* promo_start, | |
344 double* promo_end) { | |
345 *promo_start = *promo_end = 0.0; | |
346 | |
347 if (promo_start_string.empty() && !promo_end_string.empty()) | |
348 return; | |
349 | |
350 base::Time start_time, end_time; | |
351 if (!base::Time::FromString(promo_start_string.c_str(), &start_time) || | |
352 !base::Time::FromString(promo_end_string.c_str(), &end_time)) | |
353 return; | |
354 | |
355 *promo_start = start_time.ToDoubleT(); | |
356 *promo_end = end_time.ToDoubleT(); | |
357 } | |
358 | |
359 void PromoResourceService::GetCurrentNotificationTimes(double* old_promo_start, | |
360 double* old_promo_end) { | |
361 *old_promo_start = *old_promo_end = 0.0; | |
362 if (prefs_->HasPrefPath(prefs::kNTPPromoStart) && | |
363 prefs_->HasPrefPath(prefs::kNTPPromoEnd)) { | |
364 *old_promo_start = prefs_->GetDouble(prefs::kNTPPromoStart); | |
365 *old_promo_end = prefs_->GetDouble(prefs::kNTPPromoEnd); | |
366 } | |
367 } | |
368 | |
369 int PromoResourceService::ResetNotificationGroup() { | |
370 srand(static_cast<uint32>(time(NULL))); | |
371 const int promo_group = rand() % kNTPPromoGroupSize; | |
372 prefs_->SetInteger(prefs::kNTPPromoGroup, promo_group); | |
373 return promo_group; | |
374 } | |
375 | |
376 // static | |
377 double PromoResourceService::GetNotificationStartTime(PrefService* prefs) { | |
378 if (!prefs->HasPrefPath(prefs::kNTPPromoStart)) | |
379 return 0.0; | |
380 | |
381 const double promo_start = prefs->GetDouble(prefs::kNTPPromoStart); | |
382 | |
383 if (!prefs->HasPrefPath(prefs::kNTPPromoGroup) || | |
384 !prefs->HasPrefPath(prefs::kNTPPromoGroupTimeSlice)) | |
385 return promo_start; | |
386 | |
387 const int promo_group = prefs->GetInteger(prefs::kNTPPromoGroup); | |
388 const int time_slice = prefs->GetInteger(prefs::kNTPPromoGroupTimeSlice); | |
389 // Adjust promo_start using group time slice, adjusted from hours to seconds. | |
390 static const double kSecondsInHour = 60.0 * 60.0; | |
391 return promo_start + promo_group * time_slice * kSecondsInHour; | |
392 } | |
393 | |
394 void PromoResourceService::OnNewNotification(double promo_start, | |
395 double promo_end) { | |
396 ResetNotificationGroup(); | |
397 | |
398 prefs_->SetBoolean(prefs::kNTPPromoClosed, false); | |
399 | |
400 prefs_->SetDouble(prefs::kNTPPromoStart, promo_start); | |
401 prefs_->SetDouble(prefs::kNTPPromoEnd, promo_end); | |
402 | |
403 ScheduleNotification(GetNotificationStartTime(prefs_), promo_end); | |
404 } | 205 } |
405 | 206 |
406 bool PromoResourceService::CanShowNotificationPromo(Profile* profile) { | 207 bool PromoResourceService::CanShowNotificationPromo(Profile* profile) { |
407 PrefService* prefs = profile->GetPrefs(); | 208 NotificationPromo notification_promo(profile->GetPrefs(), NULL); |
408 | 209 notification_promo.InitFromPrefs(); |
409 // Check if promo has been closed by the user. | 210 return notification_promo.CanShow(); |
410 if (prefs->HasPrefPath(prefs::kNTPPromoClosed) && | |
411 prefs->GetBoolean(prefs::kNTPPromoClosed)) | |
412 return false; | |
413 | |
414 // Check if our build is appropriate for this promo. | |
415 if (!prefs->HasPrefPath(prefs::kNTPPromoBuild) || | |
416 !IsBuildTargeted(GetChannel(), prefs->GetInteger(prefs::kNTPPromoBuild))) | |
417 return false; | |
418 | |
419 // Check if we are in the right group for this promo. | |
420 if (!prefs->FindPreference(prefs::kNTPPromoGroup) || | |
421 !prefs->FindPreference(prefs::kNTPPromoGroupMax) || | |
422 (prefs->GetInteger(prefs::kNTPPromoGroup) >= | |
423 prefs->GetInteger(prefs::kNTPPromoGroupMax))) | |
424 return false; | |
425 | |
426 // Check if we are in the right time window for this promo. | |
427 if (!prefs->FindPreference(prefs::kNTPPromoStart) || | |
428 !prefs->FindPreference(prefs::kNTPPromoEnd) || | |
429 base::Time::FromDoubleT(GetNotificationStartTime(prefs)) > | |
430 base::Time::Now() || | |
431 base::Time::FromDoubleT(prefs->GetDouble(prefs::kNTPPromoEnd)) < | |
432 base::Time::Now()) | |
433 return false; | |
434 | |
435 return prefs->HasPrefPath(prefs::kNTPPromoLine); | |
436 } | 211 } |
437 | 212 |
438 void PromoResourceService::UnpackWebStoreSignal( | 213 void PromoResourceService::UnpackWebStoreSignal( |
439 const DictionaryValue& parsed_json) { | 214 const DictionaryValue& parsed_json) { |
440 DictionaryValue* topic_dict; | 215 DictionaryValue* topic_dict; |
441 ListValue* answer_list; | 216 ListValue* answer_list; |
442 | 217 |
443 bool is_webstore_active = false; | 218 bool is_webstore_active = false; |
444 bool signal_found = false; | 219 bool signal_found = false; |
445 AppsPromo::PromoData promo_data; | 220 AppsPromo::PromoData promo_data; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 // (4) optional text that specifies a URL of a logo image | 265 // (4) optional text that specifies a URL of a logo image |
491 promo_logo = name.substr(split+1); | 266 promo_logo = name.substr(split+1); |
492 | 267 |
493 if (!a_dic->GetString(kAnswerIdProperty, &promo_data.id) || | 268 if (!a_dic->GetString(kAnswerIdProperty, &promo_data.id) || |
494 !a_dic->GetString(kWebStoreHeaderProperty, &promo_data.header) || | 269 !a_dic->GetString(kWebStoreHeaderProperty, &promo_data.header) || |
495 !a_dic->GetString(kWebStoreButtonProperty, &promo_data.button) || | 270 !a_dic->GetString(kWebStoreButtonProperty, &promo_data.button) || |
496 !a_dic->GetString(kWebStoreLinkProperty, &promo_link) || | 271 !a_dic->GetString(kWebStoreLinkProperty, &promo_link) || |
497 !a_dic->GetString(kWebStoreExpireProperty, &promo_data.expire)) | 272 !a_dic->GetString(kWebStoreExpireProperty, &promo_data.expire)) |
498 continue; | 273 continue; |
499 | 274 |
500 if (IsThisBuildTargeted(target_builds)) { | 275 if (IsBuildTargeted(target_builds)) { |
501 // The downloader will set the promo prefs and send the | 276 // The downloader will set the promo prefs and send the |
502 // NOTIFICATION_WEB_STORE_PROMO_LOADED notification. | 277 // NOTIFICATION_WEB_STORE_PROMO_LOADED notification. |
503 promo_data.link = GURL(promo_link); | 278 promo_data.link = GURL(promo_link); |
504 promo_data.logo = GURL(promo_logo); | 279 promo_data.logo = GURL(promo_logo); |
505 apps_promo_logo_fetcher_.reset( | 280 apps_promo_logo_fetcher_.reset( |
506 new AppsPromoLogoFetcher(profile_, promo_data)); | 281 new AppsPromoLogoFetcher(profile_, promo_data)); |
507 signal_found = true; | 282 signal_found = true; |
508 break; | 283 break; |
509 } | 284 } |
510 } | 285 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 if (!(old_logo_start == logo_start) || | 352 if (!(old_logo_start == logo_start) || |
578 !(old_logo_end == logo_end)) { | 353 !(old_logo_end == logo_end)) { |
579 prefs_->SetDouble(prefs::kNTPCustomLogoStart, logo_start); | 354 prefs_->SetDouble(prefs::kNTPCustomLogoStart, logo_start); |
580 prefs_->SetDouble(prefs::kNTPCustomLogoEnd, logo_end); | 355 prefs_->SetDouble(prefs::kNTPCustomLogoEnd, logo_end); |
581 NotificationService* service = NotificationService::current(); | 356 NotificationService* service = NotificationService::current(); |
582 service->Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED, | 357 service->Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED, |
583 Source<WebResourceService>(this), | 358 Source<WebResourceService>(this), |
584 NotificationService::NoDetails()); | 359 NotificationService::NoDetails()); |
585 } | 360 } |
586 } | 361 } |
OLD | NEW |