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

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

Issue 7134035: Make an inserted selected tab selected before calling TabInsertedAt on observers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rename selected to active Created 9 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extension_browser_event_router.h" 5 #include "chrome/browser/extensions/extension_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/extension_event_names.h" 9 #include "chrome/browser/extensions/extension_event_names.h"
10 #include "chrome/browser/extensions/extension_event_router.h" 10 #include "chrome/browser/extensions/extension_event_router.h"
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // See crbug.com/46610. 210 // See crbug.com/46610.
211 DispatchSimpleBrowserEvent(browser ? browser->profile() : profile_, 211 DispatchSimpleBrowserEvent(browser ? browser->profile() : profile_,
212 focused_window_id_, 212 focused_window_id_,
213 events::kOnWindowFocusedChanged); 213 events::kOnWindowFocusedChanged);
214 } 214 }
215 215
216 void ExtensionBrowserEventRouter::TabCreatedAt(TabContents* contents, 216 void ExtensionBrowserEventRouter::TabCreatedAt(TabContents* contents,
217 int index, 217 int index,
218 bool foreground) { 218 bool foreground) {
219 DispatchEventWithTab(contents->profile(), "", events::kOnTabCreated, 219 DispatchEventWithTab(contents->profile(), "", events::kOnTabCreated,
220 contents); 220 contents, foreground);
sky 2011/06/10 14:58:59 foreground->active
221 221
222 RegisterForTabNotifications(contents); 222 RegisterForTabNotifications(contents);
223 } 223 }
224 224
225 void ExtensionBrowserEventRouter::TabInsertedAt(TabContentsWrapper* contents, 225 void ExtensionBrowserEventRouter::TabInsertedAt(TabContentsWrapper* contents,
226 int index, 226 int index,
227 bool foreground) { 227 bool foreground) {
228 // If tab is new, send created event. 228 // If tab is new, send created event.
229 int tab_id = ExtensionTabUtil::GetTabId(contents->tab_contents()); 229 int tab_id = ExtensionTabUtil::GetTabId(contents->tab_contents());
230 if (!GetTabEntry(contents->tab_contents())) { 230 if (!GetTabEntry(contents->tab_contents())) {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 return; 379 return;
380 380
381 profile->GetExtensionEventRouter()->DispatchEventToExtension( 381 profile->GetExtensionEventRouter()->DispatchEventToExtension(
382 extension_id, event_name, json_args, profile, GURL()); 382 extension_id, event_name, json_args, profile, GURL());
383 } 383 }
384 384
385 void ExtensionBrowserEventRouter::DispatchEventWithTab( 385 void ExtensionBrowserEventRouter::DispatchEventWithTab(
386 Profile* profile, 386 Profile* profile,
387 const std::string& extension_id, 387 const std::string& extension_id,
388 const char* event_name, 388 const char* event_name,
389 const TabContents* tab_contents) { 389 const TabContents* tab_contents,
390 bool foreground) {
sky 2011/06/10 14:58:59 foreground -> active
390 if (!profile_->IsSameProfile(profile)) 391 if (!profile_->IsSameProfile(profile))
391 return; 392 return;
392 393
393 ListValue args; 394 ListValue args;
394 args.Append(ExtensionTabUtil::CreateTabValue(tab_contents)); 395 args.Append(ExtensionTabUtil::CreateTabValueActive(
396 tab_contents, foreground));
395 std::string json_args; 397 std::string json_args;
396 base::JSONWriter::Write(&args, false, &json_args); 398 base::JSONWriter::Write(&args, false, &json_args);
397 if (!extension_id.empty()) { 399 if (!extension_id.empty()) {
398 DispatchEventToExtension(profile, extension_id, event_name, json_args); 400 DispatchEventToExtension(profile, extension_id, event_name, json_args);
399 } else { 401 } else {
400 DispatchEvent(profile, event_name, json_args); 402 DispatchEvent(profile, event_name, json_args);
401 } 403 }
402 } 404 }
403 405
404 void ExtensionBrowserEventRouter::DispatchSimpleBrowserEvent( 406 void ExtensionBrowserEventRouter::DispatchSimpleBrowserEvent(
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 const std::string& url, 538 const std::string& url,
537 int button) { 539 int button) {
538 DispatchOldPageActionEvent(profile, extension_id, page_action_id, tab_id, url, 540 DispatchOldPageActionEvent(profile, extension_id, page_action_id, tab_id, url,
539 button); 541 button);
540 TabContentsWrapper* tab_contents = NULL; 542 TabContentsWrapper* tab_contents = NULL;
541 if (!ExtensionTabUtil::GetTabById(tab_id, profile, profile->IsOffTheRecord(), 543 if (!ExtensionTabUtil::GetTabById(tab_id, profile, profile->IsOffTheRecord(),
542 NULL, NULL, &tab_contents, NULL)) { 544 NULL, NULL, &tab_contents, NULL)) {
543 return; 545 return;
544 } 546 }
545 DispatchEventWithTab(profile, extension_id, "pageAction.onClicked", 547 DispatchEventWithTab(profile, extension_id, "pageAction.onClicked",
546 tab_contents->tab_contents()); 548 tab_contents->tab_contents(), true);
547 } 549 }
548 550
549 void ExtensionBrowserEventRouter::BrowserActionExecuted( 551 void ExtensionBrowserEventRouter::BrowserActionExecuted(
550 Profile* profile, const std::string& extension_id, Browser* browser) { 552 Profile* profile, const std::string& extension_id, Browser* browser) {
551 TabContentsWrapper* tab_contents = NULL; 553 TabContentsWrapper* tab_contents = NULL;
552 int tab_id = 0; 554 int tab_id = 0;
553 if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id)) 555 if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id))
554 return; 556 return;
555 DispatchEventWithTab(profile, extension_id, "browserAction.onClicked", 557 DispatchEventWithTab(profile, extension_id, "browserAction.onClicked",
556 tab_contents->tab_contents()); 558 tab_contents->tab_contents(), true);
557 } 559 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698