Jun Cai | 149002e | 2019-05-09 23:13:07 | [diff] [blame] | 1 | // Copyright 2019 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/ui/bluetooth/bluetooth_scanning_prompt_desktop.h" |
| 6 | |
| 7 | #include "base/logging.h" |
| 8 | #include "chrome/browser/ui/bluetooth/bluetooth_scanning_prompt_controller.h" |
Jun Cai | 149002e | 2019-05-09 23:13:07 | [diff] [blame] | 9 | |
| 10 | BluetoothScanningPromptDesktop::BluetoothScanningPromptDesktop( |
Elly Fong-Jones | f260d67 | 2020-03-16 14:09:07 | [diff] [blame^] | 11 | BluetoothScanningPromptController* bluetooth_scanning_prompt_controller, |
| 12 | base::OnceClosure&& close_closure) |
Jun Cai | 149002e | 2019-05-09 23:13:07 | [diff] [blame] | 13 | : bluetooth_scanning_prompt_controller_( |
Elly Fong-Jones | f260d67 | 2020-03-16 14:09:07 | [diff] [blame^] | 14 | bluetooth_scanning_prompt_controller), |
| 15 | close_closure_(std::move(close_closure)) { |
Jun Cai | 149002e | 2019-05-09 23:13:07 | [diff] [blame] | 16 | DCHECK(bluetooth_scanning_prompt_controller_); |
| 17 | } |
| 18 | |
| 19 | BluetoothScanningPromptDesktop::~BluetoothScanningPromptDesktop() { |
| 20 | // This satisfies the WebContentsDelegate::ShowBluetoothScanningPrompt() |
| 21 | // requirement that the EventHandler can be destroyed any time after the |
| 22 | // BluetoothScanningPrompt instance. |
| 23 | bluetooth_scanning_prompt_controller_->ResetEventHandler(); |
Elly Fong-Jones | f260d67 | 2020-03-16 14:09:07 | [diff] [blame^] | 24 | if (close_closure_) |
| 25 | std::move(close_closure_).Run(); |
Jun Cai | 149002e | 2019-05-09 23:13:07 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | void BluetoothScanningPromptDesktop::AddOrUpdateDevice( |
| 29 | const std::string& device_id, |
| 30 | bool should_update_name, |
| 31 | const base::string16& device_name) { |
| 32 | bluetooth_scanning_prompt_controller_->AddOrUpdateDevice( |
| 33 | device_id, should_update_name, device_name); |
| 34 | } |