Commit 8a8383af authored by Nicholas Verne's avatar Nicholas Verne Committed by Commit Bot

Crostini installer view with progress messages.

The install progress now has feedback messages in the dialog.
The view also closes automatically on completion

Bug: 822507
Change-Id: I962c9975a19fb322c611c9a02c5e2cc7ab21e06b
Reviewed-on: https://chromium-review.googlesource.com/1029559
Commit-Queue: Nicholas Verne <nverne@chromium.org>
Reviewed-by: default avatarBen Wells <benwells@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553944}
parent 4c4ec954
......@@ -4929,6 +4929,21 @@ Installing the <ph name="APP_NAME">$2<ex>Terminal</ex></ph> will download <ph na
</message>
<message name="IDS_CROSTINI_INSTALLER_COMPLETE" desc="Text shown in the Crostini installer dialog when installation is complete.">
Finished installing <ph name="APP_NAME">$1<ex>Terminal</ex></ph>.
</message>
<message name="IDS_CROSTINI_INSTALLER_LOAD_TERMINA_MESSAGE" desc="Text shown in the Crostini installer dialog when the 'Termina' component is loading">
Loading Termina component.
</message>
<message name="IDS_CROSTINI_INSTALLER_START_CONCIERGE_MESSAGE" desc="Text shown in the Crostini installer dialog when the 'Concierge' service is starting">
Starting Concierge service.
</message>
<message name="IDS_CROSTINI_INSTALLER_CREATE_DISK_IMAGE_MESSAGE" desc="Text shown in the Crostini installer dialog when the disk image is being created">
Creating disk image.
</message>
<message name="IDS_CROSTINI_INSTALLER_START_TERMINA_VM_MESSAGE" desc="Text shown in the Crostini installer dialog when the 'Termina VM' is starting">
Starting Termina VM.
</message>
<message name="IDS_CROSTINI_INSTALLER_START_CONTAINER_MESSAGE" desc="Text shown in the Crostini installer dialog when the container inside the 'Termina VM' is starting">
Starting container inside Termina VM.
</message>
<message name="IDS_CROSTINI_INSTALLER_LOAD_TERMINA_ERROR" desc="Text shown in the Crostini installer dialog when the 'Termina' component fails to load">
ERROR: Failed to load Termina component.
......
......@@ -98,10 +98,9 @@ bool CrostiniInstallerView::Accept() {
state_ = State::INSTALL_START;
profile_->GetPrefs()->SetBoolean(crostini::prefs::kCrostiniEnabled, true);
DialogModelChanged();
SetMessageLabel();
GetWidget()->UpdateWindowTitle();
message_label_->SetVisible(false);
progress_bar_ = new views::ProgressBar();
AddChildView(progress_bar_);
......@@ -168,13 +167,12 @@ CrostiniInstallerView::~CrostiniInstallerView() {
}
void CrostiniInstallerView::StepProgress() {
constexpr float kBase = static_cast<float>(State::INSTALL_START);
constexpr float kNumSteps = static_cast<float>(State::INSTALL_END) - kBase;
if (State::INSTALL_START < state_ && state_ <= State::INSTALL_END) {
progress_bar_->SetValue((static_cast<float>(state_) - kBase) / kNumSteps);
if (State::INSTALL_START < state_ && state_ < State::INSTALL_END) {
// Setting value to -1 makes the progress bar play the
// "indeterminate animation".
progress_bar_->SetValue(-1);
}
SetMessageLabel();
DialogModelChanged();
}
......@@ -187,6 +185,29 @@ void CrostiniInstallerView::HandleError(const base::string16& error_message) {
GetWidget()->UpdateWindowTitle();
}
void CrostiniInstallerView::SetMessageLabel() {
int message_id = 0;
// The States below refer to stages that have completed.
// The messages selected refer to the next stage, now underway.
if (state_ == State::INSTALL_START) {
message_id = IDS_CROSTINI_INSTALLER_LOAD_TERMINA_MESSAGE;
} else if (state_ == State::INSTALL_IMAGE_LOADER) {
message_id = IDS_CROSTINI_INSTALLER_START_CONCIERGE_MESSAGE;
} else if (state_ == State::START_CONCIERGE) {
message_id = IDS_CROSTINI_INSTALLER_CREATE_DISK_IMAGE_MESSAGE;
} else if (state_ == State::CREATE_DISK_IMAGE) {
message_id = IDS_CROSTINI_INSTALLER_START_TERMINA_VM_MESSAGE;
} else if (state_ == State::START_TERMINA_VM) {
message_id = IDS_CROSTINI_INSTALLER_START_CONTAINER_MESSAGE;
}
if (message_id != 0) {
message_label_->SetText(l10n_util::GetStringUTF16(message_id));
message_label_->SetVisible(true);
} else {
message_label_->SetVisible(false);
}
}
void CrostiniInstallerView::OnComponentLoaded(ConciergeClientResult result) {
DCHECK_EQ(state_, State::INSTALL_START);
state_ = State::INSTALL_IMAGE_LOADER;
......@@ -245,6 +266,7 @@ void CrostiniInstallerView::OnVmStarted(ConciergeClientResult result) {
void CrostiniInstallerView::StartContainerFinished(
ConciergeClientResult result) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
state_ = State::START_CONTAINER;
if (result != ConciergeClientResult::SUCCESS) {
LOG(ERROR) << "Failed to start container with error code: "
<< static_cast<int>(result);
......@@ -263,8 +285,6 @@ void CrostiniInstallerView::ShowLoginShell() {
crostini::CrostiniManager::GetInstance()->LaunchContainerTerminal(
profile_, kCrostiniDefaultVmName, kCrostiniDefaultContainerName);
GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize());
GetWidget()->UpdateWindowTitle();
StepProgress();
GetWidget()->Show();
GetWidget()->Close();
}
......@@ -52,12 +52,10 @@ class CrostiniInstallerView
~CrostiniInstallerView() override;
void HandleError(const base::string16& error_message);
void StartContainerFinished(crostini::ConciergeClientResult result);
void ShowLoginShell();
void StepProgress();
void SetMessageLabel();
enum class State {
PROMPT, // Prompting the user to allow installation.
......
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