Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc

Issue 2733393003: Split browsing data masks between content and embedder (Closed)
Patch Set: Rebase (merged automatically) Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 #include "components/translate/core/browser/language_model.h" 67 #include "components/translate/core/browser/language_model.h"
68 #include "content/public/browser/browsing_data_filter_builder.h" 68 #include "content/public/browser/browsing_data_filter_builder.h"
69 #include "content/public/browser/plugin_data_remover.h" 69 #include "content/public/browser/plugin_data_remover.h"
70 #include "content/public/browser/ssl_host_state_delegate.h" 70 #include "content/public/browser/ssl_host_state_delegate.h"
71 #include "content/public/browser/storage_partition.h" 71 #include "content/public/browser/storage_partition.h"
72 #include "content/public/browser/user_metrics.h" 72 #include "content/public/browser/user_metrics.h"
73 #include "net/cookies/cookie_store.h" 73 #include "net/cookies/cookie_store.h"
74 #include "net/http/http_transaction_factory.h" 74 #include "net/http/http_transaction_factory.h"
75 #include "net/url_request/url_request_context.h" 75 #include "net/url_request/url_request_context.h"
76 #include "net/url_request/url_request_context_getter.h" 76 #include "net/url_request/url_request_context_getter.h"
77 #include "url/url_util.h"
77 78
78 #if defined(OS_ANDROID) 79 #if defined(OS_ANDROID)
79 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" 80 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
80 #include "chrome/browser/android/webapps/webapp_registry.h" 81 #include "chrome/browser/android/webapps/webapp_registry.h"
81 #include "chrome/browser/precache/precache_manager_factory.h" 82 #include "chrome/browser/precache/precache_manager_factory.h"
82 #include "components/offline_pages/core/offline_page_feature.h" 83 #include "components/offline_pages/core/offline_page_feature.h"
83 #include "components/offline_pages/core/offline_page_model.h" 84 #include "components/offline_pages/core/offline_page_model.h"
84 #include "components/precache/content/precache_manager.h" 85 #include "components/precache/content/precache_manager.h"
85 #endif 86 #endif
86 87
87 #if BUILDFLAG(ENABLE_EXTENSIONS) 88 #if BUILDFLAG(ENABLE_EXTENSIONS)
88 #include "chrome/browser/extensions/activity_log/activity_log.h" 89 #include "chrome/browser/extensions/activity_log/activity_log.h"
89 #include "extensions/browser/extension_prefs.h" 90 #include "extensions/browser/extension_prefs.h"
91 #include "extensions/common/constants.h"
90 #endif 92 #endif
91 93
92 #if BUILDFLAG(ENABLE_SESSION_SERVICE) 94 #if BUILDFLAG(ENABLE_SESSION_SERVICE)
93 #include "chrome/browser/sessions/session_service.h" 95 #include "chrome/browser/sessions/session_service.h"
94 #include "chrome/browser/sessions/session_service_factory.h" 96 #include "chrome/browser/sessions/session_service_factory.h"
95 #endif 97 #endif
96 98
97 #if defined(OS_CHROMEOS) 99 #if defined(OS_CHROMEOS)
98 #include "chrome/browser/chromeos/profiles/profile_helper.h" 100 #include "chrome/browser/chromeos/profiles/profile_helper.h"
99 #include "chromeos/attestation/attestation_constants.h" 101 #include "chromeos/attestation/attestation_constants.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 #if defined(OS_ANDROID) 303 #if defined(OS_ANDROID)
302 webapp_registry_(new WebappRegistry()), 304 webapp_registry_(new WebappRegistry()),
303 #endif 305 #endif
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
313 bool ChromeBrowsingDataRemoverDelegate::DoesOriginMatchEmbedderMask(
314 int origin_type_mask,
315 const GURL& origin,
316 storage::SpecialStoragePolicy* policy) const {
317 DCHECK_EQ(0, origin_type_mask & (ORIGIN_TYPE_EMBEDDER_BEGIN - 1))
318 << "|origin_type_mask| can only contain origin types defined in "
319 << "the embedder.";
320
321 #if BUILDFLAG(ENABLE_EXTENSIONS)
322 // Packaged apps and extensions match iff EXTENSION.
323 if ((origin.GetOrigin().scheme() == extensions::kExtensionScheme) &&
324 (origin_type_mask & ORIGIN_TYPE_EXTENSION)) {
325 return true;
326 }
327 origin_type_mask &= ~ORIGIN_TYPE_EXTENSION;
328 #endif
329
330 DCHECK(!origin_type_mask)
331 << "DoesOriginMatchEmbedderMask must handle all origin types.";
332
333 return false;
334 }
335
311 void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData( 336 void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData(
312 const base::Time& delete_begin, 337 const base::Time& delete_begin,
313 const base::Time& delete_end, 338 const base::Time& delete_end,
314 int remove_mask, 339 int remove_mask,
315 const BrowsingDataFilterBuilder& filter_builder, 340 const BrowsingDataFilterBuilder& filter_builder,
316 int origin_type_mask, 341 int origin_type_mask,
317 const base::Closure& callback) { 342 const base::Closure& callback) {
343 DCHECK(((remove_mask & ~FILTERABLE_DATA_TYPES) == 0) ||
344 filter_builder.IsEmptyBlacklist());
345
346 if (origin_type_mask & BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB) {
347 content::RecordAction(
348 UserMetricsAction("ClearBrowsingData_MaskContainsUnprotectedWeb"));
349 }
350 if (origin_type_mask & BrowsingDataRemover::ORIGIN_TYPE_PROTECTED_WEB) {
351 content::RecordAction(
352 UserMetricsAction("ClearBrowsingData_MaskContainsProtectedWeb"));
353 }
354 #if BUILDFLAG(ENABLE_EXTENSIONS)
355 if (origin_type_mask & ORIGIN_TYPE_EXTENSION) {
356 content::RecordAction(
357 UserMetricsAction("ClearBrowsingData_MaskContainsExtension"));
358 }
359 #endif
360 // If this fires, we added a new BrowsingDataHelper::OriginTypeMask without
361 // updating the user metrics above.
362 static_assert(
363 ALL_ORIGIN_TYPES == (BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB |
364 #if BUILDFLAG(ENABLE_EXTENSIONS)
365 ORIGIN_TYPE_EXTENSION |
366 #endif
367 BrowsingDataRemover::ORIGIN_TYPE_PROTECTED_WEB),
368 "OriginTypeMask has been updated without updating user metrics");
369
318 ////////////////////////////////////////////////////////////////////////////// 370 //////////////////////////////////////////////////////////////////////////////
319 // INITIALIZATION 371 // INITIALIZATION
320 synchronous_clear_operations_.Start(); 372 synchronous_clear_operations_.Start();
321 callback_ = callback; 373 callback_ = callback;
322 374
323 delete_begin_ = delete_begin; 375 delete_begin_ = delete_begin;
324 delete_end_ = delete_end; 376 delete_end_ = delete_end;
325 377
326 base::Callback<bool(const GURL& url)> filter = 378 base::Callback<bool(const GURL& url)> filter =
327 filter_builder.BuildGeneralFilter(); 379 filter_builder.BuildGeneralFilter();
328 380
329 // Some backends support a filter that |is_null()| to make complete deletion 381 // Some backends support a filter that |is_null()| to make complete deletion
330 // more efficient. 382 // more efficient.
331 base::Callback<bool(const GURL&)> nullable_filter = 383 base::Callback<bool(const GURL&)> nullable_filter =
332 filter_builder.IsEmptyBlacklist() ? base::Callback<bool(const GURL&)>() 384 filter_builder.IsEmptyBlacklist() ? base::Callback<bool(const GURL&)>()
333 : filter; 385 : filter;
334 386
335 // Managed devices and supervised users can have restrictions on history 387 // Managed devices and supervised users can have restrictions on history
336 // deletion. 388 // deletion.
337 PrefService* prefs = profile_->GetPrefs(); 389 PrefService* prefs = profile_->GetPrefs();
338 bool may_delete_history = prefs->GetBoolean( 390 bool may_delete_history = prefs->GetBoolean(
339 prefs::kAllowDeletingBrowserHistory); 391 prefs::kAllowDeletingBrowserHistory);
340 392
341 // All the UI entry points into the BrowsingDataRemoverImpl should be 393 // All the UI entry points into the BrowsingDataRemoverImpl should be
342 // disabled, but this will fire if something was missed or added. 394 // disabled, but this will fire if something was missed or added.
343 DCHECK(may_delete_history || 395 DCHECK(may_delete_history ||
344 (remove_mask & BrowsingDataRemover::REMOVE_NOCHECKS) || 396 (remove_mask & BrowsingDataRemover::DATA_TYPE_NO_CHECKS) ||
345 (!(remove_mask & BrowsingDataRemover::REMOVE_HISTORY) && 397 (!(remove_mask & DATA_TYPE_HISTORY) &&
346 !(remove_mask & BrowsingDataRemover::REMOVE_DOWNLOADS))); 398 !(remove_mask & BrowsingDataRemover::DATA_TYPE_DOWNLOADS)));
347 399
348 ////////////////////////////////////////////////////////////////////////////// 400 //////////////////////////////////////////////////////////////////////////////
349 // REMOVE_HISTORY 401 // DATA_TYPE_HISTORY
350 if ((remove_mask & BrowsingDataRemover::REMOVE_HISTORY) && 402 if ((remove_mask & DATA_TYPE_HISTORY) && may_delete_history) {
351 may_delete_history) {
352 history::HistoryService* history_service = 403 history::HistoryService* history_service =
353 HistoryServiceFactory::GetForProfile( 404 HistoryServiceFactory::GetForProfile(
354 profile_, ServiceAccessType::EXPLICIT_ACCESS); 405 profile_, ServiceAccessType::EXPLICIT_ACCESS);
355 if (history_service) { 406 if (history_service) {
356 // TODO(dmurph): Support all backends with filter (crbug.com/113621). 407 // TODO(dmurph): Support all backends with filter (crbug.com/113621).
357 content::RecordAction(UserMetricsAction("ClearBrowsingData_History")); 408 content::RecordAction(UserMetricsAction("ClearBrowsingData_History"));
358 clear_history_.Start(); 409 clear_history_.Start();
359 history_service->ExpireLocalAndRemoteHistoryBetween( 410 history_service->ExpireLocalAndRemoteHistoryBetween(
360 WebHistoryServiceFactory::GetForProfile(profile_), std::set<GURL>(), 411 WebHistoryServiceFactory::GetForProfile(profile_), std::set<GURL>(),
361 delete_begin_, delete_end_, 412 delete_begin_, delete_end_,
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 // Rename the method to indicate its more general usage. 616 // Rename the method to indicate its more general usage.
566 if (profile_->GetSSLHostStateDelegate()) { 617 if (profile_->GetSSLHostStateDelegate()) {
567 profile_->GetSSLHostStateDelegate()->Clear( 618 profile_->GetSSLHostStateDelegate()->Clear(
568 filter_builder.IsEmptyBlacklist() 619 filter_builder.IsEmptyBlacklist()
569 ? base::Callback<bool(const std::string&)>() 620 ? base::Callback<bool(const std::string&)>()
570 : filter_builder.BuildPluginFilter()); 621 : filter_builder.BuildPluginFilter());
571 } 622 }
572 } 623 }
573 624
574 ////////////////////////////////////////////////////////////////////////////// 625 //////////////////////////////////////////////////////////////////////////////
575 // REMOVE_DOWNLOADS 626 // DATA_TYPE_DOWNLOADS
576 if ((remove_mask & BrowsingDataRemover::REMOVE_DOWNLOADS) && 627 if ((remove_mask & BrowsingDataRemover::DATA_TYPE_DOWNLOADS) &&
577 may_delete_history) { 628 may_delete_history) {
578 DownloadPrefs* download_prefs = DownloadPrefs::FromDownloadManager( 629 DownloadPrefs* download_prefs = DownloadPrefs::FromDownloadManager(
579 BrowserContext::GetDownloadManager(profile_)); 630 BrowserContext::GetDownloadManager(profile_));
580 download_prefs->SetSaveFilePath(download_prefs->DownloadPath()); 631 download_prefs->SetSaveFilePath(download_prefs->DownloadPath());
581 } 632 }
582 633
583 ////////////////////////////////////////////////////////////////////////////// 634 //////////////////////////////////////////////////////////////////////////////
584 // REMOVE_COOKIES 635 // DATA_TYPE_COOKIES
585 // We ignore the REMOVE_COOKIES request if UNPROTECTED_WEB is not set, 636 // We ignore the DATA_TYPE_COOKIES request if UNPROTECTED_WEB is not set,
586 // so that callers who request REMOVE_SITE_DATA with PROTECTED_WEB 637 // so that callers who request DATA_TYPE_SITE_DATA with PROTECTED_WEB
587 // don't accidentally remove the cookies that are associated with the 638 // don't accidentally remove the cookies that are associated with the
588 // UNPROTECTED_WEB origin. This is necessary because cookies are not separated 639 // UNPROTECTED_WEB origin. This is necessary because cookies are not separated
589 // between UNPROTECTED_WEB and PROTECTED_WEB. 640 // between UNPROTECTED_WEB and PROTECTED_WEB.
590 if (remove_mask & BrowsingDataRemover::REMOVE_COOKIES && 641 if (remove_mask & BrowsingDataRemover::DATA_TYPE_COOKIES &&
591 origin_type_mask & BrowsingDataHelper::UNPROTECTED_WEB) { 642 origin_type_mask & BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB) {
592 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies")); 643 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies"));
593 644
594 // Clear the safebrowsing cookies only if time period is for "all time". It 645 // 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 646 // 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 647 // hours/days to the safebrowsing cookies since they aren't the result of
597 // any user action. 648 // any user action.
598 if (delete_begin_ == base::Time()) { 649 if (delete_begin_ == base::Time()) {
599 safe_browsing::SafeBrowsingService* sb_service = 650 safe_browsing::SafeBrowsingService* sb_service =
600 g_browser_process->safe_browsing_service(); 651 g_browser_process->safe_browsing_service();
601 if (sb_service) { 652 if (sb_service) {
(...skipping 22 matching lines...) Expand all
624 &ChromeBrowsingDataRemoverDelegate::OnClearedCookies, 675 &ChromeBrowsingDataRemoverDelegate::OnClearedCookies,
625 weak_ptr_factory_.GetWeakPtr())))); 676 weak_ptr_factory_.GetWeakPtr()))));
626 } 677 }
627 } 678 }
628 } 679 }
629 680
630 MediaDeviceIDSalt::Reset(profile_->GetPrefs()); 681 MediaDeviceIDSalt::Reset(profile_->GetPrefs());
631 } 682 }
632 683
633 ////////////////////////////////////////////////////////////////////////////// 684 //////////////////////////////////////////////////////////////////////////////
634 // REMOVE_DURABLE_PERMISSION 685 // DATA_TYPE_DURABLE_PERMISSION
635 if (remove_mask & BrowsingDataRemover::REMOVE_DURABLE_PERMISSION) { 686 if (remove_mask & DATA_TYPE_DURABLE_PERMISSION) {
636 HostContentSettingsMapFactory::GetForProfile(profile_) 687 HostContentSettingsMapFactory::GetForProfile(profile_)
637 ->ClearSettingsForOneTypeWithPredicate( 688 ->ClearSettingsForOneTypeWithPredicate(
638 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, 689 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE,
639 base::Bind(&WebsiteSettingsFilterAdapter, filter)); 690 base::Bind(&WebsiteSettingsFilterAdapter, filter));
640 } 691 }
641 692
642 ////////////////////////////////////////////////////////////////////////////// 693 //////////////////////////////////////////////////////////////////////////////
643 // REMOVE_SITE_USAGE_DATA 694 // DATA_TYPE_SITE_USAGE_DATA
644 if (remove_mask & BrowsingDataRemover::REMOVE_SITE_USAGE_DATA) { 695 if (remove_mask & DATA_TYPE_SITE_USAGE_DATA) {
645 HostContentSettingsMapFactory::GetForProfile(profile_) 696 HostContentSettingsMapFactory::GetForProfile(profile_)
646 ->ClearSettingsForOneTypeWithPredicate( 697 ->ClearSettingsForOneTypeWithPredicate(
647 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, 698 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT,
648 base::Bind(&WebsiteSettingsFilterAdapter, filter)); 699 base::Bind(&WebsiteSettingsFilterAdapter, filter));
649 } 700 }
650 701
651 if ((remove_mask & BrowsingDataRemover::REMOVE_SITE_USAGE_DATA) || 702 if ((remove_mask & DATA_TYPE_SITE_USAGE_DATA) ||
652 (remove_mask & BrowsingDataRemover::REMOVE_HISTORY)) { 703 (remove_mask & DATA_TYPE_HISTORY)) {
653 HostContentSettingsMapFactory::GetForProfile(profile_) 704 HostContentSettingsMapFactory::GetForProfile(profile_)
654 ->ClearSettingsForOneTypeWithPredicate( 705 ->ClearSettingsForOneTypeWithPredicate(
655 CONTENT_SETTINGS_TYPE_APP_BANNER, 706 CONTENT_SETTINGS_TYPE_APP_BANNER,
656 base::Bind(&WebsiteSettingsFilterAdapter, filter)); 707 base::Bind(&WebsiteSettingsFilterAdapter, filter));
657 708
658 PermissionDecisionAutoBlocker::GetForProfile(profile_)->RemoveCountsByUrl( 709 PermissionDecisionAutoBlocker::GetForProfile(profile_)->RemoveCountsByUrl(
659 filter); 710 filter);
660 } 711 }
661 712
662 ////////////////////////////////////////////////////////////////////////////// 713 //////////////////////////////////////////////////////////////////////////////
663 // Password manager 714 // Password manager
664 if (remove_mask & BrowsingDataRemover::REMOVE_PASSWORDS) { 715 if (remove_mask & DATA_TYPE_PASSWORDS) {
665 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords")); 716 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords"));
666 password_manager::PasswordStore* password_store = 717 password_manager::PasswordStore* password_store =
667 PasswordStoreFactory::GetForProfile( 718 PasswordStoreFactory::GetForProfile(
668 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); 719 profile_, ServiceAccessType::EXPLICIT_ACCESS).get();
669 720
670 if (password_store) { 721 if (password_store) {
671 clear_passwords_.Start(); 722 clear_passwords_.Start();
672 password_store->RemoveLoginsByURLAndTime( 723 password_store->RemoveLoginsByURLAndTime(
673 filter, delete_begin_, delete_end_, 724 filter, delete_begin_, delete_end_,
674 clear_passwords_.GetCompletionCallback()); 725 clear_passwords_.GetCompletionCallback());
675 } 726 }
676 727
677 scoped_refptr<net::URLRequestContextGetter> request_context = 728 scoped_refptr<net::URLRequestContextGetter> request_context =
678 BrowserContext::GetDefaultStoragePartition(profile_) 729 BrowserContext::GetDefaultStoragePartition(profile_)
679 ->GetURLRequestContext(); 730 ->GetURLRequestContext();
680 clear_http_auth_cache_.Start(); 731 clear_http_auth_cache_.Start();
681 BrowserThread::PostTaskAndReply( 732 BrowserThread::PostTaskAndReply(
682 BrowserThread::IO, FROM_HERE, 733 BrowserThread::IO, FROM_HERE,
683 base::Bind(&ClearHttpAuthCacheOnIOThread, std::move(request_context), 734 base::Bind(&ClearHttpAuthCacheOnIOThread, std::move(request_context),
684 delete_begin_), 735 delete_begin_),
685 clear_http_auth_cache_.GetCompletionCallback()); 736 clear_http_auth_cache_.GetCompletionCallback());
686 } 737 }
687 738
688 if (remove_mask & BrowsingDataRemover::REMOVE_COOKIES) { 739 if (remove_mask & BrowsingDataRemover::DATA_TYPE_COOKIES) {
689 password_manager::PasswordStore* password_store = 740 password_manager::PasswordStore* password_store =
690 PasswordStoreFactory::GetForProfile(profile_, 741 PasswordStoreFactory::GetForProfile(profile_,
691 ServiceAccessType::EXPLICIT_ACCESS) 742 ServiceAccessType::EXPLICIT_ACCESS)
692 .get(); 743 .get();
693 744
694 if (password_store) { 745 if (password_store) {
695 clear_auto_sign_in_.Start(); 746 clear_auto_sign_in_.Start();
696 password_store->DisableAutoSignInForOrigins( 747 password_store->DisableAutoSignInForOrigins(
697 filter, clear_auto_sign_in_.GetCompletionCallback()); 748 filter, clear_auto_sign_in_.GetCompletionCallback());
698 } 749 }
699 } 750 }
700 751
701 if (remove_mask & BrowsingDataRemover::REMOVE_HISTORY) { 752 if (remove_mask & DATA_TYPE_HISTORY) {
702 password_manager::PasswordStore* password_store = 753 password_manager::PasswordStore* password_store =
703 PasswordStoreFactory::GetForProfile( 754 PasswordStoreFactory::GetForProfile(
704 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); 755 profile_, ServiceAccessType::EXPLICIT_ACCESS).get();
705 756
706 if (password_store) { 757 if (password_store) {
707 clear_passwords_stats_.Start(); 758 clear_passwords_stats_.Start();
708 password_store->RemoveStatisticsByOriginAndTime( 759 password_store->RemoveStatisticsByOriginAndTime(
709 nullable_filter, delete_begin_, delete_end_, 760 nullable_filter, delete_begin_, delete_end_,
710 clear_passwords_stats_.GetCompletionCallback()); 761 clear_passwords_stats_.GetCompletionCallback());
711 } 762 }
712 } 763 }
713 764
714 ////////////////////////////////////////////////////////////////////////////// 765 //////////////////////////////////////////////////////////////////////////////
715 // REMOVE_FORM_DATA 766 // DATA_TYPE_FORM_DATA
716 // TODO(dmurph): Support all backends with filter (crbug.com/113621). 767 // TODO(dmurph): Support all backends with filter (crbug.com/113621).
717 if (remove_mask & BrowsingDataRemover::REMOVE_FORM_DATA) { 768 if (remove_mask & DATA_TYPE_FORM_DATA) {
718 content::RecordAction(UserMetricsAction("ClearBrowsingData_Autofill")); 769 content::RecordAction(UserMetricsAction("ClearBrowsingData_Autofill"));
719 scoped_refptr<autofill::AutofillWebDataService> web_data_service = 770 scoped_refptr<autofill::AutofillWebDataService> web_data_service =
720 WebDataServiceFactory::GetAutofillWebDataForProfile( 771 WebDataServiceFactory::GetAutofillWebDataForProfile(
721 profile_, ServiceAccessType::EXPLICIT_ACCESS); 772 profile_, ServiceAccessType::EXPLICIT_ACCESS);
722 773
723 if (web_data_service.get()) { 774 if (web_data_service.get()) {
724 clear_form_.Start(); 775 clear_form_.Start();
725 web_data_service->RemoveFormElementsAddedBetween(delete_begin_, 776 web_data_service->RemoveFormElementsAddedBetween(delete_begin_,
726 delete_end_); 777 delete_end_);
727 web_data_service->RemoveAutofillDataModifiedBetween( 778 web_data_service->RemoveAutofillDataModifiedBetween(
728 delete_begin_, delete_end_); 779 delete_begin_, delete_end_);
729 // The above calls are done on the UI thread but do their work on the DB 780 // The above calls are done on the UI thread but do their work on the DB
730 // thread. So wait for it. 781 // thread. So wait for it.
731 BrowserThread::PostTaskAndReply( 782 BrowserThread::PostTaskAndReply(
732 BrowserThread::DB, FROM_HERE, base::Bind(&base::DoNothing), 783 BrowserThread::DB, FROM_HERE, base::Bind(&base::DoNothing),
733 clear_form_.GetCompletionCallback()); 784 clear_form_.GetCompletionCallback());
734 785
735 autofill::PersonalDataManager* data_manager = 786 autofill::PersonalDataManager* data_manager =
736 autofill::PersonalDataManagerFactory::GetForProfile(profile_); 787 autofill::PersonalDataManagerFactory::GetForProfile(profile_);
737 if (data_manager) 788 if (data_manager)
738 data_manager->Refresh(); 789 data_manager->Refresh();
739 } 790 }
740 } 791 }
741 792
742 ////////////////////////////////////////////////////////////////////////////// 793 //////////////////////////////////////////////////////////////////////////////
743 // REMOVE_CACHE 794 // DATA_TYPE_CACHE
744 if (remove_mask & BrowsingDataRemover::REMOVE_CACHE) { 795 if (remove_mask & BrowsingDataRemover::DATA_TYPE_CACHE) {
745 #if !defined(DISABLE_NACL) 796 #if !defined(DISABLE_NACL)
746 clear_nacl_cache_.Start(); 797 clear_nacl_cache_.Start();
747 798
748 BrowserThread::PostTask( 799 BrowserThread::PostTask(
749 BrowserThread::IO, FROM_HERE, 800 BrowserThread::IO, FROM_HERE,
750 base::Bind(&ClearNaClCacheOnIOThread, 801 base::Bind(&ClearNaClCacheOnIOThread,
751 UIThreadTrampoline( 802 UIThreadTrampoline(
752 clear_nacl_cache_.GetCompletionCallback()))); 803 clear_nacl_cache_.GetCompletionCallback())));
753 804
754 clear_pnacl_cache_.Start(); 805 clear_pnacl_cache_.Start();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 // Network Quality Estimator (NQE) stores the quality (RTT, bandwidth 841 // Network Quality Estimator (NQE) stores the quality (RTT, bandwidth
791 // etc.) of different networks in prefs. The stored quality is not 842 // etc.) of different networks in prefs. The stored quality is not
792 // broken down by URLs or timestamps, so clearing the cache should 843 // broken down by URLs or timestamps, so clearing the cache should
793 // completely clear the prefs. 844 // completely clear the prefs.
794 ui_nqe_service->ClearPrefs(); 845 ui_nqe_service->ClearPrefs();
795 } 846 }
796 847
797 #if defined(OS_ANDROID) 848 #if defined(OS_ANDROID)
798 // For now we're considering offline pages as cache, so if we're removing 849 // For now we're considering offline pages as cache, so if we're removing
799 // cache we should remove offline pages as well. 850 // cache we should remove offline pages as well.
800 if ((remove_mask & BrowsingDataRemover::REMOVE_CACHE)) { 851 if ((remove_mask & BrowsingDataRemover::DATA_TYPE_CACHE)) {
801 clear_offline_page_data_.Start(); 852 clear_offline_page_data_.Start();
802 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile_) 853 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile_)
803 ->DeleteCachedPagesByURLPredicate( 854 ->DeleteCachedPagesByURLPredicate(
804 filter, 855 filter,
805 IgnoreArgument<offline_pages::OfflinePageModel::DeletePageResult>( 856 IgnoreArgument<offline_pages::OfflinePageModel::DeletePageResult>(
806 clear_offline_page_data_.GetCompletionCallback())); 857 clear_offline_page_data_.GetCompletionCallback()));
807 } 858 }
808 #endif 859 #endif
809 } 860 }
810 861
811 ////////////////////////////////////////////////////////////////////////////// 862 //////////////////////////////////////////////////////////////////////////////
812 // REMOVE_PLUGINS 863 // DATA_TYPE_PLUGINS
813 // Plugins are known to //content and their bulk deletion is implemented in 864 // Plugins are known to //content and their bulk deletion is implemented in
814 // PluginDataRemover. However, the filtered deletion uses 865 // PluginDataRemover. However, the filtered deletion uses
815 // BrowsingDataFlashLSOHelper which (currently) has strong dependencies 866 // BrowsingDataFlashLSOHelper which (currently) has strong dependencies
816 // on //chrome. 867 // on //chrome.
817 // TODO(msramek): Investigate these dependencies and move the plugin deletion 868 // TODO(msramek): Investigate these dependencies and move the plugin deletion
818 // to BrowsingDataRemoverImpl in //content. Note that code in //content 869 // to BrowsingDataRemoverImpl in //content. Note that code in //content
819 // can simply take advantage of PluginDataRemover directly to delete plugin 870 // can simply take advantage of PluginDataRemover directly to delete plugin
820 // data in bulk. 871 // data in bulk.
821 #if BUILDFLAG(ENABLE_PLUGINS) 872 #if BUILDFLAG(ENABLE_PLUGINS)
822 // Plugin is data not separated for protected and unprotected web origins. We 873 // Plugin is data not separated for protected and unprotected web origins. We
823 // check the origin_type_mask_ to prevent unintended deletion. 874 // check the origin_type_mask_ to prevent unintended deletion.
824 if (remove_mask & BrowsingDataRemover::REMOVE_PLUGIN_DATA && 875 if (remove_mask & DATA_TYPE_PLUGIN_DATA &&
825 origin_type_mask & BrowsingDataHelper::UNPROTECTED_WEB) { 876 origin_type_mask & BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB) {
826 content::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData")); 877 content::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData"));
827 clear_plugin_data_count_ = 1; 878 clear_plugin_data_count_ = 1;
828 879
829 if (filter_builder.IsEmptyBlacklist()) { 880 if (filter_builder.IsEmptyBlacklist()) {
830 DCHECK(!plugin_data_remover_); 881 DCHECK(!plugin_data_remover_);
831 plugin_data_remover_.reset( 882 plugin_data_remover_.reset(
832 content::PluginDataRemover::Create(profile_)); 883 content::PluginDataRemover::Create(profile_));
833 base::WaitableEvent* event = 884 base::WaitableEvent* event =
834 plugin_data_remover_->StartRemoving(delete_begin_); 885 plugin_data_remover_->StartRemoving(delete_begin_);
835 886
836 base::WaitableEventWatcher::EventCallback watcher_callback = base::Bind( 887 base::WaitableEventWatcher::EventCallback watcher_callback = base::Bind(
837 &ChromeBrowsingDataRemoverDelegate::OnWaitableEventSignaled, 888 &ChromeBrowsingDataRemoverDelegate::OnWaitableEventSignaled,
838 weak_ptr_factory_.GetWeakPtr()); 889 weak_ptr_factory_.GetWeakPtr());
839 watcher_.StartWatching(event, watcher_callback); 890 watcher_.StartWatching(event, watcher_callback);
840 } else { 891 } else {
841 // TODO(msramek): Store filters from the currently executed task on the 892 // TODO(msramek): Store filters from the currently executed task on the
842 // object to avoid having to copy them to callback methods. 893 // object to avoid having to copy them to callback methods.
843 flash_lso_helper_->StartFetching(base::Bind( 894 flash_lso_helper_->StartFetching(base::Bind(
844 &ChromeBrowsingDataRemoverDelegate::OnSitesWithFlashDataFetched, 895 &ChromeBrowsingDataRemoverDelegate::OnSitesWithFlashDataFetched,
845 weak_ptr_factory_.GetWeakPtr(), 896 weak_ptr_factory_.GetWeakPtr(),
846 filter_builder.BuildPluginFilter())); 897 filter_builder.BuildPluginFilter()));
847 } 898 }
848 } 899 }
849 #endif 900 #endif
850 901
851 ////////////////////////////////////////////////////////////////////////////// 902 //////////////////////////////////////////////////////////////////////////////
852 // REMOVE_MEDIA_LICENSES 903 // DATA_TYPE_MEDIA_LICENSES
853 if (remove_mask & BrowsingDataRemover::REMOVE_MEDIA_LICENSES) { 904 if (remove_mask & BrowsingDataRemover::DATA_TYPE_MEDIA_LICENSES) {
854 // TODO(jrummell): This UMA should be renamed to indicate it is for Media 905 // TODO(jrummell): This UMA should be renamed to indicate it is for Media
855 // Licenses. 906 // Licenses.
856 content::RecordAction( 907 content::RecordAction(
857 UserMetricsAction("ClearBrowsingData_ContentLicenses")); 908 UserMetricsAction("ClearBrowsingData_ContentLicenses"));
858 909
859 #if BUILDFLAG(ENABLE_PLUGINS) 910 #if BUILDFLAG(ENABLE_PLUGINS)
860 clear_flash_content_licenses_.Start(); 911 clear_flash_content_licenses_.Start();
861 if (!pepper_flash_settings_manager_.get()) { 912 if (!pepper_flash_settings_manager_.get()) {
862 pepper_flash_settings_manager_.reset( 913 pepper_flash_settings_manager_.reset(
863 new PepperFlashSettingsManager(this, profile_)); 914 new PepperFlashSettingsManager(this, profile_));
(...skipping 21 matching lines...) Expand all
885 weak_ptr_factory_.GetWeakPtr())); 936 weak_ptr_factory_.GetWeakPtr()));
886 } 937 }
887 #endif // defined(OS_CHROMEOS) 938 #endif // defined(OS_CHROMEOS)
888 } 939 }
889 940
890 ////////////////////////////////////////////////////////////////////////////// 941 //////////////////////////////////////////////////////////////////////////////
891 // Zero suggest. 942 // Zero suggest.
892 // Remove omnibox zero-suggest cache results. Filtering is not supported. 943 // Remove omnibox zero-suggest cache results. Filtering is not supported.
893 // This is not a problem, as deleting more data than necessary will just cause 944 // This is not a problem, as deleting more data than necessary will just cause
894 // another server round-trip; no data is actually lost. 945 // another server round-trip; no data is actually lost.
895 if ((remove_mask & (BrowsingDataRemover::REMOVE_CACHE | 946 if ((remove_mask & (BrowsingDataRemover::DATA_TYPE_CACHE |
896 BrowsingDataRemover::REMOVE_COOKIES))) { 947 BrowsingDataRemover::DATA_TYPE_COOKIES))) {
897 prefs->SetString(omnibox::kZeroSuggestCachedResults, std::string()); 948 prefs->SetString(omnibox::kZeroSuggestCachedResults, std::string());
898 } 949 }
899 950
900 ////////////////////////////////////////////////////////////////////////////// 951 //////////////////////////////////////////////////////////////////////////////
901 // Domain reliability service. 952 // Domain reliability service.
902 if (remove_mask & (BrowsingDataRemover::REMOVE_COOKIES | 953 if (remove_mask &
903 BrowsingDataRemover::REMOVE_HISTORY)) { 954 (BrowsingDataRemover::DATA_TYPE_COOKIES | DATA_TYPE_HISTORY)) {
904 domain_reliability::DomainReliabilityService* service = 955 domain_reliability::DomainReliabilityService* service =
905 domain_reliability::DomainReliabilityServiceFactory:: 956 domain_reliability::DomainReliabilityServiceFactory::
906 GetForBrowserContext(profile_); 957 GetForBrowserContext(profile_);
907 if (service) { 958 if (service) {
908 domain_reliability::DomainReliabilityClearMode mode; 959 domain_reliability::DomainReliabilityClearMode mode;
909 if (remove_mask & BrowsingDataRemover::REMOVE_COOKIES) 960 if (remove_mask & BrowsingDataRemover::DATA_TYPE_COOKIES)
910 mode = domain_reliability::CLEAR_CONTEXTS; 961 mode = domain_reliability::CLEAR_CONTEXTS;
911 else 962 else
912 mode = domain_reliability::CLEAR_BEACONS; 963 mode = domain_reliability::CLEAR_BEACONS;
913 964
914 clear_domain_reliability_monitor_.Start(); 965 clear_domain_reliability_monitor_.Start();
915 service->ClearBrowsingData( 966 service->ClearBrowsingData(
916 mode, 967 mode,
917 filter, 968 filter,
918 clear_domain_reliability_monitor_.GetCompletionCallback()); 969 clear_domain_reliability_monitor_.GetCompletionCallback());
919 } 970 }
920 } 971 }
921 972
922 ////////////////////////////////////////////////////////////////////////////// 973 //////////////////////////////////////////////////////////////////////////////
923 // REMOVE_WEBAPP_DATA 974 // DATA_TYPE_WEB_APP_DATA
924 #if defined(OS_ANDROID) 975 #if defined(OS_ANDROID)
925 // Clear all data associated with registered webapps. 976 // Clear all data associated with registered webapps.
926 if (remove_mask & BrowsingDataRemover::REMOVE_WEBAPP_DATA) 977 if (remove_mask & DATA_TYPE_WEB_APP_DATA)
927 webapp_registry_->UnregisterWebappsForUrls(filter); 978 webapp_registry_->UnregisterWebappsForUrls(filter);
928 #endif 979 #endif
929 980
930 ////////////////////////////////////////////////////////////////////////////// 981 //////////////////////////////////////////////////////////////////////////////
931 // Remove external protocol data. 982 // Remove external protocol data.
932 if (remove_mask & BrowsingDataRemover::REMOVE_EXTERNAL_PROTOCOL_DATA) 983 if (remove_mask & DATA_TYPE_EXTERNAL_PROTOCOL_DATA)
933 ExternalProtocolHandler::ClearData(profile_); 984 ExternalProtocolHandler::ClearData(profile_);
934 985
935 synchronous_clear_operations_.GetCompletionCallback().Run(); 986 synchronous_clear_operations_.GetCompletionCallback().Run();
936 } 987 }
937 988
938 void ChromeBrowsingDataRemoverDelegate::NotifyIfDone() { 989 void ChromeBrowsingDataRemoverDelegate::NotifyIfDone() {
939 if (!AllDone()) 990 if (!AllDone())
940 return; 991 return;
941 992
942 DCHECK(!callback_.is_null()); 993 DCHECK(!callback_.is_null());
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 } 1108 }
1058 1109
1059 void ChromeBrowsingDataRemoverDelegate:: 1110 void ChromeBrowsingDataRemoverDelegate::
1060 OnDeauthorizeFlashContentLicensesCompleted( 1111 OnDeauthorizeFlashContentLicensesCompleted(
1061 uint32_t request_id, 1112 uint32_t request_id,
1062 bool /* success */) { 1113 bool /* success */) {
1063 DCHECK_EQ(request_id, deauthorize_flash_content_licenses_request_id_); 1114 DCHECK_EQ(request_id, deauthorize_flash_content_licenses_request_id_);
1064 clear_flash_content_licenses_.GetCompletionCallback().Run(); 1115 clear_flash_content_licenses_.GetCompletionCallback().Run();
1065 } 1116 }
1066 #endif 1117 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698