| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ui/webui/settings/chromeos/accessibility_handler.h" | 5 #include "chrome/browser/ui/webui/settings/chromeos/accessibility_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "chrome/browser/extensions/extension_tab_util.h" | 9 #include "chrome/browser/extensions/extension_tab_util.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/browser_finder.h" | 11 #include "chrome/browser/ui/browser_finder.h" |
| 12 #include "chrome/common/extensions/extension_constants.h" | 12 #include "chrome/common/extensions/extension_constants.h" |
| 13 #include "content/public/browser/web_ui.h" | 13 #include "content/public/browser/web_ui.h" |
| 14 #include "extensions/browser/extension_registry.h" | 14 #include "extensions/browser/extension_registry.h" |
| 15 | 15 |
| 16 namespace chromeos { | 16 namespace chromeos { |
| 17 namespace settings { | 17 namespace settings { |
| 18 | 18 |
| 19 AccessibilityHandler::AccessibilityHandler(content::WebUI* webui) | 19 AccessibilityHandler::AccessibilityHandler(content::WebUI* webui) |
| 20 : profile_(Profile::FromWebUI(webui)) { | 20 : profile_(Profile::FromWebUI(webui)) { |
| 21 } | 21 } |
| 22 | 22 |
| 23 AccessibilityHandler::~AccessibilityHandler() {} | 23 AccessibilityHandler::~AccessibilityHandler() {} |
| 24 | 24 |
| 25 void AccessibilityHandler::RegisterMessages() { | 25 void AccessibilityHandler::RegisterMessages() { |
| 26 web_ui()->RegisterMessageCallback( | 26 web_ui()->RegisterMessageCallback( |
| 27 "showChromeVoxSettings", | 27 "showChromeVoxSettings", |
| 28 base::Bind(&AccessibilityHandler::HandleShowChromeVoxSettings, | 28 base::Bind(&AccessibilityHandler::HandleShowChromeVoxSettings, |
| 29 base::Unretained(this))); | 29 base::Unretained(this))); |
| 30 web_ui()->RegisterMessageCallback( |
| 31 "showSelectToSpeakSettings", |
| 32 base::Bind(&AccessibilityHandler::HandleShowSelectToSpeakSettings, |
| 33 base::Unretained(this))); |
| 34 web_ui()->RegisterMessageCallback( |
| 35 "showSwitchAccessSettings", |
| 36 base::Bind(&AccessibilityHandler::HandleShowSwitchAccessSettings, |
| 37 base::Unretained(this))); |
| 30 } | 38 } |
| 31 | 39 |
| 32 void AccessibilityHandler::HandleShowChromeVoxSettings( | 40 void AccessibilityHandler::HandleShowChromeVoxSettings( |
| 33 const base::ListValue* args) { | 41 const base::ListValue* args) { |
| 34 const extensions::Extension* chromevox_extension = | 42 OpenExtensionOptionsPage(extension_misc::kChromeVoxExtensionId); |
| 43 } |
| 44 |
| 45 void AccessibilityHandler::HandleShowSelectToSpeakSettings( |
| 46 const base::ListValue* args) { |
| 47 OpenExtensionOptionsPage(extension_misc::kSelectToSpeakExtensionId); |
| 48 } |
| 49 |
| 50 void AccessibilityHandler::HandleShowSwitchAccessSettings( |
| 51 const base::ListValue* args) { |
| 52 OpenExtensionOptionsPage(extension_misc::kSwitchAccessExtensionId); |
| 53 } |
| 54 |
| 55 void AccessibilityHandler::OpenExtensionOptionsPage(const char extension_id[]) { |
| 56 const extensions::Extension* extension = |
| 35 extensions::ExtensionRegistry::Get(profile_)->GetExtensionById( | 57 extensions::ExtensionRegistry::Get(profile_)->GetExtensionById( |
| 36 extension_misc::kChromeVoxExtensionId, | 58 extension_id, extensions::ExtensionRegistry::ENABLED); |
| 37 extensions::ExtensionRegistry::ENABLED); | 59 if (!extension) |
| 38 if (!chromevox_extension) | |
| 39 return; | 60 return; |
| 40 extensions::ExtensionTabUtil::OpenOptionsPage( | 61 extensions::ExtensionTabUtil::OpenOptionsPage( |
| 41 chromevox_extension, | 62 extension, |
| 42 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents())); | 63 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents())); |
| 43 } | 64 } |
| 44 | 65 |
| 45 } // namespace settings | 66 } // namespace settings |
| 46 } // namespace chromeos | 67 } // namespace chromeos |
| OLD | NEW |