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" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 if (is_user_active_ == is_user_active_previously) | 157 if (is_user_active_ == is_user_active_previously) |
158 return; | 158 return; |
159 | 159 |
160 if (is_user_active_) { | 160 if (is_user_active_) { |
161 user_state_check_timer_.Stop(); | 161 user_state_check_timer_.Stop(); |
162 // We need to show any postponed nofications when the user becomes active | 162 // We need to show any postponed nofications when the user becomes active |
163 // again. | 163 // again. |
164 ShowNotifications(); | 164 ShowNotifications(); |
165 } else if (!user_state_check_timer_.IsRunning()) { | 165 } else if (!user_state_check_timer_.IsRunning()) { |
166 // Start a timer to detect the moment at which the user becomes active. | 166 // Start a timer to detect the moment at which the user becomes active. |
167 user_state_check_timer_.Start(FROM_HERE, | 167 user_state_check_timer_.Start( |
168 base::TimeDelta::FromSeconds(kUserStatePollingIntervalSeconds), this, | 168 base::TimeDelta::FromSeconds(kUserStatePollingIntervalSeconds), this, |
169 &NotificationUIManager::CheckUserState); | 169 &NotificationUIManager::CheckUserState); |
170 } | 170 } |
171 } | 171 } |
172 | 172 |
173 void NotificationUIManager::ShowNotifications() { | 173 void NotificationUIManager::ShowNotifications() { |
174 while (!show_queue_.empty() && balloon_collection_->HasSpace()) { | 174 while (!show_queue_.empty() && balloon_collection_->HasSpace()) { |
175 scoped_ptr<QueuedNotification> queued_notification(show_queue_.front()); | 175 scoped_ptr<QueuedNotification> queued_notification(show_queue_.front()); |
176 show_queue_.pop_front(); | 176 show_queue_.pop_front(); |
177 balloon_collection_->Add(queued_notification->notification(), | 177 balloon_collection_->Add(queued_notification->notification(), |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 } else if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 240 } else if (type == chrome::NOTIFICATION_PREF_CHANGED) { |
241 std::string* name = Details<std::string>(details).ptr(); | 241 std::string* name = Details<std::string>(details).ptr(); |
242 if (*name == prefs::kDesktopNotificationPosition) | 242 if (*name == prefs::kDesktopNotificationPosition) |
243 balloon_collection_->SetPositionPreference( | 243 balloon_collection_->SetPositionPreference( |
244 static_cast<BalloonCollection::PositionPreference>( | 244 static_cast<BalloonCollection::PositionPreference>( |
245 position_pref_.GetValue())); | 245 position_pref_.GetValue())); |
246 } else { | 246 } else { |
247 NOTREACHED(); | 247 NOTREACHED(); |
248 } | 248 } |
249 } | 249 } |
OLD | NEW |