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

Side by Side Diff: chrome/browser/browsing_data/browsing_data_remover.h

Issue 2697123004: Convert RemoveDataMask from enum to pointers and split it between content and embedder (Closed)
Patch Set: Android compilation Created 3 years, 10 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ 5 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_
6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ 6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <set>
10
9 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
10 #include "base/time/time.h" 12 #include "base/time/time.h"
11 #include "build/build_config.h"
12 #include "chrome/browser/browsing_data/browsing_data_remover_delegate.h" 13 #include "chrome/browser/browsing_data/browsing_data_remover_delegate.h"
14 #include "content/public/browser/browsing_data_types.h"
13 15
14 namespace content { 16 namespace content {
15 class BrowsingDataFilterBuilder; 17 class BrowsingDataFilterBuilder;
18 struct BrowsingDataType;
16 } 19 }
17 20
18 //////////////////////////////////////////////////////////////////////////////// 21 ////////////////////////////////////////////////////////////////////////////////
19 // BrowsingDataRemover is responsible for removing data related to browsing: 22 // BrowsingDataRemover is responsible for removing data related to browsing:
20 // visits in url database, downloads, cookies ... 23 // visits in url database, downloads, cookies ...
21 // 24 //
22 // USAGE: 25 // USAGE:
23 // 26 //
24 // 0. Instantiation. 27 // 0. Instantiation.
25 // 28 //
(...skipping 19 matching lines...) Expand all
45 // LOG(INFO) << "Cookies were deleted."; 48 // LOG(INFO) << "Cookies were deleted.";
46 // } 49 // }
47 // } 50 // }
48 // 51 //
49 //////////////////////////////////////////////////////////////////////////////// 52 ////////////////////////////////////////////////////////////////////////////////
50 // 53 //
51 // TODO(crbug.com/668114): BrowsingDataRemover does not currently support plugin 54 // TODO(crbug.com/668114): BrowsingDataRemover does not currently support plugin
52 // data deletion. Use PluginDataRemover instead. 55 // data deletion. Use PluginDataRemover instead.
53 class BrowsingDataRemover { 56 class BrowsingDataRemover {
54 public: 57 public:
55 // Mask used for Remove.
56 enum RemoveDataMask {
57 REMOVE_APPCACHE = 1 << 0,
58 REMOVE_CACHE = 1 << 1,
59 REMOVE_COOKIES = 1 << 2,
60 REMOVE_DOWNLOADS = 1 << 3,
61 REMOVE_FILE_SYSTEMS = 1 << 4,
62 REMOVE_FORM_DATA = 1 << 5,
63 // In addition to visits, REMOVE_HISTORY removes keywords, last session and
64 // passwords UI statistics.
65 REMOVE_HISTORY = 1 << 6,
66 REMOVE_INDEXEDDB = 1 << 7,
67 REMOVE_LOCAL_STORAGE = 1 << 8,
68 REMOVE_PLUGIN_DATA = 1 << 9,
69 REMOVE_PASSWORDS = 1 << 10,
70 REMOVE_WEBSQL = 1 << 11,
71 REMOVE_CHANNEL_IDS = 1 << 12,
72 REMOVE_MEDIA_LICENSES = 1 << 13,
73 REMOVE_SERVICE_WORKERS = 1 << 14,
74 REMOVE_SITE_USAGE_DATA = 1 << 15,
75 // REMOVE_NOCHECKS intentionally does not check if the browser context is
76 // prohibited from deleting history or downloads.
77 REMOVE_NOCHECKS = 1 << 16,
78 REMOVE_CACHE_STORAGE = 1 << 17,
79 #if defined(OS_ANDROID)
80 REMOVE_WEBAPP_DATA = 1 << 18,
81 #endif
82 REMOVE_DURABLE_PERMISSION = 1 << 19,
83 REMOVE_EXTERNAL_PROTOCOL_DATA = 1 << 20,
84
85 // The following flag is used only in tests. In normal usage, hosted app
86 // data is controlled by the REMOVE_COOKIES flag, applied to the
87 // protected-web origin.
88 REMOVE_HOSTED_APP_DATA_TESTONLY = 1 << 31,
89
90 // "Site data" includes cookies, appcache, file systems, indexedDBs, local
91 // storage, webSQL, service workers, cache storage, plugin data, web app
92 // data (on Android) and statistics about passwords.
93 REMOVE_SITE_DATA = REMOVE_APPCACHE | REMOVE_COOKIES | REMOVE_FILE_SYSTEMS |
94 REMOVE_INDEXEDDB |
95 REMOVE_LOCAL_STORAGE |
96 REMOVE_PLUGIN_DATA |
97 REMOVE_SERVICE_WORKERS |
98 REMOVE_CACHE_STORAGE |
99 REMOVE_WEBSQL |
100 REMOVE_CHANNEL_IDS |
101 #if defined(OS_ANDROID)
102 REMOVE_WEBAPP_DATA |
103 #endif
104 REMOVE_SITE_USAGE_DATA |
105 REMOVE_DURABLE_PERMISSION |
106 REMOVE_EXTERNAL_PROTOCOL_DATA,
107
108 // Datatypes protected by Important Sites.
109 IMPORTANT_SITES_DATATYPES = REMOVE_SITE_DATA | REMOVE_CACHE,
110
111 // Datatypes that can be deleted partially per URL / origin / domain,
112 // whichever makes sense.
113 FILTERABLE_DATATYPES = REMOVE_SITE_DATA | REMOVE_CACHE | REMOVE_DOWNLOADS,
114
115 // Includes all the available remove options. Meant to be used by clients
116 // that wish to wipe as much data as possible from a Profile, to make it
117 // look like a new Profile.
118 REMOVE_ALL = REMOVE_SITE_DATA | REMOVE_CACHE | REMOVE_DOWNLOADS |
119 REMOVE_FORM_DATA |
120 REMOVE_HISTORY |
121 REMOVE_PASSWORDS |
122 REMOVE_MEDIA_LICENSES,
123
124 // Includes all available remove options. Meant to be used when the Profile
125 // is scheduled to be deleted, and all possible data should be wiped from
126 // disk as soon as possible.
127 REMOVE_WIPE_PROFILE = REMOVE_ALL | REMOVE_NOCHECKS,
128 };
129
130 // Important sites protect a small set of sites from the deletion of certain
131 // datatypes. Therefore, those datatypes must be filterable by
132 // url/origin/domain.
133 static_assert(0 == (IMPORTANT_SITES_DATATYPES & ~FILTERABLE_DATATYPES),
134 "All important sites datatypes must be filterable.");
135
136 // A helper enum to report the deletion of cookies and/or cache. Do not 58 // A helper enum to report the deletion of cookies and/or cache. Do not
137 // reorder the entries, as this enum is passed to UMA. 59 // reorder the entries, as this enum is passed to UMA.
138 enum CookieOrCacheDeletionChoice { 60 enum CookieOrCacheDeletionChoice {
139 NEITHER_COOKIES_NOR_CACHE, 61 NEITHER_COOKIES_NOR_CACHE,
140 ONLY_COOKIES, 62 ONLY_COOKIES,
141 ONLY_CACHE, 63 ONLY_CACHE,
142 BOTH_COOKIES_AND_CACHE, 64 BOTH_COOKIES_AND_CACHE,
143 MAX_CHOICE_VALUE 65 MAX_CHOICE_VALUE
144 }; 66 };
145 67
146 // Observer is notified when its own removal task is done. 68 // Observer is notified when its own removal task is done.
147 class Observer { 69 class Observer {
148 public: 70 public:
149 // Called when a removal task is finished. Note that every removal task can 71 // Called when a removal task is finished. Note that every removal task can
150 // only have one observer attached to it, and only that one is called. 72 // only have one observer attached to it, and only that one is called.
151 virtual void OnBrowsingDataRemoverDone() = 0; 73 virtual void OnBrowsingDataRemoverDone() = 0;
152 74
153 protected: 75 protected:
154 virtual ~Observer() {} 76 virtual ~Observer() {}
155 }; 77 };
156 78
157 // Called by the embedder to provide the delegate that will take care of 79 // Called by the embedder to provide the delegate that will take care of
158 // deleting embedder-specific data. 80 // deleting embedder-specific data.
159 virtual void SetEmbedderDelegate( 81 virtual void SetEmbedderDelegate(
160 std::unique_ptr<BrowsingDataRemoverDelegate> embedder_delegate) = 0; 82 std::unique_ptr<BrowsingDataRemoverDelegate> embedder_delegate) = 0;
161 virtual BrowsingDataRemoverDelegate* GetEmbedderDelegate() const = 0; 83 virtual BrowsingDataRemoverDelegate* GetEmbedderDelegate() const = 0;
162 84
163 // Removes browsing data within the given |time_range|, with datatypes being 85 // Removes browsing data within the given |time_range|, with datatypes being
164 // specified by |remove_mask| and origin types by |origin_type_mask|. 86 // specified by |remove_mask| and origin types by |origin_type_mask|.
165 virtual void Remove(const base::Time& delete_begin, 87 virtual void Remove(
166 const base::Time& delete_end, 88 const base::Time& delete_begin,
167 int remove_mask, 89 const base::Time& delete_end,
168 int origin_type_mask) = 0; 90 const std::set<const content::BrowsingDataType*>& remove_mask,
91 int origin_type_mask) = 0;
169 92
170 // A version of the above that in addition informs the |observer| when the 93 // A version of the above that in addition informs the |observer| when the
171 // removal task is finished. 94 // removal task is finished.
172 virtual void RemoveAndReply(const base::Time& delete_begin, 95 virtual void RemoveAndReply(
173 const base::Time& delete_end, 96 const base::Time& delete_begin,
174 int remove_mask, 97 const base::Time& delete_end,
175 int origin_type_mask, 98 const std::set<const content::BrowsingDataType*>& remove_mask,
176 Observer* observer) = 0; 99 int origin_type_mask,
100 Observer* observer) = 0;
177 101
178 // Like Remove(), but in case of URL-keyed only removes data whose URL match 102 // Like Remove(), but in case of URL-keyed only removes data whose URL match
179 // |filter_builder| (e.g. are on certain origin or domain). 103 // |filter_builder| (e.g. are on certain origin or domain).
180 // RemoveWithFilter() currently only works with FILTERABLE_DATATYPES. 104 // RemoveWithFilter() currently only works with FILTERABLE_DATATYPES.
181 virtual void RemoveWithFilter( 105 virtual void RemoveWithFilter(
182 const base::Time& delete_begin, 106 const base::Time& delete_begin,
183 const base::Time& delete_end, 107 const base::Time& delete_end,
184 int remove_mask, 108 const std::set<const content::BrowsingDataType*>& remove_mask,
185 int origin_type_mask, 109 int origin_type_mask,
186 std::unique_ptr<content::BrowsingDataFilterBuilder> filter_builder) = 0; 110 std::unique_ptr<content::BrowsingDataFilterBuilder> filter_builder) = 0;
187 111
188 // A version of the above that in addition informs the |observer| when the 112 // A version of the above that in addition informs the |observer| when the
189 // removal task is finished. 113 // removal task is finished.
190 virtual void RemoveWithFilterAndReply( 114 virtual void RemoveWithFilterAndReply(
191 const base::Time& delete_begin, 115 const base::Time& delete_begin,
192 const base::Time& delete_end, 116 const base::Time& delete_end,
193 int remove_mask, 117 const std::set<const content::BrowsingDataType*>& remove_mask,
194 int origin_type_mask, 118 int origin_type_mask,
195 std::unique_ptr<content::BrowsingDataFilterBuilder> filter_builder, 119 std::unique_ptr<content::BrowsingDataFilterBuilder> filter_builder,
196 Observer* observer) = 0; 120 Observer* observer) = 0;
197 121
198 // Observers. 122 // Observers.
199 virtual void AddObserver(Observer* observer) = 0; 123 virtual void AddObserver(Observer* observer) = 0;
200 virtual void RemoveObserver(Observer* observer) = 0; 124 virtual void RemoveObserver(Observer* observer) = 0;
201 125
202 // Parameters of the last call are exposed to be used by tests. Removal and 126 // Parameters of the last call are exposed to be used by tests. Removal and
203 // origin type masks equal to -1 mean that no removal has ever been executed. 127 // origin type masks equal to -1 mean that no removal has ever been executed.
204 // TODO(msramek): If other consumers than tests are interested in this, 128 // TODO(msramek): If other consumers than tests are interested in this,
205 // consider returning them in OnBrowsingDataRemoverDone() callback. If not, 129 // consider returning them in OnBrowsingDataRemoverDone() callback. If not,
206 // consider simplifying this interface by removing these methods and changing 130 // consider simplifying this interface by removing these methods and changing
207 // the tests to record the parameters using GMock instead. 131 // the tests to record the parameters using GMock instead.
208 virtual const base::Time& GetLastUsedBeginTime() = 0; 132 virtual const base::Time& GetLastUsedBeginTime() = 0;
209 virtual const base::Time& GetLastUsedEndTime() = 0; 133 virtual const base::Time& GetLastUsedEndTime() = 0;
210 virtual int GetLastUsedRemovalMask() = 0; 134 virtual const std::set<const content::BrowsingDataType*>&
135 GetLastUsedRemovalMask() = 0;
211 virtual int GetLastUsedOriginTypeMask() = 0; 136 virtual int GetLastUsedOriginTypeMask() = 0;
212 }; 137 };
213 138
214 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ 139 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698