| OLD | NEW |
| 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 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" | 5 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/stl_util.h" |
| 12 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 13 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 14 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 14 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 16 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 16 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 18 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 18 #include "chrome/browser/domain_reliability/service_factory.h" | 19 #include "chrome/browser/domain_reliability/service_factory.h" |
| 19 #include "chrome/browser/download/download_prefs.h" | 20 #include "chrome/browser/download/download_prefs.h" |
| 20 #include "chrome/browser/external_protocol/external_protocol_handler.h" | 21 #include "chrome/browser/external_protocol/external_protocol_handler.h" |
| 21 #include "chrome/browser/history/history_service_factory.h" | 22 #include "chrome/browser/history/history_service_factory.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 #endif | 110 #endif |
| 110 | 111 |
| 111 #if BUILDFLAG(ENABLE_PLUGINS) | 112 #if BUILDFLAG(ENABLE_PLUGINS) |
| 112 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" | 113 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" |
| 113 #endif | 114 #endif |
| 114 | 115 |
| 115 using base::UserMetricsAction; | 116 using base::UserMetricsAction; |
| 116 using content::BrowserContext; | 117 using content::BrowserContext; |
| 117 using content::BrowserThread; | 118 using content::BrowserThread; |
| 118 using content::BrowsingDataFilterBuilder; | 119 using content::BrowsingDataFilterBuilder; |
| 120 using content::BrowsingDataType; |
| 119 | 121 |
| 120 namespace { | 122 namespace { |
| 121 | 123 |
| 122 void UIThreadTrampolineHelper(const base::Closure& callback) { | 124 void UIThreadTrampolineHelper(const base::Closure& callback) { |
| 123 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); | 125 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); |
| 124 } | 126 } |
| 125 | 127 |
| 126 // Convenience method to create a callback that can be run on any thread and | 128 // Convenience method to create a callback that can be run on any thread and |
| 127 // will post the given |callback| back to the UI thread. | 129 // will post the given |callback| back to the UI thread. |
| 128 base::Closure UIThreadTrampoline(const base::Closure& callback) { | 130 base::Closure UIThreadTrampoline(const base::Closure& callback) { |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 weak_ptr_factory_(this) {} | 306 weak_ptr_factory_(this) {} |
| 305 | 307 |
| 306 ChromeBrowsingDataRemoverDelegate::~ChromeBrowsingDataRemoverDelegate() { | 308 ChromeBrowsingDataRemoverDelegate::~ChromeBrowsingDataRemoverDelegate() { |
| 307 history_task_tracker_.TryCancelAll(); | 309 history_task_tracker_.TryCancelAll(); |
| 308 template_url_sub_.reset(); | 310 template_url_sub_.reset(); |
| 309 } | 311 } |
| 310 | 312 |
| 311 void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData( | 313 void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData( |
| 312 const base::Time& delete_begin, | 314 const base::Time& delete_begin, |
| 313 const base::Time& delete_end, | 315 const base::Time& delete_end, |
| 314 int remove_mask, | 316 const std::set<const content::BrowsingDataType*>& remove_mask, |
| 315 const BrowsingDataFilterBuilder& filter_builder, | 317 const BrowsingDataFilterBuilder& filter_builder, |
| 316 int origin_type_mask, | 318 int origin_type_mask, |
| 317 const base::Closure& callback) { | 319 const base::Closure& callback) { |
| 318 ////////////////////////////////////////////////////////////////////////////// | 320 ////////////////////////////////////////////////////////////////////////////// |
| 319 // INITIALIZATION | 321 // INITIALIZATION |
| 320 synchronous_clear_operations_.Start(); | 322 synchronous_clear_operations_.Start(); |
| 321 callback_ = callback; | 323 callback_ = callback; |
| 322 | 324 |
| 323 delete_begin_ = delete_begin; | 325 delete_begin_ = delete_begin; |
| 324 delete_end_ = delete_end; | 326 delete_end_ = delete_end; |
| 325 | 327 |
| 326 base::Callback<bool(const GURL& url)> filter = | 328 base::Callback<bool(const GURL& url)> filter = |
| 327 filter_builder.BuildGeneralFilter(); | 329 filter_builder.BuildGeneralFilter(); |
| 328 | 330 |
| 329 // Some backends support a filter that |is_null()| to make complete deletion | 331 // Some backends support a filter that |is_null()| to make complete deletion |
| 330 // more efficient. | 332 // more efficient. |
| 331 base::Callback<bool(const GURL&)> nullable_filter = | 333 base::Callback<bool(const GURL&)> nullable_filter = |
| 332 filter_builder.IsEmptyBlacklist() ? base::Callback<bool(const GURL&)>() | 334 filter_builder.IsEmptyBlacklist() ? base::Callback<bool(const GURL&)>() |
| 333 : filter; | 335 : filter; |
| 334 | 336 |
| 335 // Managed devices and supervised users can have restrictions on history | 337 // Managed devices and supervised users can have restrictions on history |
| 336 // deletion. | 338 // deletion. |
| 337 PrefService* prefs = profile_->GetPrefs(); | 339 PrefService* prefs = profile_->GetPrefs(); |
| 338 bool may_delete_history = prefs->GetBoolean( | 340 bool may_delete_history = prefs->GetBoolean( |
| 339 prefs::kAllowDeletingBrowserHistory); | 341 prefs::kAllowDeletingBrowserHistory); |
| 340 | 342 |
| 341 // All the UI entry points into the BrowsingDataRemoverImpl should be | 343 // All the UI entry points into the BrowsingDataRemoverImpl should be |
| 342 // disabled, but this will fire if something was missed or added. | 344 // disabled, but this will fire if something was missed or added. |
| 343 DCHECK(may_delete_history || | 345 DCHECK(may_delete_history || |
| 344 (remove_mask & BrowsingDataRemover::REMOVE_NOCHECKS) || | 346 base::ContainsValue(remove_mask, &kBrowsingDataTypeNoChecks) || |
| 345 (!(remove_mask & BrowsingDataRemover::REMOVE_HISTORY) && | 347 (!base::ContainsValue(remove_mask, &kBrowsingDataTypeHistory) && |
| 346 !(remove_mask & BrowsingDataRemover::REMOVE_DOWNLOADS))); | 348 !base::ContainsValue(remove_mask, &kBrowsingDataTypeDownloads))); |
| 347 | 349 |
| 348 ////////////////////////////////////////////////////////////////////////////// | 350 ////////////////////////////////////////////////////////////////////////////// |
| 349 // REMOVE_HISTORY | 351 // kBrowsingDataTypeHistory |
| 350 if ((remove_mask & BrowsingDataRemover::REMOVE_HISTORY) && | 352 if (base::ContainsValue(remove_mask, &kBrowsingDataTypeHistory) && |
| 351 may_delete_history) { | 353 may_delete_history) { |
| 352 history::HistoryService* history_service = | 354 history::HistoryService* history_service = |
| 353 HistoryServiceFactory::GetForProfile( | 355 HistoryServiceFactory::GetForProfile( |
| 354 profile_, ServiceAccessType::EXPLICIT_ACCESS); | 356 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
| 355 if (history_service) { | 357 if (history_service) { |
| 356 // TODO(dmurph): Support all backends with filter (crbug.com/113621). | 358 // TODO(dmurph): Support all backends with filter (crbug.com/113621). |
| 357 content::RecordAction(UserMetricsAction("ClearBrowsingData_History")); | 359 content::RecordAction(UserMetricsAction("ClearBrowsingData_History")); |
| 358 clear_history_.Start(); | 360 clear_history_.Start(); |
| 359 history_service->ExpireLocalAndRemoteHistoryBetween( | 361 history_service->ExpireLocalAndRemoteHistoryBetween( |
| 360 WebHistoryServiceFactory::GetForProfile(profile_), std::set<GURL>(), | 362 WebHistoryServiceFactory::GetForProfile(profile_), std::set<GURL>(), |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 // Rename the method to indicate its more general usage. | 567 // Rename the method to indicate its more general usage. |
| 566 if (profile_->GetSSLHostStateDelegate()) { | 568 if (profile_->GetSSLHostStateDelegate()) { |
| 567 profile_->GetSSLHostStateDelegate()->Clear( | 569 profile_->GetSSLHostStateDelegate()->Clear( |
| 568 filter_builder.IsEmptyBlacklist() | 570 filter_builder.IsEmptyBlacklist() |
| 569 ? base::Callback<bool(const std::string&)>() | 571 ? base::Callback<bool(const std::string&)>() |
| 570 : filter_builder.BuildPluginFilter()); | 572 : filter_builder.BuildPluginFilter()); |
| 571 } | 573 } |
| 572 } | 574 } |
| 573 | 575 |
| 574 ////////////////////////////////////////////////////////////////////////////// | 576 ////////////////////////////////////////////////////////////////////////////// |
| 575 // REMOVE_DOWNLOADS | 577 // kBrowsingDataTypeDownloads |
| 576 if ((remove_mask & BrowsingDataRemover::REMOVE_DOWNLOADS) && | 578 if (base::ContainsValue(remove_mask, &kBrowsingDataTypeDownloads) && |
| 577 may_delete_history) { | 579 may_delete_history) { |
| 578 DownloadPrefs* download_prefs = DownloadPrefs::FromDownloadManager( | 580 DownloadPrefs* download_prefs = DownloadPrefs::FromDownloadManager( |
| 579 BrowserContext::GetDownloadManager(profile_)); | 581 BrowserContext::GetDownloadManager(profile_)); |
| 580 download_prefs->SetSaveFilePath(download_prefs->DownloadPath()); | 582 download_prefs->SetSaveFilePath(download_prefs->DownloadPath()); |
| 581 } | 583 } |
| 582 | 584 |
| 583 ////////////////////////////////////////////////////////////////////////////// | 585 ////////////////////////////////////////////////////////////////////////////// |
| 584 // REMOVE_COOKIES | 586 // kBrowsingDataTypeCookies |
| 585 // We ignore the REMOVE_COOKIES request if UNPROTECTED_WEB is not set, | 587 // We ignore the kBrowsingDataTypeCookies request if UNPROTECTED_WEB is not |
| 586 // so that callers who request REMOVE_SITE_DATA with PROTECTED_WEB | 588 // set, so that callers who request site data with PROTECTED_WEB |
| 587 // don't accidentally remove the cookies that are associated with the | 589 // don't accidentally remove the cookies that are associated with the |
| 588 // UNPROTECTED_WEB origin. This is necessary because cookies are not separated | 590 // UNPROTECTED_WEB origin. This is necessary because cookies are not separated |
| 589 // between UNPROTECTED_WEB and PROTECTED_WEB. | 591 // between UNPROTECTED_WEB and PROTECTED_WEB. |
| 590 if (remove_mask & BrowsingDataRemover::REMOVE_COOKIES && | 592 if (base::ContainsValue(remove_mask, &kBrowsingDataTypeCookies) && |
| 591 origin_type_mask & BrowsingDataHelper::UNPROTECTED_WEB) { | 593 origin_type_mask & BrowsingDataHelper::UNPROTECTED_WEB) { |
| 592 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies")); | 594 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies")); |
| 593 | 595 |
| 594 // Clear the safebrowsing cookies only if time period is for "all time". It | 596 // Clear the safebrowsing cookies only if time period is for "all time". It |
| 595 // doesn't make sense to apply the time period of deleting in the last X | 597 // doesn't make sense to apply the time period of deleting in the last X |
| 596 // hours/days to the safebrowsing cookies since they aren't the result of | 598 // hours/days to the safebrowsing cookies since they aren't the result of |
| 597 // any user action. | 599 // any user action. |
| 598 if (delete_begin_ == base::Time()) { | 600 if (delete_begin_ == base::Time()) { |
| 599 safe_browsing::SafeBrowsingService* sb_service = | 601 safe_browsing::SafeBrowsingService* sb_service = |
| 600 g_browser_process->safe_browsing_service(); | 602 g_browser_process->safe_browsing_service(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 624 &ChromeBrowsingDataRemoverDelegate::OnClearedCookies, | 626 &ChromeBrowsingDataRemoverDelegate::OnClearedCookies, |
| 625 weak_ptr_factory_.GetWeakPtr())))); | 627 weak_ptr_factory_.GetWeakPtr())))); |
| 626 } | 628 } |
| 627 } | 629 } |
| 628 } | 630 } |
| 629 | 631 |
| 630 MediaDeviceIDSalt::Reset(profile_->GetPrefs()); | 632 MediaDeviceIDSalt::Reset(profile_->GetPrefs()); |
| 631 } | 633 } |
| 632 | 634 |
| 633 ////////////////////////////////////////////////////////////////////////////// | 635 ////////////////////////////////////////////////////////////////////////////// |
| 634 // REMOVE_DURABLE_PERMISSION | 636 // kRemoveDurablePermission |
| 635 if (remove_mask & BrowsingDataRemover::REMOVE_DURABLE_PERMISSION) { | 637 if (base::ContainsValue(remove_mask, &kBrowsingDataTypeDurablePermission)) { |
| 636 HostContentSettingsMapFactory::GetForProfile(profile_) | 638 HostContentSettingsMapFactory::GetForProfile(profile_) |
| 637 ->ClearSettingsForOneTypeWithPredicate( | 639 ->ClearSettingsForOneTypeWithPredicate( |
| 638 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, | 640 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, |
| 639 base::Bind(&WebsiteSettingsFilterAdapter, filter)); | 641 base::Bind(&WebsiteSettingsFilterAdapter, filter)); |
| 640 } | 642 } |
| 641 | 643 |
| 642 ////////////////////////////////////////////////////////////////////////////// | 644 ////////////////////////////////////////////////////////////////////////////// |
| 643 // REMOVE_SITE_USAGE_DATA | 645 // kRemoveSiteUsageData |
| 644 if (remove_mask & BrowsingDataRemover::REMOVE_SITE_USAGE_DATA) { | 646 if (base::ContainsValue(remove_mask, &kBrowsingDataTypeSiteUsageData)) { |
| 645 HostContentSettingsMapFactory::GetForProfile(profile_) | 647 HostContentSettingsMapFactory::GetForProfile(profile_) |
| 646 ->ClearSettingsForOneTypeWithPredicate( | 648 ->ClearSettingsForOneTypeWithPredicate( |
| 647 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, | 649 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, |
| 648 base::Bind(&WebsiteSettingsFilterAdapter, filter)); | 650 base::Bind(&WebsiteSettingsFilterAdapter, filter)); |
| 649 } | 651 } |
| 650 | 652 |
| 651 if ((remove_mask & BrowsingDataRemover::REMOVE_SITE_USAGE_DATA) || | 653 if (base::ContainsValue(remove_mask, &kBrowsingDataTypeSiteUsageData) || |
| 652 (remove_mask & BrowsingDataRemover::REMOVE_HISTORY)) { | 654 base::ContainsValue(remove_mask, &kBrowsingDataTypeHistory)) { |
| 653 HostContentSettingsMapFactory::GetForProfile(profile_) | 655 HostContentSettingsMapFactory::GetForProfile(profile_) |
| 654 ->ClearSettingsForOneTypeWithPredicate( | 656 ->ClearSettingsForOneTypeWithPredicate( |
| 655 CONTENT_SETTINGS_TYPE_APP_BANNER, | 657 CONTENT_SETTINGS_TYPE_APP_BANNER, |
| 656 base::Bind(&WebsiteSettingsFilterAdapter, filter)); | 658 base::Bind(&WebsiteSettingsFilterAdapter, filter)); |
| 657 | 659 |
| 658 PermissionDecisionAutoBlocker::GetForProfile(profile_)->RemoveCountsByUrl( | 660 PermissionDecisionAutoBlocker::GetForProfile(profile_)->RemoveCountsByUrl( |
| 659 filter); | 661 filter); |
| 660 } | 662 } |
| 661 | 663 |
| 662 ////////////////////////////////////////////////////////////////////////////// | 664 ////////////////////////////////////////////////////////////////////////////// |
| 663 // Password manager | 665 // Password manager |
| 664 if (remove_mask & BrowsingDataRemover::REMOVE_PASSWORDS) { | 666 if (base::ContainsValue(remove_mask, &kBrowsingDataTypePasswords)) { |
| 665 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords")); | 667 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords")); |
| 666 password_manager::PasswordStore* password_store = | 668 password_manager::PasswordStore* password_store = |
| 667 PasswordStoreFactory::GetForProfile( | 669 PasswordStoreFactory::GetForProfile( |
| 668 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); | 670 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); |
| 669 | 671 |
| 670 if (password_store) { | 672 if (password_store) { |
| 671 clear_passwords_.Start(); | 673 clear_passwords_.Start(); |
| 672 password_store->RemoveLoginsByURLAndTime( | 674 password_store->RemoveLoginsByURLAndTime( |
| 673 filter, delete_begin_, delete_end_, | 675 filter, delete_begin_, delete_end_, |
| 674 clear_passwords_.GetCompletionCallback()); | 676 clear_passwords_.GetCompletionCallback()); |
| 675 } | 677 } |
| 676 | 678 |
| 677 scoped_refptr<net::URLRequestContextGetter> request_context = | 679 scoped_refptr<net::URLRequestContextGetter> request_context = |
| 678 BrowserContext::GetDefaultStoragePartition(profile_) | 680 BrowserContext::GetDefaultStoragePartition(profile_) |
| 679 ->GetURLRequestContext(); | 681 ->GetURLRequestContext(); |
| 680 clear_http_auth_cache_.Start(); | 682 clear_http_auth_cache_.Start(); |
| 681 BrowserThread::PostTaskAndReply( | 683 BrowserThread::PostTaskAndReply( |
| 682 BrowserThread::IO, FROM_HERE, | 684 BrowserThread::IO, FROM_HERE, |
| 683 base::Bind(&ClearHttpAuthCacheOnIOThread, std::move(request_context), | 685 base::Bind(&ClearHttpAuthCacheOnIOThread, std::move(request_context), |
| 684 delete_begin_), | 686 delete_begin_), |
| 685 clear_http_auth_cache_.GetCompletionCallback()); | 687 clear_http_auth_cache_.GetCompletionCallback()); |
| 686 } | 688 } |
| 687 | 689 |
| 688 if (remove_mask & BrowsingDataRemover::REMOVE_COOKIES) { | 690 if (base::ContainsValue(remove_mask, &kBrowsingDataTypeCookies)) { |
| 689 password_manager::PasswordStore* password_store = | 691 password_manager::PasswordStore* password_store = |
| 690 PasswordStoreFactory::GetForProfile(profile_, | 692 PasswordStoreFactory::GetForProfile(profile_, |
| 691 ServiceAccessType::EXPLICIT_ACCESS) | 693 ServiceAccessType::EXPLICIT_ACCESS) |
| 692 .get(); | 694 .get(); |
| 693 | 695 |
| 694 if (password_store) { | 696 if (password_store) { |
| 695 clear_auto_sign_in_.Start(); | 697 clear_auto_sign_in_.Start(); |
| 696 password_store->DisableAutoSignInForOrigins( | 698 password_store->DisableAutoSignInForOrigins( |
| 697 filter, clear_auto_sign_in_.GetCompletionCallback()); | 699 filter, clear_auto_sign_in_.GetCompletionCallback()); |
| 698 } | 700 } |
| 699 } | 701 } |
| 700 | 702 |
| 701 if (remove_mask & BrowsingDataRemover::REMOVE_HISTORY) { | 703 if (base::ContainsValue(remove_mask, &kBrowsingDataTypeHistory)) { |
| 702 password_manager::PasswordStore* password_store = | 704 password_manager::PasswordStore* password_store = |
| 703 PasswordStoreFactory::GetForProfile( | 705 PasswordStoreFactory::GetForProfile( |
| 704 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); | 706 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); |
| 705 | 707 |
| 706 if (password_store) { | 708 if (password_store) { |
| 707 clear_passwords_stats_.Start(); | 709 clear_passwords_stats_.Start(); |
| 708 password_store->RemoveStatisticsByOriginAndTime( | 710 password_store->RemoveStatisticsByOriginAndTime( |
| 709 nullable_filter, delete_begin_, delete_end_, | 711 nullable_filter, delete_begin_, delete_end_, |
| 710 clear_passwords_stats_.GetCompletionCallback()); | 712 clear_passwords_stats_.GetCompletionCallback()); |
| 711 } | 713 } |
| 712 } | 714 } |
| 713 | 715 |
| 714 ////////////////////////////////////////////////////////////////////////////// | 716 ////////////////////////////////////////////////////////////////////////////// |
| 715 // REMOVE_FORM_DATA | 717 // kRemoveFormData |
| 716 // TODO(dmurph): Support all backends with filter (crbug.com/113621). | 718 // TODO(dmurph): Support all backends with filter (crbug.com/113621). |
| 717 if (remove_mask & BrowsingDataRemover::REMOVE_FORM_DATA) { | 719 if (base::ContainsValue(remove_mask, &kBrowsingDataTypeFormData)) { |
| 718 content::RecordAction(UserMetricsAction("ClearBrowsingData_Autofill")); | 720 content::RecordAction(UserMetricsAction("ClearBrowsingData_Autofill")); |
| 719 scoped_refptr<autofill::AutofillWebDataService> web_data_service = | 721 scoped_refptr<autofill::AutofillWebDataService> web_data_service = |
| 720 WebDataServiceFactory::GetAutofillWebDataForProfile( | 722 WebDataServiceFactory::GetAutofillWebDataForProfile( |
| 721 profile_, ServiceAccessType::EXPLICIT_ACCESS); | 723 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
| 722 | 724 |
| 723 if (web_data_service.get()) { | 725 if (web_data_service.get()) { |
| 724 clear_form_.Start(); | 726 clear_form_.Start(); |
| 725 web_data_service->RemoveFormElementsAddedBetween(delete_begin_, | 727 web_data_service->RemoveFormElementsAddedBetween(delete_begin_, |
| 726 delete_end_); | 728 delete_end_); |
| 727 web_data_service->RemoveAutofillDataModifiedBetween( | 729 web_data_service->RemoveAutofillDataModifiedBetween( |
| 728 delete_begin_, delete_end_); | 730 delete_begin_, delete_end_); |
| 729 // The above calls are done on the UI thread but do their work on the DB | 731 // The above calls are done on the UI thread but do their work on the DB |
| 730 // thread. So wait for it. | 732 // thread. So wait for it. |
| 731 BrowserThread::PostTaskAndReply( | 733 BrowserThread::PostTaskAndReply( |
| 732 BrowserThread::DB, FROM_HERE, base::Bind(&base::DoNothing), | 734 BrowserThread::DB, FROM_HERE, base::Bind(&base::DoNothing), |
| 733 clear_form_.GetCompletionCallback()); | 735 clear_form_.GetCompletionCallback()); |
| 734 | 736 |
| 735 autofill::PersonalDataManager* data_manager = | 737 autofill::PersonalDataManager* data_manager = |
| 736 autofill::PersonalDataManagerFactory::GetForProfile(profile_); | 738 autofill::PersonalDataManagerFactory::GetForProfile(profile_); |
| 737 if (data_manager) | 739 if (data_manager) |
| 738 data_manager->Refresh(); | 740 data_manager->Refresh(); |
| 739 } | 741 } |
| 740 } | 742 } |
| 741 | 743 |
| 742 ////////////////////////////////////////////////////////////////////////////// | 744 ////////////////////////////////////////////////////////////////////////////// |
| 743 // REMOVE_CACHE | 745 // kRemoveCache |
| 744 if (remove_mask & BrowsingDataRemover::REMOVE_CACHE) { | 746 if (base::ContainsValue(remove_mask, &kBrowsingDataTypeCache)) { |
| 745 #if !defined(DISABLE_NACL) | 747 #if !defined(DISABLE_NACL) |
| 746 clear_nacl_cache_.Start(); | 748 clear_nacl_cache_.Start(); |
| 747 | 749 |
| 748 BrowserThread::PostTask( | 750 BrowserThread::PostTask( |
| 749 BrowserThread::IO, FROM_HERE, | 751 BrowserThread::IO, FROM_HERE, |
| 750 base::Bind(&ClearNaClCacheOnIOThread, | 752 base::Bind(&ClearNaClCacheOnIOThread, |
| 751 UIThreadTrampoline( | 753 UIThreadTrampoline( |
| 752 clear_nacl_cache_.GetCompletionCallback()))); | 754 clear_nacl_cache_.GetCompletionCallback()))); |
| 753 | 755 |
| 754 clear_pnacl_cache_.Start(); | 756 clear_pnacl_cache_.Start(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 // Network Quality Estimator (NQE) stores the quality (RTT, bandwidth | 792 // Network Quality Estimator (NQE) stores the quality (RTT, bandwidth |
| 791 // etc.) of different networks in prefs. The stored quality is not | 793 // etc.) of different networks in prefs. The stored quality is not |
| 792 // broken down by URLs or timestamps, so clearing the cache should | 794 // broken down by URLs or timestamps, so clearing the cache should |
| 793 // completely clear the prefs. | 795 // completely clear the prefs. |
| 794 ui_nqe_service->ClearPrefs(); | 796 ui_nqe_service->ClearPrefs(); |
| 795 } | 797 } |
| 796 | 798 |
| 797 #if defined(OS_ANDROID) | 799 #if defined(OS_ANDROID) |
| 798 // For now we're considering offline pages as cache, so if we're removing | 800 // For now we're considering offline pages as cache, so if we're removing |
| 799 // cache we should remove offline pages as well. | 801 // cache we should remove offline pages as well. |
| 800 if ((remove_mask & BrowsingDataRemover::REMOVE_CACHE)) { | 802 if (base::ContainsValue(remove_mask, &kBrowsingDataTypeCache)) { |
| 801 clear_offline_page_data_.Start(); | 803 clear_offline_page_data_.Start(); |
| 802 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile_) | 804 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile_) |
| 803 ->DeleteCachedPagesByURLPredicate( | 805 ->DeleteCachedPagesByURLPredicate( |
| 804 filter, | 806 filter, |
| 805 IgnoreArgument<offline_pages::OfflinePageModel::DeletePageResult>( | 807 IgnoreArgument<offline_pages::OfflinePageModel::DeletePageResult>( |
| 806 clear_offline_page_data_.GetCompletionCallback())); | 808 clear_offline_page_data_.GetCompletionCallback())); |
| 807 } | 809 } |
| 808 #endif | 810 #endif |
| 809 } | 811 } |
| 810 | 812 |
| 811 ////////////////////////////////////////////////////////////////////////////// | 813 ////////////////////////////////////////////////////////////////////////////// |
| 812 // REMOVE_PLUGINS | 814 // REMOVE_PLUGINS |
| 813 // Plugins are known to //content and their bulk deletion is implemented in | 815 // Plugins are known to //content and their bulk deletion is implemented in |
| 814 // PluginDataRemover. However, the filtered deletion uses | 816 // PluginDataRemover. However, the filtered deletion uses |
| 815 // BrowsingDataFlashLSOHelper which (currently) has strong dependencies | 817 // BrowsingDataFlashLSOHelper which (currently) has strong dependencies |
| 816 // on //chrome. | 818 // on //chrome. |
| 817 // TODO(msramek): Investigate these dependencies and move the plugin deletion | 819 // TODO(msramek): Investigate these dependencies and move the plugin deletion |
| 818 // to BrowsingDataRemoverImpl in //content. Note that code in //content | 820 // to BrowsingDataRemoverImpl in //content. Note that code in //content |
| 819 // can simply take advantage of PluginDataRemover directly to delete plugin | 821 // can simply take advantage of PluginDataRemover directly to delete plugin |
| 820 // data in bulk. | 822 // data in bulk. |
| 821 #if BUILDFLAG(ENABLE_PLUGINS) | 823 #if BUILDFLAG(ENABLE_PLUGINS) |
| 822 // Plugin is data not separated for protected and unprotected web origins. We | 824 // Plugin is data not separated for protected and unprotected web origins. We |
| 823 // check the origin_type_mask_ to prevent unintended deletion. | 825 // check the origin_type_mask_ to prevent unintended deletion. |
| 824 if (remove_mask & BrowsingDataRemover::REMOVE_PLUGIN_DATA && | 826 if (base::ContainsValue(remove_mask, &kBrowsingDataTypePluginData) && |
| 825 origin_type_mask & BrowsingDataHelper::UNPROTECTED_WEB) { | 827 origin_type_mask & BrowsingDataHelper::UNPROTECTED_WEB) { |
| 826 content::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData")); | 828 content::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData")); |
| 827 clear_plugin_data_count_ = 1; | 829 clear_plugin_data_count_ = 1; |
| 828 | 830 |
| 829 if (filter_builder.IsEmptyBlacklist()) { | 831 if (filter_builder.IsEmptyBlacklist()) { |
| 830 DCHECK(!plugin_data_remover_); | 832 DCHECK(!plugin_data_remover_); |
| 831 plugin_data_remover_.reset( | 833 plugin_data_remover_.reset( |
| 832 content::PluginDataRemover::Create(profile_)); | 834 content::PluginDataRemover::Create(profile_)); |
| 833 base::WaitableEvent* event = | 835 base::WaitableEvent* event = |
| 834 plugin_data_remover_->StartRemoving(delete_begin_); | 836 plugin_data_remover_->StartRemoving(delete_begin_); |
| 835 | 837 |
| 836 base::WaitableEventWatcher::EventCallback watcher_callback = base::Bind( | 838 base::WaitableEventWatcher::EventCallback watcher_callback = base::Bind( |
| 837 &ChromeBrowsingDataRemoverDelegate::OnWaitableEventSignaled, | 839 &ChromeBrowsingDataRemoverDelegate::OnWaitableEventSignaled, |
| 838 weak_ptr_factory_.GetWeakPtr()); | 840 weak_ptr_factory_.GetWeakPtr()); |
| 839 watcher_.StartWatching(event, watcher_callback); | 841 watcher_.StartWatching(event, watcher_callback); |
| 840 } else { | 842 } else { |
| 841 // TODO(msramek): Store filters from the currently executed task on the | 843 // TODO(msramek): Store filters from the currently executed task on the |
| 842 // object to avoid having to copy them to callback methods. | 844 // object to avoid having to copy them to callback methods. |
| 843 flash_lso_helper_->StartFetching(base::Bind( | 845 flash_lso_helper_->StartFetching(base::Bind( |
| 844 &ChromeBrowsingDataRemoverDelegate::OnSitesWithFlashDataFetched, | 846 &ChromeBrowsingDataRemoverDelegate::OnSitesWithFlashDataFetched, |
| 845 weak_ptr_factory_.GetWeakPtr(), | 847 weak_ptr_factory_.GetWeakPtr(), |
| 846 filter_builder.BuildPluginFilter())); | 848 filter_builder.BuildPluginFilter())); |
| 847 } | 849 } |
| 848 } | 850 } |
| 849 #endif | 851 #endif |
| 850 | 852 |
| 851 ////////////////////////////////////////////////////////////////////////////// | 853 ////////////////////////////////////////////////////////////////////////////// |
| 852 // REMOVE_MEDIA_LICENSES | 854 // kBrowsingDataTypeMediaLicenses |
| 853 if (remove_mask & BrowsingDataRemover::REMOVE_MEDIA_LICENSES) { | 855 if (base::ContainsValue(remove_mask, &kBrowsingDataTypeMediaLicenses)) { |
| 854 // TODO(jrummell): This UMA should be renamed to indicate it is for Media | 856 // TODO(jrummell): This UMA should be renamed to indicate it is for Media |
| 855 // Licenses. | 857 // Licenses. |
| 856 content::RecordAction( | 858 content::RecordAction( |
| 857 UserMetricsAction("ClearBrowsingData_ContentLicenses")); | 859 UserMetricsAction("ClearBrowsingData_ContentLicenses")); |
| 858 | 860 |
| 859 #if BUILDFLAG(ENABLE_PLUGINS) | 861 #if BUILDFLAG(ENABLE_PLUGINS) |
| 860 clear_flash_content_licenses_.Start(); | 862 clear_flash_content_licenses_.Start(); |
| 861 if (!pepper_flash_settings_manager_.get()) { | 863 if (!pepper_flash_settings_manager_.get()) { |
| 862 pepper_flash_settings_manager_.reset( | 864 pepper_flash_settings_manager_.reset( |
| 863 new PepperFlashSettingsManager(this, profile_)); | 865 new PepperFlashSettingsManager(this, profile_)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 884 } | 886 } |
| 885 #endif // defined(OS_CHROMEOS) | 887 #endif // defined(OS_CHROMEOS) |
| 886 #endif // BUILDFLAG(ENABLE_PLUGINS) | 888 #endif // BUILDFLAG(ENABLE_PLUGINS) |
| 887 } | 889 } |
| 888 | 890 |
| 889 ////////////////////////////////////////////////////////////////////////////// | 891 ////////////////////////////////////////////////////////////////////////////// |
| 890 // Zero suggest. | 892 // Zero suggest. |
| 891 // Remove omnibox zero-suggest cache results. Filtering is not supported. | 893 // Remove omnibox zero-suggest cache results. Filtering is not supported. |
| 892 // This is not a problem, as deleting more data than necessary will just cause | 894 // This is not a problem, as deleting more data than necessary will just cause |
| 893 // another server round-trip; no data is actually lost. | 895 // another server round-trip; no data is actually lost. |
| 894 if ((remove_mask & (BrowsingDataRemover::REMOVE_CACHE | | 896 if (base::ContainsValue(remove_mask, &kBrowsingDataTypeCache) || |
| 895 BrowsingDataRemover::REMOVE_COOKIES))) { | 897 base::ContainsValue(remove_mask, &kBrowsingDataTypeCookies)) { |
| 896 prefs->SetString(omnibox::kZeroSuggestCachedResults, std::string()); | 898 prefs->SetString(omnibox::kZeroSuggestCachedResults, std::string()); |
| 897 } | 899 } |
| 898 | 900 |
| 899 ////////////////////////////////////////////////////////////////////////////// | 901 ////////////////////////////////////////////////////////////////////////////// |
| 900 // Domain reliability service. | 902 // Domain reliability service. |
| 901 if (remove_mask & (BrowsingDataRemover::REMOVE_COOKIES | | 903 if (base::ContainsValue(remove_mask, &kBrowsingDataTypeCookies) || |
| 902 BrowsingDataRemover::REMOVE_HISTORY)) { | 904 base::ContainsValue(remove_mask, &kBrowsingDataTypeHistory)) { |
| 903 domain_reliability::DomainReliabilityService* service = | 905 domain_reliability::DomainReliabilityService* service = |
| 904 domain_reliability::DomainReliabilityServiceFactory:: | 906 domain_reliability::DomainReliabilityServiceFactory:: |
| 905 GetForBrowserContext(profile_); | 907 GetForBrowserContext(profile_); |
| 906 if (service) { | 908 if (service) { |
| 907 domain_reliability::DomainReliabilityClearMode mode; | 909 domain_reliability::DomainReliabilityClearMode mode; |
| 908 if (remove_mask & BrowsingDataRemover::REMOVE_COOKIES) | 910 if (base::ContainsValue(remove_mask, &kBrowsingDataTypeCookies)) |
| 909 mode = domain_reliability::CLEAR_CONTEXTS; | 911 mode = domain_reliability::CLEAR_CONTEXTS; |
| 910 else | 912 else |
| 911 mode = domain_reliability::CLEAR_BEACONS; | 913 mode = domain_reliability::CLEAR_BEACONS; |
| 912 | 914 |
| 913 clear_domain_reliability_monitor_.Start(); | 915 clear_domain_reliability_monitor_.Start(); |
| 914 service->ClearBrowsingData( | 916 service->ClearBrowsingData( |
| 915 mode, | 917 mode, |
| 916 filter, | 918 filter, |
| 917 clear_domain_reliability_monitor_.GetCompletionCallback()); | 919 clear_domain_reliability_monitor_.GetCompletionCallback()); |
| 918 } | 920 } |
| 919 } | 921 } |
| 920 | 922 |
| 921 ////////////////////////////////////////////////////////////////////////////// | 923 ////////////////////////////////////////////////////////////////////////////// |
| 922 // REMOVE_WEBAPP_DATA | 924 // kBrowsingDataTypeWebappData |
| 923 #if defined(OS_ANDROID) | 925 #if defined(OS_ANDROID) |
| 924 // Clear all data associated with registered webapps. | 926 // Clear all data associated with registered webapps. |
| 925 if (remove_mask & BrowsingDataRemover::REMOVE_WEBAPP_DATA) | 927 if (base::ContainsValue(remove_mask, &kBrowsingDataTypeWebAppData)) |
| 926 webapp_registry_->UnregisterWebappsForUrls(filter); | 928 webapp_registry_->UnregisterWebappsForUrls(filter); |
| 927 #endif | 929 #endif |
| 928 | 930 |
| 929 ////////////////////////////////////////////////////////////////////////////// | 931 ////////////////////////////////////////////////////////////////////////////// |
| 930 // Remove external protocol data. | 932 // Remove external protocol data. |
| 931 if (remove_mask & BrowsingDataRemover::REMOVE_EXTERNAL_PROTOCOL_DATA) | 933 if (base::ContainsValue(remove_mask, |
| 934 &kBrowsingDataTypeExternalProtocolData)) { |
| 932 ExternalProtocolHandler::ClearData(profile_); | 935 ExternalProtocolHandler::ClearData(profile_); |
| 936 } |
| 933 | 937 |
| 934 synchronous_clear_operations_.GetCompletionCallback().Run(); | 938 synchronous_clear_operations_.GetCompletionCallback().Run(); |
| 935 } | 939 } |
| 936 | 940 |
| 937 void ChromeBrowsingDataRemoverDelegate::NotifyIfDone() { | 941 void ChromeBrowsingDataRemoverDelegate::NotifyIfDone() { |
| 938 if (!AllDone()) | 942 if (!AllDone()) |
| 939 return; | 943 return; |
| 940 | 944 |
| 941 DCHECK(!callback_.is_null()); | 945 DCHECK(!callback_.is_null()); |
| 942 callback_.Run(); | 946 callback_.Run(); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 } | 1060 } |
| 1057 | 1061 |
| 1058 void ChromeBrowsingDataRemoverDelegate:: | 1062 void ChromeBrowsingDataRemoverDelegate:: |
| 1059 OnDeauthorizeFlashContentLicensesCompleted( | 1063 OnDeauthorizeFlashContentLicensesCompleted( |
| 1060 uint32_t request_id, | 1064 uint32_t request_id, |
| 1061 bool /* success */) { | 1065 bool /* success */) { |
| 1062 DCHECK_EQ(request_id, deauthorize_flash_content_licenses_request_id_); | 1066 DCHECK_EQ(request_id, deauthorize_flash_content_licenses_request_id_); |
| 1063 clear_flash_content_licenses_.GetCompletionCallback().Run(); | 1067 clear_flash_content_licenses_.GetCompletionCallback().Run(); |
| 1064 } | 1068 } |
| 1065 #endif | 1069 #endif |
| OLD | NEW |