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

Unified Diff: chrome/common/extensions/extension.cc

Issue 4687005: Track permissions granted to extensions in prefs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/extension.cc
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 2bbf99bc81571580c60752476e1c1534c47e08e4..4239c744cc692af25781b589e4e80f7503e4daf1 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -1129,6 +1129,37 @@ bool Extension::IsPrivilegeIncrease(const Extension* old_extension,
}
// static
+// TODO(jstritar): This can be combined with the other IsPrivilegeIncrease
+// so that extensions can remove and re-add permissions during upgrades.
Aaron Boodman 2010/11/12 00:05:24 I don't understand this comment. Can you combine t
jstritar 2010/11/19 21:38:36 Okay, I combined both IsPrivilegeIncreases and upd
+bool Extension::IsPrivilegeIncrease(const std::set<std::string>* granted_apis,
+ const std::set<std::string>* granted_hosts,
+ const Extension* extension) {
+ // TODO(erikkay) This will trip when you add a new distinct hostname,
+ // but we should unique based on RCD as well. crbug.com/57042
+ std::set<std::string> new_hosts;
+ std::set<std::string> new_hosts_only;
+
+ extension->GetEffectiveHostPermissions().GetAsStringSet(&new_hosts);
+ std::set_difference(new_hosts.begin(), new_hosts.end(),
+ granted_hosts->begin(), granted_hosts->end(),
+ std::inserter(new_hosts_only, new_hosts_only.end()));
+
+ if (!new_hosts_only.empty())
+ return true;
+
+ std::set<std::string> new_apis = extension->api_permissions();
+ std::set<std::string> new_apis_only;
+ std::set_difference(new_apis.begin(), new_apis.end(),
+ granted_apis->begin(), granted_apis->end(),
+ std::inserter(new_apis_only, new_apis_only.end()));
+
+ if (!new_apis_only.empty())
+ return true;
+
+ return false;
+}
+
+// static
void Extension::DecodeIcon(const Extension* extension,
Icons icon_size,
scoped_ptr<SkBitmap>* result) {
@@ -1706,29 +1737,29 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key,
}
}
- // Otherwise, it's a host pattern permission.
+ // Check if it's a host pattern permission.
URLPattern pattern = URLPattern(CanExecuteScriptEverywhere() ?
URLPattern::SCHEME_ALL :
(UserScript::kValidUserScriptSchemes |
URLPattern::SCHEME_CHROMEUI) & ~URLPattern::SCHEME_FILE);
- if (URLPattern::PARSE_SUCCESS != pattern.Parse(permission_str)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
- errors::kInvalidPermission, base::IntToString(i));
- return false;
- }
+ if (URLPattern::PARSE_SUCCESS == pattern.Parse(permission_str)) {
+ if (!CanSpecifyHostPermission(pattern)) {
+ *error = ExtensionErrorUtils::FormatErrorMessage(
+ errors::kInvalidPermissionScheme, base::IntToString(i));
+ return false;
+ }
- if (!CanSpecifyHostPermission(pattern)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
- errors::kInvalidPermissionScheme, base::IntToString(i));
- return false;
- }
+ // The path component is not used for host permissions, so we force it
+ // to match all paths.
+ pattern.set_path("/*");
- // The path component is not used for host permissions, so we force it to
- // match all paths.
- pattern.set_path("/*");
+ host_permissions_.push_back(pattern);
+ }
- host_permissions_.push_back(pattern);
+ // If it's not a host permission, then it's probably an unknown API
+ // permission. Do not throw an error so extensions can retain
+ // backwards compatability.
Aaron Boodman 2010/11/12 00:05:24 This is a good place to add a link to the bug, so
jstritar 2010/11/19 21:38:36 Done.
}
}

Powered by Google App Engine
This is Rietveld 408576698