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

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

Issue 2617403005: Move HISTORY and PASSWORDS from BrowsingDataRemover to the delegate (Closed)
Patch Set: Rebase. Created 3 years, 11 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
« no previous file with comments | « chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #include "components/nacl/browser/nacl_browser.h" 57 #include "components/nacl/browser/nacl_browser.h"
58 #include "components/nacl/browser/pnacl_host.h" 58 #include "components/nacl/browser/pnacl_host.h"
59 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h" 59 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h"
60 #include "components/ntp_snippets/content_suggestions_service.h" 60 #include "components/ntp_snippets/content_suggestions_service.h"
61 #include "components/omnibox/browser/omnibox_pref_names.h" 61 #include "components/omnibox/browser/omnibox_pref_names.h"
62 #include "components/password_manager/core/browser/password_store.h" 62 #include "components/password_manager/core/browser/password_store.h"
63 #include "components/prefs/pref_service.h" 63 #include "components/prefs/pref_service.h"
64 #include "components/previews/core/previews_ui_service.h" 64 #include "components/previews/core/previews_ui_service.h"
65 #include "components/search_engines/template_url_service.h" 65 #include "components/search_engines/template_url_service.h"
66 #include "components/sessions/core/tab_restore_service.h" 66 #include "components/sessions/core/tab_restore_service.h"
67 #include "content/public/browser/ssl_host_state_delegate.h"
68 #include "content/public/browser/storage_partition.h"
67 #include "content/public/browser/user_metrics.h" 69 #include "content/public/browser/user_metrics.h"
68 #include "net/cookies/cookie_store.h" 70 #include "net/cookies/cookie_store.h"
71 #include "net/http/http_transaction_factory.h"
69 #include "net/url_request/url_request_context.h" 72 #include "net/url_request/url_request_context.h"
70 #include "net/url_request/url_request_context_getter.h" 73 #include "net/url_request/url_request_context_getter.h"
71 74
72 #if defined(OS_ANDROID) 75 #if defined(OS_ANDROID)
73 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" 76 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
74 #include "chrome/browser/android/webapps/webapp_registry.h" 77 #include "chrome/browser/android/webapps/webapp_registry.h"
75 #include "chrome/browser/precache/precache_manager_factory.h" 78 #include "chrome/browser/precache/precache_manager_factory.h"
76 #include "components/offline_pages/core/offline_page_feature.h" 79 #include "components/offline_pages/core/offline_page_feature.h"
77 #include "components/offline_pages/core/offline_page_model.h" 80 #include "components/offline_pages/core/offline_page_model.h"
78 #include "components/precache/content/precache_manager.h" 81 #include "components/precache/content/precache_manager.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 203 }
201 204
202 void ClearHostnameResolutionCacheOnIOThread( 205 void ClearHostnameResolutionCacheOnIOThread(
203 IOThread* io_thread, 206 IOThread* io_thread,
204 base::Callback<bool(const std::string&)> host_filter) { 207 base::Callback<bool(const std::string&)> host_filter) {
205 DCHECK_CURRENTLY_ON(BrowserThread::IO); 208 DCHECK_CURRENTLY_ON(BrowserThread::IO);
206 209
207 io_thread->ClearHostCache(host_filter); 210 io_thread->ClearHostCache(host_filter);
208 } 211 }
209 212
213 void ClearHttpAuthCacheOnIOThread(
214 scoped_refptr<net::URLRequestContextGetter> context_getter,
215 base::Time delete_begin) {
216 DCHECK_CURRENTLY_ON(BrowserThread::IO);
217
218 net::HttpNetworkSession* http_session = context_getter->GetURLRequestContext()
219 ->http_transaction_factory()
220 ->GetSession();
221 DCHECK(http_session);
222 http_session->http_auth_cache()->ClearEntriesAddedWithin(base::Time::Now() -
223 delete_begin);
224 http_session->CloseAllConnections();
225 }
226
210 } // namespace 227 } // namespace
211 228
212 ChromeBrowsingDataRemoverDelegate::SubTask::SubTask( 229 ChromeBrowsingDataRemoverDelegate::SubTask::SubTask(
213 const base::Closure& forward_callback) 230 const base::Closure& forward_callback)
214 : is_pending_(false), 231 : is_pending_(false),
215 forward_callback_(forward_callback), 232 forward_callback_(forward_callback),
216 weak_ptr_factory_(this) { 233 weak_ptr_factory_(this) {
217 DCHECK(!forward_callback_.is_null()); 234 DCHECK(!forward_callback_.is_null());
218 } 235 }
219 236
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 clear_keyword_data_(sub_task_forward_callback_), 270 clear_keyword_data_(sub_task_forward_callback_),
254 #if !defined(DISABLE_NACL) 271 #if !defined(DISABLE_NACL)
255 clear_nacl_cache_(sub_task_forward_callback_), 272 clear_nacl_cache_(sub_task_forward_callback_),
256 clear_pnacl_cache_(sub_task_forward_callback_), 273 clear_pnacl_cache_(sub_task_forward_callback_),
257 #endif 274 #endif
258 clear_hostname_resolution_cache_(sub_task_forward_callback_), 275 clear_hostname_resolution_cache_(sub_task_forward_callback_),
259 clear_network_predictor_(sub_task_forward_callback_), 276 clear_network_predictor_(sub_task_forward_callback_),
260 clear_networking_history_(sub_task_forward_callback_), 277 clear_networking_history_(sub_task_forward_callback_),
261 clear_passwords_(sub_task_forward_callback_), 278 clear_passwords_(sub_task_forward_callback_),
262 clear_passwords_stats_(sub_task_forward_callback_), 279 clear_passwords_stats_(sub_task_forward_callback_),
280 clear_http_auth_cache_(sub_task_forward_callback_),
263 clear_platform_keys_(sub_task_forward_callback_), 281 clear_platform_keys_(sub_task_forward_callback_),
264 #if defined(OS_ANDROID) 282 #if defined(OS_ANDROID)
265 clear_precache_history_(sub_task_forward_callback_), 283 clear_precache_history_(sub_task_forward_callback_),
266 clear_offline_page_data_(sub_task_forward_callback_), 284 clear_offline_page_data_(sub_task_forward_callback_),
267 #endif 285 #endif
268 #if BUILDFLAG(ENABLE_WEBRTC) 286 #if BUILDFLAG(ENABLE_WEBRTC)
269 clear_webrtc_logs_(sub_task_forward_callback_), 287 clear_webrtc_logs_(sub_task_forward_callback_),
270 #endif 288 #endif
271 clear_auto_sign_in_(sub_task_forward_callback_), 289 clear_auto_sign_in_(sub_task_forward_callback_),
272 #if defined(OS_ANDROID) 290 #if defined(OS_ANDROID)
(...skipping 29 matching lines...) Expand all
302 base::Callback<bool(const GURL&)> nullable_filter = 320 base::Callback<bool(const GURL&)> nullable_filter =
303 filter_builder.IsEmptyBlacklist() ? base::Callback<bool(const GURL&)>() 321 filter_builder.IsEmptyBlacklist() ? base::Callback<bool(const GURL&)>()
304 : filter; 322 : filter;
305 323
306 // Managed devices and supervised users can have restrictions on history 324 // Managed devices and supervised users can have restrictions on history
307 // deletion. 325 // deletion.
308 PrefService* prefs = profile_->GetPrefs(); 326 PrefService* prefs = profile_->GetPrefs();
309 bool may_delete_history = prefs->GetBoolean( 327 bool may_delete_history = prefs->GetBoolean(
310 prefs::kAllowDeletingBrowserHistory); 328 prefs::kAllowDeletingBrowserHistory);
311 329
330 // All the UI entry points into the BrowsingDataRemoverImpl should be
331 // disabled, but this will fire if something was missed or added.
332 DCHECK(may_delete_history ||
333 (remove_mask & BrowsingDataRemover::REMOVE_NOCHECKS) ||
334 (!(remove_mask & BrowsingDataRemover::REMOVE_HISTORY) &&
335 !(remove_mask & BrowsingDataRemover::REMOVE_DOWNLOADS)));
336
312 ////////////////////////////////////////////////////////////////////////////// 337 //////////////////////////////////////////////////////////////////////////////
313 // REMOVE_HISTORY 338 // REMOVE_HISTORY
314 if ((remove_mask & BrowsingDataRemover::REMOVE_HISTORY) && 339 if ((remove_mask & BrowsingDataRemover::REMOVE_HISTORY) &&
315 may_delete_history) { 340 may_delete_history) {
316 history::HistoryService* history_service = 341 history::HistoryService* history_service =
317 HistoryServiceFactory::GetForProfile( 342 HistoryServiceFactory::GetForProfile(
318 profile_, ServiceAccessType::EXPLICIT_ACCESS); 343 profile_, ServiceAccessType::EXPLICIT_ACCESS);
319 if (history_service) { 344 if (history_service) {
320 // TODO(dmurph): Support all backends with filter (crbug.com/113621). 345 // TODO(dmurph): Support all backends with filter (crbug.com/113621).
321 content::RecordAction(UserMetricsAction("ClearBrowsingData_History")); 346 content::RecordAction(UserMetricsAction("ClearBrowsingData_History"));
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 } 533 }
509 } 534 }
510 535
511 // |previews_service| is null if |profile_| is off the record. 536 // |previews_service| is null if |profile_| is off the record.
512 PreviewsService* previews_service = 537 PreviewsService* previews_service =
513 PreviewsServiceFactory::GetForProfile(profile_); 538 PreviewsServiceFactory::GetForProfile(profile_);
514 if (previews_service && previews_service->previews_ui_service()) { 539 if (previews_service && previews_service->previews_ui_service()) {
515 previews_service->previews_ui_service()->ClearBlackList(delete_begin_, 540 previews_service->previews_ui_service()->ClearBlackList(delete_begin_,
516 delete_end_); 541 delete_end_);
517 } 542 }
543
544 // The SSL Host State that tracks SSL interstitial "proceed" decisions may
545 // include origins that the user has visited, so it must be cleared.
546 // TODO(msramek): We can reuse the plugin filter here, since both plugins
547 // and SSL host state are scoped to hosts and represent them as std::string.
548 // Rename the method to indicate its more general usage.
549 if (profile_->GetSSLHostStateDelegate()) {
550 profile_->GetSSLHostStateDelegate()->Clear(
551 filter_builder.IsEmptyBlacklist()
552 ? base::Callback<bool(const std::string&)>()
553 : filter_builder.BuildPluginFilter());
554 }
518 } 555 }
519 556
520 ////////////////////////////////////////////////////////////////////////////// 557 //////////////////////////////////////////////////////////////////////////////
521 // REMOVE_DOWNLOADS 558 // REMOVE_DOWNLOADS
522 if ((remove_mask & BrowsingDataRemover::REMOVE_DOWNLOADS) && 559 if ((remove_mask & BrowsingDataRemover::REMOVE_DOWNLOADS) &&
523 may_delete_history) { 560 may_delete_history) {
524 DownloadPrefs* download_prefs = DownloadPrefs::FromDownloadManager( 561 DownloadPrefs* download_prefs = DownloadPrefs::FromDownloadManager(
525 BrowserContext::GetDownloadManager(profile_)); 562 BrowserContext::GetDownloadManager(profile_));
526 download_prefs->SetSaveFilePath(download_prefs->DownloadPath()); 563 download_prefs->SetSaveFilePath(download_prefs->DownloadPath());
527 } 564 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 password_manager::PasswordStore* password_store = 648 password_manager::PasswordStore* password_store =
612 PasswordStoreFactory::GetForProfile( 649 PasswordStoreFactory::GetForProfile(
613 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); 650 profile_, ServiceAccessType::EXPLICIT_ACCESS).get();
614 651
615 if (password_store) { 652 if (password_store) {
616 clear_passwords_.Start(); 653 clear_passwords_.Start();
617 password_store->RemoveLoginsByURLAndTime( 654 password_store->RemoveLoginsByURLAndTime(
618 filter, delete_begin_, delete_end_, 655 filter, delete_begin_, delete_end_,
619 clear_passwords_.GetCompletionCallback()); 656 clear_passwords_.GetCompletionCallback());
620 } 657 }
658
659 scoped_refptr<net::URLRequestContextGetter> request_context =
660 BrowserContext::GetDefaultStoragePartition(profile_)
661 ->GetURLRequestContext();
662 clear_http_auth_cache_.Start();
663 BrowserThread::PostTaskAndReply(
664 BrowserThread::IO, FROM_HERE,
665 base::Bind(&ClearHttpAuthCacheOnIOThread, std::move(request_context),
666 delete_begin_),
667 clear_http_auth_cache_.GetCompletionCallback());
621 } 668 }
622 669
623 if (remove_mask & BrowsingDataRemover::REMOVE_COOKIES) { 670 if (remove_mask & BrowsingDataRemover::REMOVE_COOKIES) {
624 password_manager::PasswordStore* password_store = 671 password_manager::PasswordStore* password_store =
625 PasswordStoreFactory::GetForProfile(profile_, 672 PasswordStoreFactory::GetForProfile(profile_,
626 ServiceAccessType::EXPLICIT_ACCESS) 673 ServiceAccessType::EXPLICIT_ACCESS)
627 .get(); 674 .get();
628 675
629 if (password_store) { 676 if (password_store) {
630 clear_auto_sign_in_.Start(); 677 clear_auto_sign_in_.Start();
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 !clear_form_.is_pending() && !clear_history_.is_pending() && 887 !clear_form_.is_pending() && !clear_history_.is_pending() &&
841 !clear_hostname_resolution_cache_.is_pending() && 888 !clear_hostname_resolution_cache_.is_pending() &&
842 !clear_keyword_data_.is_pending() && 889 !clear_keyword_data_.is_pending() &&
843 #if !defined(DISABLE_NACL) 890 #if !defined(DISABLE_NACL)
844 !clear_nacl_cache_.is_pending() && !clear_pnacl_cache_.is_pending() && 891 !clear_nacl_cache_.is_pending() && !clear_pnacl_cache_.is_pending() &&
845 #endif 892 #endif
846 !clear_network_predictor_.is_pending() && 893 !clear_network_predictor_.is_pending() &&
847 !clear_networking_history_.is_pending() && 894 !clear_networking_history_.is_pending() &&
848 !clear_passwords_.is_pending() && 895 !clear_passwords_.is_pending() &&
849 !clear_passwords_stats_.is_pending() && 896 !clear_passwords_stats_.is_pending() &&
897 !clear_http_auth_cache_.is_pending() &&
850 !clear_platform_keys_.is_pending() && 898 !clear_platform_keys_.is_pending() &&
851 #if defined(OS_ANDROID) 899 #if defined(OS_ANDROID)
852 !clear_precache_history_.is_pending() && 900 !clear_precache_history_.is_pending() &&
853 !clear_offline_page_data_.is_pending() && 901 !clear_offline_page_data_.is_pending() &&
854 #endif 902 #endif
855 #if BUILDFLAG(ENABLE_WEBRTC) 903 #if BUILDFLAG(ENABLE_WEBRTC)
856 !clear_webrtc_logs_.is_pending() && 904 !clear_webrtc_logs_.is_pending() &&
857 #endif 905 #endif
858 !clear_auto_sign_in_.is_pending(); 906 !clear_auto_sign_in_.is_pending();
859 } 907 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 944
897 #if defined(OS_CHROMEOS) 945 #if defined(OS_CHROMEOS)
898 void ChromeBrowsingDataRemoverDelegate::OnClearPlatformKeys( 946 void ChromeBrowsingDataRemoverDelegate::OnClearPlatformKeys(
899 chromeos::DBusMethodCallStatus call_status, 947 chromeos::DBusMethodCallStatus call_status,
900 bool result) { 948 bool result) {
901 LOG_IF(ERROR, call_status != chromeos::DBUS_METHOD_CALL_SUCCESS || !result) 949 LOG_IF(ERROR, call_status != chromeos::DBUS_METHOD_CALL_SUCCESS || !result)
902 << "Failed to clear platform keys."; 950 << "Failed to clear platform keys.";
903 clear_platform_keys_.GetCompletionCallback().Run(); 951 clear_platform_keys_.GetCompletionCallback().Run();
904 } 952 }
905 #endif 953 #endif
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698