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

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: 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" 24 #include "chrome/browser/ui/browser_finder.h"
James Cook 2013/10/29 16:13:04 nit: Is this include still needed? (It might be,
oshima 2013/10/29 17:45:54 Done.
25 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
26 #include "content/public/browser/user_metrics.h" 26 #include "content/public/browser/user_metrics.h"
27 #include "grit/chromium_strings.h" 27 #include "grit/chromium_strings.h"
28 #include "grit/generated_resources.h" 28 #include "grit/generated_resources.h"
29 #include "ui/base/l10n/l10n_util.h" 29 #include "ui/base/l10n/l10n_util.h"
30 30
31 #if defined(OS_CHROMEOS) 31 #if defined(OS_CHROMEOS)
32 #include "chrome/browser/chromeos/login/default_pinned_apps_field_trial.h" 32 #include "chrome/browser/chromeos/login/default_pinned_apps_field_trial.h"
33 #include "chrome/browser/chromeos/login/user_manager.h" 33 #include "chrome/browser/chromeos/login/user_manager.h"
34 #endif 34 #endif
(...skipping 30 matching lines...) Expand all
65 } 65 }
66 66
67 bool ChromeShellDelegate::IsRunningInForcedAppMode() const { 67 bool ChromeShellDelegate::IsRunningInForcedAppMode() const {
68 return chrome::IsRunningInForcedAppMode(); 68 return chrome::IsRunningInForcedAppMode();
69 } 69 }
70 70
71 void ChromeShellDelegate::Exit() { 71 void ChromeShellDelegate::Exit() {
72 chrome::AttemptUserExit(); 72 chrome::AttemptUserExit();
73 } 73 }
74 74
75 void ChromeShellDelegate::ToggleFullscreen() {
76 // Only toggle if the user has a window open.
77 aura::Window* window = ash::wm::GetActiveWindow();
78 if (!window)
79 return;
80 ash::wm::WindowState* window_state = ash::wm::GetWindowState(window);
81
82 bool is_fullscreen = window_state->IsFullscreen();
83
84 // Windows which cannot be maximized should not be fullscreened.
85 if (!is_fullscreen && !window_state->CanMaximize())
86 return;
87
88 Browser* browser = chrome::FindBrowserWithWindow(window);
89 if (browser) {
90 // If a window is fullscreen, exit fullscreen.
91 if (is_fullscreen) {
92 chrome::ToggleFullscreenMode(browser);
93 return;
94 }
95
96 // AppNonClientFrameViewAsh shows only the window controls and no other
97 // window decorations which is pretty close to fullscreen. Put v1 apps
98 // into maximized mode instead of fullscreen to avoid showing the ugly
99 // fullscreen exit bubble.
100 #if defined(OS_WIN)
101 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_NATIVE) {
102 chrome::ToggleFullscreenMode(browser);
103 return;
104 }
105 #endif // OS_WIN
106 if (browser->is_app() && browser->app_type() != Browser::APP_TYPE_CHILD)
107 window_state->ToggleMaximized();
108 else
109 chrome::ToggleFullscreenMode(browser);
110 return;
111 }
112
113 // |window| may belong to a shell window.
114 apps::ShellWindow* shell_window = apps::ShellWindowRegistry::
115 GetShellWindowForNativeWindowAnyProfile(window);
116 if (shell_window) {
117 if (is_fullscreen)
118 shell_window->Restore();
119 else
120 shell_window->Fullscreen();
121 }
122 }
123
124 content::BrowserContext* ChromeShellDelegate::GetCurrentBrowserContext() { 75 content::BrowserContext* ChromeShellDelegate::GetCurrentBrowserContext() {
125 return ProfileManager::GetDefaultProfile(); 76 return ProfileManager::GetDefaultProfile();
126 } 77 }
127 78
128 app_list::AppListViewDelegate* 79 app_list::AppListViewDelegate*
129 ChromeShellDelegate::CreateAppListViewDelegate() { 80 ChromeShellDelegate::CreateAppListViewDelegate() {
130 DCHECK(ash::Shell::HasInstance()); 81 DCHECK(ash::Shell::HasInstance());
131 // Shell will own the created delegate, and the delegate will own 82 // Shell will own the created delegate, and the delegate will own
132 // the controller. 83 // the controller.
133 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); 84 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord();
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 } 271 }
321 272
322 string16 ChromeShellDelegate::GetProductName() const { 273 string16 ChromeShellDelegate::GetProductName() const {
323 return l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); 274 return l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
324 } 275 }
325 276
326 keyboard::KeyboardControllerProxy* 277 keyboard::KeyboardControllerProxy*
327 ChromeShellDelegate::CreateKeyboardControllerProxy() { 278 ChromeShellDelegate::CreateKeyboardControllerProxy() {
328 return new AshKeyboardControllerProxy(); 279 return new AshKeyboardControllerProxy();
329 } 280 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698