1 // Copyright 2020 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_ACCESSIBILITY_SECTION_H_
6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_ACCESSIBILITY_SECTION_H_
7 
8 #include "base/scoped_observer.h"
9 #include "base/values.h"
10 #include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
11 #include "components/prefs/pref_change_registrar.h"
12 #include "content/public/browser/tts_controller.h"
13 #include "extensions/browser/extension_registry.h"
14 #include "extensions/browser/extension_registry_observer.h"
15 
16 class PrefService;
17 
18 namespace content {
19 class WebUIDataSource;
20 }  // namespace content
21 
22 namespace chromeos {
23 namespace settings {
24 
25 class SearchTagRegistry;
26 
27 // Provides UI strings and search tags for Accessibility settings.
28 class AccessibilitySection : public OsSettingsSection,
29                              public content::VoicesChangedDelegate,
30                              public extensions::ExtensionRegistryObserver {
31  public:
32   AccessibilitySection(Profile* profile,
33                        SearchTagRegistry* search_tag_registry,
34                        PrefService* pref_service);
35   ~AccessibilitySection() override;
36 
37  private:
38   // OsSettingsSection:
39   void AddLoadTimeData(content::WebUIDataSource* html_source) override;
40   void AddHandlers(content::WebUI* web_ui) override;
41   int GetSectionNameMessageId() const override;
42   mojom::Section GetSection() const override;
43   mojom::SearchResultIcon GetSectionIcon() const override;
44   std::string GetSectionPath() const override;
45   bool LogMetric(mojom::Setting setting, base::Value& value) const override;
46   void RegisterHierarchy(HierarchyGenerator* generator) const override;
47 
48   // content::VoicesChangedDelegate:
49   void OnVoicesChanged() override;
50 
51   // extensions::ExtensionRegistryObserver:
52   void OnExtensionLoaded(content::BrowserContext* browser_context,
53                          const extensions::Extension* extension) override;
54   void OnExtensionUnloaded(content::BrowserContext* browser_context,
55                            const extensions::Extension* extension,
56                            extensions::UnloadedExtensionReason reason) override;
57 
58   void UpdateSearchTags();
59   void UpdateTextToSpeechVoiceSearchTags();
60   void UpdateTextToSpeechEnginesSearchTags();
61 
62   PrefService* pref_service_;
63   PrefChangeRegistrar pref_change_registrar_;
64   extensions::ExtensionRegistry* extension_registry_ = nullptr;
65 };
66 
67 }  // namespace settings
68 }  // namespace chromeos
69 
70 #endif  // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_ACCESSIBILITY_SECTION_H_
71