Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: chrome/browser/ui/ash/chrome_shell_delegate.cc

Issue 1960293003: Remove OS_CHROMEOS from ui/ash code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/browser/ui/ash/chrome_shell_delegate.h" 5 #include "chrome/browser/ui/ash/chrome_shell_delegate.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "ash/accelerators/magnifier_key_scroller.h"
10 #include "ash/accelerators/spoken_feedback_toggler.h"
11 #include "ash/accessibility_delegate.h"
9 #include "ash/container_delegate_aura.h" 12 #include "ash/container_delegate_aura.h"
10 #include "ash/content/gpu_support_impl.h" 13 #include "ash/content/gpu_support_impl.h"
11 #include "ash/pointer_watcher_delegate_aura.h" 14 #include "ash/pointer_watcher_delegate_aura.h"
12 #include "ash/session/session_state_delegate.h" 15 #include "ash/session/session_state_delegate.h"
13 #include "ash/wm/common/window_state.h" 16 #include "ash/wm/common/window_state.h"
17 #include "ash/wm/mru_window_tracker.h"
14 #include "ash/wm/window_util.h" 18 #include "ash/wm/window_util.h"
19 #include "base/command_line.h"
20 #include "base/macros.h"
15 #include "base/memory/ptr_util.h" 21 #include "base/memory/ptr_util.h"
16 #include "build/build_config.h" 22 #include "build/build_config.h"
17 #include "chrome/browser/app_mode/app_mode_utils.h" 23 #include "chrome/browser/app_mode/app_mode_utils.h"
24 #include "chrome/browser/chrome_notification_types.h"
25 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
26 #include "chrome/browser/chromeos/accessibility/magnification_manager.h"
27 #include "chrome/browser/chromeos/background/ash_user_wallpaper_delegate.h"
28 #include "chrome/browser/chromeos/display/display_configuration_observer.h"
29 #include "chrome/browser/chromeos/display/display_preferences.h"
30 #include "chrome/browser/chromeos/policy/display_rotation_default_handler.h"
31 #include "chrome/browser/chromeos/profiles/profile_helper.h"
32 #include "chrome/browser/chromeos/system/input_device_settings.h"
18 #include "chrome/browser/lifetime/application_lifetime.h" 33 #include "chrome/browser/lifetime/application_lifetime.h"
34 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/profiles/profile_manager.h" 35 #include "chrome/browser/profiles/profile_manager.h"
20 #include "chrome/browser/profiles/profiles_state.h" 36 #include "chrome/browser/profiles/profiles_state.h"
37 #include "chrome/browser/signin/signin_error_notifier_factory_ash.h"
38 #include "chrome/browser/speech/tts_controller.h"
39 #include "chrome/browser/sync/sync_error_notifier_factory_ash.h"
21 #include "chrome/browser/ui/app_list/app_list_view_delegate.h" 40 #include "chrome/browser/ui/app_list/app_list_view_delegate.h"
22 #include "chrome/browser/ui/ash/app_list/app_list_service_ash.h" 41 #include "chrome/browser/ui/ash/app_list/app_list_service_ash.h"
23 #include "chrome/browser/ui/ash/chrome_keyboard_ui.h" 42 #include "chrome/browser/ui/ash/chrome_keyboard_ui.h"
43 #include "chrome/browser/ui/ash/chrome_new_window_delegate.h"
24 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 44 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
25 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" 45 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h"
46 #include "chrome/browser/ui/ash/media_delegate_chromeos.h"
26 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 47 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
48 #include "chrome/browser/ui/ash/session_state_delegate_chromeos.h"
27 #include "chrome/browser/ui/ash/session_util.h" 49 #include "chrome/browser/ui/ash/session_util.h"
50 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h"
51 #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h"
28 #include "chrome/browser/ui/browser.h" 52 #include "chrome/browser/ui/browser.h"
29 #include "chrome/browser/ui/browser_commands.h" 53 #include "chrome/browser/ui/browser_commands.h"
30 #include "chrome/browser/ui/browser_finder.h" 54 #include "chrome/browser/ui/browser_finder.h"
31 #include "chrome/browser/ui/browser_navigator.h" 55 #include "chrome/browser/ui/browser_navigator.h"
32 #include "chrome/browser/ui/browser_navigator_params.h" 56 #include "chrome/browser/ui/browser_navigator_params.h"
33 #include "chrome/browser/ui/browser_tabstrip.h" 57 #include "chrome/browser/ui/browser_tabstrip.h"
34 #include "chrome/browser/ui/browser_window.h" 58 #include "chrome/browser/ui/browser_window.h"
35 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 59 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
60 #include "chrome/common/pref_names.h"
36 #include "chrome/grit/chromium_strings.h" 61 #include "chrome/grit/chromium_strings.h"
37 #include "grit/theme_resources.h" 62 #include "chrome/grit/generated_resources.h"
38 #include "ui/app_list/presenter/app_list_presenter.h" 63 #include "chromeos/chromeos_switches.h"
39 #include "ui/base/l10n/l10n_util.h"
40 #include "ui/base/resource/resource_bundle.h"
41
42 #if defined(OS_CHROMEOS)
43 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
44 #include "chrome/browser/chromeos/display/display_configuration_observer.h"
45 #include "chrome/browser/chromeos/profiles/profile_helper.h"
46 #include "chrome/browser/chromeos/system/input_device_settings.h"
47 #include "chrome/browser/profiles/profile.h"
48 #include "chrome/common/pref_names.h"
49 #include "components/prefs/pref_service.h" 64 #include "components/prefs/pref_service.h"
50 #include "components/user_manager/user.h" 65 #include "components/user_manager/user.h"
51 #include "components/user_manager/user_manager.h" 66 #include "components/user_manager/user_manager.h"
52 #endif 67 #include "content/public/browser/notification_service.h"
68 #include "content/public/browser/user_metrics.h"
69 #include "grit/theme_resources.h"
70 #include "ui/app_list/presenter/app_list_presenter.h"
71 #include "ui/aura/window.h"
72 #include "ui/base/ime/chromeos/input_method_manager.h"
73 #include "ui/base/l10n/l10n_util.h"
74 #include "ui/base/resource/resource_bundle.h"
53 75
54 namespace { 76 namespace {
55 77
56 const char kKeyboardShortcutHelpPageUrl[] = 78 const char kKeyboardShortcutHelpPageUrl[] =
57 "https://support.google.com/chromebook/answer/183101"; 79 "https://support.google.com/chromebook/answer/183101";
58 80
81 void InitAfterFirstSessionStart() {
82 // Restore focus after the user session is started. It's needed because some
83 // windows can be opened in background while login UI is still active because
84 // we currently restore browser windows before login UI is deleted.
85 ash::Shell* shell = ash::Shell::GetInstance();
86 ash::MruWindowTracker::WindowList mru_list =
87 shell->mru_window_tracker()->BuildMruWindowList();
88 if (!mru_list.empty())
89 mru_list.front()->Focus();
90
91 // Enable magnifier scroll keys as there may be no mouse cursor in kiosk mode.
92 ash::MagnifierKeyScroller::SetEnabled(chrome::IsRunningInForcedAppMode());
93
94 // Enable long press action to toggle spoken feedback with hotrod
95 // remote which can't handle shortcut.
96 ash::SpokenFeedbackToggler::SetEnabled(chrome::IsRunningInForcedAppMode());
97 }
98
99 class AccessibilityDelegateImpl : public ash::AccessibilityDelegate {
100 public:
101 AccessibilityDelegateImpl() {
102 ash::Shell::GetInstance()->AddShellObserver(
103 chromeos::AccessibilityManager::Get());
104 }
105 ~AccessibilityDelegateImpl() override {
106 ash::Shell::GetInstance()->RemoveShellObserver(
107 chromeos::AccessibilityManager::Get());
108 }
109
110 void ToggleHighContrast() override {
111 DCHECK(chromeos::AccessibilityManager::Get());
112 chromeos::AccessibilityManager::Get()->EnableHighContrast(
113 !chromeos::AccessibilityManager::Get()->IsHighContrastEnabled());
114 }
115
116 bool IsSpokenFeedbackEnabled() const override {
117 DCHECK(chromeos::AccessibilityManager::Get());
118 return chromeos::AccessibilityManager::Get()->IsSpokenFeedbackEnabled();
119 }
120
121 void ToggleSpokenFeedback(
122 ui::AccessibilityNotificationVisibility notify) override {
123 DCHECK(chromeos::AccessibilityManager::Get());
124 chromeos::AccessibilityManager::Get()->ToggleSpokenFeedback(notify);
125 }
126
127 bool IsHighContrastEnabled() const override {
128 DCHECK(chromeos::AccessibilityManager::Get());
129 return chromeos::AccessibilityManager::Get()->IsHighContrastEnabled();
130 }
131
132 void SetMagnifierEnabled(bool enabled) override {
133 DCHECK(chromeos::MagnificationManager::Get());
134 return chromeos::MagnificationManager::Get()->SetMagnifierEnabled(enabled);
135 }
136
137 void SetMagnifierType(ui::MagnifierType type) override {
138 DCHECK(chromeos::MagnificationManager::Get());
139 return chromeos::MagnificationManager::Get()->SetMagnifierType(type);
140 }
141
142 bool IsMagnifierEnabled() const override {
143 DCHECK(chromeos::MagnificationManager::Get());
144 return chromeos::MagnificationManager::Get()->IsMagnifierEnabled();
145 }
146
147 ui::MagnifierType GetMagnifierType() const override {
148 DCHECK(chromeos::MagnificationManager::Get());
149 return chromeos::MagnificationManager::Get()->GetMagnifierType();
150 }
151
152 void SetLargeCursorEnabled(bool enabled) override {
153 DCHECK(chromeos::AccessibilityManager::Get());
154 return chromeos::AccessibilityManager::Get()->EnableLargeCursor(enabled);
155 }
156
157 bool IsLargeCursorEnabled() const override {
158 DCHECK(chromeos::AccessibilityManager::Get());
159 return chromeos::AccessibilityManager::Get()->IsLargeCursorEnabled();
160 }
161
162 void SetAutoclickEnabled(bool enabled) override {
163 DCHECK(chromeos::AccessibilityManager::Get());
164 return chromeos::AccessibilityManager::Get()->EnableAutoclick(enabled);
165 }
166
167 bool IsAutoclickEnabled() const override {
168 DCHECK(chromeos::AccessibilityManager::Get());
169 return chromeos::AccessibilityManager::Get()->IsAutoclickEnabled();
170 }
171
172 void SetVirtualKeyboardEnabled(bool enabled) override {
173 DCHECK(chromeos::AccessibilityManager::Get());
174 return chromeos::AccessibilityManager::Get()->EnableVirtualKeyboard(
175 enabled);
176 }
177
178 bool IsVirtualKeyboardEnabled() const override {
179 DCHECK(chromeos::AccessibilityManager::Get());
180 return chromeos::AccessibilityManager::Get()->IsVirtualKeyboardEnabled();
181 }
182
183 void SetMonoAudioEnabled(bool enabled) override {
184 DCHECK(chromeos::AccessibilityManager::Get());
185 return chromeos::AccessibilityManager::Get()->EnableMonoAudio(enabled);
186 }
187
188 bool IsMonoAudioEnabled() const override {
189 DCHECK(chromeos::AccessibilityManager::Get());
190 return chromeos::AccessibilityManager::Get()->IsMonoAudioEnabled();
191 }
192
193 void SetCaretHighlightEnabled(bool enabled) override {
194 DCHECK(chromeos::AccessibilityManager::Get());
195 chromeos::AccessibilityManager::Get()->SetCaretHighlightEnabled(enabled);
196 }
197
198 bool IsCaretHighlightEnabled() const override {
199 DCHECK(chromeos::AccessibilityManager::Get());
200 return chromeos::AccessibilityManager::Get()->IsCaretHighlightEnabled();
201 }
202
203 void SetCursorHighlightEnabled(bool enabled) override {
204 DCHECK(chromeos::AccessibilityManager::Get());
205 chromeos::AccessibilityManager::Get()->SetCursorHighlightEnabled(enabled);
206 }
207
208 bool IsCursorHighlightEnabled() const override {
209 DCHECK(chromeos::AccessibilityManager::Get());
210 return chromeos::AccessibilityManager::Get()->IsCursorHighlightEnabled();
211 }
212
213 void SetFocusHighlightEnabled(bool enabled) override {
214 DCHECK(chromeos::AccessibilityManager::Get());
215 chromeos::AccessibilityManager::Get()->SetFocusHighlightEnabled(enabled);
216 }
217
218 bool IsFocusHighlightEnabled() const override {
219 DCHECK(chromeos::AccessibilityManager::Get());
220 return chromeos::AccessibilityManager::Get()->IsFocusHighlightEnabled();
221 }
222
223 void SetSelectToSpeakEnabled(bool enabled) override {
224 DCHECK(chromeos::AccessibilityManager::Get());
225 chromeos::AccessibilityManager::Get()->SetSelectToSpeakEnabled(enabled);
226 }
227
228 bool IsSelectToSpeakEnabled() const override {
229 DCHECK(chromeos::AccessibilityManager::Get());
230 return chromeos::AccessibilityManager::Get()->IsSelectToSpeakEnabled();
231 }
232
233 void SetSwitchAccessEnabled(bool enabled) override {
234 DCHECK(chromeos::AccessibilityManager::Get());
235 chromeos::AccessibilityManager::Get()->SetSwitchAccessEnabled(enabled);
236 }
237
238 bool IsSwitchAccessEnabled() const override {
239 DCHECK(chromeos::AccessibilityManager::Get());
240 return chromeos::AccessibilityManager::Get()->IsSwitchAccessEnabled();
241 }
242
243 bool ShouldShowAccessibilityMenu() const override {
244 DCHECK(chromeos::AccessibilityManager::Get());
245 return chromeos::AccessibilityManager::Get()->ShouldShowAccessibilityMenu();
246 }
247
248 bool IsBrailleDisplayConnected() const override {
249 DCHECK(chromeos::AccessibilityManager::Get());
250 return chromeos::AccessibilityManager::Get()->IsBrailleDisplayConnected();
251 }
252
253 void SilenceSpokenFeedback() const override {
254 TtsController::GetInstance()->Stop();
255 }
256
257 void SaveScreenMagnifierScale(double scale) override {
258 if (chromeos::MagnificationManager::Get())
259 chromeos::MagnificationManager::Get()->SaveScreenMagnifierScale(scale);
260 }
261
262 double GetSavedScreenMagnifierScale() override {
263 if (chromeos::MagnificationManager::Get()) {
264 return chromeos::MagnificationManager::Get()
265 ->GetSavedScreenMagnifierScale();
266 }
267 return std::numeric_limits<double>::min();
268 }
269
270 void TriggerAccessibilityAlert(ui::AccessibilityAlert alert) override {
271 Profile* profile = ProfileManager::GetActiveUserProfile();
272 if (profile) {
273 switch (alert) {
274 case ui::A11Y_ALERT_WINDOW_NEEDED: {
275 AutomationManagerAura::GetInstance()->HandleAlert(
276 profile, l10n_util::GetStringUTF8(IDS_A11Y_ALERT_WINDOW_NEEDED));
277 break;
278 }
279 case ui::A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED: {
280 AutomationManagerAura::GetInstance()->HandleAlert(
281 profile, l10n_util::GetStringUTF8(
282 IDS_A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED));
283 break;
284 }
285 case ui::A11Y_ALERT_NONE:
286 break;
287 }
288 }
289 }
290
291 ui::AccessibilityAlert GetLastAccessibilityAlert() override {
292 return ui::A11Y_ALERT_NONE;
293 }
294
295 void PlayEarcon(int sound_key) override {
296 DCHECK(chromeos::AccessibilityManager::Get());
297 return chromeos::AccessibilityManager::Get()->PlayEarcon(sound_key);
298 }
299
300 base::TimeDelta PlayShutdownSound() const override {
301 return chromeos::AccessibilityManager::Get()->PlayShutdownSound();
302 }
303
304 private:
305 DISALLOW_COPY_AND_ASSIGN(AccessibilityDelegateImpl);
306 };
307
59 } // namespace 308 } // namespace
60 309
61 ChromeShellDelegate::ChromeShellDelegate() 310 ChromeShellDelegate::ChromeShellDelegate()
62 : shelf_delegate_(NULL) { 311 : shelf_delegate_(NULL) {
63 PlatformInit(); 312 PlatformInit();
64 } 313 }
65 314
66 ChromeShellDelegate::~ChromeShellDelegate() { 315 ChromeShellDelegate::~ChromeShellDelegate() {
67 } 316 }
68 317
318 bool ChromeShellDelegate::IsFirstRunAfterBoot() const {
319 return base::CommandLine::ForCurrentProcess()->HasSwitch(
320 chromeos::switches::kFirstExecAfterBoot);
321 }
322
69 bool ChromeShellDelegate::IsMultiProfilesEnabled() const { 323 bool ChromeShellDelegate::IsMultiProfilesEnabled() const {
70 if (!profiles::IsMultipleProfilesEnabled()) 324 if (!profiles::IsMultipleProfilesEnabled())
71 return false; 325 return false;
72 #if defined(OS_CHROMEOS)
73 // If there is a user manager, we need to see that we can at least have 2 326 // If there is a user manager, we need to see that we can at least have 2
74 // simultaneous users to allow this feature. 327 // simultaneous users to allow this feature.
75 if (!user_manager::UserManager::IsInitialized()) 328 if (!user_manager::UserManager::IsInitialized())
76 return false; 329 return false;
77 size_t admitted_users_to_be_added = 330 size_t admitted_users_to_be_added =
78 user_manager::UserManager::Get()->GetUsersAllowedForMultiProfile().size(); 331 user_manager::UserManager::Get()->GetUsersAllowedForMultiProfile().size();
79 size_t logged_in_users = 332 size_t logged_in_users =
80 user_manager::UserManager::Get()->GetLoggedInUsers().size(); 333 user_manager::UserManager::Get()->GetLoggedInUsers().size();
81 if (!logged_in_users) { 334 if (!logged_in_users) {
82 // The shelf gets created on the login screen and as such we have to create 335 // The shelf gets created on the login screen and as such we have to create
83 // all multi profile items of the the system tray menu before the user logs 336 // all multi profile items of the the system tray menu before the user logs
84 // in. For special cases like Kiosk mode and / or guest mode this isn't a 337 // in. For special cases like Kiosk mode and / or guest mode this isn't a
85 // problem since either the browser gets restarted and / or the flag is not 338 // problem since either the browser gets restarted and / or the flag is not
86 // allowed, but for an "ephermal" user (see crbug.com/312324) it is not 339 // allowed, but for an "ephermal" user (see crbug.com/312324) it is not
87 // decided yet if he could add other users to his session or not. 340 // decided yet if he could add other users to his session or not.
88 // TODO(skuhne): As soon as the issue above needs to be resolved, this logic 341 // TODO(skuhne): As soon as the issue above needs to be resolved, this logic
89 // should change. 342 // should change.
90 logged_in_users = 1; 343 logged_in_users = 1;
91 } 344 }
92 if (admitted_users_to_be_added + logged_in_users <= 1) 345 return admitted_users_to_be_added + logged_in_users > 1;
93 return false;
94 #endif
95 return true;
96 } 346 }
97 347
98 bool ChromeShellDelegate::IsIncognitoAllowed() const { 348 bool ChromeShellDelegate::IsIncognitoAllowed() const {
99 #if defined(OS_CHROMEOS)
100 return chromeos::AccessibilityManager::Get()->IsIncognitoAllowed(); 349 return chromeos::AccessibilityManager::Get()->IsIncognitoAllowed();
101 #endif
102 return true;
103 } 350 }
104 351
105 bool ChromeShellDelegate::IsRunningInForcedAppMode() const { 352 bool ChromeShellDelegate::IsRunningInForcedAppMode() const {
106 return chrome::IsRunningInForcedAppMode(); 353 return chrome::IsRunningInForcedAppMode();
107 } 354 }
108 355
109 bool ChromeShellDelegate::CanShowWindowForUser(aura::Window* window) const { 356 bool ChromeShellDelegate::CanShowWindowForUser(aura::Window* window) const {
110 return ::CanShowWindowForUser(window, base::Bind(&GetActiveBrowserContext)); 357 return ::CanShowWindowForUser(window, base::Bind(&GetActiveBrowserContext));
111 } 358 }
112 359
113 bool ChromeShellDelegate::IsForceMaximizeOnFirstRun() const { 360 bool ChromeShellDelegate::IsForceMaximizeOnFirstRun() const {
114 #if defined(OS_CHROMEOS)
115 const user_manager::User* const user = 361 const user_manager::User* const user =
116 user_manager::UserManager::Get()->GetActiveUser(); 362 user_manager::UserManager::Get()->GetActiveUser();
117 if (user) { 363 if (user) {
118 return chromeos::ProfileHelper::Get() 364 return chromeos::ProfileHelper::Get()
119 ->GetProfileByUser(user) 365 ->GetProfileByUser(user)
120 ->GetPrefs() 366 ->GetPrefs()
121 ->GetBoolean(prefs::kForceMaximizeOnFirstRun); 367 ->GetBoolean(prefs::kForceMaximizeOnFirstRun);
122 } 368 }
123 #endif
124 return false; 369 return false;
125 } 370 }
126 371
372 void ChromeShellDelegate::PreInit() {
373 chromeos::LoadDisplayPreferences(IsFirstRunAfterBoot());
374 // Object owns itself, and deletes itself when Observer::OnShutdown is called:
375 new policy::DisplayRotationDefaultHandler();
376 // Set the observer now so that we can save the initial state
377 // in Shell::Init.
378 display_configuration_observer_.reset(
379 new chromeos::DisplayConfigurationObserver());
380
381 chrome_user_metrics_recorder_.reset(new ChromeUserMetricsRecorder);
382 }
383
384 void ChromeShellDelegate::PreShutdown() {
385 display_configuration_observer_.reset();
386
387 chrome_user_metrics_recorder_.reset();
388 }
389
127 void ChromeShellDelegate::Exit() { 390 void ChromeShellDelegate::Exit() {
128 chrome::AttemptUserExit(); 391 chrome::AttemptUserExit();
129 } 392 }
130 393
131 void ChromeShellDelegate::OpenUrl(const GURL& url) { 394 void ChromeShellDelegate::OpenUrl(const GURL& url) {
132 if (!url.is_valid()) 395 if (!url.is_valid())
133 return; 396 return;
134 397
135 chrome::ScopedTabbedBrowserDisplayer displayer( 398 chrome::ScopedTabbedBrowserDisplayer displayer(
136 ProfileManager::GetActiveUserProfile()); 399 ProfileManager::GetActiveUserProfile());
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 params.disposition = SINGLETON_TAB; 466 params.disposition = SINGLETON_TAB;
204 chrome::Navigate(&params); 467 chrome::Navigate(&params);
205 } 468 }
206 469
207 gfx::Image ChromeShellDelegate::GetDeprecatedAcceleratorImage() const { 470 gfx::Image ChromeShellDelegate::GetDeprecatedAcceleratorImage() const {
208 return ui::ResourceBundle::GetSharedInstance().GetImageNamed( 471 return ui::ResourceBundle::GetSharedInstance().GetImageNamed(
209 IDR_BLUETOOTH_KEYBOARD); 472 IDR_BLUETOOTH_KEYBOARD);
210 } 473 }
211 474
212 void ChromeShellDelegate::ToggleTouchpad() { 475 void ChromeShellDelegate::ToggleTouchpad() {
213 #if defined(OS_CHROMEOS)
214 chromeos::system::InputDeviceSettings::Get()->ToggleTouchpad(); 476 chromeos::system::InputDeviceSettings::Get()->ToggleTouchpad();
215 #endif // defined(OS_CHROMEOS)
216 } 477 }
217 478
218 void ChromeShellDelegate::ToggleTouchscreen() { 479 void ChromeShellDelegate::ToggleTouchscreen() {
219 #if defined(OS_CHROMEOS)
220 chromeos::system::InputDeviceSettings::Get()->ToggleTouchscreen(); 480 chromeos::system::InputDeviceSettings::Get()->ToggleTouchscreen();
221 #endif // defined(OS_CHROMEOS)
222 } 481 }
223 482
224 keyboard::KeyboardUI* ChromeShellDelegate::CreateKeyboardUI() { 483 keyboard::KeyboardUI* ChromeShellDelegate::CreateKeyboardUI() {
225 return new ChromeKeyboardUI(ProfileManager::GetActiveUserProfile()); 484 return new ChromeKeyboardUI(ProfileManager::GetActiveUserProfile());
226 } 485 }
227 486
228 void ChromeShellDelegate::VirtualKeyboardActivated(bool activated) { 487 void ChromeShellDelegate::VirtualKeyboardActivated(bool activated) {
229 FOR_EACH_OBSERVER(ash::VirtualKeyboardStateObserver, 488 FOR_EACH_OBSERVER(ash::VirtualKeyboardStateObserver,
230 keyboard_state_observer_list_, 489 keyboard_state_observer_list_,
231 OnVirtualKeyboardStateChanged(activated)); 490 OnVirtualKeyboardStateChanged(activated));
232 } 491 }
233 492
234 void ChromeShellDelegate::AddVirtualKeyboardStateObserver( 493 void ChromeShellDelegate::AddVirtualKeyboardStateObserver(
235 ash::VirtualKeyboardStateObserver* observer) { 494 ash::VirtualKeyboardStateObserver* observer) {
236 keyboard_state_observer_list_.AddObserver(observer); 495 keyboard_state_observer_list_.AddObserver(observer);
237 } 496 }
238 497
239 void ChromeShellDelegate::RemoveVirtualKeyboardStateObserver( 498 void ChromeShellDelegate::RemoveVirtualKeyboardStateObserver(
240 ash::VirtualKeyboardStateObserver* observer) { 499 ash::VirtualKeyboardStateObserver* observer) {
241 keyboard_state_observer_list_.RemoveObserver(observer); 500 keyboard_state_observer_list_.RemoveObserver(observer);
242 } 501 }
502
503 ash::SessionStateDelegate* ChromeShellDelegate::CreateSessionStateDelegate() {
504 return new SessionStateDelegateChromeos;
505 }
506
507 ash::AccessibilityDelegate* ChromeShellDelegate::CreateAccessibilityDelegate() {
508 return new AccessibilityDelegateImpl;
509 }
510
511 ash::NewWindowDelegate* ChromeShellDelegate::CreateNewWindowDelegate() {
512 return new ChromeNewWindowDelegate;
513 }
514
515 ash::MediaDelegate* ChromeShellDelegate::CreateMediaDelegate() {
516 return new MediaDelegateChromeOS;
517 }
518
519 ash::SystemTrayDelegate* ChromeShellDelegate::CreateSystemTrayDelegate() {
520 return chromeos::CreateSystemTrayDelegate();
521 }
522
523 ash::UserWallpaperDelegate* ChromeShellDelegate::CreateUserWallpaperDelegate() {
524 return chromeos::CreateUserWallpaperDelegate();
525 }
526
527 void ChromeShellDelegate::Observe(int type,
528 const content::NotificationSource& source,
529 const content::NotificationDetails& details) {
530 switch (type) {
531 case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED: {
532 Profile* profile = content::Details<Profile>(details).ptr();
533 if (!chromeos::ProfileHelper::IsSigninProfile(profile) &&
534 !profile->IsGuestSession() && !profile->IsSupervised()) {
535 // Start the error notifier services to show auth/sync notifications.
536 SigninErrorNotifierFactory::GetForProfile(profile);
537 SyncErrorNotifierFactory::GetForProfile(profile);
538 }
539 // Do not use chrome::NOTIFICATION_PROFILE_ADDED because the
540 // profile is not fully initialized by user_manager. Use
541 // chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED instead.
542 if (shelf_delegate_)
543 shelf_delegate_->OnUserProfileReadyToSwitch(profile);
544 ash::Shell::GetInstance()->OnLoginUserProfilePrepared();
545 break;
546 }
547 case chrome::NOTIFICATION_SESSION_STARTED:
548 // InitAfterFirstSessionStart() should only be called once upon system
549 // start.
550 if (user_manager::UserManager::Get()->GetLoggedInUsers().size() < 2)
551 InitAfterFirstSessionStart();
552 ash::Shell::GetInstance()->ShowShelf();
553 break;
554 default:
555 NOTREACHED() << "Unexpected notification " << type;
556 }
557 }
558
559 void ChromeShellDelegate::PlatformInit() {
560 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED,
561 content::NotificationService::AllSources());
562 registrar_.Add(this, chrome::NOTIFICATION_SESSION_STARTED,
563 content::NotificationService::AllSources());
564 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/chrome_shell_delegate.h ('k') | chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698