OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_HISTORY_HISTORY_EXTENSION_API_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_EXTENSION_API_H_ |
6 #define CHROME_BROWSER_HISTORY_HISTORY_EXTENSION_API_H_ | 6 #define CHROME_BROWSER_HISTORY_HISTORY_EXTENSION_API_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "chrome/browser/extensions/extension_function.h" | 12 #include "chrome/browser/extensions/extension_function.h" |
13 #include "chrome/browser/history/history.h" | 13 #include "chrome/browser/history/history.h" |
14 #include "chrome/browser/history/history_notifications.h" | 14 #include "chrome/browser/history/history_notifications.h" |
15 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
16 | 16 |
| 17 namespace base { |
| 18 class ListValue; |
| 19 } |
| 20 |
17 // Observes History service and routes the notifications as events to the | 21 // Observes History service and routes the notifications as events to the |
18 // extension system. | 22 // extension system. |
19 class HistoryExtensionEventRouter : public content::NotificationObserver { | 23 class HistoryExtensionEventRouter : public content::NotificationObserver { |
20 public: | 24 public: |
21 explicit HistoryExtensionEventRouter(); | 25 explicit HistoryExtensionEventRouter(); |
22 virtual ~HistoryExtensionEventRouter(); | 26 virtual ~HistoryExtensionEventRouter(); |
23 | 27 |
24 void ObserveProfile(Profile* profile); | 28 void ObserveProfile(Profile* profile); |
25 | 29 |
26 private: | 30 private: |
27 // content::NotificationObserver::Observe. | 31 // content::NotificationObserver::Observe. |
28 virtual void Observe(int type, | 32 virtual void Observe(int type, |
29 const content::NotificationSource& source, | 33 const content::NotificationSource& source, |
30 const content::NotificationDetails& details) OVERRIDE; | 34 const content::NotificationDetails& details) OVERRIDE; |
31 | 35 |
32 void HistoryUrlVisited(Profile* profile, | 36 void HistoryUrlVisited(Profile* profile, |
33 const history::URLVisitedDetails* details); | 37 const history::URLVisitedDetails* details); |
34 | 38 |
35 void HistoryUrlsRemoved(Profile* profile, | 39 void HistoryUrlsRemoved(Profile* profile, |
36 const history::URLsDeletedDetails* details); | 40 const history::URLsDeletedDetails* details); |
37 | 41 |
38 void DispatchEvent(Profile* profile, | 42 void DispatchEvent(Profile* profile, |
39 const char* event_name, | 43 const char* event_name, |
40 const std::string& json_args); | 44 base::ListValue* event_args); |
41 | 45 |
42 // Used for tracking registrations to history service notifications. | 46 // Used for tracking registrations to history service notifications. |
43 content::NotificationRegistrar registrar_; | 47 content::NotificationRegistrar registrar_; |
44 | 48 |
45 DISALLOW_COPY_AND_ASSIGN(HistoryExtensionEventRouter); | 49 DISALLOW_COPY_AND_ASSIGN(HistoryExtensionEventRouter); |
46 }; | 50 }; |
47 | 51 |
48 | 52 |
49 // Base class for history function APIs. | 53 // Base class for history function APIs. |
50 class HistoryFunction : public AsyncExtensionFunction { | 54 class HistoryFunction : public AsyncExtensionFunction { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 virtual ~DeleteRangeHistoryFunction() {} | 165 virtual ~DeleteRangeHistoryFunction() {} |
162 | 166 |
163 // HistoryFunctionWithCallback: | 167 // HistoryFunctionWithCallback: |
164 virtual bool RunAsyncImpl() OVERRIDE; | 168 virtual bool RunAsyncImpl() OVERRIDE; |
165 | 169 |
166 // Callback for the history service to acknowledge deletion. | 170 // Callback for the history service to acknowledge deletion. |
167 void DeleteComplete(); | 171 void DeleteComplete(); |
168 }; | 172 }; |
169 | 173 |
170 #endif // CHROME_BROWSER_HISTORY_HISTORY_EXTENSION_API_H_ | 174 #endif // CHROME_BROWSER_HISTORY_HISTORY_EXTENSION_API_H_ |
OLD | NEW |