summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_browser_event_router.h
diff options
context:
space:
mode:
authorrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-15 04:25:34 +0000
committerrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-15 04:25:34 +0000
commite9a4513ccdb40e341a699285d174b60f20736966 (patch)
tree7b2ea16fcc25f9b3d6524563e7f92b2907117d93 /chrome/browser/extensions/extension_browser_event_router.h
parent5d063840bdb2c53dc013e2bad48d76cb43ac89a5 (diff)
downloadchromium_src-e9a4513ccdb40e341a699285d174b60f20736966.zip
chromium_src-e9a4513ccdb40e341a699285d174b60f20736966.tar.gz
chromium_src-e9a4513ccdb40e341a699285d174b60f20736966.tar.bz2
Uploaded & applied on behalf of Roger Tawa (rogerta@google.com).
BUG=11200 R=aa,rafaelw http://codereview.chromium.org/115250 Review URL: http://codereview.chromium.org/113442 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16146 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_browser_event_router.h')
-rw-r--r--chrome/browser/extensions/extension_browser_event_router.h37
1 files changed, 33 insertions, 4 deletions
diff --git a/chrome/browser/extensions/extension_browser_event_router.h b/chrome/browser/extensions/extension_browser_event_router.h
index afebdd3..749c6e3 100644
--- a/chrome/browser/extensions/extension_browser_event_router.h
+++ b/chrome/browser/extensions/extension_browser_event_router.h
@@ -5,13 +5,14 @@
#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_EVENT_ROUTER_H_
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_EVENT_ROUTER_H_
+#include <map>
#include <vector>
-#include <set>
#include <string>
#include "base/basictypes.h"
#include "base/singleton.h"
#include "chrome/browser/browser_list.h"
+#include "chrome/browser/extensions/extension_tabs_module.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/common/notification_observer.h"
@@ -64,9 +65,37 @@ class ExtensionBrowserEventRouter : public TabStripModelObserver,
bool initialized_;
- // Maintain set of known tab ids, so we can distinguish between tab creation
- // and tab insertion. Also used to not send tab-detached after tab-removed.
- std::set<int> tab_ids_;
+ // Maintain some information about known tabs, so we can:
+ //
+ // - distinguish between tab creation and tab insertion
+ // - not send tab-detached after tab-removed
+ // - reduce the "noise" of TabChangedAt() when sending events to extensions
+ class TabEntry {
+ public:
+ // Create a new tab entry whose initial state is TAB_COMPLETE. This
+ // constructor is required because TabEntry objects placed inside an
+ // std::map<> by value.
+ TabEntry();
+
+ // Create a new tab entry whose initial state is derived from the given
+ // tab contents.
+ explicit TabEntry(const TabContents* contents);
+
+ // Returns the current state of the tab.
+ ExtensionTabUtil::TabStatus state() const { return state_; }
+
+ // Update the state of the tab based on its TabContents. Returns true if
+ // the state changed, false otherwise. Whether the state has changed or not
+ // is used to determine if events needs to be sent to extensions during
+ // processing of TabChangedAt().
+ bool UpdateState(const TabContents* contents);
+
+ private:
+ // Tab state used for last notification to extensions.
+ ExtensionTabUtil::TabStatus state_;
+ };
+
+ std::map<int, TabEntry> tab_entries_;
DISALLOW_COPY_AND_ASSIGN(ExtensionBrowserEventRouter);
};