| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_WEBUI_HISTORY_UI_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_HISTORY_UI_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_HISTORY_UI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_HISTORY_UI_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/string16.h" | 11 #include "base/string16.h" |
| 12 #include "chrome/browser/history/history.h" | 12 #include "chrome/browser/history/history.h" |
| 13 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 13 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 14 #include "chrome/browser/ui/webui/chrome_web_ui.h" | 14 #include "chrome/browser/ui/webui/chrome_web_ui.h" |
| 15 #include "content/browser/cancelable_request.h" | 15 #include "content/browser/cancelable_request.h" |
| 16 #include "content/common/notification_registrar.h" |
| 16 | 17 |
| 17 class GURL; | 18 class GURL; |
| 18 | 19 |
| 19 // The handler for Javascript messages related to the "history" view. | 20 // The handler for Javascript messages related to the "history" view. |
| 20 class BrowsingHistoryHandler : public WebUIMessageHandler { | 21 class BrowsingHistoryHandler : public WebUIMessageHandler, |
| 22 public NotificationObserver { |
| 21 public: | 23 public: |
| 22 BrowsingHistoryHandler(); | 24 BrowsingHistoryHandler(); |
| 23 virtual ~BrowsingHistoryHandler(); | 25 virtual ~BrowsingHistoryHandler(); |
| 24 | 26 |
| 25 // WebUIMessageHandler implementation. | 27 // WebUIMessageHandler implementation. |
| 26 virtual WebUIMessageHandler* Attach(WebUI* web_ui); | 28 virtual WebUIMessageHandler* Attach(WebUI* web_ui); |
| 27 virtual void RegisterMessages(); | 29 virtual void RegisterMessages(); |
| 28 | 30 |
| 29 // Callback for the "getHistory" message. | 31 // Callback for the "getHistory" message. |
| 30 void HandleGetHistory(const ListValue* args); | 32 void HandleGetHistory(const ListValue* args); |
| 31 | 33 |
| 32 // Callback for the "searchHistory" message. | 34 // Callback for the "searchHistory" message. |
| 33 void HandleSearchHistory(const ListValue* args); | 35 void HandleSearchHistory(const ListValue* args); |
| 34 | 36 |
| 35 // Callback for the "removeURLsOnOneDay" message. | 37 // Callback for the "removeURLsOnOneDay" message. |
| 36 void HandleRemoveURLsOnOneDay(const ListValue* args); | 38 void HandleRemoveURLsOnOneDay(const ListValue* args); |
| 37 | 39 |
| 38 // Handle for "clearBrowsingData" message. | 40 // Handle for "clearBrowsingData" message. |
| 39 void HandleClearBrowsingData(const ListValue* args); | 41 void HandleClearBrowsingData(const ListValue* args); |
| 40 | 42 |
| 43 // NotificationObserver implementation. |
| 44 virtual void Observe(NotificationType type, |
| 45 const NotificationSource& source, |
| 46 const NotificationDetails& details); |
| 47 |
| 41 private: | 48 private: |
| 42 // Callback from the history system when the history list is available. | 49 // Callback from the history system when the history list is available. |
| 43 void QueryComplete(HistoryService::Handle request_handle, | 50 void QueryComplete(HistoryService::Handle request_handle, |
| 44 history::QueryResults* results); | 51 history::QueryResults* results); |
| 45 | 52 |
| 46 // Callback from the history system when visits were deleted. | 53 // Callback from the history system when visits were deleted. |
| 47 void RemoveComplete(); | 54 void RemoveComplete(); |
| 48 | 55 |
| 49 // Extract the arguments from the call to HandleSearchHistory. | 56 // Extract the arguments from the call to HandleSearchHistory. |
| 50 void ExtractSearchHistoryArguments(const ListValue* args, | 57 void ExtractSearchHistoryArguments(const ListValue* args, |
| 51 int* month, | 58 int* month, |
| 52 string16* query); | 59 string16* query); |
| 53 | 60 |
| 54 // Figure out the query options for a month-wide query. | 61 // Figure out the query options for a month-wide query. |
| 55 history::QueryOptions CreateMonthQueryOptions(int month); | 62 history::QueryOptions CreateMonthQueryOptions(int month); |
| 56 | 63 |
| 64 NotificationRegistrar registrar_; |
| 65 |
| 57 // Current search text. | 66 // Current search text. |
| 58 string16 search_text_; | 67 string16 search_text_; |
| 59 | 68 |
| 60 // Our consumer for search requests to the history service. | 69 // Our consumer for search requests to the history service. |
| 61 CancelableRequestConsumerT<int, 0> cancelable_search_consumer_; | 70 CancelableRequestConsumerT<int, 0> cancelable_search_consumer_; |
| 62 | 71 |
| 63 // Our consumer for delete requests to the history service. | 72 // Our consumer for delete requests to the history service. |
| 64 CancelableRequestConsumerT<int, 0> cancelable_delete_consumer_; | 73 CancelableRequestConsumerT<int, 0> cancelable_delete_consumer_; |
| 65 | 74 |
| 66 DISALLOW_COPY_AND_ASSIGN(BrowsingHistoryHandler); | 75 DISALLOW_COPY_AND_ASSIGN(BrowsingHistoryHandler); |
| 67 }; | 76 }; |
| 68 | 77 |
| 69 class HistoryUI : public ChromeWebUI { | 78 class HistoryUI : public ChromeWebUI { |
| 70 public: | 79 public: |
| 71 explicit HistoryUI(TabContents* contents); | 80 explicit HistoryUI(TabContents* contents); |
| 72 | 81 |
| 73 // Return the URL for a given search term. | 82 // Return the URL for a given search term. |
| 74 static const GURL GetHistoryURLWithSearchText(const string16& text); | 83 static const GURL GetHistoryURLWithSearchText(const string16& text); |
| 75 | 84 |
| 76 static RefCountedMemory* GetFaviconResourceBytes(); | 85 static RefCountedMemory* GetFaviconResourceBytes(); |
| 77 | 86 |
| 78 private: | 87 private: |
| 79 DISALLOW_COPY_AND_ASSIGN(HistoryUI); | 88 DISALLOW_COPY_AND_ASSIGN(HistoryUI); |
| 80 }; | 89 }; |
| 81 | 90 |
| 82 #endif // CHROME_BROWSER_UI_WEBUI_HISTORY_UI_H_ | 91 #endif // CHROME_BROWSER_UI_WEBUI_HISTORY_UI_H_ |
| OLD | NEW |