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

NUX Onboarding: add set-as-default component

Change-Id: I03fef99aaf7b23d9a05a96a46113a913ba7e575a
Reviewed-on: https://chromium-review.googlesource.com/1188760Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarHector Carmona <hcarmona@chromium.org>
Commit-Queue: Scott Chen <scottchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#588749}
parent da27378f
...@@ -3901,6 +3901,7 @@ jumbo_split_static_library("ui") { ...@@ -3901,6 +3901,7 @@ jumbo_split_static_library("ui") {
"//components/nux:constants", "//components/nux:constants",
"//components/nux:email_feature", "//components/nux:email_feature",
"//components/nux:google_apps_feature", "//components/nux:google_apps_feature",
"//components/nux:set_as_default_feature",
] ]
} }
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "components/nux/constants.h" #include "components/nux/constants.h"
#include "components/nux/email/email_handler.h" #include "components/nux/email/email_handler.h"
#include "components/nux/google_apps/google_apps_handler.h" #include "components/nux/google_apps/google_apps_handler.h"
#include "components/nux/set_as_default/set_as_default_handler.h"
#include "components/nux/show_promo_delegate.h" #include "components/nux/show_promo_delegate.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#endif // defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) #endif // defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
...@@ -112,6 +113,14 @@ WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url) ...@@ -112,6 +113,14 @@ WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url)
} }
#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
if (base::FeatureList::IsEnabled(nux::kNuxOnboardingFeature)) {
web_ui->AddMessageHandler(std::make_unique<nux::SetAsDefaultHandler>());
nux::SetAsDefaultHandler::AddSources(html_source);
// TODO(scottchen): move all NUX features under this flag once individual
// experiments launch.
}
if (base::FeatureList::IsEnabled(nux::kNuxEmailFeature)) { if (base::FeatureList::IsEnabled(nux::kNuxEmailFeature)) {
content::BrowserContext* browser_context = content::BrowserContext* browser_context =
web_ui->GetWebContents()->GetBrowserContext(); web_ui->GetWebContents()->GetBrowserContext();
......
...@@ -5,6 +5,27 @@ ...@@ -5,6 +5,27 @@
import("//build/config/chrome_build.gni") import("//build/config/chrome_build.gni")
if (is_win && is_chrome_branded) { if (is_win && is_chrome_branded) {
static_library("set_as_default_feature") {
sources = [
"set_as_default/set_as_default_handler.cc",
"set_as_default/set_as_default_handler.h",
]
public_deps = [
"//base",
"//net",
"//url",
]
deps = [
"//components/resources",
"//components/strings",
"//components/variations",
"//content/public/browser",
"//ui/base",
]
}
source_set("constants") { source_set("constants") {
sources = [ sources = [
"constants.cc", "constants.cc",
......
...@@ -14,6 +14,9 @@ extern const base::Feature kNuxEmailFeature{"NuxEmail", ...@@ -14,6 +14,9 @@ extern const base::Feature kNuxEmailFeature{"NuxEmail",
extern const base::Feature kNuxGoogleAppsFeature{ extern const base::Feature kNuxGoogleAppsFeature{
"NuxGoogleApps", base::FEATURE_DISABLED_BY_DEFAULT}; "NuxGoogleApps", base::FEATURE_DISABLED_BY_DEFAULT};
extern const base::Feature kNuxOnboardingFeature{
"NuxOnboarding", base::FEATURE_DISABLED_BY_DEFAULT};
extern const char kNuxEmailUrl[] = "chrome://welcome/email"; extern const char kNuxEmailUrl[] = "chrome://welcome/email";
extern const char kNuxGoogleAppsUrl[] = "chrome://welcome/apps"; extern const char kNuxGoogleAppsUrl[] = "chrome://welcome/apps";
......
...@@ -13,6 +13,7 @@ namespace nux { ...@@ -13,6 +13,7 @@ namespace nux {
extern const base::Feature kNuxEmailFeature; extern const base::Feature kNuxEmailFeature;
extern const base::Feature kNuxGoogleAppsFeature; extern const base::Feature kNuxGoogleAppsFeature;
extern const base::Feature kNuxOnboardingFeature;
extern const char kNuxEmailUrl[]; extern const char kNuxEmailUrl[];
extern const char kNuxGoogleAppsUrl[]; extern const char kNuxGoogleAppsUrl[];
......
# 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.
import("//third_party/closure_compiler/compile_js.gni")
js_type_check("closure_compile") {
deps = [
":nux_set_as_default",
]
}
js_library("nux_set_as_default") {
deps = [
":nux_set_as_default_proxy",
]
}
js_library("nux_set_as_default_proxy") {
deps = []
}
<!DOCTYPE html>
<html dir="$i18n{textdirection}" lang="$i18n{language}">
<head>
<meta charset="utf-8">
<title>TODO_TITLE</title>
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="nux_set_as_default_proxy.html">
<link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css">
<style>
body {
margin: 0;
}
</style>
<dom-module id="nux-set-as-default">
<template>
<style>
:host {
align-items: center;
display: flex;
height: 100vh;
justify-content: space-around;
}
.container {
text-align: center;
width: 800;
}
</style>
<div class="container">
hi
</div>
</template>
<script src="nux_set_as_default.js"></script>
</dom-module>
</head>
<body>
<nux-set-as-default></nux-set-as-default>
</body>
</html>
\ No newline at end of file
// 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.
Polymer({
is: 'nux-set-as-default',
});
<link rel="import" href="chrome://resources/html/cr.html">
<script src="nux_set_as_default_proxy.js"></script>
\ No newline at end of file
// 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.
cr.define('nux', function() {
/** @interface */
class NuxSetAsDefaultProxy {
}
/** @implements {NuxSetAsDefaultProxy} */
class NuxSetAsDefaultProxyImpl {
}
cr.addSingletonGetter(NuxSetAsDefaultProxyImpl);
return {
NuxSetAsDefaultProxy: NuxSetAsDefaultProxy,
NuxSetAsDefaultProxyImpl: NuxSetAsDefaultProxyImpl,
};
});
\ No newline at end of file
// 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 "components/nux/set_as_default/set_as_default_handler.h"
#include "base/bind.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_macros.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "components/grit/components_resources.h"
#include "components/grit/components_scaled_resources.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "ui/base/resource/resource_bundle.h"
namespace nux {
SetAsDefaultHandler::SetAsDefaultHandler() {}
SetAsDefaultHandler::~SetAsDefaultHandler() {}
void SetAsDefaultHandler::RegisterMessages() {}
void SetAsDefaultHandler::AddSources(content::WebUIDataSource* html_source) {
// Localized strings.
// Add required resources.
html_source->AddResourcePath("nux_set_as_default.html",
IDR_NUX_SET_AS_DEFAULT_HTML);
html_source->AddResourcePath("nux_set_as_default.js",
IDR_NUX_SET_AS_DEFAULT_JS);
html_source->AddResourcePath("nux_set_as_default_proxy.html",
IDR_NUX_SET_AS_DEFAULT_PROXY_HTML);
html_source->AddResourcePath("nux_set_as_default_proxy.js",
IDR_NUX_SET_AS_DEFAULT_PROXY_JS);
// Add icons
}
} // namespace nux
\ No newline at end of file
// 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.
#ifndef COMPONENTS_NUX_SET_AS_DEFAULT_SET_AS_DEFAULT_HANDLER_H_
#define COMPONENTS_NUX_SET_AS_DEFAULT_SET_AS_DEFAULT_HANDLER_H_
#include "base/macros.h"
#include "base/values.h"
#include "content/public/browser/web_ui_message_handler.h"
namespace content {
class WebUIDataSource;
} // namespace content
namespace nux {
class SetAsDefaultHandler : public content::WebUIMessageHandler {
public:
SetAsDefaultHandler();
~SetAsDefaultHandler() override;
// WebUIMessageHandler:
void RegisterMessages() override;
// Adds webui sources.
static void AddSources(content::WebUIDataSource* html_source);
DISALLOW_COPY_AND_ASSIGN(SetAsDefaultHandler);
};
} // namespace nux
#endif // COMPONENTS_NUX_SET_AS_DEFAULT_SET_AS_DEFAULT_HANDLER_H_
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
<if expr="is_win"> <if expr="is_win">
<part file="nux_email.grdp" /> <part file="nux_email.grdp" />
<part file="nux_google_apps.grdp" /> <part file="nux_google_apps.grdp" />
<part file="nux_set_as_default.grdp" />
</if> </if>
<part file="offline_pages_resources.grdp" /> <part file="offline_pages_resources.grdp" />
<part file="password_manager_internals_resources.grdp" /> <part file="password_manager_internals_resources.grdp" />
......
<?xml version="1.0" encoding="utf-8"?>
<grit-part>
<include name="IDR_NUX_SET_AS_DEFAULT_HTML" file="../nux/set_as_default/resources/nux_set_as_default.html" type="BINDATA" />
<include name="IDR_NUX_SET_AS_DEFAULT_JS" file="../nux/set_as_default/resources/nux_set_as_default.js" type="BINDATA" />
<include name="IDR_NUX_SET_AS_DEFAULT_PROXY_HTML" file="../nux/set_as_default/resources/nux_set_as_default_proxy.html" type="BINDATA" />
<include name="IDR_NUX_SET_AS_DEFAULT_PROXY_JS" file="../nux/set_as_default/resources/nux_set_as_default_proxy.js" type="BINDATA" />
</grit-part>
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