blob: cda33f2029f414cd3a03f3daee7f45a6edd2bfeb [file] [log] [blame]
[email protected]21f4d2512010-03-05 08:15:531// Copyright (c) 2010 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]b689fce72009-03-17 22:45:345#ifndef CHROME_BROWSER_DOM_UI_HISTORY_UI_H_
6#define CHROME_BROWSER_DOM_UI_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]76a010b2008-12-07 23:48:0312#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
13#include "chrome/browser/dom_ui/dom_ui.h"
[email protected]95cdbbc02009-02-24 15:11:0514#include "chrome/browser/cancelable_request.h"
[email protected]b689fce72009-03-17 22:45:3415#include "chrome/browser/history/history.h"
[email protected]59316ec2009-05-21 00:47:2016#include "chrome/common/notification_registrar.h"
[email protected]76a010b2008-12-07 23:48:0317
18class GURL;
19
20class HistoryUIHTMLSource : public ChromeURLDataManager::DataSource {
21 public:
22 HistoryUIHTMLSource();
23
24 // Called when the network layer has requested a resource underneath
25 // the path we registered.
[email protected]f09d93792009-11-17 00:10:3626 virtual void StartDataRequest(const std::string& path,
27 bool is_off_the_record,
28 int request_id);
[email protected]ddb1e5a2010-12-13 20:10:4529 virtual std::string GetMimeType(const std::string&) const;
[email protected]76a010b2008-12-07 23:48:0330
31 private:
[email protected]8de85a62009-11-06 08:32:1732 ~HistoryUIHTMLSource() {}
33
[email protected]76a010b2008-12-07 23:48:0334 DISALLOW_COPY_AND_ASSIGN(HistoryUIHTMLSource);
35};
36
37// The handler for Javascript messages related to the "history" view.
[email protected]36e12172011-02-08 23:46:0238class BrowsingHistoryHandler : public WebUIMessageHandler,
[email protected]21f4d2512010-03-05 08:15:5339 public NotificationObserver {
[email protected]76a010b2008-12-07 23:48:0340 public:
[email protected]2bc2de62009-06-29 23:37:4241 BrowsingHistoryHandler();
[email protected]76a010b2008-12-07 23:48:0342 virtual ~BrowsingHistoryHandler();
43
[email protected]36e12172011-02-08 23:46:0244 // WebUIMessageHandler implementation.
45 virtual WebUIMessageHandler* Attach(DOMUI* dom_ui);
[email protected]2bc2de62009-06-29 23:37:4246 virtual void RegisterMessages();
47
[email protected]76a010b2008-12-07 23:48:0348 // Callback for the "getHistory" message.
[email protected]88942a22010-08-19 20:34:4349 void HandleGetHistory(const ListValue* args);
[email protected]76a010b2008-12-07 23:48:0350
[email protected]fbf644e72009-02-19 22:26:0651 // Callback for the "searchHistory" message.
[email protected]88942a22010-08-19 20:34:4352 void HandleSearchHistory(const ListValue* args);
[email protected]fbf644e72009-02-19 22:26:0653
[email protected]21f4d2512010-03-05 08:15:5354 // Callback for the "removeURLsOnOneDay" message.
[email protected]88942a22010-08-19 20:34:4355 void HandleRemoveURLsOnOneDay(const ListValue* args);
[email protected]21f4d2512010-03-05 08:15:5356
57 // Handle for "clearBrowsingData" message.
[email protected]88942a22010-08-19 20:34:4358 void HandleClearBrowsingData(const ListValue* args);
[email protected]fbf644e72009-02-19 22:26:0659
[email protected]76a010b2008-12-07 23:48:0360 // NotificationObserver implementation.
61 virtual void Observe(NotificationType type,
62 const NotificationSource& source,
63 const NotificationDetails& details);
64
65 private:
[email protected]fbf644e72009-02-19 22:26:0666 // Callback from the history system when the history list is available.
[email protected]76a010b2008-12-07 23:48:0367 void QueryComplete(HistoryService::Handle request_handle,
68 history::QueryResults* results);
69
[email protected]21f4d2512010-03-05 08:15:5370 // Callback from the history system when visits were deleted.
71 void RemoveComplete();
72
[email protected]fbf644e72009-02-19 22:26:0673 // Extract the arguments from the call to HandleSearchHistory.
[email protected]88942a22010-08-19 20:34:4374 void ExtractSearchHistoryArguments(const ListValue* args,
[email protected]f0a51fb52009-03-05 12:46:3875 int* month,
[email protected]e53668962010-06-23 15:35:2576 string16* query);
[email protected]76a010b2008-12-07 23:48:0377
[email protected]fbf644e72009-02-19 22:26:0678 // Figure out the query options for a month-wide query.
79 history::QueryOptions CreateMonthQueryOptions(int month);
[email protected]76a010b2008-12-07 23:48:0380
[email protected]59316ec2009-05-21 00:47:2081 NotificationRegistrar registrar_;
82
[email protected]76a010b2008-12-07 23:48:0383 // Current search text.
[email protected]e53668962010-06-23 15:35:2584 string16 search_text_;
[email protected]76a010b2008-12-07 23:48:0385
[email protected]b660ea9f2010-05-31 07:55:5186 // Our consumer for search requests to the history service.
87 CancelableRequestConsumerT<int, 0> cancelable_search_consumer_;
88
89 // Our consumer for delete requests to the history service.
90 CancelableRequestConsumerT<int, 0> cancelable_delete_consumer_;
[email protected]76a010b2008-12-07 23:48:0391
92 DISALLOW_COPY_AND_ASSIGN(BrowsingHistoryHandler);
93};
94
95class HistoryUI : public DOMUI {
96 public:
[email protected]57c6a652009-05-04 07:58:3497 explicit HistoryUI(TabContents* contents);
[email protected]76a010b2008-12-07 23:48:0398
[email protected]9e4c0332009-02-25 17:47:5899 // Return the URL for a given search term.
[email protected]e53668962010-06-23 15:35:25100 static const GURL GetHistoryURLWithSearchText(const string16& text);
[email protected]9e4c0332009-02-25 17:47:58101
[email protected]6de27992009-10-19 17:04:46102 static RefCountedMemory* GetFaviconResourceBytes();
[email protected]0189bc722009-08-28 21:56:48103
[email protected]76a010b2008-12-07 23:48:03104 private:
[email protected]76a010b2008-12-07 23:48:03105 DISALLOW_COPY_AND_ASSIGN(HistoryUI);
106};
107
[email protected]b689fce72009-03-17 22:45:34108#endif // CHROME_BROWSER_DOM_UI_HISTORY_UI_H_