| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/managed_mode/managed_user_settings_service.h" | 5 #include "chrome/browser/managed_mode/managed_user_settings_service.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/prefs/json_pref_store.h" | 10 #include "base/prefs/json_pref_store.h" |
| 11 #include "base/prefs/pref_filter.h" |
| 11 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 12 #include "base/threading/sequenced_worker_pool.h" | 13 #include "base/threading/sequenced_worker_pool.h" |
| 13 #include "chrome/browser/managed_mode/managed_mode_url_filter.h" | 14 #include "chrome/browser/managed_mode/managed_mode_url_filter.h" |
| 14 #include "chrome/common/chrome_constants.h" | 15 #include "chrome/common/chrome_constants.h" |
| 15 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/browser/user_metrics.h" | 17 #include "content/public/browser/user_metrics.h" |
| 17 #include "sync/api/sync_change.h" | 18 #include "sync/api/sync_change.h" |
| 18 #include "sync/api/sync_error_factory.h" | 19 #include "sync/api/sync_error_factory.h" |
| 19 #include "sync/protocol/sync.pb.h" | 20 #include "sync/protocol/sync.pb.h" |
| 20 | 21 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 : active_(false), local_settings_(new base::DictionaryValue) {} | 53 : active_(false), local_settings_(new base::DictionaryValue) {} |
| 53 | 54 |
| 54 ManagedUserSettingsService::~ManagedUserSettingsService() {} | 55 ManagedUserSettingsService::~ManagedUserSettingsService() {} |
| 55 | 56 |
| 56 void ManagedUserSettingsService::Init( | 57 void ManagedUserSettingsService::Init( |
| 57 base::FilePath profile_path, | 58 base::FilePath profile_path, |
| 58 base::SequencedTaskRunner* sequenced_task_runner, | 59 base::SequencedTaskRunner* sequenced_task_runner, |
| 59 bool load_synchronously) { | 60 bool load_synchronously) { |
| 60 base::FilePath path = | 61 base::FilePath path = |
| 61 profile_path.Append(chrome::kManagedUserSettingsFilename); | 62 profile_path.Append(chrome::kManagedUserSettingsFilename); |
| 62 PersistentPrefStore* store = new JsonPrefStore(path, sequenced_task_runner); | 63 PersistentPrefStore* store = new JsonPrefStore( |
| 64 path, sequenced_task_runner, scoped_ptr<PrefFilter>()); |
| 63 Init(store); | 65 Init(store); |
| 64 if (load_synchronously) | 66 if (load_synchronously) |
| 65 store_->ReadPrefs(); | 67 store_->ReadPrefs(); |
| 66 else | 68 else |
| 67 store_->ReadPrefsAsync(NULL); | 69 store_->ReadPrefsAsync(NULL); |
| 68 } | 70 } |
| 69 | 71 |
| 70 void ManagedUserSettingsService::Init( | 72 void ManagedUserSettingsService::Init( |
| 71 scoped_refptr<PersistentPrefStore> store) { | 73 scoped_refptr<PersistentPrefStore> store) { |
| 72 DCHECK(!store_); | 74 DCHECK(!store_); |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 void ManagedUserSettingsService::InformSubscribers() { | 374 void ManagedUserSettingsService::InformSubscribers() { |
| 373 if (!IsReady()) | 375 if (!IsReady()) |
| 374 return; | 376 return; |
| 375 | 377 |
| 376 scoped_ptr<base::DictionaryValue> settings = GetSettings(); | 378 scoped_ptr<base::DictionaryValue> settings = GetSettings(); |
| 377 for (std::vector<SettingsCallback>::iterator it = subscribers_.begin(); | 379 for (std::vector<SettingsCallback>::iterator it = subscribers_.begin(); |
| 378 it != subscribers_.end(); ++it) { | 380 it != subscribers_.end(); ++it) { |
| 379 it->Run(settings.get()); | 381 it->Run(settings.get()); |
| 380 } | 382 } |
| 381 } | 383 } |
| OLD | NEW |