Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(607)

Side by Side Diff: chrome/browser/usb/usb_chooser_bubble_controller.cc

Issue 1984923002: Refactor ChooserBubbleController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated README for ChooserController Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_controller.h" 5 #include "chrome/browser/usb/usb_chooser_bubble_controller.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"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 RecordWebUsbChooserClosure(devices_.size() == 0 98 RecordWebUsbChooserClosure(devices_.size() == 0
99 ? WEBUSB_CHOOSER_CLOSED_CANCELLED_NO_DEVICES 99 ? WEBUSB_CHOOSER_CLOSED_CANCELLED_NO_DEVICES
100 : WEBUSB_CHOOSER_CLOSED_CANCELLED); 100 : WEBUSB_CHOOSER_CLOSED_CANCELLED);
101 101
102 if (bubble_reference_) 102 if (bubble_reference_)
103 bubble_reference_->CloseBubble(BUBBLE_CLOSE_CANCELED); 103 bubble_reference_->CloseBubble(BUBBLE_CLOSE_CANCELED);
104 } 104 }
105 105
106 void UsbChooserBubbleController::Close() {} 106 void UsbChooserBubbleController::Close() {}
107 107
108 GURL UsbChooserBubbleController::GetHelpCenterUrl() const {
109 return GURL(chrome::kChooserUsbOverviewURL);
110 }
111
108 void UsbChooserBubbleController::OnDeviceAdded( 112 void UsbChooserBubbleController::OnDeviceAdded(
109 scoped_refptr<device::UsbDevice> device) { 113 scoped_refptr<device::UsbDevice> device) {
110 if (DisplayDevice(device)) { 114 if (DisplayDevice(device)) {
111 devices_.push_back(std::make_pair(device, device->product_string())); 115 devices_.push_back(std::make_pair(device, device->product_string()));
112 if (observer()) 116 if (observer())
113 observer()->OnOptionAdded(devices_.size() - 1); 117 observer()->OnOptionAdded(devices_.size() - 1);
114 } 118 }
115 } 119 }
116 120
117 GURL UsbChooserBubbleController::GetHelpCenterUrl() const {
118 return GURL(chrome::kChooserUsbOverviewURL);
119 }
120
121 void UsbChooserBubbleController::OnDeviceRemoved( 121 void UsbChooserBubbleController::OnDeviceRemoved(
122 scoped_refptr<device::UsbDevice> device) { 122 scoped_refptr<device::UsbDevice> device) {
123 for (auto it = devices_.begin(); it != devices_.end(); ++it) { 123 for (auto it = devices_.begin(); it != devices_.end(); ++it) {
124 if (it->first == device) { 124 if (it->first == device) {
125 size_t index = it - devices_.begin(); 125 size_t index = it - devices_.begin();
126 devices_.erase(it); 126 devices_.erase(it);
127 if (observer()) 127 if (observer())
128 observer()->OnOptionRemoved(index); 128 observer()->OnOptionRemoved(index);
129 return; 129 return;
130 } 130 }
(...skipping 19 matching lines...) Expand all
150 150
151 bool UsbChooserBubbleController::DisplayDevice( 151 bool UsbChooserBubbleController::DisplayDevice(
152 scoped_refptr<device::UsbDevice> device) const { 152 scoped_refptr<device::UsbDevice> device) const {
153 return device::UsbDeviceFilter::MatchesAny(device, filters_) && 153 return device::UsbDeviceFilter::MatchesAny(device, filters_) &&
154 (base::CommandLine::ForCurrentProcess()->HasSwitch( 154 (base::CommandLine::ForCurrentProcess()->HasSwitch(
155 switches::kDisableWebUsbSecurity) || 155 switches::kDisableWebUsbSecurity) ||
156 device::FindInWebUsbAllowedOrigins( 156 device::FindInWebUsbAllowedOrigins(
157 device->webusb_allowed_origins(), 157 device->webusb_allowed_origins(),
158 render_frame_host_->GetLastCommittedURL().GetOrigin())); 158 render_frame_host_->GetLastCommittedURL().GetOrigin()));
159 } 159 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698