Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(643)

Unified Diff: chrome/browser/ui/tab_webcontents_tracker.h

Issue 14518005: Add TabWebContentsTracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/tab_webcontents_tracker.h
diff --git a/chrome/browser/ui/tab_webcontents_tracker.h b/chrome/browser/ui/tab_webcontents_tracker.h
new file mode 100644
index 0000000000000000000000000000000000000000..5050c5af954d67f67e6c06e76550a6f5e73d2f60
--- /dev/null
+++ b/chrome/browser/ui/tab_webcontents_tracker.h
@@ -0,0 +1,88 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_TAB_WEBCONTENTS_TRACKER_H_
+#define CHROME_BROWSER_UI_TAB_WEBCONTENTS_TRACKER_H_
+
+#include "base/memory/singleton.h"
+#include "base/observer_list.h"
+#include "chrome/browser/ui/browser_list_observer.h"
+#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
+
+class Browser;
+class TabStripModel;
+
+namespace content { class WebContents; }
Bernhard Bauer 2013/04/26 16:30:10 Forward declarations go on a separate line.
+
+// TabWebContentsTracker can be used to be notified of events
+// like WebContents in a tab being replaced.
+class TabWebContentsTracker : public chrome::BrowserListObserver,
+ public TabStripModelObserver {
+ public:
+ static void Init();
Bernhard Bauer 2013/04/26 16:30:10 This method isn't implemented.
+
+ // 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
+ virtual void ActiveTabChanged(content::WebContents* old_contents,
+ content::WebContents* new_contents,
+ int index,
+ int reason) OVERRIDE;
+ virtual void TabInsertedAt(content::WebContents* contents,
+ int index,
+ bool foreground) OVERRIDE;
+ virtual void TabClosingAt(TabStripModel* tab_strip_model,
+ content::WebContents* contents,
+ int index) OVERRIDE;
+ virtual void TabDetachedAt(content::WebContents* contents, int index)
+ OVERRIDE;
+ virtual void TabReplacedAt(TabStripModel* tab_strip_model,
+ content::WebContents* old_contents,
+ content::WebContents* new_contents,
+ int index) OVERRIDE;
+
+ // BrowserListObserver:
+ virtual void OnBrowserAdded(Browser* browser) OVERRIDE;
+ virtual void OnBrowserRemoved(Browser* browser) OVERRIDE;
+
+ class Observer {
Bernhard Bauer 2013/04/26 16:30:10 Inner class declarations go to the beginning of th
+ public:
+ Observer() {}
+ virtual ~Observer() {}
+ virtual void OnActiveTabChanged(content::WebContents* old_contents,
+ content::WebContents* new_contents,
+ int index,
+ int reason) {}
+ virtual void OnTabInsertedAt(content::WebContents* contents,
+ int index,
+ bool foreground) {}
+ virtual void OnTabClosingAt(TabStripModel* tab_strip_model,
+ content::WebContents* contents,
+ int index) {}
+ virtual void OnTabDetachedAt(content::WebContents* contents, int index) {}
+ virtual void OnTabReplacedAt(TabStripModel* tab_strip_model,
+ content::WebContents* old_contents,
+ content::WebContents* new_contents,
+ int index) {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Observer);
+ };
+
+ static void AddObserver(Observer* observer);
+ static void RemoveObserver(Observer* observer);
+
+ private:
+ friend class Singleton<TabWebContentsTracker,
+ DefaultSingletonTraits<TabWebContentsTracker> >;
+ friend struct DefaultSingletonTraits<TabWebContentsTracker>;
+
+ static TabWebContentsTracker* GetInstance();
+
+ TabWebContentsTracker();
+ virtual ~TabWebContentsTracker();
+ ObserverList<Observer> observer_list_;
Bernhard Bauer 2013/04/26 16:30:10 Add a newline between method and member declaratio
+
+ DISALLOW_COPY_AND_ASSIGN(TabWebContentsTracker);
+};
+
+#endif // CHROME_BROWSER_UI_TAB_WEBCONTENTS_TRACKER_H_

Powered by Google App Engine
This is Rietveld 408576698