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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "headless/lib/browser/headless_browser_impl.h" 5 #include "headless/lib/browser/headless_browser_impl.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/thread_task_runner_handle.h" 8 #include "base/thread_task_runner_handle.h"
9 #include "content/public/app/content_main.h" 9 #include "content/public/app/content_main.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 13 matching lines...) Expand all
24 const HeadlessBrowser::Options& options) 24 const HeadlessBrowser::Options& options)
25 : on_start_callback_(on_start_callback), 25 : on_start_callback_(on_start_callback),
26 options_(options), 26 options_(options),
27 browser_main_parts_(nullptr) { 27 browser_main_parts_(nullptr) {
28 DCHECK(!on_start_callback_.is_null()); 28 DCHECK(!on_start_callback_.is_null());
29 } 29 }
30 30
31 HeadlessBrowserImpl::~HeadlessBrowserImpl() {} 31 HeadlessBrowserImpl::~HeadlessBrowserImpl() {}
32 32
33 std::unique_ptr<HeadlessWebContents> HeadlessBrowserImpl::CreateWebContents( 33 std::unique_ptr<HeadlessWebContents> HeadlessBrowserImpl::CreateWebContents(
34 const GURL& initial_url,
34 const gfx::Size& size) { 35 const gfx::Size& size) {
35 DCHECK(BrowserMainThread()->BelongsToCurrentThread()); 36 DCHECK(BrowserMainThread()->BelongsToCurrentThread());
36 return base::WrapUnique(new HeadlessWebContentsImpl( 37 std::unique_ptr<HeadlessWebContentsImpl> web_contents =
37 browser_context(), window_tree_host_->window(), size)); 38 base::WrapUnique(new HeadlessWebContentsImpl(
39 browser_context(), window_tree_host_->window(), size));
40 // We require the user to pass in an initial URL to ensure that the renderer
41 // gets initialized and eventually becomes ready to be inspected. See
42 // HeadlessWebContents::Observer::WebContentsReady.
43 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
44 return nullptr;
45 return std::move(web_contents);
38 } 46 }
39 47
40 scoped_refptr<base::SingleThreadTaskRunner> 48 scoped_refptr<base::SingleThreadTaskRunner>
41 HeadlessBrowserImpl::BrowserMainThread() const { 49 HeadlessBrowserImpl::BrowserMainThread() const {
42 return content::BrowserThread::GetMessageLoopProxyForThread( 50 return content::BrowserThread::GetMessageLoopProxyForThread(
43 content::BrowserThread::UI); 51 content::BrowserThread::UI);
44 } 52 }
45 53
46 void HeadlessBrowserImpl::Shutdown() { 54 void HeadlessBrowserImpl::Shutdown() {
47 DCHECK(BrowserMainThread()->BelongsToCurrentThread()); 55 DCHECK(BrowserMainThread()->BelongsToCurrentThread());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 DCHECK(!options.message_pump); 99 DCHECK(!options.message_pump);
92 100
93 headless::HeadlessContentMainDelegate delegate(std::move(browser)); 101 headless::HeadlessContentMainDelegate delegate(std::move(browser));
94 content::ContentMainParams params(&delegate); 102 content::ContentMainParams params(&delegate);
95 params.argc = options.argc; 103 params.argc = options.argc;
96 params.argv = options.argv; 104 params.argv = options.argv;
97 return content::ContentMain(params); 105 return content::ContentMain(params);
98 } 106 }
99 107
100 } // namespace headless 108 } // namespace headless
OLDNEW
« 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