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

Side by Side Diff: chrome/common/extensions/permissions/chrome_permission_message_provider_unittest.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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_HISTORY_READ), 124 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_HISTORY_READ),
125 message0.message()); 125 message0.message());
126 EXPECT_TRUE(message0.submessages().empty()); 126 EXPECT_TRUE(message0.submessages().empty());
127 const PermissionMessage& message1 = *it++; 127 const PermissionMessage& message1 = *it++;
128 EXPECT_EQ( 128 EXPECT_EQ(
129 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_USB_DEVICE_LIST), 129 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_USB_DEVICE_LIST),
130 message1.message()); 130 message1.message());
131 EXPECT_FALSE(message1.submessages().empty()); 131 EXPECT_FALSE(message1.submessages().empty());
132 } 132 }
133 133
134 // Anti-test: Check that adding a parameter to a SettingsOverridePermission
135 // doesn't trigger a privilege increase. This is because prior to M46 beta, we
136 // failed to store the parameter in the granted_permissions pref. Now we do, and
137 // we don't want to bother every user with a spurious permissions warning.
138 // See crbug.com/533086 and crbug.com/619759.
139 // TODO(treib,devlin): Remove this for M56, when hopefully all users will have
140 // updated prefs.
141 TEST_F(ChromePermissionMessageProviderUnittest,
142 EvilHackToSuppressSettingsOverrideParameter) {
143 const APIPermissionInfo* info =
144 PermissionsInfo::GetInstance()->GetByID(APIPermission::kSearchProvider);
145
146 APIPermissionSet granted_permissions;
147 granted_permissions.insert(new SettingsOverrideAPIPermission(info));
148
149 APIPermissionSet actual_permissions;
150 actual_permissions.insert(new SettingsOverrideAPIPermission(info, "a.com"));
151
152 EXPECT_FALSE(IsPrivilegeIncrease(granted_permissions, actual_permissions));
153
154 // Just to be safe: Adding the permission (with or without parameter) should
155 // still be considered a privilege escalation.
156 EXPECT_TRUE(IsPrivilegeIncrease(APIPermissionSet(), granted_permissions));
157 EXPECT_TRUE(IsPrivilegeIncrease(APIPermissionSet(), actual_permissions));
158 }
159
134 } // namespace extensions 160 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698