Commit 5d517cc9 authored by Regan Hsu's avatar Regan Hsu Committed by Commit Bot

[CrOS Settings] Copy Search strings from browser to OS settings.

This CL copies strings used by the OS Search page from browser settings
to OS settings, and removes strings unused the browser settings.

Bug: 967888
Change-Id: I2a326c91a2aa19b1d83fae11a598029bc6e67a41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2031166
Commit-Queue: Regan Hsu <hsuregan@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737982}
parent bac78793
......@@ -5,6 +5,7 @@
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_localized_strings_provider.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/mojom/assistant_state_controller.mojom.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/strings/stringprintf.h"
......@@ -16,6 +17,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/assistant/assistant_util.h"
#include "chrome/browser/chromeos/crostini/crostini_features.h"
#include "chrome/browser/chromeos/crostini/crostini_util.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
......@@ -1545,6 +1547,37 @@ void AddResetStrings(content::WebUIDataSource* html_source) {
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
}
void AddSearchStrings(content::WebUIDataSource* html_source, Profile* profile) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"osSearchEngineLabel", IDS_OS_SETTINGS_SEARCH_ENGINE_LABEL},
{"searchGoogleAssistant", IDS_SETTINGS_SEARCH_GOOGLE_ASSISTANT},
{"searchGoogleAssistantEnabled",
IDS_SETTINGS_SEARCH_GOOGLE_ASSISTANT_ENABLED},
{"searchGoogleAssistantDisabled",
IDS_SETTINGS_SEARCH_GOOGLE_ASSISTANT_DISABLED},
{"searchGoogleAssistantOn", IDS_SETTINGS_SEARCH_GOOGLE_ASSISTANT_ON},
{"searchGoogleAssistantOff", IDS_SETTINGS_SEARCH_GOOGLE_ASSISTANT_OFF},
};
AddLocalizedStringsBulk(html_source, kLocalizedStrings);
// NOTE: This will be false when the flag is disabled.
const bool is_assistant_allowed =
::assistant::IsAssistantAllowedForProfile(profile) ==
ash::mojom::AssistantAllowedState::ALLOWED;
html_source->AddBoolean("isAssistantAllowed", is_assistant_allowed);
html_source->AddLocalizedString("osSearchPageTitle",
is_assistant_allowed
? IDS_SETTINGS_SEARCH_AND_ASSISTANT
: IDS_SETTINGS_SEARCH);
html_source->AddString("searchExplanation",
l10n_util::GetStringFUTF16(
IDS_SETTINGS_SEARCH_EXPLANATION,
base::ASCIIToUTF16(chrome::kOmniboxLearnMoreURL)));
html_source->AddString(
"osSearchEngineTooltip",
ui::SubstituteChromeOSDeviceType(IDS_OS_SETTINGS_SEARCH_ENGINE_TOOLTIP));
}
} // namespace
void AddOsLocalizedStrings(content::WebUIDataSource* html_source,
......@@ -1573,6 +1606,7 @@ void AddOsLocalizedStrings(content::WebUIDataSource* html_source,
AddPrintingStrings(html_source);
AddResetStrings(html_source);
AddSearchInSettingsStrings(html_source);
AddSearchStrings(html_source, profile);
AddUsersStrings(html_source);
}
......
......@@ -78,10 +78,8 @@
#if defined(OS_CHROMEOS)
#include "ash/public/cpp/ash_switches.h"
#include "ash/public/mojom/assistant_state_controller.mojom.h"
#include "base/system/sys_info.h"
#include "chrome/browser/chromeos/account_manager/account_manager_util.h"
#include "chrome/browser/chromeos/assistant/assistant_util.h"
#include "chrome/browser/chromeos/kerberos/kerberos_credentials_manager.h"
#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
......@@ -1476,46 +1474,18 @@ void AddSearchInSettingsStrings(content::WebUIDataSource* html_source) {
html_source->AddString("searchNoResultsHelp", help_text);
}
void AddSearchStrings(content::WebUIDataSource* html_source, Profile* profile) {
#if defined(OS_CHROMEOS)
// NOTE: This will be false when the flag is disabled.
const bool is_assistant_allowed =
assistant::IsAssistantAllowedForProfile(profile) ==
ash::mojom::AssistantAllowedState::ALLOWED;
#endif
void AddSearchStrings(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"searchEnginesManage", IDS_SETTINGS_SEARCH_MANAGE_SEARCH_ENGINES},
{"searchPageTitle", IDS_SETTINGS_SEARCH},
#if defined(OS_CHROMEOS)
{"osSearchEngineLabel", IDS_OS_SETTINGS_SEARCH_ENGINE_LABEL},
{"searchGoogleAssistant", IDS_SETTINGS_SEARCH_GOOGLE_ASSISTANT},
{"searchGoogleAssistantEnabled",
IDS_SETTINGS_SEARCH_GOOGLE_ASSISTANT_ENABLED},
{"searchGoogleAssistantDisabled",
IDS_SETTINGS_SEARCH_GOOGLE_ASSISTANT_DISABLED},
{"searchGoogleAssistantOn", IDS_SETTINGS_SEARCH_GOOGLE_ASSISTANT_ON},
{"searchGoogleAssistantOff", IDS_SETTINGS_SEARCH_GOOGLE_ASSISTANT_OFF},
#endif
{"searchEnginesManage", IDS_SETTINGS_SEARCH_MANAGE_SEARCH_ENGINES},
{"searchPageTitle", IDS_SETTINGS_SEARCH},
};
AddLocalizedStringsBulk(html_source, kLocalizedStrings);
#if defined(OS_CHROMEOS)
html_source->AddLocalizedString("osSearchPageTitle",
is_assistant_allowed
? IDS_SETTINGS_SEARCH_AND_ASSISTANT
: IDS_SETTINGS_SEARCH);
#endif
base::string16 search_explanation_text = l10n_util::GetStringFUTF16(
IDS_SETTINGS_SEARCH_EXPLANATION,
base::ASCIIToUTF16(chrome::kOmniboxLearnMoreURL));
html_source->AddString("searchExplanation", search_explanation_text);
#if defined(OS_CHROMEOS)
html_source->AddString(
"osSearchEngineTooltip",
ui::SubstituteChromeOSDeviceType(IDS_OS_SETTINGS_SEARCH_ENGINE_TOOLTIP));
html_source->AddBoolean("isAssistantAllowed", is_assistant_allowed);
#endif
html_source->AddString("searchExplanation",
l10n_util::GetStringFUTF16(
IDS_SETTINGS_SEARCH_EXPLANATION,
base::ASCIIToUTF16(chrome::kOmniboxLearnMoreURL)));
}
void AddSearchEnginesStrings(content::WebUIDataSource* html_source) {
......@@ -2201,7 +2171,7 @@ void AddBrowserLocalizedStrings(content::WebUIDataSource* html_source,
AddResetStrings(html_source);
AddSearchEnginesStrings(html_source);
AddSearchInSettingsStrings(html_source);
AddSearchStrings(html_source, profile);
AddSearchStrings(html_source);
AddSiteSettingsStrings(html_source, profile);
#if defined(OS_CHROMEOS)
......
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