blob: 3690633d1446e6f2da6d21f57f05384b855f072d [file] [log] [blame]
[email protected]7ade2732011-02-10 00:13:581// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]76a010b2008-12-07 23:48:032// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]265a1492011-02-27 05:58:075#ifndef CHROME_BROWSER_UI_WEBUI_HISTORY_UI_H_
6#define CHROME_BROWSER_UI_WEBUI_HISTORY_UI_H_
[email protected]32b76ef2010-07-26 23:08:247#pragma once
[email protected]76a010b2008-12-07 23:48:038
[email protected]038d52e12009-10-14 16:53:419#include <string>
[email protected]0189bc722009-08-28 21:56:4810
[email protected]e53668962010-06-23 15:35:2511#include "base/string16.h"
[email protected]5581d762011-12-27 14:05:2412#include "chrome/browser/cancelable_request.h"
[email protected]b689fce72009-03-17 22:45:3413#include "chrome/browser/history/history.h"
[email protected]fd42ac30f2011-02-27 19:33:3614#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
[email protected]6c2381d2011-10-19 02:52:5315#include "content/public/browser/notification_registrar.h"
[email protected]e14c959122012-01-13 16:58:2516#include "content/public/browser/web_ui_controller.h"
[email protected]26e2632a2011-12-31 04:02:5517#include "content/public/browser/web_ui_message_handler.h"
[email protected]76a010b2008-12-07 23:48:0318
[email protected]76a010b2008-12-07 23:48:0319// The handler for Javascript messages related to the "history" view.
[email protected]26e2632a2011-12-31 04:02:5520class BrowsingHistoryHandler : public content::WebUIMessageHandler,
[email protected]6c2381d2011-10-19 02:52:5321 public content::NotificationObserver {
[email protected]76a010b2008-12-07 23:48:0322 public:
[email protected]2bc2de62009-06-29 23:37:4223 BrowsingHistoryHandler();
[email protected]76a010b2008-12-07 23:48:0324 virtual ~BrowsingHistoryHandler();
25
[email protected]36e12172011-02-08 23:46:0226 // WebUIMessageHandler implementation.
[email protected]3abbed002011-08-01 16:02:2027 virtual void RegisterMessages() OVERRIDE;
[email protected]2bc2de62009-06-29 23:37:4228
[email protected]60a83db2012-04-05 14:11:1429 // Handler for the "getHistory" message.
[email protected]f3a1c642011-07-12 19:15:0330 void HandleGetHistory(const base::ListValue* args);
[email protected]76a010b2008-12-07 23:48:0331
[email protected]60a83db2012-04-05 14:11:1432 // Handler for the "searchHistory" message.
[email protected]f3a1c642011-07-12 19:15:0333 void HandleSearchHistory(const base::ListValue* args);
[email protected]fbf644e72009-02-19 22:26:0634
[email protected]60a83db2012-04-05 14:11:1435 // Handler for the "removeURLsOnOneDay" message.
[email protected]f3a1c642011-07-12 19:15:0336 void HandleRemoveURLsOnOneDay(const base::ListValue* args);
[email protected]21f4d2512010-03-05 08:15:5337
[email protected]60a83db2012-04-05 14:11:1438 // Handler for "clearBrowsingData" message.
[email protected]f3a1c642011-07-12 19:15:0339 void HandleClearBrowsingData(const base::ListValue* args);
[email protected]fbf644e72009-02-19 22:26:0640
[email protected]60a83db2012-04-05 14:11:1441 // Handler for "removeBookmark" message.
42 void HandleRemoveBookmark(const base::ListValue* args);
43
[email protected]6c2381d2011-10-19 02:52:5344 // content::NotificationObserver implementation.
[email protected]432115822011-07-10 15:52:2745 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:5346 const content::NotificationSource& source,
47 const content::NotificationDetails& details) OVERRIDE;
[email protected]9f392932011-06-09 14:08:0048
[email protected]76a010b2008-12-07 23:48:0349 private:
[email protected]fbf644e72009-02-19 22:26:0650 // Callback from the history system when the history list is available.
[email protected]76a010b2008-12-07 23:48:0351 void QueryComplete(HistoryService::Handle request_handle,
52 history::QueryResults* results);
53
[email protected]21f4d2512010-03-05 08:15:5354 // Callback from the history system when visits were deleted.
55 void RemoveComplete();
56
[email protected]fbf644e72009-02-19 22:26:0657 // Extract the arguments from the call to HandleSearchHistory.
[email protected]f3a1c642011-07-12 19:15:0358 void ExtractSearchHistoryArguments(const base::ListValue* args,
[email protected]f0a51fb52009-03-05 12:46:3859 int* month,
[email protected]e53668962010-06-23 15:35:2560 string16* query);
[email protected]76a010b2008-12-07 23:48:0361
[email protected]fbf644e72009-02-19 22:26:0662 // Figure out the query options for a month-wide query.
63 history::QueryOptions CreateMonthQueryOptions(int month);
[email protected]76a010b2008-12-07 23:48:0364
[email protected]6c2381d2011-10-19 02:52:5365 content::NotificationRegistrar registrar_;
[email protected]9f392932011-06-09 14:08:0066
[email protected]76a010b2008-12-07 23:48:0367 // Current search text.
[email protected]e53668962010-06-23 15:35:2568 string16 search_text_;
[email protected]76a010b2008-12-07 23:48:0369
[email protected]b660ea9f2010-05-31 07:55:5170 // Our consumer for search requests to the history service.
71 CancelableRequestConsumerT<int, 0> cancelable_search_consumer_;
72
73 // Our consumer for delete requests to the history service.
74 CancelableRequestConsumerT<int, 0> cancelable_delete_consumer_;
[email protected]76a010b2008-12-07 23:48:0375
[email protected]d66bbe02011-11-16 10:19:4376 // The list of URLs that are in the process of being deleted.
77 std::set<GURL> urls_to_be_deleted_;
78
[email protected]76a010b2008-12-07 23:48:0379 DISALLOW_COPY_AND_ASSIGN(BrowsingHistoryHandler);
80};
81
[email protected]c63cedf22012-01-17 18:42:2282class HistoryUI : public content::WebUIController {
[email protected]76a010b2008-12-07 23:48:0383 public:
[email protected]01ec4ec2012-01-18 04:13:4784 explicit HistoryUI(content::WebUI* web_ui);
[email protected]76a010b2008-12-07 23:48:0385
[email protected]9e4c0332009-02-25 17:47:5886 // Return the URL for a given search term.
[email protected]e53668962010-06-23 15:35:2587 static const GURL GetHistoryURLWithSearchText(const string16& text);
[email protected]9e4c0332009-02-25 17:47:5888
[email protected]6de27992009-10-19 17:04:4689 static RefCountedMemory* GetFaviconResourceBytes();
[email protected]0189bc722009-08-28 21:56:4890
[email protected]76a010b2008-12-07 23:48:0391 private:
[email protected]76a010b2008-12-07 23:48:0392 DISALLOW_COPY_AND_ASSIGN(HistoryUI);
93};
94
[email protected]265a1492011-02-27 05:58:0795#endif // CHROME_BROWSER_UI_WEBUI_HISTORY_UI_H_