| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #import "chrome/browser/ui/cocoa/extensions/device_permissions_dialog_controller
.h" | 5 #import "chrome/browser/ui/cocoa/extensions/device_permissions_dialog_controller
.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| 11 #include "chrome/browser/extensions/api/chrome_device_permissions_prompt.h" |
| 11 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh
eet.h" | 12 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh
eet.h" |
| 12 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_wi
ndow.h" | 13 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_wi
ndow.h" |
| 13 #import "chrome/browser/ui/cocoa/extensions/device_permissions_view_controller.h
" | 14 #import "chrome/browser/ui/cocoa/extensions/device_permissions_view_controller.h
" |
| 14 #include "device/usb/usb_device.h" | 15 #include "device/usb/usb_device.h" |
| 15 | 16 |
| 16 using extensions::DevicePermissionsPrompt; | 17 using extensions::DevicePermissionsPrompt; |
| 17 | 18 |
| 18 namespace { | |
| 19 | |
| 20 void ShowDevicePermissionsDialogImpl( | |
| 21 content::WebContents* web_contents, | |
| 22 DevicePermissionsPrompt::Delegate* delegate, | |
| 23 scoped_refptr<DevicePermissionsPrompt::Prompt> prompt) { | |
| 24 // These objects will delete themselves when the dialog closes. | |
| 25 new DevicePermissionsDialogController(web_contents, delegate, prompt); | |
| 26 } | |
| 27 | |
| 28 } // namespace | |
| 29 | |
| 30 DevicePermissionsDialogController::DevicePermissionsDialogController( | 19 DevicePermissionsDialogController::DevicePermissionsDialogController( |
| 31 content::WebContents* web_contents, | 20 content::WebContents* web_contents, |
| 32 DevicePermissionsPrompt::Delegate* delegate, | 21 DevicePermissionsPrompt::Delegate* delegate, |
| 33 scoped_refptr<DevicePermissionsPrompt::Prompt> prompt) | 22 scoped_refptr<DevicePermissionsPrompt::Prompt> prompt) |
| 34 : delegate_(delegate), prompt_(prompt) { | 23 : delegate_(delegate), prompt_(prompt) { |
| 35 view_controller_.reset( | 24 view_controller_.reset( |
| 36 [[DevicePermissionsViewController alloc] initWithDelegate:this | 25 [[DevicePermissionsViewController alloc] initWithDelegate:this |
| 37 prompt:prompt]); | 26 prompt:prompt]); |
| 38 | 27 |
| 39 prompt_->SetObserver(this); | 28 prompt_->SetObserver(this); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 65 | 54 |
| 66 void DevicePermissionsDialogController::OnConstrainedWindowClosed( | 55 void DevicePermissionsDialogController::OnConstrainedWindowClosed( |
| 67 ConstrainedWindowMac* window) { | 56 ConstrainedWindowMac* window) { |
| 68 if (delegate_) { | 57 if (delegate_) { |
| 69 std::vector<scoped_refptr<device::UsbDevice>> empty; | 58 std::vector<scoped_refptr<device::UsbDevice>> empty; |
| 70 delegate_->OnUsbDevicesChosen(empty); | 59 delegate_->OnUsbDevicesChosen(empty); |
| 71 } | 60 } |
| 72 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); | 61 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
| 73 } | 62 } |
| 74 | 63 |
| 75 // static | 64 void ChromeDevicePermissionsPrompt::ShowDialog() { |
| 76 DevicePermissionsPrompt::ShowDialogCallback | 65 // These objects will delete themselves when the dialog closes. |
| 77 DevicePermissionsPrompt::GetDefaultShowDialogCallback() { | 66 new DevicePermissionsDialogController(web_contents(), delegate(), prompt()); |
| 78 return base::Bind(&ShowDevicePermissionsDialogImpl); | |
| 79 } | 67 } |
| OLD | NEW |