Login code: reformat to latest clang style
clang_format.py -i --sort-includes <directory>/*.cc
Bug: None
Context: https://groups.google.com/a/chromium.org/g/chromium-dev/c/PNRlXycwJTI
Change-Id: I77d262607c05a25fd7e5084401774a28b3ec7407
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4111656
Auto-Submit: Denis Kuznetsov <antrim@chromium.org>
Reviewed-by: Roman Sorokin <rsorokin@google.com>
Commit-Queue: Denis Kuznetsov <antrim@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1086748}
diff --git a/ash/login/login_screen_controller.cc b/ash/login/login_screen_controller.cc
index ce0d477..f112e9a 100644
--- a/ash/login/login_screen_controller.cc
+++ b/ash/login/login_screen_controller.cc
@@ -51,8 +51,9 @@
for (RootWindowController* window_controller :
Shell::GetAllRootWindowControllers()) {
StatusAreaWidget* status_area = window_controller->GetStatusAreaWidget();
- if (!status_area)
+ if (!status_area) {
continue;
+ }
if (window_controller == primary_window_controller) {
status_area->SetSystemTrayVisibility(
visibility == SystemTrayVisibility::kPrimary ||
@@ -131,8 +132,9 @@
LOG(WARNING) << "crbug.com/1339004 : started authentication";
authentication_stage_ = AuthenticationStage::kDoAuthenticate;
- if (authenticated_by_pin)
+ if (authenticated_by_pin) {
DCHECK(base::ContainsOnlyChars(password, "0123456789"));
+ }
client_->AuthenticateUserWithPasswordOrPin(
account_id, password, authenticated_by_pin,
@@ -144,8 +146,9 @@
const AccountId& account_id) {
// TODO(jdufault): integrate this into authenticate stage after mojom is
// refactored to use a callback.
- if (!client_)
+ if (!client_) {
return;
+ }
client_->AuthenticateUserWithEasyUnlock(account_id);
}
@@ -174,8 +177,9 @@
const std::string& code) {
DCHECK(!validation_time.is_null());
- if (!client_)
+ if (!client_) {
return ParentCodeValidationResult::kInternalError;
+ }
return client_->ValidateParentAccessCode(account_id, code, validation_time);
}
@@ -186,89 +190,103 @@
void LoginScreenController::HardlockPod(const AccountId& account_id) {
GetModel()->NotifyFocusPod(account_id);
- if (!client_)
+ if (!client_) {
return;
+ }
client_->HardlockPod(account_id);
}
void LoginScreenController::OnFocusPod(const AccountId& account_id) {
GetModel()->NotifyFocusPod(account_id);
- if (!client_)
+ if (!client_) {
return;
+ }
client_->OnFocusPod(account_id);
}
void LoginScreenController::OnNoPodFocused() {
GetModel()->NotifyFocusPod(EmptyAccountId());
- if (!client_)
+ if (!client_) {
return;
+ }
client_->OnNoPodFocused();
}
void LoginScreenController::LoadWallpaper(const AccountId& account_id) {
- if (!client_)
+ if (!client_) {
return;
+ }
client_->LoadWallpaper(account_id);
}
void LoginScreenController::SignOutUser() {
- if (!client_)
+ if (!client_) {
return;
+ }
client_->SignOutUser();
}
void LoginScreenController::CancelAddUser() {
- if (!client_)
+ if (!client_) {
return;
+ }
client_->CancelAddUser();
}
void LoginScreenController::LoginAsGuest() {
- if (!client_)
+ if (!client_) {
return;
+ }
client_->LoginAsGuest();
}
void LoginScreenController::ShowGuestTosScreen() {
- if (!client_)
+ if (!client_) {
return;
+ }
client_->ShowGuestTosScreen();
}
void LoginScreenController::OnMaxIncorrectPasswordAttempted(
const AccountId& account_id) {
- if (!client_)
+ if (!client_) {
return;
+ }
client_->OnMaxIncorrectPasswordAttempted(account_id);
}
void LoginScreenController::FocusLockScreenApps(bool reverse) {
- if (!client_)
+ if (!client_) {
return;
+ }
client_->FocusLockScreenApps(reverse);
}
void LoginScreenController::ShowGaiaSignin(const AccountId& prefilled_account) {
- if (!client_)
+ if (!client_) {
return;
+ }
client_->ShowGaiaSignin(prefilled_account);
}
void LoginScreenController::ShowOsInstallScreen() {
- if (!client_)
+ if (!client_) {
return;
+ }
client_->ShowOsInstallScreen();
}
void LoginScreenController::OnRemoveUserWarningShown() {
- if (!client_)
+ if (!client_) {
return;
+ }
client_->OnRemoveUserWarningShown();
}
void LoginScreenController::RemoveUser(const AccountId& account_id) {
- if (!client_)
+ if (!client_) {
return;
+ }
client_->RemoveUser(account_id);
}
@@ -276,16 +294,18 @@
const AccountId& account_id,
const std::string& locale,
const std::string& input_method) {
- if (!client_)
+ if (!client_) {
return;
+ }
client_->LaunchPublicSession(account_id, locale, input_method);
}
void LoginScreenController::RequestPublicSessionKeyboardLayouts(
const AccountId& account_id,
const std::string& locale) {
- if (!client_)
+ if (!client_) {
return;
+ }
client_->RequestPublicSessionKeyboardLayouts(account_id, locale);
}
@@ -441,8 +461,9 @@
void LoginScreenController::HandleAccelerator(
ash::LoginAcceleratorAction action) {
- if (!client_)
+ if (!client_) {
return;
+ }
client_->HandleAccelerator(action);
}
@@ -460,14 +481,16 @@
}
void LoginScreenController::FocusOobeDialog() {
- if (!client_)
+ if (!client_) {
return;
+ }
client_->FocusOobeDialog();
}
void LoginScreenController::NotifyUserActivity() {
- if (!client_)
+ if (!client_) {
return;
+ }
client_->OnUserActivity();
}
@@ -498,14 +521,16 @@
}
void LoginScreenController::OnFocusLeavingSystemTray(bool reverse) {
- if (!client_)
+ if (!client_) {
return;
+ }
client_->OnFocusLeavingSystemTray(reverse);
}
void LoginScreenController::OnSystemTrayBubbleShown() {
- if (!client_)
+ if (!client_) {
return;
+ }
client_->OnSystemTrayBubbleShown();
}
@@ -518,8 +543,9 @@
}
void LoginScreenController::NotifyLoginScreenShown() {
- if (!client_)
+ if (!client_) {
return;
+ }
client_->OnLoginScreenShown();
}
diff --git a/ash/login/login_screen_test_api.cc b/ash/login/login_screen_test_api.cc
index 96695383..89adc6d 100644
--- a/ash/login/login_screen_test_api.cc
+++ b/ash/login/login_screen_test_api.cc
@@ -51,8 +51,9 @@
}
LoginShelfView* GetLoginShelfView() {
- if (!Shell::HasInstance())
+ if (!Shell::HasInstance()) {
return nullptr;
+ }
return Shelf::ForWindow(Shell::GetPrimaryRootWindow())
->shelf_widget()
@@ -61,8 +62,9 @@
bool IsLoginShelfViewButtonShown(int button_view_id) {
LoginShelfView* shelf_view = GetLoginShelfView();
- if (!shelf_view)
+ if (!shelf_view) {
return false;
+ }
views::View* button_view = shelf_view->GetViewByID(button_view_id);
@@ -71,8 +73,9 @@
views::View* GetShutDownButton() {
LoginShelfView* shelf_view = GetLoginShelfView();
- if (!shelf_view)
+ if (!shelf_view) {
return nullptr;
+ }
return shelf_view->GetViewByID(LoginShelfView::kShutdown);
}
@@ -86,12 +89,14 @@
bool SimulateButtonPressedForTesting(LoginShelfView::ButtonId button_id) {
LoginShelfView* shelf_view = GetLoginShelfView();
- if (!shelf_view)
+ if (!shelf_view) {
return false;
+ }
views::View* button = shelf_view->GetViewByID(button_id);
- if (!button->GetEnabled())
+ if (!button->GetEnabled()) {
return false;
+ }
views::test::ButtonTestApi(views::Button::AsButton(button))
.NotifyClick(ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::PointF(),
@@ -121,8 +126,9 @@
delete;
~ShelfTestUiUpdateDelegate() override {
- for (PendingCallback& entry : heap_)
+ for (PendingCallback& entry : heap_) {
std::move(entry.callback).Run();
+ }
}
// Returns UI update count.
@@ -180,8 +186,9 @@
// static
void LoginScreenTestApi::AddOnLockScreenShownCallback(
base::OnceClosure on_lock_screen_shown) {
- if (!LockScreen::HasInstance())
+ if (!LockScreen::HasInstance()) {
FAIL() << "No lock screen";
+ }
LockScreen::TestApi lock_screen_test(LockScreen::Get());
lock_screen_test.AddOnShownCallback(std::move(on_lock_screen_shown));
}
@@ -270,8 +277,9 @@
// Check if all views in the hierarchy are visible.
for (views::View* view = lock_contents_test.system_info(); view != nullptr;
view = view->parent()) {
- if (!view->GetVisible())
+ if (!view->GetVisible()) {
return false;
+ }
}
return true;
}
@@ -390,8 +398,9 @@
ASSERT_TRUE(big_user_view);
ASSERT_TRUE(big_user_view->IsAuthEnabled());
LoginAuthUserView::TestApi auth_test(big_user_view->auth_user());
- if (check_if_submittable)
+ if (check_if_submittable) {
ASSERT_TRUE(auth_test.HasAuthMethod(LoginAuthUserView::AUTH_PASSWORD));
+ }
LoginPasswordView::TestApi password_test(auth_test.password_view());
ASSERT_EQ(account_id,
auth_test.user_view()->current_user().basic_user_info.account_id);
@@ -443,13 +452,16 @@
// static
void LoginScreenTestApi::ClickChallengeResponseButton(
const AccountId& account_id) {
- if (!FocusUser(account_id))
+ if (!FocusUser(account_id)) {
FAIL() << "Could not focus on user " << account_id.Serialize();
+ }
LoginBigUserView* big_user_view = GetBigUserView(account_id);
- if (!big_user_view)
+ if (!big_user_view) {
FAIL() << "Could not find user " << account_id.Serialize();
- if (!big_user_view->IsAuthEnabled())
+ }
+ if (!big_user_view->IsAuthEnabled()) {
FAIL() << "Auth is not enabled for user " << account_id.Serialize();
+ }
LoginAuthUserView::TestApi auth_test(big_user_view->auth_user());
if (!auth_test.HasAuthMethod(LoginAuthUserView::AUTH_CHALLENGE_RESPONSE)) {
FAIL() << "Challenge-response auth is not enabled for user "
@@ -524,8 +536,9 @@
login_window =
LoginScreen::Get()->GetLoginWindowWidget()->GetNativeWindow();
}
- if (!login_window)
+ if (!login_window) {
return false;
+ }
return ui_controls::SendKeyPress(
login_window, accelerator.key_code(), accelerator.IsCtrlDown(),
accelerator.IsShiftDown(), accelerator.IsAltDown(),
@@ -586,8 +599,9 @@
LockContentsView::TestApi lock_contents_test(
lock_screen_test.contents_view());
LoginBigUserView* big_user_view = GetBigUserView(account_id);
- if (!big_user_view)
+ if (!big_user_view) {
return false;
+ }
LoginPublicAccountUserView::TestApi public_account_test(
big_user_view->public_account());
if (!public_account_test.arrow_button()->GetVisible()) {
@@ -608,8 +622,9 @@
lock_screen_test.contents_view());
LoginExpandedPublicAccountView* expanded_view =
lock_contents_test.expanded_view();
- if (!expanded_view || !expanded_view->GetVisible())
+ if (!expanded_view || !expanded_view->GetVisible()) {
return false;
+ }
expanded_view->Hide();
return true;
}
@@ -803,8 +818,9 @@
// static
std::u16string LoginScreenTestApi::GetShutDownButtonLabel() {
views::View* button = GetShutDownButton();
- if (!button)
+ if (!button) {
return std::u16string();
+ }
return static_cast<views::LabelButton*>(button)->GetText();
}
@@ -812,8 +828,9 @@
// static
gfx::Rect LoginScreenTestApi::GetShutDownButtonTargetBounds() {
views::View* button = GetShutDownButton();
- if (!button)
+ if (!button) {
return gfx::Rect();
+ }
return button->layer()->GetTargetBounds();
}
@@ -821,8 +838,9 @@
// static
gfx::Rect LoginScreenTestApi::GetShutDownButtonMirroredBounds() {
views::View* button = GetShutDownButton();
- if (!button)
+ if (!button) {
return gfx::Rect();
+ }
return button->GetMirroredBounds();
}
@@ -846,8 +864,9 @@
// static
void LoginScreenTestApi::SubmitPinRequestWidget(const std::string& pin) {
- if (!PinRequestWidget::Get())
+ if (!PinRequestWidget::Get()) {
FAIL() << "No PIN request widget is shown";
+ }
auto event_generator = MakeAshEventGenerator();
PinRequestWidget::TestApi pin_widget_test(PinRequestWidget::Get());
PinRequestView::TestApi pin_test(pin_widget_test.pin_request_view());
@@ -867,8 +886,9 @@
// static
void LoginScreenTestApi::CancelPinRequestWidget() {
- if (!PinRequestWidget::Get())
+ if (!PinRequestWidget::Get()) {
FAIL() << "No PIN request widget is shown";
+ }
auto event_generator = MakeAshEventGenerator();
PinRequestWidget::TestApi pin_widget_test(PinRequestWidget::Get());
PinRequestView::TestApi pin_view_test(pin_widget_test.pin_request_view());
diff --git a/ash/login/security_token_request_controller.cc b/ash/login/security_token_request_controller.cc
index 480c017..1af6ade 100644
--- a/ash/login/security_token_request_controller.cc
+++ b/ash/login/security_token_request_controller.cc
@@ -117,8 +117,9 @@
}
void SecurityTokenRequestController::ClosePinUi() {
- if (!security_token_request_in_progress_)
+ if (!security_token_request_in_progress_) {
return;
+ }
if (PinRequestWidget::Get()) {
PinRequestWidget::Get()->Close(false); // Parameter will be ignored.
diff --git a/ash/login/security_token_request_controller_unittest.cc b/ash/login/security_token_request_controller_unittest.cc
index 08ee509..28cace7 100644
--- a/ash/login/security_token_request_controller_unittest.cc
+++ b/ash/login/security_token_request_controller_unittest.cc
@@ -72,8 +72,9 @@
generator->PressKey(ui::KeyboardCode(ui::KeyboardCode::VKEY_0 + i),
ui::EF_NONE);
}
- if (PinRequestView::TestApi(view_).submit_button()->GetEnabled())
+ if (PinRequestView::TestApi(view_).submit_button()->GetEnabled()) {
SimulateButtonPress(PinRequestView::TestApi(view_).submit_button());
+ }
}
std::unique_ptr<SecurityTokenRequestController> controller_;
diff --git a/ash/login/ui/access_code_input.cc b/ash/login/ui/access_code_input.cc
index 1687603..41ec13351 100644
--- a/ash/login/ui/access_code_input.cc
+++ b/ash/login/ui/access_code_input.cc
@@ -151,20 +151,23 @@
bool FlexCodeInput::HandleKeyEvent(views::Textfield* sender,
const ui::KeyEvent& key_event) {
// Only handle keys.
- if (key_event.type() != ui::ET_KEY_PRESSED)
+ if (key_event.type() != ui::ET_KEY_PRESSED) {
return false;
+ }
// Default handling for events with Alt modifier like spoken feedback.
- if (key_event.IsAltDown())
+ if (key_event.IsAltDown()) {
return false;
+ }
// FlexCodeInput class responds to a limited subset of key press events.
// All events not handled below are sent to |code_field_|.
const ui::KeyboardCode key_code = key_event.key_code();
// Allow using tab for keyboard navigation.
- if (key_code == ui::VKEY_TAB || key_code == ui::VKEY_BACKTAB)
+ if (key_code == ui::VKEY_TAB || key_code == ui::VKEY_BACKTAB) {
return false;
+ }
if (key_code == ui::VKEY_RETURN) {
if (GetCode().has_value()) {
@@ -287,8 +290,9 @@
// focus to the previous field (if exists) and clears input there.
void FixedLengthCodeInput::Backspace() {
// Ignore backspace on the first field, if empty.
- if (IsFirstFieldActive() && ActiveInput().empty())
+ if (IsFirstFieldActive() && ActiveInput().empty()) {
return;
+ }
if (ActiveInput().empty()) {
FocusPreviousField();
@@ -307,8 +311,9 @@
size_t length;
for (auto* field : input_fields_) {
length = field->GetText().length();
- if (!length)
+ if (!length) {
return absl::nullopt;
+ }
DCHECK_EQ(1u, length);
base::StrAppend(&result, {base::UTF16ToUTF8(field->GetText())});
@@ -377,26 +382,31 @@
const gfx::Range& range = GetSelectedRangeOfTextValueForA11y();
node_data->AddIntAttribute(ax::mojom::IntAttribute::kTextSelStart,
range.start());
- if (is_obscure_pin_)
+ if (is_obscure_pin_) {
node_data->AddState(ax::mojom::State::kProtected);
+ }
node_data->AddIntAttribute(ax::mojom::IntAttribute::kTextSelEnd, range.end());
}
bool FixedLengthCodeInput::HandleKeyEvent(views::Textfield* sender,
const ui::KeyEvent& key_event) {
- if (key_event.type() != ui::ET_KEY_PRESSED)
+ if (key_event.type() != ui::ET_KEY_PRESSED) {
return false;
+ }
// Default handling for events with Alt modifier like spoken feedback.
- if (key_event.IsAltDown())
+ if (key_event.IsAltDown()) {
return false;
+ }
// Default handling for events with Control modifier like sign out.
- if (key_event.IsControlDown())
+ if (key_event.IsControlDown()) {
return false;
+ }
- if (sender->GetReadOnly())
+ if (sender->GetReadOnly()) {
return false;
+ }
// FixedLengthCodeInput class responds to limited subset of key press
// events. All key pressed events not handled below are ignored.
@@ -420,8 +430,9 @@
} else if (key_code == ui::VKEY_BACK) {
Backspace();
} else if (key_code == ui::VKEY_RETURN) {
- if (GetCode().has_value())
+ if (GetCode().has_value()) {
on_enter_.Run();
+ }
} else if (key_code == ui::VKEY_ESCAPE) {
on_escape_.Run();
}
@@ -452,8 +463,9 @@
bool FixedLengthCodeInput::HandleGestureEvent(
views::Textfield* sender,
const ui::GestureEvent& gesture_event) {
- if (gesture_event.details().type() != ui::EventType::ET_GESTURE_TAP)
+ if (gesture_event.details().type() != ui::EventType::ET_GESTURE_TAP) {
return false;
+ }
// Move focus to the field that was selected with gesture.
for (size_t i = 0; i < input_fields_.size(); ++i) {
@@ -503,8 +515,9 @@
bool FixedLengthCodeInput::IsEmpty() const {
for (auto* field : input_fields_) {
- if (field->GetText().length())
+ if (field->GetText().length()) {
return false;
+ }
}
return true;
}
@@ -514,16 +527,18 @@
}
void FixedLengthCodeInput::FocusPreviousField() {
- if (active_input_index_ == 0)
+ if (active_input_index_ == 0) {
return;
+ }
--active_input_index_;
ActiveField()->RequestFocus();
}
void FixedLengthCodeInput::FocusNextField() {
- if (IsLastFieldActive())
+ if (IsLastFieldActive()) {
return;
+ }
++active_input_index_;
ActiveField()->RequestFocus();
diff --git a/ash/login/ui/animated_auth_factors_label_wrapper.cc b/ash/login/ui/animated_auth_factors_label_wrapper.cc
index 7b22668..70cf0cf 100644
--- a/ash/login/ui/animated_auth_factors_label_wrapper.cc
+++ b/ash/login/ui/animated_auth_factors_label_wrapper.cc
@@ -134,8 +134,9 @@
// If |previous_text_| is empty, then this is the first time the text is
// being set. Avoid animating because it looks janky to have an animation in
// progress when the lock screen first becomes visible.
- if (!animate || previous_text.empty())
+ if (!animate || previous_text.empty()) {
return;
+ }
// Set the text/transform/opacity of the previous label to match the
// appearance of the current label before the animation.
diff --git a/ash/login/ui/animated_rounded_image_view.cc b/ash/login/ui/animated_rounded_image_view.cc
index 44617dd2..82303f8 100644
--- a/ash/login/ui/animated_rounded_image_view.cc
+++ b/ash/login/ui/animated_rounded_image_view.cc
@@ -85,8 +85,9 @@
}
// Nothing to render.
- if (frames_.empty())
+ if (frames_.empty()) {
return;
+ }
View::OnPaint(canvas);
gfx::Rect image_bounds(GetContentsBounds());
diff --git a/ash/login/ui/arrow_button_view.cc b/ash/login/ui/arrow_button_view.cc
index e2576b9..61eedfe4 100644
--- a/ash/login/ui/arrow_button_view.cc
+++ b/ash/login/ui/arrow_button_view.cc
@@ -118,8 +118,9 @@
views::ImageButton::PaintButtonContents(canvas);
// Draw the arc of the loading animation.
- if (loading_animation_)
+ if (loading_animation_) {
PaintLoadingArc(canvas, rect, loading_animation_->GetCurrentValue());
+ }
}
void ArrowButtonView::OnThemeChanged() {
@@ -172,15 +173,17 @@
void ArrowButtonView::EnableLoadingAnimation(bool enabled) {
if (!enabled) {
- if (!loading_animation_)
+ if (!loading_animation_) {
return;
+ }
loading_animation_.reset();
SchedulePaint();
return;
}
- if (loading_animation_)
+ if (loading_animation_) {
return;
+ }
// Use MultiAnimation in order to have a continuously running analog of
// LinearAnimation.
diff --git a/ash/login/ui/auth_factor_model.cc b/ash/login/ui/auth_factor_model.cc
index 269c4db..e47b0d5 100644
--- a/ash/login/ui/auth_factor_model.cc
+++ b/ash/login/ui/auth_factor_model.cc
@@ -27,15 +27,17 @@
}
void AuthFactorModel::OnThemeChanged() {
- if (icon_)
+ if (icon_) {
UpdateIcon(icon_);
+ }
}
void AuthFactorModel::HandleTapOrClick() {
// If an auth factor icon is clicked while the auth factor has a permanent
// error, then show the error again by marking it as not timed out.
- if (GetAuthFactorState() == AuthFactorState::kErrorPermanent)
+ if (GetAuthFactorState() == AuthFactorState::kErrorPermanent) {
has_permanent_error_display_timed_out_ = false;
+ }
DoHandleTapOrClick();
@@ -47,8 +49,9 @@
}
void AuthFactorModel::HandleErrorTimeout() {
- if (GetAuthFactorState() == AuthFactorState::kErrorPermanent)
+ if (GetAuthFactorState() == AuthFactorState::kErrorPermanent) {
has_permanent_error_display_timed_out_ = true;
+ }
DoHandleErrorTimeout();
diff --git a/ash/login/ui/auth_icon_view.cc b/ash/login/ui/auth_icon_view.cc
index 5149746..b220f760 100644
--- a/ash/login/ui/auth_icon_view.cc
+++ b/ash/login/ui/auth_icon_view.cc
@@ -197,8 +197,9 @@
void AuthIconView::StartProgressAnimation() {
// Progress animation already running.
- if (progress_animation_timer_.IsRunning())
+ if (progress_animation_timer_.IsRunning()) {
return;
+ }
progress_animation_start_time_ = base::TimeTicks::Now();
progress_animation_timer_.Start(
@@ -210,8 +211,9 @@
void AuthIconView::StopProgressAnimation() {
// Progress already stopped.
- if (!progress_animation_timer_.IsRunning())
+ if (!progress_animation_timer_.IsRunning()) {
return;
+ }
progress_animation_timer_.Stop();
SchedulePaint();
@@ -242,8 +244,9 @@
void AuthIconView::OnGestureEvent(ui::GestureEvent* event) {
if (event->type() != ui::ET_GESTURE_TAP &&
- event->type() != ui::ET_GESTURE_TAP_DOWN)
+ event->type() != ui::ET_GESTURE_TAP_DOWN) {
return;
+ }
if (on_tap_or_click_callback_) {
on_tap_or_click_callback_.Run();
diff --git a/ash/login/ui/fake_login_detachable_base_model.cc b/ash/login/ui/fake_login_detachable_base_model.cc
index 08489fe..85deef72 100644
--- a/ash/login/ui/fake_login_detachable_base_model.cc
+++ b/ash/login/ui/fake_login_detachable_base_model.cc
@@ -25,8 +25,9 @@
std::string FakeLoginDetachableBaseModel::GetLastUsedBase(
const AccountId& account_id) {
auto it = last_used_bases_.find(account_id);
- if (it == last_used_bases_.end())
+ if (it == last_used_bases_.end()) {
return "";
+ }
return it->second;
}
@@ -55,8 +56,9 @@
bool FakeLoginDetachableBaseModel::SetPairedBaseAsLastUsedByUser(
const UserInfo& user_info) {
- if (current_authenticated_base_.empty())
+ if (current_authenticated_base_.empty()) {
return false;
+ }
last_used_bases_[user_info.account_id] = current_authenticated_base_;
return true;
diff --git a/ash/login/ui/fingerprint_auth_factor_model.cc b/ash/login/ui/fingerprint_auth_factor_model.cc
index 52d02e2..2d70ff9 100644
--- a/ash/login/ui/fingerprint_auth_factor_model.cc
+++ b/ash/login/ui/fingerprint_auth_factor_model.cc
@@ -30,8 +30,9 @@
// static
std::unique_ptr<FingerprintAuthFactorModel>
FingerprintAuthFactorModel::Factory::Create(FingerprintState state) {
- if (factory_instance_)
+ if (factory_instance_) {
return factory_instance_->CreateInstance(state);
+ }
return std::make_unique<FingerprintAuthFactorModel>(state);
}
@@ -47,8 +48,9 @@
FingerprintAuthFactorModel::~FingerprintAuthFactorModel() = default;
void FingerprintAuthFactorModel::SetFingerprintState(FingerprintState state) {
- if (state_ == state)
+ if (state_ == state) {
return;
+ }
// Clear out the timeout if the state changes. This shouldn't happen
// ordinarily -- permanent error states are permanent after all -- but this is
@@ -71,8 +73,9 @@
AuthFactorModel::AuthFactorState
FingerprintAuthFactorModel::GetAuthFactorState() const {
- if (!available_)
+ if (!available_) {
return AuthFactorState::kUnavailable;
+ }
if (auth_result_.has_value()) {
if (auth_result_.value()) {
@@ -132,8 +135,9 @@
}
int FingerprintAuthFactorModel::GetAccessibleNameId() const {
- if (state_ == FingerprintState::DISABLED_FROM_ATTEMPTS)
+ if (state_ == FingerprintState::DISABLED_FROM_ATTEMPTS) {
return IDS_ASH_LOGIN_FINGERPRINT_UNLOCK_ACCESSIBLE_AUTH_DISABLED_FROM_ATTEMPTS;
+ }
return GetLabelId();
}
diff --git a/ash/login/ui/hover_notifier.cc b/ash/login/ui/hover_notifier.cc
index 41e2fc9..504bce0 100644
--- a/ash/login/ui/hover_notifier.cc
+++ b/ash/login/ui/hover_notifier.cc
@@ -20,8 +20,9 @@
void HoverNotifier::OnEvent(ui::Event* event) {
bool has_hover = target_view_->IsMouseHovered();
- if (has_hover == had_hover_)
+ if (has_hover == had_hover_) {
return;
+ }
had_hover_ = has_hover;
on_hover_.Run(has_hover);
diff --git a/ash/login/ui/lock_contents_view.cc b/ash/login/ui/lock_contents_view.cc
index a93506c..06fc3ffb 100644
--- a/ash/login/ui/lock_contents_view.cc
+++ b/ash/login/ui/lock_contents_view.cc
@@ -220,8 +220,9 @@
auto add_style = [&](const views::StyledLabel::RangeStyleInfo& style,
int start, int end) {
- if (start >= end)
+ if (start >= end) {
return;
+ }
label->AddStyleRange(gfx::Range(start, end), style);
};
@@ -243,8 +244,9 @@
keyboard::KeyboardUIController* GetKeyboardControllerForWidget(
const views::Widget* widget) {
auto* keyboard_ui_controller = keyboard::KeyboardUIController::Get();
- if (!keyboard_ui_controller->IsEnabled())
+ if (!keyboard_ui_controller->IsEnabled()) {
return nullptr;
+ }
aura::Window* keyboard_window = keyboard_ui_controller->GetRootWindow();
aura::Window* this_window = widget->GetNativeWindow()->GetRootWindow();
@@ -288,8 +290,9 @@
int right_max_fixed_width,
int right_flex_weight) {
// No space to distribute.
- if (width <= 0)
+ if (width <= 0) {
return;
+ }
auto set_values_from_weight = [](int width, float weight_a, float weight_b,
int* value_a, int* value_b) {
@@ -540,8 +543,9 @@
const AccountId& account_id) {
LoginBigUserView* big_view =
view_->TryToFindBigUser(account_id, false /*require_auth_active*/);
- if (big_view)
+ if (big_view) {
return big_view;
+ }
LoginUserView* user_view = view_->TryToFindUserView(account_id);
if (!user_view) {
DLOG(ERROR) << "Could not find user: " << account_id.Serialize();
@@ -564,10 +568,12 @@
bool LockContentsView::TestApi::RemoveUser(const AccountId& account_id) {
LoginBigUserView* big_view = FindBigUser(account_id);
- if (!big_view)
+ if (!big_view) {
return false;
- if (!big_view->GetCurrentUser().can_remove)
+ }
+ if (!big_view->GetCurrentUser().can_remove) {
return false;
+ }
LoginBigUserView::TestApi user_api(big_view);
user_api.Remove();
return true;
@@ -588,8 +594,9 @@
: account_id(user_info.basic_user_info.account_id) {
fingerprint_state = user_info.fingerprint_state;
smart_lock_state = user_info.smart_lock_state;
- if (user_info.auth_type == proximity_auth::mojom::AuthType::ONLINE_SIGN_IN)
+ if (user_info.auth_type == proximity_auth::mojom::AuthType::ONLINE_SIGN_IN) {
force_online_sign_in = true;
+ }
show_pin_pad_for_password = user_info.show_pin_pad_for_password;
disable_auth = !user_info.is_multiprofile_allowed &&
Shell::Get()->session_controller()->GetSessionState() ==
@@ -612,9 +619,10 @@
screen_type_(screen_type),
data_dispatcher_(data_dispatcher),
detachable_base_model_(std::move(detachable_base_model)) {
- if (screen_type == LockScreen::ScreenType::kLogin)
+ if (screen_type == LockScreen::ScreenType::kLogin) {
auto_login_user_activity_handler_ =
std::make_unique<AutoLoginUserActivityHandler>();
+ }
data_dispatcher_->AddObserver(this);
Shell::Get()->system_tray_notifier()->AddSystemTrayObserver(this);
@@ -665,8 +673,9 @@
->system_tray_model()
->enterprise_domain()
->enterprise_domain_manager();
- if (!enterprise_domain_manager.empty())
+ if (!enterprise_domain_manager.empty()) {
ShowEnterpriseDomainManager(enterprise_domain_manager);
+ }
note_action_ = top_header_->AddChildView(
std::make_unique<NoteActionLaunchButton>(initial_note_action_state));
@@ -738,8 +747,9 @@
}
void LockContentsView::FocusNextUser() {
- if (users_.empty())
+ if (users_.empty()) {
return;
+ }
if (login_views_utils::HasFocusInAnyChildView(primary_big_view_)) {
if (opt_secondary_big_view_) {
@@ -761,8 +771,9 @@
if (users_list_) {
for (int i = 0; i < users_list_->user_count(); ++i) {
LoginUserView* user_view = users_list_->user_view_at(i);
- if (!login_views_utils::HasFocusInAnyChildView(user_view))
+ if (!login_views_utils::HasFocusInAnyChildView(user_view)) {
continue;
+ }
if (i == users_list_->user_count() - 1) {
SwapActiveAuthBetweenPrimaryAndSecondary(true /*is_primary*/);
@@ -777,8 +788,9 @@
}
void LockContentsView::FocusPreviousUser() {
- if (users_.empty())
+ if (users_.empty()) {
return;
+ }
if (login_views_utils::HasFocusInAnyChildView(primary_big_view_)) {
if (users_list_) {
@@ -800,8 +812,9 @@
if (users_list_) {
for (int i = 0; i < users_list_->user_count(); ++i) {
LoginUserView* user_view = users_list_->user_view_at(i);
- if (!login_views_utils::HasFocusInAnyChildView(user_view))
+ if (!login_views_utils::HasFocusInAnyChildView(user_view)) {
continue;
+ }
if (i == 0) {
SwapActiveAuthBetweenPrimaryAndSecondary(true /*is_primary*/);
@@ -876,16 +889,18 @@
LayoutUserAddingScreenIndicator();
LayoutPublicSessionView();
- if (users_list_)
+ if (users_list_) {
users_list_->Layout();
+ }
}
void LockContentsView::AddedToWidget() {
DoLayout();
// Focus the primary user when showing the UI. This will focus the password.
- if (primary_big_view_)
+ if (primary_big_view_) {
primary_big_view_->RequestFocus();
+ }
}
void LockContentsView::OnFocus() {
@@ -893,8 +908,9 @@
// under typical circumstances), immediately forward the focus to the
// primary_big_view_ since LockContentsView has no real focusable content by
// itself.
- if (primary_big_view_)
+ if (primary_big_view_) {
primary_big_view_->RequestFocus();
+ }
}
void LockContentsView::AboutToRequestFocusFromTabTraversal(bool reverse) {
@@ -923,8 +939,9 @@
bool LockContentsView::AcceleratorPressed(const ui::Accelerator& accelerator) {
auto entry = accel_map_.find(accelerator);
- if (entry == accel_map_.end())
+ if (entry == accel_map_.end()) {
return false;
+ }
PerformAction(entry->second);
return true;
@@ -957,10 +974,11 @@
std::vector<UserState> new_users;
for (const LoginUserInfo& user : users) {
UserState* old_state = FindStateForUser(user.basic_user_info.account_id);
- if (old_state)
+ if (old_state) {
new_users.push_back(std::move(*old_state));
- else
+ } else {
new_users.push_back(UserState(user));
+ }
}
users_ = std::move(new_users);
@@ -974,8 +992,9 @@
main_layout->set_cross_axis_alignment(
views::BoxLayout::CrossAxisAlignment::kCenter);
- if (kiosk_license_mode_)
+ if (kiosk_license_mode_) {
return;
+ }
// If there are no users, show GAIA signin if login.
if (users.empty() && screen_type_ == LockScreen::ScreenType::kLogin) {
@@ -996,12 +1015,13 @@
AllocateLoginBigUserView(users[0], true /*is_primary*/);
// Build layout for additional users.
- if (users.size() <= 2)
+ if (users.size() <= 2) {
CreateLowDensityLayout(users, std::move(primary_big_view));
- else if (users.size() >= 3 && users.size() <= 6)
+ } else if (users.size() >= 3 && users.size() <= 6) {
CreateMediumDensityLayout(users, std::move(primary_big_view));
- else if (users.size() >= 7)
+ } else if (users.size() >= 7) {
CreateHighDensityLayout(users, main_layout, std::move(primary_big_view));
+ }
// |primary_big_view_| must have been set by one of the above functions.
DCHECK(primary_big_view_);
@@ -1018,8 +1038,9 @@
// If one of the child views had focus before we deleted them, then this view
// will get focused. Move focus back to the primary big view.
- if (primary_big_view_ && HasFocus())
+ if (primary_big_view_ && HasFocus()) {
primary_big_view_->RequestFocus();
+ }
}
void LockContentsView::OnUserAvatarChanged(const AccountId& account_id,
@@ -1060,8 +1081,9 @@
LoginBigUserView* big_user =
TryToFindBigUser(user, true /*require_auth_active*/);
- if (big_user && big_user->auth_user())
+ if (big_user && big_user->auth_user()) {
LayoutAuth(big_user, nullptr /*opt_to_hide*/, true /*animate*/);
+ }
}
void LockContentsView::OnChallengeResponseAuthEnabledForUserChanged(
@@ -1079,21 +1101,24 @@
LoginBigUserView* big_user =
TryToFindBigUser(user, /*require_auth_active=*/true);
- if (big_user && big_user->auth_user())
+ if (big_user && big_user->auth_user()) {
LayoutAuth(big_user, /*opt_to_hide=*/nullptr, /*animate=*/true);
+ }
}
void LockContentsView::OnFingerprintStateChanged(const AccountId& account_id,
FingerprintState state) {
UserState* user_state = FindStateForUser(account_id);
- if (!user_state)
+ if (!user_state) {
return;
+ }
user_state->fingerprint_state = state;
LoginBigUserView* big_view =
TryToFindBigUser(account_id, true /*require_auth_active*/);
- if (!big_view || !big_view->auth_user())
+ if (!big_view || !big_view->auth_user()) {
return;
+ }
big_view->auth_user()->SetFingerprintState(user_state->fingerprint_state);
LayoutAuth(big_view, nullptr /*opt_to_hide*/, true /*animate*/);
@@ -1101,13 +1126,15 @@
void LockContentsView::OnResetFingerprintUIState(const AccountId& account_id) {
UserState* user_state = FindStateForUser(account_id);
- if (!user_state)
+ if (!user_state) {
return;
+ }
LoginBigUserView* big_view =
TryToFindBigUser(account_id, true /*require_auth_active*/);
- if (!big_view || !big_view->auth_user())
+ if (!big_view || !big_view->auth_user()) {
return;
+ }
big_view->auth_user()->ResetFingerprintUIState();
LayoutAuth(big_view, nullptr /*opt_to_hide*/, true /*animate*/);
@@ -1126,8 +1153,9 @@
// associated account is no longer a big user.
LoginBigUserView* big_view =
TryToFindBigUser(account_id, true /*require_auth_active*/);
- if (!big_view || !big_view->auth_user())
+ if (!big_view || !big_view->auth_user()) {
return;
+ }
big_view->auth_user()->NotifyFingerprintAuthResult(success);
}
@@ -1135,14 +1163,16 @@
void LockContentsView::OnSmartLockStateChanged(const AccountId& account_id,
SmartLockState state) {
UserState* user_state = FindStateForUser(account_id);
- if (!user_state)
+ if (!user_state) {
return;
+ }
user_state->smart_lock_state = state;
LoginBigUserView* big_view =
TryToFindBigUser(account_id, true /*require_auth_active*/);
- if (!big_view || !big_view->auth_user())
+ if (!big_view || !big_view->auth_user()) {
return;
+ }
big_view->auth_user()->SetSmartLockState(state);
LayoutAuth(big_view, /*opt_to_hide=*/nullptr, /*animate=*/true);
@@ -1152,8 +1182,9 @@
bool success) {
LoginBigUserView* big_view =
TryToFindBigUser(account_id, true /*require_auth_active*/);
- if (!big_view || !big_view->auth_user())
+ if (!big_view || !big_view->auth_user()) {
return;
+ }
big_view->auth_user()->NotifySmartLockAuthResult(success);
LayoutAuth(big_view, /*opt_to_hide=*/nullptr, /*animate=*/true);
@@ -1163,13 +1194,15 @@
const AccountId& account_id,
bool auth_factor_is_hiding_password) {
UserState* user_state = FindStateForUser(account_id);
- if (!user_state)
+ if (!user_state) {
return;
+ }
user_state->auth_factor_is_hiding_password = auth_factor_is_hiding_password;
- if (auth_factor_is_hiding_password)
+ if (auth_factor_is_hiding_password) {
HideAuthErrorMessage();
+ }
// Do not call LayoutAuth() here. This event is triggered by
// OnSmartLockStateChanged, which calls LayoutAuth(). Calling LayoutAuth() a
@@ -1190,8 +1223,9 @@
LoginBigUserView* big_user =
TryToFindBigUser(user, true /*require_auth_active*/);
- if (big_user && big_user->auth_user())
+ if (big_user && big_user->auth_user()) {
LayoutAuth(big_user, nullptr /*opt_to_hide*/, true /*animate*/);
+ }
}
void LockContentsView::OnAuthDisabledForUser(
@@ -1241,8 +1275,9 @@
void LockContentsView::OnTapToUnlockEnabledForUserChanged(const AccountId& user,
bool enabled) {
- if (base::FeatureList::IsEnabled(ash::features::kSmartLockUIRevamp))
+ if (base::FeatureList::IsEnabled(ash::features::kSmartLockUIRevamp)) {
return;
+ }
LockContentsView::UserState* state = FindStateForUser(user);
if (!state) {
@@ -1253,8 +1288,9 @@
LoginBigUserView* big_user =
TryToFindBigUser(user, true /*require_auth_active*/);
- if (big_user && big_user->auth_user())
+ if (big_user && big_user->auth_user()) {
LayoutAuth(big_user, nullptr /*opt_to_hide*/, true /*animate*/);
+ }
}
void LockContentsView::OnForceOnlineSignInForUser(const AccountId& user) {
@@ -1267,19 +1303,22 @@
LoginBigUserView* big_user =
TryToFindBigUser(user, true /*require_auth_active*/);
- if (big_user && big_user->auth_user())
+ if (big_user && big_user->auth_user()) {
LayoutAuth(big_user, nullptr /*opt_to_hide*/, true /*animate*/);
+ }
}
void LockContentsView::OnShowEasyUnlockIcon(
const AccountId& user,
const EasyUnlockIconInfo& icon_info) {
- if (base::FeatureList::IsEnabled(ash::features::kSmartLockUIRevamp))
+ if (base::FeatureList::IsEnabled(ash::features::kSmartLockUIRevamp)) {
return;
+ }
UserState* state = FindStateForUser(user);
- if (!state)
+ if (!state) {
return;
+ }
state->easy_unlock_icon_info = icon_info;
UpdateEasyUnlockIconForUser(user);
@@ -1287,11 +1326,13 @@
// Show tooltip only if the user is actively showing auth.
LoginBigUserView* big_user =
TryToFindBigUser(user, true /*require_auth_active*/);
- if (!big_user || !big_user->auth_user())
+ if (!big_user || !big_user->auth_user()) {
return;
+ }
- if (tooltip_bubble_->GetVisible())
+ if (tooltip_bubble_->GetVisible()) {
tooltip_bubble_->Hide();
+ }
if (icon_info.autoshow_tooltip) {
tooltip_bubble_->SetAnchorView(big_user->auth_user()->GetActiveInputView());
@@ -1303,8 +1344,9 @@
void LockContentsView::OnWarningMessageUpdated(const std::u16string& message) {
if (message.empty()) {
- if (warning_banner_bubble_->GetVisible())
+ if (warning_banner_bubble_->GetVisible()) {
warning_banner_bubble_->Hide();
+ }
return;
}
@@ -1314,8 +1356,9 @@
return;
}
- if (warning_banner_bubble_->GetVisible())
+ if (warning_banner_bubble_->GetVisible()) {
warning_banner_bubble_->Hide();
+ }
// Shows warning banner as a persistent error bubble.
warning_banner_bubble_->SetAnchorView(
CurrentBigUserView()->auth_user()->GetActiveInputView());
@@ -1325,8 +1368,9 @@
void LockContentsView::OnLockScreenNoteStateChanged(
mojom::TrayActionState state) {
- if (disable_lock_screen_note_)
+ if (disable_lock_screen_note_) {
state = mojom::TrayActionState::kNotAvailable;
+ }
bool old_lock_screen_apps_active = lock_screen_apps_active_;
lock_screen_apps_active_ = state == mojom::TrayActionState::kActive;
@@ -1360,8 +1404,9 @@
// Initialize the system info view.
if (system_info_->children().empty()) {
- for (int i = 0; i < 3; ++i)
+ for (int i = 0; i < 3; ++i) {
system_info_->AddChildView(create_info_label());
+ }
UpdateSystemInfoColors();
}
@@ -1390,8 +1435,9 @@
// TODO(crbug.com/1141348): Separate ADB sideloading from system info changed.
// Note that if ADB is enabled and the device is enrolled, only the ADB
// warning message will be displayed.
- if (adb_sideloading_enabled)
+ if (adb_sideloading_enabled) {
ShowAdbEnabled();
+ }
LayoutBottomStatusIndicator();
}
@@ -1400,8 +1446,9 @@
const AccountId& account_id,
const std::string& display_name) {
LoginUserView* user_view = TryToFindUserView(account_id);
- if (!user_view || !IsPublicAccountUser(user_view->current_user()))
+ if (!user_view || !IsPublicAccountUser(user_view->current_user())) {
return;
+ }
LoginUserInfo user_info = user_view->current_user();
user_info.basic_user_info.display_name = display_name;
@@ -1415,8 +1462,9 @@
const std::string& default_locale,
bool show_advanced_view) {
LoginUserView* user_view = TryToFindUserView(account_id);
- if (!user_view || !IsPublicAccountUser(user_view->current_user()))
+ if (!user_view || !IsPublicAccountUser(user_view->current_user())) {
return;
+ }
LoginUserInfo user_info = user_view->current_user();
user_info.public_account_info->available_locales = locales;
@@ -1465,8 +1513,9 @@
(pairing_status == DetachableBasePairingStatus::kAuthenticated &&
detachable_base_model_->PairedBaseMatchesLastUsedByUser(
CurrentBigUserView()->GetCurrentUser().basic_user_info))) {
- if (detachable_base_error_bubble_->GetVisible())
+ if (detachable_base_error_bubble_->GetVisible()) {
detachable_base_error_bubble_->Hide();
+ }
return;
}
@@ -1482,15 +1531,17 @@
// Remove the focus from the password field, to make user less likely to enter
// the password without seeing the warning about detachable base change.
- if (GetWidget()->IsActive())
+ if (GetWidget()->IsActive()) {
GetWidget()->GetFocusManager()->ClearFocus();
+ }
}
void LockContentsView::OnFocusLeavingLockScreenApps(bool reverse) {
- if (!reverse || lock_screen_apps_active_)
+ if (!reverse || lock_screen_apps_active_) {
FocusNextWidget(reverse);
- else
+ } else {
FocusFirstOrLastFocusableChild(this, reverse);
+ }
}
void LockContentsView::OnOobeDialogStateChanged(OobeDialogState state) {
@@ -1506,8 +1557,9 @@
oobe_dialog_closed || state == OobeDialogState::EXTENSION_LOGIN_CLOSED;
// Show either oobe dialog or user pods.
- if (main_view_)
+ if (main_view_) {
main_view_->SetVisible(main_dialog_closed);
+ }
GetWidget()->widget_delegate()->SetCanActivate(main_dialog_closed);
UpdateBottomStatusIndicatorVisibility();
@@ -1550,8 +1602,9 @@
return;
}
- if (oobe_dialog_visible_)
+ if (oobe_dialog_visible_) {
Shell::Get()->login_screen_controller()->FocusOobeDialog();
+ }
}
void LockContentsView::OnDisplayMetricsChanged(const display::Display& display,
@@ -1560,8 +1613,9 @@
uint32_t filter = DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_WORK_AREA |
DISPLAY_METRIC_DEVICE_SCALE_FACTOR |
DISPLAY_METRIC_ROTATION | DISPLAY_METRIC_PRIMARY;
- if ((filter & changed_metrics) == 0)
+ if ((filter & changed_metrics) == 0) {
return;
+ }
DoLayout();
@@ -1573,26 +1627,30 @@
}
void LockContentsView::OnKeyboardVisibilityChanged(bool is_visible) {
- if (!primary_big_view_ || keyboard_shown_ == is_visible)
+ if (!primary_big_view_ || keyboard_shown_ == is_visible) {
return;
+ }
keyboard_shown_ = is_visible;
- if (!ongoing_auth_layout_)
+ if (!ongoing_auth_layout_) {
LayoutAuth(CurrentBigUserView(), nullptr /*opt_to_hide*/, true /*animate*/);
+ }
}
void LockContentsView::SuspendImminent(
power_manager::SuspendImminent::Reason reason) {
LoginBigUserView* big_user = CurrentBigUserView();
- if (big_user && big_user->auth_user())
+ if (big_user && big_user->auth_user()) {
big_user->auth_user()->password_view()->Reset();
+ }
}
void LockContentsView::OnDeviceEnterpriseInfoChanged() {
// If feature is enabled, update the boolean kiosk_license_mode_. Otherwise,
// it's false by default.
- if (!features::IsKioskLoginScreenEnabled())
+ if (!features::IsKioskLoginScreenEnabled()) {
return;
+ }
kiosk_license_mode_ =
Shell::Get()
@@ -1606,8 +1664,9 @@
void LockContentsView::OnEnterpriseAccountDomainChanged() {}
void LockContentsView::ShowAuthErrorMessageForDebug(int unlock_attempt) {
- if (!CurrentBigUserView())
+ if (!CurrentBigUserView()) {
return;
+ }
AccountId account_id =
CurrentBigUserView()->GetCurrentUser().basic_user_info.account_id;
unlock_attempt_by_user_[account_id] = unlock_attempt;
@@ -1617,10 +1676,11 @@
void LockContentsView::ToggleManagementForUserForDebug(const AccountId& user) {
auto replace = [](const LoginUserInfo& user_info) {
auto changed = user_info;
- if (user_info.user_account_manager)
+ if (user_info.user_account_manager) {
changed.user_account_manager.reset();
- else
+ } else {
changed.user_account_manager = "example@example.com";
+ }
return changed;
};
@@ -1676,8 +1736,9 @@
LoginBigUserView* big_user =
TryToFindBigUser(user, true /*require_auth_active*/);
- if (big_user && big_user->auth_user())
+ if (big_user && big_user->auth_user()) {
LayoutAuth(big_user, nullptr /*opt_to_hide*/, true /*animate*/);
+ }
}
void LockContentsView::UndoForceOnlineSignInForUserForDebug(
@@ -1691,8 +1752,9 @@
LoginBigUserView* big_user =
TryToFindBigUser(user, true /*require_auth_active*/);
- if (big_user && big_user->auth_user())
+ if (big_user && big_user->auth_user()) {
LayoutAuth(big_user, nullptr /*opt_to_hide*/, true /*animate*/);
+ }
}
void LockContentsView::FocusNextWidget(bool reverse) {
@@ -1743,10 +1805,11 @@
}
int desired_width;
- if (!landscape || total_width <= kMediaControlsSpacingThreshold)
+ if (!landscape || total_width <= kMediaControlsSpacingThreshold) {
desired_width = available_width / kMediaControlsSmallSpaceFactor;
- else
+ } else {
desired_width = available_width / kMediaControlsLargeSpaceFactor;
+ }
SetPreferredWidthForView(middle_spacing_view_, desired_width);
}
@@ -1948,8 +2011,9 @@
SetPreferredSize(preferred_size);
bool landscape = login_views_utils::ShouldShowLandscape(GetWidget());
- for (auto& action : layout_actions_)
+ for (auto& action : layout_actions_) {
action.Run(landscape);
+ }
// SizeToPreferredSize will call Layout().
SizeToPreferredSize();
@@ -1982,18 +2046,21 @@
// If the management bubble is currently displayed, we need to re-layout it as
// the bottom status indicator is its anchor view.
- if (management_bubble_->GetVisible())
+ if (management_bubble_->GetVisible()) {
management_bubble_->Layout();
+ }
}
void LockContentsView::LayoutUserAddingScreenIndicator() {
if (Shell::Get()->session_controller()->GetSessionState() !=
- session_manager::SessionState::LOGIN_SECONDARY)
+ session_manager::SessionState::LOGIN_SECONDARY) {
return;
+ }
// The primary big view may not be ready yet.
- if (!primary_big_view_)
+ if (!primary_big_view_) {
return;
+ }
user_adding_screen_indicator_->SizeToPreferredSize();
// The element is placed at the middle of the screen horizontally. It is
@@ -2032,8 +2099,9 @@
void LockContentsView::SwapActiveAuthBetweenPrimaryAndSecondary(
bool is_primary) {
// Do not allow user-swap during authentication.
- if (Shell::Get()->login_screen_controller()->IsAuthenticating())
+ if (Shell::Get()->login_screen_controller()->IsAuthenticating()) {
return;
+ }
if (is_primary) {
if (!primary_big_view_->IsAuthEnabled()) {
@@ -2060,8 +2128,9 @@
if (auth_success) {
HideAuthErrorMessage();
- if (detachable_base_error_bubble_->GetVisible())
+ if (detachable_base_error_bubble_->GetVisible()) {
detachable_base_error_bubble_->Hide();
+ }
// Now that the user has been authenticated, update the user's last used
// detachable base (if one is attached). This will prevent further
@@ -2079,18 +2148,21 @@
true /*success*/, &unlock_attempt_by_user_[account_id]);
} else {
++unlock_attempt_by_user_[account_id];
- if (authenticated_by_pin)
+ if (authenticated_by_pin) {
++pin_unlock_attempt_by_user_[account_id];
- if (display_error_messages)
+ }
+ if (display_error_messages) {
ShowAuthErrorMessage();
+ }
}
}
LockContentsView::UserState* LockContentsView::FindStateForUser(
const AccountId& user) {
for (UserState& state : users_) {
- if (state.account_id == user)
+ if (state.account_id == user) {
return &state;
+ }
}
return nullptr;
@@ -2102,10 +2174,12 @@
DCHECK(to_update);
auto capture_animation_state_pre_layout = [&](LoginBigUserView* view) {
- if (!view)
+ if (!view) {
return;
- if (view->auth_user())
+ }
+ if (view->auth_user()) {
view->auth_user()->CaptureStateForAnimationPreLayout();
+ }
};
auto enable_auth = [&](LoginBigUserView* view) {
@@ -2138,12 +2212,15 @@
GetKeyboardControllerForView() ? keyboard_shown_ : false;
auth_metadata.show_pinpad_for_pw = state->show_pin_pad_for_password;
auth_metadata.autosubmit_pin_length = state->autosubmit_pin_length;
- if (state->show_pin)
+ if (state->show_pin) {
to_update_auth |= LoginAuthUserView::AUTH_PIN;
- if (state->enable_tap_auth)
+ }
+ if (state->enable_tap_auth) {
to_update_auth |= LoginAuthUserView::AUTH_TAP;
- if (state->fingerprint_state != FingerprintState::UNAVAILABLE)
+ }
+ if (state->fingerprint_state != FingerprintState::UNAVAILABLE) {
to_update_auth |= LoginAuthUserView::AUTH_FINGERPRINT;
+ }
if (state->smart_lock_state != SmartLockState::kDisabled &&
state->smart_lock_state != SmartLockState::kInactive) {
to_update_auth |= LoginAuthUserView::AUTH_SMART_LOCK;
@@ -2165,8 +2242,9 @@
};
auto disable_auth = [&](LoginBigUserView* view) {
- if (!view)
+ if (!view) {
return;
+ }
if (view->auth_user()) {
view->auth_user()->SetAuthMethods(LoginAuthUserView::AUTH_NONE);
} else if (view->public_account()) {
@@ -2175,10 +2253,12 @@
};
auto apply_animation_post_layout = [&](LoginBigUserView* view) {
- if (!view)
+ if (!view) {
return;
- if (view->auth_user())
+ }
+ if (view->auth_user()) {
view->auth_user()->ApplyAnimationPostLayout(animate);
+ }
};
ongoing_auth_layout_ = true;
@@ -2195,8 +2275,9 @@
void LockContentsView::SwapToBigUser(int user_index) {
// Do not allow user-swap during authentication.
- if (Shell::Get()->login_screen_controller()->IsAuthenticating())
+ if (Shell::Get()->login_screen_controller()->IsAuthenticating()) {
return;
+ }
DCHECK(users_list_);
LoginUserView* view = users_list_->user_view_at(user_index);
@@ -2217,8 +2298,9 @@
void LockContentsView::RemoveUser(bool is_primary) {
// Do not allow removing a user during authentication, such as if the user
// tried to remove the currently authenticating user.
- if (Shell::Get()->login_screen_controller()->IsAuthenticating())
+ if (Shell::Get()->login_screen_controller()->IsAuthenticating()) {
return;
+ }
LoginBigUserView* to_remove =
is_primary ? primary_big_view_ : opt_secondary_big_view_;
@@ -2246,8 +2328,9 @@
OnDetachableBasePairingStatusChanged(
detachable_base_model_->GetPairingStatus());
- if (!detachable_base_error_bubble_->GetVisible())
+ if (!detachable_base_error_bubble_->GetVisible()) {
CurrentBigUserView()->RequestFocus();
+ }
}
void LockContentsView::UpdateEasyUnlockIconForUser(const AccountId& user) {
@@ -2255,8 +2338,9 @@
// update.
LoginBigUserView* big_view =
TryToFindBigUser(user, false /*require_auth_active*/);
- if (!big_view || !big_view->auth_user())
+ if (!big_view || !big_view->auth_user()) {
return;
+ }
UserState* state = FindStateForUser(user);
DCHECK(state);
@@ -2271,8 +2355,9 @@
// TODO(jdufault): Make easy unlock backend always send aria_label, right now
// it is only sent if there is no tooltip.
std::u16string accessibility_label = state->easy_unlock_icon_info->aria_label;
- if (accessibility_label.empty())
+ if (accessibility_label.empty()) {
accessibility_label = state->easy_unlock_icon_info->tooltip;
+ }
big_view->auth_user()->SetEasyUnlockIcon(
state->easy_unlock_icon_info->icon_state, accessibility_label);
@@ -2289,8 +2374,9 @@
void LockContentsView::ShowAuthErrorMessage() {
LoginBigUserView* big_view = CurrentBigUserView();
- if (!big_view->auth_user())
+ if (!big_view->auth_user()) {
return;
+ }
const AccountId account_id =
big_view->GetCurrentUser().basic_user_info.account_id;
@@ -2385,14 +2471,16 @@
}
void LockContentsView::HideAuthErrorMessage() {
- if (auth_error_bubble_->GetVisible())
+ if (auth_error_bubble_->GetVisible()) {
auth_error_bubble_->Hide();
+ }
}
void LockContentsView::OnEasyUnlockIconHovered() {
LoginBigUserView* big_view = CurrentBigUserView();
- if (!big_view->auth_user())
+ if (!big_view->auth_user()) {
return;
+ }
UserState* state =
FindStateForUser(big_view->GetCurrentUser().basic_user_info.account_id);
@@ -2540,8 +2628,9 @@
}
// Make sure auth instance is active if required.
- if (require_auth_active && view && !view->IsAuthEnabled())
+ if (require_auth_active && view && !view->IsAuthEnabled()) {
view = nullptr;
+ }
return view;
}
@@ -2550,12 +2639,14 @@
// Try to find |user| in big user view first.
LoginBigUserView* big_view =
TryToFindBigUser(user, false /*require_auth_active*/);
- if (big_view)
+ if (big_view) {
return big_view->GetUserView();
+ }
// Try to find |user| in users_list_.
- if (users_list_)
+ if (users_list_) {
return users_list_->GetUserView(user);
+ }
return nullptr;
}
@@ -2620,8 +2711,9 @@
// Register the accelerators.
AcceleratorControllerImpl* controller =
Shell::Get()->accelerator_controller();
- for (const auto& item : accel_map_)
+ for (const auto& item : accel_map_) {
controller->Register({item.first}, this);
+ }
}
void LockContentsView::PerformAction(LoginAcceleratorAction action) {
@@ -2632,8 +2724,9 @@
// Do not allow accelerator action when system modal window is open except
// `kShowFeedback` which opens feedback tool on top of system modal.
if (!Shell::IsSystemModalWindowOpen() ||
- action == LoginAcceleratorAction::kShowFeedback)
+ action == LoginAcceleratorAction::kShowFeedback) {
Shell::Get()->login_screen_controller()->HandleAccelerator(action);
+ }
}
bool LockContentsView::GetSystemInfoVisibility() const {
@@ -2687,8 +2780,9 @@
}
void LockContentsView::OnBottomStatusIndicatorTapped() {
- if (bottom_status_indicator_state_ != BottomIndicatorState::kManagedDevice)
+ if (bottom_status_indicator_state_ != BottomIndicatorState::kManagedDevice) {
return;
+ }
management_bubble_->Show();
}
@@ -2698,8 +2792,9 @@
}
void LockContentsView::UpdateKioskDefaultMessageVisibility() {
- if (!kiosk_license_mode_)
+ if (!kiosk_license_mode_) {
return;
+ }
if (!kiosk_default_message_) {
kiosk_default_message_ =
diff --git a/ash/login/ui/lock_contents_view_unittest.cc b/ash/login/ui/lock_contents_view_unittest.cc
index 3d361c3..4c8ba387 100644
--- a/ash/login/ui/lock_contents_view_unittest.cc
+++ b/ash/login/ui/lock_contents_view_unittest.cc
@@ -139,8 +139,9 @@
// Returns true if the easy unlock icon is displayed for |view|.
bool IsEasyUnlockIconShowing(LoginBigUserView* view) {
- if (!view->auth_user())
+ if (!view->auth_user()) {
return false;
+ }
views::View* icon =
LoginPasswordView::TestApi(
@@ -204,11 +205,13 @@
// 1 extra user gets large style.
LoginDisplayStyle expected_style = LoginDisplayStyle::kLarge;
// 2-6 extra users get small style.
- if (user_count >= 3)
+ if (user_count >= 3) {
expected_style = LoginDisplayStyle::kSmall;
+ }
// 7+ users get get extra small style.
- if (user_count >= 7)
+ if (user_count >= 7) {
expected_style = LoginDisplayStyle::kExtraSmall;
+ }
for (size_t i = 0; i < users_list.user_views().size(); ++i) {
LoginUserView::TestApi user_test_api(users_list.user_views()[i]);
@@ -283,8 +286,9 @@
return lock_contents.primary_big_view();
};
auto get_right_view = [&]() -> views::View* {
- if (lock_contents.opt_secondary_big_view())
+ if (lock_contents.opt_secondary_big_view()) {
return lock_contents.opt_secondary_big_view();
+ }
return lock_contents.users_list();
};
@@ -1156,8 +1160,10 @@
// ShowGaiaSignin is never triggered.
EXPECT_CALL(*client, ShowGaiaSignin(_)).Times(0);
- for (int i = 0; i < LockContentsView::kLoginAttemptsBeforeGaiaDialog + 1; ++i)
+ for (int i = 0; i < LockContentsView::kLoginAttemptsBeforeGaiaDialog + 1;
+ ++i) {
submit_password();
+ }
}
// Gaia should not be shown after first failed login attempt for a user, even if
@@ -1182,8 +1188,10 @@
// ShowGaiaSignin is never triggered.
EXPECT_CALL(*client, ShowGaiaSignin(_)).Times(0);
- for (int i = 0; i < LockContentsView::kLoginAttemptsBeforeGaiaDialog - 1; ++i)
+ for (int i = 0; i < LockContentsView::kLoginAttemptsBeforeGaiaDialog - 1;
+ ++i) {
submit_password();
+ }
Mock::VerifyAndClearExpectations(client.get());
// Simulate a button click on the secondary UserView.
@@ -1225,8 +1233,10 @@
// The first n-1 attempts do not trigger ShowGaiaSignin.
EXPECT_CALL(*client, ShowGaiaSignin(_)).Times(0);
- for (int i = 0; i < LockContentsView::kLoginAttemptsBeforeGaiaDialog - 1; ++i)
+ for (int i = 0; i < LockContentsView::kLoginAttemptsBeforeGaiaDialog - 1;
+ ++i) {
submit_password();
+ }
Mock::VerifyAndClearExpectations(client.get());
// The final attempt triggers ShowGaiaSignin.
@@ -1266,8 +1276,10 @@
// ShowGaiaSignin is never triggered.
EXPECT_CALL(*client, ShowGaiaSignin(_)).Times(0);
- for (int i = 0; i < LockContentsView::kLoginAttemptsBeforeGaiaDialog + 1; ++i)
+ for (int i = 0; i < LockContentsView::kLoginAttemptsBeforeGaiaDialog + 1;
+ ++i) {
submit_pin();
+ }
Mock::VerifyAndClearExpectations(client.get());
}
diff --git a/ash/login/ui/lock_debug_view.cc b/ash/login/ui/lock_debug_view.cc
index c3d162b..e3ee83c 100644
--- a/ash/login/ui/lock_debug_view.cc
+++ b/ash/login/ui/lock_debug_view.cc
@@ -217,8 +217,9 @@
count = std::max(count, 0);
// Trim any extra debug users.
- if (debug_users_.size() > static_cast<size_t>(count))
+ if (debug_users_.size() > static_cast<size_t>(count)) {
debug_users_.erase(debug_users_.begin() + count, debug_users_.end());
+ }
// Build |users|, add any new users to |debug_users|.
std::vector<LoginUserInfo> users;
@@ -238,8 +239,9 @@
: users[i].basic_user_info.type;
users[i] = PopulateUserData(users[i], type, i);
- if (i >= debug_users_.size())
+ if (i >= debug_users_.size()) {
debug_users_.push_back(UserMetadata(users[i].basic_user_info));
+ }
}
return users;
@@ -247,8 +249,9 @@
void NotifyUsers(const std::vector<LoginUserInfo>& users) {
// User notification resets PIN state.
- for (UserMetadata& user : debug_users_)
+ for (UserMetadata& user : debug_users_) {
user.enable_pin = false;
+ }
debug_dispatcher_.SetUserList(users);
}
@@ -569,8 +572,9 @@
}
void RemoveKioskApp(ShelfWidget* shelf_widget) {
- if (kiosk_apps_.empty())
+ if (kiosk_apps_.empty()) {
return;
+ }
kiosk_apps_.pop_back();
shelf_widget->GetLoginShelfView()->SetKioskApps(kiosk_apps_);
}
@@ -592,8 +596,9 @@
void OnUsersChanged(const std::vector<LoginUserInfo>& users) override {
// Update root_users_ to new source data.
root_users_.clear();
- for (auto& user : users)
+ for (auto& user : users) {
root_users_.push_back(user);
+ }
// Rebuild debug users using new source data.
SetUserCount(root_users_.size());
@@ -699,8 +704,9 @@
// Calculates the pairing status to which the model should be changed when
// button for cycling detachable base pairing statuses is clicked.
DetachableBasePairingStatus NextPairingStatus() const {
- if (!pairing_status_.has_value())
+ if (!pairing_status_.has_value()) {
return DetachableBasePairingStatus::kNone;
+ }
switch (*pairing_status_) {
case DetachableBasePairingStatus::kNone:
@@ -724,8 +730,9 @@
// Gets the descripting text for currently paired base, if any.
std::string BaseButtonText() const {
- if (base_id_ < 0)
+ if (base_id_ < 0) {
return "No base";
+ }
return kDebugDetachableBases[base_id_];
}
@@ -753,8 +760,9 @@
// Marks the paired base (as seen by the model) as the user's last used base.
// No-op if the current pairing status is different than kAuthenticated.
void SetBaseLastUsedForUser(const AccountId& account_id) {
- if (GetPairingStatus() != DetachableBasePairingStatus::kAuthenticated)
+ if (GetPairingStatus() != DetachableBasePairingStatus::kAuthenticated) {
return;
+ }
DCHECK_GE(base_id_, 0);
last_used_bases_[account_id] = base_id_;
@@ -778,21 +786,25 @@
// LoginDetachableBaseModel:
DetachableBasePairingStatus GetPairingStatus() override {
- if (!pairing_status_.has_value())
+ if (!pairing_status_.has_value()) {
return DetachableBasePairingStatus::kNone;
+ }
return *pairing_status_;
}
bool PairedBaseMatchesLastUsedByUser(const UserInfo& user_info) override {
- if (GetPairingStatus() != DetachableBasePairingStatus::kAuthenticated)
+ if (GetPairingStatus() != DetachableBasePairingStatus::kAuthenticated) {
return false;
+ }
- if (last_used_bases_.count(user_info.account_id) == 0)
+ if (last_used_bases_.count(user_info.account_id) == 0) {
return true;
+ }
return last_used_bases_[user_info.account_id] == base_id_;
}
bool SetPairedBaseAsLastUsedByUser(const UserInfo& user_info) override {
- if (GetPairingStatus() != DetachableBasePairingStatus::kAuthenticated)
+ if (GetPairingStatus() != DetachableBasePairingStatus::kAuthenticated) {
return false;
+ }
last_used_bases_[user_info.account_id] = base_id_;
return true;
@@ -976,8 +988,9 @@
container_->SetPosition(gfx::Point());
container_->SizeToPreferredSize();
- for (views::View* child : container_->children())
+ for (views::View* child : container_->children()) {
child->Layout();
+ }
}
void LockDebugView::OnThemeChanged() {
@@ -994,8 +1007,9 @@
void LockDebugView::AddSystemInfoButtonPressed() {
++num_system_info_clicks_;
- if (num_system_info_clicks_ >= 7)
+ if (num_system_info_clicks_ >= 7) {
global_action_add_system_info_->SetEnabled(false);
+ }
std::string os_version = num_system_info_clicks_ / 4 ? kDebugOsVersion : "";
std::string enterprise_info =
@@ -1273,8 +1287,9 @@
&LockDebugView::ToggleDebugDetachableBaseButtonPressed,
base::Unretained(this)),
global_action_detachable_base_group_);
- if (!debug_detachable_base_model_->debugging_pairing_state())
+ if (!debug_detachable_base_model_->debugging_pairing_state()) {
return;
+ }
const std::string kPairingStatusText =
"Pairing status: " +
diff --git a/ash/login/ui/lock_screen.cc b/ash/login/ui/lock_screen.cc
index d3e1dd2e..a4687115 100644
--- a/ash/login/ui/lock_screen.cc
+++ b/ash/login/ui/lock_screen.cc
@@ -60,8 +60,9 @@
if (active_window) {
auto* active_widget =
views::Widget::GetWidgetForNativeWindow(active_window);
- if (active_widget)
+ if (active_widget) {
paint_as_active_lock_ = active_widget->LockPaintAsActive();
+ }
}
tray_action_observation_.Observe(Shell::Get()->tray_action());
@@ -77,8 +78,9 @@
if (Shell::Get()->session_controller()->GetSessionState() !=
session_manager::SessionState::LOGIN_SECONDARY) {
ui::Clipboard::DestroyClipboardForCurrentThread();
- if (saved_clipboard_)
+ if (saved_clipboard_) {
ui::Clipboard::SetClipboardForCurrentThread(std::move(saved_clipboard_));
+ }
}
}
@@ -184,11 +186,13 @@
}
void LockScreen::OnLockStateChanged(bool locked) {
- if (type_ != ScreenType::kLock)
+ if (type_ != ScreenType::kLock) {
return;
+ }
- if (!locked)
+ if (!locked) {
Destroy();
+ }
}
void LockScreen::OnChromeTerminating() {
@@ -198,15 +202,17 @@
// static
void LockScreen::ShowWidgetUponWallpaperReady() {
// |instance_| may already be destroyed in tests.
- if (!instance_ || instance_->is_shown_)
+ if (!instance_ || instance_->is_shown_) {
return;
+ }
instance_->is_shown_ = true;
instance_->widget_->Show();
std::vector<base::OnceClosure> on_shown_callbacks;
swap(instance_->on_shown_callbacks_, on_shown_callbacks);
- for (auto& callback : on_shown_callbacks)
+ for (auto& callback : on_shown_callbacks) {
std::move(callback).Run();
+ }
Shell::Get()->login_screen_controller()->NotifyLoginScreenShown();
}
diff --git a/ash/login/ui/lock_screen_media_controls_view.cc b/ash/login/ui/lock_screen_media_controls_view.cc
index ba895433..83beab16 100644
--- a/ash/login/ui/lock_screen_media_controls_view.cc
+++ b/ash/login/ui/lock_screen_media_controls_view.cc
@@ -425,8 +425,9 @@
// |service| can be null in tests.
media_session::MediaSessionService* service =
Shell::Get()->shell_delegate()->GetMediaSessionService();
- if (!service)
+ if (!service) {
return;
+ }
// Connect to the MediaControllerManager and create a MediaController that
// controls the active session so we can observe it.
@@ -456,8 +457,10 @@
// If the screen is now unlocked and we were not hidden for another reason
// then we are being hidden because the device is now unlocked.
if (shown_ == Shown::kShown) {
- if (!hide_reason_ && !Shell::Get()->session_controller()->IsScreenLocked())
+ if (!hide_reason_ &&
+ !Shell::Get()->session_controller()->IsScreenLocked()) {
hide_reason_ = HideReason::kUnlocked;
+ }
// Only record hide reason if there is one. The value could be missing
// when ash shuts down with the media controls.
@@ -486,20 +489,23 @@
l10n_util::GetStringUTF8(
IDS_ASH_LOCK_SCREEN_MEDIA_CONTROLS_ACCESSIBLE_NAME));
- if (!accessible_name_.empty())
+ if (!accessible_name_.empty()) {
node_data->SetName(accessible_name_);
+ }
}
void LockScreenMediaControlsView::OnMouseEntered(const ui::MouseEvent& event) {
- if (is_in_drag_ || contents_view_->layer()->GetAnimator()->is_animating())
+ if (is_in_drag_ || contents_view_->layer()->GetAnimator()->is_animating()) {
return;
+ }
header_row_->SetForceShowCloseButton(true);
}
void LockScreenMediaControlsView::OnMouseExited(const ui::MouseEvent& event) {
- if (is_in_drag_ || contents_view_->layer()->GetAnimator()->is_animating())
+ if (is_in_drag_ || contents_view_->layer()->GetAnimator()->is_animating()) {
return;
+ }
header_row_->SetForceShowCloseButton(false);
}
@@ -511,8 +517,9 @@
void LockScreenMediaControlsView::MediaSessionInfoChanged(
media_session::mojom::MediaSessionInfoPtr session_info) {
- if (hide_controls_timer_->IsRunning())
+ if (hide_controls_timer_->IsRunning()) {
return;
+ }
// If the controls are disabled then don't show the controls.
if (!media_controls_enabled_.Run()) {
@@ -541,16 +548,18 @@
return;
}
- if (!IsDrawn())
+ if (!IsDrawn()) {
SetShown(Shown::kShown);
+ }
SetIsPlaying(!is_paused);
}
void LockScreenMediaControlsView::MediaSessionMetadataChanged(
const absl::optional<media_session::MediaMetadata>& metadata) {
- if (hide_controls_timer_->IsRunning())
+ if (hide_controls_timer_->IsRunning()) {
return;
+ }
media_session::MediaMetadata session_metadata =
metadata.value_or(media_session::MediaMetadata());
@@ -569,8 +578,9 @@
void LockScreenMediaControlsView::MediaSessionActionsChanged(
const std::vector<MediaSessionAction>& actions) {
- if (hide_controls_timer_->IsRunning())
+ if (hide_controls_timer_->IsRunning()) {
return;
+ }
enabled_actions_ =
base::flat_set<MediaSessionAction>(actions.begin(), actions.end());
@@ -586,13 +596,15 @@
}
// If |media_session_id_| resumed while waiting, don't hide the controls.
- if (hide_controls_timer_->IsRunning() && request_id == media_session_id_)
+ if (hide_controls_timer_->IsRunning() && request_id == media_session_id_) {
hide_controls_timer_->Stop();
+ }
// If this session is different than the previous one, wait to see if the
// previous one resumes before hiding the controls.
- if (request_id == media_session_id_)
+ if (request_id == media_session_id_) {
return;
+ }
hide_controls_timer_->Start(
FROM_HERE, kNextMediaDelay,
@@ -602,8 +614,9 @@
void LockScreenMediaControlsView::MediaSessionPositionChanged(
const absl::optional<media_session::MediaPosition>& position) {
- if (hide_controls_timer_->IsRunning())
+ if (hide_controls_timer_->IsRunning()) {
return;
+ }
position_ = position;
@@ -626,8 +639,9 @@
void LockScreenMediaControlsView::MediaControllerImageChanged(
media_session::mojom::MediaSessionImageType type,
const SkBitmap& bitmap) {
- if (hide_controls_timer_->IsRunning())
+ if (hide_controls_timer_->IsRunning()) {
return;
+ }
// Convert the bitmap to kN32_SkColorType if necessary.
SkBitmap converted_bitmap;
@@ -644,8 +658,9 @@
switch (type) {
case media_session::mojom::MediaSessionImageType::kArtwork: {
absl::optional<gfx::ImageSkia> session_artwork;
- if (!converted_bitmap.empty())
+ if (!converted_bitmap.empty()) {
session_artwork = gfx::ImageSkia::CreateFrom1xBitmap(converted_bitmap);
+ }
SetArtwork(session_artwork);
break;
}
@@ -673,8 +688,9 @@
switch (event->type()) {
case ui::ET_SCROLL_FLING_START:
case ui::ET_GESTURE_SCROLL_BEGIN: {
- if (is_in_drag_)
+ if (is_in_drag_) {
break;
+ }
initial_drag_point_ = point_in_screen;
is_in_drag_ = true;
@@ -688,8 +704,9 @@
break;
}
case ui::ET_GESTURE_END: {
- if (!is_in_drag_)
+ if (!is_in_drag_) {
break;
+ }
EndDrag();
event->SetHandled();
@@ -737,8 +754,9 @@
action_button->SetVisible(should_show);
}
- if (should_invalidate)
+ if (should_invalidate) {
button_row_->InvalidateLayout();
+ }
}
void LockScreenMediaControlsView::SetIsPlaying(bool playing) {
@@ -767,8 +785,9 @@
}
void LockScreenMediaControlsView::Hide(HideReason reason) {
- if (!hide_reason_ && GetVisible())
+ if (!hide_reason_ && GetVisible()) {
hide_reason_ = reason;
+ }
hide_media_controls_.Run();
}
@@ -780,8 +799,9 @@
}
void LockScreenMediaControlsView::SetShown(Shown shown) {
- if (shown_ == shown)
+ if (shown_ == shown) {
return;
+ }
shown_ = shown;
@@ -806,8 +826,9 @@
void LockScreenMediaControlsView::SetArtwork(
absl::optional<gfx::ImageSkia> img) {
if (!img.has_value()) {
- if (!session_artwork_->GetVisible() || hide_artwork_timer_->IsRunning())
+ if (!session_artwork_->GetVisible() || hide_artwork_timer_->IsRunning()) {
return;
+ }
hide_artwork_timer_->Start(
FROM_HERE, kNextMediaDelay,
@@ -816,8 +837,9 @@
return;
}
- if (hide_artwork_timer_->IsRunning())
+ if (hide_artwork_timer_->IsRunning()) {
hide_artwork_timer_->Stop();
+ }
session_artwork_->SetVisible(true);
session_artwork_->SetImageSize(
diff --git a/ash/login/ui/lock_screen_media_controls_view_unittest.cc b/ash/login/ui/lock_screen_media_controls_view_unittest.cc
index 6d5bf6ab..bef460f 100644
--- a/ash/login/ui/lock_screen_media_controls_view_unittest.cc
+++ b/ash/login/ui/lock_screen_media_controls_view_unittest.cc
@@ -212,8 +212,9 @@
const auto it = base::ranges::find(buttons, static_cast<int>(action),
&views::Button::tag);
- if (it == buttons.end())
+ if (it == buttons.end()) {
return nullptr;
+ }
return *it;
}
diff --git a/ash/login/ui/lock_screen_sanity_unittest.cc b/ash/login/ui/lock_screen_sanity_unittest.cc
index c9fa021..ad39fb0 100644
--- a/ash/login/ui/lock_screen_sanity_unittest.cc
+++ b/ash/login/ui/lock_screen_sanity_unittest.cc
@@ -41,8 +41,9 @@
// TODO(https://crbug.com/1343114): refactor the code below after the login
// shelf widget is ready.
Shelf* shelf = Shelf::ForWindow(native_window);
- if (features::IsUseLoginShelfWidgetEnabled())
+ if (features::IsUseLoginShelfWidgetEnabled()) {
return shelf->login_shelf_widget()->GetContentsView();
+ }
return shelf->shelf_widget()->GetContentsView();
}
@@ -70,18 +71,22 @@
};
testing::AssertionResult VerifyFocused(views::View* view) {
- if (!view->GetWidget()->IsActive())
+ if (!view->GetWidget()->IsActive()) {
return testing::AssertionFailure() << "Widget not active.";
- if (!HasFocusInAnyChildView(view))
+ }
+ if (!HasFocusInAnyChildView(view)) {
return testing::AssertionFailure() << "No focused descendant.";
+ }
return testing::AssertionSuccess();
}
testing::AssertionResult VerifyNotFocused(views::View* view) {
- if (view->GetWidget()->IsActive())
+ if (view->GetWidget()->IsActive()) {
return testing::AssertionFailure() << "Widget active";
- if (HasFocusInAnyChildView(view))
+ }
+ if (HasFocusInAnyChildView(view)) {
return testing::AssertionFailure() << "Has focused descendant.";
+ }
return testing::AssertionSuccess();
}
diff --git a/ash/login/ui/login_auth_factors_view.cc b/ash/login/ui/login_auth_factors_view.cc
index 998d97f8..d9adb8ec 100644
--- a/ash/login/ui/login_auth_factors_view.cc
+++ b/ash/login/ui/login_auth_factors_view.cc
@@ -92,8 +92,9 @@
case AuthFactorState::kUnavailable:
return PrioritizedAuthFactorViewState::kUnavailable;
case AuthFactorState::kErrorPermanent:
- if (auth_factor.has_permanent_error_display_timed_out())
+ if (auth_factor.has_permanent_error_display_timed_out()) {
return PrioritizedAuthFactorViewState::kErrorBackground;
+ }
return PrioritizedAuthFactorViewState::kErrorForeground;
case AuthFactorState::kAvailable:
@@ -116,8 +117,9 @@
// state determines the behavior of LoginAuthFactorsView.
AuthFactorModel* GetHighestPriorityAuthFactor(
const std::vector<std::unique_ptr<AuthFactorModel>>& auth_factors) {
- if (auth_factors.empty())
+ if (auth_factors.empty()) {
return nullptr;
+ }
// PrioritizedAuthFactorViewState enum values are assigned so that the
// highest numerical value corresponds to the highest priority.
@@ -216,9 +218,9 @@
arrow_nudge_animation_ =
arrow_icon_container_->AddChildView(std::make_unique<AuthIconView>());
arrow_nudge_animation_->SetCircleImage(
- kArrowButtonSizeDp / 2, AshColorProvider::Get()->GetControlsLayerColor(
- AshColorProvider::ControlsLayerType::
- kHairlineBorderColor));
+ kArrowButtonSizeDp / 2,
+ AshColorProvider::Get()->GetControlsLayerColor(
+ AshColorProvider::ControlsLayerType::kHairlineBorderColor));
arrow_nudge_animation_->set_on_tap_or_click_callback(base::BindRepeating(
&LoginAuthFactorsView::RelayArrowButtonPressed, base::Unretained(this)));
@@ -256,8 +258,9 @@
}
void LoginAuthFactorsView::SetCanUsePin(bool can_use_pin) {
- if (can_use_pin == AuthFactorModel::can_use_pin())
+ if (can_use_pin == AuthFactorModel::can_use_pin()) {
return;
+ }
AuthFactorModel::set_can_use_pin(can_use_pin);
UpdateState();
@@ -343,8 +346,9 @@
// the error for a period of time.
// Do not replace the current error if an error is already showing.
- if (error_timer_.IsRunning())
+ if (error_timer_.IsRunning()) {
return;
+ }
error_timer_.Start(FROM_HERE, kErrorTimeout,
base::BindOnce(&LoginAuthFactorsView::OnErrorTimeout,
@@ -451,8 +455,9 @@
return GetDefaultLabelId();
}
- if (ready_factor_count == 1u)
+ if (ready_factor_count == 1u) {
return ready_factor->GetLabelId();
+ }
// Multiple auth factors are ready.
switch (ready_factors) {
diff --git a/ash/login/ui/login_auth_user_view.cc b/ash/login/ui/login_auth_user_view.cc
index cb85448..6f37616 100644
--- a/ash/login/ui/login_auth_user_view.cc
+++ b/ash/login/ui/login_auth_user_view.cc
@@ -160,8 +160,9 @@
const ui::CallbackLayerAnimationObserver& observer) {
// Don't hide the view if the animation is aborted, as |view| may no
// longer be valid.
- if (observer.aborted_count())
+ if (observer.aborted_count()) {
return true;
+ }
view->SetVisible(false);
return true;
@@ -176,8 +177,9 @@
const ui::CallbackLayerAnimationObserver& observer) {
// Don't notify a11y event if the animation is aborted, as |view| may no
// longer be valid.
- if (observer.aborted_count())
+ if (observer.aborted_count()) {
return true;
+ }
view->NotifyAccessibilityEvent(ax::mojom::Event::kLocationChanged,
false /*send_native_event*/);
@@ -193,8 +195,9 @@
const ui::CallbackLayerAnimationObserver& observer) {
// Don't notify a11y event if the animation is aborted, as |view| may no
// longer be valid.
- if (observer.aborted_count())
+ if (observer.aborted_count()) {
return true;
+ }
view->NotifyAccessibilityLocationChanged();
return true;
@@ -241,16 +244,18 @@
case FingerprintState::DISABLED_FROM_ATTEMPTS:
return IDS_ASH_LOGIN_FINGERPRINT_UNLOCK_DISABLED_FROM_ATTEMPTS_OLD;
case FingerprintState::DISABLED_FROM_TIMEOUT:
- if (can_use_pin)
+ if (can_use_pin) {
return IDS_ASH_LOGIN_FINGERPRINT_UNLOCK_PIN_OR_PASSWORD_REQUIRED;
+ }
return IDS_ASH_LOGIN_FINGERPRINT_UNLOCK_PASSWORD_REQUIRED;
}
NOTREACHED();
};
auto get_accessible_id = [&]() {
- if (state == FingerprintState::DISABLED_FROM_ATTEMPTS)
+ if (state == FingerprintState::DISABLED_FROM_ATTEMPTS) {
return IDS_ASH_LOGIN_FINGERPRINT_UNLOCK_ACCESSIBLE_AUTH_DISABLED_FROM_ATTEMPTS;
+ }
return get_displayed_id();
};
@@ -415,21 +420,24 @@
~FingerprintView() override = default;
void SetState(FingerprintState state) {
- if (state_ == state)
+ if (state_ == state) {
return;
+ }
reset_state_.Stop();
state_ = state;
DisplayCurrentState();
- if (ShouldFireChromeVoxAlert(state))
+ if (ShouldFireChromeVoxAlert(state)) {
FireAlert();
+ }
}
void SetCanUsePin(bool value) {
- if (can_use_pin_ == value)
+ if (can_use_pin_ == value) {
return;
+ }
can_use_pin_ = value;
label_->SetTextBasedOnState(state_, can_use_pin_);
@@ -469,8 +477,9 @@
// views::View:
void OnGestureEvent(ui::GestureEvent* event) override {
- if (event->type() != ui::ET_GESTURE_TAP)
+ if (event->type() != ui::ET_GESTURE_TAP) {
return;
+ }
if (state_ == FingerprintState::AVAILABLE_DEFAULT ||
state_ == FingerprintState::AVAILABLE_WITH_TOUCH_SENSOR_WARNING) {
SetState(FingerprintState::AVAILABLE_WITH_TOUCH_SENSOR_WARNING);
@@ -595,8 +604,9 @@
~ChallengeResponseView() override = default;
void SetState(State state) {
- if (state_ == state)
+ if (state_ == state) {
return;
+ }
state_ = state;
reset_state_timer_.Stop();
@@ -664,8 +674,9 @@
void ArrowButtonPressed() {
// Ignore further clicks while handling the previous one.
- if (state_ != State::kAuthenticating)
+ if (state_ != State::kAuthenticating) {
on_start_tap_.Run();
+ }
}
base::RepeatingClosure on_start_tap_;
@@ -1300,9 +1311,10 @@
locked_tpm_message_view_->SetVisible(current_state.tpm_is_locked);
if (current_state.tpm_is_locked &&
- auth_metadata.time_until_tpm_unlock.has_value())
+ auth_metadata.time_until_tpm_unlock.has_value()) {
locked_tpm_message_view_->SetRemainingTime(
auth_metadata.time_until_tpm_unlock.value());
+ }
// Adjust the PIN keyboard visibility before the password textfield's one, so
// that when both are about to be hidden the focus doesn't jump to the "1"
@@ -1383,8 +1395,9 @@
void LoginAuthUserView::CaptureStateForAnimationPreLayout() {
auto stop_animation = [](views::View* view) {
- if (view->layer()->GetAnimator()->is_animating())
+ if (view->layer()->GetAnimator()->is_animating()) {
view->layer()->GetAnimator()->StopAnimating();
+ }
};
// Stop any running animation scheduled in ApplyAnimationPostLayout.
@@ -1447,8 +1460,9 @@
if (current_state.has_password != previous_state_->has_password) {
float opacity_start = 0, opacity_end = 1;
- if (!current_state.has_password)
+ if (!current_state.has_password) {
std::swap(opacity_start, opacity_end);
+ }
password_view_->layer()->SetOpacity(opacity_start);
@@ -1470,8 +1484,9 @@
// Fade the pin/pwd toggle if its being hidden or shown.
if (previous_state_->has_toggle != current_state.has_toggle) {
float opacity_start = 0, opacity_end = 1;
- if (!current_state.has_toggle)
+ if (!current_state.has_toggle) {
std::swap(opacity_start, opacity_end);
+ }
pin_password_toggle_->layer()->SetOpacity(opacity_start);
@@ -1527,8 +1542,9 @@
if (!smart_lock_ui_revamp_enabled_ && fingerprint_view_ &&
previous_state_->has_fingerprint != current_state.has_fingerprint) {
float opacity_start = 0, opacity_end = 1;
- if (!current_state.has_fingerprint)
+ if (!current_state.has_fingerprint) {
std::swap(opacity_start, opacity_end);
+ }
fingerprint_view_->layer()->SetOpacity(opacity_start);
@@ -1585,8 +1601,9 @@
if (previous_state_->has_challenge_response !=
current_state.has_challenge_response) {
float opacity_start = 0, opacity_end = 1;
- if (!current_state.has_challenge_response)
+ if (!current_state.has_challenge_response) {
std::swap(opacity_start, opacity_end);
+ }
challenge_response_view_->layer()->SetOpacity(opacity_start);
@@ -1668,8 +1685,9 @@
}
base::WeakPtr<views::View> LoginAuthUserView::GetActiveInputView() {
- if (input_field_mode_ == InputFieldMode::PIN_WITH_TOGGLE)
+ if (input_field_mode_ == InputFieldMode::PIN_WITH_TOGGLE) {
return pin_input_view_ != nullptr ? pin_input_view_->AsWeakPtr() : nullptr;
+ }
return password_view_ != nullptr ? password_view_->AsWeakPtr() : nullptr;
}
@@ -1683,10 +1701,11 @@
}
void LoginAuthUserView::RequestFocus() {
- if (input_field_mode_ == InputFieldMode::PIN_WITH_TOGGLE)
+ if (input_field_mode_ == InputFieldMode::PIN_WITH_TOGGLE) {
pin_input_view_->RequestFocus();
- else if (password_view_->GetEnabled())
+ } else if (password_view_->GetEnabled()) {
RequestFocusOnPasswordView();
+ }
}
void LoginAuthUserView::OnGestureEvent(ui::GestureEvent* event) {
@@ -1803,31 +1822,35 @@
void LoginAuthUserView::OnPinPadBackspace() {
DCHECK(pin_input_view_);
DCHECK(password_view_);
- if (input_field_mode_ == InputFieldMode::PIN_WITH_TOGGLE)
+ if (input_field_mode_ == InputFieldMode::PIN_WITH_TOGGLE) {
pin_input_view_->Backspace();
- else
+ } else {
password_view_->Backspace();
+ }
}
void LoginAuthUserView::OnPinPadInsertDigit(int digit) {
DCHECK(pin_input_view_);
DCHECK(password_view_);
- if (input_field_mode_ == InputFieldMode::PIN_WITH_TOGGLE)
+ if (input_field_mode_ == InputFieldMode::PIN_WITH_TOGGLE) {
pin_input_view_->InsertDigit(digit);
- else
+ } else {
password_view_->InsertNumber(digit);
+ }
}
void LoginAuthUserView::OnPasswordTextChanged(bool is_empty) {
DCHECK(pin_view_);
- if (input_field_mode_ != InputFieldMode::PIN_WITH_TOGGLE)
+ if (input_field_mode_ != InputFieldMode::PIN_WITH_TOGGLE) {
pin_view_->OnPasswordTextChanged(is_empty);
+ }
}
void LoginAuthUserView::OnPinTextChanged(bool is_empty) {
DCHECK(pin_view_);
- if (input_field_mode_ == InputFieldMode::PIN_WITH_TOGGLE)
+ if (input_field_mode_ == InputFieldMode::PIN_WITH_TOGGLE) {
pin_view_->OnPasswordTextChanged(is_empty);
+ }
}
bool LoginAuthUserView::HasAuthMethod(AuthMethods auth_method) const {
@@ -1857,8 +1880,9 @@
// Bring up the virtual keyboard if enabled as soon as we get the focus.
// This way, the user does not have to type twice (on the user pod and
// additionally on the textfield or user view).
- if (GetInputMethod() && !current_state.has_pinpad)
+ if (GetInputMethod() && !current_state.has_pinpad) {
GetInputMethod()->SetVirtualKeyboardVisibilityIfEnabled(true);
+ }
}
void LoginAuthUserView::UpdateFocus() {
@@ -1870,18 +1894,23 @@
return;
}
// All further states are exclusive.
- if (current_state.auth_disabled)
+ if (current_state.auth_disabled) {
disabled_auth_message_->RequestFocus();
- if (current_state.has_challenge_response)
+ }
+ if (current_state.has_challenge_response) {
challenge_response_view_->RequestFocus();
- if (current_state.has_password && !previous_state_->has_password)
+ }
+ if (current_state.has_password && !previous_state_->has_password) {
RequestFocusOnPasswordView();
- if (current_state.has_pin_input)
+ }
+ if (current_state.has_pin_input) {
pin_input_view_->RequestFocus();
+ }
// Tapping the user view will trigger the online sign-in flow when
// |force_online_sign_in| is true.
- if (current_state.force_online_sign_in)
+ if (current_state.force_online_sign_in) {
user_view_->RequestFocus();
+ }
}
void LoginAuthUserView::OnSwitchButtonClicked() {
@@ -1943,8 +1972,9 @@
}
bool LoginAuthUserView::ShouldShowPinPad() const {
- if (auth_metadata_.virtual_keyboard_visible)
+ if (auth_metadata_.virtual_keyboard_visible) {
return false;
+ }
switch (input_field_mode_) {
case InputFieldMode::NONE:
return false;
@@ -1975,14 +2005,18 @@
gfx::Size LoginAuthUserView::GetPaddingBelowUserView() const {
const UiState state{this};
- if (state.has_password)
+ if (state.has_password) {
return SizeFromHeight(kDistanceBetweenUserViewAndPasswordDp);
- if (state.has_pin_input)
+ }
+ if (state.has_pin_input) {
return SizeFromHeight(kDistanceBetweenUserViewAndPinInputDp);
- if (state.force_online_sign_in)
+ }
+ if (state.force_online_sign_in) {
return SizeFromHeight(kDistanceBetweenUserViewAndOnlineSigninDp);
- if (state.has_challenge_response)
+ }
+ if (state.has_challenge_response) {
return SizeFromHeight(kDistanceBetweenUserViewAndChallengeResponseDp);
+ }
return SizeFromHeight(0);
}
@@ -1990,33 +2024,39 @@
gfx::Size LoginAuthUserView::GetPaddingBelowPasswordView() const {
const UiState state{this};
- if (state.has_pinpad)
+ if (state.has_pinpad) {
return SizeFromHeight(kDistanceBetweenPasswordFieldAndPinKeyboardDp);
+ }
if (state.has_fingerprint ||
- (auth_factors_view_ && auth_factors_view_->GetVisible()))
+ (auth_factors_view_ && auth_factors_view_->GetVisible())) {
return SizeFromHeight(kDistanceBetweenPasswordFieldAndFingerprintViewDp);
- if (state.has_challenge_response)
+ }
+ if (state.has_challenge_response) {
return SizeFromHeight(kDistanceBetweenPwdFieldAndChallengeResponseViewDp);
+ }
return SizeFromHeight(0);
}
std::u16string LoginAuthUserView::GetPinPasswordToggleText() const {
- if (input_field_mode_ == InputFieldMode::PWD_WITH_TOGGLE)
+ if (input_field_mode_ == InputFieldMode::PWD_WITH_TOGGLE) {
return l10n_util::GetStringUTF16(IDS_ASH_LOGIN_SWITCH_TO_PIN);
- else
+ } else {
return l10n_util::GetStringUTF16(IDS_ASH_LOGIN_SWITCH_TO_PASSWORD);
+ }
}
std::u16string LoginAuthUserView::GetPasswordViewPlaceholder() const {
// Note: |AUTH_TAP| must have higher priority than |AUTH_PIN| when
// determining the placeholder.
- if (HasAuthMethod(AUTH_TAP) && !smart_lock_ui_revamp_enabled_)
+ if (HasAuthMethod(AUTH_TAP) && !smart_lock_ui_revamp_enabled_) {
return l10n_util::GetStringUTF16(
IDS_ASH_LOGIN_POD_PASSWORD_TAP_PLACEHOLDER);
- if (input_field_mode_ == InputFieldMode::PIN_AND_PASSWORD)
+ }
+ if (input_field_mode_ == InputFieldMode::PIN_AND_PASSWORD) {
return l10n_util::GetStringUTF16(
IDS_ASH_LOGIN_POD_PASSWORD_PIN_PLACEHOLDER);
+ }
return l10n_util::GetStringUTF16(IDS_ASH_LOGIN_POD_PASSWORD_PLACEHOLDER);
}
diff --git a/ash/login/ui/login_base_bubble_view.cc b/ash/login/ui/login_base_bubble_view.cc
index 8aca19da..8da5d307 100644
--- a/ash/login/ui/login_base_bubble_view.cc
+++ b/ash/login/ui/login_base_bubble_view.cc
@@ -59,8 +59,9 @@
// ui::EventHandler:
void OnMouseEvent(ui::MouseEvent* event) override {
- if (event->type() == ui::ET_MOUSE_PRESSED)
+ if (event->type() == ui::ET_MOUSE_PRESSED) {
ProcessPressedEvent(event->AsLocatedEvent());
+ }
}
void OnGestureEvent(ui::GestureEvent* event) override {
@@ -76,8 +77,9 @@
return;
}
- if (!bubble_->GetVisible())
+ if (!bubble_->GetVisible()) {
return;
+ }
// Hide the bubble if the bubble opener is about to lose focus from tab
// traversal.
@@ -86,25 +88,29 @@
return;
}
- if (login_views_utils::HasFocusInAnyChildView(bubble_))
+ if (login_views_utils::HasFocusInAnyChildView(bubble_)) {
return;
+ }
- if (!bubble_->is_persistent())
+ if (!bubble_->is_persistent()) {
bubble_->Hide();
+ }
}
private:
void ProcessPressedEvent(const ui::LocatedEvent* event) {
- if (!bubble_->GetVisible())
+ if (!bubble_->GetVisible()) {
return;
+ }
gfx::Point screen_location = event->location();
::wm::ConvertPointToScreen(static_cast<aura::Window*>(event->target()),
&screen_location);
// Don't do anything with clicks inside the bubble.
- if (bubble_->GetBoundsInScreen().Contains(screen_location))
+ if (bubble_->GetBoundsInScreen().Contains(screen_location)) {
return;
+ }
// Let the bubble opener handle clicks on itself.
if (bubble_->GetBubbleOpener() &&
@@ -113,8 +119,9 @@
return;
}
- if (!bubble_->is_persistent())
+ if (!bubble_->is_persistent()) {
bubble_->Hide();
+ }
}
LoginBaseBubbleView* bubble_;
@@ -138,8 +145,9 @@
}
void LoginBaseBubbleView::EnsureLayer() {
- if (layer())
+ if (layer()) {
return;
+ }
// Layer rendering is needed for animation.
SetPaintToLayer();
SkColor background_color = AshColorProvider::Get()->GetBaseLayerColor(
@@ -153,8 +161,9 @@
LoginBaseBubbleView::~LoginBaseBubbleView() = default;
void LoginBaseBubbleView::Show() {
- if (layer())
+ if (layer()) {
layer()->GetAnimator()->RemoveObserver(this);
+ }
SetSize(GetPreferredSize());
SetPosition(CalculatePosition());
@@ -338,8 +347,9 @@
nullptr /*event*/);
}
- if (layer())
+ if (layer()) {
layer()->GetAnimator()->StopAnimating();
+ }
EnsureLayer();
float opacity_start = 0.0f;
diff --git a/ash/login/ui/login_big_user_view.cc b/ash/login/ui/login_big_user_view.cc
index 3054840..d7cee13 100644
--- a/ash/login/ui/login_big_user_view.cc
+++ b/ash/login/ui/login_big_user_view.cc
@@ -64,25 +64,28 @@
}
void LoginBigUserView::CreateChildView(const LoginUserInfo& user) {
- if (IsPublicAccountUser(user))
+ if (IsPublicAccountUser(user)) {
CreatePublicAccount(user);
- else
+ } else {
CreateAuthUser(user);
+ }
}
void LoginBigUserView::UpdateForUser(const LoginUserInfo& user) {
// Rebuild child view for the following swap case:
// 1. Public Account -> Auth User
// 2. Auth User -> Public Account
- if (IsPublicAccountUser(user) != IsPublicAccountUser(GetCurrentUser()))
+ if (IsPublicAccountUser(user) != IsPublicAccountUser(GetCurrentUser())) {
CreateChildView(user);
+ }
DCHECK(OnlyOneSet(public_account_, auth_user_));
if (public_account_) {
public_account_->UpdateForUser(user);
}
- if (auth_user_)
+ if (auth_user_) {
auth_user_->UpdateForUser(user);
+ }
}
const LoginUserInfo& LoginBigUserView::GetCurrentUser() const {
diff --git a/ash/login/ui/login_data_dispatcher.cc b/ash/login/ui/login_data_dispatcher.cc
index 2588aab..c54d448 100644
--- a/ash/login/ui/login_data_dispatcher.cc
+++ b/ash/login/ui/login_data_dispatcher.cc
@@ -125,109 +125,127 @@
}
void LoginDataDispatcher::SetUserList(const std::vector<LoginUserInfo>& users) {
- for (auto& observer : observers_)
+ for (auto& observer : observers_) {
observer.OnUsersChanged(users);
+ }
}
void LoginDataDispatcher::SetPinEnabledForUser(const AccountId& user,
bool enabled) {
// Chrome will update pin pod state every time user tries to authenticate.
// LockScreen is destroyed in the case of authentication success.
- for (auto& observer : observers_)
+ for (auto& observer : observers_) {
observer.OnPinEnabledForUserChanged(user, enabled);
+ }
}
void LoginDataDispatcher::SetChallengeResponseAuthEnabledForUser(
const AccountId& user,
bool enabled) {
- for (auto& observer : observers_)
+ for (auto& observer : observers_) {
observer.OnChallengeResponseAuthEnabledForUserChanged(user, enabled);
+ }
}
void LoginDataDispatcher::SetAvatarForUser(const AccountId& account_id,
const UserAvatar& avatar) {
- for (auto& observer : observers_)
+ for (auto& observer : observers_) {
observer.OnUserAvatarChanged(account_id, avatar);
+ }
}
void LoginDataDispatcher::SetFingerprintState(const AccountId& account_id,
FingerprintState state) {
- for (auto& observer : observers_)
+ for (auto& observer : observers_) {
observer.OnFingerprintStateChanged(account_id, state);
+ }
}
void LoginDataDispatcher::NotifyFingerprintAuthResult(
const AccountId& account_id,
bool successful) {
- for (auto& observer : observers_)
+ for (auto& observer : observers_) {
observer.OnFingerprintAuthResult(account_id, successful);
+ }
}
void LoginDataDispatcher::ResetFingerprintUIState(const AccountId& account_id) {
- for (auto& observer : observers_)
+ for (auto& observer : observers_) {
observer.OnResetFingerprintUIState(account_id);
+ }
}
void LoginDataDispatcher::NotifySmartLockAuthResult(const AccountId& account_id,
bool successful) {
- for (auto& observer : observers_)
+ for (auto& observer : observers_) {
observer.OnSmartLockAuthResult(account_id, successful);
+ }
}
void LoginDataDispatcher::EnableAuthForUser(const AccountId& account_id) {
- for (auto& observer : observers_)
+ for (auto& observer : observers_) {
observer.OnAuthEnabledForUser(account_id);
+ }
}
void LoginDataDispatcher::DisableAuthForUser(
const AccountId& account_id,
const AuthDisabledData& auth_disabled_data) {
- for (auto& observer : observers_)
+ for (auto& observer : observers_) {
observer.OnAuthDisabledForUser(account_id, auth_disabled_data);
+ }
}
void LoginDataDispatcher::SetTpmLockedState(const AccountId& account_id,
bool is_locked,
base::TimeDelta time_left) {
- for (auto& observer : observers_)
+ for (auto& observer : observers_) {
observer.OnSetTpmLockedState(account_id, is_locked, time_left);
+ }
}
void LoginDataDispatcher::SetTapToUnlockEnabledForUser(const AccountId& user,
bool enabled) {
- for (auto& observer : observers_)
+ for (auto& observer : observers_) {
observer.OnTapToUnlockEnabledForUserChanged(user, enabled);
+ }
}
void LoginDataDispatcher::ForceOnlineSignInForUser(const AccountId& user) {
- for (auto& observer : observers_)
+ for (auto& observer : observers_) {
observer.OnForceOnlineSignInForUser(user);
+ }
}
void LoginDataDispatcher::SetLockScreenNoteState(mojom::TrayActionState state) {
- for (auto& observer : observers_)
+ for (auto& observer : observers_) {
observer.OnLockScreenNoteStateChanged(state);
+ }
}
void LoginDataDispatcher::ShowEasyUnlockIcon(
const AccountId& user,
const EasyUnlockIconInfo& icon_info) {
- if (base::FeatureList::IsEnabled(ash::features::kSmartLockUIRevamp))
+ if (base::FeatureList::IsEnabled(ash::features::kSmartLockUIRevamp)) {
return;
+ }
- for (auto& observer : observers_)
+ for (auto& observer : observers_) {
observer.OnShowEasyUnlockIcon(user, icon_info);
+ }
}
void LoginDataDispatcher::SetSmartLockState(const AccountId& user,
SmartLockState state) {
- for (auto& observer : observers_)
+ for (auto& observer : observers_) {
observer.OnSmartLockStateChanged(user, state);
+ }
}
void LoginDataDispatcher::UpdateWarningMessage(const std::u16string& message) {
- for (auto& observer : observers_)
+ for (auto& observer : observers_) {
observer.OnWarningMessageUpdated(message);
+ }
}
void LoginDataDispatcher::SetSystemInfo(
@@ -247,8 +265,9 @@
void LoginDataDispatcher::SetPublicSessionDisplayName(
const AccountId& account_id,
const std::string& display_name) {
- for (auto& observer : observers_)
+ for (auto& observer : observers_) {
observer.OnPublicSessionDisplayNameChanged(account_id, display_name);
+ }
}
void LoginDataDispatcher::SetPublicSessionLocales(
@@ -282,23 +301,27 @@
void LoginDataDispatcher::SetDetachableBasePairingStatus(
DetachableBasePairingStatus pairing_status) {
- for (auto& observer : observers_)
+ for (auto& observer : observers_) {
observer.OnDetachableBasePairingStatusChanged(pairing_status);
+ }
}
void LoginDataDispatcher::HandleFocusLeavingLockScreenApps(bool reverse) {
- for (auto& observer : observers_)
+ for (auto& observer : observers_) {
observer.OnFocusLeavingLockScreenApps(reverse);
+ }
}
void LoginDataDispatcher::NotifyOobeDialogState(OobeDialogState state) {
- for (auto& observer : observers_)
+ for (auto& observer : observers_) {
observer.OnOobeDialogStateChanged(state);
+ }
}
void LoginDataDispatcher::NotifyFocusPod(const AccountId& account_id) {
- for (auto& observer : observers_)
+ for (auto& observer : observers_) {
observer.OnFocusPod(account_id);
+ }
}
} // namespace ash
diff --git a/ash/login/ui/login_error_bubble.cc b/ash/login/ui/login_error_bubble.cc
index 25ad999..cb4d9b0 100644
--- a/ash/login/ui/login_error_bubble.cc
+++ b/ash/login/ui/login_error_bubble.cc
@@ -36,8 +36,9 @@
LoginErrorBubble::~LoginErrorBubble() = default;
void LoginErrorBubble::SetContent(std::unique_ptr<views::View> content) {
- if (content_)
+ if (content_) {
RemoveChildViewT(content_);
+ }
content_ = AddChildView(std::move(content));
}
@@ -68,8 +69,9 @@
// It is assumed that we will not have an external call to SetTextContent
// followed by a call to SetContent (in such a case, the content would be
// erased on theme changed and replaced with the prior message).
- if (!message_.empty())
+ if (!message_.empty()) {
SetTextContent(message_);
+ }
}
} // namespace ash
diff --git a/ash/login/ui/login_expanded_public_account_view.cc b/ash/login/ui/login_expanded_public_account_view.cc
index 6cf933f..6026aebc 100644
--- a/ash/login/ui/login_expanded_public_account_view.cc
+++ b/ash/login/ui/login_expanded_public_account_view.cc
@@ -116,8 +116,9 @@
private:
// ui::EventHandler:
void OnMouseEvent(ui::MouseEvent* event) override {
- if (event->type() == ui::ET_MOUSE_PRESSED)
+ if (event->type() == ui::ET_MOUSE_PRESSED) {
view_->ProcessPressedEvent(event->AsLocatedEvent());
+ }
}
void OnGestureEvent(ui::GestureEvent* event) override {
if ((event->type() == ui::ET_GESTURE_TAP ||
@@ -202,8 +203,9 @@
}
void SetMargins(int left, int right) {
- if (left_margin_ == left && right_margin_ == right)
+ if (left_margin_ == left && right_margin_ == right) {
return;
+ }
left_margin_ = left;
right_margin_ = right;
@@ -309,8 +311,9 @@
// Call sequence of UpdateForUser() and SetWarningType() is not clear.
// In case SetWarningType is called first there is a need to wait for
// device_manager_ is set.
- if (warning_type_ == WarningType::kNone || !device_manager_.has_value())
+ if (warning_type_ == WarningType::kNone || !device_manager_.has_value()) {
return;
+ }
std::u16string label_text;
if (warning_type_ == WarningType::kFullWarning) {
label_text = l10n_util::GetStringFUTF16(
@@ -433,17 +436,20 @@
DCHECK_EQ(user.basic_user_info.type,
user_manager::USER_TYPE_PUBLIC_ACCOUNT);
current_user_ = user;
- if (!language_changed_by_user_)
+ if (!language_changed_by_user_) {
selected_language_item_value_ = user.public_account_info->default_locale;
+ }
PopulateLanguageItems(user.public_account_info->available_locales);
if (user.public_account_info->default_locale ==
- selected_language_item_value_)
+ selected_language_item_value_) {
PopulateKeyboardItems(user.public_account_info->keyboard_layouts);
+ }
- if (!show_advanced_changed_by_user_)
+ if (!show_advanced_changed_by_user_) {
advanced_view_->SetVisible(user.public_account_info->show_advanced_view);
+ }
}
void OnLanguageSelected(const std::string& value) {
@@ -477,8 +483,9 @@
item.is_group = false;
item.selected = selected_language_item_value_ == locale.language_code;
}
- if (selected_language_item_value_ == locale.language_code)
+ if (selected_language_item_value_ == locale.language_code) {
selected_language_index = language_items_.size();
+ }
language_items_.push_back(item);
}
@@ -649,21 +656,24 @@
views::ImageView*
LoginExpandedPublicAccountView::TestApi::monitoring_warning_icon() {
- if (view_->monitoring_warning_view_)
+ if (view_->monitoring_warning_view_) {
return view_->monitoring_warning_view_->image_;
+ }
return nullptr;
}
views::Label*
LoginExpandedPublicAccountView::TestApi::monitoring_warning_label() {
- if (view_->monitoring_warning_view_)
+ if (view_->monitoring_warning_view_) {
return view_->monitoring_warning_view_->label_;
+ }
return nullptr;
}
void LoginExpandedPublicAccountView::TestApi::ResetUserForTest() {
- if (view_->monitoring_warning_view_)
+ if (view_->monitoring_warning_view_) {
view_->monitoring_warning_view_->device_manager_.reset();
+ }
}
bool LoginExpandedPublicAccountView::TestApi::SelectLanguage(
@@ -762,15 +772,18 @@
void LoginExpandedPublicAccountView::ProcessPressedEvent(
const ui::LocatedEvent* event) {
- if (!GetVisible())
+ if (!GetVisible()) {
return;
+ }
// Keep this view to be visible until learn more dialog is dismissed.
- if (learn_more_dialog_ && learn_more_dialog_->IsVisible())
+ if (learn_more_dialog_ && learn_more_dialog_->IsVisible()) {
return;
+ }
- if (GetBoundsInScreen().Contains(event->root_location()))
+ if (GetBoundsInScreen().Contains(event->root_location())) {
return;
+ }
// Ignore press event if the language or keyboard menu is still running,
// or if it had just been closed. Note that when we checked closed time,
@@ -800,8 +813,9 @@
void LoginExpandedPublicAccountView::UpdateForUser(const LoginUserInfo& user) {
user_view_->UpdateForUser(user, false /*animate*/);
right_pane_->UpdateForUser(user);
- if (monitoring_warning_view_)
+ if (monitoring_warning_view_) {
monitoring_warning_view_->UpdateForUser(user);
+ }
}
const LoginUserInfo& LoginExpandedPublicAccountView::current_user() const {
@@ -880,12 +894,14 @@
}
void LoginExpandedPublicAccountView::OnKeyEvent(ui::KeyEvent* event) {
- if (!GetVisible() || event->type() != ui::ET_KEY_PRESSED)
+ if (!GetVisible() || event->type() != ui::ET_KEY_PRESSED) {
return;
+ }
// Give learn more dialog a chance to handle key event.
- if (learn_more_dialog_ && learn_more_dialog_->IsVisible())
+ if (learn_more_dialog_ && learn_more_dialog_->IsVisible()) {
return;
+ }
if (event->key_code() == ui::KeyboardCode::VKEY_ESCAPE) {
Hide();
diff --git a/ash/login/ui/login_password_view.cc b/ash/login/ui/login_password_view.cc
index dafd7ea6..d55598f 100644
--- a/ash/login/ui/login_password_view.cc
+++ b/ash/login/ui/login_password_view.cc
@@ -255,21 +255,24 @@
// views::Textfield:
void OnBlur() override {
- if (on_blur_closure_)
+ if (on_blur_closure_) {
on_blur_closure_.Run();
+ }
views::Textfield::OnBlur();
}
// views::Textfield:
void OnFocus() override {
- if (on_focus_closure_)
+ if (on_focus_closure_) {
on_focus_closure_.Run();
+ }
views::Textfield::OnFocus();
}
void AboutToRequestFocusFromTabTraversal(bool reverse) override {
- if (!GetText().empty())
+ if (!GetText().empty()) {
SelectAll(/*reversed=*/false);
+ }
}
void UpdateFontListAndCursor() {
@@ -375,8 +378,9 @@
// else, we need to abort the current opacity animation and set back the
// opacity to 100%. This can be done by destroying the layer that we do not
// use anymore.
- if (layer())
+ if (layer()) {
DestroyLayer();
+ }
const gfx::VectorIcon* icon = &kLockScreenEasyUnlockCloseIcon;
const auto* color_provider = AshColorProvider::Get();
@@ -501,8 +505,9 @@
shown_after->SetVisible(false);
// Do not alternate between icons if ChromeVox is enabled.
- if (Shell::Get()->accessibility_controller()->spoken_feedback().enabled())
+ if (Shell::Get()->accessibility_controller()->spoken_feedback().enabled()) {
return;
+ }
std::unique_ptr<ui::LayerAnimationSequence> opacity_sequence =
std::make_unique<ui::LayerAnimationSequence>();
@@ -708,8 +713,9 @@
const std::u16string& accessibility_label) {
// Do not update EasyUnlockIconState if the Smart Lock revamp is enabled since
// it will be removed post launch.
- if (base::FeatureList::IsEnabled(ash::features::kSmartLockUIRevamp))
+ if (base::FeatureList::IsEnabled(ash::features::kSmartLockUIRevamp)) {
return;
+ }
// Update icon.
easy_unlock_icon_->SetEasyUnlockIcon(icon_state, accessibility_label);
@@ -718,8 +724,9 @@
bool has_icon = icon_state != EasyUnlockIconState::NONE;
// We do not want to schedule a new animation when the user switches from an
// account to another.
- if (should_show_easy_unlock_ == has_icon)
+ if (should_show_easy_unlock_ == has_icon) {
return;
+ }
should_show_easy_unlock_ = has_icon;
HandleLeftIconsVisibilities(false /*handling_capslock*/);
}
@@ -736,8 +743,9 @@
void LoginPasswordView::SetDisplayPasswordButtonVisible(bool visible) {
display_password_button_->SetVisible(visible);
// Only start the timer if the display password button is enabled.
- if (visible)
+ if (visible) {
clear_password_timer_.Reset();
+ }
}
void LoginPasswordView::Reset() {
@@ -750,8 +758,9 @@
}
void LoginPasswordView::InsertNumber(int value) {
- if (textfield_->GetReadOnly())
+ if (textfield_->GetReadOnly()) {
return;
+ }
if (!textfield_->HasFocus()) {
// RequestFocus on textfield to activate cursor.
@@ -840,26 +849,31 @@
on_password_text_changed_.Run(new_contents.empty() /*is_empty*/);
// If the password is currently revealed.
- if (textfield_->GetTextInputType() == ui::TEXT_INPUT_TYPE_NULL)
+ if (textfield_->GetTextInputType() == ui::TEXT_INPUT_TYPE_NULL) {
hide_password_timer_.Reset();
+ }
// The display password button could be hidden by user policy.
- if (display_password_button_->GetVisible())
+ if (display_password_button_->GetVisible()) {
clear_password_timer_.Reset();
+ }
}
// Implements swapping active user with arrow keys
bool LoginPasswordView::HandleKeyEvent(views::Textfield* sender,
const ui::KeyEvent& key_event) {
// Treat the password field as normal if it has text
- if (!textfield_->GetText().empty())
+ if (!textfield_->GetText().empty()) {
return false;
+ }
- if (key_event.type() != ui::ET_KEY_PRESSED)
+ if (key_event.type() != ui::ET_KEY_PRESSED) {
return false;
+ }
- if (key_event.is_repeat())
+ if (key_event.is_repeat()) {
return false;
+ }
switch (key_event.key_code()) {
case ui::VKEY_LEFT:
@@ -880,8 +894,9 @@
// Disabling the submit button will make it lose focus. The previous focusable
// view will be the password textfield, which is more expected than the user
// drop down button.
- if (!enable_buttons && submit_button_->HasFocus())
+ if (!enable_buttons && submit_button_->HasFocus()) {
RequestFocus();
+ }
submit_button_->SetEnabled(enable_buttons);
display_password_button_->SetEnabled(enable_buttons);
}
@@ -938,8 +953,9 @@
void LoginPasswordView::SubmitPassword() {
DCHECK(IsPasswordSubmittable());
- if (textfield_->GetReadOnly())
+ if (textfield_->GetReadOnly()) {
return;
+ }
SetReadOnly(true);
on_submit_.Run(textfield_->GetText());
}
diff --git a/ash/login/ui/login_pin_input_view.cc b/ash/login/ui/login_pin_input_view.cc
index 18f250c..7e49d0bce 100644
--- a/ash/login/ui/login_pin_input_view.cc
+++ b/ash/login/ui/login_pin_input_view.cc
@@ -108,8 +108,9 @@
bool LoginPinInput::HandleGestureEvent(views::Textfield* sender,
const ui::GestureEvent& gesture_event) {
- if (gesture_event.details().type() != ui::EventType::ET_GESTURE_TAP)
+ if (gesture_event.details().type() != ui::EventType::ET_GESTURE_TAP) {
return false;
+ }
FixedLengthCodeInput::RequestFocus();
return true;
@@ -134,7 +135,7 @@
node_data->SetDescription(l10n_util::GetPluralStringFUTF16(
IDS_ASH_LOGIN_PIN_INPUT_DIGITS_REMAINING, remaining_digits));
node_data->SetName(l10n_util::GetStringUTF8(
- IDS_ASH_LOGIN_POD_PASSWORD_PIN_INPUT_ACCESSIBLE_NAME));
+ IDS_ASH_LOGIN_POD_PASSWORD_PIN_INPUT_ACCESSIBLE_NAME));
}
const int LoginPinInputView::kDefaultLength = 6;
@@ -192,8 +193,9 @@
void LoginPinInputView::UpdateLength(const size_t pin_length) {
// If the length is 0 (unknown) auto submit is disabled and not visible.
// Only recreate the UI if the length is different than the current one.
- if (pin_length == 0 || pin_length == length_)
+ if (pin_length == 0 || pin_length == length_) {
return;
+ }
length_ = pin_length;
@@ -233,8 +235,9 @@
void LoginPinInputView::InsertDigit(int digit) {
DCHECK(code_input_);
- if (!IsReadOnly())
+ if (!IsReadOnly()) {
code_input_->InsertDigit(digit);
+ }
}
void LoginPinInputView::SetReadOnly(bool read_only) {
@@ -247,8 +250,7 @@
}
gfx::Size LoginPinInputView::CalculatePreferredSize() const {
- const int ideal_size = kFieldWidth * length_ +
- kFieldSpace * (length_ - 1);
+ const int ideal_size = kFieldWidth * length_ + kFieldSpace * (length_ - 1);
return gfx::Size(std::min(kMaxWidthPinInputDp, ideal_size),
kPinInputTotalHeightDp);
}
@@ -273,8 +275,9 @@
}
void LoginPinInputView::OnChanged(bool is_empty) {
- if (on_changed_)
+ if (on_changed_) {
on_changed_.Run(is_empty);
+ }
}
} // namespace ash
diff --git a/ash/login/ui/login_pin_input_view_unittest.cc b/ash/login/ui/login_pin_input_view_unittest.cc
index d89b880f..d88f173 100644
--- a/ash/login/ui/login_pin_input_view_unittest.cc
+++ b/ash/login/ui/login_pin_input_view_unittest.cc
@@ -111,18 +111,18 @@
PressKeyHelper(ui::KeyboardCode::VKEY_1);
ExpectDescription("5 digits remaining");
- ExpectTextValue("\u2022 "); /* 1 bullet 5 spaces */
+ ExpectTextValue("\u2022 "); /* 1 bullet 5 spaces */
PressKeyHelper(ui::KeyboardCode::VKEY_1);
ExpectDescription("4 digits remaining");
- ExpectTextValue("\u2022\u2022 "); /* 2 bullets 4 spaces */
+ ExpectTextValue("\u2022\u2022 "); /* 2 bullets 4 spaces */
PressKeyHelper(ui::KeyboardCode::VKEY_1);
ExpectDescription("3 digits remaining");
- ExpectTextValue("\u2022\u2022\u2022 "); /* 3 bullets 3 spaces */
+ ExpectTextValue("\u2022\u2022\u2022 "); /* 3 bullets 3 spaces */
PressKeyHelper(ui::KeyboardCode::VKEY_1);
- ExpectTextValue("\u2022\u2022\u2022\u2022 "); /* 4 bullets 2 spaces */
+ ExpectTextValue("\u2022\u2022\u2022\u2022 "); /* 4 bullets 2 spaces */
ExpectDescription("2 digits remaining");
PressKeyHelper(ui::KeyboardCode::VKEY_1);
diff --git a/ash/login/ui/login_pin_view.cc b/ash/login/ui/login_pin_view.cc
index adacd379..5652d04 100644
--- a/ash/login/ui/login_pin_view.cc
+++ b/ash/login/ui/login_pin_view.cc
@@ -179,8 +179,9 @@
protected:
// Called when the button has been pressed.
virtual void DispatchPress(ui::Event* event) {
- if (event)
+ if (event) {
event->SetHandled();
+ }
views::InkDrop::Get(this)->AnimateToState(
views::InkDropState::ACTION_TRIGGERED,
@@ -188,8 +189,9 @@
SchedulePaint();
// |on_press_| may delete us.
- if (on_press_)
+ if (on_press_) {
on_press_.Run();
+ }
}
// Handler for press events. May be null.
@@ -287,8 +289,9 @@
// BasePinButton:
void OnEvent(ui::Event* event) override {
BasePinButton::OnEvent(event);
- if (event->handled())
+ if (event->handled()) {
return;
+ }
// If this is a button release style event cancel any repeat.
if (event->type() == ui::ET_GESTURE_TAP_CANCEL ||
event->type() == ui::ET_GESTURE_END ||
@@ -315,8 +318,9 @@
base::BindOnce(&BackspacePinButton::DispatchPress,
base::Unretained(this), nullptr));
- if (event)
+ if (event) {
event->SetHandled();
+ }
views::InkDrop::Get(this)->AnimateToState(
views::InkDropState::ACTIVATED, ui::LocatedEvent::FromIfValid(event));
@@ -335,24 +339,27 @@
}
// Run handler.
- if (on_press_)
+ if (on_press_) {
on_press_.Run();
+ }
}
private:
// Cancels a long-press. If the press event has not been triggered yet this
// will trigger it.
void CancelRepeat() {
- if (!is_held_)
+ if (!is_held_) {
return;
+ }
bool did_submit = !delay_timer_->IsRunning();
delay_timer_->Stop();
repeat_timer_->Stop();
is_held_ = false;
- if (!did_submit && on_press_)
+ if (!did_submit && on_press_) {
on_press_.Run();
+ }
views::InkDrop::Get(this)->AnimateToState(views::InkDropState::DEACTIVATED,
nullptr);
@@ -509,8 +516,9 @@
void LoginPinView::OnPasswordTextChanged(bool is_empty) {
backspace_->SetEnabled(!is_empty);
- if (submit_button_)
+ if (submit_button_) {
submit_button_->SetEnabled(!is_empty);
+ }
}
NonAccessibleView* LoginPinView::BuildAndAddRow() {
diff --git a/ash/login/ui/login_pin_view_unittest.cc b/ash/login/ui/login_pin_view_unittest.cc
index b9be595..dfa964ad 100644
--- a/ash/login/ui/login_pin_view_unittest.cc
+++ b/ash/login/ui/login_pin_view_unittest.cc
@@ -143,12 +143,14 @@
// Validate each x or y coordinate has the correct distance between it and the
// next one. This is correct because we have already validated button size.
EXPECT_EQ(3u, sorted_x.size());
- for (size_t i = 0; i < sorted_x.size() - 1; ++i)
+ for (size_t i = 0; i < sorted_x.size() - 1; ++i) {
EXPECT_EQ(sorted_x[i] + expected_button_size.width(), sorted_x[i + 1]);
+ }
EXPECT_EQ(4u, sorted_y.size());
- for (size_t i = 0; i < sorted_y.size() - 1; ++i)
+ for (size_t i = 0; i < sorted_y.size() - 1; ++i) {
EXPECT_EQ(sorted_y[i] + expected_button_size.height(), sorted_y[i + 1]);
+ }
}
// Validates buttons have the correct spacing for numeric PIN keyboard style.
@@ -201,12 +203,14 @@
// Validate each x or y coordinate has the correct distance between it and the
// next one. This is correct because we have already validated button size.
EXPECT_EQ(3u, sorted_x.size());
- for (size_t i = 0; i < sorted_x.size() - 1; ++i)
+ for (size_t i = 0; i < sorted_x.size() - 1; ++i) {
EXPECT_EQ(sorted_x[i] + expected_button_size.width(), sorted_x[i + 1]);
+ }
EXPECT_EQ(4u, sorted_y.size());
- for (size_t i = 0; i < sorted_y.size() - 1; ++i)
+ for (size_t i = 0; i < sorted_y.size() - 1; ++i) {
EXPECT_EQ(sorted_y[i] + expected_button_size.height(), sorted_y[i + 1]);
+ }
}
// Verifies that holding the backspace button automatically triggers and begins
diff --git a/ash/login/ui/login_public_account_user_view.cc b/ash/login/ui/login_public_account_user_view.cc
index cb0d68b..d029f8b 100644
--- a/ash/login/ui/login_public_account_user_view.cc
+++ b/ash/login/ui/login_public_account_user_view.cc
@@ -79,8 +79,9 @@
kArrowButtonSizeDp);
std::string display_name = user.basic_user_info.display_name;
// display_name can be empty in debug builds with stub users.
- if (display_name.empty())
+ if (display_name.empty()) {
display_name = user.basic_user_info.display_email;
+ }
arrow_button->SetAccessibleName(l10n_util::GetStringFUTF16(
IDS_ASH_LOGIN_PUBLIC_ACCOUNT_DIALOG_BUTTON_ACCESSIBLE_NAME,
base::UTF8ToUTF16(display_name)));
@@ -140,8 +141,9 @@
// on it will not do anything (such as swapping users).
user_view_->SetForceOpaque(enabled);
user_view_->SetTapEnabled(!enabled);
- if (enabled)
+ if (enabled) {
arrow_button_->RequestFocus();
+ }
PreferredSizeChanged();
}
@@ -165,8 +167,9 @@
void LoginPublicAccountUserView::ArrowButtonPressed() {
DCHECK(arrow_button_);
// If the pod isn't active, activate it first.
- if (!auth_enabled_)
+ if (!auth_enabled_) {
OnUserViewTap();
+ }
DCHECK(auth_enabled_);
on_public_account_tap_.Run();
@@ -177,8 +180,9 @@
}
void LoginPublicAccountUserView::OnHover(bool has_hover) {
- if (!ignore_hover_)
+ if (!ignore_hover_) {
UpdateArrowButtonOpacity(has_hover ? 1 : 0, true /*animate*/);
+ }
}
void LoginPublicAccountUserView::UpdateArrowButtonOpacity(float target_opacity,
diff --git a/ash/login/ui/login_remove_account_dialog.cc b/ash/login/ui/login_remove_account_dialog.cc
index 8199c91..44c00428 100644
--- a/ash/login/ui/login_remove_account_dialog.cc
+++ b/ash/login/ui/login_remove_account_dialog.cc
@@ -97,8 +97,9 @@
bubble_->GetBubbleOpener()->RequestFocus();
}
- if (event->key_code() == ui::VKEY_RETURN)
+ if (event->key_code() == ui::VKEY_RETURN) {
views::Button::OnKeyEvent(event);
+ }
}
LoginRemoveAccountDialog* bubble_;
@@ -223,8 +224,9 @@
LoginRemoveAccountDialog::~LoginRemoveAccountDialog() = default;
void LoginRemoveAccountDialog::ResetState() {
- if (management_disclosure_label_)
+ if (management_disclosure_label_) {
management_disclosure_label_->SetVisible(true);
+ }
if (remove_user_confirm_data_) {
remove_user_confirm_data_->SetVisible(false);
remove_user_button_->SetBackgroundAndFont(/*alert_mode=*/false);
@@ -265,8 +267,9 @@
void LoginRemoveAccountDialog::RequestFocus() {
// This view has no actual interesting contents to focus, so immediately
// forward to the button.
- if (remove_user_button_)
+ if (remove_user_button_) {
remove_user_button_->RequestFocus();
+ }
}
bool LoginRemoveAccountDialog::HasFocus() const {
@@ -319,8 +322,9 @@
// we actually allow the exit.
if (!remove_user_confirm_data_->GetVisible()) {
remove_user_confirm_data_->SetVisible(true);
- if (management_disclosure_label_)
+ if (management_disclosure_label_) {
management_disclosure_label_->SetVisible(false);
+ }
remove_user_button_->SetBackgroundAndFont(/*alert_mode=*/true);
Layout();
@@ -329,8 +333,9 @@
// ChromeVox, to report the updated description.
remove_user_button_->GetViewAccessibility().OverrideDescription(
warning_message_);
- if (on_remove_user_warning_shown_)
+ if (on_remove_user_warning_shown_) {
std::move(on_remove_user_warning_shown_).Run();
+ }
return;
}
@@ -339,8 +344,9 @@
// for this bubble is being torn down, we can get a crash.
SetVisible(false);
- if (on_remove_user_requested_)
+ if (on_remove_user_requested_) {
std::move(on_remove_user_requested_).Run();
+ }
}
} // namespace ash
diff --git a/ash/login/ui/login_test_base.cc b/ash/login/ui/login_test_base.cc
index 7e638fd..1065a66 100644
--- a/ash/login/ui/login_test_base.cc
+++ b/ash/login/ui/login_test_base.cc
@@ -42,8 +42,9 @@
GetSessionControllerClient()->SetSessionState(
session_manager::SessionState::LOGIN_PRIMARY);
// The login screen can't be shown without a wallpaper.
- if (set_wallpaper)
+ if (set_wallpaper) {
Shell::Get()->wallpaper_controller()->ShowDefaultWallpaperForTesting();
+ }
Shell::Get()->login_screen_controller()->ShowLoginScreen();
// Allow focus to reach the appropriate View.
@@ -129,12 +130,13 @@
}
void LoginTestBase::RemoveUser(const AccountId& account_id) {
- for (auto it = users().cbegin(); it != users().cend(); ++it)
+ for (auto it = users().cbegin(); it != users().cend(); ++it) {
if (it->basic_user_info.account_id == account_id) {
users().erase(it);
DataDispatcher()->SetUserList(users());
return;
}
+ }
ADD_FAILURE() << "User not found: " << account_id.Serialize();
}
@@ -145,8 +147,9 @@
void LoginTestBase::TearDown() {
widget_.reset();
- if (LockScreen::HasInstance())
+ if (LockScreen::HasInstance()) {
LockScreen::Get()->Destroy();
+ }
AshTestBase::TearDown();
}
diff --git a/ash/login/ui/login_test_utils.cc b/ash/login/ui/login_test_utils.cc
index 0bbff0c..4281a74 100644
--- a/ash/login/ui/login_test_utils.cc
+++ b/ash/login/ui/login_test_utils.cc
@@ -105,8 +105,9 @@
for (int i = 0; i < 50; ++i) {
event_generator->PressKey(ui::KeyboardCode::VKEY_TAB,
reverse ? ui::EF_SHIFT_DOWN : 0);
- if (!HasFocusInAnyChildView(view))
+ if (!HasFocusInAnyChildView(view)) {
return true;
+ }
}
return false;
@@ -116,12 +117,14 @@
// The last child is on the top of the z layer stack
views::View* FindTopButton(views::View* current_view) {
for (auto* child : base::Reversed(current_view->children())) {
- if (views::Button::AsButton(child))
+ if (views::Button::AsButton(child)) {
return child;
+ }
if (!child->children().empty()) {
views::View* child_button = FindTopButton(child);
- if (child_button)
+ if (child_button) {
return child_button;
+ }
}
}
return nullptr;
diff --git a/ash/login/ui/login_user_view.cc b/ash/login/ui/login_user_view.cc
index eff8b27d..4e0abca 100644
--- a/ash/login/ui/login_user_view.cc
+++ b/ash/login/ui/login_user_view.cc
@@ -193,8 +193,9 @@
// Set the initial image from |avatar| since we already have it available.
// Then, decode the bytes via blink's PNG decoder and play any animated
// frames if they are available.
- if (!user.basic_user_info.avatar.image.isNull())
+ if (!user.basic_user_info.avatar.image.isNull()) {
image_->SetImage(user.basic_user_info.avatar.image);
+ }
// Decode the avatar using blink, as blink's PNG decoder supports APNG,
// which is the format used for the animated avators.
@@ -305,8 +306,9 @@
void UpdateForUser(const LoginUserInfo& user) {
std::string display_name = user.basic_user_info.display_name;
// display_name can be empty in debug builds with stub users.
- if (display_name.empty())
+ if (display_name.empty()) {
display_name = user.basic_user_info.display_email;
+ }
user_name_->SetText(gfx::ElideText(base::UTF8ToUTF16(display_name),
user_name_->font_list(), label_width_,
@@ -473,15 +475,17 @@
};
setup_layer(user_image_);
setup_layer(user_label_);
- if (dropdown_)
+ if (dropdown_) {
setup_layer(dropdown_);
+ }
hover_notifier_ = std::make_unique<HoverNotifier>(
this,
base::BindRepeating(&LoginUserView::OnHover, base::Unretained(this)));
- if (ash::Shell::HasInstance())
+ if (ash::Shell::HasInstance()) {
display_observation_.Observe(ash::Shell::Get()->display_configurator());
+ }
}
LoginUserView::~LoginUserView() {
@@ -607,8 +611,9 @@
std::rotate(it, it + 1, children.end());
};
move_child_to_top(tap_button_);
- if (dropdown_)
+ if (dropdown_) {
move_child_to_top(dropdown_);
+ }
return children;
}
@@ -629,9 +634,10 @@
bool opener_focused = remove_account_dialog_->GetBubbleOpener() &&
remove_account_dialog_->GetBubbleOpener()->HasFocus();
- if (!remove_account_dialog_->parent())
+ if (!remove_account_dialog_->parent()) {
login_views_utils::GetBubbleContainer(this)->AddChildView(
remove_account_dialog_);
+ }
// Reset state in case the remove-user button was clicked once previously.
remove_account_dialog_->ResetState();
@@ -640,8 +646,9 @@
// If the remove account dialog was opened by pressing Enter on the focused
// dropdown, focus should automatically go to the remove-user button (for
// keyboard accessibility).
- if (opener_focused)
+ if (opener_focused) {
remove_account_dialog_->RequestFocus();
+ }
}
void LoginUserView::UpdateCurrentUserState() {
@@ -679,8 +686,9 @@
bool was_opaque = is_opaque_;
is_opaque_ =
force_opaque_ || tap_button_->IsMouseHovered() || tap_button_->HasFocus();
- if (was_opaque == is_opaque_)
+ if (was_opaque == is_opaque_) {
return;
+ }
// Animate to new opacity.
auto build_settings = [](views::View* view)
@@ -740,13 +748,15 @@
views::LayoutAlignment::kCenter);
auto* skip_column = AddChildView(std::make_unique<NonAccessibleView>());
- if (dropdown_)
+ if (dropdown_) {
skip_column->SetPreferredSize(dropdown_->GetPreferredSize());
+ }
AddChildView(user_label_);
- if (dropdown_)
+ if (dropdown_) {
AddChildView(dropdown_);
+ }
}
void LoginUserView::SetSmallishLayout() {
@@ -762,8 +772,9 @@
void LoginUserView::DeleteDialog() {
if (remove_account_dialog_) {
- if (remove_account_dialog_->parent())
+ if (remove_account_dialog_->parent()) {
remove_account_dialog_->parent()->RemoveChildView(remove_account_dialog_);
+ }
delete remove_account_dialog_;
remove_account_dialog_ = nullptr;
}
diff --git a/ash/login/ui/note_action_launch_button.cc b/ash/login/ui/note_action_launch_button.cc
index cee77b9..9b349df 100644
--- a/ash/login/ui/note_action_launch_button.cc
+++ b/ash/login/ui/note_action_launch_button.cc
@@ -126,8 +126,9 @@
// applying scale transform to the view's layout. Transformations are
// animated.
void SetBubbleRadiusAndOpacity(int target_radius, float opacity) {
- if (target_radius == bubble_radius_ && opacity_ == opacity)
+ if (target_radius == bubble_radius_ && opacity_ == opacity) {
return;
+ }
ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator());
settings.SetPreemptionStrategy(
@@ -138,8 +139,9 @@
if (target_radius != kLargeBubbleRadiusDp) {
// Move the buble to it's new origin before scaling the image - note that
// in RTL layout, the origin remains the same - (0, 0) in local bounds.
- if (!base::i18n::IsRTL())
+ if (!base::i18n::IsRTL()) {
transform.Translate(kLargeBubbleRadiusDp - target_radius, 0);
+ }
float scale = target_radius / static_cast<float>(kLargeBubbleRadiusDp);
transform.Scale(scale, scale);
}
@@ -259,8 +261,9 @@
// If the user has added fingers to the gesture, cancel the fling
// detection - the note action requests are restricted to single finger
// gestures.
- if (event->details().touch_points() != 1)
+ if (event->details().touch_points() != 1) {
SetTrackingPotentialActivationGesture(false);
+ }
break;
case ui::ET_GESTURE_END:
case ui::ET_GESTURE_SCROLL_END:
@@ -276,8 +279,9 @@
break;
}
- if (!event->handled())
+ if (!event->handled()) {
views::ImageButton::OnGestureEvent(event);
+ }
}
private:
diff --git a/ash/login/ui/note_action_launch_button_unittest.cc b/ash/login/ui/note_action_launch_button_unittest.cc
index deea21f2..b94bdca 100644
--- a/ash/login/ui/note_action_launch_button_unittest.cc
+++ b/ash/login/ui/note_action_launch_button_unittest.cc
@@ -55,7 +55,6 @@
TestTrayActionClient* tray_action_client() { return &tray_action_client_; }
-
void PerformClick(const gfx::Point& point) {
ui::test::EventGenerator* generator = GetEventGenerator();
generator->MoveMouseTo(point.x(), point.y());
diff --git a/ash/login/ui/pin_keyboard_animation.cc b/ash/login/ui/pin_keyboard_animation.cc
index e328228..7857138 100644
--- a/ash/login/ui/pin_keyboard_animation.cc
+++ b/ash/login/ui/pin_keyboard_animation.cc
@@ -20,8 +20,9 @@
LayerAnimationElement::TRANSFORM | LayerAnimationElement::OPACITY,
duration),
tween_type_(tween_type) {
- if (!grow)
+ if (!grow) {
std::swap(start_opacity_, end_opacity_);
+ }
transform_ = std::make_unique<ui::InterpolatedScale>(
gfx::Point3F(1, start_opacity_, 1), gfx::Point3F(1, end_opacity_, 1));
diff --git a/ash/login/ui/pin_request_view.cc b/ash/login/ui/pin_request_view.cc
index 0b2bdf34..07840e3 100644
--- a/ash/login/ui/pin_request_view.cc
+++ b/ash/login/ui/pin_request_view.cc
@@ -505,8 +505,9 @@
void PinRequestView::UpdatePreferredSize() {
SetPreferredSize(CalculatePreferredSize());
- if (GetWidget())
+ if (GetWidget()) {
GetWidget()->CenterWindow(GetPreferredSize());
+ }
}
void PinRequestView::FocusSubmitButton() {
@@ -557,8 +558,9 @@
std::min(static_cast<int>(description_label_->GetRequiredLines()),
kDescriptionMaxLines) *
kDescriptionTextLineHeightDp;
- if (PinKeyboardVisible())
+ if (PinKeyboardVisible()) {
height += kPinKeyboardHeightDp;
+ }
return gfx::Size(kPinRequestViewWidthDp, height);
}
diff --git a/ash/login/ui/pin_request_view_unittest.cc b/ash/login/ui/pin_request_view_unittest.cc
index 20b39cb8..a7d4d34 100644
--- a/ash/login/ui/pin_request_view_unittest.cc
+++ b/ash/login/ui/pin_request_view_unittest.cc
@@ -67,8 +67,9 @@
// If the test did not explicitly dismissed the widget, destroy it now.
PinRequestWidget* pin_request_widget = PinRequestWidget::Get();
- if (pin_request_widget)
+ if (pin_request_widget) {
pin_request_widget->Close(false /* validation success */);
+ }
}
PinRequestView::SubmissionResult OnPinSubmitted(
diff --git a/ash/login/ui/pin_request_widget.cc b/ash/login/ui/pin_request_widget.cc
index f697f6d..944f7792 100644
--- a/ash/login/ui/pin_request_widget.cc
+++ b/ash/login/ui/pin_request_widget.cc
@@ -43,8 +43,9 @@
PinRequestView::Delegate* delegate) {
DCHECK(!instance_);
instance_ = new PinRequestWidget(std::move(request), delegate);
- if (GetOnShownCallback())
+ if (GetOnShownCallback()) {
GetOnShownCallback().Run();
+ }
}
// static
@@ -104,8 +105,9 @@
: kShellWindowId_LockSystemModalContainer;
widget_params.parent =
Shell::GetPrimaryRootWindow()->GetChildById(parent_window_id);
- if (request.extra_dimmer)
+ if (request.extra_dimmer) {
dimmer_ = std::make_unique<WindowDimmer>(widget_params.parent);
+ }
request.on_pin_request_done =
base::BindOnce(&PinRequestWidget::Close, weak_factory_.GetWeakPtr());
widget_params.delegate = new PinRequestView(std::move(request), delegate);
@@ -119,15 +121,17 @@
PinRequestWidget::~PinRequestWidget() = default;
void PinRequestWidget::Show() {
- if (dimmer_)
+ if (dimmer_) {
dimmer_->window()->Show();
+ }
DCHECK(widget_);
widget_->Show();
auto* keyboard_controller = Shell::Get()->keyboard_controller();
- if (keyboard_controller && keyboard_controller->IsKeyboardEnabled())
+ if (keyboard_controller && keyboard_controller->IsKeyboardEnabled()) {
keyboard_controller->HideKeyboard(HideReason::kSystem);
+ }
}
PinRequestView* PinRequestWidget::GetView() {
diff --git a/ash/login/ui/public_account_monitoring_info_dialog.cc b/ash/login/ui/public_account_monitoring_info_dialog.cc
index cffffa6..1ed96466 100644
--- a/ash/login/ui/public_account_monitoring_info_dialog.cc
+++ b/ash/login/ui/public_account_monitoring_info_dialog.cc
@@ -106,8 +106,9 @@
}
PublicAccountMonitoringInfoDialog::~PublicAccountMonitoringInfoDialog() {
- if (controller_)
+ if (controller_) {
controller_->OnLearnMoreDialogClosed();
+ }
}
bool PublicAccountMonitoringInfoDialog::IsVisible() {
@@ -115,8 +116,9 @@
}
void PublicAccountMonitoringInfoDialog::Show() {
- if (GetWidget())
+ if (GetWidget()) {
GetWidget()->Show();
+ }
}
void PublicAccountMonitoringInfoDialog::AddedToWidget() {
diff --git a/ash/login/ui/scrollable_users_list_view.cc b/ash/login/ui/scrollable_users_list_view.cc
index abf059eb..f6bd158 100644
--- a/ash/login/ui/scrollable_users_list_view.cc
+++ b/ash/login/ui/scrollable_users_list_view.cc
@@ -228,8 +228,9 @@
LoginUserView* ScrollableUsersListView::GetUserView(
const AccountId& account_id) {
for (auto* view : user_views_) {
- if (view->current_user().basic_user_info.account_id == account_id)
+ if (view->current_user().basic_user_info.account_id == account_id) {
return view;
+ }
}
return nullptr;
}
@@ -251,8 +252,9 @@
if (parent()) {
int parent_height = parent()->size().height();
ClipHeightTo(parent_height, parent_height);
- if (height() != parent_height)
+ if (height() != parent_height) {
PreferredSizeChanged();
+ }
}
UpdateUserViewHostLayoutInsets();
@@ -282,8 +284,9 @@
// Draws symmetrical linear gradient at the top and bottom of the view.
SkScalar view_height = render_bounds.height();
SkScalar gradient_height = gradient_params_.height;
- if (gradient_height == 0)
+ if (gradient_height == 0) {
gradient_height = view_height;
+ }
// Start and end point of the drawing in view space.
SkPoint in_view_coordinates[2] = {SkPoint(),
diff --git a/ash/login/ui/smart_lock_auth_factor_model.cc b/ash/login/ui/smart_lock_auth_factor_model.cc
index 05478b82..906b4db 100644
--- a/ash/login/ui/smart_lock_auth_factor_model.cc
+++ b/ash/login/ui/smart_lock_auth_factor_model.cc
@@ -23,9 +23,10 @@
SmartLockAuthFactorModel::Factory::Create(
SmartLockState initial_state,
base::RepeatingCallback<void()> arrow_button_tap_callback) {
- if (factory_instance_)
+ if (factory_instance_) {
return factory_instance_->CreateInstance(initial_state,
arrow_button_tap_callback);
+ }
return std::make_unique<SmartLockAuthFactorModel>(initial_state,
arrow_button_tap_callback);
}
@@ -51,8 +52,9 @@
}
void SmartLockAuthFactorModel::SetSmartLockState(SmartLockState state) {
- if (state_ == state)
+ if (state_ == state) {
return;
+ }
// Clear out the timeout if the state changes. This shouldn't happen
// ordinarily -- permanent error states are permanent after all -- but this is
diff --git a/ash/login/ui/user_switch_flip_animation.cc b/ash/login/ui/user_switch_flip_animation.cc
index 6ed651af..613efcb 100644
--- a/ash/login/ui/user_switch_flip_animation.cc
+++ b/ash/login/ui/user_switch_flip_animation.cc
@@ -27,8 +27,9 @@
gfx::Vector3dF(0, 1, 0), start_degrees, end_degrees);
gfx::Transform from_center;
- if (horizontal_flip)
+ if (horizontal_flip) {
from_center.RotateAboutYAxis(180);
+ }
from_center.Translate(-width / 2.f, 0);
auto move_from_center =
std::make_unique<ui::InterpolatedConstantTransform>(from_center);
@@ -76,8 +77,9 @@
// Second half.
else {
- if (on_midpoint_)
+ if (on_midpoint_) {
std::move(on_midpoint_).Run();
+ }
current = (current - 0.5) * 2;
const double tweened = gfx::Tween::CalculateValue(tween_type_, current);
diff --git a/ash/login/ui/views_utils.cc b/ash/login/ui/views_utils.cc
index 74fceef..6e20127 100644
--- a/ash/login/ui/views_utils.cc
+++ b/ash/login/ui/views_utils.cc
@@ -75,8 +75,9 @@
// in that case. A new layout will happen when the view is attached to a
// widget (see LockContentsView::AddedToWidget), which will let us fetch the
// correct display orientation.
- if (!widget)
+ if (!widget) {
return true;
+ }
// Get the orientation for |widget|.
const display::Display& display =
@@ -101,8 +102,9 @@
// Find the topmost ancestor of the focused view, or |view|, whichever comes
// first.
views::View* search = view->GetFocusManager()->GetFocusedView();
- while (search && search != view)
+ while (search && search != view) {
search = search->parent();
+ }
return search == view;
}
@@ -156,8 +158,9 @@
views::View* GetBubbleContainer(views::View* view) {
views::View* v = view;
- while (v->parent() != nullptr)
+ while (v->parent() != nullptr) {
v = v->parent();
+ }
views::View* root_view = v;
// An arbitrary id that no other child of root view should use.
diff --git a/chromeos/ash/components/cryptohome/auth_factor_input.cc b/chromeos/ash/components/cryptohome/auth_factor_input.cc
index ece4838..5225e29 100644
--- a/chromeos/ash/components/cryptohome/auth_factor_input.cc
+++ b/chromeos/ash/components/cryptohome/auth_factor_input.cc
@@ -35,37 +35,49 @@
AuthFactorInput::~AuthFactorInput() = default;
AuthFactorType AuthFactorInput::GetType() const {
- if (absl::holds_alternative<AuthFactorInput::Password>(factor_input_))
+ if (absl::holds_alternative<AuthFactorInput::Password>(factor_input_)) {
return AuthFactorType::kPassword;
- if (absl::holds_alternative<AuthFactorInput::Pin>(factor_input_))
+ }
+ if (absl::holds_alternative<AuthFactorInput::Pin>(factor_input_)) {
return AuthFactorType::kPin;
- if (absl::holds_alternative<AuthFactorInput::Kiosk>(factor_input_))
+ }
+ if (absl::holds_alternative<AuthFactorInput::Kiosk>(factor_input_)) {
return AuthFactorType::kKiosk;
- if (absl::holds_alternative<AuthFactorInput::SmartCard>(factor_input_))
+ }
+ if (absl::holds_alternative<AuthFactorInput::SmartCard>(factor_input_)) {
return AuthFactorType::kSmartCard;
- if (absl::holds_alternative<AuthFactorInput::RecoveryCreation>(factor_input_))
+ }
+ if (absl::holds_alternative<AuthFactorInput::RecoveryCreation>(
+ factor_input_)) {
return AuthFactorType::kRecovery;
+ }
if (absl::holds_alternative<AuthFactorInput::RecoveryAuthentication>(
- factor_input_))
+ factor_input_)) {
return AuthFactorType::kRecovery;
+ }
NOTREACHED();
return AuthFactorType::kUnknownLegacy;
}
bool AuthFactorInput::UsableForCreation() const {
- if (GetType() != AuthFactorType::kRecovery)
+ if (GetType() != AuthFactorType::kRecovery) {
return true;
- if (absl::holds_alternative<AuthFactorInput::RecoveryCreation>(factor_input_))
+ }
+ if (absl::holds_alternative<AuthFactorInput::RecoveryCreation>(
+ factor_input_)) {
return true;
+ }
return false;
}
bool AuthFactorInput::UsableForAuthentication() const {
- if (GetType() != AuthFactorType::kRecovery)
+ if (GetType() != AuthFactorType::kRecovery) {
return true;
+ }
if (absl::holds_alternative<AuthFactorInput::RecoveryAuthentication>(
- factor_input_))
+ factor_input_)) {
return true;
+ }
return false;
}
diff --git a/chromeos/ash/components/cryptohome/cryptohome_parameters.cc b/chromeos/ash/components/cryptohome/cryptohome_parameters.cc
index f7a73f7..705976b 100644
--- a/chromeos/ash/components/cryptohome/cryptohome_parameters.cc
+++ b/chromeos/ash/components/cryptohome/cryptohome_parameters.cc
@@ -81,10 +81,12 @@
KeyDefinition::ProviderData::ProviderData(const ProviderData& other)
: name(other.name) {
- if (other.number)
+ if (other.number) {
number = std::make_unique<int64_t>(*other.number);
- if (other.bytes)
+ }
+ if (other.bytes) {
bytes = std::make_unique<std::string>(*other.bytes);
+ }
}
KeyDefinition::ProviderData::ProviderData(const std::string& name,
@@ -157,8 +159,9 @@
}
for (size_t i = 0; i < provider_data.size(); ++i) {
- if (!(provider_data[i] == other.provider_data[i]))
+ if (!(provider_data[i] == other.provider_data[i])) {
return false;
+ }
}
return true;
}
diff --git a/chromeos/ash/components/cryptohome/cryptohome_util.cc b/chromeos/ash/components/cryptohome/cryptohome_util.cc
index 21218e3..3e75502 100644
--- a/chromeos/ash/components/cryptohome/cryptohome_util.cc
+++ b/chromeos/ash/components/cryptohome/cryptohome_util.cc
@@ -67,11 +67,13 @@
const KeyDefinition::ProviderData& provider_data,
KeyProviderData::Entry* entry) {
entry->set_name(provider_data.name);
- if (provider_data.number)
+ if (provider_data.number) {
entry->set_number(*provider_data.number);
+ }
- if (provider_data.bytes)
+ if (provider_data.bytes) {
entry->set_bytes(*provider_data.bytes);
+ }
}
} // namespace
@@ -102,12 +104,15 @@
// Extract |privileges|.
const KeyPrivileges& privileges = key_data.privileges();
- if (privileges.add())
+ if (privileges.add()) {
result.privileges |= PRIV_ADD;
- if (privileges.remove())
+ }
+ if (privileges.remove()) {
result.privileges |= PRIV_REMOVE;
- if (privileges.update())
+ }
+ if (privileges.update()) {
result.privileges |= PRIV_MIGRATE;
+ }
// Extract |policy|.
result.policy.low_entropy_credential =
@@ -174,8 +179,9 @@
// TODO(crbug.com/797848): Finish testing this method.
void KeyDefinitionToKey(const KeyDefinition& key_def, Key* key) {
KeyData* data = key->mutable_data();
- if (!key_def.label.value().empty())
+ if (!key_def.label.value().empty()) {
data->set_label(key_def.label.value());
+ }
switch (key_def.type) {
case KeyDefinition::TYPE_PASSWORD:
@@ -200,8 +206,9 @@
break;
}
- if (key_def.revision > 0)
+ if (key_def.revision > 0) {
data->set_revision(key_def.revision);
+ }
if (key_def.privileges != 0) {
KeyDefPrivilegesToKeyPrivileges(key_def.privileges,
diff --git a/chromeos/ash/components/cryptohome/userdataauth_util.cc b/chromeos/ash/components/cryptohome/userdataauth_util.cc
index 69551a6..2f58a7c 100644
--- a/chromeos/ash/components/cryptohome/userdataauth_util.cc
+++ b/chromeos/ash/components/cryptohome/userdataauth_util.cc
@@ -39,8 +39,9 @@
template <typename ReplyType>
CryptohomeErrorCode ReplyToCryptohomeError(
const absl::optional<ReplyType>& reply) {
- if (IsEmpty(reply))
+ if (IsEmpty(reply)) {
return CRYPTOHOME_ERROR_MOUNT_FATAL;
+ }
return reply->error();
}
@@ -132,8 +133,9 @@
int64_t AccountDiskUsageReplyToUsageSize(
const absl::optional<GetAccountDiskUsageReply>& reply) {
- if (IsEmpty(reply))
+ if (IsEmpty(reply)) {
return -1;
+ }
if (reply->error() != CRYPTOHOME_ERROR_NOT_SET) {
LOGIN_LOG(ERROR) << "GetAccountDiskUsage failed with error: "
diff --git a/chromeos/ash/components/dbus/userdataauth/fake_arc_quota_client.cc b/chromeos/ash/components/dbus/userdataauth/fake_arc_quota_client.cc
index 9480992..d15b700 100644
--- a/chromeos/ash/components/dbus/userdataauth/fake_arc_quota_client.cc
+++ b/chromeos/ash/components/dbus/userdataauth/fake_arc_quota_client.cc
@@ -65,13 +65,15 @@
void FakeArcQuotaClient::SetServiceIsAvailable(bool is_available) {
service_is_available_ = is_available;
- if (!is_available)
+ if (!is_available) {
return;
+ }
std::vector<chromeos::WaitForServiceToBeAvailableCallback> callbacks;
callbacks.swap(pending_wait_for_service_to_be_available_callbacks_);
- for (auto& callback : callbacks)
+ for (auto& callback : callbacks) {
std::move(callback).Run(true);
+ }
}
void FakeArcQuotaClient::ReportServiceIsNotAvailable() {
@@ -80,8 +82,9 @@
std::vector<chromeos::WaitForServiceToBeAvailableCallback> callbacks;
callbacks.swap(pending_wait_for_service_to_be_available_callbacks_);
- for (auto& callback : callbacks)
+ for (auto& callback : callbacks) {
std::move(callback).Run(false);
+ }
}
} // namespace ash
diff --git a/chromeos/ash/components/dbus/userdataauth/fake_cryptohome_misc_client.cc b/chromeos/ash/components/dbus/userdataauth/fake_cryptohome_misc_client.cc
index 4f2da70..0b1136f 100644
--- a/chromeos/ash/components/dbus/userdataauth/fake_cryptohome_misc_client.cc
+++ b/chromeos/ash/components/dbus/userdataauth/fake_cryptohome_misc_client.cc
@@ -120,13 +120,15 @@
void FakeCryptohomeMiscClient::SetServiceIsAvailable(bool is_available) {
service_is_available_ = is_available;
- if (!is_available)
+ if (!is_available) {
return;
+ }
std::vector<chromeos::WaitForServiceToBeAvailableCallback> callbacks;
callbacks.swap(pending_wait_for_service_to_be_available_callbacks_);
- for (auto& callback : callbacks)
+ for (auto& callback : callbacks) {
std::move(callback).Run(true);
+ }
}
void FakeCryptohomeMiscClient::ReportServiceIsNotAvailable() {
@@ -135,8 +137,9 @@
std::vector<chromeos::WaitForServiceToBeAvailableCallback> callbacks;
callbacks.swap(pending_wait_for_service_to_be_available_callbacks_);
- for (auto& callback : callbacks)
+ for (auto& callback : callbacks) {
std::move(callback).Run(false);
+ }
}
template <typename ReplyType>
diff --git a/chromeos/ash/components/dbus/userdataauth/fake_cryptohome_pkcs11_client.cc b/chromeos/ash/components/dbus/userdataauth/fake_cryptohome_pkcs11_client.cc
index 7c1a3f1..c78ef4c 100644
--- a/chromeos/ash/components/dbus/userdataauth/fake_cryptohome_pkcs11_client.cc
+++ b/chromeos/ash/components/dbus/userdataauth/fake_cryptohome_pkcs11_client.cc
@@ -67,13 +67,15 @@
void FakeCryptohomePkcs11Client::SetServiceIsAvailable(bool is_available) {
service_is_available_ = is_available;
- if (!is_available)
+ if (!is_available) {
return;
+ }
std::vector<chromeos::WaitForServiceToBeAvailableCallback> callbacks;
callbacks.swap(pending_wait_for_service_to_be_available_callbacks_);
- for (auto& callback : callbacks)
+ for (auto& callback : callbacks) {
std::move(callback).Run(true);
+ }
}
void FakeCryptohomePkcs11Client::ReportServiceIsNotAvailable() {
@@ -82,8 +84,9 @@
std::vector<chromeos::WaitForServiceToBeAvailableCallback> callbacks;
callbacks.swap(pending_wait_for_service_to_be_available_callbacks_);
- for (auto& callback : callbacks)
+ for (auto& callback : callbacks) {
std::move(callback).Run(false);
+ }
}
} // namespace ash
diff --git a/chromeos/ash/components/dbus/userdataauth/fake_install_attributes_client.cc b/chromeos/ash/components/dbus/userdataauth/fake_install_attributes_client.cc
index 00981f3..9013d938 100644
--- a/chromeos/ash/components/dbus/userdataauth/fake_install_attributes_client.cc
+++ b/chromeos/ash/components/dbus/userdataauth/fake_install_attributes_client.cc
@@ -37,8 +37,9 @@
locked_ = base::PathService::Get(
chromeos::dbus_paths::FILE_INSTALL_ATTRIBUTES, &cache_path) &&
base::PathExists(cache_path);
- if (locked_)
+ if (locked_) {
LoadInstallAttributes();
+ }
}
FakeInstallAttributesClient::~FakeInstallAttributesClient() {
@@ -165,13 +166,15 @@
void FakeInstallAttributesClient::SetServiceIsAvailable(bool is_available) {
service_is_available_ = is_available;
- if (!is_available)
+ if (!is_available) {
return;
+ }
std::vector<chromeos::WaitForServiceToBeAvailableCallback> callbacks;
callbacks.swap(pending_wait_for_service_to_be_available_callbacks_);
- for (auto& callback : callbacks)
+ for (auto& callback : callbacks) {
std::move(callback).Run(true);
+ }
}
void FakeInstallAttributesClient::ReportServiceIsNotAvailable() {
@@ -180,8 +183,9 @@
std::vector<chromeos::WaitForServiceToBeAvailableCallback> callbacks;
callbacks.swap(pending_wait_for_service_to_be_available_callbacks_);
- for (auto& callback : callbacks)
+ for (auto& callback : callbacks) {
std::move(callback).Run(false);
+ }
}
template <typename ReplyType>
diff --git a/chromeos/ash/components/dbus/userdataauth/fake_userdataauth_client.cc b/chromeos/ash/components/dbus/userdataauth/fake_userdataauth_client.cc
index ac061d2..e11fa79 100644
--- a/chromeos/ash/components/dbus/userdataauth/fake_userdataauth_client.cc
+++ b/chromeos/ash/components/dbus/userdataauth/fake_userdataauth_client.cc
@@ -413,8 +413,9 @@
void FakeUserDataAuthClient::TestApi::SetServiceIsAvailable(bool is_available) {
FakeUserDataAuthClient::Get()->service_is_available_ = is_available;
- if (!is_available)
+ if (!is_available) {
return;
+ }
FakeUserDataAuthClient::Get()
->RunPendingWaitForServiceToBeAvailableCallbacks();
}
@@ -1471,8 +1472,9 @@
session.authorized_auth_session_intent.Put(
session.requested_auth_session_intent);
if (session.requested_auth_session_intent ==
- user_data_auth::AUTH_INTENT_DECRYPT)
+ user_data_auth::AUTH_INTENT_DECRYPT) {
reply.set_authenticated(true);
+ }
reply.add_authorized_for(session.requested_auth_session_intent);
reply.set_seconds_left(kSessionTimeoutSeconds);
}
@@ -1525,8 +1527,9 @@
DCHECK(!label.empty());
bool erased = user_state.auth_factors.erase(label) > 0;
- if (!erased)
+ if (!erased) {
reply.set_error(CryptohomeErrorCode::CRYPTOHOME_ERROR_KEY_NOT_FOUND);
+ }
}
void FakeUserDataAuthClient::GetAuthFactorExtendedInfo(
@@ -1629,8 +1632,9 @@
void FakeUserDataAuthClient::RunPendingWaitForServiceToBeAvailableCallbacks() {
std::vector<chromeos::WaitForServiceToBeAvailableCallback> callbacks;
callbacks.swap(pending_wait_for_service_to_be_available_callbacks_);
- for (auto& callback : callbacks)
+ for (auto& callback : callbacks) {
std::move(callback).Run(false);
+ }
}
FakeUserDataAuthClient::AuthResult
@@ -1640,12 +1644,14 @@
const std::string& secret,
bool wildcard_allowed,
std::string* matched_factor_label) const {
- if (!enable_auth_check_)
+ if (!enable_auth_check_) {
return AuthResult::kAuthSuccess;
+ }
const auto user_it = users_.find(account_id);
- if (user_it == std::end(users_))
+ if (user_it == std::end(users_)) {
return AuthResult::kUserNotFound;
+ }
const UserCryptohomeState& user_state = user_it->second;
if (wildcard_allowed && factor_label.empty()) {
@@ -1654,8 +1660,9 @@
for (const auto& [candidate_label, candidate_factor] :
user_state.auth_factors) {
if (CheckCredentialsViaAuthFactor(candidate_factor, secret)) {
- if (matched_factor_label)
+ if (matched_factor_label) {
*matched_factor_label = candidate_label;
+ }
return AuthResult::kAuthSuccess;
}
}
@@ -1666,13 +1673,16 @@
}
const auto factor_it = user_state.auth_factors.find(factor_label);
- if (factor_it == std::end(user_state.auth_factors))
+ if (factor_it == std::end(user_state.auth_factors)) {
return AuthResult::kFactorNotFound;
+ }
const auto& [label, factor] = *factor_it;
- if (!CheckCredentialsViaAuthFactor(factor, secret))
+ if (!CheckCredentialsViaAuthFactor(factor, secret)) {
return AuthResult::kAuthFailed;
- if (matched_factor_label)
+ }
+ if (matched_factor_label) {
*matched_factor_label = label;
+ }
return AuthResult::kAuthSuccess;
}
@@ -1685,8 +1695,9 @@
CryptohomeErrorCode FakeUserDataAuthClient::TakeOperationError(
Operation operation) {
const auto op_error = operation_errors_.find(operation);
- if (op_error == std::end(operation_errors_))
+ if (op_error == std::end(operation_errors_)) {
return CryptohomeErrorCode::CRYPTOHOME_ERROR_NOT_SET;
+ }
CryptohomeErrorCode result = op_error->second;
operation_errors_.erase(op_error);
return result;
@@ -1718,8 +1729,9 @@
void FakeUserDataAuthClient::NotifyLowDiskSpace(uint64_t disk_free_bytes) {
::user_data_auth::LowDiskSpace status;
status.set_disk_free_bytes(disk_free_bytes);
- for (auto& observer : observer_list_)
+ for (auto& observer : observer_list_) {
observer.LowDiskSpace(status);
+ }
}
void FakeUserDataAuthClient::NotifyDircryptoMigrationProgress(
@@ -1730,14 +1742,16 @@
progress.set_status(status);
progress.set_current_bytes(current);
progress.set_total_bytes(total);
- for (auto& observer : observer_list_)
+ for (auto& observer : observer_list_) {
observer.DircryptoMigrationProgress(progress);
+ }
}
absl::optional<base::FilePath> FakeUserDataAuthClient::GetUserProfileDir(
const cryptohome::AccountIdentifier& account_id) const {
- if (!user_data_dir_.has_value())
+ if (!user_data_dir_.has_value()) {
return absl::nullopt;
+ }
std::string user_dir_base_name =
kUserDataDirNamePrefix + account_id.account_id() + kUserDataDirNameSuffix;