Update JNI generator for javap version 1.8.
[chromium-blink-merge.git] / ash / test / test_shell_delegate.cc
blobbb712be0133c997871ac3372aa978e9ca679cf0d
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 test_session_state_delegate_(NULL) {
88 TestShellDelegate::~TestShellDelegate() {
91 bool TestShellDelegate::IsFirstRunAfterBoot() const {
92 return false;
95 bool TestShellDelegate::IsIncognitoAllowed() const {
96 return true;
99 bool TestShellDelegate::IsMultiProfilesEnabled() const {
100 return multi_profiles_enabled_;
103 bool TestShellDelegate::IsRunningInForcedAppMode() const {
104 return false;
107 bool TestShellDelegate::IsMultiAccountEnabled() const {
108 return false;
111 void TestShellDelegate::PreInit() {
114 void TestShellDelegate::PreShutdown() {
117 void TestShellDelegate::Exit() {
118 num_exit_requests_++;
121 keyboard::KeyboardControllerProxy*
122 TestShellDelegate::CreateKeyboardControllerProxy() {
123 return new KeyboardControllerProxyStub();
126 void TestShellDelegate::VirtualKeyboardActivated(bool activated) {
127 FOR_EACH_OBSERVER(ash::VirtualKeyboardStateObserver,
128 keyboard_state_observer_list_,
129 OnVirtualKeyboardStateChanged(activated));
132 void TestShellDelegate::AddVirtualKeyboardStateObserver(
133 VirtualKeyboardStateObserver* observer) {
134 keyboard_state_observer_list_.AddObserver(observer);
137 void TestShellDelegate::RemoveVirtualKeyboardStateObserver(
138 VirtualKeyboardStateObserver* observer) {
139 keyboard_state_observer_list_.RemoveObserver(observer);
142 content::BrowserContext* TestShellDelegate::GetActiveBrowserContext() {
143 active_browser_context_.reset(new content::TestBrowserContext());
144 return active_browser_context_.get();
147 app_list::AppListViewDelegate* TestShellDelegate::GetAppListViewDelegate() {
148 if (!app_list_view_delegate_)
149 app_list_view_delegate_.reset(new app_list::test::AppListTestViewDelegate);
150 return app_list_view_delegate_.get();
153 ShelfDelegate* TestShellDelegate::CreateShelfDelegate(ShelfModel* model) {
154 return new TestShelfDelegate(model);
157 SystemTrayDelegate* TestShellDelegate::CreateSystemTrayDelegate() {
158 return new TestSystemTrayDelegate;
161 UserWallpaperDelegate* TestShellDelegate::CreateUserWallpaperDelegate() {
162 return new TestUserWallpaperDelegate();
165 SessionStateDelegate* TestShellDelegate::CreateSessionStateDelegate() {
166 DCHECK(!test_session_state_delegate_);
167 test_session_state_delegate_ = new TestSessionStateDelegate();
168 return test_session_state_delegate_;
171 AccessibilityDelegate* TestShellDelegate::CreateAccessibilityDelegate() {
172 return new DefaultAccessibilityDelegate();
175 NewWindowDelegate* TestShellDelegate::CreateNewWindowDelegate() {
176 return new NewWindowDelegateImpl;
179 MediaDelegate* TestShellDelegate::CreateMediaDelegate() {
180 return new MediaDelegateImpl;
183 ui::MenuModel* TestShellDelegate::CreateContextMenu(
184 aura::Window* root,
185 ash::ShelfItemDelegate* item_delegate,
186 ash::ShelfItem* item) {
187 return NULL;
190 GPUSupport* TestShellDelegate::CreateGPUSupport() {
191 // Real GPU support depends on src/content, so just use a stub.
192 return new GPUSupportStub;
195 base::string16 TestShellDelegate::GetProductName() const {
196 return base::string16();
199 void TestShellDelegate::SetMediaCaptureState(MediaCaptureState state) {
200 #if defined(OS_CHROMEOS)
201 Shell* shell = Shell::GetInstance();
202 static_cast<MediaDelegateImpl*>(shell->media_delegate())
203 ->set_media_capture_state(state);
204 shell->system_tray_notifier()->NotifyMediaCaptureChanged();
205 #endif
208 } // namespace test
209 } // namespace ash