forked from chromium/chromium
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds parental handoff login screen in oobe.
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
Showing
27 changed files
with
673 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
chrome/app/chromeos_strings_grdp/IDS_LOGIN_PARENTAL_HANDOFF_SCREEN_NEXT_BUTTON.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5110db314fcfbbc1194cd27d5336c88de1790aa2 |
1 change: 1 addition & 0 deletions
1
chrome/app/chromeos_strings_grdp/IDS_LOGIN_PARENTAL_HANDOFF_SCREEN_SUBTITLE.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
72c5848be1b964cd6e77471c295e4ad19888692e |
1 change: 1 addition & 0 deletions
1
chrome/app/chromeos_strings_grdp/IDS_LOGIN_PARENTAL_HANDOFF_SCREEN_TITLE.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
f7c276d755adae2584036084356c2521de1602d9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
chrome/browser/chromeos/login/screens/parental_handoff_screen.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
54
chrome/browser/chromeos/login/screens/parental_handoff_screen.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_ |
Oops, something went wrong.