OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_TABS_TABS_EVENT_ROUTER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
14 #include "base/scoped_observer.h" | 14 #include "base/scoped_observer.h" |
15 #include "chrome/browser/extensions/api/tabs/tabs_api.h" | 15 #include "chrome/browser/extensions/api/tabs/tabs_api.h" |
16 #include "chrome/browser/ui/browser_list_observer.h" | 16 #include "chrome/browser/ui/browser_list_observer.h" |
17 #include "chrome/browser/ui/browser_tab_strip_tracker.h" | |
18 #include "chrome/browser/ui/browser_tab_strip_tracker_delegate.h" | |
17 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 19 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
18 #include "components/favicon/core/favicon_driver_observer.h" | 20 #include "components/favicon/core/favicon_driver_observer.h" |
19 #include "components/ui/zoom/zoom_observer.h" | 21 #include "components/ui/zoom/zoom_observer.h" |
20 #include "content/public/browser/notification_registrar.h" | 22 #include "content/public/browser/notification_registrar.h" |
21 #include "extensions/browser/event_router.h" | 23 #include "extensions/browser/event_router.h" |
22 | 24 |
23 namespace content { | 25 namespace content { |
24 class WebContents; | 26 class WebContents; |
25 } | 27 } |
26 | 28 |
27 namespace favicon { | 29 namespace favicon { |
28 class FaviconDriver; | 30 class FaviconDriver; |
29 } | 31 } |
30 | 32 |
31 namespace extensions { | 33 namespace extensions { |
32 | 34 |
33 // The TabsEventRouter listens to tab events and routes them to listeners inside | 35 // The TabsEventRouter listens to tab events and routes them to listeners inside |
34 // extension process renderers. | 36 // extension process renderers. |
35 // TabsEventRouter will only route events from windows/tabs within a profile to | 37 // TabsEventRouter will only route events from windows/tabs within a profile to |
36 // extension processes in the same profile. | 38 // extension processes in the same profile. |
37 class TabsEventRouter : public TabStripModelObserver, | 39 class TabsEventRouter : public TabStripModelObserver, |
40 public BrowserTabStripTrackerDelegate, | |
38 public chrome::BrowserListObserver, | 41 public chrome::BrowserListObserver, |
39 public content::NotificationObserver, | 42 public content::NotificationObserver, |
40 public favicon::FaviconDriverObserver, | 43 public favicon::FaviconDriverObserver, |
41 public ui_zoom::ZoomObserver { | 44 public ui_zoom::ZoomObserver { |
42 public: | 45 public: |
43 explicit TabsEventRouter(Profile* profile); | 46 explicit TabsEventRouter(Profile* profile); |
44 ~TabsEventRouter() override; | 47 ~TabsEventRouter() override; |
45 | 48 |
49 // BrowserTabStripTrackerDelegate: | |
50 bool ShouldTrackBrowser(Browser* browser) override; | |
51 | |
46 // chrome::BrowserListObserver | 52 // chrome::BrowserListObserver |
Peter Kasting
2015/10/10 00:34:39
Nit: While here: Colons on these class names?
sky
2015/10/12 15:16:21
Done.
| |
47 void OnBrowserAdded(Browser* browser) override; | |
48 void OnBrowserRemoved(Browser* browser) override; | |
49 void OnBrowserSetLastActive(Browser* browser) override; | 53 void OnBrowserSetLastActive(Browser* browser) override; |
50 | 54 |
51 // TabStripModelObserver | 55 // TabStripModelObserver |
52 void TabInsertedAt(content::WebContents* contents, | 56 void TabInsertedAt(content::WebContents* contents, |
53 int index, | 57 int index, |
54 bool active) override; | 58 bool active) override; |
55 void TabClosingAt(TabStripModel* tab_strip_model, | 59 void TabClosingAt(TabStripModel* tab_strip_model, |
56 content::WebContents* contents, | 60 content::WebContents* contents, |
57 int index) override; | 61 int index) override; |
58 void TabDetachedAt(content::WebContents* contents, int index) override; | 62 void TabDetachedAt(content::WebContents* contents, int index) override; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 scoped_ptr<base::ListValue> event_args, | 121 scoped_ptr<base::ListValue> event_args, |
118 scoped_ptr<base::ListValue> cross_incognito_args); | 122 scoped_ptr<base::ListValue> cross_incognito_args); |
119 | 123 |
120 // Packages |changed_properties| as a tab updated event for the tab |contents| | 124 // Packages |changed_properties| as a tab updated event for the tab |contents| |
121 // and dispatches the event to the extension. | 125 // and dispatches the event to the extension. |
122 void DispatchTabUpdatedEvent( | 126 void DispatchTabUpdatedEvent( |
123 content::WebContents* contents, | 127 content::WebContents* contents, |
124 scoped_ptr<base::DictionaryValue> changed_properties); | 128 scoped_ptr<base::DictionaryValue> changed_properties); |
125 | 129 |
126 // Register ourselves to receive the various notifications we are interested | 130 // Register ourselves to receive the various notifications we are interested |
127 // in for a browser. | |
128 void RegisterForBrowserNotifications(Browser* browser); | |
129 | |
130 // Register ourselves to receive the various notifications we are interested | |
131 // in for a tab. | 131 // in for a tab. |
132 void RegisterForTabNotifications(content::WebContents* contents); | 132 void RegisterForTabNotifications(content::WebContents* contents); |
133 | 133 |
134 // Removes notifications added in RegisterForTabNotifications. | 134 // Removes notifications added in RegisterForTabNotifications. |
135 void UnregisterForTabNotifications(content::WebContents* contents); | 135 void UnregisterForTabNotifications(content::WebContents* contents); |
136 | 136 |
137 content::NotificationRegistrar registrar_; | 137 content::NotificationRegistrar registrar_; |
138 | 138 |
139 // Maintain some information about known tabs, so we can: | 139 // Maintain some information about known tabs, so we can: |
140 // | 140 // |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 | 190 |
191 using TabEntryMap = std::map<int, linked_ptr<TabEntry>>; | 191 using TabEntryMap = std::map<int, linked_ptr<TabEntry>>; |
192 TabEntryMap tab_entries_; | 192 TabEntryMap tab_entries_; |
193 | 193 |
194 // The main profile that owns this event router. | 194 // The main profile that owns this event router. |
195 Profile* profile_; | 195 Profile* profile_; |
196 | 196 |
197 ScopedObserver<favicon::FaviconDriver, TabsEventRouter> | 197 ScopedObserver<favicon::FaviconDriver, TabsEventRouter> |
198 favicon_scoped_observer_; | 198 favicon_scoped_observer_; |
199 | 199 |
200 BrowserTabStripTracker browser_tab_strip_tracker_; | |
201 | |
200 DISALLOW_COPY_AND_ASSIGN(TabsEventRouter); | 202 DISALLOW_COPY_AND_ASSIGN(TabsEventRouter); |
201 }; | 203 }; |
202 | 204 |
203 } // namespace extensions | 205 } // namespace extensions |
204 | 206 |
205 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_ | 207 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_ |
OLD | NEW |