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/unload_controller.h" | 5 #include "chrome/browser/ui/unload_controller.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_tabstrip.h" | 10 #include "chrome/browser/ui/browser_tabstrip.h" |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 213 |
214 if (is_attempting_to_close_browser_) | 214 if (is_attempting_to_close_browser_) |
215 ClearUnloadState(contents); | 215 ClearUnloadState(contents); |
216 } | 216 } |
217 | 217 |
218 bool UnloadController::DetachWebContents(content::WebContents* contents) { | 218 bool UnloadController::DetachWebContents(content::WebContents* contents) { |
219 int index = browser_->tab_strip_model()->GetIndexOfWebContents(contents); | 219 int index = browser_->tab_strip_model()->GetIndexOfWebContents(contents); |
220 if (index != TabStripModel::kNoTab && | 220 if (index != TabStripModel::kNoTab && |
221 contents->NeedToFireBeforeUnload()) { | 221 contents->NeedToFireBeforeUnload()) { |
222 tabs_needing_unload_ack_.insert(contents); | 222 tabs_needing_unload_ack_.insert(contents); |
| 223 contents->OnUnloadAboutToDetach(); |
223 browser_->tab_strip_model()->DetachWebContentsAt(index); | 224 browser_->tab_strip_model()->DetachWebContentsAt(index); |
224 contents->SetDelegate(detached_delegate_.get()); | 225 contents->SetDelegate(detached_delegate_.get()); |
225 contents->OnUnloadDetachedStarted(); | 226 contents->OnUnloadDetachedStarted(); |
226 return true; | 227 return true; |
227 } | 228 } |
228 return false; | 229 return false; |
229 } | 230 } |
230 | 231 |
231 void UnloadController::ProcessPendingTabs() { | 232 void UnloadController::ProcessPendingTabs() { |
232 if (!is_attempting_to_close_browser_) { | 233 if (!is_attempting_to_close_browser_) { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 } | 358 } |
358 | 359 |
359 void UnloadController::PostTaskForProcessPendingTabs() { | 360 void UnloadController::PostTaskForProcessPendingTabs() { |
360 base::MessageLoop::current()->PostTask( | 361 base::MessageLoop::current()->PostTask( |
361 FROM_HERE, | 362 FROM_HERE, |
362 base::Bind(&UnloadController::ProcessPendingTabs, | 363 base::Bind(&UnloadController::ProcessPendingTabs, |
363 weak_factory_.GetWeakPtr())); | 364 weak_factory_.GetWeakPtr())); |
364 } | 365 } |
365 | 366 |
366 } // namespace chrome | 367 } // namespace chrome |
OLD | NEW |