Chromium Code Reviews| OLD | NEW |
|---|---|
| (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/usb_chooser_bubble_delegate.h" | |
| 6 | |
| 7 #if defined(OS_MACOSX) | |
| 8 #include "chrome/browser/ui/cocoa/website_settings/chooser_bubble_ui_cocoa.h" | |
| 9 #else | |
| 10 #include "chrome/browser/ui/views/website_settings/chooser_bubble_ui_view.h" | |
| 11 #endif | |
| 12 #include "chrome/browser/usb/usb_chooser_choices.h" | |
| 13 | |
| 14 UsbChooserBubbleDelegate::UsbChooserBubbleDelegate( | |
| 15 Browser* browser, | |
| 16 mojo::Array<device::usb::DeviceFilterPtr> device_filters, | |
| 17 content::RenderFrameHost* render_frame_host, | |
| 18 const webusb::WebUsbPermissionBubble::GetPermissionCallback& callback) | |
| 19 : browser_(browser) { | |
| 20 DCHECK(browser_); | |
| 21 chooser_choices_.reset(new UsbChooserChoices(device_filters.Pass(), | |
| 22 render_frame_host, callback)); | |
| 23 chooser_choices_->set_observer(this); | |
| 24 } | |
| 25 | |
| 26 UsbChooserBubbleDelegate::~UsbChooserBubbleDelegate() {} | |
| 27 | |
| 28 scoped_ptr<BubbleUi> UsbChooserBubbleDelegate::BuildBubbleUi() { | |
| 29 #if defined(OS_MACOSX) | |
| 30 scoped_ptr<ChooserBubbleUiCocoa> bubble_ui(new ChooserBubbleUiCocoa()); | |
| 31 chooser_bubble_ui_cocoa_ = bubble_ui.get(); | |
| 32 #else | |
| 33 scoped_ptr<ChooserBubbleUiView> bubble_ui( | |
| 34 new ChooserBubbleUiView(browser_, chooser_choices_.get(), this)); | |
| 35 chooser_bubble_ui_view_ = bubble_ui.get(); | |
| 36 #endif | |
| 37 return bubble_ui.Pass(); | |
| 38 } | |
| 39 | |
| 40 void UsbChooserBubbleDelegate::Select(int index) { | |
| 41 chooser_choices_->Select(index); | |
| 42 #if defined(OS_MACOSX) | |
|
Reilly Grant (use Gerrit)
2015/10/29 01:11:32
I don't see the purpose of having two different fi
juncai
2015/10/31 04:15:36
Done.
| |
| 43 chooser_bubble_ui_cocoa_->Close(); | |
| 44 #else | |
| 45 chooser_bubble_ui_view_->Close(); | |
| 46 #endif | |
| 47 } | |
| 48 | |
| 49 void UsbChooserBubbleDelegate::Cancel() { | |
| 50 #if defined(OS_MACOSX) | |
| 51 chooser_bubble_ui_cocoa_->Close(); | |
| 52 #else | |
| 53 chooser_bubble_ui_view_->Close(); | |
| 54 #endif | |
| 55 } | |
| 56 | |
| 57 void UsbChooserBubbleDelegate::OnChoicesChanged() { | |
| 58 #if defined(OS_MACOSX) | |
| 59 chooser_bubble_ui_cocoa_->Update(); | |
| 60 #else | |
| 61 chooser_bubble_ui_view_->Update(); | |
| 62 #endif | |
| 63 } | |
| OLD | NEW |