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