 Chromium Code Reviews
 Chromium Code Reviews Issue 14473011:
  Adds new experimental accessibility extension api to enable or disable native accessibility.  (Closed) 
  Base URL: http://git.chromium.org/chromium/src.git@master
    
  
    Issue 14473011:
  Adds new experimental accessibility extension api to enable or disable native accessibility.  (Closed) 
  Base URL: http://git.chromium.org/chromium/src.git@master| 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 "content/browser/accessibility/browser_accessibility_state_impl.h" | 5 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 
| 6 | 6 | 
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" | 
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" | 
| 9 #include "base/timer.h" | 9 #include "base/timer.h" | 
| 10 #include "content/browser/renderer_host/render_widget_host_impl.h" | |
| 10 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" | 
| 12 #include "content/public/browser/render_process_host.h" | |
| 11 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" | 
| 12 #include "ui/gfx/sys_color_change_listener.h" | 14 #include "ui/gfx/sys_color_change_listener.h" | 
| 13 | 15 | 
| 14 #if defined(OS_WIN) | 16 #if defined(OS_WIN) | 
| 15 #include "base/win/windows_version.h" | 17 #include "base/win/windows_version.h" | 
| 16 #endif | 18 #endif | 
| 17 | 19 | 
| 18 namespace content { | 20 namespace content { | 
| 19 | 21 | 
| 20 // Update the accessibility histogram 45 seconds after initialization. | 22 // Update the accessibility histogram 45 seconds after initialization. | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 } | 75 } | 
| 74 | 76 | 
| 75 void BrowserAccessibilityStateImpl::OnScreenReaderDetected() { | 77 void BrowserAccessibilityStateImpl::OnScreenReaderDetected() { | 
| 76 if (CommandLine::ForCurrentProcess()->HasSwitch( | 78 if (CommandLine::ForCurrentProcess()->HasSwitch( | 
| 77 switches::kDisableRendererAccessibility)) { | 79 switches::kDisableRendererAccessibility)) { | 
| 78 return; | 80 return; | 
| 79 } | 81 } | 
| 80 SetAccessibilityMode(AccessibilityModeComplete); | 82 SetAccessibilityMode(AccessibilityModeComplete); | 
| 81 } | 83 } | 
| 82 | 84 | 
| 83 void BrowserAccessibilityStateImpl::OnAccessibilityEnabledManually() { | 85 void BrowserAccessibilityStateImpl::OnAccessibilityEnabledByExtensionAPI() { | 
| 84 // We may want to do something different with this later. | 86 // We may want to do something different with this later. | 
| 85 SetAccessibilityMode(AccessibilityModeComplete); | 87 SetAccessibilityMode(AccessibilityModeComplete); | 
| 86 } | 88 } | 
| 87 | 89 | 
| 90 void BrowserAccessibilityStateImpl::OnAccessibilityDisabledByExtensionAPI() { | |
| 91 SetAccessibilityMode(AccessibilityModeOff); | |
| 92 } | |
| 93 | |
| 88 bool BrowserAccessibilityStateImpl::IsAccessibleBrowser() { | 94 bool BrowserAccessibilityStateImpl::IsAccessibleBrowser() { | 
| 89 return (accessibility_mode_ == AccessibilityModeComplete); | 95 return (accessibility_mode_ == AccessibilityModeComplete); | 
| 90 } | 96 } | 
| 91 | 97 | 
| 92 void BrowserAccessibilityStateImpl::AddHistogramCallback( | 98 void BrowserAccessibilityStateImpl::AddHistogramCallback( | 
| 93 base::Closure callback) { | 99 base::Closure callback) { | 
| 94 histogram_callbacks_.push_back(callback); | 100 histogram_callbacks_.push_back(callback); | 
| 95 } | 101 } | 
| 96 | 102 | 
| 97 void BrowserAccessibilityStateImpl::UpdateHistogramsForTesting() { | 103 void BrowserAccessibilityStateImpl::UpdateHistogramsForTesting() { | 
| (...skipping 12 matching lines...) Expand all Loading... | |
| 110 UMA_HISTOGRAM_BOOLEAN("Accessibility.ManuallyEnabled", | 116 UMA_HISTOGRAM_BOOLEAN("Accessibility.ManuallyEnabled", | 
| 111 CommandLine::ForCurrentProcess()->HasSwitch( | 117 CommandLine::ForCurrentProcess()->HasSwitch( | 
| 112 switches::kForceRendererAccessibility)); | 118 switches::kForceRendererAccessibility)); | 
| 113 } | 119 } | 
| 114 | 120 | 
| 115 #if !defined(OS_WIN) | 121 #if !defined(OS_WIN) | 
| 116 void BrowserAccessibilityStateImpl::UpdatePlatformSpecificHistograms() { | 122 void BrowserAccessibilityStateImpl::UpdatePlatformSpecificHistograms() { | 
| 117 } | 123 } | 
| 118 #endif | 124 #endif | 
| 119 | 125 | 
| 120 AccessibilityMode BrowserAccessibilityStateImpl::GetAccessibilityMode() { | |
| 121 return accessibility_mode_; | |
| 122 } | |
| 123 | |
| 124 void BrowserAccessibilityStateImpl::SetAccessibilityMode( | 126 void BrowserAccessibilityStateImpl::SetAccessibilityMode( | 
| 125 AccessibilityMode mode) { | 127 AccessibilityMode mode) { | 
| 128 if (accessibility_mode_ == mode) | |
| 129 return; | |
| 126 accessibility_mode_ = mode; | 130 accessibility_mode_ = mode; | 
| 131 for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator()); | |
| 132 !it.IsAtEnd(); it.Advance()) { | |
| 133 RenderProcessHost* render_process_host = it.GetCurrentValue(); | |
| 134 DCHECK(render_process_host); | |
| 135 | |
| 136 // Ignore processes that don't have a connection, such as crashed tabs. | |
| 137 if (!render_process_host->HasConnection()) | |
| 138 continue; | |
| 139 | |
| 140 RenderProcessHost::RenderWidgetHostsIterator rwit( | |
| 
sky
2013/05/01 00:51:22
nit: move into for loop (like you did on 131).
 | |
| 141 render_process_host->GetRenderWidgetHostsIterator()); | |
| 142 for (; !rwit.IsAtEnd(); rwit.Advance()) { | |
| 143 RenderWidgetHost* rwh = const_cast<RenderWidgetHost*>( | |
| 
sky
2013/05/01 00:51:22
I'm not sure about the const_cast here.
 
jam
2013/05/01 05:19:17
seems fine to me. i think it's a mistake that the
 | |
| 144 rwit.GetCurrentValue()); | |
| 145 DCHECK(rwh); | |
| 146 if (!rwh || !rwh->IsRenderView()) | |
| 147 continue; | |
| 148 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh); | |
| 149 rwhi->SetAccessibilityMode(mode); | |
| 150 } | |
| 151 } | |
| 127 } | 152 } | 
| 128 | 153 | 
| 129 } // namespace content | 154 } // namespace content | 
| OLD | NEW |