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