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

Unified Diff: headless/app/headless_shell.cc

Issue 2609843002: open multple tabs from CLI (Closed)
Patch Set: add flag check Created 3 years, 11 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 | no next file » | 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 530a7c5dc3498e2d3b19d99b12c8ce6da043d47a..38eebb00397df32d5b2bd59eb2c2cf37f6608fc9 100644
--- a/headless/app/headless_shell.cc
+++ b/headless/app/headless_shell.cc
@@ -104,17 +104,24 @@ class HeadlessShell : public HeadlessWebContents::Observer,
base::CommandLine::StringVector args =
base::CommandLine::ForCurrentProcess()->GetArgs();
- // TODO(alexclarke): Should we navigate to about:blank first if using
- // virtual time?
- if (!args.empty() && !args[0].empty())
- builder.SetInitialURL(GURL(args[0]));
-
- web_contents_ = builder.Build();
- if (!web_contents_) {
- LOG(ERROR) << "Navigation failed";
+ if (!MultiTabsCheckPassed(args.size())) {
Eric Seckler 2017/01/10 17:42:30 nit: Can we move this to HeadlessShellMain() befor
jzfeng 2017/01/11 12:00:27 Good point. Done.
browser_->Shutdown();
return;
}
+ // TODO(alexclarke): Should we navigate to about:blank first if using
+ // virtual time?
+ if (args.empty()) {
+ args.push_back("about:blank");
+ }
+ for (auto it = args.rbegin(); it != args.rend(); ++it) {
+ url_ = GURL(*it);
Eric Seckler 2017/01/10 17:42:30 Good spot, seems like we didn't set url_ correctly
jzfeng 2017/01/11 12:00:27 By experiment, I found the tab order on the Inspec
+ web_contents_ = builder.SetInitialURL(url_).Build();
+ if (!web_contents_) {
+ LOG(ERROR) << "Navigation to " << url_ << " failed";
+ browser_->Shutdown();
+ return;
+ }
+ }
web_contents_->AddObserver(this);
Eric Seckler 2017/01/10 17:42:30 I think this is a rather temporary solution, since
}
@@ -386,6 +393,28 @@ class HeadlessShell : public HeadlessWebContents::Observer,
return command_line.HasSwitch(::switches::kRemoteDebuggingPort);
}
+ bool MultiTabsCheckPassed(const int tab_number) const {
Sami 2017/01/11 11:32:37 nit: I'm not sure what the method name is saying.
jzfeng 2017/01/11 12:00:27 I moved this function to HeadlessShellMain and cha
alex clarke (OOO till 29th) 2017/01/11 12:03:39 One rule of thumb, any type of integer or floating
+ if (tab_number < 2 || RemoteDebuggingEnabled()) {
+ return true;
+ }
+ const base::CommandLine& command_line =
+ *base::CommandLine::ForCurrentProcess();
+ if (command_line.HasSwitch(switches::kDumpDom)) {
Eric Seckler 2017/01/10 17:42:30 Actually, I think at the moment, we kinda require
jzfeng 2017/01/11 12:00:27 Done.
+ LOG(ERROR) << "Dump dom is not supported for multiple tabs.";
Sami 2017/01/11 11:32:37 nit: s/dom/DOM/
jzfeng 2017/01/11 12:00:27 Done.
+ return false;
+ }
+ if (command_line.HasSwitch(switches::kRepl)) {
+ LOG(ERROR) << "Evaluate Javascript is not supported for multiple tabs.";
+ return false;
+ }
+ if (command_line.HasSwitch(switches::kScreenshot)) {
+ // TODO(jzfeng): Add support for multiple tabs in the future.
+ LOG(ERROR) << "Capture screenshot is not supported for multiple tabs.";
+ return false;
+ }
+ return true;
+ }
+
private:
GURL url_;
HeadlessBrowser* browser_; // Not owned.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698