[email protected] | 76a010b | 2008-12-07 23:48:03 | [diff] [blame^] | 1 | // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROME_BROWSER_DOM_UI_HISTORY_UI_H__ |
| 6 | #define CHROME_BROWSER_DOM_UI_HISTORY_UI_H__ |
| 7 | |
| 8 | #include "chrome/browser/dom_ui/chrome_url_data_manager.h" |
| 9 | #include "chrome/browser/dom_ui/dom_ui.h" |
| 10 | #include "chrome/browser/dom_ui/dom_ui_contents.h" |
| 11 | |
| 12 | class GURL; |
| 13 | |
| 14 | class HistoryUIHTMLSource : public ChromeURLDataManager::DataSource { |
| 15 | public: |
| 16 | HistoryUIHTMLSource(); |
| 17 | |
| 18 | // Called when the network layer has requested a resource underneath |
| 19 | // the path we registered. |
| 20 | virtual void StartDataRequest(const std::string& path, int request_id); |
| 21 | virtual std::string GetMimeType(const std::string&) const { |
| 22 | return "text/html"; |
| 23 | } |
| 24 | |
| 25 | private: |
| 26 | DISALLOW_COPY_AND_ASSIGN(HistoryUIHTMLSource); |
| 27 | }; |
| 28 | |
| 29 | // The handler for Javascript messages related to the "history" view. |
| 30 | class BrowsingHistoryHandler : public DOMMessageHandler, |
| 31 | public NotificationObserver { |
| 32 | public: |
| 33 | explicit BrowsingHistoryHandler(DOMUI* dom_ui_); |
| 34 | virtual ~BrowsingHistoryHandler(); |
| 35 | |
| 36 | // Callback for the "getHistory" message. |
| 37 | void HandleGetHistory(const Value* value); |
| 38 | |
| 39 | // NotificationObserver implementation. |
| 40 | virtual void Observe(NotificationType type, |
| 41 | const NotificationSource& source, |
| 42 | const NotificationDetails& details); |
| 43 | |
| 44 | private: |
| 45 | // Callback from the history system when the most visited list is available. |
| 46 | void QueryComplete(HistoryService::Handle request_handle, |
| 47 | history::QueryResults* results); |
| 48 | |
| 49 | // Extract the arguments from the call to HandleGetHistory. |
| 50 | void ExtractGetHistoryArguments(const Value* value, |
| 51 | int* month, |
| 52 | std::wstring* query); |
| 53 | |
| 54 | // Get the query options for a given month and query. |
| 55 | history::QueryOptions CreateQueryOptions(int month, |
| 56 | const std::wstring& query); |
| 57 | |
| 58 | // Current search text. |
| 59 | std::wstring search_text_; |
| 60 | |
| 61 | // Our consumer for the history service. |
| 62 | CancelableRequestConsumerT<PageUsageData*, NULL> cancelable_consumer_; |
| 63 | |
| 64 | DISALLOW_COPY_AND_ASSIGN(BrowsingHistoryHandler); |
| 65 | }; |
| 66 | |
| 67 | class HistoryUI : public DOMUI { |
| 68 | public: |
| 69 | explicit HistoryUI(DOMUIContents* contents); |
| 70 | |
| 71 | // Return the URL for the front page of this UI. |
| 72 | static GURL GetBaseURL(); |
| 73 | |
| 74 | // DOMUI Implementation |
| 75 | virtual void Init(); |
| 76 | |
| 77 | private: |
| 78 | DOMUIContents* contents_; |
| 79 | |
| 80 | DISALLOW_COPY_AND_ASSIGN(HistoryUI); |
| 81 | }; |
| 82 | |
| 83 | #endif // CHROME_BROWSER_DOM_UI_HISTORY_UI_H__ |