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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // won't return a valid value until Observer::DevToolsTargetReady has been | 76 // won't return a valid value until Observer::DevToolsTargetReady has been |
77 // signaled. | 77 // signaled. |
78 virtual HeadlessDevToolsTarget* GetDevToolsTarget() = 0; | 78 virtual HeadlessDevToolsTarget* GetDevToolsTarget() = 0; |
79 | 79 |
80 // Close this page. |HeadlessWebContents| object will be destroyed. | 80 // Close this page. |HeadlessWebContents| object will be destroyed. |
81 virtual void Close() = 0; | 81 virtual void Close() = 0; |
82 | 82 |
83 // Returns the headless tab socket for JS -> C++ if one was created. | 83 // Returns the headless tab socket for JS -> C++ if one was created. |
84 virtual HeadlessTabSocket* GetHeadlessTabSocket() const = 0; | 84 virtual HeadlessTabSocket* GetHeadlessTabSocket() const = 0; |
85 | 85 |
86 // Returns the FrameTreeNode Id associated with the |devtools_agent_host_id| | |
87 // if any. | |
88 // TODO(alexclarke): Remove this, it doesn't work as expected. | |
89 virtual bool GetFrameTreeNodeIdForDevToolsAgentHostId( | |
90 const std::string& devtools_agent_host_id, | |
91 int* frame_tree_node_id) const = 0; | |
92 | |
93 private: | 86 private: |
94 friend class HeadlessWebContentsImpl; | 87 friend class HeadlessWebContentsImpl; |
95 HeadlessWebContents() {} | 88 HeadlessWebContents() {} |
96 | 89 |
97 DISALLOW_COPY_AND_ASSIGN(HeadlessWebContents); | 90 DISALLOW_COPY_AND_ASSIGN(HeadlessWebContents); |
98 }; | 91 }; |
99 | 92 |
100 class HEADLESS_EXPORT HeadlessWebContents::Builder { | 93 class HEADLESS_EXPORT HeadlessWebContents::Builder { |
101 public: | 94 public: |
102 ~Builder(); | 95 ~Builder(); |
103 Builder(Builder&&); | 96 Builder(Builder&&); |
104 | 97 |
105 // Set an initial URL to ensure that the renderer gets initialized and | 98 // Set an initial URL to ensure that the renderer gets initialized and |
106 // eventually becomes ready to be inspected. See | 99 // eventually becomes ready to be inspected. See |
107 // HeadlessWebContents::Observer::DevToolsTargetReady. The default URL is | 100 // HeadlessWebContents::Observer::DevToolsTargetReady. The default URL is |
108 // about:blank. | 101 // about:blank. |
109 Builder& SetInitialURL(const GURL& initial_url); | 102 Builder& SetInitialURL(const GURL& initial_url); |
110 | 103 |
111 // Specify the initial window size (default is configured in browser options). | 104 // Specify the initial window size (default is configured in browser options). |
112 Builder& SetWindowSize(const gfx::Size& size); | 105 Builder& SetWindowSize(const gfx::Size& size); |
113 | 106 |
114 // DEPRECATED. Specify an embedder provided Mojo service to be installed. The | |
115 // |service_factory| callback is called on demand by Mojo to instantiate the | |
116 // service if a client asks for it. | |
117 // TODO(alexclarke): Remove AddMojoService. | |
118 template <typename Interface> | |
119 Builder& AddMojoService( | |
120 const base::Callback<void(mojo::InterfaceRequest<Interface>)>& | |
121 service_factory) { | |
122 return AddMojoService( | |
123 Interface::Name_, | |
124 base::Bind(&Builder::ForwardToServiceFactory<Interface>, | |
125 service_factory)); | |
126 } | |
127 Builder& AddMojoService(const std::string& service_name, | |
128 const base::Callback<void( | |
129 mojo::ScopedMessagePipeHandle)>& service_factory); | |
130 | |
131 // Whether or not a headless tab socket should be created, to allow JS -> C++ | 107 // Whether or not a headless tab socket should be created, to allow JS -> C++ |
132 // embedder communications. | 108 // embedder communications. |
133 Builder& CreateTabSocket(bool create_tab_socket); | 109 Builder& CreateTabSocket(bool create_tab_socket); |
134 | 110 |
135 // The returned object is owned by HeadlessBrowser. Call | 111 // The returned object is owned by HeadlessBrowser. Call |
136 // HeadlessWebContents::Close() to dispose it. | 112 // HeadlessWebContents::Close() to dispose it. |
137 HeadlessWebContents* Build(); | 113 HeadlessWebContents* Build(); |
138 | 114 |
139 private: | 115 private: |
140 friend class HeadlessBrowserImpl; | 116 friend class HeadlessBrowserImpl; |
(...skipping 30 matching lines...) Expand all Loading... |
171 gfx::Size window_size_; | 147 gfx::Size window_size_; |
172 std::list<MojoService> mojo_services_; | 148 std::list<MojoService> mojo_services_; |
173 bool create_tab_socket_ = false; | 149 bool create_tab_socket_ = false; |
174 | 150 |
175 DISALLOW_COPY_AND_ASSIGN(Builder); | 151 DISALLOW_COPY_AND_ASSIGN(Builder); |
176 }; | 152 }; |
177 | 153 |
178 } // namespace headless | 154 } // namespace headless |
179 | 155 |
180 #endif // HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_ | 156 #endif // HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_ |
OLD | NEW |