Commit 93810102 authored by Wenzhao Zang's avatar Wenzhao Zang Committed by Commit Bot

Update Welcome App texts based on voice interaction status

The texts of the first step (launcher) of Welcome App should be
customized based on if voice interaction (Assistant) is enabled.

Bug: 750941
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I2d53c2e5c8e6e0d579f1564c7793d27fde96d172
Reviewed-on: https://chromium-review.googlesource.com/595111
Commit-Queue: Wenzhao (Colin) Zang <wzang@chromium.org>
Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491129}
parent c6658284
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<h1 i18n-content="appListHeader"></h1> <h1 i18n-content="appListHeader"></h1>
<p> <p>
<span i18n-content="appListText1"></span><br> <span i18n-content="appListText1"></span><br>
<span i18n-content="appListText2"></span> <span id="voice-interaction-text" i18n-content="appListText2" hidden></span>
</p> </p>
<div class="controls"> <div class="controls">
<button i18n-content="nextButton" <button i18n-content="nextButton"
......
...@@ -222,26 +222,34 @@ cr.define('cr.FirstRun', function() { ...@@ -222,26 +222,34 @@ cr.define('cr.FirstRun', function() {
/** /**
* Shows step with given name in given position. * Shows step with given name in given position.
* @param {string} name Name of step. * @param {Object} stepParams Step params dictionary containing:
* @param {object} position Optional parameter with optional fields |top|, * |name|: Name of the step.
* |right|, |bottom|, |left| used for step positioning. * |position|: Optional parameter with optional fields |top|, |right|,
* @param {Array} pointWithOffset Optional parameter for positioning * |bottom|, |left| used for step positioning.
* bubble. Contains [x, y, offset], where (x, y) - point to which bubble * |pointWithOffset|: Optional parameter for positioning bubble. Contains
* points, offset - distance between arrow and point. * [x, y, offset], where (x, y) - point to which bubble points,
* offset - distance between arrow and point.
* |voiceInteractionEnabled|: Optional boolean value to indicate if voice
* interaction is enabled by the device.
*/ */
showStep: function(name, position, pointWithOffset) { showStep: function(stepParams) {
assert(!this.currentStep_); assert(!this.currentStep_);
if (!this.steps_.hasOwnProperty(name)) if (!this.steps_.hasOwnProperty(stepParams.name))
throw Error('Step "' + name + '" not found.'); throw Error('Step "' + stepParams.name + '" not found.');
var step = this.steps_[name]; var step = this.steps_[stepParams.name];
if (position) if (stepParams.position)
step.setPosition(position); step.setPosition(stepParams.position);
if (pointWithOffset) if (stepParams.pointWithOffset) {
step.setPointsTo(pointWithOffset.slice(0, 2), pointWithOffset[2]); step.setPointsTo(
stepParams.pointWithOffset.slice(0, 2),
stepParams.pointWithOffset[2]);
}
if (stepParams.voiceInteractionEnabled)
step.setVoiceInteractionEnabled();
step.show(true, function(step) { step.show(true, function(step) {
step.focusDefaultControl(); step.focusDefaultControl();
this.currentStep_ = step; this.currentStep_ = step;
chrome.send('stepShown', [name]); chrome.send('stepShown', [stepParams.name]);
}.bind(this)); }.bind(this));
}, },
......
...@@ -95,6 +95,14 @@ cr.define('cr.FirstRun', function() { ...@@ -95,6 +95,14 @@ cr.define('cr.FirstRun', function() {
focusDefaultControl: function() { focusDefaultControl: function() {
this.defaultControl_.focus(); this.defaultControl_.focus();
}, },
/**
* Updates UI when voice interaction is enabled by the device.
*/
setVoiceInteractionEnabled: function() {
if (this.name_ == 'app-list')
$('voice-interaction-text').hidden = false;
},
}; };
var Bubble = cr.ui.define('div'); var Bubble = cr.ui.define('div');
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/values.h" #include "base/values.h"
#include "chromeos/chromeos_switches.h"
#include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui.h"
namespace chromeos { namespace chromeos {
...@@ -43,21 +44,34 @@ void FirstRunHandler::RemoveBackgroundHoles() { ...@@ -43,21 +44,34 @@ void FirstRunHandler::RemoveBackgroundHoles() {
void FirstRunHandler::ShowStepPositioned(const std::string& name, void FirstRunHandler::ShowStepPositioned(const std::string& name,
const StepPosition& position) { const StepPosition& position) {
web_ui()->CallJavascriptFunctionUnsafe( base::DictionaryValue step_params;
"cr.FirstRun.showStep", base::Value(name), *position.AsValue()); step_params.SetString("name", name);
step_params.Set("position",
base::MakeUnique<base::Value>(*position.AsValue()));
step_params.SetList("pointWithOffset", base::MakeUnique<base::ListValue>());
step_params.SetBoolean("voiceInteractionEnabled",
chromeos::switches::IsVoiceInteractionEnabled());
web_ui()->CallJavascriptFunctionUnsafe("cr.FirstRun.showStep", step_params);
} }
void FirstRunHandler::ShowStepPointingTo(const std::string& name, void FirstRunHandler::ShowStepPointingTo(const std::string& name,
int x, int x,
int y, int y,
int offset) { int offset) {
auto null = base::MakeUnique<base::Value>(); base::DictionaryValue step_params;
step_params.SetString("name", name);
step_params.Set("position", base::MakeUnique<base::Value>());
base::ListValue point_with_offset; base::ListValue point_with_offset;
point_with_offset.AppendInteger(x); point_with_offset.AppendInteger(x);
point_with_offset.AppendInteger(y); point_with_offset.AppendInteger(y);
point_with_offset.AppendInteger(offset); point_with_offset.AppendInteger(offset);
web_ui()->CallJavascriptFunctionUnsafe( step_params.SetList("pointWithOffset",
"cr.FirstRun.showStep", base::Value(name), *null, point_with_offset); base::MakeUnique<base::ListValue>(point_with_offset));
step_params.SetBoolean("voiceInteractionEnabled",
chromeos::switches::IsVoiceInteractionEnabled());
web_ui()->CallJavascriptFunctionUnsafe("cr.FirstRun.showStep", step_params);
} }
void FirstRunHandler::HideCurrentStep() { void FirstRunHandler::HideCurrentStep() {
......
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