Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ash / test / test_shell_delegate.cc
blobdbc04f8f9c5dd6b77769578d31a7ec1c4ccc4364
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/test/test_shell_delegate.h"
7 #include <limits>
9 #include "ash/default_accessibility_delegate.h"
10 #include "ash/gpu_support_stub.h"
11 #include "ash/media_delegate.h"
12 #include "ash/new_window_delegate.h"
13 #include "ash/session/session_state_delegate.h"
14 #include "ash/shell.h"
15 #include "ash/shell/keyboard_controller_proxy_stub.h"
16 #include "ash/shell_window_ids.h"
17 #include "ash/test/test_session_state_delegate.h"
18 #include "ash/test/test_shelf_delegate.h"
19 #include "ash/test/test_system_tray_delegate.h"
20 #include "ash/test/test_user_wallpaper_delegate.h"
21 #include "ash/wm/window_state.h"
22 #include "ash/wm/window_util.h"
23 #include "base/logging.h"
24 #include "content/public/test/test_browser_context.h"
25 #include "ui/app_list/app_list_model.h"
26 #include "ui/app_list/app_list_view_delegate.h"
27 #include "ui/app_list/test/app_list_test_view_delegate.h"
28 #include "ui/aura/window.h"
29 #include "ui/gfx/image/image.h"
31 #if defined(OS_CHROMEOS)
32 #include "ash/system/tray/system_tray_notifier.h"
33 #endif
35 namespace ash {
36 namespace test {
37 namespace {
39 class NewWindowDelegateImpl : public NewWindowDelegate {
40 public:
41 NewWindowDelegateImpl() {}
42 ~NewWindowDelegateImpl() override {}
44 private:
45 // NewWindowDelegate:
46 void NewTab() override {}
47 void NewWindow(bool incognito) override {}
48 void OpenFileManager() override {}
49 void OpenCrosh() override {}
50 void OpenGetHelp() override {}
51 void RestoreTab() override {}
52 void ShowKeyboardOverlay() override {}
53 void ShowTaskManager() override {}
54 void OpenFeedbackPage() override {}
56 DISALLOW_COPY_AND_ASSIGN(NewWindowDelegateImpl);
59 class MediaDelegateImpl : public MediaDelegate {
60 public:
61 MediaDelegateImpl() : state_(MEDIA_CAPTURE_NONE) {}
62 ~MediaDelegateImpl() override {}
64 void set_media_capture_state(MediaCaptureState state) { state_ = state; }
66 private:
67 // MediaDelegate:
68 void HandleMediaNextTrack() override {}
69 void HandleMediaPlayPause() override {}
70 void HandleMediaPrevTrack() override {}
71 MediaCaptureState GetMediaCaptureState(
72 content::BrowserContext* context) override {
73 return state_;
76 MediaCaptureState state_;
78 DISALLOW_COPY_AND_ASSIGN(MediaDelegateImpl);
81 } // namespace
83 TestShellDelegate::TestShellDelegate()
84 : num_exit_requests_(0),
85 multi_profiles_enabled_(false),
86 force_maximize_on_first_run_(false),
87 test_session_state_delegate_(NULL) {
90 TestShellDelegate::~TestShellDelegate() {
93 bool TestShellDelegate::IsFirstRunAfterBoot() const {
94 return false;
97 bool TestShellDelegate::IsIncognitoAllowed() const {
98 return true;
101 bool TestShellDelegate::IsMultiProfilesEnabled() const {
102 return multi_profiles_enabled_;
105 bool TestShellDelegate::IsRunningInForcedAppMode() const {
106 return false;
109 bool TestShellDelegate::IsMultiAccountEnabled() const {
110 return false;
113 bool TestShellDelegate::IsForceMaximizeOnFirstRun() const {
114 return force_maximize_on_first_run_;
117 void TestShellDelegate::PreInit() {
120 void TestShellDelegate::PreShutdown() {
123 void TestShellDelegate::Exit() {
124 num_exit_requests_++;
127 keyboard::KeyboardControllerProxy*
128 TestShellDelegate::CreateKeyboardControllerProxy() {
129 return new KeyboardControllerProxyStub();
132 void TestShellDelegate::VirtualKeyboardActivated(bool activated) {
133 FOR_EACH_OBSERVER(ash::VirtualKeyboardStateObserver,
134 keyboard_state_observer_list_,
135 OnVirtualKeyboardStateChanged(activated));
138 void TestShellDelegate::AddVirtualKeyboardStateObserver(
139 VirtualKeyboardStateObserver* observer) {
140 keyboard_state_observer_list_.AddObserver(observer);
143 void TestShellDelegate::RemoveVirtualKeyboardStateObserver(
144 VirtualKeyboardStateObserver* observer) {
145 keyboard_state_observer_list_.RemoveObserver(observer);
148 content::BrowserContext* TestShellDelegate::GetActiveBrowserContext() {
149 active_browser_context_.reset(new content::TestBrowserContext());
150 return active_browser_context_.get();
153 app_list::AppListViewDelegate* TestShellDelegate::GetAppListViewDelegate() {
154 if (!app_list_view_delegate_)
155 app_list_view_delegate_.reset(new app_list::test::AppListTestViewDelegate);
156 return app_list_view_delegate_.get();
159 ShelfDelegate* TestShellDelegate::CreateShelfDelegate(ShelfModel* model) {
160 return new TestShelfDelegate(model);
163 SystemTrayDelegate* TestShellDelegate::CreateSystemTrayDelegate() {
164 return new TestSystemTrayDelegate;
167 UserWallpaperDelegate* TestShellDelegate::CreateUserWallpaperDelegate() {
168 return new TestUserWallpaperDelegate();
171 TestSessionStateDelegate* TestShellDelegate::CreateSessionStateDelegate() {
172 return new TestSessionStateDelegate();
175 AccessibilityDelegate* TestShellDelegate::CreateAccessibilityDelegate() {
176 return new DefaultAccessibilityDelegate();
179 NewWindowDelegate* TestShellDelegate::CreateNewWindowDelegate() {
180 return new NewWindowDelegateImpl;
183 MediaDelegate* TestShellDelegate::CreateMediaDelegate() {
184 return new MediaDelegateImpl;
187 ui::MenuModel* TestShellDelegate::CreateContextMenu(
188 aura::Window* root,
189 ash::ShelfItemDelegate* item_delegate,
190 ash::ShelfItem* item) {
191 return NULL;
194 GPUSupport* TestShellDelegate::CreateGPUSupport() {
195 // Real GPU support depends on src/content, so just use a stub.
196 return new GPUSupportStub;
199 base::string16 TestShellDelegate::GetProductName() const {
200 return base::string16();
203 gfx::Image TestShellDelegate::GetDeprecatedAcceleratorImage() const {
204 return gfx::Image();
207 void TestShellDelegate::SetMediaCaptureState(MediaCaptureState state) {
208 #if defined(OS_CHROMEOS)
209 Shell* shell = Shell::GetInstance();
210 static_cast<MediaDelegateImpl*>(shell->media_delegate())
211 ->set_media_capture_state(state);
212 shell->system_tray_notifier()->NotifyMediaCaptureChanged();
213 #endif
216 } // namespace test
217 } // namespace ash