| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/chooser_controller/mock_chooser_controller.h" | 5 #include "chrome/browser/chooser_controller/mock_chooser_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/grit/generated_resources.h" | 11 #include "chrome/grit/generated_resources.h" |
| 12 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
| 13 | 13 |
| 14 MockChooserController::MockChooserController(content::RenderFrameHost* owner) | 14 MockChooserController::MockChooserController(content::RenderFrameHost* owner) |
| 15 : ChooserController(owner, | 15 : ChooserController(owner, |
| 16 IDS_USB_DEVICE_CHOOSER_PROMPT_ORIGIN, | 16 IDS_USB_DEVICE_CHOOSER_PROMPT_ORIGIN, |
| 17 IDS_USB_DEVICE_CHOOSER_PROMPT_EXTENSION_NAME), | 17 IDS_USB_DEVICE_CHOOSER_PROMPT_EXTENSION_NAME) {} |
| 18 no_options_text_(l10n_util::GetStringUTF16( | |
| 19 IDS_DEVICE_CHOOSER_NO_DEVICES_FOUND_PROMPT)) {} | |
| 20 | 18 |
| 21 MockChooserController::~MockChooserController() {} | 19 MockChooserController::~MockChooserController() {} |
| 22 | 20 |
| 23 bool MockChooserController::ShouldShowIconBeforeText() const { | 21 bool MockChooserController::ShouldShowIconBeforeText() const { |
| 24 return true; | 22 return true; |
| 25 } | 23 } |
| 26 | 24 |
| 27 base::string16 MockChooserController::GetNoOptionsText() const { | 25 base::string16 MockChooserController::GetNoOptionsText() const { |
| 28 return no_options_text_; | 26 return l10n_util::GetStringUTF16(IDS_DEVICE_CHOOSER_NO_DEVICES_FOUND_PROMPT); |
| 29 } | 27 } |
| 30 | 28 |
| 31 base::string16 MockChooserController::GetOkButtonLabel() const { | 29 base::string16 MockChooserController::GetOkButtonLabel() const { |
| 32 return l10n_util::GetStringUTF16(IDS_USB_DEVICE_CHOOSER_CONNECT_BUTTON_TEXT); | 30 return l10n_util::GetStringUTF16(IDS_USB_DEVICE_CHOOSER_CONNECT_BUTTON_TEXT); |
| 33 } | 31 } |
| 34 | 32 |
| 35 size_t MockChooserController::NumOptions() const { | 33 size_t MockChooserController::NumOptions() const { |
| 36 return options_.size(); | 34 return options_.size(); |
| 37 } | 35 } |
| 38 | 36 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 59 } | 57 } |
| 60 | 58 |
| 61 void MockChooserController::OnAdapterPresenceChanged( | 59 void MockChooserController::OnAdapterPresenceChanged( |
| 62 content::BluetoothChooser::AdapterPresence presence) { | 60 content::BluetoothChooser::AdapterPresence presence) { |
| 63 ClearAllOptions(); | 61 ClearAllOptions(); |
| 64 switch (presence) { | 62 switch (presence) { |
| 65 case content::BluetoothChooser::AdapterPresence::ABSENT: | 63 case content::BluetoothChooser::AdapterPresence::ABSENT: |
| 66 NOTREACHED(); | 64 NOTREACHED(); |
| 67 break; | 65 break; |
| 68 case content::BluetoothChooser::AdapterPresence::POWERED_OFF: | 66 case content::BluetoothChooser::AdapterPresence::POWERED_OFF: |
| 69 no_options_text_ = | |
| 70 l10n_util::GetStringUTF16(IDS_BLUETOOTH_DEVICE_CHOOSER_ADAPTER_OFF); | |
| 71 status_text_ = base::string16(); | 67 status_text_ = base::string16(); |
| 72 if (view()) | 68 if (view()) |
| 73 view()->OnAdapterEnabledChanged(false /* Adapter is turned off */); | 69 view()->OnAdapterEnabledChanged(false /* Adapter is turned off */); |
| 74 break; | 70 break; |
| 75 case content::BluetoothChooser::AdapterPresence::POWERED_ON: | 71 case content::BluetoothChooser::AdapterPresence::POWERED_ON: |
| 76 no_options_text_ = | |
| 77 l10n_util::GetStringUTF16(IDS_DEVICE_CHOOSER_NO_DEVICES_FOUND_PROMPT); | |
| 78 status_text_ = | 72 status_text_ = |
| 79 l10n_util::GetStringUTF16(IDS_BLUETOOTH_DEVICE_CHOOSER_RE_SCAN); | 73 l10n_util::GetStringUTF16(IDS_BLUETOOTH_DEVICE_CHOOSER_RE_SCAN); |
| 80 if (view()) | 74 if (view()) |
| 81 view()->OnAdapterEnabledChanged(true /* Adapter is turned on */); | 75 view()->OnAdapterEnabledChanged(true /* Adapter is turned on */); |
| 82 break; | 76 break; |
| 83 } | 77 } |
| 84 } | 78 } |
| 85 | 79 |
| 86 void MockChooserController::OnDiscoveryStateChanged( | 80 void MockChooserController::OnDiscoveryStateChanged( |
| 87 content::BluetoothChooser::DiscoveryState state) { | 81 content::BluetoothChooser::DiscoveryState state) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 const int MockChooserController::kNoSignalStrengthLevelImage = -1; | 145 const int MockChooserController::kNoSignalStrengthLevelImage = -1; |
| 152 const int MockChooserController::kSignalStrengthLevel0Bar = 0; | 146 const int MockChooserController::kSignalStrengthLevel0Bar = 0; |
| 153 const int MockChooserController::kSignalStrengthLevel1Bar = 1; | 147 const int MockChooserController::kSignalStrengthLevel1Bar = 1; |
| 154 const int MockChooserController::kSignalStrengthLevel2Bar = 2; | 148 const int MockChooserController::kSignalStrengthLevel2Bar = 2; |
| 155 const int MockChooserController::kSignalStrengthLevel3Bar = 3; | 149 const int MockChooserController::kSignalStrengthLevel3Bar = 3; |
| 156 const int MockChooserController::kSignalStrengthLevel4Bar = 4; | 150 const int MockChooserController::kSignalStrengthLevel4Bar = 4; |
| 157 | 151 |
| 158 void MockChooserController::ClearAllOptions() { | 152 void MockChooserController::ClearAllOptions() { |
| 159 options_.clear(); | 153 options_.clear(); |
| 160 } | 154 } |
| OLD | NEW |