Commit cb748bb4 authored by David Roger's avatar David Roger Committed by Commit Bot

[signin] Set minimum size for the profile picker window.

- picker minimum size is now defined in C++ and sent to javascript in
  loadTimeData
- the picker native window uses this size as minimum size
- in the case of small screens, a smaller native window is still allowed

Change-Id: Ib4750bf09d861336d2c66f76a5fdd8bf2ec7c303
Fixed: 1119893
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2367081
Commit-Queue: David Roger <droger@chromium.org>
Reviewed-by: default avatarMonica Basta <msalama@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800568}
parent 06148875
...@@ -3,9 +3,8 @@ ...@@ -3,9 +3,8 @@
--avatar-icon-size: 74px; --avatar-icon-size: 74px;
--banner-img-height: 628px; --banner-img-height: 628px;
--banner-img-width: 250px; --banner-img-width: 250px;
--main-view-min-height: 620px; min-height: var(--view-min-size);
min-height: var(--main-view-min-height); min-width: var(--view-min-size);
min-width: 500px;
} }
.banner { .banner {
......
...@@ -62,6 +62,7 @@ Polymer({ ...@@ -62,6 +62,7 @@ Polymer({
/** @override */ /** @override */
attached() { attached() {
this.setMinimumSize_();
this.addWebUIListener( this.addWebUIListener(
'profiles-list-changed', this.handleProfilesListChanged_.bind(this)); 'profiles-list-changed', this.handleProfilesListChanged_.bind(this));
this.addWebUIListener( this.addWebUIListener(
...@@ -124,4 +125,10 @@ Polymer({ ...@@ -124,4 +125,10 @@ Polymer({
} }
} }
}, },
/** @private */
setMinimumSize_() {
this.style.setProperty(
'--view-min-size', loadTimeData.getString('minimumPickerSize'));
},
}); });
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "chrome/browser/profiles/profile_avatar_icon_util.h" #include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_window.h" #include "chrome/browser/profiles/profile_window.h"
#include "chrome/browser/ui/webui/signin/profile_picker_ui.h"
#include "chrome/common/webui_url_constants.h" #include "chrome/common/webui_url_constants.h"
#include "chrome/grit/chromium_strings.h" #include "chrome/grit/chromium_strings.h"
#include "chrome/grit/google_chrome_strings.h" #include "chrome/grit/google_chrome_strings.h"
...@@ -148,3 +149,11 @@ void ProfilePickerView::WindowClosing() { ...@@ -148,3 +149,11 @@ void ProfilePickerView::WindowClosing() {
if (g_profile_picker_view == this) if (g_profile_picker_view == this)
g_profile_picker_view = nullptr; g_profile_picker_view = nullptr;
} }
gfx::Size ProfilePickerView::GetMinimumSize() const {
// On small screens, the preferred size may be smaller than the picker
// minimum size. In that case there will be scrollbars on the picker.
gfx::Size minimum_size = GetPreferredSize();
minimum_size.SetToMin(ProfilePickerUI::GetMinimumSize());
return minimum_size;
}
...@@ -42,6 +42,9 @@ class ProfilePickerView : public views::DialogDelegateView { ...@@ -42,6 +42,9 @@ class ProfilePickerView : public views::DialogDelegateView {
gfx::Size CalculatePreferredSize() const override; gfx::Size CalculatePreferredSize() const override;
void WindowClosing() override; void WindowClosing() override;
// views::View;
gfx::Size GetMinimumSize() const override;
views::WebView* web_view_; views::WebView* web_view_;
InitState initialized_; InitState initialized_;
base::WeakPtrFactory<ProfilePickerView> weak_ptr_factory_{this}; base::WeakPtrFactory<ProfilePickerView> weak_ptr_factory_{this};
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "chrome/browser/ui/webui/signin/profile_picker_ui.h" #include "chrome/browser/ui/webui/signin/profile_picker_ui.h"
#include "base/feature_list.h" #include "base/feature_list.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/signin_util.h" #include "chrome/browser/signin/signin_util.h"
...@@ -23,6 +24,10 @@ ...@@ -23,6 +24,10 @@
#include "ui/base/webui/web_ui_util.h" #include "ui/base/webui/web_ui_util.h"
namespace { namespace {
// Miniumum size for the picker UI.
constexpr int kMinimumPickerSizePx = 620;
bool IsProfileCreationAllowed() { bool IsProfileCreationAllowed() {
PrefService* service = g_browser_process->local_state(); PrefService* service = g_browser_process->local_state();
DCHECK(service); DCHECK(service);
...@@ -77,6 +82,9 @@ void AddStrings(content::WebUIDataSource* html_source) { ...@@ -77,6 +82,9 @@ void AddStrings(content::WebUIDataSource* html_source) {
"signInProfileCreationFlowSupported", "signInProfileCreationFlowSupported",
base::FeatureList::IsEnabled(features::kSignInProfileCreationFlow)); base::FeatureList::IsEnabled(features::kSignInProfileCreationFlow));
html_source->AddString("minimumPickerSize",
base::StringPrintf("%ipx", kMinimumPickerSizePx));
// Add policies. // Add policies.
html_source->AddBoolean("isForceSigninEnabled", html_source->AddBoolean("isForceSigninEnabled",
signin_util::IsForceSigninEnabled()); signin_util::IsForceSigninEnabled());
...@@ -108,3 +116,8 @@ ProfilePickerUI::ProfilePickerUI(content::WebUI* web_ui) ...@@ -108,3 +116,8 @@ ProfilePickerUI::ProfilePickerUI(content::WebUI* web_ui)
} }
ProfilePickerUI::~ProfilePickerUI() = default; ProfilePickerUI::~ProfilePickerUI() = default;
// static
gfx::Size ProfilePickerUI::GetMinimumSize() {
return gfx::Size(kMinimumPickerSizePx, kMinimumPickerSizePx);
}
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "content/public/browser/web_ui_controller.h" #include "content/public/browser/web_ui_controller.h"
#include "ui/gfx/geometry/size.h"
// The WebUI controller for chrome://profile-picker/. // The WebUI controller for chrome://profile-picker/.
class ProfilePickerUI : public content::WebUIController { class ProfilePickerUI : public content::WebUIController {
...@@ -14,6 +15,9 @@ class ProfilePickerUI : public content::WebUIController { ...@@ -14,6 +15,9 @@ class ProfilePickerUI : public content::WebUIController {
explicit ProfilePickerUI(content::WebUI* web_ui); explicit ProfilePickerUI(content::WebUI* web_ui);
~ProfilePickerUI() override; ~ProfilePickerUI() override;
// Get the minimum size for the picker UI.
static gfx::Size GetMinimumSize();
private: private:
DISALLOW_COPY_AND_ASSIGN(ProfilePickerUI); DISALLOW_COPY_AND_ASSIGN(ProfilePickerUI);
}; };
......
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