Skip to content

Commit

Permalink
Adds parental handoff login screen in oobe.
Browse files Browse the repository at this point in the history
The description and mock can be seen in the comments in the bug report.

Bug: 1134567
Change-Id: I2ecd7c72629dc96dfbc054f747c6cb2508210709
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2466618
Commit-Queue: Yilkal Abe <yilkal@chromium.org>
Reviewed-by: Aga Wronska <agawronska@chromium.org>
Reviewed-by: Roman Sorokin [CET] <rsorokin@chromium.org>
Reviewed-by: Jesse Doherty <jwd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819158}
  • Loading branch information
yilkal authored and Commit Bot committed Oct 20, 2020
1 parent 9cd23e8 commit dca1afe
Show file tree
Hide file tree
Showing 27 changed files with 673 additions and 5 deletions.
11 changes: 11 additions & 0 deletions chrome/app/chromeos_strings.grdp
Expand Up @@ -954,6 +954,17 @@
Please retry. If you see this error again please contact your support representative.
</message>

<!-- Strings for parental handoff login screen -->
<message name="IDS_LOGIN_PARENTAL_HANDOFF_SCREEN_TITLE" desc="Title of screen which tells user that the parent can handoff the device to supervised user.">
Now it's <ph name="SUPERVISED_USER_NAME">$1<ex>Child 1</ex></ph>'s turn
</message>
<message name="IDS_LOGIN_PARENTAL_HANDOFF_SCREEN_SUBTITLE" desc="Subtitle of screen which tells user that the parent can handoff the device to supervised user.">
You can hand this Chromebook to <ph name="SUPERVISED_USER_NAME">$1<ex>Child 1</ex></ph>. Setup is almost done, then it's time to explore.
</message>
<message name="IDS_LOGIN_PARENTAL_HANDOFF_SCREEN_NEXT_BUTTON" desc="Next button of parental handoff screen">
Next
</message>

<!-- Strings for family link notice screen -->
<message name="IDS_LOGIN_FAMILY_LINK_NOTICE_SCREEN_TITLE" desc="Title of the screen which tells user they can add parental control later.">
Add parental controls after setup
Expand Down
@@ -0,0 +1 @@
5110db314fcfbbc1194cd27d5336c88de1790aa2
@@ -0,0 +1 @@
72c5848be1b964cd6e77471c295e4ad19888692e
@@ -0,0 +1 @@
f7c276d755adae2584036084356c2521de1602d9
2 changes: 2 additions & 0 deletions chrome/browser/chromeos/BUILD.gn
Expand Up @@ -1745,6 +1745,8 @@ source_set("chromeos") {
"login/screens/network_screen.h",
"login/screens/packaged_license_screen.cc",
"login/screens/packaged_license_screen.h",
"login/screens/parental_handoff_screen.cc",
"login/screens/parental_handoff_screen.h",
"login/screens/recommend_apps/fake_recommend_apps_fetcher.cc",
"login/screens/recommend_apps/fake_recommend_apps_fetcher.h",
"login/screens/recommend_apps/recommend_apps_fetcher.cc",
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/login/debug_overlay_browsertest.cc
Expand Up @@ -22,8 +22,8 @@ constexpr char kDebugButton[] = "invokeDebuggerButton";
constexpr char kDebugOverlay[] = "debuggerOverlay";
constexpr char kScreensPanel[] = "DebuggerPanelScreens";

constexpr int kOobeScreensCount = 37;
constexpr int kLoginScreensCount = 32;
constexpr int kOobeScreensCount = 38;
constexpr int kLoginScreensCount = 33;

std::string ElementsInPanel(const std::string& panel) {
return base::StrCat({"$('", panel, "').children.length"});
Expand Down
109 changes: 109 additions & 0 deletions chrome/browser/chromeos/login/screens/parental_handoff_screen.cc
@@ -0,0 +1,109 @@
// Copyright 2020 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/login/screens/parental_handoff_screen.h"

#include <string>

#include "base/strings/string16.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
#include "chrome/browser/chromeos/login/screen_manager.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/supervised_user/supervised_user_features.h"
#include "chrome/browser/ui/webui/chromeos/login/parental_handoff_screen_handler.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "components/user_manager/user.h"
#include "components/user_manager/user_manager.h"
#include "ui/base/l10n/l10n_util.h"

namespace chromeos {

namespace {

constexpr char kUserActionNext[] = "next";

base::string16 GetActiveUserName() {
const user_manager::User* user =
user_manager::UserManager::Get()->GetActiveUser();
if (!user || !user->IsChild())
return base::string16();
return user->GetDisplayName();
}

} // namespace

// static
ParentalHandoffScreen* ParentalHandoffScreen::Get(
ScreenManager* screen_manager) {
return static_cast<ParentalHandoffScreen*>(
screen_manager->GetScreen(ParentalHandoffScreenView::kScreenId));
}

// static
std::string ParentalHandoffScreen::GetResultString(
ParentalHandoffScreen::Result result) {
switch (result) {
case ParentalHandoffScreen::Result::DONE:
return "Done";
case ParentalHandoffScreen::Result::SKIPPED:
return BaseScreen::kNotApplicable;
}
}

ParentalHandoffScreen::ParentalHandoffScreen(
ParentalHandoffScreenView* view,
const ScreenExitCallback& exit_callback)
: BaseScreen(ParentalHandoffScreenView::kScreenId,
OobeScreenPriority::DEFAULT),
view_(view),
exit_callback_(exit_callback) {
if (view_)
view_->Bind(this);
}

ParentalHandoffScreen::~ParentalHandoffScreen() {
if (view_)
view_->Unbind();
}

void ParentalHandoffScreen::OnViewDestroyed(ParentalHandoffScreenView* view) {
if (view_ == view)
view_ = nullptr;
}

bool ParentalHandoffScreen::MaybeSkip(WizardContext* context) {
Profile* profile = ProfileManager::GetActiveUserProfile();
if (profile->IsChild() && supervised_users::IsEduCoexistenceFlowV2Enabled()) {
return false;
}

exit_callback_.Run(Result::SKIPPED);
return true;
}

void ParentalHandoffScreen::ShowImpl() {
if (!view_)
return;

base::string16 user_name = GetActiveUserName();

view_->Show(l10n_util::GetStringFUTF16(
IDS_LOGIN_PARENTAL_HANDOFF_SCREEN_TITLE, user_name),
l10n_util::GetStringFUTF16(
IDS_LOGIN_PARENTAL_HANDOFF_SCREEN_SUBTITLE, user_name));
}
void ParentalHandoffScreen::HideImpl() {}

void ParentalHandoffScreen::OnUserAction(const std::string& action_id) {
if (action_id == kUserActionNext) {
exit_callback_.Run(Result::DONE);
} else {
BaseScreen::OnUserAction(action_id);
}
}

} // namespace chromeos
54 changes: 54 additions & 0 deletions chrome/browser/chromeos/login/screens/parental_handoff_screen.h
@@ -0,0 +1,54 @@
// Copyright 2020 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_LOGIN_SCREENS_PARENTAL_HANDOFF_SCREEN_H_
#define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_PARENTAL_HANDOFF_SCREEN_H_

#include <string>

#include "base/bind.h"
#include "chrome/browser/chromeos/login/screens/base_screen.h"

namespace chromeos {

class ParentalHandoffScreenView;
class WizardContext;
class ScreenManager;

class ParentalHandoffScreen : public BaseScreen {
public:
enum class Result { DONE, SKIPPED };

static ParentalHandoffScreen* Get(ScreenManager* screen_manager);
static std::string GetResultString(Result result);

using ScreenExitCallback = base::RepeatingCallback<void(Result)>;
ParentalHandoffScreen(ParentalHandoffScreenView* view,
const ScreenExitCallback& exit_callback);
ParentalHandoffScreen(const ParentalHandoffScreen&) = delete;
ParentalHandoffScreen& operator=(const ParentalHandoffScreen&) = delete;
~ParentalHandoffScreen() override;

void OnViewDestroyed(ParentalHandoffScreenView* view);

ScreenExitCallback get_exit_callback_for_test() { return exit_callback_; }

void set_exit_callback_for_test(const ScreenExitCallback& exit_callback) {
exit_callback_ = exit_callback;
}

private:
// BaseScreen:
bool MaybeSkip(WizardContext* context) override;
void ShowImpl() override;
void HideImpl() override;
void OnUserAction(const std::string& action_id) override;

ParentalHandoffScreenView* view_ = nullptr;
ScreenExitCallback exit_callback_;
};

} // namespace chromeos

#endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_PARENTAL_HANDOFF_SCREEN_H_

0 comments on commit dca1afe

Please sign in to comment.