| 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 "chrome/browser/extensions/api/tabs/tabs_api.h" | 13 #include "chrome/browser/extensions/api/tabs/tabs_api.h" |
| 14 #include "chrome/browser/ui/browser_list_observer.h" | 14 #include "chrome/browser/ui/browser_list_observer.h" |
| 15 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
| 16 #include "chrome/browser/ui/zoom/zoom_observer.h" | 16 #include "components/ui/zoom/zoom_observer.h" |
| 17 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 18 #include "extensions/browser/event_router.h" | 18 #include "extensions/browser/event_router.h" |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| 21 class WebContents; | 21 class WebContents; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace extensions { | 24 namespace extensions { |
| 25 | 25 |
| 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 components::ZoomObserver { |
| 34 public: | 34 public: |
| 35 explicit TabsEventRouter(Profile* profile); | 35 explicit TabsEventRouter(Profile* profile); |
| 36 ~TabsEventRouter() override; | 36 ~TabsEventRouter() override; |
| 37 | 37 |
| 38 // chrome::BrowserListObserver | 38 // chrome::BrowserListObserver |
| 39 void OnBrowserAdded(Browser* browser) override; | 39 void OnBrowserAdded(Browser* browser) override; |
| 40 void OnBrowserRemoved(Browser* browser) override; | 40 void OnBrowserRemoved(Browser* browser) override; |
| 41 void OnBrowserSetLastActive(Browser* browser) override; | 41 void OnBrowserSetLastActive(Browser* browser) override; |
| 42 | 42 |
| 43 // TabStripModelObserver | 43 // TabStripModelObserver |
| (...skipping 22 matching lines...) Expand all Loading... |
| 66 int index) override; | 66 int index) override; |
| 67 void TabPinnedStateChanged(content::WebContents* contents, | 67 void TabPinnedStateChanged(content::WebContents* contents, |
| 68 int index) override; | 68 int index) override; |
| 69 | 69 |
| 70 // content::NotificationObserver. | 70 // content::NotificationObserver. |
| 71 void Observe(int type, | 71 void Observe(int type, |
| 72 const content::NotificationSource& source, | 72 const content::NotificationSource& source, |
| 73 const content::NotificationDetails& details) override; | 73 const content::NotificationDetails& details) override; |
| 74 | 74 |
| 75 // ZoomObserver. | 75 // ZoomObserver. |
| 76 void OnZoomChanged(const ZoomController::ZoomChangedEventData& data) override; | 76 void OnZoomChanged( |
| 77 const components::ZoomController::ZoomChangedEventData& data) override; |
| 77 | 78 |
| 78 private: | 79 private: |
| 79 // "Synthetic" event. Called from TabInsertedAt if new tab is detected. | 80 // "Synthetic" event. Called from TabInsertedAt if new tab is detected. |
| 80 void TabCreatedAt(content::WebContents* contents, int index, bool active); | 81 void TabCreatedAt(content::WebContents* contents, int index, bool active); |
| 81 | 82 |
| 82 // Internal processing of tab updated events. Is called by both TabChangedAt | 83 // Internal processing of tab updated events. Is called by both TabChangedAt |
| 83 // and Observe/NAV_ENTRY_COMMITTED. | 84 // and Observe/NAV_ENTRY_COMMITTED. |
| 84 void TabUpdated(content::WebContents* contents, bool did_navigate); | 85 void TabUpdated(content::WebContents* contents, bool did_navigate); |
| 85 | 86 |
| 86 // Triggers a tab updated event if the favicon URL changes. | 87 // Triggers a tab updated event if the favicon URL changes. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 168 |
| 168 // The main profile that owns this event router. | 169 // The main profile that owns this event router. |
| 169 Profile* profile_; | 170 Profile* profile_; |
| 170 | 171 |
| 171 DISALLOW_COPY_AND_ASSIGN(TabsEventRouter); | 172 DISALLOW_COPY_AND_ASSIGN(TabsEventRouter); |
| 172 }; | 173 }; |
| 173 | 174 |
| 174 } // namespace extensions | 175 } // namespace extensions |
| 175 | 176 |
| 176 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_ | 177 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_ |
| OLD | NEW |