blob: 3d8aae61750caab339786682ba27116211798524 [file] [log] [blame]
Jun Cai149002e2019-05-09 23:13:071// 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 Cai149002e2019-05-09 23:13:079
10BluetoothScanningPromptDesktop::BluetoothScanningPromptDesktop(
Elly Fong-Jonesf260d672020-03-16 14:09:0711 BluetoothScanningPromptController* bluetooth_scanning_prompt_controller,
12 base::OnceClosure&& close_closure)
Jun Cai149002e2019-05-09 23:13:0713 : bluetooth_scanning_prompt_controller_(
Elly Fong-Jonesf260d672020-03-16 14:09:0714 bluetooth_scanning_prompt_controller),
15 close_closure_(std::move(close_closure)) {
Jun Cai149002e2019-05-09 23:13:0716 DCHECK(bluetooth_scanning_prompt_controller_);
17}
18
19BluetoothScanningPromptDesktop::~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-Jonesf260d672020-03-16 14:09:0724 if (close_closure_)
25 std::move(close_closure_).Run();
Jun Cai149002e2019-05-09 23:13:0726}
27
28void 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}