| 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 #include "chrome/browser/browsing_data/browsing_data_remover_impl.h" | 5 #include "chrome/browser/browsing_data/browsing_data_remover_impl.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 17 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
| 18 #include "chrome/browser/browsing_data/browsing_data_remover_delegate.h" | 18 #include "chrome/browser/browsing_data/browsing_data_remover_delegate.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 21 #include "components/browsing_data/content/storage_partition_http_cache_data_rem
over.h" | |
| 22 #include "components/prefs/pref_service.h" | 21 #include "components/prefs/pref_service.h" |
| 23 #include "content/public/browser/browser_context.h" | 22 #include "content/public/browser/browser_context.h" |
| 24 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 25 #include "content/public/browser/browsing_data_filter_builder.h" | 24 #include "content/public/browser/browsing_data_filter_builder.h" |
| 26 #include "content/public/browser/content_browser_client.h" | 25 #include "content/public/browser/content_browser_client.h" |
| 27 #include "content/public/browser/download_manager.h" | 26 #include "content/public/browser/download_manager.h" |
| 28 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
| 29 #include "content/public/browser/storage_partition.h" | 28 #include "content/public/browser/storage_partition.h" |
| 30 #include "content/public/browser/user_metrics.h" | 29 #include "content/public/browser/user_metrics.h" |
| 31 #include "net/base/net_errors.h" | 30 #include "net/base/net_errors.h" |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 } | 464 } |
| 466 | 465 |
| 467 // Content Decryption Modules used by Encrypted Media store licenses in a | 466 // Content Decryption Modules used by Encrypted Media store licenses in a |
| 468 // private filesystem. These are different than content licenses used by | 467 // private filesystem. These are different than content licenses used by |
| 469 // Flash (which are deleted father down in this method). | 468 // Flash (which are deleted father down in this method). |
| 470 if (remove_mask & DATA_TYPE_MEDIA_LICENSES) { | 469 if (remove_mask & DATA_TYPE_MEDIA_LICENSES) { |
| 471 storage_partition_remove_mask |= | 470 storage_partition_remove_mask |= |
| 472 content::StoragePartition::REMOVE_DATA_MASK_PLUGIN_PRIVATE_DATA; | 471 content::StoragePartition::REMOVE_DATA_MASK_PLUGIN_PRIVATE_DATA; |
| 473 } | 472 } |
| 474 | 473 |
| 474 content::StoragePartition* storage_partition; |
| 475 if (storage_partition_for_testing_) { |
| 476 storage_partition = storage_partition_for_testing_; |
| 477 } else { |
| 478 storage_partition = |
| 479 BrowserContext::GetDefaultStoragePartition(browser_context_); |
| 480 } |
| 481 |
| 475 if (storage_partition_remove_mask) { | 482 if (storage_partition_remove_mask) { |
| 476 clear_storage_partition_data_.Start(); | 483 clear_storage_partition_data_.Start(); |
| 477 | 484 |
| 478 content::StoragePartition* storage_partition; | |
| 479 if (storage_partition_for_testing_) { | |
| 480 storage_partition = storage_partition_for_testing_; | |
| 481 } else { | |
| 482 storage_partition = | |
| 483 BrowserContext::GetDefaultStoragePartition(browser_context_); | |
| 484 } | |
| 485 | |
| 486 uint32_t quota_storage_remove_mask = | 485 uint32_t quota_storage_remove_mask = |
| 487 ~content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; | 486 ~content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; |
| 488 | 487 |
| 489 if (delete_begin_ == base::Time() || | 488 if (delete_begin_ == base::Time() || |
| 490 ((origin_type_mask_ & ~ORIGIN_TYPE_UNPROTECTED_WEB) != 0)) { | 489 ((origin_type_mask_ & ~ORIGIN_TYPE_UNPROTECTED_WEB) != 0)) { |
| 491 // If we're deleting since the beginning of time, or we're removing | 490 // If we're deleting since the beginning of time, or we're removing |
| 492 // protected origins, then remove persistent quota data. | 491 // protected origins, then remove persistent quota data. |
| 493 quota_storage_remove_mask |= | 492 quota_storage_remove_mask |= |
| 494 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; | 493 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; |
| 495 } | 494 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 512 } | 511 } |
| 513 | 512 |
| 514 ////////////////////////////////////////////////////////////////////////////// | 513 ////////////////////////////////////////////////////////////////////////////// |
| 515 // CACHE | 514 // CACHE |
| 516 if (remove_mask & DATA_TYPE_CACHE) { | 515 if (remove_mask & DATA_TYPE_CACHE) { |
| 517 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cache")); | 516 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cache")); |
| 518 | 517 |
| 519 // TODO(msramek): Clear the cache of all renderers. | 518 // TODO(msramek): Clear the cache of all renderers. |
| 520 | 519 |
| 521 clear_cache_.Start(); | 520 clear_cache_.Start(); |
| 522 // StoragePartitionHttpCacheDataRemover deletes itself when it is done. | 521 storage_partition->ClearHttpAndMediaCaches( |
| 523 if (filter_builder.IsEmptyBlacklist()) { | 522 delete_begin, delete_end, |
| 524 browsing_data::StoragePartitionHttpCacheDataRemover::CreateForRange( | 523 filter_builder.IsEmptyBlacklist() ? base::Callback<bool(const GURL&)>() |
| 525 BrowserContext::GetDefaultStoragePartition(browser_context_), | 524 : filter, |
| 526 delete_begin_, delete_end_) | 525 clear_cache_.GetCompletionCallback()); |
| 527 ->Remove(clear_cache_.GetCompletionCallback()); | |
| 528 } else { | |
| 529 browsing_data::StoragePartitionHttpCacheDataRemover:: | |
| 530 CreateForURLsAndRange( | |
| 531 BrowserContext::GetDefaultStoragePartition(browser_context_), | |
| 532 filter, delete_begin_, delete_end_) | |
| 533 ->Remove(clear_cache_.GetCompletionCallback()); | |
| 534 } | |
| 535 | 526 |
| 536 // Tell the shader disk cache to clear. | 527 // Tell the shader disk cache to clear. |
| 537 content::RecordAction(UserMetricsAction("ClearBrowsingData_ShaderCache")); | 528 content::RecordAction(UserMetricsAction("ClearBrowsingData_ShaderCache")); |
| 538 storage_partition_remove_mask |= | 529 storage_partition_remove_mask |= |
| 539 content::StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE; | 530 content::StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE; |
| 540 } | 531 } |
| 541 | 532 |
| 542 ////////////////////////////////////////////////////////////////////////////// | 533 ////////////////////////////////////////////////////////////////////////////// |
| 543 // Auth cache. | 534 // Auth cache. |
| 544 if (remove_mask & DATA_TYPE_COOKIES) { | 535 if (remove_mask & DATA_TYPE_COOKIES) { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 | 662 |
| 672 if (completion_inhibitor_) { | 663 if (completion_inhibitor_) { |
| 673 completion_inhibitor_->OnBrowsingDataRemoverWouldComplete( | 664 completion_inhibitor_->OnBrowsingDataRemoverWouldComplete( |
| 674 this, base::Bind(&BrowsingDataRemoverImpl::Notify, | 665 this, base::Bind(&BrowsingDataRemoverImpl::Notify, |
| 675 weak_ptr_factory_.GetWeakPtr())); | 666 weak_ptr_factory_.GetWeakPtr())); |
| 676 return; | 667 return; |
| 677 } | 668 } |
| 678 | 669 |
| 679 Notify(); | 670 Notify(); |
| 680 } | 671 } |
| OLD | NEW |