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> |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 DEPRECATED_DISABLE_PERMISSIONS_INCREASE, | 105 DEPRECATED_DISABLE_PERMISSIONS_INCREASE, |
106 DEPRECATED_DISABLE_RELOAD, | 106 DEPRECATED_DISABLE_RELOAD, |
107 DEPRECATED_DISABLE_LAST, // Not used. | 107 DEPRECATED_DISABLE_LAST, // Not used. |
108 }; | 108 }; |
109 | 109 |
110 enum DisableReason { | 110 enum DisableReason { |
111 DISABLE_NONE = 0, | 111 DISABLE_NONE = 0, |
112 DISABLE_USER_ACTION = 1 << 0, | 112 DISABLE_USER_ACTION = 1 << 0, |
113 DISABLE_PERMISSIONS_INCREASE = 1 << 1, | 113 DISABLE_PERMISSIONS_INCREASE = 1 << 1, |
114 DISABLE_RELOAD = 1 << 2, | 114 DISABLE_RELOAD = 1 << 2, |
| 115 DISABLE_UNSUPPORTED_REQUIREMENT = 1 << 3 |
115 }; | 116 }; |
116 | 117 |
117 enum InstallType { | 118 enum InstallType { |
118 INSTALL_ERROR, | 119 INSTALL_ERROR, |
119 DOWNGRADE, | 120 DOWNGRADE, |
120 REINSTALL, | 121 REINSTALL, |
121 UPGRADE, | 122 UPGRADE, |
122 NEW_INSTALL | 123 NEW_INSTALL |
123 }; | 124 }; |
124 | 125 |
125 // Do not change the order of entries or remove entries in this list | 126 // Do not change the order of entries or remove entries in this list |
126 // as this is used in UMA_HISTOGRAM_ENUMERATIONs about extensions. | 127 // as this is used in UMA_HISTOGRAM_ENUMERATIONs about extensions. |
127 enum Type { | 128 enum Type { |
128 TYPE_UNKNOWN = 0, | 129 TYPE_UNKNOWN = 0, |
129 TYPE_EXTENSION, | 130 TYPE_EXTENSION, |
130 TYPE_THEME, | 131 TYPE_THEME, |
131 TYPE_USER_SCRIPT, | 132 TYPE_USER_SCRIPT, |
132 TYPE_HOSTED_APP, | 133 TYPE_HOSTED_APP, |
133 TYPE_PACKAGED_APP, | 134 TYPE_PACKAGED_APP, |
134 TYPE_PLATFORM_APP | 135 TYPE_PLATFORM_APP |
135 }; | 136 }; |
136 | 137 |
137 enum SyncType { | 138 enum SyncType { |
138 SYNC_TYPE_NONE = 0, | 139 SYNC_TYPE_NONE = 0, |
139 SYNC_TYPE_EXTENSION, | 140 SYNC_TYPE_EXTENSION, |
140 SYNC_TYPE_APP | 141 SYNC_TYPE_APP |
141 }; | 142 }; |
142 | 143 |
| 144 // Declared requirements for the extension. |
| 145 struct Requirements { |
| 146 Requirements(); |
| 147 ~Requirements(); |
| 148 |
| 149 bool webgl; |
| 150 bool css3d; |
| 151 bool npapi; |
| 152 }; |
| 153 |
143 // An NPAPI plugin included in the extension. | 154 // An NPAPI plugin included in the extension. |
144 struct PluginInfo { | 155 struct PluginInfo { |
145 FilePath path; // Path to the plugin. | 156 FilePath path; // Path to the plugin. |
146 bool is_public; // False if only this extension can load this plugin. | 157 bool is_public; // False if only this extension can load this plugin. |
147 }; | 158 }; |
148 | 159 |
149 // An NaCl module included in the extension. | 160 // An NaCl module included in the extension. |
150 struct NaClModuleInfo { | 161 struct NaClModuleInfo { |
151 GURL url; | 162 GURL url; |
152 std::string mime_type; | 163 std::string mime_type; |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 // |permissions|. | 596 // |permissions|. |
586 void UpdateTabSpecificPermissions( | 597 void UpdateTabSpecificPermissions( |
587 int tab_id, | 598 int tab_id, |
588 scoped_refptr<const PermissionSet> permissions) const; | 599 scoped_refptr<const PermissionSet> permissions) const; |
589 | 600 |
590 // Clears the tab-specific permissions of |tab_id|. | 601 // Clears the tab-specific permissions of |tab_id|. |
591 void ClearTabSpecificPermissions(int tab_id) const; | 602 void ClearTabSpecificPermissions(int tab_id) const; |
592 | 603 |
593 // Accessors: | 604 // Accessors: |
594 | 605 |
| 606 const Requirements& requirements() const { return requirements_; } |
595 const FilePath& path() const { return path_; } | 607 const FilePath& path() const { return path_; } |
596 const GURL& url() const { return extension_url_; } | 608 const GURL& url() const { return extension_url_; } |
597 Location location() const; | 609 Location location() const; |
598 const std::string& id() const; | 610 const std::string& id() const; |
599 const Version* version() const { return version_.get(); } | 611 const Version* version() const { return version_.get(); } |
600 const std::string VersionString() const; | 612 const std::string VersionString() const; |
601 const std::string& name() const { return name_; } | 613 const std::string& name() const { return name_; } |
602 const std::string& non_localized_name() const { return non_localized_name_; } | 614 const std::string& non_localized_name() const { return non_localized_name_; } |
603 // Base64-encoded version of the key used to sign this extension. | 615 // Base64-encoded version of the key used to sign this extension. |
604 // In pseudocode, returns | 616 // In pseudocode, returns |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 bool LoadDescription(string16* error); | 835 bool LoadDescription(string16* error); |
824 bool LoadManifestVersion(string16* error); | 836 bool LoadManifestVersion(string16* error); |
825 bool LoadHomepageURL(string16* error); | 837 bool LoadHomepageURL(string16* error); |
826 bool LoadUpdateURL(string16* error); | 838 bool LoadUpdateURL(string16* error); |
827 bool LoadIcons(string16* error); | 839 bool LoadIcons(string16* error); |
828 bool LoadCommands(string16* error); | 840 bool LoadCommands(string16* error); |
829 bool LoadPlugins(string16* error); | 841 bool LoadPlugins(string16* error); |
830 bool LoadNaClModules(string16* error); | 842 bool LoadNaClModules(string16* error); |
831 bool LoadWebAccessibleResources(string16* error); | 843 bool LoadWebAccessibleResources(string16* error); |
832 bool LoadSandboxedPages(string16* error); | 844 bool LoadSandboxedPages(string16* error); |
| 845 // Must be called after LoadPlugins(). |
| 846 bool LoadRequirements(string16* error); |
833 bool LoadDefaultLocale(string16* error); | 847 bool LoadDefaultLocale(string16* error); |
834 bool LoadOfflineEnabled(string16* error); | 848 bool LoadOfflineEnabled(string16* error); |
835 bool LoadOptionsPage(string16* error); | 849 bool LoadOptionsPage(string16* error); |
836 bool LoadBackgroundScripts(string16* error); | 850 bool LoadBackgroundScripts(string16* error); |
837 bool LoadBackgroundScripts(const std::string& key, string16* error); | 851 bool LoadBackgroundScripts(const std::string& key, string16* error); |
838 bool LoadBackgroundPage(const APIPermissionSet& api_permissions, | 852 bool LoadBackgroundPage(const APIPermissionSet& api_permissions, |
839 string16* error); | 853 string16* error); |
840 bool LoadBackgroundPage(const std::string& key, | 854 bool LoadBackgroundPage(const std::string& key, |
841 const APIPermissionSet& api_permissions, | 855 const APIPermissionSet& api_permissions, |
842 string16* error); | 856 string16* error); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 // Custom checks for the experimental permission that can't be expressed in | 940 // Custom checks for the experimental permission that can't be expressed in |
927 // _permission_features.json. | 941 // _permission_features.json. |
928 bool CanSpecifyExperimentalPermission() const; | 942 bool CanSpecifyExperimentalPermission() const; |
929 | 943 |
930 // Checks whether the host |pattern| is allowed for this extension, given API | 944 // Checks whether the host |pattern| is allowed for this extension, given API |
931 // permissions |permissions|. | 945 // permissions |permissions|. |
932 bool CanSpecifyHostPermission(const URLPattern& pattern, | 946 bool CanSpecifyHostPermission(const URLPattern& pattern, |
933 const APIPermissionSet& permissions) const; | 947 const APIPermissionSet& permissions) const; |
934 | 948 |
935 bool CheckMinimumChromeVersion(string16* error) const; | 949 bool CheckMinimumChromeVersion(string16* error) const; |
936 bool CheckRequirements(string16* error) const; | |
937 | 950 |
938 // Check that platform app features are valid. Called after InitFromValue. | 951 // Check that platform app features are valid. Called after InitFromValue. |
939 bool CheckPlatformAppFeatures(std::string* utf8_error) const; | 952 bool CheckPlatformAppFeatures(std::string* utf8_error) const; |
940 | 953 |
941 // Check that features don't conflict. Called after InitFromValue. | 954 // Check that features don't conflict. Called after InitFromValue. |
942 bool CheckConflictingFeatures(std::string* utf8_error) const; | 955 bool CheckConflictingFeatures(std::string* utf8_error) const; |
943 | 956 |
944 // Cached images for this extension. This should only be touched on the UI | 957 // Cached images for this extension. This should only be touched on the UI |
945 // thread. | 958 // thread. |
946 mutable ImageCache image_cache_; | 959 mutable ImageCache image_cache_; |
947 | 960 |
948 // The extension's human-readable name. Name is used for display purpose. It | 961 // The extension's human-readable name. Name is used for display purpose. It |
949 // might be wrapped with unicode bidi control characters so that it is | 962 // might be wrapped with unicode bidi control characters so that it is |
950 // displayed correctly in RTL context. | 963 // displayed correctly in RTL context. |
951 // NOTE: Name is UTF-8 and may contain non-ascii characters. | 964 // NOTE: Name is UTF-8 and may contain non-ascii characters. |
952 std::string name_; | 965 std::string name_; |
953 | 966 |
954 // A non-localized version of the extension's name. This is useful for | 967 // A non-localized version of the extension's name. This is useful for |
955 // debug output. | 968 // debug output. |
956 std::string non_localized_name_; | 969 std::string non_localized_name_; |
957 | 970 |
958 // The version of this extension's manifest. We increase the manifest | 971 // The version of this extension's manifest. We increase the manifest |
959 // version when making breaking changes to the extension system. | 972 // version when making breaking changes to the extension system. |
960 // Version 1 was the first manifest version (implied by a lack of a | 973 // Version 1 was the first manifest version (implied by a lack of a |
961 // manifest_version attribute in the extension's manifest). We initialize | 974 // manifest_version attribute in the extension's manifest). We initialize |
962 // this member variable to 0 to distinguish the "uninitialized" case from | 975 // this member variable to 0 to distinguish the "uninitialized" case from |
963 // the case when we know the manifest version actually is 1. | 976 // the case when we know the manifest version actually is 1. |
964 int manifest_version_; | 977 int manifest_version_; |
965 | 978 |
| 979 // The requirements declared in the manifest. |
| 980 Requirements requirements_; |
| 981 |
966 // The absolute path to the directory the extension is stored in. | 982 // The absolute path to the directory the extension is stored in. |
967 FilePath path_; | 983 FilePath path_; |
968 | 984 |
969 // Default locale for fall back. Can be empty if extension is not localized. | 985 // Default locale for fall back. Can be empty if extension is not localized. |
970 std::string default_locale_; | 986 std::string default_locale_; |
971 | 987 |
972 // If true, a separate process will be used for the extension in incognito | 988 // If true, a separate process will be used for the extension in incognito |
973 // mode. | 989 // mode. |
974 bool incognito_split_mode_; | 990 bool incognito_split_mode_; |
975 | 991 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 | 1231 |
1216 UpdatedExtensionPermissionsInfo( | 1232 UpdatedExtensionPermissionsInfo( |
1217 const Extension* extension, | 1233 const Extension* extension, |
1218 const PermissionSet* permissions, | 1234 const PermissionSet* permissions, |
1219 Reason reason); | 1235 Reason reason); |
1220 }; | 1236 }; |
1221 | 1237 |
1222 } // namespace extensions | 1238 } // namespace extensions |
1223 | 1239 |
1224 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 1240 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
OLD | NEW |