OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_writer.h" | 7 #include "base/json_writer.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/browser.h" | 9 #include "chrome/browser/browser.h" |
10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 args.Append(data); | 368 args.Append(data); |
369 | 369 |
370 std::string json_args; | 370 std::string json_args; |
371 JSONWriter::Write(&args, false, &json_args); | 371 JSONWriter::Write(&args, false, &json_args); |
372 | 372 |
373 std::string event_name = std::string("pageAction/") + extension_id; | 373 std::string event_name = std::string("pageAction/") + extension_id; |
374 DispatchEvent(profile, event_name.c_str(), json_args); | 374 DispatchEvent(profile, event_name.c_str(), json_args); |
375 } | 375 } |
376 | 376 |
377 void ExtensionBrowserEventRouter::BrowserActionExecuted( | 377 void ExtensionBrowserEventRouter::BrowserActionExecuted( |
378 Profile* profile, const std::string& extension_id, int window_id) { | 378 Profile* profile, const std::string& extension_id, Browser* browser) { |
| 379 TabContents* tab_contents = NULL; |
| 380 int tab_id = 0; |
| 381 if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id)) |
| 382 return; |
| 383 |
379 ListValue args; | 384 ListValue args; |
380 args.Append(Value::CreateIntegerValue(window_id)); | 385 args.Append(ExtensionTabUtil::CreateTabValue(tab_contents)); |
381 | |
382 std::string json_args; | 386 std::string json_args; |
383 JSONWriter::Write(&args, false, &json_args); | 387 JSONWriter::Write(&args, false, &json_args); |
384 | 388 |
385 std::string event_name = std::string("browserAction/") + extension_id; | 389 std::string event_name = std::string("browserAction/") + extension_id; |
386 DispatchEvent(profile, event_name.c_str(), json_args); | 390 DispatchEvent(profile, event_name.c_str(), json_args); |
387 } | 391 } |
OLD | NEW |