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

Side by Side Diff: chrome/browser/notifications/message_center_notification_manager.cc

Issue 23902057: Stats collector for message center. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Histograms.xml nit Created 7 years, 3 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/message_center_notification_manager.h" 5 #include "chrome/browser/notifications/message_center_notification_manager.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/browser/extensions/extension_info_map.h" 11 #include "chrome/browser/extensions/extension_info_map.h"
12 #include "chrome/browser/extensions/extension_system.h" 12 #include "chrome/browser/extensions/extension_system.h"
13 #include "chrome/browser/notifications/desktop_notification_service.h" 13 #include "chrome/browser/notifications/desktop_notification_service.h"
14 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 14 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
15 #include "chrome/browser/notifications/fullscreen_notification_blocker.h" 15 #include "chrome/browser/notifications/fullscreen_notification_blocker.h"
16 #include "chrome/browser/notifications/message_center_settings_controller.h" 16 #include "chrome/browser/notifications/message_center_settings_controller.h"
17 #include "chrome/browser/notifications/notification.h" 17 #include "chrome/browser/notifications/notification.h"
18 #include "chrome/browser/notifications/screen_lock_notification_blocker.h" 18 #include "chrome/browser/notifications/screen_lock_notification_blocker.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/ui/browser_finder.h" 20 #include "chrome/browser/ui/browser_finder.h"
21 #include "chrome/browser/ui/chrome_pages.h" 21 #include "chrome/browser/ui/chrome_pages.h"
22 #include "chrome/browser/ui/host_desktop.h" 22 #include "chrome/browser/ui/host_desktop.h"
23 #include "chrome/common/extensions/extension_set.h" 23 #include "chrome/common/extensions/extension_set.h"
24 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
25 #include "content/public/browser/notification_service.h" 25 #include "content/public/browser/notification_service.h"
26 #include "content/public/browser/user_metrics.h"
27 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
28 #include "content/public/common/url_constants.h" 27 #include "content/public/common/url_constants.h"
29 #include "ui/gfx/image/image_skia.h" 28 #include "ui/gfx/image/image_skia.h"
30 #include "ui/message_center/message_center_style.h" 29 #include "ui/message_center/message_center_style.h"
31 #include "ui/message_center/message_center_tray.h" 30 #include "ui/message_center/message_center_tray.h"
32 #include "ui/message_center/message_center_types.h" 31 #include "ui/message_center/message_center_types.h"
33 #include "ui/message_center/notifier_settings.h" 32 #include "ui/message_center/notifier_settings.h"
34 33
35 #if defined(OS_CHROMEOS) 34 #if defined(OS_CHROMEOS)
36 #include "chrome/browser/notifications/login_state_notification_blocker_chromeos .h" 35 #include "chrome/browser/notifications/login_state_notification_blocker_chromeos .h"
37 #endif 36 #endif
38 37
39 namespace { 38 namespace {
40 // The first-run balloon will be shown |kFirstRunIdleDelaySeconds| after all 39 // The first-run balloon will be shown |kFirstRunIdleDelaySeconds| after all
41 // popups go away and the user has notifications in the message center. 40 // popups go away and the user has notifications in the message center.
42 const int kFirstRunIdleDelaySeconds = 1; 41 const int kFirstRunIdleDelaySeconds = 1;
43 } // namespace 42 } // namespace
44 43
45 MessageCenterNotificationManager::MessageCenterNotificationManager( 44 MessageCenterNotificationManager::MessageCenterNotificationManager(
46 message_center::MessageCenter* message_center, 45 message_center::MessageCenter* message_center,
47 PrefService* local_state, 46 PrefService* local_state,
48 scoped_ptr<message_center::NotifierSettingsProvider> settings_provider) 47 scoped_ptr<message_center::NotifierSettingsProvider> settings_provider)
49 : message_center_(message_center), 48 : message_center_(message_center),
50 #if defined(OS_WIN) 49 #if defined(OS_WIN)
51 first_run_idle_timeout_( 50 first_run_idle_timeout_(
52 base::TimeDelta::FromSeconds(kFirstRunIdleDelaySeconds)), 51 base::TimeDelta::FromSeconds(kFirstRunIdleDelaySeconds)),
53 weak_factory_(this), 52 weak_factory_(this),
54 #endif 53 #endif
55 settings_provider_(settings_provider.Pass()), 54 settings_provider_(settings_provider.Pass()),
56 system_observer_(this) { 55 system_observer_(this),
56 stats_collector_(message_center) {
57 #if defined(OS_WIN) 57 #if defined(OS_WIN)
58 first_run_pref_.Init(prefs::kMessageCenterShowedFirstRunBalloon, local_state); 58 first_run_pref_.Init(prefs::kMessageCenterShowedFirstRunBalloon, local_state);
59 #endif 59 #endif
60 60
61 message_center_->AddObserver(this); 61 message_center_->AddObserver(this);
62 message_center_->SetNotifierSettingsProvider(settings_provider_.get()); 62 message_center_->SetNotifierSettingsProvider(settings_provider_.get());
63 63
64 #if defined(OS_CHROMEOS) 64 #if defined(OS_CHROMEOS)
65 blockers_.push_back( 65 blockers_.push_back(
66 new LoginStateNotificationBlockerChromeOS(message_center)); 66 new LoginStateNotificationBlockerChromeOS(message_center));
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 if (iter != profile_notifications_.end()) 225 if (iter != profile_notifications_.end())
226 RemoveProfileNotification(iter->second); 226 RemoveProfileNotification(iter->second);
227 227
228 #if defined(OS_WIN) 228 #if defined(OS_WIN)
229 CheckFirstRunTimer(); 229 CheckFirstRunTimer();
230 #endif 230 #endif
231 } 231 }
232 232
233 void MessageCenterNotificationManager::OnCenterVisibilityChanged( 233 void MessageCenterNotificationManager::OnCenterVisibilityChanged(
234 message_center::Visibility visibility) { 234 message_center::Visibility visibility) {
235 switch (visibility) {
236 case message_center::VISIBILITY_TRANSIENT:
237 #if defined(OS_WIN) 235 #if defined(OS_WIN)
238 CheckFirstRunTimer(); 236 if (visibility == message_center::VISIBILITY_TRANSIENT)
237 CheckFirstRunTimer();
239 #endif 238 #endif
240 break;
241 case message_center::VISIBILITY_MESSAGE_CENTER:
242 content::RecordAction(
243 content::UserMetricsAction("Notifications.ShowMessageCenter"));
244 break;
245 case message_center::VISIBILITY_SETTINGS:
246 content::RecordAction(
247 content::UserMetricsAction("Notifications.ShowSettings"));
248 break;
249 }
250 } 239 }
251 240
252 void MessageCenterNotificationManager::OnNotificationUpdated( 241 void MessageCenterNotificationManager::OnNotificationUpdated(
253 const std::string& notification_id) { 242 const std::string& notification_id) {
254 #if defined(OS_WIN) 243 #if defined(OS_WIN)
255 CheckFirstRunTimer(); 244 CheckFirstRunTimer();
256 #endif 245 #endif
257 } 246 }
258 247
259 void MessageCenterNotificationManager::SetMessageCenterTrayDelegateForTest( 248 void MessageCenterNotificationManager::SetMessageCenterTrayDelegateForTest(
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 462
474 MessageCenterNotificationManager::ProfileNotification* 463 MessageCenterNotificationManager::ProfileNotification*
475 MessageCenterNotificationManager::FindProfileNotification( 464 MessageCenterNotificationManager::FindProfileNotification(
476 const std::string& id) const { 465 const std::string& id) const {
477 NotificationMap::const_iterator iter = profile_notifications_.find(id); 466 NotificationMap::const_iterator iter = profile_notifications_.find(id);
478 if (iter == profile_notifications_.end()) 467 if (iter == profile_notifications_.end())
479 return NULL; 468 return NULL;
480 469
481 return (*iter).second; 470 return (*iter).second;
482 } 471 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698