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
3 // found in the LICENSE file.
5 #include "ash/shell/shell_delegate_impl.h"
9 #include "ash/caps_lock_delegate_stub.h"
10 #include "ash/host/root_window_host_factory.h"
11 #include "ash/keyboard_controller_proxy_stub.h"
12 #include "ash/session_state_delegate.h"
13 #include "ash/session_state_delegate_stub.h"
14 #include "ash/shell/context_menu.h"
15 #include "ash/shell/example_factory.h"
16 #include "ash/shell/launcher_delegate_impl.h"
17 #include "ash/shell/toplevel_window.h"
18 #include "ash/shell_window_ids.h"
19 #include "ash/wm/window_util.h"
20 #include "base/message_loop/message_loop.h"
21 #include "ui/aura/window.h"
22 #include "ui/views/corewm/input_method_event_filter.h"
27 ShellDelegateImpl::ShellDelegateImpl()
29 launcher_delegate_(NULL
),
30 spoken_feedback_enabled_(false),
31 high_contrast_enabled_(false),
32 screen_magnifier_enabled_(false),
33 screen_magnifier_type_(kDefaultMagnifierType
),
34 large_cursor_enabled_(false) {
37 ShellDelegateImpl::~ShellDelegateImpl() {
40 void ShellDelegateImpl::SetWatcher(WindowWatcher
* watcher
) {
42 if (launcher_delegate_
)
43 launcher_delegate_
->set_watcher(watcher
);
46 bool ShellDelegateImpl::IsFirstRunAfterBoot() const {
50 bool ShellDelegateImpl::IsMultiProfilesEnabled() const {
54 bool ShellDelegateImpl::IsRunningInForcedAppMode() const {
58 void ShellDelegateImpl::PreInit() {
61 void ShellDelegateImpl::Shutdown() {
64 void ShellDelegateImpl::Exit() {
65 base::MessageLoopForUI::current()->Quit();
68 void ShellDelegateImpl::NewTab() {
71 void ShellDelegateImpl::NewWindow(bool incognito
) {
72 ash::shell::ToplevelWindow::CreateParams create_params
;
73 create_params
.can_resize
= true;
74 create_params
.can_maximize
= true;
75 ash::shell::ToplevelWindow::CreateToplevelWindow(create_params
);
78 void ShellDelegateImpl::ToggleFullscreen() {
82 void ShellDelegateImpl::ToggleMaximized() {
83 aura::Window
* window
= ash::wm::GetActiveWindow();
85 ash::wm::ToggleMaximizedWindow(window
);
88 void ShellDelegateImpl::OpenFileManager(bool as_dialog
) {
91 void ShellDelegateImpl::OpenCrosh() {
94 void ShellDelegateImpl::RestoreTab() {
97 void ShellDelegateImpl::ShowKeyboardOverlay() {
100 keyboard::KeyboardControllerProxy
*
101 ShellDelegateImpl::CreateKeyboardControllerProxy() {
102 return new KeyboardControllerProxyStub();
105 void ShellDelegateImpl::ShowTaskManager() {
108 content::BrowserContext
* ShellDelegateImpl::GetCurrentBrowserContext() {
109 return Shell::GetInstance()->browser_context();
112 void ShellDelegateImpl::ToggleSpokenFeedback(
113 AccessibilityNotificationVisibility notify
) {
114 spoken_feedback_enabled_
= !spoken_feedback_enabled_
;
117 bool ShellDelegateImpl::IsSpokenFeedbackEnabled() const {
118 return spoken_feedback_enabled_
;
121 void ShellDelegateImpl::ToggleHighContrast() {
122 high_contrast_enabled_
= !high_contrast_enabled_
;
125 bool ShellDelegateImpl::IsHighContrastEnabled() const {
126 return high_contrast_enabled_
;
129 void ShellDelegateImpl::SetMagnifierEnabled(bool enabled
) {
130 screen_magnifier_enabled_
= enabled
;
133 void ShellDelegateImpl::SetMagnifierType(MagnifierType type
) {
134 screen_magnifier_type_
= type
;
137 bool ShellDelegateImpl::IsMagnifierEnabled() const {
138 return screen_magnifier_enabled_
;
141 MagnifierType
ShellDelegateImpl::GetMagnifierType() const {
142 return screen_magnifier_type_
;
145 void ShellDelegateImpl::SetLargeCursorEnabled(bool enabled
) {
146 large_cursor_enabled_
= enabled
;
149 bool ShellDelegateImpl::IsLargeCursorEnabled() const {
150 return large_cursor_enabled_
;
153 bool ShellDelegateImpl::ShouldAlwaysShowAccessibilityMenu() const {
157 void ShellDelegateImpl::SilenceSpokenFeedback() const {
160 app_list::AppListViewDelegate
* ShellDelegateImpl::CreateAppListViewDelegate() {
161 return ash::shell::CreateAppListViewDelegate();
164 ash::LauncherDelegate
* ShellDelegateImpl::CreateLauncherDelegate(
165 ash::LauncherModel
* model
) {
166 launcher_delegate_
= new LauncherDelegateImpl(watcher_
);
167 return launcher_delegate_
;
170 ash::SystemTrayDelegate
* ShellDelegateImpl::CreateSystemTrayDelegate() {
174 ash::UserWallpaperDelegate
* ShellDelegateImpl::CreateUserWallpaperDelegate() {
178 ash::CapsLockDelegate
* ShellDelegateImpl::CreateCapsLockDelegate() {
179 return new CapsLockDelegateStub
;
182 ash::SessionStateDelegate
* ShellDelegateImpl::CreateSessionStateDelegate() {
183 return new SessionStateDelegateStub
;
186 aura::client::UserActionClient
* ShellDelegateImpl::CreateUserActionClient() {
190 void ShellDelegateImpl::OpenFeedbackPage() {
193 void ShellDelegateImpl::RecordUserMetricsAction(UserMetricsAction action
) {
196 void ShellDelegateImpl::HandleMediaNextTrack() {
199 void ShellDelegateImpl::HandleMediaPlayPause() {
202 void ShellDelegateImpl::HandleMediaPrevTrack() {
205 void ShellDelegateImpl::SaveScreenMagnifierScale(double scale
) {
208 double ShellDelegateImpl::GetSavedScreenMagnifierScale() {
209 return std::numeric_limits
<double>::min();
212 ui::MenuModel
* ShellDelegateImpl::CreateContextMenu(aura::RootWindow
* root
) {
213 return new ContextMenu(root
);
216 RootWindowHostFactory
* ShellDelegateImpl::CreateRootWindowHostFactory() {
217 return RootWindowHostFactory::Create();
220 base::string16
ShellDelegateImpl::GetProductName() const {
221 return base::string16();