Commit bed41c7e authored by Roman Sorokin's avatar Roman Sorokin Committed by Commit Bot

OOBE: Adapt Help App dialog to the screen size.

This is a first step to implement new Help App dialog specs (see the bug
for details)

Bug: 1008073
Test: run on a device with a long content
Change-Id: Id1abdb069ecc52aa35590f10cb5d21ab2e7eff70
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1864674Reviewed-by: default avatarDenis Kuznetsov <antrim@chromium.org>
Commit-Queue: Roman Sorokin [CET] <rsorokin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706442}
parent ff3bb353
...@@ -81,10 +81,6 @@ void HelpAppLauncher::ShowHelpTopicDialog(Profile* profile, ...@@ -81,10 +81,6 @@ void HelpAppLauncher::ShowHelpTopicDialog(Profile* profile,
LoginWebDialog* dialog = new LoginWebDialog( LoginWebDialog* dialog = new LoginWebDialog(
profile, NULL, parent_window_, profile, NULL, parent_window_,
l10n_util::GetStringUTF16(IDS_LOGIN_OOBE_HELP_DIALOG_TITLE), topic_url); l10n_util::GetStringUTF16(IDS_LOGIN_OOBE_HELP_DIALOG_TITLE), topic_url);
dialog->SetDialogSize(l10n_util::GetLocalizedContentsWidthInPixels(
IDS_HELP_APP_DIALOG_WIDTH_PIXELS),
l10n_util::GetLocalizedContentsWidthInPixels(
IDS_HELP_APP_DIALOG_HEIGHT_PIXELS));
dialog->Show(); dialog->Show();
// The dialog object will be deleted on dialog close. // The dialog object will be deleted on dialog close.
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_finder.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "ui/aura/window.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
...@@ -24,13 +25,9 @@ namespace chromeos { ...@@ -24,13 +25,9 @@ namespace chromeos {
namespace { namespace {
// Default width/height ratio of screen size. constexpr gfx::Insets kMinMargins{64, 64};
const double kDefaultWidthRatio = 0.6; constexpr gfx::Size kMinSize{128, 128};
const double kDefaultHeightRatio = 0.6; constexpr gfx::Size kMaxSize{512, 512};
// Default width/height ratio of minimal dialog size.
const double kMinimumWidthRatio = 0.25;
const double kMinimumHeightRatio = 0.25;
base::LazyInstance<base::circular_deque<WebContents*>>::DestructorAtExit base::LazyInstance<base::circular_deque<WebContents*>>::DestructorAtExit
g_web_contents_stack = LAZY_INSTANCE_INITIALIZER; g_web_contents_stack = LAZY_INSTANCE_INITIALIZER;
...@@ -58,9 +55,6 @@ LoginWebDialog::LoginWebDialog(content::BrowserContext* browser_context, ...@@ -58,9 +55,6 @@ LoginWebDialog::LoginWebDialog(content::BrowserContext* browser_context,
delegate_(delegate), delegate_(delegate),
title_(title), title_(title),
url_(url) { url_(url) {
gfx::Rect screen_bounds(CalculateScreenBounds(gfx::Size()));
width_ = static_cast<int>(kDefaultWidthRatio * screen_bounds.width());
height_ = static_cast<int>(kDefaultHeightRatio * screen_bounds.height());
} }
LoginWebDialog::~LoginWebDialog() {} LoginWebDialog::~LoginWebDialog() {}
...@@ -70,13 +64,6 @@ void LoginWebDialog::Show() { ...@@ -70,13 +64,6 @@ void LoginWebDialog::Show() {
chrome::ShowWebDialog(parent_window_, browser_context_, this); chrome::ShowWebDialog(parent_window_, browser_context_, this);
} }
void LoginWebDialog::SetDialogSize(int width, int height) {
DCHECK_GE(width, 0);
DCHECK_GE(height, 0);
width_ = width;
height_ = height;
}
void LoginWebDialog::SetDialogTitle(const base::string16& title) { void LoginWebDialog::SetDialogTitle(const base::string16& title) {
title_ = title; title_ = title;
} }
...@@ -100,13 +87,15 @@ void LoginWebDialog::GetWebUIMessageHandlers( ...@@ -100,13 +87,15 @@ void LoginWebDialog::GetWebUIMessageHandlers(
std::vector<WebUIMessageHandler*>* handlers) const {} std::vector<WebUIMessageHandler*>* handlers) const {}
void LoginWebDialog::GetDialogSize(gfx::Size* size) const { void LoginWebDialog::GetDialogSize(gfx::Size* size) const {
size->SetSize(width_, height_); gfx::Rect bounds = parent_window_->bounds();
bounds.Inset(kMinMargins);
*size = bounds.size();
size->SetToMin(kMaxSize);
size->SetToMax(kMinSize);
} }
void LoginWebDialog::GetMinimumDialogSize(gfx::Size* size) const { void LoginWebDialog::GetMinimumDialogSize(gfx::Size* size) const {
gfx::Rect screen_bounds(CalculateScreenBounds(gfx::Size())); *size = kMinSize;
size->SetSize(kMinimumWidthRatio * screen_bounds.width(),
kMinimumHeightRatio * screen_bounds.height());
} }
std::string LoginWebDialog::GetDialogArgs() const { std::string LoginWebDialog::GetDialogArgs() const {
......
...@@ -45,9 +45,6 @@ class LoginWebDialog : public ui::WebDialogDelegate { ...@@ -45,9 +45,6 @@ class LoginWebDialog : public ui::WebDialogDelegate {
void Show(); void Show();
// Overrides default width/height for dialog.
void SetDialogSize(int width, int height);
// Overrides dialog title. // Overrides dialog title.
void SetDialogTitle(const base::string16& title); void SetDialogTitle(const base::string16& title);
...@@ -95,10 +92,6 @@ class LoginWebDialog : public ui::WebDialogDelegate { ...@@ -95,10 +92,6 @@ class LoginWebDialog : public ui::WebDialogDelegate {
base::string16 title_; base::string16 title_;
const GURL url_; const GURL url_;
// Dialog display size.
int width_;
int height_;
DISALLOW_COPY_AND_ASSIGN(LoginWebDialog); DISALLOW_COPY_AND_ASSIGN(LoginWebDialog);
}; };
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
...@@ -19,7 +20,8 @@ using LoginWebDialogTest = InProcessBrowserTest; ...@@ -19,7 +20,8 @@ using LoginWebDialogTest = InProcessBrowserTest;
// Tests that LoginWebDialog is not minimizable. // Tests that LoginWebDialog is not minimizable.
IN_PROC_BROWSER_TEST_F(LoginWebDialogTest, CannotMinimize) { IN_PROC_BROWSER_TEST_F(LoginWebDialogTest, CannotMinimize) {
LoginWebDialog* dialog = new LoginWebDialog( LoginWebDialog* dialog = new LoginWebDialog(
browser()->profile(), nullptr, nullptr, base::string16(), GURL()); browser()->profile(), nullptr, browser()->window()->GetNativeWindow(),
base::string16(), GURL());
dialog->Show(); dialog->Show();
aura::Window* window = dialog->get_dialog_window_for_test(); aura::Window* window = dialog->get_dialog_window_for_test();
ASSERT_TRUE(window); ASSERT_TRUE(window);
...@@ -30,7 +32,8 @@ IN_PROC_BROWSER_TEST_F(LoginWebDialogTest, CannotMinimize) { ...@@ -30,7 +32,8 @@ IN_PROC_BROWSER_TEST_F(LoginWebDialogTest, CannotMinimize) {
// Tests that LoginWebDialog can be closed by 'Shift + BrowserBack' accelerator. // Tests that LoginWebDialog can be closed by 'Shift + BrowserBack' accelerator.
IN_PROC_BROWSER_TEST_F(LoginWebDialogTest, CloseDialogByAccelerator) { IN_PROC_BROWSER_TEST_F(LoginWebDialogTest, CloseDialogByAccelerator) {
LoginWebDialog* dialog = new LoginWebDialog( LoginWebDialog* dialog = new LoginWebDialog(
browser()->profile(), nullptr, nullptr, base::string16(), GURL()); browser()->profile(), nullptr, browser()->window()->GetNativeWindow(),
base::string16(), GURL());
dialog->Show(); dialog->Show();
gfx::NativeWindow window = dialog->get_dialog_window_for_test(); gfx::NativeWindow window = dialog->get_dialog_window_for_test();
ASSERT_TRUE(window); ASSERT_TRUE(window);
......
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