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