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) override { OnDevicesChanged(); } |
| 111 |
| 112 void OnDeviceRemoved(size_t index) override { OnDevicesChanged(); } |
| 113 |
| 114 private: |
| 115 void OnDevicesChanged() { |
111 for (size_t i = 0; i < prompt()->GetDeviceCount(); ++i) { | 116 for (size_t i = 0; i < prompt()->GetDeviceCount(); ++i) { |
112 prompt()->GrantDevicePermission(i); | 117 prompt()->GrantDevicePermission(i); |
113 if (!prompt()->multiple()) { | 118 if (!prompt()->multiple()) { |
114 break; | 119 break; |
115 } | 120 } |
116 } | 121 } |
117 prompt()->Dismissed(); | 122 prompt()->Dismissed(); |
118 } | 123 } |
119 }; | 124 }; |
120 | 125 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 277 |
273 TestExtensionsAPIClient test_api_client; | 278 TestExtensionsAPIClient test_api_client; |
274 ASSERT_TRUE(LoadApp("api_test/usb/get_user_selected_devices")); | 279 ASSERT_TRUE(LoadApp("api_test/usb/get_user_selected_devices")); |
275 ASSERT_TRUE(ready_listener.WaitUntilSatisfied()); | 280 ASSERT_TRUE(ready_listener.WaitUntilSatisfied()); |
276 | 281 |
277 device_client_->usb_service()->RemoveDevice(mock_device_); | 282 device_client_->usb_service()->RemoveDevice(mock_device_); |
278 ASSERT_TRUE(result_listener.WaitUntilSatisfied()); | 283 ASSERT_TRUE(result_listener.WaitUntilSatisfied()); |
279 } | 284 } |
280 | 285 |
281 } // namespace extensions | 286 } // namespace extensions |
OLD | NEW |