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/default_accessibility_delegate.h"
9 #include "ash/default_user_wallpaper_delegate.h"
10 #include "ash/gpu_support_stub.h"
11 #include "ash/host/window_tree_host_factory.h"
12 #include "ash/media_delegate.h"
13 #include "ash/new_window_delegate.h"
14 #include "ash/session_state_delegate.h"
15 #include "ash/session_state_delegate_stub.h"
16 #include "ash/shell/context_menu.h"
17 #include "ash/shell/example_factory.h"
18 #include "ash/shell/keyboard_controller_proxy_stub.h"
19 #include "ash/shell/shelf_delegate_impl.h"
20 #include "ash/shell/toplevel_window.h"
21 #include "ash/shell_window_ids.h"
22 #include "ash/system/tray/default_system_tray_delegate.h"
23 #include "ash/wm/window_state.h"
24 #include "base/message_loop/message_loop.h"
25 #include "ui/aura/window.h"
26 #include "ui/wm/core/input_method_event_filter.h"
32 class NewWindowDelegateImpl
: public NewWindowDelegate
{
34 NewWindowDelegateImpl() {}
35 virtual ~NewWindowDelegateImpl() {}
37 virtual void NewTab() OVERRIDE
{}
38 virtual void NewWindow(bool incognito
) OVERRIDE
{
39 ash::shell::ToplevelWindow::CreateParams create_params
;
40 create_params
.can_resize
= true;
41 create_params
.can_maximize
= true;
42 ash::shell::ToplevelWindow::CreateToplevelWindow(create_params
);
44 virtual void OpenFileManager() OVERRIDE
{}
45 virtual void OpenCrosh() OVERRIDE
{}
46 virtual void RestoreTab() OVERRIDE
{}
47 virtual void ShowKeyboardOverlay() OVERRIDE
{}
48 virtual void ShowTaskManager() OVERRIDE
{}
49 virtual void OpenFeedbackPage() OVERRIDE
{}
52 DISALLOW_COPY_AND_ASSIGN(NewWindowDelegateImpl
);
55 class MediaDelegateImpl
: public MediaDelegate
{
57 MediaDelegateImpl() {}
58 virtual ~MediaDelegateImpl() {}
60 virtual void HandleMediaNextTrack() OVERRIDE
{}
61 virtual void HandleMediaPlayPause() OVERRIDE
{}
62 virtual void HandleMediaPrevTrack() OVERRIDE
{}
65 DISALLOW_COPY_AND_ASSIGN(MediaDelegateImpl
);
70 ShellDelegateImpl::ShellDelegateImpl()
72 shelf_delegate_(NULL
),
73 browser_context_(NULL
) {
76 ShellDelegateImpl::~ShellDelegateImpl() {
79 void ShellDelegateImpl::SetWatcher(WindowWatcher
* watcher
) {
82 shelf_delegate_
->set_watcher(watcher
);
85 bool ShellDelegateImpl::IsFirstRunAfterBoot() const {
89 bool ShellDelegateImpl::IsIncognitoAllowed() const {
93 bool ShellDelegateImpl::IsMultiProfilesEnabled() const {
97 bool ShellDelegateImpl::IsRunningInForcedAppMode() const {
101 void ShellDelegateImpl::PreInit() {
104 void ShellDelegateImpl::Shutdown() {
107 void ShellDelegateImpl::Exit() {
108 base::MessageLoopForUI::current()->Quit();
111 keyboard::KeyboardControllerProxy
*
112 ShellDelegateImpl::CreateKeyboardControllerProxy() {
113 return new KeyboardControllerProxyStub();
116 content::BrowserContext
* ShellDelegateImpl::GetActiveBrowserContext() {
117 return browser_context_
;
120 app_list::AppListViewDelegate
* ShellDelegateImpl::CreateAppListViewDelegate() {
121 return ash::shell::CreateAppListViewDelegate();
124 ShelfDelegate
* ShellDelegateImpl::CreateShelfDelegate(ShelfModel
* model
) {
125 shelf_delegate_
= new ShelfDelegateImpl(watcher_
);
126 return shelf_delegate_
;
129 ash::SystemTrayDelegate
* ShellDelegateImpl::CreateSystemTrayDelegate() {
130 return new DefaultSystemTrayDelegate
;
133 ash::UserWallpaperDelegate
* ShellDelegateImpl::CreateUserWallpaperDelegate() {
134 return new DefaultUserWallpaperDelegate();
137 ash::SessionStateDelegate
* ShellDelegateImpl::CreateSessionStateDelegate() {
138 return new SessionStateDelegateStub
;
141 ash::AccessibilityDelegate
* ShellDelegateImpl::CreateAccessibilityDelegate() {
142 return new internal::DefaultAccessibilityDelegate
;
145 ash::NewWindowDelegate
* ShellDelegateImpl::CreateNewWindowDelegate() {
146 return new NewWindowDelegateImpl
;
149 ash::MediaDelegate
* ShellDelegateImpl::CreateMediaDelegate() {
150 return new MediaDelegateImpl
;
153 ui::MenuModel
* ShellDelegateImpl::CreateContextMenu(
155 ash::ShelfItemDelegate
* item_delegate
,
156 ash::ShelfItem
* item
) {
157 return new ContextMenu(root
);
160 WindowTreeHostFactory
* ShellDelegateImpl::CreateWindowTreeHostFactory() {
161 return WindowTreeHostFactory::Create();
164 GPUSupport
* ShellDelegateImpl::CreateGPUSupport() {
165 // Real GPU support depends on src/content, so just use a stub.
166 return new GPUSupportStub
;
169 base::string16
ShellDelegateImpl::GetProductName() const {
170 return base::string16();