| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 BrowserThread::PostTask( | 298 BrowserThread::PostTask( |
| 298 BrowserThread::IO, FROM_HERE, | 299 BrowserThread::IO, FROM_HERE, |
| 299 base::Bind(&BrowsingDataRemover::ClearNetworkPredictorOnIOThread, | 300 base::Bind(&BrowsingDataRemover::ClearNetworkPredictorOnIOThread, |
| 300 base::Unretained(this))); | 301 base::Unretained(this))); |
| 301 } | 302 } |
| 302 | 303 |
| 303 // As part of history deletion we also delete the auto-generated keywords. | 304 // As part of history deletion we also delete the auto-generated keywords. |
| 304 TemplateURLService* keywords_model = | 305 TemplateURLService* keywords_model = |
| 305 TemplateURLServiceFactory::GetForProfile(profile_); | 306 TemplateURLServiceFactory::GetForProfile(profile_); |
| 306 if (keywords_model && !keywords_model->loaded()) { | 307 if (keywords_model && !keywords_model->loaded()) { |
| 307 registrar_.Add(this, chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, | 308 template_url_sub_ = keywords_model->RegisterOnLoadedCallback( |
| 308 content::Source<TemplateURLService>(keywords_model)); | 309 base::Bind(&BrowsingDataRemover::OnKeywordsLoaded, |
| 310 base::Unretained(this))); |
| 309 keywords_model->Load(); | 311 keywords_model->Load(); |
| 312 waiting_for_clear_keyword_data_ = true; |
| 310 } else if (keywords_model) { | 313 } else if (keywords_model) { |
| 311 keywords_model->RemoveAutoGeneratedForOriginBetween(remove_origin_, | 314 keywords_model->RemoveAutoGeneratedForOriginBetween(remove_origin_, |
| 312 delete_begin_, delete_end_); | 315 delete_begin_, delete_end_); |
| 313 } | 316 } |
| 314 | 317 |
| 315 // The PrerenderManager keeps history of prerendered pages, so clear that. | 318 // The PrerenderManager keeps history of prerendered pages, so clear that. |
| 316 // It also may have a prerendered page. If so, the page could be | 319 // 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 | 320 // considered to have a small amount of historical information, so delete |
| 318 // it, too. | 321 // it, too. |
| 319 prerender::PrerenderManager* prerender_manager = | 322 prerender::PrerenderManager* prerender_manager = |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 delete_begin_time = base::Time(); | 639 delete_begin_time = base::Time(); |
| 637 break; | 640 break; |
| 638 default: | 641 default: |
| 639 NOTREACHED() << L"Missing item"; | 642 NOTREACHED() << L"Missing item"; |
| 640 break; | 643 break; |
| 641 } | 644 } |
| 642 return delete_begin_time - diff; | 645 return delete_begin_time - diff; |
| 643 } | 646 } |
| 644 | 647 |
| 645 bool BrowsingDataRemover::AllDone() { | 648 bool BrowsingDataRemover::AllDone() { |
| 646 return registrar_.IsEmpty() && !waiting_for_clear_autofill_origin_urls_ && | 649 return !waiting_for_clear_keyword_data_ && |
| 650 !waiting_for_clear_autofill_origin_urls_ && |
| 647 !waiting_for_clear_cache_ && !waiting_for_clear_nacl_cache_ && | 651 !waiting_for_clear_cache_ && !waiting_for_clear_nacl_cache_ && |
| 648 !waiting_for_clear_cookies_count_ && !waiting_for_clear_history_ && | 652 !waiting_for_clear_cookies_count_ && !waiting_for_clear_history_ && |
| 649 !waiting_for_clear_local_storage_ && | 653 !waiting_for_clear_local_storage_ && |
| 650 !waiting_for_clear_logged_in_predictor_ && | 654 !waiting_for_clear_logged_in_predictor_ && |
| 651 !waiting_for_clear_session_storage_ && | 655 !waiting_for_clear_session_storage_ && |
| 652 !waiting_for_clear_networking_history_ && | 656 !waiting_for_clear_networking_history_ && |
| 653 !waiting_for_clear_server_bound_certs_ && | 657 !waiting_for_clear_server_bound_certs_ && |
| 654 !waiting_for_clear_plugin_data_ && | 658 !waiting_for_clear_plugin_data_ && |
| 655 !waiting_for_clear_pnacl_cache_ && | 659 !waiting_for_clear_pnacl_cache_ && |
| 656 !waiting_for_clear_quota_managed_data_ && | 660 !waiting_for_clear_quota_managed_data_ && |
| 657 !waiting_for_clear_content_licenses_ && !waiting_for_clear_form_ && | 661 !waiting_for_clear_content_licenses_ && !waiting_for_clear_form_ && |
| 658 !waiting_for_clear_hostname_resolution_cache_ && | 662 !waiting_for_clear_hostname_resolution_cache_ && |
| 659 !waiting_for_clear_network_predictor_ && | 663 !waiting_for_clear_network_predictor_ && |
| 660 !waiting_for_clear_shader_cache_ && | 664 !waiting_for_clear_shader_cache_ && |
| 661 !waiting_for_clear_webrtc_identity_store_; | 665 !waiting_for_clear_webrtc_identity_store_; |
| 662 } | 666 } |
| 663 | 667 |
| 664 void BrowsingDataRemover::Observe(int type, | 668 void BrowsingDataRemover::OnKeywordsLoaded() { |
| 665 const content::NotificationSource& source, | 669 // Deletes the entries from the model, and if we're not waiting on anything |
| 666 const content::NotificationDetails& details) { | 670 // else notifies observers and deletes this BrowsingDataRemover. |
| 667 // TODO(brettw) bug 1139736: This should also observe session | 671 TemplateURLService* model = |
| 668 // clearing (what about other things such as passwords, etc.?) and wait for | 672 TemplateURLServiceFactory::GetForProfile(profile_); |
| 669 // them to complete before continuing. | 673 DCHECK_EQ(profile_, model->profile()); |
| 670 DCHECK(type == chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED); | 674 model->RemoveAutoGeneratedBetween(delete_begin_, delete_end_); |
| 671 TemplateURLService* model = content::Source<TemplateURLService>(source).ptr(); | 675 waiting_for_clear_keyword_data_ = false; |
| 672 if (model->profile() == profile_) { | 676 template_url_sub_.reset(); |
| 673 registrar_.RemoveAll(); | 677 NotifyAndDeleteIfDone(); |
| 674 model->RemoveAutoGeneratedBetween(delete_begin_, delete_end_); | |
| 675 NotifyAndDeleteIfDone(); | |
| 676 } | |
| 677 } | 678 } |
| 678 | 679 |
| 679 void BrowsingDataRemover::NotifyAndDeleteIfDone() { | 680 void BrowsingDataRemover::NotifyAndDeleteIfDone() { |
| 680 // TODO(brettw) bug 1139736: see TODO in Observe() above. | 681 // TODO(brettw) http://crbug.com/305259: This should also observe session |
| 682 // clearing (what about other things such as passwords, etc.?) and wait for |
| 683 // them to complete before continuing. |
| 684 |
| 681 if (!AllDone()) | 685 if (!AllDone()) |
| 682 return; | 686 return; |
| 683 | 687 |
| 684 set_removing(false); | 688 set_removing(false); |
| 685 | 689 |
| 686 // Send global notification, then notify any explicit observers. | 690 // Send global notification, then notify any explicit observers. |
| 687 BrowsingDataRemover::NotificationDetails details(delete_begin_, remove_mask_, | 691 BrowsingDataRemover::NotificationDetails details(delete_begin_, remove_mask_, |
| 688 origin_set_mask_); | 692 origin_set_mask_); |
| 689 content::NotificationService::current()->Notify( | 693 content::NotificationService::current()->Notify( |
| 690 chrome::NOTIFICATION_BROWSING_DATA_REMOVED, | 694 chrome::NOTIFICATION_BROWSING_DATA_REMOVED, |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1176 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1180 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1177 waiting_for_clear_autofill_origin_urls_ = false; | 1181 waiting_for_clear_autofill_origin_urls_ = false; |
| 1178 NotifyAndDeleteIfDone(); | 1182 NotifyAndDeleteIfDone(); |
| 1179 } | 1183 } |
| 1180 | 1184 |
| 1181 void BrowsingDataRemover::OnClearWebRTCIdentityStore() { | 1185 void BrowsingDataRemover::OnClearWebRTCIdentityStore() { |
| 1182 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1186 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1183 waiting_for_clear_webrtc_identity_store_ = false; | 1187 waiting_for_clear_webrtc_identity_store_ = false; |
| 1184 NotifyAndDeleteIfDone(); | 1188 NotifyAndDeleteIfDone(); |
| 1185 } | 1189 } |
| OLD | NEW |