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

Unified Diff: chrome/common/extensions/permissions/chrome_permission_message_provider.cc

Issue 1300353002: Make USB permissions work in the new permission message system (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kill_permissionmessage
Patch Set: review Created 5 years, 4 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/chrome_permission_message_provider.cc
diff --git a/chrome/common/extensions/permissions/chrome_permission_message_provider.cc b/chrome/common/extensions/permissions/chrome_permission_message_provider.cc
index 5f65cab982ce979aa31500c9ab71653dc04c6808..2522a66d87d026e35eb92778e5ab26a6161b18f5 100644
--- a/chrome/common/extensions/permissions/chrome_permission_message_provider.cc
+++ b/chrome/common/extensions/permissions/chrome_permission_message_provider.cc
@@ -67,8 +67,15 @@ ChromePermissionMessageProvider::GetPermissionMessages(
PermissionIDSet remaining_permissions = permissions;
CoalescedPermissionMessages messages;
for (const auto& rule : rules) {
- // Only apply the rule if we have all the required permission IDs.
- if (remaining_permissions.ContainsAllIDs(rule.required_permissions())) {
+ // Only apply the rule if we have all the required permission IDs. If the
+ // rule has no required IDs, then apply it only if any of the optional ones
+ // are there.
+ bool has_required_permissions = !rule.required_permissions().empty();
+ bool use_rule =
+ has_required_permissions
+ ? remaining_permissions.ContainsAllIDs(rule.required_permissions())
+ : remaining_permissions.ContainsAnyID(rule.optional_permissions());
+ if (use_rule) {
// We can apply the rule. Add all the required permissions, and as many
// optional permissions as we can, to the new message.
PermissionIDSet used_permissions =

Powered by Google App Engine
This is Rietveld 408576698