diff options
author | dtseng@chromium.org <dtseng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-03 19:36:38 +0000 |
---|---|---|
committer | dtseng@chromium.org <dtseng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-03 19:36:38 +0000 |
commit | f6855a0a211cadb37c953fe585405fb6d4ee02ba (patch) | |
tree | 4a81e68c4fffba5de7429e854c18d04d88ff7c03 /chrome | |
parent | 7b5481278dee3fd02fb9f7bc5a08bbddb4fc5ee5 (diff) | |
download | chromium_src-f6855a0a211cadb37c953fe585405fb6d4ee02ba.zip chromium_src-f6855a0a211cadb37c953fe585405fb6d4ee02ba.tar.gz chromium_src-f6855a0a211cadb37c953fe585405fb6d4ee02ba.tar.bz2 |
Modify screen reader detection to use the AXEnhancedUserInterface attribute set on AXApplication when VoiceOver's turned on. This gives us the ability to turn on ax even after a render widget host has started.
BUG=none
TEST=manually with VoiceOver. Launch Chrome, VoiceOver, windows, tabs (permuted order) and verify that ax is on. This sometimes required navigation to a different page or efreshing the current page.
Review URL: http://codereview.chromium.org/6909013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83940 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
4 files changed, 26 insertions, 18 deletions
diff --git a/chrome/browser/accessibility/browser_accessibility_state.h b/chrome/browser/accessibility/browser_accessibility_state.h index bdd7bcc..65d6b42 100644 --- a/chrome/browser/accessibility/browser_accessibility_state.h +++ b/chrome/browser/accessibility/browser_accessibility_state.h @@ -22,8 +22,11 @@ template <typename T> struct DefaultSingletonTraits; // we attempt to dynamically detect a MSAA client screen reader by calling // NotifiyWinEvent in WidgetWin with a custom ID and wait to see if the ID // is requested by a subsequent call to WM_GETOBJECT. -// (2) On mac we detect if VoiceOver is running. This is stored in a preference -// file for Universal Access with the key "voiceOverOnOffKey". +// (2) On mac we detect dynamically if VoiceOver is running. We rely upon the +// undocumented accessibility attribute @"AXEnhancedUserInterface" which is set +// when VoiceOver is launched and unset when VoiceOver is closed. This is an +// improvement over reading defaults preference values (which has no callback +// mechanism). class BrowserAccessibilityState { public: // Returns the singleton instance. diff --git a/chrome/browser/chrome_browser_application_mac.mm b/chrome/browser/chrome_browser_application_mac.mm index 7ba8cda..745e0ab 100644 --- a/chrome/browser/chrome_browser_application_mac.mm +++ b/chrome/browser/chrome_browser_application_mac.mm @@ -9,9 +9,13 @@ #import "base/memory/scoped_nsobject.h" #import "base/sys_string_conversions.h" #import "chrome/app/breakpad_mac.h" +#include "chrome/browser/accessibility/browser_accessibility_state.h" #import "chrome/browser/app_controller_mac.h" +#include "chrome/browser/ui/browser_list.h" #import "chrome/browser/ui/cocoa/objc_method_swizzle.h" #import "chrome/browser/ui/cocoa/objc_zombie.h" +#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" +#include "content/browser/renderer_host/render_view_host.h" // The implementation of NSExceptions break various assumptions in the // Chrome code. This category defines a replacement for @@ -384,4 +388,21 @@ BOOL SwizzleNSExceptionInit() { [super reportException:anException]; } +- (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute { + if ([attribute isEqualToString:@"AXEnhancedUserInterface"] && + [value intValue] == 1) { + BrowserAccessibilityState::GetInstance()->OnScreenReaderDetected(); + for (TabContentsIterator it; + !it.done(); + ++it) { + if (TabContentsWrapper* contents = *it) { + if (RenderViewHost* rvh = contents->render_view_host()) { + rvh->EnableRendererAccessibility(); + } + } + } + } + return [super accessibilitySetValue:value forAttribute:attribute]; +} + @end diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.h b/chrome/browser/renderer_host/render_widget_host_view_mac.h index dc06563..d2a3f33c 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_mac.h +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.h @@ -354,9 +354,6 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView { // invoke it from the message loop. void ShutdownHost(); - // Used to determine whether or not to enable accessibility. - bool IsVoiceOverRunning(); - // The associated view. This is weak and is inserted into the view hierarchy // to own this RenderWidgetHostViewMac object. RenderWidgetHostViewCocoa* cocoa_view_; diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm index 2b2d785..7eb5631 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm @@ -16,7 +16,6 @@ #include "base/sys_info.h" #include "base/sys_string_conversions.h" #import "chrome/browser/accessibility/browser_accessibility_cocoa.h" -#include "chrome/browser/accessibility/browser_accessibility_state.h" #include "chrome/browser/browser_trial.h" #import "chrome/browser/renderer_host/text_input_client_mac.h" #include "chrome/browser/spellchecker_platform_engine.h" @@ -642,12 +641,6 @@ RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) initWithRenderWidgetHostViewMac:this] autorelease]; render_widget_host_->set_view(this); - // Turn on accessibility only if VoiceOver is running. - if (IsVoiceOverRunning()) { - BrowserAccessibilityState::GetInstance()->OnScreenReaderDetected(); - render_widget_host_->EnableRendererAccessibility(); - } - if (render_widget_host_->IsRenderView()) { new SpellCheckRenderViewObserver( static_cast<RenderViewHost*>(widget), this); @@ -1346,12 +1339,6 @@ void RenderWidgetHostViewMac::ShutdownHost() { // Do not touch any members at this point, |this| has been deleted. } -bool RenderWidgetHostViewMac::IsVoiceOverRunning() { - NSUserDefaults* user_defaults = [NSUserDefaults standardUserDefaults]; - [user_defaults addSuiteNamed:@"com.apple.universalaccess"]; - return 1 == [user_defaults integerForKey:@"voiceOverOnOffKey"]; -} - gfx::Rect RenderWidgetHostViewMac::GetViewCocoaBounds() const { return gfx::Rect(NSRectToCGRect([cocoa_view_ bounds])); } |