| OLD | NEW |
| 1 // Copyright (c) 2012 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/browsing_data_remover.h" | 5 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" |
| 6 | 6 |
| 7 #include <map> | |
| 8 #include <set> | |
| 9 #include <string> | |
| 10 #include <utility> | |
| 11 | |
| 12 #include "base/bind.h" | |
| 13 #include "base/bind_helpers.h" | |
| 14 #include "base/callback.h" | |
| 15 #include "base/logging.h" | |
| 16 #include "base/metrics/histogram_macros.h" | |
| 17 #include "build/build_config.h" | |
| 18 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 7 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 19 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/browsing_data/browsing_data_filter_builder.h" | 9 #include "chrome/browser/browsing_data/browsing_data_filter_builder.h" |
| 21 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 10 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 22 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | |
| 23 #include "chrome/browser/browsing_data/registrable_domain_filter_builder.h" | 11 #include "chrome/browser/browsing_data/registrable_domain_filter_builder.h" |
| 24 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
| 25 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 13 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 26 #include "chrome/browser/domain_reliability/service_factory.h" | 14 #include "chrome/browser/domain_reliability/service_factory.h" |
| 27 #include "chrome/browser/download/download_prefs.h" | |
| 28 #include "chrome/browser/history/history_service_factory.h" | 15 #include "chrome/browser/history/history_service_factory.h" |
| 29 #include "chrome/browser/history/web_history_service_factory.h" | 16 #include "chrome/browser/history/web_history_service_factory.h" |
| 30 #include "chrome/browser/io_thread.h" | 17 #include "chrome/browser/io_thread.h" |
| 31 #include "chrome/browser/media/media_device_id_salt.h" | 18 #include "chrome/browser/media/media_device_id_salt.h" |
| 32 #include "chrome/browser/net/nqe/ui_network_quality_estimator_service.h" | 19 #include "chrome/browser/net/nqe/ui_network_quality_estimator_service.h" |
| 33 #include "chrome/browser/net/nqe/ui_network_quality_estimator_service_factory.h" | 20 #include "chrome/browser/net/nqe/ui_network_quality_estimator_service_factory.h" |
| 34 #include "chrome/browser/net/predictor.h" | 21 #include "chrome/browser/net/predictor.h" |
| 35 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | 22 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
| 36 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact
ory.h" | 23 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact
ory.h" |
| 37 #include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h" | 24 #include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h" |
| 38 #include "chrome/browser/password_manager/password_store_factory.h" | 25 #include "chrome/browser/password_manager/password_store_factory.h" |
| 39 #include "chrome/browser/permissions/permission_decision_auto_blocker.h" | 26 #include "chrome/browser/permissions/permission_decision_auto_blocker.h" |
| 40 #include "chrome/browser/prerender/prerender_manager.h" | 27 #include "chrome/browser/prerender/prerender_manager.h" |
| 41 #include "chrome/browser/prerender/prerender_manager_factory.h" | 28 #include "chrome/browser/prerender/prerender_manager_factory.h" |
| 42 #include "chrome/browser/previews/previews_service.h" | 29 #include "chrome/browser/previews/previews_service.h" |
| 43 #include "chrome/browser/previews/previews_service_factory.h" | 30 #include "chrome/browser/previews/previews_service_factory.h" |
| 44 #include "chrome/browser/profiles/profile.h" | 31 #include "chrome/browser/profiles/profile.h" |
| 45 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 32 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 46 #include "chrome/browser/search_engines/template_url_service_factory.h" | 33 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 47 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 34 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 48 #include "chrome/browser/web_data_service_factory.h" | 35 #include "chrome/browser/web_data_service_factory.h" |
| 49 #include "chrome/common/features.h" | 36 #include "chrome/common/features.h" |
| 50 #include "chrome/common/pref_names.h" | 37 #include "chrome/common/pref_names.h" |
| 51 #include "chrome/common/url_constants.h" | 38 #include "chrome/common/url_constants.h" |
| 52 #include "components/autofill/core/browser/personal_data_manager.h" | 39 #include "components/autofill/core/browser/personal_data_manager.h" |
| 53 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 40 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
| 54 #include "components/browsing_data/content/storage_partition_http_cache_data_rem
over.h" | |
| 55 #include "components/content_settings/core/browser/host_content_settings_map.h" | 41 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 56 #include "components/content_settings/core/common/content_settings.h" | 42 #include "components/content_settings/core/common/content_settings.h" |
| 57 #include "components/content_settings/core/common/content_settings_pattern.h" | 43 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 58 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp
ression_stats.h" | 44 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp
ression_stats.h" |
| 59 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv
ice.h" | 45 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv
ice.h" |
| 60 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" | 46 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" |
| 61 #include "components/domain_reliability/service.h" | 47 #include "components/domain_reliability/service.h" |
| 62 #include "components/history/core/browser/history_service.h" | 48 #include "components/history/core/browser/history_service.h" |
| 63 #include "components/nacl/browser/nacl_browser.h" | 49 #include "components/nacl/browser/nacl_browser.h" |
| 64 #include "components/nacl/browser/pnacl_host.h" | 50 #include "components/nacl/browser/pnacl_host.h" |
| 65 #include "components/ntp_snippets/content_suggestions_service.h" | 51 #include "components/ntp_snippets/content_suggestions_service.h" |
| 66 #include "components/omnibox/browser/omnibox_pref_names.h" | 52 #include "components/omnibox/browser/omnibox_pref_names.h" |
| 67 #include "components/password_manager/core/browser/password_store.h" | 53 #include "components/password_manager/core/browser/password_store.h" |
| 68 #include "components/prefs/pref_service.h" | 54 #include "components/prefs/pref_service.h" |
| 69 #include "components/previews/core/previews_ui_service.h" | 55 #include "components/previews/core/previews_ui_service.h" |
| 70 #include "components/search_engines/template_url_service.h" | 56 #include "components/search_engines/template_url_service.h" |
| 71 #include "components/sessions/core/tab_restore_service.h" | 57 #include "components/sessions/core/tab_restore_service.h" |
| 72 #include "components/web_cache/browser/web_cache_manager.h" | |
| 73 #include "content/public/browser/browser_thread.h" | |
| 74 #include "content/public/browser/download_manager.h" | |
| 75 #include "content/public/browser/notification_service.h" | |
| 76 #include "content/public/browser/plugin_data_remover.h" | |
| 77 #include "content/public/browser/ssl_host_state_delegate.h" | |
| 78 #include "content/public/browser/storage_partition.h" | |
| 79 #include "content/public/browser/user_metrics.h" | 58 #include "content/public/browser/user_metrics.h" |
| 80 #include "extensions/features/features.h" | |
| 81 #include "media/media_features.h" | |
| 82 #include "net/base/net_errors.h" | |
| 83 #include "net/cookies/cookie_store.h" | 59 #include "net/cookies/cookie_store.h" |
| 84 #include "net/http/http_network_session.h" | |
| 85 #include "net/http/http_transaction_factory.h" | |
| 86 #include "net/http/transport_security_state.h" | |
| 87 #include "net/ssl/channel_id_service.h" | |
| 88 #include "net/ssl/channel_id_store.h" | |
| 89 #include "net/url_request/url_request_context.h" | 60 #include "net/url_request/url_request_context.h" |
| 90 #include "net/url_request/url_request_context_getter.h" | 61 #include "net/url_request/url_request_context_getter.h" |
| 91 #include "ppapi/features/features.h" | |
| 92 #include "storage/browser/quota/special_storage_policy.h" | |
| 93 #include "url/origin.h" | |
| 94 | 62 |
| 95 #if BUILDFLAG(ANDROID_JAVA_UI) | 63 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 96 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 64 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
| 97 #include "chrome/browser/android/webapps/webapp_registry.h" | 65 #include "chrome/browser/android/webapps/webapp_registry.h" |
| 98 #include "chrome/browser/precache/precache_manager_factory.h" | 66 #include "chrome/browser/precache/precache_manager_factory.h" |
| 99 #include "components/offline_pages/core/offline_page_feature.h" | 67 #include "components/offline_pages/core/offline_page_feature.h" |
| 100 #include "components/offline_pages/core/offline_page_model.h" | 68 #include "components/offline_pages/core/offline_page_model.h" |
| 101 #include "components/precache/content/precache_manager.h" | 69 #include "components/precache/content/precache_manager.h" |
| 102 #endif | 70 #endif |
| 103 | 71 |
| 104 #if BUILDFLAG(ENABLE_EXTENSIONS) | 72 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 105 #include "chrome/browser/extensions/activity_log/activity_log.h" | 73 #include "chrome/browser/extensions/activity_log/activity_log.h" |
| 106 #include "extensions/browser/extension_prefs.h" | 74 #include "extensions/browser/extension_prefs.h" |
| 107 #endif | 75 #endif |
| 108 | 76 |
| 109 #if BUILDFLAG(ENABLE_PLUGINS) | |
| 110 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" | |
| 111 #endif | |
| 112 | |
| 113 #if BUILDFLAG(ENABLE_SESSION_SERVICE) | 77 #if BUILDFLAG(ENABLE_SESSION_SERVICE) |
| 114 #include "chrome/browser/sessions/session_service.h" | 78 #include "chrome/browser/sessions/session_service.h" |
| 115 #include "chrome/browser/sessions/session_service_factory.h" | 79 #include "chrome/browser/sessions/session_service_factory.h" |
| 116 #endif | 80 #endif |
| 117 | 81 |
| 118 #if defined(OS_CHROMEOS) | 82 #if defined(OS_CHROMEOS) |
| 119 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 83 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 120 #include "chromeos/attestation/attestation_constants.h" | 84 #include "chromeos/attestation/attestation_constants.h" |
| 121 #include "chromeos/cryptohome/cryptohome_parameters.h" | 85 #include "chromeos/cryptohome/cryptohome_parameters.h" |
| 122 #include "chromeos/dbus/cryptohome_client.h" | 86 #include "chromeos/dbus/cryptohome_client.h" |
| 123 #include "chromeos/dbus/dbus_thread_manager.h" | 87 #include "chromeos/dbus/dbus_thread_manager.h" |
| 124 #include "components/user_manager/user.h" | 88 #include "components/user_manager/user.h" |
| 125 #endif | 89 #endif |
| 126 | 90 |
| 127 #if BUILDFLAG(ENABLE_WEBRTC) | 91 #if BUILDFLAG(ENABLE_WEBRTC) |
| 128 #include "chrome/browser/media/webrtc/webrtc_log_list.h" | 92 #include "chrome/browser/media/webrtc/webrtc_log_list.h" |
| 129 #include "chrome/browser/media/webrtc/webrtc_log_util.h" | 93 #include "chrome/browser/media/webrtc/webrtc_log_util.h" |
| 130 #endif | 94 #endif |
| 131 | 95 |
| 132 using base::UserMetricsAction; | 96 using base::UserMetricsAction; |
| 133 using content::BrowserContext; | 97 using content::BrowserContext; |
| 134 using content::BrowserThread; | 98 using content::BrowserThread; |
| 135 using content::DOMStorageContext; | |
| 136 | 99 |
| 137 namespace { | 100 namespace { |
| 138 | 101 |
| 139 void UIThreadTrampolineHelper(const base::Closure& callback) { | 102 void UIThreadTrampolineHelper(const base::Closure& callback) { |
| 140 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); | 103 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); |
| 141 } | 104 } |
| 142 | 105 |
| 143 // Convenience method to create a callback that can be run on any thread and | 106 // Convenience method to create a callback that can be run on any thread and |
| 144 // will post the given |callback| back to the UI thread. | 107 // will post the given |callback| back to the UI thread. |
| 145 base::Closure UIThreadTrampoline(const base::Closure& callback) { | 108 base::Closure UIThreadTrampoline(const base::Closure& callback) { |
| 146 // We could directly bind &BrowserThread::PostTask, but that would require | 109 // We could directly bind &BrowserThread::PostTask, but that would require |
| 147 // evaluating FROM_HERE when this method is called, as opposed to when the | 110 // evaluating FROM_HERE when this method is called, as opposed to when the |
| 148 // task is actually posted. | 111 // task is actually posted. |
| 149 return base::Bind(&UIThreadTrampolineHelper, callback); | 112 return base::Bind(&UIThreadTrampolineHelper, callback); |
| 150 } | 113 } |
| 151 | 114 |
| 152 template <typename T> | 115 template <typename T> |
| 153 void IgnoreArgumentHelper(const base::Closure& callback, T unused_argument) { | 116 void IgnoreArgumentHelper(const base::Closure& callback, T unused_argument) { |
| 154 callback.Run(); | 117 callback.Run(); |
| 155 } | 118 } |
| 156 | 119 |
| 157 // Another convenience method to turn a callback without arguments into one that | 120 // Another convenience method to turn a callback without arguments into one that |
| 158 // accepts (and ignores) a single argument. | 121 // accepts (and ignores) a single argument. |
| 159 template <typename T> | 122 template <typename T> |
| 160 base::Callback<void(T)> IgnoreArgument(const base::Closure& callback) { | 123 base::Callback<void(T)> IgnoreArgument(const base::Closure& callback) { |
| 161 return base::Bind(&IgnoreArgumentHelper<T>, callback); | 124 return base::Bind(&IgnoreArgumentHelper<T>, callback); |
| 162 } | 125 } |
| 163 | 126 |
| 164 // Helper to create callback for BrowsingDataRemover::DoesOriginMatchMask. | |
| 165 bool DoesOriginMatchMaskAndUrls( | |
| 166 int origin_type_mask, | |
| 167 const base::Callback<bool(const GURL&)>& predicate, | |
| 168 const GURL& origin, | |
| 169 storage::SpecialStoragePolicy* special_storage_policy) { | |
| 170 return predicate.Run(origin) && | |
| 171 BrowsingDataHelper::DoesOriginMatchMask(origin, origin_type_mask, | |
| 172 special_storage_policy); | |
| 173 } | |
| 174 | |
| 175 bool ForwardPrimaryPatternCallback( | 127 bool ForwardPrimaryPatternCallback( |
| 176 const base::Callback<bool(const ContentSettingsPattern&)> predicate, | 128 const base::Callback<bool(const ContentSettingsPattern&)> predicate, |
| 177 const ContentSettingsPattern& primary_pattern, | 129 const ContentSettingsPattern& primary_pattern, |
| 178 const ContentSettingsPattern& secondary_pattern) { | 130 const ContentSettingsPattern& secondary_pattern) { |
| 179 return predicate.Run(primary_pattern); | 131 return predicate.Run(primary_pattern); |
| 180 } | 132 } |
| 181 | 133 |
| 182 void ClearHostnameResolutionCacheOnIOThread( | |
| 183 IOThread* io_thread, | |
| 184 base::Callback<bool(const std::string&)> host_filter) { | |
| 185 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 186 | |
| 187 io_thread->ClearHostCache(host_filter); | |
| 188 } | |
| 189 | |
| 190 void ClearHttpAuthCacheOnIOThread( | |
| 191 scoped_refptr<net::URLRequestContextGetter> context_getter, | |
| 192 base::Time delete_begin) { | |
| 193 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 194 | |
| 195 net::HttpNetworkSession* http_session = context_getter->GetURLRequestContext() | |
| 196 ->http_transaction_factory() | |
| 197 ->GetSession(); | |
| 198 DCHECK(http_session); | |
| 199 http_session->http_auth_cache()->ClearEntriesAddedWithin(base::Time::Now() - | |
| 200 delete_begin); | |
| 201 http_session->CloseAllConnections(); | |
| 202 } | |
| 203 | |
| 204 void ClearNetworkPredictorOnIOThread(chrome_browser_net::Predictor* predictor) { | |
| 205 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 206 DCHECK(predictor); | |
| 207 | |
| 208 predictor->DiscardInitialNavigationHistory(); | |
| 209 predictor->DiscardAllResults(); | |
| 210 } | |
| 211 | |
| 212 #if !defined(DISABLE_NACL) | 134 #if !defined(DISABLE_NACL) |
| 213 void ClearNaClCacheOnIOThread(const base::Closure& callback) { | 135 void ClearNaClCacheOnIOThread(const base::Closure& callback) { |
| 214 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 136 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 215 | 137 |
| 216 nacl::NaClBrowser::GetInstance()->ClearValidationCache(callback); | 138 nacl::NaClBrowser::GetInstance()->ClearValidationCache(callback); |
| 217 } | 139 } |
| 218 | 140 |
| 219 void ClearPnaclCacheOnIOThread(base::Time begin, | 141 void ClearPnaclCacheOnIOThread(base::Time begin, |
| 220 base::Time end, | 142 base::Time end, |
| 221 const base::Closure& callback) { | 143 const base::Closure& callback) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 243 net::CookieStore::CookiePredicate predicate, | 165 net::CookieStore::CookiePredicate predicate, |
| 244 net::URLRequestContextGetter* rq_context, | 166 net::URLRequestContextGetter* rq_context, |
| 245 const base::Closure& callback) { | 167 const base::Closure& callback) { |
| 246 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 168 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 247 net::CookieStore* cookie_store = | 169 net::CookieStore* cookie_store = |
| 248 rq_context->GetURLRequestContext()->cookie_store(); | 170 rq_context->GetURLRequestContext()->cookie_store(); |
| 249 cookie_store->DeleteAllCreatedBetweenWithPredicateAsync( | 171 cookie_store->DeleteAllCreatedBetweenWithPredicateAsync( |
| 250 delete_begin, delete_end, predicate, IgnoreArgument<int>(callback)); | 172 delete_begin, delete_end, predicate, IgnoreArgument<int>(callback)); |
| 251 } | 173 } |
| 252 | 174 |
| 253 void OnClearedChannelIDsOnIOThread(net::URLRequestContextGetter* rq_context, | 175 void ClearNetworkPredictorOnIOThread(chrome_browser_net::Predictor* predictor) { |
| 254 const base::Closure& callback) { | 176 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 177 DCHECK(predictor); |
| 178 |
| 179 predictor->DiscardInitialNavigationHistory(); |
| 180 predictor->DiscardAllResults(); |
| 181 } |
| 182 |
| 183 void ClearHostnameResolutionCacheOnIOThread( |
| 184 IOThread* io_thread, |
| 185 base::Callback<bool(const std::string&)> host_filter) { |
| 255 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 186 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 256 | 187 |
| 257 // Need to close open SSL connections which may be using the channel ids we | 188 io_thread->ClearHostCache(host_filter); |
| 258 // are deleting. | |
| 259 // TODO(mattm): http://crbug.com/166069 Make the server bound cert | |
| 260 // service/store have observers that can notify relevant things directly. | |
| 261 rq_context->GetURLRequestContext() | |
| 262 ->ssl_config_service() | |
| 263 ->NotifySSLConfigChange(); | |
| 264 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); | |
| 265 } | |
| 266 | |
| 267 void ClearChannelIDsOnIOThread( | |
| 268 const base::Callback<bool(const std::string&)>& domain_predicate, | |
| 269 base::Time delete_begin, | |
| 270 base::Time delete_end, | |
| 271 scoped_refptr<net::URLRequestContextGetter> rq_context, | |
| 272 const base::Closure& callback) { | |
| 273 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 274 net::ChannelIDService* channel_id_service = | |
| 275 rq_context->GetURLRequestContext()->channel_id_service(); | |
| 276 channel_id_service->GetChannelIDStore()->DeleteForDomainsCreatedBetween( | |
| 277 domain_predicate, delete_begin, delete_end, | |
| 278 base::Bind(&OnClearedChannelIDsOnIOThread, | |
| 279 base::RetainedRef(std::move(rq_context)), callback)); | |
| 280 } | 189 } |
| 281 | 190 |
| 282 } // namespace | 191 } // namespace |
| 283 | 192 |
| 284 BrowsingDataRemover::CompletionInhibitor* | 193 ChromeBrowsingDataRemoverDelegate::ChromeBrowsingDataRemoverDelegate( |
| 285 BrowsingDataRemover::completion_inhibitor_ = nullptr; | 194 BrowserContext* browser_context) |
| 195 : profile_(Profile::FromBrowserContext(browser_context)), |
| 196 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 197 webapp_registry_(new WebappRegistry()), |
| 198 #endif |
| 199 weak_ptr_factory_(this) {} |
| 286 | 200 |
| 287 bool BrowsingDataRemover::TimeRange::operator==( | 201 ChromeBrowsingDataRemoverDelegate::~ChromeBrowsingDataRemoverDelegate() { |
| 288 const BrowsingDataRemover::TimeRange& other) const { | |
| 289 return begin == other.begin && end == other.end; | |
| 290 } | |
| 291 | |
| 292 // static | |
| 293 BrowsingDataRemover::TimeRange BrowsingDataRemover::Unbounded() { | |
| 294 return TimeRange(base::Time(), base::Time::Max()); | |
| 295 } | |
| 296 | |
| 297 // static | |
| 298 BrowsingDataRemover::TimeRange BrowsingDataRemover::Period( | |
| 299 browsing_data::TimePeriod period) { | |
| 300 switch (period) { | |
| 301 case browsing_data::LAST_HOUR: | |
| 302 content::RecordAction(UserMetricsAction("ClearBrowsingData_LastHour")); | |
| 303 break; | |
| 304 case browsing_data::LAST_DAY: | |
| 305 content::RecordAction(UserMetricsAction("ClearBrowsingData_LastDay")); | |
| 306 break; | |
| 307 case browsing_data::LAST_WEEK: | |
| 308 content::RecordAction(UserMetricsAction("ClearBrowsingData_LastWeek")); | |
| 309 break; | |
| 310 case browsing_data::FOUR_WEEKS: | |
| 311 content::RecordAction(UserMetricsAction("ClearBrowsingData_LastMonth")); | |
| 312 break; | |
| 313 case browsing_data::ALL_TIME: | |
| 314 content::RecordAction(UserMetricsAction("ClearBrowsingData_Everything")); | |
| 315 break; | |
| 316 } | |
| 317 return TimeRange(CalculateBeginDeleteTime(period), base::Time::Max()); | |
| 318 } | |
| 319 | |
| 320 BrowsingDataRemover::BrowsingDataRemover( | |
| 321 content::BrowserContext* browser_context) | |
| 322 : profile_(Profile::FromBrowserContext(browser_context)), | |
| 323 remove_mask_(-1), | |
| 324 origin_type_mask_(-1), | |
| 325 is_removing_(false), | |
| 326 #if BUILDFLAG(ENABLE_PLUGINS) | |
| 327 flash_lso_helper_(BrowsingDataFlashLSOHelper::Create(profile_)), | |
| 328 #endif | |
| 329 #if BUILDFLAG(ANDROID_JAVA_UI) | |
| 330 webapp_registry_(new WebappRegistry()), | |
| 331 #endif | |
| 332 weak_ptr_factory_(this) { | |
| 333 DCHECK(browser_context); | |
| 334 } | |
| 335 | |
| 336 BrowsingDataRemover::~BrowsingDataRemover() { | |
| 337 if (!task_queue_.empty()) { | |
| 338 VLOG(1) << "BrowsingDataRemover shuts down with " << task_queue_.size() | |
| 339 << " pending tasks"; | |
| 340 } | |
| 341 | |
| 342 // If we are still removing data, notify observers that their task has been | |
| 343 // (albeit unsucessfuly) processed, so they can unregister themselves. | |
| 344 // TODO(bauerb): If it becomes a problem that browsing data might not actually | |
| 345 // be fully cleared when an observer is notified, add a success flag. | |
| 346 while (!task_queue_.empty()) { | |
| 347 if (observer_list_.HasObserver(task_queue_.front().observer)) | |
| 348 task_queue_.front().observer->OnBrowsingDataRemoverDone(); | |
| 349 task_queue_.pop(); | |
| 350 } | |
| 351 } | |
| 352 | |
| 353 void BrowsingDataRemover::Shutdown() { | |
| 354 history_task_tracker_.TryCancelAll(); | 202 history_task_tracker_.TryCancelAll(); |
| 355 template_url_sub_.reset(); | 203 template_url_sub_.reset(); |
| 356 } | 204 } |
| 357 | 205 |
| 358 void BrowsingDataRemover::SetRemoving(bool is_removing) { | 206 void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData( |
| 359 DCHECK_NE(is_removing_, is_removing); | 207 const base::Time& delete_begin, |
| 360 is_removing_ = is_removing; | 208 const base::Time& delete_end, |
| 361 } | |
| 362 | |
| 363 void BrowsingDataRemover::Remove(const TimeRange& time_range, | |
| 364 int remove_mask, | |
| 365 int origin_type_mask) { | |
| 366 RemoveInternal(time_range, remove_mask, origin_type_mask, | |
| 367 std::unique_ptr<RegistrableDomainFilterBuilder>(), nullptr); | |
| 368 } | |
| 369 | |
| 370 void BrowsingDataRemover::RemoveAndReply( | |
| 371 const TimeRange& time_range, | |
| 372 int remove_mask, | |
| 373 int origin_type_mask, | |
| 374 Observer* observer) { | |
| 375 DCHECK(observer); | |
| 376 RemoveInternal(time_range, remove_mask, origin_type_mask, | |
| 377 std::unique_ptr<RegistrableDomainFilterBuilder>(), observer); | |
| 378 } | |
| 379 | |
| 380 void BrowsingDataRemover::RemoveWithFilter( | |
| 381 const TimeRange& time_range, | |
| 382 int remove_mask, | |
| 383 int origin_type_mask, | |
| 384 std::unique_ptr<BrowsingDataFilterBuilder> filter_builder) { | |
| 385 DCHECK_EQ(0, remove_mask & ~FILTERABLE_DATATYPES); | |
| 386 DCHECK(filter_builder); | |
| 387 RemoveInternal(time_range, remove_mask, origin_type_mask, | |
| 388 std::move(filter_builder), nullptr); | |
| 389 } | |
| 390 | |
| 391 void BrowsingDataRemover::RemoveWithFilterAndReply( | |
| 392 const TimeRange& time_range, | |
| 393 int remove_mask, | |
| 394 int origin_type_mask, | |
| 395 std::unique_ptr<BrowsingDataFilterBuilder> filter_builder, | |
| 396 Observer* observer) { | |
| 397 DCHECK_EQ(0, remove_mask & ~FILTERABLE_DATATYPES); | |
| 398 DCHECK(filter_builder); | |
| 399 DCHECK(observer); | |
| 400 RemoveInternal(time_range, remove_mask, origin_type_mask, | |
| 401 std::move(filter_builder), observer); | |
| 402 } | |
| 403 | |
| 404 void BrowsingDataRemover::RemoveInternal( | |
| 405 const TimeRange& time_range, | |
| 406 int remove_mask, | |
| 407 int origin_type_mask, | |
| 408 std::unique_ptr<BrowsingDataFilterBuilder> filter_builder, | |
| 409 Observer* observer) { | |
| 410 DCHECK(!observer || observer_list_.HasObserver(observer)) | |
| 411 << "Every observer must register itself (by calling AddObserver()) " | |
| 412 << "before observing a removal task."; | |
| 413 | |
| 414 // Remove() and RemoveAndReply() pass a null pointer to indicate no filter. | |
| 415 // No filter is equivalent to one that |IsEmptyBlacklist()|. | |
| 416 if (!filter_builder) { | |
| 417 filter_builder = base::MakeUnique<RegistrableDomainFilterBuilder>( | |
| 418 RegistrableDomainFilterBuilder::BLACKLIST); | |
| 419 DCHECK(filter_builder->IsEmptyBlacklist()); | |
| 420 } | |
| 421 | |
| 422 task_queue_.emplace( | |
| 423 time_range, | |
| 424 remove_mask, | |
| 425 origin_type_mask, | |
| 426 std::move(filter_builder), | |
| 427 observer); | |
| 428 | |
| 429 // If this is the only scheduled task, execute it immediately. Otherwise, | |
| 430 // it will be automatically executed when all tasks scheduled before it | |
| 431 // finish. | |
| 432 if (task_queue_.size() == 1) { | |
| 433 SetRemoving(true); | |
| 434 RunNextTask(); | |
| 435 } | |
| 436 } | |
| 437 | |
| 438 void BrowsingDataRemover::RunNextTask() { | |
| 439 DCHECK(!task_queue_.empty()); | |
| 440 const RemovalTask& removal_task = task_queue_.front(); | |
| 441 | |
| 442 RemoveImpl(removal_task.time_range, | |
| 443 removal_task.remove_mask, | |
| 444 *removal_task.filter_builder, | |
| 445 removal_task.origin_type_mask); | |
| 446 } | |
| 447 | |
| 448 void BrowsingDataRemover::RemoveImpl( | |
| 449 const TimeRange& time_range, | |
| 450 int remove_mask, | 209 int remove_mask, |
| 451 const BrowsingDataFilterBuilder& filter_builder, | 210 const BrowsingDataFilterBuilder& filter_builder, |
| 452 int origin_type_mask) { | 211 int origin_type_mask, |
| 453 // =============== README before adding more storage backends =============== | 212 const base::Closure& callback) { |
| 454 // | 213 ////////////////////////////////////////////////////////////////////////////// |
| 455 // If you're adding a data storage backend that is included among | 214 // INITIALIZATION |
| 456 // RemoveDataMask::FILTERABLE_DATATYPES, you must do one of the following: | |
| 457 // 1. Support one of the filters generated by |filter_builder|. | |
| 458 // 2. Add a comment explaining why is it acceptable in your case to delete all | |
| 459 // data without filtering URLs / origins / domains. | |
| 460 // 3. Do not support partial deletion, i.e. only delete your data if | |
| 461 // |filter_builder.IsEmptyBlacklist()|. Add a comment explaining why this | |
| 462 // is acceptable. | |
| 463 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 464 waiting_for_synchronous_clear_operations_ = true; | 215 waiting_for_synchronous_clear_operations_ = true; |
| 216 callback_ = callback; |
| 465 | 217 |
| 466 // crbug.com/140910: Many places were calling this with base::Time() as | 218 delete_begin_ = delete_begin; |
| 467 // delete_end, even though they should've used base::Time::Max(). | 219 delete_end_ = delete_end; |
| 468 DCHECK_NE(base::Time(), time_range.end); | |
| 469 | |
| 470 delete_begin_ = time_range.begin; | |
| 471 delete_end_ = time_range.end; | |
| 472 remove_mask_ = remove_mask; | |
| 473 origin_type_mask_ = origin_type_mask; | |
| 474 | 220 |
| 475 base::Callback<bool(const GURL& url)> filter = | 221 base::Callback<bool(const GURL& url)> filter = |
| 476 filter_builder.BuildGeneralFilter(); | 222 filter_builder.BuildGeneralFilter(); |
| 477 base::Callback<bool(const ContentSettingsPattern& url)> same_pattern_filter = | 223 base::Callback<bool(const ContentSettingsPattern& url)> same_pattern_filter = |
| 478 filter_builder.BuildWebsiteSettingsPatternMatchesFilter(); | 224 filter_builder.BuildWebsiteSettingsPatternMatchesFilter(); |
| 479 | 225 |
| 480 // Some backends support a filter that |is_null()| to make complete deletion | 226 // Some backends support a filter that |is_null()| to make complete deletion |
| 481 // more efficient. | 227 // more efficient. |
| 482 base::Callback<bool(const GURL&)> nullable_filter = | 228 base::Callback<bool(const GURL&)> nullable_filter = |
| 483 filter_builder.IsEmptyBlacklist() ? base::Callback<bool(const GURL&)>() | 229 filter_builder.IsEmptyBlacklist() ? base::Callback<bool(const GURL&)>() |
| 484 : filter; | 230 : filter; |
| 485 | 231 |
| 232 // Managed devices and supervised users can have restrictions on history |
| 233 // deletion. |
| 486 PrefService* prefs = profile_->GetPrefs(); | 234 PrefService* prefs = profile_->GetPrefs(); |
| 487 bool may_delete_history = prefs->GetBoolean( | 235 bool may_delete_history = prefs->GetBoolean( |
| 488 prefs::kAllowDeletingBrowserHistory); | 236 prefs::kAllowDeletingBrowserHistory); |
| 489 | 237 |
| 490 // All the UI entry points into the BrowsingDataRemover should be disabled, | 238 ////////////////////////////////////////////////////////////////////////////// |
| 491 // but this will fire if something was missed or added. | 239 // REMOVE_HISTORY |
| 492 DCHECK(may_delete_history || (remove_mask & REMOVE_NOCHECKS) || | 240 if ((remove_mask & BrowsingDataRemover::REMOVE_HISTORY) && |
| 493 (!(remove_mask & REMOVE_HISTORY) && !(remove_mask & REMOVE_DOWNLOADS))); | 241 may_delete_history) { |
| 494 | |
| 495 if (origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { | |
| 496 content::RecordAction( | |
| 497 UserMetricsAction("ClearBrowsingData_MaskContainsUnprotectedWeb")); | |
| 498 } | |
| 499 if (origin_type_mask_ & BrowsingDataHelper::PROTECTED_WEB) { | |
| 500 content::RecordAction( | |
| 501 UserMetricsAction("ClearBrowsingData_MaskContainsProtectedWeb")); | |
| 502 } | |
| 503 if (origin_type_mask_ & BrowsingDataHelper::EXTENSION) { | |
| 504 content::RecordAction( | |
| 505 UserMetricsAction("ClearBrowsingData_MaskContainsExtension")); | |
| 506 } | |
| 507 // If this fires, we added a new BrowsingDataHelper::OriginTypeMask without | |
| 508 // updating the user metrics above. | |
| 509 static_assert( | |
| 510 BrowsingDataHelper::ALL == (BrowsingDataHelper::UNPROTECTED_WEB | | |
| 511 BrowsingDataHelper::PROTECTED_WEB | | |
| 512 BrowsingDataHelper::EXTENSION), | |
| 513 "OriginTypeMask has been updated without updating user metrics"); | |
| 514 | |
| 515 if ((remove_mask & REMOVE_HISTORY) && may_delete_history) { | |
| 516 history::HistoryService* history_service = | 242 history::HistoryService* history_service = |
| 517 HistoryServiceFactory::GetForProfile( | 243 HistoryServiceFactory::GetForProfile( |
| 518 profile_, ServiceAccessType::EXPLICIT_ACCESS); | 244 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
| 519 if (history_service) { | 245 if (history_service) { |
| 520 // TODO(dmurph): Support all backends with filter (crbug.com/113621). | 246 // TODO(dmurph): Support all backends with filter (crbug.com/113621). |
| 521 content::RecordAction(UserMetricsAction("ClearBrowsingData_History")); | 247 content::RecordAction(UserMetricsAction("ClearBrowsingData_History")); |
| 522 waiting_for_clear_history_ = true; | 248 waiting_for_clear_history_ = true; |
| 523 history_service->ExpireLocalAndRemoteHistoryBetween( | 249 history_service->ExpireLocalAndRemoteHistoryBetween( |
| 524 WebHistoryServiceFactory::GetForProfile(profile_), std::set<GURL>(), | 250 WebHistoryServiceFactory::GetForProfile(profile_), std::set<GURL>(), |
| 525 delete_begin_, delete_end_, | 251 delete_begin_, delete_end_, |
| 526 base::Bind(&BrowsingDataRemover::OnHistoryDeletionDone, | 252 base::Bind(&ChromeBrowsingDataRemoverDelegate::OnHistoryDeletionDone, |
| 527 weak_ptr_factory_.GetWeakPtr()), | 253 weak_ptr_factory_.GetWeakPtr()), |
| 528 &history_task_tracker_); | 254 &history_task_tracker_); |
| 529 } | 255 } |
| 530 | 256 |
| 531 ntp_snippets::ContentSuggestionsService* content_suggestions_service = | 257 ntp_snippets::ContentSuggestionsService* content_suggestions_service = |
| 532 ContentSuggestionsServiceFactory::GetForProfileIfExists(profile_); | 258 ContentSuggestionsServiceFactory::GetForProfileIfExists(profile_); |
| 533 if (content_suggestions_service) { | 259 if (content_suggestions_service) { |
| 534 content_suggestions_service->ClearHistory(delete_begin_, delete_end_, | 260 content_suggestions_service->ClearHistory(delete_begin_, delete_end_, |
| 535 filter); | 261 filter); |
| 536 } | 262 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 561 // TODO(msramek): We can use the plugin filter here because plugins, same | 287 // TODO(msramek): We can use the plugin filter here because plugins, same |
| 562 // as the hostname resolution cache, key their entries by hostname. Rename | 288 // as the hostname resolution cache, key their entries by hostname. Rename |
| 563 // BuildPluginFilter() to something more general to reflect this use. | 289 // BuildPluginFilter() to something more general to reflect this use. |
| 564 if (g_browser_process->io_thread()) { | 290 if (g_browser_process->io_thread()) { |
| 565 waiting_for_clear_hostname_resolution_cache_ = true; | 291 waiting_for_clear_hostname_resolution_cache_ = true; |
| 566 BrowserThread::PostTaskAndReply( | 292 BrowserThread::PostTaskAndReply( |
| 567 BrowserThread::IO, FROM_HERE, | 293 BrowserThread::IO, FROM_HERE, |
| 568 base::Bind(&ClearHostnameResolutionCacheOnIOThread, | 294 base::Bind(&ClearHostnameResolutionCacheOnIOThread, |
| 569 g_browser_process->io_thread(), | 295 g_browser_process->io_thread(), |
| 570 filter_builder.BuildPluginFilter()), | 296 filter_builder.BuildPluginFilter()), |
| 571 base::Bind(&BrowsingDataRemover::OnClearedHostnameResolutionCache, | 297 base::Bind(&ChromeBrowsingDataRemoverDelegate:: |
| 298 OnClearedHostnameResolutionCache, |
| 572 weak_ptr_factory_.GetWeakPtr())); | 299 weak_ptr_factory_.GetWeakPtr())); |
| 573 } | 300 } |
| 574 if (profile_->GetNetworkPredictor()) { | 301 if (profile_->GetNetworkPredictor()) { |
| 575 // TODO(dmurph): Support all backends with filter (crbug.com/113621). | 302 // TODO(dmurph): Support all backends with filter (crbug.com/113621). |
| 576 waiting_for_clear_network_predictor_ = true; | 303 waiting_for_clear_network_predictor_ = true; |
| 577 BrowserThread::PostTaskAndReply( | 304 BrowserThread::PostTaskAndReply( |
| 578 BrowserThread::IO, FROM_HERE, | 305 BrowserThread::IO, FROM_HERE, |
| 579 base::Bind(&ClearNetworkPredictorOnIOThread, | 306 base::Bind(&ClearNetworkPredictorOnIOThread, |
| 580 profile_->GetNetworkPredictor()), | 307 profile_->GetNetworkPredictor()), |
| 581 base::Bind(&BrowsingDataRemover::OnClearedNetworkPredictor, | 308 base::Bind( |
| 582 weak_ptr_factory_.GetWeakPtr())); | 309 &ChromeBrowsingDataRemoverDelegate::OnClearedNetworkPredictor, |
| 310 weak_ptr_factory_.GetWeakPtr())); |
| 583 profile_->GetNetworkPredictor()->ClearPrefsOnUIThread(); | 311 profile_->GetNetworkPredictor()->ClearPrefsOnUIThread(); |
| 584 } | 312 } |
| 585 | 313 |
| 586 // As part of history deletion we also delete the auto-generated keywords. | 314 // As part of history deletion we also delete the auto-generated keywords. |
| 587 TemplateURLService* keywords_model = | 315 TemplateURLService* keywords_model = |
| 588 TemplateURLServiceFactory::GetForProfile(profile_); | 316 TemplateURLServiceFactory::GetForProfile(profile_); |
| 589 | 317 |
| 590 if (keywords_model && !keywords_model->loaded()) { | 318 if (keywords_model && !keywords_model->loaded()) { |
| 591 // TODO(msramek): Store filters from the currently executed task on the | 319 // TODO(msramek): Store filters from the currently executed task on the |
| 592 // object to avoid having to copy them to callback methods. | 320 // object to avoid having to copy them to callback methods. |
| 593 template_url_sub_ = keywords_model->RegisterOnLoadedCallback( | 321 template_url_sub_ = keywords_model->RegisterOnLoadedCallback( |
| 594 base::Bind(&BrowsingDataRemover::OnKeywordsLoaded, | 322 base::Bind(&ChromeBrowsingDataRemoverDelegate::OnKeywordsLoaded, |
| 595 weak_ptr_factory_.GetWeakPtr(), filter)); | 323 weak_ptr_factory_.GetWeakPtr(), filter)); |
| 596 keywords_model->Load(); | 324 keywords_model->Load(); |
| 597 waiting_for_clear_keyword_data_ = true; | 325 waiting_for_clear_keyword_data_ = true; |
| 598 } else if (keywords_model) { | 326 } else if (keywords_model) { |
| 599 keywords_model->RemoveAutoGeneratedForUrlsBetween(filter, delete_begin_, | 327 keywords_model->RemoveAutoGeneratedForUrlsBetween(filter, delete_begin_, |
| 600 delete_end_); | 328 delete_end_); |
| 601 } | 329 } |
| 602 | 330 |
| 603 // The PrerenderManager keeps history of prerendered pages, so clear that. | 331 // The PrerenderManager keeps history of prerendered pages, so clear that. |
| 604 // It also may have a prerendered page. If so, the page could be | 332 // It also may have a prerendered page. If so, the page could be |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 WebDataServiceFactory::GetAutofillWebDataForProfile( | 370 WebDataServiceFactory::GetAutofillWebDataForProfile( |
| 643 profile_, ServiceAccessType::EXPLICIT_ACCESS); | 371 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
| 644 if (web_data_service.get()) { | 372 if (web_data_service.get()) { |
| 645 waiting_for_clear_autofill_origin_urls_ = true; | 373 waiting_for_clear_autofill_origin_urls_ = true; |
| 646 web_data_service->RemoveOriginURLsModifiedBetween( | 374 web_data_service->RemoveOriginURLsModifiedBetween( |
| 647 delete_begin_, delete_end_); | 375 delete_begin_, delete_end_); |
| 648 // The above calls are done on the UI thread but do their work on the DB | 376 // The above calls are done on the UI thread but do their work on the DB |
| 649 // thread. So wait for it. | 377 // thread. So wait for it. |
| 650 BrowserThread::PostTaskAndReply( | 378 BrowserThread::PostTaskAndReply( |
| 651 BrowserThread::DB, FROM_HERE, base::Bind(&base::DoNothing), | 379 BrowserThread::DB, FROM_HERE, base::Bind(&base::DoNothing), |
| 652 base::Bind(&BrowsingDataRemover::OnClearedAutofillOriginURLs, | 380 base::Bind( |
| 653 weak_ptr_factory_.GetWeakPtr())); | 381 &ChromeBrowsingDataRemoverDelegate::OnClearedAutofillOriginURLs, |
| 382 weak_ptr_factory_.GetWeakPtr())); |
| 654 | 383 |
| 655 autofill::PersonalDataManager* data_manager = | 384 autofill::PersonalDataManager* data_manager = |
| 656 autofill::PersonalDataManagerFactory::GetForProfile(profile_); | 385 autofill::PersonalDataManagerFactory::GetForProfile(profile_); |
| 657 if (data_manager) | 386 if (data_manager) |
| 658 data_manager->Refresh(); | 387 data_manager->Refresh(); |
| 659 } | 388 } |
| 660 | 389 |
| 661 #if BUILDFLAG(ENABLE_WEBRTC) | 390 #if BUILDFLAG(ENABLE_WEBRTC) |
| 662 waiting_for_clear_webrtc_logs_ = true; | 391 waiting_for_clear_webrtc_logs_ = true; |
| 663 BrowserThread::PostTaskAndReply( | 392 BrowserThread::PostTaskAndReply( |
| 664 BrowserThread::FILE, FROM_HERE, | 393 BrowserThread::FILE, FROM_HERE, |
| 665 base::Bind( | 394 base::Bind( |
| 666 &WebRtcLogUtil::DeleteOldAndRecentWebRtcLogFiles, | 395 &WebRtcLogUtil::DeleteOldAndRecentWebRtcLogFiles, |
| 667 WebRtcLogList::GetWebRtcLogDirectoryForProfile(profile_->GetPath()), | 396 WebRtcLogList::GetWebRtcLogDirectoryForProfile(profile_->GetPath()), |
| 668 delete_begin_), | 397 delete_begin_), |
| 669 base::Bind(&BrowsingDataRemover::OnClearedWebRtcLogs, | 398 base::Bind(&ChromeBrowsingDataRemoverDelegate::OnClearedWebRtcLogs, |
| 670 weak_ptr_factory_.GetWeakPtr())); | 399 weak_ptr_factory_.GetWeakPtr())); |
| 671 #endif | 400 #endif |
| 672 | 401 |
| 673 // The SSL Host State that tracks SSL interstitial "proceed" decisions may | |
| 674 // include origins that the user has visited, so it must be cleared. | |
| 675 // TODO(msramek): We can reuse the plugin filter here, since both plugins | |
| 676 // and SSL host state are scoped to hosts and represent them as std::string. | |
| 677 // Rename the method to indicate its more general usage. | |
| 678 if (profile_->GetSSLHostStateDelegate()) { | |
| 679 profile_->GetSSLHostStateDelegate()->Clear( | |
| 680 filter_builder.IsEmptyBlacklist() | |
| 681 ? base::Callback<bool(const std::string&)>() | |
| 682 : filter_builder.BuildPluginFilter()); | |
| 683 } | |
| 684 | |
| 685 #if BUILDFLAG(ANDROID_JAVA_UI) | 402 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 686 precache::PrecacheManager* precache_manager = | 403 precache::PrecacheManager* precache_manager = |
| 687 precache::PrecacheManagerFactory::GetForBrowserContext(profile_); | 404 precache::PrecacheManagerFactory::GetForBrowserContext(profile_); |
| 688 // |precache_manager| could be nullptr if the profile is off the record. | 405 // |precache_manager| could be nullptr if the profile is off the record. |
| 689 if (!precache_manager) { | 406 if (!precache_manager) { |
| 690 waiting_for_clear_precache_history_ = true; | 407 waiting_for_clear_precache_history_ = true; |
| 691 precache_manager->ClearHistory(); | 408 precache_manager->ClearHistory(); |
| 692 // The above calls are done on the UI thread but do their work on the DB | 409 // The above calls are done on the UI thread but do their work on the DB |
| 693 // thread. So wait for it. | 410 // thread. So wait for it. |
| 694 BrowserThread::PostTaskAndReply( | 411 BrowserThread::PostTaskAndReply( |
| 695 BrowserThread::DB, FROM_HERE, base::Bind(&base::DoNothing), | 412 BrowserThread::DB, FROM_HERE, base::Bind(&base::DoNothing), |
| 696 base::Bind(&BrowsingDataRemover::OnClearedPrecacheHistory, | 413 base::Bind( |
| 697 weak_ptr_factory_.GetWeakPtr())); | 414 &ChromeBrowsingDataRemoverDelegate::OnClearedPrecacheHistory, |
| 415 weak_ptr_factory_.GetWeakPtr())); |
| 698 } | 416 } |
| 699 | 417 |
| 700 // Clear the history information (last launch time and origin URL) of any | 418 // Clear the history information (last launch time and origin URL) of any |
| 701 // registered webapps. | 419 // registered webapps. |
| 702 webapp_registry_->ClearWebappHistoryForUrls(filter); | 420 webapp_registry_->ClearWebappHistoryForUrls(filter); |
| 703 #endif | 421 #endif |
| 704 | 422 |
| 705 data_reduction_proxy::DataReductionProxySettings* | 423 data_reduction_proxy::DataReductionProxySettings* |
| 706 data_reduction_proxy_settings = | 424 data_reduction_proxy_settings = |
| 707 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( | 425 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 719 | 437 |
| 720 // |previews_service| is null if |profile_| is off the record. | 438 // |previews_service| is null if |profile_| is off the record. |
| 721 PreviewsService* previews_service = | 439 PreviewsService* previews_service = |
| 722 PreviewsServiceFactory::GetForProfile(profile_); | 440 PreviewsServiceFactory::GetForProfile(profile_); |
| 723 if (previews_service && previews_service->previews_ui_service()) { | 441 if (previews_service && previews_service->previews_ui_service()) { |
| 724 previews_service->previews_ui_service()->ClearBlackList(delete_begin_, | 442 previews_service->previews_ui_service()->ClearBlackList(delete_begin_, |
| 725 delete_end_); | 443 delete_end_); |
| 726 } | 444 } |
| 727 } | 445 } |
| 728 | 446 |
| 729 if ((remove_mask & REMOVE_DOWNLOADS) && may_delete_history) { | 447 ////////////////////////////////////////////////////////////////////////////// |
| 730 content::RecordAction(UserMetricsAction("ClearBrowsingData_Downloads")); | 448 // REMOVE_COOKIES |
| 731 content::DownloadManager* download_manager = | |
| 732 BrowserContext::GetDownloadManager(profile_); | |
| 733 download_manager->RemoveDownloadsByURLAndTime(filter, | |
| 734 delete_begin_, delete_end_); | |
| 735 DownloadPrefs* download_prefs = DownloadPrefs::FromDownloadManager( | |
| 736 download_manager); | |
| 737 download_prefs->SetSaveFilePath(download_prefs->DownloadPath()); | |
| 738 } | |
| 739 | |
| 740 uint32_t storage_partition_remove_mask = 0; | |
| 741 | |
| 742 // We ignore the REMOVE_COOKIES request if UNPROTECTED_WEB is not set, | 449 // We ignore the REMOVE_COOKIES request if UNPROTECTED_WEB is not set, |
| 743 // so that callers who request REMOVE_SITE_DATA with PROTECTED_WEB | 450 // so that callers who request REMOVE_SITE_DATA with PROTECTED_WEB |
| 744 // don't accidentally remove the cookies that are associated with the | 451 // don't accidentally remove the cookies that are associated with the |
| 745 // UNPROTECTED_WEB origin. This is necessary because cookies are not separated | 452 // UNPROTECTED_WEB origin. This is necessary because cookies are not separated |
| 746 // between UNPROTECTED_WEB and PROTECTED_WEB. | 453 // between UNPROTECTED_WEB and PROTECTED_WEB. |
| 747 if (remove_mask & REMOVE_COOKIES && | 454 if (remove_mask & BrowsingDataRemover::REMOVE_COOKIES && |
| 748 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { | 455 origin_type_mask & BrowsingDataHelper::UNPROTECTED_WEB) { |
| 749 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies")); | 456 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies")); |
| 750 | 457 |
| 751 storage_partition_remove_mask |= | |
| 752 content::StoragePartition::REMOVE_DATA_MASK_COOKIES; | |
| 753 | |
| 754 // Clear the safebrowsing cookies only if time period is for "all time". It | 458 // Clear the safebrowsing cookies only if time period is for "all time". It |
| 755 // doesn't make sense to apply the time period of deleting in the last X | 459 // doesn't make sense to apply the time period of deleting in the last X |
| 756 // hours/days to the safebrowsing cookies since they aren't the result of | 460 // hours/days to the safebrowsing cookies since they aren't the result of |
| 757 // any user action. | 461 // any user action. |
| 758 if (delete_begin_ == base::Time()) { | 462 if (delete_begin_ == base::Time()) { |
| 759 safe_browsing::SafeBrowsingService* sb_service = | 463 safe_browsing::SafeBrowsingService* sb_service = |
| 760 g_browser_process->safe_browsing_service(); | 464 g_browser_process->safe_browsing_service(); |
| 761 if (sb_service) { | 465 if (sb_service) { |
| 762 scoped_refptr<net::URLRequestContextGetter> sb_context = | 466 scoped_refptr<net::URLRequestContextGetter> sb_context = |
| 763 sb_service->url_request_context(); | 467 sb_service->url_request_context(); |
| 764 ++waiting_for_clear_cookies_count_; | 468 ++waiting_for_clear_cookies_count_; |
| 765 if (filter_builder.IsEmptyBlacklist()) { | 469 if (filter_builder.IsEmptyBlacklist()) { |
| 766 BrowserThread::PostTask( | 470 BrowserThread::PostTask( |
| 767 BrowserThread::IO, FROM_HERE, | 471 BrowserThread::IO, FROM_HERE, |
| 768 base::Bind(&ClearCookiesOnIOThread, delete_begin_, delete_end_, | 472 base::Bind( |
| 769 base::RetainedRef(std::move(sb_context)), | 473 &ClearCookiesOnIOThread, delete_begin_, delete_end_, |
| 770 UIThreadTrampoline( | 474 base::RetainedRef(std::move(sb_context)), |
| 771 base::Bind(&BrowsingDataRemover::OnClearedCookies, | 475 UIThreadTrampoline( |
| 772 weak_ptr_factory_.GetWeakPtr())))); | 476 base::Bind( |
| 477 &ChromeBrowsingDataRemoverDelegate::OnClearedCookies, |
| 478 weak_ptr_factory_.GetWeakPtr())))); |
| 773 } else { | 479 } else { |
| 774 BrowserThread::PostTask( | 480 BrowserThread::PostTask( |
| 775 BrowserThread::IO, FROM_HERE, | 481 BrowserThread::IO, FROM_HERE, |
| 776 base::Bind(&ClearCookiesWithPredicateOnIOThread, delete_begin_, | 482 base::Bind( |
| 777 delete_end_, filter_builder.BuildCookieFilter(), | 483 &ClearCookiesWithPredicateOnIOThread, delete_begin_, |
| 778 base::RetainedRef(std::move(sb_context)), | 484 delete_end_, filter_builder.BuildCookieFilter(), |
| 779 UIThreadTrampoline( | 485 base::RetainedRef(std::move(sb_context)), |
| 780 base::Bind(&BrowsingDataRemover::OnClearedCookies, | 486 UIThreadTrampoline( |
| 781 weak_ptr_factory_.GetWeakPtr())))); | 487 base::Bind( |
| 488 &ChromeBrowsingDataRemoverDelegate::OnClearedCookies, |
| 489 weak_ptr_factory_.GetWeakPtr())))); |
| 782 } | 490 } |
| 783 } | 491 } |
| 784 } | 492 } |
| 785 | 493 |
| 786 MediaDeviceIDSalt::Reset(profile_->GetPrefs()); | 494 MediaDeviceIDSalt::Reset(profile_->GetPrefs()); |
| 787 } | 495 } |
| 788 | 496 |
| 789 // Channel IDs are not separated for protected and unprotected web | 497 ////////////////////////////////////////////////////////////////////////////// |
| 790 // origins. We check the origin_type_mask_ to prevent unintended deletion. | 498 // REMOVE_DURABLE_PERMISSION |
| 791 if (remove_mask & REMOVE_CHANNEL_IDS && | 499 if (remove_mask & BrowsingDataRemover::REMOVE_DURABLE_PERMISSION) { |
| 792 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { | |
| 793 content::RecordAction( | |
| 794 UserMetricsAction("ClearBrowsingData_ChannelIDs")); | |
| 795 // Since we are running on the UI thread don't call GetURLRequestContext(). | |
| 796 scoped_refptr<net::URLRequestContextGetter> rq_context = | |
| 797 content::BrowserContext::GetDefaultStoragePartition(profile_)-> | |
| 798 GetURLRequestContext(); | |
| 799 waiting_for_clear_channel_ids_ = true; | |
| 800 BrowserThread::PostTask( | |
| 801 BrowserThread::IO, FROM_HERE, | |
| 802 base::Bind(&ClearChannelIDsOnIOThread, | |
| 803 filter_builder.BuildChannelIDFilter(), | |
| 804 delete_begin_, delete_end_, std::move(rq_context), | |
| 805 base::Bind(&BrowsingDataRemover::OnClearedChannelIDs, | |
| 806 weak_ptr_factory_.GetWeakPtr()))); | |
| 807 } | |
| 808 | |
| 809 if (remove_mask & REMOVE_DURABLE_PERMISSION) { | |
| 810 HostContentSettingsMapFactory::GetForProfile(profile_) | 500 HostContentSettingsMapFactory::GetForProfile(profile_) |
| 811 ->ClearSettingsForOneTypeWithPredicate( | 501 ->ClearSettingsForOneTypeWithPredicate( |
| 812 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, | 502 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, |
| 813 base::Bind(&ForwardPrimaryPatternCallback, same_pattern_filter)); | 503 base::Bind(&ForwardPrimaryPatternCallback, same_pattern_filter)); |
| 814 } | 504 } |
| 815 | 505 |
| 816 if (remove_mask & REMOVE_LOCAL_STORAGE) { | 506 ////////////////////////////////////////////////////////////////////////////// |
| 817 storage_partition_remove_mask |= | 507 // REMOVE_SITE_USAGE_DATA |
| 818 content::StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE; | 508 if (remove_mask & BrowsingDataRemover::REMOVE_SITE_USAGE_DATA) { |
| 819 } | |
| 820 | |
| 821 if (remove_mask & REMOVE_INDEXEDDB) { | |
| 822 storage_partition_remove_mask |= | |
| 823 content::StoragePartition::REMOVE_DATA_MASK_INDEXEDDB; | |
| 824 } | |
| 825 if (remove_mask & REMOVE_WEBSQL) { | |
| 826 storage_partition_remove_mask |= | |
| 827 content::StoragePartition::REMOVE_DATA_MASK_WEBSQL; | |
| 828 } | |
| 829 if (remove_mask & REMOVE_APPCACHE) { | |
| 830 storage_partition_remove_mask |= | |
| 831 content::StoragePartition::REMOVE_DATA_MASK_APPCACHE; | |
| 832 } | |
| 833 if (remove_mask & REMOVE_SERVICE_WORKERS) { | |
| 834 storage_partition_remove_mask |= | |
| 835 content::StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS; | |
| 836 } | |
| 837 if (remove_mask & REMOVE_CACHE_STORAGE) { | |
| 838 storage_partition_remove_mask |= | |
| 839 content::StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE; | |
| 840 } | |
| 841 if (remove_mask & REMOVE_FILE_SYSTEMS) { | |
| 842 storage_partition_remove_mask |= | |
| 843 content::StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS; | |
| 844 } | |
| 845 | |
| 846 #if BUILDFLAG(ENABLE_PLUGINS) | |
| 847 // Plugin is data not separated for protected and unprotected web origins. We | |
| 848 // check the origin_type_mask_ to prevent unintended deletion. | |
| 849 if (remove_mask & REMOVE_PLUGIN_DATA && | |
| 850 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { | |
| 851 content::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData")); | |
| 852 waiting_for_clear_plugin_data_count_ = 1; | |
| 853 | |
| 854 if (filter_builder.IsEmptyBlacklist()) { | |
| 855 DCHECK(!plugin_data_remover_); | |
| 856 plugin_data_remover_.reset(content::PluginDataRemover::Create(profile_)); | |
| 857 base::WaitableEvent* event = | |
| 858 plugin_data_remover_->StartRemoving(delete_begin_); | |
| 859 | |
| 860 base::WaitableEventWatcher::EventCallback watcher_callback = | |
| 861 base::Bind(&BrowsingDataRemover::OnWaitableEventSignaled, | |
| 862 weak_ptr_factory_.GetWeakPtr()); | |
| 863 watcher_.StartWatching(event, watcher_callback); | |
| 864 } else { | |
| 865 // TODO(msramek): Store filters from the currently executed task on the | |
| 866 // object to avoid having to copy them to callback methods. | |
| 867 flash_lso_helper_->StartFetching(base::Bind( | |
| 868 &BrowsingDataRemover::OnSitesWithFlashDataFetched, | |
| 869 weak_ptr_factory_.GetWeakPtr(), | |
| 870 filter_builder.BuildPluginFilter())); | |
| 871 } | |
| 872 } | |
| 873 #endif | |
| 874 | |
| 875 if (remove_mask & REMOVE_SITE_USAGE_DATA) { | |
| 876 HostContentSettingsMapFactory::GetForProfile(profile_) | 509 HostContentSettingsMapFactory::GetForProfile(profile_) |
| 877 ->ClearSettingsForOneTypeWithPredicate( | 510 ->ClearSettingsForOneTypeWithPredicate( |
| 878 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, | 511 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, |
| 879 base::Bind(&ForwardPrimaryPatternCallback, same_pattern_filter)); | 512 base::Bind(&ForwardPrimaryPatternCallback, same_pattern_filter)); |
| 880 } | 513 } |
| 881 | 514 |
| 882 if (remove_mask & REMOVE_SITE_USAGE_DATA || remove_mask & REMOVE_HISTORY) { | 515 if ((remove_mask & BrowsingDataRemover::REMOVE_SITE_USAGE_DATA) || |
| 516 (remove_mask & BrowsingDataRemover::REMOVE_HISTORY)) { |
| 883 HostContentSettingsMapFactory::GetForProfile(profile_) | 517 HostContentSettingsMapFactory::GetForProfile(profile_) |
| 884 ->ClearSettingsForOneTypeWithPredicate( | 518 ->ClearSettingsForOneTypeWithPredicate( |
| 885 CONTENT_SETTINGS_TYPE_APP_BANNER, | 519 CONTENT_SETTINGS_TYPE_APP_BANNER, |
| 886 base::Bind(&ForwardPrimaryPatternCallback, same_pattern_filter)); | 520 base::Bind(&ForwardPrimaryPatternCallback, same_pattern_filter)); |
| 887 | 521 |
| 888 PermissionDecisionAutoBlocker::RemoveCountsByUrl(profile_, filter); | 522 PermissionDecisionAutoBlocker::RemoveCountsByUrl(profile_, filter); |
| 889 } | 523 } |
| 890 | 524 |
| 891 if (remove_mask & REMOVE_PASSWORDS) { | 525 ////////////////////////////////////////////////////////////////////////////// |
| 526 // Password manager |
| 527 if (remove_mask & BrowsingDataRemover::REMOVE_PASSWORDS) { |
| 892 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords")); | 528 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords")); |
| 893 password_manager::PasswordStore* password_store = | 529 password_manager::PasswordStore* password_store = |
| 894 PasswordStoreFactory::GetForProfile( | 530 PasswordStoreFactory::GetForProfile( |
| 895 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); | 531 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); |
| 896 | 532 |
| 897 if (password_store) { | 533 if (password_store) { |
| 898 waiting_for_clear_passwords_ = true; | 534 waiting_for_clear_passwords_ = true; |
| 899 auto on_cleared_passwords = | 535 auto on_cleared_passwords = |
| 900 base::Bind(&BrowsingDataRemover::OnClearedPasswords, | 536 base::Bind(&ChromeBrowsingDataRemoverDelegate::OnClearedPasswords, |
| 901 weak_ptr_factory_.GetWeakPtr()); | 537 weak_ptr_factory_.GetWeakPtr()); |
| 902 password_store->RemoveLoginsByURLAndTime( | 538 password_store->RemoveLoginsByURLAndTime( |
| 903 filter, delete_begin_, delete_end_, on_cleared_passwords); | 539 filter, delete_begin_, delete_end_, on_cleared_passwords); |
| 904 } | 540 } |
| 905 } | 541 } |
| 906 | 542 |
| 907 if (remove_mask & REMOVE_COOKIES) { | 543 if (remove_mask & BrowsingDataRemover::REMOVE_COOKIES) { |
| 908 password_manager::PasswordStore* password_store = | 544 password_manager::PasswordStore* password_store = |
| 909 PasswordStoreFactory::GetForProfile(profile_, | 545 PasswordStoreFactory::GetForProfile(profile_, |
| 910 ServiceAccessType::EXPLICIT_ACCESS) | 546 ServiceAccessType::EXPLICIT_ACCESS) |
| 911 .get(); | 547 .get(); |
| 912 | 548 |
| 913 if (password_store) { | 549 if (password_store) { |
| 914 waiting_for_clear_auto_sign_in_ = true; | 550 waiting_for_clear_auto_sign_in_ = true; |
| 915 base::Closure on_cleared_auto_sign_in = | 551 base::Closure on_cleared_auto_sign_in = |
| 916 base::Bind(&BrowsingDataRemover::OnClearedAutoSignIn, | 552 base::Bind(&ChromeBrowsingDataRemoverDelegate::OnClearedAutoSignIn, |
| 917 weak_ptr_factory_.GetWeakPtr()); | 553 weak_ptr_factory_.GetWeakPtr()); |
| 918 password_store->DisableAutoSignInForOrigins( | 554 password_store->DisableAutoSignInForOrigins( |
| 919 filter, on_cleared_auto_sign_in); | 555 filter, on_cleared_auto_sign_in); |
| 920 } | 556 } |
| 921 } | 557 } |
| 922 | 558 |
| 923 if (remove_mask & REMOVE_HISTORY) { | 559 if (remove_mask & BrowsingDataRemover::REMOVE_HISTORY) { |
| 924 password_manager::PasswordStore* password_store = | 560 password_manager::PasswordStore* password_store = |
| 925 PasswordStoreFactory::GetForProfile( | 561 PasswordStoreFactory::GetForProfile( |
| 926 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); | 562 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); |
| 927 | 563 |
| 928 if (password_store) { | 564 if (password_store) { |
| 929 waiting_for_clear_passwords_stats_ = true; | 565 waiting_for_clear_passwords_stats_ = true; |
| 930 password_store->RemoveStatisticsByOriginAndTime( | 566 password_store->RemoveStatisticsByOriginAndTime( |
| 931 nullable_filter, delete_begin_, delete_end_, | 567 nullable_filter, delete_begin_, delete_end_, |
| 932 base::Bind(&BrowsingDataRemover::OnClearedPasswordsStats, | 568 base::Bind( |
| 933 weak_ptr_factory_.GetWeakPtr())); | 569 &ChromeBrowsingDataRemoverDelegate::OnClearedPasswordsStats, |
| 570 weak_ptr_factory_.GetWeakPtr())); |
| 934 } | 571 } |
| 935 } | 572 } |
| 936 | 573 |
| 574 ////////////////////////////////////////////////////////////////////////////// |
| 575 // REMOVE_FORM_DATA |
| 937 // TODO(dmurph): Support all backends with filter (crbug.com/113621). | 576 // TODO(dmurph): Support all backends with filter (crbug.com/113621). |
| 938 if (remove_mask & REMOVE_FORM_DATA) { | 577 if (remove_mask & BrowsingDataRemover::REMOVE_FORM_DATA) { |
| 939 content::RecordAction(UserMetricsAction("ClearBrowsingData_Autofill")); | 578 content::RecordAction(UserMetricsAction("ClearBrowsingData_Autofill")); |
| 940 scoped_refptr<autofill::AutofillWebDataService> web_data_service = | 579 scoped_refptr<autofill::AutofillWebDataService> web_data_service = |
| 941 WebDataServiceFactory::GetAutofillWebDataForProfile( | 580 WebDataServiceFactory::GetAutofillWebDataForProfile( |
| 942 profile_, ServiceAccessType::EXPLICIT_ACCESS); | 581 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
| 943 | 582 |
| 944 if (web_data_service.get()) { | 583 if (web_data_service.get()) { |
| 945 waiting_for_clear_form_ = true; | 584 waiting_for_clear_form_ = true; |
| 946 web_data_service->RemoveFormElementsAddedBetween(delete_begin_, | 585 web_data_service->RemoveFormElementsAddedBetween(delete_begin_, |
| 947 delete_end_); | 586 delete_end_); |
| 948 web_data_service->RemoveAutofillDataModifiedBetween( | 587 web_data_service->RemoveAutofillDataModifiedBetween( |
| 949 delete_begin_, delete_end_); | 588 delete_begin_, delete_end_); |
| 950 // The above calls are done on the UI thread but do their work on the DB | 589 // The above calls are done on the UI thread but do their work on the DB |
| 951 // thread. So wait for it. | 590 // thread. So wait for it. |
| 952 BrowserThread::PostTaskAndReply( | 591 BrowserThread::PostTaskAndReply( |
| 953 BrowserThread::DB, FROM_HERE, base::Bind(&base::DoNothing), | 592 BrowserThread::DB, FROM_HERE, base::Bind(&base::DoNothing), |
| 954 base::Bind(&BrowsingDataRemover::OnClearedFormData, | 593 base::Bind(&ChromeBrowsingDataRemoverDelegate::OnClearedFormData, |
| 955 weak_ptr_factory_.GetWeakPtr())); | 594 weak_ptr_factory_.GetWeakPtr())); |
| 956 | 595 |
| 957 autofill::PersonalDataManager* data_manager = | 596 autofill::PersonalDataManager* data_manager = |
| 958 autofill::PersonalDataManagerFactory::GetForProfile(profile_); | 597 autofill::PersonalDataManagerFactory::GetForProfile(profile_); |
| 959 if (data_manager) | 598 if (data_manager) |
| 960 data_manager->Refresh(); | 599 data_manager->Refresh(); |
| 961 } | 600 } |
| 962 } | 601 } |
| 963 | 602 |
| 964 if (remove_mask & REMOVE_CACHE) { | 603 ////////////////////////////////////////////////////////////////////////////// |
| 965 // Tell the renderers to clear their cache. | 604 // REMOVE_CACHE |
| 966 web_cache::WebCacheManager::GetInstance()->ClearCache(); | 605 if (remove_mask & BrowsingDataRemover::REMOVE_CACHE) { |
| 967 | |
| 968 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cache")); | |
| 969 | |
| 970 waiting_for_clear_cache_ = true; | |
| 971 // StoragePartitionHttpCacheDataRemover deletes itself when it is done. | |
| 972 if (filter_builder.IsEmptyBlacklist()) { | |
| 973 browsing_data::StoragePartitionHttpCacheDataRemover::CreateForRange( | |
| 974 BrowserContext::GetDefaultStoragePartition(profile_), | |
| 975 delete_begin_, delete_end_) | |
| 976 ->Remove(base::Bind(&BrowsingDataRemover::ClearedCache, | |
| 977 weak_ptr_factory_.GetWeakPtr())); | |
| 978 } else { | |
| 979 browsing_data::StoragePartitionHttpCacheDataRemover:: | |
| 980 CreateForURLsAndRange( | |
| 981 BrowserContext::GetDefaultStoragePartition(profile_), | |
| 982 filter, delete_begin_, delete_end_) | |
| 983 ->Remove(base::Bind(&BrowsingDataRemover::ClearedCache, | |
| 984 weak_ptr_factory_.GetWeakPtr())); | |
| 985 } | |
| 986 | |
| 987 #if !defined(DISABLE_NACL) | 606 #if !defined(DISABLE_NACL) |
| 988 waiting_for_clear_nacl_cache_ = true; | 607 waiting_for_clear_nacl_cache_ = true; |
| 989 | 608 |
| 990 BrowserThread::PostTask( | 609 BrowserThread::PostTask( |
| 991 BrowserThread::IO, FROM_HERE, | 610 BrowserThread::IO, FROM_HERE, |
| 992 base::Bind(&ClearNaClCacheOnIOThread, | 611 base::Bind(&ClearNaClCacheOnIOThread, |
| 993 UIThreadTrampoline( | 612 UIThreadTrampoline( |
| 994 base::Bind(&BrowsingDataRemover::ClearedNaClCache, | 613 base::Bind( |
| 995 weak_ptr_factory_.GetWeakPtr())))); | 614 &ChromeBrowsingDataRemoverDelegate::ClearedNaClCache, |
| 615 weak_ptr_factory_.GetWeakPtr())))); |
| 996 | 616 |
| 997 waiting_for_clear_pnacl_cache_ = true; | 617 waiting_for_clear_pnacl_cache_ = true; |
| 998 BrowserThread::PostTask( | 618 BrowserThread::PostTask( |
| 999 BrowserThread::IO, FROM_HERE, | 619 BrowserThread::IO, FROM_HERE, |
| 1000 base::Bind(&ClearPnaclCacheOnIOThread, delete_begin_, delete_end_, | 620 base::Bind( |
| 1001 UIThreadTrampoline( | 621 &ClearPnaclCacheOnIOThread, delete_begin_, delete_end_, |
| 1002 base::Bind(&BrowsingDataRemover::ClearedPnaclCache, | 622 UIThreadTrampoline( |
| 1003 weak_ptr_factory_.GetWeakPtr())))); | 623 base::Bind( |
| 624 &ChromeBrowsingDataRemoverDelegate::ClearedPnaclCache, |
| 625 weak_ptr_factory_.GetWeakPtr())))); |
| 1004 #endif | 626 #endif |
| 1005 | 627 |
| 1006 // The PrerenderManager may have a page actively being prerendered, which | 628 // The PrerenderManager may have a page actively being prerendered, which |
| 1007 // is essentially a preemptively cached page. | 629 // is essentially a preemptively cached page. |
| 1008 prerender::PrerenderManager* prerender_manager = | 630 prerender::PrerenderManager* prerender_manager = |
| 1009 prerender::PrerenderManagerFactory::GetForBrowserContext(profile_); | 631 prerender::PrerenderManagerFactory::GetForBrowserContext(profile_); |
| 1010 if (prerender_manager) { | 632 if (prerender_manager) { |
| 1011 prerender_manager->ClearData( | 633 prerender_manager->ClearData( |
| 1012 prerender::PrerenderManager::CLEAR_PRERENDER_CONTENTS); | 634 prerender::PrerenderManager::CLEAR_PRERENDER_CONTENTS); |
| 1013 } | 635 } |
| 1014 | 636 |
| 1015 // Tell the shader disk cache to clear. | |
| 1016 content::RecordAction(UserMetricsAction("ClearBrowsingData_ShaderCache")); | |
| 1017 storage_partition_remove_mask |= | |
| 1018 content::StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE; | |
| 1019 | |
| 1020 // When clearing cache, wipe accumulated network related data | 637 // When clearing cache, wipe accumulated network related data |
| 1021 // (TransportSecurityState and HttpServerPropertiesManager data). | 638 // (TransportSecurityState and HttpServerPropertiesManager data). |
| 1022 waiting_for_clear_networking_history_ = true; | 639 waiting_for_clear_networking_history_ = true; |
| 1023 profile_->ClearNetworkingHistorySince( | 640 profile_->ClearNetworkingHistorySince( |
| 1024 delete_begin_, | 641 delete_begin_, |
| 1025 base::Bind(&BrowsingDataRemover::OnClearedNetworkingHistory, | 642 base::Bind( |
| 1026 weak_ptr_factory_.GetWeakPtr())); | 643 &ChromeBrowsingDataRemoverDelegate::OnClearedNetworkingHistory, |
| 644 weak_ptr_factory_.GetWeakPtr())); |
| 1027 | 645 |
| 1028 ntp_snippets::ContentSuggestionsService* content_suggestions_service = | 646 ntp_snippets::ContentSuggestionsService* content_suggestions_service = |
| 1029 ContentSuggestionsServiceFactory::GetForProfileIfExists(profile_); | 647 ContentSuggestionsServiceFactory::GetForProfileIfExists(profile_); |
| 1030 if (content_suggestions_service) | 648 if (content_suggestions_service) |
| 1031 content_suggestions_service->ClearAllCachedSuggestions(); | 649 content_suggestions_service->ClearAllCachedSuggestions(); |
| 1032 | 650 |
| 1033 // |ui_nqe_service| may be null if |profile_| is not a regular profile. | 651 // |ui_nqe_service| may be null if |profile_| is not a regular profile. |
| 1034 UINetworkQualityEstimatorService* ui_nqe_service = | 652 UINetworkQualityEstimatorService* ui_nqe_service = |
| 1035 UINetworkQualityEstimatorServiceFactory::GetForProfile(profile_); | 653 UINetworkQualityEstimatorServiceFactory::GetForProfile(profile_); |
| 1036 DCHECK(profile_->GetProfileType() != | 654 DCHECK(profile_->GetProfileType() != |
| 1037 Profile::ProfileType::REGULAR_PROFILE || | 655 Profile::ProfileType::REGULAR_PROFILE || |
| 1038 ui_nqe_service != nullptr); | 656 ui_nqe_service != nullptr); |
| 1039 if (ui_nqe_service) { | 657 if (ui_nqe_service) { |
| 1040 // Network Quality Estimator (NQE) stores the quality (RTT, bandwidth | 658 // Network Quality Estimator (NQE) stores the quality (RTT, bandwidth |
| 1041 // etc.) of different networks in prefs. The stored quality is not | 659 // etc.) of different networks in prefs. The stored quality is not |
| 1042 // broken down by URLs or timestamps, so clearing the cache should | 660 // broken down by URLs or timestamps, so clearing the cache should |
| 1043 // completely clear the prefs. | 661 // completely clear the prefs. |
| 1044 ui_nqe_service->ClearPrefs(); | 662 ui_nqe_service->ClearPrefs(); |
| 1045 } | 663 } |
| 664 |
| 665 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 666 // For now we're considering offline pages as cache, so if we're removing |
| 667 // cache we should remove offline pages as well. |
| 668 if ((remove_mask & BrowsingDataRemover::REMOVE_CACHE)) { |
| 669 waiting_for_clear_offline_page_data_ = true; |
| 670 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile_) |
| 671 ->DeleteCachedPagesByURLPredicate( |
| 672 filter, base::Bind( |
| 673 &ChromeBrowsingDataRemoverDelegate::OnClearedOfflinePageData, |
| 674 weak_ptr_factory_.GetWeakPtr())); |
| 675 } |
| 676 #endif |
| 1046 } | 677 } |
| 1047 | 678 |
| 1048 if (remove_mask & REMOVE_COOKIES || remove_mask & REMOVE_PASSWORDS) { | 679 ////////////////////////////////////////////////////////////////////////////// |
| 1049 scoped_refptr<net::URLRequestContextGetter> request_context = | 680 // REMOVE_MEDIA_LICENSES |
| 1050 profile_->GetRequestContext(); | 681 if (remove_mask & BrowsingDataRemover::REMOVE_MEDIA_LICENSES) { |
| 1051 waiting_for_clear_http_auth_cache_ = true; | |
| 1052 BrowserThread::PostTaskAndReply( | |
| 1053 BrowserThread::IO, FROM_HERE, | |
| 1054 base::Bind(&ClearHttpAuthCacheOnIOThread, std::move(request_context), | |
| 1055 delete_begin_), | |
| 1056 base::Bind(&BrowsingDataRemover::OnClearedHttpAuthCache, | |
| 1057 weak_ptr_factory_.GetWeakPtr())); | |
| 1058 } | |
| 1059 | |
| 1060 // Content Decryption Modules used by Encrypted Media store licenses in a | |
| 1061 // private filesystem. These are different than content licenses used by | |
| 1062 // Flash (which are deleted father down in this method). | |
| 1063 if (remove_mask & REMOVE_MEDIA_LICENSES) { | |
| 1064 storage_partition_remove_mask |= | |
| 1065 content::StoragePartition::REMOVE_DATA_MASK_PLUGIN_PRIVATE_DATA; | |
| 1066 } | |
| 1067 | |
| 1068 if (storage_partition_remove_mask) { | |
| 1069 waiting_for_clear_storage_partition_data_ = true; | |
| 1070 | |
| 1071 content::StoragePartition* storage_partition; | |
| 1072 if (storage_partition_for_testing_) | |
| 1073 storage_partition = storage_partition_for_testing_; | |
| 1074 else | |
| 1075 storage_partition = BrowserContext::GetDefaultStoragePartition(profile_); | |
| 1076 | |
| 1077 uint32_t quota_storage_remove_mask = | |
| 1078 ~content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; | |
| 1079 | |
| 1080 if (delete_begin_ == base::Time() || | |
| 1081 origin_type_mask_ & | |
| 1082 (BrowsingDataHelper::PROTECTED_WEB | BrowsingDataHelper::EXTENSION)) { | |
| 1083 // If we're deleting since the beginning of time, or we're removing | |
| 1084 // protected origins, then remove persistent quota data. | |
| 1085 quota_storage_remove_mask |= | |
| 1086 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; | |
| 1087 } | |
| 1088 | |
| 1089 // If cookies are supposed to be conditionally deleted from the storage | |
| 1090 // partition, create a cookie matcher function. | |
| 1091 content::StoragePartition::CookieMatcherFunction cookie_matcher; | |
| 1092 if (!filter_builder.IsEmptyBlacklist() && | |
| 1093 (storage_partition_remove_mask & | |
| 1094 content::StoragePartition::REMOVE_DATA_MASK_COOKIES)) { | |
| 1095 cookie_matcher = filter_builder.BuildCookieFilter(); | |
| 1096 } | |
| 1097 | |
| 1098 storage_partition->ClearData( | |
| 1099 storage_partition_remove_mask, quota_storage_remove_mask, | |
| 1100 base::Bind(&DoesOriginMatchMaskAndUrls, origin_type_mask_, filter), | |
| 1101 cookie_matcher, delete_begin_, delete_end_, | |
| 1102 base::Bind(&BrowsingDataRemover::OnClearedStoragePartitionData, | |
| 1103 weak_ptr_factory_.GetWeakPtr())); | |
| 1104 } | |
| 1105 | |
| 1106 if (remove_mask & REMOVE_MEDIA_LICENSES) { | |
| 1107 // TODO(jrummell): This UMA should be renamed to indicate it is for Media | 682 // TODO(jrummell): This UMA should be renamed to indicate it is for Media |
| 1108 // Licenses. | 683 // Licenses. |
| 1109 content::RecordAction( | 684 content::RecordAction( |
| 1110 UserMetricsAction("ClearBrowsingData_ContentLicenses")); | 685 UserMetricsAction("ClearBrowsingData_ContentLicenses")); |
| 1111 | 686 |
| 1112 #if BUILDFLAG(ENABLE_PLUGINS) | 687 #if BUILDFLAG(ENABLE_PLUGINS) |
| 1113 waiting_for_clear_flash_content_licenses_ = true; | 688 waiting_for_clear_flash_content_licenses_ = true; |
| 1114 if (!pepper_flash_settings_manager_.get()) { | 689 if (!pepper_flash_settings_manager_.get()) { |
| 1115 pepper_flash_settings_manager_.reset( | 690 pepper_flash_settings_manager_.reset( |
| 1116 new PepperFlashSettingsManager(this, profile_)); | 691 new PepperFlashSettingsManager(this, profile_)); |
| 1117 } | 692 } |
| 1118 deauthorize_flash_content_licenses_request_id_ = | 693 deauthorize_flash_content_licenses_request_id_ = |
| 1119 pepper_flash_settings_manager_->DeauthorizeContentLicenses(prefs); | 694 pepper_flash_settings_manager_->DeauthorizeContentLicenses(prefs); |
| 1120 #if defined(OS_CHROMEOS) | 695 #if defined(OS_CHROMEOS) |
| 1121 // On Chrome OS, also delete any content protection platform keys. | 696 // On Chrome OS, also delete any content protection platform keys. |
| 1122 const user_manager::User* user = | 697 const user_manager::User* user = |
| 1123 chromeos::ProfileHelper::Get()->GetUserByProfile(profile_); | 698 chromeos::ProfileHelper::Get()->GetUserByProfile(profile_); |
| 1124 if (!user) { | 699 if (!user) { |
| 1125 LOG(WARNING) << "Failed to find user for current profile."; | 700 LOG(WARNING) << "Failed to find user for current profile."; |
| 1126 } else { | 701 } else { |
| 1127 chromeos::DBusThreadManager::Get() | 702 chromeos::DBusThreadManager::Get() |
| 1128 ->GetCryptohomeClient() | 703 ->GetCryptohomeClient() |
| 1129 ->TpmAttestationDeleteKeys( | 704 ->TpmAttestationDeleteKeys( |
| 1130 chromeos::attestation::KEY_USER, | 705 chromeos::attestation::KEY_USER, |
| 1131 cryptohome::Identification(user->GetAccountId()), | 706 cryptohome::Identification(user->GetAccountId()), |
| 1132 chromeos::attestation::kContentProtectionKeyPrefix, | 707 chromeos::attestation::kContentProtectionKeyPrefix, |
| 1133 base::Bind(&BrowsingDataRemover::OnClearPlatformKeys, | 708 base::Bind( |
| 1134 weak_ptr_factory_.GetWeakPtr())); | 709 &ChromeBrowsingDataRemoverDelegate::OnClearPlatformKeys, |
| 710 weak_ptr_factory_.GetWeakPtr())); |
| 1135 waiting_for_clear_platform_keys_ = true; | 711 waiting_for_clear_platform_keys_ = true; |
| 1136 } | 712 } |
| 1137 #endif // defined(OS_CHROMEOS) | 713 #endif // defined(OS_CHROMEOS) |
| 1138 #endif // BUILDFLAG(ENABLE_PLUGINS) | 714 #endif // BUILDFLAG(ENABLE_PLUGINS) |
| 1139 } | 715 } |
| 1140 | 716 |
| 717 ////////////////////////////////////////////////////////////////////////////// |
| 718 // Zero suggest. |
| 1141 // Remove omnibox zero-suggest cache results. Filtering is not supported. | 719 // Remove omnibox zero-suggest cache results. Filtering is not supported. |
| 1142 // This is not a problem, as deleting more data than necessary will just cause | 720 // This is not a problem, as deleting more data than necessary will just cause |
| 1143 // another server round-trip; no data is actually lost. | 721 // another server round-trip; no data is actually lost. |
| 1144 if ((remove_mask & (REMOVE_CACHE | REMOVE_COOKIES))) | 722 if ((remove_mask & (BrowsingDataRemover::REMOVE_CACHE | |
| 723 BrowsingDataRemover::REMOVE_COOKIES))) { |
| 1145 prefs->SetString(omnibox::kZeroSuggestCachedResults, std::string()); | 724 prefs->SetString(omnibox::kZeroSuggestCachedResults, std::string()); |
| 725 } |
| 1146 | 726 |
| 1147 if (remove_mask & (REMOVE_COOKIES | REMOVE_HISTORY)) { | 727 ////////////////////////////////////////////////////////////////////////////// |
| 728 // Domain reliability service. |
| 729 if (remove_mask & (BrowsingDataRemover::REMOVE_COOKIES | |
| 730 BrowsingDataRemover::REMOVE_HISTORY)) { |
| 1148 domain_reliability::DomainReliabilityService* service = | 731 domain_reliability::DomainReliabilityService* service = |
| 1149 domain_reliability::DomainReliabilityServiceFactory:: | 732 domain_reliability::DomainReliabilityServiceFactory:: |
| 1150 GetForBrowserContext(profile_); | 733 GetForBrowserContext(profile_); |
| 1151 if (service) { | 734 if (service) { |
| 1152 domain_reliability::DomainReliabilityClearMode mode; | 735 domain_reliability::DomainReliabilityClearMode mode; |
| 1153 if (remove_mask & REMOVE_COOKIES) | 736 if (remove_mask & BrowsingDataRemover::REMOVE_COOKIES) |
| 1154 mode = domain_reliability::CLEAR_CONTEXTS; | 737 mode = domain_reliability::CLEAR_CONTEXTS; |
| 1155 else | 738 else |
| 1156 mode = domain_reliability::CLEAR_BEACONS; | 739 mode = domain_reliability::CLEAR_BEACONS; |
| 1157 | 740 |
| 1158 waiting_for_clear_domain_reliability_monitor_ = true; | 741 waiting_for_clear_domain_reliability_monitor_ = true; |
| 1159 service->ClearBrowsingData( | 742 service->ClearBrowsingData( |
| 1160 mode, | 743 mode, |
| 1161 filter, | 744 filter, |
| 1162 base::Bind(&BrowsingDataRemover::OnClearedDomainReliabilityMonitor, | 745 base::Bind(&ChromeBrowsingDataRemoverDelegate:: |
| 746 OnClearedDomainReliabilityMonitor, |
| 1163 weak_ptr_factory_.GetWeakPtr())); | 747 weak_ptr_factory_.GetWeakPtr())); |
| 1164 } | 748 } |
| 1165 } | 749 } |
| 1166 | 750 |
| 751 ////////////////////////////////////////////////////////////////////////////// |
| 752 // REMOVE_WEBAPP_DATA |
| 1167 #if BUILDFLAG(ANDROID_JAVA_UI) | 753 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 1168 // Clear all data associated with registered webapps. | 754 // Clear all data associated with registered webapps. |
| 1169 if (remove_mask & REMOVE_WEBAPP_DATA) | 755 if (remove_mask & BrowsingDataRemover::REMOVE_WEBAPP_DATA) |
| 1170 webapp_registry_->UnregisterWebappsForUrls(filter); | 756 webapp_registry_->UnregisterWebappsForUrls(filter); |
| 1171 | |
| 1172 // For now we're considering offline pages as cache, so if we're removing | |
| 1173 // cache we should remove offline pages as well. | |
| 1174 if ((remove_mask & REMOVE_CACHE)) { | |
| 1175 waiting_for_clear_offline_page_data_ = true; | |
| 1176 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile_) | |
| 1177 ->DeleteCachedPagesByURLPredicate( | |
| 1178 filter, base::Bind(&BrowsingDataRemover::OnClearedOfflinePageData, | |
| 1179 weak_ptr_factory_.GetWeakPtr())); | |
| 1180 } | |
| 1181 #endif | 757 #endif |
| 1182 | 758 |
| 1183 // Record the combined deletion of cookies and cache. | |
| 1184 CookieOrCacheDeletionChoice choice = NEITHER_COOKIES_NOR_CACHE; | |
| 1185 if (remove_mask & REMOVE_COOKIES && | |
| 1186 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { | |
| 1187 choice = remove_mask & REMOVE_CACHE ? BOTH_COOKIES_AND_CACHE | |
| 1188 : ONLY_COOKIES; | |
| 1189 } else if (remove_mask & REMOVE_CACHE) { | |
| 1190 choice = ONLY_CACHE; | |
| 1191 } | |
| 1192 | |
| 1193 // Notify in case all actions taken were synchronous. | |
| 1194 waiting_for_synchronous_clear_operations_ = false; | 759 waiting_for_synchronous_clear_operations_ = false; |
| 1195 NotifyIfDone(); | 760 NotifyIfDone(); |
| 1196 | |
| 1197 UMA_HISTOGRAM_ENUMERATION( | |
| 1198 "History.ClearBrowsingData.UserDeletedCookieOrCache", | |
| 1199 choice, MAX_CHOICE_VALUE); | |
| 1200 } | 761 } |
| 1201 | 762 |
| 1202 void BrowsingDataRemover::AddObserver(Observer* observer) { | 763 void ChromeBrowsingDataRemoverDelegate::NotifyIfDone() { |
| 1203 observer_list_.AddObserver(observer); | 764 if (!AllDone()) |
| 765 return; |
| 766 |
| 767 DCHECK(!callback_.is_null()); |
| 768 callback_.Run(); |
| 1204 } | 769 } |
| 1205 | 770 |
| 1206 void BrowsingDataRemover::RemoveObserver(Observer* observer) { | 771 bool ChromeBrowsingDataRemoverDelegate::AllDone() { |
| 1207 observer_list_.RemoveObserver(observer); | |
| 1208 } | |
| 1209 | |
| 1210 void BrowsingDataRemover::OverrideStoragePartitionForTesting( | |
| 1211 content::StoragePartition* storage_partition) { | |
| 1212 storage_partition_for_testing_ = storage_partition; | |
| 1213 } | |
| 1214 | |
| 1215 #if BUILDFLAG(ANDROID_JAVA_UI) | |
| 1216 void BrowsingDataRemover::OverrideWebappRegistryForTesting( | |
| 1217 std::unique_ptr<WebappRegistry> webapp_registry) { | |
| 1218 webapp_registry_ = std::move(webapp_registry); | |
| 1219 } | |
| 1220 #endif | |
| 1221 | |
| 1222 #if BUILDFLAG(ENABLE_PLUGINS) | |
| 1223 void BrowsingDataRemover::OverrideFlashLSOHelperForTesting( | |
| 1224 scoped_refptr<BrowsingDataFlashLSOHelper> flash_lso_helper) { | |
| 1225 flash_lso_helper_ = flash_lso_helper; | |
| 1226 } | |
| 1227 #endif | |
| 1228 | |
| 1229 const base::Time& BrowsingDataRemover::GetLastUsedBeginTime() { | |
| 1230 return delete_begin_; | |
| 1231 } | |
| 1232 | |
| 1233 const base::Time& BrowsingDataRemover::GetLastUsedEndTime() { | |
| 1234 return delete_end_; | |
| 1235 } | |
| 1236 | |
| 1237 int BrowsingDataRemover::GetLastUsedRemovalMask() { | |
| 1238 return remove_mask_; | |
| 1239 } | |
| 1240 | |
| 1241 int BrowsingDataRemover::GetLastUsedOriginTypeMask() { | |
| 1242 return origin_type_mask_; | |
| 1243 } | |
| 1244 | |
| 1245 BrowsingDataRemover::RemovalTask::RemovalTask( | |
| 1246 const TimeRange& time_range, | |
| 1247 int remove_mask, | |
| 1248 int origin_type_mask, | |
| 1249 std::unique_ptr<BrowsingDataFilterBuilder> filter_builder, | |
| 1250 Observer* observer) | |
| 1251 : time_range(time_range), | |
| 1252 remove_mask(remove_mask), | |
| 1253 origin_type_mask(origin_type_mask), | |
| 1254 filter_builder(std::move(filter_builder)), | |
| 1255 observer(observer) {} | |
| 1256 | |
| 1257 BrowsingDataRemover::RemovalTask::~RemovalTask() {} | |
| 1258 | |
| 1259 bool BrowsingDataRemover::AllDone() { | |
| 1260 return !waiting_for_synchronous_clear_operations_ && | 772 return !waiting_for_synchronous_clear_operations_ && |
| 1261 !waiting_for_clear_autofill_origin_urls_ && | 773 !waiting_for_clear_autofill_origin_urls_ && |
| 1262 !waiting_for_clear_cache_ && | |
| 1263 !waiting_for_clear_flash_content_licenses_ && | 774 !waiting_for_clear_flash_content_licenses_ && |
| 1264 !waiting_for_clear_channel_ids_ && !waiting_for_clear_cookies_count_ && | 775 !waiting_for_clear_cookies_count_ && |
| 1265 !waiting_for_clear_domain_reliability_monitor_ && | 776 !waiting_for_clear_domain_reliability_monitor_ && |
| 1266 !waiting_for_clear_form_ && !waiting_for_clear_history_ && | 777 !waiting_for_clear_form_ && !waiting_for_clear_history_ && |
| 1267 !waiting_for_clear_hostname_resolution_cache_ && | 778 !waiting_for_clear_hostname_resolution_cache_ && |
| 1268 !waiting_for_clear_http_auth_cache_ && | |
| 1269 !waiting_for_clear_keyword_data_ && !waiting_for_clear_nacl_cache_ && | 779 !waiting_for_clear_keyword_data_ && !waiting_for_clear_nacl_cache_ && |
| 1270 !waiting_for_clear_network_predictor_ && | 780 !waiting_for_clear_network_predictor_ && |
| 1271 !waiting_for_clear_networking_history_ && | 781 !waiting_for_clear_networking_history_ && |
| 1272 !waiting_for_clear_passwords_ && !waiting_for_clear_passwords_stats_ && | 782 !waiting_for_clear_passwords_ && !waiting_for_clear_passwords_stats_ && |
| 1273 !waiting_for_clear_platform_keys_ && | 783 !waiting_for_clear_platform_keys_ && |
| 1274 !waiting_for_clear_plugin_data_count_ && | |
| 1275 !waiting_for_clear_pnacl_cache_ && | 784 !waiting_for_clear_pnacl_cache_ && |
| 1276 #if BUILDFLAG(ANDROID_JAVA_UI) | 785 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 1277 !waiting_for_clear_precache_history_ && | 786 !waiting_for_clear_precache_history_ && |
| 1278 !waiting_for_clear_offline_page_data_ && | 787 !waiting_for_clear_offline_page_data_ && |
| 1279 #endif | 788 #endif |
| 1280 #if BUILDFLAG(ENABLE_WEBRTC) | 789 #if BUILDFLAG(ENABLE_WEBRTC) |
| 1281 !waiting_for_clear_webrtc_logs_ && | 790 !waiting_for_clear_webrtc_logs_ && |
| 1282 #endif | 791 #endif |
| 1283 !waiting_for_clear_storage_partition_data_ && | |
| 1284 !waiting_for_clear_auto_sign_in_; | 792 !waiting_for_clear_auto_sign_in_; |
| 1285 } | 793 } |
| 1286 | 794 |
| 1287 void BrowsingDataRemover::OnKeywordsLoaded( | 795 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 796 void ChromeBrowsingDataRemoverDelegate::OverrideWebappRegistryForTesting( |
| 797 std::unique_ptr<WebappRegistry> webapp_registry) { |
| 798 webapp_registry_ = std::move(webapp_registry); |
| 799 } |
| 800 #endif |
| 801 |
| 802 void ChromeBrowsingDataRemoverDelegate::OnKeywordsLoaded( |
| 1288 base::Callback<bool(const GURL&)> url_filter) { | 803 base::Callback<bool(const GURL&)> url_filter) { |
| 1289 // Deletes the entries from the model, and if we're not waiting on anything | 804 // Deletes the entries from the model, and if we're not waiting on anything |
| 1290 // else notifies observers and deletes this BrowsingDataRemover. | 805 // else notifies observers and deletes this BrowsingDataRemover. |
| 1291 TemplateURLService* model = | 806 TemplateURLService* model = |
| 1292 TemplateURLServiceFactory::GetForProfile(profile_); | 807 TemplateURLServiceFactory::GetForProfile(profile_); |
| 1293 model->RemoveAutoGeneratedForUrlsBetween(url_filter, delete_begin_, | 808 model->RemoveAutoGeneratedForUrlsBetween(url_filter, delete_begin_, |
| 1294 delete_end_); | 809 delete_end_); |
| 1295 waiting_for_clear_keyword_data_ = false; | 810 waiting_for_clear_keyword_data_ = false; |
| 1296 template_url_sub_.reset(); | 811 template_url_sub_.reset(); |
| 1297 NotifyIfDone(); | 812 NotifyIfDone(); |
| 1298 } | 813 } |
| 1299 | 814 |
| 1300 void BrowsingDataRemover::Notify() { | 815 void ChromeBrowsingDataRemoverDelegate::OnHistoryDeletionDone() { |
| 1301 // Some tests call |RemoveImpl| directly, without using the task scheduler. | |
| 1302 // TODO(msramek): Improve those tests so we don't have to do this. Tests | |
| 1303 // relying on |RemoveImpl| do so because they need to pass in | |
| 1304 // BrowsingDataFilterBuilder while still keeping ownership of it. Making | |
| 1305 // BrowsingDataFilterBuilder copyable would solve this. | |
| 1306 if (!is_removing_) { | |
| 1307 DCHECK(task_queue_.empty()); | |
| 1308 return; | |
| 1309 } | |
| 1310 | |
| 1311 // Inform the observer of the current task unless it has unregistered | |
| 1312 // itself in the meantime. | |
| 1313 DCHECK(!task_queue_.empty()); | |
| 1314 | |
| 1315 if (task_queue_.front().observer != nullptr && | |
| 1316 observer_list_.HasObserver(task_queue_.front().observer)) { | |
| 1317 task_queue_.front().observer->OnBrowsingDataRemoverDone(); | |
| 1318 } | |
| 1319 | |
| 1320 task_queue_.pop(); | |
| 1321 | |
| 1322 if (task_queue_.empty()) { | |
| 1323 // All removal tasks have finished. Inform the observers that we're idle. | |
| 1324 SetRemoving(false); | |
| 1325 return; | |
| 1326 } | |
| 1327 | |
| 1328 // Yield to the UI thread before executing the next removal task. | |
| 1329 // TODO(msramek): Consider also adding a backoff if too many tasks | |
| 1330 // are scheduled. | |
| 1331 BrowserThread::PostTask( | |
| 1332 BrowserThread::UI, FROM_HERE, | |
| 1333 base::Bind(&BrowsingDataRemover::RunNextTask, | |
| 1334 weak_ptr_factory_.GetWeakPtr())); | |
| 1335 } | |
| 1336 | |
| 1337 void BrowsingDataRemover::NotifyIfDone() { | |
| 1338 // TODO(brettw) http://crbug.com/305259: This should also observe session | |
| 1339 // clearing (what about other things such as passwords, etc.?) and wait for | |
| 1340 // them to complete before continuing. | |
| 1341 | |
| 1342 if (!AllDone()) | |
| 1343 return; | |
| 1344 | |
| 1345 if (completion_inhibitor_) { | |
| 1346 completion_inhibitor_->OnBrowsingDataRemoverWouldComplete( | |
| 1347 this, base::Bind(&BrowsingDataRemover::Notify, | |
| 1348 weak_ptr_factory_.GetWeakPtr())); | |
| 1349 return; | |
| 1350 } | |
| 1351 | |
| 1352 Notify(); | |
| 1353 } | |
| 1354 | |
| 1355 void BrowsingDataRemover::OnHistoryDeletionDone() { | |
| 1356 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 816 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1357 waiting_for_clear_history_ = false; | 817 waiting_for_clear_history_ = false; |
| 1358 NotifyIfDone(); | 818 NotifyIfDone(); |
| 1359 } | 819 } |
| 1360 | 820 |
| 1361 void BrowsingDataRemover::OnClearedHostnameResolutionCache() { | 821 void ChromeBrowsingDataRemoverDelegate::OnClearedHostnameResolutionCache() { |
| 1362 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 822 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1363 waiting_for_clear_hostname_resolution_cache_ = false; | 823 waiting_for_clear_hostname_resolution_cache_ = false; |
| 1364 NotifyIfDone(); | 824 NotifyIfDone(); |
| 1365 } | 825 } |
| 1366 | 826 |
| 1367 void BrowsingDataRemover::OnClearedHttpAuthCache() { | 827 void ChromeBrowsingDataRemoverDelegate::OnClearedNetworkPredictor() { |
| 1368 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 1369 waiting_for_clear_http_auth_cache_ = false; | |
| 1370 NotifyIfDone(); | |
| 1371 } | |
| 1372 | |
| 1373 void BrowsingDataRemover::OnClearedNetworkPredictor() { | |
| 1374 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 828 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1375 waiting_for_clear_network_predictor_ = false; | 829 waiting_for_clear_network_predictor_ = false; |
| 1376 NotifyIfDone(); | 830 NotifyIfDone(); |
| 1377 } | 831 } |
| 1378 | 832 |
| 1379 void BrowsingDataRemover::OnClearedNetworkingHistory() { | 833 void ChromeBrowsingDataRemoverDelegate::OnClearedNetworkingHistory() { |
| 1380 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 834 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1381 waiting_for_clear_networking_history_ = false; | 835 waiting_for_clear_networking_history_ = false; |
| 1382 NotifyIfDone(); | 836 NotifyIfDone(); |
| 1383 } | 837 } |
| 1384 | 838 |
| 1385 void BrowsingDataRemover::ClearedCache() { | |
| 1386 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 1387 waiting_for_clear_cache_ = false; | |
| 1388 NotifyIfDone(); | |
| 1389 } | |
| 1390 | |
| 1391 #if !defined(DISABLE_NACL) | 839 #if !defined(DISABLE_NACL) |
| 1392 void BrowsingDataRemover::ClearedNaClCache() { | 840 void ChromeBrowsingDataRemoverDelegate::ClearedNaClCache() { |
| 1393 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 841 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1394 waiting_for_clear_nacl_cache_ = false; | 842 waiting_for_clear_nacl_cache_ = false; |
| 1395 NotifyIfDone(); | 843 NotifyIfDone(); |
| 1396 } | 844 } |
| 1397 | 845 |
| 1398 void BrowsingDataRemover::ClearedPnaclCache() { | 846 void ChromeBrowsingDataRemoverDelegate::ClearedPnaclCache() { |
| 1399 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 847 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1400 waiting_for_clear_pnacl_cache_ = false; | 848 waiting_for_clear_pnacl_cache_ = false; |
| 1401 NotifyIfDone(); | 849 NotifyIfDone(); |
| 1402 } | 850 } |
| 1403 #endif | 851 #endif |
| 1404 | 852 |
| 1405 #if BUILDFLAG(ENABLE_PLUGINS) | 853 void ChromeBrowsingDataRemoverDelegate::OnClearedCookies() { |
| 1406 void BrowsingDataRemover::OnWaitableEventSignaled( | |
| 1407 base::WaitableEvent* waitable_event) { | |
| 1408 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 854 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1409 | 855 |
| 1410 DCHECK_EQ(1, waiting_for_clear_plugin_data_count_); | 856 DCHECK_GT(waiting_for_clear_cookies_count_, 0); |
| 1411 waiting_for_clear_plugin_data_count_ = 0; | 857 --waiting_for_clear_cookies_count_; |
| 1412 | |
| 1413 plugin_data_remover_.reset(); | |
| 1414 watcher_.StopWatching(); | |
| 1415 NotifyIfDone(); | 858 NotifyIfDone(); |
| 1416 } | 859 } |
| 1417 | 860 |
| 1418 void BrowsingDataRemover::OnSitesWithFlashDataFetched( | 861 #if BUILDFLAG(ENABLE_PLUGINS) |
| 1419 base::Callback<bool(const std::string&)> plugin_filter, | 862 void ChromeBrowsingDataRemoverDelegate:: |
| 1420 const std::vector<std::string>& sites) { | 863 OnDeauthorizeFlashContentLicensesCompleted( |
| 1421 DCHECK_EQ(1, waiting_for_clear_plugin_data_count_); | |
| 1422 waiting_for_clear_plugin_data_count_ = 0; | |
| 1423 | |
| 1424 std::vector<std::string> sites_to_delete; | |
| 1425 for (const std::string& site : sites) { | |
| 1426 if (plugin_filter.Run(site)) | |
| 1427 sites_to_delete.push_back(site); | |
| 1428 } | |
| 1429 | |
| 1430 waiting_for_clear_plugin_data_count_ = sites_to_delete.size(); | |
| 1431 | |
| 1432 for (const std::string& site : sites_to_delete) { | |
| 1433 flash_lso_helper_->DeleteFlashLSOsForSite( | |
| 1434 site, | |
| 1435 base::Bind(&BrowsingDataRemover::OnFlashDataDeleted, | |
| 1436 weak_ptr_factory_.GetWeakPtr())); | |
| 1437 } | |
| 1438 | |
| 1439 NotifyIfDone(); | |
| 1440 } | |
| 1441 | |
| 1442 void BrowsingDataRemover::OnFlashDataDeleted() { | |
| 1443 waiting_for_clear_plugin_data_count_--; | |
| 1444 NotifyIfDone(); | |
| 1445 } | |
| 1446 | |
| 1447 void BrowsingDataRemover::OnDeauthorizeFlashContentLicensesCompleted( | |
| 1448 uint32_t request_id, | 864 uint32_t request_id, |
| 1449 bool /* success */) { | 865 bool /* success */) { |
| 1450 DCHECK(waiting_for_clear_flash_content_licenses_); | 866 DCHECK(waiting_for_clear_flash_content_licenses_); |
| 1451 DCHECK_EQ(request_id, deauthorize_flash_content_licenses_request_id_); | 867 DCHECK_EQ(request_id, deauthorize_flash_content_licenses_request_id_); |
| 1452 | 868 |
| 1453 waiting_for_clear_flash_content_licenses_ = false; | 869 waiting_for_clear_flash_content_licenses_ = false; |
| 1454 NotifyIfDone(); | 870 NotifyIfDone(); |
| 1455 } | 871 } |
| 1456 #endif | 872 #endif |
| 1457 | 873 |
| 1458 #if defined(OS_CHROMEOS) | 874 #if defined(OS_CHROMEOS) |
| 1459 void BrowsingDataRemover::OnClearPlatformKeys( | 875 void ChromeBrowsingDataRemoverDelegate::OnClearPlatformKeys( |
| 1460 chromeos::DBusMethodCallStatus call_status, | 876 chromeos::DBusMethodCallStatus call_status, |
| 1461 bool result) { | 877 bool result) { |
| 1462 DCHECK(waiting_for_clear_platform_keys_); | 878 DCHECK(waiting_for_clear_platform_keys_); |
| 1463 LOG_IF(ERROR, call_status != chromeos::DBUS_METHOD_CALL_SUCCESS || !result) | 879 LOG_IF(ERROR, call_status != chromeos::DBUS_METHOD_CALL_SUCCESS || !result) |
| 1464 << "Failed to clear platform keys."; | 880 << "Failed to clear platform keys."; |
| 1465 waiting_for_clear_platform_keys_ = false; | 881 waiting_for_clear_platform_keys_ = false; |
| 1466 NotifyIfDone(); | 882 NotifyIfDone(); |
| 1467 } | 883 } |
| 1468 #endif | 884 #endif |
| 1469 | 885 |
| 1470 | 886 |
| 1471 void BrowsingDataRemover::OnClearedPasswords() { | 887 void ChromeBrowsingDataRemoverDelegate::OnClearedPasswords() { |
| 1472 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 888 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1473 waiting_for_clear_passwords_ = false; | 889 waiting_for_clear_passwords_ = false; |
| 1474 NotifyIfDone(); | 890 NotifyIfDone(); |
| 1475 } | 891 } |
| 1476 | 892 |
| 1477 void BrowsingDataRemover::OnClearedPasswordsStats() { | 893 void ChromeBrowsingDataRemoverDelegate::OnClearedPasswordsStats() { |
| 1478 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 894 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1479 waiting_for_clear_passwords_stats_ = false; | 895 waiting_for_clear_passwords_stats_ = false; |
| 1480 NotifyIfDone(); | 896 NotifyIfDone(); |
| 1481 } | 897 } |
| 1482 | 898 |
| 1483 void BrowsingDataRemover::OnClearedAutoSignIn() { | 899 void ChromeBrowsingDataRemoverDelegate::OnClearedAutoSignIn() { |
| 1484 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 900 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1485 waiting_for_clear_auto_sign_in_ = false; | 901 waiting_for_clear_auto_sign_in_ = false; |
| 1486 NotifyIfDone(); | 902 NotifyIfDone(); |
| 1487 } | 903 } |
| 1488 | 904 |
| 1489 void BrowsingDataRemover::OnClearedCookies() { | 905 void ChromeBrowsingDataRemoverDelegate::OnClearedFormData() { |
| 1490 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 1491 | |
| 1492 DCHECK_GT(waiting_for_clear_cookies_count_, 0); | |
| 1493 --waiting_for_clear_cookies_count_; | |
| 1494 NotifyIfDone(); | |
| 1495 } | |
| 1496 | |
| 1497 void BrowsingDataRemover::OnClearedChannelIDs() { | |
| 1498 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 1499 waiting_for_clear_channel_ids_ = false; | |
| 1500 NotifyIfDone(); | |
| 1501 } | |
| 1502 | |
| 1503 void BrowsingDataRemover::OnClearedFormData() { | |
| 1504 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 906 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1505 waiting_for_clear_form_ = false; | 907 waiting_for_clear_form_ = false; |
| 1506 NotifyIfDone(); | 908 NotifyIfDone(); |
| 1507 } | 909 } |
| 1508 | 910 |
| 1509 void BrowsingDataRemover::OnClearedAutofillOriginURLs() { | 911 void ChromeBrowsingDataRemoverDelegate::OnClearedAutofillOriginURLs() { |
| 1510 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 912 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1511 waiting_for_clear_autofill_origin_urls_ = false; | 913 waiting_for_clear_autofill_origin_urls_ = false; |
| 1512 NotifyIfDone(); | 914 NotifyIfDone(); |
| 1513 } | 915 } |
| 1514 | 916 |
| 1515 void BrowsingDataRemover::OnClearedStoragePartitionData() { | |
| 1516 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 1517 waiting_for_clear_storage_partition_data_ = false; | |
| 1518 NotifyIfDone(); | |
| 1519 } | |
| 1520 | |
| 1521 #if BUILDFLAG(ENABLE_WEBRTC) | 917 #if BUILDFLAG(ENABLE_WEBRTC) |
| 1522 void BrowsingDataRemover::OnClearedWebRtcLogs() { | 918 void ChromeBrowsingDataRemoverDelegate::OnClearedWebRtcLogs() { |
| 1523 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 919 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1524 waiting_for_clear_webrtc_logs_ = false; | 920 waiting_for_clear_webrtc_logs_ = false; |
| 1525 NotifyIfDone(); | 921 NotifyIfDone(); |
| 1526 } | 922 } |
| 1527 #endif | 923 #endif |
| 1528 | 924 |
| 1529 #if BUILDFLAG(ANDROID_JAVA_UI) | 925 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 1530 void BrowsingDataRemover::OnClearedPrecacheHistory() { | 926 void ChromeBrowsingDataRemoverDelegate::OnClearedPrecacheHistory() { |
| 1531 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 927 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1532 waiting_for_clear_precache_history_ = false; | 928 waiting_for_clear_precache_history_ = false; |
| 1533 NotifyIfDone(); | 929 NotifyIfDone(); |
| 1534 } | 930 } |
| 1535 | 931 |
| 1536 void BrowsingDataRemover::OnClearedOfflinePageData( | 932 void ChromeBrowsingDataRemoverDelegate::OnClearedOfflinePageData( |
| 1537 offline_pages::OfflinePageModel::DeletePageResult result) { | 933 offline_pages::OfflinePageModel::DeletePageResult result) { |
| 1538 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 934 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1539 waiting_for_clear_offline_page_data_ = false; | 935 waiting_for_clear_offline_page_data_ = false; |
| 1540 NotifyIfDone(); | 936 NotifyIfDone(); |
| 1541 } | 937 } |
| 1542 #endif | 938 #endif |
| 1543 | 939 |
| 1544 void BrowsingDataRemover::OnClearedDomainReliabilityMonitor() { | 940 void ChromeBrowsingDataRemoverDelegate::OnClearedDomainReliabilityMonitor() { |
| 1545 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 941 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1546 waiting_for_clear_domain_reliability_monitor_ = false; | 942 waiting_for_clear_domain_reliability_monitor_ = false; |
| 1547 NotifyIfDone(); | 943 NotifyIfDone(); |
| 1548 } | 944 } |
| OLD | NEW |