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_OS_SETTINGS_MANAGER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_OS_SETTINGS_MANAGER_H_ 7 8 #include <memory> 9 10 #include "base/gtest_prod_util.h" 11 #include "components/keyed_service/core/keyed_service.h" 12 13 class ArcAppListPrefs; 14 class Profile; 15 class SupervisedUserService; 16 17 namespace content { 18 class WebUI; 19 class WebUIDataSource; 20 } // namespace content 21 22 namespace signin { 23 class IdentityManager; 24 } // namespace signin 25 26 namespace syncer { 27 class SyncService; 28 } // namespace syncer 29 30 namespace chromeos { 31 32 class CupsPrintersManager; 33 class KerberosCredentialsManager; 34 35 namespace android_sms { 36 class AndroidSmsService; 37 } // namespace android_sms 38 39 namespace local_search_service { 40 class LocalSearchServiceSync; 41 } // namespace local_search_service 42 43 namespace multidevice_setup { 44 class MultiDeviceSetupClient; 45 } // namespace multidevice_setup 46 47 namespace phonehub { 48 class PhoneHubManager; 49 } // namespace phonehub 50 51 namespace settings { 52 53 class Hierarchy; 54 class OsSettingsSections; 55 class SearchHandler; 56 class SearchTagRegistry; 57 class SettingsUserActionTracker; 58 59 // Manager for the Chrome OS settings page. This class is implemented as a 60 // KeyedService, so one instance of the class is intended to be active for the 61 // lifetime of a logged-in user, even if the settings app is not opened. 62 // 63 // Main responsibilities: 64 // 65 // (1) Support search queries for settings content. OsSettingsManager is 66 // responsible for updating the kCroSettings index of the 67 // LocalSearchServiceSync 68 // with search tags corresponding to all settings which are available. 69 // 70 // The availability of settings depends on the user's account (e.g., 71 // Personalization settings are not available for guest accounts), the state 72 // of the device (e.g., devices without an external monitor hide some 73 // display settings), Enterprise settings (e.g., ARC++ is prohibited by some 74 // policies), and the state of various flags and switches. 75 // 76 // Whenever settings becomes available or unavailable, OsSettingsManager 77 // updates the search index accordingly. 78 // 79 // (2) Provide static data to the settings app via the loadTimeData framework. 80 // This includes localized strings required by the settings UI as well as 81 // flags passed as booleans. 82 // 83 // (3) Add logic supporting message-passing between the browser process (C++) 84 // and the settings app (JS), via SettingsPageUIHandler objects. 85 class OsSettingsManager : public KeyedService { 86 public: 87 OsSettingsManager( 88 Profile* profile, 89 local_search_service::LocalSearchServiceSync* local_search_service, 90 multidevice_setup::MultiDeviceSetupClient* multidevice_setup_client, 91 phonehub::PhoneHubManager* phone_hub_manager, 92 syncer::SyncService* sync_service, 93 SupervisedUserService* supervised_user_service, 94 KerberosCredentialsManager* kerberos_credentials_manager, 95 ArcAppListPrefs* arc_app_list_prefs, 96 signin::IdentityManager* identity_manager, 97 android_sms::AndroidSmsService* android_sms_service, 98 CupsPrintersManager* printers_manager); 99 OsSettingsManager(const OsSettingsManager& other) = delete; 100 OsSettingsManager& operator=(const OsSettingsManager& other) = delete; 101 ~OsSettingsManager() override; 102 103 // Provides static data (i.e., localized strings and flag values) to an OS 104 // settings instance. This function causes |html_source| to export a 105 // strings.js file which contains a key-value map of the data added by this 106 // function. 107 void AddLoadTimeData(content::WebUIDataSource* html_source); 108 109 // Adds SettingsPageUIHandlers to an OS settings instance. 110 void AddHandlers(content::WebUI* web_ui); 111 search_handler()112 SearchHandler* search_handler() { return search_handler_.get(); } 113 settings_user_action_tracker()114 SettingsUserActionTracker* settings_user_action_tracker() { 115 return settings_user_action_tracker_.get(); 116 } 117 hierarchy()118 const Hierarchy* hierarchy() const { return hierarchy_.get(); } 119 120 private: 121 FRIEND_TEST_ALL_PREFIXES(OsSettingsManagerTest, Initialization); 122 123 // KeyedService: 124 void Shutdown() override; 125 126 std::unique_ptr<SearchTagRegistry> search_tag_registry_; 127 std::unique_ptr<OsSettingsSections> sections_; 128 std::unique_ptr<Hierarchy> hierarchy_; 129 std::unique_ptr<SettingsUserActionTracker> settings_user_action_tracker_; 130 std::unique_ptr<SearchHandler> search_handler_; 131 }; 132 133 } // namespace settings 134 } // namespace chromeos 135 136 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_OS_SETTINGS_MANAGER_H_ 137