Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: chrome/common/extensions/extension.h

Issue 5642001: Fix issue that causes some extensions to be disabled right after installation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comment Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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. (NOTE: when de-duping hosts with common RCDs,
132 std::vector<std::string> GetDistinctHosts() const; 132 // the first pattern is returned and the rest discarded)
133 static std::vector<std::string> GetDistinctHostsForDisplay(
134 const URLPatternList& list);
135
136 // Compares two URLPatternLists for security equality by returning whether
137 // the URL patterns in |new_list| contain additional distinct hosts compared
138 // to |old_list|.
139 static bool IsElevatedHostList(
140 const URLPatternList& old_list, const URLPatternList& new_list);
133 141
134 // Icon sizes used by the extension system. 142 // Icon sizes used by the extension system.
135 static const int kIconSizes[]; 143 static const int kIconSizes[];
136 144
137 // Max size (both dimensions) for browser and page actions. 145 // Max size (both dimensions) for browser and page actions.
138 static const int kPageActionIconMaxSize; 146 static const int kPageActionIconMaxSize;
139 static const int kBrowserActionIconMaxSize; 147 static const int kBrowserActionIconMaxSize;
140 148
141 // Each permission is a module that the extension is permitted to use. 149 // Each permission is a module that the extension is permitted to use.
142 // 150 //
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 // We keep a cache of images loaded from extension resources based on their 457 // We keep a cache of images loaded from extension resources based on their
450 // path and a string representation of a size that may have been used to 458 // path and a string representation of a size that may have been used to
451 // scale it (or the empty string if the image is at its original size). 459 // scale it (or the empty string if the image is at its original size).
452 typedef std::pair<FilePath, std::string> ImageCacheKey; 460 typedef std::pair<FilePath, std::string> ImageCacheKey;
453 typedef std::map<ImageCacheKey, SkBitmap> ImageCache; 461 typedef std::map<ImageCacheKey, SkBitmap> ImageCache;
454 462
455 // Normalize the path for use by the extension. On Windows, this will make 463 // Normalize the path for use by the extension. On Windows, this will make
456 // sure the drive letter is uppercase. 464 // sure the drive letter is uppercase.
457 static FilePath MaybeNormalizePath(const FilePath& path); 465 static FilePath MaybeNormalizePath(const FilePath& path);
458 466
467 // Returns the distinct hosts that can be displayed in the install UI or be
468 // used for privilege comparisons. This discards some of the detail that is
469 // present in the manifest to make it as easy as possible to process by users.
470 // In particular we disregard the scheme and path components of URLPatterns
471 // and de-dupe the result, which includes filtering out common hosts with
472 // differing RCDs. If |include_rcd| is true, then the de-duped result
473 // will be the first full entry, including its RCD. So if the list was
474 // "*.google.co.uk" and "*.google.com", the returned value would just be
475 // "*.google.co.uk". Keeping the RCD in the result is useful for display
476 // purposes when you want to show the user one sample hostname from the list.
477 // If you need to compare two URLPatternLists for security equality, then set
478 // |include_rcd| to false, which will return a result like "*.google.",
479 // regardless of the order of the patterns.
480 static std::vector<std::string> GetDistinctHosts(
481 const URLPatternList& host_patterns, bool include_rcd);
482
459 Extension(const FilePath& path, Location location); 483 Extension(const FilePath& path, Location location);
460 ~Extension(); 484 ~Extension();
461 485
462 // Initialize the extension from a parsed manifest. 486 // Initialize the extension from a parsed manifest.
463 // Usually, the id of an extension is generated by the "key" property of 487 // Usually, the id of an extension is generated by the "key" property of
464 // its manifest, but if |require_key| is |false|, a temporary ID will be 488 // its manifest, but if |require_key| is |false|, a temporary ID will be
465 // generated based on the path. 489 // generated based on the path.
466 bool InitFromValue(const DictionaryValue& value, bool require_key, 490 bool InitFromValue(const DictionaryValue& value, bool require_key,
467 std::string* error); 491 std::string* error);
468 492
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 std::set<std::string> extension_api_permissions; 732 std::set<std::string> extension_api_permissions;
709 // TODO(akalin): Once we have a unified ExtensionType, replace the 733 // TODO(akalin): Once we have a unified ExtensionType, replace the
710 // below member variables with a member of that type. 734 // below member variables with a member of that type.
711 bool is_theme; 735 bool is_theme;
712 bool is_app; 736 bool is_app;
713 bool converted_from_user_script; 737 bool converted_from_user_script;
714 GURL update_url; 738 GURL update_url;
715 }; 739 };
716 740
717 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ 741 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698