| 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_controller.h" | 5 #include "chrome/browser/ui/bluetooth/bluetooth_chooser_controller.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/net/referrer.h" | 8 #include "chrome/browser/net/referrer.h" |
| 9 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
| 10 #include "chrome/browser/ui/bluetooth/bluetooth_chooser_desktop.h" | 10 #include "chrome/browser/ui/bluetooth/bluetooth_chooser_desktop.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 } // namespace | 27 } // namespace |
| 28 | 28 |
| 29 BluetoothChooserController::BluetoothChooserController( | 29 BluetoothChooserController::BluetoothChooserController( |
| 30 content::RenderFrameHost* owner, | 30 content::RenderFrameHost* owner, |
| 31 const content::BluetoothChooser::EventHandler& event_handler) | 31 const content::BluetoothChooser::EventHandler& event_handler) |
| 32 : ChooserController(owner), event_handler_(event_handler) {} | 32 : ChooserController(owner), event_handler_(event_handler) {} |
| 33 | 33 |
| 34 BluetoothChooserController::~BluetoothChooserController() {} | 34 BluetoothChooserController::~BluetoothChooserController() {} |
| 35 | 35 |
| 36 base::string16 BluetoothChooserController::GetOkButtonLabel() const { |
| 37 return l10n_util::GetStringUTF16( |
| 38 IDS_BLUETOOTH_DEVICE_CHOOSER_PAIR_BUTTON_TEXT); |
| 39 } |
| 40 |
| 36 size_t BluetoothChooserController::NumOptions() const { | 41 size_t BluetoothChooserController::NumOptions() const { |
| 37 return device_names_and_ids_.size(); | 42 return device_names_and_ids_.size(); |
| 38 } | 43 } |
| 39 | 44 |
| 40 base::string16 BluetoothChooserController::GetOption(size_t index) const { | 45 base::string16 BluetoothChooserController::GetOption(size_t index) const { |
| 41 DCHECK_LT(index, device_names_and_ids_.size()); | 46 DCHECK_LT(index, device_names_and_ids_.size()); |
| 42 const base::string16& device_name = device_names_and_ids_[index].first; | 47 const base::string16& device_name = device_names_and_ids_[index].first; |
| 43 const auto& it = device_name_map_.find(device_name); | 48 const auto& it = device_name_map_.find(device_name); |
| 44 DCHECK(it != device_name_map_.end()); | 49 DCHECK(it != device_name_map_.end()); |
| 45 return it->second == 1 | 50 return it->second == 1 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 DCHECK_GT(device_name_map_[it->first], 0); | 93 DCHECK_GT(device_name_map_[it->first], 0); |
| 89 if (--device_name_map_[it->first] == 0) | 94 if (--device_name_map_[it->first] == 0) |
| 90 device_name_map_.erase(it->first); | 95 device_name_map_.erase(it->first); |
| 91 device_names_and_ids_.erase(it); | 96 device_names_and_ids_.erase(it); |
| 92 if (observer()) | 97 if (observer()) |
| 93 observer()->OnOptionRemoved(index); | 98 observer()->OnOptionRemoved(index); |
| 94 return; | 99 return; |
| 95 } | 100 } |
| 96 } | 101 } |
| 97 } | 102 } |
| OLD | NEW |