| 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" |
| 11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
| 12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/sys_info.h" | 14 #include "base/sys_info.h" |
| 15 #include "base/threading/thread_restrictions.h" | 15 #include "base/threading/thread_restrictions.h" |
| 16 #include "base/time.h" | 16 #include "base/time.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/prefs/pref_registry_simple.h" |
| 19 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_service.h" |
| 20 #include "chrome/browser/prefs/pref_service_simple.h" | |
| 21 #include "chrome/browser/prefs/pref_service_syncable.h" | 21 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 22 #include "chrome/browser/web_resource/promo_resource_service.h" | 22 #include "chrome/browser/web_resource/promo_resource_service.h" |
| 23 #include "chrome/common/chrome_version_info.h" | 23 #include "chrome/common/chrome_version_info.h" |
| 24 #include "chrome/common/net/url_util.h" | 24 #include "chrome/common/net/url_util.h" |
| 25 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
| 26 #include "content/public/browser/user_metrics.h" | 26 #include "content/public/browser/user_metrics.h" |
| 27 #include "googleurl/src/gurl.h" | 27 #include "googleurl/src/gurl.h" |
| 28 | 28 |
| 29 #if defined(OS_ANDROID) | 29 #if defined(OS_ANDROID) |
| 30 #include "base/command_line.h" | 30 #include "base/command_line.h" |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 } | 305 } |
| 306 | 306 |
| 307 void NotificationPromo::OnNewNotification() { | 307 void NotificationPromo::OnNewNotification() { |
| 308 DVLOG(1) << "OnNewNotification"; | 308 DVLOG(1) << "OnNewNotification"; |
| 309 // Create a new promo group. | 309 // Create a new promo group. |
| 310 group_ = base::RandInt(0, num_groups_ - 1); | 310 group_ = base::RandInt(0, num_groups_ - 1); |
| 311 WritePrefs(); | 311 WritePrefs(); |
| 312 } | 312 } |
| 313 | 313 |
| 314 // static | 314 // static |
| 315 void NotificationPromo::RegisterPrefs(PrefServiceSimple* local_state) { | 315 void NotificationPromo::RegisterPrefs(PrefRegistrySimple* registry) { |
| 316 local_state->RegisterDictionaryPref(kPrefPromoObject); | 316 registry->RegisterDictionaryPref(kPrefPromoObject); |
| 317 } | 317 } |
| 318 | 318 |
| 319 // static | 319 // static |
| 320 void NotificationPromo::RegisterUserPrefs(PrefServiceSyncable* prefs) { | 320 void NotificationPromo::RegisterUserPrefs(PrefServiceSyncable* prefs) { |
| 321 // TODO(dbeam): Remove in M28 when we're reasonably sure all prefs are gone. | 321 // TODO(dbeam): Remove in M28 when we're reasonably sure all prefs are gone. |
| 322 // http://crbug.com/168887 | 322 // http://crbug.com/168887 |
| 323 prefs->RegisterDictionaryPref(kPrefPromoObject, | 323 prefs->RegisterDictionaryPref(kPrefPromoObject, |
| 324 PrefServiceSyncable::UNSYNCABLE_PREF); | 324 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 325 prefs->ClearPref(kPrefPromoObject); | 325 prefs->ClearPref(kPrefPromoObject); |
| 326 } | 326 } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 if (group_ < initial_segment_) | 446 if (group_ < initial_segment_) |
| 447 return start_; | 447 return start_; |
| 448 return start_ + | 448 return start_ + |
| 449 std::ceil(static_cast<float>(group_ - initial_segment_ + 1) / increment_) | 449 std::ceil(static_cast<float>(group_ - initial_segment_ + 1) / increment_) |
| 450 * time_slice_; | 450 * time_slice_; |
| 451 } | 451 } |
| 452 | 452 |
| 453 double NotificationPromo::EndTime() const { | 453 double NotificationPromo::EndTime() const { |
| 454 return end_; | 454 return end_; |
| 455 } | 455 } |
| OLD | NEW |