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/base_switches.h" |
10 #include "base/bind.h" | 11 #include "base/bind.h" |
11 #include "base/callback.h" | 12 #include "base/callback.h" |
12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
14 #include "base/json/json_writer.h" | 15 #include "base/json/json_writer.h" |
15 #include "base/location.h" | 16 #include "base/location.h" |
16 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
17 #include "base/numerics/safe_conversions.h" | 18 #include "base/numerics/safe_conversions.h" |
18 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
19 #include "headless/app/headless_shell.h" | 20 #include "headless/app/headless_shell.h" |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 RunChildProcessIfNeeded(argc, argv); | 435 RunChildProcessIfNeeded(argc, argv); |
435 HeadlessShell shell; | 436 HeadlessShell shell; |
436 HeadlessBrowser::Options::Builder builder(argc, argv); | 437 HeadlessBrowser::Options::Builder builder(argc, argv); |
437 | 438 |
438 // Enable devtools if requested. | 439 // Enable devtools if requested. |
439 const base::CommandLine& command_line( | 440 const base::CommandLine& command_line( |
440 *base::CommandLine::ForCurrentProcess()); | 441 *base::CommandLine::ForCurrentProcess()); |
441 if (!ValidateCommandLine(command_line)) | 442 if (!ValidateCommandLine(command_line)) |
442 return EXIT_FAILURE; | 443 return EXIT_FAILURE; |
443 | 444 |
| 445 if (command_line.HasSwitch(::switches::kEnableCrashReporter)) |
| 446 builder.SetCrashReporterEnabled(true); |
| 447 if (command_line.HasSwitch(switches::kCrashDumpsDir)) { |
| 448 builder.SetCrashDumpsDir( |
| 449 command_line.GetSwitchValuePath(switches::kCrashDumpsDir)); |
| 450 } |
| 451 |
444 if (command_line.HasSwitch(::switches::kRemoteDebuggingPort)) { | 452 if (command_line.HasSwitch(::switches::kRemoteDebuggingPort)) { |
445 std::string address = kDevToolsHttpServerAddress; | 453 std::string address = kDevToolsHttpServerAddress; |
446 if (command_line.HasSwitch(switches::kRemoteDebuggingAddress)) { | 454 if (command_line.HasSwitch(switches::kRemoteDebuggingAddress)) { |
447 address = | 455 address = |
448 command_line.GetSwitchValueASCII(switches::kRemoteDebuggingAddress); | 456 command_line.GetSwitchValueASCII(switches::kRemoteDebuggingAddress); |
449 net::IPAddress parsed_address; | 457 net::IPAddress parsed_address; |
450 if (!net::ParseURLHostnameToAddress(address, &parsed_address)) { | 458 if (!net::ParseURLHostnameToAddress(address, &parsed_address)) { |
451 LOG(ERROR) << "Invalid devtools server address"; | 459 LOG(ERROR) << "Invalid devtools server address"; |
452 return EXIT_FAILURE; | 460 return EXIT_FAILURE; |
453 } | 461 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 builder.SetOverrideWebPreferencesCallback(base::Bind([]( | 518 builder.SetOverrideWebPreferencesCallback(base::Bind([]( |
511 WebPreferences* preferences) { preferences->hide_scrollbars = true; })); | 519 WebPreferences* preferences) { preferences->hide_scrollbars = true; })); |
512 } | 520 } |
513 | 521 |
514 return HeadlessBrowserMain( | 522 return HeadlessBrowserMain( |
515 builder.Build(), | 523 builder.Build(), |
516 base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell))); | 524 base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell))); |
517 } | 525 } |
518 | 526 |
519 } // namespace headless | 527 } // namespace headless |
OLD | NEW |