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

Unified Diff: headless/public/headless_web_contents.h

Issue 2043603004: headless: Introduce a browser context (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address nits Created 4 years, 6 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/public/headless_browser_context.h ('k') | headless/test/headless_browser_test.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/public/headless_web_contents.h
diff --git a/headless/public/headless_web_contents.h b/headless/public/headless_web_contents.h
index 27a4e8f4b12ce7cff7d354102d2b8fb62e3d27e0..a193d5042e6932a42330ef9edca24d54eb54ce9d 100644
--- a/headless/public/headless_web_contents.h
+++ b/headless/public/headless_web_contents.h
@@ -8,15 +8,20 @@
#include "base/callback.h"
#include "base/macros.h"
#include "headless/public/headless_export.h"
+#include "ui/gfx/geometry/size.h"
#include "url/gurl.h"
namespace headless {
+class HeadlessBrowserContext;
+class HeadlessBrowserImpl;
class HeadlessDevToolsTarget;
// Class representing contents of a browser tab. Should be accessed from browser
// main thread.
class HEADLESS_EXPORT HeadlessWebContents {
public:
+ class Builder;
+
virtual ~HeadlessWebContents() {}
class Observer {
@@ -57,6 +62,44 @@ class HEADLESS_EXPORT HeadlessWebContents {
DISALLOW_COPY_AND_ASSIGN(HeadlessWebContents);
};
+class HEADLESS_EXPORT HeadlessWebContents::Builder {
+ public:
+ ~Builder();
+ Builder(Builder&&);
+
+ // Set an initial URL to ensure that the renderer gets initialized and
+ // eventually becomes ready to be inspected. See
+ // HeadlessWebContents::Observer::DevToolsTargetReady. The default URL is
+ // about:blank.
+ Builder& SetInitialURL(const GURL& initial_url);
+
+ // Specify the initial window size (default is 800x600).
+ Builder& SetWindowSize(const gfx::Size& size);
+
+ // Set a browser context for storing session data (e.g., cookies, cache, local
+ // storage) for the tab. Several tabs can share the same browser context. If
+ // unset, the default browser context will be used. The browser context must
+ // outlive this HeadlessWebContents.
+ Builder& SetBrowserContext(HeadlessBrowserContext* browser_context);
+
+ // The returned object is owned by HeadlessBrowser. Call
+ // HeadlessWebContents::Close() to dispose it.
+ HeadlessWebContents* Build();
+
+ private:
+ friend class HeadlessBrowserImpl;
+ friend class HeadlessWebContentsImpl;
+
+ explicit Builder(HeadlessBrowserImpl* browser);
+
+ HeadlessBrowserImpl* browser_;
+ GURL initial_url_ = GURL("about:blank");
+ gfx::Size window_size_ = gfx::Size(800, 600);
+ HeadlessBrowserContext* browser_context_;
+
+ DISALLOW_COPY_AND_ASSIGN(Builder);
+};
+
} // namespace headless
#endif // HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_
« no previous file with comments | « headless/public/headless_browser_context.h ('k') | headless/test/headless_browser_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698