OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" | 5 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 PersistentPrefStore* store = new JsonPrefStore( | 71 PersistentPrefStore* store = new JsonPrefStore( |
72 path, sequenced_task_runner, scoped_ptr<PrefFilter>()); | 72 path, sequenced_task_runner, scoped_ptr<PrefFilter>()); |
73 Init(store); | 73 Init(store); |
74 if (load_synchronously) { | 74 if (load_synchronously) { |
75 store_->ReadPrefs(); | 75 store_->ReadPrefs(); |
76 // TODO(bauerb): Temporary CHECK while investigating | 76 // TODO(bauerb): Temporary CHECK while investigating |
77 // https://crbug.com/425785. Remove (or change to DCHECK) once the bug | 77 // https://crbug.com/425785. Remove (or change to DCHECK) once the bug |
78 // is fixed. | 78 // is fixed. |
79 CHECK(store_->IsInitializationComplete()); | 79 CHECK(store_->IsInitializationComplete()); |
80 } else { | 80 } else { |
81 store_->ReadPrefsAsync(NULL); | 81 store_->ReadPrefsAsync(nullptr); |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 void SupervisedUserSettingsService::Init( | 85 void SupervisedUserSettingsService::Init( |
86 scoped_refptr<PersistentPrefStore> store) { | 86 scoped_refptr<PersistentPrefStore> store) { |
87 DCHECK(!store_.get()); | 87 DCHECK(!store_.get()); |
88 store_ = store; | 88 store_ = store; |
89 store_->AddObserver(this); | 89 store_->AddObserver(this); |
90 } | 90 } |
91 | 91 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 const std::string& prefix, | 127 const std::string& prefix, |
128 const std::string& key) { | 128 const std::string& key) { |
129 return prefix + kSplitSettingKeySeparator + key; | 129 return prefix + kSplitSettingKeySeparator + key; |
130 } | 130 } |
131 | 131 |
132 void SupervisedUserSettingsService::UploadItem(const std::string& key, | 132 void SupervisedUserSettingsService::UploadItem(const std::string& key, |
133 scoped_ptr<base::Value> value) { | 133 scoped_ptr<base::Value> value) { |
134 DCHECK(!SettingShouldApplyToPrefs(key)); | 134 DCHECK(!SettingShouldApplyToPrefs(key)); |
135 | 135 |
136 std::string key_suffix = key; | 136 std::string key_suffix = key; |
137 base::DictionaryValue* dict = NULL; | 137 base::DictionaryValue* dict = nullptr; |
138 if (sync_processor_) { | 138 if (sync_processor_) { |
139 content::RecordAction(UserMetricsAction("ManagedUsers_UploadItem_Syncing")); | 139 content::RecordAction(UserMetricsAction("ManagedUsers_UploadItem_Syncing")); |
140 dict = GetDictionaryAndSplitKey(&key_suffix); | 140 dict = GetDictionaryAndSplitKey(&key_suffix); |
141 DCHECK(GetQueuedItems()->empty()); | 141 DCHECK(GetQueuedItems()->empty()); |
142 SyncChangeList change_list; | 142 SyncChangeList change_list; |
143 SyncData data = CreateSyncDataForSetting(key, *value); | 143 SyncData data = CreateSyncDataForSetting(key, *value); |
144 SyncChange::SyncChangeType change_type = | 144 SyncChange::SyncChangeType change_type = |
145 dict->HasKey(key_suffix) ? SyncChange::ACTION_UPDATE | 145 dict->HasKey(key_suffix) ? SyncChange::ACTION_UPDATE |
146 : SyncChange::ACTION_ADD; | 146 : SyncChange::ACTION_ADD; |
147 change_list.push_back(SyncChange(FROM_HERE, change_type, data)); | 147 change_list.push_back(SyncChange(FROM_HERE, change_type, data)); |
148 SyncError error = | 148 SyncError error = |
149 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list); | 149 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list); |
150 DCHECK(!error.IsSet()) << error.ToString(); | 150 DCHECK(!error.IsSet()) << error.ToString(); |
151 } else { | 151 } else { |
152 // Queue the item up to be uploaded when we start syncing | 152 // Queue the item up to be uploaded when we start syncing |
153 // (in MergeDataAndStartSyncing()). | 153 // (in MergeDataAndStartSyncing()). |
154 content::RecordAction(UserMetricsAction("ManagedUsers_UploadItem_Queued")); | 154 content::RecordAction(UserMetricsAction("ManagedUsers_UploadItem_Queued")); |
155 dict = GetQueuedItems(); | 155 dict = GetQueuedItems(); |
156 } | 156 } |
157 dict->SetWithoutPathExpansion(key_suffix, value.release()); | 157 dict->SetWithoutPathExpansion(key_suffix, value.release()); |
158 } | 158 } |
159 | 159 |
160 void SupervisedUserSettingsService::SetLocalSetting( | 160 void SupervisedUserSettingsService::SetLocalSetting( |
161 const std::string& key, | 161 const std::string& key, |
162 scoped_ptr<base::Value> value) { | 162 scoped_ptr<base::Value> value) { |
163 if (value) | 163 if (value) |
164 local_settings_->SetWithoutPathExpansion(key, value.release()); | 164 local_settings_->SetWithoutPathExpansion(key, value.release()); |
165 else | 165 else |
166 local_settings_->RemoveWithoutPathExpansion(key, NULL); | 166 local_settings_->RemoveWithoutPathExpansion(key, nullptr); |
167 | 167 |
168 InformSubscribers(); | 168 InformSubscribers(); |
169 } | 169 } |
170 | 170 |
171 // static | 171 // static |
172 SyncData SupervisedUserSettingsService::CreateSyncDataForSetting( | 172 SyncData SupervisedUserSettingsService::CreateSyncDataForSetting( |
173 const std::string& name, | 173 const std::string& name, |
174 const base::Value& value) { | 174 const base::Value& value) { |
175 std::string json_value; | 175 std::string json_value; |
176 base::JSONWriter::Write(value, &json_value); | 176 base::JSONWriter::Write(value, &json_value); |
177 ::sync_pb::EntitySpecifics specifics; | 177 ::sync_pb::EntitySpecifics specifics; |
178 specifics.mutable_managed_user_setting()->set_name(name); | 178 specifics.mutable_managed_user_setting()->set_name(name); |
179 specifics.mutable_managed_user_setting()->set_value(json_value); | 179 specifics.mutable_managed_user_setting()->set_value(json_value); |
180 return SyncData::CreateLocalData(name, name, specifics); | 180 return SyncData::CreateLocalData(name, name, specifics); |
181 } | 181 } |
182 | 182 |
183 void SupervisedUserSettingsService::Shutdown() { | 183 void SupervisedUserSettingsService::Shutdown() { |
184 store_->RemoveObserver(this); | 184 store_->RemoveObserver(this); |
185 } | 185 } |
186 | 186 |
187 SyncMergeResult SupervisedUserSettingsService::MergeDataAndStartSyncing( | 187 SyncMergeResult SupervisedUserSettingsService::MergeDataAndStartSyncing( |
188 ModelType type, | 188 ModelType type, |
189 const SyncDataList& initial_sync_data, | 189 const SyncDataList& initial_sync_data, |
190 scoped_ptr<SyncChangeProcessor> sync_processor, | 190 scoped_ptr<SyncChangeProcessor> sync_processor, |
191 scoped_ptr<SyncErrorFactory> error_handler) { | 191 scoped_ptr<SyncErrorFactory> error_handler) { |
192 DCHECK_EQ(SUPERVISED_USER_SETTINGS, type); | 192 DCHECK_EQ(SUPERVISED_USER_SETTINGS, type); |
193 sync_processor_ = std::move(sync_processor); | 193 sync_processor_ = std::move(sync_processor); |
194 error_handler_ = std::move(error_handler); | 194 error_handler_ = std::move(error_handler); |
195 | 195 |
| 196 std::map<std::string, const base::Value*> seen_keys; |
| 197 int num_before_association = GetAtomicSettings()->size(); |
| 198 for (base::DictionaryValue::Iterator it(*GetAtomicSettings()); !it.IsAtEnd(); |
| 199 it.Advance()) { |
| 200 seen_keys[it.key()] = &it.value(); |
| 201 } |
| 202 for (base::DictionaryValue::Iterator it(*GetSplitSettings()); !it.IsAtEnd(); |
| 203 it.Advance()) { |
| 204 const base::DictionaryValue* dict = nullptr; |
| 205 it.value().GetAsDictionary(&dict); |
| 206 num_before_association += dict->size(); |
| 207 for (base::DictionaryValue::Iterator jt(*dict); !jt.IsAtEnd(); |
| 208 jt.Advance()) { |
| 209 seen_keys[MakeSplitSettingKey(it.key(), jt.key())] = &jt.value(); |
| 210 } |
| 211 } |
| 212 |
| 213 LOG(ERROR) << "Deepak num_before_association:" << num_before_association; |
| 214 for (std::map<std::string, const base::Value*>::iterator it = |
| 215 seen_keys.begin(); |
| 216 it != seen_keys.end(); it++) { |
| 217 LOG(ERROR) << "Deepak key:" << it->first; |
| 218 std::string json_value; |
| 219 base::JSONWriter::Write(*(it->second), &json_value); |
| 220 LOG(ERROR) << "Deepak " << json_value; |
| 221 } |
196 // Clear all atomic and split settings, then recreate them from Sync data. | 222 // Clear all atomic and split settings, then recreate them from Sync data. |
197 Clear(); | 223 Clear(); |
| 224 int num_added = 0; |
| 225 int num_modified = 0; |
198 for (const SyncData& sync_data : initial_sync_data) { | 226 for (const SyncData& sync_data : initial_sync_data) { |
199 DCHECK_EQ(SUPERVISED_USER_SETTINGS, sync_data.GetDataType()); | 227 DCHECK_EQ(SUPERVISED_USER_SETTINGS, sync_data.GetDataType()); |
200 const ::sync_pb::ManagedUserSettingSpecifics& supervised_user_setting = | 228 const ::sync_pb::ManagedUserSettingSpecifics& supervised_user_setting = |
201 sync_data.GetSpecifics().managed_user_setting(); | 229 sync_data.GetSpecifics().managed_user_setting(); |
202 scoped_ptr<base::Value> value = | 230 scoped_ptr<base::Value> value = |
203 JSONReader::Read(supervised_user_setting.value()); | 231 JSONReader::Read(supervised_user_setting.value()); |
204 std::string name_suffix = supervised_user_setting.name(); | 232 std::string name_suffix = supervised_user_setting.name(); |
| 233 std::string name_key = name_suffix; |
| 234 LOG(ERROR) << "Deepak name_suffix:" << name_suffix; |
205 base::DictionaryValue* dict = GetDictionaryAndSplitKey(&name_suffix); | 235 base::DictionaryValue* dict = GetDictionaryAndSplitKey(&name_suffix); |
206 dict->SetWithoutPathExpansion(name_suffix, value.release()); | 236 dict->SetWithoutPathExpansion(name_suffix, value.release()); |
| 237 LOG(ERROR) << "Deepak " << supervised_user_setting.value(); |
| 238 std::map<std::string, const base::Value*>::iterator it = |
| 239 seen_keys.find(name_key); |
| 240 if (it == seen_keys.end()) { |
| 241 LOG(ERROR) << "Deepak Item Added:" << name_suffix; |
| 242 num_added++; |
| 243 } else { |
| 244 LOG(ERROR) << "Deepak for checking item modification"; |
| 245 if (it->second != value.get()) { |
| 246 LOG(ERROR) << "Deepak modifying item"; |
| 247 num_modified++; |
| 248 } |
| 249 /* for (DictionaryValue::Iterator jt(*dict); !jt.IsAtEnd(); |
| 250 jt.Advance()) { |
| 251 std::string json_value; |
| 252 base::JSONWriter::Write(jt.value(), &json_value); |
| 253 LOG(ERROR) << "Deepak " << json_value; |
| 254 if (seen_keys[name_key] != &jt.value()) { |
| 255 LOG(ERROR) << "Deepak Item modified:" << name_key; |
| 256 num_modified++; |
| 257 } |
| 258 } |
| 259 */ |
| 260 } |
207 } | 261 } |
| 262 |
| 263 LOG(ERROR) << "Deepak added:" << num_added << "modified:" << num_modified; |
208 store_->ReportValueChanged(kAtomicSettings, | 264 store_->ReportValueChanged(kAtomicSettings, |
209 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 265 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
210 store_->ReportValueChanged(kSplitSettings, | 266 store_->ReportValueChanged(kSplitSettings, |
211 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 267 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
212 InformSubscribers(); | 268 InformSubscribers(); |
213 | 269 |
214 // Upload all the queued up items (either with an ADD or an UPDATE action, | 270 // Upload all the queued up items (either with an ADD or an UPDATE action, |
215 // depending on whether they already exist) and move them to split settings. | 271 // depending on whether they already exist) and move them to split settings. |
216 SyncChangeList change_list; | 272 SyncChangeList change_list; |
217 base::DictionaryValue* queued_items = GetQueuedItems(); | 273 base::DictionaryValue* queued_items = GetQueuedItems(); |
218 for (base::DictionaryValue::Iterator it(*queued_items); !it.IsAtEnd(); | 274 for (base::DictionaryValue::Iterator it(*queued_items); !it.IsAtEnd(); |
219 it.Advance()) { | 275 it.Advance()) { |
220 std::string key_suffix = it.key(); | 276 std::string key_suffix = it.key(); |
| 277 std::string name_key = key_suffix; |
221 base::DictionaryValue* dict = GetDictionaryAndSplitKey(&key_suffix); | 278 base::DictionaryValue* dict = GetDictionaryAndSplitKey(&key_suffix); |
222 SyncData data = CreateSyncDataForSetting(it.key(), it.value()); | 279 SyncData data = CreateSyncDataForSetting(it.key(), it.value()); |
223 SyncChange::SyncChangeType change_type = | 280 SyncChange::SyncChangeType change_type = |
224 dict->HasKey(key_suffix) ? SyncChange::ACTION_UPDATE | 281 dict->HasKey(key_suffix) ? SyncChange::ACTION_UPDATE |
225 : SyncChange::ACTION_ADD; | 282 : SyncChange::ACTION_ADD; |
226 change_list.push_back(SyncChange(FROM_HERE, change_type, data)); | 283 change_list.push_back(SyncChange(FROM_HERE, change_type, data)); |
227 dict->SetWithoutPathExpansion(key_suffix, it.value().DeepCopy()); | 284 dict->SetWithoutPathExpansion(key_suffix, it.value().DeepCopy()); |
| 285 if (seen_keys.find(name_key) == seen_keys.end()) { |
| 286 LOG(ERROR) << "Deepak adding"; |
| 287 num_added++; |
| 288 } else { |
| 289 for (DictionaryValue::Iterator jt(*dict); !jt.IsAtEnd(); jt.Advance()) { |
| 290 if (seen_keys[name_key] != &jt.value()) { |
| 291 LOG(ERROR) << "Deepak modifying"; |
| 292 num_modified++; |
| 293 } |
| 294 } |
| 295 } |
228 } | 296 } |
229 queued_items->Clear(); | 297 queued_items->Clear(); |
| 298 LOG(ERROR) << "Deepak added:" << num_added << "modified:" << num_modified; |
230 | 299 |
231 SyncMergeResult result(SUPERVISED_USER_SETTINGS); | 300 SyncMergeResult result(SUPERVISED_USER_SETTINGS); |
232 // Process all the accumulated changes from the queued items. | 301 // Process all the accumulated changes from the queued items. |
233 if (change_list.size() > 0) { | 302 if (change_list.size() > 0) { |
234 store_->ReportValueChanged(kQueuedItems, | 303 store_->ReportValueChanged(kQueuedItems, |
235 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 304 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
236 result.set_error( | 305 result.set_error( |
237 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list)); | 306 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list)); |
238 } | 307 } |
239 | 308 |
240 // TODO(bauerb): Statistics? | 309 // Calculating number of items after association. |
| 310 int num_after_association = GetAtomicSettings()->size(); |
| 311 for (base::DictionaryValue::Iterator it(*GetSplitSettings()); !it.IsAtEnd(); |
| 312 it.Advance()) { |
| 313 const base::DictionaryValue* dict = nullptr; |
| 314 it.value().GetAsDictionary(&dict); |
| 315 num_after_association += dict->size(); |
| 316 } |
| 317 |
| 318 LOG(ERROR) << "Deepak added:" << num_added; |
| 319 LOG(ERROR) << "Deepak modified:" << num_modified; |
| 320 LOG(ERROR) << "Deepak deleted:" << num_before_association - num_modified; |
| 321 LOG(ERROR) << "Deepak beforeAssociation:" << num_before_association; |
| 322 LOG(ERROR) << "Deepak afterAssociation:" << num_after_association; |
| 323 |
| 324 result.set_num_items_added(num_added); |
| 325 result.set_num_items_modified(num_modified); |
| 326 result.set_num_items_deleted(num_before_association - num_modified); |
| 327 result.set_num_items_before_association(num_before_association); |
| 328 result.set_num_items_after_association(num_after_association); |
241 return result; | 329 return result; |
242 } | 330 } |
243 | 331 |
244 void SupervisedUserSettingsService::StopSyncing(ModelType type) { | 332 void SupervisedUserSettingsService::StopSyncing(ModelType type) { |
245 DCHECK_EQ(syncer::SUPERVISED_USER_SETTINGS, type); | 333 DCHECK_EQ(syncer::SUPERVISED_USER_SETTINGS, type); |
246 sync_processor_.reset(); | 334 sync_processor_.reset(); |
247 error_handler_.reset(); | 335 error_handler_.reset(); |
248 } | 336 } |
249 | 337 |
250 SyncDataList SupervisedUserSettingsService::GetAllSyncData( | 338 SyncDataList SupervisedUserSettingsService::GetAllSyncData( |
251 ModelType type) const { | 339 ModelType type) const { |
252 DCHECK_EQ(syncer::SUPERVISED_USER_SETTINGS, type); | 340 DCHECK_EQ(syncer::SUPERVISED_USER_SETTINGS, type); |
253 SyncDataList data; | 341 SyncDataList data; |
254 for (base::DictionaryValue::Iterator it(*GetAtomicSettings()); !it.IsAtEnd(); | 342 for (base::DictionaryValue::Iterator it(*GetAtomicSettings()); !it.IsAtEnd(); |
255 it.Advance()) { | 343 it.Advance()) { |
256 data.push_back(CreateSyncDataForSetting(it.key(), it.value())); | 344 data.push_back(CreateSyncDataForSetting(it.key(), it.value())); |
257 } | 345 } |
258 for (base::DictionaryValue::Iterator it(*GetSplitSettings()); !it.IsAtEnd(); | 346 for (base::DictionaryValue::Iterator it(*GetSplitSettings()); !it.IsAtEnd(); |
259 it.Advance()) { | 347 it.Advance()) { |
260 const base::DictionaryValue* dict = NULL; | 348 const base::DictionaryValue* dict = nullptr; |
261 it.value().GetAsDictionary(&dict); | 349 it.value().GetAsDictionary(&dict); |
262 for (base::DictionaryValue::Iterator jt(*dict); | 350 for (base::DictionaryValue::Iterator jt(*dict); |
263 !jt.IsAtEnd(); jt.Advance()) { | 351 !jt.IsAtEnd(); jt.Advance()) { |
264 data.push_back(CreateSyncDataForSetting( | 352 data.push_back(CreateSyncDataForSetting( |
265 MakeSplitSettingKey(it.key(), jt.key()), jt.value())); | 353 MakeSplitSettingKey(it.key(), jt.key()), jt.value())); |
266 } | 354 } |
267 } | 355 } |
268 DCHECK_EQ(0u, GetQueuedItems()->size()); | 356 DCHECK_EQ(0u, GetQueuedItems()->size()); |
269 return data; | 357 return data; |
270 } | 358 } |
(...skipping 20 matching lines...) Expand all Loading... |
291 } else { | 379 } else { |
292 DLOG_IF(WARNING, change_type == SyncChange::ACTION_UPDATE) | 380 DLOG_IF(WARNING, change_type == SyncChange::ACTION_UPDATE) |
293 << "Value for key " << key << " doesn't exist yet"; | 381 << "Value for key " << key << " doesn't exist yet"; |
294 } | 382 } |
295 dict->SetWithoutPathExpansion(key, value.release()); | 383 dict->SetWithoutPathExpansion(key, value.release()); |
296 break; | 384 break; |
297 } | 385 } |
298 case SyncChange::ACTION_DELETE: { | 386 case SyncChange::ACTION_DELETE: { |
299 DLOG_IF(WARNING, !dict->HasKey(key)) << "Trying to delete nonexistent " | 387 DLOG_IF(WARNING, !dict->HasKey(key)) << "Trying to delete nonexistent " |
300 << "key " << key; | 388 << "key " << key; |
301 dict->RemoveWithoutPathExpansion(key, NULL); | 389 dict->RemoveWithoutPathExpansion(key, nullptr); |
302 break; | 390 break; |
303 } | 391 } |
304 case SyncChange::ACTION_INVALID: { | 392 case SyncChange::ACTION_INVALID: { |
305 NOTREACHED(); | 393 NOTREACHED(); |
306 break; | 394 break; |
307 } | 395 } |
308 } | 396 } |
309 } | 397 } |
310 store_->ReportValueChanged(kAtomicSettings, | 398 store_->ReportValueChanged(kAtomicSettings, |
311 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 399 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
(...skipping 18 matching lines...) Expand all Loading... |
330 } | 418 } |
331 | 419 |
332 // TODO(bauerb): Temporary CHECK while investigating https://crbug.com/425785. | 420 // TODO(bauerb): Temporary CHECK while investigating https://crbug.com/425785. |
333 // Remove (or change back to DCHECK) once the bug is fixed. | 421 // Remove (or change back to DCHECK) once the bug is fixed. |
334 CHECK(IsReady()); | 422 CHECK(IsReady()); |
335 InformSubscribers(); | 423 InformSubscribers(); |
336 } | 424 } |
337 | 425 |
338 base::DictionaryValue* SupervisedUserSettingsService::GetOrCreateDictionary( | 426 base::DictionaryValue* SupervisedUserSettingsService::GetOrCreateDictionary( |
339 const std::string& key) const { | 427 const std::string& key) const { |
340 base::Value* value = NULL; | 428 base::Value* value = nullptr; |
341 base::DictionaryValue* dict = NULL; | 429 base::DictionaryValue* dict = nullptr; |
342 if (store_->GetMutableValue(key, &value)) { | 430 if (store_->GetMutableValue(key, &value)) { |
343 bool success = value->GetAsDictionary(&dict); | 431 bool success = value->GetAsDictionary(&dict); |
344 DCHECK(success); | 432 DCHECK(success); |
345 } else { | 433 } else { |
346 dict = new base::DictionaryValue; | 434 dict = new base::DictionaryValue; |
347 store_->SetValue(key, make_scoped_ptr(dict), | 435 store_->SetValue(key, make_scoped_ptr(dict), |
348 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 436 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
349 } | 437 } |
350 | 438 |
351 return dict; | 439 return dict; |
(...skipping 13 matching lines...) Expand all Loading... |
365 } | 453 } |
366 | 454 |
367 base::DictionaryValue* SupervisedUserSettingsService::GetDictionaryAndSplitKey( | 455 base::DictionaryValue* SupervisedUserSettingsService::GetDictionaryAndSplitKey( |
368 std::string* key) const { | 456 std::string* key) const { |
369 size_t pos = key->find_first_of(kSplitSettingKeySeparator); | 457 size_t pos = key->find_first_of(kSplitSettingKeySeparator); |
370 if (pos == std::string::npos) | 458 if (pos == std::string::npos) |
371 return GetAtomicSettings(); | 459 return GetAtomicSettings(); |
372 | 460 |
373 base::DictionaryValue* split_settings = GetSplitSettings(); | 461 base::DictionaryValue* split_settings = GetSplitSettings(); |
374 std::string prefix = key->substr(0, pos); | 462 std::string prefix = key->substr(0, pos); |
375 base::DictionaryValue* dict = NULL; | 463 base::DictionaryValue* dict = nullptr; |
376 if (!split_settings->GetDictionary(prefix, &dict)) { | 464 if (!split_settings->GetDictionary(prefix, &dict)) { |
377 dict = new base::DictionaryValue; | 465 dict = new base::DictionaryValue; |
378 DCHECK(!split_settings->HasKey(prefix)); | 466 DCHECK(!split_settings->HasKey(prefix)); |
379 split_settings->Set(prefix, dict); | 467 split_settings->Set(prefix, dict); |
380 } | 468 } |
381 key->erase(0, pos + 1); | 469 key->erase(0, pos + 1); |
382 return dict; | 470 return dict; |
383 } | 471 } |
384 | 472 |
385 scoped_ptr<base::DictionaryValue> SupervisedUserSettingsService::GetSettings() { | 473 scoped_ptr<base::DictionaryValue> SupervisedUserSettingsService::GetSettings() { |
(...skipping 24 matching lines...) Expand all Loading... |
410 return settings; | 498 return settings; |
411 } | 499 } |
412 | 500 |
413 void SupervisedUserSettingsService::InformSubscribers() { | 501 void SupervisedUserSettingsService::InformSubscribers() { |
414 if (!IsReady()) | 502 if (!IsReady()) |
415 return; | 503 return; |
416 | 504 |
417 scoped_ptr<base::DictionaryValue> settings = GetSettings(); | 505 scoped_ptr<base::DictionaryValue> settings = GetSettings(); |
418 callback_list_.Notify(settings.get()); | 506 callback_list_.Notify(settings.get()); |
419 } | 507 } |
OLD | NEW |