| 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 "content/public/browser/web_contents.h" |
| 17 #include "headless/lib/browser/headless_devtools_manager_delegate.h" | 17 #include "headless/lib/browser/headless_devtools_manager_delegate.h" |
| 18 #include "headless/lib/browser/headless_web_contents_impl.h" | 18 #include "headless/lib/browser/headless_web_contents_impl.h" |
| 19 #include "headless/public/headless_export.h" | 19 #include "headless/public/headless_export.h" |
| 20 | 20 |
| 21 #if defined(USE_AURA) | |
| 22 #include "headless/lib/browser/headless_window_tree_host.h" | |
| 23 | |
| 24 namespace aura { | |
| 25 namespace client { | |
| 26 class FocusClient; | |
| 27 } | |
| 28 } | |
| 29 #endif | |
| 30 | |
| 31 namespace headless { | 21 namespace headless { |
| 32 | 22 |
| 33 class HeadlessBrowserContextImpl; | 23 class HeadlessBrowserContextImpl; |
| 34 class HeadlessBrowserMainParts; | 24 class HeadlessBrowserMainParts; |
| 35 | 25 |
| 36 // Exported for tests. | 26 // Exported for tests. |
| 37 class HEADLESS_EXPORT HeadlessBrowserImpl : public HeadlessBrowser { | 27 class HEADLESS_EXPORT HeadlessBrowserImpl : public HeadlessBrowser { |
| 38 public: | 28 public: |
| 39 HeadlessBrowserImpl( | 29 HeadlessBrowserImpl( |
| 40 const base::Callback<void(HeadlessBrowser*)>& on_start_callback, | 30 const base::Callback<void(HeadlessBrowser*)>& on_start_callback, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 void DestroyBrowserContext(HeadlessBrowserContextImpl* browser_context); | 64 void DestroyBrowserContext(HeadlessBrowserContextImpl* browser_context); |
| 75 | 65 |
| 76 base::WeakPtr<HeadlessBrowserImpl> GetWeakPtr(); | 66 base::WeakPtr<HeadlessBrowserImpl> GetWeakPtr(); |
| 77 | 67 |
| 78 // All the methods that begin with Platform need to be implemented by the | 68 // All the methods that begin with Platform need to be implemented by the |
| 79 // platform specific headless implementation. | 69 // platform specific headless implementation. |
| 80 // Helper for one time initialization of application | 70 // Helper for one time initialization of application |
| 81 void PlatformInitialize(); | 71 void PlatformInitialize(); |
| 82 void PlatformCreateWindow(); | 72 void PlatformCreateWindow(); |
| 83 void PlatformInitializeWebContents(const gfx::Size& initial_size, | 73 void PlatformInitializeWebContents(const gfx::Size& initial_size, |
| 84 content::WebContents* web_contents); | 74 HeadlessWebContentsImpl* web_contents); |
| 85 | 75 |
| 86 protected: | 76 protected: |
| 87 #if defined(USE_AURA) | |
| 88 // TODO(eseckler): Currently one window and one window_tree_host | |
| 89 // is used for all web contents. We should probably use one | |
| 90 // window per web contents, but additional investigation is needed. | |
| 91 std::unique_ptr<HeadlessWindowTreeHost> window_tree_host_; | |
| 92 std::unique_ptr<aura::client::FocusClient> focus_client_; | |
| 93 #endif | |
| 94 | |
| 95 base::Callback<void(HeadlessBrowser*)> on_start_callback_; | 77 base::Callback<void(HeadlessBrowser*)> on_start_callback_; |
| 96 HeadlessBrowser::Options options_; | 78 HeadlessBrowser::Options options_; |
| 97 HeadlessBrowserMainParts* browser_main_parts_; // Not owned. | 79 HeadlessBrowserMainParts* browser_main_parts_; // Not owned. |
| 98 | 80 |
| 99 std::unordered_map<std::string, std::unique_ptr<HeadlessBrowserContextImpl>> | 81 std::unordered_map<std::string, std::unique_ptr<HeadlessBrowserContextImpl>> |
| 100 browser_contexts_; | 82 browser_contexts_; |
| 101 HeadlessBrowserContext* default_browser_context_; // Not owned. | 83 HeadlessBrowserContext* default_browser_context_; // Not owned. |
| 102 | 84 |
| 103 base::WeakPtrFactory<HeadlessBrowserImpl> weak_ptr_factory_; | 85 base::WeakPtrFactory<HeadlessBrowserImpl> weak_ptr_factory_; |
| 104 | 86 |
| 105 private: | 87 private: |
| 106 DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserImpl); | 88 DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserImpl); |
| 107 }; | 89 }; |
| 108 | 90 |
| 109 } // namespace headless | 91 } // namespace headless |
| 110 | 92 |
| 111 #endif // HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_IMPL_H_ | 93 #endif // HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_IMPL_H_ |
| OLD | NEW |