| 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> |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 FORWARD_DECLARE_TEST(TabStripModelTest, Apps); | 49 FORWARD_DECLARE_TEST(TabStripModelTest, Apps); |
| 50 | 50 |
| 51 namespace extensions { | 51 namespace extensions { |
| 52 | 52 |
| 53 class Manifest; | 53 class Manifest; |
| 54 | 54 |
| 55 // Represents a Chrome extension. | 55 // Represents a Chrome extension. |
| 56 class Extension : public base::RefCountedThreadSafe<Extension> { | 56 class Extension : public base::RefCountedThreadSafe<Extension> { |
| 57 public: | 57 public: |
| 58 struct InstallWarning; |
| 59 |
| 58 typedef std::map<const std::string, GURL> URLOverrideMap; | 60 typedef std::map<const std::string, GURL> URLOverrideMap; |
| 59 typedef std::vector<std::string> ScriptingWhitelist; | 61 typedef std::vector<std::string> ScriptingWhitelist; |
| 60 typedef std::vector<linked_ptr<FileBrowserHandler> > FileBrowserHandlerList; | 62 typedef std::vector<linked_ptr<FileBrowserHandler> > FileBrowserHandlerList; |
| 63 typedef std::vector<InstallWarning> InstallWarningVector; |
| 61 | 64 |
| 62 // What an extension was loaded from. | 65 // What an extension was loaded from. |
| 63 // NOTE: These values are stored as integers in the preferences and used | 66 // NOTE: These values are stored as integers in the preferences and used |
| 64 // in histograms so don't remove or reorder existing items. Just append | 67 // in histograms so don't remove or reorder existing items. Just append |
| 65 // to the end. | 68 // to the end. |
| 66 enum Location { | 69 enum Location { |
| 67 INVALID, | 70 INVALID, |
| 68 INTERNAL, // A crx file from the internal Extensions directory. | 71 INTERNAL, // A crx file from the internal Extensions directory. |
| 69 EXTERNAL_PREF, // A crx file from an external directory (via prefs). | 72 EXTERNAL_PREF, // A crx file from an external directory (via prefs). |
| 70 EXTERNAL_REGISTRY, // A crx file from an external directory (via eg the | 73 EXTERNAL_REGISTRY, // A crx file from an external directory (via eg the |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 struct OAuth2Info { | 178 struct OAuth2Info { |
| 176 OAuth2Info(); | 179 OAuth2Info(); |
| 177 ~OAuth2Info(); | 180 ~OAuth2Info(); |
| 178 | 181 |
| 179 ExtensionOAuth2Scopes GetScopesAsSet(); | 182 ExtensionOAuth2Scopes GetScopesAsSet(); |
| 180 | 183 |
| 181 std::string client_id; | 184 std::string client_id; |
| 182 std::vector<std::string> scopes; | 185 std::vector<std::string> scopes; |
| 183 }; | 186 }; |
| 184 | 187 |
| 188 struct InstallWarning { |
| 189 enum Format { |
| 190 // IMPORTANT: Do not build HTML strings from user or developer-supplied |
| 191 // input. |
| 192 FORMAT_TEXT, |
| 193 FORMAT_HTML, |
| 194 }; |
| 195 InstallWarning(Format format, const std::string& message) |
| 196 : format(format), message(message) { |
| 197 } |
| 198 Format format; |
| 199 std::string message; |
| 200 }; |
| 201 |
| 185 enum InitFromValueFlags { | 202 enum InitFromValueFlags { |
| 186 NO_FLAGS = 0, | 203 NO_FLAGS = 0, |
| 187 | 204 |
| 188 // Usually, the id of an extension is generated by the "key" property of | 205 // Usually, the id of an extension is generated by the "key" property of |
| 189 // its manifest, but if |REQUIRE_KEY| is not set, a temporary ID will be | 206 // its manifest, but if |REQUIRE_KEY| is not set, a temporary ID will be |
| 190 // generated based on the path. | 207 // generated based on the path. |
| 191 REQUIRE_KEY = 1 << 0, | 208 REQUIRE_KEY = 1 << 0, |
| 192 | 209 |
| 193 // Requires the extension to have an up-to-date manifest version. | 210 // Requires the extension to have an up-to-date manifest version. |
| 194 // Typically, we'll support multiple manifest versions during a version | 211 // Typically, we'll support multiple manifest versions during a version |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 } | 621 } |
| 605 const GURL& options_url() const { return options_url_; } | 622 const GURL& options_url() const { return options_url_; } |
| 606 const GURL& devtools_url() const { return devtools_url_; } | 623 const GURL& devtools_url() const { return devtools_url_; } |
| 607 const ExtensionPermissionSet* optional_permission_set() const { | 624 const ExtensionPermissionSet* optional_permission_set() const { |
| 608 return optional_permission_set_.get(); | 625 return optional_permission_set_.get(); |
| 609 } | 626 } |
| 610 const ExtensionPermissionSet* required_permission_set() const { | 627 const ExtensionPermissionSet* required_permission_set() const { |
| 611 return required_permission_set_.get(); | 628 return required_permission_set_.get(); |
| 612 } | 629 } |
| 613 // Appends |new_warnings| to install_warnings(). | 630 // Appends |new_warnings| to install_warnings(). |
| 614 void AddInstallWarnings(const std::vector<std::string>& new_warnings); | 631 void AddInstallWarnings(const InstallWarningVector& new_warnings); |
| 615 const std::vector<std::string>& install_warnings() const { | 632 const InstallWarningVector& install_warnings() const { |
| 616 return install_warnings_; | 633 return install_warnings_; |
| 617 } | 634 } |
| 618 const GURL& update_url() const { return update_url_; } | 635 const GURL& update_url() const { return update_url_; } |
| 619 const ExtensionIconSet& icons() const { return icons_; } | 636 const ExtensionIconSet& icons() const { return icons_; } |
| 620 const extensions::Manifest* manifest() const { | 637 const extensions::Manifest* manifest() const { |
| 621 return manifest_; | 638 return manifest_; |
| 622 } | 639 } |
| 623 const std::string default_locale() const { return default_locale_; } | 640 const std::string default_locale() const { return default_locale_; } |
| 624 const URLOverrideMap& GetChromeURLOverrides() const { | 641 const URLOverrideMap& GetChromeURLOverrides() const { |
| 625 return chrome_url_overrides_; | 642 return chrome_url_overrides_; |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 mutable base::Lock runtime_data_lock_; | 913 mutable base::Lock runtime_data_lock_; |
| 897 mutable RuntimeData runtime_data_; | 914 mutable RuntimeData runtime_data_; |
| 898 | 915 |
| 899 // The set of permissions the extension can request at runtime. | 916 // The set of permissions the extension can request at runtime. |
| 900 scoped_refptr<const ExtensionPermissionSet> optional_permission_set_; | 917 scoped_refptr<const ExtensionPermissionSet> optional_permission_set_; |
| 901 | 918 |
| 902 // The extension's required / default set of permissions. | 919 // The extension's required / default set of permissions. |
| 903 scoped_refptr<const ExtensionPermissionSet> required_permission_set_; | 920 scoped_refptr<const ExtensionPermissionSet> required_permission_set_; |
| 904 | 921 |
| 905 // Any warnings that occurred when trying to create/parse the extension. | 922 // Any warnings that occurred when trying to create/parse the extension. |
| 906 std::vector<std::string> install_warnings_; | 923 InstallWarningVector install_warnings_; |
| 907 | 924 |
| 908 // The icons for the extension. | 925 // The icons for the extension. |
| 909 ExtensionIconSet icons_; | 926 ExtensionIconSet icons_; |
| 910 | 927 |
| 911 // The base extension url for the extension. | 928 // The base extension url for the extension. |
| 912 GURL extension_url_; | 929 GURL extension_url_; |
| 913 | 930 |
| 914 // The extension's version. | 931 // The extension's version. |
| 915 scoped_ptr<Version> version_; | 932 scoped_ptr<Version> version_; |
| 916 | 933 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1136 | 1153 |
| 1137 UpdatedExtensionPermissionsInfo( | 1154 UpdatedExtensionPermissionsInfo( |
| 1138 const Extension* extension, | 1155 const Extension* extension, |
| 1139 const ExtensionPermissionSet* permissions, | 1156 const ExtensionPermissionSet* permissions, |
| 1140 Reason reason); | 1157 Reason reason); |
| 1141 }; | 1158 }; |
| 1142 | 1159 |
| 1143 } // namespace extensions | 1160 } // namespace extensions |
| 1144 | 1161 |
| 1145 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 1162 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
| OLD | NEW |