| 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 } | 188 } |
| 189 | 189 |
| 190 void ProtectedPrefsWatcher::ForceUpdateBackup() { | 190 void ProtectedPrefsWatcher::ForceUpdateBackup() { |
| 191 UMA_HISTOGRAM_ENUMERATION( | 191 UMA_HISTOGRAM_ENUMERATION( |
| 192 kProtectorHistogramPrefs, | 192 kProtectorHistogramPrefs, |
| 193 kProtectorErrorForcedUpdate, | 193 kProtectorErrorForcedUpdate, |
| 194 kProtectorErrorCount); | 194 kProtectorErrorCount); |
| 195 InitBackup(); | 195 InitBackup(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void ProtectedPrefsWatcher::Observe( | 198 void ProtectedPrefsWatcher::OnPreferenceChanged(PrefServiceBase* service, |
| 199 int type, | 199 const std::string& pref_name) { |
| 200 const content::NotificationSource& source, | 200 DCHECK(pref_observer_.IsObserved(pref_name)); |
| 201 const content::NotificationDetails& details) { | 201 if (UpdateBackupEntry(pref_name)) |
| 202 DCHECK(type == chrome::NOTIFICATION_PREF_CHANGED); | |
| 203 const std::string* pref_name = content::Details<std::string>(details).ptr(); | |
| 204 DCHECK(pref_name && pref_observer_.IsObserved(*pref_name)); | |
| 205 if (UpdateBackupEntry(*pref_name)) | |
| 206 UpdateBackupSignature(); | 202 UpdateBackupSignature(); |
| 207 } | 203 } |
| 208 | 204 |
| 209 void ProtectedPrefsWatcher::EnsurePrefsMigration() { | 205 void ProtectedPrefsWatcher::EnsurePrefsMigration() { |
| 210 SessionStartupPref::MigrateIfNecessary(profile_->GetPrefs()); | 206 SessionStartupPref::MigrateIfNecessary(profile_->GetPrefs()); |
| 211 } | 207 } |
| 212 | 208 |
| 213 bool ProtectedPrefsWatcher::UpdateCachedPrefs() { | 209 bool ProtectedPrefsWatcher::UpdateCachedPrefs() { |
| 214 // ExtensionService may not yet have been initialized, so using static method | 210 // ExtensionService may not yet have been initialized, so using static method |
| 215 // exposed for this purpose. | 211 // exposed for this purpose. |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 NOTREACHED(); | 388 NOTREACHED(); |
| 393 continue; | 389 continue; |
| 394 } | 390 } |
| 395 StringAppendStringDictionary(tab, &data); | 391 StringAppendStringDictionary(tab, &data); |
| 396 } | 392 } |
| 397 } | 393 } |
| 398 return data; | 394 return data; |
| 399 } | 395 } |
| 400 | 396 |
| 401 } // namespace protector | 397 } // namespace protector |
| OLD | NEW |