NUX Onboarding: create landing page skeleton.

This CL also adds a helper function to check if the NUX onboarding feature
should be force-enabled on non-win/non-branded builds. This will make
testing and development for the feature much easier. There will be follow-up
CLs to transition all NUX contents to be behind this flag instead of the
build flags.

To test this, add --enable-features=NuxOnboardingForceEnabled

Bug: 874142
Change-Id: I0c1ae6d396901b0a7cbb1c13fe158b488ff0e14c
Reviewed-on: https://chromium-review.googlesource.com/1229502
Reviewed-by: Hector Carmona <[email protected]>
Reviewed-by: Demetrios Papadopoulos <[email protected]>
Commit-Queue: Scott Chen <[email protected]>
Cr-Commit-Position: refs/heads/master@{#593017}
diff --git a/chrome/browser/ui/webui/welcome/nux_helper.cc b/chrome/browser/ui/webui/welcome/nux_helper.cc
new file mode 100644
index 0000000..27e965a
--- /dev/null
+++ b/chrome/browser/ui/webui/welcome/nux_helper.cc
@@ -0,0 +1,33 @@
+// Copyright 2018 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.
+
+#include "chrome/browser/ui/webui/welcome/nux_helper.h"
+#include "base/feature_list.h"
+#include "build/build_config.h"
+
+// TODO(scottchen): remove #if guard once components/nux/ is moved to
+// chrome/browser/ui/webui/welcome/ and included by non-win platforms.
+// Also check if it makes sense to merge nux_helper.* with nux/constants.*.
+#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
+#include "components/nux/constants.h"
+#endif  // defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
+
+namespace nux {
+// This feature flag is used to force the feature to be turned on for non-win
+// and non-branded builds, like with tests or development on other platforms.
+extern const base::Feature kNuxOnboardingForceEnabled{
+    "NuxOnboardingForceEnabled", base::FEATURE_DISABLED_BY_DEFAULT};
+
+bool IsNuxOnboardingEnabled() {
+  if (base::FeatureList::IsEnabled(nux::kNuxOnboardingForceEnabled)) {
+    return true;
+  } else {
+#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
+    return base::FeatureList::IsEnabled(nux::kNuxOnboardingFeature);
+#else
+    return false;
+#endif  // defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
+  }
+}
+}  // namespace nux
diff --git a/chrome/browser/ui/webui/welcome/nux_helper.h b/chrome/browser/ui/webui/welcome/nux_helper.h
new file mode 100644
index 0000000..b27b3373
--- /dev/null
+++ b/chrome/browser/ui/webui/welcome/nux_helper.h
@@ -0,0 +1,14 @@
+// Copyright 2017 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.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_HELPER_H_
+#define CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_HELPER_H_
+
+#include "base/macros.h"
+
+namespace nux {
+bool IsNuxOnboardingEnabled();
+};  // namespace nux
+
+#endif  // CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_HELPER_H_
diff --git a/chrome/browser/ui/webui/welcome_ui.cc b/chrome/browser/ui/webui/welcome_ui.cc
index 5bade86..aa732e7 100644
--- a/chrome/browser/ui/webui/welcome_ui.cc
+++ b/chrome/browser/ui/webui/welcome_ui.cc
@@ -10,6 +10,7 @@
 #include "build/build_config.h"
 #include "chrome/browser/favicon/favicon_service_factory.h"
 #include "chrome/browser/signin/account_consistency_mode_manager.h"
+#include "chrome/browser/ui/webui/welcome/nux_helper.h"
 #include "chrome/browser/ui/webui/welcome_handler.h"
 #include "chrome/common/pref_names.h"
 #include "chrome/grit/browser_resources.h"
@@ -68,9 +69,18 @@
   html_source->AddResourcePath("logo.png", IDR_PRODUCT_LOGO_128);
   html_source->AddResourcePath("logo2x.png", IDR_PRODUCT_LOGO_256);
 
-  // Use special layout if the application is branded and DICE is enabled.
-  // Otherwise use the default layout.
-  if (kIsBranded && is_dice) {
+  if (nux::IsNuxOnboardingEnabled()) {
+    // Add Onboarding welcome strings.
+    html_source->AddLocalizedString("headerText", IDS_WELCOME_HEADER);
+
+    // Add onboarding welcome resources.
+    // TODO(scottchen): More resources to be added here.
+    html_source->SetDefaultResource(
+        IDR_WELCOME_ONBOARDING_WELCOME_WELCOME_HTML);
+
+  } else if (kIsBranded && is_dice) {
+    // Use special layout if the application is branded and DICE is enabled.
+    // Otherwise use the default layout.
     html_source->AddLocalizedString("headerText", IDS_WELCOME_HEADER);
     html_source->AddLocalizedString("secondHeaderText",
                                     IDS_DICE_WELCOME_SECOND_HEADER);