| 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_LIB_BROWSER_HEADLESS_BROWSER_IMPL_H_ | 5 #ifndef HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_IMPL_H_ |
| 6 #define HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_IMPL_H_ | 6 #define HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_IMPL_H_ |
| 7 | 7 |
| 8 #include "headless/public/headless_browser.h" | 8 #include "headless/public/headless_browser.h" |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 namespace headless { | 24 namespace headless { |
| 25 | 25 |
| 26 class HeadlessBrowserContext; | 26 class HeadlessBrowserContext; |
| 27 class HeadlessBrowserMainParts; | 27 class HeadlessBrowserMainParts; |
| 28 | 28 |
| 29 class HeadlessBrowserImpl : public HeadlessBrowser { | 29 class HeadlessBrowserImpl : public HeadlessBrowser { |
| 30 public: | 30 public: |
| 31 HeadlessBrowserImpl( | 31 HeadlessBrowserImpl( |
| 32 const base::Callback<void(HeadlessBrowser*)>& on_start_callback, | 32 const base::Callback<void(HeadlessBrowser*)>& on_start_callback, |
| 33 const HeadlessBrowser::Options& options); | 33 HeadlessBrowser::Options options); |
| 34 ~HeadlessBrowserImpl() override; | 34 ~HeadlessBrowserImpl() override; |
| 35 | 35 |
| 36 // HeadlessBrowser implementation: | 36 // HeadlessBrowser implementation: |
| 37 HeadlessWebContents* CreateWebContents(const GURL& initial_url, | 37 HeadlessWebContents* CreateWebContents(const GURL& initial_url, |
| 38 const gfx::Size& size) override; | 38 const gfx::Size& size) override; |
| 39 scoped_refptr<base::SingleThreadTaskRunner> BrowserMainThread() | 39 scoped_refptr<base::SingleThreadTaskRunner> BrowserMainThread() |
| 40 const override; | 40 const override; |
| 41 | 41 |
| 42 void Shutdown() override; | 42 void Shutdown() override; |
| 43 | 43 |
| 44 std::vector<HeadlessWebContents*> GetAllWebContents() override; | 44 std::vector<HeadlessWebContents*> GetAllWebContents() override; |
| 45 | 45 |
| 46 void set_browser_main_parts(HeadlessBrowserMainParts* browser_main_parts); | 46 void set_browser_main_parts(HeadlessBrowserMainParts* browser_main_parts); |
| 47 HeadlessBrowserMainParts* browser_main_parts() const; | 47 HeadlessBrowserMainParts* browser_main_parts() const; |
| 48 | 48 |
| 49 HeadlessBrowserContext* browser_context() const; | 49 HeadlessBrowserContext* browser_context() const; |
| 50 | 50 |
| 51 void RunOnStartCallback(); | 51 void RunOnStartCallback(); |
| 52 | 52 |
| 53 const HeadlessBrowser::Options& options() const { return options_; } | 53 HeadlessBrowser::Options* options() { return &options_; } |
| 54 | 54 |
| 55 HeadlessWebContentsImpl* RegisterWebContents( | 55 HeadlessWebContentsImpl* RegisterWebContents( |
| 56 std::unique_ptr<HeadlessWebContentsImpl> web_contents); | 56 std::unique_ptr<HeadlessWebContentsImpl> web_contents); |
| 57 | 57 |
| 58 // Close given |web_contents| and delete it. | 58 // Close given |web_contents| and delete it. |
| 59 void DestroyWebContents(HeadlessWebContentsImpl* web_contents); | 59 void DestroyWebContents(HeadlessWebContentsImpl* web_contents); |
| 60 | 60 |
| 61 // Customize the options used by this headless browser instance. Note that | 61 // Customize the options used by this headless browser instance. Note that |
| 62 // options which take effect before the message loop has been started (e.g., | 62 // options which take effect before the message loop has been started (e.g., |
| 63 // custom message pumps) cannot be set via this method. | 63 // custom message pumps) cannot be set via this method. |
| 64 void SetOptionsForTesting(const HeadlessBrowser::Options& options); | 64 void SetOptionsForTesting(HeadlessBrowser::Options options); |
| 65 | 65 |
| 66 protected: | 66 protected: |
| 67 base::Callback<void(HeadlessBrowser*)> on_start_callback_; | 67 base::Callback<void(HeadlessBrowser*)> on_start_callback_; |
| 68 HeadlessBrowser::Options options_; | 68 HeadlessBrowser::Options options_; |
| 69 HeadlessBrowserMainParts* browser_main_parts_; // Not owned. | 69 HeadlessBrowserMainParts* browser_main_parts_; // Not owned. |
| 70 std::unique_ptr<aura::WindowTreeHost> window_tree_host_; | 70 std::unique_ptr<aura::WindowTreeHost> window_tree_host_; |
| 71 std::unique_ptr<aura::client::WindowTreeClient> window_tree_client_; | 71 std::unique_ptr<aura::client::WindowTreeClient> window_tree_client_; |
| 72 | 72 |
| 73 std::unordered_map<HeadlessWebContents*, std::unique_ptr<HeadlessWebContents>> | 73 std::unordered_map<HeadlessWebContents*, std::unique_ptr<HeadlessWebContents>> |
| 74 web_contents_; | 74 web_contents_; |
| 75 | 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserImpl); | 76 DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserImpl); |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 } // namespace headless | 79 } // namespace headless |
| 80 | 80 |
| 81 #endif // HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_IMPL_H_ | 81 #endif // HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_IMPL_H_ |
| OLD | NEW |