| 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 17 matching lines...) Expand all Loading... |
| 28 class HeadlessWebContents; | 28 class HeadlessWebContents; |
| 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. |size| is in physical pixels. | 38 // Create a new browser tab which navigates to |initial_url|. |size| is in |
| 39 // physical pixels. |
| 39 virtual std::unique_ptr<HeadlessWebContents> CreateWebContents( | 40 virtual std::unique_ptr<HeadlessWebContents> CreateWebContents( |
| 41 const GURL& initial_url, |
| 40 const gfx::Size& size) = 0; | 42 const gfx::Size& size) = 0; |
| 41 | 43 |
| 42 // Returns a task runner for submitting work to the browser main thread. | 44 // Returns a task runner for submitting work to the browser main thread. |
| 43 virtual scoped_refptr<base::SingleThreadTaskRunner> BrowserMainThread() | 45 virtual scoped_refptr<base::SingleThreadTaskRunner> BrowserMainThread() |
| 44 const = 0; | 46 const = 0; |
| 45 | 47 |
| 46 // Requests browser to stop as soon as possible. |Run| will return as soon as | 48 // Requests browser to stop as soon as possible. |Run| will return as soon as |
| 47 // browser stops. | 49 // browser stops. |
| 48 virtual void Shutdown() = 0; | 50 virtual void Shutdown() = 0; |
| 49 | 51 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // |on_browser_start_callback| callback. Note that since this function executes | 109 // |on_browser_start_callback| callback. Note that since this function executes |
| 108 // the main loop, it will only return after HeadlessBrowser::Shutdown() is | 110 // the main loop, it will only return after HeadlessBrowser::Shutdown() is |
| 109 // called, returning the exit code for the process. | 111 // called, returning the exit code for the process. |
| 110 int HeadlessBrowserMain( | 112 int HeadlessBrowserMain( |
| 111 const HeadlessBrowser::Options& options, | 113 const HeadlessBrowser::Options& options, |
| 112 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback); | 114 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback); |
| 113 | 115 |
| 114 } // namespace headless | 116 } // namespace headless |
| 115 | 117 |
| 116 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ | 118 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ |
| OLD | NEW |