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

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: Addressed review comments, removed blacklist from extension ID list, added unittest. 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
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..cc2b95755c53298464fc20538e488dd6a00f02fd
--- /dev/null
+++ b/chrome/browser/protector/protected_prefs_watcher.h
@@ -0,0 +1,80 @@
+// 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);
+ ~ProtectedPrefsWatcher();
+
+ // Registers prefs on a new Profile instance.
+ static void RegisterUserPrefs(PrefService* prefs);
+
+ // Perform a check that backup is valid and settings have not been modified.
+ // TODO(ivankr): currently this is a stub that simply updates the backup.
+ void ValidatePrefs();
+
+ // 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;
+
+ // Returns |true| if backup signature is valid.
+ bool IsSignatureValid() const;
+
+ // Returns |false| if profile does not have a backup yet (needs to be
+ // initialized).
+ bool HasBackup() const;
+
+ private:
+ // content::NotificationObserver overrides:
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ // Updates cached prefs from their actual values and returns |true| if there
+ // were any changes.
+ bool UpdateCachedPrefs();
+
+ // Update the backup signature.
+ void UpdateBackupSignature();
+
+ // 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_;
+
+ bool did_startup_settings_change_;
+
+ Profile* profile_;
+
+ DISALLOW_COPY_AND_ASSIGN(ProtectedPrefsWatcher);
+};
+
+} // namespace protector
+
+#endif // CHROME_BROWSER_PROTECTOR_PROTECTED_PREFS_WATCHER_H_

Powered by Google App Engine
This is Rietveld 408576698