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

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

Issue 1858403003: headless: Require the user to pass in an initial URL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/browser/headless_browser_impl.h ('k') | headless/lib/browser/headless_web_contents_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/lib/browser/headless_browser_impl.cc
diff --git a/headless/lib/browser/headless_browser_impl.cc b/headless/lib/browser/headless_browser_impl.cc
index 77f463d8caa04484e52b22f22375fbad7943bfed..57564d7ddc8828994e61fb7eaa84003b5e88462a 100644
--- a/headless/lib/browser/headless_browser_impl.cc
+++ b/headless/lib/browser/headless_browser_impl.cc
@@ -31,10 +31,18 @@ HeadlessBrowserImpl::HeadlessBrowserImpl(
HeadlessBrowserImpl::~HeadlessBrowserImpl() {}
std::unique_ptr<HeadlessWebContents> HeadlessBrowserImpl::CreateWebContents(
+ const GURL& initial_url,
const gfx::Size& size) {
DCHECK(BrowserMainThread()->BelongsToCurrentThread());
- return base::WrapUnique(new HeadlessWebContentsImpl(
- browser_context(), window_tree_host_->window(), size));
+ std::unique_ptr<HeadlessWebContentsImpl> web_contents =
+ base::WrapUnique(new HeadlessWebContentsImpl(
+ browser_context(), window_tree_host_->window(), size));
+ // We require the user to pass in an initial URL to ensure that the renderer
+ // gets initialized and eventually becomes ready to be inspected. See
+ // HeadlessWebContents::Observer::WebContentsReady.
+ if (!web_contents->OpenURL(initial_url))
alex clarke (OOO till 29th) 2016/04/06 15:34:53 Suppose this failed for some reason, how does the
Sami 2016/04/06 15:40:16 The only reason this would fail immediately is if
+ return nullptr;
+ return std::move(web_contents);
}
scoped_refptr<base::SingleThreadTaskRunner>
« no previous file with comments | « headless/lib/browser/headless_browser_impl.h ('k') | headless/lib/browser/headless_web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698