Commit c3abc029 authored by Timothy Loh's avatar Timothy Loh Committed by Commit Bot

Add offline check to Plugin VM installer

Bug: 1087726
Change-Id: I9a8ee94cef620e2b486d280cb62a7895e50a0e26
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2235229
Commit-Queue: Timothy Loh <timloh@chromium.org>
Reviewed-by: default avatarJason Lin <lxj@google.com>
Cr-Commit-Position: refs/heads/master@{#776856}
parent d11a602e
...@@ -4956,6 +4956,12 @@ ...@@ -4956,6 +4956,12 @@
<message name="IDS_PLUGIN_VM_INSTALLER_NOT_ALLOWED_TITLE" desc="Title of the Plugin VM installer if Plugin VM is disallowed."> <message name="IDS_PLUGIN_VM_INSTALLER_NOT_ALLOWED_TITLE" desc="Title of the Plugin VM installer if Plugin VM is disallowed.">
<ph name="APP_NAME">$1<ex>Plugin VM</ex></ph> needs permission to run <ph name="APP_NAME">$1<ex>Plugin VM</ex></ph> needs permission to run
</message> </message>
<message name="IDS_PLUGIN_VM_INSTALLER_ERROR_OFFLINE_TITLE" desc="Title of the Plugin VM installer when the user starts installation but the device is offline.">
<ph name="DEVICE_TYPE">$1<ex>Chromebook</ex></ph> is offline
</message>
<message name="IDS_PLUGIN_VM_INSTALLER_ERROR_OFFLINE_MESSAGE" desc="Text of the Plugin VM installer when the user starts installation but the device is offline.">
Connect to the internet and try again
</message>
<message name="IDS_PLUGIN_VM_INSTALLER_LOW_DISK_SPACE_MESSAGE" desc="Text of the Plugin VM installer that warns them of low disk space."> <message name="IDS_PLUGIN_VM_INSTALLER_LOW_DISK_SPACE_MESSAGE" desc="Text of the Plugin VM installer that warns them of low disk space.">
Your device is low on storage. At least <ph name="RECOMMENDED_SPACE">$1<ex>32GB</ex></ph> of free space is recommended to use <ph name="APP_NAME">$2<ex>Plugin VM</ex></ph>. To increase free space, delete files from your device. Your device is low on storage. At least <ph name="RECOMMENDED_SPACE">$1<ex>32GB</ex></ph> of free space is recommended to use <ph name="APP_NAME">$2<ex>Plugin VM</ex></ph>. To increase free space, delete files from your device.
</message> </message>
......
e6ffee2fc778127e454a8c36fc66e17bc79f06b2
\ No newline at end of file
e6ffee2fc778127e454a8c36fc66e17bc79f06b2
\ No newline at end of file
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/network_service_instance.h"
#include "net/traffic_annotation/network_traffic_annotation.h" #include "net/traffic_annotation/network_traffic_annotation.h"
namespace { namespace {
...@@ -99,6 +100,11 @@ void PluginVmInstaller::Start() { ...@@ -99,6 +100,11 @@ void PluginVmInstaller::Start() {
return; return;
} }
if (content::GetNetworkConnectionTracker()->IsOffline()) {
InstallFailed(FailureReason::OFFLINE);
return;
}
progress_ = 0; progress_ = 0;
CheckLicense(); CheckLicense();
} }
......
...@@ -67,8 +67,9 @@ class PluginVmInstaller : public KeyedService, ...@@ -67,8 +67,9 @@ class PluginVmInstaller : public KeyedService,
DLC_NEED_SPACE = 22, DLC_NEED_SPACE = 22,
INSUFFICIENT_DISK_SPACE = 23, INSUFFICIENT_DISK_SPACE = 23,
INVALID_LICENSE = 24, INVALID_LICENSE = 24,
OFFLINE = 25,
kMaxValue = INVALID_LICENSE, kMaxValue = OFFLINE,
}; };
enum class InstallingState { enum class InstallingState {
......
...@@ -345,6 +345,10 @@ base::string16 PluginVmInstallerView::GetBigMessage() const { ...@@ -345,6 +345,10 @@ base::string16 PluginVmInstallerView::GetBigMessage() const {
case State::kError: case State::kError:
DCHECK(reason_); DCHECK(reason_);
switch (*reason_) { switch (*reason_) {
case plugin_vm::PluginVmInstaller::FailureReason::OFFLINE:
return l10n_util::GetStringFUTF16(
IDS_PLUGIN_VM_INSTALLER_ERROR_OFFLINE_TITLE,
ui::GetChromeOSDeviceName());
case plugin_vm::PluginVmInstaller::FailureReason::NOT_ALLOWED: case plugin_vm::PluginVmInstaller::FailureReason::NOT_ALLOWED:
return l10n_util::GetStringFUTF16( return l10n_util::GetStringFUTF16(
IDS_PLUGIN_VM_INSTALLER_NOT_ALLOWED_TITLE, app_name_); IDS_PLUGIN_VM_INSTALLER_NOT_ALLOWED_TITLE, app_name_);
...@@ -409,6 +413,9 @@ base::string16 PluginVmInstallerView::GetMessage() const { ...@@ -409,6 +413,9 @@ base::string16 PluginVmInstallerView::GetMessage() const {
IDS_PLUGIN_VM_INSTALLER_ERROR_MESSAGE_LOGIC_ERROR, app_name_, IDS_PLUGIN_VM_INSTALLER_ERROR_MESSAGE_LOGIC_ERROR, app_name_,
base::NumberToString16( base::NumberToString16(
static_cast<std::underlying_type_t<Reason>>(*reason_))); static_cast<std::underlying_type_t<Reason>>(*reason_)));
case Reason::OFFLINE:
return l10n_util::GetStringUTF16(
IDS_PLUGIN_VM_INSTALLER_ERROR_OFFLINE_MESSAGE);
case Reason::NOT_ALLOWED: case Reason::NOT_ALLOWED:
case Reason::DLC_UNSUPPORTED: case Reason::DLC_UNSUPPORTED:
return l10n_util::GetStringFUTF16( return l10n_util::GetStringFUTF16(
......
...@@ -32,8 +32,10 @@ ...@@ -32,8 +32,10 @@
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h" #include "components/prefs/scoped_user_pref_update.h"
#include "components/user_manager/scoped_user_manager.h" #include "components/user_manager/scoped_user_manager.h"
#include "content/public/browser/network_service_instance.h"
#include "content/public/test/browser_test.h" #include "content/public/test/browser_test.h"
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
#include "services/network/test/test_network_connection_tracker.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/strings/grit/ui_strings.h" #include "ui/strings/grit/ui_strings.h"
...@@ -51,6 +53,10 @@ const char kJpgFileHash[] = ...@@ -51,6 +53,10 @@ const char kJpgFileHash[] =
} // namespace } // namespace
// TODO(timloh): This file should only be responsible for testing the
// interactions between the installer UI and the installer backend. We should
// mock out the backend and move the tests for the backend logic out of here.
class PluginVmInstallerViewBrowserTest : public DialogBrowserTest { class PluginVmInstallerViewBrowserTest : public DialogBrowserTest {
public: public:
PluginVmInstallerViewBrowserTest() = default; PluginVmInstallerViewBrowserTest() = default;
...@@ -62,6 +68,14 @@ class PluginVmInstallerViewBrowserTest : public DialogBrowserTest { ...@@ -62,6 +68,14 @@ class PluginVmInstallerViewBrowserTest : public DialogBrowserTest {
fake_concierge_client_->set_disk_image_progress_signal_connected(true); fake_concierge_client_->set_disk_image_progress_signal_connected(true);
histogram_tester_ = std::make_unique<base::HistogramTester>(); histogram_tester_ = std::make_unique<base::HistogramTester>();
network_connection_tracker_ =
network::TestNetworkConnectionTracker::CreateInstance();
content::SetNetworkConnectionTrackerForTesting(nullptr);
content::SetNetworkConnectionTrackerForTesting(
network_connection_tracker_.get());
network::TestNetworkConnectionTracker::GetInstance()->SetConnectionType(
network::mojom::ConnectionType::CONNECTION_WIFI);
} }
void TearDownOnMainThread() override { scoped_user_manager_.reset(); } void TearDownOnMainThread() override { scoped_user_manager_.reset(); }
...@@ -128,6 +142,8 @@ class PluginVmInstallerViewBrowserTest : public DialogBrowserTest { ...@@ -128,6 +142,8 @@ class PluginVmInstallerViewBrowserTest : public DialogBrowserTest {
chromeos::ScopedTestingCrosSettings scoped_testing_cros_settings_; chromeos::ScopedTestingCrosSettings scoped_testing_cros_settings_;
chromeos::ScopedStubInstallAttributes scoped_stub_install_attributes_; chromeos::ScopedStubInstallAttributes scoped_stub_install_attributes_;
std::unique_ptr<network::TestNetworkConnectionTracker>
network_connection_tracker_;
std::unique_ptr<user_manager::ScopedUserManager> scoped_user_manager_; std::unique_ptr<user_manager::ScopedUserManager> scoped_user_manager_;
PluginVmInstallerView* view_; PluginVmInstallerView* view_;
std::unique_ptr<base::HistogramTester> histogram_tester_; std::unique_ptr<base::HistogramTester> histogram_tester_;
......
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