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

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

Issue 2771233002: Remove the wrapper functions content::RecordAction et al (Closed)
Patch Set: Rebased Created 3 years, 8 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
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/metrics/user_metrics.h"
12 #include "chrome/browser/autofill/personal_data_manager_factory.h" 13 #include "chrome/browser/autofill/personal_data_manager_factory.h"
13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 14 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
14 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/browsing_data/browsing_data_helper.h" 16 #include "chrome/browser/browsing_data/browsing_data_helper.h"
16 #include "chrome/browser/chrome_notification_types.h" 17 #include "chrome/browser/chrome_notification_types.h"
17 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 18 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
18 #include "chrome/browser/domain_reliability/service_factory.h" 19 #include "chrome/browser/domain_reliability/service_factory.h"
19 #include "chrome/browser/download/download_prefs.h" 20 #include "chrome/browser/download/download_prefs.h"
20 #include "chrome/browser/external_protocol/external_protocol_handler.h" 21 #include "chrome/browser/external_protocol/external_protocol_handler.h"
21 #include "chrome/browser/history/history_service_factory.h" 22 #include "chrome/browser/history/history_service_factory.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 #include "components/prefs/pref_service.h" 64 #include "components/prefs/pref_service.h"
64 #include "components/previews/core/previews_ui_service.h" 65 #include "components/previews/core/previews_ui_service.h"
65 #include "components/search_engines/template_url_service.h" 66 #include "components/search_engines/template_url_service.h"
66 #include "components/sessions/core/tab_restore_service.h" 67 #include "components/sessions/core/tab_restore_service.h"
67 #include "components/translate/core/browser/language_model.h" 68 #include "components/translate/core/browser/language_model.h"
68 #include "components/web_cache/browser/web_cache_manager.h" 69 #include "components/web_cache/browser/web_cache_manager.h"
69 #include "content/public/browser/browsing_data_filter_builder.h" 70 #include "content/public/browser/browsing_data_filter_builder.h"
70 #include "content/public/browser/plugin_data_remover.h" 71 #include "content/public/browser/plugin_data_remover.h"
71 #include "content/public/browser/ssl_host_state_delegate.h" 72 #include "content/public/browser/ssl_host_state_delegate.h"
72 #include "content/public/browser/storage_partition.h" 73 #include "content/public/browser/storage_partition.h"
73 #include "content/public/browser/user_metrics.h"
74 #include "net/cookies/cookie_store.h" 74 #include "net/cookies/cookie_store.h"
75 #include "net/http/http_transaction_factory.h" 75 #include "net/http/http_transaction_factory.h"
76 #include "net/url_request/url_request_context.h" 76 #include "net/url_request/url_request_context.h"
77 #include "net/url_request/url_request_context_getter.h" 77 #include "net/url_request/url_request_context_getter.h"
78 #include "url/url_util.h" 78 #include "url/url_util.h"
79 79
80 #if defined(OS_ANDROID) 80 #if defined(OS_ANDROID)
81 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" 81 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
82 #include "chrome/browser/android/webapps/webapp_registry.h" 82 #include "chrome/browser/android/webapps/webapp_registry.h"
83 #include "chrome/browser/precache/precache_manager_factory.h" 83 #include "chrome/browser/precache/precache_manager_factory.h"
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 DCHECK(((remove_mask & ~FILTERABLE_DATA_TYPES) == 0) || 344 DCHECK(((remove_mask & ~FILTERABLE_DATA_TYPES) == 0) ||
345 filter_builder.IsEmptyBlacklist()); 345 filter_builder.IsEmptyBlacklist());
346 346
347 // Embedder-defined DOM-accessible storage currently contains only 347 // Embedder-defined DOM-accessible storage currently contains only
348 // one datatype, which is the durable storage permission. 348 // one datatype, which is the durable storage permission.
349 if (remove_mask & BrowsingDataRemover::DATA_TYPE_EMBEDDER_DOM_STORAGE) { 349 if (remove_mask & BrowsingDataRemover::DATA_TYPE_EMBEDDER_DOM_STORAGE) {
350 remove_mask |= DATA_TYPE_DURABLE_PERMISSION; 350 remove_mask |= DATA_TYPE_DURABLE_PERMISSION;
351 } 351 }
352 352
353 if (origin_type_mask & BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB) { 353 if (origin_type_mask & BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB) {
354 content::RecordAction( 354 base::RecordAction(
355 UserMetricsAction("ClearBrowsingData_MaskContainsUnprotectedWeb")); 355 UserMetricsAction("ClearBrowsingData_MaskContainsUnprotectedWeb"));
356 } 356 }
357 if (origin_type_mask & BrowsingDataRemover::ORIGIN_TYPE_PROTECTED_WEB) { 357 if (origin_type_mask & BrowsingDataRemover::ORIGIN_TYPE_PROTECTED_WEB) {
358 content::RecordAction( 358 base::RecordAction(
359 UserMetricsAction("ClearBrowsingData_MaskContainsProtectedWeb")); 359 UserMetricsAction("ClearBrowsingData_MaskContainsProtectedWeb"));
360 } 360 }
361 #if BUILDFLAG(ENABLE_EXTENSIONS) 361 #if BUILDFLAG(ENABLE_EXTENSIONS)
362 if (origin_type_mask & ORIGIN_TYPE_EXTENSION) { 362 if (origin_type_mask & ORIGIN_TYPE_EXTENSION) {
363 content::RecordAction( 363 base::RecordAction(
364 UserMetricsAction("ClearBrowsingData_MaskContainsExtension")); 364 UserMetricsAction("ClearBrowsingData_MaskContainsExtension"));
365 } 365 }
366 #endif 366 #endif
367 // If this fires, we added a new BrowsingDataHelper::OriginTypeMask without 367 // If this fires, we added a new BrowsingDataHelper::OriginTypeMask without
368 // updating the user metrics above. 368 // updating the user metrics above.
369 static_assert( 369 static_assert(
370 ALL_ORIGIN_TYPES == (BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB | 370 ALL_ORIGIN_TYPES == (BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB |
371 #if BUILDFLAG(ENABLE_EXTENSIONS) 371 #if BUILDFLAG(ENABLE_EXTENSIONS)
372 ORIGIN_TYPE_EXTENSION | 372 ORIGIN_TYPE_EXTENSION |
373 #endif 373 #endif
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 !(remove_mask & BrowsingDataRemover::DATA_TYPE_DOWNLOADS))); 405 !(remove_mask & BrowsingDataRemover::DATA_TYPE_DOWNLOADS)));
406 406
407 ////////////////////////////////////////////////////////////////////////////// 407 //////////////////////////////////////////////////////////////////////////////
408 // DATA_TYPE_HISTORY 408 // DATA_TYPE_HISTORY
409 if ((remove_mask & DATA_TYPE_HISTORY) && may_delete_history) { 409 if ((remove_mask & DATA_TYPE_HISTORY) && may_delete_history) {
410 history::HistoryService* history_service = 410 history::HistoryService* history_service =
411 HistoryServiceFactory::GetForProfile( 411 HistoryServiceFactory::GetForProfile(
412 profile_, ServiceAccessType::EXPLICIT_ACCESS); 412 profile_, ServiceAccessType::EXPLICIT_ACCESS);
413 if (history_service) { 413 if (history_service) {
414 // TODO(dmurph): Support all backends with filter (crbug.com/113621). 414 // TODO(dmurph): Support all backends with filter (crbug.com/113621).
415 content::RecordAction(UserMetricsAction("ClearBrowsingData_History")); 415 base::RecordAction(UserMetricsAction("ClearBrowsingData_History"));
416 clear_history_.Start(); 416 clear_history_.Start();
417 history_service->ExpireLocalAndRemoteHistoryBetween( 417 history_service->ExpireLocalAndRemoteHistoryBetween(
418 WebHistoryServiceFactory::GetForProfile(profile_), std::set<GURL>(), 418 WebHistoryServiceFactory::GetForProfile(profile_), std::set<GURL>(),
419 delete_begin_, delete_end_, 419 delete_begin_, delete_end_,
420 clear_history_.GetCompletionCallback(), 420 clear_history_.GetCompletionCallback(),
421 &history_task_tracker_); 421 &history_task_tracker_);
422 } 422 }
423 423
424 // Currently, ContentSuggestionService instance exists only on Android. 424 // Currently, ContentSuggestionService instance exists only on Android.
425 ntp_snippets::ContentSuggestionsService* content_suggestions_service = 425 ntp_snippets::ContentSuggestionsService* content_suggestions_service =
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 640
641 ////////////////////////////////////////////////////////////////////////////// 641 //////////////////////////////////////////////////////////////////////////////
642 // DATA_TYPE_COOKIES 642 // DATA_TYPE_COOKIES
643 // We ignore the DATA_TYPE_COOKIES request if UNPROTECTED_WEB is not set, 643 // We ignore the DATA_TYPE_COOKIES request if UNPROTECTED_WEB is not set,
644 // so that callers who request DATA_TYPE_SITE_DATA with PROTECTED_WEB 644 // so that callers who request DATA_TYPE_SITE_DATA with PROTECTED_WEB
645 // don't accidentally remove the cookies that are associated with the 645 // don't accidentally remove the cookies that are associated with the
646 // UNPROTECTED_WEB origin. This is necessary because cookies are not separated 646 // UNPROTECTED_WEB origin. This is necessary because cookies are not separated
647 // between UNPROTECTED_WEB and PROTECTED_WEB. 647 // between UNPROTECTED_WEB and PROTECTED_WEB.
648 if (remove_mask & BrowsingDataRemover::DATA_TYPE_COOKIES && 648 if (remove_mask & BrowsingDataRemover::DATA_TYPE_COOKIES &&
649 origin_type_mask & BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB) { 649 origin_type_mask & BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB) {
650 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies")); 650 base::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies"));
651 651
652 // Clear the safebrowsing cookies only if time period is for "all time". It 652 // Clear the safebrowsing cookies only if time period is for "all time". It
653 // doesn't make sense to apply the time period of deleting in the last X 653 // doesn't make sense to apply the time period of deleting in the last X
654 // hours/days to the safebrowsing cookies since they aren't the result of 654 // hours/days to the safebrowsing cookies since they aren't the result of
655 // any user action. 655 // any user action.
656 if (delete_begin_ == base::Time()) { 656 if (delete_begin_ == base::Time()) {
657 safe_browsing::SafeBrowsingService* sb_service = 657 safe_browsing::SafeBrowsingService* sb_service =
658 g_browser_process->safe_browsing_service(); 658 g_browser_process->safe_browsing_service();
659 if (sb_service) { 659 if (sb_service) {
660 scoped_refptr<net::URLRequestContextGetter> sb_context = 660 scoped_refptr<net::URLRequestContextGetter> sb_context =
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 CONTENT_SETTINGS_TYPE_APP_BANNER, 713 CONTENT_SETTINGS_TYPE_APP_BANNER,
714 base::Bind(&WebsiteSettingsFilterAdapter, filter)); 714 base::Bind(&WebsiteSettingsFilterAdapter, filter));
715 715
716 PermissionDecisionAutoBlocker::GetForProfile(profile_)->RemoveCountsByUrl( 716 PermissionDecisionAutoBlocker::GetForProfile(profile_)->RemoveCountsByUrl(
717 filter); 717 filter);
718 } 718 }
719 719
720 ////////////////////////////////////////////////////////////////////////////// 720 //////////////////////////////////////////////////////////////////////////////
721 // Password manager 721 // Password manager
722 if (remove_mask & DATA_TYPE_PASSWORDS) { 722 if (remove_mask & DATA_TYPE_PASSWORDS) {
723 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords")); 723 base::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords"));
724 password_manager::PasswordStore* password_store = 724 password_manager::PasswordStore* password_store =
725 PasswordStoreFactory::GetForProfile( 725 PasswordStoreFactory::GetForProfile(
726 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); 726 profile_, ServiceAccessType::EXPLICIT_ACCESS).get();
727 727
728 if (password_store) { 728 if (password_store) {
729 clear_passwords_.Start(); 729 clear_passwords_.Start();
730 password_store->RemoveLoginsByURLAndTime( 730 password_store->RemoveLoginsByURLAndTime(
731 filter, delete_begin_, delete_end_, 731 filter, delete_begin_, delete_end_,
732 clear_passwords_.GetCompletionCallback()); 732 clear_passwords_.GetCompletionCallback());
733 } 733 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 password_store->RemoveStatisticsByOriginAndTime( 766 password_store->RemoveStatisticsByOriginAndTime(
767 nullable_filter, delete_begin_, delete_end_, 767 nullable_filter, delete_begin_, delete_end_,
768 clear_passwords_stats_.GetCompletionCallback()); 768 clear_passwords_stats_.GetCompletionCallback());
769 } 769 }
770 } 770 }
771 771
772 ////////////////////////////////////////////////////////////////////////////// 772 //////////////////////////////////////////////////////////////////////////////
773 // DATA_TYPE_FORM_DATA 773 // DATA_TYPE_FORM_DATA
774 // TODO(dmurph): Support all backends with filter (crbug.com/113621). 774 // TODO(dmurph): Support all backends with filter (crbug.com/113621).
775 if (remove_mask & DATA_TYPE_FORM_DATA) { 775 if (remove_mask & DATA_TYPE_FORM_DATA) {
776 content::RecordAction(UserMetricsAction("ClearBrowsingData_Autofill")); 776 base::RecordAction(UserMetricsAction("ClearBrowsingData_Autofill"));
777 scoped_refptr<autofill::AutofillWebDataService> web_data_service = 777 scoped_refptr<autofill::AutofillWebDataService> web_data_service =
778 WebDataServiceFactory::GetAutofillWebDataForProfile( 778 WebDataServiceFactory::GetAutofillWebDataForProfile(
779 profile_, ServiceAccessType::EXPLICIT_ACCESS); 779 profile_, ServiceAccessType::EXPLICIT_ACCESS);
780 780
781 if (web_data_service.get()) { 781 if (web_data_service.get()) {
782 clear_form_.Start(); 782 clear_form_.Start();
783 web_data_service->RemoveFormElementsAddedBetween(delete_begin_, 783 web_data_service->RemoveFormElementsAddedBetween(delete_begin_,
784 delete_end_); 784 delete_end_);
785 web_data_service->RemoveAutofillDataModifiedBetween( 785 web_data_service->RemoveAutofillDataModifiedBetween(
786 delete_begin_, delete_end_); 786 delete_begin_, delete_end_);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 // on //chrome. 882 // on //chrome.
883 // TODO(msramek): Investigate these dependencies and move the plugin deletion 883 // TODO(msramek): Investigate these dependencies and move the plugin deletion
884 // to BrowsingDataRemoverImpl in //content. Note that code in //content 884 // to BrowsingDataRemoverImpl in //content. Note that code in //content
885 // can simply take advantage of PluginDataRemover directly to delete plugin 885 // can simply take advantage of PluginDataRemover directly to delete plugin
886 // data in bulk. 886 // data in bulk.
887 #if BUILDFLAG(ENABLE_PLUGINS) 887 #if BUILDFLAG(ENABLE_PLUGINS)
888 // Plugin is data not separated for protected and unprotected web origins. We 888 // Plugin is data not separated for protected and unprotected web origins. We
889 // check the origin_type_mask_ to prevent unintended deletion. 889 // check the origin_type_mask_ to prevent unintended deletion.
890 if (remove_mask & DATA_TYPE_PLUGIN_DATA && 890 if (remove_mask & DATA_TYPE_PLUGIN_DATA &&
891 origin_type_mask & BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB) { 891 origin_type_mask & BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB) {
892 content::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData")); 892 base::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData"));
893 clear_plugin_data_count_ = 1; 893 clear_plugin_data_count_ = 1;
894 894
895 if (filter_builder.IsEmptyBlacklist()) { 895 if (filter_builder.IsEmptyBlacklist()) {
896 DCHECK(!plugin_data_remover_); 896 DCHECK(!plugin_data_remover_);
897 plugin_data_remover_.reset( 897 plugin_data_remover_.reset(
898 content::PluginDataRemover::Create(profile_)); 898 content::PluginDataRemover::Create(profile_));
899 base::WaitableEvent* event = 899 base::WaitableEvent* event =
900 plugin_data_remover_->StartRemoving(delete_begin_); 900 plugin_data_remover_->StartRemoving(delete_begin_);
901 901
902 base::WaitableEventWatcher::EventCallback watcher_callback = base::Bind( 902 base::WaitableEventWatcher::EventCallback watcher_callback = base::Bind(
903 &ChromeBrowsingDataRemoverDelegate::OnWaitableEventSignaled, 903 &ChromeBrowsingDataRemoverDelegate::OnWaitableEventSignaled,
904 weak_ptr_factory_.GetWeakPtr()); 904 weak_ptr_factory_.GetWeakPtr());
905 watcher_.StartWatching(event, watcher_callback); 905 watcher_.StartWatching(event, watcher_callback);
906 } else { 906 } else {
907 // TODO(msramek): Store filters from the currently executed task on the 907 // TODO(msramek): Store filters from the currently executed task on the
908 // object to avoid having to copy them to callback methods. 908 // object to avoid having to copy them to callback methods.
909 flash_lso_helper_->StartFetching(base::Bind( 909 flash_lso_helper_->StartFetching(base::Bind(
910 &ChromeBrowsingDataRemoverDelegate::OnSitesWithFlashDataFetched, 910 &ChromeBrowsingDataRemoverDelegate::OnSitesWithFlashDataFetched,
911 weak_ptr_factory_.GetWeakPtr(), 911 weak_ptr_factory_.GetWeakPtr(),
912 filter_builder.BuildPluginFilter())); 912 filter_builder.BuildPluginFilter()));
913 } 913 }
914 } 914 }
915 #endif 915 #endif
916 916
917 ////////////////////////////////////////////////////////////////////////////// 917 //////////////////////////////////////////////////////////////////////////////
918 // DATA_TYPE_MEDIA_LICENSES 918 // DATA_TYPE_MEDIA_LICENSES
919 if (remove_mask & BrowsingDataRemover::DATA_TYPE_MEDIA_LICENSES) { 919 if (remove_mask & BrowsingDataRemover::DATA_TYPE_MEDIA_LICENSES) {
920 // TODO(jrummell): This UMA should be renamed to indicate it is for Media 920 // TODO(jrummell): This UMA should be renamed to indicate it is for Media
921 // Licenses. 921 // Licenses.
922 content::RecordAction( 922 base::RecordAction(UserMetricsAction("ClearBrowsingData_ContentLicenses"));
923 UserMetricsAction("ClearBrowsingData_ContentLicenses"));
924 923
925 #if BUILDFLAG(ENABLE_PLUGINS) 924 #if BUILDFLAG(ENABLE_PLUGINS)
926 clear_flash_content_licenses_.Start(); 925 clear_flash_content_licenses_.Start();
927 if (!pepper_flash_settings_manager_.get()) { 926 if (!pepper_flash_settings_manager_.get()) {
928 pepper_flash_settings_manager_.reset( 927 pepper_flash_settings_manager_.reset(
929 new PepperFlashSettingsManager(this, profile_)); 928 new PepperFlashSettingsManager(this, profile_));
930 } 929 }
931 deauthorize_flash_content_licenses_request_id_ = 930 deauthorize_flash_content_licenses_request_id_ =
932 pepper_flash_settings_manager_->DeauthorizeContentLicenses(prefs); 931 pepper_flash_settings_manager_->DeauthorizeContentLicenses(prefs);
933 #endif // BUILDFLAG(ENABLE_PLUGINS) 932 #endif // BUILDFLAG(ENABLE_PLUGINS)
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 } 1122 }
1124 1123
1125 void ChromeBrowsingDataRemoverDelegate:: 1124 void ChromeBrowsingDataRemoverDelegate::
1126 OnDeauthorizeFlashContentLicensesCompleted( 1125 OnDeauthorizeFlashContentLicensesCompleted(
1127 uint32_t request_id, 1126 uint32_t request_id,
1128 bool /* success */) { 1127 bool /* success */) {
1129 DCHECK_EQ(request_id, deauthorize_flash_content_licenses_request_id_); 1128 DCHECK_EQ(request_id, deauthorize_flash_content_licenses_request_id_);
1130 clear_flash_content_licenses_.GetCompletionCallback().Run(); 1129 clear_flash_content_licenses_.GetCompletionCallback().Run();
1131 } 1130 }
1132 #endif 1131 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698