diff options
28 files changed, 481 insertions, 447 deletions
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc index 4a73ee4..d7ab549 100644 --- a/ash/accelerators/accelerator_controller.cc +++ b/ash/accelerators/accelerator_controller.cc @@ -134,8 +134,10 @@ void HandleCycleLinear(const ui::Accelerator& accelerator) { } bool HandleAccessibleFocusCycle(bool reverse) { - if (!Shell::GetInstance()->delegate()->IsSpokenFeedbackEnabled()) + if (!Shell::GetInstance()->accessibility_delegate()-> + IsSpokenFeedbackEnabled()) { return false; + } aura::Window* active_window = ash::wm::GetActiveWindow(); if (!active_window) return false; @@ -157,10 +159,11 @@ bool HandleAccessibleFocusCycle(bool reverse) { } void HandleSilenceSpokenFeedback() { - if (!Shell::GetInstance()->delegate()->IsSpokenFeedbackEnabled()) + AccessibilityDelegate* delegate = + Shell::GetInstance()->accessibility_delegate(); + if (!delegate->IsSpokenFeedbackEnabled()) return; - - Shell::GetInstance()->delegate()->SilenceSpokenFeedback(); + delegate->SilenceSpokenFeedback(); } #if defined(OS_CHROMEOS) @@ -180,7 +183,7 @@ bool HandleCrosh() { } bool HandleToggleSpokenFeedback() { - Shell::GetInstance()->delegate()-> + Shell::GetInstance()->accessibility_delegate()-> ToggleSpokenFeedback(A11Y_NOTIFICATION_SHOW); return true; } @@ -662,7 +665,8 @@ bool AcceleratorController::PerformAction(int action, // consume the key since Search+Shift is one of the shortcuts the a11y // feature uses. crbug.com/132296 DCHECK_EQ(ui::VKEY_LWIN, accelerator.key_code()); - if (Shell::GetInstance()->delegate()->IsSpokenFeedbackEnabled()) + if (Shell::GetInstance()->accessibility_delegate()-> + IsSpokenFeedbackEnabled()) return false; ash::Shell::GetInstance()->ToggleAppList(NULL); return true; diff --git a/ash/accelerators/accelerator_controller_unittest.cc b/ash/accelerators/accelerator_controller_unittest.cc index 47d82a3..ce62062 100644 --- a/ash/accelerators/accelerator_controller_unittest.cc +++ b/ash/accelerators/accelerator_controller_unittest.cc @@ -4,6 +4,7 @@ #include "ash/accelerators/accelerator_controller.h" #include "ash/accelerators/accelerator_table.h" +#include "ash/accessibility_delegate.h" #include "ash/caps_lock_delegate.h" #include "ash/display/display_manager.h" #include "ash/ime_control_delegate.h" @@ -957,9 +958,8 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) { } TEST_F(AcceleratorControllerTest, GlobalAcceleratorsToggleAppList) { - test::TestShellDelegate* delegate = - reinterpret_cast<test::TestShellDelegate*>( - ash::Shell::GetInstance()->delegate()); + AccessibilityDelegate* delegate = + ash::Shell::GetInstance()->accessibility_delegate(); EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); // The press event should not open the AppList, the release should instead. diff --git a/ash/accessibility_delegate.h b/ash/accessibility_delegate.h new file mode 100644 index 0000000..a77e840 --- /dev/null +++ b/ash/accessibility_delegate.h @@ -0,0 +1,78 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_ACCESSIBILITY_DELEGATE_H_ +#define ASH_ACCESSIBILITY_DELEGATE_H_ + +#include "ash/ash_export.h" +#include "ash/magnifier/magnifier_constants.h" + +namespace ash { + +enum AccessibilityNotificationVisibility { + A11Y_NOTIFICATION_NONE, + A11Y_NOTIFICATION_SHOW, +}; + +// A deletate class to control accessibility features. +class ASH_EXPORT AccessibilityDelegate { + public: + AccessibilityDelegate() {} + virtual ~AccessibilityDelegate() {} + + // Invoked to toggle spoken feedback for accessibility + virtual void ToggleSpokenFeedback( + AccessibilityNotificationVisibility notify) = 0; + + // Returns true if spoken feedback is enabled. + virtual bool IsSpokenFeedbackEnabled() const = 0; + + // Invoked to toggle high contrast mode for accessibility. + virtual void ToggleHighContrast() = 0; + + // Returns true if high contrast mode is enabled. + virtual bool IsHighContrastEnabled() const = 0; + + // Invoked to enable the screen magnifier. + virtual void SetMagnifierEnabled(bool enabled) = 0; + + // Invoked to change the type of the screen magnifier. + virtual void SetMagnifierType(MagnifierType type) = 0; + + // Returns true if the screen magnifier is enabled or not. + virtual bool IsMagnifierEnabled() const = 0; + + // Returns the current screen magnifier mode. + virtual MagnifierType GetMagnifierType() const = 0; + + // Invoked to enable Large Cursor. + virtual void SetLargeCursorEnabled(bool enabled) = 0; + + // Returns ture if Large Cursor is enabled or not. + virtual bool IsLargeCursorEnabled() const = 0; + + // Invoked to enable autoclick. + virtual void SetAutoclickEnabled(bool enabled) = 0; + + // Returns if autoclick is enabled or not. + virtual bool IsAutoclickEnabled() const = 0; + + // Returns true if the user wants to show accesibility menu even when all the + // accessibility features are disabled. + virtual bool ShouldAlwaysShowAccessibilityMenu() const = 0; + + // Cancel all current and queued speech immediately. + virtual void SilenceSpokenFeedback() const = 0; + + // Saves the zoom scale of the full screen magnifier. + virtual void SaveScreenMagnifierScale(double scale) = 0; + + // Gets a saved value of the zoom scale of full screen magnifier. If a value + // is not saved, return a negative value. + virtual double GetSavedScreenMagnifierScale() = 0; +}; + +} // namespace ash + +#endif // ASH_ACCESSIBILITYDELEGATE_H_ diff --git a/ash/ash.gyp b/ash/ash.gyp index d8aeaaa..b873765 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -67,6 +67,7 @@ 'accelerators/focus_manager_factory.h', 'accelerators/nested_dispatcher_controller.cc', 'accelerators/nested_dispatcher_controller.h', + 'accessibility_delegate.h', 'autoclick/autoclick_controller.cc', 'autoclick/autoclick_controller.h', 'ash_constants.cc', @@ -80,6 +81,8 @@ 'caps_lock_delegate_stub.h', 'debug.cc', 'debug.h', + 'default_accessibility_delegate.cc', + 'default_accessibility_delegate.h', 'default_user_wallpaper_delegate.cc', 'default_user_wallpaper_delegate.h', 'desktop_background/desktop_background_controller.cc', diff --git a/ash/default_accessibility_delegate.cc b/ash/default_accessibility_delegate.cc new file mode 100644 index 0000000..bfc6b50 --- /dev/null +++ b/ash/default_accessibility_delegate.cc @@ -0,0 +1,87 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ash/default_accessibility_delegate.h" + +#include <limits> + +namespace ash { +namespace internal { + +DefaultAccessibilityDelegate::DefaultAccessibilityDelegate() + : spoken_feedback_enabled_(false), + high_contrast_enabled_(false), + screen_magnifier_enabled_(false), + screen_magnifier_type_(kDefaultMagnifierType), + large_cursor_enabled_(false), + autoclick_enabled_(false) { +} + +DefaultAccessibilityDelegate::~DefaultAccessibilityDelegate() {} + +bool DefaultAccessibilityDelegate::IsSpokenFeedbackEnabled() const { + return spoken_feedback_enabled_; +} + +void DefaultAccessibilityDelegate::ToggleHighContrast() { + high_contrast_enabled_ = !high_contrast_enabled_; +} + +bool DefaultAccessibilityDelegate::IsHighContrastEnabled() const { + return high_contrast_enabled_; +} + +void DefaultAccessibilityDelegate::SetMagnifierEnabled(bool enabled) { + screen_magnifier_enabled_ = enabled; +} + +void DefaultAccessibilityDelegate::SetMagnifierType(MagnifierType type) { + screen_magnifier_type_ = type; +} + +bool DefaultAccessibilityDelegate::IsMagnifierEnabled() const { + return screen_magnifier_enabled_; +} + +MagnifierType DefaultAccessibilityDelegate::GetMagnifierType() const { + return screen_magnifier_type_; +} + +void DefaultAccessibilityDelegate::SetLargeCursorEnabled(bool enabled) { + large_cursor_enabled_ = enabled; +} + +bool DefaultAccessibilityDelegate::IsLargeCursorEnabled() const { + return large_cursor_enabled_; +} + +void DefaultAccessibilityDelegate::SetAutoclickEnabled(bool enabled) { + autoclick_enabled_ = enabled; +} + +bool DefaultAccessibilityDelegate::IsAutoclickEnabled() const { + return autoclick_enabled_; +} + +bool DefaultAccessibilityDelegate::ShouldAlwaysShowAccessibilityMenu() const { + return false; +} + +void DefaultAccessibilityDelegate::SilenceSpokenFeedback() const { +} + +void DefaultAccessibilityDelegate::ToggleSpokenFeedback( + AccessibilityNotificationVisibility notify) { + spoken_feedback_enabled_ = !spoken_feedback_enabled_; +} + +void DefaultAccessibilityDelegate::SaveScreenMagnifierScale(double scale) { +} + +double DefaultAccessibilityDelegate::GetSavedScreenMagnifierScale() { + return std::numeric_limits<double>::min(); +} + +} // namespace internal +} // namespace ash diff --git a/ash/default_accessibility_delegate.h b/ash/default_accessibility_delegate.h new file mode 100644 index 0000000..58a48ab --- /dev/null +++ b/ash/default_accessibility_delegate.h @@ -0,0 +1,53 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_DEFAULT_ACCESSIBILITY_DELEGATE_H_ +#define ASH_DEFAULT_ACCESSIBILITY_DELEGATE_H_ + +#include "ash/accessibility_delegate.h" +#include "ash/ash_export.h" +#include "base/basictypes.h" +#include "base/compiler_specific.h" + +namespace ash { +namespace internal { + +class ASH_EXPORT DefaultAccessibilityDelegate : public AccessibilityDelegate { + public: + DefaultAccessibilityDelegate(); + virtual ~DefaultAccessibilityDelegate(); + + virtual bool IsSpokenFeedbackEnabled() const OVERRIDE; + virtual void ToggleHighContrast() OVERRIDE; + virtual bool IsHighContrastEnabled() const OVERRIDE; + virtual void SetMagnifierEnabled(bool enabled) OVERRIDE; + virtual void SetMagnifierType(MagnifierType type) OVERRIDE; + virtual bool IsMagnifierEnabled() const OVERRIDE; + virtual MagnifierType GetMagnifierType() const OVERRIDE; + virtual void SetLargeCursorEnabled(bool enabled) OVERRIDE; + virtual bool IsLargeCursorEnabled() const OVERRIDE; + virtual void SetAutoclickEnabled(bool enabled) OVERRIDE; + virtual bool IsAutoclickEnabled() const OVERRIDE; + virtual bool ShouldAlwaysShowAccessibilityMenu() const OVERRIDE; + virtual void SilenceSpokenFeedback() const OVERRIDE; + virtual void ToggleSpokenFeedback( + AccessibilityNotificationVisibility notify) OVERRIDE; + virtual void SaveScreenMagnifierScale(double scale) OVERRIDE; + virtual double GetSavedScreenMagnifierScale() OVERRIDE; + + private: + bool spoken_feedback_enabled_; + bool high_contrast_enabled_; + bool screen_magnifier_enabled_; + MagnifierType screen_magnifier_type_; + bool large_cursor_enabled_; + bool autoclick_enabled_; + + DISALLOW_COPY_AND_ASSIGN(DefaultAccessibilityDelegate); +}; + +} // namespace internal +} // namespace ash + +#endif // DEFAULT_ACCESSIBILITY_DELEGATE_H_ diff --git a/ash/magnifier/magnification_controller.cc b/ash/magnifier/magnification_controller.cc index c2e269d..c6a6a52 100644 --- a/ash/magnifier/magnification_controller.cc +++ b/ash/magnifier/magnification_controller.cc @@ -4,9 +4,9 @@ #include "ash/magnifier/magnification_controller.h" +#include "ash/accessibility_delegate.h" #include "ash/display/root_window_transformers.h" #include "ash/shell.h" -#include "ash/shell_delegate.h" #include "ash/system/tray/system_tray_delegate.h" #include "base/synchronization/waitable_event.h" #include "ui/aura/client/cursor_client.h" @@ -503,7 +503,8 @@ void MagnificationControllerImpl::SetScale(float scale, bool animate) { return; ValidateScale(&scale); - ash::Shell::GetInstance()->delegate()->SaveScreenMagnifierScale(scale); + ash::Shell::GetInstance()->accessibility_delegate()-> + SaveScreenMagnifierScale(scale); RedrawKeepingMousePosition(scale, animate); } @@ -543,7 +544,8 @@ void MagnificationControllerImpl::EnsurePointIsVisible( void MagnificationControllerImpl::SetEnabled(bool enabled) { if (enabled) { float scale = - ash::Shell::GetInstance()->delegate()->GetSavedScreenMagnifierScale(); + ash::Shell::GetInstance()->accessibility_delegate()-> + GetSavedScreenMagnifierScale(); if (scale <= 0.0f) scale = kInitialMagnifiedScale; ValidateScale(&scale); @@ -554,7 +556,8 @@ void MagnificationControllerImpl::SetEnabled(bool enabled) { is_enabled_ = enabled; RedrawKeepingMousePosition(scale, true); - ash::Shell::GetInstance()->delegate()->SaveScreenMagnifierScale(scale); + ash::Shell::GetInstance()->accessibility_delegate()-> + SaveScreenMagnifierScale(scale); } else { // Do nothing, if already disabled. if (!is_enabled_) diff --git a/ash/shell.cc b/ash/shell.cc index b87a946..50810a3 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -660,6 +660,7 @@ Shell::~Shell() { screen_position_controller_.reset(); keyboard_controller_.reset(); + accessibility_delegate_.reset(); #if defined(OS_CHROMEOS) && defined(USE_X11) if (display_change_observer_) @@ -831,6 +832,7 @@ void Shell::Init() { caps_lock_delegate_.reset(delegate_->CreateCapsLockDelegate()); session_state_delegate_.reset(delegate_->CreateSessionStateDelegate()); + accessibility_delegate_.reset(delegate_->CreateAccessibilityDelegate()); if (!command_line->HasSwitch(views::corewm::switches::kNoDropShadows)) { resize_shadow_controller_.reset(new internal::ResizeShadowController()); diff --git a/ash/shell.h b/ash/shell.h index af884f4..74903cb 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -76,6 +76,7 @@ class WindowModalityController; namespace ash { class AcceleratorController; +class AccessibilityDelegate; class AshNativeCursorManager; class AutoclickController; class CapsLockDelegate; @@ -366,6 +367,10 @@ class ASH_EXPORT Shell return session_state_delegate_.get(); } + AccessibilityDelegate* accessibility_delegate() { + return accessibility_delegate_.get(); + } + HighContrastController* high_contrast_controller() { return high_contrast_controller_.get(); } @@ -573,6 +578,7 @@ class ASH_EXPORT Shell scoped_ptr<UserWallpaperDelegate> user_wallpaper_delegate_; scoped_ptr<CapsLockDelegate> caps_lock_delegate_; scoped_ptr<SessionStateDelegate> session_state_delegate_; + scoped_ptr<AccessibilityDelegate> accessibility_delegate_; scoped_ptr<LauncherDelegate> launcher_delegate_; scoped_ptr<LauncherItemDelegateManager> launcher_item_delegate_manager_; diff --git a/ash/shell/shell_delegate_impl.cc b/ash/shell/shell_delegate_impl.cc index 02f6bc6..5f3eee6 100644 --- a/ash/shell/shell_delegate_impl.cc +++ b/ash/shell/shell_delegate_impl.cc @@ -4,9 +4,9 @@ #include "ash/shell/shell_delegate_impl.h" -#include <limits> - +#include "ash/accessibility_delegate.h" #include "ash/caps_lock_delegate_stub.h" +#include "ash/default_accessibility_delegate.h" #include "ash/default_user_wallpaper_delegate.h" #include "ash/host/root_window_host_factory.h" #include "ash/keyboard_controller_proxy_stub.h" @@ -28,13 +28,7 @@ namespace shell { ShellDelegateImpl::ShellDelegateImpl() : watcher_(NULL), - launcher_delegate_(NULL), - spoken_feedback_enabled_(false), - high_contrast_enabled_(false), - screen_magnifier_enabled_(false), - screen_magnifier_type_(kDefaultMagnifierType), - large_cursor_enabled_(false), - autoclick_enabled_(false) { + launcher_delegate_(NULL) { } ShellDelegateImpl::~ShellDelegateImpl() { @@ -109,62 +103,6 @@ content::BrowserContext* ShellDelegateImpl::GetCurrentBrowserContext() { return Shell::GetInstance()->browser_context(); } -void ShellDelegateImpl::ToggleSpokenFeedback( - AccessibilityNotificationVisibility notify) { - spoken_feedback_enabled_ = !spoken_feedback_enabled_; -} - -bool ShellDelegateImpl::IsSpokenFeedbackEnabled() const { - return spoken_feedback_enabled_; -} - -void ShellDelegateImpl::ToggleHighContrast() { - high_contrast_enabled_ = !high_contrast_enabled_; -} - -bool ShellDelegateImpl::IsHighContrastEnabled() const { - return high_contrast_enabled_; -} - -void ShellDelegateImpl::SetMagnifierEnabled(bool enabled) { - screen_magnifier_enabled_ = enabled; -} - -void ShellDelegateImpl::SetMagnifierType(MagnifierType type) { - screen_magnifier_type_ = type; -} - -bool ShellDelegateImpl::IsMagnifierEnabled() const { - return screen_magnifier_enabled_; -} - -MagnifierType ShellDelegateImpl::GetMagnifierType() const { - return screen_magnifier_type_; -} - -void ShellDelegateImpl::SetLargeCursorEnabled(bool enabled) { - large_cursor_enabled_ = enabled; -} - -bool ShellDelegateImpl::IsLargeCursorEnabled() const { - return large_cursor_enabled_; -} - -void ShellDelegateImpl::SetAutoclickEnabled(bool enabled) { - autoclick_enabled_ = enabled; -} - -bool ShellDelegateImpl::IsAutoclickEnabled() const { - return autoclick_enabled_; -} - -bool ShellDelegateImpl::ShouldAlwaysShowAccessibilityMenu() const { - return false; -} - -void ShellDelegateImpl::SilenceSpokenFeedback() const { -} - app_list::AppListViewDelegate* ShellDelegateImpl::CreateAppListViewDelegate() { return ash::shell::CreateAppListViewDelegate(); } @@ -191,6 +129,10 @@ ash::SessionStateDelegate* ShellDelegateImpl::CreateSessionStateDelegate() { return new SessionStateDelegateStub; } +ash::AccessibilityDelegate* ShellDelegateImpl::CreateAccessibilityDelegate() { + return new internal::DefaultAccessibilityDelegate; +} + aura::client::UserActionClient* ShellDelegateImpl::CreateUserActionClient() { return NULL; } @@ -210,13 +152,6 @@ void ShellDelegateImpl::HandleMediaPlayPause() { void ShellDelegateImpl::HandleMediaPrevTrack() { } -void ShellDelegateImpl::SaveScreenMagnifierScale(double scale) { -} - -double ShellDelegateImpl::GetSavedScreenMagnifierScale() { - return std::numeric_limits<double>::min(); -} - ui::MenuModel* ShellDelegateImpl::CreateContextMenu(aura::RootWindow* root) { return new ContextMenu(root); } diff --git a/ash/shell/shell_delegate_impl.h b/ash/shell/shell_delegate_impl.h index e51a39d..545e2e3 100644 --- a/ash/shell/shell_delegate_impl.h +++ b/ash/shell/shell_delegate_impl.h @@ -44,21 +44,6 @@ class ShellDelegateImpl : public ash::ShellDelegate { CreateKeyboardControllerProxy() OVERRIDE; virtual void ShowTaskManager() OVERRIDE; virtual content::BrowserContext* GetCurrentBrowserContext() OVERRIDE; - virtual void ToggleSpokenFeedback( - AccessibilityNotificationVisibility notify) OVERRIDE; - virtual bool IsSpokenFeedbackEnabled() const OVERRIDE; - virtual void ToggleHighContrast() OVERRIDE; - virtual bool IsHighContrastEnabled() const OVERRIDE; - virtual void SetMagnifierEnabled(bool enabled) OVERRIDE; - virtual void SetMagnifierType(MagnifierType type) OVERRIDE; - virtual bool IsMagnifierEnabled() const OVERRIDE; - virtual MagnifierType GetMagnifierType() const OVERRIDE; - virtual void SetLargeCursorEnabled(bool enabled) OVERRIDE; - virtual bool IsLargeCursorEnabled() const OVERRIDE; - virtual void SetAutoclickEnabled(bool enabled) OVERRIDE; - virtual bool IsAutoclickEnabled() const OVERRIDE; - virtual bool ShouldAlwaysShowAccessibilityMenu() const OVERRIDE; - virtual void SilenceSpokenFeedback() const OVERRIDE; virtual app_list::AppListViewDelegate* CreateAppListViewDelegate() OVERRIDE; virtual ash::LauncherDelegate* CreateLauncherDelegate( ash::LauncherModel* model) OVERRIDE; @@ -66,14 +51,13 @@ class ShellDelegateImpl : public ash::ShellDelegate { virtual ash::UserWallpaperDelegate* CreateUserWallpaperDelegate() OVERRIDE; virtual ash::CapsLockDelegate* CreateCapsLockDelegate() OVERRIDE; virtual ash::SessionStateDelegate* CreateSessionStateDelegate() OVERRIDE; + virtual ash::AccessibilityDelegate* CreateAccessibilityDelegate() OVERRIDE; virtual aura::client::UserActionClient* CreateUserActionClient() OVERRIDE; virtual void OpenFeedbackPage() OVERRIDE; virtual void RecordUserMetricsAction(UserMetricsAction action) OVERRIDE; virtual void HandleMediaNextTrack() OVERRIDE; virtual void HandleMediaPlayPause() OVERRIDE; virtual void HandleMediaPrevTrack() OVERRIDE; - virtual void SaveScreenMagnifierScale(double scale) OVERRIDE; - virtual double GetSavedScreenMagnifierScale() OVERRIDE; virtual ui::MenuModel* CreateContextMenu( aura::RootWindow* root_window) OVERRIDE; virtual RootWindowHostFactory* CreateRootWindowHostFactory() OVERRIDE; @@ -85,13 +69,6 @@ class ShellDelegateImpl : public ash::ShellDelegate { LauncherDelegateImpl* launcher_delegate_; - bool spoken_feedback_enabled_; - bool high_contrast_enabled_; - bool screen_magnifier_enabled_; - MagnifierType screen_magnifier_type_; - bool large_cursor_enabled_; - bool autoclick_enabled_; - DISALLOW_COPY_AND_ASSIGN(ShellDelegateImpl); }; diff --git a/ash/shell_delegate.h b/ash/shell_delegate.h index a78e1c1..65b445d 100644 --- a/ash/shell_delegate.h +++ b/ash/shell_delegate.h @@ -8,7 +8,6 @@ #include <string> #include "ash/ash_export.h" -#include "ash/magnifier/magnifier_constants.h" #include "ash/shell.h" #include "base/callback.h" #include "base/strings/string16.h" @@ -44,6 +43,7 @@ class LauncherDelegate; class LauncherModel; struct LauncherItem; class RootWindowHostFactory; +class AccessibilityDelegate; class SessionStateDelegate; class SystemTrayDelegate; class UserWallpaperDelegate; @@ -101,11 +101,6 @@ enum UserMetricsAction { UMA_WINDOW_SELECTION, }; -enum AccessibilityNotificationVisibility { - A11Y_NOTIFICATION_NONE, - A11Y_NOTIFICATION_SHOW, -}; - // Delegate of the Shell. class ASH_EXPORT ShellDelegate { public: @@ -164,50 +159,6 @@ class ASH_EXPORT ShellDelegate { // Get the current browser context. This will get us the current profile. virtual content::BrowserContext* GetCurrentBrowserContext() = 0; - // Invoked to toggle spoken feedback for accessibility - virtual void ToggleSpokenFeedback( - AccessibilityNotificationVisibility notify) = 0; - - // Returns true if spoken feedback is enabled. - virtual bool IsSpokenFeedbackEnabled() const = 0; - - // Invoked to toggle high contrast for accessibility. - virtual void ToggleHighContrast() = 0; - - // Returns true if high contrast mode is enabled. - virtual bool IsHighContrastEnabled() const = 0; - - // Invoked to enable the screen magnifier. - virtual void SetMagnifierEnabled(bool enabled) = 0; - - // Invoked to change the type of the screen magnifier. - virtual void SetMagnifierType(MagnifierType type) = 0; - - // Returns if the screen magnifier is enabled or not. - virtual bool IsMagnifierEnabled() const = 0; - - // Returns the current screen magnifier mode. - virtual MagnifierType GetMagnifierType() const = 0; - - // Invoked to enable Large Cursor. - virtual void SetLargeCursorEnabled(bool enabled) = 0; - - // Returns if Large Cursor is enabled or not. - virtual bool IsLargeCursorEnabled() const = 0; - - // Invoked to enable autoclick. - virtual void SetAutoclickEnabled(bool enabled) = 0; - - // Returns if autoclick is enabled or not. - virtual bool IsAutoclickEnabled() const = 0; - - // Returns true if the user want to show accesibility menu even when all the - // accessibility features are disabled. - virtual bool ShouldAlwaysShowAccessibilityMenu() const = 0; - - // Cancel all current and queued speech immediately. - virtual void SilenceSpokenFeedback() const = 0; - // Invoked to create an AppListViewDelegate. Shell takes the ownership of // the created delegate. virtual app_list::AppListViewDelegate* CreateAppListViewDelegate() = 0; @@ -229,6 +180,9 @@ class ASH_EXPORT ShellDelegate { // Creates a session state delegate. Shell takes ownership of the delegate. virtual SessionStateDelegate* CreateSessionStateDelegate() = 0; + // Creates a accessibility delegate. Shell takes ownership of the delegate. + virtual AccessibilityDelegate* CreateAccessibilityDelegate() = 0; + // Creates a user action client. Shell takes ownership of the object. virtual aura::client::UserActionClient* CreateUserActionClient() = 0; @@ -247,13 +201,6 @@ class ASH_EXPORT ShellDelegate { // Handles the Previous Track Media shortcut key. virtual void HandleMediaPrevTrack() = 0; - // Saves the zoom scale of the full screen magnifier. - virtual void SaveScreenMagnifierScale(double scale) = 0; - - // Gets a saved value of the zoom scale of full screen magnifier. If a value - // is not saved, return a negative value. - virtual double GetSavedScreenMagnifierScale() = 0; - // Creates a menu model of the context for the |root_window|. virtual ui::MenuModel* CreateContextMenu(aura::RootWindow* root_window) = 0; diff --git a/ash/system/chromeos/enterprise/tray_enterprise.cc b/ash/system/chromeos/enterprise/tray_enterprise.cc index 05ff799..8fca1c6 100644 --- a/ash/system/chromeos/enterprise/tray_enterprise.cc +++ b/ash/system/chromeos/enterprise/tray_enterprise.cc @@ -4,6 +4,7 @@ #include "ash/system/chromeos/enterprise/tray_enterprise.h" +#include "ash/shell.h" #include "ash/system/chromeos/label_tray_view.h" #include "ash/system/tray/system_tray_notifier.h" #include "ash/system/user/login_status.h" @@ -57,4 +58,3 @@ void TrayEnterprise::OnViewClicked(views::View* sender) { } // namespace internal } // namespace ash - diff --git a/ash/system/chromeos/managed/tray_locally_managed_user.cc b/ash/system/chromeos/managed/tray_locally_managed_user.cc index 0f0ab4c..9a8fd48 100644 --- a/ash/system/chromeos/managed/tray_locally_managed_user.cc +++ b/ash/system/chromeos/managed/tray_locally_managed_user.cc @@ -4,6 +4,7 @@ #include "ash/system/chromeos/managed/tray_locally_managed_user.h" +#include "ash/shell.h" #include "ash/system/chromeos/label_tray_view.h" #include "ash/system/system_notifier.h" #include "ash/system/tray/system_tray_notifier.h" diff --git a/ash/system/chromeos/screen_security/screen_tray_item_unittest.cc b/ash/system/chromeos/screen_security/screen_tray_item_unittest.cc index 80f54b4..928dad7 100644 --- a/ash/system/chromeos/screen_security/screen_tray_item_unittest.cc +++ b/ash/system/chromeos/screen_security/screen_tray_item_unittest.cc @@ -4,6 +4,7 @@ #include "ash/system/chromeos/screen_security/screen_tray_item.h" +#include "ash/shell.h" #include "ash/system/chromeos/screen_security/screen_capture_tray_item.h" #include "ash/system/chromeos/screen_security/screen_share_tray_item.h" #include "ash/system/tray/tray_item_view.h" diff --git a/ash/system/chromeos/system_clock_observer.cc b/ash/system/chromeos/system_clock_observer.cc index 9142dd9..c5ab20c 100644 --- a/ash/system/chromeos/system_clock_observer.cc +++ b/ash/system/chromeos/system_clock_observer.cc @@ -4,6 +4,7 @@ #include "ash/system/chromeos/system_clock_observer.h" +#include "ash/shell.h" #include "ash/system/tray/system_tray_notifier.h" #include "chromeos/dbus/dbus_thread_manager.h" diff --git a/ash/system/chromeos/tray_tracing.cc b/ash/system/chromeos/tray_tracing.cc index 764e943..eddeac7 100644 --- a/ash/system/chromeos/tray_tracing.cc +++ b/ash/system/chromeos/tray_tracing.cc @@ -4,6 +4,7 @@ #include "ash/system/chromeos/tray_tracing.h" +#include "ash/shell.h" #include "ash/system/tray/actionable_view.h" #include "ash/system/tray/fixed_sized_image_view.h" #include "ash/system/tray/system_tray.h" @@ -24,17 +25,16 @@ namespace internal { namespace tray { -class DefaultTracingView : public ash::internal::ActionableView { +class DefaultTracingView : public internal::ActionableView { public: DefaultTracingView() { SetLayoutManager(new views::BoxLayout( views::BoxLayout::kHorizontal, - ash::kTrayPopupPaddingHorizontal, 0, - ash::kTrayPopupPaddingBetweenItems)); + kTrayPopupPaddingHorizontal, 0, + kTrayPopupPaddingBetweenItems)); ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); - image_ = - new ash::internal::FixedSizedImageView(0, ash::kTrayPopupItemHeight); + image_ = new internal::FixedSizedImageView(0, kTrayPopupItemHeight); image_->SetImage( bundle.GetImageNamed(IDR_AURA_UBER_TRAY_TRACING).ToImageSkia()); AddChildView(image_); @@ -51,7 +51,7 @@ class DefaultTracingView : public ash::internal::ActionableView { private: // Overridden from ActionableView. virtual bool PerformAction(const ui::Event& event) OVERRIDE { - ash::Shell::GetInstance()->system_tray_delegate()->ShowChromeSlow(); + Shell::GetInstance()->system_tray_delegate()->ShowChromeSlow(); return true; } diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc index 266f58e..09fd89c 100644 --- a/ash/system/tray/system_tray.cc +++ b/ash/system/tray/system_tray.cc @@ -8,6 +8,7 @@ #include "ash/shelf/shelf_layout_manager.h" #include "ash/shell.h" #include "ash/shell/panel_window.h" +#include "ash/shell_delegate.h" #include "ash/shell_window_ids.h" #include "ash/system/bluetooth/tray_bluetooth.h" #include "ash/system/date/tray_date.h" diff --git a/ash/system/tray_accessibility.cc b/ash/system/tray_accessibility.cc index 28c88d7..63fd215 100644 --- a/ash/system/tray_accessibility.cc +++ b/ash/system/tray_accessibility.cc @@ -4,8 +4,8 @@ #include "ash/system/tray_accessibility.h" +#include "ash/accessibility_delegate.h" #include "ash/shell.h" -#include "ash/shell_delegate.h" #include "ash/system/tray/hover_highlight_view.h" #include "ash/system/tray/system_tray.h" #include "ash/system/tray/system_tray_delegate.h" @@ -40,17 +40,18 @@ enum AccessibilityState { }; uint32 GetAccessibilityState() { - ShellDelegate* shell_delegate = Shell::GetInstance()->delegate(); + AccessibilityDelegate* delegate = + Shell::GetInstance()->accessibility_delegate(); uint32 state = A11Y_NONE; - if (shell_delegate->IsSpokenFeedbackEnabled()) + if (delegate->IsSpokenFeedbackEnabled()) state |= A11Y_SPOKEN_FEEDBACK; - if (shell_delegate->IsHighContrastEnabled()) + if (delegate->IsHighContrastEnabled()) state |= A11Y_HIGH_CONTRAST; - if (shell_delegate->IsMagnifierEnabled()) + if (delegate->IsMagnifierEnabled()) state |= A11Y_SCREEN_MAGNIFIER; - if (shell_delegate->IsLargeCursorEnabled()) + if (delegate->IsLargeCursorEnabled()) state |= A11Y_LARGE_CURSOR; - if (shell_delegate->IsAutoclickEnabled()) + if (delegate->IsAutoclickEnabled()) state |= A11Y_AUTOCLICK; return state; } @@ -136,8 +137,9 @@ void AccessibilityDetailedView::AppendAccessibilityList() { CreateScrollableList(); ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); - ShellDelegate* shell_delegate = Shell::GetInstance()->delegate(); - spoken_feedback_enabled_ = shell_delegate->IsSpokenFeedbackEnabled(); + AccessibilityDelegate* delegate = + Shell::GetInstance()->accessibility_delegate(); + spoken_feedback_enabled_ = delegate->IsSpokenFeedbackEnabled(); spoken_feedback_view_ = AddScrollListItem( bundle.GetLocalizedString( IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SPOKEN_FEEDBACK), @@ -146,7 +148,7 @@ void AccessibilityDetailedView::AppendAccessibilityList() { // Large Cursor item is shown only in Login screen. if (login_ == user::LOGGED_IN_NONE) { - large_cursor_enabled_ = shell_delegate->IsLargeCursorEnabled(); + large_cursor_enabled_ = delegate->IsLargeCursorEnabled(); large_cursor_view_ = AddScrollListItem( bundle.GetLocalizedString( IDS_ASH_STATUS_TRAY_ACCESSIBILITY_LARGE_CURSOR), @@ -154,13 +156,13 @@ void AccessibilityDetailedView::AppendAccessibilityList() { large_cursor_enabled_); } - high_contrast_enabled_ = shell_delegate->IsHighContrastEnabled(); + high_contrast_enabled_ = delegate->IsHighContrastEnabled(); high_contrast_view_ = AddScrollListItem( bundle.GetLocalizedString( IDS_ASH_STATUS_TRAY_ACCESSIBILITY_HIGH_CONTRAST_MODE), high_contrast_enabled_ ? gfx::Font::BOLD : gfx::Font::NORMAL, high_contrast_enabled_); - screen_magnifier_enabled_ = shell_delegate->IsMagnifierEnabled(); + screen_magnifier_enabled_ = delegate->IsMagnifierEnabled(); screen_magnifier_view_ = AddScrollListItem( bundle.GetLocalizedString( IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SCREEN_MAGNIFIER), @@ -169,7 +171,7 @@ void AccessibilityDetailedView::AppendAccessibilityList() { // Don't show autoclick option at login screen. if (login_ != user::LOGGED_IN_NONE) { - autoclick_enabled_ = shell_delegate->IsAutoclickEnabled(); + autoclick_enabled_ = delegate->IsAutoclickEnabled(); autoclick_view_ = AddScrollListItem( bundle.GetLocalizedString( IDS_ASH_STATUS_TRAY_ACCESSIBILITY_AUTOCLICK), @@ -224,20 +226,20 @@ HoverHighlightView* AccessibilityDetailedView::AddScrollListItem( } void AccessibilityDetailedView::OnViewClicked(views::View* sender) { - ShellDelegate* shell_delegate = Shell::GetInstance()->delegate(); + AccessibilityDelegate* delegate = + Shell::GetInstance()->accessibility_delegate(); if (sender == footer()->content()) { owner()->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING); } else if (sender == spoken_feedback_view_) { - shell_delegate->ToggleSpokenFeedback(ash::A11Y_NOTIFICATION_NONE); + delegate->ToggleSpokenFeedback(ash::A11Y_NOTIFICATION_NONE); } else if (sender == high_contrast_view_) { - shell_delegate->ToggleHighContrast(); + delegate->ToggleHighContrast(); } else if (sender == screen_magnifier_view_) { - shell_delegate->SetMagnifierEnabled(!shell_delegate->IsMagnifierEnabled()); + delegate->SetMagnifierEnabled(!delegate->IsMagnifierEnabled()); } else if (large_cursor_view_ && sender == large_cursor_view_) { - shell_delegate-> - SetLargeCursorEnabled(!shell_delegate->IsLargeCursorEnabled()); + delegate->SetLargeCursorEnabled(!delegate->IsLargeCursorEnabled()); } else if (autoclick_view_ && sender == autoclick_view_) { - shell_delegate->SetAutoclickEnabled(!shell_delegate->IsAutoclickEnabled()); + delegate->SetAutoclickEnabled(!delegate->IsAutoclickEnabled()); } } @@ -300,7 +302,8 @@ views::View* TrayAccessibility::CreateDefaultView(user::LoginStatus status) { // - "Enable accessibility menu" on chrome://settings is checked; // - or any of accessibility features is enabled // Otherwise, not shows it. - ShellDelegate* delegate = Shell::GetInstance()->delegate(); + AccessibilityDelegate* delegate = + Shell::GetInstance()->accessibility_delegate(); if (login_ != user::LOGGED_IN_NONE && !delegate->ShouldAlwaysShowAccessibilityMenu() && // On login screen, keeps the initial visivility of the menu. diff --git a/ash/system/tray_accessibility.h b/ash/system/tray_accessibility.h index 5ed27320..a3f53cb 100644 --- a/ash/system/tray_accessibility.h +++ b/ash/system/tray_accessibility.h @@ -5,7 +5,7 @@ #ifndef ASH_SYSTEM_TRAY_ACCESSIBILITY_H_ #define ASH_SYSTEM_TRAY_ACCESSIBILITY_H_ -#include "ash/shell_delegate.h" +#include "ash/accessibility_delegate.h" #include "ash/shell_observer.h" #include "ash/system/tray/tray_details_view.h" #include "ash/system/tray/tray_image_item.h" diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc index e4c8a5e..d7c11bd 100644 --- a/ash/test/test_shell_delegate.cc +++ b/ash/test/test_shell_delegate.cc @@ -7,6 +7,7 @@ #include <limits> #include "ash/caps_lock_delegate_stub.h" +#include "ash/default_accessibility_delegate.h" #include "ash/host/root_window_host_factory.h" #include "ash/keyboard_controller_proxy_stub.h" #include "ash/session_state_delegate.h" @@ -27,13 +28,7 @@ namespace ash { namespace test { TestShellDelegate::TestShellDelegate() - : spoken_feedback_enabled_(false), - high_contrast_enabled_(false), - screen_magnifier_enabled_(false), - screen_magnifier_type_(kDefaultMagnifierType), - large_cursor_enabled_(false), - autoclick_enabled_(false), - num_exit_requests_(0), + : num_exit_requests_(0), multi_profiles_enabled_(false), test_session_state_delegate_(NULL) { } @@ -97,62 +92,6 @@ content::BrowserContext* TestShellDelegate::GetCurrentBrowserContext() { return current_browser_context_.get(); } -void TestShellDelegate::ToggleSpokenFeedback( - AccessibilityNotificationVisibility notify) { - spoken_feedback_enabled_ = !spoken_feedback_enabled_; -} - -bool TestShellDelegate::IsSpokenFeedbackEnabled() const { - return spoken_feedback_enabled_; -} - -void TestShellDelegate::ToggleHighContrast() { - high_contrast_enabled_ = !high_contrast_enabled_; -} - -bool TestShellDelegate::IsHighContrastEnabled() const { - return high_contrast_enabled_; -} - -void TestShellDelegate::SetMagnifierEnabled(bool enabled) { - screen_magnifier_enabled_ = enabled; -} - -void TestShellDelegate::SetMagnifierType(MagnifierType type) { - screen_magnifier_type_ = type; -} - -bool TestShellDelegate::IsMagnifierEnabled() const { - return screen_magnifier_enabled_; -} - -MagnifierType TestShellDelegate::GetMagnifierType() const { - return screen_magnifier_type_; -} - -void TestShellDelegate::SetLargeCursorEnabled(bool enabled) { - large_cursor_enabled_ = enabled; -} - -bool TestShellDelegate::IsLargeCursorEnabled() const { - return large_cursor_enabled_; -} - -void TestShellDelegate::SetAutoclickEnabled(bool enabled) { - autoclick_enabled_ = enabled; -} - -bool TestShellDelegate::IsAutoclickEnabled() const { - return autoclick_enabled_; -} - -bool TestShellDelegate::ShouldAlwaysShowAccessibilityMenu() const { - return false; -} - -void TestShellDelegate::SilenceSpokenFeedback() const { -} - app_list::AppListViewDelegate* TestShellDelegate::CreateAppListViewDelegate() { return NULL; } @@ -180,6 +119,10 @@ SessionStateDelegate* TestShellDelegate::CreateSessionStateDelegate() { return test_session_state_delegate_; } +AccessibilityDelegate* TestShellDelegate::CreateAccessibilityDelegate() { + return new internal::DefaultAccessibilityDelegate(); +} + aura::client::UserActionClient* TestShellDelegate::CreateUserActionClient() { return NULL; } @@ -199,17 +142,10 @@ void TestShellDelegate::HandleMediaPlayPause() { void TestShellDelegate::HandleMediaPrevTrack() { } -void TestShellDelegate::SaveScreenMagnifierScale(double scale) { -} - ui::MenuModel* TestShellDelegate::CreateContextMenu(aura::RootWindow* root) { return NULL; } -double TestShellDelegate::GetSavedScreenMagnifierScale() { - return std::numeric_limits<double>::min(); -} - RootWindowHostFactory* TestShellDelegate::CreateRootWindowHostFactory() { // The ContextFactory must exist before any Compositors are created. bool allow_test_contexts = true; diff --git a/ash/test/test_shell_delegate.h b/ash/test/test_shell_delegate.h index c361bc0..8c4269d 100644 --- a/ash/test/test_shell_delegate.h +++ b/ash/test/test_shell_delegate.h @@ -47,21 +47,6 @@ class TestShellDelegate : public ShellDelegate { CreateKeyboardControllerProxy() OVERRIDE; virtual void ShowTaskManager() OVERRIDE; virtual content::BrowserContext* GetCurrentBrowserContext() OVERRIDE; - virtual void ToggleSpokenFeedback( - AccessibilityNotificationVisibility notify) OVERRIDE; - virtual bool IsSpokenFeedbackEnabled() const OVERRIDE; - virtual void ToggleHighContrast() OVERRIDE; - virtual bool IsHighContrastEnabled() const OVERRIDE; - virtual void SetMagnifierEnabled(bool enabled) OVERRIDE; - virtual void SetMagnifierType(MagnifierType type) OVERRIDE; - virtual bool IsMagnifierEnabled() const OVERRIDE; - virtual MagnifierType GetMagnifierType() const OVERRIDE; - virtual void SetLargeCursorEnabled(bool enabled) OVERRIDE; - virtual bool IsLargeCursorEnabled() const OVERRIDE; - virtual void SetAutoclickEnabled(bool enabled) OVERRIDE; - virtual bool IsAutoclickEnabled() const OVERRIDE; - virtual bool ShouldAlwaysShowAccessibilityMenu() const OVERRIDE; - virtual void SilenceSpokenFeedback() const OVERRIDE; virtual app_list::AppListViewDelegate* CreateAppListViewDelegate() OVERRIDE; virtual LauncherDelegate* CreateLauncherDelegate( ash::LauncherModel* model) OVERRIDE; @@ -69,14 +54,13 @@ class TestShellDelegate : public ShellDelegate { virtual UserWallpaperDelegate* CreateUserWallpaperDelegate() OVERRIDE; virtual CapsLockDelegate* CreateCapsLockDelegate() OVERRIDE; virtual SessionStateDelegate* CreateSessionStateDelegate() OVERRIDE; + virtual AccessibilityDelegate* CreateAccessibilityDelegate() OVERRIDE; virtual aura::client::UserActionClient* CreateUserActionClient() OVERRIDE; virtual void OpenFeedbackPage() OVERRIDE; virtual void RecordUserMetricsAction(UserMetricsAction action) OVERRIDE; virtual void HandleMediaNextTrack() OVERRIDE; virtual void HandleMediaPlayPause() OVERRIDE; virtual void HandleMediaPrevTrack() OVERRIDE; - virtual void SaveScreenMagnifierScale(double scale) OVERRIDE; - virtual double GetSavedScreenMagnifierScale() OVERRIDE; virtual ui::MenuModel* CreateContextMenu(aura::RootWindow* root) OVERRIDE; virtual RootWindowHostFactory* CreateRootWindowHostFactory() OVERRIDE; virtual base::string16 GetProductName() const OVERRIDE; @@ -86,12 +70,6 @@ class TestShellDelegate : public ShellDelegate { TestSessionStateDelegate* test_session_state_delegate(); private: - bool spoken_feedback_enabled_; - bool high_contrast_enabled_; - bool screen_magnifier_enabled_; - MagnifierType screen_magnifier_type_; - bool large_cursor_enabled_; - bool autoclick_enabled_; int num_exit_requests_; bool multi_profiles_enabled_; diff --git a/chrome/browser/chromeos/accessibility/accessibility_manager.h b/chrome/browser/chromeos/accessibility/accessibility_manager.h index 599c4b8..7c82be7 100644 --- a/chrome/browser/chromeos/accessibility/accessibility_manager.h +++ b/chrome/browser/chromeos/accessibility/accessibility_manager.h @@ -5,7 +5,7 @@ #ifndef CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_ #define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_ -#include "ash/shell_delegate.h" +#include "ash/accessibility_delegate.h" #include "base/prefs/pref_change_registrar.h" #include "chrome/browser/chromeos/accessibility/accessibility_util.h" #include "content/public/browser/notification_observer.h" diff --git a/chrome/browser/chromeos/login/webui_login_display.cc b/chrome/browser/chromeos/login/webui_login_display.cc index e9a8675..634b61a 100644 --- a/chrome/browser/chromeos/login/webui_login_display.cc +++ b/chrome/browser/chromeos/login/webui_login_display.cc @@ -4,6 +4,7 @@ #include "chrome/browser/chromeos/login/webui_login_display.h" +#include "ash/shell.h" #include "ash/wm/user_activity_detector.h" #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" #include "chrome/browser/chromeos/login/login_display_host_impl.h" diff --git a/chrome/browser/chromeos/ui/screen_capture_notification_ui_chromeos.cc b/chrome/browser/chromeos/ui/screen_capture_notification_ui_chromeos.cc index 95f4640..8571363 100644 --- a/chrome/browser/chromeos/ui/screen_capture_notification_ui_chromeos.cc +++ b/chrome/browser/chromeos/ui/screen_capture_notification_ui_chromeos.cc @@ -4,6 +4,7 @@ #include "chrome/browser/chromeos/ui/screen_capture_notification_ui_chromeos.h" +#include "ash/shell.h" #include "ash/system/tray/system_tray_notifier.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.h b/chrome/browser/ui/ash/chrome_shell_delegate.h index 2bdde85..82dd89a 100644 --- a/chrome/browser/ui/ash/chrome_shell_delegate.h +++ b/chrome/browser/ui/ash/chrome_shell_delegate.h @@ -53,21 +53,6 @@ class ChromeShellDelegate : public ash::ShellDelegate, CreateKeyboardControllerProxy() OVERRIDE; virtual void ShowTaskManager() OVERRIDE; virtual content::BrowserContext* GetCurrentBrowserContext() OVERRIDE; - virtual void ToggleHighContrast() OVERRIDE; - virtual bool IsSpokenFeedbackEnabled() const OVERRIDE; - virtual void ToggleSpokenFeedback( - ash::AccessibilityNotificationVisibility notify) OVERRIDE; - virtual bool IsHighContrastEnabled() const OVERRIDE; - virtual void SetMagnifierEnabled(bool enabled) OVERRIDE; - virtual void SetMagnifierType(ash::MagnifierType type) OVERRIDE; - virtual bool IsMagnifierEnabled() const OVERRIDE; - virtual ash::MagnifierType GetMagnifierType() const OVERRIDE; - virtual void SetLargeCursorEnabled(bool enabled) OVERRIDE; - virtual bool IsLargeCursorEnabled() const OVERRIDE; - virtual void SetAutoclickEnabled(bool enabled) OVERRIDE; - virtual bool IsAutoclickEnabled() const OVERRIDE; - virtual bool ShouldAlwaysShowAccessibilityMenu() const OVERRIDE; - virtual void SilenceSpokenFeedback() const OVERRIDE; virtual app_list::AppListViewDelegate* CreateAppListViewDelegate() OVERRIDE; virtual ash::LauncherDelegate* CreateLauncherDelegate( ash::LauncherModel* model) OVERRIDE; @@ -75,14 +60,13 @@ class ChromeShellDelegate : public ash::ShellDelegate, virtual ash::UserWallpaperDelegate* CreateUserWallpaperDelegate() OVERRIDE; virtual ash::CapsLockDelegate* CreateCapsLockDelegate() OVERRIDE; virtual ash::SessionStateDelegate* CreateSessionStateDelegate() OVERRIDE; + virtual ash::AccessibilityDelegate* CreateAccessibilityDelegate() OVERRIDE; virtual aura::client::UserActionClient* CreateUserActionClient() OVERRIDE; virtual void OpenFeedbackPage() OVERRIDE; virtual void RecordUserMetricsAction(ash::UserMetricsAction action) OVERRIDE; virtual void HandleMediaNextTrack() OVERRIDE; virtual void HandleMediaPlayPause() OVERRIDE; virtual void HandleMediaPrevTrack() OVERRIDE; - virtual void SaveScreenMagnifierScale(double scale) OVERRIDE; - virtual double GetSavedScreenMagnifierScale() OVERRIDE; virtual ui::MenuModel* CreateContextMenu(aura::RootWindow* root) OVERRIDE; virtual ash::RootWindowHostFactory* CreateRootWindowHostFactory() OVERRIDE; virtual string16 GetProductName() const OVERRIDE; diff --git a/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc b/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc index 8eb98ef..2caaa09 100644 --- a/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc +++ b/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc @@ -6,6 +6,7 @@ #include "apps/shell_window_registry.h" #include "apps/ui/native_app_window.h" +#include "ash/accessibility_delegate.h" #include "ash/keyboard_overlay/keyboard_overlay_view.h" #include "ash/wm/mru_window_tracker.h" #include "ash/wm/window_util.h" @@ -55,6 +56,104 @@ void RestoreFocus() { mru_list.front()->Focus(); } +class AccessibilityDelegateImpl : public ash::AccessibilityDelegate { + public: + AccessibilityDelegateImpl() {} + virtual ~AccessibilityDelegateImpl() {} + + virtual void ToggleHighContrast() OVERRIDE { + DCHECK(chromeos::AccessibilityManager::Get()); + chromeos::AccessibilityManager::Get()->EnableHighContrast( + !chromeos::AccessibilityManager::Get()->IsHighContrastEnabled()); + } + + virtual bool IsSpokenFeedbackEnabled() const OVERRIDE { + DCHECK(chromeos::AccessibilityManager::Get()); + return chromeos::AccessibilityManager::Get()->IsSpokenFeedbackEnabled(); + } + + virtual void ToggleSpokenFeedback( + ash::AccessibilityNotificationVisibility notify) OVERRIDE { + DCHECK(chromeos::AccessibilityManager::Get()); + chromeos::AccessibilityManager::Get()->ToggleSpokenFeedback(notify); + } + + virtual bool IsHighContrastEnabled() const OVERRIDE { + DCHECK(chromeos::AccessibilityManager::Get()); + return chromeos::AccessibilityManager::Get()->IsHighContrastEnabled(); + } + + virtual void SetMagnifierEnabled(bool enabled) OVERRIDE { + DCHECK(chromeos::MagnificationManager::Get()); + return chromeos::MagnificationManager::Get()->SetMagnifierEnabled(enabled); + } + + virtual void SetMagnifierType(ash::MagnifierType type) OVERRIDE { + DCHECK(chromeos::MagnificationManager::Get()); + return chromeos::MagnificationManager::Get()->SetMagnifierType(type); + } + + virtual bool IsMagnifierEnabled() const OVERRIDE { + DCHECK(chromeos::MagnificationManager::Get()); + return chromeos::MagnificationManager::Get()->IsMagnifierEnabled(); + } + + virtual ash::MagnifierType GetMagnifierType() const OVERRIDE { + DCHECK(chromeos::MagnificationManager::Get()); + return chromeos::MagnificationManager::Get()->GetMagnifierType(); + } + + virtual void SetLargeCursorEnabled(bool enabled) OVERRIDE { + DCHECK(chromeos::AccessibilityManager::Get()); + return chromeos::AccessibilityManager::Get()->EnableLargeCursor(enabled); + } + + virtual bool IsLargeCursorEnabled() const OVERRIDE { + DCHECK(chromeos::AccessibilityManager::Get()); + return chromeos::AccessibilityManager::Get()->IsLargeCursorEnabled(); + } + + virtual void SetAutoclickEnabled(bool enabled) OVERRIDE { + DCHECK(chromeos::AccessibilityManager::Get()); + return chromeos::AccessibilityManager::Get()->EnableAutoclick(enabled); + } + + virtual bool IsAutoclickEnabled() const OVERRIDE { + DCHECK(chromeos::AccessibilityManager::Get()); + return chromeos::AccessibilityManager::Get()->IsAutoclickEnabled(); + } + + virtual bool ShouldAlwaysShowAccessibilityMenu() const OVERRIDE { + Profile* profile = ProfileManager::GetDefaultProfile(); + if (!profile) + return false; + + PrefService* user_pref_service = profile->GetPrefs(); + return user_pref_service && user_pref_service->GetBoolean( + prefs::kShouldAlwaysShowAccessibilityMenu); + } + + virtual void SilenceSpokenFeedback() const OVERRIDE { + TtsController::GetInstance()->Stop(); + } + + virtual void SaveScreenMagnifierScale(double scale) OVERRIDE { + if (chromeos::MagnificationManager::Get()) + chromeos::MagnificationManager::Get()->SaveScreenMagnifierScale(scale); + } + + virtual double GetSavedScreenMagnifierScale() OVERRIDE { + if (chromeos::MagnificationManager::Get()) { + return chromeos::MagnificationManager::Get()-> + GetSavedScreenMagnifierScale(); + } + return std::numeric_limits<double>::min(); + } + + private: + DISALLOW_COPY_AND_ASSIGN(AccessibilityDelegateImpl); +}; + } // anonymous namespace bool ChromeShellDelegate::IsFirstRunAfterBoot() const { @@ -117,81 +216,6 @@ void ChromeShellDelegate::OpenCrosh() { page->GetView()->Focus(); } -void ChromeShellDelegate::ToggleHighContrast() { - DCHECK(chromeos::AccessibilityManager::Get()); - bool enabled = chromeos::AccessibilityManager::Get()->IsHighContrastEnabled(); - chromeos::AccessibilityManager::Get()->EnableHighContrast(!enabled); -} - -bool ChromeShellDelegate::IsSpokenFeedbackEnabled() const { - DCHECK(chromeos::AccessibilityManager::Get()); - return chromeos::AccessibilityManager::Get()->IsSpokenFeedbackEnabled(); -} - -void ChromeShellDelegate::ToggleSpokenFeedback( - ash::AccessibilityNotificationVisibility notify) { - DCHECK(chromeos::AccessibilityManager::Get()); - chromeos::AccessibilityManager::Get()->ToggleSpokenFeedback(notify); -} - -bool ChromeShellDelegate::IsHighContrastEnabled() const { - DCHECK(chromeos::AccessibilityManager::Get()); - return chromeos::AccessibilityManager::Get()->IsHighContrastEnabled(); -} - -bool ChromeShellDelegate::IsMagnifierEnabled() const { - DCHECK(chromeos::MagnificationManager::Get()); - return chromeos::MagnificationManager::Get()->IsMagnifierEnabled(); -} - -ash::MagnifierType ChromeShellDelegate::GetMagnifierType() const { - DCHECK(chromeos::MagnificationManager::Get()); - return chromeos::MagnificationManager::Get()->GetMagnifierType(); -} - -void ChromeShellDelegate::SetMagnifierEnabled(bool enabled) { - DCHECK(chromeos::MagnificationManager::Get()); - return chromeos::MagnificationManager::Get()->SetMagnifierEnabled(enabled); -} - -void ChromeShellDelegate::SetMagnifierType(ash::MagnifierType type) { - DCHECK(chromeos::MagnificationManager::Get()); - return chromeos::MagnificationManager::Get()->SetMagnifierType(type); -} - -void ChromeShellDelegate::SaveScreenMagnifierScale(double scale) { - if (chromeos::MagnificationManager::Get()) - chromeos::MagnificationManager::Get()->SaveScreenMagnifierScale(scale); -} - -double ChromeShellDelegate::GetSavedScreenMagnifierScale() { - if (chromeos::MagnificationManager::Get()) { - return chromeos::MagnificationManager::Get()-> - GetSavedScreenMagnifierScale(); - } - return std::numeric_limits<double>::min(); -} - -void ChromeShellDelegate::SetLargeCursorEnabled(bool enabled) { - DCHECK(chromeos::AccessibilityManager::Get()); - return chromeos::AccessibilityManager::Get()->EnableLargeCursor(enabled); -} - -bool ChromeShellDelegate::IsLargeCursorEnabled() const { - DCHECK(chromeos::AccessibilityManager::Get()); - return chromeos::AccessibilityManager::Get()->IsLargeCursorEnabled(); -} - -void ChromeShellDelegate::SetAutoclickEnabled(bool enabled) { - DCHECK(chromeos::AccessibilityManager::Get()); - return chromeos::AccessibilityManager::Get()->EnableAutoclick(enabled); -} - -bool ChromeShellDelegate::IsAutoclickEnabled() const { - DCHECK(chromeos::AccessibilityManager::Get()); - return chromeos::AccessibilityManager::Get()->IsAutoclickEnabled(); -} - ash::CapsLockDelegate* ChromeShellDelegate::CreateCapsLockDelegate() { chromeos::input_method::XKeyboard* xkeyboard = chromeos::input_method::InputMethodManager::Get()->GetXKeyboard(); @@ -202,6 +226,10 @@ ash::SessionStateDelegate* ChromeShellDelegate::CreateSessionStateDelegate() { return new SessionStateDelegateChromeos; } +ash::AccessibilityDelegate* ChromeShellDelegate::CreateAccessibilityDelegate() { + return new AccessibilityDelegateImpl; +} + void ChromeShellDelegate::ShowKeyboardOverlay() { // TODO(mazda): Move the show logic to ash (http://crbug.com/124222). Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); @@ -211,20 +239,6 @@ void ChromeShellDelegate::ShowKeyboardOverlay() { GURL(url)); } -bool ChromeShellDelegate::ShouldAlwaysShowAccessibilityMenu() const { - Profile* profile = ProfileManager::GetDefaultProfile(); - if (!profile) - return false; - - PrefService* user_pref_service = profile->GetPrefs(); - return user_pref_service && - user_pref_service->GetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu); -} - -void ChromeShellDelegate::SilenceSpokenFeedback() const { - TtsController::GetInstance()->Stop(); -} - ash::SystemTrayDelegate* ChromeShellDelegate::CreateSystemTrayDelegate() { return chromeos::CreateSystemTrayDelegate(); } diff --git a/chrome/browser/ui/ash/chrome_shell_delegate_views.cc b/chrome/browser/ui/ash/chrome_shell_delegate_views.cc index a85b78c..7ee8dcf 100644 --- a/chrome/browser/ui/ash/chrome_shell_delegate_views.cc +++ b/chrome/browser/ui/ash/chrome_shell_delegate_views.cc @@ -4,9 +4,10 @@ #include "chrome/browser/ui/ash/chrome_shell_delegate.h" -#include "base/command_line.h" +#include "ash/accessibility_delegate.h" #include "ash/magnifier/magnifier_constants.h" #include "ash/system/tray/default_system_tray_delegate.h" +#include "base/command_line.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/prefs/session_startup_pref.h" #include "chrome/browser/profiles/profile_manager.h" @@ -25,88 +26,101 @@ #include "chrome/browser/ui/ash/user_wallpaper_delegate_win.h" #endif -bool ChromeShellDelegate::IsFirstRunAfterBoot() const { - return false; -} +namespace { -void ChromeShellDelegate::PreInit() { -} +class EmptyAccessibilityDelegate : public ash::AccessibilityDelegate { + public: + EmptyAccessibilityDelegate() {} + virtual ~EmptyAccessibilityDelegate() {} -void ChromeShellDelegate::Shutdown() { -} + virtual void ToggleHighContrast() OVERRIDE { + } -void ChromeShellDelegate::OpenFileManager() { -} + virtual bool IsSpokenFeedbackEnabled() const OVERRIDE { + return false; + } -void ChromeShellDelegate::OpenCrosh() { -} + virtual void ToggleSpokenFeedback( + ash::AccessibilityNotificationVisibility notify) OVERRIDE { + } -void ChromeShellDelegate::ShowKeyboardOverlay() { -} + virtual void SetLargeCursorEnabled(bool enalbed) OVERRIDE { + } -void ChromeShellDelegate::ToggleHighContrast() { -} + virtual bool IsLargeCursorEnabled() const OVERRIDE { + return false; + } -bool ChromeShellDelegate::IsSpokenFeedbackEnabled() const { - return false; -} + virtual bool IsHighContrastEnabled() const OVERRIDE { + return false; + } -void ChromeShellDelegate::ToggleSpokenFeedback( - ash::AccessibilityNotificationVisibility notify) { -} + virtual void SetMagnifierEnabled(bool enabled) OVERRIDE { + } -void ChromeShellDelegate::SetLargeCursorEnabled(bool enalbed) { -} + virtual void SetMagnifierType(ash::MagnifierType type) OVERRIDE { + } -bool ChromeShellDelegate::IsLargeCursorEnabled() const { - return false; -} + virtual bool IsMagnifierEnabled() const OVERRIDE { + return false; + } -void ChromeShellDelegate::SetAutoclickEnabled(bool enabled) { -} + virtual void SetAutoclickEnabled(bool enabled) OVERRIDE { + } -bool ChromeShellDelegate::IsAutoclickEnabled() const { - return false; -} + virtual bool IsAutoclickEnabled() const OVERRIDE { + return false; + } -bool ChromeShellDelegate::IsHighContrastEnabled() const { - return false; -} + virtual ash::MagnifierType GetMagnifierType() const OVERRIDE { + return ash::kDefaultMagnifierType; + } -void ChromeShellDelegate::SetMagnifierEnabled(bool enabled) { -} + virtual void SaveScreenMagnifierScale(double scale) OVERRIDE { + } -void ChromeShellDelegate::SetMagnifierType(ash::MagnifierType type) { -} + virtual double GetSavedScreenMagnifierScale() OVERRIDE { + return std::numeric_limits<double>::min(); + } + + virtual bool ShouldAlwaysShowAccessibilityMenu() const OVERRIDE { + return false; + } + + virtual void SilenceSpokenFeedback() const OVERRIDE { + } + + private: + DISALLOW_COPY_AND_ASSIGN(EmptyAccessibilityDelegate); +}; -bool ChromeShellDelegate::IsMagnifierEnabled() const { +} // namespace + +bool ChromeShellDelegate::IsFirstRunAfterBoot() const { return false; } -ash::MagnifierType ChromeShellDelegate::GetMagnifierType() const { - return ash::kDefaultMagnifierType; +void ChromeShellDelegate::PreInit() { } -ash::CapsLockDelegate* ChromeShellDelegate::CreateCapsLockDelegate() { - return new CapsLockDelegate(); +void ChromeShellDelegate::Shutdown() { } -ash::SessionStateDelegate* ChromeShellDelegate::CreateSessionStateDelegate() { - return new SessionStateDelegate; +void ChromeShellDelegate::OpenFileManager() { } -void ChromeShellDelegate::SaveScreenMagnifierScale(double scale) { +void ChromeShellDelegate::OpenCrosh() { } -double ChromeShellDelegate::GetSavedScreenMagnifierScale() { - return std::numeric_limits<double>::min(); +void ChromeShellDelegate::ShowKeyboardOverlay() { } -bool ChromeShellDelegate::ShouldAlwaysShowAccessibilityMenu() const { - return false; +ash::CapsLockDelegate* ChromeShellDelegate::CreateCapsLockDelegate() { + return new CapsLockDelegate(); } -void ChromeShellDelegate::SilenceSpokenFeedback() const { +ash::SessionStateDelegate* ChromeShellDelegate::CreateSessionStateDelegate() { + return new SessionStateDelegate; } ash::SystemTrayDelegate* ChromeShellDelegate::CreateSystemTrayDelegate() { @@ -114,6 +128,10 @@ ash::SystemTrayDelegate* ChromeShellDelegate::CreateSystemTrayDelegate() { return new ash::DefaultSystemTrayDelegate; } +ash::AccessibilityDelegate* ChromeShellDelegate::CreateAccessibilityDelegate() { + return new EmptyAccessibilityDelegate; +} + ash::UserWallpaperDelegate* ChromeShellDelegate::CreateUserWallpaperDelegate() { #if defined(OS_WIN) return ::CreateUserWallpaperDelegate(); |