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

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

Issue 12320064: Fix prefs registration in promo code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge LKGR Created 7 years, 9 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
« no previous file with comments | « chrome/browser/web_resource/promo_resource_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/prefs/pref_registry_simple.h" 10 #include "base/prefs/pref_registry_simple.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 } // namespace 62 } // namespace
63 63
64 // static 64 // static
65 void PromoResourceService::RegisterPrefs(PrefRegistrySimple* registry) { 65 void PromoResourceService::RegisterPrefs(PrefRegistrySimple* registry) {
66 registry->RegisterStringPref(prefs::kNtpPromoResourceCacheUpdate, "0"); 66 registry->RegisterStringPref(prefs::kNtpPromoResourceCacheUpdate, "0");
67 NotificationPromo::RegisterPrefs(registry); 67 NotificationPromo::RegisterPrefs(registry);
68 } 68 }
69 69
70 // static 70 // static
71 void PromoResourceService::RegisterUserPrefs(PrefService* prefs, 71 void PromoResourceService::RegisterUserPrefs(PrefRegistrySyncable* registry) {
72 PrefRegistrySyncable* registry) { 72 // TODO(dbeam): This is registered only for migration; remove in M28
73 // TODO(dbeam): remove in M28 when all prefs have been cleared. 73 // when all prefs have been cleared. http://crbug.com/168887
74 // http://crbug.com/168887
75 // TODO(joi): Remove PrefService parameter; move this to migration code.
76 registry->RegisterStringPref(prefs::kNtpPromoResourceCacheUpdate, 74 registry->RegisterStringPref(prefs::kNtpPromoResourceCacheUpdate,
77 "0", 75 "0",
78 PrefRegistrySyncable::UNSYNCABLE_PREF); 76 PrefRegistrySyncable::UNSYNCABLE_PREF);
79 prefs->ClearPref(prefs::kNtpPromoResourceCacheUpdate); 77 NotificationPromo::RegisterUserPrefs(registry);
80 NotificationPromo::RegisterUserPrefs(prefs, registry); 78 }
79
80 // static
81 void PromoResourceService::MigrateUserPrefs(PrefService* user_prefs) {
82 user_prefs->ClearPref(prefs::kNtpPromoResourceCacheUpdate);
83 NotificationPromo::MigrateUserPrefs(user_prefs);
81 } 84 }
82 85
83 PromoResourceService::PromoResourceService() 86 PromoResourceService::PromoResourceService()
84 : WebResourceService(g_browser_process->local_state(), 87 : WebResourceService(g_browser_process->local_state(),
85 GetPromoResourceURL(), 88 GetPromoResourceURL(),
86 true, // append locale to URL 89 true, // append locale to URL
87 prefs::kNtpPromoResourceCacheUpdate, 90 prefs::kNtpPromoResourceCacheUpdate,
88 kStartResourceFetchDelay, 91 kStartResourceFetchDelay,
89 GetCacheUpdateDelay()), 92 GetCacheUpdateDelay()),
90 ALLOW_THIS_IN_INITIALIZER_LIST( 93 ALLOW_THIS_IN_INITIALIZER_LIST(
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 167 }
165 168
166 void PromoResourceService::Unpack(const DictionaryValue& parsed_json) { 169 void PromoResourceService::Unpack(const DictionaryValue& parsed_json) {
167 for (size_t i = 0; i < arraysize(kValidPromoTypes); ++i) { 170 for (size_t i = 0; i < arraysize(kValidPromoTypes); ++i) {
168 NotificationPromo notification_promo; 171 NotificationPromo notification_promo;
169 notification_promo.InitFromJson(parsed_json, kValidPromoTypes[i]); 172 notification_promo.InitFromJson(parsed_json, kValidPromoTypes[i]);
170 if (notification_promo.new_notification()) 173 if (notification_promo.new_notification())
171 ScheduleNotification(notification_promo); 174 ScheduleNotification(notification_promo);
172 } 175 }
173 } 176 }
OLDNEW
« no previous file with comments | « chrome/browser/web_resource/promo_resource_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698