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

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

Issue 42353002: Introduce WindowStateDelegate::ToggleFullscreen (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: exclude accelerator_commands_browsertest on win Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/ash/chrome_shell_delegate.h" 5 #include "chrome/browser/ui/ash/chrome_shell_delegate.h"
6 6
7 #include "apps/shell_window.h" 7 #include "apps/shell_window.h"
8 #include "apps/shell_window_registry.h" 8 #include "apps/shell_window_registry.h"
9 #include "ash/host/root_window_host_factory.h" 9 #include "ash/host/root_window_host_factory.h"
10 #include "ash/magnifier/magnifier_constants.h" 10 #include "ash/magnifier/magnifier_constants.h"
11 #include "ash/wm/window_state.h" 11 #include "ash/wm/window_state.h"
12 #include "ash/wm/window_util.h" 12 #include "ash/wm/window_util.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "chrome/browser/app_mode/app_mode_utils.h" 14 #include "chrome/browser/app_mode/app_mode_utils.h"
15 #include "chrome/browser/lifetime/application_lifetime.h" 15 #include "chrome/browser/lifetime/application_lifetime.h"
16 #include "chrome/browser/profiles/profile_manager.h" 16 #include "chrome/browser/profiles/profile_manager.h"
17 #include "chrome/browser/ui/app_list/app_list_view_delegate.h" 17 #include "chrome/browser/ui/app_list/app_list_view_delegate.h"
18 #include "chrome/browser/ui/ash/app_list/app_list_controller_ash.h" 18 #include "chrome/browser/ui/ash/app_list/app_list_controller_ash.h"
19 #include "chrome/browser/ui/ash/ash_keyboard_controller_proxy.h" 19 #include "chrome/browser/ui/ash/ash_keyboard_controller_proxy.h"
20 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 20 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
21 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" 21 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h"
22 #include "chrome/browser/ui/ash/user_action_handler.h" 22 #include "chrome/browser/ui/ash/user_action_handler.h"
23 #include "chrome/browser/ui/browser_commands.h" 23 #include "chrome/browser/ui/browser_commands.h"
24 #include "chrome/browser/ui/browser_finder.h"
25 #include "chrome/common/chrome_switches.h" 24 #include "chrome/common/chrome_switches.h"
26 #include "content/public/browser/user_metrics.h" 25 #include "content/public/browser/user_metrics.h"
27 #include "grit/chromium_strings.h" 26 #include "grit/chromium_strings.h"
28 #include "grit/generated_resources.h" 27 #include "grit/generated_resources.h"
29 #include "ui/base/l10n/l10n_util.h" 28 #include "ui/base/l10n/l10n_util.h"
30 29
31 #if defined(OS_CHROMEOS) 30 #if defined(OS_CHROMEOS)
32 #include "chrome/browser/chromeos/login/default_pinned_apps_field_trial.h" 31 #include "chrome/browser/chromeos/login/default_pinned_apps_field_trial.h"
33 #include "chrome/browser/chromeos/login/user_manager.h" 32 #include "chrome/browser/chromeos/login/user_manager.h"
34 #endif 33 #endif
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 } 79 }
81 80
82 bool ChromeShellDelegate::IsRunningInForcedAppMode() const { 81 bool ChromeShellDelegate::IsRunningInForcedAppMode() const {
83 return chrome::IsRunningInForcedAppMode(); 82 return chrome::IsRunningInForcedAppMode();
84 } 83 }
85 84
86 void ChromeShellDelegate::Exit() { 85 void ChromeShellDelegate::Exit() {
87 chrome::AttemptUserExit(); 86 chrome::AttemptUserExit();
88 } 87 }
89 88
90 void ChromeShellDelegate::ToggleFullscreen() {
91 // Only toggle if the user has a window open.
92 aura::Window* window = ash::wm::GetActiveWindow();
93 if (!window)
94 return;
95 ash::wm::WindowState* window_state = ash::wm::GetWindowState(window);
96
97 bool is_fullscreen = window_state->IsFullscreen();
98
99 // Windows which cannot be maximized should not be fullscreened.
100 if (!is_fullscreen && !window_state->CanMaximize())
101 return;
102
103 Browser* browser = chrome::FindBrowserWithWindow(window);
104 if (browser) {
105 // If a window is fullscreen, exit fullscreen.
106 if (is_fullscreen) {
107 chrome::ToggleFullscreenMode(browser);
108 return;
109 }
110
111 // AppNonClientFrameViewAsh shows only the window controls and no other
112 // window decorations which is pretty close to fullscreen. Put v1 apps
113 // into maximized mode instead of fullscreen to avoid showing the ugly
114 // fullscreen exit bubble.
115 #if defined(OS_WIN)
116 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_NATIVE) {
117 chrome::ToggleFullscreenMode(browser);
118 return;
119 }
120 #endif // OS_WIN
121 if (browser->is_app() && browser->app_type() != Browser::APP_TYPE_CHILD)
122 window_state->ToggleMaximized();
123 else
124 chrome::ToggleFullscreenMode(browser);
125 return;
126 }
127
128 // |window| may belong to a shell window.
129 apps::ShellWindow* shell_window = apps::ShellWindowRegistry::
130 GetShellWindowForNativeWindowAnyProfile(window);
131 if (shell_window) {
132 if (is_fullscreen)
133 shell_window->Restore();
134 else
135 shell_window->Fullscreen();
136 }
137 }
138
139 content::BrowserContext* ChromeShellDelegate::GetCurrentBrowserContext() { 89 content::BrowserContext* ChromeShellDelegate::GetCurrentBrowserContext() {
140 return ProfileManager::GetDefaultProfile(); 90 return ProfileManager::GetDefaultProfile();
141 } 91 }
142 92
143 app_list::AppListViewDelegate* 93 app_list::AppListViewDelegate*
144 ChromeShellDelegate::CreateAppListViewDelegate() { 94 ChromeShellDelegate::CreateAppListViewDelegate() {
145 DCHECK(ash::Shell::HasInstance()); 95 DCHECK(ash::Shell::HasInstance());
146 // Shell will own the created delegate, and the delegate will own 96 // Shell will own the created delegate, and the delegate will own
147 // the controller. 97 // the controller.
148 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); 98 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord();
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 } 285 }
336 286
337 string16 ChromeShellDelegate::GetProductName() const { 287 string16 ChromeShellDelegate::GetProductName() const {
338 return l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); 288 return l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
339 } 289 }
340 290
341 keyboard::KeyboardControllerProxy* 291 keyboard::KeyboardControllerProxy*
342 ChromeShellDelegate::CreateKeyboardControllerProxy() { 292 ChromeShellDelegate::CreateKeyboardControllerProxy() {
343 return new AshKeyboardControllerProxy(); 293 return new AshKeyboardControllerProxy();
344 } 294 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/chrome_shell_delegate.h ('k') | chrome/browser/ui/ash/chrome_shell_delegate_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698