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