Commit 0fcd065d authored by Roman Aleksandrov's avatar Roman Aleksandrov Committed by Commit Bot

BaseScreen: Simplify two Skip-related methods into one.

Bug: 1064561
Change-Id: I2bc25f71de78cfe25f24b9da545e1c0baa2d9d8b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2138272Reviewed-by: default avatarDenis Kuznetsov [CET] <antrim@chromium.org>
Commit-Queue: Roman Aleksandrov <raleksandrov@google.com>
Cr-Commit-Position: refs/heads/master@{#757182}
parent c5e25e35
......@@ -26,14 +26,10 @@ void BaseScreen::Hide() {
is_hidden_ = true;
}
bool BaseScreen::ShouldSkipScreen() {
bool BaseScreen::MaybeSkip() {
return false;
}
void BaseScreen::Skip() {
NOTREACHED() << "Skip methog should be overriden along with ShouldSkipScreen";
}
void BaseScreen::HandleUserAction(const std::string& action_id) {
if (is_hidden_) {
LOG(WARNING) << "User action came when screen is hidden: action_id="
......
......@@ -7,6 +7,7 @@
#include <string>
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
......@@ -35,11 +36,8 @@ class BaseScreen {
void Hide();
// Returns whether the screen should be skipped i. e. should be exited due to
// specific unmet conditions. Override along with Skip method.
virtual bool ShouldSkipScreen();
// Skips the screen. Override along with ShouldSkipScreen method.
virtual void Skip();
// specific unmet conditions. Returns true if skips the screen.
virtual bool MaybeSkip() WARN_UNUSED_RESULT;
// Forwards user action if screen is shown.
void HandleUserAction(const std::string& action_id);
......
......@@ -58,7 +58,7 @@ void RecommendAppsScreen::OnViewDestroyed(RecommendAppsScreenView* view) {
view_ = nullptr;
}
bool RecommendAppsScreen::ShouldSkipScreen() {
bool RecommendAppsScreen::MaybeSkip() {
const user_manager::UserManager* user_manager =
user_manager::UserManager::Get();
DCHECK(user_manager->IsUserLoggedIn());
......@@ -66,12 +66,11 @@ bool RecommendAppsScreen::ShouldSkipScreen() {
->GetProfilePolicyConnector()
->IsManaged();
bool is_child_account = user_manager->IsLoggedInAsChildUser();
return is_managed_account || is_child_account;
}
void RecommendAppsScreen::Skip() {
DCHECK(ShouldSkipScreen());
exit_callback_.Run(Result::NOT_APPLICABLE);
if (is_managed_account || is_child_account) {
exit_callback_.Run(Result::NOT_APPLICABLE);
return true;
}
return false;
}
void RecommendAppsScreen::ShowImpl() {
......
......@@ -54,8 +54,7 @@ class RecommendAppsScreen : public BaseScreen,
void OnParseResponseError() override;
// BaseScreen:
bool ShouldSkipScreen() override;
void Skip() override;
bool MaybeSkip() override;
private:
// BaseScreen:
......
......@@ -1409,10 +1409,8 @@ void WizardController::SetCurrentScreen(BaseScreen* new_current) {
if (current_screen_ == new_current || GetOobeUI() == nullptr)
return;
if (new_current && new_current->ShouldSkipScreen()) {
new_current->Skip();
if (new_current && new_current->MaybeSkip())
return;
}
if (current_screen_) {
current_screen_->Hide();
......
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