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_WEB_CONTENTS_IMPL_H_ | 5 #ifndef HEADLESS_LIB_BROWSER_HEADLESS_WEB_CONTENTS_IMPL_H_ |
6 #define HEADLESS_LIB_BROWSER_HEADLESS_WEB_CONTENTS_IMPL_H_ | 6 #define HEADLESS_LIB_BROWSER_HEADLESS_WEB_CONTENTS_IMPL_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 10 matching lines...) Expand all Loading... |
21 class DevToolsAgentHost; | 21 class DevToolsAgentHost; |
22 class WebContents; | 22 class WebContents; |
23 } | 23 } |
24 | 24 |
25 namespace gfx { | 25 namespace gfx { |
26 class Size; | 26 class Size; |
27 } | 27 } |
28 | 28 |
29 namespace headless { | 29 namespace headless { |
30 class HeadlessBrowserImpl; | 30 class HeadlessBrowserImpl; |
| 31 class HeadlessTabSocketImpl; |
31 class WebContentsObserverAdapter; | 32 class WebContentsObserverAdapter; |
32 | 33 |
33 // Exported for tests. | 34 // Exported for tests. |
34 class HEADLESS_EXPORT HeadlessWebContentsImpl | 35 class HEADLESS_EXPORT HeadlessWebContentsImpl |
35 : public HeadlessWebContents, | 36 : public HeadlessWebContents, |
36 public HeadlessDevToolsTarget, | 37 public HeadlessDevToolsTarget, |
37 public content::RenderProcessHostObserver, | 38 public content::RenderProcessHostObserver, |
38 public content::WebContentsObserver { | 39 public content::WebContentsObserver { |
39 public: | 40 public: |
40 ~HeadlessWebContentsImpl() override; | 41 ~HeadlessWebContentsImpl() override; |
41 | 42 |
42 static HeadlessWebContentsImpl* From(HeadlessWebContents* web_contents); | 43 static HeadlessWebContentsImpl* From(HeadlessWebContents* web_contents); |
43 | 44 |
44 static std::unique_ptr<HeadlessWebContentsImpl> Create( | 45 static std::unique_ptr<HeadlessWebContentsImpl> Create( |
45 HeadlessWebContents::Builder* builder); | 46 HeadlessWebContents::Builder* builder); |
46 | 47 |
47 // Takes ownership of |web_contents|. | 48 // Takes ownership of |web_contents|. |
48 static std::unique_ptr<HeadlessWebContentsImpl> CreateFromWebContents( | 49 static std::unique_ptr<HeadlessWebContentsImpl> CreateFromWebContents( |
49 content::WebContents* web_contents, | 50 content::WebContents* web_contents, |
50 HeadlessBrowserContextImpl* browser_context); | 51 HeadlessBrowserContextImpl* browser_context); |
51 | 52 |
52 // HeadlessWebContents implementation: | 53 // HeadlessWebContents implementation: |
53 void AddObserver(Observer* observer) override; | 54 void AddObserver(Observer* observer) override; |
54 void RemoveObserver(Observer* observer) override; | 55 void RemoveObserver(Observer* observer) override; |
55 HeadlessDevToolsTarget* GetDevToolsTarget() override; | 56 HeadlessDevToolsTarget* GetDevToolsTarget() override; |
| 57 HeadlessTabSocket* GetHeadlessTabSocket() const override; |
56 | 58 |
57 // HeadlessDevToolsTarget implementation: | 59 // HeadlessDevToolsTarget implementation: |
58 bool AttachClient(HeadlessDevToolsClient* client) override; | 60 bool AttachClient(HeadlessDevToolsClient* client) override; |
59 void ForceAttachClient(HeadlessDevToolsClient* client) override; | 61 void ForceAttachClient(HeadlessDevToolsClient* client) override; |
60 void DetachClient(HeadlessDevToolsClient* client) override; | 62 void DetachClient(HeadlessDevToolsClient* client) override; |
61 bool IsAttached() override; | 63 bool IsAttached() override; |
62 | 64 |
63 // RenderProcessHostObserver implementation: | 65 // RenderProcessHostObserver implementation: |
64 void RenderProcessExited(content::RenderProcessHost* host, | 66 void RenderProcessExited(content::RenderProcessHost* host, |
65 base::TerminationStatus status, | 67 base::TerminationStatus status, |
(...skipping 19 matching lines...) Expand all Loading... |
85 HeadlessWindowTreeHost* window_tree_host() const { | 87 HeadlessWindowTreeHost* window_tree_host() const { |
86 return window_tree_host_.get(); | 88 return window_tree_host_.get(); |
87 } | 89 } |
88 | 90 |
89 private: | 91 private: |
90 // Takes ownership of |web_contents|. | 92 // Takes ownership of |web_contents|. |
91 HeadlessWebContentsImpl(content::WebContents* web_contents, | 93 HeadlessWebContentsImpl(content::WebContents* web_contents, |
92 HeadlessBrowserContextImpl* browser_context); | 94 HeadlessBrowserContextImpl* browser_context); |
93 | 95 |
94 void InitializeScreen(const gfx::Size& initial_size); | 96 void InitializeScreen(const gfx::Size& initial_size); |
95 | |
96 using MojoService = HeadlessWebContents::Builder::MojoService; | 97 using MojoService = HeadlessWebContents::Builder::MojoService; |
97 | 98 |
98 class Delegate; | 99 class Delegate; |
99 std::unique_ptr<Delegate> web_contents_delegate_; | 100 std::unique_ptr<Delegate> web_contents_delegate_; |
100 std::unique_ptr<HeadlessWindowTreeHost> window_tree_host_; | 101 std::unique_ptr<HeadlessWindowTreeHost> window_tree_host_; |
101 std::unique_ptr<content::WebContents> web_contents_; | 102 std::unique_ptr<content::WebContents> web_contents_; |
102 scoped_refptr<content::DevToolsAgentHost> agent_host_; | 103 scoped_refptr<content::DevToolsAgentHost> agent_host_; |
103 std::list<MojoService> mojo_services_; | 104 std::list<MojoService> mojo_services_; |
| 105 std::unique_ptr<HeadlessTabSocketImpl> headless_tab_socket_; |
104 | 106 |
105 HeadlessBrowserContextImpl* browser_context_; // Not owned. | 107 HeadlessBrowserContextImpl* browser_context_; // Not owned. |
106 content::RenderProcessHost* render_process_host_; // Not owned. | 108 content::RenderProcessHost* render_process_host_; // Not owned. |
107 | 109 |
108 using ObserverMap = | 110 using ObserverMap = |
109 std::unordered_map<HeadlessWebContents::Observer*, | 111 std::unordered_map<HeadlessWebContents::Observer*, |
110 std::unique_ptr<WebContentsObserverAdapter>>; | 112 std::unique_ptr<WebContentsObserverAdapter>>; |
111 ObserverMap observer_map_; | 113 ObserverMap observer_map_; |
112 | 114 |
113 DISALLOW_COPY_AND_ASSIGN(HeadlessWebContentsImpl); | 115 DISALLOW_COPY_AND_ASSIGN(HeadlessWebContentsImpl); |
114 }; | 116 }; |
115 | 117 |
116 } // namespace headless | 118 } // namespace headless |
117 | 119 |
118 #endif // HEADLESS_LIB_BROWSER_HEADLESS_WEB_CONTENTS_IMPL_H_ | 120 #endif // HEADLESS_LIB_BROWSER_HEADLESS_WEB_CONTENTS_IMPL_H_ |
OLD | NEW |