Commit 1f53b5c8 authored by Kyle Horimoto's avatar Kyle Horimoto Committed by Chromium LUCI CQ

[CrOS Cellular] Use "updatedCellularActivationUi" bool in OOBE

Before this CL, this loadTimeData boolean was missing in OOBE, resulting
in a console error. This CL moves it to a shared location which is
called from both OOBE and settings.

Fixed: 1162251
Change-Id: I42e9504e903ff3fa26d797b26c8bf19967f022c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2606708Reviewed-by: default avatarAzeem Arshad <azeemarshad@chromium.org>
Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#839647}
parent d208eca4
......@@ -4,17 +4,20 @@
#include "chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.h"
#include "base/containers/span.h"
#include "base/feature_list.h"
#include "base/no_destructor.h"
#include "base/values.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/constants/chromeos_features.h"
#include "components/login/localized_values_builder.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_ui_data_source.h"
#include "ui/base/webui/web_ui_util.h"
namespace chromeos {
namespace cellular_setup {
namespace {
constexpr webui::LocalizedString kLocalizedStringsWithoutPlaceholders[] = {
......@@ -63,6 +66,21 @@ constexpr webui::LocalizedString kLocalizedStringsWithoutPlaceholders[] = {
{"qrCodeRetry", IDS_CELLULAR_SETUP_ESIM_PAGE_SCAN_QR_CODE_RETRY},
{"scanQrCodeInvalid", IDS_CELLULAR_SETUP_ESIM_PAGE_SCAN_QR_CODE_INVALID},
{"profileListPageMessage", IDS_CELLULAR_SETUP_PROFILE_LIST_PAGE_MESSAGE}};
struct NamedBoolean {
const char* name;
bool value;
};
const std::vector<const NamedBoolean>& GetBooleanValues() {
static const base::NoDestructor<std::vector<const NamedBoolean>> named_bools({
{"updatedCellularActivationUi",
base::FeatureList::IsEnabled(
chromeos::features::kUpdatedCellularActivationUi)},
});
return *named_bools;
}
} // namespace
void AddLocalizedStrings(content::WebUIDataSource* html_source) {
......@@ -74,6 +92,15 @@ void AddLocalizedValuesToBuilder(::login::LocalizedValuesBuilder* builder) {
builder->Add(entry.name, entry.id);
}
} // namespace cellular_setup
void AddNonStringLoadTimeData(content::WebUIDataSource* html_source) {
for (const auto& entry : GetBooleanValues())
html_source->AddBoolean(entry.name, entry.value);
}
void AddNonStringLoadTimeDataToDict(base::DictionaryValue* dict) {
for (const auto& entry : GetBooleanValues())
dict->SetBoolean(entry.name, entry.value);
}
} // namespace cellular_setup
} // namespace chromeos
......@@ -5,16 +5,19 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_CELLULAR_SETUP_CELLULAR_SETUP_LOCALIZED_STRINGS_PROVIDER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_CELLULAR_SETUP_CELLULAR_SETUP_LOCALIZED_STRINGS_PROVIDER_H_
namespace base {
class DictionaryValue;
} // namespace base
namespace login {
class LocalizedValuesBuilder;
}
} // namespace login
namespace content {
class WebUIDataSource;
}
} // namespace content
namespace chromeos {
namespace cellular_setup {
// Adds the strings needed for the cellular setup flow to |html_source|.
......@@ -23,8 +26,13 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source);
// Same as AddLocalizedStrings() but for a LocalizedValuesBuilder.
void AddLocalizedValuesToBuilder(::login::LocalizedValuesBuilder* builder);
} // namespace cellular_setup
// Adds non-string constants for loadTimeData consumption.
void AddNonStringLoadTimeData(content::WebUIDataSource* html_source);
// Same as AddNonStringLoadTimeData() but for a DictionaryValue.
void AddNonStringLoadTimeDataToDict(base::DictionaryValue* dict);
} // namespace cellular_setup
} // namespace chromeos
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_CELLULAR_SETUP_CELLULAR_SETUP_LOCALIZED_STRINGS_PROVIDER_H_
......@@ -10,6 +10,7 @@
#include "chrome/browser/chromeos/login/demo_mode/demo_setup_controller.h"
#include "chrome/browser/chromeos/login/screens/network_screen.h"
#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.h"
#include "chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h"
#include "chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.h"
#include "chrome/grit/generated_resources.h"
......@@ -98,10 +99,12 @@ void NetworkScreenHandler::DeclareLocalizedValues(
builder->Add("offlineDemoSetupListItemName",
IDS_NETWORK_OFFLINE_DEMO_SETUP_LIST_ITEM_NAME);
network_element::AddLocalizedValuesToBuilder(builder);
cellular_setup::AddLocalizedValuesToBuilder(builder);
}
void NetworkScreenHandler::GetAdditionalParameters(
base::DictionaryValue* dict) {
cellular_setup::AddNonStringLoadTimeDataToDict(dict);
}
void NetworkScreenHandler::Initialize() {
......
......@@ -734,6 +734,7 @@ void InternetSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
network_element::AddDetailsLocalizedStrings(html_source);
network_element::AddConfigLocalizedStrings(html_source);
network_element::AddErrorLocalizedStrings(html_source);
cellular_setup::AddNonStringLoadTimeData(html_source);
if (base::FeatureList::IsEnabled(
chromeos::features::kUpdatedCellularActivationUi)) {
cellular_setup::AddLocalizedStrings(html_source);
......@@ -747,10 +748,6 @@ void InternetSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
html_source->AddString("networkGoogleNameserversLearnMoreUrl",
chrome::kGoogleNameserversLearnMoreURL);
html_source->AddBoolean(
"updatedCellularActivationUi",
base::FeatureList::IsEnabled(
chromeos::features::kUpdatedCellularActivationUi));
html_source->AddString(
"networkNotSynced",
......
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