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