OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/browser/usb/usb_chooser_bubble_delegate.h" | 5 #include "chrome/browser/usb/usb_chooser_bubble_delegate.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
11 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/usb/usb_chooser_context.h" | 13 #include "chrome/browser/usb/usb_chooser_context.h" |
13 #include "chrome/browser/usb/usb_chooser_context_factory.h" | 14 #include "chrome/browser/usb/usb_chooser_context_factory.h" |
14 #include "components/bubble/bubble_controller.h" | 15 #include "components/bubble/bubble_controller.h" |
15 #include "content/public/browser/render_frame_host.h" | 16 #include "content/public/browser/render_frame_host.h" |
16 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
17 #include "device/core/device_client.h" | 18 #include "device/core/device_client.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 Profile* profile = | 94 Profile* profile = |
94 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 95 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
95 UsbChooserContext* chooser_context = | 96 UsbChooserContext* chooser_context = |
96 UsbChooserContextFactory::GetForProfile(profile); | 97 UsbChooserContextFactory::GetForProfile(profile); |
97 chooser_context->GrantDevicePermission( | 98 chooser_context->GrantDevicePermission( |
98 render_frame_host_->GetLastCommittedURL().GetOrigin(), embedding_origin, | 99 render_frame_host_->GetLastCommittedURL().GetOrigin(), embedding_origin, |
99 devices_[idx]->guid()); | 100 devices_[idx]->guid()); |
100 | 101 |
101 device::usb::DeviceInfoPtr device_info_ptr = | 102 device::usb::DeviceInfoPtr device_info_ptr = |
102 device::usb::DeviceInfo::From(*devices_[idx]); | 103 device::usb::DeviceInfo::From(*devices_[idx]); |
103 callback_.Run(device_info_ptr.Pass()); | 104 callback_.Run(std::move(device_info_ptr)); |
104 } else { | 105 } else { |
105 callback_.Run(nullptr); | 106 callback_.Run(nullptr); |
106 } | 107 } |
107 callback_.reset(); // Reset |callback_| so that it is only run once. | 108 callback_.reset(); // Reset |callback_| so that it is only run once. |
108 | 109 |
109 if (bubble_controller_) | 110 if (bubble_controller_) |
110 bubble_controller_->CloseBubble(BUBBLE_CLOSE_ACCEPTED); | 111 bubble_controller_->CloseBubble(BUBBLE_CLOSE_ACCEPTED); |
111 } | 112 } |
112 | 113 |
113 void UsbChooserBubbleDelegate::Cancel() { | 114 void UsbChooserBubbleDelegate::Cancel() { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 } | 158 } |
158 } | 159 } |
159 if (observer()) | 160 if (observer()) |
160 observer()->OnOptionsInitialized(); | 161 observer()->OnOptionsInitialized(); |
161 } | 162 } |
162 | 163 |
163 void UsbChooserBubbleDelegate::set_bubble_controller( | 164 void UsbChooserBubbleDelegate::set_bubble_controller( |
164 BubbleReference bubble_controller) { | 165 BubbleReference bubble_controller) { |
165 bubble_controller_ = bubble_controller; | 166 bubble_controller_ = bubble_controller; |
166 } | 167 } |
OLD | NEW |