Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Side by Side Diff: chrome/browser/extensions/api/history/history_api.h

Issue 651193002: Remove NOTIFICATION_HISTORY_URL_VISITED (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@373326.2
Patch Set: Address comments Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/scoped_observer.h"
12 #include "base/task/cancelable_task_tracker.h" 13 #include "base/task/cancelable_task_tracker.h"
13 #include "chrome/browser/extensions/chrome_extension_function.h" 14 #include "chrome/browser/extensions/chrome_extension_function.h"
14 #include "chrome/browser/history/history_notifications.h" 15 #include "chrome/browser/history/history_notifications.h"
15 #include "chrome/browser/history/history_service.h" 16 #include "chrome/browser/history/history_service.h"
16 #include "chrome/common/extensions/api/history.h" 17 #include "chrome/common/extensions/api/history.h"
18 #include "components/history/core/browser/history_service_observer.h"
17 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
18 #include "extensions/browser/browser_context_keyed_api_factory.h" 20 #include "extensions/browser/browser_context_keyed_api_factory.h"
19 #include "extensions/browser/event_router.h" 21 #include "extensions/browser/event_router.h"
20 22
21 namespace base { 23 namespace base {
22 class ListValue; 24 class ListValue;
23 } 25 }
24 26
25 namespace extensions { 27 namespace extensions {
26 28
27 // Observes History service and routes the notifications as events to the 29 // Observes History service and routes the notifications as events to the
28 // extension system. 30 // extension system.
29 class HistoryEventRouter : public content::NotificationObserver { 31 class HistoryEventRouter : public content::NotificationObserver,
32 public history::HistoryServiceObserver {
30 public: 33 public:
31 explicit HistoryEventRouter(Profile* profile); 34 HistoryEventRouter(Profile* profile, 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 ScopedObserver<HistoryService, HistoryServiceObserver>
61 history_service_observer_;
52 62
53 DISALLOW_COPY_AND_ASSIGN(HistoryEventRouter); 63 DISALLOW_COPY_AND_ASSIGN(HistoryEventRouter);
54 }; 64 };
55 65
56 class HistoryAPI : public BrowserContextKeyedAPI, public EventRouter::Observer { 66 class HistoryAPI : public BrowserContextKeyedAPI, public EventRouter::Observer {
57 public: 67 public:
58 explicit HistoryAPI(content::BrowserContext* context); 68 explicit HistoryAPI(content::BrowserContext* context);
59 virtual ~HistoryAPI(); 69 virtual ~HistoryAPI();
60 70
61 // KeyedService implementation. 71 // KeyedService implementation.
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // HistoryFunctionWithCallback: 210 // HistoryFunctionWithCallback:
201 virtual bool RunAsyncImpl() override; 211 virtual bool RunAsyncImpl() override;
202 212
203 // Callback for the history service to acknowledge deletion. 213 // Callback for the history service to acknowledge deletion.
204 void DeleteComplete(); 214 void DeleteComplete();
205 }; 215 };
206 216
207 } // namespace extensions 217 } // namespace extensions
208 218
209 #endif // CHROME_BROWSER_EXTENSIONS_API_HISTORY_HISTORY_API_H_ 219 #endif // CHROME_BROWSER_EXTENSIONS_API_HISTORY_HISTORY_API_H_
OLDNEW
« no previous file with comments | « chrome/browser/chrome_notification_types.h ('k') | chrome/browser/extensions/api/history/history_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698