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" |
| 9 | #include "components/bubble/bubble_controller.h" |
| 10 | |
| 11 | BluetoothScanningPromptDesktop::BluetoothScanningPromptDesktop( |
| 12 | BluetoothScanningPromptController* bluetooth_scanning_prompt_controller) |
| 13 | : bluetooth_scanning_prompt_controller_( |
| 14 | bluetooth_scanning_prompt_controller) { |
| 15 | DCHECK(bluetooth_scanning_prompt_controller_); |
| 16 | } |
| 17 | |
| 18 | BluetoothScanningPromptDesktop::~BluetoothScanningPromptDesktop() { |
| 19 | // This satisfies the WebContentsDelegate::ShowBluetoothScanningPrompt() |
| 20 | // requirement that the EventHandler can be destroyed any time after the |
| 21 | // BluetoothScanningPrompt instance. |
| 22 | bluetooth_scanning_prompt_controller_->ResetEventHandler(); |
| 23 | if (bubble_) |
| 24 | bubble_->CloseBubble(BUBBLE_CLOSE_FORCED); |
| 25 | } |
| 26 | |
| 27 | void BluetoothScanningPromptDesktop::AddOrUpdateDevice( |
| 28 | const std::string& device_id, |
| 29 | bool should_update_name, |
| 30 | const base::string16& device_name) { |
| 31 | bluetooth_scanning_prompt_controller_->AddOrUpdateDevice( |
| 32 | device_id, should_update_name, device_name); |
| 33 | } |