Chromium Code Reviews| 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" |
| 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 #include "url/origin.h" | 31 #include "url/origin.h" |
| 29 | 32 |
| 30 #if defined(ENABLE_PLUGINS) | 33 #if defined(ENABLE_PLUGINS) |
| 31 #include "chrome/browser/pepper_flash_settings_manager.h" | 34 #include "chrome/browser/pepper_flash_settings_manager.h" |
| 32 #endif | 35 #endif |
| 33 | 36 |
| 34 #if defined(OS_CHROMEOS) | 37 #if defined(OS_CHROMEOS) |
| 35 #include "chromeos/dbus/dbus_method_call_status.h" | 38 #include "chromeos/dbus/dbus_method_call_status.h" |
| 36 #endif | 39 #endif |
| 37 | 40 |
| 38 class BrowsingDataRemoverFactory; | 41 class BrowsingDataRemoverFactory; |
| 42 class HostContentSettingsMap; | |
| 39 class IOThread; | 43 class IOThread; |
| 44 class OriginFilterBuilder; | |
| 40 class Profile; | 45 class Profile; |
| 41 | 46 |
| 42 namespace chrome_browser_net { | 47 namespace chrome_browser_net { |
| 43 class Predictor; | 48 class Predictor; |
| 44 } | 49 } |
| 45 | 50 |
| 46 namespace content { | 51 namespace content { |
| 47 class BrowserContext; | 52 class BrowserContext; |
| 48 class PluginDataRemover; | 53 class PluginDataRemover; |
| 49 class StoragePartition; | 54 class StoragePartition; |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 // interface. | 245 // interface. |
| 241 static CallbackSubscription RegisterOnBrowsingDataRemovedCallback( | 246 static CallbackSubscription RegisterOnBrowsingDataRemovedCallback( |
| 242 const Callback& callback); | 247 const Callback& callback); |
| 243 | 248 |
| 244 // Removes the specified items related to browsing for all origins that match | 249 // Removes the specified items related to browsing for all origins that match |
| 245 // the provided |origin_type_mask| (see BrowsingDataHelper::OriginTypeMask). | 250 // the provided |origin_type_mask| (see BrowsingDataHelper::OriginTypeMask). |
| 246 void Remove(const TimeRange& time_range, | 251 void Remove(const TimeRange& time_range, |
| 247 int remove_mask, | 252 int remove_mask, |
| 248 int origin_type_mask); | 253 int origin_type_mask); |
| 249 | 254 |
| 255 // Removes the specified items related to browsing for all origins that match | |
| 256 // the provided |origin_type_mask| (see BrowsingDataHelper::OriginTypeMask). | |
| 257 // The |origin_filter| is used as a final filter for clearing operations. | |
| 258 // TODO(dmurph): Support all backends with filter (crbug.com/589586). | |
|
msramek
2016/03/01 17:24:09
Please add a comment, best in capital letters, not
dmurph
2016/03/08 01:42:56
Done.
| |
| 259 void RemoveWithFilter(const TimeRange& time_range, | |
| 260 int remove_mask, | |
| 261 int origin_type_mask, | |
| 262 const OriginFilterBuilder& origin_filter); | |
| 263 | |
| 250 void AddObserver(Observer* observer); | 264 void AddObserver(Observer* observer); |
| 251 void RemoveObserver(Observer* observer); | 265 void RemoveObserver(Observer* observer); |
| 252 | 266 |
| 253 // Used for testing. | 267 // Used for testing. |
| 254 void OverrideStoragePartitionForTesting( | 268 void OverrideStoragePartitionForTesting( |
| 255 content::StoragePartition* storage_partition); | 269 content::StoragePartition* storage_partition); |
| 256 | 270 |
| 271 // Clears all host-specific settings for one content type that satisfy the | |
| 272 // given predicate. | |
| 273 // | |
| 274 // This should only be called on the UI thread. | |
| 275 static void ClearSettingsForOneTypeWithPredicate( | |
|
msramek
2016/03/01 17:24:09
This probably doesn't belong to the public interfa
dmurph
2016/03/08 01:42:56
I'll make it private, as I want to be able to test
| |
| 276 HostContentSettingsMap* content_settings_map, | |
| 277 ContentSettingsType content_type, | |
| 278 const base::Callback< | |
| 279 bool(const ContentSettingsPattern& primary_pattern, | |
| 280 const ContentSettingsPattern& secondary_pattern)>& predicate); | |
| 281 | |
| 257 private: | 282 private: |
| 258 // 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 |
| 259 // only one BrowsingDataRemover instance can be called at a time. | 284 // only one BrowsingDataRemover instance can be called at a time. |
| 260 FRIEND_TEST_ALL_PREFIXES(ExtensionBrowsingDataTest, OneAtATime); | 285 FRIEND_TEST_ALL_PREFIXES(ExtensionBrowsingDataTest, OneAtATime); |
| 261 | 286 |
| 262 // The BrowsingDataRemover tests need to be able to access the implementation | 287 // The BrowsingDataRemover tests need to be able to access the implementation |
| 263 // of Remove(), as it exposes details that aren't yet available in the public | 288 // of Remove(), as it exposes details that aren't yet available in the public |
| 264 // API. As soon as those details are exposed via new methods, this should be | 289 // API. As soon as those details are exposed via new methods, this should be |
| 265 // removed. | 290 // removed. |
| 266 // | 291 // |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 293 bool success) override; | 318 bool success) override; |
| 294 #endif | 319 #endif |
| 295 | 320 |
| 296 #if defined (OS_CHROMEOS) | 321 #if defined (OS_CHROMEOS) |
| 297 void OnClearPlatformKeys(chromeos::DBusMethodCallStatus call_status, | 322 void OnClearPlatformKeys(chromeos::DBusMethodCallStatus call_status, |
| 298 bool result); | 323 bool result); |
| 299 #endif | 324 #endif |
| 300 | 325 |
| 301 // Removes the specified items related to browsing for a specific host. If the | 326 // Removes the specified items related to browsing for a specific host. If the |
| 302 // provided |remove_url| is empty, data is removed for all origins; otherwise, | 327 // provided |remove_url| is empty, data is removed for all origins; otherwise, |
| 303 // it is restricted by origin (where implemented yet). The | 328 // it is restricted by the origin filter origin (where implemented yet). The |
| 304 // |origin_type_mask| parameter defines the set of origins from which data | 329 // |origin_type_mask| parameter defines the set of origins from which data |
| 305 // should be removed (protected, unprotected, or both). | 330 // should be removed (protected, unprotected, or both). |
| 306 // TODO(ttr314): Remove "(where implemented yet)" constraint above once | 331 // TODO(ttr314): Remove "(where implemented yet)" constraint above once |
| 307 // crbug.com/113621 is done. | 332 // crbug.com/113621 is done. |
| 333 // TODO(crbug.com/589586): Support all backends w/ origin filter. | |
| 308 void RemoveImpl(const TimeRange& time_range, | 334 void RemoveImpl(const TimeRange& time_range, |
| 309 int remove_mask, | 335 int remove_mask, |
| 310 const GURL& remove_url, | 336 const OriginFilterBuilder& origin_filter, |
| 311 int origin_type_mask); | 337 int origin_type_mask); |
| 312 | 338 |
| 313 // Notifies observers and transitions to the idle state. | 339 // Notifies observers and transitions to the idle state. |
| 314 void Notify(); | 340 void Notify(); |
| 315 | 341 |
| 316 // Checks if we are all done, and if so, calls Notify(). | 342 // Checks if we are all done, and if so, calls Notify(). |
| 317 void NotifyIfDone(); | 343 void NotifyIfDone(); |
| 318 | 344 |
| 319 // Called when history deletion is done. | 345 // Called when history deletion is done. |
| 320 void OnHistoryDeletionDone(); | 346 void OnHistoryDeletionDone(); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 | 494 |
| 469 // We do not own this. | 495 // We do not own this. |
| 470 content::StoragePartition* storage_partition_for_testing_ = nullptr; | 496 content::StoragePartition* storage_partition_for_testing_ = nullptr; |
| 471 | 497 |
| 472 base::WeakPtrFactory<BrowsingDataRemover> weak_ptr_factory_; | 498 base::WeakPtrFactory<BrowsingDataRemover> weak_ptr_factory_; |
| 473 | 499 |
| 474 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); | 500 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); |
| 475 }; | 501 }; |
| 476 | 502 |
| 477 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ | 503 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ |
| OLD | NEW |