OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_PROVIDER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_PROVIDER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_PROVIDER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 DeviceSettingsService* device_settings_service); | 45 DeviceSettingsService* device_settings_service); |
46 ~DeviceSettingsProvider() override; | 46 ~DeviceSettingsProvider() override; |
47 | 47 |
48 // Returns true if |path| is handled by this provider. | 48 // Returns true if |path| is handled by this provider. |
49 static bool IsDeviceSetting(const std::string& name); | 49 static bool IsDeviceSetting(const std::string& name); |
50 | 50 |
51 // CrosSettingsProvider implementation. | 51 // CrosSettingsProvider implementation. |
52 const base::Value* Get(const std::string& path) const override; | 52 const base::Value* Get(const std::string& path) const override; |
53 TrustedStatus PrepareTrustedValues(const base::Closure& callback) override; | 53 TrustedStatus PrepareTrustedValues(const base::Closure& callback) override; |
54 bool HandlesSetting(const std::string& path) const override; | 54 bool HandlesSetting(const std::string& path) const override; |
| 55 void SetPrefForTesting(const std::string& path, bool value); |
55 | 56 |
56 private: | 57 private: |
57 // CrosSettingsProvider implementation: | 58 // CrosSettingsProvider implementation: |
58 void DoSet(const std::string& path, const base::Value& value) override; | 59 void DoSet(const std::string& path, const base::Value& value) override; |
59 | 60 |
60 // DeviceSettingsService::Observer implementation: | 61 // DeviceSettingsService::Observer implementation: |
61 void OwnershipStatusChanged() override; | 62 void OwnershipStatusChanged() override; |
62 void DeviceSettingsUpdated() override; | 63 void DeviceSettingsUpdated() override; |
63 void OnDeviceSettingsServiceShutdown() override; | 64 void OnDeviceSettingsServiceShutdown() override; |
64 | 65 |
65 // ownership::OwnerSettingsService::Observer implementation: | 66 // ownership::OwnerSettingsService::Observer implementation: |
66 void OnTentativeChangesInPolicy( | 67 void OnTentativeChangesInPolicy( |
67 const enterprise_management::PolicyData& policy_data) override; | 68 const enterprise_management::PolicyData& policy_data) override; |
68 | 69 |
69 // Populates in-memory cache from the local_state cache that is used to store | 70 // Populates in-memory cache from the local_state cache that is used to store |
70 // device settings before the device is owned and to speed up policy | 71 // device settings before the device is owned and to speed up policy |
71 // availability before the policy blob is fetched on boot. | 72 // availability before the policy blob is fetched on boot. |
72 void RetrieveCachedData(); | 73 void RetrieveCachedData(); |
73 | 74 |
74 // Parses the policy data and fills in |values_cache_|. | 75 // Parses the policy data and fills in |values_cache_|. |
75 void UpdateValuesCache( | 76 void UpdateValuesCache( |
76 const enterprise_management::PolicyData& policy_data, | 77 const enterprise_management::PolicyData& policy_data, |
77 const enterprise_management::ChromeDeviceSettingsProto& settings, | 78 const enterprise_management::ChromeDeviceSettingsProto& settings, |
78 TrustedStatus trusted_status); | 79 TrustedStatus trusted_status); |
79 | 80 |
80 // Applies the metrics policy and if not set migrates the legacy file. | |
81 void ApplyMetricsSetting(bool use_file, bool new_value); | |
82 | |
83 // Applies the data roaming policy. | 81 // Applies the data roaming policy. |
84 void ApplyRoamingSetting(bool new_value); | 82 void ApplyRoamingSetting(bool new_value); |
85 void ApplyRoamingSettingFromProto( | 83 void ApplyRoamingSettingFromProto( |
86 const enterprise_management::ChromeDeviceSettingsProto& settings); | 84 const enterprise_management::ChromeDeviceSettingsProto& settings); |
87 | 85 |
88 // Applies any changes of the policies that are not handled by the respective | |
89 // subsystems. | |
90 void ApplySideEffects( | |
91 const enterprise_management::ChromeDeviceSettingsProto& settings); | |
92 | |
93 // In case of missing policy blob we should verify if this is upgrade of | 86 // In case of missing policy blob we should verify if this is upgrade of |
94 // machine owned from pre version 12 OS and the user never touched the device | 87 // machine owned from pre version 12 OS and the user never touched the device |
95 // settings. In this case revert to defaults and let people in until the owner | 88 // settings. In this case revert to defaults and let people in until the owner |
96 // comes and changes that. | 89 // comes and changes that. |
97 bool MitigateMissingPolicy(); | 90 bool MitigateMissingPolicy(); |
98 | 91 |
99 // Checks if the current cache value can be trusted for being representative | 92 // Checks if the current cache value can be trusted for being representative |
100 // for the disk cache. | 93 // for the disk cache. |
101 TrustedStatus RequestTrustedEntity(); | 94 TrustedStatus RequestTrustedEntity(); |
102 | 95 |
103 // Invokes UpdateFromService() to synchronize with |device_settings_service_|, | 96 // Invokes UpdateFromService() to synchronize with |device_settings_service_|, |
104 // then triggers the next store operation if applicable. | 97 // then triggers the next store operation if applicable. |
105 void UpdateAndProceedStoring(); | 98 void UpdateAndProceedStoring(); |
106 | 99 |
107 // Re-reads state from |device_settings_service_|, adjusts | 100 // Re-reads state from |device_settings_service_|, adjusts |
108 // |trusted_status_| and calls UpdateValuesCache() if applicable. Returns true | 101 // |trusted_status_| and calls UpdateValuesCache() if applicable. Returns true |
109 // if new settings have been loaded. | 102 // if new settings have been loaded. |
110 bool UpdateFromService(); | 103 bool UpdateFromService(); |
111 | 104 |
112 // Checks the current ownership status to see whether the device owner is | |
113 // logged in and writes the data accumulated in |migration_values_| to proper | |
114 // device settings. | |
115 void AttemptMigration(); | |
116 | |
117 // Pending callbacks that need to be invoked after settings verification. | 105 // Pending callbacks that need to be invoked after settings verification. |
118 std::vector<base::Closure> callbacks_; | 106 std::vector<base::Closure> callbacks_; |
119 | 107 |
120 DeviceSettingsService* device_settings_service_; | 108 DeviceSettingsService* device_settings_service_; |
121 mutable PrefValueMap migration_values_; | 109 mutable PrefValueMap migration_values_; |
122 | 110 |
123 TrustedStatus trusted_status_; | 111 TrustedStatus trusted_status_; |
124 DeviceSettingsService::OwnershipStatus ownership_status_; | 112 DeviceSettingsService::OwnershipStatus ownership_status_; |
125 | 113 |
126 // The device settings as currently reported through the | 114 // The device settings as currently reported through the |
(...skipping 17 matching lines...) Expand all Loading... |
144 InitializationTestUnowned); | 132 InitializationTestUnowned); |
145 FRIEND_TEST_ALL_PREFIXES(DeviceSettingsProviderTest, | 133 FRIEND_TEST_ALL_PREFIXES(DeviceSettingsProviderTest, |
146 PolicyFailedPermanentlyNotification); | 134 PolicyFailedPermanentlyNotification); |
147 FRIEND_TEST_ALL_PREFIXES(DeviceSettingsProviderTest, PolicyLoadNotification); | 135 FRIEND_TEST_ALL_PREFIXES(DeviceSettingsProviderTest, PolicyLoadNotification); |
148 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsProvider); | 136 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsProvider); |
149 }; | 137 }; |
150 | 138 |
151 } // namespace chromeos | 139 } // namespace chromeos |
152 | 140 |
153 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_PROVIDER_H_ | 141 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_PROVIDER_H_ |
OLD | NEW |