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.h" | 5 #include "chrome/browser/ui/browser_list.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 it != browsers_to_close.end(); ++it) { | 158 it != browsers_to_close.end(); ++it) { |
159 if ((*it)->TryToCloseWindow( | 159 if ((*it)->TryToCloseWindow( |
160 skip_beforeunload, | 160 skip_beforeunload, |
161 base::Bind(&BrowserList::PostTryToCloseBrowserWindow, | 161 base::Bind(&BrowserList::PostTryToCloseBrowserWindow, |
162 browsers_to_close, on_close_success, on_close_aborted, | 162 browsers_to_close, on_close_success, on_close_aborted, |
163 profile_path, skip_beforeunload))) { | 163 profile_path, skip_beforeunload))) { |
164 return; | 164 return; |
165 } | 165 } |
166 } | 166 } |
167 | 167 |
168 on_close_success.Run(profile_path); | 168 if (on_close_success) |
| 169 on_close_success.Run(profile_path); |
169 | 170 |
170 for (Browser* b : browsers_to_close) { | 171 for (Browser* b : browsers_to_close) { |
171 // BeforeUnload handlers may close browser windows, so we need to explicitly | 172 // BeforeUnload handlers may close browser windows, so we need to explicitly |
172 // check whether they still exist. | 173 // check whether they still exist. |
173 if (b->window()) | 174 if (b->window()) |
174 b->window()->Close(); | 175 b->window()->Close(); |
175 } | 176 } |
176 } | 177 } |
177 | 178 |
178 // static | 179 // static |
(...skipping 11 matching lines...) Expand all Loading... |
190 | 191 |
191 if (tab_close_confirmed) { | 192 if (tab_close_confirmed) { |
192 TryToCloseBrowserList(browsers_to_close, on_close_success, on_close_aborted, | 193 TryToCloseBrowserList(browsers_to_close, on_close_success, on_close_aborted, |
193 profile_path, skip_beforeunload); | 194 profile_path, skip_beforeunload); |
194 } else if (!resetting_handlers) { | 195 } else if (!resetting_handlers) { |
195 base::AutoReset<bool> resetting_handlers_scoper(&resetting_handlers, true); | 196 base::AutoReset<bool> resetting_handlers_scoper(&resetting_handlers, true); |
196 for (BrowserVector::const_iterator it = browsers_to_close.begin(); | 197 for (BrowserVector::const_iterator it = browsers_to_close.begin(); |
197 it != browsers_to_close.end(); ++it) { | 198 it != browsers_to_close.end(); ++it) { |
198 (*it)->ResetTryToCloseWindow(); | 199 (*it)->ResetTryToCloseWindow(); |
199 } | 200 } |
200 on_close_aborted.Run(profile_path); | 201 if (on_close_aborted) |
| 202 on_close_aborted.Run(profile_path); |
201 } | 203 } |
202 } | 204 } |
203 | 205 |
204 // static | 206 // static |
205 void BrowserList::MoveBrowsersInWorkspaceToFront( | 207 void BrowserList::MoveBrowsersInWorkspaceToFront( |
206 const std::string& new_workspace) { | 208 const std::string& new_workspace) { |
207 DCHECK(!new_workspace.empty()); | 209 DCHECK(!new_workspace.empty()); |
208 | 210 |
209 BrowserList* instance = GetInstance(); | 211 BrowserList* instance = GetInstance(); |
210 | 212 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 } | 287 } |
286 | 288 |
287 // static | 289 // static |
288 void BrowserList::RemoveBrowserFrom(Browser* browser, | 290 void BrowserList::RemoveBrowserFrom(Browser* browser, |
289 BrowserVector* browser_list) { | 291 BrowserVector* browser_list) { |
290 BrowserVector::iterator remove_browser = | 292 BrowserVector::iterator remove_browser = |
291 std::find(browser_list->begin(), browser_list->end(), browser); | 293 std::find(browser_list->begin(), browser_list->end(), browser); |
292 if (remove_browser != browser_list->end()) | 294 if (remove_browser != browser_list->end()) |
293 browser_list->erase(remove_browser); | 295 browser_list->erase(remove_browser); |
294 } | 296 } |
OLD | NEW |