Commit 531ec468 authored by Jan Krcal's avatar Jan Krcal Committed by Chromium LUCI CQ

[Profile creation] React to theme changes in the sign-in flow

This CL makes the toolbar bg color in the sign-in flow react to theme
changes (so that the button color stays in sync with the toolbar color).

It also removes a few obsolete TODOs.

Bug: 1126913
Change-Id: Ia01207d4544baed1587e7c1030e9319c553c9be9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2627160
Commit-Queue: Jan Krcal <jkrcal@chromium.org>
Auto-Submit: Jan Krcal <jkrcal@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843500}
parent 4d63ce68
......@@ -512,31 +512,25 @@ void ProfilePickerView::OnProfileForSigninCreated(
// Listen for sign-in getting completed.
identity_manager_observation_.Observe(
IdentityManagerFactory::GetForProfile(profile));
// TODO(crbug.com/1126913): When there is back button from the signed-in page,
// make sure the flow does not create multiple profiles simultaneously.
signed_in_profile_being_created_ = profile;
// Build the toolbar. Do it as late as here because the elements depend on the
// Build the toolbar. Do it as late as here because the button depends on the
// ThemeProvider which is available only by signed_in_profile_being_created_.
const ui::ThemeProvider* tp = GetThemeProviderForProfileBeingCreated();
toolbar_->SetBackground(views::CreateSolidBackground(
tp->GetColor(ThemeProperties::COLOR_TOOLBAR)));
auto back_button = std::make_unique<SimpleBackButton>(base::BindRepeating(
&ProfilePickerView::BackButtonPressed, base::Unretained(this)));
toolbar_->AddChildView(std::move(back_button));
// TODO(crbug.com/1126913): Build the read-only omnibox.
new_profile_contents_ = content::WebContents::Create(
content::WebContents::CreateParams(signed_in_profile_being_created_));
new_profile_contents_->SetDelegate(this);
// Make sure the web contents used for sign-in has proper background (for dark
// mode).
// Make sure the web contents used for sign-in has proper background to match
// the toolbar (for dark mode).
views::WebContentsSetBackgroundColor::CreateForWebContentsWithColor(
new_profile_contents_.get(),
tp->GetColor(ThemeProperties::COLOR_NTP_BACKGROUND));
GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR));
UpdateToolbarColor();
ShowScreen(new_profile_contents_.get(), GetSigninURL(),
/*show_toolbar=*/true);
......@@ -628,6 +622,13 @@ bool ProfilePickerView::AcceleratorPressed(const ui::Accelerator& accelerator) {
return true;
}
void ProfilePickerView::OnThemeChanged() {
views::WidgetDelegateView::OnThemeChanged();
if (!IsSigningIn())
return;
UpdateToolbarColor();
}
bool ProfilePickerView::HandleContextMenu(
content::RenderFrameHost* render_frame_host,
const content::ContextMenuParams& params) {
......@@ -698,6 +699,12 @@ void ProfilePickerView::BuildLayout() {
web_view_ = AddChildView(std::move(web_view));
}
void ProfilePickerView::UpdateToolbarColor() {
DCHECK(new_profile_contents_);
toolbar_->SetBackground(views::CreateSolidBackground(
GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR)));
}
void ProfilePickerView::ShowScreen(content::WebContents* contents,
const GURL& url,
bool show_toolbar) {
......
......@@ -85,6 +85,7 @@ class ProfilePickerView : public views::WidgetDelegateView,
gfx::Size CalculatePreferredSize() const override;
gfx::Size GetMinimumSize() const override;
bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
void OnThemeChanged() override;
// content::WebContentsDelegate:
bool HandleContextMenu(content::RenderFrameHost* render_frame_host,
......@@ -110,6 +111,8 @@ class ProfilePickerView : public views::WidgetDelegateView,
// Builds the views hieararchy.
void BuildLayout();
void UpdateToolbarColor();
// Shows a screen with `url` in `contents` and potentially `show_toolbar`. If
// `url` is empty, it only shows `contents` with its currently loaded url.
void ShowScreen(content::WebContents* contents,
......
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