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 19 matching lines...) Expand all Loading... |
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. |
40 virtual std::unique_ptr<HeadlessWebContents> CreateWebContents( | 40 // We require the user to pass an initial URL to ensure that the renderer |
41 const GURL& initial_url, | 41 // gets initialized and eventually becomes ready to be inspected. See |
42 const gfx::Size& size) = 0; | 42 // HeadlessWebContents::Observer::DevToolsTargetReady. |
| 43 virtual HeadlessWebContents* CreateWebContents(const GURL& initial_url, |
| 44 const gfx::Size& size) = 0; |
| 45 |
| 46 virtual std::vector<HeadlessWebContents*> GetAllWebContents() = 0; |
43 | 47 |
44 // Returns a task runner for submitting work to the browser main thread. | 48 // Returns a task runner for submitting work to the browser main thread. |
45 virtual scoped_refptr<base::SingleThreadTaskRunner> BrowserMainThread() | 49 virtual scoped_refptr<base::SingleThreadTaskRunner> BrowserMainThread() |
46 const = 0; | 50 const = 0; |
47 | 51 |
48 // Requests browser to stop as soon as possible. |Run| will return as soon as | 52 // Requests browser to stop as soon as possible. |Run| will return as soon as |
49 // browser stops. | 53 // browser stops. |
50 virtual void Shutdown() = 0; | 54 virtual void Shutdown() = 0; |
51 | 55 |
52 protected: | 56 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 | 114 // |on_browser_start_callback| callback. Note that since this function executes |
111 // the main loop, it will only return after HeadlessBrowser::Shutdown() is | 115 // the main loop, it will only return after HeadlessBrowser::Shutdown() is |
112 // called, returning the exit code for the process. | 116 // called, returning the exit code for the process. |
113 int HeadlessBrowserMain( | 117 int HeadlessBrowserMain( |
114 const HeadlessBrowser::Options& options, | 118 const HeadlessBrowser::Options& options, |
115 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback); | 119 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback); |
116 | 120 |
117 } // namespace headless | 121 } // namespace headless |
118 | 122 |
119 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ | 123 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ |
OLD | NEW |