Commit 6e7b93a4 authored by Kyle Horimoto's avatar Kyle Horimoto Committed by Commit Bot

[CrOS MultiDevice] Add multi-device setup flow to OOBE/login.

This CL replaces the placeholder setup page with the real page which
includes the logic for choosing a multi-device host phone.

As part of this CL, WizardController now decides whether or not to
show the setup flow based on whether setup is applicable and needed for
the GAIA account under question.

Bug: 884065
Change-Id: I8f3be643b77890fb249516369d76f5c392a568a9
Reviewed-on: https://chromium-review.googlesource.com/c/1255591
Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597178}
parent 5f064e02
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
#include "chrome/browser/chromeos/login/session/user_session_manager.h" #include "chrome/browser/chromeos/login/session/user_session_manager.h"
#include "chrome/browser/chromeos/login/startup_utils.h" #include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h" #include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/multidevice_setup/multidevice_setup_client_factory.h"
#include "chrome/browser/chromeos/net/delay_network_call.h" #include "chrome/browser/chromeos/net/delay_network_call.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
...@@ -106,6 +107,7 @@ ...@@ -106,6 +107,7 @@
#include "chromeos/network/network_state.h" #include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h" #include "chromeos/network/network_state_handler.h"
#include "chromeos/network/portal_detector/network_portal_detector.h" #include "chromeos/network/portal_detector/network_portal_detector.h"
#include "chromeos/services/multidevice_setup/public/cpp/multidevice_setup_client.h"
#include "chromeos/settings/cros_settings_names.h" #include "chromeos/settings/cros_settings_names.h"
#include "chromeos/settings/cros_settings_provider.h" #include "chromeos/settings/cros_settings_provider.h"
#include "chromeos/settings/timezone_settings.h" #include "chromeos/settings/timezone_settings.h"
...@@ -847,17 +849,31 @@ void WizardController::ShowAssistantOptInFlowScreen() { ...@@ -847,17 +849,31 @@ void WizardController::ShowAssistantOptInFlowScreen() {
} }
void WizardController::ShowMultiDeviceSetupScreen() { void WizardController::ShowMultiDeviceSetupScreen() {
if (base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi) && // If multi-device flags are disabled, skip the associated setup flow.
base::FeatureList::IsEnabled( if (!base::FeatureList::IsEnabled(features::kMultiDeviceApi) ||
chromeos::features::kEnableUnifiedMultiDeviceSetup)) { !base::FeatureList::IsEnabled(features::kEnableUnifiedMultiDeviceSetup)) {
// TODO(khorimoto): Use MultiDeviceSetupClient to determine if any potential OnMultiDeviceSetupFinished();
// phone(s) on the same GAIA account can be used for multi-device features. return;
// Only show the setup screen if it is possible to use these features. }
UpdateStatusAreaVisibilityForScreen(OobeScreen::SCREEN_MULTIDEVICE_SETUP);
SetCurrentScreen(GetScreen(OobeScreen::SCREEN_MULTIDEVICE_SETUP)); multidevice_setup::MultiDeviceSetupClient* client =
} else { multidevice_setup::MultiDeviceSetupClientFactory::GetForProfile(
ProfileManager::GetActiveUserProfile());
DCHECK(client);
// If there is no eligible multi-device host phone or if there is a phone and
// it has already been set, skip the setup flow.
if (client->GetHostStatus().first !=
multidevice_setup::mojom::HostStatus::kEligibleHostExistsButNoHostSet) {
VLOG(1) << "Skipping MultiDevice setup screen; host status: "
<< client->GetHostStatus().first;
OnMultiDeviceSetupFinished(); OnMultiDeviceSetupFinished();
return;
} }
VLOG(1) << "Showing MultiDevice setup screen.";
UpdateStatusAreaVisibilityForScreen(OobeScreen::SCREEN_MULTIDEVICE_SETUP);
SetCurrentScreen(GetScreen(OobeScreen::SCREEN_MULTIDEVICE_SETUP));
} }
void WizardController::ShowDiscoverScreen() { void WizardController::ShowDiscoverScreen() {
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
<link rel="import" href="chrome://resources/html/polymer.html"> <link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://oobe/custom_elements.html"> <link rel="import" href="chrome://oobe/custom_elements.html">
<link rel="import" href="chrome://resources/cr_components/chromeos/multidevice_setup/multidevice_setup_shared_css.html">
<link rel="import" href="chrome://resources/cr_components/chromeos/multidevice_setup/multidevice_setup.html">
<!-- <!--
UI for the MultiDevice setup flow when displayed after OOBE or during the UI for the MultiDevice setup flow when displayed after OOBE or during the
user's first login on this Chromebook. Note that this flow is user's first login on this Chromebook. Note that this flow is
...@@ -16,20 +18,24 @@ ...@@ -16,20 +18,24 @@
screen. screen.
(3) In the first run, buttons are styled with custom OOBE buttons. (3) In the first run, buttons are styled with custom OOBE buttons.
TODO(khorimoto): Implement real flow. For now, this page simply displays
placeholder buttons. See https://crbug.com/884065.
Example: Example:
<multidevice-setup-first-run></multidevice-setup-first-run> <multidevice-setup-first-run></multidevice-setup-first-run>
--> -->
<dom-module id="multidevice-setup-first-run"> <dom-module id="multidevice-setup-first-run">
<template> <template>
<div>Placeholder MultiDevice setup flow</div> <style include="shared-style multidevice-setup-shared"></style>
<oobe-text-button inverse on-click="onSkipSetupClicked_"> <multidevice-setup delegate="[[delegate_]]"
<div>Skip setup</div> on-setup-exited="onExitRequested_"
</oobe-text-button> forward-button-text="{{forwardButtonText_}}"
<oobe-next-button on-click="onAcceptClicked_"> forward-button-disabled="{{forwardButtonDisabled_}}"
<div>Next</div> backward-button-text="{{backwardButtonText_}}">
</oobe-next-button> <oobe-text-button slot="backward-button">
<div>[[backwardButtonText_]]</div>
</oobe-text-button>
<oobe-next-button slot="forward-button"
disabled$="[[forwardButtonDisabled_]]">
<div>[[forwardButtonText_]]</div>
</oobe-next-button>
</multidevice-setup>
</template> </template>
</dom-module> </dom-module>
...@@ -7,21 +7,93 @@ ...@@ -7,21 +7,93 @@
* run (i.e., after OOBE or during the user's first login on this * run (i.e., after OOBE or during the user's first login on this
* Chromebook). * Chromebook).
*/ */
Polymer({
is: 'multidevice-setup-first-run', cr.define('multidevice_setup', function() {
/** @implements {multidevice_setup.MultiDeviceSetupDelegate} */
/** @private */ class MultiDeviceSetupFirstRunDelegate {
onSkipSetupClicked_: function() { constructor() {
this.exitSetupFlow_(); /**
}, * @private {?chromeos.multideviceSetup.mojom.
* PrivilegedHostDeviceSetterPtr}
/** @private */ */
onAcceptClicked_: function() { this.ptr_ = null;
this.exitSetupFlow_(); }
},
/** @override */
/** @private */ isPasswordRequiredToSetHost() {
exitSetupFlow_: function() { return false;
chrome.send('login.MultiDeviceSetupScreen.userActed', ['setup-finished']); }
/** @override */
setHostDevice(hostDeviceId, opt_authToken) {
// An authentication token is not expected since a password is not
// required.
assert(!opt_authToken);
if (!this.ptr_) {
this.ptr_ =
new chromeos.multideviceSetup.mojom.PrivilegedHostDeviceSetterPtr();
Mojo.bindInterface(
chromeos.multideviceSetup.mojom.PrivilegedHostDeviceSetter.name,
mojo.makeRequest(this.ptr_).handle);
}
return this.ptr_.setHostDevice(hostDeviceId);
}
/** @override */
shouldExitSetupFlowAfterSettingHost() {
return true;
}
} }
const MultiDeviceSetupFirstRun = Polymer({
is: 'multidevice-setup-first-run',
properties: {
/** @private {!multidevice_setup.MultiDeviceSetupDelegate} */
delegate_: Object,
/**
* Text to be shown on the forward navigation button.
* @private {string|undefined}
*/
forwardButtonText_: {
type: String,
value: '',
},
/**
* Whether the forward button should be disabled.
* @private {boolean}
*/
forwardButtonDisabled_: {
type: Boolean,
value: false,
},
/**
* Text to be shown on the backward navigation button.
* @private {string|undefined}
*/
backwardButtonText_: {
type: String,
value: '',
},
},
/** @override */
attached: function() {
this.delegate_ = new MultiDeviceSetupFirstRunDelegate();
},
/** @private */
onExitRequested_: function() {
chrome.send('login.MultiDeviceSetupScreen.userActed', ['setup-finished']);
}
});
return {
MultiDeviceSetupFirstRun: MultiDeviceSetupFirstRun,
};
}); });
...@@ -34,6 +34,8 @@ void MultiDeviceSetupScreenHandler::Bind(MultiDeviceSetupScreen* screen) { ...@@ -34,6 +34,8 @@ void MultiDeviceSetupScreenHandler::Bind(MultiDeviceSetupScreen* screen) {
} }
void MultiDeviceSetupScreenHandler::Show() { void MultiDeviceSetupScreenHandler::Show() {
AllowJavascript();
FireWebUIListener("multidevice_setup.initializeSetupFlow");
ShowScreen(kScreenId); ShowScreen(kScreenId);
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/ash_switches.h" #include "ash/public/cpp/ash_switches.h"
#include "base/bind.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/macros.h" #include "base/macros.h"
...@@ -32,6 +33,7 @@ ...@@ -32,6 +33,7 @@
#include "chrome/browser/extensions/signin/gaia_auth_extension_loader.h" #include "chrome/browser/extensions/signin/gaia_auth_extension_loader.h"
#include "chrome/browser/extensions/tab_helper.h" #include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/webui/about_ui.h" #include "chrome/browser/ui/webui/about_ui.h"
#include "chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/app_downloading_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/app_downloading_screen_handler.h"
...@@ -90,11 +92,14 @@ ...@@ -90,11 +92,14 @@
#include "chrome/grit/chrome_unscaled_resources.h" #include "chrome/grit/chrome_unscaled_resources.h"
#include "chrome/grit/component_extension_resources.h" #include "chrome/grit/component_extension_resources.h"
#include "chromeos/chromeos_switches.h" #include "chromeos/chromeos_switches.h"
#include "chromeos/services/multidevice_setup/public/mojom/constants.mojom.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h" #include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h" #include "content/public/browser/web_ui_data_source.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "services/service_manager/public/cpp/connector.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_features.h" #include "ui/base/ui_base_features.h"
#include "ui/base/webui/web_ui_util.h" #include "ui/base/webui/web_ui_util.h"
...@@ -453,8 +458,29 @@ void OobeUI::ConfigureOobeDisplay() { ...@@ -453,8 +458,29 @@ void OobeUI::ConfigureOobeDisplay() {
oobe_display_chooser_ = std::make_unique<OobeDisplayChooser>(); oobe_display_chooser_ = std::make_unique<OobeDisplayChooser>();
} }
service_manager::Connector* OobeUI::GetLoggedInUserMojoConnector() {
// This function should only be called after the user has logged in.
DCHECK(
user_manager::UserManager::Get()->IsUserLoggedIn() &&
user_manager::UserManager::Get()->GetActiveUser()->is_profile_created());
return content::BrowserContext::GetConnectorFor(
ProfileManager::GetActiveUserProfile());
}
void OobeUI::BindMultiDeviceSetup(
multidevice_setup::mojom::MultiDeviceSetupRequest request) {
GetLoggedInUserMojoConnector()->BindInterface(
multidevice_setup::mojom::kServiceName, std::move(request));
}
void OobeUI::BindPrivilegedHostDeviceSetter(
multidevice_setup::mojom::PrivilegedHostDeviceSetterRequest request) {
GetLoggedInUserMojoConnector()->BindInterface(
multidevice_setup::mojom::kServiceName, std::move(request));
}
OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url) OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url)
: WebUIController(web_ui) { : ui::MojoWebUIController(web_ui, true /* enable_chrome_send */) {
display_type_ = GetDisplayType(url); display_type_ = GetDisplayType(url);
js_calls_container = std::make_unique<JSCallsContainer>(); js_calls_container = std::make_unique<JSCallsContainer>();
...@@ -479,11 +505,15 @@ OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url) ...@@ -479,11 +505,15 @@ OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url)
content::WebUIDataSource* html_source = content::WebUIDataSource* html_source =
CreateOobeUIDataSource(localized_strings, display_type_); CreateOobeUIDataSource(localized_strings, display_type_);
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source); content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source);
}
OobeUI::~OobeUI() { AddHandlerToRegistry(base::BindRepeating(&OobeUI::BindMultiDeviceSetup,
base::Unretained(this)));
AddHandlerToRegistry(base::BindRepeating(
&OobeUI::BindPrivilegedHostDeviceSetter, base::Unretained(this)));
} }
OobeUI::~OobeUI() {}
CoreOobeView* OobeUI::GetCoreOobeView() { CoreOobeView* OobeUI::GetCoreOobeView() {
return core_handler_; return core_handler_;
} }
......
...@@ -18,12 +18,17 @@ ...@@ -18,12 +18,17 @@
#include "chrome/browser/chromeos/settings/shutdown_policy_handler.h" #include "chrome/browser/chromeos/settings/shutdown_policy_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h" #include "chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h"
#include "content/public/browser/web_ui_controller.h" #include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h"
#include "ui/webui/mojo_web_ui_controller.h"
namespace base { namespace base {
class DictionaryValue; class DictionaryValue;
} // namespace base } // namespace base
namespace service_manager {
class Connector;
} // namespace service_manager
namespace chromeos { namespace chromeos {
class AppDownloadingScreenView; class AppDownloadingScreenView;
class AppLaunchSplashScreenView; class AppLaunchSplashScreenView;
...@@ -76,7 +81,7 @@ class WrongHWIDScreenView; ...@@ -76,7 +81,7 @@ class WrongHWIDScreenView;
// - welcome screen (setup language/keyboard/network). // - welcome screen (setup language/keyboard/network).
// - eula screen (CrOS (+ OEM) EULA content/TPM password/crash reporting). // - eula screen (CrOS (+ OEM) EULA content/TPM password/crash reporting).
// - update screen. // - update screen.
class OobeUI : public content::WebUIController, class OobeUI : public ui::MojoWebUIController,
public ShutdownPolicyHandler::Delegate { public ShutdownPolicyHandler::Delegate {
public: public:
// List of known types of OobeUI. Type added as path in chrome://oobe url, for // List of known types of OobeUI. Type added as path in chrome://oobe url, for
...@@ -228,6 +233,13 @@ class OobeUI : public content::WebUIController, ...@@ -228,6 +233,13 @@ class OobeUI : public content::WebUIController,
// display type. // display type.
void ConfigureOobeDisplay(); void ConfigureOobeDisplay();
// Adds Mojo bindings for this WebUIController.
service_manager::Connector* GetLoggedInUserMojoConnector();
void BindMultiDeviceSetup(
multidevice_setup::mojom::MultiDeviceSetupRequest request);
void BindPrivilegedHostDeviceSetter(
multidevice_setup::mojom::PrivilegedHostDeviceSetterRequest request);
// Type of UI. // Type of UI.
std::string display_type_; std::string display_type_;
......
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