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

Unified Diff: chrome/browser/extensions/browser_event_router.cc

Issue 11607012: Add tabs.onReplaced event to notify listeners of tabs being swapped due to prerendering or instant. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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
« no previous file with comments | « no previous file | chrome/browser/extensions/event_names.h » ('j') | chrome/common/extensions/api/tabs.json » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/browser_event_router.cc
diff --git a/chrome/browser/extensions/browser_event_router.cc b/chrome/browser/extensions/browser_event_router.cc
index bf457f9fb319c29063e9f8e87ba6efa479c9df12..b351baba20a7456f2d4621132b8740d25c328441 100644
--- a/chrome/browser/extensions/browser_event_router.cc
+++ b/chrome/browser/extensions/browser_event_router.cc
@@ -471,6 +471,19 @@ void BrowserEventRouter::TabReplacedAt(TabStripModel* tab_strip_model,
WebContents* old_contents,
WebContents* new_contents,
int index) {
+ // Notify listeners that the next tabs closing or being added are due to
+ // WebContents being swapped.
+ scoped_ptr<ListValue> args(new ListValue());
+ args->Append(Value::CreateIntegerValue(
+ ExtensionTabUtil::GetTabId(new_contents)));
+ args->Append(Value::CreateIntegerValue(
+ ExtensionTabUtil::GetTabId(old_contents)));
+
+ DispatchEvent(Profile::FromBrowserContext(new_contents->GetBrowserContext()),
+ events::kOnTabSwapped,
+ args.Pass(),
+ EventRouter::USER_GESTURE_UNKNOWN);
+
TabClosingAt(tab_strip_model, old_contents, index);
TabInsertedAt(new_contents, index, tab_strip_model->active_index() == index);
Matt Perry 2012/12/18 18:04:02 Can we remove these two calls? The downside is tha
justinlin 2012/12/19 23:42:42 Yea, I thought about removing at first, but wanted
}
« no previous file with comments | « no previous file | chrome/browser/extensions/event_names.h » ('j') | chrome/common/extensions/api/tabs.json » ('J')

Powered by Google App Engine
This is Rietveld 408576698