| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browsing_data_remover.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 17 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/browsing_data/browsing_data_filter_builder.h" |
| 19 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 20 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 20 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 21 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
| 21 #include "chrome/browser/browsing_data/origin_filter_builder.h" | |
| 22 #include "chrome/browser/chrome_notification_types.h" | 22 #include "chrome/browser/chrome_notification_types.h" |
| 23 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 23 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 24 #include "chrome/browser/domain_reliability/service_factory.h" | 24 #include "chrome/browser/domain_reliability/service_factory.h" |
| 25 #include "chrome/browser/download/download_prefs.h" | 25 #include "chrome/browser/download/download_prefs.h" |
| 26 #include "chrome/browser/history/history_service_factory.h" | 26 #include "chrome/browser/history/history_service_factory.h" |
| 27 #include "chrome/browser/history/web_history_service_factory.h" | 27 #include "chrome/browser/history/web_history_service_factory.h" |
| 28 #include "chrome/browser/io_thread.h" | 28 #include "chrome/browser/io_thread.h" |
| 29 #include "chrome/browser/media/media_device_id_salt.h" | 29 #include "chrome/browser/media/media_device_id_salt.h" |
| 30 #include "chrome/browser/net/predictor.h" | 30 #include "chrome/browser/net/predictor.h" |
| 31 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | 31 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
| 32 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact
ory.h" | 32 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact
ory.h" |
| 33 #include "chrome/browser/password_manager/password_store_factory.h" | 33 #include "chrome/browser/password_manager/password_store_factory.h" |
| 34 #include "chrome/browser/prerender/prerender_manager.h" | 34 #include "chrome/browser/prerender/prerender_manager.h" |
| 35 #include "chrome/browser/prerender/prerender_manager_factory.h" | 35 #include "chrome/browser/prerender/prerender_manager_factory.h" |
| 36 #include "chrome/browser/profiles/profile.h" | 36 #include "chrome/browser/profiles/profile.h" |
| 37 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 37 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 38 #include "chrome/browser/search_engines/template_url_service_factory.h" | 38 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 39 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 39 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 40 #include "chrome/browser/web_data_service_factory.h" | 40 #include "chrome/browser/web_data_service_factory.h" |
| 41 #include "chrome/common/features.h" | 41 #include "chrome/common/features.h" |
| 42 #include "chrome/common/pref_names.h" | 42 #include "chrome/common/pref_names.h" |
| 43 #include "chrome/common/url_constants.h" | 43 #include "chrome/common/url_constants.h" |
| 44 #include "components/autofill/core/browser/personal_data_manager.h" | 44 #include "components/autofill/core/browser/personal_data_manager.h" |
| 45 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 45 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
| 46 #include "components/browsing_data/storage_partition_http_cache_data_remover.h" | 46 #include "components/browsing_data/storage_partition_http_cache_data_remover.h" |
| 47 #include "components/content_settings/core/browser/host_content_settings_map.h" | 47 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 48 #include "components/content_settings/core/common/content_settings.h" |
| 49 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 48 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp
ression_stats.h" | 50 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp
ression_stats.h" |
| 49 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv
ice.h" | 51 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv
ice.h" |
| 50 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" | 52 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" |
| 51 #include "components/domain_reliability/service.h" | 53 #include "components/domain_reliability/service.h" |
| 52 #include "components/history/core/browser/history_service.h" | 54 #include "components/history/core/browser/history_service.h" |
| 53 #include "components/nacl/browser/nacl_browser.h" | 55 #include "components/nacl/browser/nacl_browser.h" |
| 54 #include "components/nacl/browser/pnacl_host.h" | 56 #include "components/nacl/browser/pnacl_host.h" |
| 55 #include "components/omnibox/browser/omnibox_pref_names.h" | 57 #include "components/omnibox/browser/omnibox_pref_names.h" |
| 56 #include "components/password_manager/core/browser/password_store.h" | 58 #include "components/password_manager/core/browser/password_store.h" |
| 57 #include "components/power/origin_power_map.h" | 59 #include "components/power/origin_power_map.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 } | 152 } |
| 151 | 153 |
| 152 // Another convenience method to turn a callback without arguments into one that | 154 // Another convenience method to turn a callback without arguments into one that |
| 153 // accepts (and ignores) a single argument. | 155 // accepts (and ignores) a single argument. |
| 154 template <typename T> | 156 template <typename T> |
| 155 base::Callback<void(T)> IgnoreArgument(const base::Closure& callback) { | 157 base::Callback<void(T)> IgnoreArgument(const base::Closure& callback) { |
| 156 return base::Bind(&IgnoreArgumentHelper<T>, callback); | 158 return base::Bind(&IgnoreArgumentHelper<T>, callback); |
| 157 } | 159 } |
| 158 | 160 |
| 159 // Helper to create callback for BrowsingDataRemover::DoesOriginMatchMask. | 161 // Helper to create callback for BrowsingDataRemover::DoesOriginMatchMask. |
| 160 bool DoesOriginMatchMask( | 162 bool DoesOriginMatchMaskAndUrls( |
| 161 int origin_type_mask, | 163 int origin_type_mask, |
| 164 const base::Callback<bool(const GURL&)>& predicate, |
| 162 const GURL& origin, | 165 const GURL& origin, |
| 163 storage::SpecialStoragePolicy* special_storage_policy) { | 166 storage::SpecialStoragePolicy* special_storage_policy) { |
| 164 return BrowsingDataHelper::DoesOriginMatchMask( | 167 return predicate.Run(origin) && |
| 165 origin, origin_type_mask, special_storage_policy); | 168 BrowsingDataHelper::DoesOriginMatchMask(origin, origin_type_mask, |
| 169 special_storage_policy); |
| 170 } |
| 171 |
| 172 bool ForwardPrimaryPatternCallback( |
| 173 const base::Callback<bool(const ContentSettingsPattern&)> predicate, |
| 174 const ContentSettingsPattern& primary_pattern, |
| 175 const ContentSettingsPattern& secondary_pattern) { |
| 176 return predicate.Run(primary_pattern); |
| 166 } | 177 } |
| 167 | 178 |
| 168 void ClearHostnameResolutionCacheOnIOThread(IOThread* io_thread) { | 179 void ClearHostnameResolutionCacheOnIOThread(IOThread* io_thread) { |
| 169 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 180 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 170 | 181 |
| 171 io_thread->ClearHostCache(); | 182 io_thread->ClearHostCache(); |
| 172 } | 183 } |
| 173 | 184 |
| 174 void ClearNetworkPredictorOnIOThread(chrome_browser_net::Predictor* predictor) { | 185 void ClearNetworkPredictorOnIOThread(chrome_browser_net::Predictor* predictor) { |
| 175 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 186 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 200 base::Time delete_end, | 211 base::Time delete_end, |
| 201 net::URLRequestContextGetter* rq_context, | 212 net::URLRequestContextGetter* rq_context, |
| 202 const base::Closure& callback) { | 213 const base::Closure& callback) { |
| 203 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 214 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 204 net::CookieStore* cookie_store = | 215 net::CookieStore* cookie_store = |
| 205 rq_context->GetURLRequestContext()->cookie_store(); | 216 rq_context->GetURLRequestContext()->cookie_store(); |
| 206 cookie_store->DeleteAllCreatedBetweenAsync(delete_begin, delete_end, | 217 cookie_store->DeleteAllCreatedBetweenAsync(delete_begin, delete_end, |
| 207 IgnoreArgument<int>(callback)); | 218 IgnoreArgument<int>(callback)); |
| 208 } | 219 } |
| 209 | 220 |
| 221 void ClearCookiesWithPredicateOnIOThread( |
| 222 base::Time delete_begin, |
| 223 base::Time delete_end, |
| 224 net::CookieStore::CookiePredicate predicate, |
| 225 net::URLRequestContextGetter* rq_context, |
| 226 const base::Closure& callback) { |
| 227 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 228 net::CookieStore* cookie_store = |
| 229 rq_context->GetURLRequestContext()->cookie_store(); |
| 230 cookie_store->DeleteAllCreatedBetweenWithPredicateAsync( |
| 231 delete_begin, delete_end, predicate, IgnoreArgument<int>(callback)); |
| 232 } |
| 233 |
| 210 void OnClearedChannelIDsOnIOThread(net::URLRequestContextGetter* rq_context, | 234 void OnClearedChannelIDsOnIOThread(net::URLRequestContextGetter* rq_context, |
| 211 const base::Closure& callback) { | 235 const base::Closure& callback) { |
| 212 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 236 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 213 | 237 |
| 214 // Need to close open SSL connections which may be using the channel ids we | 238 // Need to close open SSL connections which may be using the channel ids we |
| 215 // are deleting. | 239 // are deleting. |
| 216 // TODO(mattm): http://crbug.com/166069 Make the server bound cert | 240 // TODO(mattm): http://crbug.com/166069 Make the server bound cert |
| 217 // service/store have observers that can notify relevant things directly. | 241 // service/store have observers that can notify relevant things directly. |
| 218 rq_context->GetURLRequestContext() | 242 rq_context->GetURLRequestContext() |
| 219 ->ssl_config_service() | 243 ->ssl_config_service() |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 } | 348 } |
| 325 | 349 |
| 326 void BrowsingDataRemover::SetRemoving(bool is_removing) { | 350 void BrowsingDataRemover::SetRemoving(bool is_removing) { |
| 327 DCHECK_NE(is_removing_, is_removing); | 351 DCHECK_NE(is_removing_, is_removing); |
| 328 is_removing_ = is_removing; | 352 is_removing_ = is_removing; |
| 329 } | 353 } |
| 330 | 354 |
| 331 void BrowsingDataRemover::Remove(const TimeRange& time_range, | 355 void BrowsingDataRemover::Remove(const TimeRange& time_range, |
| 332 int remove_mask, | 356 int remove_mask, |
| 333 int origin_type_mask) { | 357 int origin_type_mask) { |
| 334 RemoveImpl(time_range, remove_mask, GURL(), origin_type_mask); | 358 BrowsingDataFilterBuilder builder(BrowsingDataFilterBuilder::BLACKLIST); |
| 359 RemoveImpl(time_range, remove_mask, builder, origin_type_mask); |
| 335 } | 360 } |
| 336 | 361 |
| 337 void BrowsingDataRemover::RemoveImpl(const TimeRange& time_range, | 362 void BrowsingDataRemover::RemoveWithFilter( |
| 338 int remove_mask, | 363 const TimeRange& time_range, |
| 339 const GURL& remove_url, | 364 int remove_mask, |
| 340 int origin_type_mask) { | 365 int origin_type_mask, |
| 366 const BrowsingDataFilterBuilder& origin_filter) { |
| 367 RemoveImpl(time_range, remove_mask, origin_filter, origin_type_mask); |
| 368 } |
| 369 |
| 370 void BrowsingDataRemover::RemoveImpl( |
| 371 const TimeRange& time_range, |
| 372 int remove_mask, |
| 373 const BrowsingDataFilterBuilder& filter_builder, |
| 374 int origin_type_mask) { |
| 341 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 375 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 342 | 376 |
| 343 // crbug.com/140910: Many places were calling this with base::Time() as | 377 // crbug.com/140910: Many places were calling this with base::Time() as |
| 344 // delete_end, even though they should've used base::Time::Max(). | 378 // delete_end, even though they should've used base::Time::Max(). |
| 345 DCHECK_NE(base::Time(), time_range.end); | 379 DCHECK_NE(base::Time(), time_range.end); |
| 346 | 380 |
| 347 SetRemoving(true); | 381 SetRemoving(true); |
| 348 delete_begin_ = time_range.begin; | 382 delete_begin_ = time_range.begin; |
| 349 delete_end_ = time_range.end; | 383 delete_end_ = time_range.end; |
| 350 remove_mask_ = remove_mask; | 384 remove_mask_ = remove_mask; |
| 351 origin_type_mask_ = origin_type_mask; | 385 origin_type_mask_ = origin_type_mask; |
| 352 | 386 |
| 353 // TODO(msramek): Replace |remove_origin| with |filter| in all backends. | 387 base::Callback<bool(const GURL& url)> same_domain_filter = |
| 354 const url::Origin remove_origin(remove_url); | 388 filter_builder.BuildSameDomainFilter(); |
| 355 OriginFilterBuilder builder(OriginFilterBuilder::BLACKLIST); | 389 base::Callback<bool(const ContentSettingsPattern& url)> same_pattern_filter = |
| 356 if (!remove_url.is_empty()) { | 390 filter_builder.BuildWebsiteSettingsPatternMatchesFilter(); |
| 357 // Make sure that only URLs representing origins, with no extra components, | |
| 358 // are passed to this class. | |
| 359 DCHECK_EQ(remove_url, remove_url.GetOrigin()); | |
| 360 builder.SetMode(OriginFilterBuilder::WHITELIST); | |
| 361 builder.AddOrigin(url::Origin(remove_origin)); | |
| 362 } | |
| 363 base::Callback<bool(const GURL& url)> same_origin_filter = | |
| 364 builder.BuildSameOriginFilter(); | |
| 365 | 391 |
| 366 PrefService* prefs = profile_->GetPrefs(); | 392 PrefService* prefs = profile_->GetPrefs(); |
| 367 bool may_delete_history = prefs->GetBoolean( | 393 bool may_delete_history = prefs->GetBoolean( |
| 368 prefs::kAllowDeletingBrowserHistory); | 394 prefs::kAllowDeletingBrowserHistory); |
| 369 | 395 |
| 370 // All the UI entry points into the BrowsingDataRemover should be disabled, | 396 // All the UI entry points into the BrowsingDataRemover should be disabled, |
| 371 // but this will fire if something was missed or added. | 397 // but this will fire if something was missed or added. |
| 372 DCHECK(may_delete_history || (remove_mask & REMOVE_NOCHECKS) || | 398 DCHECK(may_delete_history || (remove_mask & REMOVE_NOCHECKS) || |
| 373 (!(remove_mask & REMOVE_HISTORY) && !(remove_mask & REMOVE_DOWNLOADS))); | 399 (!(remove_mask & REMOVE_HISTORY) && !(remove_mask & REMOVE_DOWNLOADS))); |
| 374 | 400 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 390 BrowsingDataHelper::ALL == (BrowsingDataHelper::UNPROTECTED_WEB | | 416 BrowsingDataHelper::ALL == (BrowsingDataHelper::UNPROTECTED_WEB | |
| 391 BrowsingDataHelper::PROTECTED_WEB | | 417 BrowsingDataHelper::PROTECTED_WEB | |
| 392 BrowsingDataHelper::EXTENSION), | 418 BrowsingDataHelper::EXTENSION), |
| 393 "OriginTypeMask has been updated without updating user metrics"); | 419 "OriginTypeMask has been updated without updating user metrics"); |
| 394 | 420 |
| 395 if ((remove_mask & REMOVE_HISTORY) && may_delete_history) { | 421 if ((remove_mask & REMOVE_HISTORY) && may_delete_history) { |
| 396 history::HistoryService* history_service = | 422 history::HistoryService* history_service = |
| 397 HistoryServiceFactory::GetForProfile( | 423 HistoryServiceFactory::GetForProfile( |
| 398 profile_, ServiceAccessType::EXPLICIT_ACCESS); | 424 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
| 399 if (history_service) { | 425 if (history_service) { |
| 400 // Selective history deletion is currently done through HistoryUI -> | 426 // TODO(dmurph): Support all backends with filter (crbug.com/113621). |
| 401 // HistoryBackend -> HistoryService, and that is for individual URLs, | |
| 402 // not origins. The code below is currently unused, as the only callsite | |
| 403 // supplying |remove_url| is the unittest. | |
| 404 // TODO(msramek): Make it possible to delete history per origin, not just | |
| 405 // per URL, and use that functionality here. | |
| 406 std::set<GURL> restrict_urls; | |
| 407 if (!remove_url.is_empty()) | |
| 408 restrict_urls.insert(remove_url); | |
| 409 content::RecordAction(UserMetricsAction("ClearBrowsingData_History")); | 427 content::RecordAction(UserMetricsAction("ClearBrowsingData_History")); |
| 410 waiting_for_clear_history_ = true; | 428 waiting_for_clear_history_ = true; |
| 411 | |
| 412 history_service->ExpireLocalAndRemoteHistoryBetween( | 429 history_service->ExpireLocalAndRemoteHistoryBetween( |
| 413 WebHistoryServiceFactory::GetForProfile(profile_), restrict_urls, | 430 WebHistoryServiceFactory::GetForProfile(profile_), std::set<GURL>(), |
| 414 delete_begin_, delete_end_, | 431 delete_begin_, delete_end_, |
| 415 base::Bind(&BrowsingDataRemover::OnHistoryDeletionDone, | 432 base::Bind(&BrowsingDataRemover::OnHistoryDeletionDone, |
| 416 weak_ptr_factory_.GetWeakPtr()), | 433 weak_ptr_factory_.GetWeakPtr()), |
| 417 &history_task_tracker_); | 434 &history_task_tracker_); |
| 418 | 435 |
| 419 #if defined(ENABLE_EXTENSIONS) | 436 #if defined(ENABLE_EXTENSIONS) |
| 420 // The extension activity contains details of which websites extensions | 437 // The extension activity contains details of which websites extensions |
| 421 // were active on. It therefore indirectly stores details of websites a | 438 // were active on. It therefore indirectly stores details of websites a |
| 422 // user has visited so best clean from here as well. | 439 // user has visited so best clean from here as well. |
| 423 extensions::ActivityLog::GetInstance(profile_)->RemoveURLs(restrict_urls); | 440 extensions::ActivityLog::GetInstance(profile_)->RemoveURLs( |
| 441 std::set<GURL>()); |
| 424 #endif | 442 #endif |
| 425 } | 443 } |
| 426 | 444 |
| 427 #if defined(ENABLE_EXTENSIONS) | 445 #if defined(ENABLE_EXTENSIONS) |
| 428 // Clear launch times as they are a form of history. | 446 // Clear launch times as they are a form of history. |
| 429 extensions::ExtensionPrefs* extension_prefs = | 447 extensions::ExtensionPrefs* extension_prefs = |
| 430 extensions::ExtensionPrefs::Get(profile_); | 448 extensions::ExtensionPrefs::Get(profile_); |
| 431 extension_prefs->ClearLastLaunchTimes(); | 449 extension_prefs->ClearLastLaunchTimes(); |
| 432 #endif | 450 #endif |
| 433 | 451 |
| 434 // The power consumption history by origin contains details of websites | 452 // The power consumption history by origin contains details of websites |
| 435 // that were visited. | 453 // that were visited. |
| 454 // TODO(dmurph): Support all backends with filter (crbug.com/113621). |
| 436 power::OriginPowerMap* origin_power_map = | 455 power::OriginPowerMap* origin_power_map = |
| 437 power::OriginPowerMapFactory::GetForBrowserContext(profile_); | 456 power::OriginPowerMapFactory::GetForBrowserContext(profile_); |
| 438 if (origin_power_map) | 457 if (origin_power_map) |
| 439 origin_power_map->ClearOriginMap(); | 458 origin_power_map->ClearOriginMap(); |
| 440 | 459 |
| 441 // Need to clear the host cache and accumulated speculative data, as it also | 460 // Need to clear the host cache and accumulated speculative data, as it also |
| 442 // reveals some history: we have no mechanism to track when these items were | 461 // reveals some history: we have no mechanism to track when these items were |
| 443 // created, so we'll clear them all. Better safe than sorry. | 462 // created, so we'll clear them all. Better safe than sorry. |
| 444 if (g_browser_process->io_thread()) { | 463 if (g_browser_process->io_thread()) { |
| 464 // TODO(dmurph): Support all backends with filter (crbug.com/113621). |
| 445 waiting_for_clear_hostname_resolution_cache_ = true; | 465 waiting_for_clear_hostname_resolution_cache_ = true; |
| 446 BrowserThread::PostTaskAndReply( | 466 BrowserThread::PostTaskAndReply( |
| 447 BrowserThread::IO, FROM_HERE, | 467 BrowserThread::IO, FROM_HERE, |
| 448 base::Bind(&ClearHostnameResolutionCacheOnIOThread, | 468 base::Bind(&ClearHostnameResolutionCacheOnIOThread, |
| 449 g_browser_process->io_thread()), | 469 g_browser_process->io_thread()), |
| 450 base::Bind(&BrowsingDataRemover::OnClearedHostnameResolutionCache, | 470 base::Bind(&BrowsingDataRemover::OnClearedHostnameResolutionCache, |
| 451 weak_ptr_factory_.GetWeakPtr())); | 471 weak_ptr_factory_.GetWeakPtr())); |
| 452 } | 472 } |
| 453 if (profile_->GetNetworkPredictor()) { | 473 if (profile_->GetNetworkPredictor()) { |
| 474 // TODO(dmurph): Support all backends with filter (crbug.com/113621). |
| 454 waiting_for_clear_network_predictor_ = true; | 475 waiting_for_clear_network_predictor_ = true; |
| 455 BrowserThread::PostTaskAndReply( | 476 BrowserThread::PostTaskAndReply( |
| 456 BrowserThread::IO, FROM_HERE, | 477 BrowserThread::IO, FROM_HERE, |
| 457 base::Bind(&ClearNetworkPredictorOnIOThread, | 478 base::Bind(&ClearNetworkPredictorOnIOThread, |
| 458 profile_->GetNetworkPredictor()), | 479 profile_->GetNetworkPredictor()), |
| 459 base::Bind(&BrowsingDataRemover::OnClearedNetworkPredictor, | 480 base::Bind(&BrowsingDataRemover::OnClearedNetworkPredictor, |
| 460 weak_ptr_factory_.GetWeakPtr())); | 481 weak_ptr_factory_.GetWeakPtr())); |
| 461 } | 482 } |
| 462 | 483 |
| 463 // As part of history deletion we also delete the auto-generated keywords. | 484 // As part of history deletion we also delete the auto-generated keywords. |
| 464 TemplateURLService* keywords_model = | 485 TemplateURLService* keywords_model = |
| 465 TemplateURLServiceFactory::GetForProfile(profile_); | 486 TemplateURLServiceFactory::GetForProfile(profile_); |
| 487 |
| 466 if (keywords_model && !keywords_model->loaded()) { | 488 if (keywords_model && !keywords_model->loaded()) { |
| 467 template_url_sub_ = keywords_model->RegisterOnLoadedCallback( | 489 template_url_sub_ = keywords_model->RegisterOnLoadedCallback( |
| 468 base::Bind(&BrowsingDataRemover::OnKeywordsLoaded, | 490 base::Bind(&BrowsingDataRemover::OnKeywordsLoaded, |
| 469 weak_ptr_factory_.GetWeakPtr())); | 491 weak_ptr_factory_.GetWeakPtr())); |
| 470 keywords_model->Load(); | 492 keywords_model->Load(); |
| 471 waiting_for_clear_keyword_data_ = true; | 493 waiting_for_clear_keyword_data_ = true; |
| 472 } else if (keywords_model) { | 494 } else if (keywords_model) { |
| 473 keywords_model->RemoveAutoGeneratedForOriginBetween( | 495 // TODO(dmurph): Support all backends with filter (crbug.com/113621). |
| 474 remove_url, delete_begin_, delete_end_); | 496 keywords_model->RemoveAutoGeneratedForOriginBetween(GURL(), delete_begin_, |
| 497 delete_end_); |
| 475 } | 498 } |
| 476 | 499 |
| 477 // The PrerenderManager keeps history of prerendered pages, so clear that. | 500 // The PrerenderManager keeps history of prerendered pages, so clear that. |
| 478 // It also may have a prerendered page. If so, the page could be | 501 // It also may have a prerendered page. If so, the page could be |
| 479 // considered to have a small amount of historical information, so delete | 502 // considered to have a small amount of historical information, so delete |
| 480 // it, too. | 503 // it, too. |
| 481 prerender::PrerenderManager* prerender_manager = | 504 prerender::PrerenderManager* prerender_manager = |
| 482 prerender::PrerenderManagerFactory::GetForProfile(profile_); | 505 prerender::PrerenderManagerFactory::GetForProfile(profile_); |
| 483 if (prerender_manager) { | 506 if (prerender_manager) { |
| 507 // TODO(dmurph): Support all backends with filter (crbug.com/113621). |
| 484 prerender_manager->ClearData( | 508 prerender_manager->ClearData( |
| 485 prerender::PrerenderManager::CLEAR_PRERENDER_CONTENTS | | 509 prerender::PrerenderManager::CLEAR_PRERENDER_CONTENTS | |
| 486 prerender::PrerenderManager::CLEAR_PRERENDER_HISTORY); | 510 prerender::PrerenderManager::CLEAR_PRERENDER_HISTORY); |
| 487 } | 511 } |
| 488 | 512 |
| 489 // If the caller is removing history for all hosts, then clear ancillary | 513 // If the caller is removing history for all hosts, then clear ancillary |
| 490 // historical information. | 514 // historical information. |
| 491 if (remove_url.is_empty()) { | 515 if (filter_builder.IsEmptyBlacklist()) { |
| 492 // We also delete the list of recently closed tabs. Since these expire, | 516 // We also delete the list of recently closed tabs. Since these expire, |
| 493 // they can't be more than a day old, so we can simply clear them all. | 517 // they can't be more than a day old, so we can simply clear them all. |
| 494 sessions::TabRestoreService* tab_service = | 518 sessions::TabRestoreService* tab_service = |
| 495 TabRestoreServiceFactory::GetForProfile(profile_); | 519 TabRestoreServiceFactory::GetForProfile(profile_); |
| 496 if (tab_service) { | 520 if (tab_service) { |
| 497 tab_service->ClearEntries(); | 521 tab_service->ClearEntries(); |
| 498 tab_service->DeleteLastSession(); | 522 tab_service->DeleteLastSession(); |
| 499 } | 523 } |
| 500 | 524 |
| 501 #if defined(ENABLE_SESSION_SERVICE) | 525 #if defined(ENABLE_SESSION_SERVICE) |
| 502 // We also delete the last session when we delete the history. | 526 // We also delete the last session when we delete the history. |
| 503 SessionService* session_service = | 527 SessionService* session_service = |
| 504 SessionServiceFactory::GetForProfile(profile_); | 528 SessionServiceFactory::GetForProfile(profile_); |
| 505 if (session_service) | 529 if (session_service) |
| 506 session_service->DeleteLastSession(); | 530 session_service->DeleteLastSession(); |
| 507 #endif | 531 #endif |
| 508 } | 532 } |
| 509 | 533 |
| 510 // The saved Autofill profiles and credit cards can include the origin from | 534 // The saved Autofill profiles and credit cards can include the origin from |
| 511 // which these profiles and credit cards were learned. These are a form of | 535 // which these profiles and credit cards were learned. These are a form of |
| 512 // history, so clear them as well. | 536 // history, so clear them as well. |
| 537 // TODO(dmurph): Support all backends with filter (crbug.com/113621). |
| 513 scoped_refptr<autofill::AutofillWebDataService> web_data_service = | 538 scoped_refptr<autofill::AutofillWebDataService> web_data_service = |
| 514 WebDataServiceFactory::GetAutofillWebDataForProfile( | 539 WebDataServiceFactory::GetAutofillWebDataForProfile( |
| 515 profile_, ServiceAccessType::EXPLICIT_ACCESS); | 540 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
| 516 if (web_data_service.get()) { | 541 if (web_data_service.get()) { |
| 517 waiting_for_clear_autofill_origin_urls_ = true; | 542 waiting_for_clear_autofill_origin_urls_ = true; |
| 518 web_data_service->RemoveOriginURLsModifiedBetween( | 543 web_data_service->RemoveOriginURLsModifiedBetween( |
| 519 delete_begin_, delete_end_); | 544 delete_begin_, delete_end_); |
| 520 // The above calls are done on the UI thread but do their work on the DB | 545 // The above calls are done on the UI thread but do their work on the DB |
| 521 // thread. So wait for it. | 546 // thread. So wait for it. |
| 522 BrowserThread::PostTaskAndReply( | 547 BrowserThread::PostTaskAndReply( |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 data_reduction_proxy_service->compression_stats() | 609 data_reduction_proxy_service->compression_stats() |
| 585 ->DeleteBrowsingHistory(delete_begin_, delete_end_); | 610 ->DeleteBrowsingHistory(delete_begin_, delete_end_); |
| 586 } | 611 } |
| 587 } | 612 } |
| 588 } | 613 } |
| 589 | 614 |
| 590 if ((remove_mask & REMOVE_DOWNLOADS) && may_delete_history) { | 615 if ((remove_mask & REMOVE_DOWNLOADS) && may_delete_history) { |
| 591 content::RecordAction(UserMetricsAction("ClearBrowsingData_Downloads")); | 616 content::RecordAction(UserMetricsAction("ClearBrowsingData_Downloads")); |
| 592 content::DownloadManager* download_manager = | 617 content::DownloadManager* download_manager = |
| 593 BrowserContext::GetDownloadManager(profile_); | 618 BrowserContext::GetDownloadManager(profile_); |
| 594 download_manager->RemoveDownloadsByURLAndTime( | 619 download_manager->RemoveDownloadsByURLAndTime(same_domain_filter, |
| 595 same_origin_filter, delete_begin_, delete_end_); | 620 delete_begin_, delete_end_); |
| 596 DownloadPrefs* download_prefs = DownloadPrefs::FromDownloadManager( | 621 DownloadPrefs* download_prefs = DownloadPrefs::FromDownloadManager( |
| 597 download_manager); | 622 download_manager); |
| 598 download_prefs->SetSaveFilePath(download_prefs->DownloadPath()); | 623 download_prefs->SetSaveFilePath(download_prefs->DownloadPath()); |
| 599 } | 624 } |
| 600 | 625 |
| 601 uint32_t storage_partition_remove_mask = 0; | 626 uint32_t storage_partition_remove_mask = 0; |
| 602 | 627 |
| 603 // We ignore the REMOVE_COOKIES request if UNPROTECTED_WEB is not set, | 628 // We ignore the REMOVE_COOKIES request if UNPROTECTED_WEB is not set, |
| 604 // so that callers who request REMOVE_SITE_DATA with PROTECTED_WEB | 629 // so that callers who request REMOVE_SITE_DATA with PROTECTED_WEB |
| 605 // don't accidentally remove the cookies that are associated with the | 630 // don't accidentally remove the cookies that are associated with the |
| (...skipping 10 matching lines...) Expand all Loading... |
| 616 // doesn't make sense to apply the time period of deleting in the last X | 641 // doesn't make sense to apply the time period of deleting in the last X |
| 617 // hours/days to the safebrowsing cookies since they aren't the result of | 642 // hours/days to the safebrowsing cookies since they aren't the result of |
| 618 // any user action. | 643 // any user action. |
| 619 if (delete_begin_ == base::Time()) { | 644 if (delete_begin_ == base::Time()) { |
| 620 safe_browsing::SafeBrowsingService* sb_service = | 645 safe_browsing::SafeBrowsingService* sb_service = |
| 621 g_browser_process->safe_browsing_service(); | 646 g_browser_process->safe_browsing_service(); |
| 622 if (sb_service) { | 647 if (sb_service) { |
| 623 scoped_refptr<net::URLRequestContextGetter> sb_context = | 648 scoped_refptr<net::URLRequestContextGetter> sb_context = |
| 624 sb_service->url_request_context(); | 649 sb_service->url_request_context(); |
| 625 ++waiting_for_clear_cookies_count_; | 650 ++waiting_for_clear_cookies_count_; |
| 626 BrowserThread::PostTask( | 651 if (filter_builder.IsEmptyBlacklist()) { |
| 627 BrowserThread::IO, FROM_HERE, | 652 BrowserThread::PostTask( |
| 628 base::Bind(&ClearCookiesOnIOThread, delete_begin_, delete_end_, | 653 BrowserThread::IO, FROM_HERE, |
| 629 base::RetainedRef(std::move(sb_context)), | 654 base::Bind(&ClearCookiesOnIOThread, delete_begin_, delete_end_, |
| 630 UIThreadTrampoline( | 655 base::RetainedRef(std::move(sb_context)), |
| 631 base::Bind(&BrowsingDataRemover::OnClearedCookies, | 656 UIThreadTrampoline( |
| 632 weak_ptr_factory_.GetWeakPtr())))); | 657 base::Bind(&BrowsingDataRemover::OnClearedCookies, |
| 658 weak_ptr_factory_.GetWeakPtr())))); |
| 659 } else { |
| 660 BrowserThread::PostTask( |
| 661 BrowserThread::IO, FROM_HERE, |
| 662 base::Bind(&ClearCookiesWithPredicateOnIOThread, delete_begin_, |
| 663 delete_end_, filter_builder.BuildDomainCookieFilter(), |
| 664 base::RetainedRef(std::move(sb_context)), |
| 665 UIThreadTrampoline( |
| 666 base::Bind(&BrowsingDataRemover::OnClearedCookies, |
| 667 weak_ptr_factory_.GetWeakPtr())))); |
| 668 } |
| 633 } | 669 } |
| 634 } | 670 } |
| 635 | 671 |
| 636 MediaDeviceIDSalt::Reset(profile_->GetPrefs()); | 672 MediaDeviceIDSalt::Reset(profile_->GetPrefs()); |
| 637 } | 673 } |
| 638 | 674 |
| 639 // Channel IDs are not separated for protected and unprotected web | 675 // Channel IDs are not separated for protected and unprotected web |
| 640 // origins. We check the origin_type_mask_ to prevent unintended deletion. | 676 // origins. We check the origin_type_mask_ to prevent unintended deletion. |
| 641 if (remove_mask & REMOVE_CHANNEL_IDS && | 677 if (remove_mask & REMOVE_CHANNEL_IDS && |
| 642 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { | 678 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 plugin_data_remover_->StartRemoving(delete_begin_); | 736 plugin_data_remover_->StartRemoving(delete_begin_); |
| 701 | 737 |
| 702 base::WaitableEventWatcher::EventCallback watcher_callback = | 738 base::WaitableEventWatcher::EventCallback watcher_callback = |
| 703 base::Bind(&BrowsingDataRemover::OnWaitableEventSignaled, | 739 base::Bind(&BrowsingDataRemover::OnWaitableEventSignaled, |
| 704 weak_ptr_factory_.GetWeakPtr()); | 740 weak_ptr_factory_.GetWeakPtr()); |
| 705 watcher_.StartWatching(event, watcher_callback); | 741 watcher_.StartWatching(event, watcher_callback); |
| 706 } | 742 } |
| 707 #endif | 743 #endif |
| 708 | 744 |
| 709 if (remove_mask & REMOVE_SITE_USAGE_DATA) { | 745 if (remove_mask & REMOVE_SITE_USAGE_DATA) { |
| 710 HostContentSettingsMapFactory::GetForProfile(profile_) | 746 ClearSettingsForOneTypeWithPredicate( |
| 711 ->ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT); | 747 HostContentSettingsMapFactory::GetForProfile(profile_), |
| 748 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, |
| 749 base::Bind(&ForwardPrimaryPatternCallback, same_pattern_filter)); |
| 712 } | 750 } |
| 713 | 751 |
| 714 if (remove_mask & REMOVE_SITE_USAGE_DATA || remove_mask & REMOVE_HISTORY) { | 752 if (remove_mask & REMOVE_SITE_USAGE_DATA || remove_mask & REMOVE_HISTORY) { |
| 715 HostContentSettingsMapFactory::GetForProfile(profile_) | 753 ClearSettingsForOneTypeWithPredicate( |
| 716 ->ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_APP_BANNER); | 754 HostContentSettingsMapFactory::GetForProfile(profile_), |
| 755 CONTENT_SETTINGS_TYPE_APP_BANNER, |
| 756 base::Bind(&ForwardPrimaryPatternCallback, same_pattern_filter)); |
| 717 } | 757 } |
| 718 | 758 |
| 719 if (remove_mask & REMOVE_PASSWORDS) { | 759 if (remove_mask & REMOVE_PASSWORDS) { |
| 720 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords")); | 760 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords")); |
| 721 password_manager::PasswordStore* password_store = | 761 password_manager::PasswordStore* password_store = |
| 722 PasswordStoreFactory::GetForProfile( | 762 PasswordStoreFactory::GetForProfile( |
| 723 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); | 763 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); |
| 724 | 764 |
| 725 if (password_store) { | 765 if (password_store) { |
| 726 waiting_for_clear_passwords_ = true; | 766 waiting_for_clear_passwords_ = true; |
| 727 auto on_cleared_passwords = | 767 auto on_cleared_passwords = |
| 728 base::Bind(&BrowsingDataRemover::OnClearedPasswords, | 768 base::Bind(&BrowsingDataRemover::OnClearedPasswords, |
| 729 weak_ptr_factory_.GetWeakPtr()); | 769 weak_ptr_factory_.GetWeakPtr()); |
| 730 password_store->RemoveLoginsByURLAndTime( | 770 password_store->RemoveLoginsByURLAndTime( |
| 731 same_origin_filter, delete_begin_, delete_end_, on_cleared_passwords); | 771 same_domain_filter, delete_begin_, delete_end_, on_cleared_passwords); |
| 732 } | 772 } |
| 733 } | 773 } |
| 734 | 774 |
| 735 if (remove_mask & REMOVE_COOKIES) { | 775 if (remove_mask & REMOVE_COOKIES) { |
| 736 password_manager::PasswordStore* password_store = | 776 password_manager::PasswordStore* password_store = |
| 737 PasswordStoreFactory::GetForProfile(profile_, | 777 PasswordStoreFactory::GetForProfile(profile_, |
| 738 ServiceAccessType::EXPLICIT_ACCESS) | 778 ServiceAccessType::EXPLICIT_ACCESS) |
| 739 .get(); | 779 .get(); |
| 740 | 780 |
| 741 if (password_store) { | 781 if (password_store) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 754 | 794 |
| 755 if (password_store) { | 795 if (password_store) { |
| 756 waiting_for_clear_passwords_stats_ = true; | 796 waiting_for_clear_passwords_stats_ = true; |
| 757 password_store->RemoveStatisticsCreatedBetween( | 797 password_store->RemoveStatisticsCreatedBetween( |
| 758 delete_begin_, delete_end_, | 798 delete_begin_, delete_end_, |
| 759 base::Bind(&BrowsingDataRemover::OnClearedPasswordsStats, | 799 base::Bind(&BrowsingDataRemover::OnClearedPasswordsStats, |
| 760 weak_ptr_factory_.GetWeakPtr())); | 800 weak_ptr_factory_.GetWeakPtr())); |
| 761 } | 801 } |
| 762 } | 802 } |
| 763 | 803 |
| 804 // TODO(dmurph): Support all backends with filter (crbug.com/113621). |
| 764 if (remove_mask & REMOVE_FORM_DATA) { | 805 if (remove_mask & REMOVE_FORM_DATA) { |
| 765 content::RecordAction(UserMetricsAction("ClearBrowsingData_Autofill")); | 806 content::RecordAction(UserMetricsAction("ClearBrowsingData_Autofill")); |
| 766 scoped_refptr<autofill::AutofillWebDataService> web_data_service = | 807 scoped_refptr<autofill::AutofillWebDataService> web_data_service = |
| 767 WebDataServiceFactory::GetAutofillWebDataForProfile( | 808 WebDataServiceFactory::GetAutofillWebDataForProfile( |
| 768 profile_, ServiceAccessType::EXPLICIT_ACCESS); | 809 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
| 769 | 810 |
| 770 if (web_data_service.get()) { | 811 if (web_data_service.get()) { |
| 771 waiting_for_clear_form_ = true; | 812 waiting_for_clear_form_ = true; |
| 772 web_data_service->RemoveFormElementsAddedBetween(delete_begin_, | 813 web_data_service->RemoveFormElementsAddedBetween(delete_begin_, |
| 773 delete_end_); | 814 delete_end_); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 | 898 |
| 858 if (delete_begin_ == base::Time() || | 899 if (delete_begin_ == base::Time() || |
| 859 origin_type_mask_ & | 900 origin_type_mask_ & |
| 860 (BrowsingDataHelper::PROTECTED_WEB | BrowsingDataHelper::EXTENSION)) { | 901 (BrowsingDataHelper::PROTECTED_WEB | BrowsingDataHelper::EXTENSION)) { |
| 861 // If we're deleting since the beginning of time, or we're removing | 902 // If we're deleting since the beginning of time, or we're removing |
| 862 // protected origins, then remove persistent quota data. | 903 // protected origins, then remove persistent quota data. |
| 863 quota_storage_remove_mask |= | 904 quota_storage_remove_mask |= |
| 864 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; | 905 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; |
| 865 } | 906 } |
| 866 | 907 |
| 908 content::StoragePartition::CookieMatcherFunction cookie_matcher; |
| 909 if (!filter_builder.IsEmptyBlacklist()) { |
| 910 cookie_matcher = filter_builder.BuildDomainCookieFilter(); |
| 911 } |
| 867 storage_partition->ClearData( | 912 storage_partition->ClearData( |
| 868 storage_partition_remove_mask, quota_storage_remove_mask, remove_url, | 913 storage_partition_remove_mask, quota_storage_remove_mask, |
| 869 base::Bind(&DoesOriginMatchMask, origin_type_mask_), delete_begin_, | 914 base::Bind(&DoesOriginMatchMaskAndUrls, origin_type_mask_, |
| 870 delete_end_, | 915 same_domain_filter), |
| 916 cookie_matcher, delete_begin_, delete_end_, |
| 871 base::Bind(&BrowsingDataRemover::OnClearedStoragePartitionData, | 917 base::Bind(&BrowsingDataRemover::OnClearedStoragePartitionData, |
| 872 weak_ptr_factory_.GetWeakPtr())); | 918 weak_ptr_factory_.GetWeakPtr())); |
| 873 } | 919 } |
| 874 | 920 |
| 875 #if defined(ENABLE_PLUGINS) | 921 #if defined(ENABLE_PLUGINS) |
| 876 if (remove_mask & REMOVE_CONTENT_LICENSES) { | 922 if (remove_mask & REMOVE_CONTENT_LICENSES) { |
| 877 content::RecordAction( | 923 content::RecordAction( |
| 878 UserMetricsAction("ClearBrowsingData_ContentLicenses")); | 924 UserMetricsAction("ClearBrowsingData_ContentLicenses")); |
| 879 | 925 |
| 880 waiting_for_clear_content_licenses_ = true; | 926 waiting_for_clear_content_licenses_ = true; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 waiting_for_clear_webapp_data_ = true; | 989 waiting_for_clear_webapp_data_ = true; |
| 944 webapp_registry_->UnregisterWebapps( | 990 webapp_registry_->UnregisterWebapps( |
| 945 base::Bind(&BrowsingDataRemover::OnClearedWebappData, | 991 base::Bind(&BrowsingDataRemover::OnClearedWebappData, |
| 946 weak_ptr_factory_.GetWeakPtr())); | 992 weak_ptr_factory_.GetWeakPtr())); |
| 947 } | 993 } |
| 948 | 994 |
| 949 if ((remove_mask & REMOVE_OFFLINE_PAGE_DATA) && | 995 if ((remove_mask & REMOVE_OFFLINE_PAGE_DATA) && |
| 950 offline_pages::IsOfflinePagesEnabled()) { | 996 offline_pages::IsOfflinePagesEnabled()) { |
| 951 waiting_for_clear_offline_page_data_ = true; | 997 waiting_for_clear_offline_page_data_ = true; |
| 952 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile_) | 998 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile_) |
| 953 ->ClearAll(base::Bind(&BrowsingDataRemover::OnClearedOfflinePageData, | 999 ->DeletePagesByURLPredicate( |
| 954 weak_ptr_factory_.GetWeakPtr())); | 1000 same_domain_filter, |
| 1001 base::Bind(&BrowsingDataRemover::OnClearedOfflinePageData, |
| 1002 weak_ptr_factory_.GetWeakPtr())); |
| 955 } | 1003 } |
| 956 #endif | 1004 #endif |
| 957 | 1005 |
| 958 // Record the combined deletion of cookies and cache. | 1006 // Record the combined deletion of cookies and cache. |
| 959 CookieOrCacheDeletionChoice choice = NEITHER_COOKIES_NOR_CACHE; | 1007 CookieOrCacheDeletionChoice choice = NEITHER_COOKIES_NOR_CACHE; |
| 960 if (remove_mask & REMOVE_COOKIES && | 1008 if (remove_mask & REMOVE_COOKIES && |
| 961 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { | 1009 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { |
| 962 choice = remove_mask & REMOVE_CACHE ? BOTH_COOKIES_AND_CACHE | 1010 choice = remove_mask & REMOVE_CACHE ? BOTH_COOKIES_AND_CACHE |
| 963 : ONLY_COOKIES; | 1011 : ONLY_COOKIES; |
| 964 } else if (remove_mask & REMOVE_CACHE) { | 1012 } else if (remove_mask & REMOVE_CACHE) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 983 storage_partition_for_testing_ = storage_partition; | 1031 storage_partition_for_testing_ = storage_partition; |
| 984 } | 1032 } |
| 985 | 1033 |
| 986 #if BUILDFLAG(ANDROID_JAVA_UI) | 1034 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 987 void BrowsingDataRemover::OverrideWebappRegistryForTesting( | 1035 void BrowsingDataRemover::OverrideWebappRegistryForTesting( |
| 988 scoped_ptr<WebappRegistry> webapp_registry) { | 1036 scoped_ptr<WebappRegistry> webapp_registry) { |
| 989 webapp_registry_.reset(webapp_registry.release()); | 1037 webapp_registry_.reset(webapp_registry.release()); |
| 990 } | 1038 } |
| 991 #endif | 1039 #endif |
| 992 | 1040 |
| 1041 void BrowsingDataRemover::ClearSettingsForOneTypeWithPredicate( |
| 1042 HostContentSettingsMap* content_settings_map, |
| 1043 ContentSettingsType content_type, |
| 1044 const base::Callback<bool(const ContentSettingsPattern& primary_pattern, |
| 1045 const ContentSettingsPattern& secondary_pattern)>& |
| 1046 predicate) { |
| 1047 ContentSettingsForOneType settings; |
| 1048 content_settings_map->GetSettingsForOneType(content_type, std::string(), |
| 1049 &settings); |
| 1050 for (const ContentSettingPatternSource& setting : settings) { |
| 1051 if (predicate.Run(setting.primary_pattern, setting.secondary_pattern)) { |
| 1052 content_settings_map->SetWebsiteSettingCustomScope( |
| 1053 setting.primary_pattern, setting.secondary_pattern, content_type, |
| 1054 std::string(), nullptr); |
| 1055 } |
| 1056 } |
| 1057 } |
| 1058 |
| 993 base::Time BrowsingDataRemover::CalculateBeginDeleteTime( | 1059 base::Time BrowsingDataRemover::CalculateBeginDeleteTime( |
| 994 TimePeriod time_period) { | 1060 TimePeriod time_period) { |
| 995 base::TimeDelta diff; | 1061 base::TimeDelta diff; |
| 996 base::Time delete_begin_time = base::Time::Now(); | 1062 base::Time delete_begin_time = base::Time::Now(); |
| 997 switch (time_period) { | 1063 switch (time_period) { |
| 998 case LAST_HOUR: | 1064 case LAST_HOUR: |
| 999 diff = base::TimeDelta::FromHours(1); | 1065 diff = base::TimeDelta::FromHours(1); |
| 1000 break; | 1066 break; |
| 1001 case LAST_DAY: | 1067 case LAST_DAY: |
| 1002 diff = base::TimeDelta::FromHours(24); | 1068 diff = base::TimeDelta::FromHours(24); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1229 waiting_for_clear_webapp_data_ = false; | 1295 waiting_for_clear_webapp_data_ = false; |
| 1230 NotifyIfDone(); | 1296 NotifyIfDone(); |
| 1231 } | 1297 } |
| 1232 | 1298 |
| 1233 void BrowsingDataRemover::OnClearedWebappHistory() { | 1299 void BrowsingDataRemover::OnClearedWebappHistory() { |
| 1234 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1300 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1235 waiting_for_clear_webapp_history_ = false; | 1301 waiting_for_clear_webapp_history_ = false; |
| 1236 NotifyIfDone(); | 1302 NotifyIfDone(); |
| 1237 } | 1303 } |
| 1238 | 1304 |
| 1239 void BrowsingDataRemover::OnClearedOfflinePageData() { | 1305 void BrowsingDataRemover::OnClearedOfflinePageData( |
| 1306 offline_pages::OfflinePageModel::DeletePageResult result) { |
| 1240 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1307 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1241 waiting_for_clear_offline_page_data_ = false; | 1308 waiting_for_clear_offline_page_data_ = false; |
| 1242 NotifyIfDone(); | 1309 NotifyIfDone(); |
| 1243 } | 1310 } |
| 1244 #endif | 1311 #endif |
| 1245 | 1312 |
| 1246 void BrowsingDataRemover::OnClearedDomainReliabilityMonitor() { | 1313 void BrowsingDataRemover::OnClearedDomainReliabilityMonitor() { |
| 1247 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1314 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1248 waiting_for_clear_domain_reliability_monitor_ = false; | 1315 waiting_for_clear_domain_reliability_monitor_ = false; |
| 1249 NotifyIfDone(); | 1316 NotifyIfDone(); |
| 1250 } | 1317 } |
| 1251 | 1318 |
| 1252 // static | 1319 // static |
| 1253 BrowsingDataRemover::CallbackSubscription | 1320 BrowsingDataRemover::CallbackSubscription |
| 1254 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( | 1321 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( |
| 1255 const BrowsingDataRemover::Callback& callback) { | 1322 const BrowsingDataRemover::Callback& callback) { |
| 1256 return GetOnBrowsingDataRemovedCallbacks()->Add(callback); | 1323 return GetOnBrowsingDataRemovedCallbacks()->Add(callback); |
| 1257 } | 1324 } |
| OLD | NEW |