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

Unified Diff: headless/public/headless_browser_context.h

Issue 2181413002: [headless] Remove default browser context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Small 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/public/headless_browser_context.h
diff --git a/headless/public/headless_browser_context.h b/headless/public/headless_browser_context.h
index 165e12fc403157b03df9e327b2be561615502bd9..6190a6a4defe32ac1121a486c37dd1ffe1f6fbf2 100644
--- a/headless/public/headless_browser_context.h
+++ b/headless/public/headless_browser_context.h
@@ -6,12 +6,20 @@
#define HEADLESS_PUBLIC_HEADLESS_BROWSER_CONTEXT_H_
#include <list>
+#include <memory>
+#include <string>
+#include <unordered_map>
+#include <vector>
+#include "base/optional.h"
#include "headless/public/headless_export.h"
+#include "headless/public/headless_web_contents.h"
+#include "net/base/host_port_pair.h"
#include "net/url_request/url_request_job_factory.h"
namespace headless {
class HeadlessBrowserImpl;
+class HeadlessBrowserContextOptions;
using ProtocolHandlerMap = std::unordered_map<
std::string,
@@ -25,6 +33,12 @@ class HEADLESS_EXPORT HeadlessBrowserContext {
virtual ~HeadlessBrowserContext() {}
+ // Open a new tab. Returns a builder object which can be used to set
+ // properties for the new tab.
+ virtual HeadlessWebContents::Builder CreateWebContentsBuilder() = 0;
+
+ virtual std::vector<HeadlessWebContents*> GetAllWebContents() = 0;
+
// TODO(skyostil): Allow saving and restoring contexts (crbug.com/617931).
protected:
@@ -34,7 +48,6 @@ class HEADLESS_EXPORT HeadlessBrowserContext {
DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserContext);
};
-// TODO(alexclarke): We should support this builder for the default context.
class HEADLESS_EXPORT HeadlessBrowserContext::Builder {
public:
Builder(Builder&&);
@@ -64,11 +77,25 @@ class HEADLESS_EXPORT HeadlessBrowserContext::Builder {
Builder& EnableUnsafeNetworkAccessWithMojoBindings(
bool enable_http_and_https_if_mojo_used);
+ // Set HeadlessBrowser::Builder::SetUserAgent.
Sami 2016/08/03 11:20:31 How about formatting this thusly: // By default H
altimin 2016/08/03 11:54:10 Done.
+ Builder& SetUserAgent(const std::string& user_agent);
+
+ // See HeadlessBrowser::Builder::SetProxyServer.
+ Builder& SetProxyServer(const net::HostPortPair& proxy_server);
+
+ // See HeadlessBrowser::Builder::SetHostResolverRules.
+ Builder& SetHostResolverRules(const std::string& host_resolver_rules);
+
+ // See HeadlessBrowser::Builder::SetUserDataDir.
+ Builder& SetUserDataDir(const base::FilePath& user_data_dir);
+
std::unique_ptr<HeadlessBrowserContext> Build();
private:
friend class HeadlessBrowserImpl;
+ explicit Builder(HeadlessBrowserImpl* browser);
+
struct MojoBindings {
MojoBindings();
MojoBindings(const std::string& mojom_name, const std::string& js_bindings);
@@ -81,10 +108,9 @@ class HEADLESS_EXPORT HeadlessBrowserContext::Builder {
DISALLOW_COPY_AND_ASSIGN(MojoBindings);
};
- explicit Builder(HeadlessBrowserImpl* browser);
-
HeadlessBrowserImpl* browser_;
- ProtocolHandlerMap protocol_handlers_;
+ std::unique_ptr<HeadlessBrowserContextOptions> options_;
+
std::list<MojoBindings> mojo_bindings_;
bool enable_http_and_https_if_mojo_used_;

Powered by Google App Engine
This is Rietveld 408576698