Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / ash / shell / shell_delegate_impl.cc
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 "ash/accessibility_delegate.h"
8 #include "ash/caps_lock_delegate_stub.h"
9 #include "ash/default_accessibility_delegate.h"
10 #include "ash/default_user_wallpaper_delegate.h"
11 #include "ash/gpu_support_stub.h"
12 #include "ash/host/window_tree_host_factory.h"
13 #include "ash/media_delegate.h"
14 #include "ash/new_window_delegate.h"
15 #include "ash/session_state_delegate.h"
16 #include "ash/session_state_delegate_stub.h"
17 #include "ash/shell/context_menu.h"
18 #include "ash/shell/example_factory.h"
19 #include "ash/shell/keyboard_controller_proxy_stub.h"
20 #include "ash/shell/shelf_delegate_impl.h"
21 #include "ash/shell/toplevel_window.h"
22 #include "ash/shell_window_ids.h"
23 #include "ash/system/tray/default_system_tray_delegate.h"
24 #include "ash/wm/window_state.h"
25 #include "base/message_loop/message_loop.h"
26 #include "ui/aura/window.h"
27 #include "ui/views/corewm/input_method_event_filter.h"
28
29 namespace ash {
30 namespace shell {
31 namespace {
32
33 class NewWindowDelegateImpl : public NewWindowDelegate {
34  public:
35   NewWindowDelegateImpl() {}
36   virtual ~NewWindowDelegateImpl() {}
37
38   virtual void NewTab() OVERRIDE {}
39   virtual void NewWindow(bool incognito) OVERRIDE {
40     ash::shell::ToplevelWindow::CreateParams create_params;
41     create_params.can_resize = true;
42     create_params.can_maximize = true;
43     ash::shell::ToplevelWindow::CreateToplevelWindow(create_params);
44   }
45   virtual void OpenFileManager() OVERRIDE {}
46   virtual void OpenCrosh() OVERRIDE {}
47   virtual void RestoreTab() OVERRIDE {}
48   virtual void ShowKeyboardOverlay() OVERRIDE {}
49   virtual void ShowTaskManager() OVERRIDE {}
50   virtual void OpenFeedbackPage() OVERRIDE {}
51
52  private:
53   DISALLOW_COPY_AND_ASSIGN(NewWindowDelegateImpl);
54 };
55
56 class MediaDelegateImpl : public MediaDelegate {
57  public:
58   MediaDelegateImpl() {}
59   virtual ~MediaDelegateImpl() {}
60
61   virtual void HandleMediaNextTrack() OVERRIDE {}
62   virtual void HandleMediaPlayPause() OVERRIDE {}
63   virtual void HandleMediaPrevTrack() OVERRIDE {}
64
65  private:
66   DISALLOW_COPY_AND_ASSIGN(MediaDelegateImpl);
67 };
68
69 }  // namespace
70
71 ShellDelegateImpl::ShellDelegateImpl()
72     : watcher_(NULL),
73       shelf_delegate_(NULL),
74       browser_context_(NULL) {
75 }
76
77 ShellDelegateImpl::~ShellDelegateImpl() {
78 }
79
80 void ShellDelegateImpl::SetWatcher(WindowWatcher* watcher) {
81   watcher_ = watcher;
82   if (shelf_delegate_)
83     shelf_delegate_->set_watcher(watcher);
84 }
85
86 bool ShellDelegateImpl::IsFirstRunAfterBoot() const {
87   return false;
88 }
89
90 bool ShellDelegateImpl::IsIncognitoAllowed() const {
91   return true;
92 }
93
94 bool ShellDelegateImpl::IsMultiProfilesEnabled() const {
95   return false;
96 }
97
98 bool ShellDelegateImpl::IsRunningInForcedAppMode() const {
99   return false;
100 }
101
102 void ShellDelegateImpl::PreInit() {
103 }
104
105 void ShellDelegateImpl::Shutdown() {
106 }
107
108 void ShellDelegateImpl::Exit() {
109   base::MessageLoopForUI::current()->Quit();
110 }
111
112 keyboard::KeyboardControllerProxy*
113     ShellDelegateImpl::CreateKeyboardControllerProxy() {
114   return new KeyboardControllerProxyStub();
115 }
116
117 content::BrowserContext* ShellDelegateImpl::GetActiveBrowserContext() {
118   return browser_context_;
119 }
120
121 app_list::AppListViewDelegate* ShellDelegateImpl::CreateAppListViewDelegate() {
122   return ash::shell::CreateAppListViewDelegate();
123 }
124
125 ShelfDelegate* ShellDelegateImpl::CreateShelfDelegate(ShelfModel* model) {
126   shelf_delegate_ = new ShelfDelegateImpl(watcher_);
127   return shelf_delegate_;
128 }
129
130 ash::SystemTrayDelegate* ShellDelegateImpl::CreateSystemTrayDelegate() {
131   return new DefaultSystemTrayDelegate;
132 }
133
134 ash::UserWallpaperDelegate* ShellDelegateImpl::CreateUserWallpaperDelegate() {
135   return new DefaultUserWallpaperDelegate();
136 }
137
138 ash::CapsLockDelegate* ShellDelegateImpl::CreateCapsLockDelegate() {
139   return new CapsLockDelegateStub;
140 }
141
142 ash::SessionStateDelegate* ShellDelegateImpl::CreateSessionStateDelegate() {
143   return new SessionStateDelegateStub;
144 }
145
146 ash::AccessibilityDelegate* ShellDelegateImpl::CreateAccessibilityDelegate() {
147   return new internal::DefaultAccessibilityDelegate;
148 }
149
150 ash::NewWindowDelegate* ShellDelegateImpl::CreateNewWindowDelegate() {
151   return new NewWindowDelegateImpl;
152 }
153
154 ash::MediaDelegate* ShellDelegateImpl::CreateMediaDelegate() {
155   return new MediaDelegateImpl;
156 }
157
158 aura::client::UserActionClient* ShellDelegateImpl::CreateUserActionClient() {
159   return NULL;
160 }
161
162 ui::MenuModel* ShellDelegateImpl::CreateContextMenu(
163     aura::Window* root,
164     ash::ShelfItemDelegate* item_delegate,
165     ash::ShelfItem* item) {
166   return new ContextMenu(root);
167 }
168
169 WindowTreeHostFactory* ShellDelegateImpl::CreateWindowTreeHostFactory() {
170   return WindowTreeHostFactory::Create();
171 }
172
173 GPUSupport* ShellDelegateImpl::CreateGPUSupport() {
174   // Real GPU support depends on src/content, so just use a stub.
175   return new GPUSupportStub;
176 }
177
178 base::string16 ShellDelegateImpl::GetProductName() const {
179   return base::string16();
180 }
181
182 }  // namespace shell
183 }  // namespace ash