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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 } | 309 } |
310 | 310 |
311 void NotificationPromo::OnNewNotification() { | 311 void NotificationPromo::OnNewNotification() { |
312 DVLOG(1) << "OnNewNotification"; | 312 DVLOG(1) << "OnNewNotification"; |
313 // Create a new promo group. | 313 // Create a new promo group. |
314 group_ = base::RandInt(0, num_groups_ - 1); | 314 group_ = base::RandInt(0, num_groups_ - 1); |
315 WritePrefs(); | 315 WritePrefs(); |
316 } | 316 } |
317 | 317 |
318 // static | 318 // static |
319 void NotificationPromo::RegisterUserPrefs(PrefService* prefs) { | 319 void NotificationPromo::RegisterUserPrefs(PrefServiceSyncable* prefs) { |
320 prefs->RegisterDictionaryPref(kPrefPromoObject, | 320 prefs->RegisterDictionaryPref(kPrefPromoObject, |
321 new base::DictionaryValue, | 321 new base::DictionaryValue, |
322 PrefService::UNSYNCABLE_PREF); | 322 PrefServiceSyncable::UNSYNCABLE_PREF); |
323 } | 323 } |
324 | 324 |
325 void NotificationPromo::WritePrefs() { | 325 void NotificationPromo::WritePrefs() { |
326 base::DictionaryValue* ntp_promo = new base::DictionaryValue; | 326 base::DictionaryValue* ntp_promo = new base::DictionaryValue; |
327 ntp_promo->SetString(kPrefPromoText, promo_text_); | 327 ntp_promo->SetString(kPrefPromoText, promo_text_); |
328 ntp_promo->Set(kPrefPromoPayload, promo_payload_->DeepCopy()); | 328 ntp_promo->Set(kPrefPromoPayload, promo_payload_->DeepCopy()); |
329 ntp_promo->SetDouble(kPrefPromoStart, start_); | 329 ntp_promo->SetDouble(kPrefPromoStart, start_); |
330 ntp_promo->SetDouble(kPrefPromoEnd, end_); | 330 ntp_promo->SetDouble(kPrefPromoEnd, end_); |
331 | 331 |
332 ntp_promo->SetInteger(kPrefPromoNumGroups, num_groups_); | 332 ntp_promo->SetInteger(kPrefPromoNumGroups, num_groups_); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 if (group_ < initial_segment_) | 452 if (group_ < initial_segment_) |
453 return start_; | 453 return start_; |
454 return start_ + | 454 return start_ + |
455 std::ceil(static_cast<float>(group_ - initial_segment_ + 1) / increment_) | 455 std::ceil(static_cast<float>(group_ - initial_segment_ + 1) / increment_) |
456 * time_slice_; | 456 * time_slice_; |
457 } | 457 } |
458 | 458 |
459 double NotificationPromo::EndTime() const { | 459 double NotificationPromo::EndTime() const { |
460 return end_; | 460 return end_; |
461 } | 461 } |
OLD | NEW |