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"
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"
33 class NewWindowDelegateImpl : public NewWindowDelegate {
35 NewWindowDelegateImpl() {}
36 virtual ~NewWindowDelegateImpl() {}
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);
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 {}
53 DISALLOW_COPY_AND_ASSIGN(NewWindowDelegateImpl);
56 class MediaDelegateImpl : public MediaDelegate {
58 MediaDelegateImpl() {}
59 virtual ~MediaDelegateImpl() {}
61 virtual void HandleMediaNextTrack() OVERRIDE {}
62 virtual void HandleMediaPlayPause() OVERRIDE {}
63 virtual void HandleMediaPrevTrack() OVERRIDE {}
66 DISALLOW_COPY_AND_ASSIGN(MediaDelegateImpl);
71 ShellDelegateImpl::ShellDelegateImpl()
73 shelf_delegate_(NULL),
74 browser_context_(NULL) {
77 ShellDelegateImpl::~ShellDelegateImpl() {
80 void ShellDelegateImpl::SetWatcher(WindowWatcher* watcher) {
83 shelf_delegate_->set_watcher(watcher);
86 bool ShellDelegateImpl::IsFirstRunAfterBoot() const {
90 bool ShellDelegateImpl::IsIncognitoAllowed() const {
94 bool ShellDelegateImpl::IsMultiProfilesEnabled() const {
98 bool ShellDelegateImpl::IsRunningInForcedAppMode() const {
102 void ShellDelegateImpl::PreInit() {
105 void ShellDelegateImpl::Shutdown() {
108 void ShellDelegateImpl::Exit() {
109 base::MessageLoopForUI::current()->Quit();
112 keyboard::KeyboardControllerProxy*
113 ShellDelegateImpl::CreateKeyboardControllerProxy() {
114 return new KeyboardControllerProxyStub();
117 content::BrowserContext* ShellDelegateImpl::GetActiveBrowserContext() {
118 return browser_context_;
121 app_list::AppListViewDelegate* ShellDelegateImpl::CreateAppListViewDelegate() {
122 return ash::shell::CreateAppListViewDelegate();
125 ShelfDelegate* ShellDelegateImpl::CreateShelfDelegate(ShelfModel* model) {
126 shelf_delegate_ = new ShelfDelegateImpl(watcher_);
127 return shelf_delegate_;
130 ash::SystemTrayDelegate* ShellDelegateImpl::CreateSystemTrayDelegate() {
131 return new DefaultSystemTrayDelegate;
134 ash::UserWallpaperDelegate* ShellDelegateImpl::CreateUserWallpaperDelegate() {
135 return new DefaultUserWallpaperDelegate();
138 ash::CapsLockDelegate* ShellDelegateImpl::CreateCapsLockDelegate() {
139 return new CapsLockDelegateStub;
142 ash::SessionStateDelegate* ShellDelegateImpl::CreateSessionStateDelegate() {
143 return new SessionStateDelegateStub;
146 ash::AccessibilityDelegate* ShellDelegateImpl::CreateAccessibilityDelegate() {
147 return new internal::DefaultAccessibilityDelegate;
150 ash::NewWindowDelegate* ShellDelegateImpl::CreateNewWindowDelegate() {
151 return new NewWindowDelegateImpl;
154 ash::MediaDelegate* ShellDelegateImpl::CreateMediaDelegate() {
155 return new MediaDelegateImpl;
158 aura::client::UserActionClient* ShellDelegateImpl::CreateUserActionClient() {
162 ui::MenuModel* ShellDelegateImpl::CreateContextMenu(
164 ash::ShelfItemDelegate* item_delegate,
165 ash::ShelfItem* item) {
166 return new ContextMenu(root);
169 WindowTreeHostFactory* ShellDelegateImpl::CreateWindowTreeHostFactory() {
170 return WindowTreeHostFactory::Create();
173 GPUSupport* ShellDelegateImpl::CreateGPUSupport() {
174 // Real GPU support depends on src/content, so just use a stub.
175 return new GPUSupportStub;
178 base::string16 ShellDelegateImpl::GetProductName() const {
179 return base::string16();