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/process.h"
21 #include "base/strings/string16.h"
22 #include "base/timer/timer.h"
23 #include "build/build_config.h"
24 #include "cc/input/top_controls_state.h"
25 #include "content/common/content_export.h"
26 #include "content/common/drag_event_source_info.h"
27 #include "content/common/edit_command.h"
28 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
29 #include "content/common/navigation_gesture.h"
30 #include "content/common/view_message_enums.h"
31 #include "content/public/common/javascript_message_type.h"
32 #include "content/public/common/page_zoom.h"
33 #include "content/public/common/referrer.h"
34 #include "content/public/common/renderer_preferences.h"
35 #include "content/public/common/stop_find_action.h"
36 #include "content/public/common/top_controls_state.h"
37 #include "content/public/renderer/render_view.h"
38 #include "content/renderer/media/webmediaplayer_delegate.h"
39 #include "content/renderer/mouse_lock_dispatcher.h"
40 #include "content/renderer/render_frame_impl.h"
41 #include "content/renderer/render_widget.h"
42 #include "content/renderer/renderer_date_time_picker.h"
43 #include "content/renderer/stats_collection_observer.h"
44 #include "ipc/ipc_platform_file.h"
45 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
46 #include "third_party/WebKit/public/web/WebAXObject.h"
47 #include "third_party/WebKit/public/web/WebConsoleMessage.h"
48 #include "third_party/WebKit/public/web/WebDataSource.h"
49 #include "third_party/WebKit/public/web/WebFrameClient.h"
50 #include "third_party/WebKit/public/web/WebHistoryItem.h"
51 #include "third_party/WebKit/public/web/WebIconURL.h"
52 #include "third_party/WebKit/public/web/WebInputEvent.h"
53 #include "third_party/WebKit/public/web/WebNavigationType.h"
54 #include "third_party/WebKit/public/web/WebNode.h"
55 #include "third_party/WebKit/public/web/WebPageSerializerClient.h"
56 #include "third_party/WebKit/public/web/WebPageVisibilityState.h"
57 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
58 #include "third_party/WebKit/public/web/WebViewClient.h"
59 #include "ui/surface/transport_dib.h"
60 #include "webkit/common/webpreferences.h"
62 #if defined(OS_ANDROID)
63 #include "content/renderer/android/content_detector.h"
64 #include "third_party/WebKit/public/web/WebContentDetectionResult.h"
67 #if defined(COMPILER_MSVC)
68 // RenderViewImpl is a diamond-shaped hierarchy, with WebWidgetClient at the
69 // root. VS warns when we inherit the WebWidgetClient method implementations
70 // from RenderWidget. It's safe to ignore that warning.
71 #pragma warning(disable: 4250)
75 class PepperDeviceTest;
77 struct PP_NetAddress_Private;
78 struct FrameMsg_Navigate_Params;
79 struct ViewMsg_PostMessage_Params;
80 struct ViewMsg_StopFinding_Params;
83 struct SelectedFileInfo;
87 class WebApplicationCacheHost;
88 class WebApplicationCacheHostClient;
89 class WebDOMMessageEvent;
91 class WebDateTimeChooserCompletion;
93 class WebGeolocationClient;
94 class WebGestureEvent;
97 class WebPeerConnection00Handler;
98 class WebPeerConnection00HandlerClient;
100 class WebMediaPlayerClient;
102 class WebPeerConnectionHandler;
103 class WebPeerConnectionHandlerClient;
104 class WebSocketStreamHandle;
105 class WebSpeechInputController;
106 class WebSpeechInputListener;
107 class WebSpeechRecognizer;
108 class WebStorageNamespace;
111 class WebUserMediaClient;
112 struct WebActiveWheelFlingParameters;
113 struct WebDateTimeChooserParams;
114 struct WebFileChooserParams;
115 struct WebFindOptions;
116 struct WebMediaPlayerAction;
117 struct WebPluginAction;
119 struct WebWindowFeatures;
121 #if defined(OS_ANDROID)
122 class WebHitTestResult;
126 namespace webkit_glue {
127 class WebURLResponseExtraDataImpl;
131 class BrowserPluginManager;
132 class DeviceOrientationDispatcher;
135 class ExternalPopupMenu;
137 class GeolocationDispatcher;
138 class ImageResourceFetcher;
139 class InputTagSpeechDispatcher;
140 class JavaBridgeDispatcher;
141 class LoadProgressTracker;
142 class MidiDispatcher;
143 class MediaStreamClient;
144 class MediaStreamDispatcher;
145 class MouseLockDispatcher;
146 class NavigationState;
147 class NotificationProvider;
148 class PepperPluginInstanceImpl;
149 class RenderViewObserver;
150 class RenderViewTest;
151 class RendererAccessibility;
152 class RendererDateTimePicker;
153 class RendererWebColorChooserImpl;
154 class SpeechRecognitionDispatcher;
155 class WebPluginDelegateProxy;
158 struct FileChooserParams;
159 struct RenderViewImplParams;
161 #if defined(OS_ANDROID)
162 class RendererMediaPlayerManager;
163 class WebMediaPlayerProxyAndroid;
167 // RenderView is an object that manages a WebView object, and provides a
168 // communication interface with an embedding application process
170 class CONTENT_EXPORT RenderViewImpl
171 : public RenderWidget,
172 NON_EXPORTED_BASE(public blink::WebViewClient),
173 NON_EXPORTED_BASE(public blink::WebFrameClient),
174 NON_EXPORTED_BASE(public blink::WebPageSerializerClient),
176 NON_EXPORTED_BASE(public WebMediaPlayerDelegate),
177 public base::SupportsWeakPtr<RenderViewImpl> {
179 // Creates a new RenderView. |opener_id| is the routing ID of the RenderView
180 // responsible for creating this RenderView.
181 static RenderViewImpl* Create(
183 const RendererPreferences& renderer_prefs,
184 const WebPreferences& webkit_prefs,
186 int32 main_frame_routing_id,
188 int64 session_storage_namespace_id,
189 const base::string16& frame_name,
190 bool is_renderer_created,
194 const blink::WebScreenInfo& screen_info,
195 unsigned int accessibility_mode,
196 bool allow_partial_swap);
198 // Used by content_layouttest_support to hook into the creation of
200 static void InstallCreateHook(
201 RenderViewImpl* (*create_render_view_impl)(RenderViewImplParams*));
203 // Returns the RenderViewImpl containing the given WebView.
204 static RenderViewImpl* FromWebView(blink::WebView* webview);
206 // Returns the RenderViewImpl for the given routing ID.
207 static RenderViewImpl* FromRoutingID(int routing_id);
209 // May return NULL when the view is closing.
210 blink::WebView* webview() const;
212 int history_list_offset() const { return history_list_offset_; }
214 const WebPreferences& webkit_preferences() const {
215 return webkit_preferences_;
218 const RendererPreferences& renderer_preferences() const {
219 return renderer_preferences_;
222 void set_send_content_state_immediately(bool value) {
223 send_content_state_immediately_ = value;
226 RenderFrameImpl* main_render_frame() { return main_render_frame_.get(); }
228 MediaStreamDispatcher* media_stream_dispatcher() {
229 return media_stream_dispatcher_;
232 RendererAccessibility* renderer_accessibility() {
233 return renderer_accessibility_;
236 MouseLockDispatcher* mouse_lock_dispatcher() {
237 return mouse_lock_dispatcher_;
240 // Lazily initialize this view's BrowserPluginManager and return it.
241 BrowserPluginManager* GetBrowserPluginManager();
243 // Functions to add and remove observers for this object.
244 void AddObserver(RenderViewObserver* observer);
245 void RemoveObserver(RenderViewObserver* observer);
247 // Returns the StatsCollectionObserver associated with this view, or NULL
248 // if one wasn't created;
249 StatsCollectionObserver* GetStatsCollectionObserver() {
250 return stats_collection_observer_.get();
253 // Adds the given file chooser request to the file_chooser_completion_ queue
254 // (see that var for more) and requests the chooser be displayed if there are
255 // no other waiting items in the queue.
257 // Returns true if the chooser was successfully scheduled. False means we
258 // didn't schedule anything.
259 bool ScheduleFileChooser(const FileChooserParams& params,
260 blink::WebFileChooserCompletion* completion);
262 void LoadNavigationErrorPage(
263 blink::WebFrame* frame,
264 const blink::WebURLRequest& failed_request,
265 const blink::WebURLError& error,
268 #if defined(OS_ANDROID)
269 void DismissDateTimeDialog();
272 // Plugin-related functions --------------------------------------------------
274 #if defined(ENABLE_PLUGINS)
275 PepperPluginInstanceImpl* focused_pepper_plugin() {
276 return focused_pepper_plugin_;
278 PepperPluginInstanceImpl* pepper_last_mouse_event_target() {
279 return pepper_last_mouse_event_target_;
281 void set_pepper_last_mouse_event_target(PepperPluginInstanceImpl* plugin) {
282 pepper_last_mouse_event_target_ = plugin;
285 #if defined(OS_MACOSX) || defined(OS_WIN)
286 // Informs the render view that the given plugin has gained or lost focus.
287 void PluginFocusChanged(bool focused, int plugin_id);
290 #if defined(OS_MACOSX)
291 // Starts plugin IME.
292 void StartPluginIme();
295 // Indicates that the given instance has been created.
296 void PepperInstanceCreated(PepperPluginInstanceImpl* instance);
298 // Indicates that the given instance is being destroyed. This is called from
299 // the destructor, so it's important that the instance is not dereferenced
301 void PepperInstanceDeleted(PepperPluginInstanceImpl* instance);
303 // Notification that the given plugin is focused or unfocused.
304 void PepperFocusChanged(PepperPluginInstanceImpl* instance, bool focused);
306 void RegisterPluginDelegate(WebPluginDelegateProxy* delegate);
307 void UnregisterPluginDelegate(WebPluginDelegateProxy* delegate);
308 #endif // ENABLE_PLUGINS
310 void TransferActiveWheelFlingAnimation(
311 const blink::WebActiveWheelFlingParameters& params);
313 // Returns true if the focused element is editable text from the perspective
314 // of IME support (also used for on-screen keyboard). Works correctly inside
315 // supported PPAPI plug-ins.
316 bool HasIMETextFocus();
318 // Callback for use with GetWindowSnapshot.
319 typedef base::Callback<void(
320 const gfx::Size&, const std::vector<unsigned char>&)>
321 WindowSnapshotCallback;
323 void GetWindowSnapshot(const WindowSnapshotCallback& callback);
325 // Dispatches the current navigation state to the browser. Called on a
326 // periodic timer so we don't send too many messages.
327 void SyncNavigationState();
329 // Temporary call until all this media code moves to RenderFrame.
330 // TODO(jam): remove me
331 blink::WebMediaPlayer* CreateMediaPlayer(
332 RenderFrame* render_frame,
333 blink::WebFrame* frame,
334 const blink::WebURL& url,
335 blink::WebMediaPlayerClient* client);
336 // Temporary call until this code moves to RenderFrame.
337 // virtual since overriden by WebTestProxy for layout tests.
338 virtual blink::WebNavigationPolicy DecidePolicyForNavigation(
339 RenderFrame* render_frame,
340 blink::WebFrame* frame,
341 blink::WebDataSource::ExtraData* extraData,
342 const blink::WebURLRequest& request,
343 blink::WebNavigationType type,
344 blink::WebNavigationPolicy default_policy,
347 // Returns the length of the session history of this RenderView. Note that
348 // this only coincides with the actual length of the session history if this
349 // RenderView is the currently active RenderView of a WebContents.
350 unsigned GetLocalSessionHistoryLengthForTesting() const;
352 // Invokes OnSetFocus and marks the widget as active depending on the value
353 // of |enable|. This is used for layout tests that need to control the focus
354 // synchronously from the renderer.
355 void SetFocusAndActivateForTesting(bool enable);
357 // Change the device scale factor and force the compositor to resize.
358 void SetDeviceScaleFactorForTesting(float factor);
360 // Used to force the size of a window when running layout tests.
361 void ForceResizeForTesting(const gfx::Size& new_size);
363 void UseSynchronousResizeModeForTesting(bool enable);
365 // Control autoresize mode.
366 void EnableAutoResizeForTesting(const gfx::Size& min_size,
367 const gfx::Size& max_size);
368 void DisableAutoResizeForTesting(const gfx::Size& new_size);
370 // Overrides the MediaStreamClient used when creating MediaStream players.
371 // Must be called before any players are created.
372 void SetMediaStreamClientForTesting(MediaStreamClient* media_stream_client);
374 // IPC::Listener implementation ----------------------------------------------
376 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
378 // blink::WebWidgetClient implementation ------------------------------------
380 // Most methods are handled by RenderWidget.
381 virtual void didFocus();
382 virtual void didBlur();
383 virtual void show(blink::WebNavigationPolicy policy);
384 virtual void runModal();
385 virtual bool enterFullScreen();
386 virtual void exitFullScreen();
387 virtual bool requestPointerLock();
388 virtual void requestPointerUnlock();
389 virtual bool isPointerLocked();
390 virtual void didActivateCompositor(int input_handler_identifier);
391 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event,
392 bool event_cancelled) OVERRIDE;
393 virtual void initializeLayerTreeView() OVERRIDE;
395 // blink::WebViewClient implementation --------------------------------------
397 virtual blink::WebView* createView(
398 blink::WebFrame* creator,
399 const blink::WebURLRequest& request,
400 const blink::WebWindowFeatures& features,
401 const blink::WebString& frame_name,
402 blink::WebNavigationPolicy policy,
403 bool suppress_opener);
404 virtual blink::WebWidget* createPopupMenu(blink::WebPopupType popup_type);
405 virtual blink::WebExternalPopupMenu* createExternalPopupMenu(
406 const blink::WebPopupMenuInfo& popup_menu_info,
407 blink::WebExternalPopupMenuClient* popup_menu_client);
408 virtual blink::WebStorageNamespace* createSessionStorageNamespace();
409 virtual bool shouldReportDetailedMessageForSource(
410 const blink::WebString& source);
411 virtual void didAddMessageToConsole(
412 const blink::WebConsoleMessage& message,
413 const blink::WebString& source_name,
414 unsigned source_line,
415 const blink::WebString& stack_trace);
416 virtual void printPage(blink::WebFrame* frame);
417 virtual blink::WebNotificationPresenter* notificationPresenter();
418 virtual bool enumerateChosenDirectory(
419 const blink::WebString& path,
420 blink::WebFileChooserCompletion* chooser_completion);
421 virtual void initializeHelperPluginWebFrame(blink::WebHelperPlugin*);
422 virtual void didStartLoading(bool to_different_document);
424 virtual void didStartLoading();
425 virtual void didStopLoading();
426 virtual void didChangeLoadProgress(blink::WebFrame* frame,
427 double load_progress);
428 virtual void didCancelCompositionOnSelectionChange();
429 virtual void didChangeSelection(bool is_selection_empty);
430 virtual void didExecuteCommand(const blink::WebString& command_name);
431 virtual bool handleCurrentKeyboardEvent();
432 virtual blink::WebColorChooser* createColorChooser(
433 blink::WebColorChooserClient*,
434 const blink::WebColor& initial_color,
435 const blink::WebVector<blink::WebColorSuggestion>& suggestions);
436 virtual bool runFileChooser(
437 const blink::WebFileChooserParams& params,
438 blink::WebFileChooserCompletion* chooser_completion);
439 virtual void runModalAlertDialog(blink::WebFrame* frame,
440 const blink::WebString& message);
441 virtual bool runModalConfirmDialog(blink::WebFrame* frame,
442 const blink::WebString& message);
443 virtual bool runModalPromptDialog(blink::WebFrame* frame,
444 const blink::WebString& message,
445 const blink::WebString& default_value,
446 blink::WebString* actual_value);
447 virtual bool runModalBeforeUnloadDialog(blink::WebFrame* frame,
449 const blink::WebString& message);
450 virtual void showValidationMessage(const blink::WebRect& anchor_in_root_view,
451 const blink::WebString& main_text,
452 const blink::WebString& sub_text,
453 blink::WebTextDirection hint) OVERRIDE;
454 virtual void hideValidationMessage() OVERRIDE;
455 virtual void moveValidationMessage(
456 const blink::WebRect& anchor_in_root_view) OVERRIDE;
459 virtual bool runModalBeforeUnloadDialog(blink::WebFrame* frame,
460 const blink::WebString& message);
461 virtual void showContextMenu(blink::WebFrame* frame,
462 const blink::WebContextMenuData& data);
463 virtual void clearContextMenu();
464 virtual void setStatusText(const blink::WebString& text);
465 virtual void setMouseOverURL(const blink::WebURL& url);
466 virtual void setKeyboardFocusURL(const blink::WebURL& url);
467 virtual void startDragging(blink::WebFrame* frame,
468 const blink::WebDragData& data,
469 blink::WebDragOperationsMask mask,
470 const blink::WebImage& image,
471 const blink::WebPoint& imageOffset);
472 virtual bool acceptsLoadDrops();
473 virtual void focusNext();
474 virtual void focusPrevious();
475 virtual void focusedNodeChanged(const blink::WebNode& node);
476 virtual void numberOfWheelEventHandlersChanged(unsigned num_handlers);
477 virtual void didUpdateLayout();
478 #if defined(OS_ANDROID)
479 virtual bool didTapMultipleTargets(
480 const blink::WebGestureEvent& event,
481 const blink::WebVector<blink::WebRect>& target_rects);
483 virtual void navigateBackForwardSoon(int offset);
484 virtual int historyBackListCount();
485 virtual int historyForwardListCount();
486 virtual void postAccessibilityEvent(
487 const blink::WebAXObject& obj, blink::WebAXEvent event);
488 virtual void didUpdateInspectorSetting(const blink::WebString& key,
489 const blink::WebString& value);
490 virtual blink::WebGeolocationClient* geolocationClient();
491 virtual blink::WebSpeechInputController* speechInputController(
492 blink::WebSpeechInputListener* listener);
493 virtual blink::WebSpeechRecognizer* speechRecognizer();
494 virtual void zoomLimitsChanged(double minimum_level, double maximum_level);
495 virtual void zoomLevelChanged();
496 virtual double zoomLevelToZoomFactor(double zoom_level) const;
497 virtual double zoomFactorToZoomLevel(double factor) const;
498 virtual void registerProtocolHandler(const blink::WebString& scheme,
499 const blink::WebURL& base_url,
500 const blink::WebURL& url,
501 const blink::WebString& title);
502 virtual blink::WebPageVisibilityState visibilityState() const;
503 virtual blink::WebUserMediaClient* userMediaClient();
504 virtual blink::WebMIDIClient* webMIDIClient();
505 virtual void draggableRegionsChanged();
507 #if defined(OS_ANDROID)
508 virtual void scheduleContentIntent(const blink::WebURL& intent);
509 virtual void cancelScheduledContentIntents();
510 virtual blink::WebContentDetectionResult detectContentAround(
511 const blink::WebHitTestResult& touch_hit);
513 // Only used on Android since all other platforms implement
514 // date and time input fields using MULTIPLE_FIELDS_UI
515 virtual bool openDateTimeChooser(const blink::WebDateTimeChooserParams&,
516 blink::WebDateTimeChooserCompletion*);
517 virtual void didScrollWithKeyboard(const blink::WebSize& delta);
520 // blink::WebFrameClient implementation -------------------------------------
522 virtual blink::WebMediaPlayer* createMediaPlayer(
523 blink::WebFrame* frame,
524 const blink::WebURL& url,
525 blink::WebMediaPlayerClient* client);
526 virtual void didAccessInitialDocument(blink::WebFrame* frame);
527 virtual void didDisownOpener(blink::WebFrame* frame);
528 virtual void frameDetached(blink::WebFrame* frame);
529 virtual void willClose(blink::WebFrame* frame);
530 virtual void didMatchCSS(
531 blink::WebFrame* frame,
532 const blink::WebVector<blink::WebString>& newly_matching_selectors,
533 const blink::WebVector<blink::WebString>& stopped_matching_selectors);
534 virtual void willSendSubmitEvent(blink::WebFrame* frame,
535 const blink::WebFormElement& form);
536 virtual void willSubmitForm(blink::WebFrame* frame,
537 const blink::WebFormElement& form);
538 virtual void didCreateDataSource(blink::WebFrame* frame,
539 blink::WebDataSource* datasource);
540 virtual void didStartProvisionalLoad(blink::WebFrame* frame);
541 virtual void didFailProvisionalLoad(blink::WebFrame* frame,
542 const blink::WebURLError& error);
543 virtual void didCommitProvisionalLoad(blink::WebFrame* frame,
544 bool is_new_navigation);
545 virtual void didClearWindowObject(blink::WebFrame* frame, int world_id);
546 virtual void didCreateDocumentElement(blink::WebFrame* frame);
547 virtual void didReceiveTitle(blink::WebFrame* frame,
548 const blink::WebString& title,
549 blink::WebTextDirection direction);
550 virtual void didChangeIcon(blink::WebFrame*,
551 blink::WebIconURL::Type);
552 virtual void didFinishDocumentLoad(blink::WebFrame* frame);
553 virtual void didHandleOnloadEvents(blink::WebFrame* frame);
554 virtual void didFailLoad(blink::WebFrame* frame,
555 const blink::WebURLError& error);
556 virtual void didFinishLoad(blink::WebFrame* frame);
557 virtual void didNavigateWithinPage(blink::WebFrame* frame,
558 bool is_new_navigation);
559 virtual void didUpdateCurrentHistoryItem(blink::WebFrame* frame);
560 virtual void willSendRequest(blink::WebFrame* frame,
562 blink::WebURLRequest& request,
563 const blink::WebURLResponse& redirect_response);
564 virtual void didReceiveResponse(blink::WebFrame* frame,
566 const blink::WebURLResponse& response);
567 virtual void didFinishResourceLoad(blink::WebFrame* frame,
568 unsigned identifier);
569 virtual void didLoadResourceFromMemoryCache(
570 blink::WebFrame* frame,
571 const blink::WebURLRequest& request,
572 const blink::WebURLResponse&);
573 virtual void didDisplayInsecureContent(blink::WebFrame* frame);
574 virtual void didRunInsecureContent(
575 blink::WebFrame* frame,
576 const blink::WebSecurityOrigin& origin,
577 const blink::WebURL& target);
578 virtual void didExhaustMemoryAvailableForScript(blink::WebFrame* frame);
579 virtual void didCreateScriptContext(blink::WebFrame* frame,
580 v8::Handle<v8::Context>,
583 virtual void willReleaseScriptContext(blink::WebFrame* frame,
584 v8::Handle<v8::Context>,
586 virtual void didChangeScrollOffset(blink::WebFrame* frame);
587 virtual void willInsertBody(blink::WebFrame* frame);
588 virtual void didFirstVisuallyNonEmptyLayout(blink::WebFrame*);
589 virtual void didChangeContentsSize(blink::WebFrame* frame,
590 const blink::WebSize& size);
591 virtual void reportFindInPageMatchCount(int request_id,
594 virtual void reportFindInPageSelection(int request_id,
595 int active_match_ordinal,
596 const blink::WebRect& sel);
597 virtual void requestStorageQuota(
598 blink::WebFrame* frame,
599 blink::WebStorageQuotaType type,
600 unsigned long long requested_size,
601 blink::WebStorageQuotaCallbacks callbacks);
602 virtual void willOpenSocketStream(
603 blink::WebSocketStreamHandle* handle);
604 virtual void willStartUsingPeerConnectionHandler(blink::WebFrame* frame,
605 blink::WebRTCPeerConnectionHandler* handler);
606 virtual bool willCheckAndDispatchMessageEvent(
607 blink::WebFrame* sourceFrame,
608 blink::WebFrame* targetFrame,
609 blink::WebSecurityOrigin targetOrigin,
610 blink::WebDOMMessageEvent event);
611 virtual blink::WebString acceptLanguages();
612 virtual blink::WebString userAgentOverride(
613 blink::WebFrame* frame,
614 const blink::WebURL& url);
615 virtual blink::WebString doNotTrackValue(blink::WebFrame* frame);
616 virtual bool allowWebGL(blink::WebFrame* frame, bool default_value);
617 virtual void didLoseWebGLContext(
618 blink::WebFrame* frame,
619 int arb_robustness_status_code);
621 // blink::WebPageSerializerClient implementation ----------------------------
623 virtual void didSerializeDataForFrame(
624 const blink::WebURL& frame_url,
625 const blink::WebCString& data,
626 PageSerializationStatus status) OVERRIDE;
628 // RenderView implementation -------------------------------------------------
630 virtual bool Send(IPC::Message* message) OVERRIDE;
631 virtual RenderFrame* GetMainRenderFrame() OVERRIDE;
632 virtual int GetRoutingID() const OVERRIDE;
633 virtual int GetPageId() const OVERRIDE;
634 virtual gfx::Size GetSize() const OVERRIDE;
635 virtual WebPreferences& GetWebkitPreferences() OVERRIDE;
636 virtual void SetWebkitPreferences(const WebPreferences& preferences) OVERRIDE;
637 virtual blink::WebView* GetWebView() OVERRIDE;
638 virtual blink::WebNode GetFocusedNode() const OVERRIDE;
639 virtual blink::WebNode GetContextMenuNode() const OVERRIDE;
640 virtual bool IsEditableNode(const blink::WebNode& node) const OVERRIDE;
641 virtual void EvaluateScript(const base::string16& frame_xpath,
642 const base::string16& jscript,
644 bool notify_result) OVERRIDE;
645 virtual bool ShouldDisplayScrollbars(int width, int height) const OVERRIDE;
646 virtual int GetEnabledBindings() const OVERRIDE;
647 virtual bool GetContentStateImmediately() const OVERRIDE;
648 virtual float GetFilteredTimePerFrame() const OVERRIDE;
649 virtual blink::WebPageVisibilityState GetVisibilityState() const OVERRIDE;
650 virtual void RunModalAlertDialog(blink::WebFrame* frame,
651 const blink::WebString& message) OVERRIDE;
652 virtual void DidStartLoading() OVERRIDE;
653 virtual void DidStopLoading() OVERRIDE;
654 virtual void Repaint(const gfx::Size& size) OVERRIDE;
655 virtual void SetEditCommandForNextKeyEvent(const std::string& name,
656 const std::string& value) OVERRIDE;
657 virtual void ClearEditCommands() OVERRIDE;
658 virtual SSLStatus GetSSLStatusOfFrame(blink::WebFrame* frame) const OVERRIDE;
659 virtual const std::string& GetAcceptLanguages() const OVERRIDE;
660 #if defined(OS_ANDROID)
661 virtual void UpdateTopControlsState(TopControlsState constraints,
662 TopControlsState current,
663 bool animate) OVERRIDE;
666 // WebMediaPlayerDelegate implementation -----------------------
668 virtual void DidPlay(blink::WebMediaPlayer* player) OVERRIDE;
669 virtual void DidPause(blink::WebMediaPlayer* player) OVERRIDE;
670 virtual void PlayerGone(blink::WebMediaPlayer* player) OVERRIDE;
672 // Please do not add your stuff randomly to the end here. If there is an
673 // appropriate section, add it there. If not, there are some random functions
674 // nearer to the top you can add it to.
676 // Cannot use std::set unfortunately since linked_ptr<> does not support
678 typedef std::vector<linked_ptr<ImageResourceFetcher> >
679 ImageResourceFetcherList;
682 // RenderWidget overrides:
683 virtual void Close() OVERRIDE;
684 virtual void OnResize(const ViewMsg_Resize_Params& params) OVERRIDE;
685 virtual void DidInitiatePaint() OVERRIDE;
686 virtual void DidFlushPaint() OVERRIDE;
687 virtual PepperPluginInstanceImpl* GetBitmapForOptimizedPluginPaint(
688 const gfx::Rect& paint_bounds,
692 float* scale_factor) OVERRIDE;
693 virtual gfx::Vector2d GetScrollOffset() OVERRIDE;
694 virtual void DidHandleKeyEvent() OVERRIDE;
695 virtual bool WillHandleMouseEvent(
696 const blink::WebMouseEvent& event) OVERRIDE;
697 virtual bool WillHandleGestureEvent(
698 const blink::WebGestureEvent& event) OVERRIDE;
699 virtual void DidHandleMouseEvent(const blink::WebMouseEvent& event) OVERRIDE;
700 virtual void DidHandleTouchEvent(const blink::WebTouchEvent& event) OVERRIDE;
701 virtual bool HasTouchEventHandlersAt(const gfx::Point& point) const OVERRIDE;
702 virtual void OnSetFocus(bool enable) OVERRIDE;
703 virtual void OnWasHidden() OVERRIDE;
704 virtual void OnWasShown(bool needs_repainting) OVERRIDE;
705 virtual GURL GetURLForGraphicsContext3D() OVERRIDE;
706 virtual bool ForceCompositingModeEnabled() OVERRIDE;
707 virtual void OnImeSetComposition(
708 const base::string16& text,
709 const std::vector<blink::WebCompositionUnderline>& underlines,
711 int selection_end) OVERRIDE;
712 virtual void OnImeConfirmComposition(const base::string16& text,
713 const gfx::Range& replacement_range,
714 bool keep_selection) OVERRIDE;
715 virtual void SetDeviceScaleFactor(float device_scale_factor) OVERRIDE;
716 virtual ui::TextInputType GetTextInputType() OVERRIDE;
717 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) OVERRIDE;
718 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
719 virtual void GetCompositionCharacterBounds(
720 std::vector<gfx::Rect>* character_bounds) OVERRIDE;
721 virtual void GetCompositionRange(gfx::Range* range) OVERRIDE;
723 virtual bool CanComposeInline() OVERRIDE;
724 virtual void DidCommitCompositorFrame() OVERRIDE;
725 virtual void InstrumentWillBeginFrame(int frame_id) OVERRIDE;
726 virtual void InstrumentDidBeginFrame() OVERRIDE;
727 virtual void InstrumentDidCancelFrame() OVERRIDE;
728 virtual void InstrumentWillComposite() OVERRIDE;
729 virtual bool AllowPartialSwap() const OVERRIDE;
732 explicit RenderViewImpl(RenderViewImplParams* params);
734 void Initialize(RenderViewImplParams* params);
735 virtual void SetScreenMetricsEmulationParameters(
736 float device_scale_factor,
737 const gfx::Point& root_layer_offset,
738 float root_layer_scale) OVERRIDE;
740 // Do not delete directly. This class is reference counted.
741 virtual ~RenderViewImpl();
745 friend class ExternalPopupMenuTest;
746 friend class PepperDeviceTest;
747 friend class RendererAccessibilityTest;
748 friend class RenderViewTest;
750 // TODO(nasko): Temporarily friend RenderFrameImpl, so we don't duplicate
751 // utility functions needed in both classes, while we move frame specific
752 // code away from this class.
753 friend class RenderFrameImpl;
755 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuRemoveTest, RemoveOnChange);
756 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, NormalCase);
757 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, ShowPopupThenNavigate);
758 FRIEND_TEST_ALL_PREFIXES(RendererAccessibilityTest,
759 AccessibilityMessagesQueueWhileSwappedOut);
760 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, DecideNavigationPolicyForWebUI);
761 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
762 DidFailProvisionalLoadWithErrorForError);
763 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
764 DidFailProvisionalLoadWithErrorForCancellation);
765 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
766 DontIgnoreBackAfterNavEntryLimit);
767 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, ImeComposition);
768 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, InsertCharacters);
769 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, JSBlockSentAfterPageLoad);
770 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, LastCommittedUpdateState);
771 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnExtendSelectionAndDelete);
772 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnHandleKeyboardEvent);
773 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnImeTypeChanged);
774 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnNavStateChanged);
775 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnSetTextDirection);
776 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnUpdateWebPreferences);
777 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, SendSwapOutACK);
778 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, ReloadWhileSwappedOut);
779 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
780 SetEditableSelectionAndComposition);
781 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, StaleNavigationsIgnored);
782 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, UpdateTargetURLWithInvalidURL);
783 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
784 GetCompositionCharacterBoundsTest);
785 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnNavigationHttpPost);
786 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
787 DecideNavigationPolicyHandlesAllTopLevel);
788 #if defined(OS_MACOSX)
789 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, MacTestCmdUp);
791 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, SetHistoryLengthAndPrune);
792 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, ZoomLimit);
793 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, NavigateFrame);
794 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, BasicRenderFrame);
795 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, TextInputTypeWithPepper);
796 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
797 MessageOrderInDidChangeSelection);
798 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, SendCandidateWindowEvents);
799 FRIEND_TEST_ALL_PREFIXES(SuppressErrorPageTest, Suppresses);
800 FRIEND_TEST_ALL_PREFIXES(SuppressErrorPageTest, DoesNotSuppress);
802 typedef std::map<GURL, double> HostZoomLevels;
810 static bool IsReload(const FrameMsg_Navigate_Params& params);
812 static Referrer GetReferrerFromRequest(
813 blink::WebFrame* frame,
814 const blink::WebURLRequest& request);
816 static void NotifyTimezoneChange(blink::WebFrame* frame);
818 void UpdateTitle(blink::WebFrame* frame, const base::string16& title,
819 blink::WebTextDirection title_direction);
820 void UpdateSessionHistory(blink::WebFrame* frame);
821 void SendUpdateState(const blink::WebHistoryItem& item);
823 // Update current main frame's encoding and send it to browser window.
824 // Since we want to let users see the right encoding info from menu
825 // before finishing loading, we call the UpdateEncoding in
826 // a) function:DidCommitLoadForFrame. When this function is called,
827 // that means we have got first data. In here we try to get encoding
828 // of page if it has been specified in http header.
829 // b) function:DidReceiveTitle. When this function is called,
830 // that means we have got specified title. Because in most of webpages,
831 // title tags will follow meta tags. In here we try to get encoding of
832 // page if it has been specified in meta tag.
833 // c) function:DidFinishDocumentLoadForFrame. When this function is
834 // called, that means we have got whole html page. In here we should
835 // finally get right encoding of page.
836 void UpdateEncoding(blink::WebFrame* frame,
837 const std::string& encoding_name);
839 void OpenURL(blink::WebFrame* frame,
841 const Referrer& referrer,
842 blink::WebNavigationPolicy policy);
844 bool RunJavaScriptMessage(JavaScriptMessageType type,
845 const base::string16& message,
846 const base::string16& default_value,
847 const GURL& frame_url,
848 base::string16* result);
850 // Sends a message and runs a nested message loop.
851 bool SendAndRunNestedMessageLoop(IPC::SyncMessage* message);
853 // Called when the "pinned to left/right edge" state needs to be updated.
854 void UpdateScrollState(blink::WebFrame* frame);
856 // IPC message handlers ------------------------------------------------------
858 // The documentation for these functions should be in
859 // content/common/*_messages.h for the message that the function is handling.
864 void OnExecuteEditCommand(const std::string& name, const std::string& value);
865 void OnMoveCaret(const gfx::Point& point);
867 void OnPasteAndMatchStyle();
869 void OnReplace(const base::string16& text);
870 void OnReplaceMisspelling(const base::string16& text);
871 void OnScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect);
873 void OnSelectRange(const gfx::Point& start, const gfx::Point& end);
874 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
877 void OnAllowBindings(int enabled_bindings_flags);
878 void OnAllowScriptToClose(bool script_can_close);
879 void OnCancelDownload(int32 download_id);
880 void OnClearFocusedNode();
882 void OnShowContextMenu(const gfx::Point& location);
883 void OnCopyImageAt(int x, int y);
884 void OnCSSInsertRequest(const base::string16& frame_xpath,
885 const std::string& css);
886 void OnSetName(const std::string& name);
887 void OnDeterminePageLanguage();
888 void OnDisableScrollbarsForSmallWindows(
889 const gfx::Size& disable_scrollbars_size_limit);
890 void OnDragSourceEndedOrMoved(const gfx::Point& client_point,
891 const gfx::Point& screen_point,
893 blink::WebDragOperation drag_operation);
894 void OnDragSourceSystemDragEnded();
895 void OnDragTargetDrop(const gfx::Point& client_pt,
896 const gfx::Point& screen_pt,
898 void OnDragTargetDragEnter(const DropData& drop_data,
899 const gfx::Point& client_pt,
900 const gfx::Point& screen_pt,
901 blink::WebDragOperationsMask operations_allowed,
903 void OnDragTargetDragLeave();
904 void OnDragTargetDragOver(const gfx::Point& client_pt,
905 const gfx::Point& screen_pt,
906 blink::WebDragOperationsMask operations_allowed,
908 void OnEnablePreferredSizeChangedMode();
909 void OnEnableAutoResize(const gfx::Size& min_size, const gfx::Size& max_size);
910 void OnDisableAutoResize(const gfx::Size& new_size);
911 void OnEnumerateDirectoryResponse(int id,
912 const std::vector<base::FilePath>& paths);
913 void OnExtendSelectionAndDelete(int before, int after);
914 void OnFileChooserResponse(
915 const std::vector<ui::SelectedFileInfo>& files);
916 void OnFind(int request_id,
917 const base::string16&,
918 const blink::WebFindOptions&);
919 void OnGetAllSavableResourceLinksForCurrentPage(const GURL& page_url);
920 void OnGetSerializedHtmlDataForCurrentPageWithLocalLinks(
921 const std::vector<GURL>& links,
922 const std::vector<base::FilePath>& local_paths,
923 const base::FilePath& local_directory_name);
924 void OnMediaPlayerActionAt(const gfx::Point& location,
925 const blink::WebMediaPlayerAction& action);
926 void OnOrientationChangeEvent(int orientation);
927 void OnPluginActionAt(const gfx::Point& location,
928 const blink::WebPluginAction& action);
929 void OnMoveOrResizeStarted();
930 void OnPostMessageEvent(const ViewMsg_PostMessage_Params& params);
931 void OnReleaseDisambiguationPopupDIB(TransportDIB::Handle dib_handle);
932 void OnReloadFrame();
933 void OnResetPageEncodingToDefault();
934 void OnScriptEvalRequest(const base::string16& frame_xpath,
935 const base::string16& jscript,
938 void OnSetAccessibilityMode(unsigned int new_mode);
939 void OnSetActive(bool active);
940 void OnSetBackground(const SkBitmap& background);
941 void OnSetCompositionFromExistingText(
943 const std::vector<blink::WebCompositionUnderline>& underlines);
944 void OnExitFullscreen();
945 void OnSetEditableSelectionOffsets(int start, int end);
946 void OnSetHistoryLengthAndPrune(int history_length, int32 minimum_page_id);
947 void OnSetInitialFocus(bool reverse);
948 void OnSetPageEncoding(const std::string& encoding_name);
949 void OnSetRendererPrefs(const RendererPreferences& renderer_prefs);
950 void OnSetWebUIProperty(const std::string& name, const std::string& value);
951 void OnSetZoomLevel(double zoom_level);
952 void OnSetZoomLevelForLoadingURL(const GURL& url, double zoom_level);
953 void OnShouldClose();
955 void OnStopFinding(StopFindAction action);
956 void OnSuppressDialogsUntilSwapOut();
958 void OnThemeChanged();
959 void OnUpdateTargetURLAck();
960 void OnUpdateTimezone();
961 void OnUpdateWebPreferences(const WebPreferences& prefs);
962 void OnZoom(PageZoom zoom);
963 void OnZoomFactor(PageZoom zoom, int zoom_center_x, int zoom_center_y);
964 void OnEnableViewSourceMode();
965 void OnDisownOpener();
966 void OnWindowSnapshotCompleted(const int snapshot_id,
967 const gfx::Size& size, const std::vector<unsigned char>& png);
968 #if defined(OS_ANDROID)
969 void OnActivateNearestFindResult(int request_id, float x, float y);
970 void OnFindMatchRects(int current_version);
971 void OnSelectPopupMenuItems(bool canceled,
972 const std::vector<int>& selected_indices);
973 void OnUndoScrollFocusedEditableNodeIntoRect();
974 void OnUpdateTopControlsState(bool enable_hiding,
978 void OnExtractSmartClipData(const gfx::Rect& rect);
979 #elif defined(OS_MACOSX)
980 void OnCopyToFindPboard();
981 void OnPluginImeCompositionCompleted(const base::string16& text,
983 void OnSelectPopupMenuItem(int selected_index);
984 void OnSetInLiveResize(bool in_live_resize);
985 void OnSetWindowVisibility(bool visible);
986 void OnWindowFrameChanged(const gfx::Rect& window_frame,
987 const gfx::Rect& view_frame);
990 // Adding a new message handler? Please add it in alphabetical order above
991 // and put it in the same position in the .cc file.
993 // Misc private functions ----------------------------------------------------
994 void ZoomFactorHelper(PageZoom zoom, int zoom_center_x, int zoom_center_y,
995 float scaling_increment);
997 // Check whether the preferred size has changed.
998 void CheckPreferredSize();
1000 // Initializes |media_stream_client_|, returning true if successful. Returns
1001 // false if it wasn't possible to create a MediaStreamClient (e.g., WebRTC is
1002 // disabled) in which case |media_stream_client_| is NULL.
1003 bool InitializeMediaStreamClient();
1005 // This callback is triggered when DownloadFavicon completes, either
1006 // succesfully or with a failure. See DownloadFavicon for more
1008 void DidDownloadFavicon(ImageResourceFetcher* fetcher,
1009 const SkBitmap& image);
1011 // Requests to download a favicon image. When done, the RenderView is notified
1012 // by way of DidDownloadFavicon. Returns true if the request was successfully
1013 // started, false otherwise. id is used to uniquely identify the request and
1014 // passed back to the DidDownloadFavicon method. If the image has multiple
1015 // frames, the frame whose size is image_size is returned. If the image
1016 // doesn't have a frame at the specified size, the first is returned.
1017 bool DownloadFavicon(int id, const GURL& image_url, int image_size);
1019 // Locates a sub frame with given xpath
1020 blink::WebFrame* GetChildFrame(const base::string16& frame_xpath) const;
1022 // Returns the URL being loaded by the given frame's request.
1023 GURL GetLoadingUrl(blink::WebFrame* frame) const;
1025 // Should only be called if this object wraps a PluginDocument.
1026 blink::WebPlugin* GetWebPluginFromPluginDocument();
1028 // Returns true if the |params| navigation is to an entry that has been
1029 // cropped due to a recent navigation the browser did not know about.
1030 bool IsBackForwardToStaleEntry(const FrameMsg_Navigate_Params& params,
1033 // TODO(nasko): Remove this method when code is migrated to use
1034 // RenderFrameObserver.
1035 void OnNavigate(const FrameMsg_Navigate_Params& params);
1037 // Make this RenderView show an empty, unscriptable page.
1038 void NavigateToSwappedOutURL(blink::WebFrame* frame);
1040 // If we initiated a navigation, this function will populate |document_state|
1041 // with the navigation information saved in OnNavigate().
1042 void PopulateDocumentStateFromPending(DocumentState* document_state);
1044 // Returns a new NavigationState populated with the navigation information
1045 // saved in OnNavigate().
1046 NavigationState* CreateNavigationStateFromPending();
1048 // Processes the command-line flags --enable-viewport,
1049 // --enable-fixed-layout[=w,h] and --enable-pinch.
1050 void ProcessViewLayoutFlags(const CommandLine& command_line);
1052 #if defined(OS_ANDROID)
1053 // Launch an Android content intent with the given URL.
1054 void LaunchAndroidContentIntent(const GURL& intent_url, size_t request_id);
1056 blink::WebMediaPlayer* CreateAndroidWebMediaPlayer(
1057 blink::WebFrame* frame,
1058 const blink::WebURL& url,
1059 blink::WebMediaPlayerClient* client);
1062 blink::WebMediaPlayer* CreateWebMediaPlayerForMediaStream(
1063 blink::WebFrame* frame,
1064 const blink::WebURL& url,
1065 blink::WebMediaPlayerClient* client);
1067 // Sends a reply to the current find operation handling if it was a
1068 // synchronous find request.
1069 void SendFindReply(int request_id,
1072 const blink::WebRect& selection_rect,
1073 bool final_status_update);
1075 // Starts nav_state_sync_timer_ if it isn't already running.
1076 void StartNavStateSyncTimerIfNecessary();
1078 // Dispatches the current state of selection on the webpage to the browser if
1080 // TODO(varunjain): delete this method once we figure out how to keep
1081 // selection handles in sync with the webpage.
1082 void SyncSelectionIfRequired();
1084 #if defined(OS_POSIX) && !defined(OS_MACOSX)
1085 void UpdateFontRenderingFromRendererPrefs();
1087 void UpdateFontRenderingFromRendererPrefs() {}
1090 // Update the target url and tell the browser that the target URL has changed.
1091 // If |url| is empty, show |fallback_url|.
1092 void UpdateTargetURL(const GURL& url, const GURL& fallback_url);
1094 // Tells the browser what the new list of favicons for the webpage is.
1095 void SendUpdateFaviconURL(const std::vector<FaviconURL>& urls);
1097 // Invoked from DidStopLoading(). Sends the current list of loaded favicons to
1099 void DidStopLoadingIcons();
1101 // Coordinate conversion -----------------------------------------------------
1103 gfx::RectF ClientRectToPhysicalWindowRect(const gfx::RectF& rect) const;
1105 // RenderFrameImpl accessible state ------------------------------------------
1106 // The following section is the set of methods that RenderFrameImpl needs
1107 // to access RenderViewImpl state. The set of state variables are page-level
1108 // specific, so they don't belong in RenderFrameImpl and should remain in
1110 ObserverList<RenderViewObserver>& observers() {
1114 // TODO(nasko): Remove this method when we move to frame proxy objects, since
1115 // the concept of swapped out will be eliminated.
1116 void set_is_swapped_out(bool swapped_out) {
1117 is_swapped_out_ = swapped_out;
1120 NavigationGesture navigation_gesture() {
1121 return navigation_gesture_;
1123 void set_navigation_gesture(NavigationGesture gesture) {
1124 navigation_gesture_ = gesture;
1127 // ---------------------------------------------------------------------------
1128 // ADDING NEW FUNCTIONS? Please keep private functions alphabetized and put
1129 // it in the same order in the .cc file as it was in the header.
1130 // ---------------------------------------------------------------------------
1132 // Settings ------------------------------------------------------------------
1134 WebPreferences webkit_preferences_;
1135 RendererPreferences renderer_preferences_;
1137 HostZoomLevels host_zoom_levels_;
1139 // Whether content state (such as form state, scroll position and page
1140 // contents) should be sent to the browser immediately. This is normally
1141 // false, but set to true by some tests.
1142 bool send_content_state_immediately_;
1144 // Bitwise-ORed set of extra bindings that have been enabled. See
1145 // BindingsPolicy for details.
1146 int enabled_bindings_;
1148 // If true, we send IPC messages when |preferred_size_| changes.
1149 bool send_preferred_size_changes_;
1151 // If non-empty, and |send_preferred_size_changes_| is true, disable drawing
1152 // scroll bars on windows smaller than this size. Used for windows that the
1153 // browser resizes to the size of the content, such as browser action popups.
1154 // If a render view is set to the minimum size of its content, webkit may add
1155 // scroll bars. This makes sense for fixed sized windows, but it does not
1156 // make sense when the size of the view was chosen to fit the content.
1157 // This setting ensures that no scroll bars are drawn. The size limit exists
1158 // because if the view grows beyond a size known to the browser, scroll bars
1160 gfx::Size disable_scrollbars_size_limit_;
1162 // Loading state -------------------------------------------------------------
1164 // True if the top level frame is currently being loaded.
1167 // The gesture that initiated the current navigation.
1168 // TODO(nasko): Move to RenderFrame, as this is per-frame state.
1169 NavigationGesture navigation_gesture_;
1172 bool opened_by_user_gesture_;
1174 // Whether this RenderView was created by a frame that was suppressing its
1175 // opener. If so, we may want to load pages in a separate process. See
1176 // decidePolicyForNavigation for details.
1177 bool opener_suppressed_;
1179 // Whether we must stop creating nested message loops for modal dialogs until
1180 // OnSwapOut is called. This is necessary because modal dialogs have a
1181 // PageGroupLoadDeferrer on the stack that interferes with swapping out.
1182 bool suppress_dialogs_until_swap_out_;
1184 // Holds state pertaining to a navigation that we initiated. This is held by
1185 // the WebDataSource::ExtraData attribute. We use pending_navigation_state_
1186 // as a temporary holder for the state until the WebDataSource corresponding
1187 // to the new navigation is created. See DidCreateDataSource.
1188 // TODO(nasko): Move to RenderFrame, as this is per-frame state.
1189 scoped_ptr<FrameMsg_Navigate_Params> pending_navigation_params_;
1191 // Timer used to delay the updating of nav state (see SyncNavigationState).
1192 base::OneShotTimer<RenderViewImpl> nav_state_sync_timer_;
1194 // Page IDs ------------------------------------------------------------------
1195 // See documentation in RenderView.
1198 // Indicates the ID of the last page that we sent a FrameNavigate to the
1199 // browser for. This is used to determine if the most recent transition
1200 // generated a history entry (less than page_id_), or not (equal to or
1201 // greater than). Note that this will be greater than page_id_ if the user
1203 int32 last_page_id_sent_to_browser_;
1205 // The next available page ID to use for this RenderView. These IDs are
1206 // specific to a given RenderView and the frames within it.
1207 int32 next_page_id_;
1209 // The offset of the current item in the history list.
1210 int history_list_offset_;
1212 // The RenderView's current impression of the history length. This includes
1213 // any items that have committed in this process, but because of cross-process
1214 // navigations, the history may have some entries that were committed in other
1215 // processes. We won't know about them until the next navigation in this
1217 int history_list_length_;
1219 // The list of page IDs for each history item this RenderView knows about.
1220 // Some entries may be -1 if they were rendered by other processes or were
1221 // restored from a previous session. This lets us detect attempts to
1222 // navigate to stale entries that have been cropped from our history.
1223 std::vector<int32> history_page_ids_;
1225 // Page info -----------------------------------------------------------------
1227 // The last gotten main frame's encoding.
1228 std::string last_encoding_name_;
1230 // UI state ------------------------------------------------------------------
1232 // The state of our target_url transmissions. When we receive a request to
1233 // send a URL to the browser, we set this to TARGET_INFLIGHT until an ACK
1234 // comes back - if a new request comes in before the ACK, we store the new
1235 // URL in pending_target_url_ and set the status to TARGET_PENDING. If an
1236 // ACK comes back and we are in TARGET_PENDING, we send the stored URL and
1237 // revert to TARGET_INFLIGHT.
1239 // We don't need a queue of URLs to send, as only the latest is useful.
1242 TARGET_INFLIGHT, // We have a request in-flight, waiting for an ACK
1243 TARGET_PENDING // INFLIGHT + we have a URL waiting to be sent
1244 } target_url_status_;
1246 // The URL we show the user in the status bar. We use this to determine if we
1247 // want to send a new one (we do not need to send duplicates). It will be
1248 // equal to either |mouse_over_url_| or |focus_url_|, depending on which was
1252 // The URL the user's mouse is hovering over.
1253 GURL mouse_over_url_;
1255 // The URL that has keyboard focus.
1258 // The next target URL we want to send to the browser.
1259 GURL pending_target_url_;
1261 // The text selection the last time DidChangeSelection got called. May contain
1262 // additional characters before and after the selected text, for IMEs. The
1263 // portion of this string that is the actual selected text starts at index
1264 // |selection_range_.GetMin() - selection_text_offset_| and has length
1265 // |selection_range_.length()|.
1266 base::string16 selection_text_;
1267 // The offset corresponding to the start of |selection_text_| in the document.
1268 size_t selection_text_offset_;
1269 // Range over the document corresponding to the actual selected text (which
1270 // could correspond to a substring of |selection_text_|; see above).
1271 gfx::Range selection_range_;
1273 #if defined(OS_ANDROID)
1274 // Cache the old top controls state constraints. Used when updating
1275 // current value only without altering the constraints.
1276 cc::TopControlsState top_controls_constraints_;
1279 // View ----------------------------------------------------------------------
1281 // Cache the preferred size of the page in order to prevent sending the IPC
1282 // when layout() recomputes but doesn't actually change sizes.
1283 gfx::Size preferred_size_;
1285 // Used to delay determining the preferred size (to avoid intermediate
1286 // states for the sizes).
1287 base::OneShotTimer<RenderViewImpl> check_preferred_size_timer_;
1289 // These store the "is main frame is scrolled all the way to the left
1290 // or right" state that was last sent to the browser.
1291 bool cached_is_main_frame_pinned_to_left_;
1292 bool cached_is_main_frame_pinned_to_right_;
1294 // These store the "has scrollbars" state last sent to the browser.
1295 bool cached_has_main_frame_horizontal_scrollbar_;
1296 bool cached_has_main_frame_vertical_scrollbar_;
1298 // Helper objects ------------------------------------------------------------
1300 scoped_ptr<RenderFrameImpl> main_render_frame_;
1302 // The next group of objects all implement RenderViewObserver, so are deleted
1303 // along with the RenderView automatically. This is why we just store
1306 // Holds a reference to the service which provides desktop notifications.
1307 NotificationProvider* notification_provider_;
1309 // The geolocation dispatcher attached to this view, lazily initialized.
1310 GeolocationDispatcher* geolocation_dispatcher_;
1312 // The speech dispatcher attached to this view, lazily initialized.
1313 InputTagSpeechDispatcher* input_tag_speech_dispatcher_;
1315 // The speech recognition dispatcher attached to this view, lazily
1317 SpeechRecognitionDispatcher* speech_recognition_dispatcher_;
1319 // Device orientation dispatcher attached to this view; lazily initialized.
1320 DeviceOrientationDispatcher* device_orientation_dispatcher_;
1322 // MediaStream dispatcher attached to this view; lazily initialized.
1323 MediaStreamDispatcher* media_stream_dispatcher_;
1325 // BrowserPluginManager attached to this view; lazily initialized.
1326 scoped_refptr<BrowserPluginManager> browser_plugin_manager_;
1328 // MediaStreamClient attached to this view; lazily initialized.
1329 MediaStreamClient* media_stream_client_;
1330 blink::WebUserMediaClient* web_user_media_client_;
1332 // MidiClient attached to this view; lazily initialized.
1333 MidiDispatcher* midi_dispatcher_;
1335 DevToolsAgent* devtools_agent_;
1337 // The current accessibility mode.
1338 unsigned int accessibility_mode_;
1340 // Only valid if |accessibility_mode_| is anything other than
1341 // AccessibilityModeOff.
1342 RendererAccessibility* renderer_accessibility_;
1344 // Mouse Lock dispatcher attached to this view.
1345 MouseLockDispatcher* mouse_lock_dispatcher_;
1347 #if defined(OS_ANDROID)
1348 // Android Specific ---------------------------------------------------------
1350 // The background color of the document body element. This is used as the
1351 // default background color for filling the screen areas for which we don't
1352 // have the actual content.
1353 SkColor body_background_color_;
1355 // Expected id of the next content intent launched. Used to prevent scheduled
1356 // intents to be launched if aborted.
1357 size_t expected_content_intent_id_;
1359 // List of click-based content detectors.
1360 typedef std::vector< linked_ptr<ContentDetector> > ContentDetectorList;
1361 ContentDetectorList content_detectors_;
1363 // The media player manager for managing all the media players on this view
1364 // for communicating with the real media player objects in browser process.
1365 RendererMediaPlayerManager* media_player_manager_;
1367 // A date/time picker object for date and time related input elements.
1368 scoped_ptr<RendererDateTimePicker> date_time_picker_client_;
1371 // Plugins -------------------------------------------------------------------
1373 // All the currently active plugin delegates for this RenderView; kept so
1374 // that we can enumerate them to send updates about things like window
1375 // location or tab focus and visibily. These are non-owning references.
1376 std::set<WebPluginDelegateProxy*> plugin_delegates_;
1379 // The ID of the focused NPAPI plug-in.
1380 int focused_plugin_id_;
1383 #if defined(ENABLE_PLUGINS)
1384 typedef std::set<PepperPluginInstanceImpl*> PepperPluginSet;
1385 PepperPluginSet active_pepper_instances_;
1387 // TODO(jam): these belong on RenderFrame, once the browser knows which frame
1388 // is focused and sends the IPCs which use these to the correct frame. Until
1389 // then, we must store these on RenderView as that's the one place that knows
1390 // about all the RenderFrames for a page.
1392 // Whether or not the focus is on a PPAPI plugin
1393 PepperPluginInstanceImpl* focused_pepper_plugin_;
1395 // The plugin instance that received the last mouse event. It is set to NULL
1396 // if the last mouse event went to elements other than Pepper plugins.
1397 // |pepper_last_mouse_event_target_| is not owned by this class. We depend on
1398 // the RenderFrameImpl to NULL it out when it destructs.
1399 PepperPluginInstanceImpl* pepper_last_mouse_event_target_;
1402 // Misc ----------------------------------------------------------------------
1404 // The current and pending file chooser completion objects. If the queue is
1405 // nonempty, the first item represents the currently running file chooser
1406 // callback, and the remaining elements are the other file chooser completion
1407 // still waiting to be run (in order).
1408 struct PendingFileChooser;
1409 std::deque< linked_ptr<PendingFileChooser> > file_chooser_completions_;
1411 // The current directory enumeration callback
1412 std::map<int, blink::WebFileChooserCompletion*> enumeration_completions_;
1413 int enumeration_completion_id_;
1415 // Reports load progress to the browser.
1416 scoped_ptr<LoadProgressTracker> load_progress_tracker_;
1418 // The SessionStorage namespace that we're assigned to has an ID, and that ID
1419 // is passed to us upon creation. WebKit asks for this ID upon first use and
1420 // uses it whenever asking the browser process to allocate new storage areas.
1421 int64 session_storage_namespace_id_;
1423 // Stores edit commands associated to the next key event.
1424 // Shall be cleared as soon as the next key event is processed.
1425 EditCommands edit_commands_;
1427 // The external popup for the currently showing select popup.
1428 scoped_ptr<ExternalPopupMenu> external_popup_menu_;
1430 // The node that the context menu was pressed over.
1431 blink::WebNode context_menu_node_;
1433 // All the registered observers. We expect this list to be small, so vector
1435 ObserverList<RenderViewObserver> observers_;
1437 // Used to inform didChangeSelection() when it is called in the context
1438 // of handling a InputMsg_SelectRange IPC.
1439 bool handling_select_range_;
1441 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface.
1442 scoped_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_;
1444 // State associated with the GetWindowSnapshot function.
1445 int next_snapshot_id_;
1446 typedef std::map<int, WindowSnapshotCallback> PendingSnapshotMap;
1447 PendingSnapshotMap pending_snapshots_;
1449 // Allows to selectively disable partial buffer swap for this renderer's
1451 bool allow_partial_swap_;
1453 // This field stores drag/drop related info for the event that is currently
1454 // being handled. If the current event results in starting a drag/drop
1455 // session, this info is sent to the browser along with other drag/drop info.
1456 DragEventSourceInfo possible_drag_event_info_;
1458 // NOTE: stats_collection_observer_ should be the last members because their
1459 // constructors call the AddObservers method of RenderViewImpl.
1460 scoped_ptr<StatsCollectionObserver> stats_collection_observer_;
1462 // ---------------------------------------------------------------------------
1463 // ADDING NEW DATA? Please see if it fits appropriately in one of the above
1464 // sections rather than throwing it randomly at the end. If you're adding a
1465 // bunch of stuff, you should probably create a helper class and put your
1466 // data and methods on that to avoid bloating RenderView more. You can
1467 // use the Observer interface to filter IPC messages and receive frame change
1469 // ---------------------------------------------------------------------------
1471 DISALLOW_COPY_AND_ASSIGN(RenderViewImpl);
1474 } // namespace content
1476 #endif // CONTENT_RENDERER_RENDER_VIEW_IMPL_H_