OLD | NEW |
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" |
| 27 #include "components/offline_pages/offline_page_model.h" |
24 #include "components/prefs/pref_member.h" | 28 #include "components/prefs/pref_member.h" |
25 #include "components/search_engines/template_url_service.h" | 29 #include "components/search_engines/template_url_service.h" |
26 #include "storage/common/quota/quota_types.h" | 30 #include "storage/common/quota/quota_types.h" |
27 #include "url/gurl.h" | 31 #include "url/gurl.h" |
28 | 32 |
29 #if defined(ENABLE_PLUGINS) | 33 #if defined(ENABLE_PLUGINS) |
30 #include "chrome/browser/pepper_flash_settings_manager.h" | 34 #include "chrome/browser/pepper_flash_settings_manager.h" |
31 #endif | 35 #endif |
32 | 36 |
33 #if defined(OS_CHROMEOS) | 37 #if defined(OS_CHROMEOS) |
34 #include "chromeos/dbus/dbus_method_call_status.h" | 38 #include "chromeos/dbus/dbus_method_call_status.h" |
35 #endif | 39 #endif |
36 | 40 |
37 class BrowsingDataRemoverFactory; | 41 class BrowsingDataRemoverFactory; |
| 42 class HostContentSettingsMap; |
38 class IOThread; | 43 class IOThread; |
| 44 class BrowsingDataFilterBuilder; |
39 class Profile; | 45 class Profile; |
40 | 46 |
41 namespace chrome_browser_net { | 47 namespace chrome_browser_net { |
42 class Predictor; | 48 class Predictor; |
43 } | 49 } |
44 | 50 |
45 namespace content { | 51 namespace content { |
46 class BrowserContext; | 52 class BrowserContext; |
47 class PluginDataRemover; | 53 class PluginDataRemover; |
48 class StoragePartition; | 54 class StoragePartition; |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 // interface. | 249 // interface. |
244 static CallbackSubscription RegisterOnBrowsingDataRemovedCallback( | 250 static CallbackSubscription RegisterOnBrowsingDataRemovedCallback( |
245 const Callback& callback); | 251 const Callback& callback); |
246 | 252 |
247 // Removes the specified items related to browsing for all origins that match | 253 // Removes the specified items related to browsing for all origins that match |
248 // the provided |origin_type_mask| (see BrowsingDataHelper::OriginTypeMask). | 254 // the provided |origin_type_mask| (see BrowsingDataHelper::OriginTypeMask). |
249 void Remove(const TimeRange& time_range, | 255 void Remove(const TimeRange& time_range, |
250 int remove_mask, | 256 int remove_mask, |
251 int origin_type_mask); | 257 int origin_type_mask); |
252 | 258 |
| 259 // Removes the specified items related to browsing for all origins that match |
| 260 // the provided |origin_type_mask| (see BrowsingDataHelper::OriginTypeMask). |
| 261 // The |origin_filter| is used as a final filter for clearing operations. |
| 262 // TODO(dmurph): Support all backends with filter (crbug.com/113621). |
| 263 // DO NOT USE THIS METHOD UNLESS CALLER KNOWS WHAT THEY'RE DOING. NOT ALL |
| 264 // BACKENDS ARE SUPPORTED YET, AND MORE DATA THAN EXPECTED COULD BE DELETED. |
| 265 void RemoveWithFilter(const TimeRange& time_range, |
| 266 int remove_mask, |
| 267 int origin_type_mask, |
| 268 const BrowsingDataFilterBuilder& origin_filter); |
| 269 |
253 void AddObserver(Observer* observer); | 270 void AddObserver(Observer* observer); |
254 void RemoveObserver(Observer* observer); | 271 void RemoveObserver(Observer* observer); |
255 | 272 |
256 // Used for testing. | 273 // Used for testing. |
257 void OverrideStoragePartitionForTesting( | 274 void OverrideStoragePartitionForTesting( |
258 content::StoragePartition* storage_partition); | 275 content::StoragePartition* storage_partition); |
259 | 276 |
260 #if BUILDFLAG(ANDROID_JAVA_UI) | 277 #if BUILDFLAG(ANDROID_JAVA_UI) |
261 void OverrideWebappRegistryForTesting( | 278 void OverrideWebappRegistryForTesting( |
262 scoped_ptr<WebappRegistry> webapp_registry); | 279 scoped_ptr<WebappRegistry> webapp_registry); |
263 #endif | 280 #endif |
264 | 281 |
265 private: | 282 private: |
266 // The clear API needs to be able to toggle removing_ in order to test that | 283 // The clear API needs to be able to toggle removing_ in order to test that |
267 // only one BrowsingDataRemover instance can be called at a time. | 284 // only one BrowsingDataRemover instance can be called at a time. |
268 FRIEND_TEST_ALL_PREFIXES(ExtensionBrowsingDataTest, OneAtATime); | 285 FRIEND_TEST_ALL_PREFIXES(ExtensionBrowsingDataTest, OneAtATime); |
| 286 // Testing our static method, ClearSettingsForOneTypeWithPredicate. |
| 287 FRIEND_TEST_ALL_PREFIXES(BrowsingDataRemoverTest, ClearWithPredicate); |
269 | 288 |
270 // The BrowsingDataRemover tests need to be able to access the implementation | 289 // The BrowsingDataRemover tests need to be able to access the implementation |
271 // of Remove(), as it exposes details that aren't yet available in the public | 290 // of Remove(), as it exposes details that aren't yet available in the public |
272 // API. As soon as those details are exposed via new methods, this should be | 291 // API. As soon as those details are exposed via new methods, this should be |
273 // removed. | 292 // removed. |
274 // | 293 // |
275 // TODO(mkwst): See http://crbug.com/113621 | 294 // TODO(mkwst): See http://crbug.com/113621 |
276 friend class BrowsingDataRemoverTest; | 295 friend class BrowsingDataRemoverTest; |
277 | 296 |
278 friend class BrowsingDataRemoverFactory; | 297 friend class BrowsingDataRemoverFactory; |
279 | 298 |
| 299 // Clears all host-specific settings for one content type that satisfy the |
| 300 // given predicate. |
| 301 // |
| 302 // This should only be called on the UI thread. |
| 303 static void ClearSettingsForOneTypeWithPredicate( |
| 304 HostContentSettingsMap* content_settings_map, |
| 305 ContentSettingsType content_type, |
| 306 const base::Callback< |
| 307 bool(const ContentSettingsPattern& primary_pattern, |
| 308 const ContentSettingsPattern& secondary_pattern)>& predicate); |
| 309 |
280 // Use BrowsingDataRemoverFactory::GetForBrowserContext to get an instance of | 310 // Use BrowsingDataRemoverFactory::GetForBrowserContext to get an instance of |
281 // this class. | 311 // this class. |
282 BrowsingDataRemover(content::BrowserContext* browser_context); | 312 BrowsingDataRemover(content::BrowserContext* browser_context); |
283 ~BrowsingDataRemover() override; | 313 ~BrowsingDataRemover() override; |
284 | 314 |
285 void Shutdown() override; | 315 void Shutdown() override; |
286 | 316 |
287 // Setter for |is_removing_|; DCHECKs that we can only start removing if we're | 317 // Setter for |is_removing_|; DCHECKs that we can only start removing if we're |
288 // not already removing, and vice-versa. | 318 // not already removing, and vice-versa. |
289 void SetRemoving(bool is_removing); | 319 void SetRemoving(bool is_removing); |
(...skipping 11 matching lines...) Expand all Loading... |
301 bool success) override; | 331 bool success) override; |
302 #endif | 332 #endif |
303 | 333 |
304 #if defined (OS_CHROMEOS) | 334 #if defined (OS_CHROMEOS) |
305 void OnClearPlatformKeys(chromeos::DBusMethodCallStatus call_status, | 335 void OnClearPlatformKeys(chromeos::DBusMethodCallStatus call_status, |
306 bool result); | 336 bool result); |
307 #endif | 337 #endif |
308 | 338 |
309 // Removes the specified items related to browsing for a specific host. If the | 339 // Removes the specified items related to browsing for a specific host. If the |
310 // provided |remove_url| is empty, data is removed for all origins; otherwise, | 340 // provided |remove_url| is empty, data is removed for all origins; otherwise, |
311 // it is restricted by origin (where implemented yet). The | 341 // it is restricted by the origin filter origin (where implemented yet). The |
312 // |origin_type_mask| parameter defines the set of origins from which data | 342 // |origin_type_mask| parameter defines the set of origins from which data |
313 // should be removed (protected, unprotected, or both). | 343 // should be removed (protected, unprotected, or both). |
314 // TODO(ttr314): Remove "(where implemented yet)" constraint above once | 344 // TODO(ttr314): Remove "(where implemented yet)" constraint above once |
315 // crbug.com/113621 is done. | 345 // crbug.com/113621 is done. |
| 346 // TODO(crbug.com/589586): Support all backends w/ origin filter. |
316 void RemoveImpl(const TimeRange& time_range, | 347 void RemoveImpl(const TimeRange& time_range, |
317 int remove_mask, | 348 int remove_mask, |
318 const GURL& remove_url, | 349 const BrowsingDataFilterBuilder& origin_filter, |
319 int origin_type_mask); | 350 int origin_type_mask); |
320 | 351 |
321 // Notifies observers and transitions to the idle state. | 352 // Notifies observers and transitions to the idle state. |
322 void Notify(); | 353 void Notify(); |
323 | 354 |
324 // Checks if we are all done, and if so, calls Notify(). | 355 // Checks if we are all done, and if so, calls Notify(). |
325 void NotifyIfDone(); | 356 void NotifyIfDone(); |
326 | 357 |
327 // Called when history deletion is done. | 358 // Called when history deletion is done. |
328 void OnHistoryDeletionDone(); | 359 void OnHistoryDeletionDone(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 // Callback on UI thread when the precache history has been cleared. | 421 // Callback on UI thread when the precache history has been cleared. |
391 void OnClearedPrecacheHistory(); | 422 void OnClearedPrecacheHistory(); |
392 | 423 |
393 // Callback on UI thread when the webapp data has been cleared. | 424 // Callback on UI thread when the webapp data has been cleared. |
394 void OnClearedWebappData(); | 425 void OnClearedWebappData(); |
395 | 426 |
396 // Callback on UI thread when the webapp history has been cleared. | 427 // Callback on UI thread when the webapp history has been cleared. |
397 void OnClearedWebappHistory(); | 428 void OnClearedWebappHistory(); |
398 | 429 |
399 // Callback on UI thread when the offline page data has been cleared. | 430 // Callback on UI thread when the offline page data has been cleared. |
400 void OnClearedOfflinePageData(); | 431 void OnClearedOfflinePageData( |
| 432 offline_pages::OfflinePageModel::DeletePageResult result); |
401 #endif | 433 #endif |
402 | 434 |
403 void OnClearedDomainReliabilityMonitor(); | 435 void OnClearedDomainReliabilityMonitor(); |
404 | 436 |
405 // Returns true if we're all done. | 437 // Returns true if we're all done. |
406 bool AllDone(); | 438 bool AllDone(); |
407 | 439 |
408 // Profile we're to remove from. | 440 // Profile we're to remove from. |
409 Profile* profile_; | 441 Profile* profile_; |
410 | 442 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 // not initialised, so the registry must be mocked out. | 522 // not initialised, so the registry must be mocked out. |
491 scoped_ptr<WebappRegistry> webapp_registry_; | 523 scoped_ptr<WebappRegistry> webapp_registry_; |
492 #endif | 524 #endif |
493 | 525 |
494 base::WeakPtrFactory<BrowsingDataRemover> weak_ptr_factory_; | 526 base::WeakPtrFactory<BrowsingDataRemover> weak_ptr_factory_; |
495 | 527 |
496 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); | 528 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); |
497 }; | 529 }; |
498 | 530 |
499 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ | 531 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ |
OLD | NEW |