Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_TAB_WEBCONTENTS_TRACKER_H_ | |
| 6 #define CHROME_BROWSER_UI_TAB_WEBCONTENTS_TRACKER_H_ | |
| 7 | |
| 8 #include "base/memory/singleton.h" | |
| 9 #include "base/observer_list.h" | |
| 10 #include "chrome/browser/ui/browser_list_observer.h" | |
| 11 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | |
| 12 | |
| 13 class Browser; | |
| 14 class TabStripModel; | |
| 15 | |
| 16 namespace content { class WebContents; } | |
|
Bernhard Bauer
2013/04/26 16:30:10
Forward declarations go on a separate line.
| |
| 17 | |
| 18 // TabWebContentsTracker can be used to be notified of events | |
| 19 // like WebContents in a tab being replaced. | |
| 20 class TabWebContentsTracker : public chrome::BrowserListObserver, | |
| 21 public TabStripModelObserver { | |
| 22 public: | |
| 23 static void Init(); | |
|
Bernhard Bauer
2013/04/26 16:30:10
This method isn't implemented.
| |
| 24 | |
| 25 // TabStripModelObserver: | |
|
Adrian Kuegel
2013/04/26 15:52:27
Should I add all methods from TabStripModelObserve
Bernhard Bauer
2013/04/26 16:30:10
Hm. Is there even a reason we need a separate inte
Adrian Kuegel
2013/04/29 08:11:15
I didn't think about it, but you are right, that s
| |
| 26 virtual void ActiveTabChanged(content::WebContents* old_contents, | |
| 27 content::WebContents* new_contents, | |
| 28 int index, | |
| 29 int reason) OVERRIDE; | |
| 30 virtual void TabInsertedAt(content::WebContents* contents, | |
| 31 int index, | |
| 32 bool foreground) OVERRIDE; | |
| 33 virtual void TabClosingAt(TabStripModel* tab_strip_model, | |
| 34 content::WebContents* contents, | |
| 35 int index) OVERRIDE; | |
| 36 virtual void TabDetachedAt(content::WebContents* contents, int index) | |
| 37 OVERRIDE; | |
| 38 virtual void TabReplacedAt(TabStripModel* tab_strip_model, | |
| 39 content::WebContents* old_contents, | |
| 40 content::WebContents* new_contents, | |
| 41 int index) OVERRIDE; | |
| 42 | |
| 43 // BrowserListObserver: | |
| 44 virtual void OnBrowserAdded(Browser* browser) OVERRIDE; | |
| 45 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE; | |
| 46 | |
| 47 class Observer { | |
|
Bernhard Bauer
2013/04/26 16:30:10
Inner class declarations go to the beginning of th
| |
| 48 public: | |
| 49 Observer() {} | |
| 50 virtual ~Observer() {} | |
| 51 virtual void OnActiveTabChanged(content::WebContents* old_contents, | |
| 52 content::WebContents* new_contents, | |
| 53 int index, | |
| 54 int reason) {} | |
| 55 virtual void OnTabInsertedAt(content::WebContents* contents, | |
| 56 int index, | |
| 57 bool foreground) {} | |
| 58 virtual void OnTabClosingAt(TabStripModel* tab_strip_model, | |
| 59 content::WebContents* contents, | |
| 60 int index) {} | |
| 61 virtual void OnTabDetachedAt(content::WebContents* contents, int index) {} | |
| 62 virtual void OnTabReplacedAt(TabStripModel* tab_strip_model, | |
| 63 content::WebContents* old_contents, | |
| 64 content::WebContents* new_contents, | |
| 65 int index) {} | |
| 66 | |
| 67 private: | |
| 68 DISALLOW_COPY_AND_ASSIGN(Observer); | |
| 69 }; | |
| 70 | |
| 71 static void AddObserver(Observer* observer); | |
| 72 static void RemoveObserver(Observer* observer); | |
| 73 | |
| 74 private: | |
| 75 friend class Singleton<TabWebContentsTracker, | |
| 76 DefaultSingletonTraits<TabWebContentsTracker> >; | |
| 77 friend struct DefaultSingletonTraits<TabWebContentsTracker>; | |
| 78 | |
| 79 static TabWebContentsTracker* GetInstance(); | |
| 80 | |
| 81 TabWebContentsTracker(); | |
| 82 virtual ~TabWebContentsTracker(); | |
| 83 ObserverList<Observer> observer_list_; | |
|
Bernhard Bauer
2013/04/26 16:30:10
Add a newline between method and member declaratio
| |
| 84 | |
| 85 DISALLOW_COPY_AND_ASSIGN(TabWebContentsTracker); | |
| 86 }; | |
| 87 | |
| 88 #endif // CHROME_BROWSER_UI_TAB_WEBCONTENTS_TRACKER_H_ | |
| OLD | NEW |