| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/browser.h" | 5 #include "chrome/browser/browser.h" |
| 6 | 6 |
| 7 #include "app/animation.h" | 7 #include "app/animation.h" |
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/idle_timer.h" | 10 #include "base/idle_timer.h" |
| (...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1550 bool Browser::RunUnloadListenerBeforeClosing(TabContents* contents) { | 1550 bool Browser::RunUnloadListenerBeforeClosing(TabContents* contents) { |
| 1551 // If the TabContents is not connected yet, then there's no unload | 1551 // If the TabContents is not connected yet, then there's no unload |
| 1552 // handler we can fire even if the TabContents has an unload listener. | 1552 // handler we can fire even if the TabContents has an unload listener. |
| 1553 // One case where we hit this is in a tab that has an infinite loop | 1553 // One case where we hit this is in a tab that has an infinite loop |
| 1554 // before load. | 1554 // before load. |
| 1555 if (TabHasUnloadListener(contents)) { | 1555 if (TabHasUnloadListener(contents)) { |
| 1556 // If the page has unload listeners, then we tell the renderer to fire | 1556 // If the page has unload listeners, then we tell the renderer to fire |
| 1557 // them. Once they have fired, we'll get a message back saying whether | 1557 // them. Once they have fired, we'll get a message back saying whether |
| 1558 // to proceed closing the page or not, which sends us back to this method | 1558 // to proceed closing the page or not, which sends us back to this method |
| 1559 // with the HasUnloadListener bit cleared. | 1559 // with the HasUnloadListener bit cleared. |
| 1560 contents->render_view_host()->FirePageBeforeUnload(); | 1560 contents->render_view_host()->FirePageBeforeUnload(false); |
| 1561 return true; | 1561 return true; |
| 1562 } | 1562 } |
| 1563 return false; | 1563 return false; |
| 1564 } | 1564 } |
| 1565 | 1565 |
| 1566 bool Browser::CanCloseContentsAt(int index) { | 1566 bool Browser::CanCloseContentsAt(int index) { |
| 1567 if (tabstrip_model_.count() > 1) | 1567 if (tabstrip_model_.count() > 1) |
| 1568 return true; | 1568 return true; |
| 1569 // We are closing the last tab for this browser. Make sure to check for | 1569 // We are closing the last tab for this browser. Make sure to check for |
| 1570 // in-progress downloads. | 1570 // in-progress downloads. |
| (...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2463 return; | 2463 return; |
| 2464 } | 2464 } |
| 2465 | 2465 |
| 2466 // Process beforeunload tabs first. When that queue is empty, process | 2466 // Process beforeunload tabs first. When that queue is empty, process |
| 2467 // unload tabs. | 2467 // unload tabs. |
| 2468 if (!tabs_needing_before_unload_fired_.empty()) { | 2468 if (!tabs_needing_before_unload_fired_.empty()) { |
| 2469 TabContents* tab = *(tabs_needing_before_unload_fired_.begin()); | 2469 TabContents* tab = *(tabs_needing_before_unload_fired_.begin()); |
| 2470 // Null check render_view_host here as this gets called on a PostTask and | 2470 // Null check render_view_host here as this gets called on a PostTask and |
| 2471 // the tab's render_view_host may have been nulled out. | 2471 // the tab's render_view_host may have been nulled out. |
| 2472 if (tab->render_view_host()) { | 2472 if (tab->render_view_host()) { |
| 2473 tab->render_view_host()->FirePageBeforeUnload(); | 2473 tab->render_view_host()->FirePageBeforeUnload(false); |
| 2474 } else { | 2474 } else { |
| 2475 ClearUnloadState(tab); | 2475 ClearUnloadState(tab); |
| 2476 } | 2476 } |
| 2477 } else if (!tabs_needing_unload_fired_.empty()) { | 2477 } else if (!tabs_needing_unload_fired_.empty()) { |
| 2478 // We've finished firing all beforeunload events and can proceed with unload | 2478 // We've finished firing all beforeunload events and can proceed with unload |
| 2479 // events. | 2479 // events. |
| 2480 // TODO(ojan): We should add a call to browser_shutdown::OnShutdownStarting | 2480 // TODO(ojan): We should add a call to browser_shutdown::OnShutdownStarting |
| 2481 // somewhere around here so that we have accurate measurements of shutdown | 2481 // somewhere around here so that we have accurate measurements of shutdown |
| 2482 // time. | 2482 // time. |
| 2483 // TODO(ojan): We can probably fire all the unload events in parallel and | 2483 // TODO(ojan): We can probably fire all the unload events in parallel and |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2770 /////////////////////////////////////////////////////////////////////////////// | 2770 /////////////////////////////////////////////////////////////////////////////// |
| 2771 // BrowserToolbarModel (private): | 2771 // BrowserToolbarModel (private): |
| 2772 | 2772 |
| 2773 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { | 2773 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { |
| 2774 // This |current_tab| can be NULL during the initialization of the | 2774 // This |current_tab| can be NULL during the initialization of the |
| 2775 // toolbar during window creation (i.e. before any tabs have been added | 2775 // toolbar during window creation (i.e. before any tabs have been added |
| 2776 // to the window). | 2776 // to the window). |
| 2777 TabContents* current_tab = browser_->GetSelectedTabContents(); | 2777 TabContents* current_tab = browser_->GetSelectedTabContents(); |
| 2778 return current_tab ? ¤t_tab->controller() : NULL; | 2778 return current_tab ? ¤t_tab->controller() : NULL; |
| 2779 } | 2779 } |
| OLD | NEW |