[email protected] | 7ade273 | 2011-02-10 00:13:58 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 265a149 | 2011-02-27 05:58:07 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_UI_WEBUI_HISTORY_UI_H_ |
6 | #define CHROME_BROWSER_UI_WEBUI_HISTORY_UI_H_ | ||||
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame] | 7 | #pragma once |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 8 | |
[email protected] | 038d52e1 | 2009-10-14 16:53:41 | [diff] [blame] | 9 | #include <string> |
[email protected] | 0189bc72 | 2009-08-28 21:56:48 | [diff] [blame] | 10 | |
[email protected] | e5366896 | 2010-06-23 15:35:25 | [diff] [blame] | 11 | #include "base/string16.h" |
[email protected] | 5581d76 | 2011-12-27 14:05:24 | [diff] [blame] | 12 | #include "chrome/browser/cancelable_request.h" |
[email protected] | b689fce7 | 2009-03-17 22:45:34 | [diff] [blame] | 13 | #include "chrome/browser/history/history.h" |
[email protected] | fd42ac30f | 2011-02-27 19:33:36 | [diff] [blame] | 14 | #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 15 | #include "content/public/browser/notification_registrar.h" |
[email protected] | e14c95912 | 2012-01-13 16:58:25 | [diff] [blame] | 16 | #include "content/public/browser/web_ui_controller.h" |
[email protected] | 26e2632a | 2011-12-31 04:02:55 | [diff] [blame] | 17 | #include "content/public/browser/web_ui_message_handler.h" |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 18 | |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 19 | // The handler for Javascript messages related to the "history" view. |
[email protected] | 26e2632a | 2011-12-31 04:02:55 | [diff] [blame] | 20 | class BrowsingHistoryHandler : public content::WebUIMessageHandler, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 21 | public content::NotificationObserver { |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 22 | public: |
[email protected] | 2bc2de6 | 2009-06-29 23:37:42 | [diff] [blame] | 23 | BrowsingHistoryHandler(); |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 24 | virtual ~BrowsingHistoryHandler(); |
25 | |||||
[email protected] | 36e1217 | 2011-02-08 23:46:02 | [diff] [blame] | 26 | // WebUIMessageHandler implementation. |
[email protected] | 3abbed00 | 2011-08-01 16:02:20 | [diff] [blame] | 27 | virtual void RegisterMessages() OVERRIDE; |
[email protected] | 2bc2de6 | 2009-06-29 23:37:42 | [diff] [blame] | 28 | |
[email protected] | 60a83db | 2012-04-05 14:11:14 | [diff] [blame^] | 29 | // Handler for the "getHistory" message. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 30 | void HandleGetHistory(const base::ListValue* args); |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 31 | |
[email protected] | 60a83db | 2012-04-05 14:11:14 | [diff] [blame^] | 32 | // Handler for the "searchHistory" message. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 33 | void HandleSearchHistory(const base::ListValue* args); |
[email protected] | fbf644e7 | 2009-02-19 22:26:06 | [diff] [blame] | 34 | |
[email protected] | 60a83db | 2012-04-05 14:11:14 | [diff] [blame^] | 35 | // Handler for the "removeURLsOnOneDay" message. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 36 | void HandleRemoveURLsOnOneDay(const base::ListValue* args); |
[email protected] | 21f4d251 | 2010-03-05 08:15:53 | [diff] [blame] | 37 | |
[email protected] | 60a83db | 2012-04-05 14:11:14 | [diff] [blame^] | 38 | // Handler for "clearBrowsingData" message. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 39 | void HandleClearBrowsingData(const base::ListValue* args); |
[email protected] | fbf644e7 | 2009-02-19 22:26:06 | [diff] [blame] | 40 | |
[email protected] | 60a83db | 2012-04-05 14:11:14 | [diff] [blame^] | 41 | // Handler for "removeBookmark" message. |
42 | void HandleRemoveBookmark(const base::ListValue* args); | ||||
43 | |||||
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 44 | // content::NotificationObserver implementation. |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 45 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 46 | const content::NotificationSource& source, |
47 | const content::NotificationDetails& details) OVERRIDE; | ||||
[email protected] | 9f39293 | 2011-06-09 14:08:00 | [diff] [blame] | 48 | |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 49 | private: |
[email protected] | fbf644e7 | 2009-02-19 22:26:06 | [diff] [blame] | 50 | // Callback from the history system when the history list is available. |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 51 | void QueryComplete(HistoryService::Handle request_handle, |
52 | history::QueryResults* results); | ||||
53 | |||||
[email protected] | 21f4d251 | 2010-03-05 08:15:53 | [diff] [blame] | 54 | // Callback from the history system when visits were deleted. |
55 | void RemoveComplete(); | ||||
56 | |||||
[email protected] | fbf644e7 | 2009-02-19 22:26:06 | [diff] [blame] | 57 | // Extract the arguments from the call to HandleSearchHistory. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 58 | void ExtractSearchHistoryArguments(const base::ListValue* args, |
[email protected] | f0a51fb5 | 2009-03-05 12:46:38 | [diff] [blame] | 59 | int* month, |
[email protected] | e5366896 | 2010-06-23 15:35:25 | [diff] [blame] | 60 | string16* query); |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 61 | |
[email protected] | fbf644e7 | 2009-02-19 22:26:06 | [diff] [blame] | 62 | // Figure out the query options for a month-wide query. |
63 | history::QueryOptions CreateMonthQueryOptions(int month); | ||||
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 64 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 65 | content::NotificationRegistrar registrar_; |
[email protected] | 9f39293 | 2011-06-09 14:08:00 | [diff] [blame] | 66 | |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 67 | // Current search text. |
[email protected] | e5366896 | 2010-06-23 15:35:25 | [diff] [blame] | 68 | string16 search_text_; |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 69 | |
[email protected] | b660ea9f | 2010-05-31 07:55:51 | [diff] [blame] | 70 | // Our consumer for search requests to the history service. |
71 | CancelableRequestConsumerT<int, 0> cancelable_search_consumer_; | ||||
72 | |||||
73 | // Our consumer for delete requests to the history service. | ||||
74 | CancelableRequestConsumerT<int, 0> cancelable_delete_consumer_; | ||||
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 75 | |
[email protected] | d66bbe0 | 2011-11-16 10:19:43 | [diff] [blame] | 76 | // The list of URLs that are in the process of being deleted. |
77 | std::set<GURL> urls_to_be_deleted_; | ||||
78 | |||||
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 79 | DISALLOW_COPY_AND_ASSIGN(BrowsingHistoryHandler); |
80 | }; | ||||
81 | |||||
[email protected] | c63cedf2 | 2012-01-17 18:42:22 | [diff] [blame] | 82 | class HistoryUI : public content::WebUIController { |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 83 | public: |
[email protected] | 01ec4ec | 2012-01-18 04:13:47 | [diff] [blame] | 84 | explicit HistoryUI(content::WebUI* web_ui); |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 85 | |
[email protected] | 9e4c033 | 2009-02-25 17:47:58 | [diff] [blame] | 86 | // Return the URL for a given search term. |
[email protected] | e5366896 | 2010-06-23 15:35:25 | [diff] [blame] | 87 | static const GURL GetHistoryURLWithSearchText(const string16& text); |
[email protected] | 9e4c033 | 2009-02-25 17:47:58 | [diff] [blame] | 88 | |
[email protected] | 6de2799 | 2009-10-19 17:04:46 | [diff] [blame] | 89 | static RefCountedMemory* GetFaviconResourceBytes(); |
[email protected] | 0189bc72 | 2009-08-28 21:56:48 | [diff] [blame] | 90 | |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 91 | private: |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 92 | DISALLOW_COPY_AND_ASSIGN(HistoryUI); |
93 | }; | ||||
94 | |||||
[email protected] | 265a149 | 2011-02-27 05:58:07 | [diff] [blame] | 95 | #endif // CHROME_BROWSER_UI_WEBUI_HISTORY_UI_H_ |