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

Unified Diff: chrome/browser/extensions/extension_prefs.cc

Issue 10689097: Enforce the 'requirements' field in manifests. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 months 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/browser/extensions/extension_prefs.cc
diff --git a/chrome/browser/extensions/extension_prefs.cc b/chrome/browser/extensions/extension_prefs.cc
index 9676f74170c8c9cf48b6f36ed0e1bbfb06197aa8..ad7d819f826f57dfcb2cf43b19447944b433d66b 100644
--- a/chrome/browser/extensions/extension_prefs.cc
+++ b/chrome/browser/extensions/extension_prefs.cc
@@ -63,6 +63,9 @@ const char kPrefOrphanAcknowledged[] = "ack_orphan";
// Indicates whether to show an install warning when the user enables.
const char kExtensionDidEscalatePermissions[] = "install_warning_on_enable";
+// Any errors that arose from unmet unmet requirements.
Aaron Boodman 2012/08/01 03:58:54 duplicate 'unmet'
eaugusti 2012/08/03 01:06:26 Done.
+const char kUnsupportedRequirements[] = "unsupported_requirements";
+
// Indicates whether the extension was updated while it was disabled.
const char kPrefDisableReason[] = "disable_reason";
@@ -624,7 +627,7 @@ bool ExtensionPrefs::IsAppNotificationDisabled(
}
void ExtensionPrefs::SetAppNotificationDisabled(
- const std::string& extension_id, bool value) {
+ const std::string& extension_id, bool value) {
DCHECK(Extension::IdIsValid(extension_id));
UpdateExtensionPref(extension_id, kPrefAppNotificationDisbaled,
Value::CreateBooleanValue(value));
@@ -641,7 +644,6 @@ std::string ExtensionPrefs::GetDebugPolicyProviderName() const {
bool ExtensionPrefs::UserMayLoad(const Extension* extension,
string16* error) const {
-
Aaron Boodman 2012/08/01 03:58:54 stray edit
eaugusti 2012/08/03 01:06:26 Done.
const base::ListValue* blacklist =
prefs_->GetList(prefs::kExtensionInstallDenyList);
const base::ListValue* whitelist =
@@ -677,6 +679,44 @@ void ExtensionPrefs::SetDidExtensionEscalatePermissions(
Value::CreateBooleanValue(did_escalate));
}
+bool ExtensionPrefs::HasUnsupportedRequirements(
+ const std::string& extension_id) {
+ const ListValue* requirement_errors = NULL;
+ return ReadExtensionPrefList(extension_id,
+ kUnsupportedRequirements,
+ &requirement_errors);
+}
+
+void ExtensionPrefs::ClearUnsupportedRequirements(
+ const std::string& extension_id) {
+ UpdateExtensionPref(extension_id, kUnsupportedRequirements, NULL);
+}
+
+void ExtensionPrefs::SetUnsupportedRequirements(
+ const std::string& extension_id,
+ std::vector<std::string> requirement_errors) {
+ ListValue* errors_list = new ListValue();
Aaron Boodman 2012/08/01 03:58:54 Are there other functions in this class doing the
eaugusti 2012/08/03 01:06:26 No one uses this exact functionality, but I can st
+ std::vector<std::string>::iterator it;
+ for (it = requirement_errors.begin(); it != requirement_errors.end(); ++it)
+ errors_list->Append(Value::CreateStringValue(*it));
+ UpdateExtensionPref(extension_id, kUnsupportedRequirements, errors_list);
+}
+
+std::vector<std::string> ExtensionPrefs::GetUnsupportedRequirements(
+ const std::string& extension_id) {
+ std::vector<std::string> requirement_errors;
+ const ListValue* errors = NULL;
+ if (ReadExtensionPrefList(extension_id, kUnsupportedRequirements,
Aaron Boodman 2012/08/01 03:58:54 Same comment about potentially pulling out duplica
eaugusti 2012/08/03 01:06:26 Done.
+ &errors)) {
+ for (size_t i = 0; i < errors->GetSize(); ++i) {
+ std::string requirement_error;
+ if (errors->GetString(i, &requirement_error))
+ requirement_errors.push_back(requirement_error);
+ }
+ }
+ return requirement_errors;
+}
+
Extension::DisableReason ExtensionPrefs::GetDisableReason(
const std::string& extension_id) {
int value = -1;
@@ -833,7 +873,6 @@ void ExtensionPrefs::MigratePermissions(const ExtensionIdSet& extension_ids) {
PermissionsInfo* info = PermissionsInfo::GetInstance();
for (ExtensionIdSet::const_iterator ext_id =
extension_ids.begin(); ext_id != extension_ids.end(); ++ext_id) {
-
// An extension's granted permissions need to be migrated if the
Aaron Boodman 2012/08/01 03:58:54 stray edit
eaugusti 2012/08/03 01:06:26 Done.
// full_access bit is present. This bit was always present in the previous
// scheme and is never present now.

Powered by Google App Engine
This is Rietveld 408576698