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 "content/browser/accessibility/accessibility_mode_helper.h" | 9 #include "content/browser/accessibility/accessibility_mode_helper.h" |
10 #include "content/browser/renderer_host/render_widget_host_impl.h" | 10 #include "content/browser/renderer_host/render_widget_host_impl.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 } | 24 } |
25 | 25 |
26 // static | 26 // static |
27 BrowserAccessibilityStateImpl* BrowserAccessibilityStateImpl::GetInstance() { | 27 BrowserAccessibilityStateImpl* BrowserAccessibilityStateImpl::GetInstance() { |
28 return Singleton<BrowserAccessibilityStateImpl, | 28 return Singleton<BrowserAccessibilityStateImpl, |
29 LeakySingletonTraits<BrowserAccessibilityStateImpl> >::get(); | 29 LeakySingletonTraits<BrowserAccessibilityStateImpl> >::get(); |
30 } | 30 } |
31 | 31 |
32 BrowserAccessibilityStateImpl::BrowserAccessibilityStateImpl() | 32 BrowserAccessibilityStateImpl::BrowserAccessibilityStateImpl() |
33 : BrowserAccessibilityState(), | 33 : BrowserAccessibilityState(), |
34 accessibility_mode_(AccessibilityModeOff) { | 34 accessibility_mode_(AccessibilityModeOff), |
| 35 animation_policy_("Allowed") { |
35 ResetAccessibilityModeValue(); | 36 ResetAccessibilityModeValue(); |
36 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
37 // On Windows, UpdateHistograms calls some system functions with unknown | 38 // On Windows, UpdateHistograms calls some system functions with unknown |
38 // runtime, so call it on the file thread to ensure there's no jank. | 39 // runtime, so call it on the file thread to ensure there's no jank. |
39 // Everything in that method must be safe to call on another thread. | 40 // Everything in that method must be safe to call on another thread. |
40 BrowserThread::ID update_histogram_thread = BrowserThread::FILE; | 41 BrowserThread::ID update_histogram_thread = BrowserThread::FILE; |
41 #else | 42 #else |
42 // On all other platforms, UpdateHistograms should be called on the main | 43 // On all other platforms, UpdateHistograms should be called on the main |
43 // thread. | 44 // thread. |
44 BrowserThread::ID update_histogram_thread = BrowserThread::UI; | 45 BrowserThread::ID update_histogram_thread = BrowserThread::UI; |
(...skipping 20 matching lines...) Expand all Loading... |
65 } | 66 } |
66 | 67 |
67 void BrowserAccessibilityStateImpl::EnableAccessibility() { | 68 void BrowserAccessibilityStateImpl::EnableAccessibility() { |
68 AddAccessibilityMode(AccessibilityModeComplete); | 69 AddAccessibilityMode(AccessibilityModeComplete); |
69 } | 70 } |
70 | 71 |
71 void BrowserAccessibilityStateImpl::DisableAccessibility() { | 72 void BrowserAccessibilityStateImpl::DisableAccessibility() { |
72 ResetAccessibilityMode(); | 73 ResetAccessibilityMode(); |
73 } | 74 } |
74 | 75 |
| 76 const std::string& BrowserAccessibilityStateImpl::GetImageAnimationPolicy() cons
t |
| 77 { |
| 78 return animation_policy_; |
| 79 } |
| 80 |
| 81 void BrowserAccessibilityStateImpl::SetImageAnimationPolicy( |
| 82 const std::string& policy) { |
| 83 if (animation_policy_ == policy) |
| 84 return; |
| 85 |
| 86 animation_policy_ = policy; |
| 87 std::vector<WebContentsImpl*> web_contents_vector = |
| 88 WebContentsImpl::GetAllWebContents(); |
| 89 for (size_t i = 0; i < web_contents_vector.size(); ++i) |
| 90 web_contents_vector[i]->SetImageAnimationPolicy(animation_policy_); |
| 91 } |
| 92 |
75 void BrowserAccessibilityStateImpl::ResetAccessibilityModeValue() { | 93 void BrowserAccessibilityStateImpl::ResetAccessibilityModeValue() { |
76 accessibility_mode_ = AccessibilityModeOff; | 94 accessibility_mode_ = AccessibilityModeOff; |
77 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 95 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
78 switches::kForceRendererAccessibility)) { | 96 switches::kForceRendererAccessibility)) { |
79 accessibility_mode_ = AccessibilityModeComplete; | 97 accessibility_mode_ = AccessibilityModeComplete; |
80 } | 98 } |
81 } | 99 } |
82 | 100 |
83 void BrowserAccessibilityStateImpl::ResetAccessibilityMode() { | 101 void BrowserAccessibilityStateImpl::ResetAccessibilityMode() { |
84 ResetAccessibilityModeValue(); | 102 ResetAccessibilityModeValue(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 WebContentsImpl::GetAllWebContents(); | 174 WebContentsImpl::GetAllWebContents(); |
157 for (size_t i = 0; i < web_contents_vector.size(); ++i) { | 175 for (size_t i = 0; i < web_contents_vector.size(); ++i) { |
158 if (add) | 176 if (add) |
159 web_contents_vector[i]->AddAccessibilityMode(mode); | 177 web_contents_vector[i]->AddAccessibilityMode(mode); |
160 else | 178 else |
161 web_contents_vector[i]->RemoveAccessibilityMode(mode); | 179 web_contents_vector[i]->RemoveAccessibilityMode(mode); |
162 } | 180 } |
163 } | 181 } |
164 | 182 |
165 } // namespace content | 183 } // namespace content |
OLD | NEW |