| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 HeadlessBrowserImpl* browser() const; | 93 HeadlessBrowserImpl* browser() const; |
| 94 HeadlessBrowserContextImpl* browser_context() const; | 94 HeadlessBrowserContextImpl* browser_context() const; |
| 95 | 95 |
| 96 void set_window_tree_host(std::unique_ptr<HeadlessWindowTreeHost> host) { | 96 void set_window_tree_host(std::unique_ptr<HeadlessWindowTreeHost> host) { |
| 97 window_tree_host_ = std::move(host); | 97 window_tree_host_ = std::move(host); |
| 98 } | 98 } |
| 99 HeadlessWindowTreeHost* window_tree_host() const { | 99 HeadlessWindowTreeHost* window_tree_host() const { |
| 100 return window_tree_host_.get(); | 100 return window_tree_host_.get(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 // Returns the devtools frame id corresponding to the |frame_tree_node_id|, if |
| 104 // any. Note this relies on an IPC sent from blink during navigation. |
| 105 std::string GetUntrustedDevToolsFrameIdForFrameTreeNodeId( |
| 106 int process_id, |
| 107 int frame_tree_node_id) const; |
| 108 |
| 109 int GetMainFrameRenderProcessId() const; |
| 110 |
| 103 private: | 111 private: |
| 104 // Takes ownership of |web_contents|. | 112 // Takes ownership of |web_contents|. |
| 105 HeadlessWebContentsImpl(content::WebContents* web_contents, | 113 HeadlessWebContentsImpl(content::WebContents* web_contents, |
| 106 HeadlessBrowserContextImpl* browser_context); | 114 HeadlessBrowserContextImpl* browser_context); |
| 107 | 115 |
| 108 void InitializeScreen(const gfx::Size& initial_size); | 116 void InitializeScreen(const gfx::Size& initial_size); |
| 109 using MojoService = HeadlessWebContents::Builder::MojoService; | 117 using MojoService = HeadlessWebContents::Builder::MojoService; |
| 110 | 118 |
| 111 std::unordered_map<content::RenderFrameHost*, std::string> | 119 std::unordered_map<content::RenderFrameHost*, std::string> |
| 112 render_frame_host_to_devtools_agent_host_id_; | 120 render_frame_host_to_devtools_agent_host_id_; |
| 113 std::unordered_map<std::string, int> devtools_agent_id_to_frame_tree_node_id_; | 121 std::unordered_map<std::string, int> devtools_agent_id_to_frame_tree_node_id_; |
| 114 | 122 |
| 115 class Delegate; | 123 class Delegate; |
| 116 std::unique_ptr<Delegate> web_contents_delegate_; | 124 std::unique_ptr<Delegate> web_contents_delegate_; |
| 117 std::unique_ptr<HeadlessWindowTreeHost> window_tree_host_; | 125 std::unique_ptr<HeadlessWindowTreeHost> window_tree_host_; |
| 118 std::unique_ptr<content::WebContents> web_contents_; | 126 std::unique_ptr<content::WebContents> web_contents_; |
| 119 scoped_refptr<content::DevToolsAgentHost> agent_host_; | 127 scoped_refptr<content::DevToolsAgentHost> agent_host_; |
| 120 std::list<MojoService> mojo_services_; | 128 std::list<MojoService> mojo_services_; |
| 121 std::unique_ptr<HeadlessTabSocketImpl> headless_tab_socket_; | 129 std::unique_ptr<HeadlessTabSocketImpl> headless_tab_socket_; |
| 122 | 130 |
| 123 HeadlessBrowserContextImpl* browser_context_; // Not owned. | 131 HeadlessBrowserContextImpl* browser_context_; // Not owned. |
| 132 // TODO(alexclarke): With OOPIF there may be more than one renderer, we need |
| 133 // to fix this. See crbug.com/715924 |
| 124 content::RenderProcessHost* render_process_host_; // Not owned. | 134 content::RenderProcessHost* render_process_host_; // Not owned. |
| 125 | 135 |
| 126 using ObserverMap = | 136 using ObserverMap = |
| 127 std::unordered_map<HeadlessWebContents::Observer*, | 137 std::unordered_map<HeadlessWebContents::Observer*, |
| 128 std::unique_ptr<WebContentsObserverAdapter>>; | 138 std::unique_ptr<WebContentsObserverAdapter>>; |
| 129 ObserverMap observer_map_; | 139 ObserverMap observer_map_; |
| 130 | 140 |
| 131 DISALLOW_COPY_AND_ASSIGN(HeadlessWebContentsImpl); | 141 DISALLOW_COPY_AND_ASSIGN(HeadlessWebContentsImpl); |
| 132 }; | 142 }; |
| 133 | 143 |
| 134 } // namespace headless | 144 } // namespace headless |
| 135 | 145 |
| 136 #endif // HEADLESS_LIB_BROWSER_HEADLESS_WEB_CONTENTS_IMPL_H_ | 146 #endif // HEADLESS_LIB_BROWSER_HEADLESS_WEB_CONTENTS_IMPL_H_ |
| OLD | NEW |