Fix emulator build error
[platform/framework/web/chromium-efl.git] / components / permissions / fake_bluetooth_chooser_controller.cc
1 // Copyright 2017 The Chromium Authors
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 "components/permissions/fake_bluetooth_chooser_controller.h"
6
7 #include "base/check_op.h"
8 #include "base/notreached.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "components/strings/grit/components_strings.h"
11 #include "ui/base/l10n/l10n_util.h"
12
13 namespace permissions {
14
15 FakeBluetoothChooserController::FakeBluetoothChooserController(
16     std::vector<FakeDevice> devices)
17     : ChooserController(
18           l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_CHOOSER_PROMPT,
19                                      u"example.com")),
20       devices_(std::move(devices)) {}
21
22 FakeBluetoothChooserController::~FakeBluetoothChooserController() {}
23
24 bool FakeBluetoothChooserController::ShouldShowIconBeforeText() const {
25   return true;
26 }
27
28 bool FakeBluetoothChooserController::ShouldShowReScanButton() const {
29   return true;
30 }
31
32 std::u16string FakeBluetoothChooserController::GetNoOptionsText() const {
33   return l10n_util::GetStringUTF16(
34       IDS_BLUETOOTH_DEVICE_CHOOSER_NO_DEVICES_FOUND_PROMPT);
35 }
36
37 std::u16string FakeBluetoothChooserController::GetOkButtonLabel() const {
38   return l10n_util::GetStringUTF16(
39       IDS_BLUETOOTH_DEVICE_CHOOSER_PAIR_BUTTON_TEXT);
40 }
41
42 std::pair<std::u16string, std::u16string>
43 FakeBluetoothChooserController::GetThrobberLabelAndTooltip() const {
44   return {
45       l10n_util::GetStringUTF16(IDS_BLUETOOTH_DEVICE_CHOOSER_SCANNING_LABEL),
46       l10n_util::GetStringUTF16(
47           IDS_BLUETOOTH_DEVICE_CHOOSER_SCANNING_LABEL_TOOLTIP)};
48 }
49
50 bool FakeBluetoothChooserController::TableViewAlwaysDisabled() const {
51   return table_view_always_disabled_;
52 }
53
54 size_t FakeBluetoothChooserController::NumOptions() const {
55   return devices_.size();
56 }
57
58 int FakeBluetoothChooserController::GetSignalStrengthLevel(size_t index) const {
59   return devices_.at(index).signal_strength;
60 }
61
62 std::u16string FakeBluetoothChooserController::GetOption(size_t index) const {
63   return base::ASCIIToUTF16(devices_.at(index).name);
64 }
65
66 bool FakeBluetoothChooserController::IsConnected(size_t index) const {
67   return devices_.at(index).connected;
68 }
69
70 bool FakeBluetoothChooserController::IsPaired(size_t index) const {
71   return devices_.at(index).paired;
72 }
73
74 void FakeBluetoothChooserController::SetBluetoothStatus(
75     BluetoothStatus status) {
76   const bool available = status != BluetoothStatus::UNAVAILABLE;
77   view()->OnAdapterEnabledChanged(available);
78   if (available)
79     view()->OnRefreshStateChanged(status == BluetoothStatus::SCANNING);
80 }
81
82 void FakeBluetoothChooserController::SetBluetoothPermission(
83     bool has_permission) {
84   view()->OnAdapterAuthorizationChanged(has_permission);
85 }
86
87 void FakeBluetoothChooserController::AddDevice(FakeDevice device) {
88   devices_.push_back(device);
89   view()->OnOptionAdded(devices_.size() - 1);
90 }
91
92 void FakeBluetoothChooserController::RemoveDevice(size_t index) {
93   DCHECK_GT(devices_.size(), index);
94   devices_.erase(devices_.begin() + index);
95   view()->OnOptionRemoved(index);
96 }
97
98 void FakeBluetoothChooserController::UpdateDevice(size_t index,
99                                                   FakeDevice new_device) {
100   DCHECK_GT(devices_.size(), index);
101   devices_[index] = new_device;
102   view()->OnOptionUpdated(index);
103 }
104
105 }  // namespace permissions