Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 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. |
| 4 | |
| 5 | #include "ash/shell/shell_delegate_impl.h" |
| 6 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 7 | #include <limits> |
| 8 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 9 | #include "ash/caps_lock_delegate_stub.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 10 | #include "ash/host/root_window_host_factory.h" |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 11 | #include "ash/session_state_delegate.h" |
| 12 | #include "ash/session_state_delegate_stub.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 13 | #include "ash/shell/context_menu.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 14 | #include "ash/shell/example_factory.h" |
| 15 | #include "ash/shell/launcher_delegate_impl.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 16 | #include "ash/shell/toplevel_window.h" |
| 17 | #include "ash/shell_window_ids.h" |
| 18 | #include "ash/wm/window_util.h" |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 19 | #include "base/message_loop/message_loop.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 20 | #include "ui/aura/window.h" |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 21 | #include "ui/keyboard/keyboard_controller_proxy.h" |
| 22 | #include "ui/views/corewm/input_method_event_filter.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 23 | |
| 24 | namespace ash { |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 25 | |
| 26 | namespace { |
| 27 | |
| 28 | class DummyKeyboardControllerProxy : public keyboard::KeyboardControllerProxy { |
| 29 | public: |
| 30 | DummyKeyboardControllerProxy() {} |
| 31 | virtual ~DummyKeyboardControllerProxy() {} |
| 32 | |
| 33 | private: |
| 34 | // Overridden from keyboard::KeyboardControllerProxy: |
| 35 | virtual content::BrowserContext* GetBrowserContext() OVERRIDE { |
| 36 | return Shell::GetInstance()->browser_context(); |
| 37 | } |
| 38 | |
| 39 | virtual ui::InputMethod* GetInputMethod() OVERRIDE { |
| 40 | return Shell::GetInstance()->input_method_filter()->input_method(); |
| 41 | } |
| 42 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 43 | virtual void RequestAudioInput(content::WebContents* web_contents, |
| 44 | const content::MediaStreamRequest& request, |
| 45 | const content::MediaResponseCallback& callback) OVERRIDE { |
| 46 | return; |
| 47 | } |
| 48 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 49 | DISALLOW_COPY_AND_ASSIGN(DummyKeyboardControllerProxy); |
| 50 | }; |
| 51 | |
| 52 | } // namespace |
| 53 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 54 | namespace shell { |
| 55 | |
| 56 | ShellDelegateImpl::ShellDelegateImpl() |
| 57 | : watcher_(NULL), |
| 58 | launcher_delegate_(NULL), |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 59 | spoken_feedback_enabled_(false), |
| 60 | high_contrast_enabled_(false), |
| 61 | screen_magnifier_enabled_(false), |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 62 | screen_magnifier_type_(kDefaultMagnifierType), |
| 63 | large_cursor_enabled_(false) { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | ShellDelegateImpl::~ShellDelegateImpl() { |
| 67 | } |
| 68 | |
| 69 | void ShellDelegateImpl::SetWatcher(WindowWatcher* watcher) { |
| 70 | watcher_ = watcher; |
| 71 | if (launcher_delegate_) |
| 72 | launcher_delegate_->set_watcher(watcher); |
| 73 | } |
| 74 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 75 | bool ShellDelegateImpl::IsFirstRunAfterBoot() const { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 76 | return false; |
| 77 | } |
| 78 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 79 | bool ShellDelegateImpl::IsMultiProfilesEnabled() const { |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 80 | return false; |
| 81 | } |
| 82 | |
| 83 | bool ShellDelegateImpl::IsRunningInForcedAppMode() const { |
| 84 | return false; |
| 85 | } |
| 86 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 87 | void ShellDelegateImpl::PreInit() { |
| 88 | } |
| 89 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 90 | void ShellDelegateImpl::Shutdown() { |
| 91 | } |
| 92 | |
| 93 | void ShellDelegateImpl::Exit() { |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 94 | base::MessageLoopForUI::current()->Quit(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | void ShellDelegateImpl::NewTab() { |
| 98 | } |
| 99 | |
| 100 | void ShellDelegateImpl::NewWindow(bool incognito) { |
| 101 | ash::shell::ToplevelWindow::CreateParams create_params; |
| 102 | create_params.can_resize = true; |
| 103 | create_params.can_maximize = true; |
| 104 | ash::shell::ToplevelWindow::CreateToplevelWindow(create_params); |
| 105 | } |
| 106 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 107 | void ShellDelegateImpl::ToggleFullscreen() { |
| 108 | ToggleMaximized(); |
| 109 | } |
| 110 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 111 | void ShellDelegateImpl::ToggleMaximized() { |
| 112 | aura::Window* window = ash::wm::GetActiveWindow(); |
| 113 | if (window) |
| 114 | ash::wm::ToggleMaximizedWindow(window); |
| 115 | } |
| 116 | |
| 117 | void ShellDelegateImpl::OpenFileManager(bool as_dialog) { |
| 118 | } |
| 119 | |
| 120 | void ShellDelegateImpl::OpenCrosh() { |
| 121 | } |
| 122 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 123 | void ShellDelegateImpl::RestoreTab() { |
| 124 | } |
| 125 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 126 | void ShellDelegateImpl::ShowKeyboardOverlay() { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 127 | } |
| 128 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 129 | keyboard::KeyboardControllerProxy* |
| 130 | ShellDelegateImpl::CreateKeyboardControllerProxy() { |
| 131 | return new DummyKeyboardControllerProxy(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | void ShellDelegateImpl::ShowTaskManager() { |
| 135 | } |
| 136 | |
| 137 | content::BrowserContext* ShellDelegateImpl::GetCurrentBrowserContext() { |
| 138 | return Shell::GetInstance()->browser_context(); |
| 139 | } |
| 140 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 141 | void ShellDelegateImpl::ToggleSpokenFeedback( |
| 142 | AccessibilityNotificationVisibility notify) { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 143 | spoken_feedback_enabled_ = !spoken_feedback_enabled_; |
| 144 | } |
| 145 | |
| 146 | bool ShellDelegateImpl::IsSpokenFeedbackEnabled() const { |
| 147 | return spoken_feedback_enabled_; |
| 148 | } |
| 149 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 150 | void ShellDelegateImpl::ToggleHighContrast() { |
| 151 | high_contrast_enabled_ = !high_contrast_enabled_; |
| 152 | } |
| 153 | |
| 154 | bool ShellDelegateImpl::IsHighContrastEnabled() const { |
| 155 | return high_contrast_enabled_; |
| 156 | } |
| 157 | |
| 158 | void ShellDelegateImpl::SetMagnifierEnabled(bool enabled) { |
| 159 | screen_magnifier_enabled_ = enabled; |
| 160 | } |
| 161 | |
| 162 | void ShellDelegateImpl::SetMagnifierType(MagnifierType type) { |
| 163 | screen_magnifier_type_ = type; |
| 164 | } |
| 165 | |
| 166 | bool ShellDelegateImpl::IsMagnifierEnabled() const { |
| 167 | return screen_magnifier_enabled_; |
| 168 | } |
| 169 | |
| 170 | MagnifierType ShellDelegateImpl::GetMagnifierType() const { |
| 171 | return screen_magnifier_type_; |
| 172 | } |
| 173 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 174 | void ShellDelegateImpl::SetLargeCursorEnabled(bool enabled) { |
| 175 | large_cursor_enabled_ = enabled; |
| 176 | } |
| 177 | |
| 178 | bool ShellDelegateImpl::IsLargeCursorEnabled() const { |
| 179 | return large_cursor_enabled_; |
| 180 | } |
| 181 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 182 | bool ShellDelegateImpl::ShouldAlwaysShowAccessibilityMenu() const { |
| 183 | return false; |
| 184 | } |
| 185 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 186 | void ShellDelegateImpl::SilenceSpokenFeedback() const { |
| 187 | } |
| 188 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 189 | app_list::AppListViewDelegate* ShellDelegateImpl::CreateAppListViewDelegate() { |
| 190 | return ash::shell::CreateAppListViewDelegate(); |
| 191 | } |
| 192 | |
| 193 | ash::LauncherDelegate* ShellDelegateImpl::CreateLauncherDelegate( |
| 194 | ash::LauncherModel* model) { |
| 195 | launcher_delegate_ = new LauncherDelegateImpl(watcher_); |
| 196 | return launcher_delegate_; |
| 197 | } |
| 198 | |
| 199 | ash::SystemTrayDelegate* ShellDelegateImpl::CreateSystemTrayDelegate() { |
| 200 | return NULL; |
| 201 | } |
| 202 | |
| 203 | ash::UserWallpaperDelegate* ShellDelegateImpl::CreateUserWallpaperDelegate() { |
| 204 | return NULL; |
| 205 | } |
| 206 | |
| 207 | ash::CapsLockDelegate* ShellDelegateImpl::CreateCapsLockDelegate() { |
| 208 | return new CapsLockDelegateStub; |
| 209 | } |
| 210 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 211 | ash::SessionStateDelegate* ShellDelegateImpl::CreateSessionStateDelegate() { |
| 212 | return new SessionStateDelegateStub; |
| 213 | } |
| 214 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 215 | aura::client::UserActionClient* ShellDelegateImpl::CreateUserActionClient() { |
| 216 | return NULL; |
| 217 | } |
| 218 | |
| 219 | void ShellDelegateImpl::OpenFeedbackPage() { |
| 220 | } |
| 221 | |
| 222 | void ShellDelegateImpl::RecordUserMetricsAction(UserMetricsAction action) { |
| 223 | } |
| 224 | |
| 225 | void ShellDelegateImpl::HandleMediaNextTrack() { |
| 226 | } |
| 227 | |
| 228 | void ShellDelegateImpl::HandleMediaPlayPause() { |
| 229 | } |
| 230 | |
| 231 | void ShellDelegateImpl::HandleMediaPrevTrack() { |
| 232 | } |
| 233 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 234 | void ShellDelegateImpl::SaveScreenMagnifierScale(double scale) { |
| 235 | } |
| 236 | |
| 237 | double ShellDelegateImpl::GetSavedScreenMagnifierScale() { |
| 238 | return std::numeric_limits<double>::min(); |
| 239 | } |
| 240 | |
| 241 | ui::MenuModel* ShellDelegateImpl::CreateContextMenu(aura::RootWindow* root) { |
| 242 | return new ContextMenu(root); |
| 243 | } |
| 244 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 245 | RootWindowHostFactory* ShellDelegateImpl::CreateRootWindowHostFactory() { |
| 246 | return RootWindowHostFactory::Create(); |
| 247 | } |
| 248 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 249 | base::string16 ShellDelegateImpl::GetProductName() const { |
| 250 | return base::string16(); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 251 | } |
| 252 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 253 | } // namespace shell |
| 254 | } // namespace ash |