Commit 168b0ac2 authored by arurajku's avatar arurajku Committed by Commit bot

Add a command line switch to control the window size of content_shell.

This CL introduces a command line switch "--content-shell-host-window-size" to help the developers to specify the content_shell size for windowless ozone platforms like test, egltest, dri, caca.

Prior to this CL, the developer has to change the constants(kDefaultTestWindowWidthDip, kDefaultTestWindowHeightDip) in shell.cc to increase the content_shell resolution for above mentioned ozone platforms.

Review URL: https://codereview.chromium.org/783203002

Cr-Commit-Position: refs/heads/master@{#308391}
parent 763ff21d
......@@ -39,6 +39,26 @@ base::Callback<void(Shell*)> Shell::shell_created_callback_;
bool Shell::quit_message_loop_ = true;
namespace {
gfx::Size ShellDefaultSize() {
static gfx::Size default_shell_size;
if (!default_shell_size.IsEmpty())
return default_shell_size;
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kContentShellHostWindowSize)) {
const std::string size_str = command_line->GetSwitchValueASCII(
switches::kContentShellHostWindowSize);
int width, height;
CHECK_EQ(2, sscanf(size_str.c_str(), "%dx%d", &width, &height));
default_shell_size = gfx::Size(width, height);
} else {
default_shell_size = gfx::Size(
Shell::kDefaultTestWindowWidthDip, Shell::kDefaultTestWindowHeightDip);
}
return default_shell_size;
}
} // namespace
class Shell::DevToolsWebContentsObserver : public WebContentsObserver {
public:
DevToolsWebContentsObserver(Shell* shell, WebContents* web_contents)
......@@ -141,14 +161,13 @@ Shell* Shell::FromRenderViewHost(RenderViewHost* rvh) {
// static
void Shell::Initialize() {
PlatformInitialize(
gfx::Size(kDefaultTestWindowWidthDip, kDefaultTestWindowHeightDip));
PlatformInitialize(ShellDefaultSize());
}
gfx::Size Shell::AdjustWindowSize(const gfx::Size& initial_size) {
if (!initial_size.IsEmpty())
return initial_size;
return gfx::Size(kDefaultTestWindowWidthDip, kDefaultTestWindowHeightDip);
return ShellDefaultSize();
}
Shell* Shell::CreateNewWindow(BrowserContext* browser_context,
......
......@@ -59,4 +59,7 @@ const char kRegisterFontFiles[] = "register-font-files";
// http://dev.chromium.org/blink/runtime-enabled-features.
const char kStableReleaseMode[] = "stable-release-mode";
// Size for the content_shell's host window (i.e. "800x600").
const char kContentShellHostWindowSize[] = "content-shell-host-window-size";
} // namespace switches
......@@ -24,6 +24,7 @@ extern const char kEncodeBinary[];
extern const char kExposeInternalsForTesting[];
extern const char kRegisterFontFiles[];
extern const char kStableReleaseMode[];
extern const char kContentShellHostWindowSize[];
} // namespace switches
......
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