1 // Copyright (c) 2012 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.
5 #ifndef CONTENT_RENDERER_RENDER_VIEW_IMPL_H_
6 #define CONTENT_RENDERER_RENDER_VIEW_IMPL_H_
14 #include "base/basictypes.h"
15 #include "base/gtest_prod_util.h"
16 #include "base/id_map.h"
17 #include "base/memory/linked_ptr.h"
18 #include "base/memory/weak_ptr.h"
19 #include "base/observer_list.h"
20 #include "base/process.h"
21 #include "base/timer.h"
22 #include "base/values.h"
23 #include "build/build_config.h"
24 #include "content/common/content_export.h"
25 #include "content/common/drag_event_source_info.h"
26 #include "content/common/edit_command.h"
27 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
28 #include "content/common/navigation_gesture.h"
29 #include "content/common/view_message_enums.h"
30 #include "content/public/common/javascript_message_type.h"
31 #include "content/public/common/page_zoom.h"
32 #include "content/public/common/referrer.h"
33 #include "content/public/common/renderer_preferences.h"
34 #include "content/public/common/stop_find_action.h"
35 #include "content/public/renderer/render_view.h"
36 #include "content/renderer/mouse_lock_dispatcher.h"
37 #include "content/renderer/render_view_pepper_helper.h"
38 #include "content/renderer/render_widget.h"
39 #include "content/renderer/renderer_webcookiejar_impl.h"
40 #include "ipc/ipc_platform_file.h"
41 #include "third_party/WebKit/Source/Platform/chromium/public/WebFileSystem.h"
42 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h"
44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h"
45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h"
46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIconURL.h"
47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
48 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNavigationType.h"
49 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h"
50 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializerClient.h"
51 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageVisibilityState.h"
52 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
53 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h"
54 #include "ui/surface/transport_dib.h"
55 #include "webkit/glue/webpreferences.h"
56 #include "webkit/media/webmediaplayer_delegate.h"
57 #include "webkit/plugins/npapi/webplugin_page_delegate.h"
59 #if defined(OS_ANDROID)
60 #include "content/renderer/android/content_detector.h"
61 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContentDetectionResult.h"
64 #if defined(COMPILER_MSVC)
65 // RenderViewImpl is a diamond-shaped hierarchy, with WebWidgetClient at the
66 // root. VS warns when we inherit the WebWidgetClient method implementations
67 // from RenderWidget. It's safe to ignore that warning.
68 #pragma warning(disable: 4250)
72 class PepperDeviceTest
;
74 struct PP_NetAddress_Private
;
75 struct ViewMsg_Navigate_Params
;
76 struct ViewMsg_PostMessage_Params
;
77 struct ViewMsg_StopFinding_Params
;
78 struct ViewMsg_SwapOut_Params
;
82 struct SelectedFileInfo
;
93 namespace webkit_glue
{
94 class ImageResourceFetcher
;
95 class ResourceFetcher
;
98 #if defined(OS_ANDROID)
99 namespace webkit_media
{
100 class MediaPlayerBridgeManagerImpl
;
101 class WebMediaPlayerManagerAndroid
;
106 class WebApplicationCacheHost
;
107 class WebApplicationCacheHostClient
;
108 class WebDOMMessageEvent
;
110 class WebDateTimeChooserCompletion
;
112 class WebGeolocationClient
;
113 class WebGestureEvent
;
116 class WebPeerConnection00Handler
;
117 class WebPeerConnection00HandlerClient
;
118 class WebMediaPlayer
;
119 class WebMediaPlayerClient
;
121 class WebPeerConnectionHandler
;
122 class WebPeerConnectionHandlerClient
;
123 class WebSocketStreamHandle
;
124 class WebSpeechInputController
;
125 class WebSpeechInputListener
;
126 class WebSpeechRecognizer
;
127 class WebStorageNamespace
;
130 class WebUserMediaClient
;
131 struct WebActiveWheelFlingParameters
;
132 struct WebDateTimeChooserParams
;
133 struct WebFileChooserParams
;
134 struct WebFindOptions
;
135 struct WebMediaPlayerAction
;
136 struct WebPluginAction
;
138 struct WebWindowFeatures
;
140 #if defined(OS_ANDROID)
141 class WebHitTestResult
;
146 class BrowserPluginManager
;
147 class DeviceOrientationDispatcher
;
150 class DomAutomationController
;
151 class ExternalPopupMenu
;
153 class GeolocationDispatcher
;
154 class InputTagSpeechDispatcher
;
155 class JavaBridgeDispatcher
;
156 class LoadProgressTracker
;
157 class MediaStreamDispatcher
;
158 class MediaStreamImpl
;
159 class MouseLockDispatcher
;
160 class NavigationState
;
161 class NotificationProvider
;
162 class RenderViewObserver
;
163 class RenderViewTest
;
164 class RendererAccessibility
;
165 class RendererDateTimePicker
;
166 class RendererPpapiHost
;
167 class RendererWebColorChooserImpl
;
168 class RenderWidgetFullscreenPepper
;
169 class SpeechRecognitionDispatcher
;
170 class WebPluginDelegateProxy
;
171 struct CustomContextMenuContext
;
173 struct FileChooserParams
;
174 struct RenderViewImplParams
;
176 #if defined(OS_ANDROID)
177 class WebMediaPlayerProxyImplAndroid
;
180 // We need to prevent a page from trying to create infinite popups. It is not
181 // as simple as keeping a count of the number of immediate children
182 // popups. Having an html file that window.open()s itself would create
183 // an unlimited chain of RenderViews who only have one RenderView child.
185 // Therefore, each new top level RenderView creates a new counter and shares it
186 // with all its children and grandchildren popup RenderViewImpls created with
187 // createView() to have a sort of global limit for the page so no more than
188 // kMaximumNumberOfPopups popups are created.
190 // This is a RefCounted holder of an int because I can't say
191 // scoped_refptr<int>.
192 typedef base::RefCountedData
<int> SharedRenderViewCounter
;
195 // RenderView is an object that manages a WebView object, and provides a
196 // communication interface with an embedding application process
198 class CONTENT_EXPORT RenderViewImpl
199 : public RenderWidget
,
200 NON_EXPORTED_BASE(public WebKit::WebViewClient
),
201 NON_EXPORTED_BASE(public WebKit::WebFrameClient
),
202 NON_EXPORTED_BASE(public WebKit::WebPageSerializerClient
),
204 NON_EXPORTED_BASE(public webkit::npapi::WebPluginPageDelegate
),
205 NON_EXPORTED_BASE(public webkit_media::WebMediaPlayerDelegate
),
206 public base::SupportsWeakPtr
<RenderViewImpl
> {
208 // Creates a new RenderView. If this is a blocked popup or as a new tab,
209 // opener_id is the routing ID of the RenderView responsible for creating this
210 // RenderView. |counter| is either a currently initialized counter, or NULL
211 // (in which case we treat this RenderView as a top level window).
212 static RenderViewImpl
* Create(
214 const RendererPreferences
& renderer_prefs
,
215 const webkit_glue::WebPreferences
& webkit_prefs
,
216 SharedRenderViewCounter
* counter
,
219 int64 session_storage_namespace_id
,
220 const string16
& frame_name
,
221 bool is_renderer_created
,
224 const WebKit::WebScreenInfo
& screen_info
,
225 AccessibilityMode accessibility_mode
,
226 bool allow_partial_swap
);
228 // Used by content_layouttest_support to hook into the creation of
230 static void InstallCreateHook(
231 RenderViewImpl
* (*create_render_view_impl
)(RenderViewImplParams
*));
233 // Returns the RenderViewImpl containing the given WebView.
234 static RenderViewImpl
* FromWebView(WebKit::WebView
* webview
);
236 // Returns the RenderViewImpl for the given routing ID.
237 static RenderViewImpl
* FromRoutingID(int routing_id
);
239 // May return NULL when the view is closing.
240 WebKit::WebView
* webview() const;
242 int history_list_offset() const { return history_list_offset_
; }
244 const webkit_glue::WebPreferences
& webkit_preferences() const {
245 return webkit_preferences_
;
248 void set_send_content_state_immediately(bool value
) {
249 send_content_state_immediately_
= value
;
252 MediaStreamDispatcher
* media_stream_dispatcher() {
253 return media_stream_dispatcher_
;
256 MouseLockDispatcher
* mouse_lock_dispatcher() {
257 return mouse_lock_dispatcher_
;
260 #if defined(OS_ANDROID)
261 webkit_media::WebMediaPlayerManagerAndroid
* media_player_manager() {
262 return media_player_manager_
.get();
266 // Lazily initialize this view's BrowserPluginManager and return it.
267 BrowserPluginManager
* browser_plugin_manager();
269 // Functions to add and remove observers for this object.
270 void AddObserver(RenderViewObserver
* observer
);
271 void RemoveObserver(RenderViewObserver
* observer
);
273 // Adds the given file chooser request to the file_chooser_completion_ queue
274 // (see that var for more) and requests the chooser be displayed if there are
275 // no other waiting items in the queue.
277 // Returns true if the chooser was successfully scheduled. False means we
278 // didn't schedule anything.
279 bool ScheduleFileChooser(const FileChooserParams
& params
,
280 WebKit::WebFileChooserCompletion
* completion
);
282 void LoadNavigationErrorPage(
283 WebKit::WebFrame
* frame
,
284 const WebKit::WebURLRequest
& failed_request
,
285 const WebKit::WebURLError
& error
,
286 const std::string
& html
,
289 // Plugin-related functions --------------------------------------------------
290 // (See also WebPluginPageDelegate implementation.)
292 // Notification that the given plugin has crashed.
293 void PluginCrashed(const base::FilePath
& plugin_path
,
294 base::ProcessId plugin_pid
);
296 // Creates a fullscreen container for a pepper plugin instance.
297 RenderWidgetFullscreenPepper
* CreatePepperFullscreenContainer(
298 webkit::ppapi::PluginInstance
* plugin
);
300 // Informs the render view that a PPAPI plugin has gained or lost focus.
301 void PpapiPluginFocusChanged();
303 // Informs the render view that a PPAPI plugin has changed text input status.
304 void PpapiPluginTextInputTypeChanged();
305 void PpapiPluginCaretPositionChanged();
307 // Cancels current composition.
308 void PpapiPluginCancelComposition();
310 // Informs the render view that a PPAPI plugin has changed selection.
311 void PpapiPluginSelectionChanged();
313 // Notification that a PPAPI plugin has been created.
314 void PpapiPluginCreated(RendererPpapiHost
* host
);
316 // Retrieves the current caret position if a PPAPI plugin has focus.
317 bool GetPpapiPluginCaretBounds(gfx::Rect
* rect
);
319 // Simulates IME events for testing purpose.
320 void SimulateImeSetComposition(
321 const string16
& text
,
322 const std::vector
<WebKit::WebCompositionUnderline
>& underlines
,
325 void SimulateImeConfirmComposition(const string16
& text
,
326 const ui::Range
& replacement_range
);
328 #if defined(OS_MACOSX) || defined(OS_WIN)
329 // Informs the render view that the given plugin has gained or lost focus.
330 void PluginFocusChanged(bool focused
, int plugin_id
);
333 #if defined(OS_MACOSX)
334 // Starts plugin IME.
335 void StartPluginIme();
338 void RegisterPluginDelegate(WebPluginDelegateProxy
* delegate
);
339 void UnregisterPluginDelegate(WebPluginDelegateProxy
* delegate
);
341 // Helper function to retrieve information about a plugin for a URL and mime
342 // type. Returns false if no plugin was found.
343 // |actual_mime_type| is the actual mime type supported by the
344 // plugin found that match the URL given (one for each item in
346 bool GetPluginInfo(const GURL
& url
,
347 const GURL
& page_url
,
348 const std::string
& mime_type
,
349 webkit::WebPluginInfo
* plugin_info
,
350 std::string
* actual_mime_type
);
352 void TransferActiveWheelFlingAnimation(
353 const WebKit::WebActiveWheelFlingParameters
& params
);
355 // Returns true if the focused element is editable text from the perspective
356 // of IME support (also used for on-screen keyboard). Works correctly inside
357 // supported PPAPI plug-ins.
358 bool HasIMETextFocus();
360 // Callback for use with GetWindowSnapshot.
361 typedef base::Callback
<void(
362 const gfx::Size
&, const std::vector
<unsigned char>&)>
363 WindowSnapshotCallback
;
365 void GetWindowSnapshot(const WindowSnapshotCallback
& callback
);
367 // Dispatches the current navigation state to the browser. Called on a
368 // periodic timer so we don't send too many messages.
369 void SyncNavigationState();
371 // Returns the length of the session history of this RenderView. Note that
372 // this only coincides with the actual length of the session history if this
373 // RenderView is the currently active RenderView of a WebContents.
374 unsigned GetLocalSessionHistoryLengthForTesting() const;
376 // Invokes OnSetFocus and marks the widget as active depending on the value
377 // of |enable|. This is used for layout tests that need to control the focus
378 // synchronously from the renderer.
379 void SetFocusAndActivateForTesting(bool enable
);
381 // Change the device scale factor and force the compositor to resize.
382 void SetDeviceScaleFactorForTesting(float factor
);
384 // IPC::Listener implementation ----------------------------------------------
386 virtual bool OnMessageReceived(const IPC::Message
& msg
) OVERRIDE
;
388 // WebKit::WebWidgetClient implementation ------------------------------------
390 // Most methods are handled by RenderWidget.
391 virtual void didFocus();
392 virtual void didBlur();
393 virtual void show(WebKit::WebNavigationPolicy policy
);
394 virtual void runModal();
395 virtual bool enterFullScreen();
396 virtual void exitFullScreen();
397 virtual bool requestPointerLock();
398 virtual void requestPointerUnlock();
399 virtual bool isPointerLocked();
400 virtual void didActivateCompositor(int input_handler_identifier
);
401 virtual void didHandleGestureEvent(const WebKit::WebGestureEvent
& event
,
402 bool event_cancelled
) OVERRIDE
;
404 // WebKit::WebViewClient implementation --------------------------------------
406 virtual WebKit::WebView
* createView(
407 WebKit::WebFrame
* creator
,
408 const WebKit::WebURLRequest
& request
,
409 const WebKit::WebWindowFeatures
& features
,
410 const WebKit::WebString
& frame_name
,
411 WebKit::WebNavigationPolicy policy
);
412 virtual WebKit::WebWidget
* createPopupMenu(WebKit::WebPopupType popup_type
);
413 virtual WebKit::WebExternalPopupMenu
* createExternalPopupMenu(
414 const WebKit::WebPopupMenuInfo
& popup_menu_info
,
415 WebKit::WebExternalPopupMenuClient
* popup_menu_client
);
416 virtual WebKit::WebStorageNamespace
* createSessionStorageNamespace(
418 virtual void didAddMessageToConsole(
419 const WebKit::WebConsoleMessage
& message
,
420 const WebKit::WebString
& source_name
,
421 unsigned source_line
);
422 virtual void printPage(WebKit::WebFrame
* frame
);
423 virtual WebKit::WebNotificationPresenter
* notificationPresenter();
424 virtual bool enumerateChosenDirectory(
425 const WebKit::WebString
& path
,
426 WebKit::WebFileChooserCompletion
* chooser_completion
);
427 virtual void initializeHelperPluginWebFrame(WebKit::WebHelperPlugin
*);
428 virtual void didStartLoading();
429 virtual void didStopLoading();
430 virtual void didChangeLoadProgress(WebKit::WebFrame
* frame
,
431 double load_progress
);
432 virtual void didCancelCompositionOnSelectionChange();
433 virtual void didChangeSelection(bool is_selection_empty
);
434 virtual void didExecuteCommand(const WebKit::WebString
& command_name
);
435 virtual bool handleCurrentKeyboardEvent();
436 virtual WebKit::WebColorChooser
* createColorChooser(
437 WebKit::WebColorChooserClient
*, const WebKit::WebColor
& initial_color
);
438 virtual bool runFileChooser(
439 const WebKit::WebFileChooserParams
& params
,
440 WebKit::WebFileChooserCompletion
* chooser_completion
);
441 virtual void runModalAlertDialog(WebKit::WebFrame
* frame
,
442 const WebKit::WebString
& message
);
443 virtual bool runModalConfirmDialog(WebKit::WebFrame
* frame
,
444 const WebKit::WebString
& message
);
445 virtual bool runModalPromptDialog(WebKit::WebFrame
* frame
,
446 const WebKit::WebString
& message
,
447 const WebKit::WebString
& default_value
,
448 WebKit::WebString
* actual_value
);
449 virtual bool runModalBeforeUnloadDialog(WebKit::WebFrame
* frame
,
450 const WebKit::WebString
& message
);
451 virtual void showContextMenu(WebKit::WebFrame
* frame
,
452 const WebKit::WebContextMenuData
& data
);
453 virtual void setStatusText(const WebKit::WebString
& text
);
454 virtual void setMouseOverURL(const WebKit::WebURL
& url
);
455 virtual void setKeyboardFocusURL(const WebKit::WebURL
& url
);
456 virtual void startDragging(WebKit::WebFrame
* frame
,
457 const WebKit::WebDragData
& data
,
458 WebKit::WebDragOperationsMask mask
,
459 const WebKit::WebImage
& image
,
460 const WebKit::WebPoint
& imageOffset
);
461 virtual bool acceptsLoadDrops();
462 virtual void focusNext();
463 virtual void focusPrevious();
464 virtual void focusedNodeChanged(const WebKit::WebNode
& node
);
465 virtual void numberOfWheelEventHandlersChanged(unsigned num_handlers
);
466 virtual void didUpdateLayout();
467 #if defined(OS_ANDROID)
468 virtual bool didTapMultipleTargets(
469 const WebKit::WebGestureEvent
& event
,
470 const WebKit::WebVector
<WebKit::WebRect
>& target_rects
);
472 virtual void navigateBackForwardSoon(int offset
);
473 virtual int historyBackListCount();
474 virtual int historyForwardListCount();
475 virtual void postAccessibilityNotification(
476 const WebKit::WebAccessibilityObject
& obj
,
477 WebKit::WebAccessibilityNotification notification
);
478 virtual void didUpdateInspectorSetting(const WebKit::WebString
& key
,
479 const WebKit::WebString
& value
);
480 virtual WebKit::WebGeolocationClient
* geolocationClient();
481 virtual WebKit::WebSpeechInputController
* speechInputController(
482 WebKit::WebSpeechInputListener
* listener
);
483 virtual WebKit::WebSpeechRecognizer
* speechRecognizer();
484 virtual WebKit::WebDeviceOrientationClient
* deviceOrientationClient();
485 virtual void zoomLimitsChanged(double minimum_level
, double maximum_level
);
486 virtual void zoomLevelChanged();
487 virtual void registerProtocolHandler(const WebKit::WebString
& scheme
,
488 const WebKit::WebString
& base_url
,
489 const WebKit::WebString
& url
,
490 const WebKit::WebString
& title
);
491 virtual WebKit::WebPageVisibilityState
visibilityState() const;
492 virtual WebKit::WebUserMediaClient
* userMediaClient();
493 virtual void draggableRegionsChanged();
495 #if defined(OS_ANDROID)
496 virtual void scheduleContentIntent(const WebKit::WebURL
& intent
);
497 virtual void cancelScheduledContentIntents();
498 virtual WebKit::WebContentDetectionResult
detectContentAround(
499 const WebKit::WebHitTestResult
& touch_hit
);
501 // Only used on Android since all other platforms implement
502 // date and time input fields using MULTIPLE_FIELDS_UI
503 virtual bool openDateTimeChooser(const WebKit::WebDateTimeChooserParams
&,
504 WebKit::WebDateTimeChooserCompletion
*);
507 // WebKit::WebFrameClient implementation -------------------------------------
509 virtual WebKit::WebPlugin
* createPlugin(
510 WebKit::WebFrame
* frame
,
511 const WebKit::WebPluginParams
& params
);
512 virtual WebKit::WebSharedWorker
* createSharedWorker(
513 WebKit::WebFrame
* frame
, const WebKit::WebURL
& url
,
514 const WebKit::WebString
& name
, unsigned long long documentId
);
515 virtual WebKit::WebMediaPlayer
* createMediaPlayer(
516 WebKit::WebFrame
* frame
,
517 const WebKit::WebURL
& url
,
518 WebKit::WebMediaPlayerClient
* client
);
519 virtual WebKit::WebApplicationCacheHost
* createApplicationCacheHost(
520 WebKit::WebFrame
* frame
,
521 WebKit::WebApplicationCacheHostClient
* client
);
522 virtual WebKit::WebCookieJar
* cookieJar(WebKit::WebFrame
* frame
);
523 virtual void didCreateFrame(WebKit::WebFrame
* parent
,
524 WebKit::WebFrame
* child
);
525 virtual void didDisownOpener(WebKit::WebFrame
* frame
);
526 virtual void frameDetached(WebKit::WebFrame
* frame
);
527 virtual void willClose(WebKit::WebFrame
* frame
);
528 virtual void didChangeName(WebKit::WebFrame
* frame
,
529 const WebKit::WebString
& name
);
530 virtual void loadURLExternally(WebKit::WebFrame
* frame
,
531 const WebKit::WebURLRequest
& request
,
532 WebKit::WebNavigationPolicy policy
);
533 virtual void loadURLExternally(WebKit::WebFrame
* frame
,
534 const WebKit::WebURLRequest
& request
,
535 WebKit::WebNavigationPolicy policy
,
536 const WebKit::WebString
& suggested_name
);
537 virtual WebKit::WebNavigationPolicy
decidePolicyForNavigation(
538 WebKit::WebFrame
* frame
,
539 const WebKit::WebURLRequest
& request
,
540 WebKit::WebNavigationType type
,
541 const WebKit::WebNode
&,
542 WebKit::WebNavigationPolicy default_policy
,
544 virtual bool canHandleRequest(WebKit::WebFrame
* frame
,
545 const WebKit::WebURLRequest
& request
);
546 virtual WebKit::WebURLError
cannotHandleRequestError(
547 WebKit::WebFrame
* frame
,
548 const WebKit::WebURLRequest
& request
);
549 virtual WebKit::WebURLError
cancelledError(
550 WebKit::WebFrame
* frame
,
551 const WebKit::WebURLRequest
& request
);
552 virtual void unableToImplementPolicyWithError(
553 WebKit::WebFrame
* frame
,
554 const WebKit::WebURLError
& error
);
555 virtual void willSendSubmitEvent(WebKit::WebFrame
* frame
,
556 const WebKit::WebFormElement
& form
);
557 virtual void willSubmitForm(WebKit::WebFrame
* frame
,
558 const WebKit::WebFormElement
& form
);
559 virtual void willPerformClientRedirect(WebKit::WebFrame
* frame
,
560 const WebKit::WebURL
& from
,
561 const WebKit::WebURL
& to
,
564 virtual void didCancelClientRedirect(WebKit::WebFrame
* frame
);
565 virtual void didCompleteClientRedirect(WebKit::WebFrame
* frame
,
566 const WebKit::WebURL
& from
);
567 virtual void didCreateDataSource(WebKit::WebFrame
* frame
,
568 WebKit::WebDataSource
* datasource
);
569 virtual void didStartProvisionalLoad(WebKit::WebFrame
* frame
);
570 virtual void didReceiveServerRedirectForProvisionalLoad(
571 WebKit::WebFrame
* frame
);
572 virtual void didFailProvisionalLoad(WebKit::WebFrame
* frame
,
573 const WebKit::WebURLError
& error
);
574 virtual void didReceiveDocumentData(WebKit::WebFrame
* frame
,
575 const char* data
, size_t length
,
576 bool& prevent_default
);
577 virtual void didCommitProvisionalLoad(WebKit::WebFrame
* frame
,
578 bool is_new_navigation
);
579 virtual void didClearWindowObject(WebKit::WebFrame
* frame
);
580 virtual void didCreateDocumentElement(WebKit::WebFrame
* frame
);
581 virtual void didReceiveTitle(WebKit::WebFrame
* frame
,
582 const WebKit::WebString
& title
,
583 WebKit::WebTextDirection direction
);
584 virtual void didChangeIcon(WebKit::WebFrame
*,
585 WebKit::WebIconURL::Type
) OVERRIDE
;
586 virtual void didFinishDocumentLoad(WebKit::WebFrame
* frame
);
587 virtual void didHandleOnloadEvents(WebKit::WebFrame
* frame
);
588 virtual void didFailLoad(WebKit::WebFrame
* frame
,
589 const WebKit::WebURLError
& error
);
590 virtual void didFinishLoad(WebKit::WebFrame
* frame
);
591 virtual void didNavigateWithinPage(WebKit::WebFrame
* frame
,
592 bool is_new_navigation
);
593 virtual void didUpdateCurrentHistoryItem(WebKit::WebFrame
* frame
);
594 virtual void assignIdentifierToRequest(WebKit::WebFrame
* frame
,
596 const WebKit::WebURLRequest
& request
);
597 virtual void willSendRequest(WebKit::WebFrame
* frame
,
599 WebKit::WebURLRequest
& request
,
600 const WebKit::WebURLResponse
& redirect_response
);
601 virtual void didReceiveResponse(WebKit::WebFrame
* frame
,
603 const WebKit::WebURLResponse
& response
);
604 virtual void didFinishResourceLoad(WebKit::WebFrame
* frame
,
605 unsigned identifier
);
606 virtual void didFailResourceLoad(WebKit::WebFrame
* frame
,
608 const WebKit::WebURLError
& error
);
609 virtual void didLoadResourceFromMemoryCache(
610 WebKit::WebFrame
* frame
,
611 const WebKit::WebURLRequest
& request
,
612 const WebKit::WebURLResponse
&);
613 virtual void didDisplayInsecureContent(WebKit::WebFrame
* frame
);
614 virtual void didRunInsecureContent(
615 WebKit::WebFrame
* frame
,
616 const WebKit::WebSecurityOrigin
& origin
,
617 const WebKit::WebURL
& target
);
618 virtual void didExhaustMemoryAvailableForScript(WebKit::WebFrame
* frame
);
619 virtual void didCreateScriptContext(WebKit::WebFrame
* frame
,
620 v8::Handle
<v8::Context
>,
623 virtual void willReleaseScriptContext(WebKit::WebFrame
* frame
,
624 v8::Handle
<v8::Context
>,
626 virtual void didChangeScrollOffset(WebKit::WebFrame
* frame
);
627 virtual void willInsertBody(WebKit::WebFrame
* frame
) OVERRIDE
;
628 virtual void didFirstVisuallyNonEmptyLayout(WebKit::WebFrame
*) OVERRIDE
;
629 virtual void didChangeContentsSize(WebKit::WebFrame
* frame
,
630 const WebKit::WebSize
& size
);
631 virtual void reportFindInPageMatchCount(int request_id
,
634 virtual void reportFindInPageSelection(int request_id
,
635 int active_match_ordinal
,
636 const WebKit::WebRect
& sel
);
637 virtual void openFileSystem(WebKit::WebFrame
* frame
,
638 WebKit::WebFileSystemType type
,
641 WebKit::WebFileSystemCallbacks
* callbacks
);
642 virtual void deleteFileSystem(WebKit::WebFrame
* frame
,
643 WebKit::WebFileSystemType type
,
644 WebKit::WebFileSystemCallbacks
* callbacks
);
645 virtual void queryStorageUsageAndQuota(
646 WebKit::WebFrame
* frame
,
647 WebKit::WebStorageQuotaType type
,
648 WebKit::WebStorageQuotaCallbacks
* callbacks
);
649 virtual void requestStorageQuota(
650 WebKit::WebFrame
* frame
,
651 WebKit::WebStorageQuotaType type
,
652 unsigned long long requested_size
,
653 WebKit::WebStorageQuotaCallbacks
* callbacks
);
654 virtual void willOpenSocketStream(
655 WebKit::WebSocketStreamHandle
* handle
);
656 virtual void willStartUsingPeerConnectionHandler(WebKit::WebFrame
* frame
,
657 WebKit::WebRTCPeerConnectionHandler
* handler
) OVERRIDE
;
658 virtual bool willCheckAndDispatchMessageEvent(
659 WebKit::WebFrame
* sourceFrame
,
660 WebKit::WebFrame
* targetFrame
,
661 WebKit::WebSecurityOrigin targetOrigin
,
662 WebKit::WebDOMMessageEvent event
) OVERRIDE
;
663 virtual WebKit::WebString
userAgentOverride(
664 WebKit::WebFrame
* frame
,
665 const WebKit::WebURL
& url
) OVERRIDE
;
666 virtual WebKit::WebString
doNotTrackValue(WebKit::WebFrame
* frame
) OVERRIDE
;
667 virtual bool allowWebGL(WebKit::WebFrame
* frame
, bool default_value
) OVERRIDE
;
668 virtual void didLoseWebGLContext(
669 WebKit::WebFrame
* frame
,
670 int arb_robustness_status_code
) OVERRIDE
;
672 // WebKit::WebPageSerializerClient implementation ----------------------------
674 virtual void didSerializeDataForFrame(
675 const WebKit::WebURL
& frame_url
,
676 const WebKit::WebCString
& data
,
677 PageSerializationStatus status
) OVERRIDE
;
679 // RenderView implementation -------------------------------------------------
681 virtual bool Send(IPC::Message
* message
) OVERRIDE
;
682 virtual int GetRoutingID() const OVERRIDE
;
683 virtual int GetPageId() const OVERRIDE
;
684 virtual gfx::Size
GetSize() const OVERRIDE
;
685 virtual webkit_glue::WebPreferences
& GetWebkitPreferences() OVERRIDE
;
686 virtual void SetWebkitPreferences(
687 const webkit_glue::WebPreferences
& preferences
) OVERRIDE
;
688 virtual WebKit::WebView
* GetWebView() OVERRIDE
;
689 virtual WebKit::WebNode
GetFocusedNode() const OVERRIDE
;
690 virtual WebKit::WebNode
GetContextMenuNode() const OVERRIDE
;
691 virtual bool IsEditableNode(const WebKit::WebNode
& node
) const OVERRIDE
;
692 virtual WebKit::WebPlugin
* CreatePlugin(
693 WebKit::WebFrame
* frame
,
694 const webkit::WebPluginInfo
& info
,
695 const WebKit::WebPluginParams
& params
) OVERRIDE
;
696 virtual void EvaluateScript(const string16
& frame_xpath
,
697 const string16
& jscript
,
699 bool notify_result
) OVERRIDE
;
700 virtual bool ShouldDisplayScrollbars(int width
, int height
) const OVERRIDE
;
701 virtual int GetEnabledBindings() const OVERRIDE
;
702 virtual bool GetContentStateImmediately() const OVERRIDE
;
703 virtual float GetFilteredTimePerFrame() const OVERRIDE
;
704 virtual int ShowContextMenu(ContextMenuClient
* client
,
705 const ContextMenuParams
& params
) OVERRIDE
;
706 virtual void CancelContextMenu(int request_id
) OVERRIDE
;
707 virtual WebKit::WebPageVisibilityState
GetVisibilityState() const OVERRIDE
;
708 virtual void RunModalAlertDialog(WebKit::WebFrame
* frame
,
709 const WebKit::WebString
& message
) OVERRIDE
;
710 virtual void LoadURLExternally(
711 WebKit::WebFrame
* frame
,
712 const WebKit::WebURLRequest
& request
,
713 WebKit::WebNavigationPolicy policy
) OVERRIDE
;
714 virtual void Repaint(const gfx::Size
& size
) OVERRIDE
;
715 virtual void SetEditCommandForNextKeyEvent(const std::string
& name
,
716 const std::string
& value
) OVERRIDE
;
717 virtual void ClearEditCommands() OVERRIDE
;
718 virtual SSLStatus
GetSSLStatusOfFrame(WebKit::WebFrame
* frame
) const OVERRIDE
;
719 #if defined(OS_ANDROID)
720 virtual skia::RefPtr
<SkPicture
> CapturePicture() OVERRIDE
;
723 // webkit_glue::WebPluginPageDelegate implementation -------------------------
725 virtual webkit::npapi::WebPluginDelegate
* CreatePluginDelegate(
726 const base::FilePath
& file_path
,
727 const std::string
& mime_type
) OVERRIDE
;
728 virtual WebKit::WebPlugin
* CreatePluginReplacement(
729 const base::FilePath
& file_path
) OVERRIDE
;
730 virtual void CreatedPluginWindow(gfx::PluginWindowHandle handle
) OVERRIDE
;
731 virtual void WillDestroyPluginWindow(gfx::PluginWindowHandle handle
) OVERRIDE
;
732 virtual void DidMovePlugin(
733 const webkit::npapi::WebPluginGeometry
& move
) OVERRIDE
;
734 virtual void DidStartLoadingForPlugin() OVERRIDE
;
735 virtual void DidStopLoadingForPlugin() OVERRIDE
;
736 virtual WebKit::WebCookieJar
* GetCookieJar() OVERRIDE
;
738 // webkit_media::WebMediaPlayerDelegate implementation -----------------------
740 virtual void DidPlay(WebKit::WebMediaPlayer
* player
) OVERRIDE
;
741 virtual void DidPause(WebKit::WebMediaPlayer
* player
) OVERRIDE
;
742 virtual void PlayerGone(WebKit::WebMediaPlayer
* player
) OVERRIDE
;
744 // Please do not add your stuff randomly to the end here. If there is an
745 // appropriate section, add it there. If not, there are some random functions
746 // nearer to the top you can add it to.
748 // Cannot use std::set unfortunately since linked_ptr<> does not support
750 typedef std::vector
<linked_ptr
<webkit_glue::ImageResourceFetcher
> >
751 ImageResourceFetcherList
;
754 // RenderWidget overrides:
755 virtual void Close() OVERRIDE
;
756 virtual void OnResize(const gfx::Size
& new_size
,
757 const gfx::Size
& physical_backing_size
,
758 float overdraw_bottom_height
,
759 const gfx::Rect
& resizer_rect
,
760 bool is_fullscreen
) OVERRIDE
;
761 virtual void WillInitiatePaint() OVERRIDE
;
762 virtual void DidInitiatePaint() OVERRIDE
;
763 virtual void DidFlushPaint() OVERRIDE
;
764 virtual webkit::ppapi::PluginInstance
* GetBitmapForOptimizedPluginPaint(
765 const gfx::Rect
& paint_bounds
,
769 float* scale_factor
) OVERRIDE
;
770 virtual gfx::Vector2d
GetScrollOffset() OVERRIDE
;
771 virtual void DidHandleKeyEvent() OVERRIDE
;
772 virtual bool WillHandleMouseEvent(
773 const WebKit::WebMouseEvent
& event
) OVERRIDE
;
774 virtual bool WillHandleGestureEvent(
775 const WebKit::WebGestureEvent
& event
) OVERRIDE
;
776 virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent
& event
) OVERRIDE
;
777 virtual void DidHandleTouchEvent(const WebKit::WebTouchEvent
& event
) OVERRIDE
;
778 virtual bool HasTouchEventHandlersAt(const gfx::Point
& point
) const OVERRIDE
;
779 virtual void OnSetFocus(bool enable
) OVERRIDE
;
780 virtual void OnWasHidden() OVERRIDE
;
781 virtual void OnWasShown(bool needs_repainting
) OVERRIDE
;
782 virtual GURL
GetURLForGraphicsContext3D() OVERRIDE
;
783 virtual bool ForceCompositingModeEnabled() OVERRIDE
;
784 virtual void OnImeSetComposition(
785 const string16
& text
,
786 const std::vector
<WebKit::WebCompositionUnderline
>& underlines
,
788 int selection_end
) OVERRIDE
;
789 virtual void OnImeConfirmComposition(
790 const string16
& text
, const ui::Range
& replacement_range
) OVERRIDE
;
791 virtual void SetDeviceScaleFactor(float device_scale_factor
) OVERRIDE
;
792 virtual ui::TextInputType
GetTextInputType() OVERRIDE
;
793 virtual void GetSelectionBounds(gfx::Rect
* start
, gfx::Rect
* end
) OVERRIDE
;
794 virtual void GetCompositionCharacterBounds(
795 std::vector
<gfx::Rect
>* character_bounds
) OVERRIDE
;
796 virtual bool CanComposeInline() OVERRIDE
;
797 virtual void DidCommitCompositorFrame() OVERRIDE
;
798 virtual void InstrumentWillBeginFrame() OVERRIDE
;
799 virtual void InstrumentDidBeginFrame() OVERRIDE
;
800 virtual void InstrumentDidCancelFrame() OVERRIDE
;
801 virtual void InstrumentWillComposite() OVERRIDE
;
802 virtual bool AllowPartialSwap() const OVERRIDE
;
805 explicit RenderViewImpl(RenderViewImplParams
* params
);
807 void Initialize(RenderViewImplParams
* params
);
809 // Do not delete directly. This class is reference counted.
810 virtual ~RenderViewImpl();
814 friend class ExternalPopupMenuTest
;
815 friend class PepperDeviceTest
;
816 friend class RendererAccessibilityTest
;
817 friend class RenderViewTest
;
819 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuRemoveTest
, RemoveOnChange
);
820 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest
, NormalCase
);
821 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest
, ShowPopupThenNavigate
);
822 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, DecideNavigationPolicyForWebUI
);
823 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
,
824 DontIgnoreBackAfterNavEntryLimit
);
825 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, ImeComposition
);
826 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, InsertCharacters
);
827 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, JSBlockSentAfterPageLoad
);
828 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, LastCommittedUpdateState
);
829 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, OnExtendSelectionAndDelete
);
830 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, OnHandleKeyboardEvent
);
831 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, OnImeStateChanged
);
832 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, OnNavStateChanged
);
833 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, OnSetTextDirection
);
834 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, OnUpdateWebPreferences
);
835 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, SendSwapOutACK
);
836 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, ReloadWhileSwappedOut
);
837 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
,
838 SetEditableSelectionAndComposition
);
839 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, StaleNavigationsIgnored
);
840 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, UpdateTargetURLWithInvalidURL
);
841 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
,
842 GetCompositionCharacterBoundsTest
);
843 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, OnNavigationHttpPost
);
844 #if defined(OS_MACOSX)
845 FRIEND_TEST_ALL_PREFIXES(RenderViewTest
, MacTestCmdUp
);
847 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, SetHistoryLengthAndPrune
);
848 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, ZoomLimit
);
849 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, NavigateFrame
);
850 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
,
851 ShouldUpdateSelectionTextFromContextMenuParams
);
853 typedef std::map
<GURL
, double> HostZoomLevels
;
861 void UpdateURL(WebKit::WebFrame
* frame
);
862 void UpdateTitle(WebKit::WebFrame
* frame
, const string16
& title
,
863 WebKit::WebTextDirection title_direction
);
864 void UpdateSessionHistory(WebKit::WebFrame
* frame
);
865 void SendUpdateState(const WebKit::WebHistoryItem
& item
);
867 // Update current main frame's encoding and send it to browser window.
868 // Since we want to let users see the right encoding info from menu
869 // before finishing loading, we call the UpdateEncoding in
870 // a) function:DidCommitLoadForFrame. When this function is called,
871 // that means we have got first data. In here we try to get encoding
872 // of page if it has been specified in http header.
873 // b) function:DidReceiveTitle. When this function is called,
874 // that means we have got specified title. Because in most of webpages,
875 // title tags will follow meta tags. In here we try to get encoding of
876 // page if it has been specified in meta tag.
877 // c) function:DidFinishDocumentLoadForFrame. When this function is
878 // called, that means we have got whole html page. In here we should
879 // finally get right encoding of page.
880 void UpdateEncoding(WebKit::WebFrame
* frame
,
881 const std::string
& encoding_name
);
883 void OpenURL(WebKit::WebFrame
* frame
,
885 const Referrer
& referrer
,
886 WebKit::WebNavigationPolicy policy
);
888 bool RunJavaScriptMessage(JavaScriptMessageType type
,
889 const string16
& message
,
890 const string16
& default_value
,
891 const GURL
& frame_url
,
894 // Sends a message and runs a nested message loop.
895 bool SendAndRunNestedMessageLoop(IPC::SyncMessage
* message
);
897 // Called when the "pinned to left/right edge" state needs to be updated.
898 void UpdateScrollState(WebKit::WebFrame
* frame
);
900 // IPC message handlers ------------------------------------------------------
902 // The documentation for these functions should be in
903 // render_messages_internal.h for the message that the function is handling.
905 void OnAllowBindings(int enabled_bindings_flags
);
906 void OnAllowScriptToClose(bool script_can_close
);
907 void OnAsyncFileOpened(base::PlatformFileError error_code
,
908 IPC::PlatformFileForTransit file_for_transit
,
910 void OnPpapiBrokerChannelCreated(int request_id
,
911 base::ProcessId broker_pid
,
912 const IPC::ChannelHandle
& handle
);
913 void OnPpapiBrokerPermissionResult(int request_id
, bool result
);
914 void OnCancelDownload(int32 download_id
);
915 void OnClearFocusedNode();
917 void OnContextMenuClosed(const CustomContextMenuContext
& custom_context
);
919 void OnCopyImageAt(int x
, int y
);
921 void OnCSSInsertRequest(const string16
& frame_xpath
,
922 const std::string
& css
);
923 void OnCustomContextMenuAction(const CustomContextMenuContext
& custom_context
,
926 void OnSetName(const std::string
& name
);
927 void OnDeterminePageLanguage();
928 void OnDisableScrollbarsForSmallWindows(
929 const gfx::Size
& disable_scrollbars_size_limit
);
930 void OnDisassociateFromPopupCount();
931 void OnDragSourceEndedOrMoved(const gfx::Point
& client_point
,
932 const gfx::Point
& screen_point
,
934 WebKit::WebDragOperation drag_operation
);
935 void OnDragSourceSystemDragEnded();
936 void OnDragTargetDrop(const gfx::Point
& client_pt
,
937 const gfx::Point
& screen_pt
,
939 void OnDragTargetDragEnter(const WebDropData
& drop_data
,
940 const gfx::Point
& client_pt
,
941 const gfx::Point
& screen_pt
,
942 WebKit::WebDragOperationsMask operations_allowed
,
944 void OnDragTargetDragLeave();
945 void OnDragTargetDragOver(const gfx::Point
& client_pt
,
946 const gfx::Point
& screen_pt
,
947 WebKit::WebDragOperationsMask operations_allowed
,
949 void OnEnablePreferredSizeChangedMode();
950 void OnEnableAutoResize(const gfx::Size
& min_size
, const gfx::Size
& max_size
);
951 void OnDisableAutoResize(const gfx::Size
& new_size
);
952 void OnEnumerateDirectoryResponse(int id
,
953 const std::vector
<base::FilePath
>& paths
);
954 void OnExecuteEditCommand(const std::string
& name
, const std::string
& value
);
955 void OnExtendSelectionAndDelete(int before
, int after
);
956 void OnFileChooserResponse(
957 const std::vector
<ui::SelectedFileInfo
>& files
);
958 void OnFind(int request_id
, const string16
&, const WebKit::WebFindOptions
&);
959 void OnGetAllSavableResourceLinksForCurrentPage(const GURL
& page_url
);
960 void OnGetSerializedHtmlDataForCurrentPageWithLocalLinks(
961 const std::vector
<GURL
>& links
,
962 const std::vector
<base::FilePath
>& local_paths
,
963 const base::FilePath
& local_directory_name
);
964 void OnMediaPlayerActionAt(const gfx::Point
& location
,
965 const WebKit::WebMediaPlayerAction
& action
);
967 // Screen has rotated. 0 = default (portrait), 90 = one turn right, and so on.
968 void OnOrientationChangeEvent(int orientation
);
970 void OnPluginActionAt(const gfx::Point
& location
,
971 const WebKit::WebPluginAction
& action
);
972 void OnMoveOrResizeStarted();
973 void OnNavigate(const ViewMsg_Navigate_Params
& params
);
975 void OnPasteAndMatchStyle();
976 void OnPostMessageEvent(const ViewMsg_PostMessage_Params
& params
);
978 void OnReleaseDisambiguationPopupDIB(TransportDIB::Handle dib_handle
);
979 void OnReloadFrame();
980 void OnReplace(const string16
& text
);
981 void OnReplaceMisspelling(const string16
& text
);
982 void OnResetPageEncodingToDefault();
983 void OnScriptEvalRequest(const string16
& frame_xpath
,
984 const string16
& jscript
,
988 void OnSelectRange(const gfx::Point
& start
, const gfx::Point
& end
);
989 void OnMoveCaret(const gfx::Point
& point
);
990 void OnSetAccessibilityMode(AccessibilityMode new_mode
);
991 void OnSetActive(bool active
);
992 void OnSetAltErrorPageURL(const GURL
& gurl
);
993 void OnSetBackground(const SkBitmap
& background
);
994 void OnSetCompositionFromExistingText(
996 const std::vector
<WebKit::WebCompositionUnderline
>& underlines
);
997 void OnSetEditableSelectionOffsets(int start
, int end
);
998 void OnSetWebUIProperty(const std::string
& name
, const std::string
& value
);
999 void OnSetEditCommandsForNextKeyEvent(const EditCommands
& edit_commands
);
1000 void OnSetHistoryLengthAndPrune(int history_length
, int32 minimum_page_id
);
1001 void OnSetInitialFocus(bool reverse
);
1002 void OnScrollFocusedEditableNodeIntoRect(const gfx::Rect
& rect
);
1003 void OnSetPageEncoding(const std::string
& encoding_name
);
1004 void OnSetRendererPrefs(const RendererPreferences
& renderer_prefs
);
1005 void OnSetZoomLevel(double zoom_level
);
1006 void OnSetZoomLevelForLoadingURL(const GURL
& url
, double zoom_level
);
1007 void OnExitFullscreen();
1008 void OnShouldClose();
1010 void OnStopFinding(StopFindAction action
);
1011 void OnSwapOut(const ViewMsg_SwapOut_Params
& params
);
1012 void OnThemeChanged();
1014 void OnUpdateTargetURLAck();
1015 void OnUpdateTimezone();
1016 void OnUpdateWebPreferences(const webkit_glue::WebPreferences
& prefs
);
1019 void OnZoom(PageZoom zoom
);
1020 void OnZoomFactor(PageZoom zoom
, int zoom_center_x
, int zoom_center_y
);
1022 void OnEnableViewSourceMode();
1024 void OnJavaBridgeInit();
1026 void OnDisownOpener();
1027 void OnUpdatedFrameTree(int process_id
,
1029 const std::string
& frame_tree
);
1031 #if defined(OS_ANDROID)
1032 void OnActivateNearestFindResult(int request_id
, float x
, float y
);
1033 void OnFindMatchRects(int current_version
);
1034 void OnSelectPopupMenuItems(bool canceled
,
1035 const std::vector
<int>& selected_indices
);
1036 void OnUndoScrollFocusedEditableNodeIntoRect();
1037 void OnUpdateTopControlsState(bool enable_hiding
,
1038 bool enable_showing
,
1040 #elif defined(OS_MACOSX)
1041 void OnCopyToFindPboard();
1042 void OnPluginImeCompositionCompleted(const string16
& text
, int plugin_id
);
1043 void OnSelectPopupMenuItem(int selected_index
);
1044 void OnSetInLiveResize(bool in_live_resize
);
1045 void OnSetWindowVisibility(bool visible
);
1046 void OnWindowFrameChanged(const gfx::Rect
& window_frame
,
1047 const gfx::Rect
& view_frame
);
1050 void OnWindowSnapshotCompleted(const int snapshot_id
,
1051 const gfx::Size
& size
, const std::vector
<unsigned char>& png
);
1054 // Adding a new message handler? Please add it in alphabetical order above
1055 // and put it in the same position in the .cc file.
1057 // Misc private functions ----------------------------------------------------
1058 void ZoomFactorHelper(PageZoom zoom
, int zoom_center_x
, int zoom_center_y
,
1059 float scaling_increment
);
1061 void AltErrorPageFinished(WebKit::WebFrame
* frame
,
1062 const WebKit::WebURLError
& original_error
,
1063 const std::string
& html
);
1065 // Check whether the preferred size has changed.
1066 void CheckPreferredSize();
1068 // This method walks the entire frame tree for this RenderView and sends an
1069 // update to the browser process as described in the
1070 // ViewHostMsg_FrameTreeUpdated comments. If |exclude_frame_subtree|
1071 // frame is non-NULL, the subtree starting at that frame not included in the
1073 // This is used when a frame is going to be removed from the tree.
1074 void SendUpdatedFrameTree(WebKit::WebFrame
* exclude_frame_subtree
);
1076 // Recursively creates a DOM frame tree starting with |frame|, based on
1077 // |frame_tree|. For each node, the frame is navigated to the swapped out URL,
1078 // the name (if present) is set on it, and all the subframes are created
1079 // and added to the DOM.
1080 void CreateFrameTree(WebKit::WebFrame
* frame
,
1081 base::DictionaryValue
* frame_tree
);
1083 // If this is a swapped out RenderView, which maintains a copy of the frame
1084 // tree of an active RenderView, we keep a map from frame ids in this view to
1085 // the frame ids of the active view for each corresponding frame.
1086 // This method returns the frame in this RenderView that corresponds to the
1087 // frame in the active RenderView specified by |remote_frame_id|.
1088 WebKit::WebFrame
* GetFrameByRemoteID(int remote_frame_id
);
1090 void EnsureMediaStreamImpl();
1092 // This callback is triggered when DownloadFavicon completes, either
1093 // succesfully or with a failure. See DownloadFavicon for more
1095 void DidDownloadFavicon(webkit_glue::ImageResourceFetcher
* fetcher
,
1096 const SkBitmap
& image
);
1098 // Requests to download a favicon image. When done, the RenderView is notified
1099 // by way of DidDownloadFavicon. Returns true if the request was successfully
1100 // started, false otherwise. id is used to uniquely identify the request and
1101 // passed back to the DidDownloadFavicon method. If the image has multiple
1102 // frames, the frame whose size is image_size is returned. If the image
1103 // doesn't have a frame at the specified size, the first is returned.
1104 bool DownloadFavicon(int id
, const GURL
& image_url
, int image_size
);
1106 GURL
GetAlternateErrorPageURL(const GURL
& failed_url
,
1107 ErrorPageType error_type
);
1109 // Locates a sub frame with given xpath
1110 WebKit::WebFrame
* GetChildFrame(const string16
& frame_xpath
) const;
1112 // Returns the URL being loaded by the given frame's request.
1113 GURL
GetLoadingUrl(WebKit::WebFrame
* frame
) const;
1115 // Should only be called if this object wraps a PluginDocument.
1116 WebKit::WebPlugin
* GetWebPluginFromPluginDocument();
1118 // Returns true if the |params| navigation is to an entry that has been
1119 // cropped due to a recent navigation the browser did not know about.
1120 bool IsBackForwardToStaleEntry(const ViewMsg_Navigate_Params
& params
,
1123 bool MaybeLoadAlternateErrorPage(WebKit::WebFrame
* frame
,
1124 const WebKit::WebURLError
& error
,
1127 // Make this RenderView show an empty, unscriptable page.
1128 void NavigateToSwappedOutURL(WebKit::WebFrame
* frame
);
1130 // If we initiated a navigation, this function will populate |document_state|
1131 // with the navigation information saved in OnNavigate().
1132 void PopulateDocumentStateFromPending(DocumentState
* document_state
);
1134 // Returns a new NavigationState populated with the navigation information
1135 // saved in OnNavigate().
1136 NavigationState
* CreateNavigationStateFromPending();
1138 // Processes the command-line flags --enable-viewport,
1139 // --enable-fixed-layout[=w,h] and --enable-pinch.
1140 void ProcessViewLayoutFlags(const CommandLine
& command_line
);
1142 #if defined(OS_ANDROID)
1143 // Launch an Android content intent with the given URL.
1144 void LaunchAndroidContentIntent(const GURL
& intent_url
, size_t request_id
);
1147 // Sends a reply to the current find operation handling if it was a
1148 // synchronous find request.
1149 void SendFindReply(int request_id
,
1152 const WebKit::WebRect
& selection_rect
,
1153 bool final_status_update
);
1155 // Returns whether |params.selection_text| should be synchronized to the
1156 // browser before bringing up the context menu. Static for testing.
1157 static bool ShouldUpdateSelectionTextFromContextMenuParams(
1158 const string16
& selection_text
,
1159 size_t selection_text_offset
,
1160 const ui::Range
& selection_range
,
1161 const ContextMenuParams
& params
);
1163 // Starts nav_state_sync_timer_ if it isn't already running.
1164 void StartNavStateSyncTimerIfNecessary();
1166 // Dispatches the current state of selection on the webpage to the browser if
1168 // TODO(varunjain): delete this method once we figure out how to keep
1169 // selection handles in sync with the webpage.
1170 void SyncSelectionIfRequired();
1172 #if defined(OS_POSIX) && !defined(OS_MACOSX)
1173 void UpdateFontRenderingFromRendererPrefs();
1175 void UpdateFontRenderingFromRendererPrefs() {}
1178 // Update the target url and tell the browser that the target URL has changed.
1179 // If |url| is empty, show |fallback_url|.
1180 void UpdateTargetURL(const GURL
& url
, const GURL
& fallback_url
);
1182 // Tells the browser what the new list of favicons for the webpage is.
1183 void SendUpdateFaviconURL(const std::vector
<FaviconURL
>& urls
);
1185 // Invoked from DidStopLoading(). Sends the current list of loaded favicons to
1187 void DidStopLoadingIcons();
1189 // Coordinate conversion -----------------------------------------------------
1191 gfx::RectF
ClientRectToPhysicalWindowRect(const gfx::RectF
& rect
) const;
1193 // ---------------------------------------------------------------------------
1194 // ADDING NEW FUNCTIONS? Please keep private functions alphabetized and put
1195 // it in the same order in the .cc file as it was in the header.
1196 // ---------------------------------------------------------------------------
1198 // Settings ------------------------------------------------------------------
1200 webkit_glue::WebPreferences webkit_preferences_
;
1201 RendererPreferences renderer_preferences_
;
1203 HostZoomLevels host_zoom_levels_
;
1205 // Whether content state (such as form state, scroll position and page
1206 // contents) should be sent to the browser immediately. This is normally
1207 // false, but set to true by some tests.
1208 bool send_content_state_immediately_
;
1210 // Bitwise-ORed set of extra bindings that have been enabled. See
1211 // BindingsPolicy for details.
1212 int enabled_bindings_
;
1214 // The alternate error page URL, if one exists.
1215 GURL alternate_error_page_url_
;
1217 // If true, we send IPC messages when |preferred_size_| changes.
1218 bool send_preferred_size_changes_
;
1220 // If non-empty, and |send_preferred_size_changes_| is true, disable drawing
1221 // scroll bars on windows smaller than this size. Used for windows that the
1222 // browser resizes to the size of the content, such as browser action popups.
1223 // If a render view is set to the minimum size of its content, webkit may add
1224 // scroll bars. This makes sense for fixed sized windows, but it does not
1225 // make sense when the size of the view was chosen to fit the content.
1226 // This setting ensures that no scroll bars are drawn. The size limit exists
1227 // because if the view grows beyond a size known to the browser, scroll bars
1229 gfx::Size disable_scrollbars_size_limit_
;
1231 // Loading state -------------------------------------------------------------
1233 // True if the top level frame is currently being loaded.
1236 // The gesture that initiated the current navigation.
1237 NavigationGesture navigation_gesture_
;
1240 bool opened_by_user_gesture_
;
1242 // Whether this RenderView was created by a frame that was suppressing its
1243 // opener. If so, we may want to load pages in a separate process. See
1244 // decidePolicyForNavigation for details.
1245 bool opener_suppressed_
;
1247 // If we are handling a top-level client-side redirect, this tracks the URL
1248 // of the page that initiated it. Specifically, when a load is committed this
1249 // is used to determine if that load originated from a client-side redirect.
1250 // It is empty if there is no top-level client-side redirect.
1251 Referrer completed_client_redirect_src_
;
1253 // Holds state pertaining to a navigation that we initiated. This is held by
1254 // the WebDataSource::ExtraData attribute. We use pending_navigation_state_
1255 // as a temporary holder for the state until the WebDataSource corresponding
1256 // to the new navigation is created. See DidCreateDataSource.
1257 scoped_ptr
<ViewMsg_Navigate_Params
> pending_navigation_params_
;
1259 // Timer used to delay the updating of nav state (see SyncNavigationState).
1260 base::OneShotTimer
<RenderViewImpl
> nav_state_sync_timer_
;
1262 // Page IDs ------------------------------------------------------------------
1263 // See documentation in RenderView.
1266 // Indicates the ID of the last page that we sent a FrameNavigate to the
1267 // browser for. This is used to determine if the most recent transition
1268 // generated a history entry (less than page_id_), or not (equal to or
1269 // greater than). Note that this will be greater than page_id_ if the user
1271 int32 last_page_id_sent_to_browser_
;
1273 // The next available page ID to use for this RenderView. These IDs are
1274 // specific to a given RenderView and the frames within it.
1275 int32 next_page_id_
;
1277 // The offset of the current item in the history list.
1278 int history_list_offset_
;
1280 // The RenderView's current impression of the history length. This includes
1281 // any items that have committed in this process, but because of cross-process
1282 // navigations, the history may have some entries that were committed in other
1283 // processes. We won't know about them until the next navigation in this
1285 int history_list_length_
;
1287 // The list of page IDs for each history item this RenderView knows about.
1288 // Some entries may be -1 if they were rendered by other processes or were
1289 // restored from a previous session. This lets us detect attempts to
1290 // navigate to stale entries that have been cropped from our history.
1291 std::vector
<int32
> history_page_ids_
;
1293 // Page info -----------------------------------------------------------------
1295 // The last gotten main frame's encoding.
1296 std::string last_encoding_name_
;
1298 // UI state ------------------------------------------------------------------
1300 // The state of our target_url transmissions. When we receive a request to
1301 // send a URL to the browser, we set this to TARGET_INFLIGHT until an ACK
1302 // comes back - if a new request comes in before the ACK, we store the new
1303 // URL in pending_target_url_ and set the status to TARGET_PENDING. If an
1304 // ACK comes back and we are in TARGET_PENDING, we send the stored URL and
1305 // revert to TARGET_INFLIGHT.
1307 // We don't need a queue of URLs to send, as only the latest is useful.
1310 TARGET_INFLIGHT
, // We have a request in-flight, waiting for an ACK
1311 TARGET_PENDING
// INFLIGHT + we have a URL waiting to be sent
1312 } target_url_status_
;
1314 // The URL we show the user in the status bar. We use this to determine if we
1315 // want to send a new one (we do not need to send duplicates). It will be
1316 // equal to either |mouse_over_url_| or |focus_url_|, depending on which was
1320 // The URL the user's mouse is hovering over.
1321 GURL mouse_over_url_
;
1323 // The URL that has keyboard focus.
1326 // The next target URL we want to send to the browser.
1327 GURL pending_target_url_
;
1329 // The text selection the last time DidChangeSelection got called. May contain
1330 // additional characters before and after the selected text, for IMEs. The
1331 // portion of this string that is the actual selected text starts at index
1332 // |selection_range_.GetMin() - selection_text_offset_| and has length
1333 // |selection_range_.length()|.
1334 string16 selection_text_
;
1335 // The offset corresponding to the start of |selection_text_| in the document.
1336 size_t selection_text_offset_
;
1337 // Range over the document corresponding to the actual selected text (which
1338 // could correspond to a substring of |selection_text_|; see above).
1339 ui::Range selection_range_
;
1341 // External context menu requests we're waiting for. "Internal"
1342 // (WebKit-originated) context menu events will have an ID of 0 and will not
1345 // We don't want to add internal ones since some of the "special" page
1346 // handlers in the browser process just ignore the context menu requests so
1347 // avoid showing context menus, and so this will cause right clicks to leak
1348 // entries in this map. Most users of the custom context menu (e.g. Pepper
1349 // plugins) are normally only on "regular" pages and the regular pages will
1350 // always respond properly to the request, so we don't have to worry so
1351 // much about leaks.
1352 IDMap
<ContextMenuClient
, IDMapExternalPointer
> pending_context_menus_
;
1354 // View ----------------------------------------------------------------------
1356 // Cache the preferred size of the page in order to prevent sending the IPC
1357 // when layout() recomputes but doesn't actually change sizes.
1358 gfx::Size preferred_size_
;
1360 // Used to delay determining the preferred size (to avoid intermediate
1361 // states for the sizes).
1362 base::OneShotTimer
<RenderViewImpl
> check_preferred_size_timer_
;
1364 // These store the "is main frame is scrolled all the way to the left
1365 // or right" state that was last sent to the browser.
1366 bool cached_is_main_frame_pinned_to_left_
;
1367 bool cached_is_main_frame_pinned_to_right_
;
1369 // These store the "has scrollbars" state last sent to the browser.
1370 bool cached_has_main_frame_horizontal_scrollbar_
;
1371 bool cached_has_main_frame_vertical_scrollbar_
;
1373 // Helper objects ------------------------------------------------------------
1375 RendererWebCookieJarImpl cookie_jar_
;
1377 // The next group of objects all implement RenderViewObserver, so are deleted
1378 // along with the RenderView automatically. This is why we just store
1381 // Holds a reference to the service which provides desktop notifications.
1382 NotificationProvider
* notification_provider_
;
1384 // The geolocation dispatcher attached to this view, lazily initialized.
1385 GeolocationDispatcher
* geolocation_dispatcher_
;
1387 // The speech dispatcher attached to this view, lazily initialized.
1388 InputTagSpeechDispatcher
* input_tag_speech_dispatcher_
;
1390 // The speech recognition dispatcher attached to this view, lazily
1392 SpeechRecognitionDispatcher
* speech_recognition_dispatcher_
;
1394 // Device orientation dispatcher attached to this view; lazily initialized.
1395 DeviceOrientationDispatcher
* device_orientation_dispatcher_
;
1397 // MediaStream dispatcher attached to this view; lazily initialized.
1398 MediaStreamDispatcher
* media_stream_dispatcher_
;
1400 // BrowserPluginManager attached to this view; lazily initialized.
1401 scoped_refptr
<BrowserPluginManager
> browser_plugin_manager_
;
1403 // MediaStreamImpl attached to this view; lazily initialized.
1404 MediaStreamImpl
* media_stream_impl_
;
1406 DevToolsAgent
* devtools_agent_
;
1408 // The current accessibility mode.
1409 AccessibilityMode accessibility_mode_
;
1411 // Only valid if |accessibility_mode_| is anything other than
1412 // AccessibilityModeOff.
1413 RendererAccessibility
* renderer_accessibility_
;
1415 // Java Bridge dispatcher attached to this view; lazily initialized.
1416 JavaBridgeDispatcher
* java_bridge_dispatcher_
;
1418 // Mouse Lock dispatcher attached to this view.
1419 MouseLockDispatcher
* mouse_lock_dispatcher_
;
1421 #if defined(OS_ANDROID)
1422 // Android Specific ---------------------------------------------------------
1424 // The background color of the document body element. This is used as the
1425 // default background color for filling the screen areas for which we don't
1426 // have the actual content.
1427 SkColor body_background_color_
;
1429 // Expected id of the next content intent launched. Used to prevent scheduled
1430 // intents to be launched if aborted.
1431 size_t expected_content_intent_id_
;
1433 // List of click-based content detectors.
1434 typedef std::vector
< linked_ptr
<ContentDetector
> > ContentDetectorList
;
1435 ContentDetectorList content_detectors_
;
1437 // Proxy class for WebMediaPlayer to communicate with the real media player
1438 // objects in browser process.
1439 WebMediaPlayerProxyImplAndroid
* media_player_proxy_
;
1441 // The media player manager for managing all the media players on this view.
1442 scoped_ptr
<webkit_media::WebMediaPlayerManagerAndroid
> media_player_manager_
;
1444 // Resource manager for all the android media player objects if they are
1445 // created in the renderer process.
1446 scoped_ptr
<webkit_media::MediaPlayerBridgeManagerImpl
> media_bridge_manager_
;
1448 // A date/time picker object for date and time related input elements.
1449 scoped_ptr
<RendererDateTimePicker
> date_time_picker_client_
;
1452 // Misc ----------------------------------------------------------------------
1454 // The current and pending file chooser completion objects. If the queue is
1455 // nonempty, the first item represents the currently running file chooser
1456 // callback, and the remaining elements are the other file chooser completion
1457 // still waiting to be run (in order).
1458 struct PendingFileChooser
;
1459 std::deque
< linked_ptr
<PendingFileChooser
> > file_chooser_completions_
;
1461 // The current directory enumeration callback
1462 std::map
<int, WebKit::WebFileChooserCompletion
*> enumeration_completions_
;
1463 int enumeration_completion_id_
;
1465 // Reports load progress to the browser.
1466 scoped_ptr
<LoadProgressTracker
> load_progress_tracker_
;
1468 // The SessionStorage namespace that we're assigned to has an ID, and that ID
1469 // is passed to us upon creation. WebKit asks for this ID upon first use and
1470 // uses it whenever asking the browser process to allocate new storage areas.
1471 int64 session_storage_namespace_id_
;
1473 // The total number of unrequested popups that exist and can be followed back
1474 // to a common opener. This count is shared among all RenderViews created with
1475 // createView(). All popups are treated as unrequested until specifically
1476 // instructed otherwise by the Browser process.
1477 scoped_refptr
<SharedRenderViewCounter
> shared_popup_counter_
;
1479 // Whether this is a top level window (instead of a popup). Top level windows
1480 // shouldn't count against their own |shared_popup_counter_|.
1481 bool decrement_shared_popup_at_destruction_
;
1483 // Stores edit commands associated to the next key event.
1484 // Shall be cleared as soon as the next key event is processed.
1485 EditCommands edit_commands_
;
1487 // The external popup for the currently showing select popup.
1488 scoped_ptr
<ExternalPopupMenu
> external_popup_menu_
;
1490 // The node that the context menu was pressed over.
1491 WebKit::WebNode context_menu_node_
;
1493 // All the registered observers. We expect this list to be small, so vector
1495 ObserverList
<RenderViewObserver
> observers_
;
1497 // Used to inform didChangeSelection() when it is called in the context
1498 // of handling a ViewMsg_SelectRange IPC.
1499 bool handling_select_range_
;
1501 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface.
1502 scoped_ptr
<MouseLockDispatcher::LockTarget
> webwidget_mouse_lock_target_
;
1504 // State associated with the GetWindowSnapshot function.
1505 int next_snapshot_id_
;
1506 typedef std::map
<int, WindowSnapshotCallback
>
1508 PendingSnapshotMap pending_snapshots_
;
1510 bool allow_partial_swap_
;
1512 // Plugins -------------------------------------------------------------------
1514 // All the currently active plugin delegates for this RenderView; kept so
1515 // that we can enumerate them to send updates about things like window
1516 // location or tab focus and visibily. These are non-owning references.
1517 std::set
<WebPluginDelegateProxy
*> plugin_delegates_
;
1520 // The ID of the focused NPAPI plug-in.
1521 int focused_plugin_id_
;
1524 // Allows JS to access DOM automation. The JS object is only exposed when the
1525 // DOM automation bindings are enabled.
1526 scoped_ptr
<DomAutomationController
> dom_automation_controller_
;
1528 // Boolean indicating whether we are in the process of creating the frame
1529 // tree for this renderer in response to ViewMsg_UpdateFrameTree. If true,
1530 // we won't be sending ViewHostMsg_FrameTreeUpdated messages back to the
1531 // browser, as those will be redundant.
1532 bool updating_frame_tree_
;
1534 // Boolean indicating that the frame tree has changed, but a message has not
1535 // been sent to the browser because a page has been loading. This helps
1536 // avoid extra messages being sent to the browser when navigating away from a
1537 // page with subframes, which will be destroyed. Instead, a single message
1538 // is sent when the load is stopped with the final state of the frame tree.
1540 // TODO(nasko): Relying on the is_loading_ means that frame tree updates will
1541 // not be sent until *all* subframes have completed loading. This can cause
1542 // JavaScript calls to fail, if they occur prior to the first update message
1543 // being sent. This will be fixed by bug http://crbug.com/145014.
1544 bool pending_frame_tree_update_
;
1546 // If this render view is a swapped out "mirror" of an active render view in a
1547 // different process, we record the process id and route id for the active RV.
1548 // For further details, see the comments on ViewHostMsg_FrameTreeUpdated.
1549 int target_process_id_
;
1550 int target_routing_id_
;
1552 // A map of the current process's frame ids to ids in the remote active render
1553 // view, if this is a swapped out render view.
1554 std::map
<int, int> active_frame_id_map_
;
1556 // This field stores drag/drop related info for the event that is currently
1557 // being handled. If the current event results in starting a drag/drop
1558 // session, this info is sent to the browser along with other drag/drop info.
1559 DragEventSourceInfo possible_drag_event_info_
;
1561 // NOTE: pepper_helper_ should be last member because its constructor calls
1562 // AddObservers method of RenderViewImpl from c-tor.
1563 scoped_ptr
<RenderViewPepperHelper
> pepper_helper_
;
1565 // ---------------------------------------------------------------------------
1566 // ADDING NEW DATA? Please see if it fits appropriately in one of the above
1567 // sections rather than throwing it randomly at the end. If you're adding a
1568 // bunch of stuff, you should probably create a helper class and put your
1569 // data and methods on that to avoid bloating RenderView more. You can
1570 // use the Observer interface to filter IPC messages and receive frame change
1572 // ---------------------------------------------------------------------------
1574 DISALLOW_COPY_AND_ASSIGN(RenderViewImpl
);
1577 } // namespace content
1579 #endif // CONTENT_RENDERER_RENDER_VIEW_IMPL_H_