Infer appropriate GNU_STACK alignment for a shared library.
[chromium-blink-merge.git] / ash / shell / shell_delegate_impl.cc
blobdc081c6fc359aba744fdf4c1c1020099b65bc638
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/shell/shell_delegate_impl.h"
7 #include "ash/accessibility_delegate.h"
8 #include "ash/default_accessibility_delegate.h"
9 #include "ash/default_user_wallpaper_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/context_menu.h"
15 #include "ash/shell/example_factory.h"
16 #include "ash/shell/keyboard_controller_proxy_stub.h"
17 #include "ash/shell/shelf_delegate_impl.h"
18 #include "ash/shell/toplevel_window.h"
19 #include "ash/shell_window_ids.h"
20 #include "ash/system/tray/default_system_tray_delegate.h"
21 #include "ash/wm/window_state.h"
22 #include "base/message_loop/message_loop.h"
23 #include "base/strings/utf_string_conversions.h"
24 #include "components/user_manager/user_info_impl.h"
25 #include "ui/app_list/app_list_view_delegate.h"
26 #include "ui/aura/window.h"
27 #include "ui/wm/core/input_method_event_filter.h"
29 namespace ash {
30 namespace shell {
31 namespace {
33 class NewWindowDelegateImpl : public NewWindowDelegate {
34 public:
35 NewWindowDelegateImpl() {}
36 ~NewWindowDelegateImpl() override {}
38 // NewWindowDelegate:
39 void NewTab() override {}
40 void NewWindow(bool incognito) override {
41 ash::shell::ToplevelWindow::CreateParams create_params;
42 create_params.can_resize = true;
43 create_params.can_maximize = true;
44 ash::shell::ToplevelWindow::CreateToplevelWindow(create_params);
46 void OpenFileManager() override {}
47 void OpenCrosh() override {}
48 void OpenGetHelp() override {}
49 void RestoreTab() override {}
50 void ShowKeyboardOverlay() override {}
51 void ShowTaskManager() override {}
52 void OpenFeedbackPage() override {}
54 private:
55 DISALLOW_COPY_AND_ASSIGN(NewWindowDelegateImpl);
58 class MediaDelegateImpl : public MediaDelegate {
59 public:
60 MediaDelegateImpl() {}
61 ~MediaDelegateImpl() override {}
63 // MediaDelegate:
64 void HandleMediaNextTrack() override {}
65 void HandleMediaPlayPause() override {}
66 void HandleMediaPrevTrack() override {}
67 MediaCaptureState GetMediaCaptureState(
68 content::BrowserContext* context) override {
69 return MEDIA_CAPTURE_VIDEO;
72 private:
73 DISALLOW_COPY_AND_ASSIGN(MediaDelegateImpl);
76 class SessionStateDelegateImpl : public SessionStateDelegate {
77 public:
78 SessionStateDelegateImpl()
79 : screen_locked_(false), user_info_(new user_manager::UserInfoImpl()) {}
81 ~SessionStateDelegateImpl() override {}
83 // SessionStateDelegate:
84 content::BrowserContext* GetBrowserContextByIndex(
85 MultiProfileIndex index) override {
86 return Shell::GetInstance()->delegate()->GetActiveBrowserContext();
88 content::BrowserContext* GetBrowserContextForWindow(
89 aura::Window* window) override {
90 return Shell::GetInstance()->delegate()->GetActiveBrowserContext();
92 int GetMaximumNumberOfLoggedInUsers() const override { return 3; }
93 int NumberOfLoggedInUsers() const override {
94 // ash_shell has 2 users.
95 return 2;
97 bool IsActiveUserSessionStarted() const override { return true; }
98 bool CanLockScreen() const override { return true; }
99 bool IsScreenLocked() const override { return screen_locked_; }
100 bool ShouldLockScreenBeforeSuspending() const override { return false; }
101 void LockScreen() override {
102 shell::CreateLockScreen();
103 screen_locked_ = true;
104 Shell::GetInstance()->UpdateShelfVisibility();
106 void UnlockScreen() override {
107 screen_locked_ = false;
108 Shell::GetInstance()->UpdateShelfVisibility();
110 bool IsUserSessionBlocked() const override {
111 return !IsActiveUserSessionStarted() || IsScreenLocked();
113 SessionState GetSessionState() const override {
114 // Assume that if session is not active we're at login.
115 return IsActiveUserSessionStarted() ? SESSION_STATE_ACTIVE
116 : SESSION_STATE_LOGIN_PRIMARY;
118 const user_manager::UserInfo* GetUserInfo(
119 MultiProfileIndex index) const override {
120 return user_info_.get();
122 const user_manager::UserInfo* GetUserInfo(
123 content::BrowserContext* context) const override {
124 return user_info_.get();
126 bool ShouldShowAvatar(aura::Window* window) const override {
127 return !user_info_->GetImage().isNull();
129 void SwitchActiveUser(const std::string& user_id) override {}
130 void CycleActiveUser(CycleUser cycle_user) override {}
131 bool IsMultiProfileAllowedByPrimaryUserPolicy() const override {
132 return true;
134 void AddSessionStateObserver(ash::SessionStateObserver* observer) override {}
135 void RemoveSessionStateObserver(
136 ash::SessionStateObserver* observer) override {}
138 private:
139 bool screen_locked_;
141 // A pseudo user info.
142 scoped_ptr<user_manager::UserInfo> user_info_;
144 DISALLOW_COPY_AND_ASSIGN(SessionStateDelegateImpl);
147 } // namespace
149 ShellDelegateImpl::ShellDelegateImpl()
150 : watcher_(NULL),
151 shelf_delegate_(NULL),
152 browser_context_(NULL) {
155 ShellDelegateImpl::~ShellDelegateImpl() {
158 void ShellDelegateImpl::SetWatcher(WindowWatcher* watcher) {
159 watcher_ = watcher;
160 if (shelf_delegate_)
161 shelf_delegate_->set_watcher(watcher);
164 bool ShellDelegateImpl::IsFirstRunAfterBoot() const {
165 return false;
168 bool ShellDelegateImpl::IsIncognitoAllowed() const {
169 return true;
172 bool ShellDelegateImpl::IsMultiProfilesEnabled() const {
173 return false;
176 bool ShellDelegateImpl::IsRunningInForcedAppMode() const {
177 return false;
180 bool ShellDelegateImpl::IsMultiAccountEnabled() const {
181 return false;
184 void ShellDelegateImpl::PreInit() {
187 void ShellDelegateImpl::PreShutdown() {
190 void ShellDelegateImpl::Exit() {
191 base::MessageLoopForUI::current()->Quit();
194 keyboard::KeyboardControllerProxy*
195 ShellDelegateImpl::CreateKeyboardControllerProxy() {
196 return new KeyboardControllerProxyStub();
199 void ShellDelegateImpl::VirtualKeyboardActivated(bool activated) {
202 void ShellDelegateImpl::AddVirtualKeyboardStateObserver(
203 VirtualKeyboardStateObserver* observer) {
206 void ShellDelegateImpl::RemoveVirtualKeyboardStateObserver(
207 VirtualKeyboardStateObserver* observer) {
210 content::BrowserContext* ShellDelegateImpl::GetActiveBrowserContext() {
211 return browser_context_;
214 app_list::AppListViewDelegate* ShellDelegateImpl::GetAppListViewDelegate() {
215 if (!app_list_view_delegate_)
216 app_list_view_delegate_.reset(ash::shell::CreateAppListViewDelegate());
217 return app_list_view_delegate_.get();
220 ShelfDelegate* ShellDelegateImpl::CreateShelfDelegate(ShelfModel* model) {
221 shelf_delegate_ = new ShelfDelegateImpl(watcher_);
222 return shelf_delegate_;
225 ash::SystemTrayDelegate* ShellDelegateImpl::CreateSystemTrayDelegate() {
226 return new DefaultSystemTrayDelegate;
229 ash::UserWallpaperDelegate* ShellDelegateImpl::CreateUserWallpaperDelegate() {
230 return new DefaultUserWallpaperDelegate();
233 ash::SessionStateDelegate* ShellDelegateImpl::CreateSessionStateDelegate() {
234 return new SessionStateDelegateImpl;
237 ash::AccessibilityDelegate* ShellDelegateImpl::CreateAccessibilityDelegate() {
238 return new DefaultAccessibilityDelegate;
241 ash::NewWindowDelegate* ShellDelegateImpl::CreateNewWindowDelegate() {
242 return new NewWindowDelegateImpl;
245 ash::MediaDelegate* ShellDelegateImpl::CreateMediaDelegate() {
246 return new MediaDelegateImpl;
249 ui::MenuModel* ShellDelegateImpl::CreateContextMenu(
250 aura::Window* root,
251 ash::ShelfItemDelegate* item_delegate,
252 ash::ShelfItem* item) {
253 return new ContextMenu(root);
256 GPUSupport* ShellDelegateImpl::CreateGPUSupport() {
257 // Real GPU support depends on src/content, so just use a stub.
258 return new GPUSupportStub;
261 base::string16 ShellDelegateImpl::GetProductName() const {
262 return base::string16();
265 } // namespace shell
266 } // namespace ash