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_EXTENSIONS_EXTENSION_HISTORY_API_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_EXTENSION_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_HISTORY_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 // Observes History service and routes the notifications as events to the | 17 // Observes History service and routes the notifications as events to the |
18 // extension system. | 18 // extension system. |
19 class ExtensionHistoryEventRouter : public content::NotificationObserver { | 19 class HistoryExtensionEventRouter : public content::NotificationObserver { |
20 public: | 20 public: |
21 explicit ExtensionHistoryEventRouter(); | 21 explicit HistoryExtensionEventRouter(); |
22 virtual ~ExtensionHistoryEventRouter(); | 22 virtual ~HistoryExtensionEventRouter(); |
23 | 23 |
24 void ObserveProfile(Profile* profile); | 24 void ObserveProfile(Profile* profile); |
25 | 25 |
26 private: | 26 private: |
27 // content::NotificationObserver::Observe. | 27 // content::NotificationObserver::Observe. |
28 virtual void Observe(int type, | 28 virtual void Observe(int type, |
29 const content::NotificationSource& source, | 29 const content::NotificationSource& source, |
30 const content::NotificationDetails& details) OVERRIDE; | 30 const content::NotificationDetails& details) OVERRIDE; |
31 | 31 |
32 void HistoryUrlVisited(Profile* profile, | 32 void HistoryUrlVisited(Profile* profile, |
33 const history::URLVisitedDetails* details); | 33 const history::URLVisitedDetails* details); |
34 | 34 |
35 void HistoryUrlsRemoved(Profile* profile, | 35 void HistoryUrlsRemoved(Profile* profile, |
36 const history::URLsDeletedDetails* details); | 36 const history::URLsDeletedDetails* details); |
37 | 37 |
38 void DispatchEvent(Profile* profile, | 38 void DispatchEvent(Profile* profile, |
39 const char* event_name, | 39 const char* event_name, |
40 const std::string& json_args); | 40 const std::string& json_args); |
41 | 41 |
42 // Used for tracking registrations to history service notifications. | 42 // Used for tracking registrations to history service notifications. |
43 content::NotificationRegistrar registrar_; | 43 content::NotificationRegistrar registrar_; |
44 | 44 |
45 DISALLOW_COPY_AND_ASSIGN(ExtensionHistoryEventRouter); | 45 DISALLOW_COPY_AND_ASSIGN(HistoryExtensionEventRouter); |
46 }; | 46 }; |
47 | 47 |
48 | 48 |
49 // Base class for history function APIs. | 49 // Base class for history function APIs. |
50 class HistoryFunction : public AsyncExtensionFunction { | 50 class HistoryFunction : public AsyncExtensionFunction { |
51 public: | 51 public: |
52 virtual void Run() OVERRIDE; | 52 virtual void Run() OVERRIDE; |
53 virtual bool RunImpl() = 0; | 53 virtual bool RunImpl() = 0; |
54 | 54 |
55 bool GetUrlFromValue(base::Value* value, GURL* url); | 55 bool GetUrlFromValue(base::Value* value, GURL* url); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 class DeleteRangeHistoryFunction : public HistoryFunctionWithCallback { | 131 class DeleteRangeHistoryFunction : public HistoryFunctionWithCallback { |
132 public: | 132 public: |
133 virtual bool RunAsyncImpl() OVERRIDE; | 133 virtual bool RunAsyncImpl() OVERRIDE; |
134 DECLARE_EXTENSION_FUNCTION_NAME("history.deleteRange"); | 134 DECLARE_EXTENSION_FUNCTION_NAME("history.deleteRange"); |
135 | 135 |
136 // Callback for the history service to acknowledge deletion. | 136 // Callback for the history service to acknowledge deletion. |
137 void DeleteComplete(); | 137 void DeleteComplete(); |
138 }; | 138 }; |
139 | 139 |
140 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_HISTORY_API_H_ | 140 #endif // CHROME_BROWSER_HISTORY_HISTORY_EXTENSION_API_H_ |
OLD | NEW |