OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 | 646 |
647 void ExtensionBrowserEventRouter::BrowserActionExecuted( | 647 void ExtensionBrowserEventRouter::BrowserActionExecuted( |
648 Profile* profile, const std::string& extension_id, Browser* browser) { | 648 Profile* profile, const std::string& extension_id, Browser* browser) { |
649 TabContentsWrapper* tab_contents = NULL; | 649 TabContentsWrapper* tab_contents = NULL; |
650 int tab_id = 0; | 650 int tab_id = 0; |
651 if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id)) | 651 if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id)) |
652 return; | 652 return; |
653 DispatchEventWithTab(profile, extension_id, "browserAction.onClicked", | 653 DispatchEventWithTab(profile, extension_id, "browserAction.onClicked", |
654 tab_contents->web_contents(), true); | 654 tab_contents->web_contents(), true); |
655 } | 655 } |
| 656 |
| 657 void ExtensionBrowserEventRouter::CommandExecuted( |
| 658 Profile* profile, |
| 659 const std::string& extension_id, |
| 660 const std::string& command) { |
| 661 ListValue args; |
| 662 args.Append(Value::CreateStringValue(command)); |
| 663 std::string json_args; |
| 664 base::JSONWriter::Write(&args, false, &json_args); |
| 665 |
| 666 DispatchEventToExtension(profile, |
| 667 extension_id, |
| 668 "experimental.keybinding.onCommand", |
| 669 json_args); |
| 670 } |
OLD | NEW |