Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 // Return the update url used by gallery/webstore extensions. | 116 // Return the update url used by gallery/webstore extensions. |
| 117 static GURL GalleryUpdateUrl(bool secure); | 117 static GURL GalleryUpdateUrl(bool secure); |
| 118 | 118 |
| 119 // The install message id for |permission|. Returns 0 if none exists. | 119 // The install message id for |permission|. Returns 0 if none exists. |
| 120 static int GetPermissionMessageId(const std::string& permission); | 120 static int GetPermissionMessageId(const std::string& permission); |
| 121 | 121 |
| 122 // Returns the full list of permission messages that this extension | 122 // Returns the full list of permission messages that this extension |
| 123 // should display at install time. | 123 // should display at install time. |
| 124 std::vector<string16> GetPermissionMessages() const; | 124 std::vector<string16> GetPermissionMessages() const; |
| 125 | 125 |
| 126 // Returns the distinct hosts that should be displayed in the install UI. This | 126 // Returns the distinct hosts that should be displayed in the install UI |
| 127 // discards some of the detail that is present in the manifest to make it as | 127 // for the URL patterns |list|. This discards some of the detail that is |
| 128 // easy as possible to process by users. In particular we disregard the scheme | 128 // present in the manifest to make it as easy as possible to process by |
| 129 // and path components of URLPatterns and de-dupe the result. | 129 // users. In particular we disregard the scheme and path components of |
| 130 static std::vector<std::string> GetDistinctHosts( | 130 // URLPatterns and de-dupe the result, which includes filtering out common |
| 131 const URLPatternList& host_patterns); | 131 // hosts with differing RCDs. |
|
Erik does not do reviews
2010/12/03 23:40:41
add (NOTE: when de-duping hosts with common RCDs,
| |
| 132 std::vector<std::string> GetDistinctHosts() const; | 132 static std::vector<std::string> GetDistinctHostsForDisplay( |
| 133 const URLPatternList& list); | |
| 134 | |
| 135 // Compares two URLPatternLists for security equality by returning whether | |
| 136 // the URL patterns in |new_list| contain additional distinct hosts compared | |
| 137 // to |old_list|. | |
| 138 static bool IsElevatedHostList( | |
| 139 const URLPatternList& old_list, const URLPatternList& new_list); | |
| 133 | 140 |
| 134 // Icon sizes used by the extension system. | 141 // Icon sizes used by the extension system. |
| 135 static const int kIconSizes[]; | 142 static const int kIconSizes[]; |
| 136 | 143 |
| 137 // Max size (both dimensions) for browser and page actions. | 144 // Max size (both dimensions) for browser and page actions. |
| 138 static const int kPageActionIconMaxSize; | 145 static const int kPageActionIconMaxSize; |
| 139 static const int kBrowserActionIconMaxSize; | 146 static const int kBrowserActionIconMaxSize; |
| 140 | 147 |
| 141 // Each permission is a module that the extension is permitted to use. | 148 // Each permission is a module that the extension is permitted to use. |
| 142 // | 149 // |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 // We keep a cache of images loaded from extension resources based on their | 453 // We keep a cache of images loaded from extension resources based on their |
| 447 // path and a string representation of a size that may have been used to | 454 // path and a string representation of a size that may have been used to |
| 448 // scale it (or the empty string if the image is at its original size). | 455 // scale it (or the empty string if the image is at its original size). |
| 449 typedef std::pair<FilePath, std::string> ImageCacheKey; | 456 typedef std::pair<FilePath, std::string> ImageCacheKey; |
| 450 typedef std::map<ImageCacheKey, SkBitmap> ImageCache; | 457 typedef std::map<ImageCacheKey, SkBitmap> ImageCache; |
| 451 | 458 |
| 452 // Normalize the path for use by the extension. On Windows, this will make | 459 // Normalize the path for use by the extension. On Windows, this will make |
| 453 // sure the drive letter is uppercase. | 460 // sure the drive letter is uppercase. |
| 454 static FilePath MaybeNormalizePath(const FilePath& path); | 461 static FilePath MaybeNormalizePath(const FilePath& path); |
| 455 | 462 |
| 463 // Returns the distinct hosts that can be displayed in the install UI or be | |
| 464 // used for privilege comparisons. This discards some of the detail that is | |
| 465 // present in the manifest to make it as easy as possible to process by users. | |
| 466 // In particular we disregard the scheme and path components of URLPatterns | |
| 467 // and de-dupe the result, which includes filtering out common hosts with | |
| 468 // differing RCDs. If |include_rcd| is true, then the de-duped result | |
| 469 // will be the first full entry, including its RCD. So if the list was | |
| 470 // "*.google.co.uk" and "*.google.com", the returned value would just be | |
| 471 // "*.google.co.uk". Keeping the RCD in the result is useful for display | |
| 472 // purposes when you want to show the user one sample hostname from the list. | |
| 473 // If you need to compare two URLPatternLists for security equality, then set | |
| 474 // |include_rcd| to false, which will return a result like "*.google.", | |
| 475 // regardless of the order of the patterns. | |
| 476 static std::vector<std::string> GetDistinctHosts( | |
| 477 const URLPatternList& host_patterns, bool include_rcd); | |
| 478 | |
| 456 Extension(const FilePath& path, Location location); | 479 Extension(const FilePath& path, Location location); |
| 457 ~Extension(); | 480 ~Extension(); |
| 458 | 481 |
| 459 // Initialize the extension from a parsed manifest. | 482 // Initialize the extension from a parsed manifest. |
| 460 // Usually, the id of an extension is generated by the "key" property of | 483 // Usually, the id of an extension is generated by the "key" property of |
| 461 // its manifest, but if |require_key| is |false|, a temporary ID will be | 484 // its manifest, but if |require_key| is |false|, a temporary ID will be |
| 462 // generated based on the path. | 485 // generated based on the path. |
| 463 bool InitFromValue(const DictionaryValue& value, bool require_key, | 486 bool InitFromValue(const DictionaryValue& value, bool require_key, |
| 464 std::string* error); | 487 std::string* error); |
| 465 | 488 |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 705 std::set<std::string> extension_api_permissions; | 728 std::set<std::string> extension_api_permissions; |
| 706 // TODO(akalin): Once we have a unified ExtensionType, replace the | 729 // TODO(akalin): Once we have a unified ExtensionType, replace the |
| 707 // below member variables with a member of that type. | 730 // below member variables with a member of that type. |
| 708 bool is_theme; | 731 bool is_theme; |
| 709 bool is_app; | 732 bool is_app; |
| 710 bool converted_from_user_script; | 733 bool converted_from_user_script; |
| 711 GURL update_url; | 734 GURL update_url; |
| 712 }; | 735 }; |
| 713 | 736 |
| 714 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 737 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
| OLD | NEW |