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

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

Issue 2418353002: Allow interfaceClass USB device permissions (Closed)
Patch Set: . Created 4 years, 1 month 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 TEST_F(ChromePermissionMessageProviderUnittest, 99 TEST_F(ChromePermissionMessageProviderUnittest,
100 WarningsAndDetailsCoalesceTogether) { 100 WarningsAndDetailsCoalesceTogether) {
101 // kTab and kTopSites should be merged into a single message. 101 // kTab and kTopSites should be merged into a single message.
102 APIPermissionSet permissions; 102 APIPermissionSet permissions;
103 permissions.insert(APIPermission::kTab); 103 permissions.insert(APIPermission::kTab);
104 permissions.insert(APIPermission::kTopSites); 104 permissions.insert(APIPermission::kTopSites);
105 // The USB device permission message has a non-empty details string. 105 // The USB device permission message has a non-empty details string.
106 std::unique_ptr<UsbDevicePermission> usb(new UsbDevicePermission( 106 std::unique_ptr<UsbDevicePermission> usb(new UsbDevicePermission(
107 PermissionsInfo::GetInstance()->GetByID(APIPermission::kUsbDevice))); 107 PermissionsInfo::GetInstance()->GetByID(APIPermission::kUsbDevice)));
108 std::unique_ptr<base::ListValue> devices_list(new base::ListValue()); 108 std::unique_ptr<base::ListValue> devices_list(new base::ListValue());
109 devices_list->Append(UsbDevicePermissionData(0x02ad, 0x138c, -1).ToValue()); 109 devices_list->Append(
110 devices_list->Append(UsbDevicePermissionData(0x02ad, 0x138d, -1).ToValue()); 110 UsbDevicePermissionData(0x02ad, 0x138c, -1, -1).ToValue());
111 devices_list->Append(
112 UsbDevicePermissionData(0x02ad, 0x138d, -1, -1).ToValue());
111 ASSERT_TRUE(usb->FromValue(devices_list.get(), nullptr, nullptr)); 113 ASSERT_TRUE(usb->FromValue(devices_list.get(), nullptr, nullptr));
112 permissions.insert(usb.release()); 114 permissions.insert(usb.release());
113 115
114 PermissionMessages messages = 116 PermissionMessages messages =
115 GetMessages(permissions, Manifest::TYPE_EXTENSION); 117 GetMessages(permissions, Manifest::TYPE_EXTENSION);
116 118
117 ASSERT_EQ(2U, messages.size()); 119 ASSERT_EQ(2U, messages.size());
118 auto it = messages.begin(); 120 auto it = messages.begin();
119 const PermissionMessage& message0 = *it++; 121 const PermissionMessage& message0 = *it++;
120 EXPECT_EQ( 122 EXPECT_EQ(
(...skipping 27 matching lines...) Expand all
148 150
149 EXPECT_FALSE(IsPrivilegeIncrease(granted_permissions, actual_permissions)); 151 EXPECT_FALSE(IsPrivilegeIncrease(granted_permissions, actual_permissions));
150 152
151 // Just to be safe: Adding the permission (with or without parameter) should 153 // Just to be safe: Adding the permission (with or without parameter) should
152 // still be considered a privilege escalation. 154 // still be considered a privilege escalation.
153 EXPECT_TRUE(IsPrivilegeIncrease(APIPermissionSet(), granted_permissions)); 155 EXPECT_TRUE(IsPrivilegeIncrease(APIPermissionSet(), granted_permissions));
154 EXPECT_TRUE(IsPrivilegeIncrease(APIPermissionSet(), actual_permissions)); 156 EXPECT_TRUE(IsPrivilegeIncrease(APIPermissionSet(), actual_permissions));
155 } 157 }
156 158
157 } // namespace extensions 159 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/print_preview/extension_printer_handler.cc ('k') | device/usb/mock_usb_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698