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

Side by Side Diff: chrome/browser/notifications/sync_notifier/chrome_notifier_delegate.cc

Issue 26943002: Add UMA histogram data representing the Synced Notifications feature. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced Notifications UMA - remove unused data Created 7 years, 2 months 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/notifications/sync_notifier/chrome_notifier_delegate.h" 5 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_delegate.h"
6 6
7 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" 7 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h"
8 #include "chrome/browser/notifications/sync_notifier/synced_notification.h" 8 #include "chrome/browser/notifications/sync_notifier/synced_notification.h"
9 #include "chrome/browser/notifications/sync_notifier/synced_notification_stats.h "
9 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_finder.h" 11 #include "chrome/browser/ui/browser_finder.h"
11 #include "content/public/browser/page_navigator.h" 12 #include "content/public/browser/page_navigator.h"
12 13
13 namespace notifier { 14 namespace notifier {
14 ChromeNotifierDelegate::ChromeNotifierDelegate( 15 ChromeNotifierDelegate::ChromeNotifierDelegate(
15 const std::string& notification_id, 16 const std::string& notification_id,
16 ChromeNotifierService* notifier) 17 ChromeNotifierService* notifier)
17 : notification_id_(notification_id), chrome_notifier_(notifier) {} 18 : notification_id_(notification_id), chrome_notifier_(notifier) {}
18 19
(...skipping 10 matching lines...) Expand all
29 // TODO(petewil) Add the ability to do URL actions also. 30 // TODO(petewil) Add the ability to do URL actions also.
30 void ChromeNotifierDelegate::Click() { 31 void ChromeNotifierDelegate::Click() {
31 SyncedNotification* notification = 32 SyncedNotification* notification =
32 chrome_notifier_->FindNotificationById(notification_id_); 33 chrome_notifier_->FindNotificationById(notification_id_);
33 if (notification == NULL) 34 if (notification == NULL)
34 return; 35 return;
35 36
36 GURL destination = notification->GetDefaultDestinationUrl(); 37 GURL destination = notification->GetDefaultDestinationUrl();
37 NavigateToUrl(destination); 38 NavigateToUrl(destination);
38 chrome_notifier_->MarkNotificationAsRead(notification_id_); 39 chrome_notifier_->MarkNotificationAsRead(notification_id_);
40
41 // Record the action in UMA statistics.
42 StatsCollection::iterator iter = stats_.find(notification_id_);
43 if (iter == stats_.end())
44 return;
45 SyncedNotificationStats& notification_stat = iter->second;
46
47 notification_stat.CollectAction(SYNCED_NOTIFICATION_ACTION_CLICK);
39 } 48 }
40 49
41 // TODO(petewil) Add the ability to do URL actions also. 50 // TODO(petewil) Add the ability to do URL actions also.
42 void ChromeNotifierDelegate::ButtonClick(int button_index) { 51 void ChromeNotifierDelegate::ButtonClick(int button_index) {
43 SyncedNotification* notification = 52 SyncedNotification* notification =
44 chrome_notifier_->FindNotificationById(notification_id_); 53 chrome_notifier_->FindNotificationById(notification_id_);
45 if (notification) { 54 if (notification) {
46 GURL destination = notification->GetButtonUrl(button_index); 55 GURL destination = notification->GetButtonUrl(button_index);
47 NavigateToUrl(destination); 56 NavigateToUrl(destination);
48 chrome_notifier_->MarkNotificationAsRead(notification_id_); 57 chrome_notifier_->MarkNotificationAsRead(notification_id_);
49 } 58 }
59
60 // Now record the UMA statistics for this action.
61 StatsCollection::iterator iter = stats_.find(notification_id_);
62 if (iter == stats_.end())
63 return;
64 SyncedNotificationStats& notification_stat = iter->second;
65
66 notification_stat.CollectAction(SYNCED_NOTIFICATION_ACTION_CLICK);
50 } 67 }
51 68
52 void ChromeNotifierDelegate::NavigateToUrl(const GURL& destination) const { 69 void ChromeNotifierDelegate::NavigateToUrl(const GURL& destination) const {
53 if (!destination.is_valid()) 70 if (!destination.is_valid())
54 return; 71 return;
55 72
56 content::OpenURLParams openParams(destination, content::Referrer(), 73 content::OpenURLParams openParams(destination, content::Referrer(),
57 NEW_FOREGROUND_TAB, 74 NEW_FOREGROUND_TAB,
58 content::PAGE_TRANSITION_LINK, false); 75 content::PAGE_TRANSITION_LINK, false);
59 Browser* browser = chrome::FindLastActiveWithProfile( 76 Browser* browser = chrome::FindLastActiveWithProfile(
60 chrome_notifier_->profile(), 77 chrome_notifier_->profile(),
61 chrome::GetActiveDesktop()); 78 chrome::GetActiveDesktop());
62 // Navigate to the URL in a new tab. 79 // Navigate to the URL in a new tab.
63 if (browser != NULL) 80 if (browser != NULL)
64 browser->OpenURL(openParams); 81 browser->OpenURL(openParams);
65 82
66 } 83 }
67 84
68 void ChromeNotifierDelegate::Close(bool by_user) { 85 void ChromeNotifierDelegate::Close(bool by_user) {
69 if (by_user) 86 if (by_user)
70 chrome_notifier_->MarkNotificationAsRead(notification_id_); 87 chrome_notifier_->MarkNotificationAsRead(notification_id_);
88
89 StatsCollection::iterator iter = stats_.find(notification_id_);
90 if (iter == stats_.end())
91 return;
92 SyncedNotificationStats& notification_stat = iter->second;
93 notification_stat.CollectAction(by_user ?
94 SYNCED_NOTIFICATION_ACTION_CLOSE_BY_USER :
95 SYNCED_NOTIFICATION_ACTION_CLOSE_BY_SYSTEM);
96 stats_.erase(notification_id_);
71 } 97 }
72 98
73 } // namespace notifier 99 } // namespace notifier
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698