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