OLD | NEW |
---|---|
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 #ifndef HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ | 5 #ifndef HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ |
6 #define HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ | 6 #define HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... | |
29 | 29 |
30 // This class represents the global headless browser instance. To get a pointer | 30 // This class represents the global headless browser instance. To get a pointer |
31 // to one, call |HeadlessBrowserMain| to initiate the browser main loop. An | 31 // to one, call |HeadlessBrowserMain| to initiate the browser main loop. An |
32 // instance of |HeadlessBrowser| will be passed to the callback given to that | 32 // instance of |HeadlessBrowser| will be passed to the callback given to that |
33 // function. | 33 // function. |
34 class HEADLESS_EXPORT HeadlessBrowser { | 34 class HEADLESS_EXPORT HeadlessBrowser { |
35 public: | 35 public: |
36 struct Options; | 36 struct Options; |
37 | 37 |
38 // Create a new browser tab which navigates to |initial_url|. |size| is in | 38 // Create a new browser tab which navigates to |initial_url|. |size| is in |
39 // physical pixels. | 39 // physical pixels. |
Sami
2016/04/20 16:38:50
Could you mention that the browser owns the return
altimin
2016/04/20 17:35:25
Done.
| |
40 virtual std::unique_ptr<HeadlessWebContents> CreateWebContents( | 40 virtual HeadlessWebContents* CreateWebContents(const GURL& initial_url, |
41 const GURL& initial_url, | 41 const gfx::Size& size) = 0; |
42 const gfx::Size& size) = 0; | 42 |
43 virtual std::vector<HeadlessWebContents*> GetAllWebContents() = 0; | |
43 | 44 |
44 // Returns a task runner for submitting work to the browser main thread. | 45 // Returns a task runner for submitting work to the browser main thread. |
45 virtual scoped_refptr<base::SingleThreadTaskRunner> BrowserMainThread() | 46 virtual scoped_refptr<base::SingleThreadTaskRunner> BrowserMainThread() |
46 const = 0; | 47 const = 0; |
47 | 48 |
48 // Requests browser to stop as soon as possible. |Run| will return as soon as | 49 // Requests browser to stop as soon as possible. |Run| will return as soon as |
49 // browser stops. | 50 // browser stops. |
50 virtual void Shutdown() = 0; | 51 virtual void Shutdown() = 0; |
51 | 52 |
52 protected: | 53 protected: |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 // |on_browser_start_callback| callback. Note that since this function executes | 111 // |on_browser_start_callback| callback. Note that since this function executes |
111 // the main loop, it will only return after HeadlessBrowser::Shutdown() is | 112 // the main loop, it will only return after HeadlessBrowser::Shutdown() is |
112 // called, returning the exit code for the process. | 113 // called, returning the exit code for the process. |
113 int HeadlessBrowserMain( | 114 int HeadlessBrowserMain( |
114 const HeadlessBrowser::Options& options, | 115 const HeadlessBrowser::Options& options, |
115 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback); | 116 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback); |
116 | 117 |
117 } // namespace headless | 118 } // namespace headless |
118 | 119 |
119 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ | 120 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ |
OLD | NEW |