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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 & ORIGIN_TYPE_UNPROTECTED_WEB) { |
| 347 content::RecordAction( |
| 348 UserMetricsAction("ClearBrowsingData_MaskContainsUnprotectedWeb")); |
| 349 } |
| 350 if (origin_type_mask & 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 == (ORIGIN_TYPE_UNPROTECTED_WEB | |
| 364 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 365 ORIGIN_TYPE_EXTENSION | |
| 366 #endif |
| 367 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 & 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 & 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) && |
351 may_delete_history) { | 403 may_delete_history) { |
352 history::HistoryService* history_service = | 404 history::HistoryService* history_service = |
353 HistoryServiceFactory::GetForProfile( | 405 HistoryServiceFactory::GetForProfile( |
354 profile_, ServiceAccessType::EXPLICIT_ACCESS); | 406 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
355 if (history_service) { | 407 if (history_service) { |
356 // TODO(dmurph): Support all backends with filter (crbug.com/113621). | 408 // TODO(dmurph): Support all backends with filter (crbug.com/113621). |
357 content::RecordAction(UserMetricsAction("ClearBrowsingData_History")); | 409 content::RecordAction(UserMetricsAction("ClearBrowsingData_History")); |
358 clear_history_.Start(); | 410 clear_history_.Start(); |
359 history_service->ExpireLocalAndRemoteHistoryBetween( | 411 history_service->ExpireLocalAndRemoteHistoryBetween( |
360 WebHistoryServiceFactory::GetForProfile(profile_), std::set<GURL>(), | 412 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. | 617 // Rename the method to indicate its more general usage. |
566 if (profile_->GetSSLHostStateDelegate()) { | 618 if (profile_->GetSSLHostStateDelegate()) { |
567 profile_->GetSSLHostStateDelegate()->Clear( | 619 profile_->GetSSLHostStateDelegate()->Clear( |
568 filter_builder.IsEmptyBlacklist() | 620 filter_builder.IsEmptyBlacklist() |
569 ? base::Callback<bool(const std::string&)>() | 621 ? base::Callback<bool(const std::string&)>() |
570 : filter_builder.BuildPluginFilter()); | 622 : filter_builder.BuildPluginFilter()); |
571 } | 623 } |
572 } | 624 } |
573 | 625 |
574 ////////////////////////////////////////////////////////////////////////////// | 626 ////////////////////////////////////////////////////////////////////////////// |
575 // REMOVE_DOWNLOADS | 627 // DATA_TYPE_DOWNLOADS |
576 if ((remove_mask & BrowsingDataRemover::REMOVE_DOWNLOADS) && | 628 if ((remove_mask & DATA_TYPE_DOWNLOADS) && |
577 may_delete_history) { | 629 may_delete_history) { |
578 DownloadPrefs* download_prefs = DownloadPrefs::FromDownloadManager( | 630 DownloadPrefs* download_prefs = DownloadPrefs::FromDownloadManager( |
579 BrowserContext::GetDownloadManager(profile_)); | 631 BrowserContext::GetDownloadManager(profile_)); |
580 download_prefs->SetSaveFilePath(download_prefs->DownloadPath()); | 632 download_prefs->SetSaveFilePath(download_prefs->DownloadPath()); |
581 } | 633 } |
582 | 634 |
583 ////////////////////////////////////////////////////////////////////////////// | 635 ////////////////////////////////////////////////////////////////////////////// |
584 // REMOVE_COOKIES | 636 // DATA_TYPE_COOKIES |
585 // We ignore the REMOVE_COOKIES request if UNPROTECTED_WEB is not set, | 637 // 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 | 638 // so that callers who request DATA_TYPE_SITE_DATA with PROTECTED_WEB |
587 // don't accidentally remove the cookies that are associated with the | 639 // don't accidentally remove the cookies that are associated with the |
588 // UNPROTECTED_WEB origin. This is necessary because cookies are not separated | 640 // UNPROTECTED_WEB origin. This is necessary because cookies are not separated |
589 // between UNPROTECTED_WEB and PROTECTED_WEB. | 641 // between UNPROTECTED_WEB and PROTECTED_WEB. |
590 if (remove_mask & BrowsingDataRemover::REMOVE_COOKIES && | 642 if (remove_mask & DATA_TYPE_COOKIES && |
591 origin_type_mask & BrowsingDataHelper::UNPROTECTED_WEB) { | 643 origin_type_mask & ORIGIN_TYPE_UNPROTECTED_WEB) { |
592 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies")); | 644 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies")); |
593 | 645 |
594 // Clear the safebrowsing cookies only if time period is for "all time". It | 646 // 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 | 647 // 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 | 648 // hours/days to the safebrowsing cookies since they aren't the result of |
597 // any user action. | 649 // any user action. |
598 if (delete_begin_ == base::Time()) { | 650 if (delete_begin_ == base::Time()) { |
599 safe_browsing::SafeBrowsingService* sb_service = | 651 safe_browsing::SafeBrowsingService* sb_service = |
600 g_browser_process->safe_browsing_service(); | 652 g_browser_process->safe_browsing_service(); |
601 if (sb_service) { | 653 if (sb_service) { |
(...skipping 22 matching lines...) Expand all Loading... |
624 &ChromeBrowsingDataRemoverDelegate::OnClearedCookies, | 676 &ChromeBrowsingDataRemoverDelegate::OnClearedCookies, |
625 weak_ptr_factory_.GetWeakPtr())))); | 677 weak_ptr_factory_.GetWeakPtr())))); |
626 } | 678 } |
627 } | 679 } |
628 } | 680 } |
629 | 681 |
630 MediaDeviceIDSalt::Reset(profile_->GetPrefs()); | 682 MediaDeviceIDSalt::Reset(profile_->GetPrefs()); |
631 } | 683 } |
632 | 684 |
633 ////////////////////////////////////////////////////////////////////////////// | 685 ////////////////////////////////////////////////////////////////////////////// |
634 // REMOVE_DURABLE_PERMISSION | 686 // DATA_TYPE_DURABLE_PERMISSION |
635 if (remove_mask & BrowsingDataRemover::REMOVE_DURABLE_PERMISSION) { | 687 if (remove_mask & DATA_TYPE_DURABLE_PERMISSION) { |
636 HostContentSettingsMapFactory::GetForProfile(profile_) | 688 HostContentSettingsMapFactory::GetForProfile(profile_) |
637 ->ClearSettingsForOneTypeWithPredicate( | 689 ->ClearSettingsForOneTypeWithPredicate( |
638 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, | 690 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, |
639 base::Bind(&WebsiteSettingsFilterAdapter, filter)); | 691 base::Bind(&WebsiteSettingsFilterAdapter, filter)); |
640 } | 692 } |
641 | 693 |
642 ////////////////////////////////////////////////////////////////////////////// | 694 ////////////////////////////////////////////////////////////////////////////// |
643 // REMOVE_SITE_USAGE_DATA | 695 // DATA_TYPE_SITE_USAGE_DATA |
644 if (remove_mask & BrowsingDataRemover::REMOVE_SITE_USAGE_DATA) { | 696 if (remove_mask & DATA_TYPE_SITE_USAGE_DATA) { |
645 HostContentSettingsMapFactory::GetForProfile(profile_) | 697 HostContentSettingsMapFactory::GetForProfile(profile_) |
646 ->ClearSettingsForOneTypeWithPredicate( | 698 ->ClearSettingsForOneTypeWithPredicate( |
647 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, | 699 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, |
648 base::Bind(&WebsiteSettingsFilterAdapter, filter)); | 700 base::Bind(&WebsiteSettingsFilterAdapter, filter)); |
649 } | 701 } |
650 | 702 |
651 if ((remove_mask & BrowsingDataRemover::REMOVE_SITE_USAGE_DATA) || | 703 if ((remove_mask & DATA_TYPE_SITE_USAGE_DATA) || |
652 (remove_mask & BrowsingDataRemover::REMOVE_HISTORY)) { | 704 (remove_mask & DATA_TYPE_HISTORY)) { |
653 HostContentSettingsMapFactory::GetForProfile(profile_) | 705 HostContentSettingsMapFactory::GetForProfile(profile_) |
654 ->ClearSettingsForOneTypeWithPredicate( | 706 ->ClearSettingsForOneTypeWithPredicate( |
655 CONTENT_SETTINGS_TYPE_APP_BANNER, | 707 CONTENT_SETTINGS_TYPE_APP_BANNER, |
656 base::Bind(&WebsiteSettingsFilterAdapter, filter)); | 708 base::Bind(&WebsiteSettingsFilterAdapter, filter)); |
657 | 709 |
658 PermissionDecisionAutoBlocker::GetForProfile(profile_)->RemoveCountsByUrl( | 710 PermissionDecisionAutoBlocker::GetForProfile(profile_)->RemoveCountsByUrl( |
659 filter); | 711 filter); |
660 } | 712 } |
661 | 713 |
662 ////////////////////////////////////////////////////////////////////////////// | 714 ////////////////////////////////////////////////////////////////////////////// |
663 // Password manager | 715 // Password manager |
664 if (remove_mask & BrowsingDataRemover::REMOVE_PASSWORDS) { | 716 if (remove_mask & DATA_TYPE_PASSWORDS) { |
665 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords")); | 717 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords")); |
666 password_manager::PasswordStore* password_store = | 718 password_manager::PasswordStore* password_store = |
667 PasswordStoreFactory::GetForProfile( | 719 PasswordStoreFactory::GetForProfile( |
668 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); | 720 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); |
669 | 721 |
670 if (password_store) { | 722 if (password_store) { |
671 clear_passwords_.Start(); | 723 clear_passwords_.Start(); |
672 password_store->RemoveLoginsByURLAndTime( | 724 password_store->RemoveLoginsByURLAndTime( |
673 filter, delete_begin_, delete_end_, | 725 filter, delete_begin_, delete_end_, |
674 clear_passwords_.GetCompletionCallback()); | 726 clear_passwords_.GetCompletionCallback()); |
675 } | 727 } |
676 | 728 |
677 scoped_refptr<net::URLRequestContextGetter> request_context = | 729 scoped_refptr<net::URLRequestContextGetter> request_context = |
678 BrowserContext::GetDefaultStoragePartition(profile_) | 730 BrowserContext::GetDefaultStoragePartition(profile_) |
679 ->GetURLRequestContext(); | 731 ->GetURLRequestContext(); |
680 clear_http_auth_cache_.Start(); | 732 clear_http_auth_cache_.Start(); |
681 BrowserThread::PostTaskAndReply( | 733 BrowserThread::PostTaskAndReply( |
682 BrowserThread::IO, FROM_HERE, | 734 BrowserThread::IO, FROM_HERE, |
683 base::Bind(&ClearHttpAuthCacheOnIOThread, std::move(request_context), | 735 base::Bind(&ClearHttpAuthCacheOnIOThread, std::move(request_context), |
684 delete_begin_), | 736 delete_begin_), |
685 clear_http_auth_cache_.GetCompletionCallback()); | 737 clear_http_auth_cache_.GetCompletionCallback()); |
686 } | 738 } |
687 | 739 |
688 if (remove_mask & BrowsingDataRemover::REMOVE_COOKIES) { | 740 if (remove_mask & DATA_TYPE_COOKIES) { |
689 password_manager::PasswordStore* password_store = | 741 password_manager::PasswordStore* password_store = |
690 PasswordStoreFactory::GetForProfile(profile_, | 742 PasswordStoreFactory::GetForProfile(profile_, |
691 ServiceAccessType::EXPLICIT_ACCESS) | 743 ServiceAccessType::EXPLICIT_ACCESS) |
692 .get(); | 744 .get(); |
693 | 745 |
694 if (password_store) { | 746 if (password_store) { |
695 clear_auto_sign_in_.Start(); | 747 clear_auto_sign_in_.Start(); |
696 password_store->DisableAutoSignInForOrigins( | 748 password_store->DisableAutoSignInForOrigins( |
697 filter, clear_auto_sign_in_.GetCompletionCallback()); | 749 filter, clear_auto_sign_in_.GetCompletionCallback()); |
698 } | 750 } |
699 } | 751 } |
700 | 752 |
701 if (remove_mask & BrowsingDataRemover::REMOVE_HISTORY) { | 753 if (remove_mask & DATA_TYPE_HISTORY) { |
702 password_manager::PasswordStore* password_store = | 754 password_manager::PasswordStore* password_store = |
703 PasswordStoreFactory::GetForProfile( | 755 PasswordStoreFactory::GetForProfile( |
704 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); | 756 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); |
705 | 757 |
706 if (password_store) { | 758 if (password_store) { |
707 clear_passwords_stats_.Start(); | 759 clear_passwords_stats_.Start(); |
708 password_store->RemoveStatisticsByOriginAndTime( | 760 password_store->RemoveStatisticsByOriginAndTime( |
709 nullable_filter, delete_begin_, delete_end_, | 761 nullable_filter, delete_begin_, delete_end_, |
710 clear_passwords_stats_.GetCompletionCallback()); | 762 clear_passwords_stats_.GetCompletionCallback()); |
711 } | 763 } |
712 } | 764 } |
713 | 765 |
714 ////////////////////////////////////////////////////////////////////////////// | 766 ////////////////////////////////////////////////////////////////////////////// |
715 // REMOVE_FORM_DATA | 767 // DATA_TYPE_FORM_DATA |
716 // TODO(dmurph): Support all backends with filter (crbug.com/113621). | 768 // TODO(dmurph): Support all backends with filter (crbug.com/113621). |
717 if (remove_mask & BrowsingDataRemover::REMOVE_FORM_DATA) { | 769 if (remove_mask & DATA_TYPE_FORM_DATA) { |
718 content::RecordAction(UserMetricsAction("ClearBrowsingData_Autofill")); | 770 content::RecordAction(UserMetricsAction("ClearBrowsingData_Autofill")); |
719 scoped_refptr<autofill::AutofillWebDataService> web_data_service = | 771 scoped_refptr<autofill::AutofillWebDataService> web_data_service = |
720 WebDataServiceFactory::GetAutofillWebDataForProfile( | 772 WebDataServiceFactory::GetAutofillWebDataForProfile( |
721 profile_, ServiceAccessType::EXPLICIT_ACCESS); | 773 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
722 | 774 |
723 if (web_data_service.get()) { | 775 if (web_data_service.get()) { |
724 clear_form_.Start(); | 776 clear_form_.Start(); |
725 web_data_service->RemoveFormElementsAddedBetween(delete_begin_, | 777 web_data_service->RemoveFormElementsAddedBetween(delete_begin_, |
726 delete_end_); | 778 delete_end_); |
727 web_data_service->RemoveAutofillDataModifiedBetween( | 779 web_data_service->RemoveAutofillDataModifiedBetween( |
728 delete_begin_, delete_end_); | 780 delete_begin_, delete_end_); |
729 // The above calls are done on the UI thread but do their work on the DB | 781 // The above calls are done on the UI thread but do their work on the DB |
730 // thread. So wait for it. | 782 // thread. So wait for it. |
731 BrowserThread::PostTaskAndReply( | 783 BrowserThread::PostTaskAndReply( |
732 BrowserThread::DB, FROM_HERE, base::Bind(&base::DoNothing), | 784 BrowserThread::DB, FROM_HERE, base::Bind(&base::DoNothing), |
733 clear_form_.GetCompletionCallback()); | 785 clear_form_.GetCompletionCallback()); |
734 | 786 |
735 autofill::PersonalDataManager* data_manager = | 787 autofill::PersonalDataManager* data_manager = |
736 autofill::PersonalDataManagerFactory::GetForProfile(profile_); | 788 autofill::PersonalDataManagerFactory::GetForProfile(profile_); |
737 if (data_manager) | 789 if (data_manager) |
738 data_manager->Refresh(); | 790 data_manager->Refresh(); |
739 } | 791 } |
740 } | 792 } |
741 | 793 |
742 ////////////////////////////////////////////////////////////////////////////// | 794 ////////////////////////////////////////////////////////////////////////////// |
743 // REMOVE_CACHE | 795 // DATA_TYPE_CACHE |
744 if (remove_mask & BrowsingDataRemover::REMOVE_CACHE) { | 796 if (remove_mask & DATA_TYPE_CACHE) { |
745 #if !defined(DISABLE_NACL) | 797 #if !defined(DISABLE_NACL) |
746 clear_nacl_cache_.Start(); | 798 clear_nacl_cache_.Start(); |
747 | 799 |
748 BrowserThread::PostTask( | 800 BrowserThread::PostTask( |
749 BrowserThread::IO, FROM_HERE, | 801 BrowserThread::IO, FROM_HERE, |
750 base::Bind(&ClearNaClCacheOnIOThread, | 802 base::Bind(&ClearNaClCacheOnIOThread, |
751 UIThreadTrampoline( | 803 UIThreadTrampoline( |
752 clear_nacl_cache_.GetCompletionCallback()))); | 804 clear_nacl_cache_.GetCompletionCallback()))); |
753 | 805 |
754 clear_pnacl_cache_.Start(); | 806 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 | 842 // Network Quality Estimator (NQE) stores the quality (RTT, bandwidth |
791 // etc.) of different networks in prefs. The stored quality is not | 843 // etc.) of different networks in prefs. The stored quality is not |
792 // broken down by URLs or timestamps, so clearing the cache should | 844 // broken down by URLs or timestamps, so clearing the cache should |
793 // completely clear the prefs. | 845 // completely clear the prefs. |
794 ui_nqe_service->ClearPrefs(); | 846 ui_nqe_service->ClearPrefs(); |
795 } | 847 } |
796 | 848 |
797 #if defined(OS_ANDROID) | 849 #if defined(OS_ANDROID) |
798 // For now we're considering offline pages as cache, so if we're removing | 850 // For now we're considering offline pages as cache, so if we're removing |
799 // cache we should remove offline pages as well. | 851 // cache we should remove offline pages as well. |
800 if ((remove_mask & BrowsingDataRemover::REMOVE_CACHE)) { | 852 if ((remove_mask & DATA_TYPE_CACHE)) { |
801 clear_offline_page_data_.Start(); | 853 clear_offline_page_data_.Start(); |
802 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile_) | 854 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile_) |
803 ->DeleteCachedPagesByURLPredicate( | 855 ->DeleteCachedPagesByURLPredicate( |
804 filter, | 856 filter, |
805 IgnoreArgument<offline_pages::OfflinePageModel::DeletePageResult>( | 857 IgnoreArgument<offline_pages::OfflinePageModel::DeletePageResult>( |
806 clear_offline_page_data_.GetCompletionCallback())); | 858 clear_offline_page_data_.GetCompletionCallback())); |
807 } | 859 } |
808 #endif | 860 #endif |
809 } | 861 } |
810 | 862 |
811 ////////////////////////////////////////////////////////////////////////////// | 863 ////////////////////////////////////////////////////////////////////////////// |
812 // REMOVE_PLUGINS | 864 // DATA_TYPE_PLUGINS |
813 // Plugins are known to //content and their bulk deletion is implemented in | 865 // Plugins are known to //content and their bulk deletion is implemented in |
814 // PluginDataRemover. However, the filtered deletion uses | 866 // PluginDataRemover. However, the filtered deletion uses |
815 // BrowsingDataFlashLSOHelper which (currently) has strong dependencies | 867 // BrowsingDataFlashLSOHelper which (currently) has strong dependencies |
816 // on //chrome. | 868 // on //chrome. |
817 // TODO(msramek): Investigate these dependencies and move the plugin deletion | 869 // TODO(msramek): Investigate these dependencies and move the plugin deletion |
818 // to BrowsingDataRemoverImpl in //content. Note that code in //content | 870 // to BrowsingDataRemoverImpl in //content. Note that code in //content |
819 // can simply take advantage of PluginDataRemover directly to delete plugin | 871 // can simply take advantage of PluginDataRemover directly to delete plugin |
820 // data in bulk. | 872 // data in bulk. |
821 #if BUILDFLAG(ENABLE_PLUGINS) | 873 #if BUILDFLAG(ENABLE_PLUGINS) |
822 // Plugin is data not separated for protected and unprotected web origins. We | 874 // Plugin is data not separated for protected and unprotected web origins. We |
823 // check the origin_type_mask_ to prevent unintended deletion. | 875 // check the origin_type_mask_ to prevent unintended deletion. |
824 if (remove_mask & BrowsingDataRemover::REMOVE_PLUGIN_DATA && | 876 if (remove_mask & DATA_TYPE_PLUGIN_DATA && |
825 origin_type_mask & BrowsingDataHelper::UNPROTECTED_WEB) { | 877 origin_type_mask & ORIGIN_TYPE_UNPROTECTED_WEB) { |
826 content::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData")); | 878 content::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData")); |
827 clear_plugin_data_count_ = 1; | 879 clear_plugin_data_count_ = 1; |
828 | 880 |
829 if (filter_builder.IsEmptyBlacklist()) { | 881 if (filter_builder.IsEmptyBlacklist()) { |
830 DCHECK(!plugin_data_remover_); | 882 DCHECK(!plugin_data_remover_); |
831 plugin_data_remover_.reset( | 883 plugin_data_remover_.reset( |
832 content::PluginDataRemover::Create(profile_)); | 884 content::PluginDataRemover::Create(profile_)); |
833 base::WaitableEvent* event = | 885 base::WaitableEvent* event = |
834 plugin_data_remover_->StartRemoving(delete_begin_); | 886 plugin_data_remover_->StartRemoving(delete_begin_); |
835 | 887 |
836 base::WaitableEventWatcher::EventCallback watcher_callback = base::Bind( | 888 base::WaitableEventWatcher::EventCallback watcher_callback = base::Bind( |
837 &ChromeBrowsingDataRemoverDelegate::OnWaitableEventSignaled, | 889 &ChromeBrowsingDataRemoverDelegate::OnWaitableEventSignaled, |
838 weak_ptr_factory_.GetWeakPtr()); | 890 weak_ptr_factory_.GetWeakPtr()); |
839 watcher_.StartWatching(event, watcher_callback); | 891 watcher_.StartWatching(event, watcher_callback); |
840 } else { | 892 } else { |
841 // TODO(msramek): Store filters from the currently executed task on the | 893 // TODO(msramek): Store filters from the currently executed task on the |
842 // object to avoid having to copy them to callback methods. | 894 // object to avoid having to copy them to callback methods. |
843 flash_lso_helper_->StartFetching(base::Bind( | 895 flash_lso_helper_->StartFetching(base::Bind( |
844 &ChromeBrowsingDataRemoverDelegate::OnSitesWithFlashDataFetched, | 896 &ChromeBrowsingDataRemoverDelegate::OnSitesWithFlashDataFetched, |
845 weak_ptr_factory_.GetWeakPtr(), | 897 weak_ptr_factory_.GetWeakPtr(), |
846 filter_builder.BuildPluginFilter())); | 898 filter_builder.BuildPluginFilter())); |
847 } | 899 } |
848 } | 900 } |
849 #endif | 901 #endif |
850 | 902 |
851 ////////////////////////////////////////////////////////////////////////////// | 903 ////////////////////////////////////////////////////////////////////////////// |
852 // REMOVE_MEDIA_LICENSES | 904 // DATA_TYPE_MEDIA_LICENSES |
853 if (remove_mask & BrowsingDataRemover::REMOVE_MEDIA_LICENSES) { | 905 if (remove_mask & DATA_TYPE_MEDIA_LICENSES) { |
854 // TODO(jrummell): This UMA should be renamed to indicate it is for Media | 906 // TODO(jrummell): This UMA should be renamed to indicate it is for Media |
855 // Licenses. | 907 // Licenses. |
856 content::RecordAction( | 908 content::RecordAction( |
857 UserMetricsAction("ClearBrowsingData_ContentLicenses")); | 909 UserMetricsAction("ClearBrowsingData_ContentLicenses")); |
858 | 910 |
859 #if BUILDFLAG(ENABLE_PLUGINS) | 911 #if BUILDFLAG(ENABLE_PLUGINS) |
860 clear_flash_content_licenses_.Start(); | 912 clear_flash_content_licenses_.Start(); |
861 if (!pepper_flash_settings_manager_.get()) { | 913 if (!pepper_flash_settings_manager_.get()) { |
862 pepper_flash_settings_manager_.reset( | 914 pepper_flash_settings_manager_.reset( |
863 new PepperFlashSettingsManager(this, profile_)); | 915 new PepperFlashSettingsManager(this, profile_)); |
(...skipping 21 matching lines...) Expand all Loading... |
885 weak_ptr_factory_.GetWeakPtr())); | 937 weak_ptr_factory_.GetWeakPtr())); |
886 } | 938 } |
887 #endif // defined(OS_CHROMEOS) | 939 #endif // defined(OS_CHROMEOS) |
888 } | 940 } |
889 | 941 |
890 ////////////////////////////////////////////////////////////////////////////// | 942 ////////////////////////////////////////////////////////////////////////////// |
891 // Zero suggest. | 943 // Zero suggest. |
892 // Remove omnibox zero-suggest cache results. Filtering is not supported. | 944 // 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 | 945 // This is not a problem, as deleting more data than necessary will just cause |
894 // another server round-trip; no data is actually lost. | 946 // another server round-trip; no data is actually lost. |
895 if ((remove_mask & (BrowsingDataRemover::REMOVE_CACHE | | 947 if ((remove_mask & (DATA_TYPE_CACHE | |
896 BrowsingDataRemover::REMOVE_COOKIES))) { | 948 DATA_TYPE_COOKIES))) { |
897 prefs->SetString(omnibox::kZeroSuggestCachedResults, std::string()); | 949 prefs->SetString(omnibox::kZeroSuggestCachedResults, std::string()); |
898 } | 950 } |
899 | 951 |
900 ////////////////////////////////////////////////////////////////////////////// | 952 ////////////////////////////////////////////////////////////////////////////// |
901 // Domain reliability service. | 953 // Domain reliability service. |
902 if (remove_mask & (BrowsingDataRemover::REMOVE_COOKIES | | 954 if (remove_mask & (DATA_TYPE_COOKIES | |
903 BrowsingDataRemover::REMOVE_HISTORY)) { | 955 DATA_TYPE_HISTORY)) { |
904 domain_reliability::DomainReliabilityService* service = | 956 domain_reliability::DomainReliabilityService* service = |
905 domain_reliability::DomainReliabilityServiceFactory:: | 957 domain_reliability::DomainReliabilityServiceFactory:: |
906 GetForBrowserContext(profile_); | 958 GetForBrowserContext(profile_); |
907 if (service) { | 959 if (service) { |
908 domain_reliability::DomainReliabilityClearMode mode; | 960 domain_reliability::DomainReliabilityClearMode mode; |
909 if (remove_mask & BrowsingDataRemover::REMOVE_COOKIES) | 961 if (remove_mask & DATA_TYPE_COOKIES) |
910 mode = domain_reliability::CLEAR_CONTEXTS; | 962 mode = domain_reliability::CLEAR_CONTEXTS; |
911 else | 963 else |
912 mode = domain_reliability::CLEAR_BEACONS; | 964 mode = domain_reliability::CLEAR_BEACONS; |
913 | 965 |
914 clear_domain_reliability_monitor_.Start(); | 966 clear_domain_reliability_monitor_.Start(); |
915 service->ClearBrowsingData( | 967 service->ClearBrowsingData( |
916 mode, | 968 mode, |
917 filter, | 969 filter, |
918 clear_domain_reliability_monitor_.GetCompletionCallback()); | 970 clear_domain_reliability_monitor_.GetCompletionCallback()); |
919 } | 971 } |
920 } | 972 } |
921 | 973 |
922 ////////////////////////////////////////////////////////////////////////////// | 974 ////////////////////////////////////////////////////////////////////////////// |
923 // REMOVE_WEBAPP_DATA | 975 // DATA_TYPE_WEB_APP_DATA |
924 #if defined(OS_ANDROID) | 976 #if defined(OS_ANDROID) |
925 // Clear all data associated with registered webapps. | 977 // Clear all data associated with registered webapps. |
926 if (remove_mask & BrowsingDataRemover::REMOVE_WEBAPP_DATA) | 978 if (remove_mask & DATA_TYPE_WEB_APP_DATA) |
927 webapp_registry_->UnregisterWebappsForUrls(filter); | 979 webapp_registry_->UnregisterWebappsForUrls(filter); |
928 #endif | 980 #endif |
929 | 981 |
930 ////////////////////////////////////////////////////////////////////////////// | 982 ////////////////////////////////////////////////////////////////////////////// |
931 // Remove external protocol data. | 983 // Remove external protocol data. |
932 if (remove_mask & BrowsingDataRemover::REMOVE_EXTERNAL_PROTOCOL_DATA) | 984 if (remove_mask & DATA_TYPE_EXTERNAL_PROTOCOL_DATA) |
933 ExternalProtocolHandler::ClearData(profile_); | 985 ExternalProtocolHandler::ClearData(profile_); |
934 | 986 |
935 synchronous_clear_operations_.GetCompletionCallback().Run(); | 987 synchronous_clear_operations_.GetCompletionCallback().Run(); |
936 } | 988 } |
937 | 989 |
938 void ChromeBrowsingDataRemoverDelegate::NotifyIfDone() { | 990 void ChromeBrowsingDataRemoverDelegate::NotifyIfDone() { |
939 if (!AllDone()) | 991 if (!AllDone()) |
940 return; | 992 return; |
941 | 993 |
942 DCHECK(!callback_.is_null()); | 994 DCHECK(!callback_.is_null()); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 } | 1109 } |
1058 | 1110 |
1059 void ChromeBrowsingDataRemoverDelegate:: | 1111 void ChromeBrowsingDataRemoverDelegate:: |
1060 OnDeauthorizeFlashContentLicensesCompleted( | 1112 OnDeauthorizeFlashContentLicensesCompleted( |
1061 uint32_t request_id, | 1113 uint32_t request_id, |
1062 bool /* success */) { | 1114 bool /* success */) { |
1063 DCHECK_EQ(request_id, deauthorize_flash_content_licenses_request_id_); | 1115 DCHECK_EQ(request_id, deauthorize_flash_content_licenses_request_id_); |
1064 clear_flash_content_licenses_.GetCompletionCallback().Run(); | 1116 clear_flash_content_licenses_.GetCompletionCallback().Run(); |
1065 } | 1117 } |
1066 #endif | 1118 #endif |
OLD | NEW |