blob: 892b2ab1800eae48e35842a576a56b0c56502f68 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_DOM_UI_HISTORY_UI_H_
#define CHROME_BROWSER_DOM_UI_HISTORY_UI_H_
#include <string>
#include <vector>
#include "chrome/browser/browsing_data_remover.h"
#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
#include "chrome/browser/dom_ui/dom_ui.h"
#include "chrome/browser/cancelable_request.h"
#include "chrome/browser/history/history.h"
#include "chrome/common/notification_registrar.h"
class GURL;
class HistoryUIHTMLSource : public ChromeURLDataManager::DataSource {
public:
HistoryUIHTMLSource();
// Called when the network layer has requested a resource underneath
// the path we registered.
virtual void StartDataRequest(const std::string& path, int request_id);
virtual std::string GetMimeType(const std::string&) const {
return "text/html";
}
private:
DISALLOW_COPY_AND_ASSIGN(HistoryUIHTMLSource);
};
// The handler for Javascript messages related to the "history" view.
class BrowsingHistoryHandler : public DOMMessageHandler,
public NotificationObserver,
public BrowsingDataRemover::Observer {
public:
BrowsingHistoryHandler();
virtual ~BrowsingHistoryHandler();
// DOMMessageHandler implementation.
virtual DOMMessageHandler* Attach(DOMUI* dom_ui);
virtual void RegisterMessages();
// Callback for the "getHistory" message.
void HandleGetHistory(const Value* value);
// Callback for the "searchHistory" message.
void HandleSearchHistory(const Value* value);
// Callback for the "deleteDay" message.
void HandleDeleteDay(const Value* value);
// NotificationObserver implementation.
virtual void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details);
// BrowsingDataRemover observer implementation.
void OnBrowsingDataRemoverDone();
private:
// Callback from the history system when the history list is available.
void QueryComplete(HistoryService::Handle request_handle,
history::QueryResults* results);
// Extract the arguments from the call to HandleSearchHistory.
void ExtractSearchHistoryArguments(const Value* value,
int* month,
std::wstring* query);
// Figure out the query options for a month-wide query.
history::QueryOptions CreateMonthQueryOptions(int month);
NotificationRegistrar registrar_;
// Current search text.
std::wstring search_text_;
// Browsing history remover
BrowsingDataRemover* remover_;
// Our consumer for the history service.
CancelableRequestConsumerT<int, 0> cancelable_consumer_;
DISALLOW_COPY_AND_ASSIGN(BrowsingHistoryHandler);
};
class HistoryUI : public DOMUI {
public:
explicit HistoryUI(TabContents* contents);
// Return the URL for a given search term.
static const GURL GetHistoryURLWithSearchText(const std::wstring& text);
static bool GetFaviconResourceBytes(std::vector<unsigned char>* bytes);
private:
DISALLOW_COPY_AND_ASSIGN(HistoryUI);
};
#endif // CHROME_BROWSER_DOM_UI_HISTORY_UI_H_
|