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/api/commands/commands.h" | 5 #include "chrome/browser/extensions/api/commands/commands.h" |
6 | 6 |
7 #include "chrome/browser/extensions/api/commands/command_service.h" | 7 #include "chrome/browser/extensions/api/commands/command_service.h" |
8 | 8 |
9 namespace { | 9 namespace { |
10 | 10 |
11 base::DictionaryValue* CreateCommandValue( | 11 base::DictionaryValue* CreateCommandValue( |
12 const extensions::Command& command, bool active) { | 12 const extensions::Command& command, bool active) { |
13 DictionaryValue* result = new DictionaryValue(); | 13 base::DictionaryValue* result = new base::DictionaryValue(); |
14 result->SetString("name", command.command_name()); | 14 result->SetString("name", command.command_name()); |
15 result->SetString("description", command.description()); | 15 result->SetString("description", command.description()); |
16 result->SetString("shortcut", | 16 result->SetString("shortcut", |
17 active ? command.accelerator().GetShortcutText() : | 17 active ? command.accelerator().GetShortcutText() : |
18 string16()); | 18 string16()); |
19 return result; | 19 return result; |
20 } | 20 } |
21 | 21 |
22 } // namespace | 22 } // namespace |
23 | 23 |
24 bool GetAllCommandsFunction::RunImpl() { | 24 bool GetAllCommandsFunction::RunImpl() { |
25 ListValue* command_list = new ListValue(); | 25 base::ListValue* command_list = new base::ListValue(); |
26 | 26 |
27 extensions::CommandService* command_service = | 27 extensions::CommandService* command_service = |
28 extensions::CommandService::Get(profile_); | 28 extensions::CommandService::Get(profile_); |
29 | 29 |
30 extensions::Command browser_action; | 30 extensions::Command browser_action; |
31 bool active = false; | 31 bool active = false; |
32 if (command_service->GetBrowserActionCommand(extension_->id(), | 32 if (command_service->GetBrowserActionCommand(extension_->id(), |
33 extensions::CommandService::ALL, | 33 extensions::CommandService::ALL, |
34 &browser_action, | 34 &browser_action, |
35 &active)) { | 35 &active)) { |
(...skipping 27 matching lines...) Expand all Loading... |
63 command_service->FindShortcutForCommand( | 63 command_service->FindShortcutForCommand( |
64 extension_->id(), iter->second.command_name()); | 64 extension_->id(), iter->second.command_name()); |
65 active = (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN); | 65 active = (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN); |
66 | 66 |
67 command_list->Append(CreateCommandValue(iter->second, active)); | 67 command_list->Append(CreateCommandValue(iter->second, active)); |
68 } | 68 } |
69 | 69 |
70 SetResult(command_list); | 70 SetResult(command_list); |
71 return true; | 71 return true; |
72 } | 72 } |
OLD | NEW |