Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Unified Diff: headless/app/headless_shell.cc

Issue 2814043002: [headless] Add command line flag for default background color. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | headless/app/headless_shell_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/app/headless_shell.cc
diff --git a/headless/app/headless_shell.cc b/headless/app/headless_shell.cc
index a49aef1f47abd940e8639a5086c08c1f68e1f934..ff670db059b80d023d289528e3a23b4e870123f2 100644
--- a/headless/app/headless_shell.cc
+++ b/headless/app/headless_shell.cc
@@ -136,8 +136,6 @@ void HeadlessShell::DevToolsTargetReady() {
devtools_client_->GetInspector()->GetExperimental()->AddObserver(this);
devtools_client_->GetPage()->GetExperimental()->AddObserver(this);
devtools_client_->GetPage()->Enable();
- // Check if the document had already finished loading by the time we
- // attached.
devtools_client_->GetEmulation()->GetExperimental()->AddObserver(this);
@@ -148,6 +146,28 @@ void HeadlessShell::DevToolsTargetReady() {
.SetEnabled(true)
.Build());
}
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDefaultBackgroundColor)) {
+ std::string color_hex =
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kDefaultBackgroundColor);
+ uint32_t color;
+ CHECK(base::HexStringToUInt(color_hex, &color))
+ << "Expected a hex value for --default-background-color=";
+ auto rgba = headless::dom::RGBA::Builder()
+ .SetR((color & 0xff000000) >> 24)
+ .SetG((color & 0x00ff0000) >> 16)
+ .SetB((color & 0x0000ff00) >> 8)
+ .SetA(color & 0x000000ff)
+ .Build();
+ devtools_client_->GetEmulation()
+ ->GetExperimental()
+ ->SetDefaultBackgroundColorOverride(
+ headless::emulation::SetDefaultBackgroundColorOverrideParams::
+ Builder()
+ .SetColor(std::move(rgba))
+ .Build());
+ }
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kVirtualTimeBudget)) {
@@ -164,6 +184,8 @@ void HeadlessShell::DevToolsTargetReady() {
.SetBudget(budget_ms)
.Build());
} else {
+ // Check if the document had already finished loading by the time we
+ // attached.
PollReadyState();
}
@@ -438,10 +460,20 @@ bool ValidateCommandLine(const base::CommandLine& command_line) {
<< "remote debug port is set.";
return false;
}
+ if (command_line.HasSwitch(switches::kDefaultBackgroundColor)) {
+ LOG(ERROR) << "Setting default background color is disabled "
+ << "when remote debugging is enabled.";
+ return false;
+ }
if (command_line.HasSwitch(switches::kDumpDom)) {
LOG(ERROR) << "Dump DOM is disabled when remote debugging is enabled.";
return false;
}
+ if (command_line.HasSwitch(switches::kPrintToPDF)) {
+ LOG(ERROR) << "Print to PDF is disabled "
+ << "when remote debugging is enabled.";
+ return false;
+ }
if (command_line.HasSwitch(switches::kRepl)) {
LOG(ERROR) << "Evaluate Javascript is disabled "
<< "when remote debugging is enabled.";
@@ -452,11 +484,6 @@ bool ValidateCommandLine(const base::CommandLine& command_line) {
<< "when remote debugging is enabled.";
return false;
}
- if (command_line.HasSwitch(switches::kPrintToPDF)) {
- LOG(ERROR) << "Print to PDF is disabled "
- << "when remote debugging is enabled.";
- return false;
- }
if (command_line.HasSwitch(switches::kTimeout)) {
LOG(ERROR) << "Navigation timeout is disabled "
<< "when remote debugging is enabled.";
« no previous file with comments | « no previous file | headless/app/headless_shell_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698