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

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

Issue 17286015: Adds a first-run balloon to the Windows notification center. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: dimich comments. Created 7 years, 6 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/extensions/extension_info_map.h" 10 #include "chrome/browser/extensions/extension_info_map.h"
11 #include "chrome/browser/extensions/extension_system.h" 11 #include "chrome/browser/extensions/extension_system.h"
12 #include "chrome/browser/notifications/desktop_notification_service.h" 12 #include "chrome/browser/notifications/desktop_notification_service.h"
13 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 13 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
14 #include "chrome/browser/notifications/message_center_settings_controller.h" 14 #include "chrome/browser/notifications/message_center_settings_controller.h"
15 #include "chrome/browser/notifications/notification.h" 15 #include "chrome/browser/notifications/notification.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/browser_finder.h" 17 #include "chrome/browser/ui/browser_finder.h"
18 #include "chrome/browser/ui/chrome_pages.h" 18 #include "chrome/browser/ui/chrome_pages.h"
19 #include "chrome/browser/ui/host_desktop.h" 19 #include "chrome/browser/ui/host_desktop.h"
20 #include "chrome/common/extensions/extension_set.h" 20 #include "chrome/common/extensions/extension_set.h"
21 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
22 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
23 #include "content/public/common/url_constants.h" 23 #include "content/public/common/url_constants.h"
24 #include "ui/message_center/message_center_style.h" 24 #include "ui/message_center/message_center_style.h"
25 #include "ui/message_center/message_center_tray.h" 25 #include "ui/message_center/message_center_tray.h"
26 #include "ui/message_center/notifier_settings.h" 26 #include "ui/message_center/notifier_settings.h"
27 27
28 namespace {
29 // The first-run balloon will be shown |kFirstRunIdleDelaySeconds| after all
30 // popups go away and the user has notifications in the message center.
31 const int kFirstRunIdleDelaySeconds = 1;
32 } // namespace
33
28 MessageCenterNotificationManager::MessageCenterNotificationManager( 34 MessageCenterNotificationManager::MessageCenterNotificationManager(
29 message_center::MessageCenter* message_center) 35 message_center::MessageCenter* message_center,
36 PrefService* local_state)
30 : message_center_(message_center), 37 : message_center_(message_center),
38 #if defined(OS_WIN)
39 first_run_idle_timeout_(
40 base::TimeDelta::FromSeconds(kFirstRunIdleDelaySeconds)),
41 weak_factory_(this),
42 #endif
31 settings_controller_(new MessageCenterSettingsController) { 43 settings_controller_(new MessageCenterSettingsController) {
44 #if defined(OS_WIN)
45 first_run_pref_.Init(prefs::kMessageCenterShowedFirstRunBalloon, local_state);
46 #endif
47
32 message_center_->SetDelegate(this); 48 message_center_->SetDelegate(this);
33 message_center_->AddObserver(this); 49 message_center_->AddObserver(this);
34 message_center_->SetNotifierSettingsProvider(settings_controller_.get()); 50 message_center_->SetNotifierSettingsProvider(settings_controller_.get());
35 51
36 #if defined(OS_WIN) || defined(OS_MACOSX) \ 52 #if defined(OS_WIN) || defined(OS_MACOSX) \
37 || (defined(USE_AURA) && !defined(USE_ASH)) 53 || (defined(USE_AURA) && !defined(USE_ASH))
38 // On Windows, Linux and Mac, the notification manager owns the tray icon and 54 // On Windows, Linux and Mac, the notification manager owns the tray icon and
39 // views.Other platforms have global ownership and Create will return NULL. 55 // views.Other platforms have global ownership and Create will return NULL.
40 tray_.reset(message_center::CreateMessageCenterTray()); 56 tray_.reset(message_center::CreateMessageCenterTray());
41 #endif 57 #endif
42 } 58 }
43 59
44 MessageCenterNotificationManager::~MessageCenterNotificationManager() { 60 MessageCenterNotificationManager::~MessageCenterNotificationManager() {
45 message_center_->RemoveObserver(this); 61 message_center_->RemoveObserver(this);
46 } 62 }
47 63
48
49 //////////////////////////////////////////////////////////////////////////////// 64 ////////////////////////////////////////////////////////////////////////////////
50 // NotificationUIManager 65 // NotificationUIManager
51 66
52 bool MessageCenterNotificationManager::DoesIdExist(const std::string& id) { 67 bool MessageCenterNotificationManager::DoesIdExist(const std::string& id) {
53 if (NotificationUIManagerImpl::DoesIdExist(id)) 68 if (NotificationUIManagerImpl::DoesIdExist(id))
54 return true; 69 return true;
55 NotificationMap::iterator iter = profile_notifications_.find(id); 70 NotificationMap::iterator iter = profile_notifications_.find(id);
56 if (iter == profile_notifications_.end()) 71 if (iter == profile_notifications_.end())
57 return false; 72 return false;
58 return true; 73 return true;
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 void MessageCenterNotificationManager::OnNotificationRemoved( 278 void MessageCenterNotificationManager::OnNotificationRemoved(
264 const std::string& notification_id, 279 const std::string& notification_id,
265 bool by_user) { 280 bool by_user) {
266 // Do not call FindProfileNotification(). Some tests create notifications 281 // Do not call FindProfileNotification(). Some tests create notifications
267 // directly to MessageCenter, but this method will be called for the removals 282 // directly to MessageCenter, but this method will be called for the removals
268 // of such notifications. 283 // of such notifications.
269 NotificationMap::const_iterator iter = 284 NotificationMap::const_iterator iter =
270 profile_notifications_.find(notification_id); 285 profile_notifications_.find(notification_id);
271 if (iter != profile_notifications_.end()) 286 if (iter != profile_notifications_.end())
272 RemoveProfileNotification(iter->second, by_user); 287 RemoveProfileNotification(iter->second, by_user);
288
289 #if defined(OS_WIN)
290 CheckFirstRunTimer();
291 #endif
273 } 292 }
274 293
275 void MessageCenterNotificationManager::OnNotificationCenterClosed() { 294 void MessageCenterNotificationManager::OnNotificationCenterClosed() {
276 // When the center is open it halts all notifications, so we need to listen 295 // When the center is open it halts all notifications, so we need to listen
277 // for events indicating it's been closed. 296 // for events indicating it's been closed.
278 CheckAndShowNotifications(); 297 CheckAndShowNotifications();
298 #if defined(OS_WIN)
299 CheckFirstRunTimer();
300 #endif
301 }
302
303 void MessageCenterNotificationManager::OnNotificationUpdated(
304 const std::string& notification_id) {
305 #if defined(OS_WIN)
306 CheckFirstRunTimer();
307 #endif
308 }
309
310 void MessageCenterNotificationManager::SetMessageCenterTrayDelegateForTest(
311 message_center::MessageCenterTrayDelegate* delegate) {
312 tray_.reset(delegate);
279 } 313 }
280 314
281 //////////////////////////////////////////////////////////////////////////////// 315 ////////////////////////////////////////////////////////////////////////////////
282 // ImageDownloads 316 // ImageDownloads
283 317
284 MessageCenterNotificationManager::ImageDownloads::ImageDownloads( 318 MessageCenterNotificationManager::ImageDownloads::ImageDownloads(
285 message_center::MessageCenter* message_center, 319 message_center::MessageCenter* message_center,
286 ImageDownloadsObserver* observer) 320 ImageDownloadsObserver* observer)
287 : message_center_(message_center), 321 : message_center_(message_center),
288 pending_downloads_(0), 322 pending_downloads_(0),
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 520
487 MessageCenterNotificationManager::ProfileNotification* 521 MessageCenterNotificationManager::ProfileNotification*
488 MessageCenterNotificationManager::FindProfileNotification( 522 MessageCenterNotificationManager::FindProfileNotification(
489 const std::string& id) const { 523 const std::string& id) const {
490 NotificationMap::const_iterator iter = profile_notifications_.find(id); 524 NotificationMap::const_iterator iter = profile_notifications_.find(id);
491 if (iter == profile_notifications_.end()) 525 if (iter == profile_notifications_.end())
492 return NULL; 526 return NULL;
493 527
494 return (*iter).second; 528 return (*iter).second;
495 } 529 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698