usb_gadget: Switch to official Google product IDs.
[chromium-blink-merge.git] / ash / test / test_shell_delegate.cc
blob982cae47873e1705228507fb9d9d9dc3982e186b
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 virtual ~NewWindowDelegateImpl() {}
43 private:
44 // NewWindowDelegate:
45 virtual void NewTab() OVERRIDE {}
46 virtual void NewWindow(bool incognito) OVERRIDE {}
47 virtual void OpenFileManager() OVERRIDE {}
48 virtual void OpenCrosh() OVERRIDE {}
49 virtual void RestoreTab() OVERRIDE {}
50 virtual void ShowKeyboardOverlay() OVERRIDE {}
51 virtual void ShowTaskManager() OVERRIDE {}
52 virtual void OpenFeedbackPage() OVERRIDE {}
54 DISALLOW_COPY_AND_ASSIGN(NewWindowDelegateImpl);
57 class MediaDelegateImpl : public MediaDelegate {
58 public:
59 MediaDelegateImpl() : state_(MEDIA_CAPTURE_NONE) {}
60 virtual ~MediaDelegateImpl() {}
62 void set_media_capture_state(MediaCaptureState state) { state_ = state; }
64 private:
65 // MediaDelegate:
66 virtual void HandleMediaNextTrack() OVERRIDE {}
67 virtual void HandleMediaPlayPause() OVERRIDE {}
68 virtual void HandleMediaPrevTrack() OVERRIDE {}
69 virtual MediaCaptureState GetMediaCaptureState(
70 content::BrowserContext* context) OVERRIDE {
71 return state_;
74 MediaCaptureState state_;
76 DISALLOW_COPY_AND_ASSIGN(MediaDelegateImpl);
79 } // namespace
81 TestShellDelegate::TestShellDelegate()
82 : num_exit_requests_(0),
83 multi_profiles_enabled_(false),
84 test_session_state_delegate_(NULL) {
87 TestShellDelegate::~TestShellDelegate() {
90 bool TestShellDelegate::IsFirstRunAfterBoot() const {
91 return false;
94 bool TestShellDelegate::IsIncognitoAllowed() const {
95 return true;
98 bool TestShellDelegate::IsMultiProfilesEnabled() const {
99 return multi_profiles_enabled_;
102 bool TestShellDelegate::IsRunningInForcedAppMode() const {
103 return false;
106 bool TestShellDelegate::IsMultiAccountEnabled() const {
107 return false;
110 void TestShellDelegate::PreInit() {
113 void TestShellDelegate::PreShutdown() {
116 void TestShellDelegate::Exit() {
117 num_exit_requests_++;
120 keyboard::KeyboardControllerProxy*
121 TestShellDelegate::CreateKeyboardControllerProxy() {
122 return new KeyboardControllerProxyStub();
125 void TestShellDelegate::VirtualKeyboardActivated(bool activated) {
126 FOR_EACH_OBSERVER(ash::VirtualKeyboardStateObserver,
127 keyboard_state_observer_list_,
128 OnVirtualKeyboardStateChanged(activated));
131 void TestShellDelegate::AddVirtualKeyboardStateObserver(
132 VirtualKeyboardStateObserver* observer) {
133 keyboard_state_observer_list_.AddObserver(observer);
136 void TestShellDelegate::RemoveVirtualKeyboardStateObserver(
137 VirtualKeyboardStateObserver* observer) {
138 keyboard_state_observer_list_.RemoveObserver(observer);
141 content::BrowserContext* TestShellDelegate::GetActiveBrowserContext() {
142 active_browser_context_.reset(new content::TestBrowserContext());
143 return active_browser_context_.get();
146 app_list::AppListViewDelegate* TestShellDelegate::CreateAppListViewDelegate() {
147 return new app_list::test::AppListTestViewDelegate;
150 ShelfDelegate* TestShellDelegate::CreateShelfDelegate(ShelfModel* model) {
151 return new TestShelfDelegate(model);
154 SystemTrayDelegate* TestShellDelegate::CreateSystemTrayDelegate() {
155 return new TestSystemTrayDelegate;
158 UserWallpaperDelegate* TestShellDelegate::CreateUserWallpaperDelegate() {
159 return new TestUserWallpaperDelegate();
162 SessionStateDelegate* TestShellDelegate::CreateSessionStateDelegate() {
163 DCHECK(!test_session_state_delegate_);
164 test_session_state_delegate_ = new TestSessionStateDelegate();
165 return test_session_state_delegate_;
168 AccessibilityDelegate* TestShellDelegate::CreateAccessibilityDelegate() {
169 return new DefaultAccessibilityDelegate();
172 NewWindowDelegate* TestShellDelegate::CreateNewWindowDelegate() {
173 return new NewWindowDelegateImpl;
176 MediaDelegate* TestShellDelegate::CreateMediaDelegate() {
177 return new MediaDelegateImpl;
180 ui::MenuModel* TestShellDelegate::CreateContextMenu(
181 aura::Window* root,
182 ash::ShelfItemDelegate* item_delegate,
183 ash::ShelfItem* item) {
184 return NULL;
187 GPUSupport* TestShellDelegate::CreateGPUSupport() {
188 // Real GPU support depends on src/content, so just use a stub.
189 return new GPUSupportStub;
192 base::string16 TestShellDelegate::GetProductName() const {
193 return base::string16();
196 void TestShellDelegate::SetMediaCaptureState(MediaCaptureState state) {
197 #if defined(OS_CHROMEOS)
198 Shell* shell = Shell::GetInstance();
199 static_cast<MediaDelegateImpl*>(shell->media_delegate())
200 ->set_media_capture_state(state);
201 shell->system_tray_notifier()->NotifyMediaCaptureChanged();
202 #endif
205 } // namespace test
206 } // namespace ash