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/ui/browser_list_impl.h" | 5 #include "chrome/browser/ui/browser_list_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/browser_shutdown.h" | 10 #include "chrome/browser/browser_shutdown.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 bool closing_app = (browsers_.size() == 1); | 88 bool closing_app = (browsers_.size() == 1); |
89 #endif // OS_CHROMEOS | 89 #endif // OS_CHROMEOS |
90 | 90 |
91 content::NotificationService::current()->Notify( | 91 content::NotificationService::current()->Notify( |
92 chrome::NOTIFICATION_BROWSER_CLOSED, | 92 chrome::NOTIFICATION_BROWSER_CLOSED, |
93 content::Source<Browser>(browser), | 93 content::Source<Browser>(browser), |
94 content::Details<bool>(&closing_app)); | 94 content::Details<bool>(&closing_app)); |
95 | 95 |
96 RemoveBrowserFrom(browser, &browsers_); | 96 RemoveBrowserFrom(browser, &browsers_); |
97 | 97 |
98 // Do some basic checking to try to catch evil observers | |
99 // that change the list from under us. | |
100 size_t original_count = observers_.size(); | |
101 FOR_EACH_OBSERVER(BrowserListObserver, observers_, OnBrowserRemoved(browser)); | 98 FOR_EACH_OBSERVER(BrowserListObserver, observers_, OnBrowserRemoved(browser)); |
102 DCHECK_EQ(original_count, observers_.size()) | |
103 << "observer list modified during notification"; | |
104 | 99 |
105 g_browser_process->ReleaseModule(); | 100 g_browser_process->ReleaseModule(); |
106 | 101 |
107 // If we're exiting, send out the APP_TERMINATING notification to allow other | 102 // If we're exiting, send out the APP_TERMINATING notification to allow other |
108 // modules to shut themselves down. | 103 // modules to shut themselves down. |
109 if (browsers_.empty() && | 104 if (browsers_.empty() && |
110 (browser_shutdown::IsTryingToQuit() || | 105 (browser_shutdown::IsTryingToQuit() || |
111 g_browser_process->IsShuttingDown())) { | 106 g_browser_process->IsShuttingDown())) { |
112 // Last browser has just closed, and this is a user-initiated quit or there | 107 // Last browser has just closed, and this is a user-initiated quit or there |
113 // is no module keeping the app alive, so send out our notification. No need | 108 // is no module keeping the app alive, so send out our notification. No need |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 192 |
198 void BrowserListImpl::RemoveBrowserFrom(Browser* browser, | 193 void BrowserListImpl::RemoveBrowserFrom(Browser* browser, |
199 BrowserVector* browser_list) { | 194 BrowserVector* browser_list) { |
200 const iterator remove_browser = | 195 const iterator remove_browser = |
201 std::find(browser_list->begin(), browser_list->end(), browser); | 196 std::find(browser_list->begin(), browser_list->end(), browser); |
202 if (remove_browser != browser_list->end()) | 197 if (remove_browser != browser_list->end()) |
203 browser_list->erase(remove_browser); | 198 browser_list->erase(remove_browser); |
204 } | 199 } |
205 | 200 |
206 } // namespace chrome | 201 } // namespace chrome |
OLD | NEW |