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

Side by Side Diff: headless/public/headless_browser.h

Issue 1430673002: Headless demo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Better javascript Created 5 years 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
« no previous file with comments | « headless/lib/web_node.cc ('k') | headless/public/headless_browser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef HEADLESS_PUBLIC_HEADLESS_BROWSER_H_
6 #define HEADLESS_PUBLIC_HEADLESS_BROWSER_H_
7
8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "headless/public/headless_export.h"
12
13 namespace base {
14 class SingleThreadTaskRunner;
15
16 namespace trace_event {
17 class TraceConfig;
18 }
19 }
20
21 namespace gfx {
22 class Size;
23 }
24
25 namespace net {
26 class URLRequestContextGetter;
27 }
28
29 namespace headless {
30 class WebContents;
31
32 class HEADLESS_EXPORT HeadlessBrowser {
33 public:
34 static HeadlessBrowser* Get();
35
36 struct Options;
37
38 // Create a new browser tab.
39 virtual scoped_ptr<WebContents> CreateWebContents(const gfx::Size& size) = 0;
40
41 virtual scoped_refptr<base::SingleThreadTaskRunner> browser_main_thread() = 0;
42 virtual scoped_refptr<base::SingleThreadTaskRunner>
43 renderer_main_thread() = 0;
44
45 // Main routine for running browser.
46 // Takes command line args and callback to run as soon as browser starts.
47 // Should be called from main in the following manner:
48 // int main(int argc, const char** argv) {
49 // return headless::HeadlessBrowser::Get()->Run(
50 // argc, argv, base::Bind(function_to_be_run_on_browser_start));
51 // }
52 virtual int Run(const Options& options,
53 const base::Closure& on_browser_start_callback) = 0;
54
55 // Requests browser to stop as soon as possible.
56 virtual void Stop() = 0;
57
58 virtual void StartTracing(
59 const base::trace_event::TraceConfig& trace_config,
60 const base::Closure& tracing_started) = 0;
61 virtual void StopTracing(
62 const std::string& log_file_name,
63 const base::Closure& tracing_stopped) = 0;
64
65 protected:
66 virtual ~HeadlessBrowser() {}
67 };
68
69 struct HeadlessBrowser::Options {
70 Options(Options&&);
71 ~Options();
72
73 class Builder;
74
75 // Command line options to be passed to browser.
76 int argc;
77 const char** argv;
78
79 scoped_ptr<std::string> user_agent;
80
81 // If not null, create start devtools for remote debugging
82 // on specified port.
83 scoped_ptr<int> devtools_http_port;
84
85 // Using URLRequestContextGetter we can provide our own implementation of
86 // entire network stack.
87 // If null, default Chromium network settings will be used.
88 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter;
89
90 private:
91 Options(int argc, const char** argv);
92 };
93
94 class HeadlessBrowser::Options::Builder {
95 public:
96 Builder(int argc, const char** argv);
97 ~Builder();
98
99 Builder& SetUserAgent(const std::string& user_agent);
100 Builder& EnableDevtoolsServer(int port);
101 Builder& SetURLRequestContextGetter(
102 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter);
103
104 Options Build();
105
106 private:
107 Options options_;
108 };
109
110
111 } // namespace headless
112
113 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_H_
OLDNEW
« no previous file with comments | « headless/lib/web_node.cc ('k') | headless/public/headless_browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698