Commit 25a1b05e authored by James Wallace-Lee's avatar James Wallace-Lee Committed by Commit Bot

chrome://accessibility: save "Internal" checkbox as preference

Saves the option to show the internal accessibility tree as the
preference kShowInternalAccessibilityTree.

Change-Id: Ib16c93f982da3e3cae1728fb8cdb0747a7463549
Reviewed-on: https://chromium-review.googlesource.com/1144271
Commit-Queue: James Wallace-Lee <jamwalla@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577353}
parent f63c9a84
...@@ -14,8 +14,12 @@ ...@@ -14,8 +14,12 @@
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/webui_url_constants.h" #include "chrome/common/webui_url_constants.h"
#include "chrome/grit/browser_resources.h" #include "chrome/grit/browser_resources.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_accessibility_state.h" #include "content/public/browser/browser_accessibility_state.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/favicon_status.h" #include "content/public/browser/favicon_status.h"
...@@ -57,8 +61,6 @@ static const char kDisabled[] = "disabled"; ...@@ -57,8 +61,6 @@ static const char kDisabled[] = "disabled";
namespace { namespace {
bool g_show_internal_accessibility_tree = false;
std::unique_ptr<base::DictionaryValue> BuildTargetDescriptor( std::unique_ptr<base::DictionaryValue> BuildTargetDescriptor(
const GURL& url, const GURL& url,
const std::string& name, const std::string& name,
...@@ -163,7 +165,9 @@ bool HandleAccessibilityRequestCallback( ...@@ -163,7 +165,9 @@ bool HandleAccessibilityRequestCallback(
data.SetString(kScreenReader, web ? (screenreader ? kOn : kOff) : kDisabled); data.SetString(kScreenReader, web ? (screenreader ? kOn : kOff) : kDisabled);
data.SetString(kHTML, web ? (html ? kOn : kOff) : kDisabled); data.SetString(kHTML, web ? (html ? kOn : kOff) : kDisabled);
data.SetString(kInternal, g_show_internal_accessibility_tree ? kOn : kOff); PrefService* pref = Profile::FromBrowserContext(current_context)->GetPrefs();
bool show_internal = pref->GetBoolean(prefs::kShowInternalAccessibilityTree);
data.SetString(kInternal, show_internal ? kOn : kOff);
std::string json_string; std::string json_string;
base::JSONWriter::Write(data, &json_string); base::JSONWriter::Write(data, &json_string);
...@@ -291,8 +295,8 @@ void AccessibilityUIMessageHandler::SetGlobalFlag(const base::ListValue* args) { ...@@ -291,8 +295,8 @@ void AccessibilityUIMessageHandler::SetGlobalFlag(const base::ListValue* args) {
AllowJavascript(); AllowJavascript();
if (flag_name_str == kInternal) { if (flag_name_str == kInternal) {
g_show_internal_accessibility_tree = enabled; PrefService* pref = Profile::FromWebUI(web_ui())->GetPrefs();
LOG(ERROR) << "INTERNAL: " << g_show_internal_accessibility_tree; pref->SetBoolean(prefs::kShowInternalAccessibilityTree, enabled);
return; return;
} }
...@@ -368,8 +372,10 @@ void AccessibilityUIMessageHandler::RequestWebContentsTree( ...@@ -368,8 +372,10 @@ void AccessibilityUIMessageHandler::RequestWebContentsTree(
web_contents->SetAccessibilityMode( web_contents->SetAccessibilityMode(
ui::AXMode(ui::AXMode::kNativeAPIs | ui::AXMode::kWebContents)); ui::AXMode(ui::AXMode::kNativeAPIs | ui::AXMode::kWebContents));
PrefService* pref = Profile::FromWebUI(web_ui())->GetPrefs();
bool internal = pref->GetBoolean(prefs::kShowInternalAccessibilityTree);
base::string16 accessibility_contents_utf16 = base::string16 accessibility_contents_utf16 =
web_contents->DumpAccessibilityTree(g_show_internal_accessibility_tree); web_contents->DumpAccessibilityTree(internal);
result->SetString("tree", base::UTF16ToUTF8(accessibility_contents_utf16)); result->SetString("tree", base::UTF16ToUTF8(accessibility_contents_utf16));
CallJavascriptFunction("accessibility.showTree", *(result.get())); CallJavascriptFunction("accessibility.showTree", *(result.get()));
} }
...@@ -387,3 +393,9 @@ void AccessibilityUIMessageHandler::RequestNativeUITree( ...@@ -387,3 +393,9 @@ void AccessibilityUIMessageHandler::RequestNativeUITree(
result->SetString("tree", str); result->SetString("tree", str);
CallJavascriptFunction("accessibility.showNativeUITree", *(result.get())); CallJavascriptFunction("accessibility.showNativeUITree", *(result.get()));
} }
// static
void AccessibilityUIMessageHandler::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterBooleanPref(prefs::kShowInternalAccessibilityTree, false);
}
...@@ -14,6 +14,10 @@ namespace base { ...@@ -14,6 +14,10 @@ namespace base {
class ListValue; class ListValue;
} // namespace base } // namespace base
namespace user_prefs {
class PrefRegistrySyncable;
} // namespace user_prefs
class AccessibilityUI : public content::WebUIController { class AccessibilityUI : public content::WebUIController {
public: public:
explicit AccessibilityUI(content::WebUI* web_ui); explicit AccessibilityUI(content::WebUI* web_ui);
...@@ -27,6 +31,8 @@ class AccessibilityUIMessageHandler : public content::WebUIMessageHandler { ...@@ -27,6 +31,8 @@ class AccessibilityUIMessageHandler : public content::WebUIMessageHandler {
void RegisterMessages() override; void RegisterMessages() override;
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
private: private:
void ToggleAccessibility(const base::ListValue* args); void ToggleAccessibility(const base::ListValue* args);
void SetGlobalFlag(const base::ListValue* args); void SetGlobalFlag(const base::ListValue* args);
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/about_flags.h" #include "chrome/browser/about_flags.h"
#include "chrome/browser/accessibility/accessibility_ui.h"
#include "chrome/browser/accessibility/invert_bubble_prefs.h" #include "chrome/browser/accessibility/invert_bubble_prefs.h"
#include "chrome/browser/browser_process_impl.h" #include "chrome/browser/browser_process_impl.h"
#include "chrome/browser/chrome_content_browser_client.h" #include "chrome/browser/chrome_content_browser_client.h"
...@@ -512,6 +513,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { ...@@ -512,6 +513,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
TRACE_EVENT0("browser", "chrome::RegisterProfilePrefs"); TRACE_EVENT0("browser", "chrome::RegisterProfilePrefs");
SCOPED_UMA_HISTOGRAM_TIMER("Settings.RegisterProfilePrefsTime"); SCOPED_UMA_HISTOGRAM_TIMER("Settings.RegisterProfilePrefsTime");
// User prefs. Please keep this list alphabetized. // User prefs. Please keep this list alphabetized.
AccessibilityUIMessageHandler::RegisterProfilePrefs(registry);
autofill::AutofillManager::RegisterProfilePrefs(registry); autofill::AutofillManager::RegisterProfilePrefs(registry);
browsing_data::prefs::RegisterBrowserUserPrefs(registry); browsing_data::prefs::RegisterBrowserUserPrefs(registry);
certificate_transparency::prefs::RegisterPrefs(registry); certificate_transparency::prefs::RegisterPrefs(registry);
......
...@@ -990,6 +990,11 @@ const char kResetCheckDefaultBrowser[] = ...@@ -990,6 +990,11 @@ const char kResetCheckDefaultBrowser[] =
const char kDefaultBrowserSettingEnabled[] = const char kDefaultBrowserSettingEnabled[] =
"browser.default_browser_setting_enabled"; "browser.default_browser_setting_enabled";
// Boolean that indicates whether chrome://accessibility should show the
// internal accessibility tree.
const char kShowInternalAccessibilityTree[] =
"accessibility.show_internal_accessibility_tree";
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
// Boolean that indicates whether the application should show the info bar // Boolean that indicates whether the application should show the info bar
// asking the user to set up automatic updates when Keystone promotion is // asking the user to set up automatic updates when Keystone promotion is
......
...@@ -169,6 +169,7 @@ extern const char kContextualSearchEnabled[]; ...@@ -169,6 +169,7 @@ extern const char kContextualSearchEnabled[];
(defined(OS_LINUX) && !defined(OS_CHROMEOS)) (defined(OS_LINUX) && !defined(OS_CHROMEOS))
extern const char kConfirmToQuitEnabled[]; extern const char kConfirmToQuitEnabled[];
#endif #endif
extern const char kShowInternalAccessibilityTree[];
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
extern const char kShowFullscreenToolbar[]; extern const char kShowFullscreenToolbar[];
extern const char kAllowJavascriptAppleEvents[]; extern const char kAllowJavascriptAppleEvents[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment