Skip to content

Commit

Permalink
Add interface for Supervision Onboarding flow.
Browse files Browse the repository at this point in the history
This flow is triggered at the end of the OOBE/Login for supervised
accounts. It will show a series of pages that will be fetched from
families.google.com and displayed in a webview.

This flow will be triggered from a custom WebUI in the future, so we
also add a common mojo interface that can be used in both WebUIs.

For more context about this flow, see the documents linked in the bug.

Added as reviewers:
- sky@ for chrome/app/BUILD.gn
- alemate@ for chromeos/login
- stevenjb@ for chromeos/supervision
- kerrnel for mojom and chrome/app/*_manifest.cc

Bug: 958995
Change-Id: I8dc11d6a1d9c645cbaaeac18013d81f73f9add31
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1599924
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Greg Kerr <kerrnel@chromium.org>
Reviewed-by: Alexander Alekseev <alemate@chromium.org>
Reviewed-by: Steven Bennetts <stevenjb@chromium.org>
Commit-Queue: Lucas Tenório <ltenorio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#658354}
  • Loading branch information
Lucas Tenório authored and Commit Bot committed May 10, 2019
1 parent cd54ad1 commit ffa543e
Show file tree
Hide file tree
Showing 21 changed files with 272 additions and 8 deletions.
1 change: 1 addition & 0 deletions chrome/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ source_set("chrome_content_browser_overlay_manifest") {
if (is_chromeos) {
deps += [
"//chrome/browser/chromeos/kiosk_next_home/mojom",
"//chrome/browser/chromeos/supervision/mojom",
"//chromeos/assistant:buildflags",
"//chromeos/services/cellular_setup/public/mojom",
"//chromeos/services/device_sync/public/cpp:manifest",
Expand Down
2 changes: 2 additions & 0 deletions chrome/app/chrome_content_browser_overlay_manifest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/kiosk_next_home/mojom/kiosk_next_home_interface_broker.mojom.h" // nogncheck
#include "chrome/browser/chromeos/supervision/mojom/onboarding_controller.mojom.h"
#include "chromeos/assistant/buildflags.h" // nogncheck
#include "chromeos/services/cellular_setup/public/mojom/cellular_setup.mojom.h"
#include "chromeos/services/device_sync/public/cpp/manifest.h"
Expand Down Expand Up @@ -225,6 +226,7 @@ const service_manager::Manifest& GetChromeContentBrowserOverlayManifest() {
chromeos::kiosk_next_home::mojom::
KioskNextHomeInterfaceBroker,
chromeos::media_perception::mojom::MediaPerception,
chromeos::supervision::mojom::OnboardingController,
cros::mojom::CrosImageCapture,
#endif
contextual_search::mojom::ContextualSearchJsApiService,
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -5121,6 +5121,10 @@ grit("resources") {
]
}

if (is_chromeos) {
deps += [ "//chrome/browser/chromeos/supervision/mojom:mojom_js" ]
}

if (is_android) {
deps += [
"//chrome/browser/ui/webui/explore_sites_internals:mojo_bindings_js",
Expand Down
14 changes: 14 additions & 0 deletions chrome/browser/browser_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,20 @@
<include name="IDR_HANGOUT_SERVICES_MANIFEST" file="resources\hangout_services\manifest.json" type="BINDATA" />
</if>

<!-- Chrome OS Supervised users. -->
<if expr="chromeos">
<include name="IDR_SUPERVISION_ONBOARDING_CONTROLLER_MOJOM_HTML"
file="${root_gen_dir}/chrome/browser/chromeos/supervision/mojom/onboarding_controller.mojom.html"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
<include name="IDR_SUPERVISION_ONBOARDING_CONTROLLER_MOJOM_LITE_JS"
file="${root_gen_dir}/chrome/browser/chromeos/supervision/mojom/onboarding_controller.mojom-lite.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
</if>

<!-- App Management. -->
<if expr="not is_android">
<include name="IDR_APP_MANAGEMENT_BITMAP_MOJO_LITE_JS" file="${root_gen_dir}\skia\public\interfaces\bitmap.mojom-lite.js" use_base_dir="false" type="BINDATA" />
Expand Down
3 changes: 3 additions & 0 deletions chrome/browser/chromeos/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ source_set("chromeos") {
"//chrome/browser/apps/platform_apps/api",
"//chrome/browser/chromeos/kiosk_next_home/mojom",
"//chrome/browser/chromeos/power/ml/smart_dim",
"//chrome/browser/chromeos/supervision/mojom",
"//chrome/browser/devtools",
"//chrome/browser/extensions",
"//chrome/browser/resource_coordinator:tab_metrics_event_proto",
Expand Down Expand Up @@ -1932,6 +1933,8 @@ source_set("chromeos") {
"smb_client/temp_file_manager.h",
"startup_settings_cache.cc",
"startup_settings_cache.h",
"supervision/onboarding_controller_impl.cc",
"supervision/onboarding_controller_impl.h",
"system/automatic_reboot_manager.cc",
"system/automatic_reboot_manager.h",
"system/automatic_reboot_manager_observer.h",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <memory>

#include "base/bind.h"
#include "base/command_line.h"
#include "base/run_loop.h"
#include "base/strings/string_piece.h"
#include "base/test/scoped_feature_list.h"
Expand All @@ -23,12 +24,15 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/webui/chromeos/login/supervision_onboarding_screen_handler.h"
#include "chromeos/constants/chromeos_features.h"
#include "chromeos/constants/chromeos_switches.h"

namespace chromeos {

namespace {

constexpr char kTestUser[] = "test-user1@gmail.com";
constexpr char kTestOnboardingPageUrl[] =
"https://families.google.com/families";

chromeos::OobeUI* GetOobeUI() {
auto* host = chromeos::LoginDisplayHost::default_host();
Expand All @@ -43,6 +47,10 @@ class SupervisionOnboardingTest : public MixinBasedInProcessBrowserTest {
~SupervisionOnboardingTest() override = default;

void SetUpOnMainThread() override {
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
chromeos::switches::kSupervisionOnboardingStartPageUrl,
kTestOnboardingPageUrl);

login_manager_.LoginAndWaitForActiveSession(
LoginManagerMixin::CreateDefaultUserContext(test_user_));

Expand Down
5 changes: 5 additions & 0 deletions chrome/browser/chromeos/supervision/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
agawronska@chromium.org
brunoad@chromium.org
hgrandinetti@chromium.org
ltenorio@chromium.org
michaelpg@chromium.org
11 changes: 11 additions & 0 deletions chrome/browser/chromeos/supervision/mojom/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2019 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("//mojo/public/tools/bindings/mojom.gni")

mojom("mojom") {
sources = [
"onboarding_controller.mojom",
]
}
2 changes: 2 additions & 0 deletions chrome/browser/chromeos/supervision/mojom/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2019 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.

module chromeos.supervision.mojom;

// Represents user actions that the OnboardingController can handle.
enum OnboardingFlowAction {
// The user has expressed intent to skip the remaining screens of the flow.
// When receiving this we will most likely perform cleanup functions and
// order the WebviewHost to exit the flow.
kSkipFlow,

// The user wants to go back/forward in the flow.
kShowNextPage,
kShowPreviousPage,
};


// Represents a webview host, responsible for displaying supervision
// onboarding pages. This will usually be a WebUI page that contains a
// webview tag and manages its properties.
// TODO(958995): Complete this interface.
interface OnboardingWebviewHost {
// Requests that the webview load the page with the given url.
LoadPage(string url);

// Requests that the host exit the flow immediately. This might mean
// different things depending on the type of host. If we are running in the
// OOBE we will exit the supervision screen and move the the next OOBE step,
// if we are running in a custom WebUI, we should close it.
ExitFlow();
};

// Interface responsible for managing the whole onboarding flow.
// TODO(958995): Complete this interface.
interface OnboardingController {
// Binds the given webview host to this controller. The host will start
// receiving commands as soon as this is called.
BindWebviewHost(OnboardingWebviewHost webview_host);

// Requests the controller to handle the given action.
// The controller will decide the next step to continue/end the flow.
HandleAction(OnboardingFlowAction action);
};
51 changes: 51 additions & 0 deletions chrome/browser/chromeos/supervision/onboarding_controller_impl.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2019 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/chromeos/supervision/onboarding_controller_impl.h"

#include "base/command_line.h"
#include "base/logging.h"
#include "chromeos/constants/chromeos_switches.h"

namespace chromeos {
namespace supervision {

OnboardingControllerImpl::OnboardingControllerImpl() = default;
OnboardingControllerImpl::~OnboardingControllerImpl() = default;

void OnboardingControllerImpl::BindRequest(
mojom::OnboardingControllerRequest request) {
bindings_.AddBinding(this, std::move(request));
}

void OnboardingControllerImpl::BindWebviewHost(
mojom::OnboardingWebviewHostPtr webview_host) {
webview_host_ = std::move(webview_host);

std::string start_page_url =
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
chromeos::switches::kSupervisionOnboardingStartPageUrl);
if (start_page_url.empty()) {
webview_host_->ExitFlow();
return;
}

webview_host_->LoadPage(start_page_url);
}

void OnboardingControllerImpl::HandleAction(
mojom::OnboardingFlowAction action) {
DCHECK(webview_host_);
switch (action) {
// TODO(958985): Implement the full flow state machine.
case mojom::OnboardingFlowAction::kSkipFlow:
case mojom::OnboardingFlowAction::kShowNextPage:
case mojom::OnboardingFlowAction::kShowPreviousPage:
webview_host_->ExitFlow();
return;
}
}

} // namespace supervision
} // namespace chromeos
39 changes: 39 additions & 0 deletions chrome/browser/chromeos/supervision/onboarding_controller_impl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2019 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_CHROMEOS_SUPERVISION_ONBOARDING_CONTROLLER_IMPL_H_
#define CHROME_BROWSER_CHROMEOS_SUPERVISION_ONBOARDING_CONTROLLER_IMPL_H_

#include <string>
#include <vector>

#include "base/macros.h"
#include "chrome/browser/chromeos/supervision/mojom/onboarding_controller.mojom.h"
#include "mojo/public/cpp/bindings/binding_set.h"

namespace chromeos {
namespace supervision {

class OnboardingControllerImpl : public mojom::OnboardingController {
public:
OnboardingControllerImpl();
~OnboardingControllerImpl() override;

void BindRequest(mojom::OnboardingControllerRequest request);

private:
// mojom::OnboardingController:
void BindWebviewHost(mojom::OnboardingWebviewHostPtr webview_host) override;
void HandleAction(mojom::OnboardingFlowAction action) override;

mojom::OnboardingWebviewHostPtr webview_host_;
mojo::BindingSet<mojom::OnboardingController> bindings_;

DISALLOW_COPY_AND_ASSIGN(OnboardingControllerImpl);
};

} // namespace supervision
} // namespace chromeos

#endif // CHROME_BROWSER_CHROMEOS_SUPERVISION_ONBOARDING_CONTROLLER_IMPL_H_
8 changes: 8 additions & 0 deletions chrome/browser/resources/chromeos/login/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ js_type_check("closure_compile") {
":recommend_apps",
":saml_confirm_password",
":saml_interstitial",
":supervision_onboarding",
":sync_consent",
":throbber_notice",
":update_required_card",
Expand Down Expand Up @@ -145,6 +146,13 @@ js_library("multidevice_setup_first_run") {
]
}

js_library("supervision_onboarding") {
deps = [
"//chrome/browser/chromeos/supervision/mojom:mojom_js_library_for_compile",
"//ui/webui/resources/js:cr",
]
}

js_library("active_directory_password_change") {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<link rel="import" href="chrome://resources/html/polymer.html">

<link rel="import" href="chrome://oobe/custom_elements.html">
<link rel="import" href="chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.html">
<link rel="import" href="chrome://oobe/supervision_onboarding_controller.mojom.html">

<!--
UI for the Supervision Onboarding flow that's displayed for the first login
Expand All @@ -13,10 +15,7 @@
<template>
<link rel="stylesheet" href="oobe_flex_layout.css">
<oobe-dialog id="supervision-onboarding-dialog" has-buttons>
<iron-icon src="chrome://oobe/supervision_icon.png" slot="oobe-icon"
aria-hidden="true">
</iron-icon>
<h1 slot="title">Placeholder Supervision Onboarding flow</h1>
<webview id="contentWebview" slot="footer"></webview>
<div slot="bottom-buttons" class="flex layout horizontal">
<oobe-back-button id="back-button"
on-tap="onBack_">
Expand Down
42 changes: 38 additions & 4 deletions chrome/browser/resources/chromeos/login/supervision_onboarding.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,37 @@ Polymer({

behaviors: [LoginScreenBehavior],

/** Overridden from LoginScreenBehavior. */
EXTERNAL_API: [
'setupMojo',
],

/** @private {?chromeos.supervision.mojom.OnboardingControllerProxy} */
controller_: null,

/**
* @private {?chromeos.supervision.mojom.
* OnboardingWebviewHostCallbackRouter}
*/
hostCallbackRouter_: null,

setupMojo: function() {
this.controller_ =
chromeos.supervision.mojom.OnboardingController.getProxy();

this.hostCallbackRouter_ =
new chromeos.supervision.mojom.OnboardingWebviewHostCallbackRouter();

this.hostCallbackRouter_.loadPage.addListener(pageUrl => {
this.$.contentWebview.src = pageUrl;
});
this.hostCallbackRouter_.exitFlow.addListener(() => {
this.exitFlow_();
});

this.controller_.bindWebviewHost(this.hostCallbackRouter_.createProxy());
},

/** @override */
ready: function() {
this.initializeLoginScreen('SupervisionOnboardingScreen', {
Expand All @@ -21,21 +52,24 @@ Polymer({

/** @private */
onBack_: function() {
this.exitSetupFlow_();
this.controller_.handleAction(
chromeos.supervision.mojom.OnboardingFlowAction.kShowPreviousPage);
},

/** @private */
onSkip_: function() {
this.exitSetupFlow_();
this.controller_.handleAction(
chromeos.supervision.mojom.OnboardingFlowAction.kSkipFlow);
},

/** @private */
onNext_: function() {
this.exitSetupFlow_();
this.controller_.handleAction(
chromeos.supervision.mojom.OnboardingFlowAction.kShowNextPage);
},

/** @private */
exitSetupFlow_: function() {
exitFlow_: function() {
chrome.send('login.SupervisionOnboardingScreen.userActed',
['setup-finished']);
}
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1798,6 +1798,7 @@ jumbo_split_static_library("ui") {
"//ash/public/cpp/resources:ash_public_unscaled_resources",
"//ash/public/cpp/vector_icons",
"//chrome/browser/chromeos",
"//chrome/browser/chromeos/supervision/mojom",
"//chrome/browser/ui/webui/chromeos/add_supervision:mojo_bindings",
"//chromeos",
"//chromeos/assistant:buildflags",
Expand Down
Loading

0 comments on commit ffa543e

Please sign in to comment.