OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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.h" | 5 #include "chrome/browser/ui/browser.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 TabRestoreServiceFactory::GetForProfile(profile()); | 739 TabRestoreServiceFactory::GetForProfile(profile()); |
740 | 740 |
741 #if defined(USE_AURA) | 741 #if defined(USE_AURA) |
742 if (tab_restore_service && is_app() && !is_devtools()) | 742 if (tab_restore_service && is_app() && !is_devtools()) |
743 tab_restore_service->BrowserClosing(live_tab_context()); | 743 tab_restore_service->BrowserClosing(live_tab_context()); |
744 #endif | 744 #endif |
745 | 745 |
746 if (tab_restore_service && is_type_tabbed() && tab_strip_model_->count()) | 746 if (tab_restore_service && is_type_tabbed() && tab_strip_model_->count()) |
747 tab_restore_service->BrowserClosing(live_tab_context()); | 747 tab_restore_service->BrowserClosing(live_tab_context()); |
748 | 748 |
749 // TODO(sky): convert session/tab restore to use notification. | 749 BrowserList::NotifyBrowserCloseStarted(this); |
750 content::NotificationService::current()->Notify( | |
751 chrome::NOTIFICATION_BROWSER_CLOSING, | |
752 content::Source<Browser>(this), | |
753 content::NotificationService::NoDetails()); | |
754 | 750 |
755 if (!IsFastTabUnloadEnabled()) | 751 if (!IsFastTabUnloadEnabled()) |
756 tab_strip_model_->CloseAllTabs(); | 752 tab_strip_model_->CloseAllTabs(); |
757 } | 753 } |
758 | 754 |
759 //////////////////////////////////////////////////////////////////////////////// | 755 //////////////////////////////////////////////////////////////////////////////// |
760 // In-progress download termination handling: | 756 // In-progress download termination handling: |
761 | 757 |
762 void Browser::InProgressDownloadResponse(bool cancel_downloads) { | 758 void Browser::InProgressDownloadResponse(bool cancel_downloads) { |
763 if (cancel_downloads) { | 759 if (cancel_downloads) { |
(...skipping 1785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2549 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); | 2545 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); |
2550 } | 2546 } |
2551 | 2547 |
2552 bool Browser::ShouldHideUIForFullscreen() const { | 2548 bool Browser::ShouldHideUIForFullscreen() const { |
2553 // Windows and GTK remove the browser controls in fullscreen, but Mac and Ash | 2549 // Windows and GTK remove the browser controls in fullscreen, but Mac and Ash |
2554 // keep the controls in a slide-down panel. | 2550 // keep the controls in a slide-down panel. |
2555 return window_ && window_->ShouldHideUIForFullscreen(); | 2551 return window_ && window_->ShouldHideUIForFullscreen(); |
2556 } | 2552 } |
2557 | 2553 |
2558 bool Browser::ShouldStartShutdown() const { | 2554 bool Browser::ShouldStartShutdown() const { |
2559 return BrowserList::GetInstance()->size() <= 1; | 2555 DCHECK_GE(BrowserList::GetInstance()->size(), |
| 2556 BrowserList::GetInstance()->currently_closing_browsers_count()); |
| 2557 // Start shutdown process only when closing the last browser. |
| 2558 return BrowserList::GetInstance()->size() == |
| 2559 BrowserList::GetInstance()->currently_closing_browsers_count() + 1; |
2560 } | 2560 } |
2561 | 2561 |
2562 bool Browser::MaybeCreateBackgroundContents( | 2562 bool Browser::MaybeCreateBackgroundContents( |
2563 content::SiteInstance* source_site_instance, | 2563 content::SiteInstance* source_site_instance, |
2564 const GURL& opener_url, | 2564 const GURL& opener_url, |
2565 int32_t route_id, | 2565 int32_t route_id, |
2566 int32_t main_frame_route_id, | 2566 int32_t main_frame_route_id, |
2567 int32_t main_frame_widget_route_id, | 2567 int32_t main_frame_widget_route_id, |
2568 const std::string& frame_name, | 2568 const std::string& frame_name, |
2569 const GURL& target_url, | 2569 const GURL& target_url, |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2638 // new window later, thus we need to navigate the window now. | 2638 // new window later, thus we need to navigate the window now. |
2639 if (contents) { | 2639 if (contents) { |
2640 contents->web_contents()->GetController().LoadURL( | 2640 contents->web_contents()->GetController().LoadURL( |
2641 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, | 2641 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, |
2642 std::string()); // No extra headers. | 2642 std::string()); // No extra headers. |
2643 } | 2643 } |
2644 } | 2644 } |
2645 | 2645 |
2646 return contents != NULL; | 2646 return contents != NULL; |
2647 } | 2647 } |
OLD | NEW |