Commit 00858246 authored by Scott Chen's avatar Scott Chen Committed by Commit Bot

Nux Onboarding: get hard-coded module list from feature params instead.

In this CL, four FeatureParams were added.

These 2 are added for "os_win && google_chrome_build" when
kNuxOnboardingFeature is enabled:

kNuxOnboardingNewUserModules
kNuxOnboardingReturningUserModules

And 2 more are added for when the feature is force-enabled with
kNuxOnboardingForceEnabled on other platforms/non-branded build:

kNuxOnboardingForceEnabledNewUserModules
kNuxOnboardingForceEnabledReturningUserModules

Sample command line to test the changes:

./out/gn/chrome --user-data-dir=/tmp/debug_chrome_1 \
    --enable-features="NuxOnboardingForceEnabled<study" \
    --force-fieldtrials=study/g1 \
    --force-fieldtrial-params=study.g1:new-user-modules/nux-google-apps/returning-user-modules/nux-email

TBR=mpearson@chromium.org

Bug: 874153
Change-Id: I495e6492ee66ce20ec8bfad8743d20c9c55acf53
Reviewed-on: https://chromium-review.googlesource.com/c/1311659
Commit-Queue: Scott Chen <scottchen@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarHector Carmona <hcarmona@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604748}
parent 7ee7bac4
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<link rel="import" href="navigation_behavior.html"> <link rel="import" href="navigation_behavior.html">
<link rel="import" href="set_as_default/nux_set_as_default.html"> <link rel="import" href="set_as_default/nux_set_as_default.html">
<link rel="import" href="set_as_default/nux_set_as_default_proxy.html"> <link rel="import" href="set_as_default/nux_set_as_default_proxy.html">
<link rel="import" href="shared/i18n_setup.html">
<link rel="import" href="signin_view.html"> <link rel="import" href="signin_view.html">
<dom-module id="welcome-app"> <dom-module id="welcome-app">
......
...@@ -11,10 +11,21 @@ ...@@ -11,10 +11,21 @@
*/ */
let NuxOnboardingModules; let NuxOnboardingModules;
// This list needs to be updated if new modules that need step-indicators are /**
// added. * This list needs to be updated if new modules need to be supported in the
const MODELS_NEEDING_INDICATOR = * onboarding flow.
['nux-email', 'nux-google-apps', 'nux-set-as-default']; * @const {!Set<string>}
*/
const MODULES_WHITELIST = new Set(
['nux-email', 'nux-google-apps', 'nux-set-as-default', 'signin-view']);
/**
* This list needs to be updated if new modules that need step-indicators are
* added.
* @const {!Set<string>}
*/
const MODULES_NEEDING_INDICATOR =
new Set(['nux-email', 'nux-google-apps', 'nux-set-as-default']);
Polymer({ Polymer({
is: 'welcome-app', is: 'welcome-app',
...@@ -27,12 +38,11 @@ Polymer({ ...@@ -27,12 +38,11 @@ Polymer({
/** @private {!PromiseResolver} */ /** @private {!PromiseResolver} */
defaultCheckPromise_: new PromiseResolver(), defaultCheckPromise_: new PromiseResolver(),
// TODO(scottchen): instead of dummy, get data from finch/load time data.
/** @private {NuxOnboardingModules} */ /** @private {NuxOnboardingModules} */
modules_: { modules_: {
'new-user': 'new-user': loadTimeData.getString('new_user_modules').split(','),
['nux-email', 'nux-google-apps', 'nux-set-as-default', 'signin-view'], 'returning-user':
'returning-user': ['nux-set-as-default'], loadTimeData.getString('returning_user_modules').split(','),
}, },
properties: { properties: {
...@@ -113,20 +123,22 @@ Polymer({ ...@@ -113,20 +123,22 @@ Polymer({
element.remove(); element.remove();
}); });
let indicatorElementCount = 0; const indicatorElementCount = modules.reduce((count, module) => {
for (let i = 0; i < modules.length; i++) { return count += MODULES_NEEDING_INDICATOR.has(module) ? 1 : 0;
if (MODELS_NEEDING_INDICATOR.includes(modules[i])) }, 0);
indicatorElementCount++;
}
let indicatorActiveCount = 0; let indicatorActiveCount = 0;
modules.forEach((elementTagName, index) => { modules.forEach((elementTagName, index) => {
// Makes sure the module specified by the feature configuration is
// whitelisted.
assert(MODULES_WHITELIST.has(elementTagName));
const element = document.createElement(elementTagName); const element = document.createElement(elementTagName);
element.id = 'step-' + (index + 1); element.id = 'step-' + (index + 1);
element.setAttribute('slot', 'view'); element.setAttribute('slot', 'view');
this.$.viewManager.appendChild(element); this.$.viewManager.appendChild(element);
if (MODELS_NEEDING_INDICATOR.includes(elementTagName)) { if (MODULES_NEEDING_INDICATOR.has(elementTagName)) {
element.indicatorModel = { element.indicatorModel = {
total: indicatorElementCount, total: indicatorElementCount,
active: indicatorActiveCount++, active: indicatorActiveCount++,
......
...@@ -8,16 +8,16 @@ ...@@ -8,16 +8,16 @@
namespace nux { namespace nux {
extern const base::Feature kNuxEmailFeature{"NuxEmail", const base::Feature kNuxOnboardingFeature{"NuxOnboarding",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
extern const base::Feature kNuxGoogleAppsFeature{ // The value of these FeatureParam values should be a comma-delimited list
"NuxGoogleApps", base::FEATURE_DISABLED_BY_DEFAULT}; // of element names whitelisted in the MODULES_WHITELIST list, defined in
// chrome/browser/resources/welcome/onboarding_welcome/welcome_app.js
extern const base::Feature kNuxOnboardingFeature{ const base::FeatureParam<std::string> kNuxOnboardingNewUserModules{
"NuxOnboarding", base::FEATURE_DISABLED_BY_DEFAULT}; &kNuxOnboardingFeature, "new-user-modules",
"nux-email,nux-google-apps,nux-set-as-default,signin-view"};
extern const char kNuxEmailUrl[] = "chrome://welcome/email"; const base::FeatureParam<std::string> kNuxOnboardingReturningUserModules{
extern const char kNuxGoogleAppsUrl[] = "chrome://welcome/apps"; &kNuxOnboardingFeature, "returning-user-modules", "nux-set-as-default"};
} // namespace nux } // namespace nux
\ No newline at end of file
...@@ -5,17 +5,19 @@ ...@@ -5,17 +5,19 @@
#ifndef CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_CONSTANTS_H_ #ifndef CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_CONSTANTS_H_
#define CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_CONSTANTS_H_ #define CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_CONSTANTS_H_
#include <string>
#include "base/metrics/field_trial_params.h"
namespace base { namespace base {
struct Feature; struct Feature;
} // namespace base } // namespace base
namespace nux { namespace nux {
extern const base::Feature kNuxEmailFeature;
extern const base::Feature kNuxGoogleAppsFeature;
extern const base::Feature kNuxOnboardingFeature; extern const base::Feature kNuxOnboardingFeature;
extern const char kNuxEmailUrl[];
extern const char kNuxGoogleAppsUrl[]; extern const base::FeatureParam<std::string> kNuxOnboardingNewUserModules;
extern const base::FeatureParam<std::string> kNuxOnboardingReturningUserModules;
} // namespace nux } // namespace nux
......
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/ui/webui/welcome/nux_helper.h" #include "chrome/browser/ui/webui/welcome/nux_helper.h"
#include "base/feature_list.h"
#include "base/values.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/welcome/nux/constants.h" #include "chrome/browser/ui/webui/welcome/nux/constants.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
...@@ -14,6 +17,17 @@ namespace nux { ...@@ -14,6 +17,17 @@ namespace nux {
const base::Feature kNuxOnboardingForceEnabled = { const base::Feature kNuxOnboardingForceEnabled = {
"NuxOnboardingForceEnabled", base::FEATURE_DISABLED_BY_DEFAULT}; "NuxOnboardingForceEnabled", base::FEATURE_DISABLED_BY_DEFAULT};
// The value of these FeatureParam values should be a comma-delimited list
// of element names whitelisted in the MODULES_WHITELIST list, defined in
// chrome/browser/resources/welcome/onboarding_welcome/welcome_app.js
const base::FeatureParam<std::string> kNuxOnboardingForceEnabledNewUserModules =
{&kNuxOnboardingForceEnabled, "new-user-modules",
"nux-email,nux-google-apps,nux-set-as-default,signin-view"};
const base::FeatureParam<std::string>
kNuxOnboardingForceEnabledReturningUserModules = {
&kNuxOnboardingForceEnabled, "returning-user-modules",
"nux-set-as-default"};
bool IsNuxOnboardingEnabled(Profile* profile) { bool IsNuxOnboardingEnabled(Profile* profile) {
if (base::FeatureList::IsEnabled(nux::kNuxOnboardingForceEnabled)) { if (base::FeatureList::IsEnabled(nux::kNuxOnboardingForceEnabled)) {
return true; return true;
...@@ -33,4 +47,24 @@ bool IsNuxOnboardingEnabled(Profile* profile) { ...@@ -33,4 +47,24 @@ bool IsNuxOnboardingEnabled(Profile* profile) {
#endif // defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) #endif // defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
} }
} }
base::DictionaryValue GetNuxOnboardingModules(Profile* profile) {
// This function should not be called when nux onboarding feature is not on.
DCHECK(nux::IsNuxOnboardingEnabled(profile));
base::DictionaryValue modules;
if (base::FeatureList::IsEnabled(nux::kNuxOnboardingForceEnabled)) {
modules.SetString("new-user",
kNuxOnboardingForceEnabledNewUserModules.Get());
modules.SetString("returning-user",
kNuxOnboardingForceEnabledReturningUserModules.Get());
} else { // This means nux::kNuxOnboardingFeature is enabled.
modules.SetString("new-user", kNuxOnboardingNewUserModules.Get());
modules.SetString("returning-user",
kNuxOnboardingReturningUserModules.Get());
}
return modules;
}
} // namespace nux } // namespace nux
...@@ -5,16 +5,27 @@ ...@@ -5,16 +5,27 @@
#ifndef CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_HELPER_H_ #ifndef CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_HELPER_H_
#define CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_HELPER_H_ #define CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_HELPER_H_
#include "base/feature_list.h"
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/profiles/profile.h" #include "base/metrics/field_trial_params.h"
namespace base {
class DictionaryValue;
struct Feature;
} // namespace base
class Profile; class Profile;
namespace nux { namespace nux {
extern const base::Feature kNuxOnboardingForceEnabled; extern const base::Feature kNuxOnboardingForceEnabled;
extern const base::FeatureParam<std::string>
kNuxOnboardingForceEnabledNewUserModules;
extern const base::FeatureParam<std::string>
kNuxOnboardingForceEnabledReturningUserModules;
bool IsNuxOnboardingEnabled(Profile* profile); bool IsNuxOnboardingEnabled(Profile* profile);
base::DictionaryValue GetNuxOnboardingModules(Profile* profile);
} // namespace nux } // namespace nux
#endif // CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_HELPER_H_ #endif // CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_HELPER_H_
...@@ -206,6 +206,14 @@ WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url) ...@@ -206,6 +206,14 @@ WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url)
// Add set-as-default onboarding module. // Add set-as-default onboarding module.
web_ui->AddMessageHandler(std::make_unique<nux::SetAsDefaultHandler>()); web_ui->AddMessageHandler(std::make_unique<nux::SetAsDefaultHandler>());
html_source->AddString(
"new_user_modules",
nux::GetNuxOnboardingModules(profile).FindKey("new-user")->GetString());
html_source->AddString("returning_user_modules",
nux::GetNuxOnboardingModules(profile)
.FindKey("returning-user")
->GetString());
} else if (kIsBranded && is_dice) { } else if (kIsBranded && is_dice) {
// Use special layout if the application is branded and DICE is enabled. // Use special layout if the application is branded and DICE is enabled.
html_source->AddLocalizedString("headerText", IDS_WELCOME_HEADER); html_source->AddLocalizedString("headerText", IDS_WELCOME_HEADER);
......
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