fake_usb_chooser_controller.cc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2017 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. #include "components/permissions/fake_usb_chooser_controller.h"
  5. #include "base/strings/stringprintf.h"
  6. #include "base/strings/utf_string_conversions.h"
  7. #include "components/strings/grit/components_strings.h"
  8. #include "ui/base/l10n/l10n_util.h"
  9. FakeUsbChooserController::FakeUsbChooserController(int device_count)
  10. : ChooserController(u""), device_count_(device_count) {
  11. set_title_for_testing(l10n_util::GetStringFUTF16(
  12. IDS_USB_DEVICE_CHOOSER_PROMPT_ORIGIN, u"example.com"));
  13. }
  14. std::u16string FakeUsbChooserController::GetNoOptionsText() const {
  15. return l10n_util::GetStringUTF16(IDS_DEVICE_CHOOSER_NO_DEVICES_FOUND_PROMPT);
  16. }
  17. std::u16string FakeUsbChooserController::GetOkButtonLabel() const {
  18. return l10n_util::GetStringUTF16(IDS_USB_DEVICE_CHOOSER_CONNECT_BUTTON_TEXT);
  19. }
  20. std::pair<std::u16string, std::u16string>
  21. FakeUsbChooserController::GetThrobberLabelAndTooltip() const {
  22. return {
  23. l10n_util::GetStringUTF16(IDS_USB_DEVICE_CHOOSER_LOADING_LABEL),
  24. l10n_util::GetStringUTF16(IDS_USB_DEVICE_CHOOSER_LOADING_LABEL_TOOLTIP)};
  25. }
  26. size_t FakeUsbChooserController::NumOptions() const {
  27. return device_count_;
  28. }
  29. std::u16string FakeUsbChooserController::GetOption(size_t index) const {
  30. return base::ASCIIToUTF16(base::StringPrintf("Device #%zu", index));
  31. }