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

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

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.h
diff --git a/headless/lib/browser/headless_browser_context_options.h b/headless/lib/browser/headless_browser_context_options.h
new file mode 100644
index 0000000000000000000000000000000000000000..a3f97eac9ed0868f1a3cf27f39ed1c5c66b2d9c8
--- /dev/null
+++ b/headless/lib/browser/headless_browser_context_options.h
@@ -0,0 +1,67 @@
+// 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.
+
+#ifndef HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_OPTIONS_H_
+#define HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_OPTIONS_H_
+
+#include <string>
+
+#include "base/files/file_path.h"
+#include "base/optional.h"
+#include "headless/public/headless_browser.h"
+#include "headless/public/headless_browser_context.h"
+
+namespace headless {
+
+// Represents options which can be customized for a given BrowserContext.
+// Provides a fallback to default browser-side options when an option
+// is not set for a particular BrowserContext.
+class HeadlessBrowserContextOptions {
+ public:
+ HeadlessBrowserContextOptions(HeadlessBrowserContextOptions&& options);
+ ~HeadlessBrowserContextOptions();
+
+ HeadlessBrowserContextOptions& operator=(
+ HeadlessBrowserContextOptions&& options);
+
+ const std::string& user_agent() const;
+
+ // See HeadlessBrowser::Options::proxy_server.
+ const net::HostPortPair& proxy_server() const;
+
+ // See HeadlessBrowser::Options::host_resolver_rules.
+ const std::string& host_resolver_rules() const;
+
+ const gfx::Size& window_size() const;
+
+ // See HeadlessBrowser::Options::user_data_dir.
+ const base::FilePath& user_data_dir() const;
+
+ // Custom network protocol handlers. These can be used to override URL
+ // fetching for different network schemes.
+ const ProtocolHandlerMap& protocol_handlers() const;
+ // Since ProtocolHandlerMap is move-only, this method takes ownership of them.
+ ProtocolHandlerMap TakeProtocolHandlers();
+
+ private:
+ friend class HeadlessBrowserContext::Builder;
+
+ explicit HeadlessBrowserContextOptions(HeadlessBrowser::Options*);
+
+ HeadlessBrowser::Options* browser_options_;
+
+ base::Optional<std::string> user_agent_;
+ base::Optional<net::HostPortPair> proxy_server_;
+ base::Optional<std::string> host_resolver_rules_;
+ base::Optional<gfx::Size> window_size_;
+ base::Optional<base::FilePath> user_data_dir_;
+
+ ProtocolHandlerMap protocol_handlers_;
+
+ DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserContextOptions);
+};
+
+} // namespace headless
+
+#endif // HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_OPTIONS_H_

Powered by Google App Engine
This is Rietveld 408576698