Commit ebfb9282 authored by tommycli's avatar tommycli Committed by Commit bot

Settings People Revamp: Easy Unlock: Add browser proxy and setup flow.

Adds a browser proxy object and implements the setup flow. Tests in a
separate CL.

BUG=563721

Review URL: https://codereview.chromium.org/1806123002

Cr-Commit-Position: refs/heads/master@{#381845}
parent de9c87d3
...@@ -32,6 +32,13 @@ ...@@ -32,6 +32,13 @@
], ],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
}, },
{
'target_name': 'easy_unlock_browser_proxy',
'dependencies': [
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
},
{ {
'target_name': 'people_page', 'target_name': 'people_page',
'dependencies': [ 'dependencies': [
...@@ -40,6 +47,7 @@ ...@@ -40,6 +47,7 @@
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
'../settings_page/compiled_resources2.gyp:settings_animated_pages', '../settings_page/compiled_resources2.gyp:settings_animated_pages',
'easy_unlock_browser_proxy',
'sync_private_api', 'sync_private_api',
], ],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
......
<script src="chrome://md-settings/people_page/easy_unlock_browser_proxy.js"></script>
// 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 helper object used from the the People section to interact
* with the Easy Unlock functionality of the browser. ChromeOS only.
*/
cr.exportPath('settings');
cr.define('settings', function() {
/** @interface */
function EasyUnlockBrowserProxy() {}
EasyUnlockBrowserProxy.prototype = {
/**
* Returns a true promise if Easy Unlock is already enabled on the device.
* @return {!Promise<boolean>}
*/
getEnabledStatus: function() {},
/**
* Starts the Easy Unlock setup flow.
*/
launchSetup: function() {}
};
/**
* @constructor
* @implements {EasyUnlockBrowserProxy}
*/
function EasyUnlockBrowserProxyImpl() {}
// The singleton instance_ is replaced with a test version of this wrapper
// during testing.
cr.addSingletonGetter(EasyUnlockBrowserProxyImpl);
EasyUnlockBrowserProxyImpl.prototype = {
/** @override */
getEnabledStatus: function() {
return cr.sendWithPromise('easyUnlockGetEnabledStatus');
},
/** @override */
launchSetup: function() {
chrome.send('easyUnlockLaunchSetup');
},
};
return {
EasyUnlockBrowserProxyImpl: EasyUnlockBrowserProxyImpl,
};
});
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
<if expr="chromeos"> <if expr="chromeos">
<link rel="import" href="chrome://md-settings/people_page/change_picture.html"> <link rel="import" href="chrome://md-settings/people_page/change_picture.html">
<link rel="import" href="chrome://md-settings/people_page/easy_unlock_browser_proxy.html">
<link rel="import" href="chrome://md-settings/people_page/users_page.html"> <link rel="import" href="chrome://md-settings/people_page/users_page.html">
</if> </if>
<if expr="not chromeos"> <if expr="not chromeos">
...@@ -103,14 +104,15 @@ ...@@ -103,14 +104,15 @@
</div> </div>
</div> </div>
<div class="secondary-action"> <div class="secondary-action">
<!-- TODO(tommycli): Hook up these buttons to actions. -->
<template is="dom-if" if=[[!easyUnlockEnabled_]]> <template is="dom-if" if=[[!easyUnlockEnabled_]]>
<paper-button class="secondary-button"> <paper-button class="secondary-button"
on-tap="onEasyUnlockSetupTap_">
[[i18n('easyUnlockSetupButton')]] [[i18n('easyUnlockSetupButton')]]
</paper-button> </paper-button>
</template> </template>
<template is="dom-if" if=[[easyUnlockEnabled_]]> <template is="dom-if" if=[[easyUnlockEnabled_]]>
<paper-button class="secondary-button"> <paper-button class="secondary-button"
on-tap="onEasyUnlockTurnOffTap_">
[[i18n('easyUnlockTurnOffButton')]] [[i18n('easyUnlockTurnOffButton')]]
</paper-button> </paper-button>
</template> </template>
......
...@@ -57,6 +57,14 @@ Polymer({ ...@@ -57,6 +57,14 @@ Polymer({
profileName_: String, profileName_: String,
<if expr="chromeos"> <if expr="chromeos">
/** @private {!settings.EasyUnlockBrowserProxyImpl} */
browserProxy_: {
type: Object,
value: function() {
return settings.EasyUnlockBrowserProxyImpl.getInstance();
},
},
/** /**
* True if Easy Unlock is allowed on this machine. * True if Easy Unlock is allowed on this machine.
* @private {boolean} * @private {boolean}
...@@ -93,6 +101,8 @@ Polymer({ ...@@ -93,6 +101,8 @@ Polymer({
this.addWebUIListener( this.addWebUIListener(
'easy-unlock-enabled-status', 'easy-unlock-enabled-status',
this.handleEasyUnlockEnabledStatusChanged_.bind(this)); this.handleEasyUnlockEnabledStatusChanged_.bind(this));
this.browserProxy_.getEnabledStatus().then(
this.handleEasyUnlockEnabledStatusChanged_.bind(this));
} }
</if> </if>
}, },
...@@ -175,6 +185,18 @@ Polymer({ ...@@ -175,6 +185,18 @@ Polymer({
this.$.pages.setSubpageChain(['sync']); this.$.pages.setSubpageChain(['sync']);
}, },
<if expr="chromeos">
/** @private */
onEasyUnlockSetupTap_: function() {
this.browserProxy_.launchSetup();
},
/** @private */
onEasyUnlockTurnOffTap_: function() {
// TODO(tommycli): Implement Easy Unlock turn off functionality.
},
</if>
/** @private */ /** @private */
onManageOtherPeople_: function() { onManageOtherPeople_: function() {
<if expr="not chromeos"> <if expr="not chromeos">
......
...@@ -825,11 +825,17 @@ ...@@ -825,11 +825,17 @@
type="chrome_html" /> type="chrome_html" />
<structure name="IDR_SETTINGS_PEOPLE_CHANGE_PICTURE_BROWSER_PROXY_JS" <structure name="IDR_SETTINGS_PEOPLE_CHANGE_PICTURE_BROWSER_PROXY_JS"
file="people_page/change_picture_browser_proxy.js" file="people_page/change_picture_browser_proxy.js"
type="chrome_html" />
<structure name="IDR_SETTINGS_PEOPLE_CHANGE_PICTURE_BROWSER_PROXY_HTML"
file="people_page/change_picture_browser_proxy.html"
type="chrome_html" type="chrome_html"
flattenhtml="true" flattenhtml="true"
allowexternalscript="true" /> allowexternalscript="true" />
<structure name="IDR_SETTINGS_PEOPLE_CHANGE_PICTURE_BROWSER_PROXY_HTML" <structure name="IDR_SETTINGS_PEOPLE_EASY_UNLOCK_BROWSER_PROXY_JS"
file="people_page/change_picture_browser_proxy.html" file="people_page/easy_unlock_browser_proxy.js"
type="chrome_html" />
<structure name="IDR_SETTINGS_PEOPLE_EASY_UNLOCK_BROWSER_PROXY_HTML"
file="people_page/easy_unlock_browser_proxy.html"
type="chrome_html" type="chrome_html"
flattenhtml="true" flattenhtml="true"
allowexternalscript="true" /> allowexternalscript="true" />
......
...@@ -55,6 +55,10 @@ void EasyUnlockSettingsHandler::RegisterMessages() { ...@@ -55,6 +55,10 @@ void EasyUnlockSettingsHandler::RegisterMessages() {
"easyUnlockGetEnabledStatus", "easyUnlockGetEnabledStatus",
base::Bind(&EasyUnlockSettingsHandler::HandleGetEnabledStatus, base::Bind(&EasyUnlockSettingsHandler::HandleGetEnabledStatus,
base::Unretained(this))); base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"easyUnlockLaunchSetup",
base::Bind(&EasyUnlockSettingsHandler::HandleLaunchSetup,
base::Unretained(this)));
web_ui()->RegisterMessageCallback( web_ui()->RegisterMessageCallback(
"easyUnlockGetTurnOffFlowStatus", "easyUnlockGetTurnOffFlowStatus",
base::Bind(&EasyUnlockSettingsHandler::HandleGetTurnOffFlowStatus, base::Bind(&EasyUnlockSettingsHandler::HandleGetTurnOffFlowStatus,
...@@ -144,6 +148,11 @@ void EasyUnlockSettingsHandler::HandleGetEnabledStatus( ...@@ -144,6 +148,11 @@ void EasyUnlockSettingsHandler::HandleGetEnabledStatus(
base::FundamentalValue(EasyUnlockService::Get(profile_)->IsEnabled())); base::FundamentalValue(EasyUnlockService::Get(profile_)->IsEnabled()));
} }
void EasyUnlockSettingsHandler::HandleLaunchSetup(
const base::ListValue* args) {
EasyUnlockService::Get(profile_)->LaunchSetup();
}
void EasyUnlockSettingsHandler::HandleGetTurnOffFlowStatus( void EasyUnlockSettingsHandler::HandleGetTurnOffFlowStatus(
const base::ListValue* args) { const base::ListValue* args) {
SendTurnOffOperationStatus(); SendTurnOffOperationStatus();
......
...@@ -48,6 +48,7 @@ class EasyUnlockSettingsHandler : public ::settings::SettingsPageUIHandler, ...@@ -48,6 +48,7 @@ class EasyUnlockSettingsHandler : public ::settings::SettingsPageUIHandler,
// JS callbacks. // JS callbacks.
void HandleGetEnabledStatus(const base::ListValue* args); void HandleGetEnabledStatus(const base::ListValue* args);
void HandleLaunchSetup(const base::ListValue* args);
void HandleGetTurnOffFlowStatus(const base::ListValue* args); void HandleGetTurnOffFlowStatus(const base::ListValue* args);
void HandleRequestTurnOff(const base::ListValue* args); void HandleRequestTurnOff(const base::ListValue* args);
void HandlePageDismissed(const base::ListValue* args); void HandlePageDismissed(const base::ListValue* args);
......
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