| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/ui/bluetooth/bluetooth_chooser_bubble_delegate.h" | 5 #include "chrome/browser/ui/bluetooth/bluetooth_chooser_bubble_delegate.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "chrome/browser/ui/bluetooth/bluetooth_chooser_desktop.h" | 8 #include "chrome/browser/ui/bluetooth/bluetooth_chooser_desktop.h" |
| 9 #include "chrome/common/url_constants.h" |
| 9 #include "components/bubble/bubble_controller.h" | 10 #include "components/bubble/bubble_controller.h" |
| 11 #include "url/gurl.h" |
| 10 | 12 |
| 11 BluetoothChooserBubbleDelegate::BluetoothChooserBubbleDelegate( | 13 BluetoothChooserBubbleDelegate::BluetoothChooserBubbleDelegate( |
| 12 content::RenderFrameHost* owner) | 14 content::RenderFrameHost* owner) |
| 13 : ChooserBubbleDelegate(owner), bluetooth_chooser_(nullptr) {} | 15 : ChooserBubbleDelegate(owner), bluetooth_chooser_(nullptr) {} |
| 14 | 16 |
| 15 BluetoothChooserBubbleDelegate::~BluetoothChooserBubbleDelegate() { | 17 BluetoothChooserBubbleDelegate::~BluetoothChooserBubbleDelegate() { |
| 16 if (bluetooth_chooser_) | 18 if (bluetooth_chooser_) |
| 17 bluetooth_chooser_->set_bluetooth_chooser_bubble_delegate(nullptr); | 19 bluetooth_chooser_->set_bluetooth_chooser_bubble_delegate(nullptr); |
| 18 } | 20 } |
| 19 | 21 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 49 bubble_controller_->CloseBubble(BUBBLE_CLOSE_CANCELED); | 51 bubble_controller_->CloseBubble(BUBBLE_CLOSE_CANCELED); |
| 50 } | 52 } |
| 51 | 53 |
| 52 void BluetoothChooserBubbleDelegate::Close() { | 54 void BluetoothChooserBubbleDelegate::Close() { |
| 53 if (bluetooth_chooser_) { | 55 if (bluetooth_chooser_) { |
| 54 bluetooth_chooser_->CallEventHandler( | 56 bluetooth_chooser_->CallEventHandler( |
| 55 content::BluetoothChooser::Event::CANCELLED, std::string()); | 57 content::BluetoothChooser::Event::CANCELLED, std::string()); |
| 56 } | 58 } |
| 57 } | 59 } |
| 58 | 60 |
| 61 GURL BluetoothChooserBubbleDelegate::GetHelpCenterUrl() const { |
| 62 return GURL(chrome::kChooserBluetoothOverviewURL); |
| 63 } |
| 64 |
| 59 void BluetoothChooserBubbleDelegate::AddDevice( | 65 void BluetoothChooserBubbleDelegate::AddDevice( |
| 60 const std::string& device_id, | 66 const std::string& device_id, |
| 61 const base::string16& device_name) { | 67 const base::string16& device_name) { |
| 62 device_names_and_ids_.push_back(std::make_pair(device_name, device_id)); | 68 device_names_and_ids_.push_back(std::make_pair(device_name, device_id)); |
| 63 if (observer()) | 69 if (observer()) |
| 64 observer()->OnOptionAdded(device_names_and_ids_.size() - 1); | 70 observer()->OnOptionAdded(device_names_and_ids_.size() - 1); |
| 65 } | 71 } |
| 66 | 72 |
| 67 void BluetoothChooserBubbleDelegate::RemoveDevice( | 73 void BluetoothChooserBubbleDelegate::RemoveDevice( |
| 68 const std::string& device_id) { | 74 const std::string& device_id) { |
| 69 for (auto it = device_names_and_ids_.begin(); | 75 for (auto it = device_names_and_ids_.begin(); |
| 70 it != device_names_and_ids_.end(); ++it) { | 76 it != device_names_and_ids_.end(); ++it) { |
| 71 if (it->second == device_id) { | 77 if (it->second == device_id) { |
| 72 size_t index = it - device_names_and_ids_.begin(); | 78 size_t index = it - device_names_and_ids_.begin(); |
| 73 device_names_and_ids_.erase(it); | 79 device_names_and_ids_.erase(it); |
| 74 if (observer()) | 80 if (observer()) |
| 75 observer()->OnOptionRemoved(index); | 81 observer()->OnOptionRemoved(index); |
| 76 return; | 82 return; |
| 77 } | 83 } |
| 78 } | 84 } |
| 79 } | 85 } |
| OLD | NEW |