Chromium Code Reviews| 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> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <unordered_map> | 12 #include <unordered_map> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "content/public/browser/web_contents.h" | |
| 16 #include "headless/lib/browser/headless_devtools_manager_delegate.h" | 17 #include "headless/lib/browser/headless_devtools_manager_delegate.h" |
| 17 #include "headless/lib/browser/headless_web_contents_impl.h" | 18 #include "headless/lib/browser/headless_web_contents_impl.h" |
| 18 | 19 |
| 19 namespace aura { | 20 #if defined(USE_AURA) |
| 20 class WindowTreeHost; | 21 #include "headless/lib/browser/headless_window_tree_host.h" |
| 21 | 22 #endif |
| 22 namespace client { | |
| 23 class WindowParentingClient; | |
| 24 } | |
| 25 } | |
| 26 | 23 |
| 27 namespace headless { | 24 namespace headless { |
| 28 | 25 |
| 29 class HeadlessBrowserContextImpl; | 26 class HeadlessBrowserContextImpl; |
| 30 class HeadlessBrowserMainParts; | 27 class HeadlessBrowserMainParts; |
| 31 | 28 |
| 32 class HeadlessBrowserImpl : public HeadlessBrowser { | 29 class HeadlessBrowserImpl : public HeadlessBrowser { |
| 33 public: | 30 public: |
| 34 HeadlessBrowserImpl( | 31 HeadlessBrowserImpl( |
| 35 const base::Callback<void(HeadlessBrowser*)>& on_start_callback, | 32 const base::Callback<void(HeadlessBrowser*)>& on_start_callback, |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 63 HeadlessBrowser::Options* options() { return &options_; } | 60 HeadlessBrowser::Options* options() { return &options_; } |
| 64 | 61 |
| 65 HeadlessBrowserContext* CreateBrowserContext( | 62 HeadlessBrowserContext* CreateBrowserContext( |
| 66 HeadlessBrowserContext::Builder* builder); | 63 HeadlessBrowserContext::Builder* builder); |
| 67 // Close given |browser_context| and delete it | 64 // Close given |browser_context| and delete it |
| 68 // (all web contents associated with it go away too). | 65 // (all web contents associated with it go away too). |
| 69 void DestroyBrowserContext(HeadlessBrowserContextImpl* browser_context); | 66 void DestroyBrowserContext(HeadlessBrowserContextImpl* browser_context); |
| 70 | 67 |
| 71 base::WeakPtr<HeadlessBrowserImpl> GetWeakPtr(); | 68 base::WeakPtr<HeadlessBrowserImpl> GetWeakPtr(); |
| 72 | 69 |
| 73 aura::WindowTreeHost* window_tree_host() const; | 70 // All the methods that begin with Platform need to be implemented by the |
| 71 // platform specific headless implementation. | |
| 72 // Helper for one time initialization of application | |
| 73 void PlatformInitialize(); | |
| 74 void PlatformCreateWindow(); | |
| 75 void PlatformSetWebContents(const gfx::Size& initial_size, | |
|
Sami
2017/02/10 13:53:11
Sorry for not noticing earlier, but something like
| |
| 76 content::WebContents* web_contents); | |
| 74 | 77 |
| 75 protected: | 78 protected: |
| 79 #if defined(USE_AURA) | |
| 80 // TODO(eseckler): Currently one window and one window_tree_host | |
| 81 // is used for all web contents. We should probably use one | |
| 82 // window per web contents, but additional investigation is needed. | |
| 83 std::unique_ptr<HeadlessWindowTreeHost> window_tree_host_; | |
| 84 #endif | |
| 76 base::Callback<void(HeadlessBrowser*)> on_start_callback_; | 85 base::Callback<void(HeadlessBrowser*)> on_start_callback_; |
| 77 HeadlessBrowser::Options options_; | 86 HeadlessBrowser::Options options_; |
| 78 HeadlessBrowserMainParts* browser_main_parts_; // Not owned. | 87 HeadlessBrowserMainParts* browser_main_parts_; // Not owned. |
| 79 | 88 |
| 80 // TODO(eseckler): Currently one window and one window_tree_host | |
| 81 // is used for all web contents. We should probably use one | |
| 82 // window per web contents, but additional investigation is needed. | |
| 83 std::unique_ptr<aura::WindowTreeHost> window_tree_host_; | |
| 84 std::unique_ptr<aura::client::WindowParentingClient> window_parenting_client_; | |
| 85 | |
| 86 std::unordered_map<std::string, std::unique_ptr<HeadlessBrowserContextImpl>> | 89 std::unordered_map<std::string, std::unique_ptr<HeadlessBrowserContextImpl>> |
| 87 browser_contexts_; | 90 browser_contexts_; |
| 88 HeadlessBrowserContext* default_browser_context_; // Not owned. | 91 HeadlessBrowserContext* default_browser_context_; // Not owned. |
| 89 | 92 |
| 90 base::WeakPtrFactory<HeadlessBrowserImpl> weak_ptr_factory_; | 93 base::WeakPtrFactory<HeadlessBrowserImpl> weak_ptr_factory_; |
| 91 | 94 |
| 92 private: | 95 private: |
| 93 DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserImpl); | 96 DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserImpl); |
| 94 }; | 97 }; |
| 95 | 98 |
| 96 } // namespace headless | 99 } // namespace headless |
| 97 | 100 |
| 98 #endif // HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_IMPL_H_ | 101 #endif // HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_IMPL_H_ |
| OLD | NEW |