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 <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "chrome/browser/extensions/api/commands/command_service.h" | 10 #include "chrome/browser/extensions/api/commands/command_service.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 base::DictionaryValue* CreateCommandValue( | 15 std::unique_ptr<base::DictionaryValue> CreateCommandValue( |
16 const extensions::Command& command, bool active) { | 16 const extensions::Command& command, |
17 base::DictionaryValue* result = new base::DictionaryValue(); | 17 bool active) { |
18 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); | |
Devlin
2016/09/12 19:12:34
I'm assuming that future MakeUnique calls are orth
dcheng
2016/09/12 20:26:45
This CL has been in progress for awhile: previousl
| |
18 result->SetString("name", command.command_name()); | 19 result->SetString("name", command.command_name()); |
19 result->SetString("description", command.description()); | 20 result->SetString("description", command.description()); |
20 result->SetString("shortcut", | 21 result->SetString("shortcut", |
21 active ? command.accelerator().GetShortcutText() : | 22 active ? command.accelerator().GetShortcutText() : |
22 base::string16()); | 23 base::string16()); |
23 return result; | 24 return result; |
24 } | 25 } |
25 | 26 |
26 } // namespace | 27 } // namespace |
27 | 28 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 extensions::Command command = command_service->FindCommandByName( | 60 extensions::Command command = command_service->FindCommandByName( |
60 extension_->id(), iter->second.command_name()); | 61 extension_->id(), iter->second.command_name()); |
61 ui::Accelerator shortcut_assigned = command.accelerator(); | 62 ui::Accelerator shortcut_assigned = command.accelerator(); |
62 active = (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN); | 63 active = (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN); |
63 | 64 |
64 command_list->Append(CreateCommandValue(iter->second, active)); | 65 command_list->Append(CreateCommandValue(iter->second, active)); |
65 } | 66 } |
66 | 67 |
67 return RespondNow(OneArgument(std::move(command_list))); | 68 return RespondNow(OneArgument(std::move(command_list))); |
68 } | 69 } |
OLD | NEW |