| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 on_close_success, | 144 on_close_success, |
| 145 profile->GetPath()); | 145 profile->GetPath()); |
| 146 } | 146 } |
| 147 | 147 |
| 148 // static | 148 // static |
| 149 void BrowserList::TryToCloseBrowserList(const BrowserVector& browsers_to_close, | 149 void BrowserList::TryToCloseBrowserList(const BrowserVector& browsers_to_close, |
| 150 const base::Callback<void(const base::FilePath&)>& on_close_success, | 150 const base::Callback<void(const base::FilePath&)>& on_close_success, |
| 151 const base::FilePath& profile_path) { | 151 const base::FilePath& profile_path) { |
| 152 for (BrowserVector::const_iterator it = browsers_to_close.begin(); | 152 for (BrowserVector::const_iterator it = browsers_to_close.begin(); |
| 153 it != browsers_to_close.end(); ++it) { | 153 it != browsers_to_close.end(); ++it) { |
| 154 // TODO(mlerman): crbug.com/423229, if we can determine why window() is |
| 155 // false we can better solve the underlying issue here. |
| 156 CHECK((*it)->window()); |
| 154 if ((*it)->CallBeforeUnloadHandlers( | 157 if ((*it)->CallBeforeUnloadHandlers( |
| 155 base::Bind(&BrowserList::PostBeforeUnloadHandlers, | 158 base::Bind(&BrowserList::PostBeforeUnloadHandlers, |
| 156 browsers_to_close, | 159 browsers_to_close, |
| 157 on_close_success, | 160 on_close_success, |
| 158 profile_path))) { | 161 profile_path))) { |
| 159 return; | 162 return; |
| 160 } | 163 } |
| 161 } | 164 } |
| 162 | 165 |
| 163 on_close_success.Run(profile_path); | 166 on_close_success.Run(profile_path); |
| 164 | 167 |
| 165 for (BrowserVector::const_iterator it = browsers_to_close.begin(); | 168 for (BrowserVector::const_iterator it = browsers_to_close.begin(); |
| 166 it != browsers_to_close.end(); ++it) | 169 it != browsers_to_close.end(); ++it) { |
| 170 // TODO(mlerman): If reproducible, determine cause if window() being null. |
| 171 CHECK((*it)); |
| 172 CHECK((*it)->window()); |
| 167 (*it)->window()->Close(); | 173 (*it)->window()->Close(); |
| 174 } |
| 168 } | 175 } |
| 169 | 176 |
| 170 // static | 177 // static |
| 171 void BrowserList::PostBeforeUnloadHandlers( | 178 void BrowserList::PostBeforeUnloadHandlers( |
| 172 const BrowserVector& browsers_to_close, | 179 const BrowserVector& browsers_to_close, |
| 173 const base::Callback<void(const base::FilePath&)>& on_close_success, | 180 const base::Callback<void(const base::FilePath&)>& on_close_success, |
| 174 const base::FilePath& profile_path, | 181 const base::FilePath& profile_path, |
| 175 bool tab_close_confirmed) { | 182 bool tab_close_confirmed) { |
| 176 // We need this bool to avoid infinite recursion when resetting the | 183 // We need this bool to avoid infinite recursion when resetting the |
| 177 // BeforeUnload handlers, since doing that will trigger calls back to this | 184 // BeforeUnload handlers, since doing that will trigger calls back to this |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 } | 240 } |
| 234 | 241 |
| 235 // static | 242 // static |
| 236 void BrowserList::RemoveBrowserFrom(Browser* browser, | 243 void BrowserList::RemoveBrowserFrom(Browser* browser, |
| 237 BrowserVector* browser_list) { | 244 BrowserVector* browser_list) { |
| 238 BrowserVector::iterator remove_browser = | 245 BrowserVector::iterator remove_browser = |
| 239 std::find(browser_list->begin(), browser_list->end(), browser); | 246 std::find(browser_list->begin(), browser_list->end(), browser); |
| 240 if (remove_browser != browser_list->end()) | 247 if (remove_browser != browser_list->end()) |
| 241 browser_list->erase(remove_browser); | 248 browser_list->erase(remove_browser); |
| 242 } | 249 } |
| OLD | NEW |