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/ui/webui/history_ui.h" | 5 #include "chrome/browser/ui/webui/history_ui.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 void BrowsingHistoryHandler::ReturnResultsToFrontEnd() { | 814 void BrowsingHistoryHandler::ReturnResultsToFrontEnd() { |
815 Profile* profile = Profile::FromWebUI(web_ui()); | 815 Profile* profile = Profile::FromWebUI(web_ui()); |
816 BookmarkModel* bookmark_model = BookmarkModelFactory::GetForProfile(profile); | 816 BookmarkModel* bookmark_model = BookmarkModelFactory::GetForProfile(profile); |
817 ManagedUserService* managed_user_service = NULL; | 817 ManagedUserService* managed_user_service = NULL; |
818 #if defined(ENABLE_MANAGED_USERS) | 818 #if defined(ENABLE_MANAGED_USERS) |
819 managed_user_service = ManagedUserServiceFactory::GetForProfile(profile); | 819 managed_user_service = ManagedUserServiceFactory::GetForProfile(profile); |
820 #endif | 820 #endif |
821 | 821 |
822 // Combine the local and remote results into |query_results_|, and remove | 822 // Combine the local and remote results into |query_results_|, and remove |
823 // any duplicates. | 823 // any duplicates. |
824 if (query_results_.size() && web_history_query_results_.size()) { | 824 if (!web_history_query_results_.empty()) { |
825 // Each result set covers a particular time range. Determine the | 825 if (!query_results_.empty()) { |
826 // intersection of the two time ranges, discard any entries from either | 826 // Each result set covers a particular time range. Determine the |
827 // set the are older than that, and then combine the results. | 827 // intersection of the two time ranges, discard any entries from either |
828 base::Time cutoff_time = std::max(query_results_.back().time, | 828 // set that are older than that, and then combine the results. |
829 web_history_query_results_.back().time); | 829 base::Time cutoff_time = std::max( |
830 RemoveOlderEntries(&query_results_, cutoff_time); | 830 query_results_.back().time, |
831 RemoveOlderEntries(&web_history_query_results_, cutoff_time); | 831 web_history_query_results_.back().time); |
| 832 RemoveOlderEntries(&query_results_, cutoff_time); |
| 833 RemoveOlderEntries(&web_history_query_results_, cutoff_time); |
| 834 } |
832 | 835 |
833 int local_result_count = query_results_.size(); | 836 int local_result_count = query_results_.size(); |
834 query_results_.insert(query_results_.end(), | 837 query_results_.insert(query_results_.end(), |
835 web_history_query_results_.begin(), | 838 web_history_query_results_.begin(), |
836 web_history_query_results_.end()); | 839 web_history_query_results_.end()); |
837 RemoveDuplicateResults(&query_results_); | 840 RemoveDuplicateResults(&query_results_); |
838 | 841 |
839 // In the best case, we expect that all local results are duplicated on the | |
840 // server. Keep track of how many are missing. | |
841 if (local_result_count) { | 842 if (local_result_count) { |
| 843 // In the best case, we expect that all local results are duplicated on |
| 844 // the server. Keep track of how many are missing. |
842 int missing_count = std::count_if( | 845 int missing_count = std::count_if( |
843 query_results_.begin(), query_results_.end(), IsLocalOnlyResult); | 846 query_results_.begin(), query_results_.end(), IsLocalOnlyResult); |
844 UMA_HISTOGRAM_PERCENTAGE("WebHistory.LocalResultMissingOnServer", | 847 UMA_HISTOGRAM_PERCENTAGE("WebHistory.LocalResultMissingOnServer", |
845 missing_count * 100.0 / local_result_count); | 848 missing_count * 100.0 / local_result_count); |
846 } | 849 } |
847 } | 850 } |
848 | 851 |
849 // Convert the result vector into a ListValue. | 852 // Convert the result vector into a ListValue. |
850 ListValue results_value; | 853 ListValue results_value; |
851 for (std::vector<BrowsingHistoryHandler::HistoryEntry>::iterator it = | 854 for (std::vector<BrowsingHistoryHandler::HistoryEntry>::iterator it = |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + | 1112 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + |
1110 net::EscapeQueryParamValue(UTF16ToUTF8(text), true)); | 1113 net::EscapeQueryParamValue(UTF16ToUTF8(text), true)); |
1111 } | 1114 } |
1112 | 1115 |
1113 // static | 1116 // static |
1114 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( | 1117 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( |
1115 ui::ScaleFactor scale_factor) { | 1118 ui::ScaleFactor scale_factor) { |
1116 return ResourceBundle::GetSharedInstance(). | 1119 return ResourceBundle::GetSharedInstance(). |
1117 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); | 1120 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); |
1118 } | 1121 } |
OLD | NEW |