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

Side by Side Diff: components/webusb/webusb_detector.cc

Issue 1289423002: Add webusb notification UI code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moved chrome related code back to chrome directory Created 5 years, 3 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 | « components/webusb/webusb_detector.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/webusb/webusb_detector.h"
6
7 #include "base/memory/scoped_ptr.h"
8 #include "base/memory/singleton.h"
9 #include "components/webusb/webusb_browser_client.h"
10 #include "device/core/device_client.h"
11 #include "device/usb/usb_device.h"
12 #include "device/usb/usb_ids.h"
13
14 namespace webusb {
15
16 WebUsbDetector* WebUsbDetector::GetInstance() {
17 return Singleton<WebUsbDetector>::get();
Reilly Grant (use Gerrit) 2015/08/26 22:32:12 Issues I've been trying to resolve recently have c
juncai 2015/08/27 00:54:42 Done.
18 }
19
20 WebUsbDetector::WebUsbDetector() : observer_(this) {
21 Initialize();
22 }
23
24 WebUsbDetector::~WebUsbDetector() {}
25
26 void WebUsbDetector::Initialize() {
27 if (!webusb::WebUsbBrowserClient::Get()) {
28 return;
29 }
30
31 device::UsbService* usb_service =
32 device::DeviceClient::Get()->GetUsbService();
33 if (!usb_service)
34 return;
35
36 observer_.Add(usb_service);
37 }
38
39 void WebUsbDetector::OnDeviceAdded(scoped_refptr<device::UsbDevice> device) {
40 const base::string16& product_name = device->product_string();
41 if (product_name.empty()) {
42 return;
43 }
44
45 const GURL& landing_page = device->webusb_landing_page();
46 if (!landing_page.is_valid()) {
47 return;
48 }
49
50 std::string notification_id = device->guid();
51
52 webusb::WebUsbBrowserClient::Get()->OnDeviceAdded(product_name, landing_page,
53 notification_id);
54 }
55
56 void WebUsbDetector::OnDeviceRemoved(scoped_refptr<device::UsbDevice> device) {
57 std::string notification_id = device->guid();
58 webusb::WebUsbBrowserClient::Get()->OnDeviceRemoved(notification_id);
59 }
60
61 } // namespace webusb
OLDNEW
« no previous file with comments | « components/webusb/webusb_detector.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698