| 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 "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" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |