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 |
(...skipping 15 matching lines...) Expand all Loading... |
26 // The TabsEventRouter listens to tab events and routes them to listeners inside | 26 // The TabsEventRouter listens to tab events and routes them to listeners inside |
27 // extension process renderers. | 27 // extension process renderers. |
28 // TabsEventRouter will only route events from windows/tabs within a profile to | 28 // TabsEventRouter will only route events from windows/tabs within a profile to |
29 // extension processes in the same profile. | 29 // extension processes in the same profile. |
30 class TabsEventRouter : public TabStripModelObserver, | 30 class TabsEventRouter : public TabStripModelObserver, |
31 public chrome::BrowserListObserver, | 31 public chrome::BrowserListObserver, |
32 public content::NotificationObserver, | 32 public content::NotificationObserver, |
33 public ZoomObserver { | 33 public ZoomObserver { |
34 public: | 34 public: |
35 explicit TabsEventRouter(Profile* profile); | 35 explicit TabsEventRouter(Profile* profile); |
36 virtual ~TabsEventRouter(); | 36 ~TabsEventRouter() override; |
37 | 37 |
38 // chrome::BrowserListObserver | 38 // chrome::BrowserListObserver |
39 virtual void OnBrowserAdded(Browser* browser) override; | 39 void OnBrowserAdded(Browser* browser) override; |
40 virtual void OnBrowserRemoved(Browser* browser) override; | 40 void OnBrowserRemoved(Browser* browser) override; |
41 virtual void OnBrowserSetLastActive(Browser* browser) override; | 41 void OnBrowserSetLastActive(Browser* browser) override; |
42 | 42 |
43 // TabStripModelObserver | 43 // TabStripModelObserver |
44 virtual void TabInsertedAt(content::WebContents* contents, int index, | 44 void TabInsertedAt(content::WebContents* contents, |
45 bool active) override; | 45 int index, |
46 virtual void TabClosingAt(TabStripModel* tab_strip_model, | 46 bool active) override; |
47 content::WebContents* contents, | 47 void TabClosingAt(TabStripModel* tab_strip_model, |
48 int index) override; | 48 content::WebContents* contents, |
49 virtual void TabDetachedAt(content::WebContents* contents, | 49 int index) override; |
| 50 void TabDetachedAt(content::WebContents* contents, int index) override; |
| 51 void ActiveTabChanged(content::WebContents* old_contents, |
| 52 content::WebContents* new_contents, |
| 53 int index, |
| 54 int reason) override; |
| 55 void TabSelectionChanged(TabStripModel* tab_strip_model, |
| 56 const ui::ListSelectionModel& old_model) override; |
| 57 void TabMoved(content::WebContents* contents, |
| 58 int from_index, |
| 59 int to_index) override; |
| 60 void TabChangedAt(content::WebContents* contents, |
| 61 int index, |
| 62 TabChangeType change_type) override; |
| 63 void TabReplacedAt(TabStripModel* tab_strip_model, |
| 64 content::WebContents* old_contents, |
| 65 content::WebContents* new_contents, |
| 66 int index) override; |
| 67 void TabPinnedStateChanged(content::WebContents* contents, |
50 int index) override; | 68 int index) override; |
51 virtual void ActiveTabChanged(content::WebContents* old_contents, | |
52 content::WebContents* new_contents, | |
53 int index, | |
54 int reason) override; | |
55 virtual void TabSelectionChanged( | |
56 TabStripModel* tab_strip_model, | |
57 const ui::ListSelectionModel& old_model) override; | |
58 virtual void TabMoved(content::WebContents* contents, | |
59 int from_index, | |
60 int to_index) override; | |
61 virtual void TabChangedAt(content::WebContents* contents, | |
62 int index, | |
63 TabChangeType change_type) override; | |
64 virtual void TabReplacedAt(TabStripModel* tab_strip_model, | |
65 content::WebContents* old_contents, | |
66 content::WebContents* new_contents, | |
67 int index) override; | |
68 virtual void TabPinnedStateChanged(content::WebContents* contents, | |
69 int index) override; | |
70 | 69 |
71 // content::NotificationObserver. | 70 // content::NotificationObserver. |
72 virtual void Observe(int type, | 71 void Observe(int type, |
73 const content::NotificationSource& source, | 72 const content::NotificationSource& source, |
74 const content::NotificationDetails& details) override; | 73 const content::NotificationDetails& details) override; |
75 | 74 |
76 // ZoomObserver. | 75 // ZoomObserver. |
77 virtual void OnZoomChanged( | 76 void OnZoomChanged(const ZoomController::ZoomChangedEventData& data) override; |
78 const ZoomController::ZoomChangedEventData& data) override; | |
79 | 77 |
80 private: | 78 private: |
81 // "Synthetic" event. Called from TabInsertedAt if new tab is detected. | 79 // "Synthetic" event. Called from TabInsertedAt if new tab is detected. |
82 void TabCreatedAt(content::WebContents* contents, int index, bool active); | 80 void TabCreatedAt(content::WebContents* contents, int index, bool active); |
83 | 81 |
84 // Internal processing of tab updated events. Is called by both TabChangedAt | 82 // Internal processing of tab updated events. Is called by both TabChangedAt |
85 // and Observe/NAV_ENTRY_COMMITTED. | 83 // and Observe/NAV_ENTRY_COMMITTED. |
86 void TabUpdated(content::WebContents* contents, bool did_navigate); | 84 void TabUpdated(content::WebContents* contents, bool did_navigate); |
87 | 85 |
88 // Triggers a tab updated event if the favicon URL changes. | 86 // Triggers a tab updated event if the favicon URL changes. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 167 |
170 // The main profile that owns this event router. | 168 // The main profile that owns this event router. |
171 Profile* profile_; | 169 Profile* profile_; |
172 | 170 |
173 DISALLOW_COPY_AND_ASSIGN(TabsEventRouter); | 171 DISALLOW_COPY_AND_ASSIGN(TabsEventRouter); |
174 }; | 172 }; |
175 | 173 |
176 } // namespace extensions | 174 } // namespace extensions |
177 | 175 |
178 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_ | 176 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_ |
OLD | NEW |