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

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

Issue 8919017: Split UserMetrics into API vs. implementation. Move API to content/public. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Version for commit (merged again). 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 <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
11 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
12 #include "base/string_split.h" 12 #include "base/string_split.h"
13 #include "base/time.h" 13 #include "base/time.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/prefs/pref_service.h" 15 #include "chrome/browser/prefs/pref_service.h"
16 #include "chrome/browser/profiles/profile_impl.h" 16 #include "chrome/browser/profiles/profile_impl.h"
17 #include "chrome/browser/web_resource/promo_resource_service.h" 17 #include "chrome/browser/web_resource/promo_resource_service.h"
18 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
19 #include "content/browser/user_metrics.h" 19 #include "content/public/browser/user_metrics.h"
20 #include "googleurl/src/gurl.h" 20 #include "googleurl/src/gurl.h"
21 #include "net/base/cookie_store.h" 21 #include "net/base/cookie_store.h"
22 #include "net/url_request/url_request_context.h" 22 #include "net/url_request/url_request_context.h"
23 23
24 using content::UserMetricsAction;
25
24 namespace { 26 namespace {
25 27
26 // Maximum number of views. 28 // Maximum number of views.
27 static const int kMaxViews = 1000; 29 static const int kMaxViews = 1000;
28 30
29 // Maximum number of hours for each time slice (4 weeks). 31 // Maximum number of hours for each time slice (4 weeks).
30 static const int kMaxTimeSliceHours = 24 * 7 * 4; 32 static const int kMaxTimeSliceHours = 24 * 7 * 4;
31 33
32 bool OutOfBounds(int var, int min, int max) { 34 bool OutOfBounds(int var, int min, int max) {
33 return var < min || var > max; 35 return var < min || var > max;
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 group_ < max_group_ && 330 group_ < max_group_ &&
329 views_ < max_views_ && 331 views_ < max_views_ &&
330 IsPlatformAllowed(platform_) && 332 IsPlatformAllowed(platform_) &&
331 IsBuildAllowed(build_) && 333 IsBuildAllowed(build_) &&
332 base::Time::FromDoubleT(StartTimeWithOffset()) < base::Time::Now() && 334 base::Time::FromDoubleT(StartTimeWithOffset()) < base::Time::Now() &&
333 base::Time::FromDoubleT(end_) > base::Time::Now() && 335 base::Time::FromDoubleT(end_) > base::Time::Now() &&
334 (!(feature_mask_ & NotificationPromo::FEATURE_GPLUS) || gplus_); 336 (!(feature_mask_ & NotificationPromo::FEATURE_GPLUS) || gplus_);
335 } 337 }
336 338
337 void NotificationPromo::HandleClosed() { 339 void NotificationPromo::HandleClosed() {
338 UserMetrics::RecordAction(UserMetricsAction("NTPPromoClosed")); 340 content::RecordAction(UserMetricsAction("NTPPromoClosed"));
339 prefs_->SetBoolean(prefs::kNTPPromoClosed, true); 341 prefs_->SetBoolean(prefs::kNTPPromoClosed, true);
340 } 342 }
341 343
342 bool NotificationPromo::HandleViewed() { 344 bool NotificationPromo::HandleViewed() {
343 UserMetrics::RecordAction(UserMetricsAction("NTPPromoShown")); 345 content::RecordAction(UserMetricsAction("NTPPromoShown"));
344 if (prefs_->HasPrefPath(prefs::kNTPPromoViewsMax)) 346 if (prefs_->HasPrefPath(prefs::kNTPPromoViewsMax))
345 max_views_ = prefs_->GetInteger(prefs::kNTPPromoViewsMax); 347 max_views_ = prefs_->GetInteger(prefs::kNTPPromoViewsMax);
346 348
347 if (prefs_->HasPrefPath(prefs::kNTPPromoViews)) 349 if (prefs_->HasPrefPath(prefs::kNTPPromoViews))
348 views_ = prefs_->GetInteger(prefs::kNTPPromoViews); 350 views_ = prefs_->GetInteger(prefs::kNTPPromoViews);
349 351
350 prefs_->SetInteger(prefs::kNTPPromoViews, ++views_); 352 prefs_->SetInteger(prefs::kNTPPromoViews, ++views_);
351 return views_ >= max_views_; 353 return views_ >= max_views_;
352 } 354 }
353 355
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 max_group_ == other.max_group_ && 417 max_group_ == other.max_group_ &&
416 max_views_ == other.max_views_ && 418 max_views_ == other.max_views_ &&
417 platform_ == other.platform_ && 419 platform_ == other.platform_ &&
418 group_ == other.group_ && 420 group_ == other.group_ &&
419 views_ == other.views_ && 421 views_ == other.views_ &&
420 text_ == other.text_ && 422 text_ == other.text_ &&
421 closed_ == other.closed_ && 423 closed_ == other.closed_ &&
422 gplus_ == other.gplus_ && 424 gplus_ == other.gplus_ &&
423 feature_mask_ == other.feature_mask_; 425 feature_mask_ == other.feature_mask_;
424 } 426 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/personal_options_handler.cc ('k') | chrome/browser/web_resource/web_resource_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698