| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 ProtocolHandlerMap protocol_handlers; | 85 ProtocolHandlerMap protocol_handlers; |
| 86 protocol_handlers[url::kHttpScheme] = | 86 protocol_handlers[url::kHttpScheme] = |
| 87 base::MakeUnique<DeterministicHttpProtocolHandler>( | 87 base::MakeUnique<DeterministicHttpProtocolHandler>( |
| 88 deterministic_dispatcher_.get(), browser->BrowserIOThread()); | 88 deterministic_dispatcher_.get(), browser->BrowserIOThread()); |
| 89 protocol_handlers[url::kHttpsScheme] = | 89 protocol_handlers[url::kHttpsScheme] = |
| 90 base::MakeUnique<DeterministicHttpProtocolHandler>( | 90 base::MakeUnique<DeterministicHttpProtocolHandler>( |
| 91 deterministic_dispatcher_.get(), browser->BrowserIOThread()); | 91 deterministic_dispatcher_.get(), browser->BrowserIOThread()); |
| 92 | 92 |
| 93 context_builder.SetProtocolHandlers(std::move(protocol_handlers)); | 93 context_builder.SetProtocolHandlers(std::move(protocol_handlers)); |
| 94 } | 94 } |
| 95 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 96 switches::kHideScrollbars)) { | |
| 97 context_builder.SetOverrideWebPreferencesCallback( | |
| 98 base::Bind([](WebPreferences* preferences) { | |
| 99 preferences->hide_scrollbars = true; | |
| 100 })); | |
| 101 } | |
| 102 browser_context_ = context_builder.Build(); | 95 browser_context_ = context_builder.Build(); |
| 103 browser_->SetDefaultBrowserContext(browser_context_); | 96 browser_->SetDefaultBrowserContext(browser_context_); |
| 104 | 97 |
| 105 HeadlessWebContents::Builder builder( | 98 HeadlessWebContents::Builder builder( |
| 106 browser_context_->CreateWebContentsBuilder()); | 99 browser_context_->CreateWebContentsBuilder()); |
| 107 base::CommandLine::StringVector args = | 100 base::CommandLine::StringVector args = |
| 108 base::CommandLine::ForCurrentProcess()->GetArgs(); | 101 base::CommandLine::ForCurrentProcess()->GetArgs(); |
| 109 | 102 |
| 110 // TODO(alexclarke): Should we navigate to about:blank first if using | 103 // TODO(alexclarke): Should we navigate to about:blank first if using |
| 111 // virtual time? | 104 // virtual time? |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 std::string window_size = | 504 std::string window_size = |
| 512 command_line.GetSwitchValueASCII(switches::kWindowSize); | 505 command_line.GetSwitchValueASCII(switches::kWindowSize); |
| 513 gfx::Size parsed_window_size; | 506 gfx::Size parsed_window_size; |
| 514 if (!ParseWindowSize(window_size, &parsed_window_size)) { | 507 if (!ParseWindowSize(window_size, &parsed_window_size)) { |
| 515 LOG(ERROR) << "Malformed window size"; | 508 LOG(ERROR) << "Malformed window size"; |
| 516 return EXIT_FAILURE; | 509 return EXIT_FAILURE; |
| 517 } | 510 } |
| 518 builder.SetWindowSize(parsed_window_size); | 511 builder.SetWindowSize(parsed_window_size); |
| 519 } | 512 } |
| 520 | 513 |
| 514 if (command_line.HasSwitch(switches::kHideScrollbars)) { |
| 515 builder.SetOverrideWebPreferencesCallback(base::Bind([]( |
| 516 WebPreferences* preferences) { preferences->hide_scrollbars = true; })); |
| 517 } |
| 518 |
| 521 return HeadlessBrowserMain( | 519 return HeadlessBrowserMain( |
| 522 builder.Build(), | 520 builder.Build(), |
| 523 base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell))); | 521 base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell))); |
| 524 } | 522 } |
| 525 | 523 |
| 526 } // namespace headless | 524 } // namespace headless |
| OLD | NEW |