| 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 BrowserContext::GetDOMStorageContext(profile_)->DeleteDataModifiedSince( | 306 BrowserContext::GetDOMStorageContext(profile_)->DeleteDataModifiedSince( |
| 307 delete_begin_); | 307 delete_begin_); |
| 308 } | 308 } |
| 309 | 309 |
| 310 if (remove_mask & REMOVE_INDEXEDDB || remove_mask & REMOVE_WEBSQL || | 310 if (remove_mask & REMOVE_INDEXEDDB || remove_mask & REMOVE_WEBSQL || |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 net::URLRequestContextGetter* rq_context) { | 685 net::URLRequestContextGetter* rq_context) { |
| 686 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 686 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 687 net::CookieStore* cookie_store = rq_context-> | 687 net::CookieStore* cookie_store = rq_context-> |
| 688 GetURLRequestContext()->cookie_store(); | 688 GetURLRequestContext()->cookie_store(); |
| 689 cookie_store->DeleteAllCreatedBetweenAsync( | 689 cookie_store->DeleteAllCreatedBetweenAsync( |
| 690 delete_begin_, delete_end_, | 690 delete_begin_, delete_end_, |
| 691 base::Bind(&BrowsingDataRemover::OnClearedCookies, | 691 base::Bind(&BrowsingDataRemover::OnClearedCookies, |
| 692 base::Unretained(this))); | 692 base::Unretained(this))); |
| 693 } | 693 } |
| 694 | 694 |
| 695 void BrowsingDataRemover::ClearOriginBoundCertsOnIOThread( | 695 void BrowsingDataRemover::ClearServerBoundCertsOnIOThread( |
| 696 net::URLRequestContextGetter* rq_context) { | 696 net::URLRequestContextGetter* rq_context) { |
| 697 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 697 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 698 net::OriginBoundCertService* origin_bound_cert_service = | 698 net::ServerBoundCertService* server_bound_cert_service = |
| 699 rq_context->GetURLRequestContext()->origin_bound_cert_service(); | 699 rq_context->GetURLRequestContext()->server_bound_cert_service(); |
| 700 origin_bound_cert_service->GetCertStore()->DeleteAllCreatedBetween( | 700 server_bound_cert_service->GetCertStore()->DeleteAllCreatedBetween( |
| 701 delete_begin_, delete_end_); | 701 delete_begin_, delete_end_); |
| 702 BrowserThread::PostTask( | 702 BrowserThread::PostTask( |
| 703 BrowserThread::UI, FROM_HERE, | 703 BrowserThread::UI, FROM_HERE, |
| 704 base::Bind(&BrowsingDataRemover::OnClearedOriginBoundCerts, | 704 base::Bind(&BrowsingDataRemover::OnClearedServerBoundCerts, |
| 705 base::Unretained(this))); | 705 base::Unretained(this))); |
| 706 } | 706 } |
| 707 | 707 |
| 708 void BrowsingDataRemover::OnClearedOriginBoundCerts() { | 708 void BrowsingDataRemover::OnClearedServerBoundCerts() { |
| 709 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 709 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 710 waiting_for_clear_origin_bound_certs_ = false; | 710 waiting_for_clear_server_bound_certs_ = false; |
| 711 NotifyAndDeleteIfDone(); | 711 NotifyAndDeleteIfDone(); |
| 712 } | 712 } |
| OLD | NEW |