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

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

Issue 1143183002: Proof of concept implementation of context based history filtering. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « chrome/browser/ui/webui/history_ui.h ('k') | components/history/core/browser/history_backend.h » ('j') | 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 source->AddBoolean("isUserSignedIn", is_authenticated); 129 source->AddBoolean("isUserSignedIn", is_authenticated);
130 source->AddLocalizedString("collapseSessionMenuItemText", 130 source->AddLocalizedString("collapseSessionMenuItemText",
131 IDS_NEW_TAB_OTHER_SESSIONS_COLLAPSE_SESSION); 131 IDS_NEW_TAB_OTHER_SESSIONS_COLLAPSE_SESSION);
132 source->AddLocalizedString("expandSessionMenuItemText", 132 source->AddLocalizedString("expandSessionMenuItemText",
133 IDS_NEW_TAB_OTHER_SESSIONS_EXPAND_SESSION); 133 IDS_NEW_TAB_OTHER_SESSIONS_EXPAND_SESSION);
134 source->AddLocalizedString("restoreSessionMenuItemText", 134 source->AddLocalizedString("restoreSessionMenuItemText",
135 IDS_NEW_TAB_OTHER_SESSIONS_OPEN_ALL); 135 IDS_NEW_TAB_OTHER_SESSIONS_OPEN_ALL);
136 source->AddLocalizedString("xMore", IDS_OTHER_DEVICES_X_MORE); 136 source->AddLocalizedString("xMore", IDS_OTHER_DEVICES_X_MORE);
137 source->AddLocalizedString("loading", IDS_HISTORY_LOADING); 137 source->AddLocalizedString("loading", IDS_HISTORY_LOADING);
138 source->AddLocalizedString("title", IDS_HISTORY_TITLE); 138 source->AddLocalizedString("title", IDS_HISTORY_TITLE);
139 source->AddLocalizedString("context", IDS_HISTORY_CONTEXT);
139 source->AddLocalizedString("newest", IDS_HISTORY_NEWEST); 140 source->AddLocalizedString("newest", IDS_HISTORY_NEWEST);
140 source->AddLocalizedString("newer", IDS_HISTORY_NEWER); 141 source->AddLocalizedString("newer", IDS_HISTORY_NEWER);
141 source->AddLocalizedString("older", IDS_HISTORY_OLDER); 142 source->AddLocalizedString("older", IDS_HISTORY_OLDER);
142 source->AddLocalizedString("searchResultsFor", IDS_HISTORY_SEARCHRESULTSFOR); 143 source->AddLocalizedString("searchResultsFor", IDS_HISTORY_SEARCHRESULTSFOR);
143 source->AddLocalizedString("searchResult", IDS_HISTORY_SEARCH_RESULT); 144 source->AddLocalizedString("searchResult", IDS_HISTORY_SEARCH_RESULT);
144 source->AddLocalizedString("searchResults", IDS_HISTORY_SEARCH_RESULTS); 145 source->AddLocalizedString("searchResults", IDS_HISTORY_SEARCH_RESULTS);
145 source->AddLocalizedString("foundSearchResults", 146 source->AddLocalizedString("foundSearchResults",
146 IDS_HISTORY_FOUND_SEARCH_RESULTS); 147 IDS_HISTORY_FOUND_SEARCH_RESULTS);
147 source->AddLocalizedString("history", IDS_HISTORY_BROWSERESULTS); 148 source->AddLocalizedString("history", IDS_HISTORY_BROWSERESULTS);
148 source->AddLocalizedString("cont", IDS_HISTORY_CONTINUED); 149 source->AddLocalizedString("cont", IDS_HISTORY_CONTINUED);
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 } // namespace 286 } // namespace
286 287
287 //////////////////////////////////////////////////////////////////////////////// 288 ////////////////////////////////////////////////////////////////////////////////
288 // 289 //
289 // BrowsingHistoryHandler 290 // BrowsingHistoryHandler
290 // 291 //
291 //////////////////////////////////////////////////////////////////////////////// 292 ////////////////////////////////////////////////////////////////////////////////
292 293
293 BrowsingHistoryHandler::HistoryEntry::HistoryEntry( 294 BrowsingHistoryHandler::HistoryEntry::HistoryEntry(
294 BrowsingHistoryHandler::HistoryEntry::EntryType entry_type, 295 BrowsingHistoryHandler::HistoryEntry::EntryType entry_type,
295 const GURL& url, const base::string16& title, base::Time time, 296 const GURL& url, const base::string16& title, history::HistoryContext contex t, base::Time time,
296 const std::string& client_id, bool is_search_result, 297 const std::string& client_id, bool is_search_result,
297 const base::string16& snippet, bool blocked_visit, 298 const base::string16& snippet, bool blocked_visit,
298 const std::string& accept_languages) { 299 const std::string& accept_languages) {
299 this->entry_type = entry_type; 300 this->entry_type = entry_type;
300 this->url = url; 301 this->url = url;
301 this->title = title; 302 this->title = title;
303 this->context = context;
302 this->time = time; 304 this->time = time;
303 this->client_id = client_id; 305 this->client_id = client_id;
304 all_timestamps.insert(time.ToInternalValue()); 306 all_timestamps.insert(time.ToInternalValue());
305 this->is_search_result = is_search_result; 307 this->is_search_result = is_search_result;
306 this->snippet = snippet; 308 this->snippet = snippet;
307 this->blocked_visit = blocked_visit; 309 this->blocked_visit = blocked_visit;
308 this->accept_languages = accept_languages; 310 this->accept_languages = accept_languages;
309 } 311 }
310 312
311 BrowsingHistoryHandler::HistoryEntry::HistoryEntry() 313 BrowsingHistoryHandler::HistoryEntry::HistoryEntry()
312 : entry_type(EMPTY_ENTRY), is_search_result(false), blocked_visit(false) { 314 : entry_type(EMPTY_ENTRY), is_search_result(false), blocked_visit(false) {
313 } 315 }
314 316
315 BrowsingHistoryHandler::HistoryEntry::~HistoryEntry() { 317 BrowsingHistoryHandler::HistoryEntry::~HistoryEntry() {
316 } 318 }
317 319
318 void BrowsingHistoryHandler::HistoryEntry::SetUrlAndTitle( 320 void BrowsingHistoryHandler::HistoryEntry::SetUrlAndTitle(
319 base::DictionaryValue* result) const { 321 base::DictionaryValue* result) const {
320 result->SetString("url", url.spec()); 322 result->SetString("url", url.spec());
323 result->SetInteger("context", static_cast<int>(context));
321 324
322 bool using_url_as_the_title = false; 325 bool using_url_as_the_title = false;
323 base::string16 title_to_set(title); 326 base::string16 title_to_set(title);
324 if (title.empty()) { 327 if (title.empty()) {
325 using_url_as_the_title = true; 328 using_url_as_the_title = true;
326 title_to_set = base::UTF8ToUTF16(url.spec()); 329 title_to_set = base::UTF8ToUTF16(url.spec());
327 } 330 }
328 331
329 // Since the title can contain BiDi text, we need to mark the text as either 332 // Since the title can contain BiDi text, we need to mark the text as either
330 // RTL or LTR, depending on the characters in the string. If we use the URL 333 // RTL or LTR, depending on the characters in the string. If we use the URL
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 else if (range == BrowsingHistoryHandler::WEEK) 554 else if (range == BrowsingHistoryHandler::WEEK)
552 SetQueryTimeInWeeks(offset, &options); 555 SetQueryTimeInWeeks(offset, &options);
553 556
554 double end_time; 557 double end_time;
555 if (!args->GetDouble(3, &end_time)) { 558 if (!args->GetDouble(3, &end_time)) {
556 NOTREACHED() << "Failed to convert argument 3. "; 559 NOTREACHED() << "Failed to convert argument 3. ";
557 return; 560 return;
558 } 561 }
559 if (end_time) 562 if (end_time)
560 options.end_time = base::Time::FromJsTime(end_time); 563 options.end_time = base::Time::FromJsTime(end_time);
564 int context;
565 if (!ExtractIntegerValueAtIndex(args, 4, &context)) {
566 NOTREACHED() << "Failed to convert argument 4.";
567 return;
568 }
569 if (context)
570 options.context = static_cast<history::HistoryContext>(context);
561 571
562 if (!ExtractIntegerValueAtIndex(args, 4, &options.max_count)) { 572 if (!ExtractIntegerValueAtIndex(args, 5, &options.max_count)) {
563 NOTREACHED() << "Failed to convert argument 4."; 573 NOTREACHED() << "Failed to convert argument 5.";
564 return; 574 return;
565 } 575 }
566 576
567 options.duplicate_policy = history::QueryOptions::REMOVE_DUPLICATES_PER_DAY; 577 options.duplicate_policy = history::QueryOptions::REMOVE_DUPLICATES_PER_DAY;
578
568 QueryHistory(search_text, options); 579 QueryHistory(search_text, options);
569 } 580 }
570 581
571 void BrowsingHistoryHandler::HandleRemoveVisits(const base::ListValue* args) { 582 void BrowsingHistoryHandler::HandleRemoveVisits(const base::ListValue* args) {
572 Profile* profile = Profile::FromWebUI(web_ui()); 583 Profile* profile = Profile::FromWebUI(web_ui());
573 // TODO(davidben): history.js is not aware of this failure and will still 584 // TODO(davidben): history.js is not aware of this failure and will still
574 // override |deleteCompleteCallback_|. 585 // override |deleteCompleteCallback_|.
575 if (delete_task_tracker_.HasTrackedTasks() || 586 if (delete_task_tracker_.HasTrackedTasks() ||
576 has_pending_delete_request_ || 587 has_pending_delete_request_ ||
577 !profile->GetPrefs()->GetBoolean(prefs::kAllowDeletingBrowserHistory)) { 588 !profile->GetPrefs()->GetBoolean(prefs::kAllowDeletingBrowserHistory)) {
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 const base::string16& search_text, 810 const base::string16& search_text,
800 const history::QueryOptions& options, 811 const history::QueryOptions& options,
801 history::QueryResults* results) { 812 history::QueryResults* results) {
802 DCHECK_EQ(0U, query_results_.size()); 813 DCHECK_EQ(0U, query_results_.size());
803 query_results_.reserve(results->size()); 814 query_results_.reserve(results->size());
804 const std::string accept_languages = GetAcceptLanguages(); 815 const std::string accept_languages = GetAcceptLanguages();
805 816
806 for (size_t i = 0; i < results->size(); ++i) { 817 for (size_t i = 0; i < results->size(); ++i) {
807 history::URLResult const &page = (*results)[i]; 818 history::URLResult const &page = (*results)[i];
808 // TODO(dubroy): Use sane time (crbug.com/146090) here when it's ready. 819 // TODO(dubroy): Use sane time (crbug.com/146090) here when it's ready.
820 printf("\npage.context() %d %s\n", page.context(), page.url().spec().c_str() );
809 query_results_.push_back( 821 query_results_.push_back(
810 HistoryEntry( 822 HistoryEntry(
811 HistoryEntry::LOCAL_ENTRY, 823 HistoryEntry::LOCAL_ENTRY,
812 page.url(), 824 page.url(),
813 page.title(), 825 page.title(),
826 page.context(),
814 page.visit_time(), 827 page.visit_time(),
815 std::string(), 828 std::string(),
816 !search_text.empty(), 829 !search_text.empty(),
817 page.snippet().text(), 830 page.snippet().text(),
818 page.blocked_visit(), 831 page.blocked_visit(),
819 accept_languages)); 832 accept_languages));
820 } 833 }
821 834
822 // The items which are to be written into results_info_value_ are also 835 // The items which are to be written into results_info_value_ are also
823 // described in chrome/browser/resources/history/history.js in @typedef for 836 // described in chrome/browser/resources/history/history.js in @typedef for
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 920
908 // Get the ID of the client that this visit came from. 921 // Get the ID of the client that this visit came from.
909 std::string client_id; 922 std::string client_id;
910 id->GetString("client_id", &client_id); 923 id->GetString("client_id", &client_id);
911 924
912 web_history_query_results_.push_back( 925 web_history_query_results_.push_back(
913 HistoryEntry( 926 HistoryEntry(
914 HistoryEntry::REMOTE_ENTRY, 927 HistoryEntry::REMOTE_ENTRY,
915 GURL(url), 928 GURL(url),
916 title, 929 title,
930 history::HistoryContext::CONTEXT_NONE,
917 time, 931 time,
918 client_id, 932 client_id,
919 !search_text.empty(), 933 !search_text.empty(),
920 base::string16(), 934 base::string16(),
921 /* blocked_visit */ false, 935 /* blocked_visit */ false,
922 accept_languages)); 936 accept_languages));
923 } 937 }
924 } 938 }
925 } else if (results_value) { 939 } else if (results_value) {
926 NOTREACHED() << "Failed to parse JSON response."; 940 NOTREACHED() << "Failed to parse JSON response.";
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 Profile* profile = Profile::FromWebUI(web_ui); 1055 Profile* profile = Profile::FromWebUI(web_ui);
1042 content::WebUIDataSource::Add(profile, CreateHistoryUIHTMLSource(profile)); 1056 content::WebUIDataSource::Add(profile, CreateHistoryUIHTMLSource(profile));
1043 } 1057 }
1044 1058
1045 // static 1059 // static
1046 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( 1060 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes(
1047 ui::ScaleFactor scale_factor) { 1061 ui::ScaleFactor scale_factor) {
1048 return ResourceBundle::GetSharedInstance(). 1062 return ResourceBundle::GetSharedInstance().
1049 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); 1063 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor);
1050 } 1064 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/history_ui.h ('k') | components/history/core/browser/history_backend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698