| 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 <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/scoped_observer.h" | 13 #include "base/scoped_observer.h" |
| 14 #include "chrome/browser/extensions/api/tabs/tabs_api.h" | 14 #include "chrome/browser/extensions/api/tabs/tabs_api.h" |
| 15 #include "chrome/browser/memory/tab_manager.h" | 15 #include "chrome/browser/resource_coordinator/tab_manager.h" |
| 16 #include "chrome/browser/memory/tab_manager_observer.h" | 16 #include "chrome/browser/resource_coordinator/tab_manager_observer.h" |
| 17 #include "chrome/browser/ui/browser_list_observer.h" | 17 #include "chrome/browser/ui/browser_list_observer.h" |
| 18 #include "chrome/browser/ui/browser_tab_strip_tracker.h" | 18 #include "chrome/browser/ui/browser_tab_strip_tracker.h" |
| 19 #include "chrome/browser/ui/browser_tab_strip_tracker_delegate.h" | 19 #include "chrome/browser/ui/browser_tab_strip_tracker_delegate.h" |
| 20 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 20 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
| 21 #include "components/favicon/core/favicon_driver_observer.h" | 21 #include "components/favicon/core/favicon_driver_observer.h" |
| 22 #include "components/zoom/zoom_observer.h" | 22 #include "components/zoom/zoom_observer.h" |
| 23 #include "content/public/browser/web_contents_observer.h" | 23 #include "content/public/browser/web_contents_observer.h" |
| 24 #include "extensions/browser/event_router.h" | 24 #include "extensions/browser/event_router.h" |
| 25 | 25 |
| 26 namespace content { | 26 namespace content { |
| 27 class WebContents; | 27 class WebContents; |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace favicon { | 30 namespace favicon { |
| 31 class FaviconDriver; | 31 class FaviconDriver; |
| 32 } | 32 } |
| 33 | 33 |
| 34 namespace extensions { | 34 namespace extensions { |
| 35 | 35 |
| 36 // The TabsEventRouter listens to tab events and routes them to listeners inside | 36 // The TabsEventRouter listens to tab events and routes them to listeners inside |
| 37 // extension process renderers. | 37 // extension process renderers. |
| 38 // TabsEventRouter will only route events from windows/tabs within a profile to | 38 // TabsEventRouter will only route events from windows/tabs within a profile to |
| 39 // extension processes in the same profile. | 39 // extension processes in the same profile. |
| 40 class TabsEventRouter : public TabStripModelObserver, | 40 class TabsEventRouter : public TabStripModelObserver, |
| 41 public BrowserTabStripTrackerDelegate, | 41 public BrowserTabStripTrackerDelegate, |
| 42 public chrome::BrowserListObserver, | 42 public chrome::BrowserListObserver, |
| 43 public favicon::FaviconDriverObserver, | 43 public favicon::FaviconDriverObserver, |
| 44 public zoom::ZoomObserver, | 44 public zoom::ZoomObserver, |
| 45 public memory::TabManagerObserver { | 45 public resource_coordinator::TabManagerObserver { |
| 46 public: | 46 public: |
| 47 explicit TabsEventRouter(Profile* profile); | 47 explicit TabsEventRouter(Profile* profile); |
| 48 ~TabsEventRouter() override; | 48 ~TabsEventRouter() override; |
| 49 | 49 |
| 50 // BrowserTabStripTrackerDelegate: | 50 // BrowserTabStripTrackerDelegate: |
| 51 bool ShouldTrackBrowser(Browser* browser) override; | 51 bool ShouldTrackBrowser(Browser* browser) override; |
| 52 | 52 |
| 53 // chrome::BrowserListObserver: | 53 // chrome::BrowserListObserver: |
| 54 void OnBrowserSetLastActive(Browser* browser) override; | 54 void OnBrowserSetLastActive(Browser* browser) override; |
| 55 | 55 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 86 void OnZoomChanged( | 86 void OnZoomChanged( |
| 87 const zoom::ZoomController::ZoomChangedEventData& data) override; | 87 const zoom::ZoomController::ZoomChangedEventData& data) override; |
| 88 | 88 |
| 89 // favicon::FaviconDriverObserver: | 89 // favicon::FaviconDriverObserver: |
| 90 void OnFaviconUpdated(favicon::FaviconDriver* favicon_driver, | 90 void OnFaviconUpdated(favicon::FaviconDriver* favicon_driver, |
| 91 NotificationIconType notification_icon_type, | 91 NotificationIconType notification_icon_type, |
| 92 const GURL& icon_url, | 92 const GURL& icon_url, |
| 93 bool icon_url_changed, | 93 bool icon_url_changed, |
| 94 const gfx::Image& image) override; | 94 const gfx::Image& image) override; |
| 95 | 95 |
| 96 // memory::TabManagerObserver: | 96 // resource_coordinator::TabManagerObserver: |
| 97 void OnDiscardedStateChange(content::WebContents* contents, | 97 void OnDiscardedStateChange(content::WebContents* contents, |
| 98 bool is_discarded) override; | 98 bool is_discarded) override; |
| 99 void OnAutoDiscardableStateChange(content::WebContents* contents, | 99 void OnAutoDiscardableStateChange(content::WebContents* contents, |
| 100 bool is_auto_discardable) override; | 100 bool is_auto_discardable) override; |
| 101 | 101 |
| 102 private: | 102 private: |
| 103 // "Synthetic" event. Called from TabInsertedAt if new tab is detected. | 103 // "Synthetic" event. Called from TabInsertedAt if new tab is detected. |
| 104 void TabCreatedAt(content::WebContents* contents, int index, bool active); | 104 void TabCreatedAt(content::WebContents* contents, int index, bool active); |
| 105 | 105 |
| 106 // Internal processing of tab updated events. Intended to be called when | 106 // Internal processing of tab updated events. Intended to be called when |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 TabEntryMap tab_entries_; | 200 TabEntryMap tab_entries_; |
| 201 | 201 |
| 202 // The main profile that owns this event router. | 202 // The main profile that owns this event router. |
| 203 Profile* profile_; | 203 Profile* profile_; |
| 204 | 204 |
| 205 ScopedObserver<favicon::FaviconDriver, TabsEventRouter> | 205 ScopedObserver<favicon::FaviconDriver, TabsEventRouter> |
| 206 favicon_scoped_observer_; | 206 favicon_scoped_observer_; |
| 207 | 207 |
| 208 BrowserTabStripTracker browser_tab_strip_tracker_; | 208 BrowserTabStripTracker browser_tab_strip_tracker_; |
| 209 | 209 |
| 210 ScopedObserver<memory::TabManager, TabsEventRouter> | 210 ScopedObserver<resource_coordinator::TabManager, TabsEventRouter> |
| 211 tab_manager_scoped_observer_; | 211 tab_manager_scoped_observer_; |
| 212 | 212 |
| 213 DISALLOW_COPY_AND_ASSIGN(TabsEventRouter); | 213 DISALLOW_COPY_AND_ASSIGN(TabsEventRouter); |
| 214 }; | 214 }; |
| 215 | 215 |
| 216 } // namespace extensions | 216 } // namespace extensions |
| 217 | 217 |
| 218 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_ | 218 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_ |
| OLD | NEW |