Chromium Code Reviews| 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 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/usb/usb_chooser_context.h" | 14 #include "chrome/browser/usb/usb_chooser_context.h" |
| 15 #include "chrome/browser/usb/usb_chooser_context_factory.h" | 15 #include "chrome/browser/usb/usb_chooser_context_factory.h" |
| 16 #include "chrome/common/url_constants.h" | |
| 16 #include "components/bubble/bubble_controller.h" | 17 #include "components/bubble/bubble_controller.h" |
| 17 #include "content/public/browser/render_frame_host.h" | 18 #include "content/public/browser/render_frame_host.h" |
| 18 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| 19 #include "device/core/device_client.h" | 20 #include "device/core/device_client.h" |
| 20 #include "device/usb/mojo/type_converters.h" | 21 #include "device/usb/mojo/type_converters.h" |
| 21 #include "device/usb/usb_device.h" | 22 #include "device/usb/usb_device.h" |
| 22 #include "device/usb/usb_device_filter.h" | 23 #include "device/usb/usb_device_filter.h" |
| 23 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 if (device::UsbDeviceFilter::MatchesAny(device, filters_) && | 155 if (device::UsbDeviceFilter::MatchesAny(device, filters_) && |
| 155 FindInAllowedOrigins( | 156 FindInAllowedOrigins( |
| 156 device->webusb_allowed_origins(), | 157 device->webusb_allowed_origins(), |
| 157 render_frame_host_->GetLastCommittedURL().GetOrigin())) { | 158 render_frame_host_->GetLastCommittedURL().GetOrigin())) { |
| 158 devices_.push_back(std::make_pair(device, device->product_string())); | 159 devices_.push_back(std::make_pair(device, device->product_string())); |
| 159 if (observer()) | 160 if (observer()) |
| 160 observer()->OnOptionAdded(devices_.size() - 1); | 161 observer()->OnOptionAdded(devices_.size() - 1); |
| 161 } | 162 } |
| 162 } | 163 } |
| 163 | 164 |
| 165 GURL UsbChooserBubbleDelegate::GetHelpCenterURL() const { | |
| 166 return GURL(chrome::kWebUsbHelpCenterURL); | |
|
msw
2016/02/17 01:31:35
Does it make sense to link to a general support ur
juncai
2016/02/17 22:40:40
A WebUsb help center URL has been requested, once
| |
| 167 } | |
| 168 | |
| 164 void UsbChooserBubbleDelegate::OnDeviceRemoved( | 169 void UsbChooserBubbleDelegate::OnDeviceRemoved( |
| 165 scoped_refptr<device::UsbDevice> device) { | 170 scoped_refptr<device::UsbDevice> device) { |
| 166 for (auto it = devices_.begin(); it != devices_.end(); ++it) { | 171 for (auto it = devices_.begin(); it != devices_.end(); ++it) { |
| 167 if (it->first == device) { | 172 if (it->first == device) { |
| 168 size_t index = it - devices_.begin(); | 173 size_t index = it - devices_.begin(); |
| 169 devices_.erase(it); | 174 devices_.erase(it); |
| 170 if (observer()) | 175 if (observer()) |
| 171 observer()->OnOptionRemoved(index); | 176 observer()->OnOptionRemoved(index); |
| 172 return; | 177 return; |
| 173 } | 178 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 187 } | 192 } |
| 188 } | 193 } |
| 189 if (observer()) | 194 if (observer()) |
| 190 observer()->OnOptionsInitialized(); | 195 observer()->OnOptionsInitialized(); |
| 191 } | 196 } |
| 192 | 197 |
| 193 void UsbChooserBubbleDelegate::set_bubble_controller( | 198 void UsbChooserBubbleDelegate::set_bubble_controller( |
| 194 BubbleReference bubble_controller) { | 199 BubbleReference bubble_controller) { |
| 195 bubble_controller_ = bubble_controller; | 200 bubble_controller_ = bubble_controller; |
| 196 } | 201 } |
| OLD | NEW |