Chromium Code Reviews| 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/root_window_controller.h" | 5 #include "ash/root_window_controller.h" |
| 6 | 6 |
| 7 #include <queue> | 7 #include <queue> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/ash_constants.h" | 10 #include "ash/ash_constants.h" |
| 11 #include "ash/ash_switches.h" | 11 #include "ash/ash_switches.h" |
| 12 #include "ash/audio/sounds.h" | |
| 12 #include "ash/desktop_background/desktop_background_controller.h" | 13 #include "ash/desktop_background/desktop_background_controller.h" |
| 13 #include "ash/desktop_background/desktop_background_widget_controller.h" | 14 #include "ash/desktop_background/desktop_background_widget_controller.h" |
| 14 #include "ash/desktop_background/user_wallpaper_delegate.h" | 15 #include "ash/desktop_background/user_wallpaper_delegate.h" |
| 15 #include "ash/display/display_manager.h" | 16 #include "ash/display/display_manager.h" |
| 16 #include "ash/focus_cycler.h" | 17 #include "ash/focus_cycler.h" |
| 17 #include "ash/high_contrast/high_contrast_controller.h" | 18 #include "ash/high_contrast/high_contrast_controller.h" |
| 18 #include "ash/host/ash_window_tree_host.h" | 19 #include "ash/host/ash_window_tree_host.h" |
| 19 #include "ash/root_window_settings.h" | 20 #include "ash/root_window_settings.h" |
| 20 #include "ash/session/session_state_delegate.h" | 21 #include "ash/session/session_state_delegate.h" |
| 21 #include "ash/shelf/shelf_layout_manager.h" | 22 #include "ash/shelf/shelf_layout_manager.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 44 #include "ash/wm/status_area_layout_manager.h" | 45 #include "ash/wm/status_area_layout_manager.h" |
| 45 #include "ash/wm/system_background_controller.h" | 46 #include "ash/wm/system_background_controller.h" |
| 46 #include "ash/wm/system_modal_container_layout_manager.h" | 47 #include "ash/wm/system_modal_container_layout_manager.h" |
| 47 #include "ash/wm/window_properties.h" | 48 #include "ash/wm/window_properties.h" |
| 48 #include "ash/wm/window_state.h" | 49 #include "ash/wm/window_state.h" |
| 49 #include "ash/wm/window_util.h" | 50 #include "ash/wm/window_util.h" |
| 50 #include "ash/wm/workspace/workspace_layout_manager.h" | 51 #include "ash/wm/workspace/workspace_layout_manager.h" |
| 51 #include "ash/wm/workspace_controller.h" | 52 #include "ash/wm/workspace_controller.h" |
| 52 #include "base/command_line.h" | 53 #include "base/command_line.h" |
| 53 #include "base/time/time.h" | 54 #include "base/time/time.h" |
| 55 #include "chromeos/audio/chromeos_sounds.h" | |
|
James Cook
2014/07/14 17:19:31
Ash code is compile on non-ChromeOS platforms (e.g
lisayin
2014/07/14 22:38:38
Done.
| |
| 56 #include "chromeos/audio/cras_audio_handler.h" | |
| 57 #include "chromeos/chromeos_switches.h" | |
| 54 #include "ui/aura/client/aura_constants.h" | 58 #include "ui/aura/client/aura_constants.h" |
| 55 #include "ui/aura/client/screen_position_client.h" | 59 #include "ui/aura/client/screen_position_client.h" |
| 56 #include "ui/aura/window.h" | 60 #include "ui/aura/window.h" |
| 57 #include "ui/aura/window_delegate.h" | 61 #include "ui/aura/window_delegate.h" |
| 58 #include "ui/aura/window_event_dispatcher.h" | 62 #include "ui/aura/window_event_dispatcher.h" |
| 59 #include "ui/aura/window_observer.h" | 63 #include "ui/aura/window_observer.h" |
| 60 #include "ui/aura/window_tracker.h" | 64 #include "ui/aura/window_tracker.h" |
| 61 #include "ui/base/hit_test.h" | 65 #include "ui/base/hit_test.h" |
| 62 #include "ui/base/models/menu_model.h" | 66 #include "ui/base/models/menu_model.h" |
| 63 #include "ui/gfx/display.h" | 67 #include "ui/gfx/display.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 257 } | 261 } |
| 258 virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE {} | 262 virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE {} |
| 259 | 263 |
| 260 private: | 264 private: |
| 261 DISALLOW_COPY_AND_ASSIGN(EmptyWindowDelegate); | 265 DISALLOW_COPY_AND_ASSIGN(EmptyWindowDelegate); |
| 262 }; | 266 }; |
| 263 | 267 |
| 264 #if defined(OS_CHROMEOS) | 268 #if defined(OS_CHROMEOS) |
| 265 // Responsible for initializing TouchExplorationController when spoken | 269 // Responsible for initializing TouchExplorationController when spoken |
| 266 // feedback is on. | 270 // feedback is on. |
| 267 class CrosAccessibilityObserver : public AccessibilityObserver { | 271 class CrosAccessibilityObserver |
|
James Cook
2014/07/14 17:19:30
Please extract this class into its own file. It's
dmazzoni
2014/07/14 18:00:33
That sounds good to me. I'd call it something like
lisayin
2014/07/14 22:40:36
Should the file be in the same folder as this file
| |
| 272 : public AccessibilityObserver, | |
| 273 public ui::TouchExplorationControllerDelegate { | |
| 268 public: | 274 public: |
| 269 explicit CrosAccessibilityObserver( | 275 explicit CrosAccessibilityObserver( |
| 270 RootWindowController* root_window_controller) | 276 RootWindowController* root_window_controller) |
| 271 : root_window_controller_(root_window_controller) { | 277 : root_window_controller_(root_window_controller), |
| 278 audio_handler_(chromeos::CrasAudioHandler::Get()) { | |
| 272 Shell::GetInstance()->system_tray_notifier()-> | 279 Shell::GetInstance()->system_tray_notifier()-> |
| 273 AddAccessibilityObserver(this); | 280 AddAccessibilityObserver(this); |
| 274 UpdateTouchExplorationState(); | 281 UpdateTouchExplorationState(); |
| 275 } | 282 } |
| 276 | 283 |
| 277 virtual ~CrosAccessibilityObserver() { | 284 virtual ~CrosAccessibilityObserver() { |
| 278 SystemTrayNotifier* system_tray_notifier = | 285 SystemTrayNotifier* system_tray_notifier = |
| 279 Shell::GetInstance()->system_tray_notifier(); | 286 Shell::GetInstance()->system_tray_notifier(); |
| 280 if (system_tray_notifier) | 287 if (system_tray_notifier) |
| 281 system_tray_notifier->RemoveAccessibilityObserver(this); | 288 system_tray_notifier->RemoveAccessibilityObserver(this); |
| 282 } | 289 } |
| 283 | 290 |
| 291 bool VolumeAdjustSoundEnabled() { | |
|
James Cook
2014/07/14 17:19:30
const?
lisayin
2014/07/14 22:38:38
Done.
| |
| 292 return !CommandLine::ForCurrentProcess()->HasSwitch( | |
| 293 chromeos::switches::kDisableVolumeAdjustSound); | |
| 294 } | |
| 295 | |
| 296 // Overridden from TouchExplorationControllerDelegate | |
|
James Cook
2014/07/14 17:19:30
nit: end with colon
lisayin
2014/07/14 22:38:38
Done.
| |
| 297 virtual void PlayVolumeAdjustSound() OVERRIDE{ | |
| 298 if (!VolumeAdjustSoundEnabled()) | |
| 299 return; | |
| 300 | |
| 301 if (!audio_handler_->IsOutputMuted() || | |
| 302 !audio_handler_->GetOutputVolumePercent() == 100) | |
| 303 PlaySystemSoundIfSpokenFeedback(chromeos::SOUND_VOLUME_ADJUST); | |
| 304 } | |
| 305 | |
| 306 // Overridden from TouchExplorationControllerDelegate | |
|
James Cook
2014/07/14 17:19:30
nit: We usually only have one of these lines
lisayin
2014/07/14 22:38:38
Done.
| |
| 307 virtual void AdjustSound(float volume) OVERRIDE { | |
| 308 if (volume > 0) { | |
| 309 if (audio_handler_->IsOutputMuted()) { | |
| 310 audio_handler_->SetOutputMute(false); | |
| 311 } | |
| 312 } | |
| 313 audio_handler_->SetOutputVolumePercent(volume); | |
| 314 // Avoid negative volume. | |
| 315 if (audio_handler_->IsOutputVolumeBelowDefaultMuteLvel()) | |
|
James Cook
2014/07/14 17:19:31
Not your typo, but could you use this CL to change
| |
| 316 audio_handler_->SetOutputMute(true); | |
| 317 } | |
| 318 | |
| 284 private: | 319 private: |
| 285 void UpdateTouchExplorationState() { | 320 void UpdateTouchExplorationState() { |
| 286 AccessibilityDelegate* delegate = | 321 AccessibilityDelegate* delegate = |
| 287 Shell::GetInstance()->accessibility_delegate(); | 322 Shell::GetInstance()->accessibility_delegate(); |
| 288 bool enabled = delegate->IsSpokenFeedbackEnabled(); | 323 bool enabled = delegate->IsSpokenFeedbackEnabled(); |
| 289 | 324 |
| 290 if (enabled && !touch_exploration_controller_.get()) { | 325 if (enabled && !touch_exploration_controller_.get()) { |
| 291 touch_exploration_controller_.reset( | 326 touch_exploration_controller_.reset(new ui::TouchExplorationController( |
| 292 new ui::TouchExplorationController( | 327 root_window_controller_->GetRootWindow(), this)); |
| 293 root_window_controller_->GetRootWindow())); | |
| 294 } else if (!enabled) { | 328 } else if (!enabled) { |
| 295 touch_exploration_controller_.reset(); | 329 touch_exploration_controller_.reset(); |
| 296 } | 330 } |
| 297 } | 331 } |
| 298 | 332 |
| 299 // Overridden from AccessibilityObserver. | 333 // Overridden from AccessibilityObserver. |
| 300 virtual void OnAccessibilityModeChanged( | 334 virtual void OnAccessibilityModeChanged( |
| 301 AccessibilityNotificationVisibility notify) OVERRIDE { | 335 AccessibilityNotificationVisibility notify) OVERRIDE { |
| 302 UpdateTouchExplorationState(); | 336 UpdateTouchExplorationState(); |
| 303 } | 337 } |
| 304 | 338 |
| 305 scoped_ptr<ui::TouchExplorationController> touch_exploration_controller_; | 339 scoped_ptr<ui::TouchExplorationController> touch_exploration_controller_; |
| 306 RootWindowController* root_window_controller_; | 340 RootWindowController* root_window_controller_; |
| 341 chromeos::CrasAudioHandler* audio_handler_; | |
| 307 | 342 |
| 308 DISALLOW_COPY_AND_ASSIGN(CrosAccessibilityObserver); | 343 DISALLOW_COPY_AND_ASSIGN(CrosAccessibilityObserver); |
| 309 }; | 344 }; |
| 310 #endif // OS_CHROMEOS | 345 #endif // OS_CHROMEOS |
| 311 | 346 |
| 312 } // namespace | 347 } // namespace |
| 313 | 348 |
| 314 void RootWindowController::CreateForPrimaryDisplay(AshWindowTreeHost* host) { | 349 void RootWindowController::CreateForPrimaryDisplay(AshWindowTreeHost* host) { |
| 315 RootWindowController* controller = new RootWindowController(host); | 350 RootWindowController* controller = new RootWindowController(host); |
| 316 controller->Init(RootWindowController::PRIMARY, | 351 controller->Init(RootWindowController::PRIMARY, |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1111 else | 1146 else |
| 1112 DisableTouchHudProjection(); | 1147 DisableTouchHudProjection(); |
| 1113 } | 1148 } |
| 1114 | 1149 |
| 1115 RootWindowController* GetRootWindowController( | 1150 RootWindowController* GetRootWindowController( |
| 1116 const aura::Window* root_window) { | 1151 const aura::Window* root_window) { |
| 1117 return root_window ? GetRootWindowSettings(root_window)->controller : NULL; | 1152 return root_window ? GetRootWindowSettings(root_window)->controller : NULL; |
| 1118 } | 1153 } |
| 1119 | 1154 |
| 1120 } // namespace ash | 1155 } // namespace ash |
| OLD | NEW |