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

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 "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
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 #if 0
154 void ChromeShellDelegate::ToggleFullscreen() { 155 void ChromeShellDelegate::ToggleFullscreen() {
155 // Only toggle if the user has a window open. 156 // Only toggle if the user has a window open.
156 aura::Window* window = ash::wm::GetActiveWindow(); 157 aura::Window* window = ash::wm::GetActiveWindow();
157 if (!window) 158 if (!window)
158 return; 159 return;
159 ash::wm::WindowState* window_state = ash::wm::GetWindowState(window); 160 ash::wm::WindowState* window_state = ash::wm::GetWindowState(window);
160 161
161 bool is_fullscreen = window_state->IsFullscreen(); 162 bool is_fullscreen = window_state->IsFullscreen();
162 163
163 // Windows which cannot be maximized should not be fullscreened. 164 // Windows which cannot be maximized should not be fullscreened.
164 if (!is_fullscreen && !window_state->CanMaximize()) 165 if (!is_fullscreen && !window_state->CanMaximize())
165 return; 166 return;
166 167
167 Browser* browser = chrome::FindBrowserWithWindow(window); 168 Browser* browser = chrome::FindBrowserWithWindow(window);
168 if (browser) { 169 if (browser) {
169 // If a window is fullscreen, exit fullscreen. 170 chrome::ToggleFullscreenMode(browser);
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; 171 return;
190 } 172 }
191 173
192 // |window| may belong to a shell window. 174 // |window| may belong to a shell window.
193 apps::ShellWindow* shell_window = apps::ShellWindowRegistry:: 175 apps::ShellWindow* shell_window = apps::ShellWindowRegistry::
194 GetShellWindowForNativeWindowAnyProfile(window); 176 GetShellWindowForNativeWindowAnyProfile(window);
195 if (shell_window) { 177 if (shell_window) {
196 if (is_fullscreen) 178 if (is_fullscreen)
197 shell_window->Restore(); 179 shell_window->Restore();
198 else 180 else
199 shell_window->Fullscreen(); 181 shell_window->Fullscreen();
200 } 182 }
201 } 183 }
184 #endif
202 185
203 void ChromeShellDelegate::RestoreTab() { 186 void ChromeShellDelegate::RestoreTab() {
204 if (tab_restore_helper_.get()) { 187 if (tab_restore_helper_.get()) {
205 DCHECK(!tab_restore_helper_->tab_restore_service()->IsLoaded()); 188 DCHECK(!tab_restore_helper_->tab_restore_service()->IsLoaded());
206 return; 189 return;
207 } 190 }
208 191
209 Browser* browser = chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()); 192 Browser* browser = chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow());
210 Profile* profile = browser ? browser->profile() : NULL; 193 Profile* profile = browser ? browser->profile() : NULL;
211 if (!profile) 194 if (!profile)
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 } 428 }
446 429
447 Browser* ChromeShellDelegate::GetTargetBrowserIfAvailable() { 430 Browser* ChromeShellDelegate::GetTargetBrowserIfAvailable() {
448 return chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()); 431 return chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow());
449 } 432 }
450 433
451 keyboard::KeyboardControllerProxy* 434 keyboard::KeyboardControllerProxy*
452 ChromeShellDelegate::CreateKeyboardControllerProxy() { 435 ChromeShellDelegate::CreateKeyboardControllerProxy() {
453 return new AshKeyboardControllerProxy(); 436 return new AshKeyboardControllerProxy();
454 } 437 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698