Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: chrome/browser/ui/webui/history_ui.cc

Issue 12930011: History: Include search term in queries to history server. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address joao's comments. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/history/web_history_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_.size()) {
Dan Beam 2013/03/25 21:09:19 size() -> !empty()
Patrick Dubroy 2013/03/25 21:18:49 Done.
825 // Each result set covers a particular time range. Determine the 825 if (query_results_.size()) {
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 832 RemoveOlderEntries(&query_results_, cutoff_time);
833 int local_result_count = query_results_.size(); 833 RemoveOlderEntries(&web_history_query_results_, cutoff_time);
834 }
834 query_results_.insert(query_results_.end(), 835 query_results_.insert(query_results_.end(),
835 web_history_query_results_.begin(), 836 web_history_query_results_.begin(),
836 web_history_query_results_.end()); 837 web_history_query_results_.end());
837 RemoveDuplicateResults(&query_results_);
838 838
839 // In the best case, we expect that all local results are duplicated on the 839 if (query_results_.size()) {
Dan Beam 2013/03/25 21:09:19 ^ wont this always be non-empty now?
Patrick Dubroy 2013/03/25 21:18:49 Nope, RemoveOlderEntries might actually make it em
Dan Beam 2013/03/25 21:27:02 but there's a "querty_results_.insert()" call righ
Patrick Dubroy 2013/03/25 21:31:56 Yeah, you're right. Fixed.
840 // server. Keep track of how many are missing. 840 RemoveDuplicateResults(&query_results_);
841 if (local_result_count) { 841
842 // In the best case, we expect that all local results are duplicated on
843 // the server. Keep track of how many are missing.
842 int missing_count = std::count_if( 844 int missing_count = std::count_if(
843 query_results_.begin(), query_results_.end(), IsLocalOnlyResult); 845 query_results_.begin(), query_results_.end(), IsLocalOnlyResult);
844 UMA_HISTOGRAM_PERCENTAGE("WebHistory.LocalResultMissingOnServer", 846 UMA_HISTOGRAM_PERCENTAGE("WebHistory.LocalResultMissingOnServer",
845 missing_count * 100.0 / local_result_count); 847 missing_count * 100.0 / query_results_.size());
846 } 848 }
847 } 849 }
848 850
849 // Convert the result vector into a ListValue. 851 // Convert the result vector into a ListValue.
850 ListValue results_value; 852 ListValue results_value;
851 for (std::vector<BrowsingHistoryHandler::HistoryEntry>::iterator it = 853 for (std::vector<BrowsingHistoryHandler::HistoryEntry>::iterator it =
852 query_results_.begin(); it != query_results_.end(); ++it) { 854 query_results_.begin(); it != query_results_.end(); ++it) {
853 scoped_ptr<base::Value> value( 855 scoped_ptr<base::Value> value(
854 it->ToValue(bookmark_model, managed_user_service)); 856 it->ToValue(bookmark_model, managed_user_service));
855 results_value.Append(value.release()); 857 results_value.Append(value.release());
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + 1111 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" +
1110 net::EscapeQueryParamValue(UTF16ToUTF8(text), true)); 1112 net::EscapeQueryParamValue(UTF16ToUTF8(text), true));
1111 } 1113 }
1112 1114
1113 // static 1115 // static
1114 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( 1116 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes(
1115 ui::ScaleFactor scale_factor) { 1117 ui::ScaleFactor scale_factor) {
1116 return ResourceBundle::GetSharedInstance(). 1118 return ResourceBundle::GetSharedInstance().
1117 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); 1119 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor);
1118 } 1120 }
OLDNEW
« no previous file with comments | « chrome/browser/history/web_history_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698