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_remover.h" | 5 #include "chrome/browser/browsing_data_remover.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 delete_begin_(delete_begin), | 97 delete_begin_(delete_begin), |
98 delete_end_(delete_end), | 98 delete_end_(delete_end), |
99 next_cache_state_(STATE_NONE), | 99 next_cache_state_(STATE_NONE), |
100 cache_(NULL), | 100 cache_(NULL), |
101 main_context_getter_(profile->GetRequestContext()), | 101 main_context_getter_(profile->GetRequestContext()), |
102 media_context_getter_(profile->GetRequestContextForMedia()), | 102 media_context_getter_(profile->GetRequestContextForMedia()), |
103 waiting_for_clear_cache_(false), | 103 waiting_for_clear_cache_(false), |
104 waiting_for_clear_cookies_count_(0), | 104 waiting_for_clear_cookies_count_(0), |
105 waiting_for_clear_history_(false), | 105 waiting_for_clear_history_(false), |
106 waiting_for_clear_networking_history_(false), | 106 waiting_for_clear_networking_history_(false), |
107 waiting_for_clear_origin_bound_certs_(false), | 107 waiting_for_clear_server_bound_certs_(false), |
108 waiting_for_clear_plugin_data_(false), | 108 waiting_for_clear_plugin_data_(false), |
109 waiting_for_clear_quota_managed_data_(false), | 109 waiting_for_clear_quota_managed_data_(false), |
110 remove_mask_(0), | 110 remove_mask_(0), |
111 remove_origin_(GURL()), | 111 remove_origin_(GURL()), |
112 remove_protected_(false) { | 112 remove_protected_(false) { |
113 DCHECK(profile); | 113 DCHECK(profile); |
114 } | 114 } |
115 | 115 |
116 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, | 116 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, |
117 TimePeriod time_period, | 117 TimePeriod time_period, |
118 base::Time delete_end) | 118 base::Time delete_end) |
119 : profile_(profile), | 119 : profile_(profile), |
120 quota_manager_(NULL), | 120 quota_manager_(NULL), |
121 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), | 121 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), |
122 delete_begin_(CalculateBeginDeleteTime(time_period)), | 122 delete_begin_(CalculateBeginDeleteTime(time_period)), |
123 delete_end_(delete_end), | 123 delete_end_(delete_end), |
124 next_cache_state_(STATE_NONE), | 124 next_cache_state_(STATE_NONE), |
125 cache_(NULL), | 125 cache_(NULL), |
126 main_context_getter_(profile->GetRequestContext()), | 126 main_context_getter_(profile->GetRequestContext()), |
127 media_context_getter_(profile->GetRequestContextForMedia()), | 127 media_context_getter_(profile->GetRequestContextForMedia()), |
128 waiting_for_clear_cache_(false), | 128 waiting_for_clear_cache_(false), |
129 waiting_for_clear_cookies_count_(0), | 129 waiting_for_clear_cookies_count_(0), |
130 waiting_for_clear_history_(false), | 130 waiting_for_clear_history_(false), |
131 waiting_for_clear_networking_history_(false), | 131 waiting_for_clear_networking_history_(false), |
132 waiting_for_clear_origin_bound_certs_(false), | 132 waiting_for_clear_server_bound_certs_(false), |
133 waiting_for_clear_plugin_data_(false), | 133 waiting_for_clear_plugin_data_(false), |
134 waiting_for_clear_quota_managed_data_(false), | 134 waiting_for_clear_quota_managed_data_(false), |
135 remove_mask_(0), | 135 remove_mask_(0), |
136 remove_origin_(GURL()), | 136 remove_origin_(GURL()), |
137 remove_protected_(false) { | 137 remove_protected_(false) { |
138 DCHECK(profile); | 138 DCHECK(profile); |
139 } | 139 } |
140 | 140 |
141 BrowsingDataRemover::~BrowsingDataRemover() { | 141 BrowsingDataRemover::~BrowsingDataRemover() { |
142 DCHECK(all_done()); | 142 DCHECK(all_done()); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 ++waiting_for_clear_cookies_count_; | 281 ++waiting_for_clear_cookies_count_; |
282 BrowserThread::PostTask( | 282 BrowserThread::PostTask( |
283 BrowserThread::IO, FROM_HERE, | 283 BrowserThread::IO, FROM_HERE, |
284 base::Bind(&BrowsingDataRemover::ClearCookiesOnIOThread, | 284 base::Bind(&BrowsingDataRemover::ClearCookiesOnIOThread, |
285 base::Unretained(this), base::Unretained(sb_context))); | 285 base::Unretained(this), base::Unretained(sb_context))); |
286 } | 286 } |
287 } | 287 } |
288 #endif | 288 #endif |
289 } | 289 } |
290 | 290 |
291 if (remove_mask & REMOVE_ORIGIN_BOUND_CERTS) { | 291 if (remove_mask & REMOVE_SERVER_BOUND_CERTS) { |
292 content::RecordAction( | 292 content::RecordAction( |
293 UserMetricsAction("ClearBrowsingData_OriginBoundCerts")); | 293 UserMetricsAction("ClearBrowsingData_ServerBoundCerts")); |
294 // Since we are running on the UI thread don't call GetURLRequestContext(). | 294 // Since we are running on the UI thread don't call GetURLRequestContext(). |
295 net::URLRequestContextGetter* rq_context = profile_->GetRequestContext(); | 295 net::URLRequestContextGetter* rq_context = profile_->GetRequestContext(); |
296 if (rq_context) { | 296 if (rq_context) { |
297 waiting_for_clear_origin_bound_certs_ = true; | 297 waiting_for_clear_server_bound_certs_ = true; |
298 BrowserThread::PostTask( | 298 BrowserThread::PostTask( |
299 BrowserThread::IO, FROM_HERE, | 299 BrowserThread::IO, FROM_HERE, |
300 base::Bind(&BrowsingDataRemover::ClearOriginBoundCertsOnIOThread, | 300 base::Bind(&BrowsingDataRemover::ClearServerBoundCertsOnIOThread, |
301 base::Unretained(this), base::Unretained(rq_context))); | 301 base::Unretained(this), base::Unretained(rq_context))); |
302 } | 302 } |
303 } | 303 } |
304 | 304 |
305 if (remove_mask & REMOVE_LOCAL_STORAGE) { | 305 if (remove_mask & REMOVE_LOCAL_STORAGE) { |
306 DOMStorageContext* context = BrowserContext::GetDOMStorageContext(profile_); | 306 DOMStorageContext* context = BrowserContext::GetDOMStorageContext(profile_); |
307 context->task_runner()->PostTask( | 307 context->task_runner()->PostTask( |
308 FROM_HERE, | 308 FROM_HERE, |
309 base::Bind(&BrowsingDataRemover::ClearDOMStorageInSequencedTask, | 309 base::Bind(&BrowsingDataRemover::ClearDOMStorageInSequencedTask, |
310 base::Unretained(this), make_scoped_refptr(context))); | 310 base::Unretained(this), make_scoped_refptr(context))); |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 net::URLRequestContextGetter* rq_context) { | 695 net::URLRequestContextGetter* rq_context) { |
696 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 696 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
697 net::CookieStore* cookie_store = rq_context-> | 697 net::CookieStore* cookie_store = rq_context-> |
698 GetURLRequestContext()->cookie_store(); | 698 GetURLRequestContext()->cookie_store(); |
699 cookie_store->DeleteAllCreatedBetweenAsync( | 699 cookie_store->DeleteAllCreatedBetweenAsync( |
700 delete_begin_, delete_end_, | 700 delete_begin_, delete_end_, |
701 base::Bind(&BrowsingDataRemover::OnClearedCookies, | 701 base::Bind(&BrowsingDataRemover::OnClearedCookies, |
702 base::Unretained(this))); | 702 base::Unretained(this))); |
703 } | 703 } |
704 | 704 |
705 void BrowsingDataRemover::ClearOriginBoundCertsOnIOThread( | 705 void BrowsingDataRemover::ClearServerBoundCertsOnIOThread( |
706 net::URLRequestContextGetter* rq_context) { | 706 net::URLRequestContextGetter* rq_context) { |
707 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 707 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
708 net::OriginBoundCertService* origin_bound_cert_service = | 708 net::ServerBoundCertService* server_bound_cert_service = |
709 rq_context->GetURLRequestContext()->origin_bound_cert_service(); | 709 rq_context->GetURLRequestContext()->server_bound_cert_service(); |
710 origin_bound_cert_service->GetCertStore()->DeleteAllCreatedBetween( | 710 server_bound_cert_service->GetCertStore()->DeleteAllCreatedBetween( |
711 delete_begin_, delete_end_); | 711 delete_begin_, delete_end_); |
712 BrowserThread::PostTask( | 712 BrowserThread::PostTask( |
713 BrowserThread::UI, FROM_HERE, | 713 BrowserThread::UI, FROM_HERE, |
714 base::Bind(&BrowsingDataRemover::OnClearedOriginBoundCerts, | 714 base::Bind(&BrowsingDataRemover::OnClearedServerBoundCerts, |
715 base::Unretained(this))); | 715 base::Unretained(this))); |
716 } | 716 } |
717 | 717 |
718 void BrowsingDataRemover::OnClearedOriginBoundCerts() { | 718 void BrowsingDataRemover::OnClearedServerBoundCerts() { |
719 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 719 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
720 waiting_for_clear_origin_bound_certs_ = false; | 720 waiting_for_clear_server_bound_certs_ = false; |
721 NotifyAndDeleteIfDone(); | 721 NotifyAndDeleteIfDone(); |
722 } | 722 } |
OLD | NEW |