summaryrefslogtreecommitdiffstats
path: root/extensions/common/permissions
diff options
context:
space:
mode:
authortreib <treib@chromium.org>2015-09-24 09:50:16 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-24 16:52:18 +0000
commitb443d6098d9dc4f69b1f2ad9ac1628931481222e (patch)
tree678544148de5a1e689e0936edc733ffd8a294d8c /extensions/common/permissions
parent91bd4b5ebf5df7bcfdc1a707d2ef551022f95df7 (diff)
downloadchromium_src-b443d6098d9dc4f69b1f2ad9ac1628931481222e.zip
chromium_src-b443d6098d9dc4f69b1f2ad9ac1628931481222e.tar.gz
chromium_src-b443d6098d9dc4f69b1f2ad9ac1628931481222e.tar.bz2
Workaround to suppress spurious permission popup for searchProvider permission.
Followup to https://codereview.chromium.org/1347043003/ Also fix PermissionIDSet::erase. BUG=533086 Review URL: https://codereview.chromium.org/1363873002 Cr-Commit-Position: refs/heads/master@{#350577}
Diffstat (limited to 'extensions/common/permissions')
-rw-r--r--extensions/common/permissions/api_permission_set.cc8
-rw-r--r--extensions/common/permissions/api_permission_set.h1
-rw-r--r--extensions/common/permissions/settings_override_permission.cc9
3 files changed, 16 insertions, 2 deletions
diff --git a/extensions/common/permissions/api_permission_set.cc b/extensions/common/permissions/api_permission_set.cc
index 9f6df2f..5093f2e 100644
--- a/extensions/common/permissions/api_permission_set.cc
+++ b/extensions/common/permissions/api_permission_set.cc
@@ -216,7 +216,13 @@ void PermissionIDSet::InsertAll(const PermissionIDSet& permission_set) {
}
void PermissionIDSet::erase(APIPermission::ID permission_id) {
- permissions_.erase(PermissionID(permission_id));
+ auto lower_bound = permissions_.lower_bound(PermissionID(permission_id));
+ auto upper_bound = lower_bound;
+ while (upper_bound != permissions_.end() &&
+ upper_bound->id() == permission_id) {
+ ++upper_bound;
+ }
+ permissions_.erase(lower_bound, upper_bound);
}
std::vector<base::string16> PermissionIDSet::GetAllPermissionParameters()
diff --git a/extensions/common/permissions/api_permission_set.h b/extensions/common/permissions/api_permission_set.h
index a596a0e..bcb371b 100644
--- a/extensions/common/permissions/api_permission_set.h
+++ b/extensions/common/permissions/api_permission_set.h
@@ -123,6 +123,7 @@ class PermissionIDSet {
const base::string16& permission_parameter);
void InsertAll(const PermissionIDSet& permission_set);
+ // Erases all permissions with the given id.
void erase(APIPermission::ID permission_id);
// Returns the parameters for all PermissionIDs in this set.
diff --git a/extensions/common/permissions/settings_override_permission.cc b/extensions/common/permissions/settings_override_permission.cc
index f3641bd..7756c5e 100644
--- a/extensions/common/permissions/settings_override_permission.cc
+++ b/extensions/common/permissions/settings_override_permission.cc
@@ -48,7 +48,14 @@ bool SettingsOverrideAPIPermission::FromValue(
const base::Value* value,
std::string* /*error*/,
std::vector<std::string>* unhandled_permissions) {
- return value && value->GetAsString(&setting_value_);
+ // Ugly hack: |value| being null should be an error. But before M46 beta, we
+ // didn't store the parameter for settings override permissions in prefs.
+ // See crbug.com/533086.
+ // TODO(treib,devlin): Remove this for M48, when hopefully all users will have
+ // updated prefs.
+ // This should read:
+ // return value && value->GetAsString(&setting_value_);
+ return !value || value->GetAsString(&setting_value_);
}
scoped_ptr<base::Value> SettingsOverrideAPIPermission::ToValue() const {