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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 | 547 |
551 void ExtensionBrowserEventRouter::BrowserActionExecuted( | 548 void ExtensionBrowserEventRouter::BrowserActionExecuted( |
552 Profile* profile, const std::string& extension_id, Browser* browser) { | 549 Profile* profile, const std::string& extension_id, Browser* browser) { |
553 TabContentsWrapper* tab_contents = NULL; | 550 TabContentsWrapper* tab_contents = NULL; |
554 int tab_id = 0; | 551 int tab_id = 0; |
555 if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id)) | 552 if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id)) |
556 return; | 553 return; |
557 DispatchEventWithTab(profile, extension_id, "browserAction.onClicked", | 554 DispatchEventWithTab(profile, extension_id, "browserAction.onClicked", |
558 tab_contents->tab_contents(), true); | 555 tab_contents->tab_contents(), true); |
559 } | 556 } |
OLD | NEW |