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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 116 |
117 void BrowserListImpl::AddObserver(BrowserListObserver* observer) { | 117 void BrowserListImpl::AddObserver(BrowserListObserver* observer) { |
118 observers_.AddObserver(observer); | 118 observers_.AddObserver(observer); |
119 } | 119 } |
120 | 120 |
121 void BrowserListImpl::RemoveObserver(BrowserListObserver* observer) { | 121 void BrowserListImpl::RemoveObserver(BrowserListObserver* observer) { |
122 observers_.RemoveObserver(observer); | 122 observers_.RemoveObserver(observer); |
123 } | 123 } |
124 | 124 |
125 void BrowserListImpl::SetLastActive(Browser* browser) { | 125 void BrowserListImpl::SetLastActive(Browser* browser) { |
126 // If the browser is currently trying to quit, we don't want to set the last | |
127 // active browser because that can alter the last active browser that the user | |
128 // intended depending on the order in which the windows close. | |
129 if (browser_shutdown::IsTryingToQuit()) | |
130 return; | |
131 RemoveBrowserFrom(browser, &last_active_browsers_); | 126 RemoveBrowserFrom(browser, &last_active_browsers_); |
132 last_active_browsers_.push_back(browser); | 127 last_active_browsers_.push_back(browser); |
133 | 128 |
134 FOR_EACH_OBSERVER(BrowserListObserver, observers_, | 129 FOR_EACH_OBSERVER(BrowserListObserver, observers_, |
135 OnBrowserSetLastActive(browser)); | 130 OnBrowserSetLastActive(browser)); |
136 } | 131 } |
137 | 132 |
138 Browser* BrowserListImpl::GetLastActive() { | 133 Browser* BrowserListImpl::GetLastActive() { |
139 if (!last_active_browsers_.empty()) | 134 if (!last_active_browsers_.empty()) |
140 return *(last_active_browsers_.rbegin()); | 135 return *(last_active_browsers_.rbegin()); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 187 |
193 void BrowserListImpl::RemoveBrowserFrom(Browser* browser, | 188 void BrowserListImpl::RemoveBrowserFrom(Browser* browser, |
194 BrowserVector* browser_list) { | 189 BrowserVector* browser_list) { |
195 const iterator remove_browser = | 190 const iterator remove_browser = |
196 std::find(browser_list->begin(), browser_list->end(), browser); | 191 std::find(browser_list->begin(), browser_list->end(), browser); |
197 if (remove_browser != browser_list->end()) | 192 if (remove_browser != browser_list->end()) |
198 browser_list->erase(remove_browser); | 193 browser_list->erase(remove_browser); |
199 } | 194 } |
200 | 195 |
201 } // namespace chrome | 196 } // namespace chrome |
OLD | NEW |