Commit ba19e614 authored by Petr Smirnov's avatar Petr Smirnov Committed by Commit Bot

Disable back button on ErrorScreen

Add functionality for disabling back button on ErrorScreen.

Bug: 1005151
Change-Id: Ic62ca8d56f529d60c2e45c9d2d8e4fcbfeb420d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1807230Reviewed-by: default avatarDenis Kuznetsov <antrim@chromium.org>
Reviewed-by: default avatarIvan Šandrk <isandrk@chromium.org>
Commit-Queue: Petr Smirnov <petrsmirnov@google.com>
Cr-Commit-Position: refs/heads/master@{#699933}
parent 7428299e
......@@ -164,6 +164,11 @@ void ErrorScreen::ShowConnectingIndicator(bool show) {
view_->SetShowConnectingIndicator(show);
}
void ErrorScreen::SetIsPersistentError(bool is_persistent) {
if (view_)
view_->SetIsPersistentError(is_persistent);
}
ErrorScreen::ConnectRequestCallbackSubscription
ErrorScreen::RegisterConnectRequestCallback(const base::Closure& callback) {
return connect_request_callbacks_.Add(callback);
......
......@@ -94,6 +94,9 @@ class ErrorScreen : public BaseScreen,
// Toggles the connection pending indicator.
void ShowConnectingIndicator(bool show);
// Makes error persistent (e.g. non-closable).
void SetIsPersistentError(bool is_persistent);
// Register a callback to be invoked when the user indicates that an attempt
// to connect to the network should be made.
ConnectRequestCallbackSubscription RegisterConnectRequestCallback(
......
......@@ -48,6 +48,7 @@ class MockErrorScreenView : public ErrorScreenView {
MOCK_METHOD1(SetOfflineSigninAllowed, void(bool value));
MOCK_METHOD1(SetShowConnectingIndicator, void(bool value));
MOCK_METHOD1(SetUIState, void(NetworkError::UIState ui_state));
MOCK_METHOD1(SetIsPersistentError, void(bool is_persistent));
private:
ErrorScreen* screen_ = nullptr;
......
......@@ -75,6 +75,7 @@ login.createScreen('ErrorMessageScreen', 'error-message', function() {
'setErrorState',
'showConnectingIndicator',
'setErrorStateNetwork',
'setIsPersistentError',
],
// Error screen initial UI state.
......@@ -83,12 +84,18 @@ login.createScreen('ErrorMessageScreen', 'error-message', function() {
// Error screen initial error state.
error_state_: ERROR_STATE.UNKNOWN,
// True if it is forbidden to close the error message.
is_persistent_error_: false,
/**
* Whether the screen can be closed.
* |is_persistent_error_| prevents error screen to be closable even
* if there are some user pods.
* (E.g. out of OOBE process on the sign-in screen).
* @type {boolean}
*/
get closable() {
return Oobe.getInstance().hasUserPods;
return Oobe.getInstance().hasUserPods && !this.is_persistent_error_;
},
/**
......@@ -255,6 +262,8 @@ login.createScreen('ErrorMessageScreen', 'error-message', function() {
*/
onBeforeHide: function() {
Oobe.getInstance().setSigninUIState(SIGNIN_UI_STATE.HIDDEN);
// Reset property to the default state.
this.setIsPersistentError(false);
},
/**
......@@ -376,5 +385,12 @@ login.createScreen('ErrorMessageScreen', 'error-message', function() {
if (this.closable)
Oobe.showUserPods();
},
/**
* Makes error message non-closable.
*/
setIsPersistentError: function(is_persistent) {
this.is_persistent_error_ = is_persistent;
}
};
});
......@@ -80,6 +80,10 @@ void ErrorScreenHandler::SetShowConnectingIndicator(bool value) {
CallJS("login.ErrorMessageScreen.showConnectingIndicator", value);
}
void ErrorScreenHandler::SetIsPersistentError(bool is_persistent) {
CallJS("login.ErrorMessageScreen.setIsPersistentError", is_persistent);
}
void ErrorScreenHandler::SetUIState(NetworkError::UIState ui_state) {
CallJS("login.ErrorMessageScreen.setUIState", static_cast<int>(ui_state));
}
......
......@@ -51,6 +51,9 @@ class ErrorScreenView {
// Updates visibility of the label indicating we're reconnecting.
virtual void SetShowConnectingIndicator(bool value) = 0;
// Makes error persistent (e.g. non-closable).
virtual void SetIsPersistentError(bool is_persistent) = 0;
// Sets current UI state of the screen.
virtual void SetUIState(NetworkError::UIState ui_state) = 0;
};
......@@ -75,6 +78,7 @@ class ErrorScreenHandler : public BaseScreenHandler, public ErrorScreenView {
void SetGuestSigninAllowed(bool value) override;
void SetOfflineSigninAllowed(bool value) override;
void SetShowConnectingIndicator(bool value) override;
void SetIsPersistentError(bool is_persistent) override;
void SetUIState(NetworkError::UIState ui_state) override;
// WebUIMessageHandler:
......
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