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