| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "chrome/browser/notifications/notification_ui_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/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/fullscreen.h" | 11 #include "chrome/browser/fullscreen.h" |
| 12 #include "chrome/browser/idle.h" | 12 #include "chrome/browser/idle.h" |
| 13 #include "chrome/browser/notifications/balloon_collection.h" | 13 #include "chrome/browser/notifications/balloon_collection.h" |
| 14 #include "chrome/browser/notifications/notification.h" | 14 #include "chrome/browser/notifications/notification.h" |
| 15 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
| 16 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
| 17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 18 #include "content/browser/site_instance.h" | 18 #include "content/browser/site_instance.h" |
| 19 #include "content/common/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 const int kUserStatePollingIntervalSeconds = 1; | 22 const int kUserStatePollingIntervalSeconds = 1; |
| 23 } | 23 } |
| 24 | 24 |
| 25 // A class which represents a notification waiting to be shown. | 25 // A class which represents a notification waiting to be shown. |
| 26 class QueuedNotification { | 26 class QueuedNotification { |
| 27 public: | 27 public: |
| 28 QueuedNotification(const Notification& notification, Profile* profile) | 28 QueuedNotification(const Notification& notification, Profile* profile) |
| 29 : notification_(notification), | 29 : notification_(notification), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 44 // Non owned pointer to the user's profile. | 44 // Non owned pointer to the user's profile. |
| 45 Profile* profile_; | 45 Profile* profile_; |
| 46 | 46 |
| 47 DISALLOW_COPY_AND_ASSIGN(QueuedNotification); | 47 DISALLOW_COPY_AND_ASSIGN(QueuedNotification); |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 NotificationUIManager::NotificationUIManager(PrefService* local_state) | 50 NotificationUIManager::NotificationUIManager(PrefService* local_state) |
| 51 : balloon_collection_(NULL), | 51 : balloon_collection_(NULL), |
| 52 is_user_active_(true) { | 52 is_user_active_(true) { |
| 53 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, | 53 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, |
| 54 NotificationService::AllSources()); | 54 content::NotificationService::AllSources()); |
| 55 position_pref_.Init(prefs::kDesktopNotificationPosition, local_state, this); | 55 position_pref_.Init(prefs::kDesktopNotificationPosition, local_state, this); |
| 56 #if defined(OS_MACOSX) | 56 #if defined(OS_MACOSX) |
| 57 InitFullScreenMonitor(); | 57 InitFullScreenMonitor(); |
| 58 #endif | 58 #endif |
| 59 } | 59 } |
| 60 | 60 |
| 61 NotificationUIManager::~NotificationUIManager() { | 61 NotificationUIManager::~NotificationUIManager() { |
| 62 STLDeleteElements(&show_queue_); | 62 STLDeleteElements(&show_queue_); |
| 63 #if defined(OS_MACOSX) | 63 #if defined(OS_MACOSX) |
| 64 StopFullScreenMonitor(); | 64 StopFullScreenMonitor(); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 } else if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 249 } else if (type == chrome::NOTIFICATION_PREF_CHANGED) { |
| 250 std::string* name = content::Details<std::string>(details).ptr(); | 250 std::string* name = content::Details<std::string>(details).ptr(); |
| 251 if (*name == prefs::kDesktopNotificationPosition) | 251 if (*name == prefs::kDesktopNotificationPosition) |
| 252 balloon_collection_->SetPositionPreference( | 252 balloon_collection_->SetPositionPreference( |
| 253 static_cast<BalloonCollection::PositionPreference>( | 253 static_cast<BalloonCollection::PositionPreference>( |
| 254 position_pref_.GetValue())); | 254 position_pref_.GetValue())); |
| 255 } else { | 255 } else { |
| 256 NOTREACHED(); | 256 NOTREACHED(); |
| 257 } | 257 } |
| 258 } | 258 } |
| OLD | NEW |