Update of the extension install UI:
- Give the user more information about which hosts an
extension can access.
- Remove the red severe warning because it doesn't play well
with themes and because it adds nothing when the other
text is more specific.
- Make the image a bit smaller.
Also integrate this new idea with the silent/not-silent update flow.
BUG=12129,12140,19582
Review URL: http://codereview.chromium.org/173463
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24599 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h
index 34685fc..ab68d600 100644
--- a/chrome/common/extensions/extension.h
+++ b/chrome/common/extensions/extension.h
@@ -23,6 +23,8 @@
// Represents a Chrome extension.
class Extension {
public:
+ typedef std::vector<URLPattern> HostPermissions;
+
// What an extension was loaded from.
enum Location {
INVALID,
@@ -65,15 +67,6 @@
static const char* kPermissionNames[];
static const size_t kNumPermissions;
- // A classification of how dangerous an extension can be, based on what it has
- // access to.
- enum PermissionClass {
- PERMISSION_CLASS_LOW = 0, // green
- PERMISSION_CLASS_MEDIUM, // yellow
- PERMISSION_CLASS_HIGH, // orange
- PERMISSION_CLASS_FULL, // red
- };
-
struct PrivacyBlacklistInfo {
FilePath path; // Path to the plain-text blacklist.
};
@@ -175,6 +168,11 @@
static bool FormatPEMForFileOutput(const std::string input,
std::string* output, bool is_public);
+ // Determine whether we should allow a silent upgrade from |old_extension| to
+ // |new_extension|. If not, the user will have to approve the upgrade.
+ static bool AllowSilentUpgrade(Extension* old_extension,
+ Extension* new_extension);
+
// Initialize the extension from a parsed manifest.
// If |require_id| is true, will return an error if the "id" key is missing
// from the value.
@@ -201,12 +199,23 @@
const std::vector<PluginInfo>& plugins() const { return plugins_; }
const GURL& background_url() const { return background_url_; }
const std::vector<ToolstripInfo>& toolstrips() const { return toolstrips_; }
- const std::vector<URLPattern>& host_permissions() const {
+ const HostPermissions& host_permissions() const {
return host_permissions_;
}
const std::vector<std::string>& api_permissions() const {
return api_permissions_;
}
+
+ // Returns the set of hosts that the extension effectively has access to. This
+ // is used in the permissions UI and is a combination of the hosts accessible
+ // through content scripts and the hosts accessible through XHR.
+ const std::set<std::string> GetEffectiveHostPermissions() const;
+
+ // Whether the extension has access to all hosts. This is true if there is
+ // a content script that matches all hosts, or if there is a host permission
+ // for all hosts.
+ bool HasAccessToAllHosts() const;
+
const GURL& update_url() const { return update_url_; }
const std::map<int, std::string>& icons() { return icons_; }
@@ -230,9 +239,6 @@
// the browser might load (like themes and page action icons).
std::set<FilePath> GetBrowserImages();
- // Calculates and returns the permission class this extension is in.
- PermissionClass GetPermissionClass();
-
// Returns an absolute path to the given icon inside of the extension. Returns
// an empty FilePath if the extension does not have that icon.
FilePath GetIconPath(Icons icon);
@@ -359,7 +365,7 @@
std::vector<std::string> api_permissions_;
// The sites this extension has permission to talk to (using XHR, etc).
- std::vector<URLPattern> host_permissions_;
+ HostPermissions host_permissions_;
// The paths to the icons the extension contains mapped by their width.
std::map<int, std::string> icons_;