| 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/notification_ui_manager_impl.h" | 5 #include "chrome/browser/notifications/notification_ui_manager_impl.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/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 Profile* profile_; | 44 Profile* profile_; |
| 45 | 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(QueuedNotification); | 46 DISALLOW_COPY_AND_ASSIGN(QueuedNotification); |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 NotificationUIManagerImpl::NotificationUIManagerImpl(PrefService* local_state) | 49 NotificationUIManagerImpl::NotificationUIManagerImpl(PrefService* local_state) |
| 50 : balloon_collection_(NULL), | 50 : balloon_collection_(NULL), |
| 51 is_user_active_(true) { | 51 is_user_active_(true) { |
| 52 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, | 52 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, |
| 53 content::NotificationService::AllSources()); | 53 content::NotificationService::AllSources()); |
| 54 position_pref_.Init(prefs::kDesktopNotificationPosition, local_state, this); | 54 position_pref_.Init( |
| 55 prefs::kDesktopNotificationPosition, |
| 56 local_state, |
| 57 base::Bind( |
| 58 &NotificationUIManagerImpl::OnDesktopNotificationPositionChanged, |
| 59 base::Unretained(this))); |
| 55 #if defined(OS_MACOSX) | 60 #if defined(OS_MACOSX) |
| 56 InitFullScreenMonitor(); | 61 InitFullScreenMonitor(); |
| 57 InitIdleMonitor(); | 62 InitIdleMonitor(); |
| 58 #endif | 63 #endif |
| 59 } | 64 } |
| 60 | 65 |
| 61 NotificationUIManagerImpl::~NotificationUIManagerImpl() { | 66 NotificationUIManagerImpl::~NotificationUIManagerImpl() { |
| 62 STLDeleteElements(&show_queue_); | 67 STLDeleteElements(&show_queue_); |
| 63 #if defined(OS_MACOSX) | 68 #if defined(OS_MACOSX) |
| 64 StopIdleMonitor(); | 69 StopIdleMonitor(); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 int type, | 238 int type, |
| 234 const content::NotificationSource& source, | 239 const content::NotificationSource& source, |
| 235 const content::NotificationDetails& details) { | 240 const content::NotificationDetails& details) { |
| 236 if (type == chrome::NOTIFICATION_APP_TERMINATING) { | 241 if (type == chrome::NOTIFICATION_APP_TERMINATING) { |
| 237 CancelAll(); | 242 CancelAll(); |
| 238 } else { | 243 } else { |
| 239 NOTREACHED(); | 244 NOTREACHED(); |
| 240 } | 245 } |
| 241 } | 246 } |
| 242 | 247 |
| 243 void NotificationUIManagerImpl::OnPreferenceChanged( | 248 void NotificationUIManagerImpl::OnDesktopNotificationPositionChanged() { |
| 244 PrefServiceBase* service, | 249 balloon_collection_->SetPositionPreference( |
| 245 const std::string& pref_name) { | 250 static_cast<BalloonCollection::PositionPreference>( |
| 246 if (pref_name == prefs::kDesktopNotificationPosition) { | 251 position_pref_.GetValue())); |
| 247 balloon_collection_->SetPositionPreference( | |
| 248 static_cast<BalloonCollection::PositionPreference>( | |
| 249 position_pref_.GetValue())); | |
| 250 } | |
| 251 } | 252 } |
| OLD | NEW |