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

Unified Diff: headless/public/headless_browser.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
« no previous file with comments | « headless/lib/headless_web_contents_browsertest.cc ('k') | headless/public/headless_browser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/public/headless_browser.h
diff --git a/headless/public/headless_browser.h b/headless/public/headless_browser.h
index 9fcd62c6a0141bebb16e23d665501f3e36c9fc91..781382466379af07509ada4f274caa5f1e39cb93 100644
--- a/headless/public/headless_browser.h
+++ b/headless/public/headless_browser.h
@@ -11,6 +11,7 @@
#include <vector>
#include "base/callback.h"
+#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "headless/public/headless_browser_context.h"
@@ -35,13 +36,11 @@ class HEADLESS_EXPORT HeadlessBrowser {
public:
struct Options;
- // Open a new tab. Returns a builder object which can be used to set
- // properties for the new tab.
- virtual HeadlessWebContents::Builder CreateWebContentsBuilder() = 0;
-
- // Deprecated. Use CreateWebContentsBuilder() instead.
- virtual HeadlessWebContents* CreateWebContents(const GURL& initial_url,
- const gfx::Size& size) = 0;
+ // Create a new browser context which can be used to create tabs and isolate
+ // them from one another.
+ // User owns newly created HeadlessBrowserContext and should delete them
Sami 2016/08/03 14:25:49 s/them/it/
+ // before calling HeadlessBrowser::Shutdown().
+ virtual HeadlessBrowserContext::Builder CreateBrowserContextBuilder() = 0;
virtual std::vector<HeadlessWebContents*> GetAllWebContents() = 0;
@@ -62,10 +61,6 @@ class HEADLESS_EXPORT HeadlessBrowser {
// browser stops.
virtual void Shutdown() = 0;
- // Create a new browser context, which can be used to isolate
- // HeadlessWebContents from one another.
- virtual HeadlessBrowserContext::Builder CreateBrowserContextBuilder() = 0;
-
protected:
HeadlessBrowser() {}
virtual ~HeadlessBrowser() {}
@@ -87,24 +82,13 @@ struct HeadlessBrowser::Options {
int argc;
const char** argv;
- std::string user_agent;
- std::string navigator_platform;
-
// Address at which DevTools should listen for connections. Disabled by
// default.
net::IPEndPoint devtools_endpoint;
- // Address of the HTTP/HTTPS proxy server to use. The system proxy settings
- // are used by default.
- net::HostPortPair proxy_server;
-
// Optional message pump that overrides the default. Must outlive the browser.
base::MessagePump* message_pump;
- // Comma-separated list of rules that control how hostnames are mapped. See
- // chrome::switches::kHostRules for a description for the format.
- std::string host_resolver_rules;
-
// Run the browser in single process mode instead of using separate renderer
// processes as per default. Note that this also disables any sandboxing of
// web content, which can be a security risk.
@@ -114,19 +98,33 @@ struct HeadlessBrowser::Options {
// a security risk and should be used with caution.
bool disable_sandbox;
- // Custom network protocol handlers. These can be used to override URL
- // fetching for different network schemes.
- ProtocolHandlerMap protocol_handlers;
-
// Choose the GL implementation to use for rendering. A suitable
// implementantion is selected by default. Setting this to an empty
// string can be used to disable GL rendering (e.g., WebGL support).
std::string gl_implementation;
+ // Default per-context options, can be specialized on per-context basis.
+
+ std::string user_agent;
+
+ // Address of the HTTP/HTTPS proxy server to use. The system proxy settings
+ // are used by default.
+ net::HostPortPair proxy_server;
+
+ // Comma-separated list of rules that control how hostnames are mapped. See
+ // chrome::switches::kHostRules for a description for the format.
+ std::string host_resolver_rules;
+
// Default window size. This is also used to create the window tree host and
// as initial screen size. Defaults to 800x600.
gfx::Size window_size;
+ // Path to user data directory, where browser will look for its state.
+ // If empty, default directory (where the binary is located) will be used.
+ base::FilePath user_data_dir;
+
+ // Reminder: when adding a new field here, do not forget to add it to
+ // HeadlessBrowserContextOptions (where appropriate).
private:
Options(int argc, const char** argv);
@@ -139,16 +137,21 @@ class HeadlessBrowser::Options::Builder {
Builder();
~Builder();
- Builder& SetUserAgent(const std::string& user_agent);
+ // Browser-wide settings.
+
Builder& EnableDevToolsServer(const net::IPEndPoint& endpoint);
Builder& SetMessagePump(base::MessagePump* message_pump);
- Builder& SetProxyServer(const net::HostPortPair& proxy_server);
- Builder& SetHostResolverRules(const std::string& host_resolver_rules);
Builder& SetSingleProcessMode(bool single_process_mode);
Builder& SetDisableSandbox(bool disable_sandbox);
- Builder& SetProtocolHandlers(ProtocolHandlerMap protocol_handlers);
Builder& SetGLImplementation(const std::string& gl_implementation);
+
+ // Per-context settings.
+
+ Builder& SetUserAgent(const std::string& user_agent);
+ Builder& SetProxyServer(const net::HostPortPair& proxy_server);
+ Builder& SetHostResolverRules(const std::string& host_resolver_rules);
Builder& SetWindowSize(const gfx::Size& window_size);
+ Builder& SetUserDataDir(const base::FilePath& user_data_dir);
Options Build();
« no previous file with comments | « headless/lib/headless_web_contents_browsertest.cc ('k') | headless/public/headless_browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698