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/history/top_sites.h" | 5 #include "chrome/browser/history/top_sites.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 if (!loaded_) | 675 if (!loaded_) |
676 return; | 676 return; |
677 | 677 |
678 if (type == chrome::NOTIFICATION_HISTORY_URLS_DELETED) { | 678 if (type == chrome::NOTIFICATION_HISTORY_URLS_DELETED) { |
679 content::Details<history::URLsDeletedDetails> deleted_details(details); | 679 content::Details<history::URLsDeletedDetails> deleted_details(details); |
680 if (deleted_details->all_history) { | 680 if (deleted_details->all_history) { |
681 SetTopSites(MostVisitedURLList()); | 681 SetTopSites(MostVisitedURLList()); |
682 backend_->ResetDatabase(); | 682 backend_->ResetDatabase(); |
683 } else { | 683 } else { |
684 std::set<size_t> indices_to_delete; // Indices into top_sites_. | 684 std::set<size_t> indices_to_delete; // Indices into top_sites_. |
685 for (std::set<GURL>::iterator i = deleted_details->urls.begin(); | 685 for (URLRows::const_iterator i = deleted_details->rows.begin(); |
686 i != deleted_details->urls.end(); ++i) { | 686 i != deleted_details->rows.end(); ++i) { |
687 if (cache_->IsKnownURL(*i)) | 687 if (cache_->IsKnownURL(i->url())) |
688 indices_to_delete.insert(cache_->GetURLIndex(*i)); | 688 indices_to_delete.insert(cache_->GetURLIndex(i->url())); |
689 } | 689 } |
690 | 690 |
691 if (indices_to_delete.empty()) | 691 if (indices_to_delete.empty()) |
692 return; | 692 return; |
693 | 693 |
694 MostVisitedURLList new_top_sites(cache_->top_sites()); | 694 MostVisitedURLList new_top_sites(cache_->top_sites()); |
695 for (std::set<size_t>::reverse_iterator i = indices_to_delete.rbegin(); | 695 for (std::set<size_t>::reverse_iterator i = indices_to_delete.rbegin(); |
696 i != indices_to_delete.rend(); i++) { | 696 i != indices_to_delete.rend(); i++) { |
697 new_top_sites.erase(new_top_sites.begin() + *i); | 697 new_top_sites.erase(new_top_sites.begin() + *i); |
698 } | 698 } |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 SetTopSites(pages); | 893 SetTopSites(pages); |
894 | 894 |
895 // Used only in testing. | 895 // Used only in testing. |
896 content::NotificationService::current()->Notify( | 896 content::NotificationService::current()->Notify( |
897 chrome::NOTIFICATION_TOP_SITES_UPDATED, | 897 chrome::NOTIFICATION_TOP_SITES_UPDATED, |
898 content::Source<TopSites>(this), | 898 content::Source<TopSites>(this), |
899 content::Details<CancelableRequestProvider::Handle>(&handle)); | 899 content::Details<CancelableRequestProvider::Handle>(&handle)); |
900 } | 900 } |
901 | 901 |
902 } // namespace history | 902 } // namespace history |
OLD | NEW |