OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_COMMANDS_H_ | |
6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_COMMANDS_H_ | |
7 #pragma once | |
8 | |
9 #include <string> | |
10 #include <map> | |
11 | |
12 #include "base/string16.h" | |
13 #include "ui/base/accelerators/accelerator.h" | |
14 | |
15 namespace base { | |
16 class DictionaryValue; | |
17 } | |
18 | |
19 namespace extensions { | |
20 class Extension; | |
21 } | |
22 | |
23 namespace extensions { | |
24 | |
25 class Command { | |
26 public: | |
27 // Define out of line constructor/destructor to please Clang. | |
28 Command(); | |
29 ~Command(); | |
30 | |
31 // The platform value for the Command. | |
32 static std::string CommandPlatform(); | |
33 | |
34 // Parse the command. | |
35 bool Parse(base::DictionaryValue* command, | |
36 const std::string& command_name, | |
37 int index, | |
38 string16* error); | |
39 | |
40 // Convert a Command object from |extension| to a DictionaryValue. | |
41 // |active| specifies whether the command is active or not. | |
42 base::DictionaryValue* ToValue( | |
43 const Extension* extension, bool active) const; | |
44 | |
45 // Accessors: | |
46 const std::string& command_name() const { return command_name_; } | |
47 const ui::Accelerator& accelerator() const { return accelerator_; } | |
48 const string16& description() const { return description_; } | |
49 | |
50 private: | |
51 ui::Accelerator ParseImpl(const std::string& shortcut, | |
52 const std::string& platform_key, | |
53 int index, | |
54 string16* error); | |
55 std::string command_name_; | |
56 ui::Accelerator accelerator_; | |
57 string16 description_; | |
58 }; | |
59 | |
60 // A mapping of command name (std::string) to a command object. | |
61 typedef std::map<std::string, Command> CommandMap; | |
62 | |
63 } // namespace extensions | |
64 | |
65 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_COMMANDS_H_ | |
OLD | NEW |