Chromium Code Reviews| 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 // Usually, the id of an extension is generated by the "key" property of |
|
Aaron Boodman
2011/03/28 23:26:40
Add a blank line between each item?
| |
| 120 // chrome did not flag. To avoid errors in installed extensions | 120 // its manifest, but if |REQUIRE_KEY| is not set, a temporary ID will be |
| 121 // when chrome is upgraded, strict error checking is only enabled | 121 // generated based on the path. |
| 122 // when loading extensions as a developer would (such as loading | 122 REQUIRE_KEY = 1 << 0, |
| 123 // an unpacked extension), or when loading an extension that is | 123 // |STRICT_ERROR_CHECKS| enables extra error checking, such as |
| 124 // tied to a specific version of chrome (such as a component | 124 // checks that URL patterns do not contain ports. This error |
| 125 // extension). Most callers will set |strict_error_checks| to | 125 // checking may find an error that a previous version of |
| 126 // Extension::ShouldDoStrictErrorChecking(location). | 126 // Chrome did not flag. To avoid errors in installed extensions |
| 127 // when Chrome is upgraded, strict error checking is only enabled | |
| 128 // when loading extensions as a developer would (such as loading | |
| 129 // an unpacked extension), or when loading an extension that is | |
| 130 // tied to a specific version of Chrome (such as a component | |
| 131 // extension). Most callers will set the |STRICT_ERROR_CHECKS| bit when | |
| 132 // Extension::ShouldDoStrictErrorChecking(location) returns true. | |
| 133 STRICT_ERROR_CHECKS = 1 << 1, | |
| 134 }; | |
| 135 | |
| 127 static scoped_refptr<Extension> Create(const FilePath& path, | 136 static scoped_refptr<Extension> Create(const FilePath& path, |
| 128 Location location, | 137 Location location, |
| 129 const DictionaryValue& value, | 138 const DictionaryValue& value, |
| 130 bool require_key, | 139 int flags, |
|
Aaron Boodman
2011/03/28 23:26:40
I always forget: Can you define this as InitFromVa
| |
| 131 bool strict_error_checks, | |
| 132 std::string* error); | 140 std::string* error); |
| 133 | 141 |
| 134 // Return the update url used by gallery/webstore extensions. | 142 // Return the update url used by gallery/webstore extensions. |
| 135 static GURL GalleryUpdateUrl(bool secure); | 143 static GURL GalleryUpdateUrl(bool secure); |
| 136 | 144 |
| 137 // The install message id for |permission|. Returns 0 if none exists. | 145 // The install message id for |permission|. Returns 0 if none exists. |
| 138 static int GetPermissionMessageId(const std::string& permission); | 146 static int GetPermissionMessageId(const std::string& permission); |
| 139 | 147 |
| 140 // Returns the full list of permission messages that this extension | 148 // Returns the full list of permission messages that this extension |
| 141 // should display at install time. | 149 // 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 | 540 // If you need to compare two URLPatternLists for security equality, then set |
| 533 // |include_rcd| to false, which will return a result like "*.google.", | 541 // |include_rcd| to false, which will return a result like "*.google.", |
| 534 // regardless of the order of the patterns. | 542 // regardless of the order of the patterns. |
| 535 static std::vector<std::string> GetDistinctHosts( | 543 static std::vector<std::string> GetDistinctHosts( |
| 536 const URLPatternList& host_patterns, bool include_rcd); | 544 const URLPatternList& host_patterns, bool include_rcd); |
| 537 | 545 |
| 538 Extension(const FilePath& path, Location location); | 546 Extension(const FilePath& path, Location location); |
| 539 ~Extension(); | 547 ~Extension(); |
| 540 | 548 |
| 541 // Initialize the extension from a parsed manifest. | 549 // Initialize the extension from a parsed manifest. |
| 542 // Usually, the id of an extension is generated by the "key" property of | 550 bool InitFromValue(const DictionaryValue& value, int flags, |
| 543 // its manifest, but if |require_key| is |false|, a temporary ID will be | 551 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 | 552 |
| 548 // Helper function for implementing HasCachedImage/GetCachedImage. A return | 553 // Helper function for implementing HasCachedImage/GetCachedImage. A return |
| 549 // value of NULL means there is no matching image cached (we allow caching an | 554 // value of NULL means there is no matching image cached (we allow caching an |
| 550 // empty SkBitmap). | 555 // empty SkBitmap). |
| 551 SkBitmap* GetCachedImageImpl(const ExtensionResource& source, | 556 SkBitmap* GetCachedImageImpl(const ExtensionResource& source, |
| 552 const gfx::Size& max_size) const; | 557 const gfx::Size& max_size) const; |
| 553 | 558 |
| 554 // Helper method that loads a UserScript object from a | 559 // Helper method that loads a UserScript object from a |
| 555 // dictionary in the content_script list of the manifest. | 560 // dictionary in the content_script list of the manifest. |
| 556 bool LoadUserScriptHelper(const DictionaryValue* content_script, | 561 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? | 830 // Was the extension already disabled? |
| 826 bool already_disabled; | 831 bool already_disabled; |
| 827 | 832 |
| 828 // The extension being unloaded - this should always be non-NULL. | 833 // The extension being unloaded - this should always be non-NULL. |
| 829 const Extension* extension; | 834 const Extension* extension; |
| 830 | 835 |
| 831 UnloadedExtensionInfo(const Extension* extension, Reason reason); | 836 UnloadedExtensionInfo(const Extension* extension, Reason reason); |
| 832 }; | 837 }; |
| 833 | 838 |
| 834 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 839 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
| OLD | NEW |