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 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <iosfwd> | 9 #include <iosfwd> |
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/command.h" | 23 #include "chrome/common/extensions/command.h" |
24 #include "chrome/common/extensions/extension_action.h" | |
25 #include "chrome/common/extensions/extension_constants.h" | 24 #include "chrome/common/extensions/extension_constants.h" |
26 #include "chrome/common/extensions/extension_icon_set.h" | 25 #include "chrome/common/extensions/extension_icon_set.h" |
27 #include "chrome/common/extensions/permissions/api_permission.h" | 26 #include "chrome/common/extensions/permissions/api_permission.h" |
28 #include "chrome/common/extensions/permissions/api_permission_set.h" | 27 #include "chrome/common/extensions/permissions/api_permission_set.h" |
29 #include "chrome/common/extensions/permissions/permission_message.h" | 28 #include "chrome/common/extensions/permissions/permission_message.h" |
30 #include "chrome/common/extensions/user_script.h" | 29 #include "chrome/common/extensions/user_script.h" |
31 #include "chrome/common/extensions/url_pattern.h" | 30 #include "chrome/common/extensions/url_pattern.h" |
32 #include "chrome/common/extensions/url_pattern_set.h" | 31 #include "chrome/common/extensions/url_pattern_set.h" |
33 #include "googleurl/src/gurl.h" | 32 #include "googleurl/src/gurl.h" |
34 #include "ui/base/accelerators/accelerator.h" | 33 #include "ui/base/accelerators/accelerator.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 struct OAuth2Info { | 200 struct OAuth2Info { |
202 OAuth2Info(); | 201 OAuth2Info(); |
203 ~OAuth2Info(); | 202 ~OAuth2Info(); |
204 | 203 |
205 OAuth2Scopes GetScopesAsSet(); | 204 OAuth2Scopes GetScopesAsSet(); |
206 | 205 |
207 std::string client_id; | 206 std::string client_id; |
208 std::vector<std::string> scopes; | 207 std::vector<std::string> scopes; |
209 }; | 208 }; |
210 | 209 |
210 // Manifest information for ExtensionActions. | |
211 struct ActionInfo { | |
212 // The types of extension actions. | |
213 enum Type { | |
214 TYPE_BROWSER, | |
Aaron Boodman
2012/09/16 01:42:50
Do we need to carry around the type? The caller kn
not at google - send to devlin
2012/09/27 00:46:10
It was initially added for when page actions got i
| |
215 TYPE_PAGE, | |
216 TYPE_SCRIPT_BADGE, | |
217 }; | |
218 | |
219 explicit ActionInfo(Type action_type); | |
220 ~ActionInfo(); | |
221 | |
222 Type action_type; | |
223 | |
224 // Empty implies not present. | |
225 std::string default_icon_path; | |
226 std::string default_title; | |
227 GURL default_popup_url; | |
228 // action id -- only used with legacy page actions API. | |
229 std::string id; | |
230 }; | |
231 | |
211 struct InstallWarning { | 232 struct InstallWarning { |
212 enum Format { | 233 enum Format { |
213 // IMPORTANT: Do not build HTML strings from user or developer-supplied | 234 // IMPORTANT: Do not build HTML strings from user or developer-supplied |
214 // input. | 235 // input. |
215 FORMAT_TEXT, | 236 FORMAT_TEXT, |
216 FORMAT_HTML, | 237 FORMAT_HTML, |
217 }; | 238 }; |
218 InstallWarning(Format format, const std::string& message) | 239 InstallWarning(Format format, const std::string& message) |
219 : format(format), message(message) { | 240 : format(format), message(message) { |
220 } | 241 } |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
615 // Base64-encoded version of the key used to sign this extension. | 636 // Base64-encoded version of the key used to sign this extension. |
616 // In pseudocode, returns | 637 // In pseudocode, returns |
617 // base::Base64Encode(RSAPrivateKey(pem_file).ExportPublicKey()). | 638 // base::Base64Encode(RSAPrivateKey(pem_file).ExportPublicKey()). |
618 const std::string& public_key() const { return public_key_; } | 639 const std::string& public_key() const { return public_key_; } |
619 const std::string& description() const { return description_; } | 640 const std::string& description() const { return description_; } |
620 int manifest_version() const { return manifest_version_; } | 641 int manifest_version() const { return manifest_version_; } |
621 bool converted_from_user_script() const { | 642 bool converted_from_user_script() const { |
622 return converted_from_user_script_; | 643 return converted_from_user_script_; |
623 } | 644 } |
624 const UserScriptList& content_scripts() const { return content_scripts_; } | 645 const UserScriptList& content_scripts() const { return content_scripts_; } |
625 ExtensionAction* script_badge() const { return script_badge_.get(); } | 646 ActionInfo* script_badge() const { return script_badge_.get(); } |
626 ExtensionAction* page_action() const { return page_action_.get(); } | 647 ActionInfo* page_action() const { return page_action_.get(); } |
627 ExtensionAction* browser_action() const { return browser_action_.get(); } | 648 ActionInfo* browser_action() const { return browser_action_.get(); } |
628 bool is_verbose_install_message() const { | 649 bool is_verbose_install_message() const { |
629 return !omnibox_keyword().empty() || | 650 return !omnibox_keyword().empty() || |
630 browser_action() || | 651 browser_action() || |
631 (page_action() && | 652 (page_action() && |
632 (page_action_command() || | 653 (page_action_command() || |
633 !page_action()->default_icon_path().empty())); | 654 !page_action()->default_icon_path.empty())); |
634 } | 655 } |
635 const FileBrowserHandlerList* file_browser_handlers() const { | 656 const FileBrowserHandlerList* file_browser_handlers() const { |
636 return file_browser_handlers_.get(); | 657 return file_browser_handlers_.get(); |
637 } | 658 } |
638 const std::vector<PluginInfo>& plugins() const { return plugins_; } | 659 const std::vector<PluginInfo>& plugins() const { return plugins_; } |
639 const std::vector<NaClModuleInfo>& nacl_modules() const { | 660 const std::vector<NaClModuleInfo>& nacl_modules() const { |
640 return nacl_modules_; | 661 return nacl_modules_; |
641 } | 662 } |
642 const std::vector<InputComponentInfo>& input_components() const { | 663 const std::vector<InputComponentInfo>& input_components() const { |
643 return input_components_; | 664 return input_components_; |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
912 | 933 |
913 // Helper method that loads either the include_globs or exclude_globs list | 934 // Helper method that loads either the include_globs or exclude_globs list |
914 // from an entry in the content_script lists of the manifest. | 935 // from an entry in the content_script lists of the manifest. |
915 bool LoadGlobsHelper(const base::DictionaryValue* content_script, | 936 bool LoadGlobsHelper(const base::DictionaryValue* content_script, |
916 int content_script_index, | 937 int content_script_index, |
917 const char* globs_property_name, | 938 const char* globs_property_name, |
918 string16* error, | 939 string16* error, |
919 void(UserScript::*add_method)(const std::string& glob), | 940 void(UserScript::*add_method)(const std::string& glob), |
920 UserScript* instance); | 941 UserScript* instance); |
921 | 942 |
922 // Helper method to load an ExtensionAction from the page_action or | 943 // Helper method to load an ActionInfo from the page_action, |
923 // browser_action entries in the manifest. | 944 // browser_action, or script_badge entries in the manifest. |
924 scoped_ptr<ExtensionAction> LoadExtensionActionHelper( | 945 scoped_ptr<ActionInfo> LoadExtensionActionHelper( |
925 const base::DictionaryValue* extension_action, | 946 const base::DictionaryValue* extension_action, |
926 ExtensionAction::Type action_type, | 947 ActionInfo::Type action_type, |
927 string16* error); | 948 string16* error); |
928 | 949 |
929 // Helper method that loads the OAuth2 info from the 'oauth2' manifest key. | 950 // Helper method that loads the OAuth2 info from the 'oauth2' manifest key. |
930 bool LoadOAuth2Info(string16* error); | 951 bool LoadOAuth2Info(string16* error); |
931 | 952 |
932 // Returns true if the extension has more than one "UI surface". For example, | 953 // Returns true if the extension has more than one "UI surface". For example, |
933 // an extension that has a browser action and a page action. | 954 // an extension that has a browser action and a page action. |
934 bool HasMultipleUISurfaces() const; | 955 bool HasMultipleUISurfaces() const; |
935 | 956 |
936 // Updates the launch URL and extents for the extension using the given | 957 // Updates the launch URL and extents for the extension using the given |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1021 std::string description_; | 1042 std::string description_; |
1022 | 1043 |
1023 // True if the extension was generated from a user script. (We show slightly | 1044 // True if the extension was generated from a user script. (We show slightly |
1024 // different UI if so). | 1045 // different UI if so). |
1025 bool converted_from_user_script_; | 1046 bool converted_from_user_script_; |
1026 | 1047 |
1027 // Paths to the content scripts the extension contains. | 1048 // Paths to the content scripts the extension contains. |
1028 UserScriptList content_scripts_; | 1049 UserScriptList content_scripts_; |
1029 | 1050 |
1030 // The extension's page action, if any. | 1051 // The extension's page action, if any. |
1031 scoped_ptr<ExtensionAction> page_action_; | 1052 scoped_ptr<ActionInfo> page_action_; |
1032 | 1053 |
1033 // The extension's browser action, if any. | 1054 // The extension's browser action, if any. |
1034 scoped_ptr<ExtensionAction> browser_action_; | 1055 scoped_ptr<ActionInfo> browser_action_; |
1035 | 1056 |
1036 // The extension's script badge. Never NULL. | 1057 // The extension's script badge. Never NULL. |
1037 scoped_ptr<ExtensionAction> script_badge_; | 1058 scoped_ptr<ActionInfo> script_badge_; |
1038 | 1059 |
1039 // The extension's file browser actions, if any. | 1060 // The extension's file browser actions, if any. |
1040 scoped_ptr<FileBrowserHandlerList> file_browser_handlers_; | 1061 scoped_ptr<FileBrowserHandlerList> file_browser_handlers_; |
1041 | 1062 |
1042 // Optional list of NPAPI plugins and associated properties. | 1063 // Optional list of NPAPI plugins and associated properties. |
1043 std::vector<PluginInfo> plugins_; | 1064 std::vector<PluginInfo> plugins_; |
1044 | 1065 |
1045 // Optional list of NaCl modules and associated properties. | 1066 // Optional list of NaCl modules and associated properties. |
1046 std::vector<NaClModuleInfo> nacl_modules_; | 1067 std::vector<NaClModuleInfo> nacl_modules_; |
1047 | 1068 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1231 | 1252 |
1232 UpdatedExtensionPermissionsInfo( | 1253 UpdatedExtensionPermissionsInfo( |
1233 const Extension* extension, | 1254 const Extension* extension, |
1234 const PermissionSet* permissions, | 1255 const PermissionSet* permissions, |
1235 Reason reason); | 1256 Reason reason); |
1236 }; | 1257 }; |
1237 | 1258 |
1238 } // namespace extensions | 1259 } // namespace extensions |
1239 | 1260 |
1240 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 1261 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
OLD | NEW |