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 "apps/ui/native_app_window.h" | 9 #include "apps/ui/native_app_window.h" |
10 #include "ash/host/root_window_host_factory.h" | 10 #include "ash/host/root_window_host_factory.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 browser->window()->Show(); | 144 browser->window()->Show(); |
145 } | 145 } |
146 | 146 |
147 void ChromeShellDelegate::NewWindow(bool is_incognito) { | 147 void ChromeShellDelegate::NewWindow(bool is_incognito) { |
148 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); | 148 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); |
149 chrome::NewEmptyWindow( | 149 chrome::NewEmptyWindow( |
150 is_incognito ? profile->GetOffTheRecordProfile() : profile, | 150 is_incognito ? profile->GetOffTheRecordProfile() : profile, |
151 chrome::HOST_DESKTOP_TYPE_ASH); | 151 chrome::HOST_DESKTOP_TYPE_ASH); |
152 } | 152 } |
153 | 153 |
154 void ChromeShellDelegate::ToggleFullscreen() { | |
155 // Only toggle if the user has a window open. | |
156 aura::Window* window = ash::wm::GetActiveWindow(); | |
157 if (!window) | |
158 return; | |
159 ash::wm::WindowState* window_state = ash::wm::GetWindowState(window); | |
160 | |
161 bool is_fullscreen = window_state->IsFullscreen(); | |
162 | |
163 // Windows which cannot be maximized should not be fullscreened. | |
164 if (!is_fullscreen && !window_state->CanMaximize()) | |
165 return; | |
166 | |
167 Browser* browser = chrome::FindBrowserWithWindow(window); | |
168 if (browser) { | |
169 // If a window is fullscreen, exit fullscreen. | |
170 if (is_fullscreen) { | |
171 chrome::ToggleFullscreenMode(browser); | |
172 return; | |
173 } | |
174 | |
175 // AppNonClientFrameViewAsh shows only the window controls and no other | |
176 // window decorations which is pretty close to fullscreen. Put v1 apps | |
177 // into maximized mode instead of fullscreen to avoid showing the ugly | |
178 // fullscreen exit bubble. | |
179 #if defined(OS_WIN) | |
180 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_NATIVE) { | |
181 chrome::ToggleFullscreenMode(browser); | |
182 return; | |
183 } | |
184 #endif // OS_WIN | |
185 if (browser->is_app() && browser->app_type() != Browser::APP_TYPE_CHILD) | |
186 window_state->ToggleMaximized(); | |
187 else | |
188 chrome::ToggleFullscreenMode(browser); | |
189 return; | |
190 } | |
191 | |
192 // |window| may belong to a shell window. | |
193 apps::ShellWindow* shell_window = apps::ShellWindowRegistry:: | |
194 GetShellWindowForNativeWindowAnyProfile(window); | |
195 if (shell_window) { | |
196 if (is_fullscreen) | |
197 shell_window->Restore(); | |
198 else | |
199 shell_window->Fullscreen(); | |
200 } | |
201 } | |
202 | |
203 void ChromeShellDelegate::RestoreTab() { | 154 void ChromeShellDelegate::RestoreTab() { |
204 if (tab_restore_helper_.get()) { | 155 if (tab_restore_helper_.get()) { |
205 DCHECK(!tab_restore_helper_->tab_restore_service()->IsLoaded()); | 156 DCHECK(!tab_restore_helper_->tab_restore_service()->IsLoaded()); |
206 return; | 157 return; |
207 } | 158 } |
208 | 159 |
209 Browser* browser = chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()); | 160 Browser* browser = chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()); |
210 Profile* profile = browser ? browser->profile() : NULL; | 161 Profile* profile = browser ? browser->profile() : NULL; |
211 if (!profile) | 162 if (!profile) |
212 profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); | 163 profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 } | 396 } |
446 | 397 |
447 Browser* ChromeShellDelegate::GetTargetBrowserIfAvailable() { | 398 Browser* ChromeShellDelegate::GetTargetBrowserIfAvailable() { |
448 return chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()); | 399 return chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()); |
449 } | 400 } |
450 | 401 |
451 keyboard::KeyboardControllerProxy* | 402 keyboard::KeyboardControllerProxy* |
452 ChromeShellDelegate::CreateKeyboardControllerProxy() { | 403 ChromeShellDelegate::CreateKeyboardControllerProxy() { |
453 return new AshKeyboardControllerProxy(); | 404 return new AshKeyboardControllerProxy(); |
454 } | 405 } |
OLD | NEW |