Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_UI_WEBUI_HISTORY_UI_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_HISTORY_UI_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_HISTORY_UI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_HISTORY_UI_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 class ManagedUserService; | 23 class ManagedUserService; |
| 24 | 24 |
| 25 // The handler for Javascript messages related to the "history" view. | 25 // The handler for Javascript messages related to the "history" view. |
| 26 class BrowsingHistoryHandler : public content::WebUIMessageHandler, | 26 class BrowsingHistoryHandler : public content::WebUIMessageHandler, |
| 27 public content::NotificationObserver { | 27 public content::NotificationObserver { |
| 28 public: | 28 public: |
| 29 // Represents a history entry to be shown to the user, representing either | 29 // Represents a history entry to be shown to the user, representing either |
| 30 // a local or remote visit. A single entry can represent multiple visits, | 30 // a local or remote visit. A single entry can represent multiple visits, |
| 31 // since only the most recent visit on a particular day is shown. | 31 // since only the most recent visit on a particular day is shown. |
| 32 struct HistoryEntry { | 32 struct HistoryEntry { |
| 33 HistoryEntry(const GURL& url, const string16& title, base::Time time, | 33 // Values indicating whether an entry represents only local visits, only |
| 34 const std::set<int64>& timestamps, bool is_search_result, | 34 // remote visits, or a mixture of both. |
| 35 const string16& snippet); | 35 enum EntryType { |
| 36 LOCAL_ENTRY, | |
| 37 REMOTE_ENTRY, | |
| 38 COMBINED_ENTRY | |
| 39 }; | |
| 40 | |
| 41 HistoryEntry(EntryType type, const GURL& url, const string16& title, | |
| 42 base::Time time, const std::set<int64>& timestamps, | |
|
James Hawkins
2013/03/04 19:09:45
nit: The start of parameter rows must align on the
Patrick Dubroy
2013/03/05 13:15:54
Fixed. So google-style.el *was* doing the right th
| |
| 43 bool is_search_result, const string16& snippet); | |
| 36 HistoryEntry(); | 44 HistoryEntry(); |
| 37 virtual ~HistoryEntry(); | 45 virtual ~HistoryEntry(); |
| 38 | 46 |
| 39 // Format this entry's URL and title and add them to |result|. | 47 // Format this entry's URL and title and add them to |result|. |
| 40 void SetUrlAndTitle(DictionaryValue* result); | 48 void SetUrlAndTitle(DictionaryValue* result) const; |
| 41 | 49 |
| 42 // Convert the entry to a DictionaryValue to be owned by the caller. | 50 // Convert the entry to a DictionaryValue to be owned by the caller. |
| 43 scoped_ptr<DictionaryValue> ToValue( | 51 scoped_ptr<DictionaryValue> ToValue( |
| 44 BookmarkModel* bookmark_model, | 52 BookmarkModel* bookmark_model, |
| 45 ManagedUserService* managed_user_service); | 53 ManagedUserService* managed_user_service) const; |
| 46 | 54 |
| 47 // Comparison function for sorting HistoryEntries from newest to oldest. | 55 // Comparison function for sorting HistoryEntries from newest to oldest. |
| 48 static bool SortByTimeDescending( | 56 static bool SortByTimeDescending( |
| 49 const HistoryEntry& entry1, const HistoryEntry& entry2); | 57 const HistoryEntry& entry1, const HistoryEntry& entry2); |
| 50 | 58 |
| 59 EntryType entry_type; | |
|
James Hawkins
2013/03/04 19:09:45
Optional nit: The type name itself is not quite de
Patrick Dubroy
2013/03/05 13:15:54
Done.
| |
| 60 | |
| 51 GURL url; | 61 GURL url; |
| 52 string16 title; // Title of the entry. May be empty. | 62 string16 title; // Title of the entry. May be empty. |
| 53 | 63 |
| 54 // The time of the entry. Usually this will be the time of the most recent | 64 // The time of the entry. Usually this will be the time of the most recent |
| 55 // visit to |url| on a particular day as defined in the local timezone. | 65 // visit to |url| on a particular day as defined in the local timezone. |
| 56 base::Time time; | 66 base::Time time; |
| 57 | 67 |
| 58 // Timestamps of all local or remote visits the same URL on the same day. | 68 // Timestamps of all local or remote visits the same URL on the same day. |
| 59 std::set<int64> all_timestamps; | 69 std::set<int64> all_timestamps; |
| 60 | 70 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 // - MONTH: the last calendar month. | 131 // - MONTH: the last calendar month. |
| 122 enum Range { | 132 enum Range { |
| 123 ALL_TIME = 0, | 133 ALL_TIME = 0, |
| 124 WEEK = 1, | 134 WEEK = 1, |
| 125 MONTH = 2 | 135 MONTH = 2 |
| 126 }; | 136 }; |
| 127 | 137 |
| 128 // Core implementation of history querying. | 138 // Core implementation of history querying. |
| 129 void QueryHistory(string16 search_text, const history::QueryOptions& options); | 139 void QueryHistory(string16 search_text, const history::QueryOptions& options); |
| 130 | 140 |
| 131 // Sends the accumulated results of the query to the front end, truncating | 141 // Combines the query results from the local history database and the history |
| 132 // the number to |max_count| if necessary. If |max_count| is 0, the results | 142 // server, and sends the combined results to the front end. |
| 133 // are not truncated. | 143 void ReturnResultsToFrontEnd(); |
| 134 // If |remove_duplicates| is true, duplicate visits on the same day are | |
| 135 // removed. | |
| 136 void ReturnResultsToFrontEnd(bool remove_duplicates, int max_count); | |
| 137 | 144 |
| 138 // Callback from |web_history_timer_| when a response from web history has | 145 // Callback from |web_history_timer_| when a response from web history has |
| 139 // not been received in time. | 146 // not been received in time. |
| 140 void WebHistoryTimeout(); | 147 void WebHistoryTimeout(); |
| 141 | 148 |
| 142 // Callback from the history system when a history query has completed. | 149 // Callback from the history system when a history query has completed. |
| 143 void QueryComplete(const string16& search_text, | 150 void QueryComplete(const string16& search_text, |
| 144 const history::QueryOptions& options, | 151 const history::QueryOptions& options, |
| 145 HistoryService::Handle request_handle, | 152 HistoryService::Handle request_handle, |
| 146 history::QueryResults* results); | 153 history::QueryResults* results); |
| 147 | 154 |
| 148 // Callback from the WebHistoryService when a query has completed. | 155 // Callback from the WebHistoryService when a query has completed. |
| 149 void WebHistoryQueryComplete(const string16& search_text, | 156 void WebHistoryQueryComplete(const string16& search_text, |
| 150 const history::QueryOptions& options, | 157 const history::QueryOptions& options, |
| 158 base::TimeTicks start_time, | |
| 151 history::WebHistoryService::Request* request, | 159 history::WebHistoryService::Request* request, |
| 152 const base::DictionaryValue* results_value); | 160 const base::DictionaryValue* results_value); |
| 153 | 161 |
| 154 // Callback from the history system when visits were deleted. | 162 // Callback from the history system when visits were deleted. |
| 155 void RemoveComplete(); | 163 void RemoveComplete(); |
| 156 | 164 |
| 157 // Callback from history server when visits were deleted. | 165 // Callback from history server when visits were deleted. |
| 158 void RemoveWebHistoryComplete(history::WebHistoryService::Request* request, | 166 void RemoveWebHistoryComplete(history::WebHistoryService::Request* request, |
| 159 bool success); | 167 bool success); |
| 160 | 168 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 187 | 195 |
| 188 // Tracker for delete requests to the history service. | 196 // Tracker for delete requests to the history service. |
| 189 CancelableTaskTracker delete_task_tracker_; | 197 CancelableTaskTracker delete_task_tracker_; |
| 190 | 198 |
| 191 // The list of URLs that are in the process of being deleted. | 199 // The list of URLs that are in the process of being deleted. |
| 192 std::set<GURL> urls_to_be_deleted_; | 200 std::set<GURL> urls_to_be_deleted_; |
| 193 | 201 |
| 194 // The info value that is returned to the front end with the query results. | 202 // The info value that is returned to the front end with the query results. |
| 195 base::DictionaryValue results_info_value_; | 203 base::DictionaryValue results_info_value_; |
| 196 | 204 |
| 197 // The list of query results that is returned to the front end. | 205 // The list of query results received from the history service. |
| 198 std::vector<HistoryEntry> query_results_; | 206 std::vector<HistoryEntry> query_results_; |
| 199 | 207 |
| 208 // The list of query results received from the history server. | |
| 209 std::vector<HistoryEntry> web_history_query_results_; | |
| 210 | |
| 200 // Timer used to implement a timeout on a Web History response. | 211 // Timer used to implement a timeout on a Web History response. |
| 201 base::OneShotTimer<BrowsingHistoryHandler> web_history_timer_; | 212 base::OneShotTimer<BrowsingHistoryHandler> web_history_timer_; |
| 202 | 213 |
| 203 DISALLOW_COPY_AND_ASSIGN(BrowsingHistoryHandler); | 214 DISALLOW_COPY_AND_ASSIGN(BrowsingHistoryHandler); |
| 204 }; | 215 }; |
| 205 | 216 |
| 206 class HistoryUI : public content::WebUIController { | 217 class HistoryUI : public content::WebUIController { |
| 207 public: | 218 public: |
| 208 explicit HistoryUI(content::WebUI* web_ui); | 219 explicit HistoryUI(content::WebUI* web_ui); |
| 209 | 220 |
| 210 // Return the URL for a given search term. | 221 // Return the URL for a given search term. |
| 211 static const GURL GetHistoryURLWithSearchText(const string16& text); | 222 static const GURL GetHistoryURLWithSearchText(const string16& text); |
| 212 | 223 |
| 213 static base::RefCountedMemory* GetFaviconResourceBytes( | 224 static base::RefCountedMemory* GetFaviconResourceBytes( |
| 214 ui::ScaleFactor scale_factor); | 225 ui::ScaleFactor scale_factor); |
| 215 | 226 |
| 216 private: | 227 private: |
| 217 DISALLOW_COPY_AND_ASSIGN(HistoryUI); | 228 DISALLOW_COPY_AND_ASSIGN(HistoryUI); |
| 218 }; | 229 }; |
| 219 | 230 |
| 220 #endif // CHROME_BROWSER_UI_WEBUI_HISTORY_UI_H_ | 231 #endif // CHROME_BROWSER_UI_WEBUI_HISTORY_UI_H_ |
| OLD | NEW |