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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <numeric> | 7 #include <numeric> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 class TestDevicePermissionsPrompt | 101 class TestDevicePermissionsPrompt |
102 : public DevicePermissionsPrompt, | 102 : public DevicePermissionsPrompt, |
103 public DevicePermissionsPrompt::Prompt::Observer { | 103 public DevicePermissionsPrompt::Prompt::Observer { |
104 public: | 104 public: |
105 explicit TestDevicePermissionsPrompt(content::WebContents* web_contents) | 105 explicit TestDevicePermissionsPrompt(content::WebContents* web_contents) |
106 : DevicePermissionsPrompt(web_contents) {} | 106 : DevicePermissionsPrompt(web_contents) {} |
107 | 107 |
108 void ShowDialog() override { prompt()->SetObserver(this); } | 108 void ShowDialog() override { prompt()->SetObserver(this); } |
109 | 109 |
110 void OnDevicesChanged() override { | 110 void OnDeviceAdded(size_t index, const base::string16& device_name) override { |
| 111 OnDevicesChanged(); |
| 112 } |
| 113 |
| 114 void OnDeviceRemoved(size_t index, |
| 115 const base::string16& device_name) override { |
| 116 OnDevicesChanged(); |
| 117 } |
| 118 |
| 119 private: |
| 120 void OnDevicesChanged() { |
111 for (size_t i = 0; i < prompt()->GetDeviceCount(); ++i) { | 121 for (size_t i = 0; i < prompt()->GetDeviceCount(); ++i) { |
112 prompt()->GrantDevicePermission(i); | 122 prompt()->GrantDevicePermission(i); |
113 if (!prompt()->multiple()) { | 123 if (!prompt()->multiple()) { |
114 break; | 124 break; |
115 } | 125 } |
116 } | 126 } |
117 prompt()->Dismissed(); | 127 prompt()->Dismissed(); |
118 } | 128 } |
119 }; | 129 }; |
120 | 130 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 282 |
273 TestExtensionsAPIClient test_api_client; | 283 TestExtensionsAPIClient test_api_client; |
274 ASSERT_TRUE(LoadApp("api_test/usb/get_user_selected_devices")); | 284 ASSERT_TRUE(LoadApp("api_test/usb/get_user_selected_devices")); |
275 ASSERT_TRUE(ready_listener.WaitUntilSatisfied()); | 285 ASSERT_TRUE(ready_listener.WaitUntilSatisfied()); |
276 | 286 |
277 device_client_->usb_service()->RemoveDevice(mock_device_); | 287 device_client_->usb_service()->RemoveDevice(mock_device_); |
278 ASSERT_TRUE(result_listener.WaitUntilSatisfied()); | 288 ASSERT_TRUE(result_listener.WaitUntilSatisfied()); |
279 } | 289 } |
280 | 290 |
281 } // namespace extensions | 291 } // namespace extensions |
OLD | NEW |