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