| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ios/chrome/browser/browsing_data/ios_chrome_browsing_data_remover.h" | 5 #include "ios/chrome/browser/browsing_data/ios_chrome_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 20 matching lines...) Expand all Loading... |
| 31 #include "ios/chrome/browser/ios_chrome_io_thread.h" | 31 #include "ios/chrome/browser/ios_chrome_io_thread.h" |
| 32 #include "ios/chrome/browser/passwords/ios_chrome_password_store_factory.h" | 32 #include "ios/chrome/browser/passwords/ios_chrome_password_store_factory.h" |
| 33 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" | 33 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" |
| 34 #include "ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.h" | 34 #include "ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.h" |
| 35 #include "ios/chrome/browser/web_data_service_factory.h" | 35 #include "ios/chrome/browser/web_data_service_factory.h" |
| 36 #include "ios/net/http_cache_helper.h" | 36 #include "ios/net/http_cache_helper.h" |
| 37 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 37 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
| 38 #include "ios/web/public/user_metrics.h" | 38 #include "ios/web/public/user_metrics.h" |
| 39 #include "ios/web/public/web_thread.h" | 39 #include "ios/web/public/web_thread.h" |
| 40 #include "net/base/net_errors.h" | 40 #include "net/base/net_errors.h" |
| 41 #include "net/cookies/canonical_cookie.h" |
| 41 #include "net/cookies/cookie_store.h" | 42 #include "net/cookies/cookie_store.h" |
| 42 #include "net/http/transport_security_state.h" | 43 #include "net/http/transport_security_state.h" |
| 43 #include "net/ssl/channel_id_service.h" | 44 #include "net/ssl/channel_id_service.h" |
| 44 #include "net/ssl/channel_id_store.h" | 45 #include "net/ssl/channel_id_store.h" |
| 45 #include "net/url_request/url_request_context.h" | 46 #include "net/url_request/url_request_context.h" |
| 46 #include "net/url_request/url_request_context_getter.h" | 47 #include "net/url_request/url_request_context_getter.h" |
| 47 | 48 |
| 48 using base::UserMetricsAction; | 49 using base::UserMetricsAction; |
| 49 using web::WebThread; | 50 using web::WebThread; |
| 50 | 51 |
| 51 namespace { | 52 namespace { |
| 52 | 53 |
| 53 using CallbackList = base::CallbackList<void( | 54 using CallbackList = base::CallbackList<void( |
| 54 const IOSChromeBrowsingDataRemover::NotificationDetails&)>; | 55 const IOSChromeBrowsingDataRemover::NotificationDetails&)>; |
| 55 | 56 |
| 56 // Contains all registered callbacks for browsing data removed notifications. | 57 // Contains all registered callbacks for browsing data removed notifications. |
| 57 CallbackList* g_on_browsing_data_removed_callbacks = nullptr; | 58 CallbackList* g_on_browsing_data_removed_callbacks = nullptr; |
| 58 | 59 |
| 59 // Accessor for |*g_on_browsing_data_removed_callbacks|. Creates a new object | 60 // Accessor for |*g_on_browsing_data_removed_callbacks|. Creates a new object |
| 60 // the first time so that it always returns a valid object. | 61 // the first time so that it always returns a valid object. |
| 61 CallbackList* GetOnBrowsingDataRemovedCallbacks() { | 62 CallbackList* GetOnBrowsingDataRemovedCallbacks() { |
| 62 if (!g_on_browsing_data_removed_callbacks) | 63 if (!g_on_browsing_data_removed_callbacks) |
| 63 g_on_browsing_data_removed_callbacks = new CallbackList(); | 64 g_on_browsing_data_removed_callbacks = new CallbackList(); |
| 64 return g_on_browsing_data_removed_callbacks; | 65 return g_on_browsing_data_removed_callbacks; |
| 65 } | 66 } |
| 66 | 67 |
| 68 bool DoesCookieMatchHost(const std::string& host, |
| 69 const net::CanonicalCookie& cookie) { |
| 70 return cookie.IsHostCookie() && cookie.IsDomainMatch(host); |
| 71 } |
| 72 |
| 67 } // namespace | 73 } // namespace |
| 68 | 74 |
| 69 bool IOSChromeBrowsingDataRemover::is_removing_ = false; | 75 bool IOSChromeBrowsingDataRemover::is_removing_ = false; |
| 70 | 76 |
| 71 IOSChromeBrowsingDataRemover::NotificationDetails::NotificationDetails() | 77 IOSChromeBrowsingDataRemover::NotificationDetails::NotificationDetails() |
| 72 : removal_begin(base::Time()), removal_mask(-1) {} | 78 : removal_begin(base::Time()), removal_mask(-1) {} |
| 73 | 79 |
| 74 IOSChromeBrowsingDataRemover::NotificationDetails::NotificationDetails( | 80 IOSChromeBrowsingDataRemover::NotificationDetails::NotificationDetails( |
| 75 const IOSChromeBrowsingDataRemover::NotificationDetails& details) | 81 const IOSChromeBrowsingDataRemover::NotificationDetails& details) |
| 76 : removal_begin(details.removal_begin), | 82 : removal_begin(details.removal_begin), |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 const GURL& storage_url) { | 481 const GURL& storage_url) { |
| 476 DCHECK_CURRENTLY_ON(WebThread::IO); | 482 DCHECK_CURRENTLY_ON(WebThread::IO); |
| 477 net::CookieStore* cookie_store = | 483 net::CookieStore* cookie_store = |
| 478 rq_context->GetURLRequestContext()->cookie_store(); | 484 rq_context->GetURLRequestContext()->cookie_store(); |
| 479 if (storage_url.is_empty()) { | 485 if (storage_url.is_empty()) { |
| 480 cookie_store->DeleteAllCreatedBetweenAsync( | 486 cookie_store->DeleteAllCreatedBetweenAsync( |
| 481 delete_begin_, delete_end_, | 487 delete_begin_, delete_end_, |
| 482 base::Bind(&IOSChromeBrowsingDataRemover::OnClearedCookies, | 488 base::Bind(&IOSChromeBrowsingDataRemover::OnClearedCookies, |
| 483 base::Unretained(this))); | 489 base::Unretained(this))); |
| 484 } else { | 490 } else { |
| 485 cookie_store->DeleteAllCreatedBetweenForHostAsync( | 491 cookie_store->DeleteAllCreatedBetweenWithPredicateAsync( |
| 486 delete_begin_, delete_end_, storage_url, | 492 delete_begin_, delete_end_, |
| 493 base::Bind(&DoesCookieMatchHost, storage_url.host()), |
| 487 base::Bind(&IOSChromeBrowsingDataRemover::OnClearedCookies, | 494 base::Bind(&IOSChromeBrowsingDataRemover::OnClearedCookies, |
| 488 base::Unretained(this))); | 495 base::Unretained(this))); |
| 489 } | 496 } |
| 490 } | 497 } |
| 491 | 498 |
| 492 void IOSChromeBrowsingDataRemover::ClearChannelIDsOnIOThread( | 499 void IOSChromeBrowsingDataRemover::ClearChannelIDsOnIOThread( |
| 493 const scoped_refptr<net::URLRequestContextGetter>& rq_context) { | 500 const scoped_refptr<net::URLRequestContextGetter>& rq_context) { |
| 494 DCHECK_CURRENTLY_ON(WebThread::IO); | 501 DCHECK_CURRENTLY_ON(WebThread::IO); |
| 495 net::ChannelIDService* channel_id_service = | 502 net::ChannelIDService* channel_id_service = |
| 496 rq_context->GetURLRequestContext()->channel_id_service(); | 503 rq_context->GetURLRequestContext()->channel_id_service(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 waiting_for_clear_autofill_origin_urls_ = false; | 539 waiting_for_clear_autofill_origin_urls_ = false; |
| 533 NotifyAndDeleteIfDone(); | 540 NotifyAndDeleteIfDone(); |
| 534 } | 541 } |
| 535 | 542 |
| 536 // static | 543 // static |
| 537 IOSChromeBrowsingDataRemover::CallbackSubscription | 544 IOSChromeBrowsingDataRemover::CallbackSubscription |
| 538 IOSChromeBrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( | 545 IOSChromeBrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( |
| 539 const IOSChromeBrowsingDataRemover::Callback& callback) { | 546 const IOSChromeBrowsingDataRemover::Callback& callback) { |
| 540 return GetOnBrowsingDataRemovedCallbacks()->Add(callback); | 547 return GetOnBrowsingDataRemovedCallbacks()->Add(callback); |
| 541 } | 548 } |
| OLD | NEW |