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

Side by Side Diff: chrome/browser/web_resource/web_resource_service.cc

Issue 6248026: Rename Real* to Double* in values.* and dependent files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More renames Created 9 years, 10 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) 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/web_resource_service.h" 5 #include "chrome/browser/web_resource/web_resource_service.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 Init(); 235 Init();
236 } 236 }
237 237
238 WebResourceService::~WebResourceService() { } 238 WebResourceService::~WebResourceService() { }
239 239
240 void WebResourceService::Init() { 240 void WebResourceService::Init() {
241 cache_update_delay_ = kCacheUpdateDelay; 241 cache_update_delay_ = kCacheUpdateDelay;
242 resource_dispatcher_host_ = g_browser_process->resource_dispatcher_host(); 242 resource_dispatcher_host_ = g_browser_process->resource_dispatcher_host();
243 web_resource_fetcher_.reset(new WebResourceFetcher(this)); 243 web_resource_fetcher_.reset(new WebResourceFetcher(this));
244 prefs_->RegisterStringPref(prefs::kNTPWebResourceCacheUpdate, "0"); 244 prefs_->RegisterStringPref(prefs::kNTPWebResourceCacheUpdate, "0");
245 prefs_->RegisterRealPref(prefs::kNTPCustomLogoStart, 0); 245 prefs_->RegisterDoublePref(prefs::kNTPCustomLogoStart, 0);
246 prefs_->RegisterRealPref(prefs::kNTPCustomLogoEnd, 0); 246 prefs_->RegisterDoublePref(prefs::kNTPCustomLogoEnd, 0);
247 prefs_->RegisterRealPref(prefs::kNTPPromoStart, 0); 247 prefs_->RegisterDoublePref(prefs::kNTPPromoStart, 0);
248 prefs_->RegisterRealPref(prefs::kNTPPromoEnd, 0); 248 prefs_->RegisterDoublePref(prefs::kNTPPromoEnd, 0);
249 prefs_->RegisterStringPref(prefs::kNTPPromoLine, std::string()); 249 prefs_->RegisterStringPref(prefs::kNTPPromoLine, std::string());
250 prefs_->RegisterBooleanPref(prefs::kNTPPromoClosed, false); 250 prefs_->RegisterBooleanPref(prefs::kNTPPromoClosed, false);
251 prefs_->RegisterIntegerPref(prefs::kNTPPromoGroup, -1); 251 prefs_->RegisterIntegerPref(prefs::kNTPPromoGroup, -1);
252 prefs_->RegisterIntegerPref(prefs::kNTPPromoBuild, 252 prefs_->RegisterIntegerPref(prefs::kNTPPromoBuild,
253 DEV_BUILD | BETA_BUILD | STABLE_BUILD); 253 DEV_BUILD | BETA_BUILD | STABLE_BUILD);
254 prefs_->RegisterIntegerPref(prefs::kNTPPromoGroupTimeSlice, 0); 254 prefs_->RegisterIntegerPref(prefs::kNTPPromoGroupTimeSlice, 0);
255 255
256 // If the promo start is in the future, set a notification task to invalidate 256 // If the promo start is in the future, set a notification task to invalidate
257 // the NTP cache at the time of the promo start. 257 // the NTP cache at the time of the promo start.
258 double promo_start = prefs_->GetReal(prefs::kNTPPromoStart); 258 double promo_start = prefs_->GetDouble(prefs::kNTPPromoStart);
259 double promo_end = prefs_->GetReal(prefs::kNTPPromoEnd); 259 double promo_end = prefs_->GetDouble(prefs::kNTPPromoEnd);
260 ScheduleNotification(promo_start, promo_end); 260 ScheduleNotification(promo_start, promo_end);
261 } 261 }
262 262
263 void WebResourceService::EndFetch() { 263 void WebResourceService::EndFetch() {
264 in_fetch_ = false; 264 in_fetch_ = false;
265 } 265 }
266 266
267 void WebResourceService::OnWebResourceUnpacked( 267 void WebResourceService::OnWebResourceUnpacked(
268 const DictionaryValue& parsed_json) { 268 const DictionaryValue& parsed_json) {
269 UnpackLogoSignal(parsed_json); 269 UnpackLogoSignal(parsed_json);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 DictionaryValue* topic_dict; 384 DictionaryValue* topic_dict;
385 ListValue* answer_list; 385 ListValue* answer_list;
386 double old_promo_start = 0; 386 double old_promo_start = 0;
387 double old_promo_end = 0; 387 double old_promo_end = 0;
388 double promo_start = 0; 388 double promo_start = 0;
389 double promo_end = 0; 389 double promo_end = 0;
390 390
391 // Check for preexisting start and end values. 391 // Check for preexisting start and end values.
392 if (prefs_->HasPrefPath(prefs::kNTPPromoStart) && 392 if (prefs_->HasPrefPath(prefs::kNTPPromoStart) &&
393 prefs_->HasPrefPath(prefs::kNTPPromoEnd)) { 393 prefs_->HasPrefPath(prefs::kNTPPromoEnd)) {
394 old_promo_start = prefs_->GetReal(prefs::kNTPPromoStart); 394 old_promo_start = prefs_->GetDouble(prefs::kNTPPromoStart);
395 old_promo_end = prefs_->GetReal(prefs::kNTPPromoEnd); 395 old_promo_end = prefs_->GetDouble(prefs::kNTPPromoEnd);
396 } 396 }
397 397
398 // Check for newly received start and end values. 398 // Check for newly received start and end values.
399 if (parsed_json.GetDictionary("topic", &topic_dict)) { 399 if (parsed_json.GetDictionary("topic", &topic_dict)) {
400 if (topic_dict->GetList("answers", &answer_list)) { 400 if (topic_dict->GetList("answers", &answer_list)) {
401 std::string promo_start_string = ""; 401 std::string promo_start_string = "";
402 std::string promo_end_string = ""; 402 std::string promo_end_string = "";
403 std::string promo_string = ""; 403 std::string promo_string = "";
404 std::string promo_build = ""; 404 std::string promo_build = "";
405 int promo_build_type = 0; 405 int promo_build_type = 0;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 } 466 }
467 } 467 }
468 468
469 // If start or end times have changed, trigger a new web resource 469 // If start or end times have changed, trigger a new web resource
470 // notification, so that the logo on the NTP is updated. This check is 470 // notification, so that the logo on the NTP is updated. This check is
471 // outside the reading of the web resource data, because the absence of 471 // outside the reading of the web resource data, because the absence of
472 // dates counts as a triggering change if there were dates before. 472 // dates counts as a triggering change if there were dates before.
473 // Also reset the promo closed preference, to signal a new promo. 473 // Also reset the promo closed preference, to signal a new promo.
474 if (!(old_promo_start == promo_start) || 474 if (!(old_promo_start == promo_start) ||
475 !(old_promo_end == promo_end)) { 475 !(old_promo_end == promo_end)) {
476 prefs_->SetReal(prefs::kNTPPromoStart, promo_start); 476 prefs_->SetDouble(prefs::kNTPPromoStart, promo_start);
477 prefs_->SetReal(prefs::kNTPPromoEnd, promo_end); 477 prefs_->SetDouble(prefs::kNTPPromoEnd, promo_end);
478 prefs_->SetBoolean(prefs::kNTPPromoClosed, false); 478 prefs_->SetBoolean(prefs::kNTPPromoClosed, false);
479 ScheduleNotification(promo_start, promo_end); 479 ScheduleNotification(promo_start, promo_end);
480 } 480 }
481 } 481 }
482 482
483 void WebResourceService::UnpackLogoSignal(const DictionaryValue& parsed_json) { 483 void WebResourceService::UnpackLogoSignal(const DictionaryValue& parsed_json) {
484 DictionaryValue* topic_dict; 484 DictionaryValue* topic_dict;
485 ListValue* answer_list; 485 ListValue* answer_list;
486 double old_logo_start = 0; 486 double old_logo_start = 0;
487 double old_logo_end = 0; 487 double old_logo_end = 0;
488 double logo_start = 0; 488 double logo_start = 0;
489 double logo_end = 0; 489 double logo_end = 0;
490 490
491 // Check for preexisting start and end values. 491 // Check for preexisting start and end values.
492 if (prefs_->HasPrefPath(prefs::kNTPCustomLogoStart) && 492 if (prefs_->HasPrefPath(prefs::kNTPCustomLogoStart) &&
493 prefs_->HasPrefPath(prefs::kNTPCustomLogoEnd)) { 493 prefs_->HasPrefPath(prefs::kNTPCustomLogoEnd)) {
494 old_logo_start = prefs_->GetReal(prefs::kNTPCustomLogoStart); 494 old_logo_start = prefs_->GetDouble(prefs::kNTPCustomLogoStart);
495 old_logo_end = prefs_->GetReal(prefs::kNTPCustomLogoEnd); 495 old_logo_end = prefs_->GetDouble(prefs::kNTPCustomLogoEnd);
496 } 496 }
497 497
498 // Check for newly received start and end values. 498 // Check for newly received start and end values.
499 if (parsed_json.GetDictionary("topic", &topic_dict)) { 499 if (parsed_json.GetDictionary("topic", &topic_dict)) {
500 if (topic_dict->GetList("answers", &answer_list)) { 500 if (topic_dict->GetList("answers", &answer_list)) {
501 std::string logo_start_string = ""; 501 std::string logo_start_string = "";
502 std::string logo_end_string = ""; 502 std::string logo_end_string = "";
503 for (ListValue::const_iterator tip_iter = answer_list->begin(); 503 for (ListValue::const_iterator tip_iter = answer_list->begin();
504 tip_iter != answer_list->end(); ++tip_iter) { 504 tip_iter != answer_list->end(); ++tip_iter) {
505 if (!(*tip_iter)->IsType(Value::TYPE_DICTIONARY)) 505 if (!(*tip_iter)->IsType(Value::TYPE_DICTIONARY))
(...skipping 25 matching lines...) Expand all
531 } 531 }
532 } 532 }
533 } 533 }
534 534
535 // If logo start or end times have changed, trigger a new web resource 535 // If logo start or end times have changed, trigger a new web resource
536 // notification, so that the logo on the NTP is updated. This check is 536 // notification, so that the logo on the NTP is updated. This check is
537 // outside the reading of the web resource data, because the absence of 537 // outside the reading of the web resource data, because the absence of
538 // dates counts as a triggering change if there were dates before. 538 // dates counts as a triggering change if there were dates before.
539 if (!(old_logo_start == logo_start) || 539 if (!(old_logo_start == logo_start) ||
540 !(old_logo_end == logo_end)) { 540 !(old_logo_end == logo_end)) {
541 prefs_->SetReal(prefs::kNTPCustomLogoStart, logo_start); 541 prefs_->SetDouble(prefs::kNTPCustomLogoStart, logo_start);
542 prefs_->SetReal(prefs::kNTPCustomLogoEnd, logo_end); 542 prefs_->SetDouble(prefs::kNTPCustomLogoEnd, logo_end);
543 NotificationService* service = NotificationService::current(); 543 NotificationService* service = NotificationService::current();
544 service->Notify(NotificationType::WEB_RESOURCE_STATE_CHANGED, 544 service->Notify(NotificationType::WEB_RESOURCE_STATE_CHANGED,
545 Source<WebResourceService>(this), 545 Source<WebResourceService>(this),
546 NotificationService::NoDetails()); 546 NotificationService::NoDetails());
547 } 547 }
548 } 548 }
549 549
550 namespace WebResourceServiceUtil { 550 namespace WebResourceServiceUtil {
551 551
552 bool CanShowPromo(Profile* profile) { 552 bool CanShowPromo(Profile* profile) {
(...skipping 23 matching lines...) Expand all
576 } else { 576 } else {
577 is_promo_build = true; 577 is_promo_build = true;
578 } 578 }
579 } 579 }
580 580
581 return !promo_closed && !is_synced && is_promo_build; 581 return !promo_closed && !is_synced && is_promo_build;
582 } 582 }
583 583
584 } // namespace WebResourceService 584 } // namespace WebResourceService
585 585
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698