| 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, const base::string16& device_name) override { |
| 137 OnDevicesChanged(); |
| 138 } |
| 139 |
| 140 void OnDeviceRemoved(size_t index, |
| 141 const base::string16& device_name) override { |
| 142 OnDevicesChanged(); |
| 143 } |
| 144 |
| 145 private: |
| 146 void OnDevicesChanged() { |
| 137 for (size_t i = 0; i < prompt()->GetDeviceCount(); ++i) { | 147 for (size_t i = 0; i < prompt()->GetDeviceCount(); ++i) { |
| 138 prompt()->GrantDevicePermission(i); | 148 prompt()->GrantDevicePermission(i); |
| 139 if (!prompt()->multiple()) { | 149 if (!prompt()->multiple()) { |
| 140 break; | 150 break; |
| 141 } | 151 } |
| 142 } | 152 } |
| 143 prompt()->Dismissed(); | 153 prompt()->Dismissed(); |
| 144 } | 154 } |
| 145 }; | 155 }; |
| 146 | 156 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 ExtensionTestMessageListener remove_listener("removed", false); | 268 ExtensionTestMessageListener remove_listener("removed", false); |
| 259 device_client_->hid_service()->RemoveDevice(kTestDeviceIds[0]); | 269 device_client_->hid_service()->RemoveDevice(kTestDeviceIds[0]); |
| 260 ASSERT_TRUE(remove_listener.WaitUntilSatisfied()); | 270 ASSERT_TRUE(remove_listener.WaitUntilSatisfied()); |
| 261 | 271 |
| 262 ExtensionTestMessageListener add_listener("added", false); | 272 ExtensionTestMessageListener add_listener("added", false); |
| 263 AddDevice(kTestDeviceIds[0], 0x18D1, 0x58F0, true); | 273 AddDevice(kTestDeviceIds[0], 0x18D1, 0x58F0, true); |
| 264 ASSERT_TRUE(add_listener.WaitUntilSatisfied()); | 274 ASSERT_TRUE(add_listener.WaitUntilSatisfied()); |
| 265 } | 275 } |
| 266 | 276 |
| 267 } // namespace extensions | 277 } // namespace extensions |
| OLD | NEW |