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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 const double old_end = old_promo.end_; | 348 const double old_end = old_promo.end_; |
349 const std::string old_promo_text = old_promo.promo_text_; | 349 const std::string old_promo_text = old_promo.promo_text_; |
350 | 350 |
351 new_notification_ = | 351 new_notification_ = |
352 old_start != start_ || old_end != end_ || old_promo_text != promo_text_; | 352 old_start != start_ || old_end != end_ || old_promo_text != promo_text_; |
353 if (new_notification_) | 353 if (new_notification_) |
354 OnNewNotification(); | 354 OnNewNotification(); |
355 } | 355 } |
356 | 356 |
357 void NotificationPromo::OnNewNotification() { | 357 void NotificationPromo::OnNewNotification() { |
| 358 DVLOG(1) << "OnNewNotification"; |
358 // Create a new promo group. | 359 // Create a new promo group. |
359 group_ = base::RandInt(0, num_groups_ - 1); | 360 group_ = base::RandInt(0, num_groups_ - 1); |
360 WritePrefs(); | 361 WritePrefs(); |
361 } | 362 } |
362 | 363 |
363 // static | 364 // static |
364 void NotificationPromo::RegisterUserPrefs(PrefService* prefs) { | 365 void NotificationPromo::RegisterUserPrefs(PrefService* prefs) { |
365 ClearDeprecatedPrefs(prefs); | 366 ClearDeprecatedPrefs(prefs); |
366 prefs->RegisterDictionaryPref("promo", | 367 prefs->RegisterDictionaryPref("promo", |
367 new base::DictionaryValue, | 368 new base::DictionaryValue, |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 if (group_ < initial_segment_) | 505 if (group_ < initial_segment_) |
505 return start_; | 506 return start_; |
506 return start_ + | 507 return start_ + |
507 std::ceil(static_cast<float>(group_ - initial_segment_ + 1) / increment_) | 508 std::ceil(static_cast<float>(group_ - initial_segment_ + 1) / increment_) |
508 * time_slice_; | 509 * time_slice_; |
509 } | 510 } |
510 | 511 |
511 double NotificationPromo::EndTime() const { | 512 double NotificationPromo::EndTime() const { |
512 return end_; | 513 return end_; |
513 } | 514 } |
OLD | NEW |