Commit 96fc083e authored by Joel Hockey's avatar Joel Hockey Committed by Commit Bot

Remove unneeded app_name from GetBrowserWindowBoundsAndShowState

Browser type can be found directly from Browser rather
than passing app_name as a proxy.

Change-Id: I87e102dab24a67f2f691e0fd709a11c6252bee7e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2098157
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Auto-Submit: Joel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749472}
parent 8d958130
......@@ -547,9 +547,8 @@ ExtensionFunction::ResponseAction WindowsCreateFunction::Run() {
// Initialize default window bounds according to window type.
ui::WindowShowState ignored_show_state = ui::SHOW_STATE_DEFAULT;
WindowSizer::GetBrowserWindowBoundsAndShowState(std::string(), gfx::Rect(),
nullptr, &window_bounds,
&ignored_show_state);
WindowSizer::GetBrowserWindowBoundsAndShowState(
gfx::Rect(), nullptr, &window_bounds, &ignored_show_state);
// Any part of the bounds can optionally be set by the caller.
if (create_data->left)
......
......@@ -156,8 +156,8 @@ void GetSavedWindowBoundsAndShowState(const Browser* browser,
DCHECK(bounds);
DCHECK(show_state);
*bounds = browser->override_bounds();
WindowSizer::GetBrowserWindowBoundsAndShowState(browser->app_name(), *bounds,
browser, bounds, show_state);
WindowSizer::GetBrowserWindowBoundsAndShowState(*bounds, browser, bounds,
show_state);
const base::CommandLine& parsed_command_line =
*base::CommandLine::ForCurrentProcess();
......
......@@ -35,9 +35,7 @@ const int kMinVisibleWidth = 30;
// and persistent state from the browser window and the user's profile.
class DefaultStateProvider : public WindowSizer::StateProvider {
public:
DefaultStateProvider(const std::string& app_name, const Browser* browser)
: app_name_(app_name), browser_(browser) {
}
explicit DefaultStateProvider(const Browser* browser) : browser_(browser) {}
// Overridden from WindowSizer::StateProvider:
bool GetPersistentState(gfx::Rect* bounds,
......@@ -87,7 +85,7 @@ class DefaultStateProvider : public WindowSizer::StateProvider {
ui::WindowShowState* show_state) const override {
DCHECK(show_state);
// Applications are always restored with the same position.
if (!app_name_.empty())
if (browser_ && browser_->deprecated_is_app())
return false;
// If a reference browser is set, use its window. Otherwise find last
......@@ -146,13 +144,11 @@ WindowSizer::~WindowSizer() = default;
// static
void WindowSizer::GetBrowserWindowBoundsAndShowState(
const std::string& app_name,
const gfx::Rect& specified_bounds,
const Browser* browser,
gfx::Rect* window_bounds,
ui::WindowShowState* show_state) {
std::unique_ptr<StateProvider> state_provider(
new DefaultStateProvider(app_name, browser));
auto state_provider = std::make_unique<DefaultStateProvider>(browser);
const WindowSizer sizer(std::move(state_provider), browser);
sizer.DetermineWindowBoundsAndShowState(specified_bounds,
window_bounds,
......
......@@ -72,12 +72,11 @@ class WindowSizer {
ui::WindowShowState* show_state) const;
// Determines the size, position and maximized state for the browser window.
// See documentation for DetermineWindowBounds above. Normally,
// See documentation for DetermineWindowBoundsAndShowState above. Normally,
// |window_bounds| is calculated by calling GetLastActiveWindowState(). To
// explicitly specify a particular window to base the bounds on, pass in a
// non-NULL value for |browser|.
static void GetBrowserWindowBoundsAndShowState(
const std::string& app_name,
const gfx::Rect& specified_bounds,
const Browser* browser,
gfx::Rect* window_bounds,
......
......@@ -698,7 +698,7 @@ TEST_F(WindowSizerAshTest, DefaultStateBecomesMaximized) {
ui::WindowShowState show_state = ui::SHOW_STATE_DEFAULT;
gfx::Rect bounds;
WindowSizer::GetBrowserWindowBoundsAndShowState(
std::string(), specified_bounds, browser.get(), &bounds, &show_state);
specified_bounds, browser.get(), &bounds, &show_state);
// The window should start maximized with its restore bounds shrunken.
EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, show_state);
EXPECT_NE(display_bounds.ToString(), bounds.ToString());
......@@ -708,7 +708,7 @@ TEST_F(WindowSizerAshTest, DefaultStateBecomesMaximized) {
specified_bounds.Inset(100, 100);
show_state = ui::SHOW_STATE_DEFAULT;
WindowSizer::GetBrowserWindowBoundsAndShowState(
std::string(), specified_bounds, browser.get(), &bounds, &show_state);
specified_bounds, browser.get(), &bounds, &show_state);
// The window should start in default state.
EXPECT_EQ(ui::SHOW_STATE_DEFAULT, show_state);
EXPECT_EQ(specified_bounds.ToString(), bounds.ToString());
......@@ -726,8 +726,8 @@ TEST_F(WindowSizerAshTest, DefaultBoundsInTargetDisplay) {
EXPECT_EQ(first_root, ash::Shell::GetRootWindowForNewWindows());
gfx::Rect bounds;
ui::WindowShowState show_state;
WindowSizer::GetBrowserWindowBoundsAndShowState(std::string(), gfx::Rect(),
NULL, &bounds, &show_state);
WindowSizer::GetBrowserWindowBoundsAndShowState(gfx::Rect(), nullptr, &bounds,
&show_state);
EXPECT_TRUE(first_root->GetBoundsInScreen().Contains(bounds));
{
......@@ -741,7 +741,6 @@ TEST_F(WindowSizerAshTest, DefaultBoundsInTargetDisplay) {
gfx::Rect bounds;
ui::WindowShowState show_state;
WindowSizer::GetBrowserWindowBoundsAndShowState(
std::string(),
gfx::Rect(),
NULL,
&bounds,
......
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