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

Side by Side Diff: chrome/browser/web_resource/notification_promo.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, 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) 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/notification_promo.h" 5 #include "chrome/browser/web_resource/notification_promo.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 group_ = base::RandInt(0, num_groups_ - 1); 308 group_ = base::RandInt(0, num_groups_ - 1);
309 WritePrefs(); 309 WritePrefs();
310 } 310 }
311 311
312 // static 312 // static
313 void NotificationPromo::RegisterPrefs(PrefRegistrySimple* registry) { 313 void NotificationPromo::RegisterPrefs(PrefRegistrySimple* registry) {
314 registry->RegisterDictionaryPref(kPrefPromoObject); 314 registry->RegisterDictionaryPref(kPrefPromoObject);
315 } 315 }
316 316
317 // static 317 // static
318 void NotificationPromo::RegisterUserPrefs(PrefService* prefs, 318 void NotificationPromo::RegisterUserPrefs(PrefRegistrySyncable* registry) {
319 PrefRegistrySyncable* registry) { 319 // TODO(dbeam): Registered only for migration. Remove in M28 when
320 // TODO(dbeam): Remove in M28 when we're reasonably sure all prefs are gone. 320 // we're reasonably sure all prefs are gone.
321 // http://crbug.com/168887 321 // http://crbug.com/168887
322 // TODO(joi): Remove PrefService parameter; move this to migration code.
323 registry->RegisterDictionaryPref(kPrefPromoObject, 322 registry->RegisterDictionaryPref(kPrefPromoObject,
324 PrefRegistrySyncable::UNSYNCABLE_PREF); 323 PrefRegistrySyncable::UNSYNCABLE_PREF);
325 prefs->ClearPref(kPrefPromoObject); 324 }
325
326 // static
327 void NotificationPromo::MigrateUserPrefs(PrefService* user_prefs) {
328 user_prefs->ClearPref(kPrefPromoObject);
326 } 329 }
327 330
328 void NotificationPromo::WritePrefs() { 331 void NotificationPromo::WritePrefs() {
329 base::DictionaryValue* ntp_promo = new base::DictionaryValue; 332 base::DictionaryValue* ntp_promo = new base::DictionaryValue;
330 ntp_promo->SetString(kPrefPromoText, promo_text_); 333 ntp_promo->SetString(kPrefPromoText, promo_text_);
331 ntp_promo->Set(kPrefPromoPayload, promo_payload_->DeepCopy()); 334 ntp_promo->Set(kPrefPromoPayload, promo_payload_->DeepCopy());
332 ntp_promo->SetDouble(kPrefPromoStart, start_); 335 ntp_promo->SetDouble(kPrefPromoStart, start_);
333 ntp_promo->SetDouble(kPrefPromoEnd, end_); 336 ntp_promo->SetDouble(kPrefPromoEnd, end_);
334 337
335 ntp_promo->SetInteger(kPrefPromoNumGroups, num_groups_); 338 ntp_promo->SetInteger(kPrefPromoNumGroups, num_groups_);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 if (group_ < initial_segment_) 449 if (group_ < initial_segment_)
447 return start_; 450 return start_;
448 return start_ + 451 return start_ +
449 std::ceil(static_cast<float>(group_ - initial_segment_ + 1) / increment_) 452 std::ceil(static_cast<float>(group_ - initial_segment_ + 1) / increment_)
450 * time_slice_; 453 * time_slice_;
451 } 454 }
452 455
453 double NotificationPromo::EndTime() const { 456 double NotificationPromo::EndTime() const {
454 return end_; 457 return end_;
455 } 458 }
OLDNEW
« no previous file with comments | « chrome/browser/web_resource/notification_promo.h ('k') | chrome/browser/web_resource/promo_resource_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698