Skip to content

Commit

Permalink
remove demo mode language and keyboard selection
Browse files Browse the repository at this point in the history
Bug: b/227652797
Change-Id: I284320524accae88bbb417a650afc73a3e09989f
screenshot: https://screenshot.googleplex.com/8EBznnC5hWddHF3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3564188
Reviewed-by: Roman Sorokin <rsorokin@chromium.org>
Reviewed-by: Yves Arrouye <drcrash@chromium.org>
Commit-Queue: Geng Li <ligeng@google.com>
Cr-Commit-Position: refs/heads/main@{#988592}
  • Loading branch information
Geng Li authored and Chromium LUCI CQ committed Apr 4, 2022
1 parent 9f23039 commit 1d9b11c
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 111 deletions.
37 changes: 1 addition & 36 deletions chrome/browser/ash/login/screens/demo_preferences_screen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#include "chrome/browser/ash/login/screens/demo_preferences_screen.h"

#include "chrome/browser/ash/login/demo_mode/demo_session.h"
#include "chrome/browser/ash/login/screens/welcome_screen.h"
#include "chrome/browser/ash/login/wizard_controller.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/ui/webui/chromeos/login/demo_preferences_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.h"
Expand All @@ -19,22 +19,6 @@ namespace {
constexpr char kUserActionContinue[] = "continue-setup";
constexpr char kUserActionClose[] = "close-setup";

WelcomeScreen* GetWelcomeScreen() {
const WizardController* wizard_controller =
WizardController::default_controller();
DCHECK(wizard_controller);
return wizard_controller->GetScreen<WelcomeScreen>();
}

// Sets locale and input method. If `locale` or `input_method` is empty then
// they will not be changed.
void SetApplicationLocaleAndInputMethod(const std::string& locale,
const std::string& input_method) {
WelcomeScreen* welcome_screen = GetWelcomeScreen();
DCHECK(welcome_screen);
welcome_screen->SetApplicationLocaleAndInputMethod(locale, input_method);
}

} // namespace

// static
Expand Down Expand Up @@ -71,34 +55,17 @@ DemoPreferencesScreen::~DemoPreferencesScreen() {
view_->Bind(nullptr);
}

void DemoPreferencesScreen::SetLocale(const std::string& locale) {
SetApplicationLocaleAndInputMethod(locale, std::string());
}

void DemoPreferencesScreen::SetInputMethod(const std::string& input_method) {
SetApplicationLocaleAndInputMethod(std::string(), input_method);
}

void DemoPreferencesScreen::SetDemoModeCountry(const std::string& country_id) {
g_browser_process->local_state()->SetString(prefs::kDemoModeCountry,
country_id);
}

void DemoPreferencesScreen::ShowImpl() {
WelcomeScreen* welcome_screen = GetWelcomeScreen();
if (welcome_screen) {
initial_locale_ = welcome_screen->GetApplicationLocale();
initial_input_method_ = welcome_screen->GetInputMethod();
}

if (view_)
view_->Show();
}

void DemoPreferencesScreen::HideImpl() {
initial_locale_.clear();
initial_input_method_.clear();

if (view_)
view_->Hide();
}
Expand All @@ -112,8 +79,6 @@ void DemoPreferencesScreen::OnUserAction(const std::string& action_id) {
}
exit_callback_.Run(Result::COMPLETED);
} else if (action_id == kUserActionClose) {
// Restore initial locale and input method if the user pressed back button.
SetApplicationLocaleAndInputMethod(initial_locale_, initial_input_method_);
exit_callback_.Run(Result::CANCELED);
} else {
BaseScreen::OnUserAction(action_id);
Expand Down
10 changes: 0 additions & 10 deletions chrome/browser/ash/login/screens/demo_preferences_screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ class DemoPreferencesScreen

~DemoPreferencesScreen() override;

void SetLocale(const std::string& locale);
void SetInputMethod(const std::string& input_method);
void SetDemoModeCountry(const std::string& country_id);

// Called when view is being destroyed. If Screen is destroyed earlier
Expand All @@ -60,14 +58,6 @@ class DemoPreferencesScreen
// Passes current input method to the context, so it can be shown in the UI.
void UpdateInputMethod(input_method::InputMethodManager* input_manager);

// Initial locale that was set when the screen was shown. It will be restored
// if user presses back button.
std::string initial_locale_;

// Initial input method that was set when the screen was shown. It will be
// restored if user presses back button.
std::string initial_input_method_;

base::ScopedObservation<input_method::InputMethodManager,
input_method::InputMethodManager::Observer>
input_manager_observation_{this};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,6 @@ <h1 slot="title">
[[i18nDynamic(locale, 'demoPreferencesScreenTitle')]]
</h1>
<div slot="content" class="landscape-header-aligned">
<div id="languageDropdownContainer" class="flex layout center horizontal
justified language-selection-entry">
<div class="language-selection-title layout vertical
center-justified">
[[i18nDynamic(locale, 'languageDropdownTitle')]]
</div>
<oobe-i18n-dropdown id="languageSelect" items="[[languages]]"
label-for-aria="[[i18nDynamic(locale, 'languageDropdownLabel')]]"
on-select-item="onLanguageSelected_" class="focus-on-show">
</oobe-i18n-dropdown>
</div>
<div id="keyboardDropdownContainer" class="flex layout center horizontal
justified language-selection-entry">
<div class="language-selection-title layout vertical
center-justified">
[[i18nDynamic(locale, 'keyboardDropdownTitle')]]
</div>
<oobe-i18n-dropdown id="keyboardSelect" items="[[keyboards]]"
label-for-aria="[[i18nDynamic(locale, 'keyboardDropdownLabel')]]"
on-select-item="onKeyboardSelected_">
</oobe-i18n-dropdown>
</div>
<div id="countryDropdownContainer" class="flex layout center horizontal
justified language-selection-entry">
<div class="language-selection-title layout vertical
Expand All @@ -82,7 +60,7 @@ <h1 slot="title">
<oobe-back-button on-click="onBackClicked_"></oobe-back-button>
</div>
<div slot="bottom-buttons">
<oobe-text-button id="nextButton" inverse on-click="onNextClicked_"
<oobe-text-button id="nextButton" inverse on-click="onNextClicked_"
disabled="[[!is_country_selected_]]"
text-key="demoPreferencesNextButtonLabel">
</oobe-text-button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,26 +190,6 @@ class DemoPreferencesScreen extends DemoPreferencesScreenBase {
}
}

/**
* Handle language selection.
* @param {!CustomEvent<!OobeTypes.LanguageDsc>} event
* @private
*/
onLanguageSelected_(event) {
const languageId = event.detail.value;
chrome.send('DemoPreferencesScreen.setLocaleId', [languageId]);
}

/**
* Handle keyboard layout selection.
* @param {!CustomEvent<!OobeTypes.IMEDsc>} event
* @private
*/
onKeyboardSelected_(event) {
const inputMethodId = event.detail.value;
chrome.send('DemoPreferencesScreen.setInputMethodId', [inputMethodId]);
}

/**
* Handle country selection.
* @param {!CustomEvent<!OobeTypes.DemoCountryDsc>} event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,36 +50,16 @@ void DemoPreferencesScreenHandler::DeclareLocalizedValues(
IDS_OOBE_DEMO_SETUP_PREFERENCES_SCREEN_TITLE);
builder->Add("demoPreferencesNextButtonLabel",
IDS_OOBE_DEMO_SETUP_PREFERENCES_SCREEN_NEXT_BUTTON_LABEL);
builder->Add("languageDropdownTitle", IDS_LANGUAGE_DROPDOWN_TITLE);
builder->Add("languageDropdownLabel", IDS_LANGUAGE_DROPDOWN_LABEL);
builder->Add("keyboardDropdownTitle", IDS_KEYBOARD_DROPDOWN_TITLE);
builder->Add("keyboardDropdownLabel", IDS_KEYBOARD_DROPDOWN_LABEL);
builder->Add("countryDropdownTitle", IDS_COUNTRY_DROPDOWN_TITLE);
builder->Add("countryDropdownLabel", IDS_COUNTRY_DROPDOWN_LABEL);
}

void DemoPreferencesScreenHandler::RegisterMessages() {
BaseScreenHandler::RegisterMessages();
AddCallback("DemoPreferencesScreen.setLocaleId",
&DemoPreferencesScreenHandler::HandleSetLocaleId);
AddCallback("DemoPreferencesScreen.setInputMethodId",
&DemoPreferencesScreenHandler::HandleSetInputMethodId);
AddCallback("DemoPreferencesScreen.setDemoModeCountry",
&DemoPreferencesScreenHandler::HandleSetDemoModeCountry);
}

void DemoPreferencesScreenHandler::HandleSetLocaleId(
const std::string& language_id) {
if (screen_)
screen_->SetLocale(language_id);
}

void DemoPreferencesScreenHandler::HandleSetInputMethodId(
const std::string& input_method_id) {
if (screen_)
screen_->SetInputMethod(input_method_id);
}

void DemoPreferencesScreenHandler::HandleSetDemoModeCountry(
const std::string& country_id) {
if (screen_)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ class DemoPreferencesScreenHandler : public BaseScreenHandler,
void RegisterMessages() override;

private:
void HandleSetLocaleId(const std::string& language_id);
void HandleSetInputMethodId(const std::string& language_id);
void HandleSetDemoModeCountry(const std::string& country_id);

ash::DemoPreferencesScreen* screen_ = nullptr;
Expand Down

0 comments on commit 1d9b11c

Please sign in to comment.