Mash cleanup: remove more functions from mojom::LoginScreen
TBR=estade@chromium.org, tsepez@chromium.org
(cherry picked from commit 481f244592236367330cb53f4fe5092f378110a5)
Bug: 958206
Change-Id: I66b1924d9ab0d49047a7ee3fe8d1b696b74ed726
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1637865
Reviewed-by: Evan Stade <estade@chromium.org>
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Evan Stade <estade@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#665171}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1661666
Cr-Commit-Position: refs/branch-heads/3809@{#369}
Cr-Branched-From: d82dec1a818f378c464ba307ddd9c92133eac355-refs/heads/master@{#665002}
diff --git a/ash/login/login_screen_controller.cc b/ash/login/login_screen_controller.cc
index 59c6044..9f10598 100644
--- a/ash/login/login_screen_controller.cc
+++ b/ash/login/login_screen_controller.cc
@@ -338,31 +338,6 @@
NOTIMPLEMENTED();
}
-void LoginScreenController::SetAuthType(
- const AccountId& account_id,
- proximity_auth::mojom::AuthType auth_type,
- const base::string16& initial_value) {
- if (auth_type == proximity_auth::mojom::AuthType::USER_CLICK) {
- login_data_dispatcher_.SetTapToUnlockEnabledForUser(account_id,
- true /*enabled*/);
- } else if (auth_type == proximity_auth::mojom::AuthType::ONLINE_SIGN_IN) {
- login_data_dispatcher_.SetForceOnlineSignInForUser(account_id);
- } else {
- NOTIMPLEMENTED();
- }
-}
-
-void LoginScreenController::EnableAuthForUser(const AccountId& account_id) {
- login_data_dispatcher_.EnableAuthForUser(account_id);
-}
-
-void LoginScreenController::DisableAuthForUser(
- const AccountId& account_id,
- ash::mojom::AuthDisabledDataPtr auth_disabled_data) {
- login_data_dispatcher_.DisableAuthForUser(account_id,
- std::move(auth_disabled_data));
-}
-
void LoginScreenController::IsReadyForPassword(
IsReadyForPasswordCallback callback) {
std::move(callback).Run(LockScreen::HasInstance() && !IsAuthenticating());
diff --git a/ash/login/login_screen_controller.h b/ash/login/login_screen_controller.h
index e7305ee..d3a1313 100644
--- a/ash/login/login_screen_controller.h
+++ b/ash/login/login_screen_controller.h
@@ -119,13 +119,6 @@
const std::string& help_link_text,
int32_t help_topic_id) override;
void ClearErrors() override;
- void SetAuthType(const AccountId& account_id,
- proximity_auth::mojom::AuthType auth_type,
- const base::string16& initial_value) override;
- void EnableAuthForUser(const AccountId& account_id) override;
- void DisableAuthForUser(
- const AccountId& account_id,
- ash::mojom::AuthDisabledDataPtr auth_disabled_data) override;
void IsReadyForPassword(IsReadyForPasswordCallback callback) override;
void ShowKioskAppError(const std::string& message) override;
void SetAddUserButtonEnabled(bool enable) override;
diff --git a/ash/login/ui/lock_contents_view.cc b/ash/login/ui/lock_contents_view.cc
index 8aa4961..f2bccf8 100644
--- a/ash/login/ui/lock_contents_view.cc
+++ b/ash/login/ui/lock_contents_view.cc
@@ -800,7 +800,7 @@
void LockContentsView::OnAuthDisabledForUser(
const AccountId& user,
- const ash::mojom::AuthDisabledDataPtr& auth_disabled_data) {
+ const AuthDisabledData& auth_disabled_data) {
LockContentsView::UserState* state = FindStateForUser(user);
if (!state) {
LOG(ERROR) << "Unable to find user when disabling auth";
diff --git a/ash/login/ui/lock_contents_view.h b/ash/login/ui/lock_contents_view.h
index 10cc494e..c47b282 100644
--- a/ash/login/ui/lock_contents_view.h
+++ b/ash/login/ui/lock_contents_view.h
@@ -145,7 +145,7 @@
void OnAuthEnabledForUser(const AccountId& user) override;
void OnAuthDisabledForUser(
const AccountId& user,
- const ash::mojom::AuthDisabledDataPtr& auth_disabled_data) override;
+ const AuthDisabledData& auth_disabled_data) override;
void OnLockScreenNoteStateChanged(mojom::TrayActionState state) override;
void OnTapToUnlockEnabledForUserChanged(const AccountId& user,
bool enabled) override;
diff --git a/ash/login/ui/lock_contents_view_unittest.cc b/ash/login/ui/lock_contents_view_unittest.cc
index 54e0a97..7c21325 100644
--- a/ash/login/ui/lock_contents_view_unittest.cc
+++ b/ash/login/ui/lock_contents_view_unittest.cc
@@ -1809,10 +1809,9 @@
// Setting auth disabled will hide the password field and show the message.
DataDispatcher()->DisableAuthForUser(
kFirstUserAccountId,
- ash::mojom::AuthDisabledData::New(
- ash::mojom::AuthDisabledReason::TIME_WINDOW_LIMIT,
- base::Time::Now() + base::TimeDelta::FromHours(8),
- base::TimeDelta::FromHours(1)));
+ AuthDisabledData(ash::AuthDisabledReason::kTimeWindowLimit,
+ base::Time::Now() + base::TimeDelta::FromHours(8),
+ base::TimeDelta::FromHours(1)));
EXPECT_FALSE(password_view->GetVisible());
EXPECT_FALSE(pin_view->GetVisible());
EXPECT_TRUE(disabled_auth_message->GetVisible());
@@ -1825,10 +1824,9 @@
// Set auth disabled again.
DataDispatcher()->DisableAuthForUser(
kFirstUserAccountId,
- ash::mojom::AuthDisabledData::New(
- ash::mojom::AuthDisabledReason::TIME_WINDOW_LIMIT,
- base::Time::Now() + base::TimeDelta::FromHours(8),
- base::TimeDelta::FromHours(1)));
+ AuthDisabledData(ash::AuthDisabledReason::kTimeWindowLimit,
+ base::Time::Now() + base::TimeDelta::FromHours(8),
+ base::TimeDelta::FromHours(1)));
EXPECT_FALSE(password_view->GetVisible());
EXPECT_FALSE(pin_view->GetVisible());
EXPECT_TRUE(disabled_auth_message->GetVisible());
@@ -1865,10 +1863,9 @@
// Setting auth disabled hides the note action button.
DataDispatcher()->DisableAuthForUser(
kFirstUserAccountId,
- ash::mojom::AuthDisabledData::New(
- ash::mojom::AuthDisabledReason::TIME_WINDOW_LIMIT,
- base::Time::Now() + base::TimeDelta::FromHours(8),
- base::TimeDelta::FromHours(1)));
+ AuthDisabledData(ash::AuthDisabledReason::kTimeWindowLimit,
+ base::Time::Now() + base::TimeDelta::FromHours(8),
+ base::TimeDelta::FromHours(1)));
EXPECT_FALSE(note_action_button->GetVisible());
// Setting auth enabled shows the note action button.
DataDispatcher()->EnableAuthForUser(kFirstUserAccountId);
@@ -1877,10 +1874,9 @@
// Set auth disabled again.
DataDispatcher()->DisableAuthForUser(
kFirstUserAccountId,
- ash::mojom::AuthDisabledData::New(
- ash::mojom::AuthDisabledReason::TIME_WINDOW_LIMIT,
- base::Time::Now() + base::TimeDelta::FromHours(8),
- base::TimeDelta::FromHours(1)));
+ AuthDisabledData(ash::AuthDisabledReason::kTimeWindowLimit,
+ base::Time::Now() + base::TimeDelta::FromHours(8),
+ base::TimeDelta::FromHours(1)));
EXPECT_FALSE(note_action_button->GetVisible());
// Set the lock screen note state to |kNotAvailable| while the note action
// button is hidden.
@@ -1908,10 +1904,9 @@
// The message is visible after disabling auth and it receives initial focus.
DataDispatcher()->DisableAuthForUser(
kFirstUserAccountId,
- ash::mojom::AuthDisabledData::New(
- ash::mojom::AuthDisabledReason::TIME_WINDOW_LIMIT,
- base::Time::Now() + base::TimeDelta::FromHours(8),
- base::TimeDelta::FromHours(1)));
+ AuthDisabledData(ash::AuthDisabledReason::kTimeWindowLimit,
+ base::Time::Now() + base::TimeDelta::FromHours(8),
+ base::TimeDelta::FromHours(1)));
EXPECT_TRUE(disabled_auth_message->GetVisible());
EXPECT_TRUE(HasFocusInAnyChildView(disabled_auth_message));
// Tabbing from the message will move focus to the user view.
diff --git a/ash/login/ui/lock_debug_view.cc b/ash/login/ui/lock_debug_view.cc
index c6e3247..98819c2 100644
--- a/ash/login/ui/lock_debug_view.cc
+++ b/ash/login/ui/lock_debug_view.cc
@@ -349,7 +349,7 @@
// Force online sign-in for the user at |user_index|.
void ForceOnlineSignInForUserIndex(size_t user_index) {
DCHECK(user_index >= 0 && user_index < debug_users_.size());
- debug_dispatcher_.SetForceOnlineSignInForUser(
+ debug_dispatcher_.ForceOnlineSignInForUser(
debug_users_[user_index].account_id);
}
@@ -357,14 +357,14 @@
// manner.
void UpdateAuthDisabledReason() {
switch (auth_disabled_reason_) {
- case mojom::AuthDisabledReason::TIME_LIMIT_OVERRIDE:
- auth_disabled_reason_ = mojom::AuthDisabledReason::TIME_USAGE_LIMIT;
+ case AuthDisabledReason::kTimeLimitOverride:
+ auth_disabled_reason_ = AuthDisabledReason::kTimeUsageLimit;
break;
- case mojom::AuthDisabledReason::TIME_USAGE_LIMIT:
- auth_disabled_reason_ = mojom::AuthDisabledReason::TIME_WINDOW_LIMIT;
+ case AuthDisabledReason::kTimeUsageLimit:
+ auth_disabled_reason_ = AuthDisabledReason::kTimeWindowLimit;
break;
- case mojom::AuthDisabledReason::TIME_WINDOW_LIMIT:
- auth_disabled_reason_ = mojom::AuthDisabledReason::TIME_LIMIT_OVERRIDE;
+ case AuthDisabledReason::kTimeWindowLimit:
+ auth_disabled_reason_ = AuthDisabledReason::kTimeLimitOverride;
break;
}
}
@@ -379,11 +379,11 @@
} else {
debug_dispatcher_.DisableAuthForUser(
user.account_id,
- mojom::AuthDisabledData::New(
- auth_disabled_reason_,
- base::Time::Now() + base::TimeDelta::FromHours(user_index) +
- base::TimeDelta::FromHours(8),
- base::TimeDelta::FromMinutes(15)));
+ AuthDisabledData(auth_disabled_reason_,
+ base::Time::Now() +
+ base::TimeDelta::FromHours(user_index) +
+ base::TimeDelta::FromHours(8),
+ base::TimeDelta::FromMinutes(15)));
UpdateAuthDisabledReason();
}
}
@@ -525,8 +525,8 @@
// When auth is disabled, this property is used to define the reason, which
// customizes the UI accordingly.
- mojom::AuthDisabledReason auth_disabled_reason_ =
- mojom::AuthDisabledReason::TIME_LIMIT_OVERRIDE;
+ AuthDisabledReason auth_disabled_reason_ =
+ AuthDisabledReason::kTimeLimitOverride;
DISALLOW_COPY_AND_ASSIGN(DebugDataDispatcherTransformer);
};
diff --git a/ash/login/ui/login_auth_user_view.cc b/ash/login/ui/login_auth_user_view.cc
index 93e6284c..ae2b27ec 100644
--- a/ash/login/ui/login_auth_user_view.cc
+++ b/ash/login/ui/login_auth_user_view.cc
@@ -302,15 +302,15 @@
return message;
}
-LockScreenMessage GetLockScreenMessage(mojom::AuthDisabledReason lock_reason,
+LockScreenMessage GetLockScreenMessage(AuthDisabledReason lock_reason,
const base::Time& unlock_time,
const base::TimeDelta& used_time) {
switch (lock_reason) {
- case mojom::AuthDisabledReason::TIME_WINDOW_LIMIT:
+ case AuthDisabledReason::kTimeWindowLimit:
return GetWindowLimitMessage(unlock_time);
- case mojom::AuthDisabledReason::TIME_USAGE_LIMIT:
+ case AuthDisabledReason::kTimeUsageLimit:
return GetUsageLimitMessage(used_time);
- case mojom::AuthDisabledReason::TIME_LIMIT_OVERRIDE:
+ case AuthDisabledReason::kTimeLimitOverride:
return GetOverrideMessage();
default:
NOTREACHED();
@@ -487,11 +487,10 @@
~DisabledAuthMessageView() override = default;
// Set the parameters needed to render the message.
- void SetAuthDisabledMessage(
- const ash::mojom::AuthDisabledDataPtr& auth_disabled_data) {
+ void SetAuthDisabledMessage(const AuthDisabledData& auth_disabled_data) {
LockScreenMessage message = GetLockScreenMessage(
- auth_disabled_data->reason, auth_disabled_data->auth_reenabled_time,
- auth_disabled_data->device_used_time);
+ auth_disabled_data.reason, auth_disabled_data.auth_reenabled_time,
+ auth_disabled_data.device_used_time);
message_icon_->SetImage(gfx::CreateVectorIcon(
*message.icon, kDisabledAuthMessageIconSizeDp, SK_ColorWHITE));
message_title_->SetText(message.title);
@@ -970,7 +969,7 @@
}
void LoginAuthUserView::SetAuthDisabledMessage(
- const ash::mojom::AuthDisabledDataPtr& auth_disabled_data) {
+ const AuthDisabledData& auth_disabled_data) {
disabled_auth_message_->SetAuthDisabledMessage(auth_disabled_data);
Layout();
}
diff --git a/ash/login/ui/login_auth_user_view.h b/ash/login/ui/login_auth_user_view.h
index f952c2d..de6f6ca 100644
--- a/ash/login/ui/login_auth_user_view.h
+++ b/ash/login/ui/login_auth_user_view.h
@@ -12,8 +12,8 @@
#include "ash/login/ui/login_password_view.h"
#include "ash/login/ui/login_user_view.h"
#include "ash/login/ui/non_accessible_view.h"
+#include "ash/public/cpp/login_types.h"
#include "ash/public/cpp/session/user_info.h"
-#include "ash/public/interfaces/login_screen.mojom.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "base/scoped_observer.h"
@@ -129,8 +129,7 @@
// Set the parameters needed to render the message that is shown to user when
// auth method is |AUTH_DISABLED|.
- void SetAuthDisabledMessage(
- const ash::mojom::AuthDisabledDataPtr& auth_disabled_data);
+ void SetAuthDisabledMessage(const AuthDisabledData& auth_disabled_data);
const LoginUserInfo& current_user() const;
diff --git a/ash/login/ui/login_data_dispatcher.cc b/ash/login/ui/login_data_dispatcher.cc
index 33bee75..4ca7fbb 100644
--- a/ash/login/ui/login_data_dispatcher.cc
+++ b/ash/login/ui/login_data_dispatcher.cc
@@ -32,7 +32,7 @@
void LoginDataDispatcher::Observer::OnAuthDisabledForUser(
const AccountId& user,
- const mojom::AuthDisabledDataPtr& auth_disabled_data) {}
+ const AuthDisabledData& auth_disabled_data) {}
void LoginDataDispatcher::Observer::OnTapToUnlockEnabledForUserChanged(
const AccountId& user,
@@ -99,6 +99,12 @@
observers_.RemoveObserver(observer);
}
+void LoginDataDispatcher::SetTapToUnlockEnabledForUser(const AccountId& user,
+ bool enabled) {
+ for (auto& observer : observers_)
+ observer.OnTapToUnlockEnabledForUserChanged(user, enabled);
+}
+
void LoginDataDispatcher::SetUserList(const std::vector<LoginUserInfo>& users) {
for (auto& observer : observers_)
observer.OnUsersChanged(users);
@@ -138,19 +144,16 @@
void LoginDataDispatcher::DisableAuthForUser(
const AccountId& account_id,
- ash::mojom::AuthDisabledDataPtr auth_disabled_data) {
- for (auto& observer : observers_) {
- observer.OnAuthDisabledForUser(account_id, auth_disabled_data);
- }
-}
-
-void LoginDataDispatcher::SetTapToUnlockEnabledForUser(const AccountId& user,
- bool enabled) {
+ const AuthDisabledData& auth_disabled_data) {
for (auto& observer : observers_)
- observer.OnTapToUnlockEnabledForUserChanged(user, enabled);
+ observer.OnAuthDisabledForUser(account_id, auth_disabled_data);
}
-void LoginDataDispatcher::SetForceOnlineSignInForUser(const AccountId& user) {
+void LoginDataDispatcher::EnableTapToUnlockForUser(const AccountId& user) {
+ SetTapToUnlockEnabledForUser(user, true);
+}
+
+void LoginDataDispatcher::ForceOnlineSignInForUser(const AccountId& user) {
for (auto& observer : observers_)
observer.OnForceOnlineSignInForUser(user);
}
diff --git a/ash/login/ui/login_data_dispatcher.h b/ash/login/ui/login_data_dispatcher.h
index 48d38d4..fe66da28 100644
--- a/ash/login/ui/login_data_dispatcher.h
+++ b/ash/login/ui/login_data_dispatcher.h
@@ -69,7 +69,7 @@
// be enabled.
virtual void OnAuthDisabledForUser(
const AccountId& user,
- const ash::mojom::AuthDisabledDataPtr& auth_disabled_data);
+ const AuthDisabledData& auth_disabled_data);
// Called when the given user can click their pod to unlock.
virtual void OnTapToUnlockEnabledForUserChanged(const AccountId& user,
@@ -144,6 +144,8 @@
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
+ void SetTapToUnlockEnabledForUser(const AccountId& user, bool enabled);
+
// LoginScreenModel:
// TODO(estade): for now, LoginScreenModel overrides are mixed with
// non-virtual methods. More of the non-virtual methods will become a part of
@@ -158,11 +160,11 @@
const UserAvatar& avatar) override;
void NotifyFingerprintAuthResult(const AccountId& account_id,
bool successful) override;
- void EnableAuthForUser(const AccountId& account_id);
+ void EnableAuthForUser(const AccountId& account_id) override;
void DisableAuthForUser(const AccountId& account_id,
- ash::mojom::AuthDisabledDataPtr auth_disabled_data);
- void SetTapToUnlockEnabledForUser(const AccountId& user, bool enabled);
- void SetForceOnlineSignInForUser(const AccountId& user);
+ const AuthDisabledData& auth_disabled_data) override;
+ void EnableTapToUnlockForUser(const AccountId& user) override;
+ void ForceOnlineSignInForUser(const AccountId& user) override;
void SetLockScreenNoteState(mojom::TrayActionState state);
void ShowEasyUnlockIcon(const AccountId& user,
const EasyUnlockIconOptions& icon) override;
diff --git a/ash/public/cpp/login_screen_model.h b/ash/public/cpp/login_screen_model.h
index c8f5f52..0b5c831 100644
--- a/ash/public/cpp/login_screen_model.h
+++ b/ash/public/cpp/login_screen_model.h
@@ -16,6 +16,7 @@
enum class FingerprintState;
enum class OobeDialogState;
+struct AuthDisabledData;
struct EasyUnlockIconOptions;
struct InputMethodItem;
struct LocaleItem;
@@ -58,6 +59,25 @@
virtual void NotifyFingerprintAuthResult(const AccountId& account_id,
bool successful) = 0;
+ // Called when auth should be enabled for the given user. When auth is
+ // disabled, the user cannot unlock the device. Auth is enabled by default.
+ // |account_id|: The account id of the user in the user pod.
+ virtual void EnableAuthForUser(const AccountId& account_id) = 0;
+
+ // Called when auth should be disabled for the given user. When auth is
+ // disabled, the user cannot unlock the device. Auth is enabled by default.
+ // |account_id|: The account id of the user in the user pod.
+ // |auth_disabled_data|: The data needed to customize the lock screen UI.
+ virtual void DisableAuthForUser(
+ const AccountId& account_id,
+ const AuthDisabledData& auth_disabled_data) = 0;
+
+ // Sets the authentication type to tap-to-unlock for the user.
+ virtual void EnableTapToUnlockForUser(const AccountId& account_id) = 0;
+
+ // Forces online sign-in for the user.
+ virtual void ForceOnlineSignInForUser(const AccountId& account_id) = 0;
+
// Called when |avatar| for |account_id| has changed.
virtual void SetAvatarForUser(const AccountId& account_id,
const UserAvatar& avatar) = 0;
diff --git a/ash/public/cpp/login_types.cc b/ash/public/cpp/login_types.cc
index 47857fb..83b91faa 100644
--- a/ash/public/cpp/login_types.cc
+++ b/ash/public/cpp/login_types.cc
@@ -53,4 +53,20 @@
LoginUserInfo& LoginUserInfo::operator=(const LoginUserInfo& other) = default;
LoginUserInfo& LoginUserInfo::operator=(LoginUserInfo&& other) = default;
+AuthDisabledData::AuthDisabledData() = default;
+AuthDisabledData::AuthDisabledData(AuthDisabledReason reason,
+ const base::Time& auth_reenabled_time,
+ const base::TimeDelta& device_used_time)
+ : reason(reason),
+ auth_reenabled_time(auth_reenabled_time),
+ device_used_time(device_used_time) {}
+AuthDisabledData::AuthDisabledData(const AuthDisabledData& other) = default;
+AuthDisabledData::AuthDisabledData(AuthDisabledData&& other) = default;
+AuthDisabledData::~AuthDisabledData() = default;
+
+AuthDisabledData& AuthDisabledData::operator=(const AuthDisabledData& other) =
+ default;
+AuthDisabledData& AuthDisabledData::operator=(AuthDisabledData&& other) =
+ default;
+
} // namespace ash
diff --git a/ash/public/cpp/login_types.h b/ash/public/cpp/login_types.h
index e2325640..0434503 100644
--- a/ash/public/cpp/login_types.h
+++ b/ash/public/cpp/login_types.h
@@ -7,6 +7,7 @@
#include "ash/public/cpp/ash_public_export.h"
#include "ash/public/cpp/session/user_info.h"
+#include "base/time/time.h"
#include "base/token.h"
#include "chromeos/components/proximity_auth/public/interfaces/auth_type.mojom.h"
@@ -249,6 +250,42 @@
base::Optional<PublicAccountInfo> public_account_info;
};
+enum class AuthDisabledReason {
+ // Auth is disabled because the device is locked by a time limit override.
+ kTimeLimitOverride,
+
+ // Auth is disabled because the user has reached their daily usage limit on
+ // the device.
+ kTimeUsageLimit,
+
+ // Auth is disabled because the device is within a locked time window.
+ kTimeWindowLimit,
+};
+
+// The data needed to customize the lock screen when auth is disabled.
+struct ASH_PUBLIC_EXPORT AuthDisabledData {
+ AuthDisabledData();
+ AuthDisabledData(AuthDisabledReason reason,
+ const base::Time& auth_reenabled_time,
+ const base::TimeDelta& device_used_time);
+ AuthDisabledData(const AuthDisabledData& other);
+ AuthDisabledData(AuthDisabledData&& other);
+ ~AuthDisabledData();
+
+ AuthDisabledData& operator=(const AuthDisabledData& other);
+ AuthDisabledData& operator=(AuthDisabledData&& other);
+
+ // Reason why auth is disabled.
+ AuthDisabledReason reason = AuthDisabledReason::kTimeLimitOverride;
+
+ // A future time when auth will be enabled. This value is for display purpose
+ // only, auth won't be automatically enabled when this time is reached.
+ base::Time auth_reenabled_time;
+
+ // The amount of time that the user used this device.
+ base::TimeDelta device_used_time;
+};
+
} // namespace ash
#endif // ASH_PUBLIC_CPP_LOGIN_TYPES_H_
diff --git a/ash/public/interfaces/login_screen.mojom b/ash/public/interfaces/login_screen.mojom
index af66bd3..f7c67992 100644
--- a/ash/public/interfaces/login_screen.mojom
+++ b/ash/public/interfaces/login_screen.mojom
@@ -4,37 +4,10 @@
module ash.mojom;
-import "chromeos/components/proximity_auth/public/interfaces/auth_type.mojom";
import "components/account_id/interfaces/account_id.mojom";
import "mojo/public/mojom/base/string16.mojom";
import "mojo/public/mojom/base/time.mojom";
-// Reason why the auth is disabled. This is used to personalize the UI.
-enum AuthDisabledReason {
- // Auth is disabled because the device is locked by a time limit override.
- TIME_LIMIT_OVERRIDE,
-
- // Auth is disabled because the user has reached their daily usage limit on
- // the device.
- TIME_USAGE_LIMIT,
-
- // Auth is disabled because the device is within a locked time window.
- TIME_WINDOW_LIMIT,
-};
-
-// The data needed to customize the lock screen when auth is disabled.
-struct AuthDisabledData {
- // Reason why auth is disabled.
- AuthDisabledReason reason;
-
- // A future time when auth will be enabled. This value is for display purpose
- // only, auth won't be automatically enabled when this time is reached.
- mojo_base.mojom.Time auth_reenabled_time;
-
- // The amount of time that the user used this device.
- mojo_base.mojom.TimeDelta device_used_time;
-};
-
// Allows clients (e.g. the browser process) to send messages to the ash
// login/lock/user-add screens.
// TODO(estade): this is in the process of being migrated off Mojo. Methods will
@@ -66,27 +39,6 @@
// Requests to close any displayed error messages in ash lock screen.
ClearErrors();
- // Requests to set the authentication type.
- // |account_id|: The account id of the user in the user pod.
- // |auth_type|: Authentication type.
- // |initial_value|: A message shown in the password field of the user pod.
- SetAuthType(signin.mojom.AccountId account_id,
- proximity_auth.mojom.AuthType auth_type,
- mojo_base.mojom.String16 initial_value);
-
-
- // Called when auth should be enabled for the given user. When auth is
- // disabled, the user cannot unlock the device. Auth is enabled by default.
- // |account_id|: The account id of the user in the user pod.
- EnableAuthForUser(signin.mojom.AccountId account_id);
-
- // Called when auth should be disabled for the given user. When auth is
- // disabled, the user cannot unlock the device. Auth is enabled by default.
- // |account_id|: The account id of the user in the user pod.
- // |auth_disabled_data|: The data needed to customize the lock screen UI.
- DisableAuthForUser(signin.mojom.AccountId account_id,
- AuthDisabledData auth_disabled_data);
-
// Check if the login/lock screen is ready for a password.
IsReadyForPassword() => (bool is_ready);
diff --git a/chrome/browser/chromeos/child_accounts/screen_time_controller.cc b/chrome/browser/chromeos/child_accounts/screen_time_controller.cc
index ee6b8ba6..c81f7eb 100644
--- a/chrome/browser/chromeos/child_accounts/screen_time_controller.cc
+++ b/chrome/browser/chromeos/child_accounts/screen_time_controller.cc
@@ -46,6 +46,22 @@
constexpr char kScreenStateNextPolicyType[] = "next_active_policy";
constexpr char kScreenStateNextUnlockTime[] = "next_unlock_time";
+ash::AuthDisabledReason ConvertLockReason(
+ usage_time_limit::PolicyType active_policy) {
+ switch (active_policy) {
+ case usage_time_limit::PolicyType::kFixedLimit:
+ return ash::AuthDisabledReason::kTimeWindowLimit;
+ case usage_time_limit::PolicyType::kUsageLimit:
+ return ash::AuthDisabledReason::kTimeUsageLimit;
+ case usage_time_limit::PolicyType::kOverride:
+ return ash::AuthDisabledReason::kTimeLimitOverride;
+ case usage_time_limit::PolicyType::kNoPolicy:
+ break;
+ }
+ NOTREACHED();
+ return ash::AuthDisabledReason();
+}
+
} // namespace
// static
@@ -263,13 +279,10 @@
chromeos::ProfileHelper::Get()
->GetUserByProfile(Profile::FromBrowserContext(context_))
->GetAccountId();
- base::Optional<ash::mojom::AuthDisabledReason> disabled_reason =
- ConvertLockReason(active_policy);
- DCHECK(disabled_reason.has_value());
ScreenLocker::default_screen_locker()->DisableAuthForUser(
account_id,
- ash::mojom::AuthDisabledData::New(
- disabled_reason.value(), next_unlock_time, GetScreenTimeDuration()));
+ ash::AuthDisabledData(ConvertLockReason(active_policy), next_unlock_time,
+ GetScreenTimeDuration()));
// Add parent access code button.
if (base::FeatureList::IsEnabled(features::kParentAccessCode))
@@ -292,26 +305,6 @@
LoginScreenClient::Get()->login_screen()->SetShowParentAccessButton(false);
}
-base::Optional<ash::mojom::AuthDisabledReason>
-ScreenTimeController::ConvertLockReason(
- usage_time_limit::PolicyType active_policy) {
- base::Optional<ash::mojom::AuthDisabledReason> disabled_reason;
- switch (active_policy) {
- case usage_time_limit::PolicyType::kFixedLimit:
- disabled_reason = ash::mojom::AuthDisabledReason::TIME_WINDOW_LIMIT;
- break;
- case usage_time_limit::PolicyType::kUsageLimit:
- disabled_reason = ash::mojom::AuthDisabledReason::TIME_USAGE_LIMIT;
- break;
- case usage_time_limit::PolicyType::kOverride:
- disabled_reason = ash::mojom::AuthDisabledReason::TIME_LIMIT_OVERRIDE;
- break;
- default:
- disabled_reason = base::nullopt;
- }
- return disabled_reason;
-}
-
void ScreenTimeController::OnPolicyChanged() {
CheckTimeLimit("OnPolicyChanged");
}
diff --git a/chrome/browser/chromeos/child_accounts/screen_time_controller.h b/chrome/browser/chromeos/child_accounts/screen_time_controller.h
index 99c9c39..b688ad3 100644
--- a/chrome/browser/chromeos/child_accounts/screen_time_controller.h
+++ b/chrome/browser/chromeos/child_accounts/screen_time_controller.h
@@ -101,10 +101,6 @@
// Disables the time limits message in the lock screen.
void OnScreenLockByPolicyEnd();
- // Converts the active policy to its equivalent on the ash enum.
- base::Optional<ash::mojom::AuthDisabledReason> ConvertLockReason(
- usage_time_limit::PolicyType active_policy);
-
// Called when the policy of time limits changes.
void OnPolicyChanged();
diff --git a/chrome/browser/chromeos/login/lock/screen_locker.cc b/chrome/browser/chromeos/login/lock/screen_locker.cc
index feda770a..fd4c87cb 100644
--- a/chrome/browser/chromeos/login/lock/screen_locker.cc
+++ b/chrome/browser/chromeos/login/lock/screen_locker.cc
@@ -324,18 +324,18 @@
CHECK(user) << "Invalid user - cannot enable authentication.";
users_with_disabled_auth_.erase(account_id);
- LoginScreenClient::Get()->login_screen()->EnableAuthForUser(account_id);
+ ash::LoginScreen::Get()->GetModel()->EnableAuthForUser(account_id);
}
void ScreenLocker::DisableAuthForUser(
const AccountId& account_id,
- ash::mojom::AuthDisabledDataPtr auth_disabled_data) {
+ const ash::AuthDisabledData& auth_disabled_data) {
const user_manager::User* user = FindUnlockUser(account_id);
CHECK(user) << "Invalid user - cannot disable authentication.";
users_with_disabled_auth_.insert(account_id);
- LoginScreenClient::Get()->login_screen()->DisableAuthForUser(
- account_id, std::move(auth_disabled_data));
+ ash::LoginScreen::Get()->GetModel()->DisableAuthForUser(account_id,
+ auth_disabled_data);
}
void ScreenLocker::Authenticate(const UserContext& user_context,
diff --git a/chrome/browser/chromeos/login/lock/screen_locker.h b/chrome/browser/chromeos/login/lock/screen_locker.h
index 240f852..eeffd73 100644
--- a/chrome/browser/chromeos/login/lock/screen_locker.h
+++ b/chrome/browser/chromeos/login/lock/screen_locker.h
@@ -9,7 +9,7 @@
#include <set>
#include <string>
-#include "ash/public/interfaces/login_screen.mojom.h"
+#include "ash/public/cpp/login_types.h"
#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
@@ -89,7 +89,7 @@
// Enables authentication for the user with |account_id|. Notifies lock screen
// UI. |auth_disabled_data| is used to display information in the UI.
void DisableAuthForUser(const AccountId& account_id,
- ash::mojom::AuthDisabledDataPtr auth_disabled_data);
+ const ash::AuthDisabledData& auth_disabled_data);
// Authenticates the user with given |user_context|.
void Authenticate(const UserContext& user_context,
diff --git a/chrome/browser/chromeos/login/lock/screen_locker_browsertest.cc b/chrome/browser/chromeos/login/lock/screen_locker_browsertest.cc
index a080c88..8937422 100644
--- a/chrome/browser/chromeos/login/lock/screen_locker_browsertest.cc
+++ b/chrome/browser/chromeos/login/lock/screen_locker_browsertest.cc
@@ -249,10 +249,9 @@
// Disable authentication for user.
ScreenLocker::default_screen_locker()->DisableAuthForUser(
user_manager::StubAccountId(),
- ash::mojom::AuthDisabledData::New(
- ash::mojom::AuthDisabledReason::TIME_WINDOW_LIMIT,
- base::Time::Now() + base::TimeDelta::FromHours(1),
- base::TimeDelta::FromHours(1)));
+ ash::AuthDisabledData(ash::AuthDisabledReason::kTimeWindowLimit,
+ base::Time::Now() + base::TimeDelta::FromHours(1),
+ base::TimeDelta::FromHours(1)));
// Try to authenticate with password.
tester.UnlockWithPassword(user_manager::StubAccountId(), kPassword);
@@ -288,10 +287,9 @@
// Disable authentication for user.
ScreenLocker::default_screen_locker()->DisableAuthForUser(
user_manager::StubAccountId(),
- ash::mojom::AuthDisabledData::New(
- ash::mojom::AuthDisabledReason::TIME_USAGE_LIMIT,
- base::Time::Now() + base::TimeDelta::FromHours(1),
- base::TimeDelta::FromHours(3)));
+ ash::AuthDisabledData(ash::AuthDisabledReason::kTimeUsageLimit,
+ base::Time::Now() + base::TimeDelta::FromHours(1),
+ base::TimeDelta::FromHours(3)));
// Try to authenticate with fingerprint.
AuthenticateWithFingerprint();
diff --git a/chrome/browser/chromeos/login/user_board_view_mojo.cc b/chrome/browser/chromeos/login/user_board_view_mojo.cc
index 691e703..4464541 100644
--- a/chrome/browser/chromeos/login/user_board_view_mojo.cc
+++ b/chrome/browser/chromeos/login/user_board_view_mojo.cc
@@ -122,8 +122,13 @@
void UserBoardViewMojo::SetAuthType(const AccountId& account_id,
proximity_auth::mojom::AuthType auth_type,
const base::string16& initial_value) {
- LoginScreenClient::Get()->login_screen()->SetAuthType(account_id, auth_type,
- initial_value);
+ if (auth_type == proximity_auth::mojom::AuthType::USER_CLICK) {
+ ash::LoginScreen::Get()->GetModel()->EnableTapToUnlockForUser(account_id);
+ } else if (auth_type == proximity_auth::mojom::AuthType::ONLINE_SIGN_IN) {
+ ash::LoginScreen::Get()->GetModel()->ForceOnlineSignInForUser(account_id);
+ } else {
+ NOTIMPLEMENTED();
+ }
}
base::WeakPtr<UserBoardView> UserBoardViewMojo::GetWeakPtr() {
diff --git a/chrome/browser/ui/ash/test_login_screen.cc b/chrome/browser/ui/ash/test_login_screen.cc
index e6bda90..ffc9089 100644
--- a/chrome/browser/ui/ash/test_login_screen.cc
+++ b/chrome/browser/ui/ash/test_login_screen.cc
@@ -48,16 +48,6 @@
void TestLoginScreen::ClearErrors() {}
-void TestLoginScreen::SetAuthType(const AccountId& account_id,
- ::proximity_auth::mojom::AuthType auth_type,
- const base::string16& initial_value) {}
-
-void TestLoginScreen::EnableAuthForUser(const AccountId& account_id) {}
-
-void TestLoginScreen::DisableAuthForUser(
- const AccountId& account_id,
- ash::mojom::AuthDisabledDataPtr auth_disabled_data) {}
-
void TestLoginScreen::IsReadyForPassword(IsReadyForPasswordCallback callback) {
std::move(callback).Run(true);
}
diff --git a/chrome/browser/ui/ash/test_login_screen.h b/chrome/browser/ui/ash/test_login_screen.h
index c6cfda1..6d3cffd7 100644
--- a/chrome/browser/ui/ash/test_login_screen.h
+++ b/chrome/browser/ui/ash/test_login_screen.h
@@ -36,13 +36,6 @@
const std::string& help_link_text,
int32_t help_topic_id) override;
void ClearErrors() override;
- void SetAuthType(const AccountId& account_id,
- ::proximity_auth::mojom::AuthType auth_type,
- const base::string16& initial_value) override;
- void EnableAuthForUser(const AccountId& account_id) override;
- void DisableAuthForUser(
- const AccountId& account_id,
- ash::mojom::AuthDisabledDataPtr auth_disabled_data) override;
void IsReadyForPassword(IsReadyForPasswordCallback callback) override;
void ShowKioskAppError(const std::string& message) override;
void SetAddUserButtonEnabled(bool enable) override;
diff --git a/chrome/browser/ui/ash/test_login_screen_model.cc b/chrome/browser/ui/ash/test_login_screen_model.cc
index f06f995..3781b140 100644
--- a/chrome/browser/ui/ash/test_login_screen_model.cc
+++ b/chrome/browser/ui/ash/test_login_screen_model.cc
@@ -18,6 +18,14 @@
void TestLoginScreenModel::NotifyFingerprintAuthResult(
const AccountId& account_id,
bool successful) {}
+void TestLoginScreenModel::EnableAuthForUser(const AccountId& account_id) {}
+void TestLoginScreenModel::DisableAuthForUser(
+ const AccountId& account_id,
+ const ash::AuthDisabledData& auth_disabled_data) {}
+void TestLoginScreenModel::EnableTapToUnlockForUser(
+ const AccountId& account_id) {}
+void TestLoginScreenModel::ForceOnlineSignInForUser(
+ const AccountId& account_id) {}
void TestLoginScreenModel::ShowEasyUnlockIcon(
const AccountId& account_id,
const ash::EasyUnlockIconOptions& icon) {}
diff --git a/chrome/browser/ui/ash/test_login_screen_model.h b/chrome/browser/ui/ash/test_login_screen_model.h
index b3649f2..e31e728 100644
--- a/chrome/browser/ui/ash/test_login_screen_model.h
+++ b/chrome/browser/ui/ash/test_login_screen_model.h
@@ -23,6 +23,12 @@
const ash::UserAvatar& avatar) override;
void NotifyFingerprintAuthResult(const AccountId& account_id,
bool successful) override;
+ void EnableAuthForUser(const AccountId& account_id) override;
+ void DisableAuthForUser(
+ const AccountId& account_id,
+ const ash::AuthDisabledData& auth_disabled_data) override;
+ void EnableTapToUnlockForUser(const AccountId& account_id) override;
+ void ForceOnlineSignInForUser(const AccountId& account_id) override;
void ShowEasyUnlockIcon(const AccountId& user,
const ash::EasyUnlockIconOptions& icon) override;
void UpdateWarningMessage(const base::string16& message) override;