Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Side by Side Diff: chrome/browser/ui/browser.cc

Issue 1388303002: Move assorted function in application_lifetime to where they are used. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 #include "ui/base/touch/touch_device.h" 212 #include "ui/base/touch/touch_device.h"
213 #include "ui/base/win/shell.h" 213 #include "ui/base/win/shell.h"
214 #endif // OS_WIN 214 #endif // OS_WIN
215 215
216 #if defined(OS_CHROMEOS) 216 #if defined(OS_CHROMEOS)
217 #include "chrome/browser/chromeos/fileapi/external_file_url_util.h" 217 #include "chrome/browser/chromeos/fileapi/external_file_url_util.h"
218 #endif 218 #endif
219 219
220 #if defined(USE_ASH) 220 #if defined(USE_ASH)
221 #include "ash/ash_switches.h" 221 #include "ash/ash_switches.h"
222 #include "ash/shell.h"
222 #endif 223 #endif
223 224
224 using base::TimeDelta; 225 using base::TimeDelta;
225 using base::UserMetricsAction; 226 using base::UserMetricsAction;
226 using content::NativeWebKeyboardEvent; 227 using content::NativeWebKeyboardEvent;
227 using content::NavigationController; 228 using content::NavigationController;
228 using content::NavigationEntry; 229 using content::NavigationEntry;
229 using content::OpenURLParams; 230 using content::OpenURLParams;
230 using content::PluginService; 231 using content::PluginService;
231 using content::Referrer; 232 using content::Referrer;
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 if (!ShouldCloseWindow()) 707 if (!ShouldCloseWindow())
707 return; 708 return;
708 709
709 // Application should shutdown on last window close if the user is explicitly 710 // Application should shutdown on last window close if the user is explicitly
710 // trying to quit, or if there is nothing keeping the browser alive (such as 711 // trying to quit, or if there is nothing keeping the browser alive (such as
711 // AppController on the Mac, or BackgroundContentsService for background 712 // AppController on the Mac, or BackgroundContentsService for background
712 // pages). 713 // pages).
713 bool should_quit_if_last_browser = 714 bool should_quit_if_last_browser =
714 browser_shutdown::IsTryingToQuit() || !chrome::WillKeepAlive(); 715 browser_shutdown::IsTryingToQuit() || !chrome::WillKeepAlive();
715 716
716 if (should_quit_if_last_browser && chrome::ShouldStartShutdown(this)) 717 if (should_quit_if_last_browser && ShouldStartShutdown())
717 browser_shutdown::OnShutdownStarting(browser_shutdown::WINDOW_CLOSE); 718 browser_shutdown::OnShutdownStarting(browser_shutdown::WINDOW_CLOSE);
718 719
719 // Don't use GetForProfileIfExisting here, we want to force creation of the 720 // Don't use GetForProfileIfExisting here, we want to force creation of the
720 // session service so that user can restore what was open. 721 // session service so that user can restore what was open.
721 SessionService* session_service = 722 SessionService* session_service =
722 SessionServiceFactory::GetForProfile(profile()); 723 SessionServiceFactory::GetForProfile(profile());
723 if (session_service) 724 if (session_service)
724 session_service->WindowClosing(session_id()); 725 session_service->WindowClosing(session_id());
725 726
726 sessions::TabRestoreService* tab_restore_service = 727 sessions::TabRestoreService* tab_restore_service =
(...skipping 1867 matching lines...) Expand 10 before | Expand all | Expand 10 after
2594 BookmarkBar::ANIMATE_STATE_CHANGE : 2595 BookmarkBar::ANIMATE_STATE_CHANGE :
2595 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); 2596 BookmarkBar::DONT_ANIMATE_STATE_CHANGE);
2596 } 2597 }
2597 2598
2598 bool Browser::ShouldHideUIForFullscreen() const { 2599 bool Browser::ShouldHideUIForFullscreen() const {
2599 // Windows and GTK remove the top controls in fullscreen, but Mac and Ash 2600 // Windows and GTK remove the top controls in fullscreen, but Mac and Ash
2600 // keep the controls in a slide-down panel. 2601 // keep the controls in a slide-down panel.
2601 return window_ && window_->ShouldHideUIForFullscreen(); 2602 return window_ && window_->ShouldHideUIForFullscreen();
2602 } 2603 }
2603 2604
2605 bool Browser::ShouldStartShutdown() const {
2606 if (BrowserList::GetInstance(host_desktop_type())->size() > 1)
2607 return false;
2608 #if defined(OS_WIN)
2609 // On Windows 8 the desktop and ASH environments could be active
2610 // at the same time.
2611 // We should not start the shutdown process in the following cases:-
2612 // 1. If the desktop type of the browser going away is ASH and there
2613 // are browser windows open in the desktop.
2614 // 2. If the desktop type of the browser going away is desktop and the ASH
2615 // environment is still active.
2616 if (host_desktop_type() == chrome::HOST_DESKTOP_TYPE_NATIVE)
2617 return !ash::Shell::HasInstance();
2618 if (host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH)
2619 return BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE)->empty();
2620 #endif
2621 return true;
2622 }
2623
2604 bool Browser::MaybeCreateBackgroundContents( 2624 bool Browser::MaybeCreateBackgroundContents(
2605 int route_id, 2625 int route_id,
2606 int main_frame_route_id, 2626 int main_frame_route_id,
2607 WebContents* opener_web_contents, 2627 WebContents* opener_web_contents,
2608 const std::string& frame_name, 2628 const std::string& frame_name,
2609 const GURL& target_url, 2629 const GURL& target_url,
2610 const std::string& partition_id, 2630 const std::string& partition_id,
2611 content::SessionStorageNamespace* session_storage_namespace) { 2631 content::SessionStorageNamespace* session_storage_namespace) {
2612 GURL opener_url = opener_web_contents->GetURL(); 2632 GURL opener_url = opener_web_contents->GetURL();
2613 ExtensionService* extensions_service = 2633 ExtensionService* extensions_service =
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2681 if (contents && !allow_js_access) { 2701 if (contents && !allow_js_access) {
2682 contents->web_contents()->GetController().LoadURL( 2702 contents->web_contents()->GetController().LoadURL(
2683 target_url, 2703 target_url,
2684 content::Referrer(), 2704 content::Referrer(),
2685 ui::PAGE_TRANSITION_LINK, 2705 ui::PAGE_TRANSITION_LINK,
2686 std::string()); // No extra headers. 2706 std::string()); // No extra headers.
2687 } 2707 }
2688 2708
2689 return contents != NULL; 2709 return contents != NULL;
2690 } 2710 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698