Commit 925cddec authored by Roman Sorokin's avatar Roman Sorokin Committed by Commit Bot

cros: Propagate parent window for GetHelp App on the lock screen

Fixed: 1022774
Change-Id: I2ffc80512230316cc3b94b70e7e11f6b2db0390e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2010950Reviewed-by: default avatarDenis Kuznetsov [CET] <antrim@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Roman Sorokin [CET] <rsorokin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734377}
parent 7155df8c
...@@ -446,12 +446,14 @@ void LoginScreenController::ShowResetScreen() { ...@@ -446,12 +446,14 @@ void LoginScreenController::ShowResetScreen() {
client_->ShowResetScreen(); client_->ShowResetScreen();
} }
void LoginScreenController::ShowAccountAccessHelpApp() { void LoginScreenController::ShowAccountAccessHelpApp(
client_->ShowAccountAccessHelpApp(); gfx::NativeWindow parent_window) {
client_->ShowAccountAccessHelpApp(parent_window);
} }
void LoginScreenController::ShowParentAccessHelpApp() { void LoginScreenController::ShowParentAccessHelpApp(
client_->ShowParentAccessHelpApp(); gfx::NativeWindow parent_window) {
client_->ShowParentAccessHelpApp(parent_window);
} }
void LoginScreenController::ShowLockScreenNotificationSettings() { void LoginScreenController::ShowLockScreenNotificationSettings() {
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "ui/gfx/native_widget_types.h"
class PrefRegistrySimple; class PrefRegistrySimple;
...@@ -91,8 +92,8 @@ class ASH_EXPORT LoginScreenController : public LoginScreen, ...@@ -91,8 +92,8 @@ class ASH_EXPORT LoginScreenController : public LoginScreen,
const std::string& locale); const std::string& locale);
void ShowFeedback(); void ShowFeedback();
void ShowResetScreen(); void ShowResetScreen();
void ShowAccountAccessHelpApp(); void ShowAccountAccessHelpApp(gfx::NativeWindow parent_window);
void ShowParentAccessHelpApp(); void ShowParentAccessHelpApp(gfx::NativeWindow parent_window);
void ShowLockScreenNotificationSettings(); void ShowLockScreenNotificationSettings();
void FocusOobeDialog(); void FocusOobeDialog();
void NotifyUserActivity(); void NotifyUserActivity();
......
...@@ -119,8 +119,8 @@ class MockLoginScreenClient : public LoginScreenClient { ...@@ -119,8 +119,8 @@ class MockLoginScreenClient : public LoginScreenClient {
(override)); (override));
MOCK_METHOD(void, ShowFeedback, (), (override)); MOCK_METHOD(void, ShowFeedback, (), (override));
MOCK_METHOD(void, ShowResetScreen, (), (override)); MOCK_METHOD(void, ShowResetScreen, (), (override));
MOCK_METHOD(void, ShowAccountAccessHelpApp, (), (override)); MOCK_METHOD(void, ShowAccountAccessHelpApp, (gfx::NativeWindow), (override));
MOCK_METHOD(void, ShowParentAccessHelpApp, (), (override)); MOCK_METHOD(void, ShowParentAccessHelpApp, (gfx::NativeWindow), (override));
MOCK_METHOD(void, ShowLockScreenNotificationSettings, (), (override)); MOCK_METHOD(void, ShowLockScreenNotificationSettings, (), (override));
MOCK_METHOD(void, FocusOobeDialog, (), (override)); MOCK_METHOD(void, FocusOobeDialog, (), (override));
MOCK_METHOD(void, OnFocusLeavingSystemTray, (bool reverse), (override)); MOCK_METHOD(void, OnFocusLeavingSystemTray, (bool reverse), (override));
......
...@@ -148,7 +148,8 @@ class AuthErrorLearnMoreButton : public views::Button, ...@@ -148,7 +148,8 @@ class AuthErrorLearnMoreButton : public views::Button,
} }
void ButtonPressed(Button* sender, const ui::Event& event) override { void ButtonPressed(Button* sender, const ui::Event& event) override {
Shell::Get()->login_screen_controller()->ShowAccountAccessHelpApp(); Shell::Get()->login_screen_controller()->ShowAccountAccessHelpApp(
GetWidget()->GetNativeWindow());
parent_bubble_->Hide(); parent_bubble_->Hide();
} }
......
...@@ -991,6 +991,7 @@ TEST_F(LockContentsViewUnitTest, AuthErrorButtonClickable) { ...@@ -991,6 +991,7 @@ TEST_F(LockContentsViewUnitTest, AuthErrorButtonClickable) {
DataDispatcher(), DataDispatcher(),
std::make_unique<FakeLoginDetachableBaseModel>(DataDispatcher())); std::make_unique<FakeLoginDetachableBaseModel>(DataDispatcher()));
SetUserCount(1); SetUserCount(1);
SetWidget(CreateWidgetWithContent(contents)); SetWidget(CreateWidgetWithContent(contents));
LockContentsView::TestApi test_api(contents); LockContentsView::TestApi test_api(contents);
...@@ -1018,7 +1019,8 @@ TEST_F(LockContentsViewUnitTest, AuthErrorButtonClickable) { ...@@ -1018,7 +1019,8 @@ TEST_F(LockContentsViewUnitTest, AuthErrorButtonClickable) {
ASSERT_TRUE(button); ASSERT_TRUE(button);
// Expect ShowAccountAccessHelp() to be called due to button click. // Expect ShowAccountAccessHelp() to be called due to button click.
EXPECT_CALL(*client, ShowAccountAccessHelpApp()).Times(1); EXPECT_CALL(*client, ShowAccountAccessHelpApp(widget()->GetNativeWindow()))
.Times(1);
// Move mouse to AuthError's ShowAccountAccessHelp button and click it. // Move mouse to AuthError's ShowAccountAccessHelp button and click it.
// Should result in ShowAccountAccessHelpApp(). // Should result in ShowAccountAccessHelpApp().
......
...@@ -805,9 +805,13 @@ void ParentAccessView::ButtonPressed(views::Button* sender, ...@@ -805,9 +805,13 @@ void ParentAccessView::ButtonPressed(views::Button* sender,
// TODO(https://crbug.com/999387): Remove this when handling touch // TODO(https://crbug.com/999387): Remove this when handling touch
// cancellation is fixed for system modal windows. // cancellation is fixed for system modal windows.
base::ThreadTaskRunnerHandle::Get()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce([]() { FROM_HERE,
Shell::Get()->login_screen_controller()->ShowParentAccessHelpApp(); base::BindOnce(
})); [](gfx::NativeWindow parent_window) {
Shell::Get()->login_screen_controller()->ShowParentAccessHelpApp(
parent_window);
},
GetWidget()->GetNativeWindow()));
} else if (sender == submit_button_) { } else if (sender == submit_button_) {
SubmitCode(); SubmitCode();
} }
......
...@@ -280,7 +280,8 @@ TEST_F(ParentAccessViewTest, HelpButton) { ...@@ -280,7 +280,8 @@ TEST_F(ParentAccessViewTest, HelpButton) {
ParentAccessView::TestApi test_api(view_); ParentAccessView::TestApi test_api(view_);
EXPECT_TRUE(test_api.help_button()->GetEnabled()); EXPECT_TRUE(test_api.help_button()->GetEnabled());
EXPECT_CALL(*client, ShowParentAccessHelpApp()).Times(1); EXPECT_CALL(*client, ShowParentAccessHelpApp(widget()->GetNativeWindow()))
.Times(1);
SimulateButtonPress(test_api.help_button()); SimulateButtonPress(test_api.help_button());
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "ash/public/cpp/ash_public_export.h" #include "ash/public/cpp/ash_public_export.h"
#include "base/callback_forward.h" #include "base/callback_forward.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "ui/gfx/native_widget_types.h"
class AccountId; class AccountId;
...@@ -148,10 +149,10 @@ class ASH_PUBLIC_EXPORT LoginScreenClient { ...@@ -148,10 +149,10 @@ class ASH_PUBLIC_EXPORT LoginScreenClient {
virtual void ShowResetScreen() = 0; virtual void ShowResetScreen() = 0;
// Show the help app for when users have trouble signing in to their account. // Show the help app for when users have trouble signing in to their account.
virtual void ShowAccountAccessHelpApp() = 0; virtual void ShowAccountAccessHelpApp(gfx::NativeWindow parent_window) = 0;
// Shows help app for users that have trouble using parent access code. // Shows help app for users that have trouble using parent access code.
virtual void ShowParentAccessHelpApp() = 0; virtual void ShowParentAccessHelpApp(gfx::NativeWindow parent_window) = 0;
// Show the lockscreen notification settings page. // Show the lockscreen notification settings page.
virtual void ShowLockScreenNotificationSettings() = 0; virtual void ShowLockScreenNotificationSettings() = 0;
......
...@@ -60,6 +60,8 @@ LoginWebDialog::LoginWebDialog(content::BrowserContext* browser_context, ...@@ -60,6 +60,8 @@ LoginWebDialog::LoginWebDialog(content::BrowserContext* browser_context,
parent_window_ = parent_window_ =
chromeos::LoginDisplayHost::default_host()->GetNativeWindow(); chromeos::LoginDisplayHost::default_host()->GetNativeWindow();
} }
LOG_IF(WARNING, !parent_window)
<< "No parent window. Dialog sizes could be wrong";
} }
LoginWebDialog::~LoginWebDialog() {} LoginWebDialog::~LoginWebDialog() {}
......
...@@ -227,15 +227,17 @@ void LoginScreenClient::ShowResetScreen() { ...@@ -227,15 +227,17 @@ void LoginScreenClient::ShowResetScreen() {
chromeos::LoginDisplayHost::default_host()->ShowResetScreen(); chromeos::LoginDisplayHost::default_host()->ShowResetScreen();
} }
void LoginScreenClient::ShowAccountAccessHelpApp() { void LoginScreenClient::ShowAccountAccessHelpApp(
gfx::NativeWindow parent_window) {
scoped_refptr<chromeos::HelpAppLauncher>( scoped_refptr<chromeos::HelpAppLauncher>(
new chromeos::HelpAppLauncher(nullptr)) new chromeos::HelpAppLauncher(parent_window))
->ShowHelpTopic(chromeos::HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); ->ShowHelpTopic(chromeos::HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT);
} }
void LoginScreenClient::ShowParentAccessHelpApp() { void LoginScreenClient::ShowParentAccessHelpApp(
gfx::NativeWindow parent_window) {
scoped_refptr<chromeos::HelpAppLauncher>( scoped_refptr<chromeos::HelpAppLauncher>(
new chromeos::HelpAppLauncher(nullptr)) new chromeos::HelpAppLauncher(parent_window))
->ShowHelpTopic(chromeos::HelpAppLauncher::HELP_PARENT_ACCESS_CODE); ->ShowHelpTopic(chromeos::HelpAppLauncher::HELP_PARENT_ACCESS_CODE);
} }
......
...@@ -120,8 +120,8 @@ class LoginScreenClient : public ash::LoginScreenClient { ...@@ -120,8 +120,8 @@ class LoginScreenClient : public ash::LoginScreenClient {
const std::string& locale) override; const std::string& locale) override;
void ShowFeedback() override; void ShowFeedback() override;
void ShowResetScreen() override; void ShowResetScreen() override;
void ShowAccountAccessHelpApp() override; void ShowAccountAccessHelpApp(gfx::NativeWindow parent_window) override;
void ShowParentAccessHelpApp() override; void ShowParentAccessHelpApp(gfx::NativeWindow parent_window) override;
void ShowLockScreenNotificationSettings() override; void ShowLockScreenNotificationSettings() override;
void OnFocusLeavingSystemTray(bool reverse) override; void OnFocusLeavingSystemTray(bool reverse) override;
void OnUserActivity() override; void OnUserActivity() override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment