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

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

Issue 2155743002: Add throbber and status text to WebBluetooth chooser UI on non-Mac desktops (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed unnecessary include file Created 4 years, 5 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
« no previous file with comments | « chrome/browser/usb/usb_chooser_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_controller.h" 5 #include "chrome/browser/usb/usb_chooser_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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 usb_service->GetDevices(base::Bind(&UsbChooserController::GotUsbDeviceList, 67 usb_service->GetDevices(base::Bind(&UsbChooserController::GotUsbDeviceList,
68 weak_factory_.GetWeakPtr())); 68 weak_factory_.GetWeakPtr()));
69 } 69 }
70 70
71 UsbChooserController::~UsbChooserController() { 71 UsbChooserController::~UsbChooserController() {
72 if (!callback_.is_null()) 72 if (!callback_.is_null())
73 callback_.Run(nullptr); 73 callback_.Run(nullptr);
74 } 74 }
75 75
76 base::string16 UsbChooserController::GetNoOptionsText() const {
77 return l10n_util::GetStringUTF16(IDS_DEVICE_CHOOSER_NO_DEVICES_FOUND_PROMPT);
78 }
79
76 base::string16 UsbChooserController::GetOkButtonLabel() const { 80 base::string16 UsbChooserController::GetOkButtonLabel() const {
77 return l10n_util::GetStringUTF16(IDS_USB_DEVICE_CHOOSER_CONNECT_BUTTON_TEXT); 81 return l10n_util::GetStringUTF16(IDS_USB_DEVICE_CHOOSER_CONNECT_BUTTON_TEXT);
78 } 82 }
79 83
80 size_t UsbChooserController::NumOptions() const { 84 size_t UsbChooserController::NumOptions() const {
81 return devices_.size(); 85 return devices_.size();
82 } 86 }
83 87
84 base::string16 UsbChooserController::GetOption(size_t index) const { 88 base::string16 UsbChooserController::GetOption(size_t index) const {
85 DCHECK_LT(index, devices_.size()); 89 DCHECK_LT(index, devices_.size());
86 const base::string16& device_name = devices_[index].second; 90 const base::string16& device_name = devices_[index].second;
87 const auto& it = device_name_map_.find(device_name); 91 const auto& it = device_name_map_.find(device_name);
88 DCHECK(it != device_name_map_.end()); 92 DCHECK(it != device_name_map_.end());
89 return it->second == 1 93 return it->second == 1
90 ? device_name 94 ? device_name
91 : l10n_util::GetStringFUTF16( 95 : l10n_util::GetStringFUTF16(
92 IDS_DEVICE_CHOOSER_DEVICE_NAME_WITH_ID, device_name, 96 IDS_DEVICE_CHOOSER_DEVICE_NAME_WITH_ID, device_name,
93 devices_[index].first->serial_number()); 97 devices_[index].first->serial_number());
94 } 98 }
95 99
100 void UsbChooserController::RefreshOptions() {}
101
102 base::string16 UsbChooserController::GetStatus() const {
103 return base::string16();
104 }
105
96 void UsbChooserController::Select(size_t index) { 106 void UsbChooserController::Select(size_t index) {
97 DCHECK_LT(index, devices_.size()); 107 DCHECK_LT(index, devices_.size());
98 content::WebContents* web_contents = 108 content::WebContents* web_contents =
99 content::WebContents::FromRenderFrameHost(render_frame_host_); 109 content::WebContents::FromRenderFrameHost(render_frame_host_);
100 GURL embedding_origin = 110 GURL embedding_origin =
101 web_contents->GetMainFrame()->GetLastCommittedURL().GetOrigin(); 111 web_contents->GetMainFrame()->GetLastCommittedURL().GetOrigin();
102 Profile* profile = 112 Profile* profile =
103 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 113 Profile::FromBrowserContext(web_contents->GetBrowserContext());
104 UsbChooserContext* chooser_context = 114 UsbChooserContext* chooser_context =
105 UsbChooserContextFactory::GetForProfile(profile); 115 UsbChooserContextFactory::GetForProfile(profile);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 187
178 bool UsbChooserController::DisplayDevice( 188 bool UsbChooserController::DisplayDevice(
179 scoped_refptr<device::UsbDevice> device) const { 189 scoped_refptr<device::UsbDevice> device) const {
180 return device::UsbDeviceFilter::MatchesAny(device, filters_) && 190 return device::UsbDeviceFilter::MatchesAny(device, filters_) &&
181 (base::CommandLine::ForCurrentProcess()->HasSwitch( 191 (base::CommandLine::ForCurrentProcess()->HasSwitch(
182 switches::kDisableWebUsbSecurity) || 192 switches::kDisableWebUsbSecurity) ||
183 device::FindInWebUsbAllowedOrigins( 193 device::FindInWebUsbAllowedOrigins(
184 device->webusb_allowed_origins(), 194 device->webusb_allowed_origins(),
185 render_frame_host_->GetLastCommittedURL().GetOrigin())); 195 render_frame_host_->GetLastCommittedURL().GetOrigin()));
186 } 196 }
OLDNEW
« no previous file with comments | « chrome/browser/usb/usb_chooser_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698