OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "base/threading/thread_checker.h" | 23 #include "base/threading/thread_checker.h" |
| 24 #include "chrome/common/extensions/api/extension_action/action_info.h" |
24 #include "chrome/common/extensions/command.h" | 25 #include "chrome/common/extensions/command.h" |
25 #include "chrome/common/extensions/extension_constants.h" | 26 #include "chrome/common/extensions/extension_constants.h" |
26 #include "chrome/common/extensions/extension_icon_set.h" | 27 #include "chrome/common/extensions/extension_icon_set.h" |
27 #include "chrome/common/extensions/permissions/api_permission.h" | 28 #include "chrome/common/extensions/permissions/api_permission.h" |
28 #include "chrome/common/extensions/permissions/api_permission_set.h" | 29 #include "chrome/common/extensions/permissions/api_permission_set.h" |
29 #include "chrome/common/extensions/permissions/permission_message.h" | 30 #include "chrome/common/extensions/permissions/permission_message.h" |
30 #include "chrome/common/extensions/user_script.h" | 31 #include "chrome/common/extensions/user_script.h" |
31 #include "extensions/common/url_pattern.h" | 32 #include "extensions/common/url_pattern.h" |
32 #include "extensions/common/url_pattern_set.h" | 33 #include "extensions/common/url_pattern_set.h" |
33 #include "googleurl/src/gurl.h" | 34 #include "googleurl/src/gurl.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 struct OAuth2Info { | 176 struct OAuth2Info { |
176 OAuth2Info(); | 177 OAuth2Info(); |
177 ~OAuth2Info(); | 178 ~OAuth2Info(); |
178 | 179 |
179 OAuth2Scopes GetScopesAsSet(); | 180 OAuth2Scopes GetScopesAsSet(); |
180 | 181 |
181 std::string client_id; | 182 std::string client_id; |
182 std::vector<std::string> scopes; | 183 std::vector<std::string> scopes; |
183 }; | 184 }; |
184 | 185 |
185 struct ActionInfo { | |
186 explicit ActionInfo(); | |
187 ~ActionInfo(); | |
188 | |
189 // The types of extension actions. | |
190 enum Type { | |
191 TYPE_BROWSER, | |
192 TYPE_PAGE, | |
193 TYPE_SCRIPT_BADGE, | |
194 TYPE_SYSTEM_INDICATOR, | |
195 }; | |
196 | |
197 // Empty implies the key wasn't present. | |
198 ExtensionIconSet default_icon; | |
199 std::string default_title; | |
200 GURL default_popup_url; | |
201 // action id -- only used with legacy page actions API. | |
202 std::string id; | |
203 }; | |
204 | |
205 struct InstallWarning { | 186 struct InstallWarning { |
206 enum Format { | 187 enum Format { |
207 // IMPORTANT: Do not build HTML strings from user or developer-supplied | 188 // IMPORTANT: Do not build HTML strings from user or developer-supplied |
208 // input. | 189 // input. |
209 FORMAT_TEXT, | 190 FORMAT_TEXT, |
210 FORMAT_HTML, | 191 FORMAT_HTML, |
211 }; | 192 }; |
212 InstallWarning(Format format, const std::string& message) | 193 InstallWarning(Format format, const std::string& message) |
213 : format(format), message(message) { | 194 : format(format), message(message) { |
214 } | 195 } |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 // Base64-encoded version of the key used to sign this extension. | 605 // Base64-encoded version of the key used to sign this extension. |
625 // In pseudocode, returns | 606 // In pseudocode, returns |
626 // base::Base64Encode(RSAPrivateKey(pem_file).ExportPublicKey()). | 607 // base::Base64Encode(RSAPrivateKey(pem_file).ExportPublicKey()). |
627 const std::string& public_key() const { return public_key_; } | 608 const std::string& public_key() const { return public_key_; } |
628 const std::string& description() const { return description_; } | 609 const std::string& description() const { return description_; } |
629 int manifest_version() const { return manifest_version_; } | 610 int manifest_version() const { return manifest_version_; } |
630 bool converted_from_user_script() const { | 611 bool converted_from_user_script() const { |
631 return converted_from_user_script_; | 612 return converted_from_user_script_; |
632 } | 613 } |
633 const UserScriptList& content_scripts() const { return content_scripts_; } | 614 const UserScriptList& content_scripts() const { return content_scripts_; } |
634 const ActionInfo* script_badge_info() const { | |
635 return script_badge_info_.get(); | |
636 } | |
637 const ActionInfo* page_action_info() const { return page_action_info_.get(); } | 615 const ActionInfo* page_action_info() const { return page_action_info_.get(); } |
638 const ActionInfo* browser_action_info() const { | 616 const ActionInfo* browser_action_info() const { |
639 return browser_action_info_.get(); | 617 return browser_action_info_.get(); |
640 } | 618 } |
641 const ActionInfo* system_indicator_info() const { | 619 const ActionInfo* system_indicator_info() const { |
642 return system_indicator_info_.get(); | 620 return system_indicator_info_.get(); |
643 } | 621 } |
644 const std::vector<PluginInfo>& plugins() const { return plugins_; } | 622 const std::vector<PluginInfo>& plugins() const { return plugins_; } |
645 const std::vector<NaClModuleInfo>& nacl_modules() const { | 623 const std::vector<NaClModuleInfo>& nacl_modules() const { |
646 return nacl_modules_; | 624 return nacl_modules_; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 bool has_lazy_background_page() const { | 662 bool has_lazy_background_page() const { |
685 return has_background_page() && !background_page_is_persistent_; | 663 return has_background_page() && !background_page_is_persistent_; |
686 } | 664 } |
687 const GURL& details_url() const { return details_url_;} | 665 const GURL& details_url() const { return details_url_;} |
688 const PermissionSet* optional_permission_set() const { | 666 const PermissionSet* optional_permission_set() const { |
689 return optional_permission_set_.get(); | 667 return optional_permission_set_.get(); |
690 } | 668 } |
691 const PermissionSet* required_permission_set() const { | 669 const PermissionSet* required_permission_set() const { |
692 return required_permission_set_.get(); | 670 return required_permission_set_.get(); |
693 } | 671 } |
694 // Appends |new_warnings| to install_warnings(). | 672 // Appends |new_warning[s]| to install_warnings_. |
| 673 void AddInstallWarning(const InstallWarning& new_warning); |
695 void AddInstallWarnings(const InstallWarningVector& new_warnings); | 674 void AddInstallWarnings(const InstallWarningVector& new_warnings); |
696 const InstallWarningVector& install_warnings() const { | 675 const InstallWarningVector& install_warnings() const { |
697 return install_warnings_; | 676 return install_warnings_; |
698 } | 677 } |
699 const ExtensionIconSet& icons() const { return icons_; } | 678 const ExtensionIconSet& icons() const { return icons_; } |
700 const extensions::Manifest* manifest() const { | 679 const extensions::Manifest* manifest() const { |
701 return manifest_.get(); | 680 return manifest_.get(); |
702 } | 681 } |
703 const std::string default_locale() const { return default_locale_; } | 682 const std::string default_locale() const { return default_locale_; } |
704 bool incognito_split_mode() const { return incognito_split_mode_; } | 683 bool incognito_split_mode() const { return incognito_split_mode_; } |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 string16* error); | 836 string16* error); |
858 bool LoadBackgroundAllowJSAccess( | 837 bool LoadBackgroundAllowJSAccess( |
859 const APIPermissionSet& api_permissions, | 838 const APIPermissionSet& api_permissions, |
860 string16* error); | 839 string16* error); |
861 bool LoadExtensionFeatures(APIPermissionSet* api_permissions, | 840 bool LoadExtensionFeatures(APIPermissionSet* api_permissions, |
862 string16* error); | 841 string16* error); |
863 bool LoadManifestHandlerFeatures(string16* error); | 842 bool LoadManifestHandlerFeatures(string16* error); |
864 bool LoadContentScripts(string16* error); | 843 bool LoadContentScripts(string16* error); |
865 bool LoadPageAction(string16* error); | 844 bool LoadPageAction(string16* error); |
866 bool LoadBrowserAction(string16* error); | 845 bool LoadBrowserAction(string16* error); |
867 bool LoadScriptBadge(string16* error); | |
868 bool LoadSystemIndicator(APIPermissionSet* api_permissions, string16* error); | 846 bool LoadSystemIndicator(APIPermissionSet* api_permissions, string16* error); |
869 bool LoadTextToSpeechVoices(string16* error); | 847 bool LoadTextToSpeechVoices(string16* error); |
870 bool LoadIncognitoMode(string16* error); | 848 bool LoadIncognitoMode(string16* error); |
871 bool LoadContentSecurityPolicy(string16* error); | 849 bool LoadContentSecurityPolicy(string16* error); |
872 | 850 |
873 bool LoadThemeFeatures(string16* error); | 851 bool LoadThemeFeatures(string16* error); |
874 bool LoadThemeImages(const base::DictionaryValue* theme_value, | 852 bool LoadThemeImages(const base::DictionaryValue* theme_value, |
875 string16* error); | 853 string16* error); |
876 bool LoadThemeColors(const base::DictionaryValue* theme_value, | 854 bool LoadThemeColors(const base::DictionaryValue* theme_value, |
877 string16* error); | 855 string16* error); |
(...skipping 25 matching lines...) Expand all Loading... |
903 | 881 |
904 // Helper method that loads either the include_globs or exclude_globs list | 882 // Helper method that loads either the include_globs or exclude_globs list |
905 // from an entry in the content_script lists of the manifest. | 883 // from an entry in the content_script lists of the manifest. |
906 bool LoadGlobsHelper(const base::DictionaryValue* content_script, | 884 bool LoadGlobsHelper(const base::DictionaryValue* content_script, |
907 int content_script_index, | 885 int content_script_index, |
908 const char* globs_property_name, | 886 const char* globs_property_name, |
909 string16* error, | 887 string16* error, |
910 void(UserScript::*add_method)(const std::string& glob), | 888 void(UserScript::*add_method)(const std::string& glob), |
911 UserScript* instance); | 889 UserScript* instance); |
912 | 890 |
913 // Helper method to load an ExtensionAction from the page_action or | |
914 // browser_action entries in the manifest. | |
915 scoped_ptr<ActionInfo> LoadExtensionActionInfoHelper( | |
916 const base::DictionaryValue* manifest_section, | |
917 ActionInfo::Type action_type, | |
918 string16* error); | |
919 | |
920 // Helper method that loads the OAuth2 info from the 'oauth2' manifest key. | 891 // Helper method that loads the OAuth2 info from the 'oauth2' manifest key. |
921 bool LoadOAuth2Info(string16* error); | 892 bool LoadOAuth2Info(string16* error); |
922 | 893 |
923 // Returns true if the extension has more than one "UI surface". For example, | 894 // Returns true if the extension has more than one "UI surface". For example, |
924 // an extension that has a browser action and a page action. | 895 // an extension that has a browser action and a page action. |
925 bool HasMultipleUISurfaces() const; | 896 bool HasMultipleUISurfaces() const; |
926 | 897 |
927 // Updates the launch URL and extents for the extension using the given | 898 // Updates the launch URL and extents for the extension using the given |
928 // |override_url|. | 899 // |override_url|. |
929 void OverrideLaunchUrl(const GURL& override_url); | 900 void OverrideLaunchUrl(const GURL& override_url); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 | 988 |
1018 // Paths to the content scripts the extension contains. | 989 // Paths to the content scripts the extension contains. |
1019 UserScriptList content_scripts_; | 990 UserScriptList content_scripts_; |
1020 | 991 |
1021 // The extension's page action, if any. | 992 // The extension's page action, if any. |
1022 scoped_ptr<ActionInfo> page_action_info_; | 993 scoped_ptr<ActionInfo> page_action_info_; |
1023 | 994 |
1024 // The extension's browser action, if any. | 995 // The extension's browser action, if any. |
1025 scoped_ptr<ActionInfo> browser_action_info_; | 996 scoped_ptr<ActionInfo> browser_action_info_; |
1026 | 997 |
1027 // The extension's script badge. Never NULL. | |
1028 scoped_ptr<ActionInfo> script_badge_info_; | |
1029 | |
1030 // The extension's system indicator, if any. | 998 // The extension's system indicator, if any. |
1031 scoped_ptr<ActionInfo> system_indicator_info_; | 999 scoped_ptr<ActionInfo> system_indicator_info_; |
1032 | 1000 |
1033 // Optional list of NPAPI plugins and associated properties. | 1001 // Optional list of NPAPI plugins and associated properties. |
1034 std::vector<PluginInfo> plugins_; | 1002 std::vector<PluginInfo> plugins_; |
1035 | 1003 |
1036 // Optional list of NaCl modules and associated properties. | 1004 // Optional list of NaCl modules and associated properties. |
1037 std::vector<NaClModuleInfo> nacl_modules_; | 1005 std::vector<NaClModuleInfo> nacl_modules_; |
1038 | 1006 |
1039 // Optional list of commands (keyboard shortcuts). | 1007 // Optional list of commands (keyboard shortcuts). |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1214 | 1182 |
1215 UpdatedExtensionPermissionsInfo( | 1183 UpdatedExtensionPermissionsInfo( |
1216 const Extension* extension, | 1184 const Extension* extension, |
1217 const PermissionSet* permissions, | 1185 const PermissionSet* permissions, |
1218 Reason reason); | 1186 Reason reason); |
1219 }; | 1187 }; |
1220 | 1188 |
1221 } // namespace extensions | 1189 } // namespace extensions |
1222 | 1190 |
1223 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 1191 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
OLD | NEW |