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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_PROTECTOR_PROTECTED_PREFS_WATCHER_H_
6 #define CHROME_BROWSER_PROTECTOR_PROTECTED_PREFS_WATCHER_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/extensions/extension_prefs.h"
14 #include "content/public/browser/notification_observer.h"
15
16 class PrefService;
17 class PrefSetObserver;
18 class Profile;
19
20 namespace base {
21 class Value;
22 }
23
24 namespace protector {
25
26 class ProtectedPrefsWatcher : public content::NotificationObserver {
27 public:
28 explicit ProtectedPrefsWatcher(Profile* profile);
29 ~ProtectedPrefsWatcher();
30
31 // Registers prefs on a new Profile instance.
32 static void RegisterUserPrefs(PrefService* prefs);
33
34 // Perform a check that backup is valid and settings have not been modified.
35 // TODO(ivankr): currently this is a stub that simply updates the backup.
36 void ValidatePrefs();
37
38 // Returns the backup value for pref named |path| or |NULL| if the pref is
39 // not protected or does not exist. The returned Value instance is owned by
40 // the PrefService.
41 const base::Value* GetBackupForPref(const std::string& path) const;
42
43 // Returns |true| if backup signature is valid.
44 bool IsSignatureValid() const;
45
46 // Returns |false| if profile does not have a backup yet (needs to be
47 // initialized).
48 bool HasBackup() const;
49
50 private:
51 // content::NotificationObserver overrides:
52 virtual void Observe(int type,
53 const content::NotificationSource& source,
54 const content::NotificationDetails& details) OVERRIDE;
55
56 // Updates cached prefs from their actual values and returns |true| if there
57 // were any changes.
58 bool UpdateCachedPrefs();
59
60 // Update the backup signature.
61 void UpdateBackupSignature();
62
63 // Returns data to be signed as string.
64 std::string GetSignatureData(PrefService* prefs) const;
65
66 // Cached set of extension IDs. They are not changed as frequently
67 ExtensionPrefs::ExtensionIdSet cached_extension_ids_;
68
69 scoped_ptr<PrefSetObserver> pref_observer_;
70
71 bool did_startup_settings_change_;
72
73 Profile* profile_;
74
75 DISALLOW_COPY_AND_ASSIGN(ProtectedPrefsWatcher);
76 };
77
78 } // namespace protector
79
80 #endif // CHROME_BROWSER_PROTECTOR_PROTECTED_PREFS_WATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698