Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Side by Side Diff: chrome/browser/chromeos/settings/device_settings_provider.h

Issue 666363002: DeviceSettingsProvider's write path uses OwnerSettingsService now. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <deque>
9 #include <string> 8 #include <string>
10 #include <utility>
11 #include <vector> 9 #include <vector>
12 10
13 #include "base/basictypes.h" 11 #include "base/basictypes.h"
14 #include "base/callback.h" 12 #include "base/callback.h"
15 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
16 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
17 #include "base/prefs/pref_value_map.h" 15 #include "base/prefs/pref_value_map.h"
18 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" 16 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
19 #include "chrome/browser/chromeos/settings/device_settings_service.h" 17 #include "chrome/browser/chromeos/settings/device_settings_service.h"
20 #include "chromeos/settings/cros_settings_provider.h" 18 #include "chromeos/settings/cros_settings_provider.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 65
68 // ownership::OwnerSettingsService::Observer implementation: 66 // ownership::OwnerSettingsService::Observer implementation:
69 virtual void OnTentativeChangesInPolicy( 67 virtual void OnTentativeChangesInPolicy(
70 const enterprise_management::PolicyData& policy_data) override; 68 const enterprise_management::PolicyData& policy_data) override;
71 69
72 // 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
73 // 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
74 // availability before the policy blob is fetched on boot. 72 // availability before the policy blob is fetched on boot.
75 void RetrieveCachedData(); 73 void RetrieveCachedData();
76 74
77 // Stores a value from the |pending_changes_| queue in the device settings.
78 // If the device is not owned yet the data ends up only in the local_state
79 // cache and is serialized once ownership is acquired.
80 void SetInPolicy();
81
82 // Parses the policy data and fills in |values_cache_|. 75 // Parses the policy data and fills in |values_cache_|.
83 void UpdateValuesCache( 76 void UpdateValuesCache(
84 const enterprise_management::PolicyData& policy_data, 77 const enterprise_management::PolicyData& policy_data,
85 const enterprise_management::ChromeDeviceSettingsProto& settings, 78 const enterprise_management::ChromeDeviceSettingsProto& settings,
86 TrustedStatus trusted_status); 79 TrustedStatus trusted_status);
87 80
88 // Applies the metrics policy and if not set migrates the legacy file. 81 // Applies the metrics policy and if not set migrates the legacy file.
89 void ApplyMetricsSetting(bool use_file, bool new_value); 82 void ApplyMetricsSetting(bool use_file, bool new_value);
90 83
91 // Applies the data roaming policy. 84 // Applies the data roaming policy.
(...skipping 18 matching lines...) Expand all
110 103
111 // Invokes UpdateFromService() to synchronize with |device_settings_service_|, 104 // Invokes UpdateFromService() to synchronize with |device_settings_service_|,
112 // then triggers the next store operation if applicable. 105 // then triggers the next store operation if applicable.
113 void UpdateAndProceedStoring(); 106 void UpdateAndProceedStoring();
114 107
115 // Re-reads state from |device_settings_service_|, adjusts 108 // Re-reads state from |device_settings_service_|, adjusts
116 // |trusted_status_| and calls UpdateValuesCache() if applicable. Returns true 109 // |trusted_status_| and calls UpdateValuesCache() if applicable. Returns true
117 // if new settings have been loaded. 110 // if new settings have been loaded.
118 bool UpdateFromService(); 111 bool UpdateFromService();
119 112
120 // Sends |device_settings_| to |device_settings_service_| for signing and
121 // storage in session_manager.
122 void StoreDeviceSettings();
123
124 // Checks the current ownership status to see whether the device owner is 113 // Checks the current ownership status to see whether the device owner is
125 // logged in and writes the data accumulated in |migration_values_| to proper 114 // logged in and writes the data accumulated in |migration_values_| to proper
126 // device settings. 115 // device settings.
127 void AttemptMigration(); 116 void AttemptMigration();
128 117
129 // Pending callbacks that need to be invoked after settings verification. 118 // Pending callbacks that need to be invoked after settings verification.
130 std::vector<base::Closure> callbacks_; 119 std::vector<base::Closure> callbacks_;
131 120
132 DeviceSettingsService* device_settings_service_; 121 DeviceSettingsService* device_settings_service_;
133 mutable PrefValueMap migration_values_; 122 mutable PrefValueMap migration_values_;
134 123
135 TrustedStatus trusted_status_; 124 TrustedStatus trusted_status_;
136 DeviceSettingsService::OwnershipStatus ownership_status_; 125 DeviceSettingsService::OwnershipStatus ownership_status_;
137 126
138 // The device settings as currently reported through the CrosSettingsProvider 127 // The device settings as currently reported through the
139 // interface. This may be different from the actual current device settings 128 // CrosSettingsProvider interface. This may be different from the
140 // (which can be obtained from |device_settings_service_|) in case the device 129 // actual current device settings (which can be obtained from
141 // does not have an owner yet or there are pending changes that have not yet 130 // |device_settings_service_|) in case the device does not have an
142 // been written to session_manager. 131 // owner yet. As soon as ownership of the device will be taken,
132 // |device_settings_| will stored on disk and won't be used.
143 enterprise_management::ChromeDeviceSettingsProto device_settings_; 133 enterprise_management::ChromeDeviceSettingsProto device_settings_;
144 134
145 // A cache of values, indexed by the settings keys served through the 135 // A cache of values, indexed by the settings keys served through the
146 // CrosSettingsProvider interface. This is always kept in sync with the raw 136 // CrosSettingsProvider interface. This is always kept in sync with the
147 // data found in |device_settings_|. 137 // current device settings.
148 PrefValueMap values_cache_; 138 PrefValueMap values_cache_;
149 139
150 // This is a queue for set requests, because those need to be sequential.
151 typedef std::pair<std::string, base::Value*> PendingQueueElement;
152 std::deque<PendingQueueElement> pending_changes_;
153
154 // Weak pointer factory for creating store operation callbacks. 140 // Weak pointer factory for creating store operation callbacks.
155 base::WeakPtrFactory<DeviceSettingsProvider> store_callback_factory_; 141 base::WeakPtrFactory<DeviceSettingsProvider> store_callback_factory_;
156 142
157 friend class DeviceSettingsProviderTest; 143 friend class DeviceSettingsProviderTest;
158 FRIEND_TEST_ALL_PREFIXES(DeviceSettingsProviderTest, 144 FRIEND_TEST_ALL_PREFIXES(DeviceSettingsProviderTest,
159 InitializationTestUnowned); 145 InitializationTestUnowned);
160 FRIEND_TEST_ALL_PREFIXES(DeviceSettingsProviderTest, 146 FRIEND_TEST_ALL_PREFIXES(DeviceSettingsProviderTest,
161 PolicyFailedPermanentlyNotification); 147 PolicyFailedPermanentlyNotification);
162 FRIEND_TEST_ALL_PREFIXES(DeviceSettingsProviderTest, PolicyLoadNotification); 148 FRIEND_TEST_ALL_PREFIXES(DeviceSettingsProviderTest, PolicyLoadNotification);
163 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsProvider); 149 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsProvider);
164 }; 150 };
165 151
166 } // namespace chromeos 152 } // namespace chromeos
167 153
168 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_PROVIDER_H_ 154 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698