Chromium Code Reviews| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 delete_begin_(delete_begin), | 96 delete_begin_(delete_begin), |
| 97 delete_end_(delete_end), | 97 delete_end_(delete_end), |
| 98 next_cache_state_(STATE_NONE), | 98 next_cache_state_(STATE_NONE), |
| 99 cache_(NULL), | 99 cache_(NULL), |
| 100 main_context_getter_(profile->GetRequestContext()), | 100 main_context_getter_(profile->GetRequestContext()), |
| 101 media_context_getter_(profile->GetRequestContextForMedia()), | 101 media_context_getter_(profile->GetRequestContextForMedia()), |
| 102 waiting_for_clear_cache_(false), | 102 waiting_for_clear_cache_(false), |
| 103 waiting_for_clear_cookies_count_(0), | 103 waiting_for_clear_cookies_count_(0), |
| 104 waiting_for_clear_history_(false), | 104 waiting_for_clear_history_(false), |
| 105 waiting_for_clear_networking_history_(false), | 105 waiting_for_clear_networking_history_(false), |
| 106 waiting_for_clear_origin_bound_certs_(false), | 106 waiting_for_clear_domain_bound_certs_(false), |
| 107 waiting_for_clear_plugin_data_(false), | 107 waiting_for_clear_plugin_data_(false), |
| 108 waiting_for_clear_quota_managed_data_(false), | 108 waiting_for_clear_quota_managed_data_(false), |
| 109 remove_mask_(0), | 109 remove_mask_(0), |
| 110 remove_origin_(GURL()), | 110 remove_origin_(GURL()), |
| 111 remove_protected_(false) { | 111 remove_protected_(false) { |
| 112 DCHECK(profile); | 112 DCHECK(profile); |
| 113 } | 113 } |
| 114 | 114 |
| 115 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, | 115 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, |
| 116 TimePeriod time_period, | 116 TimePeriod time_period, |
| 117 base::Time delete_end) | 117 base::Time delete_end) |
| 118 : profile_(profile), | 118 : profile_(profile), |
| 119 quota_manager_(NULL), | 119 quota_manager_(NULL), |
| 120 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), | 120 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), |
| 121 delete_begin_(CalculateBeginDeleteTime(time_period)), | 121 delete_begin_(CalculateBeginDeleteTime(time_period)), |
| 122 delete_end_(delete_end), | 122 delete_end_(delete_end), |
| 123 next_cache_state_(STATE_NONE), | 123 next_cache_state_(STATE_NONE), |
| 124 cache_(NULL), | 124 cache_(NULL), |
| 125 main_context_getter_(profile->GetRequestContext()), | 125 main_context_getter_(profile->GetRequestContext()), |
| 126 media_context_getter_(profile->GetRequestContextForMedia()), | 126 media_context_getter_(profile->GetRequestContextForMedia()), |
| 127 waiting_for_clear_cache_(false), | 127 waiting_for_clear_cache_(false), |
| 128 waiting_for_clear_cookies_count_(0), | 128 waiting_for_clear_cookies_count_(0), |
| 129 waiting_for_clear_history_(false), | 129 waiting_for_clear_history_(false), |
| 130 waiting_for_clear_networking_history_(false), | 130 waiting_for_clear_networking_history_(false), |
| 131 waiting_for_clear_origin_bound_certs_(false), | 131 waiting_for_clear_domain_bound_certs_(false), |
| 132 waiting_for_clear_plugin_data_(false), | 132 waiting_for_clear_plugin_data_(false), |
| 133 waiting_for_clear_quota_managed_data_(false), | 133 waiting_for_clear_quota_managed_data_(false), |
| 134 remove_mask_(0), | 134 remove_mask_(0), |
| 135 remove_origin_(GURL()), | 135 remove_origin_(GURL()), |
| 136 remove_protected_(false) { | 136 remove_protected_(false) { |
| 137 DCHECK(profile); | 137 DCHECK(profile); |
| 138 } | 138 } |
| 139 | 139 |
| 140 BrowsingDataRemover::~BrowsingDataRemover() { | 140 BrowsingDataRemover::~BrowsingDataRemover() { |
| 141 DCHECK(all_done()); | 141 DCHECK(all_done()); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 280 ++waiting_for_clear_cookies_count_; | 280 ++waiting_for_clear_cookies_count_; |
| 281 BrowserThread::PostTask( | 281 BrowserThread::PostTask( |
| 282 BrowserThread::IO, FROM_HERE, | 282 BrowserThread::IO, FROM_HERE, |
| 283 base::Bind(&BrowsingDataRemover::ClearCookiesOnIOThread, | 283 base::Bind(&BrowsingDataRemover::ClearCookiesOnIOThread, |
| 284 base::Unretained(this), base::Unretained(sb_context))); | 284 base::Unretained(this), base::Unretained(sb_context))); |
| 285 } | 285 } |
| 286 } | 286 } |
| 287 #endif | 287 #endif |
| 288 } | 288 } |
| 289 | 289 |
| 290 if (remove_mask & REMOVE_ORIGIN_BOUND_CERTS) { | 290 if (remove_mask & REMOVE_DOMAIN_BOUND_CERTS) { |
| 291 content::RecordAction( | 291 content::RecordAction( |
| 292 UserMetricsAction("ClearBrowsingData_OriginBoundCerts")); | 292 UserMetricsAction("ClearBrowsingData_DomainBoundCerts")); |
| 293 // Since we are running on the UI thread don't call GetURLRequestContext(). | 293 // Since we are running on the UI thread don't call GetURLRequestContext(). |
| 294 net::URLRequestContextGetter* rq_context = profile_->GetRequestContext(); | 294 net::URLRequestContextGetter* rq_context = profile_->GetRequestContext(); |
| 295 if (rq_context) { | 295 if (rq_context) { |
| 296 waiting_for_clear_origin_bound_certs_ = true; | 296 waiting_for_clear_domain_bound_certs_ = true; |
| 297 BrowserThread::PostTask( | 297 BrowserThread::PostTask( |
| 298 BrowserThread::IO, FROM_HERE, | 298 BrowserThread::IO, FROM_HERE, |
| 299 base::Bind(&BrowsingDataRemover::ClearOriginBoundCertsOnIOThread, | 299 base::Bind(&BrowsingDataRemover::ClearDomainBoundCertsOnIOThread, |
| 300 base::Unretained(this), base::Unretained(rq_context))); | 300 base::Unretained(this), base::Unretained(rq_context))); |
| 301 } | 301 } |
| 302 } | 302 } |
| 303 | 303 |
| 304 if (remove_mask & REMOVE_LOCAL_STORAGE && | 304 if (remove_mask & REMOVE_LOCAL_STORAGE && |
| 305 BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) { | 305 BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) { |
| 306 DOMStorageContext* context = BrowserContext::GetDOMStorageContext(profile_); | 306 DOMStorageContext* context = BrowserContext::GetDOMStorageContext(profile_); |
| 307 BrowserThread::PostTask( | 307 BrowserThread::PostTask( |
| 308 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, | 308 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, |
| 309 base::Bind(&BrowsingDataRemover::ClearDOMStorageOnWebKitThread, | 309 base::Bind(&BrowsingDataRemover::ClearDOMStorageOnWebKitThread, |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 710 net::URLRequestContextGetter* rq_context) { | 710 net::URLRequestContextGetter* rq_context) { |
| 711 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 711 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 712 net::CookieStore* cookie_store = rq_context-> | 712 net::CookieStore* cookie_store = rq_context-> |
| 713 GetURLRequestContext()->cookie_store(); | 713 GetURLRequestContext()->cookie_store(); |
| 714 cookie_store->DeleteAllCreatedBetweenAsync( | 714 cookie_store->DeleteAllCreatedBetweenAsync( |
| 715 delete_begin_, delete_end_, | 715 delete_begin_, delete_end_, |
| 716 base::Bind(&BrowsingDataRemover::OnClearedCookies, | 716 base::Bind(&BrowsingDataRemover::OnClearedCookies, |
| 717 base::Unretained(this))); | 717 base::Unretained(this))); |
| 718 } | 718 } |
| 719 | 719 |
| 720 void BrowsingDataRemover::ClearOriginBoundCertsOnIOThread( | 720 void BrowsingDataRemover::ClearDomainBoundCertsOnIOThread( |
| 721 net::URLRequestContextGetter* rq_context) { | 721 net::URLRequestContextGetter* rq_context) { |
| 722 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 722 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 723 net::OriginBoundCertService* origin_bound_cert_service = | 723 net::OriginBoundCertService* origin_bound_cert_service = |
|
Mike West
2012/03/07 10:31:47
domain_bound_cert_service?
| |
| 724 rq_context->GetURLRequestContext()->origin_bound_cert_service(); | 724 rq_context->GetURLRequestContext()->origin_bound_cert_service(); |
| 725 origin_bound_cert_service->GetCertStore()->DeleteAllCreatedBetween( | 725 origin_bound_cert_service->GetCertStore()->DeleteAllCreatedBetween( |
| 726 delete_begin_, delete_end_); | 726 delete_begin_, delete_end_); |
| 727 BrowserThread::PostTask( | 727 BrowserThread::PostTask( |
| 728 BrowserThread::UI, FROM_HERE, | 728 BrowserThread::UI, FROM_HERE, |
| 729 base::Bind(&BrowsingDataRemover::OnClearedOriginBoundCerts, | 729 base::Bind(&BrowsingDataRemover::OnClearedDomainBoundCerts, |
| 730 base::Unretained(this))); | 730 base::Unretained(this))); |
| 731 } | 731 } |
| 732 | 732 |
| 733 void BrowsingDataRemover::OnClearedOriginBoundCerts() { | 733 void BrowsingDataRemover::OnClearedDomainBoundCerts() { |
| 734 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 734 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 735 waiting_for_clear_origin_bound_certs_ = false; | 735 waiting_for_clear_domain_bound_certs_ = false; |
| 736 NotifyAndDeleteIfDone(); | 736 NotifyAndDeleteIfDone(); |
| 737 } | 737 } |
| OLD | NEW |