Commit 49fdb4e1 authored by Kyle Horimoto's avatar Kyle Horimoto Committed by Commit Bot

[CrOS Settings] Add PrintingStringsProvider

This CL migrates Printing UI strings to a per-page provider and adds
TODOs for adding relevant search tags.

Bug: 1069849
Change-Id: I69d261b65b3003305f608997e85a3d92d4f93b0d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2165672
Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#762665}
parent ac3c0e49
......@@ -2077,6 +2077,8 @@ jumbo_static_library("ui") {
"webui/settings/chromeos/plugin_vm_strings_provider.h",
"webui/settings/chromeos/pref_names.cc",
"webui/settings/chromeos/pref_names.h",
"webui/settings/chromeos/printing_strings_provider.cc",
"webui/settings/chromeos/printing_strings_provider.h",
"webui/settings/chromeos/privacy_strings_provider.cc",
"webui/settings/chromeos/privacy_strings_provider.h",
"webui/settings/chromeos/quick_unlock_handler.cc",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/webui/settings/chromeos/printing_strings_provider.h"
#include "base/feature_list.h"
#include "base/no_destructor.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/web_ui_data_source.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/web_ui_util.h"
namespace chromeos {
namespace settings {
namespace {
const std::vector<SearchConcept>& GetPrintingSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
// TODO(khorimoto): Add "Printing" search concepts.
});
return *tags;
}
} // namespace
PrintingStringsProvider::PrintingStringsProvider(Profile* profile,
Delegate* per_page_delegate)
: OsSettingsPerPageStringsProvider(profile, per_page_delegate) {
delegate()->AddSearchTags(GetPrintingSearchConcepts());
}
PrintingStringsProvider::~PrintingStringsProvider() = default;
void PrintingStringsProvider::AddUiStrings(
content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"printingPageTitle", IDS_SETTINGS_PRINTING},
{"cupsPrintersTitle", IDS_SETTINGS_PRINTING_CUPS_PRINTERS},
{"cupsPrintersLearnMoreLabel",
IDS_SETTINGS_PRINTING_CUPS_PRINTERS_LEARN_MORE_LABEL},
{"addCupsPrinter", IDS_SETTINGS_PRINTING_CUPS_PRINTERS_ADD_PRINTER},
{"editPrinter", IDS_SETTINGS_PRINTING_CUPS_PRINTERS_EDIT},
{"removePrinter", IDS_SETTINGS_PRINTING_CUPS_PRINTERS_REMOVE},
{"setupPrinter", IDS_SETTINGS_PRINTING_CUPS_PRINTER_SETUP_BUTTON},
{"setupPrinterAria",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_SETUP_BUTTON_ARIA},
{"savePrinter", IDS_SETTINGS_PRINTING_CUPS_PRINTER_SAVE_BUTTON},
{"savePrinterAria", IDS_SETTINGS_PRINTING_CUPS_PRINTER_SAVE_BUTTON_ARIA},
{"searchLabel", IDS_SETTINGS_PRINTING_CUPS_SEARCH_LABEL},
{"noSearchResults", IDS_SEARCH_NO_RESULTS},
{"printerDetailsTitle", IDS_SETTINGS_PRINTING_CUPS_PRINTER_DETAILS_TITLE},
{"printerName", IDS_SETTINGS_PRINTING_CUPS_PRINTER_DETAILS_NAME},
{"printerModel", IDS_SETTINGS_PRINTING_CUPS_PRINTER_DETAILS_MODEL},
{"printerQueue", IDS_SETTINGS_PRINTING_CUPS_PRINTER_DETAILS_QUEUE},
{"savedPrintersTitle", IDS_SETTINGS_PRINTING_CUPS_SAVED_PRINTERS_TITLE},
{"savedPrintersCountMany",
IDS_SETTINGS_PRINTING_CUPS_PRINTERS_SAVED_PRINTERS_COUNT_MANY},
{"savedPrintersCountOne",
IDS_SETTINGS_PRINTING_CUPS_PRINTERS_SAVED_PRINTERS_COUNT_ONE},
{"savedPrintersCountNone",
IDS_SETTINGS_PRINTING_CUPS_PRINTERS_SAVED_PRINTERS_COUNT_NONE},
{"showMorePrinters", IDS_SETTINGS_PRINTING_CUPS_SHOW_MORE},
{"addPrintersNearbyTitle",
IDS_SETTINGS_PRINTING_CUPS_ADD_PRINTERS_NEARBY_TITLE},
{"addPrintersManuallyTitle",
IDS_SETTINGS_PRINTING_CUPS_ADD_PRINTERS_MANUALLY_TITLE},
{"manufacturerAndModelDialogTitle",
IDS_SETTINGS_PRINTING_CUPS_SELECT_MANUFACTURER_AND_MODEL_TITLE},
{"nearbyPrintersListTitle",
IDS_SETTINGS_PRINTING_CUPS_PRINTERS_AVAILABLE_PRINTERS},
{"nearbyPrintersCountMany",
IDS_SETTINGS_PRINTING_CUPS_PRINTERS_AVAILABLE_PRINTERS_COUNT_MANY},
{"nearbyPrintersCountOne",
IDS_SETTINGS_PRINTING_CUPS_PRINTERS_AVAILABLE_PRINTER_COUNT_ONE},
{"nearbyPrintersCountNone",
IDS_SETTINGS_PRINTING_CUPS_PRINTERS_AVAILABLE_PRINTER_COUNT_NONE},
{"nearbyPrintersListDescription",
IDS_SETTINGS_PRINTING_CUPS_PRINTERS_ADD_DETECTED_OR_NEW_PRINTER},
{"manufacturerAndModelAdditionalInformation",
IDS_SETTINGS_PRINTING_CUPS_MANUFACTURER_MODEL_ADDITIONAL_INFORMATION},
{"addPrinterButtonText",
IDS_SETTINGS_PRINTING_CUPS_ADD_PRINTER_BUTTON_ADD},
{"printerDetailsAdvanced", IDS_SETTINGS_PRINTING_CUPS_PRINTER_ADVANCED},
{"printerDetailsA11yLabel",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_ADVANCED_ACCESSIBILITY_LABEL},
{"printerAddress", IDS_SETTINGS_PRINTING_CUPS_PRINTER_ADVANCED_ADDRESS},
{"printerProtocol", IDS_SETTINGS_PRINTING_CUPS_PRINTER_ADVANCED_PROTOCOL},
{"printerURI", IDS_SETTINGS_PRINTING_CUPS_PRINTER_ADVANCED_URI},
{"manuallyAddPrinterButtonText",
IDS_SETTINGS_PRINTING_CUPS_ADD_PRINTER_BUTTON_MANUAL_ADD},
{"discoverPrintersButtonText",
IDS_SETTINGS_PRINTING_CUPS_ADD_PRINTER_BUTTON_DISCOVER_PRINTERS},
{"printerProtocolIpp", IDS_SETTINGS_PRINTING_CUPS_PRINTER_PROTOCOL_IPP},
{"printerProtocolIpps", IDS_SETTINGS_PRINTING_CUPS_PRINTER_PROTOCOL_IPPS},
{"printerProtocolHttp", IDS_SETTINGS_PRINTING_CUPS_PRINTER_PROTOCOL_HTTP},
{"printerProtocolHttps",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_PROTOCOL_HTTPS},
{"printerProtocolAppSocket",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_PROTOCOL_APP_SOCKET},
{"printerProtocolLpd", IDS_SETTINGS_PRINTING_CUPS_PRINTER_PROTOCOL_LPD},
{"printerProtocolUsb", IDS_SETTINGS_PRINTING_CUPS_PRINTER_PROTOCOL_USB},
{"printerProtocolIppUsb",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_PROTOCOL_IPPUSB},
{"printerConfiguringMessage",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_CONFIGURING_MESSAGE},
{"printerManufacturer", IDS_SETTINGS_PRINTING_CUPS_PRINTER_MANUFACTURER},
{"selectDriver", IDS_SETTINGS_PRINTING_CUPS_PRINTER_SELECT_DRIVER},
{"selectDriverButtonText",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_BUTTON_SELECT_DRIVER},
{"selectDriverButtonAriaLabel",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_BUTTON_SELECT_DRIVER_ARIA_LABEL},
{"selectDriverErrorMessage",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_INVALID_DRIVER},
{"printerAddedSuccessfulMessage",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_ADDED_PRINTER_DONE_MESSAGE},
{"printerEditedSuccessfulMessage",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_EDITED_PRINTER_DONE_MESSAGE},
{"printerUnavailableMessage",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_UNAVAILABLE_MESSAGE},
{"noPrinterNearbyMessage",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_NO_PRINTER_NEARBY},
{"searchingNearbyPrinters",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_SEARCHING_NEARBY_PRINTER},
{"printerAddedFailedMessage",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_ADDED_PRINTER_ERROR_MESSAGE},
{"printerAddedFatalErrorMessage",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_ADDED_PRINTER_FATAL_ERROR_MESSAGE},
{"printerAddedUnreachableMessage",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_ADDED_PRINTER_PRINTER_UNREACHABLE_MESSAGE},
{"printerAddedPpdTooLargeMessage",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_ADDED_PRINTER_PPD_TOO_LARGE_MESSAGE},
{"printerAddedInvalidPpdMessage",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_ADDED_PRINTER_INVALID_PPD_MESSAGE},
{"printerAddedPpdNotFoundMessage",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_ADDED_PRINTER_PPD_NOT_FOUND},
{"printerAddedPpdUnretrievableMessage",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_ADDED_PRINTER_PPD_UNRETRIEVABLE},
{"printerAddedNativePrintersNotAllowedMessage",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_ADDED_NATIVE_PRINTERS_NOT_ALLOWED_MESSAGE},
{"editPrinterInvalidPrinterUpdate",
IDS_SETTINGS_PRINTING_CUPS_EDIT_PRINTER_INVALID_PRINTER_UPDATE},
{"requireNetworkMessage",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_REQUIRE_INTERNET_MESSAGE},
{"checkNetworkMessage",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_CHECK_CONNECTION_MESSAGE},
{"noInternetConnection",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_NO_INTERNET_CONNECTION},
{"checkNetworkAndTryAgain",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_CONNECT_TO_NETWORK_SUBTEXT},
{"editPrinterDialogTitle",
IDS_SETTINGS_PRINTING_CUPS_EDIT_PRINTER_DIALOG_TITLE},
{"editPrinterButtonText", IDS_SETTINGS_PRINTING_CUPS_EDIT_PRINTER_BUTTON},
{"currentPpdMessage",
IDS_SETTINGS_PRINTING_CUPS_EDIT_PRINTER_CURRENT_PPD_MESSAGE},
{"printerEulaNotice", IDS_SETTINGS_PRINTING_CUPS_EULA_NOTICE},
{"ippPrinterUnreachable", IDS_SETTINGS_PRINTING_CUPS_IPP_URI_UNREACHABLE},
{"generalPrinterDialogError",
IDS_SETTINGS_PRINTING_CUPS_DIALOG_GENERAL_ERROR},
{"printServerButtonText", IDS_SETTINGS_PRINTING_CUPS_PRINT_SERVER},
{"addPrintServerTitle",
IDS_SETTINGS_PRINTING_CUPS_ADD_PRINT_SERVER_TITLE},
{"printServerAddress", IDS_SETTINGS_PRINTING_CUPS_PRINT_SERVER_ADDRESS},
{"printServerFoundZeroPrinters",
IDS_SETTINGS_PRINTING_CUPS_PRINT_SERVER_FOUND_ZERO_PRINTERS},
{"printServerFoundOnePrinter",
IDS_SETTINGS_PRINTING_CUPS_PRINT_SERVER_FOUND_ONE_PRINTER},
{"printServerFoundManyPrinters",
IDS_SETTINGS_PRINTING_CUPS_PRINT_SERVER_FOUND_MANY_PRINTERS},
{"printServerInvalidUrlAddress",
IDS_SETTINGS_PRINTING_CUPS_PRINT_SERVER_INVALID_URL_ADDRESS},
{"printServerConnectionError",
IDS_SETTINGS_PRINTING_CUPS_PRINT_SERVER_CONNECTION_ERROR},
{"printServerConfigurationErrorMessage",
IDS_SETTINGS_PRINTING_CUPS_PRINT_SERVER_REACHABLE_BUT_CANNOT_ADD},
};
AddLocalizedStringsBulk(html_source, kLocalizedStrings);
html_source->AddString("printingCUPSPrintLearnMoreUrl",
GetHelpUrlWithBoard(chrome::kCupsPrintLearnMoreURL));
html_source->AddString(
"printingCUPSPrintPpdLearnMoreUrl",
GetHelpUrlWithBoard(chrome::kCupsPrintPPDLearnMoreURL));
html_source->AddBoolean(
"consumerPrintServerUiEnabled",
base::FeatureList::IsEnabled(::features::kPrintServerUi));
}
} // namespace settings
} // namespace chromeos
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_PRINTING_STRINGS_PROVIDER_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_PRINTING_STRINGS_PROVIDER_H_
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_per_page_strings_provider.h"
namespace content {
class WebUIDataSource;
} // namespace content
namespace chromeos {
namespace settings {
// Provides UI strings and search tags for Printing settings.
class PrintingStringsProvider : public OsSettingsPerPageStringsProvider {
public:
PrintingStringsProvider(Profile* profile, Delegate* per_page_delegate);
~PrintingStringsProvider() override;
private:
// OsSettingsPerPageStringsProvider:
void AddUiStrings(content::WebUIDataSource* html_source) override;
};
} // namespace settings
} // namespace chromeos
#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_PRINTING_STRINGS_PROVIDER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment