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

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

Issue 1742753002: Rename web_usb_permission_bubble.cc/h and webusb_permission_bubble.mojom (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 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/web_usb_permission_bubble.h ('k') | chrome/chrome_browser.gypi » ('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 "chrome/browser/usb/web_usb_permission_bubble.h"
6
7 #include <utility>
8
9 #include "chrome/browser/ui/browser_finder.h"
10 #include "chrome/browser/ui/chrome_bubble_manager.h"
11 #include "chrome/browser/usb/usb_chooser_bubble_controller.h"
12 #include "components/bubble/bubble_controller.h"
13 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/render_frame_host.h"
15
16 ChromeWebUsbPermissionBubble::ChromeWebUsbPermissionBubble(
17 content::RenderFrameHost* render_frame_host)
18 : render_frame_host_(render_frame_host) {
19 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
20 DCHECK(render_frame_host);
21 }
22
23 ChromeWebUsbPermissionBubble::~ChromeWebUsbPermissionBubble() {
24 for (const auto& bubble : bubbles_) {
25 if (bubble)
26 bubble->CloseBubble(BUBBLE_CLOSE_FORCED);
27 }
28 }
29
30 void ChromeWebUsbPermissionBubble::GetPermission(
31 mojo::Array<device::usb::DeviceFilterPtr> device_filters,
32 const GetPermissionCallback& callback) {
33 content::WebContents* web_contents =
34 content::WebContents::FromRenderFrameHost(render_frame_host_);
35 Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
36 scoped_ptr<UsbChooserBubbleController> bubble_controller(
37 new UsbChooserBubbleController(render_frame_host_,
38 std::move(device_filters),
39 render_frame_host_, callback));
40 UsbChooserBubbleController* bubble_controller_ptr = bubble_controller.get();
41 BubbleReference bubble_reference =
42 browser->GetBubbleManager()->ShowBubble(std::move(bubble_controller));
43 bubble_controller_ptr->set_bubble_reference(bubble_reference);
44 bubbles_.push_back(bubble_reference);
45 }
46
47 void ChromeWebUsbPermissionBubble::Bind(
48 mojo::InterfaceRequest<webusb::WebUsbPermissionBubble> request) {
49 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
50 bindings_.AddBinding(this, std::move(request));
51 }
OLDNEW
« no previous file with comments | « chrome/browser/usb/web_usb_permission_bubble.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698