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" |
11 #include "ash/wm/window_state.h" | 11 #include "ash/wm/window_state.h" |
12 #include "ash/wm/window_util.h" | 12 #include "ash/wm/window_util.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "chrome/browser/app_mode/app_mode_utils.h" | 14 #include "chrome/browser/app_mode/app_mode_utils.h" |
15 #include "chrome/browser/lifetime/application_lifetime.h" | 15 #include "chrome/browser/lifetime/application_lifetime.h" |
16 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
17 #include "chrome/browser/ui/app_list/app_list_view_delegate.h" | 17 #include "chrome/browser/ui/app_list/app_list_view_delegate.h" |
18 #include "chrome/browser/ui/ash/app_list/app_list_controller_ash.h" | 18 #include "chrome/browser/ui/ash/app_list/app_list_controller_ash.h" |
19 #include "chrome/browser/ui/ash/ash_keyboard_controller_proxy.h" | 19 #include "chrome/browser/ui/ash/ash_keyboard_controller_proxy.h" |
20 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 20 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
21 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" | 21 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" |
22 #include "chrome/browser/ui/ash/user_action_handler.h" | 22 #include "chrome/browser/ui/ash/user_action_handler.h" |
23 #include "chrome/browser/ui/browser_commands.h" | 23 #include "chrome/browser/ui/browser_commands.h" |
24 #include "chrome/browser/ui/browser_finder.h" | |
25 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
26 #include "content/public/browser/user_metrics.h" | 25 #include "content/public/browser/user_metrics.h" |
27 #include "grit/chromium_strings.h" | 26 #include "grit/chromium_strings.h" |
28 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
29 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
30 | 29 |
31 #if defined(OS_CHROMEOS) | 30 #if defined(OS_CHROMEOS) |
32 #include "chrome/browser/chromeos/login/default_pinned_apps_field_trial.h" | 31 #include "chrome/browser/chromeos/login/default_pinned_apps_field_trial.h" |
33 #include "chrome/browser/chromeos/login/user_manager.h" | 32 #include "chrome/browser/chromeos/login/user_manager.h" |
34 #endif | 33 #endif |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } | 79 } |
81 | 80 |
82 bool ChromeShellDelegate::IsRunningInForcedAppMode() const { | 81 bool ChromeShellDelegate::IsRunningInForcedAppMode() const { |
83 return chrome::IsRunningInForcedAppMode(); | 82 return chrome::IsRunningInForcedAppMode(); |
84 } | 83 } |
85 | 84 |
86 void ChromeShellDelegate::Exit() { | 85 void ChromeShellDelegate::Exit() { |
87 chrome::AttemptUserExit(); | 86 chrome::AttemptUserExit(); |
88 } | 87 } |
89 | 88 |
90 void ChromeShellDelegate::ToggleFullscreen() { | |
91 // Only toggle if the user has a window open. | |
92 aura::Window* window = ash::wm::GetActiveWindow(); | |
93 if (!window) | |
94 return; | |
95 ash::wm::WindowState* window_state = ash::wm::GetWindowState(window); | |
96 | |
97 bool is_fullscreen = window_state->IsFullscreen(); | |
98 | |
99 // Windows which cannot be maximized should not be fullscreened. | |
100 if (!is_fullscreen && !window_state->CanMaximize()) | |
101 return; | |
102 | |
103 Browser* browser = chrome::FindBrowserWithWindow(window); | |
104 if (browser) { | |
105 // If a window is fullscreen, exit fullscreen. | |
106 if (is_fullscreen) { | |
107 chrome::ToggleFullscreenMode(browser); | |
108 return; | |
109 } | |
110 | |
111 // AppNonClientFrameViewAsh shows only the window controls and no other | |
112 // window decorations which is pretty close to fullscreen. Put v1 apps | |
113 // into maximized mode instead of fullscreen to avoid showing the ugly | |
114 // fullscreen exit bubble. | |
115 #if defined(OS_WIN) | |
116 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_NATIVE) { | |
117 chrome::ToggleFullscreenMode(browser); | |
118 return; | |
119 } | |
120 #endif // OS_WIN | |
121 if (browser->is_app() && browser->app_type() != Browser::APP_TYPE_CHILD) | |
122 window_state->ToggleMaximized(); | |
123 else | |
124 chrome::ToggleFullscreenMode(browser); | |
125 return; | |
126 } | |
127 | |
128 // |window| may belong to a shell window. | |
129 apps::ShellWindow* shell_window = apps::ShellWindowRegistry:: | |
130 GetShellWindowForNativeWindowAnyProfile(window); | |
131 if (shell_window) { | |
132 if (is_fullscreen) | |
133 shell_window->Restore(); | |
134 else | |
135 shell_window->Fullscreen(); | |
136 } | |
137 } | |
138 | |
139 content::BrowserContext* ChromeShellDelegate::GetCurrentBrowserContext() { | 89 content::BrowserContext* ChromeShellDelegate::GetCurrentBrowserContext() { |
140 return ProfileManager::GetDefaultProfile(); | 90 return ProfileManager::GetDefaultProfile(); |
141 } | 91 } |
142 | 92 |
143 app_list::AppListViewDelegate* | 93 app_list::AppListViewDelegate* |
144 ChromeShellDelegate::CreateAppListViewDelegate() { | 94 ChromeShellDelegate::CreateAppListViewDelegate() { |
145 DCHECK(ash::Shell::HasInstance()); | 95 DCHECK(ash::Shell::HasInstance()); |
146 // Shell will own the created delegate, and the delegate will own | 96 // Shell will own the created delegate, and the delegate will own |
147 // the controller. | 97 // the controller. |
148 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); | 98 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 } | 285 } |
336 | 286 |
337 string16 ChromeShellDelegate::GetProductName() const { | 287 string16 ChromeShellDelegate::GetProductName() const { |
338 return l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); | 288 return l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); |
339 } | 289 } |
340 | 290 |
341 keyboard::KeyboardControllerProxy* | 291 keyboard::KeyboardControllerProxy* |
342 ChromeShellDelegate::CreateKeyboardControllerProxy() { | 292 ChromeShellDelegate::CreateKeyboardControllerProxy() { |
343 return new AshKeyboardControllerProxy(); | 293 return new AshKeyboardControllerProxy(); |
344 } | 294 } |
OLD | NEW |