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

Side by Side Diff: chrome/browser/extensions/browser_event_router.cc

Issue 11364196: Remove TabContents from TabStripModelObserver::ActiveTabChanged. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/extensions/browser_event_router.h" 5 #include "chrome/browser/extensions/browser_event_router.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_ api_constants.h" 9 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_ api_constants.h"
10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); 243 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
244 DispatchEvent(profile, events::kOnTabRemoved, args.Pass(), 244 DispatchEvent(profile, events::kOnTabRemoved, args.Pass(),
245 EventRouter::USER_GESTURE_UNKNOWN); 245 EventRouter::USER_GESTURE_UNKNOWN);
246 246
247 int removed_count = tab_entries_.erase(tab_id); 247 int removed_count = tab_entries_.erase(tab_id);
248 DCHECK_GT(removed_count, 0); 248 DCHECK_GT(removed_count, 0);
249 249
250 UnregisterForTabNotifications(contents); 250 UnregisterForTabNotifications(contents);
251 } 251 }
252 252
253 void BrowserEventRouter::ActiveTabChanged(TabContents* old_contents, 253 void BrowserEventRouter::ActiveTabChanged(WebContents* old_contents,
254 TabContents* new_contents, 254 WebContents* new_contents,
255 int index, 255 int index,
256 bool user_gesture) { 256 bool user_gesture) {
257 scoped_ptr<ListValue> args(new ListValue()); 257 scoped_ptr<ListValue> args(new ListValue());
258 int tab_id = ExtensionTabUtil::GetTabId(new_contents->web_contents()); 258 int tab_id = ExtensionTabUtil::GetTabId(new_contents);
259 args->Append(Value::CreateIntegerValue(tab_id)); 259 args->Append(Value::CreateIntegerValue(tab_id));
260 260
261 DictionaryValue* object_args = new DictionaryValue(); 261 DictionaryValue* object_args = new DictionaryValue();
262 object_args->Set(tab_keys::kWindowIdKey, Value::CreateIntegerValue( 262 object_args->Set(tab_keys::kWindowIdKey, Value::CreateIntegerValue(
263 ExtensionTabUtil::GetWindowIdOfTab(new_contents->web_contents()))); 263 ExtensionTabUtil::GetWindowIdOfTab(new_contents)));
264 args->Append(object_args); 264 args->Append(object_args);
265 265
266 // The onActivated event replaced onActiveChanged and onSelectionChanged. The 266 // The onActivated event replaced onActiveChanged and onSelectionChanged. The
267 // deprecated events take two arguments: tabId, {windowId}. 267 // deprecated events take two arguments: tabId, {windowId}.
268 Profile* profile = new_contents->profile(); 268 Profile* profile =
269 Profile::FromBrowserContext(new_contents->GetBrowserContext());
269 EventRouter::UserGestureState gesture = user_gesture ? 270 EventRouter::UserGestureState gesture = user_gesture ?
270 EventRouter::USER_GESTURE_ENABLED : EventRouter::USER_GESTURE_NOT_ENABLED; 271 EventRouter::USER_GESTURE_ENABLED : EventRouter::USER_GESTURE_NOT_ENABLED;
271 DispatchEvent(profile, events::kOnTabSelectionChanged, 272 DispatchEvent(profile, events::kOnTabSelectionChanged,
272 scoped_ptr<ListValue>(args->DeepCopy()), gesture); 273 scoped_ptr<ListValue>(args->DeepCopy()), gesture);
273 DispatchEvent(profile, events::kOnTabActiveChanged, 274 DispatchEvent(profile, events::kOnTabActiveChanged,
274 scoped_ptr<ListValue>(args->DeepCopy()), gesture); 275 scoped_ptr<ListValue>(args->DeepCopy()), gesture);
275 276
276 // The onActivated event takes one argument: {windowId, tabId}. 277 // The onActivated event takes one argument: {windowId, tabId}.
277 args->Remove(0, NULL); 278 args->Remove(0, NULL);
278 object_args->Set(tab_keys::kTabIdKey, Value::CreateIntegerValue(tab_id)); 279 object_args->Set(tab_keys::kTabIdKey, Value::CreateIntegerValue(tab_id));
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 596
596 DispatchEventToExtension(profile, 597 DispatchEventToExtension(profile,
597 extension_action.extension_id(), 598 extension_action.extension_id(),
598 event_name, 599 event_name,
599 args.Pass(), 600 args.Pass(),
600 EventRouter::USER_GESTURE_ENABLED); 601 EventRouter::USER_GESTURE_ENABLED);
601 } 602 }
602 } 603 }
603 604
604 } // namespace extensions 605 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/browser_event_router.h ('k') | chrome/browser/ui/ash/launcher/browser_launcher_item_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698