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

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

Issue 1741123002: Add removal filter support for Cookies, Storage, and Content Settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ios fix, and fixed test Created 4 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
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_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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
11 11
12 #include "base/callback_forward.h"
12 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
16 #include "base/observer_list.h" 17 #include "base/observer_list.h"
17 #include "base/sequenced_task_runner_helpers.h" 18 #include "base/sequenced_task_runner_helpers.h"
18 #include "base/synchronization/waitable_event_watcher.h" 19 #include "base/synchronization/waitable_event_watcher.h"
19 #include "base/task/cancelable_task_tracker.h" 20 #include "base/task/cancelable_task_tracker.h"
20 #include "base/time/time.h" 21 #include "base/time/time.h"
21 #include "build/build_config.h" 22 #include "build/build_config.h"
22 #include "chrome/common/features.h" 23 #include "chrome/common/features.h"
24 #include "components/content_settings/core/common/content_settings_pattern.h"
25 #include "components/content_settings/core/common/content_settings_types.h"
23 #include "components/keyed_service/core/keyed_service.h" 26 #include "components/keyed_service/core/keyed_service.h"
24 #include "components/prefs/pref_member.h" 27 #include "components/prefs/pref_member.h"
25 #include "components/search_engines/template_url_service.h" 28 #include "components/search_engines/template_url_service.h"
26 #include "storage/common/quota/quota_types.h" 29 #include "storage/common/quota/quota_types.h"
27 #include "url/gurl.h" 30 #include "url/gurl.h"
28 31
29 #if defined(ENABLE_PLUGINS) 32 #if defined(ENABLE_PLUGINS)
30 #include "chrome/browser/pepper_flash_settings_manager.h" 33 #include "chrome/browser/pepper_flash_settings_manager.h"
31 #endif 34 #endif
32 35
33 #if defined(OS_CHROMEOS) 36 #if defined(OS_CHROMEOS)
34 #include "chromeos/dbus/dbus_method_call_status.h" 37 #include "chromeos/dbus/dbus_method_call_status.h"
35 #endif 38 #endif
36 39
37 class BrowsingDataRemoverFactory; 40 class BrowsingDataRemoverFactory;
41 class HostContentSettingsMap;
38 class IOThread; 42 class IOThread;
43 class OriginFilterBuilder;
39 class Profile; 44 class Profile;
40 45
41 namespace chrome_browser_net { 46 namespace chrome_browser_net {
42 class Predictor; 47 class Predictor;
43 } 48 }
44 49
45 namespace content { 50 namespace content {
46 class BrowserContext; 51 class BrowserContext;
47 class PluginDataRemover; 52 class PluginDataRemover;
48 class StoragePartition; 53 class StoragePartition;
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 // interface. 244 // interface.
240 static CallbackSubscription RegisterOnBrowsingDataRemovedCallback( 245 static CallbackSubscription RegisterOnBrowsingDataRemovedCallback(
241 const Callback& callback); 246 const Callback& callback);
242 247
243 // Removes the specified items related to browsing for all origins that match 248 // Removes the specified items related to browsing for all origins that match
244 // the provided |origin_type_mask| (see BrowsingDataHelper::OriginTypeMask). 249 // the provided |origin_type_mask| (see BrowsingDataHelper::OriginTypeMask).
245 void Remove(const TimeRange& time_range, 250 void Remove(const TimeRange& time_range,
246 int remove_mask, 251 int remove_mask,
247 int origin_type_mask); 252 int origin_type_mask);
248 253
254 // Removes the specified items related to browsing for all origins that match
255 // the provided |origin_type_mask| (see BrowsingDataHelper::OriginTypeMask).
256 // The |origin_filter| is used as a final filter for clearing operations.
257 // TODO(dmurph): Support all backends with filter (crbug.com/113621).
258 // DO NOT USE THIS METHOD UNLESS CALLER KNOWS WHAT THEY'RE DOING. NOT ALL
259 // BACKENDS ARE SUPPORTED YET, AND MORE DATA THAN EXPECTED COULD BE DELETED.
260 void RemoveWithFilter(const TimeRange& time_range,
261 int remove_mask,
262 int origin_type_mask,
263 const OriginFilterBuilder& origin_filter);
264
249 void AddObserver(Observer* observer); 265 void AddObserver(Observer* observer);
250 void RemoveObserver(Observer* observer); 266 void RemoveObserver(Observer* observer);
251 267
252 // Used for testing. 268 // Used for testing.
253 void OverrideStoragePartitionForTesting( 269 void OverrideStoragePartitionForTesting(
254 content::StoragePartition* storage_partition); 270 content::StoragePartition* storage_partition);
255 271
256 private: 272 private:
257 // The clear API needs to be able to toggle removing_ in order to test that 273 // The clear API needs to be able to toggle removing_ in order to test that
258 // only one BrowsingDataRemover instance can be called at a time. 274 // only one BrowsingDataRemover instance can be called at a time.
259 FRIEND_TEST_ALL_PREFIXES(ExtensionBrowsingDataTest, OneAtATime); 275 FRIEND_TEST_ALL_PREFIXES(ExtensionBrowsingDataTest, OneAtATime);
276 // Testing our static method, ClearSettingsForOneTypeWithPredicate.
277 FRIEND_TEST_ALL_PREFIXES(BrowsingDataRemoverTest, ClearWithPredicate);
260 278
261 // The BrowsingDataRemover tests need to be able to access the implementation 279 // The BrowsingDataRemover tests need to be able to access the implementation
262 // of Remove(), as it exposes details that aren't yet available in the public 280 // of Remove(), as it exposes details that aren't yet available in the public
263 // API. As soon as those details are exposed via new methods, this should be 281 // API. As soon as those details are exposed via new methods, this should be
264 // removed. 282 // removed.
265 // 283 //
266 // TODO(mkwst): See http://crbug.com/113621 284 // TODO(mkwst): See http://crbug.com/113621
267 friend class BrowsingDataRemoverTest; 285 friend class BrowsingDataRemoverTest;
268 286
269 friend class BrowsingDataRemoverFactory; 287 friend class BrowsingDataRemoverFactory;
270 288
289 // Clears all host-specific settings for one content type that satisfy the
290 // given predicate.
291 //
292 // This should only be called on the UI thread.
293 static void ClearSettingsForOneTypeWithPredicate(
294 HostContentSettingsMap* content_settings_map,
295 ContentSettingsType content_type,
296 const base::Callback<
297 bool(const ContentSettingsPattern& primary_pattern,
298 const ContentSettingsPattern& secondary_pattern)>& predicate);
299
271 // Use BrowsingDataRemoverFactory::GetForBrowserContext to get an instance of 300 // Use BrowsingDataRemoverFactory::GetForBrowserContext to get an instance of
272 // this class. 301 // this class.
273 BrowsingDataRemover(content::BrowserContext* browser_context); 302 BrowsingDataRemover(content::BrowserContext* browser_context);
274 ~BrowsingDataRemover() override; 303 ~BrowsingDataRemover() override;
275 304
276 void Shutdown() override; 305 void Shutdown() override;
277 306
278 // Setter for |is_removing_|; DCHECKs that we can only start removing if we're 307 // Setter for |is_removing_|; DCHECKs that we can only start removing if we're
279 // not already removing, and vice-versa. 308 // not already removing, and vice-versa.
280 void SetRemoving(bool is_removing); 309 void SetRemoving(bool is_removing);
(...skipping 11 matching lines...) Expand all
292 bool success) override; 321 bool success) override;
293 #endif 322 #endif
294 323
295 #if defined (OS_CHROMEOS) 324 #if defined (OS_CHROMEOS)
296 void OnClearPlatformKeys(chromeos::DBusMethodCallStatus call_status, 325 void OnClearPlatformKeys(chromeos::DBusMethodCallStatus call_status,
297 bool result); 326 bool result);
298 #endif 327 #endif
299 328
300 // Removes the specified items related to browsing for a specific host. If the 329 // Removes the specified items related to browsing for a specific host. If the
301 // provided |remove_url| is empty, data is removed for all origins; otherwise, 330 // provided |remove_url| is empty, data is removed for all origins; otherwise,
302 // it is restricted by origin (where implemented yet). The 331 // it is restricted by the origin filter origin (where implemented yet). The
303 // |origin_type_mask| parameter defines the set of origins from which data 332 // |origin_type_mask| parameter defines the set of origins from which data
304 // should be removed (protected, unprotected, or both). 333 // should be removed (protected, unprotected, or both).
305 // TODO(ttr314): Remove "(where implemented yet)" constraint above once 334 // TODO(ttr314): Remove "(where implemented yet)" constraint above once
306 // crbug.com/113621 is done. 335 // crbug.com/113621 is done.
336 // TODO(crbug.com/589586): Support all backends w/ origin filter.
307 void RemoveImpl(const TimeRange& time_range, 337 void RemoveImpl(const TimeRange& time_range,
308 int remove_mask, 338 int remove_mask,
309 const GURL& remove_url, 339 const OriginFilterBuilder& origin_filter,
310 int origin_type_mask); 340 int origin_type_mask);
311 341
312 // Notifies observers and transitions to the idle state. 342 // Notifies observers and transitions to the idle state.
313 void Notify(); 343 void Notify();
314 344
315 // Checks if we are all done, and if so, calls Notify(). 345 // Checks if we are all done, and if so, calls Notify().
316 void NotifyIfDone(); 346 void NotifyIfDone();
317 347
318 // Called when history deletion is done. 348 // Called when history deletion is done.
319 void OnHistoryDeletionDone(); 349 void OnHistoryDeletionDone();
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 501
472 // We do not own this. 502 // We do not own this.
473 content::StoragePartition* storage_partition_for_testing_ = nullptr; 503 content::StoragePartition* storage_partition_for_testing_ = nullptr;
474 504
475 base::WeakPtrFactory<BrowsingDataRemover> weak_ptr_factory_; 505 base::WeakPtrFactory<BrowsingDataRemover> weak_ptr_factory_;
476 506
477 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); 507 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover);
478 }; 508 };
479 509
480 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ 510 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698