OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_ | 5 #ifndef CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_ |
6 #define CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_ | 6 #define CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
15 #include "content/public/common/console_message_level.h" | 15 #include "content/public/common/console_message_level.h" |
16 #include "content/public/renderer/render_thread.h" | |
16 #include "ipc/ipc_listener.h" | 17 #include "ipc/ipc_listener.h" |
17 #include "ipc/ipc_sender.h" | 18 #include "ipc/ipc_sender.h" |
19 #include "ipc/ipc_sync_channel.h" | |
20 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" | |
21 #include "mojo/public/cpp/bindings/associated_interface_request.h" | |
18 #include "third_party/WebKit/public/platform/WebPageVisibilityState.h" | 22 #include "third_party/WebKit/public/platform/WebPageVisibilityState.h" |
19 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" | 23 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" |
20 | 24 |
21 class GURL; | 25 class GURL; |
22 | 26 |
23 namespace blink { | 27 namespace blink { |
24 class WebFrame; | 28 class WebFrame; |
25 class WebLocalFrame; | 29 class WebLocalFrame; |
26 class WebPlugin; | 30 class WebPlugin; |
27 class WebURLRequest; | 31 class WebURLRequest; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
148 virtual bool IsHidden() = 0; | 152 virtual bool IsHidden() = 0; |
149 | 153 |
150 // Returns the InterfaceRegistry that this process uses to expose interfaces | 154 // Returns the InterfaceRegistry that this process uses to expose interfaces |
151 // to the application running in this frame. | 155 // to the application running in this frame. |
152 virtual shell::InterfaceRegistry* GetInterfaceRegistry() = 0; | 156 virtual shell::InterfaceRegistry* GetInterfaceRegistry() = 0; |
153 | 157 |
154 // Returns the InterfaceProvider that this process can use to bind | 158 // Returns the InterfaceProvider that this process can use to bind |
155 // interfaces exposed to it by the application running in this frame. | 159 // interfaces exposed to it by the application running in this frame. |
156 virtual shell::InterfaceProvider* GetRemoteInterfaces() = 0; | 160 virtual shell::InterfaceProvider* GetRemoteInterfaces() = 0; |
157 | 161 |
162 using GenericRoutedInterfaceFactory = | |
163 base::Callback<void(mojo::ScopedInterfaceEndpointHandle)>; | |
164 | |
165 // Adds an associated interface factory to this frame, allowing the remote | |
166 // RenderFrameHost to acquire a proxy to the interface on this specific frame. | |
167 virtual void AddRoutedInterface( | |
tibell
2016/09/05 00:32:13
It's a bit unfortunate that we couldn't instead ha
| |
168 const base::StringPiece& name, | |
169 const GenericRoutedInterfaceFactory& factory) = 0; | |
170 | |
171 virtual void RemoveRoutedInterface(const base::StringPiece& name) = 0; | |
172 | |
173 // Binds an interface proxy to be associated with the remote RenderFrameHost | |
174 // in the browser process. | |
175 virtual void GetRemoteRoutedInterface( | |
176 const base::StringPiece& name, | |
177 mojo::ScopedInterfaceEndpointHandle handle) = 0; | |
178 | |
158 #if defined(ENABLE_PLUGINS) | 179 #if defined(ENABLE_PLUGINS) |
159 // Registers a plugin that has been marked peripheral. If the origin | 180 // Registers a plugin that has been marked peripheral. If the origin |
160 // whitelist is later updated and includes |content_origin|, then | 181 // whitelist is later updated and includes |content_origin|, then |
161 // |unthrottle_callback| will be called. | 182 // |unthrottle_callback| will be called. |
162 virtual void RegisterPeripheralPlugin( | 183 virtual void RegisterPeripheralPlugin( |
163 const url::Origin& content_origin, | 184 const url::Origin& content_origin, |
164 const base::Closure& unthrottle_callback) = 0; | 185 const base::Closure& unthrottle_callback) = 0; |
165 | 186 |
166 // Returns the peripheral content heuristic decision. | 187 // Returns the peripheral content heuristic decision. |
167 // | 188 // |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 | 243 |
223 // Whether or not this frame is using Lo-Fi. | 244 // Whether or not this frame is using Lo-Fi. |
224 virtual bool IsUsingLoFi() const = 0; | 245 virtual bool IsUsingLoFi() const = 0; |
225 | 246 |
226 // Whether or not this frame is currently pasting. | 247 // Whether or not this frame is currently pasting. |
227 virtual bool IsPasting() const = 0; | 248 virtual bool IsPasting() const = 0; |
228 | 249 |
229 // Returns the current visibility of the frame. | 250 // Returns the current visibility of the frame. |
230 virtual blink::WebPageVisibilityState GetVisibilityState() const = 0; | 251 virtual blink::WebPageVisibilityState GetVisibilityState() const = 0; |
231 | 252 |
253 template <typename Interface> | |
254 void GetRemoteRoutedInterface( | |
255 mojo::AssociatedInterfacePtr<Interface>* proxy) { | |
256 IPC::ChannelProxy* channel = RenderThread::Get()->GetChannel(); | |
257 | |
258 // Tests may not have a channel set up. Since they clearly don't expect IPC | |
259 // to work, we can bind these interface requests to dead-ends. | |
260 if (!channel) { | |
261 mojo::GetDummyProxy(proxy); | |
262 return; | |
263 } | |
264 | |
265 mojo::AssociatedInterfaceRequest<Interface> request = mojo::GetProxy( | |
266 proxy, channel->GetAssociatedGroup()); | |
267 GetRemoteRoutedInterface(Interface::Name_, request.PassHandle()); | |
268 } | |
269 | |
270 template <typename Interface> | |
271 using RoutedInterfaceFactory = | |
272 base::Callback<void(mojo::AssociatedInterfaceRequest<Interface>)>; | |
273 | |
274 template <typename Interface> | |
275 void AddRoutedInterface(const RoutedInterfaceFactory<Interface>& factory) { | |
276 AddRoutedInterface(Interface::Name_, | |
277 base::Bind(&BindRoutedInterface<Interface>, factory)); | |
278 } | |
279 | |
232 protected: | 280 protected: |
233 ~RenderFrame() override {} | 281 ~RenderFrame() override {} |
234 | 282 |
235 private: | 283 private: |
236 // This interface should only be implemented inside content. | 284 // This interface should only be implemented inside content. |
237 friend class RenderFrameImpl; | 285 friend class RenderFrameImpl; |
286 | |
238 RenderFrame() {} | 287 RenderFrame() {} |
288 | |
289 template <typename Interface> | |
290 static void BindRoutedInterface( | |
291 const RoutedInterfaceFactory<Interface>& factory, | |
292 mojo::ScopedInterfaceEndpointHandle handle) { | |
293 mojo::AssociatedInterfaceRequest<Interface> request; | |
294 request.Bind(std::move(handle)); | |
295 factory.Run(std::move(request)); | |
296 } | |
239 }; | 297 }; |
240 | 298 |
241 } // namespace content | 299 } // namespace content |
242 | 300 |
243 #endif // CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_ | 301 #endif // CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_ |
OLD | NEW |