OLD | NEW |
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" |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "ui/message_center/notifier_settings.h" | 26 #include "ui/message_center/notifier_settings.h" |
27 | 27 |
28 namespace { | 28 namespace { |
29 // The first-run balloon will be shown |kFirstRunIdleDelaySeconds| after all | 29 // The first-run balloon will be shown |kFirstRunIdleDelaySeconds| after all |
30 // popups go away and the user has notifications in the message center. | 30 // popups go away and the user has notifications in the message center. |
31 const int kFirstRunIdleDelaySeconds = 1; | 31 const int kFirstRunIdleDelaySeconds = 1; |
32 } // namespace | 32 } // namespace |
33 | 33 |
34 MessageCenterNotificationManager::MessageCenterNotificationManager( | 34 MessageCenterNotificationManager::MessageCenterNotificationManager( |
35 message_center::MessageCenter* message_center, | 35 message_center::MessageCenter* message_center, |
36 PrefService* local_state) | 36 PrefService* local_state, |
| 37 scoped_ptr<message_center::NotifierSettingsProvider> settings_provider) |
37 : message_center_(message_center), | 38 : message_center_(message_center), |
38 #if defined(OS_WIN) | 39 #if defined(OS_WIN) |
39 first_run_idle_timeout_( | 40 first_run_idle_timeout_( |
40 base::TimeDelta::FromSeconds(kFirstRunIdleDelaySeconds)), | 41 base::TimeDelta::FromSeconds(kFirstRunIdleDelaySeconds)), |
41 weak_factory_(this), | 42 weak_factory_(this), |
42 #endif | 43 #endif |
43 settings_controller_(new MessageCenterSettingsController) { | 44 settings_provider_(settings_provider.Pass()) { |
44 #if defined(OS_WIN) | 45 #if defined(OS_WIN) |
45 first_run_pref_.Init(prefs::kMessageCenterShowedFirstRunBalloon, local_state); | 46 first_run_pref_.Init(prefs::kMessageCenterShowedFirstRunBalloon, local_state); |
46 #endif | 47 #endif |
47 | 48 |
48 message_center_->SetDelegate(this); | 49 message_center_->SetDelegate(this); |
49 message_center_->AddObserver(this); | 50 message_center_->AddObserver(this); |
50 message_center_->SetNotifierSettingsProvider(settings_controller_.get()); | 51 message_center_->SetNotifierSettingsProvider(settings_provider_.get()); |
51 | 52 |
52 #if defined(OS_WIN) || defined(OS_MACOSX) \ | 53 #if defined(OS_WIN) || defined(OS_MACOSX) \ |
53 || (defined(USE_AURA) && !defined(USE_ASH)) | 54 || (defined(USE_AURA) && !defined(USE_ASH)) |
54 // On Windows, Linux and Mac, the notification manager owns the tray icon and | 55 // On Windows, Linux and Mac, the notification manager owns the tray icon and |
55 // views.Other platforms have global ownership and Create will return NULL. | 56 // views.Other platforms have global ownership and Create will return NULL. |
56 tray_.reset(message_center::CreateMessageCenterTray()); | 57 tray_.reset(message_center::CreateMessageCenterTray()); |
57 #endif | 58 #endif |
58 } | 59 } |
59 | 60 |
60 MessageCenterNotificationManager::~MessageCenterNotificationManager() { | 61 MessageCenterNotificationManager::~MessageCenterNotificationManager() { |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 | 539 |
539 MessageCenterNotificationManager::ProfileNotification* | 540 MessageCenterNotificationManager::ProfileNotification* |
540 MessageCenterNotificationManager::FindProfileNotification( | 541 MessageCenterNotificationManager::FindProfileNotification( |
541 const std::string& id) const { | 542 const std::string& id) const { |
542 NotificationMap::const_iterator iter = profile_notifications_.find(id); | 543 NotificationMap::const_iterator iter = profile_notifications_.find(id); |
543 if (iter == profile_notifications_.end()) | 544 if (iter == profile_notifications_.end()) |
544 return NULL; | 545 return NULL; |
545 | 546 |
546 return (*iter).second; | 547 return (*iter).second; |
547 } | 548 } |
OLD | NEW |