Commit 427f452d authored by Jan Krcal's avatar Jan Krcal Committed by Chromium LUCI CQ

[Creation flow] Re-enable buttons on the profile_type_choice page

This CL re-enables the buttons on the profile_type_choice page in the
profile creation flow once the creation of the new profile object
finishes. This allows to reuse the same page and its buttons if the user
navigates back from the sign-in page.

Bug: 1126913
Change-Id: If014f49f20fc593a140db3eac020faf68f3eec4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2572476
Commit-Queue: Jan Krcal <jkrcal@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Reviewed-by: default avatarMonica Basta <msalama@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834784}
parent 37e0ccc3
...@@ -40,7 +40,8 @@ Polymer({ ...@@ -40,7 +40,8 @@ Polymer({
/** @override */ /** @override */
ready() { ready() {
this.addWebUIListener( this.addWebUIListener(
'load-signin-failed', () => this.handleLoadSigninFailed_()); 'load-signin-finished',
success => this.handleLoadSigninFinished_(success));
FocusOutlineManager.forDocument(document); FocusOutlineManager.forDocument(document);
}, },
...@@ -63,8 +64,9 @@ Polymer({ ...@@ -63,8 +64,9 @@ Polymer({
}, },
/** @private */ /** @private */
handleLoadSigninFailed_() { handleLoadSigninFinished_(success) {
// TODO(crbug.com/1126913): Show some error message to inform the user. // TODO(crbug.com/1126913): If failed, show some error message to inform the
// user.
this.loadSigninInProgess_ = false; this.loadSigninInProgess_ = false;
} }
}); });
...@@ -54,10 +54,11 @@ class ProfilePicker { ...@@ -54,10 +54,11 @@ class ProfilePicker {
// Starts the sign-in flow. The layout of the window gets updated for the // Starts the sign-in flow. The layout of the window gets updated for the
// sign-in flow. At the same time, the new profile is created (with // sign-in flow. At the same time, the new profile is created (with
// `profile_color`) and the sign-in page is rendered using the new profile. // `profile_color`) and the sign-in page is rendered using the new profile.
// If the creation of the new profile fails, `switch_failure_callback` gets // `switch_finished_callback` gets informed whether the creation of the new
// called. // profile succeeded and the sign-in page gets displayed.
static void SwitchToSignIn(SkColor profile_color, static void SwitchToSignIn(
base::OnceClosure switch_failure_callback); SkColor profile_color,
base::OnceCallback<void(bool)> switch_finished_callback);
// Finishes the sign-in flow by moving to the sync confirmation screen. It // Finishes the sign-in flow by moving to the sync confirmation screen. It
// uses the same new profile created by `SwitchToSignIn()`. // uses the same new profile created by `SwitchToSignIn()`.
......
...@@ -182,9 +182,9 @@ IN_PROC_BROWSER_TEST_F(ProfilePickerInteractiveUiTest, ...@@ -182,9 +182,9 @@ IN_PROC_BROWSER_TEST_F(ProfilePickerInteractiveUiTest,
WaitForLayoutWithoutToolbar(); WaitForLayoutWithoutToolbar();
// Simulate a click on the signin button. // Simulate a click on the signin button.
base::MockCallback<base::OnceClosure> switch_failure_callback; base::MockCallback<base::OnceCallback<void(bool)>> switch_finished_callback;
EXPECT_CALL(switch_failure_callback, Run()).Times(0); EXPECT_CALL(switch_finished_callback, Run(true));
ProfilePicker::SwitchToSignIn(SK_ColorRED, switch_failure_callback.Get()); ProfilePicker::SwitchToSignIn(SK_ColorRED, switch_finished_callback.Get());
// Switch to the signin webview. // Switch to the signin webview.
WaitForLayoutWithToolbar(); WaitForLayoutWithToolbar();
......
...@@ -104,11 +104,12 @@ void ProfilePicker::Show(EntryPoint entry_point) { ...@@ -104,11 +104,12 @@ void ProfilePicker::Show(EntryPoint entry_point) {
} }
// static // static
void ProfilePicker::SwitchToSignIn(SkColor profile_color, void ProfilePicker::SwitchToSignIn(
base::OnceClosure switch_failure_callback) { SkColor profile_color,
base::OnceCallback<void(bool)> switch_finished_callback) {
if (g_profile_picker_view) { if (g_profile_picker_view) {
g_profile_picker_view->SwitchToSignIn(profile_color, g_profile_picker_view->SwitchToSignIn(profile_color,
std::move(switch_failure_callback)); std::move(switch_finished_callback));
} }
} }
...@@ -259,9 +260,9 @@ void ProfilePickerView::Init(ProfilePicker::EntryPoint entry_point, ...@@ -259,9 +260,9 @@ void ProfilePickerView::Init(ProfilePicker::EntryPoint entry_point,
void ProfilePickerView::SwitchToSignIn( void ProfilePickerView::SwitchToSignIn(
SkColor profile_color, SkColor profile_color,
base::OnceClosure switch_failure_callback) { base::OnceCallback<void(bool)> switch_finished_callback) {
DCHECK(!switch_failure_callback_); DCHECK(!switch_finished_callback_);
switch_failure_callback_ = std::move(switch_failure_callback); switch_finished_callback_ = std::move(switch_finished_callback);
size_t icon_index = profiles::GetPlaceholderAvatarIndex(); size_t icon_index = profiles::GetPlaceholderAvatarIndex();
// Silently create the new profile for browsing on GAIA (so that the sign-in // Silently create the new profile for browsing on GAIA (so that the sign-in
// cookies are stored in the right profile). // cookies are stored in the right profile).
...@@ -279,18 +280,15 @@ void ProfilePickerView::OnProfileForSigninCreated( ...@@ -279,18 +280,15 @@ void ProfilePickerView::OnProfileForSigninCreated(
Profile* profile, Profile* profile,
Profile::CreateStatus status) { Profile::CreateStatus status) {
if (status == Profile::CREATE_STATUS_LOCAL_FAIL) { if (status == Profile::CREATE_STATUS_LOCAL_FAIL) {
if (switch_failure_callback_) if (switch_finished_callback_)
std::move(switch_failure_callback_).Run(); std::move(switch_finished_callback_).Run(false);
return; return;
} else if (status != Profile::CREATE_STATUS_INITIALIZED) { } else if (status != Profile::CREATE_STATUS_INITIALIZED) {
return; return;
} }
// No need to report failure any more, delete the callback.
DCHECK(switch_failure_callback_);
switch_failure_callback_ = base::OnceClosure();
DCHECK(profile); DCHECK(profile);
std::move(switch_finished_callback_).Run(true);
ProfileAttributesEntry* entry = nullptr; ProfileAttributesEntry* entry = nullptr;
if (!g_browser_process->profile_manager() if (!g_browser_process->profile_manager()
......
...@@ -60,7 +60,7 @@ class ProfilePickerView : public views::DialogDelegateView, ...@@ -60,7 +60,7 @@ class ProfilePickerView : public views::DialogDelegateView,
// Switches the layout to the sign-in flow (and creates a new profile) // Switches the layout to the sign-in flow (and creates a new profile)
void SwitchToSignIn(SkColor profile_color, void SwitchToSignIn(SkColor profile_color,
base::OnceClosure switch_failure_callback); base::OnceCallback<void(bool)> switch_finished_callback);
// On creation success for the sign-in profile, it rebuilds the view. // On creation success for the sign-in profile, it rebuilds the view.
void OnProfileForSigninCreated(SkColor profile_color, void OnProfileForSigninCreated(SkColor profile_color,
Profile* new_profile, Profile* new_profile,
...@@ -151,7 +151,7 @@ class ProfilePickerView : public views::DialogDelegateView, ...@@ -151,7 +151,7 @@ class ProfilePickerView : public views::DialogDelegateView,
base::TimeDelta extended_account_info_timeout_; base::TimeDelta extended_account_info_timeout_;
// Not null iff switching to sign-in is in progress. // Not null iff switching to sign-in is in progress.
base::OnceClosure switch_failure_callback_; base::OnceCallback<void(bool)> switch_finished_callback_;
base::ScopedObservation<signin::IdentityManager, base::ScopedObservation<signin::IdentityManager,
signin::IdentityManager::Observer> signin::IdentityManager::Observer>
identity_manager_observation_{this}; identity_manager_observation_{this};
......
...@@ -258,9 +258,9 @@ IN_PROC_BROWSER_TEST_F(ProfilePickerCreationFlowBrowserTest, ...@@ -258,9 +258,9 @@ IN_PROC_BROWSER_TEST_F(ProfilePickerCreationFlowBrowserTest,
WaitForLayoutWithoutToolbar(); WaitForLayoutWithoutToolbar();
// Simulate a click on the signin button. // Simulate a click on the signin button.
base::MockCallback<base::OnceClosure> switch_failure_callback; base::MockCallback<base::OnceCallback<void(bool)>> switch_finished_callback;
EXPECT_CALL(switch_failure_callback, Run()).Times(0); EXPECT_CALL(switch_finished_callback, Run(true));
ProfilePicker::SwitchToSignIn(kProfileColor, switch_failure_callback.Get()); ProfilePicker::SwitchToSignIn(kProfileColor, switch_finished_callback.Get());
// The DICE navigation happens in a new web contents (for the profile being // The DICE navigation happens in a new web contents (for the profile being
// created), wait for it. // created), wait for it.
...@@ -320,9 +320,9 @@ IN_PROC_BROWSER_TEST_F(ProfilePickerCreationFlowBrowserTest, ...@@ -320,9 +320,9 @@ IN_PROC_BROWSER_TEST_F(ProfilePickerCreationFlowBrowserTest,
WaitForLayoutWithoutToolbar(); WaitForLayoutWithoutToolbar();
// Simulate a click on the signin button. // Simulate a click on the signin button.
base::MockCallback<base::OnceClosure> switch_failure_callback; base::MockCallback<base::OnceCallback<void(bool)>> switch_finished_callback;
EXPECT_CALL(switch_failure_callback, Run()).Times(0); EXPECT_CALL(switch_finished_callback, Run(true));
ProfilePicker::SwitchToSignIn(kProfileColor, switch_failure_callback.Get()); ProfilePicker::SwitchToSignIn(kProfileColor, switch_finished_callback.Get());
// The DICE navigation happens in a new web contents (for the profile being // The DICE navigation happens in a new web contents (for the profile being
// created), wait for it. // created), wait for it.
...@@ -384,9 +384,9 @@ IN_PROC_BROWSER_TEST_F(ProfilePickerCreationFlowBrowserTest, ...@@ -384,9 +384,9 @@ IN_PROC_BROWSER_TEST_F(ProfilePickerCreationFlowBrowserTest,
WaitForLayoutWithoutToolbar(); WaitForLayoutWithoutToolbar();
// Simulate a click on the signin button. // Simulate a click on the signin button.
base::MockCallback<base::OnceClosure> switch_failure_callback; base::MockCallback<base::OnceCallback<void(bool)>> switch_finished_callback;
EXPECT_CALL(switch_failure_callback, Run()).Times(0); EXPECT_CALL(switch_finished_callback, Run(true));
ProfilePicker::SwitchToSignIn(kProfileColor, switch_failure_callback.Get()); ProfilePicker::SwitchToSignIn(kProfileColor, switch_finished_callback.Get());
// The DICE navigation happens in a new web contents (for the profile being // The DICE navigation happens in a new web contents (for the profile being
// created), wait for it. // created), wait for it.
...@@ -445,9 +445,9 @@ IN_PROC_BROWSER_TEST_F(ProfilePickerCreationFlowBrowserTest, ...@@ -445,9 +445,9 @@ IN_PROC_BROWSER_TEST_F(ProfilePickerCreationFlowBrowserTest,
WaitForLayoutWithoutToolbar(); WaitForLayoutWithoutToolbar();
// Simulate a click on the signin button. // Simulate a click on the signin button.
base::MockCallback<base::OnceClosure> switch_failure_callback; base::MockCallback<base::OnceCallback<void(bool)>> switch_finished_callback;
EXPECT_CALL(switch_failure_callback, Run()).Times(0); EXPECT_CALL(switch_finished_callback, Run(true));
ProfilePicker::SwitchToSignIn(kProfileColor, switch_failure_callback.Get()); ProfilePicker::SwitchToSignIn(kProfileColor, switch_finished_callback.Get());
// The DICE navigation happens in a new web contents (for the profile being // The DICE navigation happens in a new web contents (for the profile being
// created), wait for it. // created), wait for it.
...@@ -505,9 +505,9 @@ IN_PROC_BROWSER_TEST_F(ProfilePickerCreationFlowBrowserTest, ...@@ -505,9 +505,9 @@ IN_PROC_BROWSER_TEST_F(ProfilePickerCreationFlowBrowserTest,
WaitForLayoutWithoutToolbar(); WaitForLayoutWithoutToolbar();
// Simulate a click on the signin button. // Simulate a click on the signin button.
base::MockCallback<base::OnceClosure> switch_failure_callback; base::MockCallback<base::OnceCallback<void(bool)>> switch_finished_callback;
EXPECT_CALL(switch_failure_callback, Run()).Times(0); EXPECT_CALL(switch_finished_callback, Run(true));
ProfilePicker::SwitchToSignIn(kProfileColor, switch_failure_callback.Get()); ProfilePicker::SwitchToSignIn(kProfileColor, switch_finished_callback.Get());
// The DICE navigation happens in a new web contents (for the profile being // The DICE navigation happens in a new web contents (for the profile being
// created), wait for it. // created), wait for it.
...@@ -555,9 +555,9 @@ IN_PROC_BROWSER_TEST_F(ProfilePickerCreationFlowBrowserTest, ...@@ -555,9 +555,9 @@ IN_PROC_BROWSER_TEST_F(ProfilePickerCreationFlowBrowserTest,
WaitForLayoutWithoutToolbar(); WaitForLayoutWithoutToolbar();
// Simulate a click on the signin button. // Simulate a click on the signin button.
base::MockCallback<base::OnceClosure> switch_failure_callback; base::MockCallback<base::OnceCallback<void(bool)>> switch_finished_callback;
EXPECT_CALL(switch_failure_callback, Run()).Times(0); EXPECT_CALL(switch_finished_callback, Run(true));
ProfilePicker::SwitchToSignIn(kProfileColor, switch_failure_callback.Get()); ProfilePicker::SwitchToSignIn(kProfileColor, switch_finished_callback.Get());
// The DICE navigation happens in a new web contents (for the profile being // The DICE navigation happens in a new web contents (for the profile being
// created), wait for it. // created), wait for it.
...@@ -631,9 +631,9 @@ IN_PROC_BROWSER_TEST_F(ProfilePickerEnterpriseCreationFlowBrowserTest, ...@@ -631,9 +631,9 @@ IN_PROC_BROWSER_TEST_F(ProfilePickerEnterpriseCreationFlowBrowserTest,
WaitForLayoutWithoutToolbar(); WaitForLayoutWithoutToolbar();
// Simulate a click on the signin button. // Simulate a click on the signin button.
base::MockCallback<base::OnceClosure> switch_failure_callback; base::MockCallback<base::OnceCallback<void(bool)>> switch_finished_callback;
EXPECT_CALL(switch_failure_callback, Run()).Times(0); EXPECT_CALL(switch_finished_callback, Run(true));
ProfilePicker::SwitchToSignIn(kProfileColor, switch_failure_callback.Get()); ProfilePicker::SwitchToSignIn(kProfileColor, switch_finished_callback.Get());
// The DICE navigation happens in a new web contents (for the profile being // The DICE navigation happens in a new web contents (for the profile being
// created), wait for it. // created), wait for it.
...@@ -702,9 +702,9 @@ IN_PROC_BROWSER_TEST_F(ProfilePickerEnterpriseCreationFlowBrowserTest, ...@@ -702,9 +702,9 @@ IN_PROC_BROWSER_TEST_F(ProfilePickerEnterpriseCreationFlowBrowserTest,
WaitForLayoutWithoutToolbar(); WaitForLayoutWithoutToolbar();
// Simulate a click on the signin button. // Simulate a click on the signin button.
base::MockCallback<base::OnceClosure> switch_failure_callback; base::MockCallback<base::OnceCallback<void(bool)>> switch_finished_callback;
EXPECT_CALL(switch_failure_callback, Run()).Times(0); EXPECT_CALL(switch_finished_callback, Run(true));
ProfilePicker::SwitchToSignIn(kProfileColor, switch_failure_callback.Get()); ProfilePicker::SwitchToSignIn(kProfileColor, switch_finished_callback.Get());
// The DICE navigation happens in a new web contents (for the profile being // The DICE navigation happens in a new web contents (for the profile being
// created), wait for it. // created), wait for it.
......
...@@ -504,13 +504,13 @@ void ProfilePickerHandler::HandleLoadSignInProfileCreationFlow( ...@@ -504,13 +504,13 @@ void ProfilePickerHandler::HandleLoadSignInProfileCreationFlow(
DCHECK(args->GetList()[0].is_int()); DCHECK(args->GetList()[0].is_int());
SkColor profile_color = args->GetList()[0].GetInt(); SkColor profile_color = args->GetList()[0].GetInt();
ProfilePicker::SwitchToSignIn( ProfilePicker::SwitchToSignIn(
profile_color, base::BindOnce(&ProfilePickerHandler::OnLoadSigninFailed, profile_color, base::BindOnce(&ProfilePickerHandler::OnLoadSigninFinished,
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
} }
void ProfilePickerHandler::OnLoadSigninFailed() { void ProfilePickerHandler::OnLoadSigninFinished(bool success) {
if (IsJavascriptAllowed()) if (IsJavascriptAllowed())
FireWebUIListener("load-signin-failed", base::Value()); FireWebUIListener("load-signin-finished", base::Value(success));
} }
void ProfilePickerHandler::OnSwitchToProfileComplete( void ProfilePickerHandler::OnSwitchToProfileComplete(
......
...@@ -46,7 +46,7 @@ class ProfilePickerHandler : public content::WebUIMessageHandler, ...@@ -46,7 +46,7 @@ class ProfilePickerHandler : public content::WebUIMessageHandler,
void HandleGetProfileThemeInfo(const base::ListValue* args); void HandleGetProfileThemeInfo(const base::ListValue* args);
void HandleCreateProfile(const base::ListValue* args); void HandleCreateProfile(const base::ListValue* args);
void OnLoadSigninFailed(); void OnLoadSigninFinished(bool success);
void GatherProfileStatistics(Profile* profile); void GatherProfileStatistics(Profile* profile);
void OnProfileStatisticsReceived(base::FilePath profile_path, void OnProfileStatisticsReceived(base::FilePath profile_path,
profiles::ProfileCategoryStats result); profiles::ProfileCategoryStats result);
......
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