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

Side by Side Diff: chrome/browser/ui/ash/chrome_shell_delegate.cc

Issue 24108003: [Cleanup] Rename WindowSettings to WindowState (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase fix Created 7 years, 3 months 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/native_app_window.h" 7 #include "apps/native_app_window.h"
8 #include "apps/shell_window.h" 8 #include "apps/shell_window.h"
9 #include "apps/shell_window_registry.h" 9 #include "apps/shell_window_registry.h"
10 #include "ash/host/root_window_host_factory.h" 10 #include "ash/host/root_window_host_factory.h"
11 #include "ash/magnifier/magnifier_constants.h" 11 #include "ash/magnifier/magnifier_constants.h"
12 #include "ash/session_state_delegate.h" 12 #include "ash/session_state_delegate.h"
13 #include "ash/system/tray/system_tray_delegate.h" 13 #include "ash/system/tray/system_tray_delegate.h"
14 #include "ash/wm/window_state.h"
14 #include "ash/wm/window_util.h" 15 #include "ash/wm/window_util.h"
15 #include "base/command_line.h" 16 #include "base/command_line.h"
16 #include "base/prefs/pref_service.h" 17 #include "base/prefs/pref_service.h"
17 #include "chrome/browser/app_mode/app_mode_utils.h" 18 #include "chrome/browser/app_mode/app_mode_utils.h"
18 #include "chrome/browser/lifetime/application_lifetime.h" 19 #include "chrome/browser/lifetime/application_lifetime.h"
19 #include "chrome/browser/profiles/profile_manager.h" 20 #include "chrome/browser/profiles/profile_manager.h"
20 #include "chrome/browser/sessions/tab_restore_service.h" 21 #include "chrome/browser/sessions/tab_restore_service.h"
21 #include "chrome/browser/sessions/tab_restore_service_factory.h" 22 #include "chrome/browser/sessions/tab_restore_service_factory.h"
22 #include "chrome/browser/sessions/tab_restore_service_observer.h" 23 #include "chrome/browser/sessions/tab_restore_service_observer.h"
23 #include "chrome/browser/ui/app_list/app_list_view_delegate.h" 24 #include "chrome/browser/ui/app_list/app_list_view_delegate.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 chrome::NewEmptyWindow( 152 chrome::NewEmptyWindow(
152 is_incognito ? profile->GetOffTheRecordProfile() : profile, 153 is_incognito ? profile->GetOffTheRecordProfile() : profile,
153 chrome::HOST_DESKTOP_TYPE_ASH); 154 chrome::HOST_DESKTOP_TYPE_ASH);
154 } 155 }
155 156
156 void ChromeShellDelegate::ToggleFullscreen() { 157 void ChromeShellDelegate::ToggleFullscreen() {
157 // Only toggle if the user has a window open. 158 // Only toggle if the user has a window open.
158 aura::Window* window = ash::wm::GetActiveWindow(); 159 aura::Window* window = ash::wm::GetActiveWindow();
159 if (!window) 160 if (!window)
160 return; 161 return;
162 ash::wm::WindowState* window_state = ash::wm::GetWindowState(window);
161 163
162 bool is_fullscreen = ash::wm::IsWindowFullscreen(window); 164 bool is_fullscreen = window_state->IsFullscreen();
163 165
164 // Windows which cannot be maximized should not be fullscreened. 166 // Windows which cannot be maximized should not be fullscreened.
165 if (!is_fullscreen && !ash::wm::CanMaximizeWindow(window)) 167 if (!is_fullscreen && !window_state->CanMaximize())
166 return; 168 return;
167 169
168 Browser* browser = chrome::FindBrowserWithWindow(window); 170 Browser* browser = chrome::FindBrowserWithWindow(window);
169 if (browser) { 171 if (browser) {
170 // If a window is fullscreen, exit fullscreen. 172 // If a window is fullscreen, exit fullscreen.
171 if (is_fullscreen) { 173 if (is_fullscreen) {
172 chrome::ToggleFullscreenMode(browser); 174 chrome::ToggleFullscreenMode(browser);
173 return; 175 return;
174 } 176 }
175 177
176 // AppNonClientFrameViewAsh shows only the window controls and no other 178 // AppNonClientFrameViewAsh shows only the window controls and no other
177 // window decorations which is pretty close to fullscreen. Put v1 apps 179 // window decorations which is pretty close to fullscreen. Put v1 apps
178 // into maximized mode instead of fullscreen to avoid showing the ugly 180 // into maximized mode instead of fullscreen to avoid showing the ugly
179 // fullscreen exit bubble. 181 // fullscreen exit bubble.
180 #if defined(OS_WIN) 182 #if defined(OS_WIN)
181 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_NATIVE) { 183 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_NATIVE) {
182 chrome::ToggleFullscreenMode(browser); 184 chrome::ToggleFullscreenMode(browser);
183 return; 185 return;
184 } 186 }
185 #endif // OS_WIN 187 #endif // OS_WIN
186 if (browser->is_app() && browser->app_type() != Browser::APP_TYPE_CHILD) 188 if (browser->is_app() && browser->app_type() != Browser::APP_TYPE_CHILD)
187 ash::wm::ToggleMaximizedWindow(window); 189 window_state->ToggleMaximized();
188 else 190 else
189 chrome::ToggleFullscreenMode(browser); 191 chrome::ToggleFullscreenMode(browser);
190 return; 192 return;
191 } 193 }
192 194
193 // |window| may belong to a shell window. 195 // |window| may belong to a shell window.
194 apps::ShellWindow* shell_window = apps::ShellWindowRegistry:: 196 apps::ShellWindow* shell_window = apps::ShellWindowRegistry::
195 GetShellWindowForNativeWindowAnyProfile(window); 197 GetShellWindowForNativeWindowAnyProfile(window);
196 if (shell_window) { 198 if (shell_window) {
197 if (is_fullscreen) 199 if (is_fullscreen)
198 shell_window->Restore(); 200 shell_window->Restore();
199 else 201 else
200 shell_window->Fullscreen(); 202 shell_window->Fullscreen();
201 } 203 }
202 } 204 }
203 205
204 void ChromeShellDelegate::ToggleMaximized() { 206 void ChromeShellDelegate::ToggleMaximized() {
205 // Only toggle if the user has a window open. 207 // Only toggle if the user has a window open.
206 aura::Window* window = ash::wm::GetActiveWindow(); 208 aura::Window* window = ash::wm::GetActiveWindow();
207 if (!window) 209 if (!window)
208 return; 210 return;
209 211
212 ash::wm::WindowState* window_state = ash::wm::GetWindowState(window);
210 // Get out of fullscreen when in fullscreen mode. 213 // Get out of fullscreen when in fullscreen mode.
211 if (ash::wm::IsWindowFullscreen(window)) { 214 if (window_state->IsFullscreen()) {
212 ToggleFullscreen(); 215 ToggleFullscreen();
213 return; 216 return;
214 } 217 }
215 ash::wm::ToggleMaximizedWindow(window); 218 window_state->ToggleMaximized();
216 } 219 }
217 220
218 void ChromeShellDelegate::RestoreTab() { 221 void ChromeShellDelegate::RestoreTab() {
219 if (tab_restore_helper_.get()) { 222 if (tab_restore_helper_.get()) {
220 DCHECK(!tab_restore_helper_->tab_restore_service()->IsLoaded()); 223 DCHECK(!tab_restore_helper_->tab_restore_service()->IsLoaded());
221 return; 224 return;
222 } 225 }
223 226
224 Browser* browser = chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()); 227 Browser* browser = chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow());
225 Profile* profile = browser ? browser->profile() : NULL; 228 Profile* profile = browser ? browser->profile() : NULL;
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 return browser; 446 return browser;
444 return chrome::FindOrCreateTabbedBrowser( 447 return chrome::FindOrCreateTabbedBrowser(
445 ProfileManager::GetDefaultProfileOrOffTheRecord(), 448 ProfileManager::GetDefaultProfileOrOffTheRecord(),
446 chrome::HOST_DESKTOP_TYPE_ASH); 449 chrome::HOST_DESKTOP_TYPE_ASH);
447 } 450 }
448 451
449 keyboard::KeyboardControllerProxy* 452 keyboard::KeyboardControllerProxy*
450 ChromeShellDelegate::CreateKeyboardControllerProxy() { 453 ChromeShellDelegate::CreateKeyboardControllerProxy() {
451 return new AshKeyboardControllerProxy(); 454 return new AshKeyboardControllerProxy();
452 } 455 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_restore.cc ('k') | chrome/browser/ui/ash/chrome_shell_delegate_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698