diff options
author | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-05 23:40:02 +0000 |
---|---|---|
committer | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-05 23:40:02 +0000 |
commit | d68a4fc6f448c6ebf407e2817320e7736c4735ee (patch) | |
tree | d76e2c91aa67af5a880ec81eddcbf2d12887e865 /chrome/browser/browsing_data_remover.cc | |
parent | 63eb6c0bebc31046bbd954ef21dee86dca9d7fe3 (diff) | |
download | chromium_src-d68a4fc6f448c6ebf407e2817320e7736c4735ee.zip chromium_src-d68a4fc6f448c6ebf407e2817320e7736c4735ee.tar.gz chromium_src-d68a4fc6f448c6ebf407e2817320e7736c4735ee.tar.bz2 |
Hook up the content settings UI to the appcache.
* Populate the tree view with appcaches
* Delete selected appcaches from the tree view
* Delete the date range indicated in the browsing data remover
TEST=manual
BUG=34634
Review URL: http://codereview.chromium.org/660423
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40796 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browsing_data_remover.cc')
-rw-r--r-- | chrome/browser/browsing_data_remover.cc | 86 |
1 files changed, 83 insertions, 3 deletions
diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc index b4468c7..0614969 100644 --- a/chrome/browser/browsing_data_remover.cc +++ b/chrome/browser/browsing_data_remover.cc @@ -11,6 +11,7 @@ #include "chrome/browser/in_process_webkit/webkit_context.h" #include "chrome/browser/profile.h" #include "chrome/browser/metrics/user_metrics.h" +#include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/net/url_request_context_getter.h" #include "chrome/browser/password_manager/password_store.h" #include "chrome/browser/search_engines/template_url_model.h" @@ -46,9 +47,16 @@ BrowsingDataRemover::BrowsingDataRemover(Profile* profile, delete_end_(delete_end), ALLOW_THIS_IN_INITIALIZER_LIST(database_cleared_callback_( this, &BrowsingDataRemover::OnClearedDatabases)), + ALLOW_THIS_IN_INITIALIZER_LIST(appcache_got_info_callback_( + this, &BrowsingDataRemover::OnGotAppCacheInfo)), + ALLOW_THIS_IN_INITIALIZER_LIST(appcache_deleted_callback_( + this, &BrowsingDataRemover::OnAppCacheDeleted)), + request_context_getter_(profile->GetRequestContext()), + appcaches_to_be_deleted_count_(0), waiting_for_clear_databases_(false), waiting_for_clear_history_(false), - waiting_for_clear_cache_(false) { + waiting_for_clear_cache_(false), + waiting_for_clear_appcache_(false) { DCHECK(profile); } @@ -60,9 +68,16 @@ BrowsingDataRemover::BrowsingDataRemover(Profile* profile, delete_end_(delete_end), ALLOW_THIS_IN_INITIALIZER_LIST(database_cleared_callback_( this, &BrowsingDataRemover::OnClearedDatabases)), + ALLOW_THIS_IN_INITIALIZER_LIST(appcache_got_info_callback_( + this, &BrowsingDataRemover::OnGotAppCacheInfo)), + ALLOW_THIS_IN_INITIALIZER_LIST(appcache_deleted_callback_( + this, &BrowsingDataRemover::OnAppCacheDeleted)), + request_context_getter_(profile->GetRequestContext()), + appcaches_to_be_deleted_count_(0), waiting_for_clear_databases_(false), waiting_for_clear_history_(false), - waiting_for_clear_cache_(false) { + waiting_for_clear_cache_(false), + waiting_for_clear_appcache_(false) { DCHECK(profile); } @@ -146,7 +161,13 @@ void BrowsingDataRemover::Remove(int remove_mask) { profile_->GetTransportSecurityState(); ts_state->DeleteSince(delete_begin_); - // TODO(michaeln): clear appcaches created in the date range + waiting_for_clear_appcache_ = true; + ChromeThread::PostTask( + ChromeThread::IO, FROM_HERE, + NewRunnableMethod( + this, + &BrowsingDataRemover::ClearAppCacheOnIOThread, + delete_begin_)); // we assume end time == now } if (remove_mask & REMOVE_PASSWORDS) { @@ -336,3 +357,62 @@ void BrowsingDataRemover::ClearDatabasesOnFILEThread(base::Time delete_begin) { if (rv != net::ERR_IO_PENDING) OnClearedDatabases(rv); } + +void BrowsingDataRemover::OnClearedAppCache() { + if (!ChromeThread::CurrentlyOn(ChromeThread::UI)) { + bool result = ChromeThread::PostTask( + ChromeThread::UI, FROM_HERE, + NewRunnableMethod(this, &BrowsingDataRemover::OnClearedAppCache)); + DCHECK(result); + return; + } + waiting_for_clear_appcache_ = false; + NotifyAndDeleteIfDone(); +} + +void BrowsingDataRemover::ClearAppCacheOnIOThread(base::Time delete_begin) { + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); + DCHECK(waiting_for_clear_appcache_); + + appcache_info_ = new appcache::AppCacheInfoCollection; + GetAppCacheService()->GetAllAppCacheInfo( + appcache_info_, &appcache_got_info_callback_); + // continues in OnGotAppCacheInfo +} + +void BrowsingDataRemover::OnGotAppCacheInfo(int rv) { + using appcache::AppCacheInfoVector; + typedef std::map<GURL, AppCacheInfoVector> InfoByOrigin; + + for (InfoByOrigin::const_iterator origin = + appcache_info_->infos_by_origin.begin(); + origin != appcache_info_->infos_by_origin.end(); ++origin) { + for (AppCacheInfoVector::const_iterator info = origin->second.begin(); + info != origin->second.end(); ++info) { + if (info->creation_time > delete_begin_) { + ++appcaches_to_be_deleted_count_; + GetAppCacheService()->DeleteAppCacheGroup( + info->manifest_url, &appcache_deleted_callback_); + } + } + } + + if (!appcaches_to_be_deleted_count_) + OnClearedAppCache(); + // else continues in OnAppCacheDeleted +} + +void BrowsingDataRemover::OnAppCacheDeleted(int rv) { + --appcaches_to_be_deleted_count_; + if (!appcaches_to_be_deleted_count_) + OnClearedAppCache(); +} + +ChromeAppCacheService* BrowsingDataRemover::GetAppCacheService() { + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); + ChromeURLRequestContext* request_context = + reinterpret_cast<ChromeURLRequestContext*>( + request_context_getter_->GetURLRequestContext()); + return request_context ? request_context->appcache_service() + : NULL; +} |