[email protected] | 21f4d251 | 2010-03-05 08:15:53 | [diff] [blame] | 1 | // Copyright (c) 2010 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] | b689fce7 | 2009-03-17 22:45:34 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_DOM_UI_HISTORY_UI_H_ |
| 6 | #define CHROME_BROWSER_DOM_UI_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] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 12 | #include "chrome/browser/dom_ui/chrome_url_data_manager.h" |
| 13 | #include "chrome/browser/dom_ui/dom_ui.h" |
[email protected] | 95cdbbc0 | 2009-02-24 15:11:05 | [diff] [blame] | 14 | #include "chrome/browser/cancelable_request.h" |
[email protected] | b689fce7 | 2009-03-17 22:45:34 | [diff] [blame] | 15 | #include "chrome/browser/history/history.h" |
[email protected] | 59316ec | 2009-05-21 00:47:20 | [diff] [blame] | 16 | #include "chrome/common/notification_registrar.h" |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 17 | |
| 18 | class GURL; |
| 19 | |
| 20 | class HistoryUIHTMLSource : public ChromeURLDataManager::DataSource { |
| 21 | public: |
| 22 | HistoryUIHTMLSource(); |
| 23 | |
| 24 | // Called when the network layer has requested a resource underneath |
| 25 | // the path we registered. |
[email protected] | f09d9379 | 2009-11-17 00:10:36 | [diff] [blame] | 26 | virtual void StartDataRequest(const std::string& path, |
| 27 | bool is_off_the_record, |
| 28 | int request_id); |
[email protected] | ddb1e5a | 2010-12-13 20:10:45 | [diff] [blame] | 29 | virtual std::string GetMimeType(const std::string&) const; |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 30 | |
| 31 | private: |
[email protected] | 8de85a6 | 2009-11-06 08:32:17 | [diff] [blame] | 32 | ~HistoryUIHTMLSource() {} |
| 33 | |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 34 | DISALLOW_COPY_AND_ASSIGN(HistoryUIHTMLSource); |
| 35 | }; |
| 36 | |
| 37 | // The handler for Javascript messages related to the "history" view. |
[email protected] | 36e1217 | 2011-02-08 23:46:02 | [diff] [blame^] | 38 | class BrowsingHistoryHandler : public WebUIMessageHandler, |
[email protected] | 21f4d251 | 2010-03-05 08:15:53 | [diff] [blame] | 39 | public NotificationObserver { |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 40 | public: |
[email protected] | 2bc2de6 | 2009-06-29 23:37:42 | [diff] [blame] | 41 | BrowsingHistoryHandler(); |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 42 | virtual ~BrowsingHistoryHandler(); |
| 43 | |
[email protected] | 36e1217 | 2011-02-08 23:46:02 | [diff] [blame^] | 44 | // WebUIMessageHandler implementation. |
| 45 | virtual WebUIMessageHandler* Attach(DOMUI* dom_ui); |
[email protected] | 2bc2de6 | 2009-06-29 23:37:42 | [diff] [blame] | 46 | virtual void RegisterMessages(); |
| 47 | |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 48 | // Callback for the "getHistory" message. |
[email protected] | 88942a2 | 2010-08-19 20:34:43 | [diff] [blame] | 49 | void HandleGetHistory(const ListValue* args); |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 50 | |
[email protected] | fbf644e7 | 2009-02-19 22:26:06 | [diff] [blame] | 51 | // Callback for the "searchHistory" message. |
[email protected] | 88942a2 | 2010-08-19 20:34:43 | [diff] [blame] | 52 | void HandleSearchHistory(const ListValue* args); |
[email protected] | fbf644e7 | 2009-02-19 22:26:06 | [diff] [blame] | 53 | |
[email protected] | 21f4d251 | 2010-03-05 08:15:53 | [diff] [blame] | 54 | // Callback for the "removeURLsOnOneDay" message. |
[email protected] | 88942a2 | 2010-08-19 20:34:43 | [diff] [blame] | 55 | void HandleRemoveURLsOnOneDay(const ListValue* args); |
[email protected] | 21f4d251 | 2010-03-05 08:15:53 | [diff] [blame] | 56 | |
| 57 | // Handle for "clearBrowsingData" message. |
[email protected] | 88942a2 | 2010-08-19 20:34:43 | [diff] [blame] | 58 | void HandleClearBrowsingData(const ListValue* args); |
[email protected] | fbf644e7 | 2009-02-19 22:26:06 | [diff] [blame] | 59 | |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 60 | // NotificationObserver implementation. |
| 61 | virtual void Observe(NotificationType type, |
| 62 | const NotificationSource& source, |
| 63 | const NotificationDetails& details); |
| 64 | |
| 65 | private: |
[email protected] | fbf644e7 | 2009-02-19 22:26:06 | [diff] [blame] | 66 | // Callback from the history system when the history list is available. |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 67 | void QueryComplete(HistoryService::Handle request_handle, |
| 68 | history::QueryResults* results); |
| 69 | |
[email protected] | 21f4d251 | 2010-03-05 08:15:53 | [diff] [blame] | 70 | // Callback from the history system when visits were deleted. |
| 71 | void RemoveComplete(); |
| 72 | |
[email protected] | fbf644e7 | 2009-02-19 22:26:06 | [diff] [blame] | 73 | // Extract the arguments from the call to HandleSearchHistory. |
[email protected] | 88942a2 | 2010-08-19 20:34:43 | [diff] [blame] | 74 | void ExtractSearchHistoryArguments(const ListValue* args, |
[email protected] | f0a51fb5 | 2009-03-05 12:46:38 | [diff] [blame] | 75 | int* month, |
[email protected] | e5366896 | 2010-06-23 15:35:25 | [diff] [blame] | 76 | string16* query); |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 77 | |
[email protected] | fbf644e7 | 2009-02-19 22:26:06 | [diff] [blame] | 78 | // Figure out the query options for a month-wide query. |
| 79 | history::QueryOptions CreateMonthQueryOptions(int month); |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 80 | |
[email protected] | 59316ec | 2009-05-21 00:47:20 | [diff] [blame] | 81 | NotificationRegistrar registrar_; |
| 82 | |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 83 | // Current search text. |
[email protected] | e5366896 | 2010-06-23 15:35:25 | [diff] [blame] | 84 | string16 search_text_; |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 85 | |
[email protected] | b660ea9f | 2010-05-31 07:55:51 | [diff] [blame] | 86 | // Our consumer for search requests to the history service. |
| 87 | CancelableRequestConsumerT<int, 0> cancelable_search_consumer_; |
| 88 | |
| 89 | // Our consumer for delete requests to the history service. |
| 90 | CancelableRequestConsumerT<int, 0> cancelable_delete_consumer_; |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 91 | |
| 92 | DISALLOW_COPY_AND_ASSIGN(BrowsingHistoryHandler); |
| 93 | }; |
| 94 | |
| 95 | class HistoryUI : public DOMUI { |
| 96 | public: |
[email protected] | 57c6a65 | 2009-05-04 07:58:34 | [diff] [blame] | 97 | explicit HistoryUI(TabContents* contents); |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 98 | |
[email protected] | 9e4c033 | 2009-02-25 17:47:58 | [diff] [blame] | 99 | // Return the URL for a given search term. |
[email protected] | e5366896 | 2010-06-23 15:35:25 | [diff] [blame] | 100 | static const GURL GetHistoryURLWithSearchText(const string16& text); |
[email protected] | 9e4c033 | 2009-02-25 17:47:58 | [diff] [blame] | 101 | |
[email protected] | 6de2799 | 2009-10-19 17:04:46 | [diff] [blame] | 102 | static RefCountedMemory* GetFaviconResourceBytes(); |
[email protected] | 0189bc72 | 2009-08-28 21:56:48 | [diff] [blame] | 103 | |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 104 | private: |
[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame] | 105 | DISALLOW_COPY_AND_ASSIGN(HistoryUI); |
| 106 | }; |
| 107 | |
[email protected] | b689fce7 | 2009-03-17 22:45:34 | [diff] [blame] | 108 | #endif // CHROME_BROWSER_DOM_UI_HISTORY_UI_H_ |