render_frame_impl.h revision 5f1c94371a64b3196d4be9466099bb892df9b88e
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 3// found in the LICENSE file. 4 5#ifndef CONTENT_RENDERER_RENDER_FRAME_IMPL_H_ 6#define CONTENT_RENDERER_RENDER_FRAME_IMPL_H_ 7 8#include <vector> 9 10#include "base/basictypes.h" 11#include "base/files/file_path.h" 12#include "base/gtest_prod_util.h" 13#include "base/id_map.h" 14#include "base/memory/weak_ptr.h" 15#include "base/observer_list.h" 16#include "base/process/process_handle.h" 17#include "content/common/accessibility_mode_enums.h" 18#include "content/common/mojo/service_registry_impl.h" 19#include "content/public/common/javascript_message_type.h" 20#include "content/public/common/referrer.h" 21#include "content/public/renderer/render_frame.h" 22#include "content/renderer/media/webmediaplayer_delegate.h" 23#include "content/renderer/render_frame_proxy.h" 24#include "content/renderer/renderer_webcookiejar_impl.h" 25#include "ipc/ipc_message.h" 26#include "third_party/WebKit/public/web/WebAXObject.h" 27#include "third_party/WebKit/public/web/WebDataSource.h" 28#include "third_party/WebKit/public/web/WebFrameClient.h" 29#include "third_party/WebKit/public/web/WebHistoryCommitType.h" 30#include "ui/gfx/range/range.h" 31 32#if defined(OS_ANDROID) 33#include "content/renderer/media/android/renderer_media_player_manager.h" 34#endif 35 36class TransportDIB; 37struct FrameMsg_Navigate_Params; 38 39namespace blink { 40class WebGeolocationClient; 41class WebInputEvent; 42class WebMouseEvent; 43class WebContentDecryptionModule; 44class WebMediaPlayer; 45class WebNotificationPresenter; 46class WebPushClient; 47class WebSecurityOrigin; 48struct WebCompositionUnderline; 49struct WebContextMenuData; 50struct WebCursorInfo; 51} 52 53namespace gfx { 54class Point; 55class Range; 56class Rect; 57} 58 59namespace content { 60 61class ChildFrameCompositingHelper; 62class GeolocationDispatcher; 63class MediaStreamDispatcher; 64class MediaStreamImpl; 65class MediaStreamRendererFactory; 66class MidiDispatcher; 67class NotificationPermissionDispatcher; 68class NotificationProvider; 69class PepperPluginInstanceImpl; 70class PushMessagingDispatcher; 71class RendererAccessibility; 72class RendererCdmManager; 73class RendererMediaPlayerManager; 74class RendererPpapiHost; 75class RenderFrameObserver; 76class RenderViewImpl; 77class RenderWidget; 78class RenderWidgetFullscreenPepper; 79class ScreenOrientationDispatcher; 80struct CustomContextMenuContext; 81 82class CONTENT_EXPORT RenderFrameImpl 83 : public RenderFrame, 84 NON_EXPORTED_BASE(public blink::WebFrameClient), 85 NON_EXPORTED_BASE(public WebMediaPlayerDelegate) { 86 public: 87 // Creates a new RenderFrame. |render_view| is the RenderView object that this 88 // frame belongs to. 89 // Callers *must* call |SetWebFrame| immediately after creation. 90 // Note: This is called only when RenderFrame is created by Blink through 91 // createChildFrame. 92 // TODO(creis): We should structure this so that |SetWebFrame| isn't needed. 93 static RenderFrameImpl* Create(RenderViewImpl* render_view, int32 routing_id); 94 95 // Creates a new RenderFrame with |routing_id| as a child of the RenderFrame 96 // identified by |parent_routing_id| or as the top-level frame if the latter 97 // is MSG_ROUTING_NONE. It creates the Blink WebLocalFrame and inserts it in 98 // the proper place in the frame tree. 99 // Note: This is called only when RenderFrame is being created in response to 100 // IPC message from the browser process. All other frame creation is driven 101 // through Blink and Create. 102 static void CreateFrame(int routing_id, int parent_routing_id); 103 104 // Returns the RenderFrameImpl for the given routing ID. 105 static RenderFrameImpl* FromRoutingID(int routing_id); 106 107 // Just like RenderFrame::FromWebFrame but returns the implementation. 108 static RenderFrameImpl* FromWebFrame(blink::WebFrame* web_frame); 109 110 // Used by content_layouttest_support to hook into the creation of 111 // RenderFrameImpls. 112 static void InstallCreateHook( 113 RenderFrameImpl* (*create_render_frame_impl)(RenderViewImpl*, int32)); 114 115 virtual ~RenderFrameImpl(); 116 117 bool is_swapped_out() const { 118 return is_swapped_out_; 119 } 120 121 // TODO(nasko): This can be removed once we don't have a swapped out state on 122 // RenderFrames. See https://crbug.com/357747. 123 void set_render_frame_proxy(RenderFrameProxy* proxy) { 124 render_frame_proxy_ = proxy; 125 } 126 127 // Out-of-process child frames receive a signal from RenderWidgetCompositor 128 // when a compositor frame has committed. 129 void DidCommitCompositorFrame(); 130 131 // TODO(jam): this is a temporary getter until all the code is transitioned 132 // to using RenderFrame instead of RenderView. 133 RenderViewImpl* render_view() { return render_view_.get(); } 134 135 RendererWebCookieJarImpl* cookie_jar() { return &cookie_jar_; } 136 137 // Returns the RenderWidget associated with this frame. 138 RenderWidget* GetRenderWidget(); 139 140 // This is called right after creation with the WebLocalFrame for this 141 // RenderFrame. It must be called before Initialize. 142 void SetWebFrame(blink::WebLocalFrame* web_frame); 143 144 // This method must be called after the frame has been added to the frame 145 // tree. It creates all objects that depend on the frame being at its proper 146 // spot. 147 void Initialize(); 148 149 // Notification from RenderView. 150 virtual void OnStop(); 151 152 // Notifications from RenderWidget. 153 void WasHidden(); 154 void WasShown(); 155 156 // Start/Stop loading notifications. 157 // TODO(nasko): Those are page-level methods at this time and come from 158 // WebViewClient. We should move them to be WebFrameClient calls and put 159 // logic in the browser side to balance starts/stops. 160 // |to_different_document| will be true unless the load is a fragment 161 // navigation, or triggered by history.pushState/replaceState. 162 virtual void didStartLoading(bool to_different_document); 163 virtual void didStopLoading(); 164 virtual void didChangeLoadProgress(double load_progress); 165 166 AccessibilityMode accessibility_mode() { 167 return accessibility_mode_; 168 } 169 170 RendererAccessibility* renderer_accessibility() { 171 return renderer_accessibility_; 172 } 173 174 void HandleWebAccessibilityEvent(const blink::WebAXObject& obj, 175 blink::WebAXEvent event); 176 177 // TODO(dmazzoni): the only reason this is here is to plumb it through to 178 // RendererAccessibility. It should be part of RenderFrameObserver, once 179 // blink has a separate accessibility tree per frame. 180 void FocusedNodeChanged(const blink::WebNode& node); 181 182#if defined(ENABLE_PLUGINS) 183 // Notification that a PPAPI plugin has been created. 184 void PepperPluginCreated(RendererPpapiHost* host); 185 186 // Notifies that |instance| has changed the cursor. 187 // This will update the cursor appearance if it is currently over the plugin 188 // instance. 189 void PepperDidChangeCursor(PepperPluginInstanceImpl* instance, 190 const blink::WebCursorInfo& cursor); 191 192 // Notifies that |instance| has received a mouse event. 193 void PepperDidReceiveMouseEvent(PepperPluginInstanceImpl* instance); 194 195 // Informs the render view that a PPAPI plugin has changed text input status. 196 void PepperTextInputTypeChanged(PepperPluginInstanceImpl* instance); 197 void PepperCaretPositionChanged(PepperPluginInstanceImpl* instance); 198 199 // Cancels current composition. 200 void PepperCancelComposition(PepperPluginInstanceImpl* instance); 201 202 // Informs the render view that a PPAPI plugin has changed selection. 203 void PepperSelectionChanged(PepperPluginInstanceImpl* instance); 204 205 // Creates a fullscreen container for a pepper plugin instance. 206 RenderWidgetFullscreenPepper* CreatePepperFullscreenContainer( 207 PepperPluginInstanceImpl* plugin); 208 209 bool IsPepperAcceptingCompositionEvents() const; 210 211 // Notification that the given plugin has crashed. 212 void PluginCrashed(const base::FilePath& plugin_path, 213 base::ProcessId plugin_pid); 214 215 // Simulates IME events for testing purpose. 216 void SimulateImeSetComposition( 217 const base::string16& text, 218 const std::vector<blink::WebCompositionUnderline>& underlines, 219 int selection_start, 220 int selection_end); 221 void SimulateImeConfirmComposition(const base::string16& text, 222 const gfx::Range& replacement_range); 223 224 // TODO(jam): remove these once the IPC handler moves from RenderView to 225 // RenderFrame. 226 void OnImeSetComposition( 227 const base::string16& text, 228 const std::vector<blink::WebCompositionUnderline>& underlines, 229 int selection_start, 230 int selection_end); 231 void OnImeConfirmComposition( 232 const base::string16& text, 233 const gfx::Range& replacement_range, 234 bool keep_selection); 235#endif // ENABLE_PLUGINS 236 237 // May return NULL in some cases, especially if userMediaClient() returns 238 // NULL. 239 MediaStreamDispatcher* GetMediaStreamDispatcher(); 240 241 // IPC::Sender 242 virtual bool Send(IPC::Message* msg) OVERRIDE; 243 244 // IPC::Listener 245 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 246 247 // RenderFrame implementation: 248 virtual RenderView* GetRenderView() OVERRIDE; 249 virtual int GetRoutingID() OVERRIDE; 250 virtual blink::WebFrame* GetWebFrame() OVERRIDE; 251 virtual WebPreferences& GetWebkitPreferences() OVERRIDE; 252 virtual int ShowContextMenu(ContextMenuClient* client, 253 const ContextMenuParams& params) OVERRIDE; 254 virtual void CancelContextMenu(int request_id) OVERRIDE; 255 virtual blink::WebNode GetContextMenuNode() const OVERRIDE; 256 virtual blink::WebPlugin* CreatePlugin( 257 blink::WebFrame* frame, 258 const WebPluginInfo& info, 259 const blink::WebPluginParams& params) OVERRIDE; 260 virtual void LoadURLExternally(blink::WebLocalFrame* frame, 261 const blink::WebURLRequest& request, 262 blink::WebNavigationPolicy policy) OVERRIDE; 263 virtual void ExecuteJavaScript(const base::string16& javascript) OVERRIDE; 264 virtual bool IsHidden() OVERRIDE; 265 virtual ServiceRegistry* GetServiceRegistry() OVERRIDE; 266 virtual bool IsFTPDirectoryListing() OVERRIDE; 267 268 // blink::WebFrameClient implementation: 269 virtual blink::WebPlugin* createPlugin(blink::WebLocalFrame* frame, 270 const blink::WebPluginParams& params); 271 virtual blink::WebMediaPlayer* createMediaPlayer( 272 blink::WebLocalFrame* frame, 273 const blink::WebURL& url, 274 blink::WebMediaPlayerClient* client); 275 virtual blink::WebContentDecryptionModule* createContentDecryptionModule( 276 blink::WebLocalFrame* frame, 277 const blink::WebSecurityOrigin& security_origin, 278 const blink::WebString& key_system); 279 virtual blink::WebApplicationCacheHost* createApplicationCacheHost( 280 blink::WebLocalFrame* frame, 281 blink::WebApplicationCacheHostClient* client); 282 virtual blink::WebWorkerPermissionClientProxy* 283 createWorkerPermissionClientProxy(blink::WebLocalFrame* frame); 284 virtual blink::WebCookieJar* cookieJar(blink::WebLocalFrame* frame); 285 virtual blink::WebServiceWorkerProvider* createServiceWorkerProvider( 286 blink::WebLocalFrame* frame); 287 virtual void didAccessInitialDocument(blink::WebLocalFrame* frame); 288 virtual blink::WebFrame* createChildFrame(blink::WebLocalFrame* parent, 289 const blink::WebString& name); 290 virtual void didDisownOpener(blink::WebLocalFrame* frame); 291 virtual void frameDetached(blink::WebFrame* frame); 292 virtual void frameFocused(); 293 virtual void willClose(blink::WebFrame* frame); 294 virtual void didChangeName(blink::WebLocalFrame* frame, 295 const blink::WebString& name); 296 virtual void didMatchCSS( 297 blink::WebLocalFrame* frame, 298 const blink::WebVector<blink::WebString>& newly_matching_selectors, 299 const blink::WebVector<blink::WebString>& stopped_matching_selectors); 300 virtual bool shouldReportDetailedMessageForSource( 301 const blink::WebString& source); 302 virtual void didAddMessageToConsole(const blink::WebConsoleMessage& message, 303 const blink::WebString& source_name, 304 unsigned source_line, 305 const blink::WebString& stack_trace); 306 virtual void loadURLExternally(blink::WebLocalFrame* frame, 307 const blink::WebURLRequest& request, 308 blink::WebNavigationPolicy policy, 309 const blink::WebString& suggested_name); 310 // The WebDataSource::ExtraData* is assumed to be a DocumentState* subclass. 311 virtual blink::WebNavigationPolicy decidePolicyForNavigation( 312 const NavigationPolicyInfo& info); 313 virtual blink::WebHistoryItem historyItemForNewChildFrame( 314 blink::WebFrame* frame); 315 virtual void willSendSubmitEvent(blink::WebLocalFrame* frame, 316 const blink::WebFormElement& form); 317 virtual void willSubmitForm(blink::WebLocalFrame* frame, 318 const blink::WebFormElement& form); 319 virtual void didCreateDataSource(blink::WebLocalFrame* frame, 320 blink::WebDataSource* datasource); 321 virtual void didStartProvisionalLoad(blink::WebLocalFrame* frame, 322 bool is_transition_navigation); 323 virtual void didReceiveServerRedirectForProvisionalLoad( 324 blink::WebLocalFrame* frame); 325 virtual void didFailProvisionalLoad( 326 blink::WebLocalFrame* frame, 327 const blink::WebURLError& error); 328 virtual void didCommitProvisionalLoad( 329 blink::WebLocalFrame* frame, 330 const blink::WebHistoryItem& item, 331 blink::WebHistoryCommitType commit_type); 332 virtual void didClearWindowObject(blink::WebLocalFrame* frame); 333 virtual void didCreateDocumentElement(blink::WebLocalFrame* frame); 334 virtual void didReceiveTitle(blink::WebLocalFrame* frame, 335 const blink::WebString& title, 336 blink::WebTextDirection direction); 337 virtual void didChangeIcon(blink::WebLocalFrame* frame, 338 blink::WebIconURL::Type icon_type); 339 virtual void didFinishDocumentLoad(blink::WebLocalFrame* frame); 340 virtual void didHandleOnloadEvents(blink::WebLocalFrame* frame); 341 virtual void didFailLoad(blink::WebLocalFrame* frame, 342 const blink::WebURLError& error); 343 virtual void didFinishLoad(blink::WebLocalFrame* frame); 344 virtual void didNavigateWithinPage(blink::WebLocalFrame* frame, 345 const blink::WebHistoryItem& item, 346 blink::WebHistoryCommitType commit_type); 347 virtual void didUpdateCurrentHistoryItem(blink::WebLocalFrame* frame); 348 virtual void didChangeThemeColor(); 349 virtual void requestNotificationPermission( 350 const blink::WebSecurityOrigin& origin, 351 blink::WebNotificationPermissionCallback* callback); 352 virtual blink::WebNotificationPresenter* notificationPresenter(); 353 virtual void didChangeSelection(bool is_empty_selection); 354 virtual blink::WebColorChooser* createColorChooser( 355 blink::WebColorChooserClient* client, 356 const blink::WebColor& initial_color, 357 const blink::WebVector<blink::WebColorSuggestion>& suggestions); 358 virtual void runModalAlertDialog(const blink::WebString& message); 359 virtual bool runModalConfirmDialog(const blink::WebString& message); 360 virtual bool runModalPromptDialog(const blink::WebString& message, 361 const blink::WebString& default_value, 362 blink::WebString* actual_value); 363 virtual bool runModalBeforeUnloadDialog(bool is_reload, 364 const blink::WebString& message); 365 virtual void showContextMenu(const blink::WebContextMenuData& data); 366 virtual void clearContextMenu(); 367 virtual void willSendRequest(blink::WebLocalFrame* frame, 368 unsigned identifier, 369 blink::WebURLRequest& request, 370 const blink::WebURLResponse& redirect_response); 371 virtual void didReceiveResponse(blink::WebLocalFrame* frame, 372 unsigned identifier, 373 const blink::WebURLResponse& response); 374 virtual void didFinishResourceLoad(blink::WebLocalFrame* frame, 375 unsigned identifier); 376 virtual void didLoadResourceFromMemoryCache( 377 blink::WebLocalFrame* frame, 378 const blink::WebURLRequest& request, 379 const blink::WebURLResponse& response); 380 virtual void didDisplayInsecureContent(blink::WebLocalFrame* frame); 381 virtual void didRunInsecureContent(blink::WebLocalFrame* frame, 382 const blink::WebSecurityOrigin& origin, 383 const blink::WebURL& target); 384 virtual void didAbortLoading(blink::WebLocalFrame* frame); 385 virtual void didCreateScriptContext(blink::WebLocalFrame* frame, 386 v8::Handle<v8::Context> context, 387 int extension_group, 388 int world_id); 389 virtual void willReleaseScriptContext(blink::WebLocalFrame* frame, 390 v8::Handle<v8::Context> context, 391 int world_id); 392 virtual void didFirstVisuallyNonEmptyLayout(blink::WebLocalFrame* frame); 393 virtual void didChangeScrollOffset(blink::WebLocalFrame* frame); 394 virtual void willInsertBody(blink::WebLocalFrame* frame); 395 virtual void reportFindInPageMatchCount(int request_id, 396 int count, 397 bool final_update); 398 virtual void reportFindInPageSelection(int request_id, 399 int active_match_ordinal, 400 const blink::WebRect& sel); 401 virtual void requestStorageQuota(blink::WebLocalFrame* frame, 402 blink::WebStorageQuotaType type, 403 unsigned long long requested_size, 404 blink::WebStorageQuotaCallbacks callbacks); 405 virtual void willOpenSocketStream( 406 blink::WebSocketStreamHandle* handle); 407 virtual void willOpenWebSocket(blink::WebSocketHandle* handle); 408 virtual blink::WebGeolocationClient* geolocationClient(); 409 virtual blink::WebPushClient* pushClient(); 410 virtual void willStartUsingPeerConnectionHandler( 411 blink::WebLocalFrame* frame, 412 blink::WebRTCPeerConnectionHandler* handler); 413 virtual blink::WebUserMediaClient* userMediaClient(); 414 virtual blink::WebMIDIClient* webMIDIClient(); 415 virtual bool willCheckAndDispatchMessageEvent( 416 blink::WebLocalFrame* source_frame, 417 blink::WebFrame* target_frame, 418 blink::WebSecurityOrigin target_origin, 419 blink::WebDOMMessageEvent event); 420 virtual blink::WebString userAgentOverride(blink::WebLocalFrame* frame, 421 const blink::WebURL& url); 422 virtual blink::WebString doNotTrackValue(blink::WebLocalFrame* frame); 423 virtual bool allowWebGL(blink::WebLocalFrame* frame, bool default_value); 424 virtual void didLoseWebGLContext(blink::WebLocalFrame* frame, 425 int arb_robustness_status_code); 426 virtual void forwardInputEvent(const blink::WebInputEvent* event); 427 virtual void initializeChildFrame(const blink::WebRect& frame_rect, 428 float scale_factor); 429 virtual blink::WebScreenOrientationClient* webScreenOrientationClient(); 430 431 // WebMediaPlayerDelegate implementation: 432 virtual void DidPlay(blink::WebMediaPlayer* player) OVERRIDE; 433 virtual void DidPause(blink::WebMediaPlayer* player) OVERRIDE; 434 virtual void PlayerGone(blink::WebMediaPlayer* player) OVERRIDE; 435 436 // TODO(nasko): Make all tests in RenderViewImplTest friends and then move 437 // this back to private member. 438 void OnNavigate(const FrameMsg_Navigate_Params& params); 439 440 // Binds this render frame's service registry to a handle to the remote 441 // service registry. 442 void BindServiceRegistry( 443 mojo::ScopedMessagePipeHandle service_provider_handle); 444 445 protected: 446 RenderFrameImpl(RenderViewImpl* render_view, int32 routing_id); 447 448 private: 449 friend class RenderFrameObserver; 450 friend class RendererAccessibilityTest; 451 FRIEND_TEST_ALL_PREFIXES(RendererAccessibilityTest, 452 AccessibilityMessagesQueueWhileSwappedOut); 453 FRIEND_TEST_ALL_PREFIXES(RenderFrameImplTest, 454 ShouldUpdateSelectionTextFromContextMenuParams); 455 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, 456 OnExtendSelectionAndDelete); 457 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, ReloadWhileSwappedOut); 458 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, SendSwapOutACK); 459 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, 460 SetEditableSelectionAndComposition); 461 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, 462 OnSetAccessibilityMode); 463 464 typedef std::map<GURL, double> HostZoomLevels; 465 466 // Functions to add and remove observers for this object. 467 void AddObserver(RenderFrameObserver* observer); 468 void RemoveObserver(RenderFrameObserver* observer); 469 470 // Builds and sends DidCommitProvisionalLoad to the host. 471 void SendDidCommitProvisionalLoad(blink::WebFrame* frame); 472 473 // Gets the focused element. If no such element exists then the element will 474 // be NULL. 475 blink::WebElement GetFocusedElement(); 476 477 // IPC message handlers ------------------------------------------------------ 478 // 479 // The documentation for these functions should be in 480 // content/common/*_messages.h for the message that the function is handling. 481 void OnBeforeUnload(); 482 void OnSwapOut(int proxy_routing_id); 483 void OnShowContextMenu(const gfx::Point& location); 484 void OnContextMenuClosed(const CustomContextMenuContext& custom_context); 485 void OnCustomContextMenuAction(const CustomContextMenuContext& custom_context, 486 unsigned action); 487 void OnUndo(); 488 void OnRedo(); 489 void OnCut(); 490 void OnCopy(); 491 void OnPaste(); 492 void OnPasteAndMatchStyle(); 493 void OnDelete(); 494 void OnSelectAll(); 495 void OnSelectRange(const gfx::Point& start, const gfx::Point& end); 496 void OnUnselect(); 497 void OnReplace(const base::string16& text); 498 void OnReplaceMisspelling(const base::string16& text); 499 void OnCSSInsertRequest(const std::string& css); 500 void OnJavaScriptExecuteRequest(const base::string16& javascript, 501 int id, 502 bool notify_result); 503 void OnSetEditableSelectionOffsets(int start, int end); 504 void OnSetCompositionFromExistingText( 505 int start, int end, 506 const std::vector<blink::WebCompositionUnderline>& underlines); 507 void OnExtendSelectionAndDelete(int before, int after); 508 void OnReload(bool ignore_cache); 509 void OnTextSurroundingSelectionRequest(size_t max_length); 510 void OnAddStyleSheetByURL(const std::string& url); 511 void OnSetAccessibilityMode(AccessibilityMode new_mode); 512#if defined(OS_MACOSX) 513 void OnCopyToFindPboard(); 514#endif 515 516 // Virtual since overridden by WebTestProxy for layout tests. 517 virtual blink::WebNavigationPolicy DecidePolicyForNavigation( 518 RenderFrame* render_frame, 519 const NavigationPolicyInfo& info); 520 void OpenURL(blink::WebFrame* frame, 521 const GURL& url, 522 const Referrer& referrer, 523 blink::WebNavigationPolicy policy); 524 525 // Update current main frame's encoding and send it to browser window. 526 // Since we want to let users see the right encoding info from menu 527 // before finishing loading, we call the UpdateEncoding in 528 // a) function:DidCommitLoadForFrame. When this function is called, 529 // that means we have got first data. In here we try to get encoding 530 // of page if it has been specified in http header. 531 // b) function:DidReceiveTitle. When this function is called, 532 // that means we have got specified title. Because in most of webpages, 533 // title tags will follow meta tags. In here we try to get encoding of 534 // page if it has been specified in meta tag. 535 // c) function:DidFinishDocumentLoadForFrame. When this function is 536 // called, that means we have got whole html page. In here we should 537 // finally get right encoding of page. 538 void UpdateEncoding(blink::WebFrame* frame, 539 const std::string& encoding_name); 540 541 // Dispatches the current state of selection on the webpage to the browser if 542 // it has changed. 543 // TODO(varunjain): delete this method once we figure out how to keep 544 // selection handles in sync with the webpage. 545 void SyncSelectionIfRequired(); 546 547 // Returns whether |params.selection_text| should be synchronized to the 548 // browser before bringing up the context menu. Static for testing. 549 static bool ShouldUpdateSelectionTextFromContextMenuParams( 550 const base::string16& selection_text, 551 size_t selection_text_offset, 552 const gfx::Range& selection_range, 553 const ContextMenuParams& params); 554 555 bool RunJavaScriptMessage(JavaScriptMessageType type, 556 const base::string16& message, 557 const base::string16& default_value, 558 const GURL& frame_url, 559 base::string16* result); 560 561 // Loads the appropriate error page for the specified failure into the frame. 562 void LoadNavigationErrorPage(const blink::WebURLRequest& failed_request, 563 const blink::WebURLError& error, 564 bool replace); 565 566 // Initializes |web_user_media_client_|. If this fails, because it wasn't 567 // possible to create a MediaStreamClient (e.g., WebRTC is disabled), then 568 // |web_user_media_client_| will remain NULL. 569 void InitializeUserMediaClient(); 570 571 blink::WebMediaPlayer* CreateWebMediaPlayerForMediaStream( 572 const blink::WebURL& url, 573 blink::WebMediaPlayerClient* client); 574 575 // Creates a factory object used for creating audio and video renderers. 576 // The method is virtual so that layouttests can override it. 577 virtual scoped_ptr<MediaStreamRendererFactory> CreateRendererFactory(); 578 579 // Returns the URL being loaded by the |frame_|'s request. 580 GURL GetLoadingUrl() const; 581 582#if defined(OS_ANDROID) 583 blink::WebMediaPlayer* CreateAndroidWebMediaPlayer( 584 const blink::WebURL& url, 585 blink::WebMediaPlayerClient* client); 586 587 RendererMediaPlayerManager* GetMediaPlayerManager(); 588#endif 589 590#if defined(ENABLE_BROWSER_CDMS) 591 RendererCdmManager* GetCdmManager(); 592#endif 593 594 // Stores the WebLocalFrame we are associated with. 595 blink::WebLocalFrame* frame_; 596 597 base::WeakPtr<RenderViewImpl> render_view_; 598 int routing_id_; 599 bool is_swapped_out_; 600 // RenderFrameProxy exists only when is_swapped_out_ is true. 601 // TODO(nasko): This can be removed once we don't have a swapped out state on 602 // RenderFrame. See https://crbug.com/357747. 603 RenderFrameProxy* render_frame_proxy_; 604 bool is_detaching_; 605 606#if defined(ENABLE_PLUGINS) 607 // Current text input composition text. Empty if no composition is in 608 // progress. 609 base::string16 pepper_composition_text_; 610#endif 611 612 RendererWebCookieJarImpl cookie_jar_; 613 614 // All the registered observers. 615 ObserverList<RenderFrameObserver> observers_; 616 617 scoped_refptr<ChildFrameCompositingHelper> compositing_helper_; 618 619 // The node that the context menu was pressed over. 620 blink::WebNode context_menu_node_; 621 622 // External context menu requests we're waiting for. "Internal" 623 // (WebKit-originated) context menu events will have an ID of 0 and will not 624 // be in this map. 625 // 626 // We don't want to add internal ones since some of the "special" page 627 // handlers in the browser process just ignore the context menu requests so 628 // avoid showing context menus, and so this will cause right clicks to leak 629 // entries in this map. Most users of the custom context menu (e.g. Pepper 630 // plugins) are normally only on "regular" pages and the regular pages will 631 // always respond properly to the request, so we don't have to worry so 632 // much about leaks. 633 IDMap<ContextMenuClient, IDMapExternalPointer> pending_context_menus_; 634 635 // The text selection the last time DidChangeSelection got called. May contain 636 // additional characters before and after the selected text, for IMEs. The 637 // portion of this string that is the actual selected text starts at index 638 // |selection_range_.GetMin() - selection_text_offset_| and has length 639 // |selection_range_.length()|. 640 base::string16 selection_text_; 641 // The offset corresponding to the start of |selection_text_| in the document. 642 size_t selection_text_offset_; 643 // Range over the document corresponding to the actual selected text (which 644 // could correspond to a substring of |selection_text_|; see above). 645 gfx::Range selection_range_; 646 // Used to inform didChangeSelection() when it is called in the context 647 // of handling a InputMsg_SelectRange IPC. 648 bool handling_select_range_; 649 650 // The next group of objects all implement RenderFrameObserver, so are deleted 651 // along with the RenderFrame automatically. This is why we just store weak 652 // references. 653 654 // Dispatches permission requests for Web Notifications. 655 NotificationPermissionDispatcher* notification_permission_dispatcher_; 656 657 // Holds a reference to the service which provides desktop notifications. 658 // TODO(peter) Remove this once Web Notifications are routed through Platform. 659 NotificationProvider* notification_provider_; 660 661 // Destroyed via the RenderFrameObserver::OnDestruct() mechanism. 662 MediaStreamImpl* web_user_media_client_; 663 664 // MidiClient attached to this frame; lazily initialized. 665 MidiDispatcher* midi_dispatcher_; 666 667#if defined(OS_ANDROID) 668 // Manages all media players in this render frame for communicating with the 669 // real media player in the browser process. It's okay to use a raw pointer 670 // since it's a RenderFrameObserver. 671 RendererMediaPlayerManager* media_player_manager_; 672#endif 673 674#if defined(ENABLE_BROWSER_CDMS) 675 // Manage all CDMs in this render frame for communicating with the real CDM in 676 // the browser process. It's okay to use a raw pointer since it's a 677 // RenderFrameObserver. 678 RendererCdmManager* cdm_manager_; 679#endif 680 681#if defined(VIDEO_HOLE) 682 // Whether or not this RenderFrameImpl contains a media player. Used to 683 // register as an observer for video-hole-specific events. 684 bool contains_media_player_; 685#endif 686 687 // The geolocation dispatcher attached to this frame, lazily initialized. 688 GeolocationDispatcher* geolocation_dispatcher_; 689 690 // The push messaging dispatcher attached to this frame, lazily initialized. 691 PushMessagingDispatcher* push_messaging_dispatcher_; 692 693 ServiceRegistryImpl service_registry_; 694 695 // The screen orientation dispatcher attached to the frame, lazily 696 // initialized. 697 ScreenOrientationDispatcher* screen_orientation_dispatcher_; 698 699 // The current accessibility mode. 700 AccessibilityMode accessibility_mode_; 701 702 // Only valid if |accessibility_mode_| is anything other than 703 // AccessibilityModeOff. 704 RendererAccessibility* renderer_accessibility_; 705 706 base::WeakPtrFactory<RenderFrameImpl> weak_factory_; 707 708 DISALLOW_COPY_AND_ASSIGN(RenderFrameImpl); 709}; 710 711} // namespace content 712 713#endif // CONTENT_RENDERER_RENDER_FRAME_IMPL_H_ 714