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

Unified Diff: headless/lib/browser/headless_browser_context_options.cc

Issue 2181413002: [headless] Remove default browser context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More fixes Created 4 years, 4 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
Index: headless/lib/browser/headless_browser_context_options.cc
diff --git a/headless/lib/browser/headless_browser_context_options.cc b/headless/lib/browser/headless_browser_context_options.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6f7a4d8fc61f0379364e3ca5d08e17df98a427f4
--- /dev/null
+++ b/headless/lib/browser/headless_browser_context_options.cc
@@ -0,0 +1,68 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "headless/lib/browser/headless_browser_context_options.h"
+
+#include <string>
+#include <utility>
+
+namespace headless {
+
+namespace {
+
+template <class T>
+const T& ReturnOverriddenValue(const base::Optional<T>& value,
+ const T& default_value) {
+ if (value) {
+ return *value;
+ } else {
+ return default_value;
+ }
+}
+
+} // namespace
+
+HeadlessBrowserContextOptions::HeadlessBrowserContextOptions(
+ HeadlessBrowserContextOptions&& options) = default;
+
+HeadlessBrowserContextOptions::~HeadlessBrowserContextOptions() = default;
+
+HeadlessBrowserContextOptions& HeadlessBrowserContextOptions::operator=(
+ HeadlessBrowserContextOptions&& options) = default;
+
+HeadlessBrowserContextOptions::HeadlessBrowserContextOptions(
+ HeadlessBrowser::Options* options)
+ : browser_options_(options) {}
+
+const std::string& HeadlessBrowserContextOptions::user_agent() const {
+ return ReturnOverriddenValue(user_agent_, browser_options_->user_agent);
+}
+
+const net::HostPortPair& HeadlessBrowserContextOptions::proxy_server() const {
+ return ReturnOverriddenValue(proxy_server_, browser_options_->proxy_server);
+}
+
+const std::string& HeadlessBrowserContextOptions::host_resolver_rules() const {
+ return ReturnOverriddenValue(host_resolver_rules_,
+ browser_options_->host_resolver_rules);
+}
+
+const gfx::Size& HeadlessBrowserContextOptions::window_size() const {
+ return ReturnOverriddenValue(window_size_, browser_options_->window_size);
+}
+
+const base::FilePath& HeadlessBrowserContextOptions::user_data_dir() const {
+ return ReturnOverriddenValue(user_data_dir_, browser_options_->user_data_dir);
+}
+
+const ProtocolHandlerMap& HeadlessBrowserContextOptions::protocol_handlers()
+ const {
+ return protocol_handlers_;
+}
+
+ProtocolHandlerMap HeadlessBrowserContextOptions::TakeProtocolHandlers() {
+ return std::move(protocol_handlers_);
+}
+
+} // namespace headless

Powered by Google App Engine
This is Rietveld 408576698