OLD | NEW |
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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 base::JSONWriter::Write(&args, false, &json_args); | 337 base::JSONWriter::Write(&args, false, &json_args); |
338 | 338 |
339 DispatchEvent(contents->profile(), events::kOnTabRemoved, json_args); | 339 DispatchEvent(contents->profile(), events::kOnTabRemoved, json_args); |
340 | 340 |
341 int removed_count = tab_entries_.erase(tab_id); | 341 int removed_count = tab_entries_.erase(tab_id); |
342 DCHECK_GT(removed_count, 0); | 342 DCHECK_GT(removed_count, 0); |
343 | 343 |
344 UnregisterForTabNotifications(contents->tab_contents()); | 344 UnregisterForTabNotifications(contents->tab_contents()); |
345 } | 345 } |
346 | 346 |
347 void ExtensionBrowserEventRouter::TabSelectedAt( | 347 void ExtensionBrowserEventRouter::ActiveTabChanged( |
348 TabContentsWrapper* old_contents, | 348 TabContentsWrapper* old_contents, |
349 TabContentsWrapper* new_contents, | 349 TabContentsWrapper* new_contents, |
350 int index, | 350 int index, |
351 bool user_gesture) { | 351 bool user_gesture) { |
352 if (old_contents == new_contents) | 352 if (old_contents == new_contents) |
353 return; | 353 return; |
354 | 354 |
355 ListValue args; | 355 ListValue args; |
356 args.Append(Value::CreateIntegerValue( | 356 args.Append(Value::CreateIntegerValue( |
357 ExtensionTabUtil::GetTabId(new_contents->tab_contents()))); | 357 ExtensionTabUtil::GetTabId(new_contents->tab_contents()))); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 | 539 |
540 void ExtensionBrowserEventRouter::BrowserActionExecuted( | 540 void ExtensionBrowserEventRouter::BrowserActionExecuted( |
541 Profile* profile, const std::string& extension_id, Browser* browser) { | 541 Profile* profile, const std::string& extension_id, Browser* browser) { |
542 TabContentsWrapper* tab_contents = NULL; | 542 TabContentsWrapper* tab_contents = NULL; |
543 int tab_id = 0; | 543 int tab_id = 0; |
544 if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id)) | 544 if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id)) |
545 return; | 545 return; |
546 DispatchEventWithTab(profile, extension_id, "browserAction.onClicked", | 546 DispatchEventWithTab(profile, extension_id, "browserAction.onClicked", |
547 tab_contents->tab_contents()); | 547 tab_contents->tab_contents()); |
548 } | 548 } |
OLD | NEW |