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

Unified Diff: chrome/common/extensions/permissions/set_disjunction_permission.h

Issue 141743005: Extensions: Make it possible for permission parsing code to return a detailed error message. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 11 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/common/extensions/permissions/set_disjunction_permission.h
===================================================================
--- chrome/common/extensions/permissions/set_disjunction_permission.h (revision 247036)
+++ chrome/common/extensions/permissions/set_disjunction_permission.h (working copy)
@@ -110,24 +110,29 @@
return result->data_set_.empty() ? NULL : result.release();
}
- virtual bool FromValue(const base::Value* value) OVERRIDE {
+ virtual bool FromValue(const base::Value* value,
+ std::string* error) OVERRIDE {
data_set_.clear();
const base::ListValue* list = NULL;
- if (!value)
+ if (!value || !value->GetAsList(&list) || list->GetSize() == 0) {
+ if (error)
+ *error = "NULL or empty permission list";
return false;
+ }
- if (!value->GetAsList(&list) || list->GetSize() == 0)
- return false;
-
for (size_t i = 0; i < list->GetSize(); ++i) {
- const base::Value* item_value;
- if (!list->Get(i, &item_value))
- return false;
+ const base::Value* item_value = NULL;
+ bool got_item = list->Get(i, &item_value);
+ DCHECK(got_item);
+ DCHECK(item_value);
PermissionDataType data;
- if (!data.FromValue(item_value))
+ if (!data.FromValue(item_value)) {
+ if (error)
+ *error = "Cannot parse an item from the permission list";
return false;
+ }
data_set_.insert(data);
}

Powered by Google App Engine
This is Rietveld 408576698