| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/shell/shell_delegate_impl.h" | 5 #include "ash/shell/shell_delegate_impl.h" |
| 6 | 6 |
| 7 #include "ash/accessibility_delegate.h" | 7 #include "ash/accessibility_delegate.h" |
| 8 #include "ash/default_accessibility_delegate.h" | 8 #include "ash/default_accessibility_delegate.h" |
| 9 #include "ash/default_user_wallpaper_delegate.h" | 9 #include "ash/default_user_wallpaper_delegate.h" |
| 10 #include "ash/gpu_support_stub.h" | 10 #include "ash/gpu_support_stub.h" |
| 11 #include "ash/media_delegate.h" | 11 #include "ash/media_delegate.h" |
| 12 #include "ash/new_window_delegate.h" | 12 #include "ash/new_window_delegate.h" |
| 13 #include "ash/session/session_state_delegate.h" | 13 #include "ash/session/session_state_delegate.h" |
| 14 #include "ash/session/session_state_delegate_stub.h" | 14 #include "ash/session/user_info.h" |
| 15 #include "ash/shell/context_menu.h" | 15 #include "ash/shell/context_menu.h" |
| 16 #include "ash/shell/example_factory.h" | 16 #include "ash/shell/example_factory.h" |
| 17 #include "ash/shell/keyboard_controller_proxy_stub.h" | 17 #include "ash/shell/keyboard_controller_proxy_stub.h" |
| 18 #include "ash/shell/shelf_delegate_impl.h" | 18 #include "ash/shell/shelf_delegate_impl.h" |
| 19 #include "ash/shell/toplevel_window.h" | 19 #include "ash/shell/toplevel_window.h" |
| 20 #include "ash/shell_window_ids.h" | 20 #include "ash/shell_window_ids.h" |
| 21 #include "ash/system/tray/default_system_tray_delegate.h" | 21 #include "ash/system/tray/default_system_tray_delegate.h" |
| 22 #include "ash/wm/window_state.h" | 22 #include "ash/wm/window_state.h" |
| 23 #include "base/message_loop/message_loop.h" | 23 #include "base/message_loop/message_loop.h" |
| 24 #include "base/strings/utf_string_conversions.h" |
| 24 #include "ui/aura/window.h" | 25 #include "ui/aura/window.h" |
| 25 #include "ui/wm/core/input_method_event_filter.h" | 26 #include "ui/wm/core/input_method_event_filter.h" |
| 26 | 27 |
| 27 namespace ash { | 28 namespace ash { |
| 28 namespace shell { | 29 namespace shell { |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 class NewWindowDelegateImpl : public NewWindowDelegate { | 32 class NewWindowDelegateImpl : public NewWindowDelegate { |
| 32 public: | 33 public: |
| 33 NewWindowDelegateImpl() {} | 34 NewWindowDelegateImpl() {} |
| 34 virtual ~NewWindowDelegateImpl() {} | 35 virtual ~NewWindowDelegateImpl() {} |
| 35 | 36 |
| 37 // NewWindowDelegate: |
| 36 virtual void NewTab() OVERRIDE {} | 38 virtual void NewTab() OVERRIDE {} |
| 37 virtual void NewWindow(bool incognito) OVERRIDE { | 39 virtual void NewWindow(bool incognito) OVERRIDE { |
| 38 ash::shell::ToplevelWindow::CreateParams create_params; | 40 ash::shell::ToplevelWindow::CreateParams create_params; |
| 39 create_params.can_resize = true; | 41 create_params.can_resize = true; |
| 40 create_params.can_maximize = true; | 42 create_params.can_maximize = true; |
| 41 ash::shell::ToplevelWindow::CreateToplevelWindow(create_params); | 43 ash::shell::ToplevelWindow::CreateToplevelWindow(create_params); |
| 42 } | 44 } |
| 43 virtual void OpenFileManager() OVERRIDE {} | 45 virtual void OpenFileManager() OVERRIDE {} |
| 44 virtual void OpenCrosh() OVERRIDE {} | 46 virtual void OpenCrosh() OVERRIDE {} |
| 45 virtual void RestoreTab() OVERRIDE {} | 47 virtual void RestoreTab() OVERRIDE {} |
| 46 virtual void ShowKeyboardOverlay() OVERRIDE {} | 48 virtual void ShowKeyboardOverlay() OVERRIDE {} |
| 47 virtual void ShowTaskManager() OVERRIDE {} | 49 virtual void ShowTaskManager() OVERRIDE {} |
| 48 virtual void OpenFeedbackPage() OVERRIDE {} | 50 virtual void OpenFeedbackPage() OVERRIDE {} |
| 49 | 51 |
| 50 private: | 52 private: |
| 51 DISALLOW_COPY_AND_ASSIGN(NewWindowDelegateImpl); | 53 DISALLOW_COPY_AND_ASSIGN(NewWindowDelegateImpl); |
| 52 }; | 54 }; |
| 53 | 55 |
| 54 class MediaDelegateImpl : public MediaDelegate { | 56 class MediaDelegateImpl : public MediaDelegate { |
| 55 public: | 57 public: |
| 56 MediaDelegateImpl() {} | 58 MediaDelegateImpl() {} |
| 57 virtual ~MediaDelegateImpl() {} | 59 virtual ~MediaDelegateImpl() {} |
| 58 | 60 |
| 61 // MediaDelegate: |
| 59 virtual void HandleMediaNextTrack() OVERRIDE {} | 62 virtual void HandleMediaNextTrack() OVERRIDE {} |
| 60 virtual void HandleMediaPlayPause() OVERRIDE {} | 63 virtual void HandleMediaPlayPause() OVERRIDE {} |
| 61 virtual void HandleMediaPrevTrack() OVERRIDE {} | 64 virtual void HandleMediaPrevTrack() OVERRIDE {} |
| 65 virtual MediaCaptureState GetMediaCaptureState( |
| 66 content::BrowserContext* context) OVERRIDE { |
| 67 return MEDIA_CAPTURE_VIDEO; |
| 68 } |
| 62 | 69 |
| 63 private: | 70 private: |
| 64 DISALLOW_COPY_AND_ASSIGN(MediaDelegateImpl); | 71 DISALLOW_COPY_AND_ASSIGN(MediaDelegateImpl); |
| 65 }; | 72 }; |
| 66 | 73 |
| 74 class UserInfoImpl : public UserInfo { |
| 75 public: |
| 76 UserInfoImpl() {} |
| 77 virtual ~UserInfoImpl() {} |
| 78 |
| 79 // UserInfo: |
| 80 virtual base::string16 GetDisplayName() const OVERRIDE { |
| 81 return base::UTF8ToUTF16("stub-user"); |
| 82 } |
| 83 virtual base::string16 GetGivenName() const OVERRIDE { |
| 84 return base::UTF8ToUTF16("Stub"); |
| 85 } |
| 86 virtual std::string GetEmail() const OVERRIDE { |
| 87 return "stub-user@domain.com"; |
| 88 } |
| 89 virtual std::string GetUserID() const OVERRIDE { return GetEmail(); } |
| 90 virtual const gfx::ImageSkia& GetImage() const OVERRIDE { |
| 91 return user_image_; |
| 92 } |
| 93 |
| 94 private: |
| 95 gfx::ImageSkia user_image_; |
| 96 |
| 97 DISALLOW_COPY_AND_ASSIGN(UserInfoImpl); |
| 98 }; |
| 99 |
| 100 class SessionStateDelegateImpl : public SessionStateDelegate { |
| 101 public: |
| 102 SessionStateDelegateImpl() |
| 103 : screen_locked_(false), user_info_(new UserInfoImpl()) {} |
| 104 |
| 105 virtual ~SessionStateDelegateImpl() {} |
| 106 |
| 107 // SessionStateDelegate: |
| 108 virtual content::BrowserContext* GetBrowserContextByIndex( |
| 109 MultiProfileIndex index) OVERRIDE { |
| 110 return Shell::GetInstance()->delegate()->GetActiveBrowserContext(); |
| 111 } |
| 112 virtual content::BrowserContext* GetBrowserContextForWindow( |
| 113 aura::Window* window) OVERRIDE { |
| 114 return Shell::GetInstance()->delegate()->GetActiveBrowserContext(); |
| 115 } |
| 116 virtual int GetMaximumNumberOfLoggedInUsers() const OVERRIDE { return 3; } |
| 117 virtual int NumberOfLoggedInUsers() const OVERRIDE { |
| 118 // ash_shell has 2 users. |
| 119 return 2; |
| 120 } |
| 121 virtual bool IsActiveUserSessionStarted() const OVERRIDE { return true; } |
| 122 virtual bool CanLockScreen() const OVERRIDE { return true; } |
| 123 virtual bool IsScreenLocked() const OVERRIDE { return screen_locked_; } |
| 124 virtual bool ShouldLockScreenBeforeSuspending() const OVERRIDE { |
| 125 return false; |
| 126 } |
| 127 virtual void LockScreen() OVERRIDE { |
| 128 shell::CreateLockScreen(); |
| 129 screen_locked_ = true; |
| 130 Shell::GetInstance()->UpdateShelfVisibility(); |
| 131 } |
| 132 virtual void UnlockScreen() OVERRIDE { |
| 133 screen_locked_ = false; |
| 134 Shell::GetInstance()->UpdateShelfVisibility(); |
| 135 } |
| 136 virtual bool IsUserSessionBlocked() const OVERRIDE { |
| 137 return !IsActiveUserSessionStarted() || IsScreenLocked(); |
| 138 } |
| 139 virtual SessionState GetSessionState() const OVERRIDE { |
| 140 // Assume that if session is not active we're at login. |
| 141 return IsActiveUserSessionStarted() ? SESSION_STATE_ACTIVE |
| 142 : SESSION_STATE_LOGIN_PRIMARY; |
| 143 } |
| 144 virtual const UserInfo* GetUserInfo(MultiProfileIndex index) const OVERRIDE { |
| 145 return user_info_.get(); |
| 146 } |
| 147 virtual const UserInfo* GetUserInfo( |
| 148 content::BrowserContext* context) const OVERRIDE { |
| 149 return user_info_.get(); |
| 150 } |
| 151 virtual bool ShouldShowAvatar(aura::Window* window) const OVERRIDE { |
| 152 return !user_info_->GetImage().isNull(); |
| 153 } |
| 154 virtual void SwitchActiveUser(const std::string& user_id) OVERRIDE {} |
| 155 virtual void CycleActiveUser(CycleUser cycle_user) OVERRIDE {} |
| 156 virtual void AddSessionStateObserver( |
| 157 ash::SessionStateObserver* observer) OVERRIDE {} |
| 158 virtual void RemoveSessionStateObserver( |
| 159 ash::SessionStateObserver* observer) OVERRIDE {} |
| 160 |
| 161 private: |
| 162 bool screen_locked_; |
| 163 |
| 164 // A pseudo user info. |
| 165 scoped_ptr<UserInfo> user_info_; |
| 166 |
| 167 DISALLOW_COPY_AND_ASSIGN(SessionStateDelegateImpl); |
| 168 }; |
| 169 |
| 67 } // namespace | 170 } // namespace |
| 68 | 171 |
| 69 ShellDelegateImpl::ShellDelegateImpl() | 172 ShellDelegateImpl::ShellDelegateImpl() |
| 70 : watcher_(NULL), | 173 : watcher_(NULL), |
| 71 shelf_delegate_(NULL), | 174 shelf_delegate_(NULL), |
| 72 browser_context_(NULL) { | 175 browser_context_(NULL) { |
| 73 } | 176 } |
| 74 | 177 |
| 75 ShellDelegateImpl::~ShellDelegateImpl() { | 178 ShellDelegateImpl::~ShellDelegateImpl() { |
| 76 } | 179 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 245 |
| 143 ash::SystemTrayDelegate* ShellDelegateImpl::CreateSystemTrayDelegate() { | 246 ash::SystemTrayDelegate* ShellDelegateImpl::CreateSystemTrayDelegate() { |
| 144 return new DefaultSystemTrayDelegate; | 247 return new DefaultSystemTrayDelegate; |
| 145 } | 248 } |
| 146 | 249 |
| 147 ash::UserWallpaperDelegate* ShellDelegateImpl::CreateUserWallpaperDelegate() { | 250 ash::UserWallpaperDelegate* ShellDelegateImpl::CreateUserWallpaperDelegate() { |
| 148 return new DefaultUserWallpaperDelegate(); | 251 return new DefaultUserWallpaperDelegate(); |
| 149 } | 252 } |
| 150 | 253 |
| 151 ash::SessionStateDelegate* ShellDelegateImpl::CreateSessionStateDelegate() { | 254 ash::SessionStateDelegate* ShellDelegateImpl::CreateSessionStateDelegate() { |
| 152 return new SessionStateDelegateStub; | 255 return new SessionStateDelegateImpl; |
| 153 } | 256 } |
| 154 | 257 |
| 155 ash::AccessibilityDelegate* ShellDelegateImpl::CreateAccessibilityDelegate() { | 258 ash::AccessibilityDelegate* ShellDelegateImpl::CreateAccessibilityDelegate() { |
| 156 return new DefaultAccessibilityDelegate; | 259 return new DefaultAccessibilityDelegate; |
| 157 } | 260 } |
| 158 | 261 |
| 159 ash::NewWindowDelegate* ShellDelegateImpl::CreateNewWindowDelegate() { | 262 ash::NewWindowDelegate* ShellDelegateImpl::CreateNewWindowDelegate() { |
| 160 return new NewWindowDelegateImpl; | 263 return new NewWindowDelegateImpl; |
| 161 } | 264 } |
| 162 | 265 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 175 // Real GPU support depends on src/content, so just use a stub. | 278 // Real GPU support depends on src/content, so just use a stub. |
| 176 return new GPUSupportStub; | 279 return new GPUSupportStub; |
| 177 } | 280 } |
| 178 | 281 |
| 179 base::string16 ShellDelegateImpl::GetProductName() const { | 282 base::string16 ShellDelegateImpl::GetProductName() const { |
| 180 return base::string16(); | 283 return base::string16(); |
| 181 } | 284 } |
| 182 | 285 |
| 183 } // namespace shell | 286 } // namespace shell |
| 184 } // namespace ash | 287 } // namespace ash |
| OLD | NEW |