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_PUBLIC_HEADLESS_WEB_CONTENTS_H_ | 5 #ifndef HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_ |
6 #define HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_ | 6 #define HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 // Set an initial URL to ensure that the renderer gets initialized and | 106 // Set an initial URL to ensure that the renderer gets initialized and |
107 // eventually becomes ready to be inspected. See | 107 // eventually becomes ready to be inspected. See |
108 // HeadlessWebContents::Observer::DevToolsTargetReady. The default URL is | 108 // HeadlessWebContents::Observer::DevToolsTargetReady. The default URL is |
109 // about:blank. | 109 // about:blank. |
110 Builder& SetInitialURL(const GURL& initial_url); | 110 Builder& SetInitialURL(const GURL& initial_url); |
111 | 111 |
112 // Specify the initial window size (default is configured in browser options). | 112 // Specify the initial window size (default is configured in browser options). |
113 Builder& SetWindowSize(const gfx::Size& size); | 113 Builder& SetWindowSize(const gfx::Size& size); |
114 | 114 |
115 enum class TabSocketType { | 115 // Whether or not a headless tab socket should be created, to allow JS -> C++ |
116 NONE, // No TabSocket binds created (default). | 116 // embedder communications. |
117 MAIN_WORLD, // TabSocket bindings available only to the main world. | 117 Builder& CreateTabSocket(bool create_tab_socket); |
118 ISOLATED_WORLD // TabSocket bindings available only to isolated worlds | |
119 // created via DevTools protocol. | |
120 }; | |
121 | |
122 // Sets the type of TabSocket to be created, if any. | |
123 Builder& SetTabSocketType(TabSocketType type); | |
124 | 118 |
125 // The returned object is owned by HeadlessBrowser. Call | 119 // The returned object is owned by HeadlessBrowser. Call |
126 // HeadlessWebContents::Close() to dispose it. | 120 // HeadlessWebContents::Close() to dispose it. |
127 HeadlessWebContents* Build(); | 121 HeadlessWebContents* Build(); |
128 | 122 |
129 private: | 123 private: |
130 friend class HeadlessBrowserImpl; | 124 friend class HeadlessBrowserImpl; |
131 friend class HeadlessBrowserContextImpl; | 125 friend class HeadlessBrowserContextImpl; |
132 friend class HeadlessWebContentsImpl; | 126 friend class HeadlessWebContentsImpl; |
133 | 127 |
(...skipping 19 matching lines...) Expand all Loading... |
153 | 147 |
154 private: | 148 private: |
155 DISALLOW_COPY_AND_ASSIGN(MojoService); | 149 DISALLOW_COPY_AND_ASSIGN(MojoService); |
156 }; | 150 }; |
157 | 151 |
158 HeadlessBrowserContextImpl* browser_context_; | 152 HeadlessBrowserContextImpl* browser_context_; |
159 | 153 |
160 GURL initial_url_ = GURL("about:blank"); | 154 GURL initial_url_ = GURL("about:blank"); |
161 gfx::Size window_size_; | 155 gfx::Size window_size_; |
162 std::list<MojoService> mojo_services_; | 156 std::list<MojoService> mojo_services_; |
163 TabSocketType tab_socket_type_ = TabSocketType::NONE; | 157 bool create_tab_socket_ = false; |
164 | 158 |
165 DISALLOW_COPY_AND_ASSIGN(Builder); | 159 DISALLOW_COPY_AND_ASSIGN(Builder); |
166 }; | 160 }; |
167 | 161 |
168 } // namespace headless | 162 } // namespace headless |
169 | 163 |
170 #endif // HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_ | 164 #endif // HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_ |
OLD | NEW |