| 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 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 : public DevicePermissionsPrompt, | 126 : public DevicePermissionsPrompt, |
| 127 public DevicePermissionsPrompt::Prompt::Observer { | 127 public DevicePermissionsPrompt::Prompt::Observer { |
| 128 public: | 128 public: |
| 129 explicit TestDevicePermissionsPrompt(content::WebContents* web_contents) | 129 explicit TestDevicePermissionsPrompt(content::WebContents* web_contents) |
| 130 : DevicePermissionsPrompt(web_contents) {} | 130 : DevicePermissionsPrompt(web_contents) {} |
| 131 | 131 |
| 132 ~TestDevicePermissionsPrompt() override { prompt()->SetObserver(nullptr); } | 132 ~TestDevicePermissionsPrompt() override { prompt()->SetObserver(nullptr); } |
| 133 | 133 |
| 134 void ShowDialog() override { prompt()->SetObserver(this); } | 134 void ShowDialog() override { prompt()->SetObserver(this); } |
| 135 | 135 |
| 136 void OnDevicesChanged() override { | 136 void OnDeviceAdded(size_t index) override { OnDevicesChanged(); } |
| 137 |
| 138 void OnDeviceRemoved(size_t index) override { OnDevicesChanged(); } |
| 139 |
| 140 private: |
| 141 void OnDevicesChanged() { |
| 137 for (size_t i = 0; i < prompt()->GetDeviceCount(); ++i) { | 142 for (size_t i = 0; i < prompt()->GetDeviceCount(); ++i) { |
| 138 prompt()->GrantDevicePermission(i); | 143 prompt()->GrantDevicePermission(i); |
| 139 if (!prompt()->multiple()) { | 144 if (!prompt()->multiple()) { |
| 140 break; | 145 break; |
| 141 } | 146 } |
| 142 } | 147 } |
| 143 prompt()->Dismissed(); | 148 prompt()->Dismissed(); |
| 144 } | 149 } |
| 145 }; | 150 }; |
| 146 | 151 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 ExtensionTestMessageListener remove_listener("removed", false); | 263 ExtensionTestMessageListener remove_listener("removed", false); |
| 259 device_client_->hid_service()->RemoveDevice(kTestDeviceIds[0]); | 264 device_client_->hid_service()->RemoveDevice(kTestDeviceIds[0]); |
| 260 ASSERT_TRUE(remove_listener.WaitUntilSatisfied()); | 265 ASSERT_TRUE(remove_listener.WaitUntilSatisfied()); |
| 261 | 266 |
| 262 ExtensionTestMessageListener add_listener("added", false); | 267 ExtensionTestMessageListener add_listener("added", false); |
| 263 AddDevice(kTestDeviceIds[0], 0x18D1, 0x58F0, true); | 268 AddDevice(kTestDeviceIds[0], 0x18D1, 0x58F0, true); |
| 264 ASSERT_TRUE(add_listener.WaitUntilSatisfied()); | 269 ASSERT_TRUE(add_listener.WaitUntilSatisfied()); |
| 265 } | 270 } |
| 266 | 271 |
| 267 } // namespace extensions | 272 } // namespace extensions |
| OLD | NEW |