Commit feb61914 authored by James Hawkins's avatar James Hawkins Committed by Commit Bot

Smart Lock: Remove the 'turn off' functionality from EasyUnlock V1.

R=dpapad@chromium.org, hansberry@chromium.org

Bug: 899324
Test: none
Change-Id: I01b9786b3e5f49490660829bd1c3a7659e73f9c7
Reviewed-on: https://chromium-review.googlesource.com/c/1306916
Commit-Queue: James Hawkins <jhawkins@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarRyan Hansberry <hansberry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604003}
parent 4f64b826
...@@ -547,11 +547,6 @@ void EasyUnlockService::DisableAppWithoutResettingScreenlockState() { ...@@ -547,11 +547,6 @@ void EasyUnlockService::DisableAppWithoutResettingScreenlockState() {
app_manager_->DisableAppIfLoaded(); app_manager_->DisableAppIfLoaded();
} }
void EasyUnlockService::NotifyTurnOffOperationStatusChanged() {
for (EasyUnlockServiceObserver& observer : observers_)
observer.OnTurnOffOperationStatusChanged();
}
void EasyUnlockService::ResetScreenlockState() { void EasyUnlockService::ResetScreenlockState() {
screenlock_state_handler_.reset(); screenlock_state_handler_.reset();
auth_attempt_.reset(); auth_attempt_.reset();
......
...@@ -57,12 +57,6 @@ class UserContext; ...@@ -57,12 +57,6 @@ class UserContext;
class EasyUnlockService : public KeyedService { class EasyUnlockService : public KeyedService {
public: public:
enum TurnOffFlowStatus {
IDLE,
PENDING,
FAIL,
};
enum Type { TYPE_REGULAR, TYPE_SIGNIN }; enum Type { TYPE_REGULAR, TYPE_SIGNIN };
// Gets EasyUnlockService instance. // Gets EasyUnlockService instance.
...@@ -99,15 +93,6 @@ class EasyUnlockService : public KeyedService { ...@@ -99,15 +93,6 @@ class EasyUnlockService : public KeyedService {
virtual const base::ListValue* GetRemoteDevices() const = 0; virtual const base::ListValue* GetRemoteDevices() const = 0;
virtual void SetRemoteDevices(const base::ListValue& devices) = 0; virtual void SetRemoteDevices(const base::ListValue& devices) = 0;
// Runs the flow for turning Easy unlock off.
virtual void RunTurnOffFlow() = 0;
// Resets the turn off flow if one is in progress.
virtual void ResetTurnOffFlow() = 0;
// Returns the current turn off flow status.
virtual TurnOffFlowStatus GetTurnOffFlowStatus() const = 0;
// Gets the challenge bytes for the user currently associated with the // Gets the challenge bytes for the user currently associated with the
// service. // service.
virtual std::string GetChallenge() const = 0; virtual std::string GetChallenge() const = 0;
...@@ -233,9 +218,6 @@ class EasyUnlockService : public KeyedService { ...@@ -233,9 +218,6 @@ class EasyUnlockService : public KeyedService {
// the lock screen UI should remain unchanged until the screen unlocks. // the lock screen UI should remain unchanged until the screen unlocks.
void DisableAppWithoutResettingScreenlockState(); void DisableAppWithoutResettingScreenlockState();
// Notifies observers that the turn off flow status changed.
void NotifyTurnOffOperationStatusChanged();
// Resets the screenlock state set by this service. // Resets the screenlock state set by this service.
void ResetScreenlockState(); void ResetScreenlockState();
......
...@@ -11,9 +11,6 @@ namespace chromeos { ...@@ -11,9 +11,6 @@ namespace chromeos {
class EasyUnlockServiceObserver { class EasyUnlockServiceObserver {
public: public:
// Invoked when turn-off operation status changes.
virtual void OnTurnOffOperationStatusChanged() {}
// Invoked when screenlock state changes. // Invoked when screenlock state changes.
virtual void OnScreenlockStateChanged(proximity_auth::ScreenlockState state) { virtual void OnScreenlockStateChanged(proximity_auth::ScreenlockState state) {
} }
......
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
#include "chromeos/components/proximity_auth/proximity_auth_system.h" #include "chromeos/components/proximity_auth/proximity_auth_system.h"
#include "chromeos/components/proximity_auth/screenlock_bridge.h" #include "chromeos/components/proximity_auth/screenlock_bridge.h"
#include "chromeos/components/proximity_auth/switches.h" #include "chromeos/components/proximity_auth/switches.h"
#include "components/cryptauth/cryptauth_client_impl.h"
#include "components/cryptauth/cryptauth_enrollment_manager.h" #include "components/cryptauth/cryptauth_enrollment_manager.h"
#include "components/cryptauth/cryptauth_enrollment_utils.h" #include "components/cryptauth/cryptauth_enrollment_utils.h"
#include "components/cryptauth/cryptauth_gcm_manager_impl.h" #include "components/cryptauth/cryptauth_gcm_manager_impl.h"
...@@ -88,15 +87,6 @@ enum class SmartLockEnabledState { ...@@ -88,15 +87,6 @@ enum class SmartLockEnabledState {
COUNT COUNT
}; };
void LogToggleFeature(SmartLockToggleFeature toggle) {
UMA_HISTOGRAM_BOOLEAN("SmartLock.ToggleFeature", static_cast<bool>(toggle));
}
void LogToggleFeatureDisableResult(SmartLockResult result) {
UMA_HISTOGRAM_BOOLEAN("SmartLock.ToggleFeature.Disable.Result",
static_cast<bool>(result));
}
void LogSmartLockEnabledState(SmartLockEnabledState state) { void LogSmartLockEnabledState(SmartLockEnabledState state) {
UMA_HISTOGRAM_ENUMERATION("SmartLock.EnabledState", state, UMA_HISTOGRAM_ENUMERATION("SmartLock.EnabledState", state,
SmartLockEnabledState::COUNT); SmartLockEnabledState::COUNT);
...@@ -123,7 +113,6 @@ EasyUnlockServiceRegular::EasyUnlockServiceRegular( ...@@ -123,7 +113,6 @@ EasyUnlockServiceRegular::EasyUnlockServiceRegular(
device_sync::DeviceSyncClient* device_sync_client, device_sync::DeviceSyncClient* device_sync_client,
multidevice_setup::MultiDeviceSetupClient* multidevice_setup_client) multidevice_setup::MultiDeviceSetupClient* multidevice_setup_client)
: EasyUnlockService(profile, secure_channel_client), : EasyUnlockService(profile, secure_channel_client),
turn_off_flow_status_(EasyUnlockService::IDLE),
scoped_crypt_auth_device_manager_observer_(this), scoped_crypt_auth_device_manager_observer_(this),
will_unlock_using_easy_unlock_(false), will_unlock_using_easy_unlock_(false),
lock_screen_last_shown_timestamp_(base::TimeTicks::Now()), lock_screen_last_shown_timestamp_(base::TimeTicks::Now()),
...@@ -424,51 +413,6 @@ void EasyUnlockServiceRegular::SetRemoteDevices( ...@@ -424,51 +413,6 @@ void EasyUnlockServiceRegular::SetRemoteDevices(
RefreshCryptohomeKeysIfPossible(); RefreshCryptohomeKeysIfPossible();
} }
void EasyUnlockServiceRegular::RunTurnOffFlow() {
if (turn_off_flow_status_ == PENDING)
return;
LogToggleFeature(SmartLockToggleFeature::DISABLE);
SetTurnOffFlowStatus(PENDING);
if (base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi)) {
// Disabling EASY_UNLOCK_HOST is a special case that does not require a
// public key to be passed; EASY_UNLOCK_HOST will be disabled for all hosts.
device_sync_client_->SetSoftwareFeatureState(
std::string() /* public_key */,
cryptauth::SoftwareFeature::EASY_UNLOCK_HOST, false /* enabled */,
false /* is_exclusive */,
base::BindOnce(&EasyUnlockServiceRegular::OnTurnOffEasyUnlockCompleted,
weak_ptr_factory_.GetWeakPtr()));
} else {
DCHECK(!cryptauth_client_);
std::unique_ptr<cryptauth::CryptAuthClientFactory> factory =
proximity_auth_client()->CreateCryptAuthClientFactory();
cryptauth_client_ = factory->CreateInstance();
cryptauth::ToggleEasyUnlockRequest request;
request.set_enable(false);
request.set_apply_to_all(true);
cryptauth_client_->ToggleEasyUnlock(
request,
base::Bind(&EasyUnlockServiceRegular::OnToggleEasyUnlockApiComplete,
weak_ptr_factory_.GetWeakPtr()),
base::Bind(&EasyUnlockServiceRegular::OnToggleEasyUnlockApiFailed,
weak_ptr_factory_.GetWeakPtr()));
}
}
void EasyUnlockServiceRegular::ResetTurnOffFlow() {
cryptauth_client_.reset();
SetTurnOffFlowStatus(IDLE);
}
EasyUnlockService::TurnOffFlowStatus
EasyUnlockServiceRegular::GetTurnOffFlowStatus() const {
return turn_off_flow_status_;
}
std::string EasyUnlockServiceRegular::GetChallenge() const { std::string EasyUnlockServiceRegular::GetChallenge() const {
return std::string(); return std::string();
} }
...@@ -522,7 +466,6 @@ void EasyUnlockServiceRegular::ShutdownInternal() { ...@@ -522,7 +466,6 @@ void EasyUnlockServiceRegular::ShutdownInternal() {
short_lived_user_context_.reset(); short_lived_user_context_.reset();
pref_manager_.reset(); pref_manager_.reset();
turn_off_flow_status_ = EasyUnlockService::IDLE;
proximity_auth::ScreenlockBridge::Get()->RemoveObserver(this); proximity_auth::ScreenlockBridge::Get()->RemoveObserver(this);
if (!base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi)) { if (!base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi)) {
...@@ -846,63 +789,6 @@ void EasyUnlockServiceRegular::OnFocusedUserChanged( ...@@ -846,63 +789,6 @@ void EasyUnlockServiceRegular::OnFocusedUserChanged(
// Nothing to do. // Nothing to do.
} }
void EasyUnlockServiceRegular::SetTurnOffFlowStatus(TurnOffFlowStatus status) {
turn_off_flow_status_ = status;
NotifyTurnOffOperationStatusChanged();
}
void EasyUnlockServiceRegular::OnToggleEasyUnlockApiComplete(
const cryptauth::ToggleEasyUnlockResponse& response) {
DCHECK(!base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi));
cryptauth_client_.reset();
OnTurnOffEasyUnlockSuccess();
}
void EasyUnlockServiceRegular::OnToggleEasyUnlockApiFailed(
cryptauth::NetworkRequestError error) {
PA_LOG(WARNING) << "ToggleEasyUnlock call failed: " << error;
DCHECK(!base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi));
OnTurnOffEasyUnlockFailure();
}
void EasyUnlockServiceRegular::OnTurnOffEasyUnlockCompleted(
device_sync::mojom::NetworkRequestResult result_code) {
DCHECK(base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi));
if (result_code != device_sync::mojom::NetworkRequestResult::kSuccess) {
PA_LOG(WARNING) << "ToggleEasyUnlock call failed: " << result_code;
OnTurnOffEasyUnlockFailure();
} else {
OnTurnOffEasyUnlockSuccess();
}
}
void EasyUnlockServiceRegular::OnTurnOffEasyUnlockSuccess() {
PA_LOG(INFO) << "Successfully turned off Smart Lock.";
LogToggleFeatureDisableResult(SmartLockResult::SUCCESS);
if (base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi)) {
remote_device_unlock_keys_before_sync_ = GetUnlockKeys();
} else {
GetCryptAuthDeviceManager()->ForceSyncNow(
cryptauth::InvocationReason::INVOCATION_REASON_FEATURE_TOGGLED);
}
EasyUnlockService::ResetLocalStateForUser(GetAccountId());
SetRemoteDevices(base::ListValue());
SetProximityAuthDevices(GetAccountId(), cryptauth::RemoteDeviceRefList(),
base::nullopt /* local_device */);
pref_manager_->SetIsEasyUnlockEnabled(false);
SetTurnOffFlowStatus(IDLE);
ResetScreenlockState();
registrar_.RemoveAll();
}
void EasyUnlockServiceRegular::OnTurnOffEasyUnlockFailure() {
LogToggleFeatureDisableResult(SmartLockResult::FAILURE);
SetTurnOffFlowStatus(FAIL);
}
cryptauth::CryptAuthEnrollmentManager* cryptauth::CryptAuthEnrollmentManager*
EasyUnlockServiceRegular::GetCryptAuthEnrollmentManager() { EasyUnlockServiceRegular::GetCryptAuthEnrollmentManager() {
DCHECK(!base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi)); DCHECK(!base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi));
......
...@@ -29,12 +29,10 @@ class ListValue; ...@@ -29,12 +29,10 @@ class ListValue;
} // namespace base } // namespace base
namespace cryptauth { namespace cryptauth {
class CryptAuthClient;
class CryptAuthDeviceManager; class CryptAuthDeviceManager;
class CryptAuthEnrollmentManager; class CryptAuthEnrollmentManager;
class LocalDeviceDataProvider; class LocalDeviceDataProvider;
class RemoteDeviceLoader; class RemoteDeviceLoader;
class ToggleEasyUnlockResponse;
} // namespace cryptauth } // namespace cryptauth
namespace proximity_auth { namespace proximity_auth {
...@@ -95,9 +93,6 @@ class EasyUnlockServiceRegular ...@@ -95,9 +93,6 @@ class EasyUnlockServiceRegular
void ClearPermitAccess() override; void ClearPermitAccess() override;
const base::ListValue* GetRemoteDevices() const override; const base::ListValue* GetRemoteDevices() const override;
void SetRemoteDevices(const base::ListValue& devices) override; void SetRemoteDevices(const base::ListValue& devices) override;
void RunTurnOffFlow() override;
void ResetTurnOffFlow() override;
TurnOffFlowStatus GetTurnOffFlowStatus() const override;
std::string GetChallenge() const override; std::string GetChallenge() const override;
std::string GetWrappedSecret() const override; std::string GetWrappedSecret() const override;
void RecordEasySignInOutcome(const AccountId& account_id, void RecordEasySignInOutcome(const AccountId& account_id,
...@@ -150,20 +145,6 @@ class EasyUnlockServiceRegular ...@@ -150,20 +145,6 @@ class EasyUnlockServiceRegular
override; override;
void OnFocusedUserChanged(const AccountId& account_id) override; void OnFocusedUserChanged(const AccountId& account_id) override;
// Sets the new turn-off flow status.
void SetTurnOffFlowStatus(TurnOffFlowStatus status);
// Callback for ToggleEasyUnlock CryptAuth API.
void OnToggleEasyUnlockApiComplete(
const cryptauth::ToggleEasyUnlockResponse& response);
void OnToggleEasyUnlockApiFailed(cryptauth::NetworkRequestError error);
void OnTurnOffEasyUnlockCompleted(
device_sync::mojom::NetworkRequestResult result_code);
void OnTurnOffEasyUnlockSuccess();
void OnTurnOffEasyUnlockFailure();
// Called after a cryptohome RemoveKey or RefreshKey operation to set the // Called after a cryptohome RemoveKey or RefreshKey operation to set the
// proper hardlock state if the operation is successful. // proper hardlock state if the operation is successful.
void SetHardlockAfterKeyOperation( void SetHardlockAfterKeyOperation(
...@@ -186,8 +167,6 @@ class EasyUnlockServiceRegular ...@@ -186,8 +167,6 @@ class EasyUnlockServiceRegular
cryptauth::RemoteDeviceRefList GetUnlockKeys(); cryptauth::RemoteDeviceRefList GetUnlockKeys();
TurnOffFlowStatus turn_off_flow_status_;
std::unique_ptr<cryptauth::CryptAuthClient> cryptauth_client_;
ScopedObserver<cryptauth::CryptAuthDeviceManager, EasyUnlockServiceRegular> ScopedObserver<cryptauth::CryptAuthDeviceManager, EasyUnlockServiceRegular>
scoped_crypt_auth_device_manager_observer_; scoped_crypt_auth_device_manager_observer_;
......
...@@ -241,19 +241,6 @@ void EasyUnlockServiceSignin::SetRemoteDevices(const base::ListValue& devices) { ...@@ -241,19 +241,6 @@ void EasyUnlockServiceSignin::SetRemoteDevices(const base::ListValue& devices) {
NOTREACHED(); NOTREACHED();
} }
void EasyUnlockServiceSignin::RunTurnOffFlow() {
NOTREACHED();
}
void EasyUnlockServiceSignin::ResetTurnOffFlow() {
NOTREACHED();
}
EasyUnlockService::TurnOffFlowStatus
EasyUnlockServiceSignin::GetTurnOffFlowStatus() const {
return EasyUnlockService::IDLE;
}
std::string EasyUnlockServiceSignin::GetChallenge() const { std::string EasyUnlockServiceSignin::GetChallenge() const {
const UserData* data = FindLoadedDataForCurrentUser(); const UserData* data = FindLoadedDataForCurrentUser();
if (!data) if (!data)
......
...@@ -95,9 +95,6 @@ class EasyUnlockServiceSignin ...@@ -95,9 +95,6 @@ class EasyUnlockServiceSignin
void ClearPermitAccess() override; void ClearPermitAccess() override;
const base::ListValue* GetRemoteDevices() const override; const base::ListValue* GetRemoteDevices() const override;
void SetRemoteDevices(const base::ListValue& devices) override; void SetRemoteDevices(const base::ListValue& devices) override;
void RunTurnOffFlow() override;
void ResetTurnOffFlow() override;
TurnOffFlowStatus GetTurnOffFlowStatus() const override;
std::string GetChallenge() const override; std::string GetChallenge() const override;
std::string GetWrappedSecret() const override; std::string GetWrappedSecret() const override;
void RecordEasySignInOutcome(const AccountId& account_id, void RecordEasySignInOutcome(const AccountId& account_id,
......
...@@ -11,7 +11,6 @@ js_type_check("closure_compile") { ...@@ -11,7 +11,6 @@ js_type_check("closure_compile") {
":change_picture", ":change_picture",
":change_picture_browser_proxy", ":change_picture_browser_proxy",
":easy_unlock_browser_proxy", ":easy_unlock_browser_proxy",
":easy_unlock_turn_off_dialog",
":fingerprint_browser_proxy", ":fingerprint_browser_proxy",
":fingerprint_list", ":fingerprint_list",
":import_data_browser_proxy", ":import_data_browser_proxy",
...@@ -78,16 +77,6 @@ js_library("easy_unlock_browser_proxy") { ...@@ -78,16 +77,6 @@ js_library("easy_unlock_browser_proxy") {
] ]
} }
js_library("easy_unlock_turn_off_dialog") {
deps = [
":easy_unlock_browser_proxy",
"//ui/webui/resources/cr_elements/cr_dialog:cr_dialog",
"//ui/webui/resources/js:cr",
"//ui/webui/resources/js:i18n_behavior",
"//ui/webui/resources/js:web_ui_listener_behavior",
]
}
js_library("fingerprint_browser_proxy") { js_library("fingerprint_browser_proxy") {
deps = [ deps = [
"//ui/webui/resources/js:cr", "//ui/webui/resources/js:cr",
...@@ -118,7 +107,6 @@ js_library("import_data_browser_proxy") { ...@@ -118,7 +107,6 @@ js_library("import_data_browser_proxy") {
js_library("lock_screen") { js_library("lock_screen") {
deps = [ deps = [
":easy_unlock_browser_proxy", ":easy_unlock_browser_proxy",
":easy_unlock_turn_off_dialog",
":fingerprint_browser_proxy", ":fingerprint_browser_proxy",
":lock_screen_password_prompt_dialog", ":lock_screen_password_prompt_dialog",
":lock_state_behavior", ":lock_state_behavior",
......
...@@ -16,22 +16,6 @@ cr.define('settings', function() { ...@@ -16,22 +16,6 @@ cr.define('settings', function() {
* @return {!Promise<boolean>} * @return {!Promise<boolean>}
*/ */
getEnabledStatus() {} getEnabledStatus() {}
/**
* Returns the Easy Unlock turn off flow status.
* @return {!Promise<string>}
*/
getTurnOffFlowStatus() {}
/**
* Begins the Easy Unlock turn off flow.
*/
startTurnOffFlow() {}
/**
* Cancels any in-progress Easy Unlock turn-off flows.
*/
cancelTurnOffFlow() {}
} }
/** /**
...@@ -42,21 +26,6 @@ cr.define('settings', function() { ...@@ -42,21 +26,6 @@ cr.define('settings', function() {
getEnabledStatus() { getEnabledStatus() {
return cr.sendWithPromise('easyUnlockGetEnabledStatus'); return cr.sendWithPromise('easyUnlockGetEnabledStatus');
} }
/** @override */
getTurnOffFlowStatus() {
return cr.sendWithPromise('easyUnlockGetTurnOffFlowStatus');
}
/** @override */
startTurnOffFlow() {
chrome.send('easyUnlockStartTurnOffFlow');
}
/** @override */
cancelTurnOffFlow() {
chrome.send('easyUnlockCancelTurnOffFlow');
}
} }
// The singleton instance_ is replaced with a test version of this wrapper // The singleton instance_ is replaced with a test version of this wrapper
......
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-spinner/paper-spinner-lite.html">
<link rel="import" href="../i18n_setup.html">
<link rel="import" href="easy_unlock_browser_proxy.html">
<link rel="import" href="../settings_shared_css.html">
<dom-module id="easy-unlock-turn-off-dialog">
<template>
<style include="settings-shared"></style>
<cr-dialog id="dialog" close-text="$i18n{close}">
<div slot="title">[[getTitleText_(status_)]]</div>
<div slot="body">
[[getDescriptionText_(status_)]]
</div>
<div slot="button-container"
hidden="[[isButtonBarHidden_(status_)]]">
<paper-spinner-lite active="[[isSpinnerActive_(status_)]]">
</paper-spinner-lite>
<paper-button class="cancel-button" on-click="onCancelTap_"
hidden="[[isCancelButtonHidden_(status_)]]">
$i18n{cancel}
</paper-button>
<paper-button id="turnOff" class="action-button"
on-click="onTurnOffTap_"
disabled="[[!isTurnOffButtonEnabled_(status_)]]">
[[getTurnOffButtonText_(status_)]]
</paper-button>
</div>
</cr-dialog>
</template>
<script src="easy_unlock_turn_off_dialog.js"></script>
</dom-module>
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview A dialog allowing the user to turn off the Easy Unlock feature.
*/
cr.exportPath('settings');
/**
* Possible UI statuses for the EasyUnlockTurnOffDialogElement.
* See easy_unlock_settings_handler.cc.
* @enum {string}
*/
settings.EasyUnlockTurnOffStatus = {
UNKNOWN: 'unknown',
OFFLINE: 'offline',
IDLE: 'idle',
PENDING: 'pending',
SERVER_ERROR: 'server-error',
};
(function() {
Polymer({
is: 'easy-unlock-turn-off-dialog',
behaviors: [I18nBehavior, WebUIListenerBehavior],
properties: {
/** @private {!settings.EasyUnlockTurnOffStatus} */
status_: {
type: String,
value: settings.EasyUnlockTurnOffStatus.UNKNOWN,
},
},
/** @private {settings.EasyUnlockBrowserProxy} */
browserProxy_: null,
/** @override */
attached: function() {
this.browserProxy_ = settings.EasyUnlockBrowserProxyImpl.getInstance();
this.addWebUIListener(
'easy-unlock-enabled-status',
this.handleEasyUnlockEnabledStatusChanged_.bind(this));
this.addWebUIListener('easy-unlock-turn-off-flow-status', status => {
this.status_ = status;
});
// Since the dialog text depends on the status, defer opening until we have
// retrieved the turn off status to prevent UI flicker.
this.getTurnOffStatus_().then(status => {
this.status_ = status;
this.$.dialog.showModal();
});
},
/**
* @return {!Promise<!settings.EasyUnlockTurnOffStatus>}
* @private
*/
getTurnOffStatus_: function() {
return navigator.onLine ?
this.browserProxy_.getTurnOffFlowStatus() :
Promise.resolve(settings.EasyUnlockTurnOffStatus.OFFLINE);
},
/**
* This dialog listens for Easy Unlock to become disabled. This signals
* that the turnoff process has succeeded. Regardless of whether the turnoff
* was initiated from this tab or another, this closes the dialog.
* @param {boolean} easyUnlockEnabled
* @private
*/
handleEasyUnlockEnabledStatusChanged_: function(easyUnlockEnabled) {
const dialog = /** @type {!CrDialogElement} */ (this.$.dialog);
if (!easyUnlockEnabled && dialog.open)
this.onCancelTap_();
},
/** @private */
onCancelTap_: function() {
this.browserProxy_.cancelTurnOffFlow();
this.$.dialog.close();
},
/** @private */
onTurnOffTap_: function() {
this.browserProxy_.startTurnOffFlow();
},
/**
* @param {!settings.EasyUnlockTurnOffStatus} status
* @return {string}
* @private
*/
getTitleText_: function(status) {
switch (status) {
case settings.EasyUnlockTurnOffStatus.OFFLINE:
return this.i18n('easyUnlockTurnOffOfflineTitle');
case settings.EasyUnlockTurnOffStatus.UNKNOWN:
case settings.EasyUnlockTurnOffStatus.IDLE:
case settings.EasyUnlockTurnOffStatus.PENDING:
return this.i18n('easyUnlockTurnOffTitle');
case settings.EasyUnlockTurnOffStatus.SERVER_ERROR:
return this.i18n('easyUnlockTurnOffErrorTitle');
}
assertNotReached();
},
/**
* @param {!settings.EasyUnlockTurnOffStatus} status
* @return {string}
* @private
*/
getDescriptionText_: function(status) {
switch (status) {
case settings.EasyUnlockTurnOffStatus.OFFLINE:
return this.i18n('easyUnlockTurnOffOfflineMessage');
case settings.EasyUnlockTurnOffStatus.UNKNOWN:
case settings.EasyUnlockTurnOffStatus.IDLE:
case settings.EasyUnlockTurnOffStatus.PENDING:
return this.i18n('easyUnlockTurnOffDescription');
case settings.EasyUnlockTurnOffStatus.SERVER_ERROR:
return this.i18n('easyUnlockTurnOffErrorMessage');
}
assertNotReached();
},
/**
* @param {!settings.EasyUnlockTurnOffStatus} status
* @return {string}
* @private
*/
getTurnOffButtonText_: function(status) {
switch (status) {
case settings.EasyUnlockTurnOffStatus.OFFLINE:
return '';
case settings.EasyUnlockTurnOffStatus.UNKNOWN:
case settings.EasyUnlockTurnOffStatus.IDLE:
case settings.EasyUnlockTurnOffStatus.PENDING:
return this.i18n('easyUnlockTurnOffButton');
case settings.EasyUnlockTurnOffStatus.SERVER_ERROR:
return this.i18n('retry');
}
assertNotReached();
},
/**
* @param {!settings.EasyUnlockTurnOffStatus} status
* @return {boolean}
* @private
*/
isButtonBarHidden_: function(status) {
return status == settings.EasyUnlockTurnOffStatus.OFFLINE;
},
/**
* @param {!settings.EasyUnlockTurnOffStatus} status
* @return {boolean}
* @private
*/
isSpinnerActive_: function(status) {
return status == settings.EasyUnlockTurnOffStatus.PENDING;
},
/**
* @param {!settings.EasyUnlockTurnOffStatus} status
* @return {boolean}
* @private
*/
isCancelButtonHidden_: function(status) {
return status == settings.EasyUnlockTurnOffStatus.SERVER_ERROR;
},
/**
* @param {!settings.EasyUnlockTurnOffStatus} status
* @return {boolean}
* @private
*/
isTurnOffButtonEnabled_: function(status) {
return status == settings.EasyUnlockTurnOffStatus.IDLE ||
status == settings.EasyUnlockTurnOffStatus.SERVER_ERROR;
},
});
})();
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> <link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="../controls/settings_toggle_button.html"> <link rel="import" href="../controls/settings_toggle_button.html">
<link rel="import" href="easy_unlock_browser_proxy.html"> <link rel="import" href="easy_unlock_browser_proxy.html">
<link rel="import" href="easy_unlock_turn_off_dialog.html">
<link rel="import" href="fingerprint_browser_proxy.html"> <link rel="import" href="fingerprint_browser_proxy.html">
<link rel="import" href="lock_state_behavior.html"> <link rel="import" href="lock_state_behavior.html">
<link rel="import" href="lock_screen_password_prompt_dialog.html"> <link rel="import" href="lock_screen_password_prompt_dialog.html">
...@@ -187,17 +186,6 @@ ...@@ -187,17 +186,6 @@
</a> </a>
</div> </div>
</div> </div>
<template is="dom-if" if="[[easyUnlockAvailable_(
multideviceSettingsEnabled_, easyUnlockAllowed_,
easyUnlockInLegacyHostMode_)]]">
<div class="separator"></div>
<template is="dom-if" if="[[easyUnlockEnabled_]]">
<paper-button id="easyUnlockTurnOff" class="secondary-button"
on-click="onEasyUnlockTurnOffTap_">
$i18n{easyUnlockTurnOffButton}
</paper-button>
</template>
</template>
</div> </div>
<iron-collapse opened="[[easyUnlockEnabled_]]" <iron-collapse opened="[[easyUnlockEnabled_]]"
id="easyUnlockSettingsCollapsible"> id="easyUnlockSettingsCollapsible">
...@@ -231,12 +219,6 @@ ...@@ -231,12 +219,6 @@
on-close="onSetupPinDialogClose_"> on-close="onSetupPinDialogClose_">
</settings-setup-pin-dialog> </settings-setup-pin-dialog>
</template> </template>
<template is="dom-if" if="[[showEasyUnlockTurnOffDialog_]]" restamp>
<easy-unlock-turn-off-dialog id="easyUnlockTurnOffDialog"
on-close="onEasyUnlockTurnOffDialogClose_">
</easy-unlock-turn-off-dialog>
</template>
</div> </div>
</template> </template>
......
...@@ -213,12 +213,6 @@ Polymer({ ...@@ -213,12 +213,6 @@ Polymer({
readOnly: true, readOnly: true,
}, },
/** @private */
showEasyUnlockTurnOffDialog_: {
type: Boolean,
value: false,
},
/** @private */ /** @private */
showPasswordPromptDialog_: Boolean, showPasswordPromptDialog_: Boolean,
...@@ -401,28 +395,6 @@ Polymer({ ...@@ -401,28 +395,6 @@ Polymer({
*/ */
handleEasyUnlockEnabledStatusChanged_: function(easyUnlockEnabled) { handleEasyUnlockEnabledStatusChanged_: function(easyUnlockEnabled) {
this.easyUnlockEnabled_ = easyUnlockEnabled; this.easyUnlockEnabled_ = easyUnlockEnabled;
this.showEasyUnlockTurnOffDialog_ =
easyUnlockEnabled && this.showEasyUnlockTurnOffDialog_;
},
/**
* @param {!Event} e
* @private
*/
onEasyUnlockTurnOffTap_: function(e) {
// Prevent the end of the tap event from focusing what is underneath the
// button.
e.preventDefault();
this.showEasyUnlockTurnOffDialog_ = true;
},
/** @private */
onEasyUnlockTurnOffDialogClose_: function() {
this.showEasyUnlockTurnOffDialog_ = false;
// Restores focus on close to either the turn-off or set-up button,
// whichever is being displayed.
cr.ui.focusWithoutInk(assert(this.$$('.secondary-button')));
}, },
/** /**
......
...@@ -1463,14 +1463,6 @@ ...@@ -1463,14 +1463,6 @@
type="chrome_html" type="chrome_html"
preprocess="true" preprocess="true"
allowexternalscript="true" /> allowexternalscript="true" />
<structure name="IDR_SETTINGS_PEOPLE_EASY_UNLOCK_TURN_OFF_DIALOG_JS"
file="people_page/easy_unlock_turn_off_dialog.js"
type="chrome_html" />
<structure name="IDR_SETTINGS_PEOPLE_EASY_UNLOCK_TURN_OFF_DIALOG_HTML"
file="people_page/easy_unlock_turn_off_dialog.html"
type="chrome_html"
preprocess="true"
allowexternalscript="true" />
<structure name="IDR_SETTINGS_PEOPLE_LOCK_SCREEN_PASSWORD_PROMPT_DIALOG_JS" <structure name="IDR_SETTINGS_PEOPLE_LOCK_SCREEN_PASSWORD_PROMPT_DIALOG_JS"
file="people_page/lock_screen_password_prompt_dialog.js" file="people_page/lock_screen_password_prompt_dialog.js"
type="chrome_html" /> type="chrome_html" />
......
...@@ -25,9 +25,7 @@ EasyUnlockSettingsHandler::EasyUnlockSettingsHandler(Profile* profile) ...@@ -25,9 +25,7 @@ EasyUnlockSettingsHandler::EasyUnlockSettingsHandler(Profile* profile)
profile_pref_registrar_.Init(profile->GetPrefs()); profile_pref_registrar_.Init(profile->GetPrefs());
} }
EasyUnlockSettingsHandler::~EasyUnlockSettingsHandler() { EasyUnlockSettingsHandler::~EasyUnlockSettingsHandler() {}
EasyUnlockService::Get(profile_)->RemoveObserver(this);
}
EasyUnlockSettingsHandler* EasyUnlockSettingsHandler::Create( EasyUnlockSettingsHandler* EasyUnlockSettingsHandler::Create(
content::WebUIDataSource* html_source, content::WebUIDataSource* html_source,
...@@ -56,24 +54,9 @@ void EasyUnlockSettingsHandler::RegisterMessages() { ...@@ -56,24 +54,9 @@ void EasyUnlockSettingsHandler::RegisterMessages() {
"easyUnlockGetEnabledStatus", "easyUnlockGetEnabledStatus",
base::BindRepeating(&EasyUnlockSettingsHandler::HandleGetEnabledStatus, base::BindRepeating(&EasyUnlockSettingsHandler::HandleGetEnabledStatus,
base::Unretained(this))); base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"easyUnlockGetTurnOffFlowStatus",
base::BindRepeating(
&EasyUnlockSettingsHandler::HandleGetTurnOffFlowStatus,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"easyUnlockStartTurnOffFlow",
base::BindRepeating(&EasyUnlockSettingsHandler::HandleStartTurnOffFlow,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"easyUnlockCancelTurnOffFlow",
base::BindRepeating(&EasyUnlockSettingsHandler::HandleCancelTurnOffFlow,
base::Unretained(this)));
} }
void EasyUnlockSettingsHandler::OnJavascriptAllowed() { void EasyUnlockSettingsHandler::OnJavascriptAllowed() {
EasyUnlockService::Get(profile_)->AddObserver(this);
profile_pref_registrar_.Add( profile_pref_registrar_.Add(
prefs::kEasyUnlockPairing, prefs::kEasyUnlockPairing,
base::Bind(&EasyUnlockSettingsHandler::SendEnabledStatus, base::Bind(&EasyUnlockSettingsHandler::SendEnabledStatus,
...@@ -81,47 +64,15 @@ void EasyUnlockSettingsHandler::OnJavascriptAllowed() { ...@@ -81,47 +64,15 @@ void EasyUnlockSettingsHandler::OnJavascriptAllowed() {
} }
void EasyUnlockSettingsHandler::OnJavascriptDisallowed() { void EasyUnlockSettingsHandler::OnJavascriptDisallowed() {
EasyUnlockService::Get(profile_)->RemoveObserver(this);
profile_pref_registrar_.RemoveAll(); profile_pref_registrar_.RemoveAll();
} }
void EasyUnlockSettingsHandler::OnTurnOffOperationStatusChanged() {
FireWebUIListener("easy-unlock-turn-off-flow-status",
base::Value(GetTurnOffFlowStatus()));
}
void EasyUnlockSettingsHandler::SendEnabledStatus() { void EasyUnlockSettingsHandler::SendEnabledStatus() {
CallJavascriptFunction( CallJavascriptFunction(
"cr.webUIListenerCallback", base::Value("easy-unlock-enabled-status"), "cr.webUIListenerCallback", base::Value("easy-unlock-enabled-status"),
base::Value(EasyUnlockService::Get(profile_)->IsEnabled())); base::Value(EasyUnlockService::Get(profile_)->IsEnabled()));
} }
std::string EasyUnlockSettingsHandler::GetTurnOffFlowStatus() {
EasyUnlockService::TurnOffFlowStatus status =
EasyUnlockService::Get(profile_)->GetTurnOffFlowStatus();
// Translate status into JS UI state string. Note the translated string
// should match UIState defined in easy_unlock_turn_off_dialog.js.
std::string status_string;
switch (status) {
case EasyUnlockService::IDLE:
status_string = "idle";
break;
case EasyUnlockService::PENDING:
status_string = "pending";
break;
case EasyUnlockService::FAIL:
status_string = "server-error";
break;
default:
LOG(ERROR) << "Unknown Easy unlock turn-off operation status: " << status;
status_string = "idle";
break;
}
return status_string;
}
void EasyUnlockSettingsHandler::HandleGetEnabledStatus( void EasyUnlockSettingsHandler::HandleGetEnabledStatus(
const base::ListValue* args) { const base::ListValue* args) {
AllowJavascript(); AllowJavascript();
...@@ -133,23 +84,5 @@ void EasyUnlockSettingsHandler::HandleGetEnabledStatus( ...@@ -133,23 +84,5 @@ void EasyUnlockSettingsHandler::HandleGetEnabledStatus(
*callback_id, base::Value(EasyUnlockService::Get(profile_)->IsEnabled())); *callback_id, base::Value(EasyUnlockService::Get(profile_)->IsEnabled()));
} }
void EasyUnlockSettingsHandler::HandleGetTurnOffFlowStatus(
const base::ListValue* args) {
CHECK_EQ(1U, args->GetSize());
const base::Value* callback_id;
CHECK(args->Get(0, &callback_id));
ResolveJavascriptCallback(*callback_id, base::Value(GetTurnOffFlowStatus()));
}
void EasyUnlockSettingsHandler::HandleStartTurnOffFlow(
const base::ListValue* args) {
EasyUnlockService::Get(profile_)->RunTurnOffFlow();
}
void EasyUnlockSettingsHandler::HandleCancelTurnOffFlow(
const base::ListValue* args) {
EasyUnlockService::Get(profile_)->ResetTurnOffFlow();
}
} // namespace settings } // namespace settings
} // namespace chromeos } // namespace chromeos
...@@ -19,8 +19,7 @@ class Profile; ...@@ -19,8 +19,7 @@ class Profile;
namespace chromeos { namespace chromeos {
namespace settings { namespace settings {
class EasyUnlockSettingsHandler : public ::settings::SettingsPageUIHandler, class EasyUnlockSettingsHandler : public ::settings::SettingsPageUIHandler {
public EasyUnlockServiceObserver {
public: public:
// Returns nullptr if EasyUnlock is not allowed for this device. // Returns nullptr if EasyUnlock is not allowed for this device.
static EasyUnlockSettingsHandler* Create( static EasyUnlockSettingsHandler* Create(
...@@ -34,25 +33,16 @@ class EasyUnlockSettingsHandler : public ::settings::SettingsPageUIHandler, ...@@ -34,25 +33,16 @@ class EasyUnlockSettingsHandler : public ::settings::SettingsPageUIHandler,
void OnJavascriptAllowed() override; void OnJavascriptAllowed() override;
void OnJavascriptDisallowed() override; void OnJavascriptDisallowed() override;
// EasyUnlockServiceObserver:
void OnTurnOffOperationStatusChanged() override;
protected: protected:
explicit EasyUnlockSettingsHandler(Profile* profile); explicit EasyUnlockSettingsHandler(Profile* profile);
private: private:
FRIEND_TEST_ALL_PREFIXES(EasyUnlockSettingsHandlerTest, EnabledStatus); FRIEND_TEST_ALL_PREFIXES(EasyUnlockSettingsHandlerTest, EnabledStatus);
FRIEND_TEST_ALL_PREFIXES(EasyUnlockSettingsHandlerTest, TurnOffFlowStatus);
void SendEnabledStatus(); void SendEnabledStatus();
std::string GetTurnOffFlowStatus();
// JS callbacks. // JS callbacks.
void HandleGetEnabledStatus(const base::ListValue* args); void HandleGetEnabledStatus(const base::ListValue* args);
void HandleStartTurnOnFlow(const base::ListValue* args);
void HandleGetTurnOffFlowStatus(const base::ListValue* args);
void HandleStartTurnOffFlow(const base::ListValue* args);
void HandleCancelTurnOffFlow(const base::ListValue* args);
Profile* const profile_; Profile* const profile_;
......
...@@ -24,35 +24,15 @@ class FakeEasyUnlockService : public EasyUnlockService { ...@@ -24,35 +24,15 @@ class FakeEasyUnlockService : public EasyUnlockService {
public: public:
explicit FakeEasyUnlockService(Profile* profile) explicit FakeEasyUnlockService(Profile* profile)
: EasyUnlockService(profile, nullptr /* secure_channel_client */), : EasyUnlockService(profile, nullptr /* secure_channel_client */),
turn_off_status_(IDLE),
is_allowed_(true), is_allowed_(true),
is_enabled_(false) {} is_enabled_(false) {}
TurnOffFlowStatus GetTurnOffFlowStatus() const override {
return turn_off_status_;
}
bool IsAllowed() const override { return is_allowed_; } bool IsAllowed() const override { return is_allowed_; }
void set_is_allowed(bool is_allowed) { is_allowed_ = is_allowed; } void set_is_allowed(bool is_allowed) { is_allowed_ = is_allowed; }
bool IsEnabled() const override { return is_enabled_; } bool IsEnabled() const override { return is_enabled_; }
void set_is_enabled(bool is_enabled) { is_enabled_ = is_enabled; } void set_is_enabled(bool is_enabled) { is_enabled_ = is_enabled; }
void RunTurnOffFlow() override {
turn_off_status_ = PENDING;
NotifyTurnOffOperationStatusChanged();
}
void ResetTurnOffFlow() override {
turn_off_status_ = IDLE;
NotifyTurnOffOperationStatusChanged();
}
void SetTurnOffFlowFailForTest() {
turn_off_status_ = FAIL;
NotifyTurnOffOperationStatusChanged();
}
private: private:
Type GetType() const override { return TYPE_REGULAR; } Type GetType() const override { return TYPE_REGULAR; }
AccountId GetAccountId() const override { return EmptyAccountId(); } AccountId GetAccountId() const override { return EmptyAccountId(); }
...@@ -73,7 +53,6 @@ class FakeEasyUnlockService : public EasyUnlockService { ...@@ -73,7 +53,6 @@ class FakeEasyUnlockService : public EasyUnlockService {
void OnWillFinalizeUnlock(bool success) override {} void OnWillFinalizeUnlock(bool success) override {}
void OnSuspendDoneInternal() override {} void OnSuspendDoneInternal() override {}
TurnOffFlowStatus turn_off_status_;
bool is_allowed_; bool is_allowed_;
bool is_enabled_; bool is_enabled_;
}; };
...@@ -142,41 +121,6 @@ class EasyUnlockSettingsHandlerTest : public testing::Test { ...@@ -142,41 +121,6 @@ class EasyUnlockSettingsHandlerTest : public testing::Test {
EXPECT_EQ(expected_status, status); EXPECT_EQ(expected_status, status);
} }
void VerifyTurnOffFlowStatusWebUIListenerCallback(
size_t expected_total_calls,
const std::string& expected_status) {
std::string event;
std::string status;
EXPECT_EQ(expected_total_calls, web_ui_.call_data().size());
const content::TestWebUI::CallData& data = *web_ui_.call_data().back();
EXPECT_EQ("cr.webUIListenerCallback", data.function_name());
ASSERT_TRUE(data.arg1()->GetAsString(&event));
EXPECT_EQ("easy-unlock-turn-off-flow-status", event);
ASSERT_TRUE(data.arg2()->GetAsString(&status));
EXPECT_EQ(expected_status, status);
}
void VerifyTurnOffFlowStatusWebUIResponse(
size_t expected_total_calls,
const std::string& expected_callback_id,
const std::string& expected_status) {
EXPECT_EQ(expected_total_calls, web_ui()->call_data().size());
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
EXPECT_EQ("cr.webUIResponse", data.function_name());
std::string callback_id;
ASSERT_TRUE(data.arg1()->GetAsString(&callback_id));
EXPECT_EQ(expected_callback_id, callback_id);
std::string actual_status;
ASSERT_TRUE(data.arg3()->GetAsString(&actual_status));
EXPECT_EQ(expected_status, actual_status);
}
private: private:
content::TestBrowserThreadBundle thread_bundle_; content::TestBrowserThreadBundle thread_bundle_;
std::unique_ptr<TestingProfile> profile_; std::unique_ptr<TestingProfile> profile_;
...@@ -239,42 +183,5 @@ TEST_F(EasyUnlockSettingsHandlerTest, EnabledStatus) { ...@@ -239,42 +183,5 @@ TEST_F(EasyUnlockSettingsHandlerTest, EnabledStatus) {
VerifyEnabledStatusCallback(3U, true); VerifyEnabledStatusCallback(3U, true);
} }
TEST_F(EasyUnlockSettingsHandlerTest, TurnOffFlowStatus) {
std::unique_ptr<EasyUnlockSettingsHandler> handler;
handler.reset(new TestEasyUnlockSettingsHandler(profile()));
handler->set_web_ui(web_ui());
// Send an initial status query to turn on service observer.
base::ListValue list_args1;
list_args1.AppendString("test-callback-id-1");
handler->HandleGetEnabledStatus(&list_args1);
EXPECT_EQ(1U, web_ui()->call_data().size());
base::ListValue list_args2;
list_args2.AppendString("test-callback-id-2");
handler->HandleGetTurnOffFlowStatus(&list_args2);
VerifyTurnOffFlowStatusWebUIResponse(2U, "test-callback-id-2", "idle");
handler->HandleStartTurnOffFlow(nullptr);
VerifyTurnOffFlowStatusWebUIListenerCallback(3U, "pending");
base::ListValue list_args3;
list_args3.AppendString("test-callback-id-3");
handler->HandleGetTurnOffFlowStatus(&list_args3);
VerifyTurnOffFlowStatusWebUIResponse(4U, "test-callback-id-3", "pending");
handler->HandleCancelTurnOffFlow(nullptr);
VerifyTurnOffFlowStatusWebUIListenerCallback(5U, "idle");
fake_easy_unlock_service()->SetTurnOffFlowFailForTest();
VerifyTurnOffFlowStatusWebUIListenerCallback(6U, "server-error");
base::ListValue list_args4;
list_args4.AppendString("test-callback-id-4");
handler->HandleGetTurnOffFlowStatus(&list_args4);
VerifyTurnOffFlowStatusWebUIResponse(7U, "test-callback-id-4",
"server-error");
}
} // namespace settings } // namespace settings
} // namespace chromeos } // namespace chromeos
...@@ -1112,16 +1112,6 @@ void AddDateTimeStrings(content::WebUIDataSource* html_source) { ...@@ -1112,16 +1112,6 @@ void AddDateTimeStrings(content::WebUIDataSource* html_source) {
void AddEasyUnlockStrings(content::WebUIDataSource* html_source) { void AddEasyUnlockStrings(content::WebUIDataSource* html_source) {
LocalizedString localized_strings[] = { LocalizedString localized_strings[] = {
{"easyUnlockSectionTitle", IDS_SETTINGS_EASY_UNLOCK_SECTION_TITLE}, {"easyUnlockSectionTitle", IDS_SETTINGS_EASY_UNLOCK_SECTION_TITLE},
// Easy Unlock turn-off dialog.
{"easyUnlockTurnOffButton", IDS_SETTINGS_EASY_UNLOCK_TURN_OFF},
{"easyUnlockTurnOffOfflineTitle",
IDS_SETTINGS_EASY_UNLOCK_TURN_OFF_OFFLINE_TITLE},
{"easyUnlockTurnOffOfflineMessage",
IDS_SETTINGS_EASY_UNLOCK_TURN_OFF_OFFLINE_MESSAGE},
{"easyUnlockTurnOffErrorTitle",
IDS_SETTINGS_EASY_UNLOCK_TURN_OFF_ERROR_TITLE},
{"easyUnlockTurnOffErrorMessage",
IDS_SETTINGS_EASY_UNLOCK_TURN_OFF_ERROR_MESSAGE},
{"easyUnlockAllowSignInLabel", {"easyUnlockAllowSignInLabel",
IDS_SETTINGS_EASY_UNLOCK_ALLOW_SIGN_IN_LABEL}, IDS_SETTINGS_EASY_UNLOCK_ALLOW_SIGN_IN_LABEL},
{"easyUnlockProximityThresholdLabel", {"easyUnlockProximityThresholdLabel",
...@@ -1152,14 +1142,6 @@ void AddEasyUnlockStrings(content::WebUIDataSource* html_source) { ...@@ -1152,14 +1142,6 @@ void AddEasyUnlockStrings(content::WebUIDataSource* html_source) {
"easyUnlockDescription", "easyUnlockDescription",
l10n_util::GetStringFUTF16(IDS_SETTINGS_EASY_UNLOCK_DESCRIPTION, l10n_util::GetStringFUTF16(IDS_SETTINGS_EASY_UNLOCK_DESCRIPTION,
device_name)); device_name));
html_source->AddString(
"easyUnlockTurnOffTitle",
l10n_util::GetStringFUTF16(IDS_SETTINGS_EASY_UNLOCK_TURN_OFF_TITLE,
device_name));
html_source->AddString(
"easyUnlockTurnOffDescription",
l10n_util::GetStringFUTF16(IDS_SETTINGS_EASY_UNLOCK_TURN_OFF_DESCRIPTION,
device_name));
html_source->AddString( html_source->AddString(
"easyUnlockProximityThresholdLabel", "easyUnlockProximityThresholdLabel",
l10n_util::GetStringFUTF16( l10n_util::GetStringFUTF16(
......
...@@ -100,7 +100,6 @@ js2gtest("browser_tests_js_webui") { ...@@ -100,7 +100,6 @@ js2gtest("browser_tests_js_webui") {
if (is_chromeos) { if (is_chromeos) {
sources += [ sources += [
"certificate_viewer_dialog_test.js", "certificate_viewer_dialog_test.js",
"settings/easy_unlock_browsertest_chromeos.js",
"sys_internals/sys_internals_browsertest.js", "sys_internals/sys_internals_browsertest.js",
] ]
} else { } else {
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/** @fileoverview Suite of tests for Easy Unlock within People section. */
GEN_INCLUDE(['settings_page_browsertest.js']);
/**
* @constructor
* @extends {SettingsPageBrowserTest}
*/
function SettingsEasyUnlockBrowserTest() {}
SettingsEasyUnlockBrowserTest.prototype = {
__proto__: SettingsPageBrowserTest.prototype,
/** @override */
extraLibraries: PolymerTest.getLibraries(ROOT_PATH).concat([
'../test_browser_proxy.js',
]),
};
// Times out on debug builders and may time out on memory bots because
// the Settings page can take several seconds to load in a Release build
// and several times that in a Debug build. See https://crbug.com/558434
// and http://crbug.com/711256.
// Runs easy unlock tests.
TEST_F('SettingsEasyUnlockBrowserTest', 'DISABLED_EasyUnlock', function() {
/**
* A test version of EasyUnlockBrowserProxy. Provides helper methods
* for allowing tests to know when a method was called, as well as
* specifying mock responses.
*
* @implements {settings.EasyUnlockBrowserProxy}
*/
class TestEasyUnlockBrowserProxy extends TestBrowserProxy {
constructor() {
super([
'getEnabledStatus',
'getTurnOffFlowStatus',
'startTurnOffFlow',
'cancelTurnOffFlow',
]);
/** @private {boolean} */
this.isEnabled_ = false;
}
/**
* @param {boolean} easyUnlockEnabled
*/
setEnabledStatus(easyUnlockEnabled) {
this.isEnabled_ = easyUnlockEnabled;
}
/** @override */
getEnabledStatus() {
this.methodCalled('getEnabledStatus');
return Promise.resolve(this.isEnabled_);
}
/** @override */
getTurnOffFlowStatus() {
this.methodCalled('getTurnOffFlowStatus');
return Promise.resolve('idle');
}
/** @override */
startTurnOffFlow() {
this.methodCalled('startTurnOffFlow');
}
/** @override */
cancelTurnOffFlow() {
this.methodCalled('cancelTurnOffFlow');
}
}
/** @type {?SettingsLockScreenElement} */
let lockScreen = null;
/** @type {?TestEasyUnlockBrowserProxy} */
let browserProxy = null;
suite('SettingsEasyUnlock', function() {
suiteSetup(function() {
Polymer.dom.flush();
// These overrides are necessary for this test to function on ChromeOS
// bots that do not have Bluetooth (don't actually support Easy Unlock).
loadTimeData.overrideValues({
easyUnlockAllowed: true,
easyUnlockSectionTitle: '',
easyUnlockLearnMoreURL: '',
easyUnlockSetupIntro: '',
easyUnlockDescription: '',
easyUnlockTurnOffTitle: '',
easyUnlockTurnOffDescription: '',
easyUnlockTurnOffButton: '',
});
});
setup(function() {
browserProxy = new TestEasyUnlockBrowserProxy();
settings.EasyUnlockBrowserProxyImpl.instance_ = browserProxy;
PolymerTest.clearBody();
lockScreen = document.createElement('settings-lock-screen');
});
test('turn off dialog', function() {
browserProxy.setEnabledStatus(true);
document.body.appendChild(lockScreen);
let turnOffDialog = null;
return browserProxy.whenCalled('getEnabledStatus')
.then(function() {
assertTrue(lockScreen.easyUnlockAllowed_);
expectTrue(lockScreen.easyUnlockEnabled_);
Polymer.dom.flush();
const turnOffButton = lockScreen.$$('#easyUnlockTurnOff');
assertTrue(!!turnOffButton);
expectFalse(turnOffButton.hidden);
turnOffButton.click();
return browserProxy.whenCalled('getTurnOffFlowStatus');
})
.then(function() {
Polymer.dom.flush();
turnOffDialog = lockScreen.$$('#easyUnlockTurnOffDialog');
assertTrue(!!turnOffDialog);
// Verify that elements on the turn off dialog are hidden or active
// according to the easy unlock turn off status.
const turnOffDialogButtonContainer =
turnOffDialog.$$('[slot=button-container]');
const turnOffDialogButtonSpinner =
turnOffDialog.$$('paper-spinner-lite');
const turnOffDialogConfirmButton = turnOffDialog.$$('#turnOff');
const turnOffDialogCancelButton =
turnOffDialog.$$('.cancel-button');
assertTrue(!!turnOffDialogButtonContainer);
assertTrue(!!turnOffDialogButtonSpinner);
assertTrue(!!turnOffDialogConfirmButton);
assertTrue(!!turnOffDialogCancelButton);
cr.webUIListenerCallback(
'easy-unlock-turn-off-flow-status', 'offline');
expectTrue(turnOffDialogButtonContainer.hidden);
expectFalse(turnOffDialogButtonSpinner.active);
cr.webUIListenerCallback(
'easy-unlock-turn-off-flow-status', 'pending');
expectFalse(turnOffDialogButtonContainer.hidden);
expectTrue(turnOffDialogButtonSpinner.active);
cr.webUIListenerCallback(
'easy-unlock-turn-off-flow-status', 'server-error');
expectFalse(turnOffDialogButtonContainer.hidden);
expectTrue(turnOffDialogCancelButton.hidden);
cr.webUIListenerCallback(
'easy-unlock-turn-off-flow-status', 'idle');
expectFalse(turnOffDialogConfirmButton.hidden);
turnOffDialogConfirmButton.click();
return browserProxy.whenCalled('startTurnOffFlow');
})
.then(function() {
// To signal successful turnoff, the enabled status is broadcast
// as false. At that point, the dialog should close and cancel
// any in-progress turnoff flow. The cancellation should be
// a no-op assuming the turnoff originated from this tab.
cr.webUIListenerCallback('easy-unlock-enabled-status', false);
return browserProxy.whenCalled('cancelTurnOffFlow');
})
.then(function() {
Polymer.dom.flush();
expectFalse(turnOffDialog.$.dialog.open);
});
});
});
// Run all registered tests.
mocha.run();
});
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