Chromium Code Reviews| Index: chrome/browser/ui/webui/settings/chromeos/accessibility_handler.cc |
| diff --git a/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.cc b/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5868086db7eb00e7ed304f55c6c292afd2e678a8 |
| --- /dev/null |
| +++ b/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.cc |
| @@ -0,0 +1,51 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/webui/settings/chromeos/accessibility_handler.h" |
| + |
| +#include "base/bind.h" |
| +#include "base/bind_helpers.h" |
| +#include "chrome/browser/extensions/extension_service.h" |
| +#include "chrome/browser/extensions/extension_tab_util.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/ui/browser_finder.h" |
| +#include "chrome/browser/ui/webui/settings_utils.h" |
|
Dan Beam
2016/08/02 05:18:47
what are you using settings_utils.h for?
dmazzoni
2016/08/02 17:14:51
Removed.
|
| +#include "chrome/common/extensions/extension_constants.h" |
| +#include "content/public/browser/web_ui.h" |
| +#include "extensions/browser/extension_registry.h" |
|
Dan Beam
2016/08/02 05:18:47
what are you using extension_registry.h for?
dmazzoni
2016/08/02 17:14:52
Kept this in due to your suggestion below, and rem
|
| +#include "extensions/browser/extension_system.h" |
| + |
| +namespace chromeos { |
| +namespace settings { |
| + |
| +AccessibilityHandler::AccessibilityHandler(content::WebUI* webui) |
| + : profile_(Profile::FromWebUI(webui)) { |
| +} |
| + |
| +AccessibilityHandler::~AccessibilityHandler() {} |
| + |
| +void AccessibilityHandler::RegisterMessages() { |
| + web_ui()->RegisterMessageCallback( |
| + "showChromeVoxSettings", |
| + base::Bind(&AccessibilityHandler::HandleShowChromeVoxSettings, |
| + base::Unretained(this))); |
| +} |
| + |
| +void AccessibilityHandler::HandleShowChromeVoxSettings( |
| + const base::ListValue* args) { |
| + ExtensionService* service = |
| + extensions::ExtensionSystem::Get(profile_)->extension_service(); |
|
Dan Beam
2016/08/02 05:18:47
nit: can the extension system or service ever be n
dmazzoni
2016/08/02 17:14:52
I don't believe so, anywhere else in the code does
|
| + if (!service->IsExtensionEnabled(extension_misc::kChromeVoxExtensionId)) |
| + return; |
| + const extensions::Extension* extension = |
| + service->GetInstalledExtension(extension_misc::kChromeVoxExtensionId); |
|
Dan Beam
2016/08/02 05:18:47
nit: can we use
Extension* chrome_vox = Extensi
dmazzoni
2016/08/02 17:14:51
Sure, that's cleaner. Thanks.
|
| + if (!extension) |
| + return; |
| + extensions::ExtensionTabUtil::OpenOptionsPage( |
| + extension, |
| + chrome::FindBrowserWithWebContents(web_ui()->GetWebContents())); |
| +} |
| + |
| +} // namespace settings |
| +} // namespace chromeos |