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_EXTENSIONS_API_HISTORY_HISTORY_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_HISTORY_HISTORY_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_HISTORY_HISTORY_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_HISTORY_HISTORY_API_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/task/cancelable_task_tracker.h" | 12 #include "base/task/cancelable_task_tracker.h" |
13 #include "chrome/browser/extensions/chrome_extension_function.h" | 13 #include "chrome/browser/extensions/chrome_extension_function.h" |
14 #include "chrome/browser/history/history_notifications.h" | 14 #include "chrome/browser/history/history_notifications.h" |
15 #include "chrome/browser/history/history_service.h" | 15 #include "chrome/browser/history/history_service.h" |
16 #include "chrome/common/extensions/api/history.h" | 16 #include "chrome/common/extensions/api/history.h" |
17 #include "components/history/core/browser/history_service_observer.h" | |
17 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
18 #include "extensions/browser/browser_context_keyed_api_factory.h" | 19 #include "extensions/browser/browser_context_keyed_api_factory.h" |
19 #include "extensions/browser/event_router.h" | 20 #include "extensions/browser/event_router.h" |
20 | 21 |
21 namespace base { | 22 namespace base { |
22 class ListValue; | 23 class ListValue; |
23 } | 24 } |
24 | 25 |
25 namespace extensions { | 26 namespace extensions { |
26 | 27 |
27 // Observes History service and routes the notifications as events to the | 28 // Observes History service and routes the notifications as events to the |
28 // extension system. | 29 // extension system. |
29 class HistoryEventRouter : public content::NotificationObserver { | 30 class HistoryEventRouter : public content::NotificationObserver, |
31 public history::HistoryServiceObserver { | |
30 public: | 32 public: |
31 explicit HistoryEventRouter(Profile* profile); | 33 explicit HistoryEventRouter(Profile* profile, |
not at google - send to devlin
2014/10/14 16:06:41
explicit no longer needed.
| |
34 HistoryService* history_service); | |
32 virtual ~HistoryEventRouter(); | 35 virtual ~HistoryEventRouter(); |
33 | 36 |
34 private: | 37 private: |
35 // content::NotificationObserver::Observe. | 38 // content::NotificationObserver::Observe. |
36 virtual void Observe(int type, | 39 virtual void Observe(int type, |
37 const content::NotificationSource& source, | 40 const content::NotificationSource& source, |
38 const content::NotificationDetails& details) override; | 41 const content::NotificationDetails& details) override; |
39 | 42 |
40 void HistoryUrlVisited(Profile* profile, | 43 // history::HistoryServiceObserver. |
41 const history::URLVisitedDetails* details); | 44 virtual void OnURLVisited(HistoryService* history_service, |
45 ui::PageTransition transition, | |
46 const history::URLRow& row, | |
47 const history::RedirectList& redirects, | |
48 base::Time visit_time) override; | |
42 | 49 |
43 void HistoryUrlsRemoved(Profile* profile, | 50 void HistoryUrlsRemoved(Profile* profile, |
44 const history::URLsDeletedDetails* details); | 51 const history::URLsDeletedDetails* details); |
45 | 52 |
46 void DispatchEvent(Profile* profile, | 53 void DispatchEvent(Profile* profile, |
47 const std::string& event_name, | 54 const std::string& event_name, |
48 scoped_ptr<base::ListValue> event_args); | 55 scoped_ptr<base::ListValue> event_args); |
49 | 56 |
50 // Used for tracking registrations to history service notifications. | 57 // Used for tracking registrations to history service notifications. |
51 content::NotificationRegistrar registrar_; | 58 content::NotificationRegistrar registrar_; |
59 Profile* profile_; | |
60 HistoryService* history_service_; | |
52 | 61 |
53 DISALLOW_COPY_AND_ASSIGN(HistoryEventRouter); | 62 DISALLOW_COPY_AND_ASSIGN(HistoryEventRouter); |
54 }; | 63 }; |
55 | 64 |
56 class HistoryAPI : public BrowserContextKeyedAPI, public EventRouter::Observer { | 65 class HistoryAPI : public BrowserContextKeyedAPI, public EventRouter::Observer { |
57 public: | 66 public: |
58 explicit HistoryAPI(content::BrowserContext* context); | 67 explicit HistoryAPI(content::BrowserContext* context); |
59 virtual ~HistoryAPI(); | 68 virtual ~HistoryAPI(); |
60 | 69 |
61 // KeyedService implementation. | 70 // KeyedService implementation. |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 // HistoryFunctionWithCallback: | 209 // HistoryFunctionWithCallback: |
201 virtual bool RunAsyncImpl() override; | 210 virtual bool RunAsyncImpl() override; |
202 | 211 |
203 // Callback for the history service to acknowledge deletion. | 212 // Callback for the history service to acknowledge deletion. |
204 void DeleteComplete(); | 213 void DeleteComplete(); |
205 }; | 214 }; |
206 | 215 |
207 } // namespace extensions | 216 } // namespace extensions |
208 | 217 |
209 #endif // CHROME_BROWSER_EXTENSIONS_API_HISTORY_HISTORY_API_H_ | 218 #endif // CHROME_BROWSER_EXTENSIONS_API_HISTORY_HISTORY_API_H_ |
OLD | NEW |