Updating XTBs based on .GRDs from branch master
[chromium-blink-merge.git] / ash / test / test_shell_delegate.cc
blobee6fd44a06c28c7d52be65d43248b76dd3d5a52e
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"
30 #if defined(OS_CHROMEOS)
31 #include "ash/system/tray/system_tray_notifier.h"
32 #endif
34 namespace ash {
35 namespace test {
36 namespace {
38 class NewWindowDelegateImpl : public NewWindowDelegate {
39 public:
40 NewWindowDelegateImpl() {}
41 ~NewWindowDelegateImpl() override {}
43 private:
44 // NewWindowDelegate:
45 void NewTab() override {}
46 void NewWindow(bool incognito) override {}
47 void OpenFileManager() override {}
48 void OpenCrosh() override {}
49 void OpenGetHelp() override {}
50 void RestoreTab() override {}
51 void ShowKeyboardOverlay() override {}
52 void ShowTaskManager() override {}
53 void OpenFeedbackPage() override {}
55 DISALLOW_COPY_AND_ASSIGN(NewWindowDelegateImpl);
58 class MediaDelegateImpl : public MediaDelegate {
59 public:
60 MediaDelegateImpl() : state_(MEDIA_CAPTURE_NONE) {}
61 ~MediaDelegateImpl() override {}
63 void set_media_capture_state(MediaCaptureState state) { state_ = state; }
65 private:
66 // MediaDelegate:
67 void HandleMediaNextTrack() override {}
68 void HandleMediaPlayPause() override {}
69 void HandleMediaPrevTrack() override {}
70 MediaCaptureState GetMediaCaptureState(
71 content::BrowserContext* context) override {
72 return state_;
75 MediaCaptureState state_;
77 DISALLOW_COPY_AND_ASSIGN(MediaDelegateImpl);
80 } // namespace
82 TestShellDelegate::TestShellDelegate()
83 : num_exit_requests_(0),
84 multi_profiles_enabled_(false),
85 force_maximize_on_first_run_(false),
86 test_session_state_delegate_(NULL) {
89 TestShellDelegate::~TestShellDelegate() {
92 bool TestShellDelegate::IsFirstRunAfterBoot() const {
93 return false;
96 bool TestShellDelegate::IsIncognitoAllowed() const {
97 return true;
100 bool TestShellDelegate::IsMultiProfilesEnabled() const {
101 return multi_profiles_enabled_;
104 bool TestShellDelegate::IsRunningInForcedAppMode() const {
105 return false;
108 bool TestShellDelegate::IsMultiAccountEnabled() const {
109 return false;
112 bool TestShellDelegate::IsForceMaximizeOnFirstRun() const {
113 return force_maximize_on_first_run_;
116 void TestShellDelegate::PreInit() {
119 void TestShellDelegate::PreShutdown() {
122 void TestShellDelegate::Exit() {
123 num_exit_requests_++;
126 keyboard::KeyboardControllerProxy*
127 TestShellDelegate::CreateKeyboardControllerProxy() {
128 return new KeyboardControllerProxyStub();
131 void TestShellDelegate::VirtualKeyboardActivated(bool activated) {
132 FOR_EACH_OBSERVER(ash::VirtualKeyboardStateObserver,
133 keyboard_state_observer_list_,
134 OnVirtualKeyboardStateChanged(activated));
137 void TestShellDelegate::AddVirtualKeyboardStateObserver(
138 VirtualKeyboardStateObserver* observer) {
139 keyboard_state_observer_list_.AddObserver(observer);
142 void TestShellDelegate::RemoveVirtualKeyboardStateObserver(
143 VirtualKeyboardStateObserver* observer) {
144 keyboard_state_observer_list_.RemoveObserver(observer);
147 content::BrowserContext* TestShellDelegate::GetActiveBrowserContext() {
148 active_browser_context_.reset(new content::TestBrowserContext());
149 return active_browser_context_.get();
152 app_list::AppListViewDelegate* TestShellDelegate::GetAppListViewDelegate() {
153 if (!app_list_view_delegate_)
154 app_list_view_delegate_.reset(new app_list::test::AppListTestViewDelegate);
155 return app_list_view_delegate_.get();
158 ShelfDelegate* TestShellDelegate::CreateShelfDelegate(ShelfModel* model) {
159 return new TestShelfDelegate(model);
162 SystemTrayDelegate* TestShellDelegate::CreateSystemTrayDelegate() {
163 return new TestSystemTrayDelegate;
166 UserWallpaperDelegate* TestShellDelegate::CreateUserWallpaperDelegate() {
167 return new TestUserWallpaperDelegate();
170 TestSessionStateDelegate* TestShellDelegate::CreateSessionStateDelegate() {
171 return new TestSessionStateDelegate();
174 AccessibilityDelegate* TestShellDelegate::CreateAccessibilityDelegate() {
175 return new DefaultAccessibilityDelegate();
178 NewWindowDelegate* TestShellDelegate::CreateNewWindowDelegate() {
179 return new NewWindowDelegateImpl;
182 MediaDelegate* TestShellDelegate::CreateMediaDelegate() {
183 return new MediaDelegateImpl;
186 ui::MenuModel* TestShellDelegate::CreateContextMenu(
187 aura::Window* root,
188 ash::ShelfItemDelegate* item_delegate,
189 ash::ShelfItem* item) {
190 return NULL;
193 GPUSupport* TestShellDelegate::CreateGPUSupport() {
194 // Real GPU support depends on src/content, so just use a stub.
195 return new GPUSupportStub;
198 base::string16 TestShellDelegate::GetProductName() const {
199 return base::string16();
202 void TestShellDelegate::SetMediaCaptureState(MediaCaptureState state) {
203 #if defined(OS_CHROMEOS)
204 Shell* shell = Shell::GetInstance();
205 static_cast<MediaDelegateImpl*>(shell->media_delegate())
206 ->set_media_capture_state(state);
207 shell->system_tray_notifier()->NotifyMediaCaptureChanged();
208 #endif
211 } // namespace test
212 } // namespace ash