1 // Copyright (c) 2011 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_UI_WEBUI_HISTORY2_UI_H_ 6 #define CHROME_BROWSER_UI_WEBUI_HISTORY2_UI_H_ 7 #pragma once 8 9 #include <string> 10 11 #include "base/string16.h" 12 #include "chrome/browser/history/history.h" 13 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 14 #include "content/browser/cancelable_request.h" 15 #include "content/browser/webui/web_ui.h" 16 17 class GURL; 18 19 // Temporary fork for development of new history UI. 20 // TODO(pamg): merge back in when new UI is complete. 21 22 class HistoryUIHTMLSource2 : public ChromeURLDataManager::DataSource { 23 public: 24 HistoryUIHTMLSource2(); 25 26 // Called when the network layer has requested a resource underneath 27 // the path we registered. 28 virtual void StartDataRequest(const std::string& path, 29 bool is_incognito, 30 int request_id); 31 32 virtual std::string GetMimeType(const std::string&) const; 33 34 private: ~HistoryUIHTMLSource2()35 ~HistoryUIHTMLSource2() {} 36 37 DISALLOW_COPY_AND_ASSIGN(HistoryUIHTMLSource2); 38 }; 39 40 // The handler for Javascript messages related to the "history" view. 41 class BrowsingHistoryHandler2 : public WebUIMessageHandler { 42 public: 43 BrowsingHistoryHandler2(); 44 virtual ~BrowsingHistoryHandler2(); 45 46 // WebUIMessageHandler implementation. 47 virtual WebUIMessageHandler* Attach(WebUI* web_ui); 48 virtual void RegisterMessages(); 49 50 // Callback for the "getHistory" message. 51 void HandleGetHistory(const ListValue* args); 52 53 // Callback for the "searchHistory" message. 54 void HandleSearchHistory(const ListValue* args); 55 56 // Callback for the "removeURLsOnOneDay" message. 57 void HandleRemoveURLsOnOneDay(const ListValue* args); 58 59 // Handle for "clearBrowsingData" message. 60 void HandleClearBrowsingData(const ListValue* args); 61 62 private: 63 // Callback from the history system when the history list is available. 64 void QueryComplete(HistoryService::Handle request_handle, 65 history::QueryResults* results); 66 67 // Callback from the history system when visits were deleted. 68 void RemoveComplete(); 69 70 // Extract the arguments from the call to HandleSearchHistory. 71 void ExtractSearchHistoryArguments(const ListValue* args, 72 int* month, 73 string16* query); 74 75 // Figure out the query options for a month-wide query. 76 history::QueryOptions CreateMonthQueryOptions(int month); 77 78 // Current search text. 79 string16 search_text_; 80 81 // Our consumer for search requests to the history service. 82 CancelableRequestConsumerT<int, 0> cancelable_search_consumer_; 83 84 // Our consumer for delete requests to the history service. 85 CancelableRequestConsumerT<int, 0> cancelable_delete_consumer_; 86 87 DISALLOW_COPY_AND_ASSIGN(BrowsingHistoryHandler2); 88 }; 89 90 class HistoryUI2 : public WebUI { 91 public: 92 explicit HistoryUI2(TabContents* contents); 93 94 // Return the URL for a given search term. 95 static const GURL GetHistoryURLWithSearchText(const string16& text); 96 97 static RefCountedMemory* GetFaviconResourceBytes(); 98 99 private: 100 DISALLOW_COPY_AND_ASSIGN(HistoryUI2); 101 }; 102 103 #endif // CHROME_BROWSER_UI_WEBUI_HISTORY2_UI_H_ 104