Remove PlatformFile from profile_browsertest
[chromium-blink-merge.git] / content / browser / accessibility / accessibility_mode_helper.cc
blob7988595aa214f9c883fa53912fc75991b6783cd4
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 "content/browser/accessibility/accessibility_mode_helper.h"
7 #if defined(OS_WIN)
8 #include "base/command_line.h"
9 #include "base/win/windows_version.h"
10 #include "content/public/common/content_switches.h"
11 #endif
13 namespace content {
15 namespace {
17 AccessibilityMode CastToAccessibilityMode(unsigned int int_mode) {
18 AccessibilityMode mode = static_cast<AccessibilityMode>(int_mode);
19 switch (mode) {
20 case AccessibilityModeOff:
21 case AccessibilityModeComplete:
22 case AccessibilityModeEditableTextOnly:
23 case AccessibilityModeTreeOnly:
24 return mode;
26 DCHECK(false) << "Could not convert to AccessibilityMode: " << int_mode;
27 return AccessibilityModeOff;
30 } // namespace
32 AccessibilityMode AddAccessibilityModeTo(AccessibilityMode to,
33 AccessibilityMode mode_to_add) {
34 return CastToAccessibilityMode(to | mode_to_add);
37 AccessibilityMode RemoveAccessibilityModeFrom(
38 AccessibilityMode from,
39 AccessibilityMode mode_to_remove) {
40 unsigned int new_mode = from ^ (mode_to_remove & from);
41 #if defined(OS_WIN)
42 // On Windows 8, always enable accessibility for editable text controls
43 // so we can show the virtual keyboard when one is enabled.
44 if (base::win::GetVersion() >= base::win::VERSION_WIN8 &&
45 !CommandLine::ForCurrentProcess()->HasSwitch(
46 switches::kDisableRendererAccessibility)) {
47 if ((from & AccessibilityModeEditableTextOnly) ==
48 AccessibilityModeEditableTextOnly)
49 new_mode |= AccessibilityModeEditableTextOnly;
51 #endif // defined(OS_WIN)
53 return CastToAccessibilityMode(new_mode);
56 } // namespace content