| Index: chrome/browser/browsing_data/browsing_data_remover.cc
|
| diff --git a/chrome/browser/browsing_data/browsing_data_remover.cc b/chrome/browser/browsing_data/browsing_data_remover.cc
|
| index b7af2e1b448bdad66e7836002d665e4e863a9f2d..b8d8e90462794d3024079c69694c53f5315dde74 100644
|
| --- a/chrome/browser/browsing_data/browsing_data_remover.cc
|
| +++ b/chrome/browser/browsing_data/browsing_data_remover.cc
|
| @@ -177,6 +177,7 @@ BrowsingDataRemover::BrowsingDataRemover(Profile* profile,
|
| waiting_for_clear_session_storage_(false),
|
| waiting_for_clear_shader_cache_(false),
|
| waiting_for_clear_webrtc_identity_store_(false),
|
| + waiting_for_clear_keyword_data_(false),
|
| remove_mask_(0),
|
| remove_origin_(GURL()),
|
| origin_set_mask_(0) {
|
| @@ -304,9 +305,11 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
|
| TemplateURLService* keywords_model =
|
| TemplateURLServiceFactory::GetForProfile(profile_);
|
| if (keywords_model && !keywords_model->loaded()) {
|
| - registrar_.Add(this, chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED,
|
| - content::Source<TemplateURLService>(keywords_model));
|
| + template_url_sub_ = keywords_model->RegisterOnLoadedCallback(
|
| + base::Bind(&BrowsingDataRemover::OnKeywordsLoaded,
|
| + base::Unretained(this)));
|
| keywords_model->Load();
|
| + waiting_for_clear_keyword_data_ = true;
|
| } else if (keywords_model) {
|
| keywords_model->RemoveAutoGeneratedForOriginBetween(remove_origin_,
|
| delete_begin_, delete_end_);
|
| @@ -643,7 +646,8 @@ base::Time BrowsingDataRemover::CalculateBeginDeleteTime(
|
| }
|
|
|
| bool BrowsingDataRemover::AllDone() {
|
| - return registrar_.IsEmpty() && !waiting_for_clear_autofill_origin_urls_ &&
|
| + return !waiting_for_clear_keyword_data_ &&
|
| + !waiting_for_clear_autofill_origin_urls_ &&
|
| !waiting_for_clear_cache_ && !waiting_for_clear_nacl_cache_ &&
|
| !waiting_for_clear_cookies_count_ && !waiting_for_clear_history_ &&
|
| !waiting_for_clear_local_storage_ &&
|
| @@ -661,23 +665,23 @@ bool BrowsingDataRemover::AllDone() {
|
| !waiting_for_clear_webrtc_identity_store_;
|
| }
|
|
|
| -void BrowsingDataRemover::Observe(int type,
|
| - const content::NotificationSource& source,
|
| - const content::NotificationDetails& details) {
|
| - // TODO(brettw) bug 1139736: This should also observe session
|
| - // clearing (what about other things such as passwords, etc.?) and wait for
|
| - // them to complete before continuing.
|
| - DCHECK(type == chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED);
|
| - TemplateURLService* model = content::Source<TemplateURLService>(source).ptr();
|
| - if (model->profile() == profile_) {
|
| - registrar_.RemoveAll();
|
| - model->RemoveAutoGeneratedBetween(delete_begin_, delete_end_);
|
| - NotifyAndDeleteIfDone();
|
| - }
|
| +void BrowsingDataRemover::OnKeywordsLoaded() {
|
| + // Deletes the entries from the model, and if we're not waiting on anything
|
| + // else notifies observers and deletes this BrowsingDataRemover.
|
| + TemplateURLService* model =
|
| + TemplateURLServiceFactory::GetForProfile(profile_);
|
| + DCHECK_EQ(profile_, model->profile());
|
| + model->RemoveAutoGeneratedBetween(delete_begin_, delete_end_);
|
| + waiting_for_clear_keyword_data_ = false;
|
| + template_url_sub_.reset();
|
| + NotifyAndDeleteIfDone();
|
| }
|
|
|
| void BrowsingDataRemover::NotifyAndDeleteIfDone() {
|
| - // TODO(brettw) bug 1139736: see TODO in Observe() above.
|
| + // TODO(brettw) http://crbug.com/305259: This should also observe session
|
| + // clearing (what about other things such as passwords, etc.?) and wait for
|
| + // them to complete before continuing.
|
| +
|
| if (!AllDone())
|
| return;
|
|
|
|
|