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

Unified Diff: chrome/browser/protector/protected_prefs_watcher.h

Issue 9620010: Added Protector backup for Preferences. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reupload Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/protector/histograms.cc ('k') | chrome/browser/protector/protected_prefs_watcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/protector/protected_prefs_watcher.h
diff --git a/chrome/browser/protector/protected_prefs_watcher.h b/chrome/browser/protector/protected_prefs_watcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..5316fc685e830c80c4296212142f1063afbeb6c5
--- /dev/null
+++ b/chrome/browser/protector/protected_prefs_watcher.h
@@ -0,0 +1,96 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_PROTECTOR_PROTECTED_PREFS_WATCHER_H_
+#define CHROME_BROWSER_PROTECTOR_PROTECTED_PREFS_WATCHER_H_
+#pragma once
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/extensions/extension_prefs.h"
+#include "content/public/browser/notification_observer.h"
+
+class PrefService;
+class PrefSetObserver;
+class Profile;
+
+namespace base {
+class Value;
+}
+
+namespace protector {
+
+class ProtectedPrefsWatcher : public content::NotificationObserver {
+ public:
+ explicit ProtectedPrefsWatcher(Profile* profile);
+ virtual ~ProtectedPrefsWatcher();
+
+ // Registers prefs on a new Profile instance.
+ static void RegisterUserPrefs(PrefService* prefs);
+
+ // Returns the backup value for pref named |path| or |NULL| if the pref is
+ // not protected or does not exist. The returned Value instance is owned by
+ // the PrefService.
+ const base::Value* GetBackupForPref(const std::string& path) const;
+
+ // True if the backup was valid at the profile load time.
+ bool is_backup_valid() { return is_backup_valid_; }
+
+ private:
+ friend class ProtectedPrefsWatcherTest;
+
+ // content::NotificationObserver overrides:
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ // Makes sure that all protected prefs have been migrated before starting to
+ // observe them.
+ void EnsurePrefsMigration();
+
+ // Updates cached prefs from their actual values and returns |true| if there
+ // were any changes.
+ bool UpdateCachedPrefs();
+
+ // Returns |false| if profile does not have a backup yet (needs to be
+ // initialized).
+ bool HasBackup() const;
+
+ // Creates initial backup entries.
+ void InitBackup();
+
+ // Updates the backup утекн for |pref_name| and кeturns |true| if the
+ // backup has changed.
+ bool UpdateBackupEntry(const std::string& pref_name);
+
+ // Updates the backup signature.
+ void UpdateBackupSignature();
+
+ // Perform a check that backup is valid and settings have not been modified.
+ void ValidateBackup();
+
+ // Returns |true| if backup signature is valid.
+ bool IsSignatureValid() const;
+
+ // Returns data to be signed as string.
+ std::string GetSignatureData(PrefService* prefs) const;
+
+ // Cached set of extension IDs. They are not changed as frequently
+ ExtensionPrefs::ExtensionIdSet cached_extension_ids_;
+
+ scoped_ptr<PrefSetObserver> pref_observer_;
+
+ // True if the backup was valid at the profile load time.
+ bool is_backup_valid_;
+
+ Profile* profile_;
+
+ DISALLOW_COPY_AND_ASSIGN(ProtectedPrefsWatcher);
+};
+
+} // namespace protector
+
+#endif // CHROME_BROWSER_PROTECTOR_PROTECTED_PREFS_WATCHER_H_
« no previous file with comments | « chrome/browser/protector/histograms.cc ('k') | chrome/browser/protector/protected_prefs_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698