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

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

Issue 11741003: Remove PrefServiceSimple, replacing it with PrefService and PrefRegistrySimple. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 #include "chrome/browser/web_resource/promo_resource_service.h" 5 #include "chrome/browser/web_resource/promo_resource_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/prefs/pref_registrar_simple.h"
13 #include "chrome/browser/prefs/pref_service.h" 14 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/web_resource/notification_promo.h" 16 #include "chrome/browser/web_resource/notification_promo.h"
16 #include "chrome/common/chrome_notification_types.h" 17 #include "chrome/common/chrome_notification_types.h"
17 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
18 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
19 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
20 #include "content/public/browser/notification_service.h" 21 #include "content/public/browser/notification_service.h"
21 #include "googleurl/src/gurl.h" 22 #include "googleurl/src/gurl.h"
22 23
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kPromoServerURL); 56 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kPromoServerURL);
56 } 57 }
57 58
58 int GetCacheUpdateDelay() { 59 int GetCacheUpdateDelay() {
59 return IsTest() ? kTestCacheUpdateDelay : kCacheUpdateDelay; 60 return IsTest() ? kTestCacheUpdateDelay : kCacheUpdateDelay;
60 } 61 }
61 62
62 } // namespace 63 } // namespace
63 64
64 // static 65 // static
65 void PromoResourceService::RegisterPrefs(PrefServiceSimple* local_state) { 66 void PromoResourceService::RegisterPrefs(PrefService* local_state,
67 PrefRegistrarSimple* registrar) {
66 // TODO(achuith): Delete this in M26. http://crbug.com/143773 68 // TODO(achuith): Delete this in M26. http://crbug.com/143773
67 // The promo service version number, and last locale. 69 // The promo service version number, and last locale.
68 const char kNtpPromoVersion[] = "ntp.promo_version"; 70 const char kNtpPromoVersion[] = "ntp.promo_version";
69 const char kNtpPromoLocale[] = "ntp.promo_locale"; 71 const char kNtpPromoLocale[] = "ntp.promo_locale";
70 local_state->RegisterIntegerPref(kNtpPromoVersion, 0); 72 registrar->RegisterIntegerPref(kNtpPromoVersion, 0);
71 local_state->RegisterStringPref(kNtpPromoLocale, std::string()); 73 registrar->RegisterStringPref(kNtpPromoLocale, std::string());
72 local_state->ClearPref(kNtpPromoVersion); 74 local_state->ClearPref(kNtpPromoVersion);
73 local_state->ClearPref(kNtpPromoLocale); 75 local_state->ClearPref(kNtpPromoLocale);
74 } 76 }
75 77
76 // static 78 // static
77 void PromoResourceService::RegisterUserPrefs(PrefServiceSyncable* prefs) { 79 void PromoResourceService::RegisterUserPrefs(PrefServiceSyncable* prefs) {
78 prefs->RegisterStringPref(prefs::kNtpPromoResourceCacheUpdate, 80 prefs->RegisterStringPref(prefs::kNtpPromoResourceCacheUpdate,
79 "0", 81 "0",
80 PrefServiceSyncable::UNSYNCABLE_PREF); 82 PrefServiceSyncable::UNSYNCABLE_PREF);
81 NotificationPromo::RegisterUserPrefs(prefs); 83 NotificationPromo::RegisterUserPrefs(prefs);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 168 }
167 169
168 void PromoResourceService::Unpack(const DictionaryValue& parsed_json) { 170 void PromoResourceService::Unpack(const DictionaryValue& parsed_json) {
169 for (size_t i = 0; i < arraysize(kValidPromoTypes); ++i) { 171 for (size_t i = 0; i < arraysize(kValidPromoTypes); ++i) {
170 NotificationPromo notification_promo(profile_); 172 NotificationPromo notification_promo(profile_);
171 notification_promo.InitFromJson(parsed_json, kValidPromoTypes[i]); 173 notification_promo.InitFromJson(parsed_json, kValidPromoTypes[i]);
172 if (notification_promo.new_notification()) 174 if (notification_promo.new_notification())
173 ScheduleNotification(notification_promo); 175 ScheduleNotification(notification_promo);
174 } 176 }
175 } 177 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698