| 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 "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 17 #include "extensions/browser/event_router.h" | 18 #include "extensions/browser/event_router.h" |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 class WebContents; | 21 class WebContents; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace extensions { | 24 namespace extensions { |
| 24 | 25 |
| 25 // 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 |
| 26 // extension process renderers. | 27 // extension process renderers. |
| 27 // 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 |
| 28 // extension processes in the same profile. | 29 // extension processes in the same profile. |
| 29 class TabsEventRouter : public TabStripModelObserver, | 30 class TabsEventRouter : public TabStripModelObserver, |
| 30 public chrome::BrowserListObserver, | 31 public chrome::BrowserListObserver, |
| 31 public content::NotificationObserver { | 32 public content::NotificationObserver, |
| 33 public ZoomObserver { |
| 32 public: | 34 public: |
| 33 explicit TabsEventRouter(Profile* profile); | 35 explicit TabsEventRouter(Profile* profile); |
| 34 virtual ~TabsEventRouter(); | 36 virtual ~TabsEventRouter(); |
| 35 | 37 |
| 36 // chrome::BrowserListObserver | 38 // chrome::BrowserListObserver |
| 37 virtual void OnBrowserAdded(Browser* browser) OVERRIDE; | 39 virtual void OnBrowserAdded(Browser* browser) OVERRIDE; |
| 38 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE; | 40 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE; |
| 39 virtual void OnBrowserSetLastActive(Browser* browser) OVERRIDE; | 41 virtual void OnBrowserSetLastActive(Browser* browser) OVERRIDE; |
| 40 | 42 |
| 41 // TabStripModelObserver | 43 // TabStripModelObserver |
| (...skipping 21 matching lines...) Expand all Loading... |
| 63 content::WebContents* old_contents, | 65 content::WebContents* old_contents, |
| 64 content::WebContents* new_contents, | 66 content::WebContents* new_contents, |
| 65 int index) OVERRIDE; | 67 int index) OVERRIDE; |
| 66 virtual void TabPinnedStateChanged(content::WebContents* contents, | 68 virtual void TabPinnedStateChanged(content::WebContents* contents, |
| 67 int index) OVERRIDE; | 69 int index) OVERRIDE; |
| 68 | 70 |
| 69 // content::NotificationObserver. | 71 // content::NotificationObserver. |
| 70 virtual void Observe(int type, | 72 virtual void Observe(int type, |
| 71 const content::NotificationSource& source, | 73 const content::NotificationSource& source, |
| 72 const content::NotificationDetails& details) OVERRIDE; | 74 const content::NotificationDetails& details) OVERRIDE; |
| 75 |
| 76 // ZoomObserver. |
| 77 virtual void OnZoomChanged( |
| 78 const ZoomController::ZoomChangedEventData& data) OVERRIDE; |
| 79 |
| 73 private: | 80 private: |
| 74 // "Synthetic" event. Called from TabInsertedAt if new tab is detected. | 81 // "Synthetic" event. Called from TabInsertedAt if new tab is detected. |
| 75 void TabCreatedAt(content::WebContents* contents, int index, bool active); | 82 void TabCreatedAt(content::WebContents* contents, int index, bool active); |
| 76 | 83 |
| 77 // Internal processing of tab updated events. Is called by both TabChangedAt | 84 // Internal processing of tab updated events. Is called by both TabChangedAt |
| 78 // and Observe/NAV_ENTRY_COMMITTED. | 85 // and Observe/NAV_ENTRY_COMMITTED. |
| 79 void TabUpdated(content::WebContents* contents, bool did_navigate); | 86 void TabUpdated(content::WebContents* contents, bool did_navigate); |
| 80 | 87 |
| 81 // Triggers a tab updated event if the favicon URL changes. | 88 // Triggers a tab updated event if the favicon URL changes. |
| 82 void FaviconUrlUpdated(content::WebContents* contents); | 89 void FaviconUrlUpdated(content::WebContents* contents); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 169 |
| 163 // The main profile that owns this event router. | 170 // The main profile that owns this event router. |
| 164 Profile* profile_; | 171 Profile* profile_; |
| 165 | 172 |
| 166 DISALLOW_COPY_AND_ASSIGN(TabsEventRouter); | 173 DISALLOW_COPY_AND_ASSIGN(TabsEventRouter); |
| 167 }; | 174 }; |
| 168 | 175 |
| 169 } // namespace extensions | 176 } // namespace extensions |
| 170 | 177 |
| 171 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_ | 178 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_ |
| OLD | NEW |