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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 DCHECK_GT(removed_count, 0); | 296 DCHECK_GT(removed_count, 0); |
297 | 297 |
298 UnregisterForTabNotifications(contents->tab_contents()); | 298 UnregisterForTabNotifications(contents->tab_contents()); |
299 } | 299 } |
300 | 300 |
301 void ExtensionBrowserEventRouter::ActiveTabChanged( | 301 void ExtensionBrowserEventRouter::ActiveTabChanged( |
302 TabContentsWrapper* old_contents, | 302 TabContentsWrapper* old_contents, |
303 TabContentsWrapper* new_contents, | 303 TabContentsWrapper* new_contents, |
304 int index, | 304 int index, |
305 bool user_gesture) { | 305 bool user_gesture) { |
306 if (old_contents == new_contents) | |
307 return; | |
308 | |
309 ListValue args; | 306 ListValue args; |
310 args.Append(Value::CreateIntegerValue( | 307 args.Append(Value::CreateIntegerValue( |
311 ExtensionTabUtil::GetTabId(new_contents->tab_contents()))); | 308 ExtensionTabUtil::GetTabId(new_contents->tab_contents()))); |
312 | 309 |
313 DictionaryValue* object_args = new DictionaryValue(); | 310 DictionaryValue* object_args = new DictionaryValue(); |
314 object_args->Set(tab_keys::kWindowIdKey, Value::CreateIntegerValue( | 311 object_args->Set(tab_keys::kWindowIdKey, Value::CreateIntegerValue( |
315 ExtensionTabUtil::GetWindowIdOfTab(new_contents->tab_contents()))); | 312 ExtensionTabUtil::GetWindowIdOfTab(new_contents->tab_contents()))); |
316 args.Append(object_args); | 313 args.Append(object_args); |
317 | 314 |
318 std::string json_args; | 315 std::string json_args; |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 | 545 |
549 void ExtensionBrowserEventRouter::BrowserActionExecuted( | 546 void ExtensionBrowserEventRouter::BrowserActionExecuted( |
550 Profile* profile, const std::string& extension_id, Browser* browser) { | 547 Profile* profile, const std::string& extension_id, Browser* browser) { |
551 TabContentsWrapper* tab_contents = NULL; | 548 TabContentsWrapper* tab_contents = NULL; |
552 int tab_id = 0; | 549 int tab_id = 0; |
553 if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id)) | 550 if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id)) |
554 return; | 551 return; |
555 DispatchEventWithTab(profile, extension_id, "browserAction.onClicked", | 552 DispatchEventWithTab(profile, extension_id, "browserAction.onClicked", |
556 tab_contents->tab_contents()); | 553 tab_contents->tab_contents()); |
557 } | 554 } |
OLD | NEW |