| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |