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

Side by Side Diff: chrome/browser/protector/protector_service.h

Issue 9968007: [protector] Support for collapsing multiple changes into a single one. (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 #ifndef CHROME_BROWSER_PROTECTOR_PROTECTOR_SERVICE_H_ 5 #ifndef CHROME_BROWSER_PROTECTOR_PROTECTOR_SERVICE_H_
6 #define CHROME_BROWSER_PROTECTOR_PROTECTOR_SERVICE_H_ 6 #define CHROME_BROWSER_PROTECTOR_PROTECTOR_SERVICE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 // Returns the most recent change instance or NULL if there are no changes. 65 // Returns the most recent change instance or NULL if there are no changes.
66 BaseSettingChange* GetLastChange(); 66 BaseSettingChange* GetLastChange();
67 67
68 // Returns the Profile instance for this service. 68 // Returns the Profile instance for this service.
69 Profile* profile() { return profile_; } 69 Profile* profile() { return profile_; }
70 70
71 private: 71 private:
72 friend class ProtectorServiceTest; 72 friend class ProtectorServiceTest;
73 73
74 // Pair of error and corresponding change instance. linked_ptr is used because 74 // Each item consists of an error and corresponding change instance.
75 // Item instances are stored in a std::vector and must be copyable. 75 // linked_ptr is used because Item instances are stored in a std::vector and
76 // must be copyable.
76 struct Item { 77 struct Item {
77 Item(); 78 Item();
78 ~Item(); 79 ~Item();
79 linked_ptr<BaseSettingChange> change; 80 linked_ptr<BaseSettingChange> change;
80 linked_ptr<SettingsChangeGlobalError> error; 81 linked_ptr<SettingsChangeGlobalError> error;
82 // When true, this means |change| was merged with another instance and
83 // |error| is in process of being removed from GlobalErrorService.
84 bool was_merged;
85 // Meaningful only when |was_merged| is true. In that case, true means that
86 // the new merged GlobalError instance will be immediately shown.
87 bool show_when_merged;
81 }; 88 };
82 89
90 typedef std::vector<Item> Items;
91
83 // Matches Item by |change| field. 92 // Matches Item by |change| field.
84 class MatchItemByChange { 93 class MatchItemByChange {
85 public: 94 public:
86 explicit MatchItemByChange(const BaseSettingChange* other); 95 explicit MatchItemByChange(const BaseSettingChange* other);
87 96
88 bool operator()(const Item& item); 97 bool operator()(const Item& item);
89 98
90 private: 99 private:
91 const BaseSettingChange* other_; 100 const BaseSettingChange* other_;
92 }; 101 };
93 102
94 // Matches Item by |error| field. 103 // Matches Item by |error| field.
95 class MatchItemByError { 104 class MatchItemByError {
96 public: 105 public:
97 explicit MatchItemByError(const SettingsChangeGlobalError* other); 106 explicit MatchItemByError(const SettingsChangeGlobalError* other);
98 107
99 bool operator()(const Item& item); 108 bool operator()(const Item& item);
100 109
101 private: 110 private:
102 const SettingsChangeGlobalError* other_; 111 const SettingsChangeGlobalError* other_;
103 }; 112 };
104 113
114 // Returns an Item instance whose change can be merged with |change|, if any.
115 // Otherwise returns |NULL|. Provided that the merge strategy is transitive,
116 // there can be only one such instance.
117 Item* FindItemToMergeWith(const BaseSettingChange* change);
118
105 // ProfileKeyedService implementation. 119 // ProfileKeyedService implementation.
106 virtual void Shutdown() OVERRIDE; 120 virtual void Shutdown() OVERRIDE;
107 121
108 // SettingsChangeGlobalErrorDelegate implementation. 122 // SettingsChangeGlobalErrorDelegate implementation.
109 virtual void OnApplyChange(SettingsChangeGlobalError* error, 123 virtual void OnApplyChange(SettingsChangeGlobalError* error,
110 Browser* browser) OVERRIDE; 124 Browser* browser) OVERRIDE;
111 virtual void OnDiscardChange(SettingsChangeGlobalError* error, 125 virtual void OnDiscardChange(SettingsChangeGlobalError* error,
112 Browser* browser) OVERRIDE; 126 Browser* browser) OVERRIDE;
113 virtual void OnDecisionTimeout(SettingsChangeGlobalError* error) OVERRIDE; 127 virtual void OnDecisionTimeout(SettingsChangeGlobalError* error) OVERRIDE;
114 virtual void OnRemovedFromProfile(SettingsChangeGlobalError* error) OVERRIDE; 128 virtual void OnRemovedFromProfile(SettingsChangeGlobalError* error) OVERRIDE;
115 129
116 // Pointers to error bubble controllers and corresponding changes in the order 130 // Pointers to error bubble controllers and corresponding changes in the order
117 // added. 131 // added.
118 std::vector<Item> items_; 132 Items items_;
119 133
120 // Profile which settings we are protecting. 134 // Profile which settings we are protecting.
121 Profile* profile_; 135 Profile* profile_;
122 136
123 // True if there is a change that has been shown and not yet accepted or 137 // True if there is a change that has been shown and not yet accepted or
124 // discarded by user. 138 // discarded by user.
125 bool has_active_change_; 139 bool has_active_change_;
126 140
127 // Observes changes to protected prefs and updates the backup. 141 // Observes changes to protected prefs and updates the backup.
128 scoped_ptr<ProtectedPrefsWatcher> prefs_watcher_; 142 scoped_ptr<ProtectedPrefsWatcher> prefs_watcher_;
129 143
130 DISALLOW_COPY_AND_ASSIGN(ProtectorService); 144 DISALLOW_COPY_AND_ASSIGN(ProtectorService);
131 }; 145 };
132 146
133 } // namespace protector 147 } // namespace protector
134 148
135 #endif // CHROME_BROWSER_PROTECTOR_PROTECTOR_SERVICE_H_ 149 #endif // CHROME_BROWSER_PROTECTOR_PROTECTOR_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/protector/prefs_backup_invalid_change.cc ('k') | chrome/browser/protector/protector_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698