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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 DCHECK(AllDone()); | 125 DCHECK(AllDone()); |
120 } | 126 } |
121 | 127 |
122 // Static. | 128 // Static. |
123 void IOSChromeBrowsingDataRemover::set_removing(bool is_removing) { | 129 void IOSChromeBrowsingDataRemover::set_removing(bool is_removing) { |
124 DCHECK(is_removing_ != is_removing); | 130 DCHECK(is_removing_ != is_removing); |
125 is_removing_ = is_removing; | 131 is_removing_ = is_removing; |
126 } | 132 } |
127 | 133 |
128 void IOSChromeBrowsingDataRemover::Remove(int remove_mask) { | 134 void IOSChromeBrowsingDataRemover::Remove(int remove_mask) { |
129 RemoveImpl(remove_mask, GURL()); | 135 RemoveImpl(remove_mask, GURL()); |
droger
2016/04/05 12:24:27
It seems that the only call to RemoveImpl is here,
dmurph
2016/04/05 18:35:19
Done.
| |
130 } | 136 } |
131 | 137 |
132 void IOSChromeBrowsingDataRemover::RemoveImpl(int remove_mask, | 138 void IOSChromeBrowsingDataRemover::RemoveImpl(int remove_mask, |
133 const GURL& remove_url) { | 139 const GURL& remove_url) { |
134 DCHECK_CURRENTLY_ON(WebThread::UI); | 140 DCHECK_CURRENTLY_ON(WebThread::UI); |
135 set_removing(true); | 141 set_removing(true); |
136 remove_mask_ = remove_mask; | 142 remove_mask_ = remove_mask; |
137 | 143 |
138 // On other platforms, it is possible to specify different types of origins | 144 // On other platforms, it is possible to specify different types of origins |
139 // to clear data for (e.g., unprotected web vs. extensions). On iOS, this | 145 // to clear data for (e.g., unprotected web vs. extensions). On iOS, this |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
465 return; | 471 return; |
466 } | 472 } |
467 | 473 |
468 DCHECK_GT(waiting_for_clear_cookies_count_, 0); | 474 DCHECK_GT(waiting_for_clear_cookies_count_, 0); |
469 --waiting_for_clear_cookies_count_; | 475 --waiting_for_clear_cookies_count_; |
470 NotifyAndDeleteIfDone(); | 476 NotifyAndDeleteIfDone(); |
471 } | 477 } |
472 | 478 |
473 void IOSChromeBrowsingDataRemover::ClearCookiesOnIOThread( | 479 void IOSChromeBrowsingDataRemover::ClearCookiesOnIOThread( |
474 const scoped_refptr<net::URLRequestContextGetter>& rq_context, | 480 const scoped_refptr<net::URLRequestContextGetter>& rq_context, |
475 const GURL& storage_url) { | 481 const GURL& storage_url) { |
droger
2016/04/05 12:24:27
storage_url is always empty (see comment above).
Y
dmurph
2016/04/05 18:35:20
Done.
| |
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 |