Chromium Code Reviews| 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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #endif // defined(OS_WIN) | 10 #endif // defined(OS_WIN) |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 213 #include "ui/base/touch/touch_device.h" | 213 #include "ui/base/touch/touch_device.h" |
| 214 #include "ui/base/win/shell.h" | 214 #include "ui/base/win/shell.h" |
| 215 #endif // OS_WIN | 215 #endif // OS_WIN |
| 216 | 216 |
| 217 #if defined(OS_CHROMEOS) | 217 #if defined(OS_CHROMEOS) |
| 218 #include "chrome/browser/chromeos/fileapi/external_file_url_util.h" | 218 #include "chrome/browser/chromeos/fileapi/external_file_url_util.h" |
| 219 #endif | 219 #endif |
| 220 | 220 |
| 221 #if defined(USE_ASH) | 221 #if defined(USE_ASH) |
| 222 #include "ash/ash_switches.h" | 222 #include "ash/ash_switches.h" |
| 223 #include "ash/shell.h" | |
| 223 #endif | 224 #endif |
| 224 | 225 |
| 225 using base::TimeDelta; | 226 using base::TimeDelta; |
| 226 using base::UserMetricsAction; | 227 using base::UserMetricsAction; |
| 227 using content::NativeWebKeyboardEvent; | 228 using content::NativeWebKeyboardEvent; |
| 228 using content::NavigationController; | 229 using content::NavigationController; |
| 229 using content::NavigationEntry; | 230 using content::NavigationEntry; |
| 230 using content::OpenURLParams; | 231 using content::OpenURLParams; |
| 231 using content::PluginService; | 232 using content::PluginService; |
| 232 using content::Referrer; | 233 using content::Referrer; |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 707 if (!ShouldCloseWindow()) | 708 if (!ShouldCloseWindow()) |
| 708 return; | 709 return; |
| 709 | 710 |
| 710 // Application should shutdown on last window close if the user is explicitly | 711 // Application should shutdown on last window close if the user is explicitly |
| 711 // trying to quit, or if there is nothing keeping the browser alive (such as | 712 // trying to quit, or if there is nothing keeping the browser alive (such as |
| 712 // AppController on the Mac, or BackgroundContentsService for background | 713 // AppController on the Mac, or BackgroundContentsService for background |
| 713 // pages). | 714 // pages). |
| 714 bool should_quit_if_last_browser = | 715 bool should_quit_if_last_browser = |
| 715 browser_shutdown::IsTryingToQuit() || !chrome::WillKeepAlive(); | 716 browser_shutdown::IsTryingToQuit() || !chrome::WillKeepAlive(); |
| 716 | 717 |
| 717 if (should_quit_if_last_browser && chrome::ShouldStartShutdown(this)) { | 718 if (should_quit_if_last_browser && ShouldStartShutdown()) { |
| 718 #if defined(OS_WIN) | 719 #if defined(OS_WIN) |
| 719 browser_watcher::ExitFunnel::RecordSingleEvent( | 720 browser_watcher::ExitFunnel::RecordSingleEvent( |
| 720 chrome::kBrowserExitCodesRegistryPath, L"LastWindowClose"); | 721 chrome::kBrowserExitCodesRegistryPath, L"LastWindowClose"); |
| 721 #endif | 722 #endif |
| 722 browser_shutdown::OnShutdownStarting(browser_shutdown::WINDOW_CLOSE); | 723 browser_shutdown::OnShutdownStarting(browser_shutdown::WINDOW_CLOSE); |
| 723 } | 724 } |
| 724 | 725 |
| 725 // Don't use GetForProfileIfExisting here, we want to force creation of the | 726 // Don't use GetForProfileIfExisting here, we want to force creation of the |
| 726 // session service so that user can restore what was open. | 727 // session service so that user can restore what was open. |
| 727 SessionService* session_service = | 728 SessionService* session_service = |
| (...skipping 1872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2600 BookmarkBar::ANIMATE_STATE_CHANGE : | 2601 BookmarkBar::ANIMATE_STATE_CHANGE : |
| 2601 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); | 2602 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); |
| 2602 } | 2603 } |
| 2603 | 2604 |
| 2604 bool Browser::ShouldHideUIForFullscreen() const { | 2605 bool Browser::ShouldHideUIForFullscreen() const { |
| 2605 // Windows and GTK remove the top controls in fullscreen, but Mac and Ash | 2606 // Windows and GTK remove the top controls in fullscreen, but Mac and Ash |
| 2606 // keep the controls in a slide-down panel. | 2607 // keep the controls in a slide-down panel. |
| 2607 return window_ && window_->ShouldHideUIForFullscreen(); | 2608 return window_ && window_->ShouldHideUIForFullscreen(); |
| 2608 } | 2609 } |
| 2609 | 2610 |
| 2611 bool Browser::ShouldStartShutdown() const { | |
| 2612 if (BrowserList::GetInstance(host_desktop_type())->size() > 1) | |
| 2613 return false; | |
| 2614 #if defined(OS_WIN) | |
| 2615 // On Windows 8 the desktop and ASH environments could be active | |
| 2616 // at the same time. | |
| 2617 // We should not start the shutdown process in the following cases:- | |
| 2618 // 1. If the desktop type of the browser going away is ASH and there | |
| 2619 // are browser windows open in the desktop. | |
| 2620 // 2. If the desktop type of the browser going away is desktop and the ASH | |
| 2621 // environment is still active. | |
| 2622 if (host_desktop_type() == chrome::HOST_DESKTOP_TYPE_NATIVE) | |
| 2623 return !ash::Shell::HasInstance(); | |
| 2624 else if (host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) | |
|
sky
2015/10/07 17:12:32
nit: no else.
Lei Zhang
2015/10/08 07:01:58
copy + paste
| |
| 2625 return BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE)->empty(); | |
| 2626 #endif | |
| 2627 return true; | |
| 2628 } | |
| 2629 | |
| 2610 bool Browser::MaybeCreateBackgroundContents( | 2630 bool Browser::MaybeCreateBackgroundContents( |
| 2611 int route_id, | 2631 int route_id, |
| 2612 int main_frame_route_id, | 2632 int main_frame_route_id, |
| 2613 WebContents* opener_web_contents, | 2633 WebContents* opener_web_contents, |
| 2614 const std::string& frame_name, | 2634 const std::string& frame_name, |
| 2615 const GURL& target_url, | 2635 const GURL& target_url, |
| 2616 const std::string& partition_id, | 2636 const std::string& partition_id, |
| 2617 content::SessionStorageNamespace* session_storage_namespace) { | 2637 content::SessionStorageNamespace* session_storage_namespace) { |
| 2618 GURL opener_url = opener_web_contents->GetURL(); | 2638 GURL opener_url = opener_web_contents->GetURL(); |
| 2619 ExtensionService* extensions_service = | 2639 ExtensionService* extensions_service = |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2687 if (contents && !allow_js_access) { | 2707 if (contents && !allow_js_access) { |
| 2688 contents->web_contents()->GetController().LoadURL( | 2708 contents->web_contents()->GetController().LoadURL( |
| 2689 target_url, | 2709 target_url, |
| 2690 content::Referrer(), | 2710 content::Referrer(), |
| 2691 ui::PAGE_TRANSITION_LINK, | 2711 ui::PAGE_TRANSITION_LINK, |
| 2692 std::string()); // No extra headers. | 2712 std::string()); // No extra headers. |
| 2693 } | 2713 } |
| 2694 | 2714 |
| 2695 return contents != NULL; | 2715 return contents != NULL; |
| 2696 } | 2716 } |
| OLD | NEW |