Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(462)

Side by Side Diff: chrome/browser/web_resource/notification_promo.cc

Issue 8520009: Only show G+ promo for users logged into G+ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 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/web_resource/notification_promo.h" 5 #include "chrome/browser/web_resource/notification_promo.h"
6 6
7 #include "base/bind.h"
7 #include "base/rand_util.h" 8 #include "base/rand_util.h"
8 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_split.h"
9 #include "base/time.h" 11 #include "base/time.h"
10 #include "base/values.h" 12 #include "base/values.h"
11 #include "chrome/browser/prefs/pref_service.h" 13 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/browser/profiles/profile_impl.h"
12 #include "chrome/browser/web_resource/promo_resource_service.h" 15 #include "chrome/browser/web_resource/promo_resource_service.h"
13 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
17 #include "googleurl/src/gurl.h"
18 #include "net/base/cookie_store.h"
19 #include "net/url_request/url_request_context.h"
14 20
15 namespace { 21 namespace {
16 22
17 // Maximum number of views. 23 // Maximum number of views.
18 static const int kMaxViews = 1000; 24 static const int kMaxViews = 1000;
19 25
20 // Maximum number of hours for each time slice (4 weeks). 26 // Maximum number of hours for each time slice (4 weeks).
21 static const int kMaxTimeSliceHours = 24 * 7 * 4; 27 static const int kMaxTimeSliceHours = 24 * 7 * 4;
22 28
23 bool OutOfBounds(int var, int min, int max) { 29 bool OutOfBounds(int var, int min, int max) {
24 return var < min || var > max; 30 return var < min || var > max;
25 } 31 }
26 32
27 static const char kHeaderProperty[] = "topic"; 33 static const char kHeaderProperty[] = "topic";
28 static const char kArrayProperty[] = "answers"; 34 static const char kArrayProperty[] = "answers";
29 static const char kIdentifierProperty[] = "name"; 35 static const char kIdentifierProperty[] = "name";
30 static const char kStartPropertyValue[] = "promo_start"; 36 static const char kStartPropertyValue[] = "promo_start";
31 static const char kEndPropertyValue[] = "promo_end"; 37 static const char kEndPropertyValue[] = "promo_end";
32 static const char kTextProperty[] = "tooltip"; 38 static const char kTextProperty[] = "tooltip";
33 static const char kTimeProperty[] = "inproduct"; 39 static const char kTimeProperty[] = "inproduct";
34 static const char kParamsProperty[] = "question"; 40 static const char kParamsProperty[] = "question";
35 41
42 static const char kGPlusDomainUrl[] = "http://plus.google.com/";
43 static const char kGPlusDomainSecureCookieId[] = "SID=";
44 static const char kSplitStringToken = ';';
45
36 // Time getters. 46 // Time getters.
37 double GetTimeFromDict(const DictionaryValue* dict) { 47 double GetTimeFromDict(const DictionaryValue* dict) {
38 std::string time_str; 48 std::string time_str;
39 if (!dict->GetString(kTimeProperty, &time_str)) 49 if (!dict->GetString(kTimeProperty, &time_str))
40 return 0.0; 50 return 0.0;
41 51
42 base::Time time; 52 base::Time time;
43 if (time_str.empty() || !base::Time::FromString(time_str.c_str(), &time)) 53 if (time_str.empty() || !base::Time::FromString(time_str.c_str(), &time))
44 return 0.0; 54 return 0.0;
45 55
46 return time.ToDoubleT(); 56 return time.ToDoubleT();
47 } 57 }
48 58
49 double GetTimeFromPrefs(PrefService* prefs, const char* pref) { 59 double GetTimeFromPrefs(PrefService* prefs, const char* pref) {
50 return prefs->HasPrefPath(pref) ? prefs->GetDouble(pref) : 0.0; 60 return prefs->HasPrefPath(pref) ? prefs->GetDouble(pref) : 0.0;
51 } 61 }
52 62
53 } // namespace 63 } // namespace
54 64
55 NotificationPromo::NotificationPromo(PrefService* prefs, Delegate* delegate) 65 NotificationPromo::NotificationPromo(Profile* profile, Delegate* delegate)
56 : prefs_(prefs), 66 : profile_(profile),
57 delegate_(delegate), 67 delegate_(delegate),
68 prefs_(profile_->GetPrefs()),
58 start_(0.0), 69 start_(0.0),
59 end_(0.0), 70 end_(0.0),
60 build_(PromoResourceService::NO_BUILD), 71 build_(PromoResourceService::NO_BUILD),
61 time_slice_(0), 72 time_slice_(0),
62 max_group_(0), 73 max_group_(0),
63 max_views_(0), 74 max_views_(0),
64 platform_(PLATFORM_NONE), 75 platform_(PLATFORM_NONE),
65 group_(0), 76 group_(0),
66 views_(0), 77 views_(0),
67 text_(), 78 text_(),
68 closed_(false) { 79 closed_(false),
69 DCHECK(prefs); 80 gplus_(false),
81 feature_mask_(0) {
82 DCHECK(profile);
83 DCHECK(prefs_);
70 } 84 }
71 85
72 void NotificationPromo::InitFromJson(const DictionaryValue& json) { 86 NotificationPromo::~NotificationPromo() {}
87
88 void NotificationPromo::InitFromJson(const DictionaryValue& json,
89 bool do_cookie_check) {
73 DictionaryValue* dict; 90 DictionaryValue* dict;
74 if (json.GetDictionary(kHeaderProperty, &dict)) { 91 if (json.GetDictionary(kHeaderProperty, &dict)) {
75 ListValue* answers; 92 ListValue* answers;
76 if (dict->GetList(kArrayProperty, &answers)) { 93 if (dict->GetList(kArrayProperty, &answers)) {
77 for (ListValue::const_iterator it = answers->begin(); 94 for (ListValue::const_iterator it = answers->begin();
78 it != answers->end(); 95 it != answers->end();
79 ++it) { 96 ++it) {
80 if ((*it)->IsType(Value::TYPE_DICTIONARY)) 97 if ((*it)->IsType(Value::TYPE_DICTIONARY))
81 Parse(static_cast<DictionaryValue*>(*it)); 98 Parse(static_cast<DictionaryValue*>(*it));
82 } 99 }
83 } 100 }
84 } 101 }
102 if (do_cookie_check) {
103 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
104 base::Bind(&NotificationPromo::GetCookies, this,
105 profile_->GetRequestContext()));
106 } else {
107 CheckForNewNotification(false);
108 }
109 }
85 110
86 CheckForNewNotification(); 111 bool NotificationPromo::CheckForGPlusCookie(const std::string& cookies) {
112 std::vector<std::string> cookie_list;
achuithb 2011/11/27 07:48:26 Could you please add a DCHECK for the IO thread he
Cait (Slow) 2011/11/28 19:06:25 Right now I'm calling this method directly in my u
achuithb 2011/11/28 21:21:22 Ok, that's fine.
113 base::SplitString(cookies, kSplitStringToken, &cookie_list);
114 for (std::vector<std::string>::const_iterator current = cookie_list.begin();
115 current != cookie_list.end();
116 ++current) {
117 if ((*current).find(kGPlusDomainSecureCookieId) == 0) {
118 return true;
119 }
120 }
121 return false;
122 }
123
124 void NotificationPromo::GetCookiesCallback(const std::string& cookies) {
125 bool found_cookie = CheckForGPlusCookie(cookies);
achuithb 2011/11/27 07:48:26 Could you please add a DCHECK for the IO thread he
Cait (Slow) 2011/11/28 19:06:25 Done.
126 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
127 base::Bind(&NotificationPromo::CheckForNewNotification, this,
128 found_cookie));
129 }
130
131 void NotificationPromo::GetCookies(net::URLRequestContextGetter* getter) {
132 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
133 getter->GetURLRequestContext()->cookie_store()->
134 GetCookiesWithOptionsAsync(
135 GURL(kGPlusDomainUrl), net::CookieOptions(),
136 base::Bind(&NotificationPromo::GetCookiesCallback, this));
87 } 137 }
88 138
89 void NotificationPromo::Parse(const DictionaryValue* dict) { 139 void NotificationPromo::Parse(const DictionaryValue* dict) {
90 std::string key; 140 std::string key;
91 if (dict->GetString(kIdentifierProperty, &key)) { 141 if (dict->GetString(kIdentifierProperty, &key)) {
92 if (key == kStartPropertyValue) { 142 if (key == kStartPropertyValue) {
93 ParseParams(dict); 143 ParseParams(dict);
94 dict->GetString(kTextProperty, &text_); 144 dict->GetString(kTextProperty, &text_);
95 start_ = GetTimeFromDict(dict); 145 start_ = GetTimeFromDict(dict);
96 } else if (key == kEndPropertyValue) { 146 } else if (key == kEndPropertyValue) {
97 end_ = GetTimeFromDict(dict); 147 end_ = GetTimeFromDict(dict);
98 } 148 }
99 } 149 }
100 } 150 }
101 151
102 void NotificationPromo::ParseParams(const DictionaryValue* dict) { 152 void NotificationPromo::ParseParams(const DictionaryValue* dict) {
103 std::string question; 153 std::string question;
104 if (!dict->GetString(kParamsProperty, &question)) 154 if (!dict->GetString(kParamsProperty, &question))
105 return; 155 return;
106 156
107 size_t index = 0; 157 size_t index = 0;
108 bool err = false; 158 bool err = false;
109 159
110 build_ = GetNextQuestionValue(question, &index, &err); 160 build_ = GetNextQuestionValue(question, &index, &err);
111 time_slice_ = GetNextQuestionValue(question, &index, &err); 161 time_slice_ = GetNextQuestionValue(question, &index, &err);
112 max_group_ = GetNextQuestionValue(question, &index, &err); 162 max_group_ = GetNextQuestionValue(question, &index, &err);
113 max_views_ = GetNextQuestionValue(question, &index, &err); 163 max_views_ = GetNextQuestionValue(question, &index, &err);
114 platform_ = GetNextQuestionValue(question, &index, &err); 164 platform_ = GetNextQuestionValue(question, &index, &err);
165 feature_mask_ = GetNextQuestionValue(question, &index, &err);
115 166
116 if (err || 167 if (err ||
117 OutOfBounds(build_, PromoResourceService::NO_BUILD, 168 OutOfBounds(build_, PromoResourceService::NO_BUILD,
118 PromoResourceService::ALL_BUILDS) || 169 PromoResourceService::ALL_BUILDS) ||
119 OutOfBounds(time_slice_, 0, kMaxTimeSliceHours) || 170 OutOfBounds(time_slice_, 0, kMaxTimeSliceHours) ||
120 OutOfBounds(max_group_, 0, kMaxGroupSize) || 171 OutOfBounds(max_group_, 0, kMaxGroupSize) ||
121 OutOfBounds(max_views_, 0, kMaxViews) || 172 OutOfBounds(max_views_, 0, kMaxViews) ||
122 OutOfBounds(platform_, PLATFORM_NONE, PLATFORM_ALL)) { 173 OutOfBounds(platform_, PLATFORM_NONE, PLATFORM_ALL)) {
123 // If values are not valid, do not show promo notification. 174 // If values are not valid, do not show promo notification.
124 DLOG(ERROR) << "Invalid server data, question=" << question << 175 DLOG(ERROR) << "Invalid server data, question=" << question <<
125 ", build=" << build_ << 176 ", build=" << build_ <<
126 ", time_slice=" << time_slice_ << 177 ", time_slice=" << time_slice_ <<
127 ", max_group=" << max_group_ << 178 ", max_group=" << max_group_ <<
128 ", max_views=" << max_views_ << 179 ", max_views=" << max_views_ <<
129 ", platform_=" << platform_; 180 ", platform_=" << platform_ <<
181 ", feature_mask=" << feature_mask_;
130 build_ = PromoResourceService::NO_BUILD; 182 build_ = PromoResourceService::NO_BUILD;
131 time_slice_ = 0; 183 time_slice_ = 0;
132 max_group_ = 0; 184 max_group_ = 0;
133 max_views_ = 0; 185 max_views_ = 0;
134 platform_ = PLATFORM_NONE; 186 platform_ = PLATFORM_NONE;
187 feature_mask_ = 0;
135 } 188 }
136 } 189 }
137 190
138 void NotificationPromo::CheckForNewNotification() { 191 void NotificationPromo::CheckForNewNotification(bool found_cookie) {
192 gplus_ = found_cookie;
139 const double old_start = GetTimeFromPrefs(prefs_, prefs::kNTPPromoStart); 193 const double old_start = GetTimeFromPrefs(prefs_, prefs::kNTPPromoStart);
140 const double old_end = GetTimeFromPrefs(prefs_, prefs::kNTPPromoEnd); 194 const double old_end = GetTimeFromPrefs(prefs_, prefs::kNTPPromoEnd);
achuithb 2011/11/27 07:48:26 Add 2 more variables here: double start = 0.0, end
Cait (Slow) 2011/11/28 19:06:25 Done.
141 const bool has_platform = prefs_->HasPrefPath(prefs::kNTPPromoPlatform); 195 const bool has_platform = prefs_->HasPrefPath(prefs::kNTPPromoPlatform);
achuithb 2011/11/27 07:48:26 Don't think has_platform is necessary any longer..
Cait (Slow) 2011/11/28 19:06:25 Really? All the platform-related code showed up wh
achuithb 2011/11/28 21:21:22 The platform code is still there. We only need to
Cait (Slow) 2011/11/29 00:12:27 Done.
142 196
197 const bool old_gplus = prefs_->GetBoolean(prefs::kNTPPromoIsLoggedInToPlus);
198 const int old_feature_mask = prefs_->GetInteger(prefs::kNTPPromoFeatureMask);
achuithb 2011/11/28 21:21:22 This should be: const bool has_feature_mask = pref
Cait (Slow) 2011/11/29 00:12:27 Done.
143 // Trigger a new notification if the times have changed, or if 199 // Trigger a new notification if the times have changed, or if
144 // we previously never wrote out a platform preference. This handles 200 // we previously never wrote out a feature_mask or platform preference, or
145 // the case where we update to a new client in the middle of a promo. 201 // if the user's gplus cookies have changed.
146 if (old_start != start_ || old_end != end_ || !has_platform) 202 if (old_start != start_ || old_end != end_ || old_gplus != gplus_ ||
203 old_feature_mask != feature_mask_ || !has_platform) {
achuithb 2011/11/28 21:21:22 This line should be !has_feature_mask) {
Cait (Slow) 2011/11/29 00:12:27 Done.
147 OnNewNotification(); 204 OnNewNotification();
205 if (delegate_)
206 delegate_->OnNotificationParsed(StartTimeWithOffset(), end_);
207 } else if (delegate_) {
208 // If no change needed, call delegate with default values (this
209 // is for testing purposes).
210 delegate_->OnNotificationParsed(0.0, 0.0);
211 }
148 } 212 }
149 213
150 void NotificationPromo::OnNewNotification() { 214 void NotificationPromo::OnNewNotification() {
151 group_ = NewGroup(); 215 group_ = NewGroup();
152 WritePrefs(); 216 WritePrefs();
153 if (delegate_)
154 delegate_->OnNewNotification(StartTimeWithOffset(), end_);
155 } 217 }
156 218
157 // static 219 // static
158 int NotificationPromo::NewGroup() { 220 int NotificationPromo::NewGroup() {
159 return base::RandInt(0, kMaxGroupSize); 221 return base::RandInt(0, kMaxGroupSize);
160 } 222 }
161 223
162 // static 224 // static
163 void NotificationPromo::RegisterUserPrefs(PrefService* prefs) { 225 void NotificationPromo::RegisterUserPrefs(PrefService* prefs) {
164 prefs->RegisterDoublePref(prefs::kNTPPromoStart, 226 prefs->RegisterDoublePref(prefs::kNTPPromoStart,
(...skipping 24 matching lines...) Expand all
189 PrefService::UNSYNCABLE_PREF); 251 PrefService::UNSYNCABLE_PREF);
190 prefs->RegisterIntegerPref(prefs::kNTPPromoGroup, 252 prefs->RegisterIntegerPref(prefs::kNTPPromoGroup,
191 0, 253 0,
192 PrefService::UNSYNCABLE_PREF); 254 PrefService::UNSYNCABLE_PREF);
193 prefs->RegisterIntegerPref(prefs::kNTPPromoViews, 255 prefs->RegisterIntegerPref(prefs::kNTPPromoViews,
194 0, 256 0,
195 PrefService::UNSYNCABLE_PREF); 257 PrefService::UNSYNCABLE_PREF);
196 prefs->RegisterBooleanPref(prefs::kNTPPromoClosed, 258 prefs->RegisterBooleanPref(prefs::kNTPPromoClosed,
197 false, 259 false,
198 PrefService::UNSYNCABLE_PREF); 260 PrefService::UNSYNCABLE_PREF);
261 prefs->RegisterBooleanPref(prefs::kNTPPromoIsLoggedInToPlus,
262 false,
263 PrefService::UNSYNCABLE_PREF);
264 prefs->RegisterIntegerPref(prefs::kNTPPromoFeatureMask,
265 0,
266 PrefService::UNSYNCABLE_PREF);
199 } 267 }
200 268
269 // static
270 NotificationPromo* NotificationPromo::Factory(Profile *profile,
271 NotificationPromo::Delegate * delegate) {
272 return new NotificationPromo(profile, delegate);
273 }
201 274
202 void NotificationPromo::WritePrefs() { 275 void NotificationPromo::WritePrefs() {
203 prefs_->SetDouble(prefs::kNTPPromoStart, start_); 276 prefs_->SetDouble(prefs::kNTPPromoStart, start_);
204 prefs_->SetDouble(prefs::kNTPPromoEnd, end_); 277 prefs_->SetDouble(prefs::kNTPPromoEnd, end_);
205 278
206 prefs_->SetInteger(prefs::kNTPPromoBuild, build_); 279 prefs_->SetInteger(prefs::kNTPPromoBuild, build_);
207 prefs_->SetInteger(prefs::kNTPPromoGroupTimeSlice, time_slice_); 280 prefs_->SetInteger(prefs::kNTPPromoGroupTimeSlice, time_slice_);
208 prefs_->SetInteger(prefs::kNTPPromoGroupMax, max_group_); 281 prefs_->SetInteger(prefs::kNTPPromoGroupMax, max_group_);
209 prefs_->SetInteger(prefs::kNTPPromoViewsMax, max_views_); 282 prefs_->SetInteger(prefs::kNTPPromoViewsMax, max_views_);
210 prefs_->SetInteger(prefs::kNTPPromoPlatform, platform_); 283 prefs_->SetInteger(prefs::kNTPPromoPlatform, platform_);
211 284
212 prefs_->SetString(prefs::kNTPPromoLine, text_); 285 prefs_->SetString(prefs::kNTPPromoLine, text_);
213 prefs_->SetInteger(prefs::kNTPPromoGroup, group_); 286 prefs_->SetInteger(prefs::kNTPPromoGroup, group_);
214 prefs_->SetInteger(prefs::kNTPPromoViews, views_); 287 prefs_->SetInteger(prefs::kNTPPromoViews, views_);
215 prefs_->SetBoolean(prefs::kNTPPromoClosed, closed_); 288 prefs_->SetBoolean(prefs::kNTPPromoClosed, closed_);
289 prefs_->SetBoolean(prefs::kNTPPromoIsLoggedInToPlus, gplus_);
290 prefs_->SetInteger(prefs::kNTPPromoFeatureMask, feature_mask_);
216 } 291 }
217 292
218 void NotificationPromo::InitFromPrefs() { 293 void NotificationPromo::InitFromPrefs() {
219 start_ = prefs_->GetDouble(prefs::kNTPPromoStart); 294 start_ = prefs_->GetDouble(prefs::kNTPPromoStart);
220 end_ = prefs_->GetDouble(prefs::kNTPPromoEnd); 295 end_ = prefs_->GetDouble(prefs::kNTPPromoEnd);
221 build_ = prefs_->GetInteger(prefs::kNTPPromoBuild); 296 build_ = prefs_->GetInteger(prefs::kNTPPromoBuild);
222 time_slice_ = prefs_->GetInteger(prefs::kNTPPromoGroupTimeSlice); 297 time_slice_ = prefs_->GetInteger(prefs::kNTPPromoGroupTimeSlice);
223 max_group_ = prefs_->GetInteger(prefs::kNTPPromoGroupMax); 298 max_group_ = prefs_->GetInteger(prefs::kNTPPromoGroupMax);
224 max_views_ = prefs_->GetInteger(prefs::kNTPPromoViewsMax); 299 max_views_ = prefs_->GetInteger(prefs::kNTPPromoViewsMax);
225 platform_ = prefs_->GetInteger(prefs::kNTPPromoPlatform); 300 platform_ = prefs_->GetInteger(prefs::kNTPPromoPlatform);
226 text_ = prefs_->GetString(prefs::kNTPPromoLine); 301 text_ = prefs_->GetString(prefs::kNTPPromoLine);
227 group_ = prefs_->GetInteger(prefs::kNTPPromoGroup); 302 group_ = prefs_->GetInteger(prefs::kNTPPromoGroup);
228 views_ = prefs_->GetInteger(prefs::kNTPPromoViews); 303 views_ = prefs_->GetInteger(prefs::kNTPPromoViews);
229 closed_ = prefs_->GetBoolean(prefs::kNTPPromoClosed); 304 closed_ = prefs_->GetBoolean(prefs::kNTPPromoClosed);
305
306 if (prefs_->HasPrefPath(prefs::kNTPPromoIsLoggedInToPlus))
307 gplus_ = prefs_->GetBoolean(prefs::kNTPPromoIsLoggedInToPlus);
308
309 if (prefs_->HasPrefPath(prefs::kNTPPromoFeatureMask))
310 feature_mask_ = prefs_->GetInteger(prefs::kNTPPromoFeatureMask);
230 } 311 }
231 312
232 bool NotificationPromo::CanShow() const { 313 bool NotificationPromo::CanShow() const {
233 return !closed_ && 314 return !closed_ &&
234 !text_.empty() && 315 !text_.empty() &&
235 group_ < max_group_ && 316 group_ < max_group_ &&
236 views_ < max_views_ && 317 views_ < max_views_ &&
237 IsPlatformAllowed(platform_) && 318 IsPlatformAllowed(platform_) &&
238 IsBuildAllowed(build_) && 319 IsBuildAllowed(build_) &&
239 base::Time::FromDoubleT(StartTimeWithOffset()) < base::Time::Now() && 320 base::Time::FromDoubleT(StartTimeWithOffset()) < base::Time::Now() &&
240 base::Time::FromDoubleT(end_) > base::Time::Now(); 321 base::Time::FromDoubleT(end_) > base::Time::Now() &&
322 (!(feature_mask_ & NotificationPromo::FEATURE_GPLUS) || gplus_);
achuithb 2011/11/27 07:48:26 I think it's better if the feature_mask has the in
Cait (Slow) 2011/11/28 19:06:25 If feature_mask_ is set to GPLUS, this means we ar
achuithb 2011/11/28 21:21:22 Ok, I misunderstood the use of this feature. I ass
241 } 323 }
242 324
243 void NotificationPromo::HandleClosed() { 325 void NotificationPromo::HandleClosed() {
244 prefs_->SetBoolean(prefs::kNTPPromoClosed, true); 326 prefs_->SetBoolean(prefs::kNTPPromoClosed, true);
245 } 327 }
246 328
247 bool NotificationPromo::HandleViewed() { 329 bool NotificationPromo::HandleViewed() {
248 if (prefs_->HasPrefPath(prefs::kNTPPromoViewsMax)) 330 if (prefs_->HasPrefPath(prefs::kNTPPromoViewsMax))
249 max_views_ = prefs_->GetInteger(prefs::kNTPPromoViewsMax); 331 max_views_ = prefs_->GetInteger(prefs::kNTPPromoViewsMax);
250 332
(...skipping 24 matching lines...) Expand all
275 // Order is important - OS_LINUX and OS_CHROMEOS can both be defined. 357 // Order is important - OS_LINUX and OS_CHROMEOS can both be defined.
276 #if defined(OS_WIN) 358 #if defined(OS_WIN)
277 return PLATFORM_WIN; 359 return PLATFORM_WIN;
278 #elif defined(OS_MACOSX) 360 #elif defined(OS_MACOSX)
279 return PLATFORM_MAC; 361 return PLATFORM_MAC;
280 #elif defined(OS_CHROMEOS) 362 #elif defined(OS_CHROMEOS)
281 return PLATFORM_CHROMEOS; 363 return PLATFORM_CHROMEOS;
282 #elif defined(OS_LINUX) 364 #elif defined(OS_LINUX)
283 return PLATFORM_LINUX; 365 return PLATFORM_LINUX;
284 #else 366 #else
285 return PLATFORM_NONE; 367 return PLATFORM_NONE;
286 #endif 368 #endif
287 } 369 }
288 370
289 double NotificationPromo::StartTimeWithOffset() const { 371 double NotificationPromo::StartTimeWithOffset() const {
290 // Adjust start using group and time slice, adjusted from hours to seconds. 372 // Adjust start using group and time slice, adjusted from hours to seconds.
291 static const double kSecondsInHour = 60.0 * 60.0; 373 static const double kSecondsInHour = 60.0 * 60.0;
292 return start_ + group_ * time_slice_ * kSecondsInHour; 374 return start_ + group_ * time_slice_ * kSecondsInHour;
293 } 375 }
294 376
295 // static 377 // static
(...skipping 19 matching lines...) Expand all
315 start_ == other.start_ && 397 start_ == other.start_ &&
316 end_ == other.end_ && 398 end_ == other.end_ &&
317 build_ == other.build_ && 399 build_ == other.build_ &&
318 time_slice_ == other.time_slice_ && 400 time_slice_ == other.time_slice_ &&
319 max_group_ == other.max_group_ && 401 max_group_ == other.max_group_ &&
320 max_views_ == other.max_views_ && 402 max_views_ == other.max_views_ &&
321 platform_ == other.platform_ && 403 platform_ == other.platform_ &&
322 group_ == other.group_ && 404 group_ == other.group_ &&
323 views_ == other.views_ && 405 views_ == other.views_ &&
324 text_ == other.text_ && 406 text_ == other.text_ &&
325 closed_ == other.closed_; 407 closed_ == other.closed_ &&
408 gplus_ == other.gplus_ &&
409 feature_mask_ == other.feature_mask_;
326 } 410 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698