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/browsing_data_remover.h" | 5 #include "chrome/browser/browsing_data/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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 #include "webkit/browser/quota/special_storage_policy.h" | 71 #include "webkit/browser/quota/special_storage_policy.h" |
| 72 #include "webkit/common/quota/quota_types.h" | 72 #include "webkit/common/quota/quota_types.h" |
| 73 | 73 |
| 74 using content::BrowserContext; | 74 using content::BrowserContext; |
| 75 using content::BrowserThread; | 75 using content::BrowserThread; |
| 76 using content::DOMStorageContext; | 76 using content::DOMStorageContext; |
| 77 using content::UserMetricsAction; | 77 using content::UserMetricsAction; |
| 78 | 78 |
| 79 bool BrowsingDataRemover::is_removing_ = false; | 79 bool BrowsingDataRemover::is_removing_ = false; |
| 80 | 80 |
| 81 // Helper to create callback for BrowsingDataRemover::DoesOriginMatchMask. | |
| 82 // Static. | |
| 83 bool DoesOriginMatchMask(int origin_set_mask, | |
| 84 const GURL& origin, | |
| 85 quota::SpecialStoragePolicy* special_storage_policy) { | |
| 86 return BrowsingDataHelper::DoesOriginMatchMask( | |
| 87 origin, origin_set_mask, | |
| 88 static_cast<ExtensionSpecialStoragePolicy*>(special_storage_policy)); | |
| 89 } | |
| 90 | |
| 81 BrowsingDataRemover::NotificationDetails::NotificationDetails() | 91 BrowsingDataRemover::NotificationDetails::NotificationDetails() |
| 82 : removal_begin(base::Time()), | 92 : removal_begin(base::Time()), |
| 83 removal_mask(-1), | 93 removal_mask(-1), |
| 84 origin_set_mask(-1) { | 94 origin_set_mask(-1) { |
| 85 } | 95 } |
| 86 | 96 |
| 87 BrowsingDataRemover::NotificationDetails::NotificationDetails( | 97 BrowsingDataRemover::NotificationDetails::NotificationDetails( |
| 88 const BrowsingDataRemover::NotificationDetails& details) | 98 const BrowsingDataRemover::NotificationDetails& details) |
| 89 : removal_begin(details.removal_begin), | 99 : removal_begin(details.removal_begin), |
| 90 removal_mask(details.removal_mask), | 100 removal_mask(details.removal_mask), |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 } | 151 } |
| 142 return new BrowsingDataRemover(profile, | 152 return new BrowsingDataRemover(profile, |
| 143 BrowsingDataRemover::CalculateBeginDeleteTime(period), | 153 BrowsingDataRemover::CalculateBeginDeleteTime(period), |
| 144 base::Time::Max()); | 154 base::Time::Max()); |
| 145 } | 155 } |
| 146 | 156 |
| 147 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, | 157 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, |
| 148 base::Time delete_begin, | 158 base::Time delete_begin, |
| 149 base::Time delete_end) | 159 base::Time delete_end) |
| 150 : profile_(profile), | 160 : profile_(profile), |
| 151 quota_manager_(NULL), | |
| 152 dom_storage_context_(NULL), | |
| 153 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), | 161 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), |
| 154 delete_begin_(delete_begin), | 162 delete_begin_(delete_begin), |
| 155 delete_end_(delete_end), | 163 delete_end_(delete_end), |
| 156 next_cache_state_(STATE_NONE), | 164 next_cache_state_(STATE_NONE), |
| 157 cache_(NULL), | 165 cache_(NULL), |
| 158 main_context_getter_(profile->GetRequestContext()), | 166 main_context_getter_(profile->GetRequestContext()), |
| 159 media_context_getter_(profile->GetMediaRequestContext()), | 167 media_context_getter_(profile->GetMediaRequestContext()), |
| 160 deauthorize_content_licenses_request_id_(0), | 168 deauthorize_content_licenses_request_id_(0), |
| 161 waiting_for_clear_autofill_origin_urls_(false), | 169 waiting_for_clear_autofill_origin_urls_(false), |
| 162 waiting_for_clear_cache_(false), | 170 waiting_for_clear_cache_(false), |
| 163 waiting_for_clear_content_licenses_(false), | 171 waiting_for_clear_content_licenses_(false), |
| 164 waiting_for_clear_cookies_count_(0), | 172 waiting_for_clear_cookies_count_(0), |
| 165 waiting_for_clear_form_(false), | 173 waiting_for_clear_form_(false), |
| 166 waiting_for_clear_history_(false), | 174 waiting_for_clear_history_(false), |
| 167 waiting_for_clear_hostname_resolution_cache_(false), | 175 waiting_for_clear_hostname_resolution_cache_(false), |
| 168 waiting_for_clear_local_storage_(false), | 176 waiting_for_clear_keyword_data_(false), |
| 169 waiting_for_clear_logged_in_predictor_(false), | 177 waiting_for_clear_logged_in_predictor_(false), |
| 170 waiting_for_clear_nacl_cache_(false), | 178 waiting_for_clear_nacl_cache_(false), |
| 171 waiting_for_clear_network_predictor_(false), | 179 waiting_for_clear_network_predictor_(false), |
| 172 waiting_for_clear_networking_history_(false), | 180 waiting_for_clear_networking_history_(false), |
| 173 waiting_for_clear_plugin_data_(false), | 181 waiting_for_clear_plugin_data_(false), |
| 174 waiting_for_clear_pnacl_cache_(false), | 182 waiting_for_clear_pnacl_cache_(false), |
| 175 waiting_for_clear_quota_managed_data_(false), | 183 waiting_for_clear_quota_managed_data_(false), |
| 176 waiting_for_clear_server_bound_certs_(false), | 184 waiting_for_clear_server_bound_certs_(false), |
| 177 waiting_for_clear_session_storage_(false), | 185 waiting_for_clear_storage_partition_data_(false), |
| 178 waiting_for_clear_shader_cache_(false), | |
| 179 waiting_for_clear_webrtc_identity_store_(false), | |
| 180 waiting_for_clear_keyword_data_(false), | |
| 181 remove_mask_(0), | 186 remove_mask_(0), |
| 182 remove_origin_(GURL()), | 187 remove_origin_(GURL()), |
| 183 origin_set_mask_(0) { | 188 origin_set_mask_(0) { |
| 184 DCHECK(profile); | 189 DCHECK(profile); |
| 185 // crbug.com/140910: Many places were calling this with base::Time() as | 190 // crbug.com/140910: Many places were calling this with base::Time() as |
| 186 // delete_end, even though they should've used base::Time::Max(). Work around | 191 // delete_end, even though they should've used base::Time::Max(). Work around |
| 187 // it here. New code should use base::Time::Max(). | 192 // it here. New code should use base::Time::Max(). |
| 188 DCHECK(delete_end_ != base::Time()); | 193 DCHECK(delete_end_ != base::Time()); |
| 189 if (delete_end_ == base::Time()) | 194 if (delete_end_ == base::Time()) |
| 190 delete_end_ = base::Time::Max(); | 195 delete_end_ = base::Time::Max(); |
| 191 } | 196 } |
| 192 | 197 |
| 193 BrowsingDataRemover::~BrowsingDataRemover() { | 198 BrowsingDataRemover::~BrowsingDataRemover() { |
| 194 DCHECK(AllDone()); | 199 DCHECK(AllDone()); |
| 195 } | 200 } |
| 196 | 201 |
| 197 // Static. | 202 // Static. |
| 198 void BrowsingDataRemover::set_removing(bool is_removing) { | 203 void BrowsingDataRemover::set_removing(bool is_removing) { |
| 199 DCHECK(is_removing_ != is_removing); | 204 DCHECK(is_removing_ != is_removing); |
| 200 is_removing_ = is_removing; | 205 is_removing_ = is_removing; |
| 201 } | 206 } |
| 202 | 207 |
| 203 // Static. | |
| 204 int BrowsingDataRemover::GenerateQuotaClientMask(int remove_mask) { | |
| 205 int quota_client_mask = 0; | |
| 206 if (remove_mask & BrowsingDataRemover::REMOVE_FILE_SYSTEMS) | |
| 207 quota_client_mask |= quota::QuotaClient::kFileSystem; | |
| 208 if (remove_mask & BrowsingDataRemover::REMOVE_WEBSQL) | |
| 209 quota_client_mask |= quota::QuotaClient::kDatabase; | |
| 210 if (remove_mask & BrowsingDataRemover::REMOVE_APPCACHE) | |
| 211 quota_client_mask |= quota::QuotaClient::kAppcache; | |
| 212 if (remove_mask & BrowsingDataRemover::REMOVE_INDEXEDDB) | |
| 213 quota_client_mask |= quota::QuotaClient::kIndexedDatabase; | |
| 214 | |
| 215 return quota_client_mask; | |
| 216 } | |
| 217 | |
| 218 void BrowsingDataRemover::Remove(int remove_mask, int origin_set_mask) { | 208 void BrowsingDataRemover::Remove(int remove_mask, int origin_set_mask) { |
| 219 RemoveImpl(remove_mask, GURL(), origin_set_mask); | 209 RemoveImpl(remove_mask, GURL(), origin_set_mask); |
| 220 } | 210 } |
| 221 | 211 |
| 222 void BrowsingDataRemover::RemoveImpl(int remove_mask, | 212 void BrowsingDataRemover::RemoveImpl(int remove_mask, |
| 223 const GURL& origin, | 213 const GURL& origin, |
| 224 int origin_set_mask) { | 214 int origin_set_mask) { |
| 225 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 215 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 226 set_removing(true); | 216 set_removing(true); |
| 227 remove_mask_ = remove_mask; | 217 remove_mask_ = remove_mask; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 376 if ((remove_mask & REMOVE_DOWNLOADS) && may_delete_history) { | 366 if ((remove_mask & REMOVE_DOWNLOADS) && may_delete_history) { |
| 377 content::RecordAction(UserMetricsAction("ClearBrowsingData_Downloads")); | 367 content::RecordAction(UserMetricsAction("ClearBrowsingData_Downloads")); |
| 378 content::DownloadManager* download_manager = | 368 content::DownloadManager* download_manager = |
| 379 BrowserContext::GetDownloadManager(profile_); | 369 BrowserContext::GetDownloadManager(profile_); |
| 380 download_manager->RemoveDownloadsBetween(delete_begin_, delete_end_); | 370 download_manager->RemoveDownloadsBetween(delete_begin_, delete_end_); |
| 381 DownloadPrefs* download_prefs = DownloadPrefs::FromDownloadManager( | 371 DownloadPrefs* download_prefs = DownloadPrefs::FromDownloadManager( |
| 382 download_manager); | 372 download_manager); |
| 383 download_prefs->SetSaveFilePath(download_prefs->DownloadPath()); | 373 download_prefs->SetSaveFilePath(download_prefs->DownloadPath()); |
| 384 } | 374 } |
| 385 | 375 |
| 376 uint32 storage_partition_remove_mask = 0; | |
| 377 | |
| 386 // We ignore the REMOVE_COOKIES request if UNPROTECTED_WEB is not set, | 378 // We ignore the REMOVE_COOKIES request if UNPROTECTED_WEB is not set, |
| 387 // so that callers who request REMOVE_SITE_DATA with PROTECTED_WEB | 379 // so that callers who request REMOVE_SITE_DATA with PROTECTED_WEB |
| 388 // don't accidentally remove the cookies that are associated with the | 380 // don't accidentally remove the cookies that are associated with the |
| 389 // UNPROTECTED_WEB origin. This is necessary because cookies are not separated | 381 // UNPROTECTED_WEB origin. This is necessary because cookies are not separated |
| 390 // between UNPROTECTED_WEB and PROTECTED_WEB. | 382 // between UNPROTECTED_WEB and PROTECTED_WEB. |
| 391 if (remove_mask & REMOVE_COOKIES && | 383 if (remove_mask & REMOVE_COOKIES && |
| 392 origin_set_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { | 384 origin_set_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { |
| 393 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies")); | 385 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies")); |
| 394 // Since we are running on the UI thread don't call GetURLRequestContext(). | 386 |
| 395 net::URLRequestContextGetter* rq_context = profile_->GetRequestContext(); | 387 storage_partition_remove_mask |= |
| 396 if (rq_context) { | 388 content::StoragePartition::REMOVE_DATA_MASK_COOKIES; |
| 397 ++waiting_for_clear_cookies_count_; | 389 |
| 398 BrowserThread::PostTask( | |
| 399 BrowserThread::IO, FROM_HERE, | |
| 400 base::Bind(&BrowsingDataRemover::ClearCookiesOnIOThread, | |
| 401 base::Unretained(this), base::Unretained(rq_context))); | |
| 402 } | |
| 403 // Also delete the LoggedIn Predictor, which tries to keep track of which | 390 // Also delete the LoggedIn Predictor, which tries to keep track of which |
| 404 // sites a user is logged into. | 391 // sites a user is logged into. |
| 405 ClearLoggedInPredictor(); | 392 ClearLoggedInPredictor(); |
| 406 | 393 |
| 407 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) | 394 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) |
| 408 // Clear the safebrowsing cookies only if time period is for "all time". It | 395 // Clear the safebrowsing cookies only if time period is for "all time". It |
| 409 // doesn't make sense to apply the time period of deleting in the last X | 396 // doesn't make sense to apply the time period of deleting in the last X |
| 410 // hours/days to the safebrowsing cookies since they aren't the result of | 397 // hours/days to the safebrowsing cookies since they aren't the result of |
| 411 // any user action. | 398 // any user action. |
| 412 if (delete_begin_ == base::Time()) { | 399 if (delete_begin_ == base::Time()) { |
| 413 SafeBrowsingService* sb_service = | 400 SafeBrowsingService* sb_service = |
| 414 g_browser_process->safe_browsing_service(); | 401 g_browser_process->safe_browsing_service(); |
| 415 if (sb_service) { | 402 if (sb_service) { |
| 416 net::URLRequestContextGetter* sb_context = | 403 net::URLRequestContextGetter* sb_context = |
| 417 sb_service->url_request_context(); | 404 sb_service->url_request_context(); |
| 418 ++waiting_for_clear_cookies_count_; | 405 ++waiting_for_clear_cookies_count_; |
| 419 BrowserThread::PostTask( | 406 BrowserThread::PostTask( |
| 420 BrowserThread::IO, FROM_HERE, | 407 BrowserThread::IO, FROM_HERE, |
| 421 base::Bind(&BrowsingDataRemover::ClearCookiesOnIOThread, | 408 base::Bind(&BrowsingDataRemover::ClearCookiesOnIOThread, |
| 422 base::Unretained(this), base::Unretained(sb_context))); | 409 base::Unretained(this), base::Unretained(sb_context))); |
|
Mike West
2013/10/29 11:14:32
Are these cookies not tied to a StoragePartition?
lazyboy
2013/10/30 00:33:23
These are related to SafeBrowsingService, which is
| |
| 423 } | 410 } |
| 424 } | 411 } |
| 425 #endif | 412 #endif |
| 426 } | 413 } |
| 427 | 414 |
| 428 // Server bound certs are not separated for protected and unprotected web | 415 // Server bound certs are not separated for protected and unprotected web |
| 429 // origins. We check the origin_set_mask_ to prevent unintended deletion. | 416 // origins. We check the origin_set_mask_ to prevent unintended deletion. |
| 430 if (remove_mask & REMOVE_SERVER_BOUND_CERTS && | 417 if (remove_mask & REMOVE_SERVER_BOUND_CERTS && |
| 431 origin_set_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { | 418 origin_set_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { |
| 432 content::RecordAction( | 419 content::RecordAction( |
| 433 UserMetricsAction("ClearBrowsingData_ServerBoundCerts")); | 420 UserMetricsAction("ClearBrowsingData_ServerBoundCerts")); |
| 434 // Since we are running on the UI thread don't call GetURLRequestContext(). | 421 // Since we are running on the UI thread don't call GetURLRequestContext(). |
| 435 net::URLRequestContextGetter* rq_context = profile_->GetRequestContext(); | 422 net::URLRequestContextGetter* rq_context = profile_->GetRequestContext(); |
| 436 if (rq_context) { | 423 if (rq_context) { |
| 437 waiting_for_clear_server_bound_certs_ = true; | 424 waiting_for_clear_server_bound_certs_ = true; |
| 438 BrowserThread::PostTask( | 425 BrowserThread::PostTask( |
| 439 BrowserThread::IO, FROM_HERE, | 426 BrowserThread::IO, FROM_HERE, |
| 440 base::Bind(&BrowsingDataRemover::ClearServerBoundCertsOnIOThread, | 427 base::Bind(&BrowsingDataRemover::ClearServerBoundCertsOnIOThread, |
| 441 base::Unretained(this), base::Unretained(rq_context))); | 428 base::Unretained(this), base::Unretained(rq_context))); |
| 442 } | 429 } |
| 443 } | 430 } |
| 444 | 431 |
| 445 if (remove_mask & REMOVE_LOCAL_STORAGE) { | 432 if (remove_mask & REMOVE_LOCAL_STORAGE) { |
| 446 waiting_for_clear_local_storage_ = true; | 433 storage_partition_remove_mask |= |
| 447 waiting_for_clear_session_storage_ = true; | 434 content::StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE; |
| 448 if (!dom_storage_context_) { | |
| 449 dom_storage_context_ = | |
| 450 BrowserContext::GetDefaultStoragePartition(profile_)-> | |
| 451 GetDOMStorageContext(); | |
| 452 } | |
| 453 ClearLocalStorageOnUIThread(); | |
| 454 ClearSessionStorageOnUIThread(); | |
| 455 } | 435 } |
| 456 | 436 |
| 457 if (remove_mask & REMOVE_INDEXEDDB || remove_mask & REMOVE_WEBSQL || | 437 if (remove_mask & REMOVE_INDEXEDDB) { |
| 458 remove_mask & REMOVE_APPCACHE || remove_mask & REMOVE_FILE_SYSTEMS) { | 438 storage_partition_remove_mask |= |
| 459 if (!quota_manager_) { | 439 content::StoragePartition::REMOVE_DATA_MASK_INDEXEDDB; |
| 460 quota_manager_ = | 440 } |
| 461 BrowserContext::GetDefaultStoragePartition(profile_)-> | 441 if (remove_mask & REMOVE_WEBSQL) { |
| 462 GetQuotaManager(); | 442 storage_partition_remove_mask |= |
| 463 } | 443 content::StoragePartition::REMOVE_DATA_MASK_WEBSQL; |
| 464 waiting_for_clear_quota_managed_data_ = true; | 444 } |
| 465 BrowserThread::PostTask( | 445 if (remove_mask & REMOVE_APPCACHE) { |
| 466 BrowserThread::IO, FROM_HERE, | 446 storage_partition_remove_mask |= |
| 467 base::Bind(&BrowsingDataRemover::ClearQuotaManagedDataOnIOThread, | 447 content::StoragePartition::REMOVE_DATA_MASK_APPCACHE; |
| 468 base::Unretained(this))); | 448 } |
| 449 if (remove_mask & REMOVE_FILE_SYSTEMS) { | |
| 450 storage_partition_remove_mask |= | |
| 451 content::StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS; | |
| 469 } | 452 } |
| 470 | 453 |
| 471 #if defined(ENABLE_PLUGINS) | 454 #if defined(ENABLE_PLUGINS) |
| 472 // Plugin is data not separated for protected and unprotected web origins. We | 455 // Plugin is data not separated for protected and unprotected web origins. We |
| 473 // check the origin_set_mask_ to prevent unintended deletion. | 456 // check the origin_set_mask_ to prevent unintended deletion. |
| 474 if (remove_mask & REMOVE_PLUGIN_DATA && | 457 if (remove_mask & REMOVE_PLUGIN_DATA && |
| 475 origin_set_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { | 458 origin_set_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { |
| 476 content::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData")); | 459 content::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData")); |
| 477 | 460 |
| 478 waiting_for_clear_plugin_data_ = true; | 461 waiting_for_clear_plugin_data_ = true; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 554 // The PrerenderManager may have a page actively being prerendered, which | 537 // The PrerenderManager may have a page actively being prerendered, which |
| 555 // is essentially a preemptively cached page. | 538 // is essentially a preemptively cached page. |
| 556 prerender::PrerenderManager* prerender_manager = | 539 prerender::PrerenderManager* prerender_manager = |
| 557 prerender::PrerenderManagerFactory::GetForProfile(profile_); | 540 prerender::PrerenderManagerFactory::GetForProfile(profile_); |
| 558 if (prerender_manager) { | 541 if (prerender_manager) { |
| 559 prerender_manager->ClearData( | 542 prerender_manager->ClearData( |
| 560 prerender::PrerenderManager::CLEAR_PRERENDER_CONTENTS); | 543 prerender::PrerenderManager::CLEAR_PRERENDER_CONTENTS); |
| 561 } | 544 } |
| 562 | 545 |
| 563 // Tell the shader disk cache to clear. | 546 // Tell the shader disk cache to clear. |
| 564 waiting_for_clear_shader_cache_ = true; | |
| 565 content::RecordAction(UserMetricsAction("ClearBrowsingData_ShaderCache")); | 547 content::RecordAction(UserMetricsAction("ClearBrowsingData_ShaderCache")); |
| 548 storage_partition_remove_mask |= | |
| 549 content::StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE; | |
| 566 | 550 |
| 567 ClearShaderCacheOnUIThread(); | 551 storage_partition_remove_mask |= |
| 552 content::StoragePartition::REMOVE_DATA_MASK_WEBRTC_IDENTITY; | |
| 553 } | |
| 568 | 554 |
| 569 waiting_for_clear_webrtc_identity_store_ = true; | 555 if (storage_partition_remove_mask) { |
| 570 BrowserContext::GetDefaultStoragePartition(profile_)->ClearDataForRange( | 556 waiting_for_clear_storage_partition_data_ = true; |
| 571 content::StoragePartition::REMOVE_DATA_MASK_WEBRTC_IDENTITY, | 557 content::StoragePartition* storage_partition = |
| 572 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, | 558 BrowserContext::GetDefaultStoragePartition(profile_); |
| 559 | |
| 560 uint32 quota_storage_remove_mask = | |
| 561 ~content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; | |
| 562 | |
| 563 if (delete_begin_ == base::Time() || | |
| 564 origin_set_mask_ & | |
| 565 (BrowsingDataHelper::PROTECTED_WEB | BrowsingDataHelper::EXTENSION)) { | |
| 566 // If we're deleting since the beginning of time, or we're removing | |
| 567 // protected origins, then remove persistent quota data. | |
| 568 quota_storage_remove_mask |= | |
| 569 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; | |
| 570 } | |
| 571 | |
| 572 storage_partition->ClearDataForOriginWithinRange( | |
| 573 storage_partition_remove_mask, | |
| 574 quota_storage_remove_mask, | |
| 575 remove_origin_, | |
| 576 base::Bind(&DoesOriginMatchMask, origin_set_mask_), | |
| 573 delete_begin_, | 577 delete_begin_, |
| 574 delete_end_, | 578 delete_end_, |
| 575 base::Bind(&BrowsingDataRemover::OnClearWebRTCIdentityStore, | 579 base::Bind(&BrowsingDataRemover::OnClearedStoragePartitionData, |
| 576 base::Unretained(this))); | 580 base::Unretained(this))); |
| 577 } | 581 } |
| 578 | 582 |
| 579 #if defined(ENABLE_PLUGINS) | 583 #if defined(ENABLE_PLUGINS) |
| 580 if (remove_mask & REMOVE_CONTENT_LICENSES) { | 584 if (remove_mask & REMOVE_CONTENT_LICENSES) { |
| 581 content::RecordAction( | 585 content::RecordAction( |
| 582 UserMetricsAction("ClearBrowsingData_ContentLicenses")); | 586 UserMetricsAction("ClearBrowsingData_ContentLicenses")); |
| 583 | 587 |
| 584 waiting_for_clear_content_licenses_ = true; | 588 waiting_for_clear_content_licenses_ = true; |
| 585 if (!pepper_flash_settings_manager_.get()) { | 589 if (!pepper_flash_settings_manager_.get()) { |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 606 | 610 |
| 607 void BrowsingDataRemover::RemoveObserver(Observer* observer) { | 611 void BrowsingDataRemover::RemoveObserver(Observer* observer) { |
| 608 observer_list_.RemoveObserver(observer); | 612 observer_list_.RemoveObserver(observer); |
| 609 } | 613 } |
| 610 | 614 |
| 611 void BrowsingDataRemover::OnHistoryDeletionDone() { | 615 void BrowsingDataRemover::OnHistoryDeletionDone() { |
| 612 waiting_for_clear_history_ = false; | 616 waiting_for_clear_history_ = false; |
| 613 NotifyAndDeleteIfDone(); | 617 NotifyAndDeleteIfDone(); |
| 614 } | 618 } |
| 615 | 619 |
| 616 void BrowsingDataRemover::OverrideQuotaManagerForTesting( | |
| 617 quota::QuotaManager* quota_manager) { | |
| 618 quota_manager_ = quota_manager; | |
| 619 } | |
| 620 | |
| 621 base::Time BrowsingDataRemover::CalculateBeginDeleteTime( | 620 base::Time BrowsingDataRemover::CalculateBeginDeleteTime( |
| 622 TimePeriod time_period) { | 621 TimePeriod time_period) { |
| 623 base::TimeDelta diff; | 622 base::TimeDelta diff; |
| 624 base::Time delete_begin_time = base::Time::Now(); | 623 base::Time delete_begin_time = base::Time::Now(); |
| 625 switch (time_period) { | 624 switch (time_period) { |
| 626 case LAST_HOUR: | 625 case LAST_HOUR: |
| 627 diff = base::TimeDelta::FromHours(1); | 626 diff = base::TimeDelta::FromHours(1); |
| 628 break; | 627 break; |
| 629 case LAST_DAY: | 628 case LAST_DAY: |
| 630 diff = base::TimeDelta::FromHours(24); | 629 diff = base::TimeDelta::FromHours(24); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 643 break; | 642 break; |
| 644 } | 643 } |
| 645 return delete_begin_time - diff; | 644 return delete_begin_time - diff; |
| 646 } | 645 } |
| 647 | 646 |
| 648 bool BrowsingDataRemover::AllDone() { | 647 bool BrowsingDataRemover::AllDone() { |
| 649 return !waiting_for_clear_keyword_data_ && | 648 return !waiting_for_clear_keyword_data_ && |
| 650 !waiting_for_clear_autofill_origin_urls_ && | 649 !waiting_for_clear_autofill_origin_urls_ && |
| 651 !waiting_for_clear_cache_ && !waiting_for_clear_nacl_cache_ && | 650 !waiting_for_clear_cache_ && !waiting_for_clear_nacl_cache_ && |
| 652 !waiting_for_clear_cookies_count_ && !waiting_for_clear_history_ && | 651 !waiting_for_clear_cookies_count_ && !waiting_for_clear_history_ && |
| 653 !waiting_for_clear_local_storage_ && | |
| 654 !waiting_for_clear_logged_in_predictor_ && | 652 !waiting_for_clear_logged_in_predictor_ && |
| 655 !waiting_for_clear_session_storage_ && | |
| 656 !waiting_for_clear_networking_history_ && | 653 !waiting_for_clear_networking_history_ && |
| 657 !waiting_for_clear_server_bound_certs_ && | 654 !waiting_for_clear_server_bound_certs_ && |
| 658 !waiting_for_clear_plugin_data_ && | 655 !waiting_for_clear_plugin_data_ && |
| 659 !waiting_for_clear_pnacl_cache_ && | 656 !waiting_for_clear_pnacl_cache_ && |
| 660 !waiting_for_clear_quota_managed_data_ && | 657 !waiting_for_clear_quota_managed_data_ && |
| 661 !waiting_for_clear_content_licenses_ && !waiting_for_clear_form_ && | 658 !waiting_for_clear_content_licenses_ && !waiting_for_clear_form_ && |
| 662 !waiting_for_clear_hostname_resolution_cache_ && | 659 !waiting_for_clear_hostname_resolution_cache_ && |
| 663 !waiting_for_clear_network_predictor_ && | 660 !waiting_for_clear_network_predictor_ && |
| 664 !waiting_for_clear_shader_cache_ && | 661 !waiting_for_clear_storage_partition_data_; |
| 665 !waiting_for_clear_webrtc_identity_store_; | |
| 666 } | 662 } |
| 667 | 663 |
| 668 void BrowsingDataRemover::OnKeywordsLoaded() { | 664 void BrowsingDataRemover::OnKeywordsLoaded() { |
| 669 // Deletes the entries from the model, and if we're not waiting on anything | 665 // Deletes the entries from the model, and if we're not waiting on anything |
| 670 // else notifies observers and deletes this BrowsingDataRemover. | 666 // else notifies observers and deletes this BrowsingDataRemover. |
| 671 TemplateURLService* model = | 667 TemplateURLService* model = |
| 672 TemplateURLServiceFactory::GetForProfile(profile_); | 668 TemplateURLServiceFactory::GetForProfile(profile_); |
| 673 DCHECK_EQ(profile_, model->profile()); | 669 DCHECK_EQ(profile_, model->profile()); |
| 674 model->RemoveAutoGeneratedBetween(delete_begin_, delete_end_); | 670 model->RemoveAutoGeneratedBetween(delete_begin_, delete_end_); |
| 675 waiting_for_clear_keyword_data_ = false; | 671 waiting_for_clear_keyword_data_ = false; |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 861 } | 857 } |
| 862 default: { | 858 default: { |
| 863 NOTREACHED() << "bad state"; | 859 NOTREACHED() << "bad state"; |
| 864 next_cache_state_ = STATE_NONE; // Stop looping. | 860 next_cache_state_ = STATE_NONE; // Stop looping. |
| 865 return; | 861 return; |
| 866 } | 862 } |
| 867 } | 863 } |
| 868 } | 864 } |
| 869 } | 865 } |
| 870 | 866 |
| 871 void BrowsingDataRemover::ClearedShaderCache() { | |
| 872 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 873 | |
| 874 waiting_for_clear_shader_cache_ = false; | |
| 875 NotifyAndDeleteIfDone(); | |
| 876 } | |
| 877 | |
| 878 void BrowsingDataRemover::ClearShaderCacheOnUIThread() { | |
| 879 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 880 | |
| 881 BrowserContext::GetDefaultStoragePartition(profile_)->ClearDataForRange( | |
| 882 content::StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE, | |
| 883 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, | |
| 884 delete_begin_, delete_end_, | |
| 885 base::Bind(&BrowsingDataRemover::ClearedShaderCache, | |
| 886 base::Unretained(this))); | |
| 887 } | |
| 888 | |
| 889 #if !defined(DISABLE_NACL) | 867 #if !defined(DISABLE_NACL) |
| 890 void BrowsingDataRemover::ClearedNaClCache() { | 868 void BrowsingDataRemover::ClearedNaClCache() { |
| 891 // This function should be called on the UI thread. | 869 // This function should be called on the UI thread. |
| 892 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 870 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 893 | 871 |
| 894 waiting_for_clear_nacl_cache_ = false; | 872 waiting_for_clear_nacl_cache_ = false; |
| 895 | 873 |
| 896 NotifyAndDeleteIfDone(); | 874 NotifyAndDeleteIfDone(); |
| 897 } | 875 } |
| 898 | 876 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 939 base::Time end) { | 917 base::Time end) { |
| 940 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 918 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 941 | 919 |
| 942 PnaclHost::GetInstance()->ClearTranslationCacheEntriesBetween( | 920 PnaclHost::GetInstance()->ClearTranslationCacheEntriesBetween( |
| 943 begin, end, | 921 begin, end, |
| 944 base::Bind(&BrowsingDataRemover::ClearedPnaclCacheOnIOThread, | 922 base::Bind(&BrowsingDataRemover::ClearedPnaclCacheOnIOThread, |
| 945 base::Unretained(this))); | 923 base::Unretained(this))); |
| 946 } | 924 } |
| 947 #endif | 925 #endif |
| 948 | 926 |
| 949 void BrowsingDataRemover::ClearLocalStorageOnUIThread() { | |
| 950 DCHECK(waiting_for_clear_local_storage_); | |
| 951 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 952 dom_storage_context_->GetLocalStorageUsage( | |
| 953 base::Bind(&BrowsingDataRemover::OnGotLocalStorageUsageInfo, | |
| 954 base::Unretained(this))); | |
| 955 } | |
| 956 | |
| 957 void BrowsingDataRemover::OnGotLocalStorageUsageInfo( | |
| 958 const std::vector<content::LocalStorageUsageInfo>& infos) { | |
| 959 DCHECK(waiting_for_clear_local_storage_); | |
| 960 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 961 | |
| 962 for (size_t i = 0; i < infos.size(); ++i) { | |
| 963 if (!BrowsingDataHelper::DoesOriginMatchMask( | |
| 964 infos[i].origin, origin_set_mask_, special_storage_policy_.get())) | |
| 965 continue; | |
| 966 | |
| 967 if (infos[i].last_modified >= delete_begin_ && | |
| 968 infos[i].last_modified <= delete_end_) { | |
| 969 dom_storage_context_->DeleteLocalStorage(infos[i].origin); | |
| 970 } | |
| 971 } | |
| 972 waiting_for_clear_local_storage_ = false; | |
| 973 NotifyAndDeleteIfDone(); | |
| 974 } | |
| 975 | |
| 976 void BrowsingDataRemover::ClearSessionStorageOnUIThread() { | |
| 977 DCHECK(waiting_for_clear_session_storage_); | |
| 978 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 979 | |
| 980 dom_storage_context_->GetSessionStorageUsage( | |
| 981 base::Bind(&BrowsingDataRemover::OnGotSessionStorageUsageInfo, | |
| 982 base::Unretained(this))); | |
| 983 } | |
| 984 | |
| 985 void BrowsingDataRemover::OnGotSessionStorageUsageInfo( | |
| 986 const std::vector<content::SessionStorageUsageInfo>& infos) { | |
| 987 DCHECK(waiting_for_clear_session_storage_); | |
| 988 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 989 | |
| 990 for (size_t i = 0; i < infos.size(); ++i) { | |
| 991 if (!BrowsingDataHelper::DoesOriginMatchMask( | |
| 992 infos[i].origin, origin_set_mask_, special_storage_policy_.get())) | |
| 993 continue; | |
| 994 | |
| 995 dom_storage_context_->DeleteSessionStorage(infos[i]); | |
| 996 } | |
| 997 waiting_for_clear_session_storage_ = false; | |
| 998 NotifyAndDeleteIfDone(); | |
| 999 } | |
| 1000 | |
| 1001 void BrowsingDataRemover::ClearQuotaManagedDataOnIOThread() { | |
| 1002 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 1003 | |
| 1004 // Ask the QuotaManager for all origins with temporary quota modified within | |
| 1005 // the user-specified timeframe, and deal with the resulting set in | |
| 1006 // OnGotQuotaManagedOrigins(). | |
| 1007 quota_managed_origins_to_delete_count_ = 0; | |
| 1008 quota_managed_storage_types_to_delete_count_ = 0; | |
| 1009 | |
| 1010 if (delete_begin_ == base::Time() || | |
| 1011 origin_set_mask_ & | |
| 1012 (BrowsingDataHelper::PROTECTED_WEB | BrowsingDataHelper::EXTENSION)) { | |
| 1013 // If we're deleting since the beginning of time, or we're removing | |
| 1014 // protected origins, then ask the QuotaManager for all origins with | |
| 1015 // persistent quota modified within the user-specified timeframe, and deal | |
| 1016 // with the resulting set in OnGotQuotaManagedOrigins. | |
| 1017 ++quota_managed_storage_types_to_delete_count_; | |
| 1018 quota_manager_->GetOriginsModifiedSince( | |
| 1019 quota::kStorageTypePersistent, delete_begin_, | |
| 1020 base::Bind(&BrowsingDataRemover::OnGotQuotaManagedOrigins, | |
| 1021 base::Unretained(this))); | |
| 1022 } | |
| 1023 | |
| 1024 // Do the same for temporary quota. | |
| 1025 ++quota_managed_storage_types_to_delete_count_; | |
| 1026 quota_manager_->GetOriginsModifiedSince( | |
| 1027 quota::kStorageTypeTemporary, delete_begin_, | |
| 1028 base::Bind(&BrowsingDataRemover::OnGotQuotaManagedOrigins, | |
| 1029 base::Unretained(this))); | |
| 1030 | |
| 1031 // Do the same for syncable quota. | |
| 1032 ++quota_managed_storage_types_to_delete_count_; | |
| 1033 quota_manager_->GetOriginsModifiedSince( | |
| 1034 quota::kStorageTypeSyncable, delete_begin_, | |
| 1035 base::Bind(&BrowsingDataRemover::OnGotQuotaManagedOrigins, | |
| 1036 base::Unretained(this))); | |
| 1037 } | |
| 1038 | |
| 1039 void BrowsingDataRemover::OnGotQuotaManagedOrigins( | |
| 1040 const std::set<GURL>& origins, quota::StorageType type) { | |
| 1041 DCHECK_GT(quota_managed_storage_types_to_delete_count_, 0); | |
| 1042 // Walk through the origins passed in, delete quota of |type| from each that | |
| 1043 // matches the |origin_set_mask_|. | |
| 1044 std::set<GURL>::const_iterator origin; | |
| 1045 for (origin = origins.begin(); origin != origins.end(); ++origin) { | |
| 1046 // TODO(mkwst): Clean this up, it's slow. http://crbug.com/130746 | |
| 1047 if (!remove_origin_.is_empty() && remove_origin_ != origin->GetOrigin()) | |
| 1048 continue; | |
| 1049 | |
| 1050 if (!BrowsingDataHelper::DoesOriginMatchMask(origin->GetOrigin(), | |
| 1051 origin_set_mask_, | |
| 1052 special_storage_policy_.get())) | |
| 1053 continue; | |
| 1054 | |
| 1055 ++quota_managed_origins_to_delete_count_; | |
| 1056 quota_manager_->DeleteOriginData( | |
| 1057 origin->GetOrigin(), type, | |
| 1058 BrowsingDataRemover::GenerateQuotaClientMask(remove_mask_), | |
| 1059 base::Bind(&BrowsingDataRemover::OnQuotaManagedOriginDeletion, | |
| 1060 base::Unretained(this), origin->GetOrigin(), type)); | |
| 1061 } | |
| 1062 | |
| 1063 --quota_managed_storage_types_to_delete_count_; | |
| 1064 CheckQuotaManagedDataDeletionStatus(); | |
| 1065 } | |
| 1066 | |
| 1067 void BrowsingDataRemover::OnQuotaManagedOriginDeletion( | |
| 1068 const GURL& origin, | |
| 1069 quota::StorageType type, | |
| 1070 quota::QuotaStatusCode status) { | |
| 1071 DCHECK_GT(quota_managed_origins_to_delete_count_, 0); | |
| 1072 if (status != quota::kQuotaStatusOk) { | |
| 1073 DLOG(ERROR) << "Couldn't remove data of type " << type << " for origin " | |
| 1074 << origin << ". Status: " << status; | |
| 1075 } | |
| 1076 | |
| 1077 --quota_managed_origins_to_delete_count_; | |
| 1078 CheckQuotaManagedDataDeletionStatus(); | |
| 1079 } | |
| 1080 | |
| 1081 void BrowsingDataRemover::CheckQuotaManagedDataDeletionStatus() { | |
| 1082 if (quota_managed_storage_types_to_delete_count_ != 0 || | |
| 1083 quota_managed_origins_to_delete_count_ != 0) { | |
| 1084 return; | |
| 1085 } | |
| 1086 | |
| 1087 BrowserThread::PostTask( | |
| 1088 BrowserThread::UI, FROM_HERE, | |
| 1089 base::Bind(&BrowsingDataRemover::OnQuotaManagedDataDeleted, | |
| 1090 base::Unretained(this))); | |
| 1091 } | |
| 1092 | |
| 1093 void BrowsingDataRemover::OnQuotaManagedDataDeleted() { | |
| 1094 DCHECK(waiting_for_clear_quota_managed_data_); | |
| 1095 waiting_for_clear_quota_managed_data_ = false; | |
| 1096 NotifyAndDeleteIfDone(); | |
| 1097 } | |
| 1098 | |
| 1099 void BrowsingDataRemover::OnWaitableEventSignaled( | 927 void BrowsingDataRemover::OnWaitableEventSignaled( |
| 1100 base::WaitableEvent* waitable_event) { | 928 base::WaitableEvent* waitable_event) { |
| 1101 waiting_for_clear_plugin_data_ = false; | 929 waiting_for_clear_plugin_data_ = false; |
| 1102 NotifyAndDeleteIfDone(); | 930 NotifyAndDeleteIfDone(); |
| 1103 } | 931 } |
| 1104 | 932 |
| 1105 #if defined(ENABLE_PLUGINS) | 933 #if defined(ENABLE_PLUGINS) |
| 1106 void BrowsingDataRemover::OnDeauthorizeContentLicensesCompleted( | 934 void BrowsingDataRemover::OnDeauthorizeContentLicensesCompleted( |
| 1107 uint32 request_id, | 935 uint32 request_id, |
| 1108 bool /* success */) { | 936 bool /* success */) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1175 waiting_for_clear_form_ = false; | 1003 waiting_for_clear_form_ = false; |
| 1176 NotifyAndDeleteIfDone(); | 1004 NotifyAndDeleteIfDone(); |
| 1177 } | 1005 } |
| 1178 | 1006 |
| 1179 void BrowsingDataRemover::OnClearedAutofillOriginURLs() { | 1007 void BrowsingDataRemover::OnClearedAutofillOriginURLs() { |
| 1180 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1008 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1181 waiting_for_clear_autofill_origin_urls_ = false; | 1009 waiting_for_clear_autofill_origin_urls_ = false; |
| 1182 NotifyAndDeleteIfDone(); | 1010 NotifyAndDeleteIfDone(); |
| 1183 } | 1011 } |
| 1184 | 1012 |
| 1185 void BrowsingDataRemover::OnClearWebRTCIdentityStore() { | 1013 void BrowsingDataRemover::OnClearedStoragePartitionData() { |
| 1186 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1014 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1187 waiting_for_clear_webrtc_identity_store_ = false; | 1015 waiting_for_clear_storage_partition_data_ = false; |
| 1188 NotifyAndDeleteIfDone(); | 1016 NotifyAndDeleteIfDone(); |
| 1189 } | 1017 } |
| OLD | NEW |