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 BrowserList::NotifyBrowserCloseStarted(this); | |
750 | |
749 // TODO(sky): convert session/tab restore to use notification. | 751 // TODO(sky): convert session/tab restore to use notification. |
750 content::NotificationService::current()->Notify( | 752 content::NotificationService::current()->Notify( |
751 chrome::NOTIFICATION_BROWSER_CLOSING, | 753 chrome::NOTIFICATION_BROWSER_CLOSING, |
hashimoto
2017/04/14 08:54:37
How about moving this notification code to Browser
Alexey Seren
2017/04/22 19:52:54
Acknowledged.
| |
752 content::Source<Browser>(this), | 754 content::Source<Browser>(this), |
753 content::NotificationService::NoDetails()); | 755 content::NotificationService::NoDetails()); |
754 | 756 |
755 if (!IsFastTabUnloadEnabled()) | 757 if (!IsFastTabUnloadEnabled()) |
756 tab_strip_model_->CloseAllTabs(); | 758 tab_strip_model_->CloseAllTabs(); |
757 } | 759 } |
758 | 760 |
759 //////////////////////////////////////////////////////////////////////////////// | 761 //////////////////////////////////////////////////////////////////////////////// |
760 // In-progress download termination handling: | 762 // In-progress download termination handling: |
761 | 763 |
(...skipping 1787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2549 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); | 2551 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); |
2550 } | 2552 } |
2551 | 2553 |
2552 bool Browser::ShouldHideUIForFullscreen() const { | 2554 bool Browser::ShouldHideUIForFullscreen() const { |
2553 // Windows and GTK remove the browser controls in fullscreen, but Mac and Ash | 2555 // Windows and GTK remove the browser controls in fullscreen, but Mac and Ash |
2554 // keep the controls in a slide-down panel. | 2556 // keep the controls in a slide-down panel. |
2555 return window_ && window_->ShouldHideUIForFullscreen(); | 2557 return window_ && window_->ShouldHideUIForFullscreen(); |
2556 } | 2558 } |
2557 | 2559 |
2558 bool Browser::ShouldStartShutdown() const { | 2560 bool Browser::ShouldStartShutdown() const { |
2559 return BrowserList::GetInstance()->size() <= 1; | 2561 DCHECK_GE(BrowserList::GetInstance()->size(), |
2562 BrowserList::GetInstance()->currently_closing_browsers_count()); | |
2563 // Start shutdown process only when closing the last browser. | |
2564 return BrowserList::GetInstance()->size() == | |
2565 BrowserList::GetInstance()->currently_closing_browsers_count() + 1; | |
hashimoto
2017/04/14 08:54:37
Sorry, I still don't understand why this change is
Alexey Seren
2017/04/22 19:52:54
This fixes the races happened when two browsers ar
hashimoto
2017/04/28 09:16:29
Thank you for the explanation.
I don't think it's
Alexey Seren
2017/05/03 17:19:44
Actually we cannot cancel shutdown after we have e
| |
2560 } | 2566 } |
2561 | 2567 |
2562 bool Browser::MaybeCreateBackgroundContents( | 2568 bool Browser::MaybeCreateBackgroundContents( |
2563 content::SiteInstance* source_site_instance, | 2569 content::SiteInstance* source_site_instance, |
2564 const GURL& opener_url, | 2570 const GURL& opener_url, |
2565 int32_t route_id, | 2571 int32_t route_id, |
2566 int32_t main_frame_route_id, | 2572 int32_t main_frame_route_id, |
2567 int32_t main_frame_widget_route_id, | 2573 int32_t main_frame_widget_route_id, |
2568 const std::string& frame_name, | 2574 const std::string& frame_name, |
2569 const GURL& target_url, | 2575 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. | 2644 // new window later, thus we need to navigate the window now. |
2639 if (contents) { | 2645 if (contents) { |
2640 contents->web_contents()->GetController().LoadURL( | 2646 contents->web_contents()->GetController().LoadURL( |
2641 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, | 2647 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, |
2642 std::string()); // No extra headers. | 2648 std::string()); // No extra headers. |
2643 } | 2649 } |
2644 } | 2650 } |
2645 | 2651 |
2646 return contents != NULL; | 2652 return contents != NULL; |
2647 } | 2653 } |
OLD | NEW |