| OLD | NEW |
| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 TEST_F(ChromePermissionMessageProviderUnittest, | 100 TEST_F(ChromePermissionMessageProviderUnittest, |
| 101 WarningsAndDetailsCoalesceTogether) { | 101 WarningsAndDetailsCoalesceTogether) { |
| 102 // kTab and kTopSites should be merged into a single message. | 102 // kTab and kTopSites should be merged into a single message. |
| 103 APIPermissionSet permissions; | 103 APIPermissionSet permissions; |
| 104 permissions.insert(APIPermission::kTab); | 104 permissions.insert(APIPermission::kTab); |
| 105 permissions.insert(APIPermission::kTopSites); | 105 permissions.insert(APIPermission::kTopSites); |
| 106 // The USB device permission message has a non-empty details string. | 106 // The USB device permission message has a non-empty details string. |
| 107 std::unique_ptr<UsbDevicePermission> usb(new UsbDevicePermission( | 107 std::unique_ptr<UsbDevicePermission> usb(new UsbDevicePermission( |
| 108 PermissionsInfo::GetInstance()->GetByID(APIPermission::kUsbDevice))); | 108 PermissionsInfo::GetInstance()->GetByID(APIPermission::kUsbDevice))); |
| 109 std::unique_ptr<base::ListValue> devices_list(new base::ListValue()); | 109 std::unique_ptr<base::ListValue> devices_list(new base::ListValue()); |
| 110 devices_list->Append( | 110 devices_list->Append(UsbDevicePermissionData(0x02ad, 0x138c, -1).ToValue()); |
| 111 UsbDevicePermissionData(0x02ad, 0x138c, -1).ToValue().release()); | 111 devices_list->Append(UsbDevicePermissionData(0x02ad, 0x138d, -1).ToValue()); |
| 112 devices_list->Append( | |
| 113 UsbDevicePermissionData(0x02ad, 0x138d, -1).ToValue().release()); | |
| 114 ASSERT_TRUE(usb->FromValue(devices_list.get(), nullptr, nullptr)); | 112 ASSERT_TRUE(usb->FromValue(devices_list.get(), nullptr, nullptr)); |
| 115 permissions.insert(usb.release()); | 113 permissions.insert(usb.release()); |
| 116 | 114 |
| 117 PermissionMessages messages = | 115 PermissionMessages messages = |
| 118 GetMessages(permissions, Manifest::TYPE_EXTENSION); | 116 GetMessages(permissions, Manifest::TYPE_EXTENSION); |
| 119 | 117 |
| 120 ASSERT_EQ(2U, messages.size()); | 118 ASSERT_EQ(2U, messages.size()); |
| 121 auto it = messages.begin(); | 119 auto it = messages.begin(); |
| 122 const PermissionMessage& message0 = *it++; | 120 const PermissionMessage& message0 = *it++; |
| 123 EXPECT_EQ( | 121 EXPECT_EQ( |
| 124 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_HISTORY_READ), | 122 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_HISTORY_READ), |
| 125 message0.message()); | 123 message0.message()); |
| 126 EXPECT_TRUE(message0.submessages().empty()); | 124 EXPECT_TRUE(message0.submessages().empty()); |
| 127 const PermissionMessage& message1 = *it++; | 125 const PermissionMessage& message1 = *it++; |
| 128 EXPECT_EQ( | 126 EXPECT_EQ( |
| 129 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_USB_DEVICE_LIST), | 127 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_USB_DEVICE_LIST), |
| 130 message1.message()); | 128 message1.message()); |
| 131 EXPECT_FALSE(message1.submessages().empty()); | 129 EXPECT_FALSE(message1.submessages().empty()); |
| 132 } | 130 } |
| 133 | 131 |
| 134 } // namespace extensions | 132 } // namespace extensions |
| OLD | NEW |