| 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" | |
| 11 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| 12 #include "chrome/common/url_constants.h" | 11 #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" | |
| 17 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 18 | 13 |
| 19 // TODO(yoshiki): move the following method to accessibility_manager.cc and | 14 // TODO(yoshiki): move the following method to accessibility_manager.cc and |
| 20 // remove this file. | 15 // remove this file. |
| 21 | 16 |
| 22 namespace chromeos { | 17 namespace chromeos { |
| 23 namespace accessibility { | 18 namespace accessibility { |
| 24 | 19 |
| 25 void EnableVirtualKeyboard(bool enabled) { | 20 void EnableVirtualKeyboard(bool enabled) { |
| 26 PrefService* pref_service = g_browser_process->local_state(); | 21 PrefService* pref_service = g_browser_process->local_state(); |
| 27 pref_service->SetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled, | 22 pref_service->SetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled, |
| 28 enabled); | 23 enabled); |
| 29 pref_service->CommitPendingWrite(); | 24 pref_service->CommitPendingWrite(); |
| 30 } | 25 } |
| 31 | 26 |
| 32 bool IsVirtualKeyboardEnabled() { | 27 bool IsVirtualKeyboardEnabled() { |
| 33 if (!g_browser_process) { | 28 if (!g_browser_process) { |
| 34 return false; | 29 return false; |
| 35 } | 30 } |
| 36 PrefService* prefs = g_browser_process->local_state(); | 31 PrefService* prefs = g_browser_process->local_state(); |
| 37 bool virtual_keyboard_enabled = | 32 bool virtual_keyboard_enabled = |
| 38 prefs && prefs->GetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled); | 33 prefs && prefs->GetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled); |
| 39 return virtual_keyboard_enabled; | 34 return virtual_keyboard_enabled; |
| 40 } | 35 } |
| 41 | 36 |
| 42 void ShowAccessibilityHelp(Browser* browser) { | 37 void ShowAccessibilityHelp(Browser* browser) { |
| 43 chrome::ShowSingletonTab(browser, GURL(chrome::kChromeAccessibilityHelpURL)); | 38 chrome::ShowSingletonTab(browser, GURL(chrome::kChromeAccessibilityHelpURL)); |
| 44 } | 39 } |
| 45 | 40 |
| 46 | |
| 47 void SimulateTouchScreenInChromeVoxForTest(content::BrowserContext* profile) { | |
| 48 // ChromeVox looks at whether 'ontouchstart' exists to know whether or not it | |
| 49 // should respond to hover events. Fake it so that touch exploration events | |
| 50 // 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() {};")); | |
| 59 } | |
| 60 | |
| 61 } // namespace accessibility | 41 } // namespace accessibility |
| 62 } // namespace chromeos | 42 } // namespace chromeos |
| OLD | NEW |