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_RENDERER_RENDER_FRAME_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_RENDER_FRAME_IMPL_H_ |
6 #define CONTENT_RENDERER_RENDER_FRAME_IMPL_H_ | 6 #define CONTENT_RENDERER_RENDER_FRAME_IMPL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/id_map.h" | 13 #include "base/id_map.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
16 #include "base/process/process_handle.h" | 16 #include "base/process/process_handle.h" |
17 #include "content/public/common/javascript_message_type.h" | 17 #include "content/public/common/javascript_message_type.h" |
18 #include "content/public/common/referrer.h" | 18 #include "content/public/common/referrer.h" |
19 #include "content/public/renderer/render_frame.h" | 19 #include "content/public/renderer/render_frame.h" |
| 20 #include "content/renderer/media/webmediaplayer_delegate.h" |
20 #include "content/renderer/renderer_webcookiejar_impl.h" | 21 #include "content/renderer/renderer_webcookiejar_impl.h" |
21 #include "ipc/ipc_message.h" | 22 #include "ipc/ipc_message.h" |
22 #include "third_party/WebKit/public/web/WebDataSource.h" | 23 #include "third_party/WebKit/public/web/WebDataSource.h" |
23 #include "third_party/WebKit/public/web/WebFrameClient.h" | 24 #include "third_party/WebKit/public/web/WebFrameClient.h" |
24 #include "third_party/WebKit/public/web/WebHistoryCommitType.h" | 25 #include "third_party/WebKit/public/web/WebHistoryCommitType.h" |
25 #include "ui/gfx/range/range.h" | 26 #include "ui/gfx/range/range.h" |
26 | 27 |
27 class TransportDIB; | 28 class TransportDIB; |
28 struct FrameMsg_BuffersSwapped_Params; | 29 struct FrameMsg_BuffersSwapped_Params; |
29 struct FrameMsg_CompositorFrameSwapped_Params; | 30 struct FrameMsg_CompositorFrameSwapped_Params; |
30 struct FrameMsg_Navigate_Params; | 31 struct FrameMsg_Navigate_Params; |
31 | 32 |
32 namespace blink { | 33 namespace blink { |
33 class WebGeolocationClient; | 34 class WebGeolocationClient; |
34 class WebInputEvent; | 35 class WebInputEvent; |
35 class WebMouseEvent; | 36 class WebMouseEvent; |
36 class WebContentDecryptionModule; | 37 class WebContentDecryptionModule; |
37 class WebMIDIClient; | 38 class WebMIDIClient; |
| 39 class WebMediaPlayer; |
38 class WebNotificationPresenter; | 40 class WebNotificationPresenter; |
39 class WebSecurityOrigin; | 41 class WebSecurityOrigin; |
40 class WebUserMediaClient; | |
41 struct WebCompositionUnderline; | 42 struct WebCompositionUnderline; |
42 struct WebContextMenuData; | 43 struct WebContextMenuData; |
43 struct WebCursorInfo; | 44 struct WebCursorInfo; |
44 } | 45 } |
45 | 46 |
46 namespace gfx { | 47 namespace gfx { |
47 class Point; | 48 class Point; |
48 class Range; | 49 class Range; |
49 class Rect; | 50 class Rect; |
50 } | 51 } |
51 | 52 |
52 namespace content { | 53 namespace content { |
53 | 54 |
54 class ChildFrameCompositingHelper; | 55 class ChildFrameCompositingHelper; |
| 56 class MediaStreamClient; |
55 class NotificationProvider; | 57 class NotificationProvider; |
56 class PepperPluginInstanceImpl; | 58 class PepperPluginInstanceImpl; |
57 class RendererPpapiHost; | 59 class RendererPpapiHost; |
58 class RenderFrameObserver; | 60 class RenderFrameObserver; |
59 class RenderViewImpl; | 61 class RenderViewImpl; |
60 class RenderWidget; | 62 class RenderWidget; |
61 class RenderWidgetFullscreenPepper; | 63 class RenderWidgetFullscreenPepper; |
62 struct CustomContextMenuContext; | 64 struct CustomContextMenuContext; |
63 | 65 |
64 class CONTENT_EXPORT RenderFrameImpl | 66 class CONTENT_EXPORT RenderFrameImpl |
65 : public RenderFrame, | 67 : public RenderFrame, |
66 NON_EXPORTED_BASE(public blink::WebFrameClient) { | 68 NON_EXPORTED_BASE(public blink::WebFrameClient), |
| 69 NON_EXPORTED_BASE(public WebMediaPlayerDelegate) { |
67 public: | 70 public: |
68 // Creates a new RenderFrame. |render_view| is the RenderView object that this | 71 // Creates a new RenderFrame. |render_view| is the RenderView object that this |
69 // frame belongs to. | 72 // frame belongs to. |
70 // Callers *must* call |SetWebFrame| immediately after creation. | 73 // Callers *must* call |SetWebFrame| immediately after creation. |
71 // TODO(creis): We should structure this so that |SetWebFrame| isn't needed. | 74 // TODO(creis): We should structure this so that |SetWebFrame| isn't needed. |
72 static RenderFrameImpl* Create(RenderViewImpl* render_view, int32 routing_id); | 75 static RenderFrameImpl* Create(RenderViewImpl* render_view, int32 routing_id); |
73 | 76 |
74 // Just like RenderFrame::FromWebFrame but returns the implementation. | 77 // Just like RenderFrame::FromWebFrame but returns the implementation. |
75 static RenderFrameImpl* FromWebFrame(blink::WebFrame* web_frame); | 78 static RenderFrameImpl* FromWebFrame(blink::WebFrame* web_frame); |
76 | 79 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 const base::string16& text, | 171 const base::string16& text, |
169 const std::vector<blink::WebCompositionUnderline>& underlines, | 172 const std::vector<blink::WebCompositionUnderline>& underlines, |
170 int selection_start, | 173 int selection_start, |
171 int selection_end); | 174 int selection_end); |
172 void OnImeConfirmComposition( | 175 void OnImeConfirmComposition( |
173 const base::string16& text, | 176 const base::string16& text, |
174 const gfx::Range& replacement_range, | 177 const gfx::Range& replacement_range, |
175 bool keep_selection); | 178 bool keep_selection); |
176 #endif // ENABLE_PLUGINS | 179 #endif // ENABLE_PLUGINS |
177 | 180 |
| 181 // Overrides the MediaStreamClient used when creating MediaStream players. |
| 182 // Must be called before any players are created. |
| 183 void SetMediaStreamClientForTesting(MediaStreamClient* media_stream_client); |
| 184 |
178 // IPC::Sender | 185 // IPC::Sender |
179 virtual bool Send(IPC::Message* msg) OVERRIDE; | 186 virtual bool Send(IPC::Message* msg) OVERRIDE; |
180 | 187 |
181 // IPC::Listener | 188 // IPC::Listener |
182 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 189 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
183 | 190 |
184 // RenderFrame implementation: | 191 // RenderFrame implementation: |
185 virtual RenderView* GetRenderView() OVERRIDE; | 192 virtual RenderView* GetRenderView() OVERRIDE; |
186 virtual int GetRoutingID() OVERRIDE; | 193 virtual int GetRoutingID() OVERRIDE; |
187 virtual blink::WebFrame* GetWebFrame() OVERRIDE; | 194 virtual blink::WebFrame* GetWebFrame() OVERRIDE; |
188 virtual WebPreferences& GetWebkitPreferences() OVERRIDE; | 195 virtual WebPreferences& GetWebkitPreferences() OVERRIDE; |
189 virtual int ShowContextMenu(ContextMenuClient* client, | 196 virtual int ShowContextMenu(ContextMenuClient* client, |
190 const ContextMenuParams& params) OVERRIDE; | 197 const ContextMenuParams& params) OVERRIDE; |
191 virtual void CancelContextMenu(int request_id) OVERRIDE; | 198 virtual void CancelContextMenu(int request_id) OVERRIDE; |
192 virtual blink::WebNode GetContextMenuNode() const OVERRIDE; | 199 virtual blink::WebNode GetContextMenuNode() const OVERRIDE; |
193 virtual blink::WebPlugin* CreatePlugin( | 200 virtual blink::WebPlugin* CreatePlugin( |
194 blink::WebFrame* frame, | 201 blink::WebFrame* frame, |
195 const WebPluginInfo& info, | 202 const WebPluginInfo& info, |
196 const blink::WebPluginParams& params) OVERRIDE; | 203 const blink::WebPluginParams& params) OVERRIDE; |
197 virtual void LoadURLExternally(blink::WebLocalFrame* frame, | 204 virtual void LoadURLExternally(blink::WebLocalFrame* frame, |
198 const blink::WebURLRequest& request, | 205 const blink::WebURLRequest& request, |
199 blink::WebNavigationPolicy policy) OVERRIDE; | 206 blink::WebNavigationPolicy policy) OVERRIDE; |
200 virtual void ExecuteJavaScript(const base::string16& javascript) OVERRIDE; | 207 virtual void ExecuteJavaScript(const base::string16& javascript) OVERRIDE; |
201 | 208 |
202 // blink::WebFrameClient implementation ------------------------------------- | 209 // blink::WebFrameClient implementation: |
203 virtual blink::WebPlugin* createPlugin(blink::WebLocalFrame* frame, | 210 virtual blink::WebPlugin* createPlugin(blink::WebLocalFrame* frame, |
204 const blink::WebPluginParams& params); | 211 const blink::WebPluginParams& params); |
205 virtual blink::WebMediaPlayer* createMediaPlayer( | 212 virtual blink::WebMediaPlayer* createMediaPlayer( |
206 blink::WebLocalFrame* frame, | 213 blink::WebLocalFrame* frame, |
207 const blink::WebURL& url, | 214 const blink::WebURL& url, |
208 blink::WebMediaPlayerClient* client); | 215 blink::WebMediaPlayerClient* client); |
209 virtual blink::WebContentDecryptionModule* createContentDecryptionModule( | 216 virtual blink::WebContentDecryptionModule* createContentDecryptionModule( |
210 blink::WebLocalFrame* frame, | 217 blink::WebLocalFrame* frame, |
211 const blink::WebSecurityOrigin& security_origin, | 218 const blink::WebSecurityOrigin& security_origin, |
212 const blink::WebString& key_system); | 219 const blink::WebString& key_system); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 virtual blink::WebString userAgentOverride(blink::WebLocalFrame* frame, | 363 virtual blink::WebString userAgentOverride(blink::WebLocalFrame* frame, |
357 const blink::WebURL& url); | 364 const blink::WebURL& url); |
358 virtual blink::WebString doNotTrackValue(blink::WebLocalFrame* frame); | 365 virtual blink::WebString doNotTrackValue(blink::WebLocalFrame* frame); |
359 virtual bool allowWebGL(blink::WebLocalFrame* frame, bool default_value); | 366 virtual bool allowWebGL(blink::WebLocalFrame* frame, bool default_value); |
360 virtual void didLoseWebGLContext(blink::WebLocalFrame* frame, | 367 virtual void didLoseWebGLContext(blink::WebLocalFrame* frame, |
361 int arb_robustness_status_code); | 368 int arb_robustness_status_code); |
362 virtual void forwardInputEvent(const blink::WebInputEvent* event); | 369 virtual void forwardInputEvent(const blink::WebInputEvent* event); |
363 virtual void initializeChildFrame(const blink::WebRect& frame_rect, | 370 virtual void initializeChildFrame(const blink::WebRect& frame_rect, |
364 float scale_factor); | 371 float scale_factor); |
365 | 372 |
| 373 // WebMediaPlayerDelegate implementation: |
| 374 virtual void DidPlay(blink::WebMediaPlayer* player) OVERRIDE; |
| 375 virtual void DidPause(blink::WebMediaPlayer* player) OVERRIDE; |
| 376 virtual void PlayerGone(blink::WebMediaPlayer* player) OVERRIDE; |
| 377 |
366 // TODO(nasko): Make all tests in RenderViewImplTest friends and then move | 378 // TODO(nasko): Make all tests in RenderViewImplTest friends and then move |
367 // this back to private member. | 379 // this back to private member. |
368 void OnNavigate(const FrameMsg_Navigate_Params& params); | 380 void OnNavigate(const FrameMsg_Navigate_Params& params); |
369 | 381 |
370 protected: | 382 protected: |
371 RenderFrameImpl(RenderViewImpl* render_view, int32 routing_id); | 383 RenderFrameImpl(RenderViewImpl* render_view, int32 routing_id); |
372 | 384 |
373 private: | 385 private: |
374 friend class RenderFrameObserver; | 386 friend class RenderFrameObserver; |
375 FRIEND_TEST_ALL_PREFIXES(RendererAccessibilityTest, | 387 FRIEND_TEST_ALL_PREFIXES(RendererAccessibilityTest, |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 const base::string16& message, | 478 const base::string16& message, |
467 const base::string16& default_value, | 479 const base::string16& default_value, |
468 const GURL& frame_url, | 480 const GURL& frame_url, |
469 base::string16* result); | 481 base::string16* result); |
470 | 482 |
471 // Loads the appropriate error page for the specified failure into the frame. | 483 // Loads the appropriate error page for the specified failure into the frame. |
472 void LoadNavigationErrorPage(const blink::WebURLRequest& failed_request, | 484 void LoadNavigationErrorPage(const blink::WebURLRequest& failed_request, |
473 const blink::WebURLError& error, | 485 const blink::WebURLError& error, |
474 bool replace); | 486 bool replace); |
475 | 487 |
| 488 // Initializes |media_stream_client_|, returning true if successful. Returns |
| 489 // false if it wasn't possible to create a MediaStreamClient (e.g., WebRTC is |
| 490 // disabled) in which case |media_stream_client_| is NULL. |
| 491 bool InitializeMediaStreamClient(); |
| 492 |
| 493 blink::WebMediaPlayer* CreateWebMediaPlayerForMediaStream( |
| 494 const blink::WebURL& url, |
| 495 blink::WebMediaPlayerClient* client); |
| 496 |
| 497 #if defined(OS_ANDROID) |
| 498 blink::WebMediaPlayer* CreateAndroidWebMediaPlayer( |
| 499 const blink::WebURL& url, |
| 500 blink::WebMediaPlayerClient* client); |
| 501 #endif |
| 502 |
476 // Stores the WebLocalFrame we are associated with. | 503 // Stores the WebLocalFrame we are associated with. |
477 blink::WebLocalFrame* frame_; | 504 blink::WebLocalFrame* frame_; |
478 | 505 |
479 base::WeakPtr<RenderViewImpl> render_view_; | 506 base::WeakPtr<RenderViewImpl> render_view_; |
480 int routing_id_; | 507 int routing_id_; |
481 bool is_swapped_out_; | 508 bool is_swapped_out_; |
482 bool is_detaching_; | 509 bool is_detaching_; |
483 | 510 |
484 #if defined(ENABLE_PLUGINS) | 511 #if defined(ENABLE_PLUGINS) |
485 // Current text input composition text. Empty if no composition is in | 512 // Current text input composition text. Empty if no composition is in |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 // of handling a InputMsg_SelectRange IPC. | 552 // of handling a InputMsg_SelectRange IPC. |
526 bool handling_select_range_; | 553 bool handling_select_range_; |
527 | 554 |
528 // The next group of objects all implement RenderFrameObserver, so are deleted | 555 // The next group of objects all implement RenderFrameObserver, so are deleted |
529 // along with the RenderFrame automatically. This is why we just store weak | 556 // along with the RenderFrame automatically. This is why we just store weak |
530 // references. | 557 // references. |
531 | 558 |
532 // Holds a reference to the service which provides desktop notifications. | 559 // Holds a reference to the service which provides desktop notifications. |
533 NotificationProvider* notification_provider_; | 560 NotificationProvider* notification_provider_; |
534 | 561 |
| 562 // MediaStreamClient attached to this frame; lazily initialized. |
| 563 MediaStreamClient* media_stream_client_; |
| 564 blink::WebUserMediaClient* web_user_media_client_; |
| 565 |
| 566 base::WeakPtrFactory<RenderFrameImpl> weak_factory_; |
| 567 |
535 DISALLOW_COPY_AND_ASSIGN(RenderFrameImpl); | 568 DISALLOW_COPY_AND_ASSIGN(RenderFrameImpl); |
536 }; | 569 }; |
537 | 570 |
538 } // namespace content | 571 } // namespace content |
539 | 572 |
540 #endif // CONTENT_RENDERER_RENDER_FRAME_IMPL_H_ | 573 #endif // CONTENT_RENDERER_RENDER_FRAME_IMPL_H_ |
OLD | NEW |