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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 waiting_for_clear_nacl_cache_(false), | 170 waiting_for_clear_nacl_cache_(false), |
| 171 waiting_for_clear_network_predictor_(false), | 171 waiting_for_clear_network_predictor_(false), |
| 172 waiting_for_clear_networking_history_(false), | 172 waiting_for_clear_networking_history_(false), |
| 173 waiting_for_clear_plugin_data_(false), | 173 waiting_for_clear_plugin_data_(false), |
| 174 waiting_for_clear_pnacl_cache_(false), | 174 waiting_for_clear_pnacl_cache_(false), |
| 175 waiting_for_clear_quota_managed_data_(false), | 175 waiting_for_clear_quota_managed_data_(false), |
| 176 waiting_for_clear_server_bound_certs_(false), | 176 waiting_for_clear_server_bound_certs_(false), |
| 177 waiting_for_clear_session_storage_(false), | 177 waiting_for_clear_session_storage_(false), |
| 178 waiting_for_clear_shader_cache_(false), | 178 waiting_for_clear_shader_cache_(false), |
| 179 waiting_for_clear_webrtc_identity_store_(false), | 179 waiting_for_clear_webrtc_identity_store_(false), |
| 180 waiting_for_clear_keyword_data_(false), | |
| 180 remove_mask_(0), | 181 remove_mask_(0), |
| 181 remove_origin_(GURL()), | 182 remove_origin_(GURL()), |
| 182 origin_set_mask_(0) { | 183 origin_set_mask_(0) { |
| 183 DCHECK(profile); | 184 DCHECK(profile); |
| 184 // crbug.com/140910: Many places were calling this with base::Time() as | 185 // crbug.com/140910: Many places were calling this with base::Time() as |
| 185 // delete_end, even though they should've used base::Time::Max(). Work around | 186 // delete_end, even though they should've used base::Time::Max(). Work around |
| 186 // it here. New code should use base::Time::Max(). | 187 // it here. New code should use base::Time::Max(). |
| 187 DCHECK(delete_end_ != base::Time()); | 188 DCHECK(delete_end_ != base::Time()); |
| 188 if (delete_end_ == base::Time()) | 189 if (delete_end_ == base::Time()) |
| 189 delete_end_ = base::Time::Max(); | 190 delete_end_ = base::Time::Max(); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 214 return quota_client_mask; | 215 return quota_client_mask; |
| 215 } | 216 } |
| 216 | 217 |
| 217 void BrowsingDataRemover::Remove(int remove_mask, int origin_set_mask) { | 218 void BrowsingDataRemover::Remove(int remove_mask, int origin_set_mask) { |
| 218 RemoveImpl(remove_mask, GURL(), origin_set_mask); | 219 RemoveImpl(remove_mask, GURL(), origin_set_mask); |
| 219 } | 220 } |
| 220 | 221 |
| 221 void BrowsingDataRemover::RemoveImpl(int remove_mask, | 222 void BrowsingDataRemover::RemoveImpl(int remove_mask, |
| 222 const GURL& origin, | 223 const GURL& origin, |
| 223 int origin_set_mask) { | 224 int origin_set_mask) { |
| 225 // TODO(brettw) bug 1139736: This should also observe session | |
| 226 // clearing (what about other things such as passwords, etc.?) and wait for | |
|
Cait (Slow)
2013/10/03 15:38:55
brettw: Is this buganizer bug still relevant? If s
| |
| 227 // them to complete before continuing. | |
| 228 | |
| 224 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 229 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 225 set_removing(true); | 230 set_removing(true); |
| 226 remove_mask_ = remove_mask; | 231 remove_mask_ = remove_mask; |
| 227 remove_origin_ = origin; | 232 remove_origin_ = origin; |
| 228 origin_set_mask_ = origin_set_mask; | 233 origin_set_mask_ = origin_set_mask; |
| 229 | 234 |
| 230 PrefService* prefs = profile_->GetPrefs(); | 235 PrefService* prefs = profile_->GetPrefs(); |
| 231 bool may_delete_history = prefs->GetBoolean( | 236 bool may_delete_history = prefs->GetBoolean( |
| 232 prefs::kAllowDeletingBrowserHistory); | 237 prefs::kAllowDeletingBrowserHistory); |
| 233 | 238 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 BrowserThread::PostTask( | 302 BrowserThread::PostTask( |
| 298 BrowserThread::IO, FROM_HERE, | 303 BrowserThread::IO, FROM_HERE, |
| 299 base::Bind(&BrowsingDataRemover::ClearNetworkPredictorOnIOThread, | 304 base::Bind(&BrowsingDataRemover::ClearNetworkPredictorOnIOThread, |
| 300 base::Unretained(this))); | 305 base::Unretained(this))); |
| 301 } | 306 } |
| 302 | 307 |
| 303 // As part of history deletion we also delete the auto-generated keywords. | 308 // As part of history deletion we also delete the auto-generated keywords. |
| 304 TemplateURLService* keywords_model = | 309 TemplateURLService* keywords_model = |
| 305 TemplateURLServiceFactory::GetForProfile(profile_); | 310 TemplateURLServiceFactory::GetForProfile(profile_); |
| 306 if (keywords_model && !keywords_model->loaded()) { | 311 if (keywords_model && !keywords_model->loaded()) { |
| 307 registrar_.Add(this, chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, | 312 template_url_sub_ = keywords_model->RegisterOnLoadedCallback( |
| 308 content::Source<TemplateURLService>(keywords_model)); | 313 base::Bind(&BrowsingDataRemover::OnKeywordsLoaded, |
| 314 base::Unretained(this))); | |
| 309 keywords_model->Load(); | 315 keywords_model->Load(); |
| 316 waiting_for_clear_keyword_data_ = true; | |
| 310 } else if (keywords_model) { | 317 } else if (keywords_model) { |
| 311 keywords_model->RemoveAutoGeneratedForOriginBetween(remove_origin_, | 318 keywords_model->RemoveAutoGeneratedForOriginBetween(remove_origin_, |
| 312 delete_begin_, delete_end_); | 319 delete_begin_, delete_end_); |
| 313 } | 320 } |
| 314 | 321 |
| 315 // The PrerenderManager keeps history of prerendered pages, so clear that. | 322 // The PrerenderManager keeps history of prerendered pages, so clear that. |
| 316 // It also may have a prerendered page. If so, the page could be | 323 // It also may have a prerendered page. If so, the page could be |
| 317 // considered to have a small amount of historical information, so delete | 324 // considered to have a small amount of historical information, so delete |
| 318 // it, too. | 325 // it, too. |
| 319 prerender::PrerenderManager* prerender_manager = | 326 prerender::PrerenderManager* prerender_manager = |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 636 delete_begin_time = base::Time(); | 643 delete_begin_time = base::Time(); |
| 637 break; | 644 break; |
| 638 default: | 645 default: |
| 639 NOTREACHED() << L"Missing item"; | 646 NOTREACHED() << L"Missing item"; |
| 640 break; | 647 break; |
| 641 } | 648 } |
| 642 return delete_begin_time - diff; | 649 return delete_begin_time - diff; |
| 643 } | 650 } |
| 644 | 651 |
| 645 bool BrowsingDataRemover::AllDone() { | 652 bool BrowsingDataRemover::AllDone() { |
| 646 return registrar_.IsEmpty() && !waiting_for_clear_autofill_origin_urls_ && | 653 return !waiting_for_clear_keyword_data_ && |
| 654 !waiting_for_clear_autofill_origin_urls_ && | |
| 647 !waiting_for_clear_cache_ && !waiting_for_clear_nacl_cache_ && | 655 !waiting_for_clear_cache_ && !waiting_for_clear_nacl_cache_ && |
| 648 !waiting_for_clear_cookies_count_ && !waiting_for_clear_history_ && | 656 !waiting_for_clear_cookies_count_ && !waiting_for_clear_history_ && |
| 649 !waiting_for_clear_local_storage_ && | 657 !waiting_for_clear_local_storage_ && |
| 650 !waiting_for_clear_logged_in_predictor_ && | 658 !waiting_for_clear_logged_in_predictor_ && |
| 651 !waiting_for_clear_session_storage_ && | 659 !waiting_for_clear_session_storage_ && |
| 652 !waiting_for_clear_networking_history_ && | 660 !waiting_for_clear_networking_history_ && |
| 653 !waiting_for_clear_server_bound_certs_ && | 661 !waiting_for_clear_server_bound_certs_ && |
| 654 !waiting_for_clear_plugin_data_ && | 662 !waiting_for_clear_plugin_data_ && |
| 655 !waiting_for_clear_pnacl_cache_ && | 663 !waiting_for_clear_pnacl_cache_ && |
| 656 !waiting_for_clear_quota_managed_data_ && | 664 !waiting_for_clear_quota_managed_data_ && |
| 657 !waiting_for_clear_content_licenses_ && !waiting_for_clear_form_ && | 665 !waiting_for_clear_content_licenses_ && !waiting_for_clear_form_ && |
| 658 !waiting_for_clear_hostname_resolution_cache_ && | 666 !waiting_for_clear_hostname_resolution_cache_ && |
| 659 !waiting_for_clear_network_predictor_ && | 667 !waiting_for_clear_network_predictor_ && |
| 660 !waiting_for_clear_shader_cache_ && | 668 !waiting_for_clear_shader_cache_ && |
| 661 !waiting_for_clear_webrtc_identity_store_; | 669 !waiting_for_clear_webrtc_identity_store_; |
| 662 } | 670 } |
| 663 | 671 |
| 664 void BrowsingDataRemover::Observe(int type, | 672 void BrowsingDataRemover::OnKeywordsLoaded() { |
| 665 const content::NotificationSource& source, | 673 // Deletes the entries from the model, and if we're not waiting on anything |
| 666 const content::NotificationDetails& details) { | 674 // else notifies observers and deletes this BrowsingDataRemover. |
| 667 // TODO(brettw) bug 1139736: This should also observe session | 675 TemplateURLService* model = |
| 668 // clearing (what about other things such as passwords, etc.?) and wait for | 676 TemplateURLServiceFactory::GetForProfile(profile_); |
| 669 // them to complete before continuing. | 677 DCHECK(model->profile() == profile_); |
| 670 DCHECK(type == chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED); | 678 model->RemoveAutoGeneratedBetween(delete_begin_, delete_end_); |
| 671 TemplateURLService* model = content::Source<TemplateURLService>(source).ptr(); | 679 waiting_for_clear_keyword_data_ = false; |
| 672 if (model->profile() == profile_) { | 680 template_url_sub_.reset(); |
| 673 registrar_.RemoveAll(); | 681 NotifyAndDeleteIfDone(); |
| 674 model->RemoveAutoGeneratedBetween(delete_begin_, delete_end_); | |
| 675 NotifyAndDeleteIfDone(); | |
| 676 } | |
| 677 } | 682 } |
| 678 | 683 |
| 679 void BrowsingDataRemover::NotifyAndDeleteIfDone() { | 684 void BrowsingDataRemover::NotifyAndDeleteIfDone() { |
| 680 // TODO(brettw) bug 1139736: see TODO in Observe() above. | 685 // TODO(brettw) bug 1139736: see TODO in Observe() above. |
| 681 if (!AllDone()) | 686 if (!AllDone()) |
| 682 return; | 687 return; |
| 683 | 688 |
| 684 set_removing(false); | 689 set_removing(false); |
| 685 | 690 |
| 686 // Send global notification, then notify any explicit observers. | 691 // Send global notification, then notify any explicit observers. |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1176 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1181 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1177 waiting_for_clear_autofill_origin_urls_ = false; | 1182 waiting_for_clear_autofill_origin_urls_ = false; |
| 1178 NotifyAndDeleteIfDone(); | 1183 NotifyAndDeleteIfDone(); |
| 1179 } | 1184 } |
| 1180 | 1185 |
| 1181 void BrowsingDataRemover::OnClearWebRTCIdentityStore() { | 1186 void BrowsingDataRemover::OnClearWebRTCIdentityStore() { |
| 1182 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1187 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1183 waiting_for_clear_webrtc_identity_store_ = false; | 1188 waiting_for_clear_webrtc_identity_store_ = false; |
| 1184 NotifyAndDeleteIfDone(); | 1189 NotifyAndDeleteIfDone(); |
| 1185 } | 1190 } |
| OLD | NEW |