OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/instant/promo_counter.h" | 5 #include "chrome/browser/instant/promo_counter.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 | 11 |
(...skipping 20 matching lines...) Expand all Loading... |
32 did_init_(false), | 32 did_init_(false), |
33 show_(false) { | 33 show_(false) { |
34 } | 34 } |
35 | 35 |
36 PromoCounter::~PromoCounter() { | 36 PromoCounter::~PromoCounter() { |
37 } | 37 } |
38 | 38 |
39 // static | 39 // static |
40 void PromoCounter::RegisterUserPrefs(PrefService* prefs, | 40 void PromoCounter::RegisterUserPrefs(PrefService* prefs, |
41 const std::string& base_key) { | 41 const std::string& base_key) { |
42 prefs->RegisterBooleanPref((base_key + kShowKey).c_str(), true); | 42 prefs->RegisterBooleanPref((base_key + kShowKey).c_str(), |
43 prefs->RegisterIntegerPref((base_key + kNumSessionsKey).c_str(), 0); | 43 true, |
44 prefs->RegisterInt64Pref((base_key + kInitialTimeKey).c_str(), 0); | 44 PrefService::UNSYNCABLE_PREF); |
| 45 prefs->RegisterIntegerPref((base_key + kNumSessionsKey).c_str(), |
| 46 0, |
| 47 PrefService::UNSYNCABLE_PREF); |
| 48 prefs->RegisterInt64Pref((base_key + kInitialTimeKey).c_str(), |
| 49 0, |
| 50 PrefService::UNSYNCABLE_PREF); |
45 } | 51 } |
46 | 52 |
47 bool PromoCounter::ShouldShow(base::Time current_time) { | 53 bool PromoCounter::ShouldShow(base::Time current_time) { |
48 if (!did_init_) { | 54 if (!did_init_) { |
49 did_init_ = true; | 55 did_init_ = true; |
50 Init(current_time); | 56 Init(current_time); |
51 } | 57 } |
52 | 58 |
53 if (show_ && (current_time - initial_show_).InDays() >= max_days_) | 59 if (show_ && (current_time - initial_show_).InDays() >= max_days_) |
54 MaxTimeLapsed(current_time); | 60 MaxTimeLapsed(current_time); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } | 112 } |
107 | 113 |
108 void PromoCounter::MaxTimeLapsed(base::Time current_time) { | 114 void PromoCounter::MaxTimeLapsed(base::Time current_time) { |
109 show_ = false; | 115 show_ = false; |
110 UMA_HISTOGRAM_CUSTOM_COUNTS(histogram_key_ + kHistogramMaxTime, | 116 UMA_HISTOGRAM_CUSTOM_COUNTS(histogram_key_ + kHistogramMaxTime, |
111 (current_time - initial_show_).InHours(), | 117 (current_time - initial_show_).InHours(), |
112 1, max_days_ * 24, 24); | 118 1, max_days_ * 24, 24); |
113 if (profile_->GetPrefs()) | 119 if (profile_->GetPrefs()) |
114 profile_->GetPrefs()->SetBoolean((pref_key_ + kShowKey).c_str(), false); | 120 profile_->GetPrefs()->SetBoolean((pref_key_ + kShowKey).c_str(), false); |
115 } | 121 } |
OLD | NEW |