OLD | NEW |
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 "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/host/root_window_host_factory.h" | 8 #include "ash/host/root_window_host_factory.h" |
9 #include "ash/launcher/launcher_types.h" | 9 #include "ash/launcher/launcher_types.h" |
10 #include "ash/magnifier/magnifier_constants.h" | 10 #include "ash/magnifier/magnifier_constants.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 152 |
153 void ChromeShellDelegate::ToggleFullscreen() { | 153 void ChromeShellDelegate::ToggleFullscreen() { |
154 // Only toggle if the user has a window open. | 154 // Only toggle if the user has a window open. |
155 aura::Window* window = ash::wm::GetActiveWindow(); | 155 aura::Window* window = ash::wm::GetActiveWindow(); |
156 if (!window) | 156 if (!window) |
157 return; | 157 return; |
158 | 158 |
159 bool is_fullscreen = ash::wm::IsWindowFullscreen(window); | 159 bool is_fullscreen = ash::wm::IsWindowFullscreen(window); |
160 | 160 |
161 // Windows which cannot be maximized should not be fullscreened. | 161 // Windows which cannot be maximized should not be fullscreened. |
162 if (is_fullscreen && !ash::wm::CanMaximizeWindow(window)) | 162 if (!is_fullscreen && !ash::wm::CanMaximizeWindow(window)) |
163 return; | 163 return; |
164 | 164 |
165 Browser* browser = chrome::FindBrowserWithWindow(window); | 165 Browser* browser = chrome::FindBrowserWithWindow(window); |
166 if (browser) { | 166 if (browser) { |
167 chrome::ToggleFullscreenMode(browser); | 167 // If a window is fullscreen, exit fullscreen. |
| 168 if (is_fullscreen) { |
| 169 chrome::ToggleFullscreenMode(browser); |
| 170 return; |
| 171 } |
| 172 |
| 173 // AppNonClientFrameViewAsh shows only the window controls and no other |
| 174 // window decorations which is pretty close to fullscreen. Put v1 apps |
| 175 // into maximized mode instead of fullscreen to avoid showing the ugly |
| 176 // fullscreen exit bubble. |
| 177 #if defined(OS_WIN) |
| 178 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_NATIVE) { |
| 179 chrome::ToggleFullscreenMode(browser); |
| 180 return; |
| 181 } |
| 182 #endif // OS_WIN |
| 183 if (browser->is_app() && browser->app_type() != Browser::APP_TYPE_CHILD) |
| 184 ash::wm::ToggleMaximizedWindow(window); |
| 185 else |
| 186 chrome::ToggleFullscreenMode(browser); |
168 return; | 187 return; |
169 } | 188 } |
170 | 189 |
171 // |window| may belong to a shell window. | 190 // |window| may belong to a shell window. |
172 ShellWindow* shell_window = extensions::ShellWindowRegistry:: | 191 ShellWindow* shell_window = extensions::ShellWindowRegistry:: |
173 GetShellWindowForNativeWindowAnyProfile(window); | 192 GetShellWindowForNativeWindowAnyProfile(window); |
174 if (shell_window) { | 193 if (shell_window) { |
175 if (is_fullscreen) | 194 if (is_fullscreen) |
176 shell_window->Restore(); | 195 shell_window->Restore(); |
177 else | 196 else |
178 shell_window->Fullscreen(); | 197 shell_window->Fullscreen(); |
179 } | 198 } |
180 } | 199 } |
181 | 200 |
182 void ChromeShellDelegate::ToggleMaximized() { | 201 void ChromeShellDelegate::ToggleMaximized() { |
183 // Only toggle if the user has a window open. | 202 // Only toggle if the user has a window open. |
184 aura::Window* window = ash::wm::GetActiveWindow(); | 203 aura::Window* window = ash::wm::GetActiveWindow(); |
185 if (!window) | 204 if (!window) |
186 return; | 205 return; |
187 | 206 |
188 // TODO(pkotwicz): If immersive mode replaces fullscreen, bind fullscreen to | |
189 // F4 and find a different key binding for maximize. | |
190 if (ImmersiveFullscreenConfiguration::UseImmersiveFullscreen()) { | |
191 ToggleFullscreen(); | |
192 return; | |
193 } | |
194 | |
195 // Get out of fullscreen when in fullscreen mode. | 207 // Get out of fullscreen when in fullscreen mode. |
196 if (ash::wm::IsWindowFullscreen(window)) { | 208 if (ash::wm::IsWindowFullscreen(window)) { |
197 ToggleFullscreen(); | 209 ToggleFullscreen(); |
198 return; | 210 return; |
199 } | 211 } |
200 ash::wm::ToggleMaximizedWindow(window); | 212 ash::wm::ToggleMaximizedWindow(window); |
201 } | 213 } |
202 | 214 |
203 void ChromeShellDelegate::RestoreTab() { | 215 void ChromeShellDelegate::RestoreTab() { |
204 if (tab_restore_helper_.get()) { | 216 if (tab_restore_helper_.get()) { |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 return browser; | 448 return browser; |
437 return chrome::FindOrCreateTabbedBrowser( | 449 return chrome::FindOrCreateTabbedBrowser( |
438 ProfileManager::GetDefaultProfileOrOffTheRecord(), | 450 ProfileManager::GetDefaultProfileOrOffTheRecord(), |
439 chrome::HOST_DESKTOP_TYPE_ASH); | 451 chrome::HOST_DESKTOP_TYPE_ASH); |
440 } | 452 } |
441 | 453 |
442 keyboard::KeyboardControllerProxy* | 454 keyboard::KeyboardControllerProxy* |
443 ChromeShellDelegate::CreateKeyboardControllerProxy() { | 455 ChromeShellDelegate::CreateKeyboardControllerProxy() { |
444 return new AshKeyboardControllerProxy(); | 456 return new AshKeyboardControllerProxy(); |
445 } | 457 } |
OLD | NEW |