1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/logging.h"
6 #include "content/browser/accessibility/accessibility_mode_helper.h"
9 #include "base/command_line.h"
10 #include "base/win/windows_version.h"
11 #include "content/public/common/content_switches.h"
18 AccessibilityMode
CastToAccessibilityMode(unsigned int int_mode
) {
19 AccessibilityMode mode
= static_cast<AccessibilityMode
>(int_mode
);
21 case AccessibilityModeOff
:
22 case AccessibilityModeComplete
:
23 case AccessibilityModeEditableTextOnly
:
24 case AccessibilityModeTreeOnly
:
27 DCHECK(false) << "Could not convert to AccessibilityMode: " << int_mode
;
28 return AccessibilityModeOff
;
33 AccessibilityMode
AddAccessibilityModeTo(AccessibilityMode to
,
34 AccessibilityMode mode_to_add
) {
35 return CastToAccessibilityMode(to
| mode_to_add
);
38 AccessibilityMode
RemoveAccessibilityModeFrom(
39 AccessibilityMode from
,
40 AccessibilityMode mode_to_remove
) {
41 unsigned int new_mode
= from
^ (mode_to_remove
& from
);
43 // On Windows 8, always enable accessibility for editable text controls
44 // so we can show the virtual keyboard when one is enabled.
45 if (base::win::GetVersion() >= base::win::VERSION_WIN8
&&
46 !CommandLine::ForCurrentProcess()->HasSwitch(
47 switches::kDisableRendererAccessibility
)) {
48 if ((from
& AccessibilityModeEditableTextOnly
) ==
49 AccessibilityModeEditableTextOnly
)
50 new_mode
|= AccessibilityModeEditableTextOnly
;
52 #endif // defined(OS_WIN)
54 return CastToAccessibilityMode(new_mode
);
57 } // namespace content