| 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 #include "chrome/browser/protector/protected_prefs_watcher.h" | 5 #include "chrome/browser/protector/protected_prefs_watcher.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 DCHECK(pref_name && pref_observer_->IsObserved(*pref_name)); | 193 DCHECK(pref_name && pref_observer_->IsObserved(*pref_name)); |
| 194 if (UpdateBackupEntry(*pref_name)) | 194 if (UpdateBackupEntry(*pref_name)) |
| 195 UpdateBackupSignature(); | 195 UpdateBackupSignature(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void ProtectedPrefsWatcher::EnsurePrefsMigration() { | 198 void ProtectedPrefsWatcher::EnsurePrefsMigration() { |
| 199 SessionStartupPref::MigrateIfNecessary(profile_->GetPrefs()); | 199 SessionStartupPref::MigrateIfNecessary(profile_->GetPrefs()); |
| 200 } | 200 } |
| 201 | 201 |
| 202 bool ProtectedPrefsWatcher::UpdateCachedPrefs() { | 202 bool ProtectedPrefsWatcher::UpdateCachedPrefs() { |
| 203 // Direct access to the extensions prefs is required becase ExtensionService | 203 // ExtensionService may not yet have been initialized, so using static method |
| 204 // may not yet have been initialized. | 204 // exposed for this purpose. |
| 205 const base::DictionaryValue* extension_prefs; | |
| 206 const base::Value* extension_prefs_value = | |
| 207 profile_->GetPrefs()->GetUserPrefValue(ExtensionPrefs::kExtensionsPref); | |
| 208 if (!extension_prefs_value || | |
| 209 !extension_prefs_value->GetAsDictionary(&extension_prefs)) { | |
| 210 return false; | |
| 211 } | |
| 212 ExtensionPrefs::ExtensionIds extension_ids = | 205 ExtensionPrefs::ExtensionIds extension_ids = |
| 213 ExtensionPrefs::GetExtensionsFrom(extension_prefs); | 206 ExtensionPrefs::GetExtensionsFrom(profile_->GetPrefs()); |
| 214 if (extension_ids == cached_extension_ids_) | 207 if (extension_ids == cached_extension_ids_) |
| 215 return false; | 208 return false; |
| 216 cached_extension_ids_.swap(extension_ids); | 209 cached_extension_ids_.swap(extension_ids); |
| 217 return true; | 210 return true; |
| 218 } | 211 } |
| 219 | 212 |
| 220 bool ProtectedPrefsWatcher::HasBackup() const { | 213 bool ProtectedPrefsWatcher::HasBackup() const { |
| 221 // TODO(ivankr): as soon as some irreversible change to Preferences happens, | 214 // TODO(ivankr): as soon as some irreversible change to Preferences happens, |
| 222 // add a condition that this change has occured as well (otherwise it's | 215 // add a condition that this change has occured as well (otherwise it's |
| 223 // possible to simply clear the "backup" dictionary to make settings | 216 // possible to simply clear the "backup" dictionary to make settings |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 NOTREACHED(); | 381 NOTREACHED(); |
| 389 continue; | 382 continue; |
| 390 } | 383 } |
| 391 StringAppendStringDictionary(tab, &data); | 384 StringAppendStringDictionary(tab, &data); |
| 392 } | 385 } |
| 393 } | 386 } |
| 394 return data; | 387 return data; |
| 395 } | 388 } |
| 396 | 389 |
| 397 } // namespace protector | 390 } // namespace protector |
| OLD | NEW |