OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <memory> | 5 #include <memory> |
6 #include <sstream> | 6 #include <sstream> |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 } | 99 } |
100 browser_context_ = context_builder.Build(); | 100 browser_context_ = context_builder.Build(); |
101 | 101 |
102 HeadlessWebContents::Builder builder( | 102 HeadlessWebContents::Builder builder( |
103 browser_context_->CreateWebContentsBuilder()); | 103 browser_context_->CreateWebContentsBuilder()); |
104 base::CommandLine::StringVector args = | 104 base::CommandLine::StringVector args = |
105 base::CommandLine::ForCurrentProcess()->GetArgs(); | 105 base::CommandLine::ForCurrentProcess()->GetArgs(); |
106 | 106 |
107 // TODO(alexclarke): Should we navigate to about:blank first if using | 107 // TODO(alexclarke): Should we navigate to about:blank first if using |
108 // virtual time? | 108 // virtual time? |
109 if (args.empty()) | 109 //if (args.empty()) |
dvallet
2017/02/13 03:20:24
These is no longer needed
| |
110 args.push_back("about:blank"); | 110 // args.push_back("about:blank"); |
111 for (auto it = args.rbegin(); it != args.rend(); ++it) { | 111 for (auto it = args.rbegin(); it != args.rend(); ++it) { |
112 GURL url(*it); | 112 GURL url(*it); |
113 HeadlessWebContents* web_contents = builder.SetInitialURL(url).Build(); | 113 HeadlessWebContents* web_contents = builder.SetInitialURL(url).Build(); |
114 if (!web_contents) { | 114 if (!web_contents) { |
115 LOG(ERROR) << "Navigation to " << url << " failed"; | 115 LOG(ERROR) << "Navigation to " << url << " failed"; |
116 browser_->Shutdown(); | 116 browser_->Shutdown(); |
117 return; | 117 return; |
118 } | 118 } |
119 if (!web_contents_ && !RemoteDebuggingEnabled()) { | 119 if (!web_contents_ && !RemoteDebuggingEnabled()) { |
120 // TODO(jzfeng): Support observing multiple targets. | 120 // TODO(jzfeng): Support observing multiple targets. |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
439 } | 439 } |
440 return true; | 440 return true; |
441 } | 441 } |
442 | 442 |
443 int HeadlessShellMain(int argc, const char** argv) { | 443 int HeadlessShellMain(int argc, const char** argv) { |
444 RunChildProcessIfNeeded(argc, argv); | 444 RunChildProcessIfNeeded(argc, argv); |
445 HeadlessShell shell; | 445 HeadlessShell shell; |
446 HeadlessBrowser::Options::Builder builder(argc, argv); | 446 HeadlessBrowser::Options::Builder builder(argc, argv); |
447 | 447 |
448 // Enable devtools if requested. | 448 // Enable devtools if requested. |
449 base::CommandLine command_line(argc, argv); | 449 base::CommandLine::Init(0, nullptr); |
dvallet
2017/02/13 03:20:24
Ditto, this is not needed anymore
| |
450 | |
451 const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess( ); | |
450 if (!ValidateCommandLine(command_line)) | 452 if (!ValidateCommandLine(command_line)) |
451 return EXIT_FAILURE; | 453 return EXIT_FAILURE; |
452 | 454 |
453 if (command_line.HasSwitch(::switches::kRemoteDebuggingPort)) { | 455 if (command_line.HasSwitch(::switches::kRemoteDebuggingPort)) { |
454 std::string address = kDevToolsHttpServerAddress; | 456 std::string address = kDevToolsHttpServerAddress; |
455 if (command_line.HasSwitch(switches::kRemoteDebuggingAddress)) { | 457 if (command_line.HasSwitch(switches::kRemoteDebuggingAddress)) { |
456 address = | 458 address = |
457 command_line.GetSwitchValueASCII(switches::kRemoteDebuggingAddress); | 459 command_line.GetSwitchValueASCII(switches::kRemoteDebuggingAddress); |
458 net::IPAddress parsed_address; | 460 net::IPAddress parsed_address; |
459 if (!net::ParseURLHostnameToAddress(address, &parsed_address)) { | 461 if (!net::ParseURLHostnameToAddress(address, &parsed_address)) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
514 } | 516 } |
515 builder.SetWindowSize(parsed_window_size); | 517 builder.SetWindowSize(parsed_window_size); |
516 } | 518 } |
517 | 519 |
518 return HeadlessBrowserMain( | 520 return HeadlessBrowserMain( |
519 builder.Build(), | 521 builder.Build(), |
520 base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell))); | 522 base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell))); |
521 } | 523 } |
522 | 524 |
523 } // namespace headless | 525 } // namespace headless |
OLD | NEW |