| 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 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 #include "content/public/browser/user_metrics.h" | 68 #include "content/public/browser/user_metrics.h" |
| 69 #include "net/base/net_errors.h" | 69 #include "net/base/net_errors.h" |
| 70 #include "net/cookies/cookie_store.h" | 70 #include "net/cookies/cookie_store.h" |
| 71 #include "net/http/transport_security_state.h" | 71 #include "net/http/transport_security_state.h" |
| 72 #include "net/ssl/channel_id_service.h" | 72 #include "net/ssl/channel_id_service.h" |
| 73 #include "net/ssl/channel_id_store.h" | 73 #include "net/ssl/channel_id_store.h" |
| 74 #include "net/url_request/url_request_context.h" | 74 #include "net/url_request/url_request_context.h" |
| 75 #include "net/url_request/url_request_context_getter.h" | 75 #include "net/url_request/url_request_context_getter.h" |
| 76 #include "storage/browser/quota/special_storage_policy.h" | 76 #include "storage/browser/quota/special_storage_policy.h" |
| 77 #include "url/origin.h" | 77 #include "url/origin.h" |
| 78 #include "url/origin_filter.h" |
| 78 | 79 |
| 79 #if BUILDFLAG(ANDROID_JAVA_UI) | 80 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 80 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 81 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
| 81 #include "chrome/browser/android/webapps/webapp_registry.h" | 82 #include "chrome/browser/android/webapps/webapp_registry.h" |
| 82 #include "chrome/browser/precache/precache_manager_factory.h" | 83 #include "chrome/browser/precache/precache_manager_factory.h" |
| 83 #include "components/offline_pages/offline_page_feature.h" | 84 #include "components/offline_pages/offline_page_feature.h" |
| 84 #include "components/offline_pages/offline_page_model.h" | 85 #include "components/offline_pages/offline_page_model.h" |
| 85 #include "components/precache/content/precache_manager.h" | 86 #include "components/precache/content/precache_manager.h" |
| 86 #endif | 87 #endif |
| 87 | 88 |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 | 337 |
| 337 // crbug.com/140910: Many places were calling this with base::Time() as | 338 // crbug.com/140910: Many places were calling this with base::Time() as |
| 338 // delete_end, even though they should've used base::Time::Max(). | 339 // delete_end, even though they should've used base::Time::Max(). |
| 339 DCHECK_NE(base::Time(), time_range.end); | 340 DCHECK_NE(base::Time(), time_range.end); |
| 340 | 341 |
| 341 SetRemoving(true); | 342 SetRemoving(true); |
| 342 delete_begin_ = time_range.begin; | 343 delete_begin_ = time_range.begin; |
| 343 delete_end_ = time_range.end; | 344 delete_end_ = time_range.end; |
| 344 remove_mask_ = remove_mask; | 345 remove_mask_ = remove_mask; |
| 345 origin_type_mask_ = origin_type_mask; | 346 origin_type_mask_ = origin_type_mask; |
| 346 url::Origin remove_origin(remove_url); | 347 |
| 348 scoped_ptr<url::OriginFilter> filter = url::OriginFilter::Empty(); |
| 349 if (!remove_url.is_empty()) { |
| 350 // Make sure that only URLs representing origins, with no extra components, |
| 351 // are passed to this class. |
| 352 DCHECK_EQ(remove_url, remove_url.GetOrigin()); |
| 353 |
| 354 std::vector<url::Origin> whitelist; |
| 355 whitelist.push_back(url::Origin(remove_url)); |
| 356 filter = url::OriginFilter::AsWhitelist(whitelist); |
| 357 } |
| 347 | 358 |
| 348 PrefService* prefs = profile_->GetPrefs(); | 359 PrefService* prefs = profile_->GetPrefs(); |
| 349 bool may_delete_history = prefs->GetBoolean( | 360 bool may_delete_history = prefs->GetBoolean( |
| 350 prefs::kAllowDeletingBrowserHistory); | 361 prefs::kAllowDeletingBrowserHistory); |
| 351 | 362 |
| 352 // All the UI entry points into the BrowsingDataRemover should be disabled, | 363 // All the UI entry points into the BrowsingDataRemover should be disabled, |
| 353 // but this will fire if something was missed or added. | 364 // but this will fire if something was missed or added. |
| 354 DCHECK(may_delete_history || (remove_mask & REMOVE_NOCHECKS) || | 365 DCHECK(may_delete_history || (remove_mask & REMOVE_NOCHECKS) || |
| 355 (!(remove_mask & REMOVE_HISTORY) && !(remove_mask & REMOVE_DOWNLOADS))); | 366 (!(remove_mask & REMOVE_HISTORY) && !(remove_mask & REMOVE_DOWNLOADS))); |
| 356 | 367 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 372 BrowsingDataHelper::ALL == (BrowsingDataHelper::UNPROTECTED_WEB | | 383 BrowsingDataHelper::ALL == (BrowsingDataHelper::UNPROTECTED_WEB | |
| 373 BrowsingDataHelper::PROTECTED_WEB | | 384 BrowsingDataHelper::PROTECTED_WEB | |
| 374 BrowsingDataHelper::EXTENSION), | 385 BrowsingDataHelper::EXTENSION), |
| 375 "OriginTypeMask has been updated without updating user metrics"); | 386 "OriginTypeMask has been updated without updating user metrics"); |
| 376 | 387 |
| 377 if ((remove_mask & REMOVE_HISTORY) && may_delete_history) { | 388 if ((remove_mask & REMOVE_HISTORY) && may_delete_history) { |
| 378 history::HistoryService* history_service = | 389 history::HistoryService* history_service = |
| 379 HistoryServiceFactory::GetForProfile( | 390 HistoryServiceFactory::GetForProfile( |
| 380 profile_, ServiceAccessType::EXPLICIT_ACCESS); | 391 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
| 381 if (history_service) { | 392 if (history_service) { |
| 393 // Selective history deletion is currently done through HistoryUI -> |
| 394 // HistoryBackend -> HistoryService, and that is for individual URLs, |
| 395 // not origins. The code below is currently unused, as the only callsite |
| 396 // supplying |remove_url| is the unittest. |
| 397 // TODO(msramek): Investigate whether history deletion, especially in the |
| 398 // case of web history, understands an origin parameter as the deletion |
| 399 // of all URLs from that origin, or just the URL with empty path. |
| 400 // TODO(msramek): Replace |remove_url| with OriginFilter. |
| 382 std::set<GURL> restrict_urls; | 401 std::set<GURL> restrict_urls; |
| 383 if (!remove_url.is_empty()) | 402 if (!remove_url.is_empty()) |
| 384 restrict_urls.insert(remove_url); | 403 restrict_urls.insert(remove_url); |
| 385 content::RecordAction(UserMetricsAction("ClearBrowsingData_History")); | 404 content::RecordAction(UserMetricsAction("ClearBrowsingData_History")); |
| 386 waiting_for_clear_history_ = true; | 405 waiting_for_clear_history_ = true; |
| 387 | 406 |
| 388 history_service->ExpireLocalAndRemoteHistoryBetween( | 407 history_service->ExpireLocalAndRemoteHistoryBetween( |
| 389 WebHistoryServiceFactory::GetForProfile(profile_), restrict_urls, | 408 WebHistoryServiceFactory::GetForProfile(profile_), restrict_urls, |
| 390 delete_begin_, delete_end_, | 409 delete_begin_, delete_end_, |
| 391 base::Bind(&BrowsingDataRemover::OnHistoryDeletionDone, | 410 base::Bind(&BrowsingDataRemover::OnHistoryDeletionDone, |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 data_reduction_proxy_service->compression_stats() | 571 data_reduction_proxy_service->compression_stats() |
| 553 ->DeleteBrowsingHistory(delete_begin_, delete_end_); | 572 ->DeleteBrowsingHistory(delete_begin_, delete_end_); |
| 554 } | 573 } |
| 555 } | 574 } |
| 556 } | 575 } |
| 557 | 576 |
| 558 if ((remove_mask & REMOVE_DOWNLOADS) && may_delete_history) { | 577 if ((remove_mask & REMOVE_DOWNLOADS) && may_delete_history) { |
| 559 content::RecordAction(UserMetricsAction("ClearBrowsingData_Downloads")); | 578 content::RecordAction(UserMetricsAction("ClearBrowsingData_Downloads")); |
| 560 content::DownloadManager* download_manager = | 579 content::DownloadManager* download_manager = |
| 561 BrowserContext::GetDownloadManager(profile_); | 580 BrowserContext::GetDownloadManager(profile_); |
| 562 if (remove_origin.unique()) | 581 download_manager->RemoveDownloadsByOriginAndTime( |
| 563 download_manager->RemoveDownloadsBetween(delete_begin_, delete_end_); | 582 filter.get(), delete_begin_, delete_end_); |
| 564 else | |
| 565 download_manager->RemoveDownloadsByOriginAndTime( | |
| 566 remove_origin, delete_begin_, delete_end_); | |
| 567 DownloadPrefs* download_prefs = DownloadPrefs::FromDownloadManager( | 583 DownloadPrefs* download_prefs = DownloadPrefs::FromDownloadManager( |
| 568 download_manager); | 584 download_manager); |
| 569 download_prefs->SetSaveFilePath(download_prefs->DownloadPath()); | 585 download_prefs->SetSaveFilePath(download_prefs->DownloadPath()); |
| 570 } | 586 } |
| 571 | 587 |
| 572 uint32_t storage_partition_remove_mask = 0; | 588 uint32_t storage_partition_remove_mask = 0; |
| 573 | 589 |
| 574 // We ignore the REMOVE_COOKIES request if UNPROTECTED_WEB is not set, | 590 // We ignore the REMOVE_COOKIES request if UNPROTECTED_WEB is not set, |
| 575 // so that callers who request REMOVE_SITE_DATA with PROTECTED_WEB | 591 // so that callers who request REMOVE_SITE_DATA with PROTECTED_WEB |
| 576 // don't accidentally remove the cookies that are associated with the | 592 // don't accidentally remove the cookies that are associated with the |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 waiting_for_clear_domain_reliability_monitor_ = false; | 1204 waiting_for_clear_domain_reliability_monitor_ = false; |
| 1189 NotifyIfDone(); | 1205 NotifyIfDone(); |
| 1190 } | 1206 } |
| 1191 | 1207 |
| 1192 // static | 1208 // static |
| 1193 BrowsingDataRemover::CallbackSubscription | 1209 BrowsingDataRemover::CallbackSubscription |
| 1194 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( | 1210 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( |
| 1195 const BrowsingDataRemover::Callback& callback) { | 1211 const BrowsingDataRemover::Callback& callback) { |
| 1196 return GetOnBrowsingDataRemovedCallbacks()->Add(callback); | 1212 return GetOnBrowsingDataRemovedCallbacks()->Add(callback); |
| 1197 } | 1213 } |
| OLD | NEW |