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

Side by Side Diff: chrome/browser/ui/webui/browsing_history_handler.h

Issue 2318643003: MD History: truncate title to 300 chars in C++ instead of JS (Closed)
Patch Set: more !android Created 4 years, 3 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_UI_WEBUI_BROWSING_HISTORY_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_BROWSING_HISTORY_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_BROWSING_HISTORY_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_BROWSING_HISTORY_HANDLER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 HistoryEntry(EntryType type, const GURL& url, const base::string16& title, 64 HistoryEntry(EntryType type, const GURL& url, const base::string16& title,
65 base::Time time, const std::string& client_id, 65 base::Time time, const std::string& client_id,
66 bool is_search_result, const base::string16& snippet, 66 bool is_search_result, const base::string16& snippet,
67 bool blocked_visit); 67 bool blocked_visit);
68 HistoryEntry(); 68 HistoryEntry();
69 HistoryEntry(const HistoryEntry& other); 69 HistoryEntry(const HistoryEntry& other);
70 virtual ~HistoryEntry(); 70 virtual ~HistoryEntry();
71 71
72 // Formats this entry's URL and title and adds them to |result|. 72 // Formats this entry's URL and title and adds them to |result|.
73 void SetUrlAndTitle(base::DictionaryValue* result) const; 73 void SetUrlAndTitle(base::DictionaryValue* result,
74 bool limit_title_length) const;
74 75
75 // Converts the entry to a DictionaryValue to be owned by the caller. 76 // Converts the entry to a DictionaryValue to be owned by the caller.
76 std::unique_ptr<base::DictionaryValue> ToValue( 77 std::unique_ptr<base::DictionaryValue> ToValue(
77 bookmarks::BookmarkModel* bookmark_model, 78 bookmarks::BookmarkModel* bookmark_model,
78 SupervisedUserService* supervised_user_service, 79 SupervisedUserService* supervised_user_service,
79 const ProfileSyncService* sync_service) const; 80 const ProfileSyncService* sync_service,
81 bool limit_title_length) const;
80 82
81 // Comparison function for sorting HistoryEntries from newest to oldest. 83 // Comparison function for sorting HistoryEntries from newest to oldest.
82 static bool SortByTimeDescending( 84 static bool SortByTimeDescending(
83 const HistoryEntry& entry1, const HistoryEntry& entry2); 85 const HistoryEntry& entry1, const HistoryEntry& entry2);
84 86
85 // The type of visits this entry represents: local, remote, or both. 87 // The type of visits this entry represents: local, remote, or both.
86 EntryType entry_type; 88 EntryType entry_type;
87 89
88 GURL url; 90 GURL url;
89 base::string16 title; // Title of the entry. May be empty. 91 base::string16 title; // Title of the entry. May be empty.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 130
129 // Handler for "removeBookmark" message. 131 // Handler for "removeBookmark" message.
130 void HandleRemoveBookmark(const base::ListValue* args); 132 void HandleRemoveBookmark(const base::ListValue* args);
131 133
132 // Merges duplicate entries from the query results, only retaining the most 134 // Merges duplicate entries from the query results, only retaining the most
133 // recent visit to a URL on a particular day. That visit contains the 135 // recent visit to a URL on a particular day. That visit contains the
134 // timestamps of the other visits. 136 // timestamps of the other visits.
135 static void MergeDuplicateResults( 137 static void MergeDuplicateResults(
136 std::vector<BrowsingHistoryHandler::HistoryEntry>* results); 138 std::vector<BrowsingHistoryHandler::HistoryEntry>* results);
137 139
140 protected:
141 // Callback from the history system when a history query has completed.
142 // Exposed for testing.
143 void QueryComplete(const base::string16& search_text,
144 const history::QueryOptions& options,
145 history::QueryResults* results);
146
138 private: 147 private:
139 // The range for which to return results: 148 // The range for which to return results:
140 // - ALLTIME: allows access to all the results in a paginated way. 149 // - ALLTIME: allows access to all the results in a paginated way.
141 // - WEEK: the last 7 days. 150 // - WEEK: the last 7 days.
142 // - MONTH: the last calendar month. 151 // - MONTH: the last calendar month.
143 enum Range { 152 enum Range {
144 ALL_TIME = 0, 153 ALL_TIME = 0,
145 WEEK = 1, 154 WEEK = 1,
146 MONTH = 2 155 MONTH = 2
147 }; 156 };
148 157
149 // Core implementation of history querying. 158 // Core implementation of history querying.
150 void QueryHistory(const base::string16& search_text, 159 void QueryHistory(const base::string16& search_text,
151 const history::QueryOptions& options); 160 const history::QueryOptions& options);
152 161
153 // Combines the query results from the local history database and the history 162 // Combines the query results from the local history database and the history
154 // server, and sends the combined results to the front end. 163 // server, and sends the combined results to the front end.
155 void ReturnResultsToFrontEnd(); 164 void ReturnResultsToFrontEnd();
156 165
157 // Callback from |web_history_timer_| when a response from web history has 166 // Callback from |web_history_timer_| when a response from web history has
158 // not been received in time. 167 // not been received in time.
159 void WebHistoryTimeout(); 168 void WebHistoryTimeout();
160 169
161 // Callback from the history system when a history query has completed.
162 void QueryComplete(const base::string16& search_text,
163 const history::QueryOptions& options,
164 history::QueryResults* results);
165
166 // Callback from the WebHistoryService when a query has completed. 170 // Callback from the WebHistoryService when a query has completed.
167 void WebHistoryQueryComplete(const base::string16& search_text, 171 void WebHistoryQueryComplete(const base::string16& search_text,
168 const history::QueryOptions& options, 172 const history::QueryOptions& options,
169 base::TimeTicks start_time, 173 base::TimeTicks start_time,
170 history::WebHistoryService::Request* request, 174 history::WebHistoryService::Request* request,
171 const base::DictionaryValue* results_value); 175 const base::DictionaryValue* results_value);
172 176
173 // Callback telling us whether other forms of browsing history were found 177 // Callback telling us whether other forms of browsing history were found
174 // on the history server. 178 // on the history server.
175 void OtherFormsOfBrowsingHistoryQueryComplete( 179 void OtherFormsOfBrowsingHistoryQueryComplete(
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 252
249 // Whether there are other forms of browsing history on the history server. 253 // Whether there are other forms of browsing history on the history server.
250 bool has_other_forms_of_browsing_history_; 254 bool has_other_forms_of_browsing_history_;
251 255
252 base::WeakPtrFactory<BrowsingHistoryHandler> weak_factory_; 256 base::WeakPtrFactory<BrowsingHistoryHandler> weak_factory_;
253 257
254 DISALLOW_COPY_AND_ASSIGN(BrowsingHistoryHandler); 258 DISALLOW_COPY_AND_ASSIGN(BrowsingHistoryHandler);
255 }; 259 };
256 260
257 #endif // CHROME_BROWSER_UI_WEBUI_BROWSING_HISTORY_HANDLER_H_ 261 #endif // CHROME_BROWSER_UI_WEBUI_BROWSING_HISTORY_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/find_bar/find_bar_host_browsertest.cc ('k') | chrome/browser/ui/webui/browsing_history_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698