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

Side by Side Diff: chrome/browser/protector/protected_prefs_watcher.cc

Issue 10065016: [protector] Refactoring of --no-protector code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 8 years, 8 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 | Annotate | Revision Log
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 #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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 79 }
80 80
81 ProtectedPrefsWatcher::~ProtectedPrefsWatcher() { 81 ProtectedPrefsWatcher::~ProtectedPrefsWatcher() {
82 } 82 }
83 83
84 // static 84 // static
85 void ProtectedPrefsWatcher::RegisterUserPrefs(PrefService* prefs) { 85 void ProtectedPrefsWatcher::RegisterUserPrefs(PrefService* prefs) {
86 prefs->RegisterStringPref(kBackupHomePage, "", 86 prefs->RegisterStringPref(kBackupHomePage, "",
87 PrefService::UNSYNCABLE_PREF); 87 PrefService::UNSYNCABLE_PREF);
88 prefs->RegisterBooleanPref(kBackupHomePageIsNewTabPage, false, 88 prefs->RegisterBooleanPref(kBackupHomePageIsNewTabPage, false,
89 PrefService::UNSYNCABLE_PREF); 89 PrefService::UNSYNCABLE_PREF);
90 prefs->RegisterBooleanPref(kBackupShowHomeButton, false, 90 prefs->RegisterBooleanPref(kBackupShowHomeButton, false,
91 PrefService::UNSYNCABLE_PREF); 91 PrefService::UNSYNCABLE_PREF);
92 prefs->RegisterIntegerPref(kBackupRestoreOnStartup, 0, 92 prefs->RegisterIntegerPref(kBackupRestoreOnStartup, 0,
93 PrefService::UNSYNCABLE_PREF); 93 PrefService::UNSYNCABLE_PREF);
94 prefs->RegisterListPref(kBackupURLsToRestoreOnStartup, 94 prefs->RegisterListPref(kBackupURLsToRestoreOnStartup,
95 PrefService::UNSYNCABLE_PREF); 95 PrefService::UNSYNCABLE_PREF);
96 prefs->RegisterListPref(kBackupPinnedTabs, 96 prefs->RegisterListPref(kBackupPinnedTabs,
97 PrefService::UNSYNCABLE_PREF); 97 PrefService::UNSYNCABLE_PREF);
98 prefs->RegisterListPref(kBackupExtensionsIDs, 98 prefs->RegisterListPref(kBackupExtensionsIDs,
99 PrefService::UNSYNCABLE_PREF); 99 PrefService::UNSYNCABLE_PREF);
(...skipping 24 matching lines...) Expand all
124 std::string backup_path = std::string(kBackupPrefsPrefix) + path; 124 std::string backup_path = std::string(kBackupPrefsPrefix) + path;
125 const PrefService::Preference* backup_pref = 125 const PrefService::Preference* backup_pref =
126 profile_->GetPrefs()->FindPreference(backup_path.c_str()); 126 profile_->GetPrefs()->FindPreference(backup_path.c_str());
127 DCHECK(backup_pref && 127 DCHECK(backup_pref &&
128 // These do not directly correspond to any real preference. 128 // These do not directly correspond to any real preference.
129 backup_path != kBackupExtensionsIDs && 129 backup_path != kBackupExtensionsIDs &&
130 backup_path != kBackupSignature); 130 backup_path != kBackupSignature);
131 return backup_pref->GetValue(); 131 return backup_pref->GetValue();
132 } 132 }
133 133
134 void ProtectedPrefsWatcher::ForceUpdateBackup() {
135 UMA_HISTOGRAM_ENUMERATION(
136 kProtectorHistogramPrefs,
137 kProtectorErrorForcedUpdate,
138 kProtectorErrorCount);
139 InitBackup();
140 }
141
134 void ProtectedPrefsWatcher::Observe( 142 void ProtectedPrefsWatcher::Observe(
135 int type, 143 int type,
136 const content::NotificationSource& source, 144 const content::NotificationSource& source,
137 const content::NotificationDetails& details) { 145 const content::NotificationDetails& details) {
138 DCHECK(type == chrome::NOTIFICATION_PREF_CHANGED); 146 DCHECK(type == chrome::NOTIFICATION_PREF_CHANGED);
139 const std::string* pref_name = content::Details<std::string>(details).ptr(); 147 const std::string* pref_name = content::Details<std::string>(details).ptr();
140 DCHECK(pref_name && pref_observer_->IsObserved(*pref_name)); 148 DCHECK(pref_name && pref_observer_->IsObserved(*pref_name));
141 if (UpdateBackupEntry(*pref_name)) 149 if (UpdateBackupEntry(*pref_name))
142 UpdateBackupSignature(); 150 UpdateBackupSignature();
143 } 151 }
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 NOTREACHED(); 332 NOTREACHED();
325 continue; 333 continue;
326 } 334 }
327 StringAppendStringDictionary(tab, &data); 335 StringAppendStringDictionary(tab, &data);
328 } 336 }
329 } 337 }
330 return data; 338 return data;
331 } 339 }
332 340
333 } // namespace protector 341 } // namespace protector
OLDNEW
« no previous file with comments | « chrome/browser/protector/protected_prefs_watcher.h ('k') | chrome/browser/protector/protector_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698