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. 4 5 #include "ash/test/test_shell_delegate.h" 6 7 #include <limits> 8 9 #include "ash/caps_lock_delegate_stub.h" 10 #include "ash/default_accessibility_delegate.h" 11 #include "ash/host/root_window_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/shell.h" 16 #include "ash/shell/keyboard_controller_proxy_stub.h" 17 #include "ash/shell_window_ids.h" 18 #include "ash/test/test_session_state_delegate.h" 19 #include "ash/test/test_shelf_delegate.h" 20 #include "ash/test/test_system_tray_delegate.h" 21 #include "ash/test/test_user_wallpaper_delegate.h" 22 #include "ash/wm/window_state.h" 23 #include "ash/wm/window_util.h" 24 #include "base/logging.h" 25 #include "content/public/test/test_browser_context.h" 26 #include "ui/app_list/app_list_model.h" 27 #include "ui/app_list/app_list_view_delegate.h" 28 #include "ui/app_list/test/app_list_test_view_delegate.h" 29 #include "ui/aura/window.h" 30 31 namespace ash { 32 namespace test { 33 namespace { 34 35 class NewWindowDelegateImpl : public NewWindowDelegate { 36 virtual void NewTab() OVERRIDE {} 37 virtual void NewWindow(bool incognito) OVERRIDE {} 38 virtual void OpenFileManager() OVERRIDE {} 39 virtual void OpenCrosh() OVERRIDE {} 40 virtual void RestoreTab() OVERRIDE {} 41 virtual void ShowKeyboardOverlay() OVERRIDE {} 42 virtual void ShowTaskManager() OVERRIDE {} 43 virtual void OpenFeedbackPage() OVERRIDE {} 44 }; 45 46 class MediaDelegateImpl : public MediaDelegate { 47 public: 48 virtual void HandleMediaNextTrack() OVERRIDE {} 49 virtual void HandleMediaPlayPause() OVERRIDE {} 50 virtual void HandleMediaPrevTrack() OVERRIDE {} 51 }; 52 53 } // namespace 54 55 TestShellDelegate::TestShellDelegate() 56 : num_exit_requests_(0), 57 multi_profiles_enabled_(false), 58 test_session_state_delegate_(NULL) { 59 } 60 61 TestShellDelegate::~TestShellDelegate() { 62 } 63 64 bool TestShellDelegate::IsFirstRunAfterBoot() const { 65 return false; 66 } 67 68 bool TestShellDelegate::IsIncognitoAllowed() const { 69 return true; 70 } 71 72 bool TestShellDelegate::IsMultiProfilesEnabled() const { 73 return multi_profiles_enabled_; 74 } 75 76 bool TestShellDelegate::IsRunningInForcedAppMode() const { 77 return false; 78 } 79 80 void TestShellDelegate::PreInit() { 81 } 82 83 void TestShellDelegate::Shutdown() { 84 } 85 86 void TestShellDelegate::Exit() { 87 num_exit_requests_++; 88 } 89 90 keyboard::KeyboardControllerProxy* 91 TestShellDelegate::CreateKeyboardControllerProxy() { 92 return new KeyboardControllerProxyStub(); 93 } 94 95 content::BrowserContext* TestShellDelegate::GetActiveBrowserContext() { 96 active_browser_context_.reset(new content::TestBrowserContext()); 97 return active_browser_context_.get(); 98 } 99 100 app_list::AppListViewDelegate* TestShellDelegate::CreateAppListViewDelegate() { 101 return new app_list::test::AppListTestViewDelegate; 102 } 103 104 ShelfDelegate* TestShellDelegate::CreateShelfDelegate(ShelfModel* model) { 105 return new TestShelfDelegate(model); 106 } 107 108 SystemTrayDelegate* TestShellDelegate::CreateSystemTrayDelegate() { 109 return new TestSystemTrayDelegate; 110 } 111 112 UserWallpaperDelegate* TestShellDelegate::CreateUserWallpaperDelegate() { 113 return new TestUserWallpaperDelegate(); 114 } 115 116 CapsLockDelegate* TestShellDelegate::CreateCapsLockDelegate() { 117 return new CapsLockDelegateStub; 118 } 119 120 SessionStateDelegate* TestShellDelegate::CreateSessionStateDelegate() { 121 DCHECK(!test_session_state_delegate_); 122 test_session_state_delegate_ = new TestSessionStateDelegate(); 123 return test_session_state_delegate_; 124 } 125 126 AccessibilityDelegate* TestShellDelegate::CreateAccessibilityDelegate() { 127 return new internal::DefaultAccessibilityDelegate(); 128 } 129 130 NewWindowDelegate* TestShellDelegate::CreateNewWindowDelegate() { 131 return new NewWindowDelegateImpl; 132 } 133 134 MediaDelegate* TestShellDelegate::CreateMediaDelegate() { 135 return new MediaDelegateImpl; 136 } 137 138 aura::client::UserActionClient* TestShellDelegate::CreateUserActionClient() { 139 return NULL; 140 } 141 142 ui::MenuModel* TestShellDelegate::CreateContextMenu(aura::Window* root) { 143 return NULL; 144 } 145 146 RootWindowHostFactory* TestShellDelegate::CreateRootWindowHostFactory() { 147 return RootWindowHostFactory::Create(); 148 } 149 150 base::string16 TestShellDelegate::GetProductName() const { 151 return base::string16(); 152 } 153 154 TestSessionStateDelegate* TestShellDelegate::test_session_state_delegate() { 155 return test_session_state_delegate_; 156 } 157 158 } // namespace test 159 } // namespace ash 160