OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 std::string gender; | 107 std::string gender; |
108 }; | 108 }; |
109 | 109 |
110 // A permission is defined by its |name| (what is used in the manifest), | 110 // A permission is defined by its |name| (what is used in the manifest), |
111 // and the |message_id| that's used by install/update UI. | 111 // and the |message_id| that's used by install/update UI. |
112 struct Permission { | 112 struct Permission { |
113 const char* const name; | 113 const char* const name; |
114 const int message_id; | 114 const int message_id; |
115 }; | 115 }; |
116 | 116 |
117 // |strict_error_checks| enables extra error checking, such as | 117 enum InitFromValueFlags { |
118 // checks that URL patterns do not contain ports. This error | 118 NO_FLAGS = 0, |
119 // checking may find an error that a previous version of | 119 |
120 // chrome did not flag. To avoid errors in installed extensions | 120 // Usually, the id of an extension is generated by the "key" property of |
121 // when chrome is upgraded, strict error checking is only enabled | 121 // its manifest, but if |REQUIRE_KEY| is not set, a temporary ID will be |
122 // when loading extensions as a developer would (such as loading | 122 // generated based on the path. |
123 // an unpacked extension), or when loading an extension that is | 123 REQUIRE_KEY = 1 << 0, |
124 // tied to a specific version of chrome (such as a component | 124 |
125 // extension). Most callers will set |strict_error_checks| to | 125 // |STRICT_ERROR_CHECKS| enables extra error checking, such as |
126 // Extension::ShouldDoStrictErrorChecking(location). | 126 // checks that URL patterns do not contain ports. This error |
| 127 // checking may find an error that a previous version of |
| 128 // Chrome did not flag. To avoid errors in installed extensions |
| 129 // when Chrome is upgraded, strict error checking is only enabled |
| 130 // when loading extensions as a developer would (such as loading |
| 131 // an unpacked extension), or when loading an extension that is |
| 132 // tied to a specific version of Chrome (such as a component |
| 133 // extension). Most callers will set the |STRICT_ERROR_CHECKS| bit when |
| 134 // Extension::ShouldDoStrictErrorChecking(location) returns true. |
| 135 STRICT_ERROR_CHECKS = 1 << 1, |
| 136 }; |
| 137 |
127 static scoped_refptr<Extension> Create(const FilePath& path, | 138 static scoped_refptr<Extension> Create(const FilePath& path, |
128 Location location, | 139 Location location, |
129 const DictionaryValue& value, | 140 const DictionaryValue& value, |
130 bool require_key, | 141 int flags, |
131 bool strict_error_checks, | |
132 std::string* error); | 142 std::string* error); |
133 | 143 |
134 // Return the update url used by gallery/webstore extensions. | 144 // Return the update url used by gallery/webstore extensions. |
135 static GURL GalleryUpdateUrl(bool secure); | 145 static GURL GalleryUpdateUrl(bool secure); |
136 | 146 |
137 // The install message id for |permission|. Returns 0 if none exists. | 147 // The install message id for |permission|. Returns 0 if none exists. |
138 static int GetPermissionMessageId(const std::string& permission); | 148 static int GetPermissionMessageId(const std::string& permission); |
139 | 149 |
140 // Returns the full list of permission messages that this extension | 150 // Returns the full list of permission messages that this extension |
141 // should display at install time. | 151 // should display at install time. |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 // If you need to compare two URLPatternLists for security equality, then set | 542 // If you need to compare two URLPatternLists for security equality, then set |
533 // |include_rcd| to false, which will return a result like "*.google.", | 543 // |include_rcd| to false, which will return a result like "*.google.", |
534 // regardless of the order of the patterns. | 544 // regardless of the order of the patterns. |
535 static std::vector<std::string> GetDistinctHosts( | 545 static std::vector<std::string> GetDistinctHosts( |
536 const URLPatternList& host_patterns, bool include_rcd); | 546 const URLPatternList& host_patterns, bool include_rcd); |
537 | 547 |
538 Extension(const FilePath& path, Location location); | 548 Extension(const FilePath& path, Location location); |
539 ~Extension(); | 549 ~Extension(); |
540 | 550 |
541 // Initialize the extension from a parsed manifest. | 551 // Initialize the extension from a parsed manifest. |
542 // Usually, the id of an extension is generated by the "key" property of | 552 bool InitFromValue(const DictionaryValue& value, int flags, |
543 // its manifest, but if |require_key| is |false|, a temporary ID will be | 553 std::string* error); |
544 // generated based on the path. | |
545 bool InitFromValue(const DictionaryValue& value, bool require_key, | |
546 bool strict_error_checks, std::string* error); | |
547 | 554 |
548 // Helper function for implementing HasCachedImage/GetCachedImage. A return | 555 // Helper function for implementing HasCachedImage/GetCachedImage. A return |
549 // value of NULL means there is no matching image cached (we allow caching an | 556 // value of NULL means there is no matching image cached (we allow caching an |
550 // empty SkBitmap). | 557 // empty SkBitmap). |
551 SkBitmap* GetCachedImageImpl(const ExtensionResource& source, | 558 SkBitmap* GetCachedImageImpl(const ExtensionResource& source, |
552 const gfx::Size& max_size) const; | 559 const gfx::Size& max_size) const; |
553 | 560 |
554 // Helper method that loads a UserScript object from a | 561 // Helper method that loads a UserScript object from a |
555 // dictionary in the content_script list of the manifest. | 562 // dictionary in the content_script list of the manifest. |
556 bool LoadUserScriptHelper(const DictionaryValue* content_script, | 563 bool LoadUserScriptHelper(const DictionaryValue* content_script, |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 // Was the extension already disabled? | 832 // Was the extension already disabled? |
826 bool already_disabled; | 833 bool already_disabled; |
827 | 834 |
828 // The extension being unloaded - this should always be non-NULL. | 835 // The extension being unloaded - this should always be non-NULL. |
829 const Extension* extension; | 836 const Extension* extension; |
830 | 837 |
831 UnloadedExtensionInfo(const Extension* extension, Reason reason); | 838 UnloadedExtensionInfo(const Extension* extension, Reason reason); |
832 }; | 839 }; |
833 | 840 |
834 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 841 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
OLD | NEW |