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_test_util.h" | 5 #include "chrome/browser/notifications/notification_test_util.h" |
6 | 6 |
7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
8 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" | 8 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" |
9 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" | 9 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" |
10 #include "content/public/test/test_utils.h" | 10 #include "content/public/test/test_utils.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 if (iter->first.delegate_id() != delegate_id || iter->second != profile_id) | 45 if (iter->first.delegate_id() != delegate_id || iter->second != profile_id) |
46 continue; | 46 continue; |
47 notifications_.erase(iter); | 47 notifications_.erase(iter); |
48 return true; | 48 return true; |
49 } | 49 } |
50 return false; | 50 return false; |
51 } | 51 } |
52 | 52 |
53 void StubNotificationUIManager::Add(const Notification& notification, | 53 void StubNotificationUIManager::Add(const Notification& notification, |
54 Profile* profile) { | 54 Profile* profile) { |
| 55 if (is_shutdown_started_) |
| 56 return; |
| 57 |
55 notifications_.push_back(std::make_pair( | 58 notifications_.push_back(std::make_pair( |
56 notification, NotificationUIManager::GetProfileID(profile))); | 59 notification, NotificationUIManager::GetProfileID(profile))); |
57 | 60 |
58 if (!notification_added_callback_.is_null()) { | 61 if (!notification_added_callback_.is_null()) { |
59 notification_added_callback_.Run(); | 62 notification_added_callback_.Run(); |
60 notification_added_callback_.Reset(); | 63 notification_added_callback_.Reset(); |
61 } | 64 } |
62 | 65 |
63 // Fire the Display() event on the delegate. | 66 // Fire the Display() event on the delegate. |
64 notification.delegate()->Display(); | 67 notification.delegate()->Display(); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 NOTIMPLEMENTED(); | 150 NOTIMPLEMENTED(); |
148 return false; | 151 return false; |
149 } | 152 } |
150 | 153 |
151 void StubNotificationUIManager::CancelAll() { | 154 void StubNotificationUIManager::CancelAll() { |
152 for (const auto& pair : notifications_) | 155 for (const auto& pair : notifications_) |
153 pair.first.delegate()->Close(false /* by_user */); | 156 pair.first.delegate()->Close(false /* by_user */); |
154 notifications_.clear(); | 157 notifications_.clear(); |
155 } | 158 } |
156 | 159 |
| 160 void StubNotificationUIManager::StartShutdown() { |
| 161 is_shutdown_started_ = true; |
| 162 CancelAll(); |
| 163 } |
| 164 |
157 FullscreenStateWaiter::FullscreenStateWaiter( | 165 FullscreenStateWaiter::FullscreenStateWaiter( |
158 Browser* browser, bool desired_state) | 166 Browser* browser, bool desired_state) |
159 : browser_(browser), | 167 : browser_(browser), |
160 desired_state_(desired_state) {} | 168 desired_state_(desired_state) {} |
161 | 169 |
162 void FullscreenStateWaiter::Wait() { | 170 void FullscreenStateWaiter::Wait() { |
163 while (desired_state_ != | 171 while (desired_state_ != |
164 browser_->exclusive_access_manager()->context()->IsFullscreen()) { | 172 browser_->exclusive_access_manager()->context()->IsFullscreen()) { |
165 content::RunAllPendingInMessageLoop(); | 173 content::RunAllPendingInMessageLoop(); |
166 } | 174 } |
167 } | 175 } |
OLD | NEW |