Commit 80c575a9 authored by Jacob Dufault's avatar Jacob Dufault Committed by Commit Bot

cros: Simplify BaseScreen configuration code

Bug: 928555
Change-Id: I6ae62f29040216ea349c3d78f102716e86044d1b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1562715
Commit-Queue: Jacob Dufault <jdufault@chromium.org>
Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652253}
parent dc86bdf4
......@@ -12,16 +12,12 @@ BaseScreen::BaseScreen(OobeScreen screen_id) : screen_id_(screen_id) {}
BaseScreen::~BaseScreen() {}
void BaseScreen::OnConfigurationChanged() {}
void BaseScreen::OnUserAction(const std::string& action_id) {
LOG(WARNING) << "Unhandled user action: action_id=" << action_id;
}
void BaseScreen::SetConfiguration(base::Value* configuration, bool notify) {
void BaseScreen::SetConfiguration(base::Value* configuration) {
configuration_ = configuration;
if (notify)
OnConfigurationChanged();
}
} // namespace chromeos
......@@ -38,7 +38,8 @@ class BaseScreen {
// counterpart.
virtual void OnUserAction(const std::string& action_id);
virtual void SetConfiguration(base::Value* configuration, bool notify);
// Change the configuration for the screen. |configuration| is unowned.
virtual void SetConfiguration(base::Value* configuration);
protected:
// Global configuration for OOBE screens, that can be used to automate some
......@@ -51,9 +52,6 @@ class BaseScreen {
// triggering while the screen is not displayed.
base::Value* GetConfiguration() { return configuration_; }
// This is called when configuration is changed while screen is displayed.
virtual void OnConfigurationChanged();
private:
// Configuration itself is owned by WizardController and is accessible
// to screen only between OnShow / OnHide calls.
......
......@@ -22,7 +22,7 @@ class MockWelcomeScreen : public WelcomeScreen {
MOCK_METHOD0(Show, void());
MOCK_METHOD0(Hide, void());
MOCK_METHOD2(SetConfiguration, void(base::Value* configuration, bool notify));
MOCK_METHOD1(SetConfiguration, void(base::Value* configuration));
void ExitScreen();
......
......@@ -286,9 +286,7 @@ PrefService* WizardController::local_state_for_testing_ = nullptr;
WizardController::WizardController()
: screen_manager_(std::make_unique<ScreenManager>()),
network_state_helper_(std::make_unique<login::NetworkStateHelper>()),
oobe_configuration_(base::Value(base::Value::Type::DICTIONARY)),
weak_factory_(this) {
network_state_helper_(std::make_unique<login::NetworkStateHelper>()) {
// In session OOBE was initiated from voice interaction keyboard shortcuts.
is_in_session_oobe_ =
session_manager::SessionManager::Get()->IsSessionStarted();
......@@ -1279,7 +1277,7 @@ void WizardController::ShowCurrentScreen() {
smooth_show_timer_.Stop();
UpdateStatusAreaVisibilityForScreen(current_screen_->screen_id());
current_screen_->SetConfiguration(&oobe_configuration_, false /*notify */);
current_screen_->SetConfiguration(&oobe_configuration_);
current_screen_->Show();
}
......@@ -1296,7 +1294,7 @@ void WizardController::SetCurrentScreenSmooth(BaseScreen* new_current,
if (current_screen_) {
current_screen_->Hide();
current_screen_->SetConfiguration(nullptr, false /*notify */);
current_screen_->SetConfiguration(nullptr);
}
const OobeScreen screen = new_current->screen_id();
......
......@@ -416,11 +416,11 @@ class WizardController : public BaseScreenDelegate {
base::Closure on_timezone_resolved_for_testing_;
// Configuration (dictionary) for automating OOBE screens.
base::Value oobe_configuration_;
base::Value oobe_configuration_{base::Value::Type::DICTIONARY};
BaseScreen* hid_screen_ = nullptr;
base::WeakPtrFactory<WizardController> weak_factory_;
base::WeakPtrFactory<WizardController> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(WizardController);
};
......
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