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