Commit 7d6721f2 authored by Igor's avatar Igor Committed by Commit Bot

Display serial_number for disabled device

If the device is disabled, it can be brought back to life only by the
admin of the domain. And to re-enable the device, admin needs the serial
number which might not match the data displayed on the sticker. Or the
sticker could be damaged. This change will provide the serial number on
the disabled device screen.

BUG=chromium:852284
TEST=Unit tests

Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: I3fe38afc59d7c08ffc175c723b1a37660d8b1160
Reviewed-on: https://chromium-review.googlesource.com/1101209Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Reviewed-by: default avatarDan Erat <derat@chromium.org>
Commit-Queue: Igor <igorcov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569218}
parent deebd6c2
...@@ -3506,10 +3506,10 @@ ...@@ -3506,10 +3506,10 @@
Locked Locked
</message> </message>
<message name="IDS_DEVICE_DISABLED_EXPLANATION_WITH_DOMAIN" desc="Explanation shown to the user when the device has been disabled by its owner. This version is used when the domain that owns the device is known."> <message name="IDS_DEVICE_DISABLED_EXPLANATION_WITH_DOMAIN" desc="Explanation shown to the user when the device has been disabled by its owner. This version is used when the domain that owns the device is known.">
This device was locked by the <ph name="SAML_DOMAIN">$1<ex>example.com</ex></ph> administrator. This device (SN: <ph name="SERIAL_NUMBER">$1<ex>1234</ex></ph>) was locked by the <ph name="SAML_DOMAIN">$2<ex>example.com</ex></ph> administrator.
</message> </message>
<message name="IDS_DEVICE_DISABLED_EXPLANATION_WITHOUT_DOMAIN" desc="Explanation shown to the user when the device has been disabled by its owner. This version is used when the domain that owns the device is not known."> <message name="IDS_DEVICE_DISABLED_EXPLANATION_WITHOUT_DOMAIN" desc="Explanation shown to the user when the device has been disabled by its owner. This version is used when the domain that owns the device is not known.">
This device was locked by the owner. This device (SN: <ph name="SERIAL_NUMBER">$1<ex>1234</ex></ph>) was locked by the owner.
</message> </message>
<!-- Encryption migration dialog --> <!-- Encryption migration dialog -->
......
...@@ -61,6 +61,10 @@ const std::string& DeviceDisabledScreen::GetMessage() const { ...@@ -61,6 +61,10 @@ const std::string& DeviceDisabledScreen::GetMessage() const {
return device_disabling_manager_->disabled_message(); return device_disabling_manager_->disabled_message();
} }
const std::string& DeviceDisabledScreen::GetSerialNumber() const {
return device_disabling_manager_->serial_number();
}
void DeviceDisabledScreen::OnDisabledMessageChanged( void DeviceDisabledScreen::OnDisabledMessageChanged(
const std::string& disabled_message) { const std::string& disabled_message) {
if (view_) if (view_)
......
...@@ -35,6 +35,7 @@ class DeviceDisabledScreen : public BaseScreen, ...@@ -35,6 +35,7 @@ class DeviceDisabledScreen : public BaseScreen,
void OnViewDestroyed(DeviceDisabledScreenView* view) override; void OnViewDestroyed(DeviceDisabledScreenView* view) override;
const std::string& GetEnrollmentDomain() const override; const std::string& GetEnrollmentDomain() const override;
const std::string& GetMessage() const override; const std::string& GetMessage() const override;
const std::string& GetSerialNumber() const override;
// system::DeviceDisablingManager::Observer: // system::DeviceDisablingManager::Observer:
void OnDisabledMessageChanged(const std::string& disabled_message) override; void OnDisabledMessageChanged(const std::string& disabled_message) override;
......
...@@ -27,6 +27,9 @@ class DeviceDisabledScreenView { ...@@ -27,6 +27,9 @@ class DeviceDisabledScreenView {
// Returns the message that should be shown to the user. // Returns the message that should be shown to the user.
virtual const std::string& GetMessage() const = 0; virtual const std::string& GetMessage() const = 0;
// Returns the device serial number that should be shown to the user.
virtual const std::string& GetSerialNumber() const = 0;
}; };
constexpr static OobeScreen kScreenId = OobeScreen::SCREEN_DEVICE_DISABLED; constexpr static OobeScreen kScreenId = OobeScreen::SCREEN_DEVICE_DISABLED;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "chromeos/chromeos_switches.h" #include "chromeos/chromeos_switches.h"
#include "chromeos/settings/cros_settings_names.h" #include "chromeos/settings/cros_settings_names.h"
#include "chromeos/settings/cros_settings_provider.h" #include "chromeos/settings/cros_settings_provider.h"
#include "chromeos/system/statistics_provider.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h" #include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
...@@ -132,6 +133,10 @@ void DeviceDisablingManager::CheckWhetherDeviceDisabledDuringOOBE( ...@@ -132,6 +133,10 @@ void DeviceDisablingManager::CheckWhetherDeviceDisabledDuringOOBE(
policy::kDeviceStateManagementDomain, policy::kDeviceStateManagementDomain,
&enrollment_domain_); &enrollment_domain_);
// Update the serial number.
serial_number_ = chromeos::system::StatisticsProvider::GetInstance()
->GetEnterpriseMachineID();
// Update the disabled message. // Update the disabled message.
std::string disabled_message; std::string disabled_message;
g_browser_process->local_state()->GetDictionary( g_browser_process->local_state()->GetDictionary(
...@@ -231,6 +236,10 @@ void DeviceDisablingManager::UpdateFromCrosSettings() { ...@@ -231,6 +236,10 @@ void DeviceDisablingManager::UpdateFromCrosSettings() {
enrollment_domain_ = enrollment_domain_ =
browser_policy_connector_->GetEnterpriseEnrollmentDomain(); browser_policy_connector_->GetEnterpriseEnrollmentDomain();
// Cache the device serial number.
serial_number_ = chromeos::system::StatisticsProvider::GetInstance()
->GetEnterpriseMachineID();
// If no session or login is in progress, show the device disabled screen. // If no session or login is in progress, show the device disabled screen.
delegate_->ShowDeviceDisabledScreen(); delegate_->ShowDeviceDisabledScreen();
} }
......
...@@ -58,7 +58,7 @@ class DeviceDisablingManager { ...@@ -58,7 +58,7 @@ class DeviceDisablingManager {
virtual ~Observer(); virtual ~Observer();
virtual void OnDisabledMessageChanged( virtual void OnDisabledMessageChanged(
const std::string& disabled_message) = 0; const std::string& disabled_message) = 0;
private: private:
DISALLOW_ASSIGN(Observer); DISALLOW_ASSIGN(Observer);
...@@ -99,6 +99,10 @@ class DeviceDisablingManager { ...@@ -99,6 +99,10 @@ class DeviceDisablingManager {
// up to date if the disabled screen was triggered. // up to date if the disabled screen was triggered.
const std::string& disabled_message() const { return disabled_message_; } const std::string& disabled_message() const { return disabled_message_; }
// Returns the cached serial_number. The value is only guaranteed to be
// up to date if the disabled screen was triggered.
const std::string& serial_number() const { return serial_number_; }
// Performs a check whether the device is disabled during OOBE. |callback| // Performs a check whether the device is disabled during OOBE. |callback|
// will be invoked with the result of the check. // will be invoked with the result of the check.
void CheckWhetherDeviceDisabledDuringOOBE( void CheckWhetherDeviceDisabledDuringOOBE(
...@@ -141,6 +145,9 @@ class DeviceDisablingManager { ...@@ -141,6 +145,9 @@ class DeviceDisablingManager {
// A cached copy of the message to show on the device disabled screen. // A cached copy of the message to show on the device disabled screen.
std::string disabled_message_; std::string disabled_message_;
// A cached copy of the serial number to show on the device disabled screen.
std::string serial_number_;
base::WeakPtrFactory<DeviceDisablingManager> weak_factory_; base::WeakPtrFactory<DeviceDisablingManager> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(DeviceDisablingManager); DISALLOW_COPY_AND_ASSIGN(DeviceDisablingManager);
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_browser_process.h"
#include "chromeos/chromeos_switches.h" #include "chromeos/chromeos_switches.h"
#include "chromeos/dbus/fake_session_manager_client.h" #include "chromeos/dbus/fake_session_manager_client.h"
#include "chromeos/system/fake_statistics_provider.h"
#include "components/ownership/mock_owner_key_util.h" #include "components/ownership/mock_owner_key_util.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h" #include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/policy/proto/device_management_backend.pb.h" #include "components/policy/proto/device_management_backend.pb.h"
...@@ -81,12 +82,14 @@ class DeviceDisablingManagerTestBase : public testing::Test, ...@@ -81,12 +82,14 @@ class DeviceDisablingManagerTestBase : public testing::Test,
chromeos::ScopedTestCrosSettings test_cros_settings_; chromeos::ScopedTestCrosSettings test_cros_settings_;
chromeos::FakeChromeUserManager fake_user_manager_; chromeos::FakeChromeUserManager fake_user_manager_;
std::unique_ptr<DeviceDisablingManager> device_disabling_manager_; std::unique_ptr<DeviceDisablingManager> device_disabling_manager_;
FakeStatisticsProvider statistics_provider_;
DISALLOW_COPY_AND_ASSIGN(DeviceDisablingManagerTestBase); DISALLOW_COPY_AND_ASSIGN(DeviceDisablingManagerTestBase);
}; };
DeviceDisablingManagerTestBase::DeviceDisablingManagerTestBase() DeviceDisablingManagerTestBase::DeviceDisablingManagerTestBase()
: install_attributes_(ScopedStubInstallAttributes::CreateUnset()) { : install_attributes_(ScopedStubInstallAttributes::CreateUnset()) {
system::StatisticsProvider::SetTestProvider(&statistics_provider_);
} }
void DeviceDisablingManagerTestBase::TearDown() { void DeviceDisablingManagerTestBase::TearDown() {
...@@ -150,6 +153,7 @@ class DeviceDisablingManagerOOBETest : public DeviceDisablingManagerTestBase { ...@@ -150,6 +153,7 @@ class DeviceDisablingManagerOOBETest : public DeviceDisablingManagerTestBase {
void OnDeviceDisabledChecked(bool device_disabled); void OnDeviceDisabledChecked(bool device_disabled);
TestingPrefServiceSimple local_state_; TestingPrefServiceSimple local_state_;
FakeStatisticsProvider statistics_provider_;
base::RunLoop run_loop_; base::RunLoop run_loop_;
bool device_disabled_; bool device_disabled_;
...@@ -168,6 +172,7 @@ void DeviceDisablingManagerOOBETest::SetUp() { ...@@ -168,6 +172,7 @@ void DeviceDisablingManagerOOBETest::SetUp() {
policy::DeviceCloudPolicyManagerChromeOS::RegisterPrefs( policy::DeviceCloudPolicyManagerChromeOS::RegisterPrefs(
local_state_.registry()); local_state_.registry());
CreateDeviceDisablingManager(); CreateDeviceDisablingManager();
system::StatisticsProvider::SetTestProvider(&statistics_provider_);
} }
void DeviceDisablingManagerOOBETest::TearDown() { void DeviceDisablingManagerOOBETest::TearDown() {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
login.createScreen('DeviceDisabledScreen', 'device-disabled', function() { login.createScreen('DeviceDisabledScreen', 'device-disabled', function() {
return { return {
EXTERNAL_API: ['setEnrollmentDomain', 'setMessage'], EXTERNAL_API: ['setSerialNumberAndEnrollmentDomain', 'setMessage'],
/** /**
* Ignore any accelerators the user presses on this screen. * Ignore any accelerators the user presses on this screen.
...@@ -17,7 +17,7 @@ login.createScreen('DeviceDisabledScreen', 'device-disabled', function() { ...@@ -17,7 +17,7 @@ login.createScreen('DeviceDisabledScreen', 'device-disabled', function() {
/** @override */ /** @override */
decorate: function() { decorate: function() {
this.setEnrollmentDomain(null); this.setSerialNumberAndEnrollmentDomain('', null);
}, },
/** /**
...@@ -42,21 +42,24 @@ login.createScreen('DeviceDisabledScreen', 'device-disabled', function() { ...@@ -42,21 +42,24 @@ login.createScreen('DeviceDisabledScreen', 'device-disabled', function() {
/** /**
* Updates the explanation shown to the user. The explanation will indicate * Updates the explanation shown to the user. The explanation will indicate
* that the device is owned by |enrollment_domain|. If |enrollment_domain| * the device serial number and that it is owned by |enrollment_domain|. If
* is null or empty, a generic explanation will be used instead that does * |enrollment_domain| is null or empty, a generic explanation will be used
* not reference any domain. * instead that does not reference any domain.
* @param {string} serial_number The serial number of the device.
* @param {string} enrollment_domain The domain that owns the device. * @param {string} enrollment_domain The domain that owns the device.
*/ */
setEnrollmentDomain: function(enrollment_domain) { setSerialNumberAndEnrollmentDomain: function(
serial_number, enrollment_domain) {
if (enrollment_domain) { if (enrollment_domain) {
// The contents of |enrollment_domain| is untrusted. Set the resulting // The contents of |enrollment_domain| is untrusted. Set the resulting
// string as |textContent| so that it gets treated as plain text and // string as |textContent| so that it gets treated as plain text and
// cannot be used to inject JS or HTML. // cannot be used to inject JS or HTML.
$('device-disabled-explanation').textContent = loadTimeData.getStringF( $('device-disabled-explanation').textContent = loadTimeData.getStringF(
'deviceDisabledExplanationWithDomain', enrollment_domain); 'deviceDisabledExplanationWithDomain', serial_number,
enrollment_domain);
} else { } else {
$('device-disabled-explanation').textContent = $('device-disabled-explanation').textContent = loadTimeData.getStringF(
loadTimeData.getString('deviceDisabledExplanationWithoutDomain'); 'deviceDisabledExplanationWithoutDomain', serial_number);
} }
}, },
......
...@@ -34,7 +34,8 @@ void DeviceDisabledScreenHandler::Show() { ...@@ -34,7 +34,8 @@ void DeviceDisabledScreenHandler::Show() {
} }
if (delegate_) { if (delegate_) {
CallJS("setEnrollmentDomain", delegate_->GetEnrollmentDomain()); CallJS("setSerialNumberAndEnrollmentDomain", delegate_->GetSerialNumber(),
delegate_->GetEnrollmentDomain());
CallJS("setMessage", delegate_->GetMessage()); CallJS("setMessage", delegate_->GetMessage());
} }
ShowScreen(kScreenId); ShowScreen(kScreenId);
......
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