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

Side by Side Diff: chrome/common/extensions/permissions/chrome_permission_message_provider.cc

Issue 2086523002: Reinstate evil hack to suppress permission warnings for searchProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/common/extensions/permissions/chrome_permission_message_provider_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/extensions/permissions/chrome_permission_message_provide r.h" 5 #include "chrome/common/extensions/permissions/chrome_permission_message_provide r.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 26 matching lines...) Expand all
37 if (msg_->message() > rhs.msg_->message()) 37 if (msg_->message() > rhs.msg_->message())
38 return false; 38 return false;
39 return msg_->submessages() < rhs.msg_->submessages(); 39 return msg_->submessages() < rhs.msg_->submessages();
40 } 40 }
41 41
42 private: 42 private:
43 const PermissionMessage* msg_; 43 const PermissionMessage* msg_;
44 }; 44 };
45 using ComparablePermissions = std::vector<ComparablePermission>; 45 using ComparablePermissions = std::vector<ComparablePermission>;
46 46
47 void DropPermissionParameter(APIPermission::ID id,
48 PermissionIDSet* permissions) {
49 if (permissions->ContainsID(id)) {
50 // Erase the permission, and insert it again without a parameter.
51 permissions->erase(id);
52 permissions->insert(id);
53 }
54 }
55
47 } // namespace 56 } // namespace
48 57
49 typedef std::set<PermissionMessage> PermissionMsgSet; 58 typedef std::set<PermissionMessage> PermissionMsgSet;
50 59
51 ChromePermissionMessageProvider::ChromePermissionMessageProvider() { 60 ChromePermissionMessageProvider::ChromePermissionMessageProvider() {
52 } 61 }
53 62
54 ChromePermissionMessageProvider::~ChromePermissionMessageProvider() { 63 ChromePermissionMessageProvider::~ChromePermissionMessageProvider() {
55 } 64 }
56 65
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 bool ChromePermissionMessageProvider::IsAPIOrManifestPrivilegeIncrease( 178 bool ChromePermissionMessageProvider::IsAPIOrManifestPrivilegeIncrease(
170 const PermissionSet& old_permissions, 179 const PermissionSet& old_permissions,
171 const PermissionSet& new_permissions) const { 180 const PermissionSet& new_permissions) const {
172 PermissionIDSet old_ids; 181 PermissionIDSet old_ids;
173 AddAPIPermissions(old_permissions, &old_ids); 182 AddAPIPermissions(old_permissions, &old_ids);
174 AddManifestPermissions(old_permissions, &old_ids); 183 AddManifestPermissions(old_permissions, &old_ids);
175 PermissionIDSet new_ids; 184 PermissionIDSet new_ids;
176 AddAPIPermissions(new_permissions, &new_ids); 185 AddAPIPermissions(new_permissions, &new_ids);
177 AddManifestPermissions(new_permissions, &new_ids); 186 AddManifestPermissions(new_permissions, &new_ids);
178 187
188 // Ugly hack: Before M46 beta, we didn't store the parameter for settings
189 // override permissions in prefs (which is where |old_permissions| is coming
190 // from). To avoid a spurious permission increase warning, drop the parameter.
191 // See crbug.com/533086 and crbug.com/619759.
192 // TODO(treib,devlin): Remove this for M56, when hopefully all users will have
193 // updated prefs.
194 const APIPermission::ID kSettingsOverrideIDs[] = {
195 APIPermission::kHomepage, APIPermission::kSearchProvider,
196 APIPermission::kStartupPages};
197 for (auto id : kSettingsOverrideIDs) {
198 DropPermissionParameter(id, &old_ids);
199 DropPermissionParameter(id, &new_ids);
200 }
201
179 // If all the IDs were already there, it's not a privilege increase. 202 // If all the IDs were already there, it's not a privilege increase.
180 if (old_ids.Includes(new_ids)) 203 if (old_ids.Includes(new_ids))
181 return false; 204 return false;
182 205
183 // Otherwise, check the actual messages - not all IDs result in a message, 206 // Otherwise, check the actual messages - not all IDs result in a message,
184 // and some messages can suppress others. 207 // and some messages can suppress others.
185 PermissionMessages old_messages = GetPermissionMessages(old_ids); 208 PermissionMessages old_messages = GetPermissionMessages(old_ids);
186 PermissionMessages new_messages = GetPermissionMessages(new_ids); 209 PermissionMessages new_messages = GetPermissionMessages(new_ids);
187 210
188 ComparablePermissions old_strings(old_messages.begin(), old_messages.end()); 211 ComparablePermissions old_strings(old_messages.begin(), old_messages.end());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 std::set<std::string> old_hosts_set( 246 std::set<std::string> old_hosts_set(
224 permission_message_util::GetDistinctHosts(old_list, false, false)); 247 permission_message_util::GetDistinctHosts(old_list, false, false));
225 std::set<std::string> new_hosts_only = 248 std::set<std::string> new_hosts_only =
226 base::STLSetDifference<std::set<std::string> >(new_hosts_set, 249 base::STLSetDifference<std::set<std::string> >(new_hosts_set,
227 old_hosts_set); 250 old_hosts_set);
228 251
229 return !new_hosts_only.empty(); 252 return !new_hosts_only.empty();
230 } 253 }
231 254
232 } // namespace extensions 255 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/permissions/chrome_permission_message_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698