Chromium Code Reviews| 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 "chrome/browser/chromeos/accessibility/accessibility_util.h" | 5 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/ui/singleton_tabs.h" | 9 #include "chrome/browser/ui/singleton_tabs.h" |
| 10 #include "chrome/common/extensions/extension_constants.h" | |
| 10 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
| 11 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
| 13 #include "content/public/test/browser_test_utils.h" | |
| 14 #include "extensions/browser/extension_host.h" | |
| 15 #include "extensions/browser/extension_system.h" | |
| 16 #include "extensions/browser/process_manager.h" | |
| 12 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 13 | 18 |
| 14 // TODO(yoshiki): move the following method to accessibility_manager.cc and | 19 // TODO(yoshiki): move the following method to accessibility_manager.cc and |
| 15 // remove this file. | 20 // remove this file. |
| 16 | 21 |
| 17 namespace chromeos { | 22 namespace chromeos { |
| 18 namespace accessibility { | 23 namespace accessibility { |
| 19 | 24 |
| 20 void EnableVirtualKeyboard(bool enabled) { | 25 void EnableVirtualKeyboard(bool enabled) { |
| 21 PrefService* pref_service = g_browser_process->local_state(); | 26 PrefService* pref_service = g_browser_process->local_state(); |
| 22 pref_service->SetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled, | 27 pref_service->SetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled, |
| 23 enabled); | 28 enabled); |
| 24 pref_service->CommitPendingWrite(); | 29 pref_service->CommitPendingWrite(); |
| 25 } | 30 } |
| 26 | 31 |
| 27 bool IsVirtualKeyboardEnabled() { | 32 bool IsVirtualKeyboardEnabled() { |
| 28 if (!g_browser_process) { | 33 if (!g_browser_process) { |
| 29 return false; | 34 return false; |
| 30 } | 35 } |
| 31 PrefService* prefs = g_browser_process->local_state(); | 36 PrefService* prefs = g_browser_process->local_state(); |
| 32 bool virtual_keyboard_enabled = | 37 bool virtual_keyboard_enabled = |
| 33 prefs && prefs->GetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled); | 38 prefs && prefs->GetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled); |
| 34 return virtual_keyboard_enabled; | 39 return virtual_keyboard_enabled; |
| 35 } | 40 } |
| 36 | 41 |
| 37 void ShowAccessibilityHelp(Browser* browser) { | 42 void ShowAccessibilityHelp(Browser* browser) { |
| 38 chrome::ShowSingletonTab(browser, GURL(chrome::kChromeAccessibilityHelpURL)); | 43 chrome::ShowSingletonTab(browser, GURL(chrome::kChromeAccessibilityHelpURL)); |
| 39 } | 44 } |
| 40 | 45 |
| 46 | |
| 47 void SimulateTouchScreenInChromeVoxForTest(content::BrowserContext* profile) { | |
| 48 // ChromeVox looks at whether 'ontouchstart' exists to know whether | |
|
aboxhall
2014/08/11 15:48:27
trivial: comment could be reflowed (clang-format s
evy
2014/08/11 17:19:07
Done.
| |
| 49 // or not it should respond to hover events. Fake it so that touch | |
| 50 // exploration events get spoken. | |
| 51 extensions::ExtensionHost* host = | |
| 52 extensions::ExtensionSystem::Get(profile) | |
| 53 ->process_manager() | |
| 54 ->GetBackgroundHostForExtension( | |
| 55 extension_misc::kChromeVoxExtensionId); | |
| 56 CHECK(content::ExecuteScript( | |
| 57 host->host_contents(), | |
| 58 "if (!('ontouchstart' in window)) window.ontouchstart = function() {};")); | |
|
James Cook
2014/08/08 23:31:37
If this works I would keep it this way.
evy
2014/08/09 02:26:52
Acknowledged.
| |
| 59 } | |
| 60 | |
| 41 } // namespace accessibility | 61 } // namespace accessibility |
| 42 } // namespace chromeos | 62 } // namespace chromeos |
| OLD | NEW |