| 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 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
| 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <utility> | 13 #include <utility> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/file_path.h" | 16 #include "base/file_path.h" |
| 17 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
| 18 #include "base/hash_tables.h" | 18 #include "base/hash_tables.h" |
| 19 #include "base/memory/linked_ptr.h" | 19 #include "base/memory/linked_ptr.h" |
| 20 #include "base/memory/ref_counted.h" | 20 #include "base/memory/ref_counted.h" |
| 21 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
| 22 #include "base/synchronization/lock.h" | 22 #include "base/synchronization/lock.h" |
| 23 #include "chrome/common/extensions/extension_action.h" | 23 #include "chrome/common/extensions/extension_action.h" |
| 24 #include "chrome/common/extensions/extension_commands.h" |
| 24 #include "chrome/common/extensions/extension_constants.h" | 25 #include "chrome/common/extensions/extension_constants.h" |
| 25 #include "chrome/common/extensions/extension_icon_set.h" | 26 #include "chrome/common/extensions/extension_icon_set.h" |
| 26 #include "chrome/common/extensions/extension_permission_set.h" | 27 #include "chrome/common/extensions/extension_permission_set.h" |
| 27 #include "chrome/common/extensions/user_script.h" | 28 #include "chrome/common/extensions/user_script.h" |
| 28 #include "chrome/common/extensions/url_pattern.h" | 29 #include "chrome/common/extensions/url_pattern.h" |
| 29 #include "chrome/common/extensions/url_pattern_set.h" | 30 #include "chrome/common/extensions/url_pattern_set.h" |
| 30 #include "googleurl/src/gurl.h" | 31 #include "googleurl/src/gurl.h" |
| 31 #include "ui/base/accelerators/accelerator.h" | 32 #include "ui/base/accelerators/accelerator.h" |
| 32 #include "ui/gfx/size.h" | 33 #include "ui/gfx/size.h" |
| 33 | 34 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 std::string id; | 152 std::string id; |
| 152 std::string description; | 153 std::string description; |
| 153 std::string language; | 154 std::string language; |
| 154 std::set<std::string> layouts; | 155 std::set<std::string> layouts; |
| 155 std::string shortcut_keycode; | 156 std::string shortcut_keycode; |
| 156 bool shortcut_alt; | 157 bool shortcut_alt; |
| 157 bool shortcut_ctrl; | 158 bool shortcut_ctrl; |
| 158 bool shortcut_shift; | 159 bool shortcut_shift; |
| 159 }; | 160 }; |
| 160 | 161 |
| 161 class Command { | |
| 162 public: | |
| 163 // Define out of line constructor/destructor to please Clang. | |
| 164 Command(); | |
| 165 ~Command(); | |
| 166 | |
| 167 // The platform value for the Command. | |
| 168 static std::string CommandPlatform(); | |
| 169 | |
| 170 // Parse the command. | |
| 171 bool Parse(base::DictionaryValue* command, | |
| 172 const std::string& command_name, | |
| 173 int index, | |
| 174 string16* error); | |
| 175 | |
| 176 // Accessors: | |
| 177 const std::string& command_name() const { return command_name_; } | |
| 178 const ui::Accelerator& accelerator() const { return accelerator_; } | |
| 179 const std::string& description() const { return description_; } | |
| 180 | |
| 181 private: | |
| 182 ui::Accelerator ParseImpl(const std::string& shortcut, | |
| 183 const std::string& platform_key, | |
| 184 int index, | |
| 185 string16* error); | |
| 186 std::string command_name_; | |
| 187 ui::Accelerator accelerator_; | |
| 188 std::string description_; | |
| 189 }; | |
| 190 | |
| 191 // A mapping of command name (std::string) to a command object. | |
| 192 typedef std::map<std::string, Command> CommandMap; | |
| 193 | |
| 194 struct TtsVoice { | 162 struct TtsVoice { |
| 195 // Define out of line constructor/destructor to please Clang. | 163 // Define out of line constructor/destructor to please Clang. |
| 196 TtsVoice(); | 164 TtsVoice(); |
| 197 ~TtsVoice(); | 165 ~TtsVoice(); |
| 198 | 166 |
| 199 std::string voice_name; | 167 std::string voice_name; |
| 200 std::string lang; | 168 std::string lang; |
| 201 std::string gender; | 169 std::string gender; |
| 202 std::set<std::string> event_types; | 170 std::set<std::string> event_types; |
| 203 }; | 171 }; |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 const std::vector<PluginInfo>& plugins() const { return plugins_; } | 562 const std::vector<PluginInfo>& plugins() const { return plugins_; } |
| 595 const std::vector<NaClModuleInfo>& nacl_modules() const { | 563 const std::vector<NaClModuleInfo>& nacl_modules() const { |
| 596 return nacl_modules_; | 564 return nacl_modules_; |
| 597 } | 565 } |
| 598 const std::vector<InputComponentInfo>& input_components() const { | 566 const std::vector<InputComponentInfo>& input_components() const { |
| 599 return input_components_; | 567 return input_components_; |
| 600 } | 568 } |
| 601 // The browser action command that the extension wants to use, which is not | 569 // The browser action command that the extension wants to use, which is not |
| 602 // necessarily the one it can use, as it might be inactive (see also | 570 // necessarily the one it can use, as it might be inactive (see also |
| 603 // GetActiveBrowserActionCommand in ExtensionKeybindingRegistry). | 571 // GetActiveBrowserActionCommand in ExtensionKeybindingRegistry). |
| 604 const Command* browser_action_command() const { | 572 const extensions::Command* browser_action_command() const { |
| 605 return browser_action_command_.get(); | 573 return browser_action_command_.get(); |
| 606 } | 574 } |
| 607 // The page action command that the extension wants to use, which is not | 575 // The page action command that the extension wants to use, which is not |
| 608 // necessarily the one it can use, as it might be inactive (see also | 576 // necessarily the one it can use, as it might be inactive (see also |
| 609 // GetActivePageActionCommand in ExtensionKeybindingRegistry). | 577 // GetActivePageActionCommand in ExtensionKeybindingRegistry). |
| 610 const Command* page_action_command() const { | 578 const extensions::Command* page_action_command() const { |
| 611 return page_action_command_.get(); | 579 return page_action_command_.get(); |
| 612 } | 580 } |
| 613 // The map (of command names to commands) that the extension wants to use, | 581 // The map (of command names to commands) that the extension wants to use, |
| 614 // which is not necessarily the one it can use, as they might be inactive | 582 // which is not necessarily the one it can use, as they might be inactive |
| 615 // (see also GetActiveNamedCommands in ExtensionKeybindingRegistry). | 583 // (see also GetActiveNamedCommands in ExtensionKeybindingRegistry). |
| 616 const CommandMap& named_commands() const { | 584 const extensions::CommandMap& named_commands() const { |
| 617 return named_commands_; | 585 return named_commands_; |
| 618 } | 586 } |
| 619 bool has_background_page() const { | 587 bool has_background_page() const { |
| 620 return background_url_.is_valid() || !background_scripts_.empty(); | 588 return background_url_.is_valid() || !background_scripts_.empty(); |
| 621 } | 589 } |
| 622 bool allow_background_js_access() const { | 590 bool allow_background_js_access() const { |
| 623 return allow_background_js_access_; | 591 return allow_background_js_access_; |
| 624 } | 592 } |
| 625 const std::vector<std::string>& background_scripts() const { | 593 const std::vector<std::string>& background_scripts() const { |
| 626 return background_scripts_; | 594 return background_scripts_; |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 // Optional list of NPAPI plugins and associated properties. | 931 // Optional list of NPAPI plugins and associated properties. |
| 964 std::vector<PluginInfo> plugins_; | 932 std::vector<PluginInfo> plugins_; |
| 965 | 933 |
| 966 // Optional list of NaCl modules and associated properties. | 934 // Optional list of NaCl modules and associated properties. |
| 967 std::vector<NaClModuleInfo> nacl_modules_; | 935 std::vector<NaClModuleInfo> nacl_modules_; |
| 968 | 936 |
| 969 // Optional list of input components and associated properties. | 937 // Optional list of input components and associated properties. |
| 970 std::vector<InputComponentInfo> input_components_; | 938 std::vector<InputComponentInfo> input_components_; |
| 971 | 939 |
| 972 // Optional list of commands (keyboard shortcuts). | 940 // Optional list of commands (keyboard shortcuts). |
| 973 scoped_ptr<Command> browser_action_command_; | 941 scoped_ptr<extensions::Command> browser_action_command_; |
| 974 scoped_ptr<Command> page_action_command_; | 942 scoped_ptr<extensions::Command> page_action_command_; |
| 975 CommandMap named_commands_; | 943 extensions::CommandMap named_commands_; |
| 976 | 944 |
| 977 // Optional list of web accessible extension resources. | 945 // Optional list of web accessible extension resources. |
| 978 base::hash_set<std::string> web_accessible_resources_; | 946 base::hash_set<std::string> web_accessible_resources_; |
| 979 | 947 |
| 980 // Optional URL to a master page of which a single instance should be always | 948 // Optional URL to a master page of which a single instance should be always |
| 981 // loaded in the background. | 949 // loaded in the background. |
| 982 GURL background_url_; | 950 GURL background_url_; |
| 983 | 951 |
| 984 // Optional list of scripts to use to generate a background page. If this is | 952 // Optional list of scripts to use to generate a background page. If this is |
| 985 // present, background_url_ will be empty and generated by GetBackgroundURL(). | 953 // present, background_url_ will be empty and generated by GetBackgroundURL(). |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1142 // only contain the removed permissions. | 1110 // only contain the removed permissions. |
| 1143 const ExtensionPermissionSet* permissions; | 1111 const ExtensionPermissionSet* permissions; |
| 1144 | 1112 |
| 1145 UpdatedExtensionPermissionsInfo( | 1113 UpdatedExtensionPermissionsInfo( |
| 1146 const Extension* extension, | 1114 const Extension* extension, |
| 1147 const ExtensionPermissionSet* permissions, | 1115 const ExtensionPermissionSet* permissions, |
| 1148 Reason reason); | 1116 Reason reason); |
| 1149 }; | 1117 }; |
| 1150 | 1118 |
| 1151 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 1119 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
| OLD | NEW |