Commit 84410a9d authored by Regan Hsu's avatar Regan Hsu Committed by Commit Bot

[CrOS Settings] Initial skeleton of OS and Shared strings provider.

This CL creates a placeholder for the OS settings strings provider
and Shared settings strings provider.

Strings used exclusively by OS settings will be moved to the OS
settings provider, and strings used by both the browser and OS
will be moved to the shared settings string provider.

Follow-up CLs will start transferring strings page-by-page from the
browser strings provider to either the OS or shared string
provider.

As an example, this CL divides the A11y page strings between
browser, OS, and shared string providers.

Bug: 967888
Change-Id: I2f558cca8b17a66b88af184bb5643cabdef7fee7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2001850
Commit-Queue: Regan Hsu <hsuregan@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732645}
parent 0f8e211c
...@@ -1356,6 +1356,8 @@ jumbo_static_library("ui") { ...@@ -1356,6 +1356,8 @@ jumbo_static_library("ui") {
"webui/settings/settings_startup_pages_handler.h", "webui/settings/settings_startup_pages_handler.h",
"webui/settings/settings_ui.cc", "webui/settings/settings_ui.cc",
"webui/settings/settings_ui.h", "webui/settings/settings_ui.h",
"webui/settings/shared_settings_localized_strings_provider.cc",
"webui/settings/shared_settings_localized_strings_provider.h",
"webui/settings/site_settings_handler.cc", "webui/settings/site_settings_handler.cc",
"webui/settings/site_settings_handler.h", "webui/settings/site_settings_handler.h",
"webui/settings_utils.cc", "webui/settings_utils.cc",
...@@ -1948,6 +1950,8 @@ jumbo_static_library("ui") { ...@@ -1948,6 +1950,8 @@ jumbo_static_library("ui") {
"webui/settings/chromeos/kerberos_accounts_handler.h", "webui/settings/chromeos/kerberos_accounts_handler.h",
"webui/settings/chromeos/multidevice_handler.cc", "webui/settings/chromeos/multidevice_handler.cc",
"webui/settings/chromeos/multidevice_handler.h", "webui/settings/chromeos/multidevice_handler.h",
"webui/settings/chromeos/os_settings_localized_strings_provider.cc",
"webui/settings/chromeos/os_settings_localized_strings_provider.h",
"webui/settings/chromeos/os_settings_ui.cc", "webui/settings/chromeos/os_settings_ui.cc",
"webui/settings/chromeos/os_settings_ui.h", "webui/settings/chromeos/os_settings_ui.h",
"webui/settings/chromeos/parental_controls_handler.cc", "webui/settings/chromeos/parental_controls_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.
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_OS_SETTINGS_LOCALIZED_STRINGS_PROVIDER_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_OS_SETTINGS_LOCALIZED_STRINGS_PROVIDER_H_
class Profile;
namespace content {
class WebUIDataSource;
class WebContents;
} // namespace content
namespace chromeos {
namespace settings {
// Adds the strings needed by the OS settings page to |html_source|
// This function causes |html_source| to expose a strings.js file from its
// source which contains a mapping from string's name to its translated value.
void AddOsLocalizedStrings(content::WebUIDataSource* html_source,
Profile* profile,
content::WebContents* web_contents);
} // namespace settings
} // namespace chromeos
#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_OS_SETTINGS_LOCALIZED_STRINGS_PROVIDER_H_
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
#include "chrome/browser/ui/webui/settings/chromeos/internet_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/internet_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/kerberos_accounts_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/kerberos_accounts_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_localized_strings_provider.h"
#include "chrome/browser/ui/webui/settings/chromeos/parental_controls_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/parental_controls_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.h"
...@@ -73,6 +74,7 @@ ...@@ -73,6 +74,7 @@
#include "chrome/browser/ui/webui/settings/settings_cookies_view_handler.h" #include "chrome/browser/ui/webui/settings/settings_cookies_view_handler.h"
#include "chrome/browser/ui/webui/settings/settings_localized_strings_provider.h" #include "chrome/browser/ui/webui/settings/settings_localized_strings_provider.h"
#include "chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.h" #include "chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.h"
#include "chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.h"
#include "chrome/browser/ui/webui/settings/tts_handler.h" #include "chrome/browser/ui/webui/settings/tts_handler.h"
#include "chrome/browser/web_applications/system_web_app_manager.h" #include "chrome/browser/web_applications/system_web_app_manager.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
...@@ -204,8 +206,15 @@ OSSettingsUI::OSSettingsUI(content::WebUI* web_ui) ...@@ -204,8 +206,15 @@ OSSettingsUI::OSSettingsUI(content::WebUI* web_ui)
html_source->AddResourcePath("app-management/image_info.mojom-lite.js", html_source->AddResourcePath("app-management/image_info.mojom-lite.js",
IDR_APP_MANAGEMENT_IMAGE_INFO_MOJO_LITE_JS); IDR_APP_MANAGEMENT_IMAGE_INFO_MOJO_LITE_JS);
::settings::AddLocalizedStrings(html_source, profile, ::chromeos::settings::AddOsLocalizedStrings(html_source, profile,
web_ui->GetWebContents()); web_ui->GetWebContents());
::settings::AddSharedLocalizedStrings(html_source, profile,
web_ui->GetWebContents());
// TODO(crbug/967888): Remove when all the needed keys have been added
// to os_localized_string_provider.
::settings::AddBrowserLocalizedStrings(html_source, profile,
web_ui->GetWebContents());
auto plural_string_handler = std::make_unique<PluralStringHandler>(); auto plural_string_handler = std::make_unique<PluralStringHandler>();
plural_string_handler->AddLocalizedString("profileLabel", plural_string_handler->AddLocalizedString("profileLabel",
......
...@@ -14,12 +14,14 @@ class WebContents; ...@@ -14,12 +14,14 @@ class WebContents;
namespace settings { namespace settings {
// Adds the strings needed by the settings page to |html_source|. This function // Adds the strings needed by the browser settings page to |html_source|
// causes |html_source| to expose a strings.js file from its source which // This function causes |html_source| to expose a strings.js file from its
// contains a mapping from string's name to its translated value. // source which contains a mapping from string's name to its translated value.
void AddLocalizedStrings(content::WebUIDataSource* html_source, // TODO(crbug/967888): This still contains OS Settings strings. Strings specific
Profile* profile, // to OS settings should be moved to os_settings_localized_strings_provider.cc.
content::WebContents* web_contents); void AddBrowserLocalizedStrings(content::WebUIDataSource* html_source,
Profile* profile,
content::WebContents* web_contents);
} // namespace settings } // namespace settings
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "chrome/browser/ui/webui/settings/settings_security_key_handler.h" #include "chrome/browser/ui/webui/settings/settings_security_key_handler.h"
#include "chrome/browser/ui/webui/settings/settings_startup_pages_handler.h" #include "chrome/browser/ui/webui/settings/settings_startup_pages_handler.h"
#include "chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.h"
#include "chrome/browser/ui/webui/settings/site_settings_handler.h" #include "chrome/browser/ui/webui/settings/site_settings_handler.h"
#include "chrome/browser/web_applications/components/app_registrar.h" #include "chrome/browser/web_applications/components/app_registrar.h"
#include "chrome/browser/web_applications/web_app_provider.h" #include "chrome/browser/web_applications/web_app_provider.h"
...@@ -281,7 +282,8 @@ SettingsUI::SettingsUI(content::WebUI* web_ui) ...@@ -281,7 +282,8 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
html_source->SetDefaultResource(IDR_SETTINGS_SETTINGS_HTML); html_source->SetDefaultResource(IDR_SETTINGS_SETTINGS_HTML);
#endif #endif
AddLocalizedStrings(html_source, profile, web_ui->GetWebContents()); AddSharedLocalizedStrings(html_source, profile, web_ui->GetWebContents());
AddBrowserLocalizedStrings(html_source, profile, web_ui->GetWebContents());
ManagedUIHandler::Initialize(web_ui, html_source); ManagedUIHandler::Initialize(web_ui, html_source);
......
// 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/shared_settings_localized_strings_provider.h"
#include "base/feature_list.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/chrome_features.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/common/content_features.h"
#include "media/base/media_switches.h"
namespace settings {
namespace {
void AddA11yStrings(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"a11yPageTitle", IDS_SETTINGS_ACCESSIBILITY},
{"a11yWebStore", IDS_SETTINGS_ACCESSIBILITY_WEB_STORE},
{"moreFeaturesLinkDescription",
IDS_SETTINGS_MORE_FEATURES_LINK_DESCRIPTION},
{"accessibleImageLabelsTitle", IDS_SETTINGS_ACCESSIBLE_IMAGE_LABELS_TITLE},
{"accessibleImageLabelsSubtitle",
IDS_SETTINGS_ACCESSIBLE_IMAGE_LABELS_SUBTITLE},
{"settingsSliderRoleDescription",
IDS_SETTINGS_SLIDER_MIN_MAX_ARIA_ROLE_DESCRIPTION},
#if defined(OS_CHROMEOS)
{"manageAccessibilityFeatures",
IDS_SETTINGS_ACCESSIBILITY_MANAGE_ACCESSIBILITY_FEATURES},
#endif // defined(OS_CHROMEOS)
};
AddLocalizedStringsBulk(html_source, kLocalizedStrings);
html_source->AddBoolean(
"showExperimentalA11yLabels",
base::FeatureList::IsEnabled(features::kExperimentalAccessibilityLabels));
html_source->AddBoolean(
"enableCaptionSettings",
base::FeatureList::IsEnabled(features::kCaptionSettings));
html_source->AddBoolean("enableLiveCaption",
base::FeatureList::IsEnabled(media::kLiveCaption));
}
} // namespace
void AddSharedLocalizedStrings(content::WebUIDataSource* html_source,
Profile* profile,
content::WebContents* web_contents) {
AddA11yStrings(html_source);
}
void AddSharedA11yStrings(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"captionsTitle", IDS_SETTINGS_CAPTIONS},
{"captionsSettings", IDS_SETTINGS_CAPTIONS_SETTINGS},
{"captionsPreview", IDS_SETTINGS_CAPTIONS_PREVIEW},
{"captionsTextSize", IDS_SETTINGS_CAPTIONS_TEXT_SIZE},
{"captionsTextFont", IDS_SETTINGS_CAPTIONS_TEXT_FONT},
{"captionsTextColor", IDS_SETTINGS_CAPTIONS_TEXT_COLOR},
{"captionsTextOpacity", IDS_SETTINGS_CAPTIONS_TEXT_OPACITY},
{"captionsBackgroundOpacity", IDS_SETTINGS_CAPTIONS_BACKGROUND_OPACITY},
{"captionsOpacityOpaque", IDS_SETTINGS_CAPTIONS_OPACITY_OPAQUE},
{"captionsOpacitySemiTransparent",
IDS_SETTINGS_CAPTIONS_OPACITY_SEMI_TRANSPARENT},
{"captionsOpacityTransparent", IDS_SETTINGS_CAPTIONS_OPACITY_TRANSPARENT},
{"captionsTextShadow", IDS_SETTINGS_CAPTIONS_TEXT_SHADOW},
{"captionsTextShadowNone", IDS_SETTINGS_CAPTIONS_TEXT_SHADOW_NONE},
{"captionsTextShadowRaised", IDS_SETTINGS_CAPTIONS_TEXT_SHADOW_RAISED},
{"captionsTextShadowDepressed",
IDS_SETTINGS_CAPTIONS_TEXT_SHADOW_DEPRESSED},
{"captionsTextShadowUniform", IDS_SETTINGS_CAPTIONS_TEXT_SHADOW_UNIFORM},
{"captionsTextShadowDropShadow",
IDS_SETTINGS_CAPTIONS_TEXT_SHADOW_DROP_SHADOW},
{"captionsBackgroundColor", IDS_SETTINGS_CAPTIONS_BACKGROUND_COLOR},
{"captionsColorBlack", IDS_SETTINGS_CAPTIONS_COLOR_BLACK},
{"captionsColorWhite", IDS_SETTINGS_CAPTIONS_COLOR_WHITE},
{"captionsColorRed", IDS_SETTINGS_CAPTIONS_COLOR_RED},
{"captionsColorGreen", IDS_SETTINGS_CAPTIONS_COLOR_GREEN},
{"captionsColorBlue", IDS_SETTINGS_CAPTIONS_COLOR_BLUE},
{"captionsColorYellow", IDS_SETTINGS_CAPTIONS_COLOR_YELLOW},
{"captionsColorCyan", IDS_SETTINGS_CAPTIONS_COLOR_CYAN},
{"captionsColorMagenta", IDS_SETTINGS_CAPTIONS_COLOR_MAGENTA},
{"captionsDefaultSetting", IDS_SETTINGS_CAPTIONS_DEFAULT_SETTING},
{"captionsEnableLiveCaption", IDS_SETTINGS_CAPTIONS_ENABLE_LIVE_CAPTION},
};
AddLocalizedStringsBulk(html_source, kLocalizedStrings);
}
} // namespace settings
// 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_SHARED_SETTINGS_LOCALIZED_STRINGS_PROVIDER_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_SHARED_SETTINGS_LOCALIZED_STRINGS_PROVIDER_H_
class Profile;
namespace content {
class WebUIDataSource;
class WebContents;
} // namespace content
namespace settings {
// Adds the strings needed by OS and Browser settings page to |html_source|
// This function causes |html_source| to expose a strings.js file from its
// source which contains a mapping from string's name to its translated value.
void AddSharedLocalizedStrings(content::WebUIDataSource* html_source,
Profile* profile,
content::WebContents* web_contents);
// The set of strings used by the A11y subpage that manages accessibility
// features, excluding the top-level settings rows which link to this section.
void AddSharedA11yStrings(content::WebUIDataSource* html_source);
} // namespace settings
#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SHARED_SETTINGS_LOCALIZED_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