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

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

Issue 8833009: Count of user dismissals of notification promo. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: move NTPPromoShown to notification_promo.cc 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
« no previous file with comments | « chrome/browser/ui/webui/ntp/ntp_resource_cache.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <vector>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/rand_util.h" 10 #include "base/rand_util.h"
9 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
10 #include "base/string_split.h" 12 #include "base/string_split.h"
11 #include "base/time.h" 13 #include "base/time.h"
12 #include "base/values.h" 14 #include "base/values.h"
13 #include "chrome/browser/prefs/pref_service.h" 15 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/browser/profiles/profile_impl.h" 16 #include "chrome/browser/profiles/profile_impl.h"
15 #include "chrome/browser/web_resource/promo_resource_service.h" 17 #include "chrome/browser/web_resource/promo_resource_service.h"
16 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
19 #include "content/browser/user_metrics.h"
17 #include "googleurl/src/gurl.h" 20 #include "googleurl/src/gurl.h"
18 #include "net/base/cookie_store.h" 21 #include "net/base/cookie_store.h"
19 #include "net/url_request/url_request_context.h" 22 #include "net/url_request/url_request_context.h"
20 23
21 namespace { 24 namespace {
22 25
23 // Maximum number of views. 26 // Maximum number of views.
24 static const int kMaxViews = 1000; 27 static const int kMaxViews = 1000;
25 28
26 // Maximum number of hours for each time slice (4 weeks). 29 // Maximum number of hours for each time slice (4 weeks).
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 group_ < max_group_ && 328 group_ < max_group_ &&
326 views_ < max_views_ && 329 views_ < max_views_ &&
327 IsPlatformAllowed(platform_) && 330 IsPlatformAllowed(platform_) &&
328 IsBuildAllowed(build_) && 331 IsBuildAllowed(build_) &&
329 base::Time::FromDoubleT(StartTimeWithOffset()) < base::Time::Now() && 332 base::Time::FromDoubleT(StartTimeWithOffset()) < base::Time::Now() &&
330 base::Time::FromDoubleT(end_) > base::Time::Now() && 333 base::Time::FromDoubleT(end_) > base::Time::Now() &&
331 (!(feature_mask_ & NotificationPromo::FEATURE_GPLUS) || gplus_); 334 (!(feature_mask_ & NotificationPromo::FEATURE_GPLUS) || gplus_);
332 } 335 }
333 336
334 void NotificationPromo::HandleClosed() { 337 void NotificationPromo::HandleClosed() {
338 UserMetrics::RecordAction(UserMetricsAction("NTPPromoClosed"));
335 prefs_->SetBoolean(prefs::kNTPPromoClosed, true); 339 prefs_->SetBoolean(prefs::kNTPPromoClosed, true);
336 } 340 }
337 341
338 bool NotificationPromo::HandleViewed() { 342 bool NotificationPromo::HandleViewed() {
343 UserMetrics::RecordAction(UserMetricsAction("NTPPromoShown"));
339 if (prefs_->HasPrefPath(prefs::kNTPPromoViewsMax)) 344 if (prefs_->HasPrefPath(prefs::kNTPPromoViewsMax))
340 max_views_ = prefs_->GetInteger(prefs::kNTPPromoViewsMax); 345 max_views_ = prefs_->GetInteger(prefs::kNTPPromoViewsMax);
341 346
342 if (prefs_->HasPrefPath(prefs::kNTPPromoViews)) 347 if (prefs_->HasPrefPath(prefs::kNTPPromoViews))
343 views_ = prefs_->GetInteger(prefs::kNTPPromoViews); 348 views_ = prefs_->GetInteger(prefs::kNTPPromoViews);
344 349
345 prefs_->SetInteger(prefs::kNTPPromoViews, ++views_); 350 prefs_->SetInteger(prefs::kNTPPromoViews, ++views_);
346 return views_ >= max_views_; 351 return views_ >= max_views_;
347 } 352 }
348 353
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 max_group_ == other.max_group_ && 415 max_group_ == other.max_group_ &&
411 max_views_ == other.max_views_ && 416 max_views_ == other.max_views_ &&
412 platform_ == other.platform_ && 417 platform_ == other.platform_ &&
413 group_ == other.group_ && 418 group_ == other.group_ &&
414 views_ == other.views_ && 419 views_ == other.views_ &&
415 text_ == other.text_ && 420 text_ == other.text_ &&
416 closed_ == other.closed_ && 421 closed_ == other.closed_ &&
417 gplus_ == other.gplus_ && 422 gplus_ == other.gplus_ &&
418 feature_mask_ == other.feature_mask_; 423 feature_mask_ == other.feature_mask_;
419 } 424 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/ntp_resource_cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698