| 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> |
| 11 #include <unordered_map> | 11 #include <unordered_map> |
| 12 | 12 |
| 13 #include "content/public/browser/render_process_host_observer.h" | 13 #include "content/public/browser/render_process_host_observer.h" |
| 14 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
| 15 #include "headless/lib/browser/headless_window_tree_host.h" | |
| 16 #include "headless/public/headless_devtools_target.h" | 15 #include "headless/public/headless_devtools_target.h" |
| 17 #include "headless/public/headless_export.h" | 16 #include "headless/public/headless_export.h" |
| 18 #include "headless/public/headless_web_contents.h" | 17 #include "headless/public/headless_web_contents.h" |
| 19 | 18 |
| 20 namespace content { | 19 namespace content { |
| 21 class DevToolsAgentHost; | 20 class DevToolsAgentHost; |
| 22 class WebContents; | 21 class WebContents; |
| 23 } | 22 } |
| 24 | 23 |
| 25 namespace gfx { | 24 namespace gfx { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 content::WebContents* web_contents() const; | 71 content::WebContents* web_contents() const; |
| 73 bool OpenURL(const GURL& url); | 72 bool OpenURL(const GURL& url); |
| 74 | 73 |
| 75 void Close() override; | 74 void Close() override; |
| 76 | 75 |
| 77 std::string GetDevToolsAgentHostId(); | 76 std::string GetDevToolsAgentHostId(); |
| 78 | 77 |
| 79 HeadlessBrowserImpl* browser() const; | 78 HeadlessBrowserImpl* browser() const; |
| 80 HeadlessBrowserContextImpl* browser_context() const; | 79 HeadlessBrowserContextImpl* browser_context() const; |
| 81 | 80 |
| 82 void set_window_tree_host(std::unique_ptr<HeadlessWindowTreeHost> host) { | |
| 83 window_tree_host_ = std::move(host); | |
| 84 } | |
| 85 HeadlessWindowTreeHost* window_tree_host() const { | |
| 86 return window_tree_host_.get(); | |
| 87 } | |
| 88 | |
| 89 private: | 81 private: |
| 90 // Takes ownership of |web_contents|. | 82 // Takes ownership of |web_contents|. |
| 91 HeadlessWebContentsImpl(content::WebContents* web_contents, | 83 HeadlessWebContentsImpl(content::WebContents* web_contents, |
| 92 HeadlessBrowserContextImpl* browser_context); | 84 HeadlessBrowserContextImpl* browser_context); |
| 93 | 85 |
| 94 void InitializeScreen(const gfx::Size& initial_size); | 86 void InitializeScreen(const gfx::Size& initial_size); |
| 95 | 87 |
| 96 using MojoService = HeadlessWebContents::Builder::MojoService; | 88 using MojoService = HeadlessWebContents::Builder::MojoService; |
| 97 | 89 |
| 98 class Delegate; | 90 class Delegate; |
| 99 std::unique_ptr<Delegate> web_contents_delegate_; | 91 std::unique_ptr<Delegate> web_contents_delegate_; |
| 100 std::unique_ptr<HeadlessWindowTreeHost> window_tree_host_; | |
| 101 std::unique_ptr<content::WebContents> web_contents_; | 92 std::unique_ptr<content::WebContents> web_contents_; |
| 102 scoped_refptr<content::DevToolsAgentHost> agent_host_; | 93 scoped_refptr<content::DevToolsAgentHost> agent_host_; |
| 103 std::list<MojoService> mojo_services_; | 94 std::list<MojoService> mojo_services_; |
| 104 | 95 |
| 105 HeadlessBrowserContextImpl* browser_context_; // Not owned. | 96 HeadlessBrowserContextImpl* browser_context_; // Not owned. |
| 106 content::RenderProcessHost* render_process_host_; // Not owned. | 97 content::RenderProcessHost* render_process_host_; // Not owned. |
| 107 | 98 |
| 108 using ObserverMap = | 99 using ObserverMap = |
| 109 std::unordered_map<HeadlessWebContents::Observer*, | 100 std::unordered_map<HeadlessWebContents::Observer*, |
| 110 std::unique_ptr<WebContentsObserverAdapter>>; | 101 std::unique_ptr<WebContentsObserverAdapter>>; |
| 111 ObserverMap observer_map_; | 102 ObserverMap observer_map_; |
| 112 | 103 |
| 113 DISALLOW_COPY_AND_ASSIGN(HeadlessWebContentsImpl); | 104 DISALLOW_COPY_AND_ASSIGN(HeadlessWebContentsImpl); |
| 114 }; | 105 }; |
| 115 | 106 |
| 116 } // namespace headless | 107 } // namespace headless |
| 117 | 108 |
| 118 #endif // HEADLESS_LIB_BROWSER_HEADLESS_WEB_CONTENTS_IMPL_H_ | 109 #endif // HEADLESS_LIB_BROWSER_HEADLESS_WEB_CONTENTS_IMPL_H_ |
| OLD | NEW |