blob: c57c03ab8316f2bc51f5cb8c6a96663a2844872c [file] [log] [blame]
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001// 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.
4
5#ifndef CONTENT_RENDERER_RENDER_VIEW_IMPL_H_
6#define CONTENT_RENDERER_RENDER_VIEW_IMPL_H_
7
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00008#include <deque>
9#include <map>
Torne (Richard Coles)58218062012-11-14 11:43:16 +000010#include <set>
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000011#include <string>
12#include <vector>
Torne (Richard Coles)58218062012-11-14 11:43:16 +000013
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"
Ben Murdochbbcdd452013-07-25 10:06:34 +010020#include "base/process/process.h"
Ben Murdocheb525c52013-07-10 11:40:50 +010021#include "base/timer/timer.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000022#include "build/build_config.h"
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +010023#include "cc/input/top_controls_state.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000024#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"
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +010035#include "content/public/common/top_controls_state.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000036#include "content/public/renderer/render_view.h"
Ben Murdoch7dbb3d52013-07-17 14:55:54 +010037#include "content/renderer/media/webmediaplayer_delegate.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000038#include "content/renderer/mouse_lock_dispatcher.h"
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010039#include "content/renderer/render_frame_impl.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000040#include "content/renderer/render_widget.h"
41#include "content/renderer/renderer_webcookiejar_impl.h"
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010042#include "content/renderer/stats_collection_observer.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000043#include "ipc/ipc_platform_file.h"
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010044#include "third_party/WebKit/public/platform/WebFileSystem.h"
45#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
Torne (Richard Coles)7d4cd472013-06-19 11:58:07 +010046#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"
Ben Murdocheb525c52013-07-10 11:40:50 +010058#include "ui/base/ui_base_types.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000059#include "ui/surface/transport_dib.h"
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010060#include "webkit/common/webpreferences.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000061
62#if defined(OS_ANDROID)
63#include "content/renderer/android/content_detector.h"
Torne (Richard Coles)7d4cd472013-06-19 11:58:07 +010064#include "third_party/WebKit/public/web/WebContentDetectionResult.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000065#endif
66
67#if defined(COMPILER_MSVC)
68// RenderViewImpl is a diamond-shaped hierarchy, with WebWidgetClient at the
69// root. VS warns when we inherit the WebWidgetClient method implementations
70// from RenderWidget. It's safe to ignore that warning.
71#pragma warning(disable: 4250)
72#endif
73
74class CommandLine;
75class PepperDeviceTest;
76class SkBitmap;
77struct PP_NetAddress_Private;
78struct ViewMsg_Navigate_Params;
79struct ViewMsg_PostMessage_Params;
80struct ViewMsg_StopFinding_Params;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000081
82namespace ui {
83struct SelectedFileInfo;
84} // namespace ui
85
Torne (Richard Coles)58218062012-11-14 11:43:16 +000086namespace WebKit {
87class WebApplicationCacheHost;
88class WebApplicationCacheHostClient;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000089class WebDOMMessageEvent;
90class WebDataSource;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000091class WebDateTimeChooserCompletion;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000092class WebDragData;
93class WebGeolocationClient;
94class WebGestureEvent;
95class WebIconURL;
96class WebImage;
97class WebPeerConnection00Handler;
98class WebPeerConnection00HandlerClient;
99class WebMediaPlayer;
100class WebMediaPlayerClient;
101class WebMouseEvent;
102class WebPeerConnectionHandler;
103class WebPeerConnectionHandlerClient;
104class WebSocketStreamHandle;
105class WebSpeechInputController;
106class WebSpeechInputListener;
107class WebSpeechRecognizer;
108class WebStorageNamespace;
109class WebTouchEvent;
110class WebURLRequest;
111class WebUserMediaClient;
112struct WebActiveWheelFlingParameters;
Ben Murdoch32409262013-08-07 11:04:47 +0100113struct WebCursorInfo;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000114struct WebDateTimeChooserParams;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000115struct WebFileChooserParams;
116struct WebFindOptions;
117struct WebMediaPlayerAction;
118struct WebPluginAction;
119struct WebPoint;
120struct WebWindowFeatures;
121
122#if defined(OS_ANDROID)
123class WebHitTestResult;
124#endif
125}
126
Ben Murdochbbcdd452013-07-25 10:06:34 +0100127namespace webkit_glue {
128class WebURLResponseExtraDataImpl;
129}
130
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000131namespace content {
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000132class BrowserPluginManager;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000133class DeviceOrientationDispatcher;
134class DevToolsAgent;
135class DocumentState;
136class DomAutomationController;
137class ExternalPopupMenu;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000138class FaviconHelper;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000139class GeolocationDispatcher;
Torne (Richard Coles)a93a17c2013-05-15 11:34:50 +0100140class ImageResourceFetcher;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000141class InputTagSpeechDispatcher;
142class JavaBridgeDispatcher;
143class LoadProgressTracker;
Ben Murdoch58e6fbe2013-07-26 10:20:38 +0100144class MIDIDispatcher;
Ben Murdoch7dbb3d52013-07-17 14:55:54 +0100145class MediaStreamClient;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000146class MediaStreamDispatcher;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000147class MouseLockDispatcher;
148class NavigationState;
149class NotificationProvider;
Ben Murdoch58e6fbe2013-07-26 10:20:38 +0100150class PepperPluginInstanceImpl;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000151class RenderViewObserver;
152class RenderViewTest;
153class RendererAccessibility;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000154class RendererDateTimePicker;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000155class RendererPpapiHost;
156class RendererWebColorChooserImpl;
157class RenderWidgetFullscreenPepper;
158class SpeechRecognitionDispatcher;
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100159class StatsCollectionController;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000160class WebPluginDelegateProxy;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000161struct CustomContextMenuContext;
Ben Murdocheb525c52013-07-10 11:40:50 +0100162struct DropData;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100163struct FaviconURL;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000164struct FileChooserParams;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000165struct RenderViewImplParams;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000166
167#if defined(OS_ANDROID)
Ben Murdoch7dbb3d52013-07-17 14:55:54 +0100168class RendererMediaPlayerManager;
Ben Murdocheb525c52013-07-10 11:40:50 +0100169class WebMediaPlayerProxyAndroid;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000170#endif
171
172// We need to prevent a page from trying to create infinite popups. It is not
173// as simple as keeping a count of the number of immediate children
174// popups. Having an html file that window.open()s itself would create
175// an unlimited chain of RenderViews who only have one RenderView child.
176//
177// Therefore, each new top level RenderView creates a new counter and shares it
178// with all its children and grandchildren popup RenderViewImpls created with
179// createView() to have a sort of global limit for the page so no more than
180// kMaximumNumberOfPopups popups are created.
181//
182// This is a RefCounted holder of an int because I can't say
183// scoped_refptr<int>.
184typedef base::RefCountedData<int> SharedRenderViewCounter;
185
186//
187// RenderView is an object that manages a WebView object, and provides a
188// communication interface with an embedding application process
189//
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000190class CONTENT_EXPORT RenderViewImpl
191 : public RenderWidget,
192 NON_EXPORTED_BASE(public WebKit::WebViewClient),
193 NON_EXPORTED_BASE(public WebKit::WebFrameClient),
194 NON_EXPORTED_BASE(public WebKit::WebPageSerializerClient),
195 public RenderView,
Ben Murdoch7dbb3d52013-07-17 14:55:54 +0100196 NON_EXPORTED_BASE(public WebMediaPlayerDelegate),
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000197 public base::SupportsWeakPtr<RenderViewImpl> {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000198 public:
199 // Creates a new RenderView. If this is a blocked popup or as a new tab,
200 // opener_id is the routing ID of the RenderView responsible for creating this
201 // RenderView. |counter| is either a currently initialized counter, or NULL
202 // (in which case we treat this RenderView as a top level window).
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000203 static RenderViewImpl* Create(
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000204 int32 opener_id,
205 const RendererPreferences& renderer_prefs,
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100206 const WebPreferences& webkit_prefs,
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000207 SharedRenderViewCounter* counter,
208 int32 routing_id,
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100209 int32 main_frame_routing_id,
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000210 int32 surface_id,
211 int64 session_storage_namespace_id,
212 const string16& frame_name,
213 bool is_renderer_created,
214 bool swapped_out,
215 int32 next_page_id,
216 const WebKit::WebScreenInfo& screen_info,
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000217 AccessibilityMode accessibility_mode,
218 bool allow_partial_swap);
219
220 // Used by content_layouttest_support to hook into the creation of
221 // RenderViewImpls.
222 static void InstallCreateHook(
223 RenderViewImpl* (*create_render_view_impl)(RenderViewImplParams*));
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000224
225 // Returns the RenderViewImpl containing the given WebView.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000226 static RenderViewImpl* FromWebView(WebKit::WebView* webview);
227
228 // Returns the RenderViewImpl for the given routing ID.
229 static RenderViewImpl* FromRoutingID(int routing_id);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000230
231 // May return NULL when the view is closing.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000232 WebKit::WebView* webview() const;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000233
234 int history_list_offset() const { return history_list_offset_; }
235
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100236 const WebPreferences& webkit_preferences() const {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000237 return webkit_preferences_;
238 }
239
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000240 void set_send_content_state_immediately(bool value) {
241 send_content_state_immediately_ = value;
242 }
243
244 MediaStreamDispatcher* media_stream_dispatcher() {
245 return media_stream_dispatcher_;
246 }
247
248 MouseLockDispatcher* mouse_lock_dispatcher() {
249 return mouse_lock_dispatcher_;
250 }
251
Ben Murdochca12bfa2013-07-23 11:17:05 +0100252 RendererWebCookieJarImpl* cookie_jar() { return &cookie_jar_; }
253
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000254#if defined(OS_ANDROID)
Ben Murdoch7dbb3d52013-07-17 14:55:54 +0100255 RendererMediaPlayerManager* media_player_manager() {
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000256 return media_player_manager_.get();
257 }
258#endif
259
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000260 // Lazily initialize this view's BrowserPluginManager and return it.
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100261 BrowserPluginManager* GetBrowserPluginManager();
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000262
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000263 // Functions to add and remove observers for this object.
264 void AddObserver(RenderViewObserver* observer);
265 void RemoveObserver(RenderViewObserver* observer);
266
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100267 // Returns the StatsCollectionObserver associated with this view, or NULL
268 // if one wasn't created;
269 StatsCollectionObserver* GetStatsCollectionObserver() {
270 return stats_collection_observer_.get();
271 }
272
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000273 // Adds the given file chooser request to the file_chooser_completion_ queue
274 // (see that var for more) and requests the chooser be displayed if there are
275 // no other waiting items in the queue.
276 //
277 // Returns true if the chooser was successfully scheduled. False means we
278 // didn't schedule anything.
279 bool ScheduleFileChooser(const FileChooserParams& params,
280 WebKit::WebFileChooserCompletion* completion);
281
282 void LoadNavigationErrorPage(
283 WebKit::WebFrame* frame,
284 const WebKit::WebURLRequest& failed_request,
285 const WebKit::WebURLError& error,
286 const std::string& html,
287 bool replace);
288
289 // Plugin-related functions --------------------------------------------------
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000290
Ben Murdoch32409262013-08-07 11:04:47 +0100291#if defined(ENABLE_PLUGINS)
292 // Indicates that the given instance has been created.
293 void PepperInstanceCreated(PepperPluginInstanceImpl* instance);
294
295 // Indicates that the given instance is being destroyed. This is called from
296 // the destructor, so it's important that the instance is not dereferenced
297 // from this call.
298 void PepperInstanceDeleted(PepperPluginInstanceImpl* instance);
299
300 // Notifies that |instance| has changed the cursor.
301 // This will update the cursor appearance if it is currently over the plugin
302 // instance.
303 void PepperDidChangeCursor(PepperPluginInstanceImpl* instance,
304 const WebKit::WebCursorInfo& cursor);
305
306 // Notifies that |instance| has received a mouse event.
307 void PepperDidReceiveMouseEvent(PepperPluginInstanceImpl* instance);
308
309 // Notification that the given plugin is focused or unfocused.
310 void PepperFocusChanged(PepperPluginInstanceImpl* instance, bool focused);
311
312 // Informs the render view that a PPAPI plugin has changed text input status.
313 void PepperTextInputTypeChanged(PepperPluginInstanceImpl* instance);
314 void PepperCaretPositionChanged(PepperPluginInstanceImpl* instance);
315
316 // Cancels current composition.
317 void PepperCancelComposition(PepperPluginInstanceImpl* instance);
318
319 // Informs the render view that a PPAPI plugin has changed selection.
320 void PepperSelectionChanged(PepperPluginInstanceImpl* instance);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000321
322 // Creates a fullscreen container for a pepper plugin instance.
323 RenderWidgetFullscreenPepper* CreatePepperFullscreenContainer(
Ben Murdoch58e6fbe2013-07-26 10:20:38 +0100324 PepperPluginInstanceImpl* plugin);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000325
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000326 // Notification that a PPAPI plugin has been created.
Ben Murdoch32409262013-08-07 11:04:47 +0100327 void PepperPluginCreated(RendererPpapiHost* host);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000328
329 // Retrieves the current caret position if a PPAPI plugin has focus.
Ben Murdoch32409262013-08-07 11:04:47 +0100330 bool GetPepperCaretBounds(gfx::Rect* rect);
331
332 bool IsPepperAcceptingCompositionEvents() const;
Ben Murdoch32409262013-08-07 11:04:47 +0100333
334 // Notification that the given plugin has crashed.
335 void PluginCrashed(const base::FilePath& plugin_path,
336 base::ProcessId plugin_pid);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000337
338 // Simulates IME events for testing purpose.
339 void SimulateImeSetComposition(
340 const string16& text,
341 const std::vector<WebKit::WebCompositionUnderline>& underlines,
342 int selection_start,
343 int selection_end);
344 void SimulateImeConfirmComposition(const string16& text,
345 const ui::Range& replacement_range);
346
347#if defined(OS_MACOSX) || defined(OS_WIN)
348 // Informs the render view that the given plugin has gained or lost focus.
349 void PluginFocusChanged(bool focused, int plugin_id);
350#endif
351
352#if defined(OS_MACOSX)
353 // Starts plugin IME.
354 void StartPluginIme();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000355#endif
356
357 void RegisterPluginDelegate(WebPluginDelegateProxy* delegate);
358 void UnregisterPluginDelegate(WebPluginDelegateProxy* delegate);
359
360 // Helper function to retrieve information about a plugin for a URL and mime
361 // type. Returns false if no plugin was found.
362 // |actual_mime_type| is the actual mime type supported by the
363 // plugin found that match the URL given (one for each item in
364 // |info|).
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000365 bool GetPluginInfo(const GURL& url,
366 const GURL& page_url,
367 const std::string& mime_type,
Ben Murdochca12bfa2013-07-23 11:17:05 +0100368 WebPluginInfo* plugin_info,
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000369 std::string* actual_mime_type);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000370
Ben Murdochbb1529c2013-08-08 10:24:53 +0100371#endif // ENABLE_PLUGINS
372
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000373 void TransferActiveWheelFlingAnimation(
374 const WebKit::WebActiveWheelFlingParameters& params);
375
376 // Returns true if the focused element is editable text from the perspective
377 // of IME support (also used for on-screen keyboard). Works correctly inside
378 // supported PPAPI plug-ins.
379 bool HasIMETextFocus();
380
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000381 // Callback for use with GetWindowSnapshot.
382 typedef base::Callback<void(
383 const gfx::Size&, const std::vector<unsigned char>&)>
384 WindowSnapshotCallback;
385
386 void GetWindowSnapshot(const WindowSnapshotCallback& callback);
387
388 // Dispatches the current navigation state to the browser. Called on a
389 // periodic timer so we don't send too many messages.
390 void SyncNavigationState();
391
392 // Returns the length of the session history of this RenderView. Note that
393 // this only coincides with the actual length of the session history if this
394 // RenderView is the currently active RenderView of a WebContents.
395 unsigned GetLocalSessionHistoryLengthForTesting() const;
396
397 // Invokes OnSetFocus and marks the widget as active depending on the value
398 // of |enable|. This is used for layout tests that need to control the focus
399 // synchronously from the renderer.
400 void SetFocusAndActivateForTesting(bool enable);
401
402 // Change the device scale factor and force the compositor to resize.
403 void SetDeviceScaleFactorForTesting(float factor);
404
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +0100405 // Control autoresize mode.
406 void EnableAutoResizeForTesting(const gfx::Size& min_size,
407 const gfx::Size& max_size);
408 void DisableAutoResizeForTesting(const gfx::Size& new_size);
409
Ben Murdoch7dbb3d52013-07-17 14:55:54 +0100410 // Overrides the MediaStreamClient used when creating MediaStream players.
411 // Must be called before any players are created.
412 void SetMediaStreamClientForTesting(MediaStreamClient* media_stream_client);
413
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000414 // IPC::Listener implementation ----------------------------------------------
415
416 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
417
418 // WebKit::WebWidgetClient implementation ------------------------------------
419
420 // Most methods are handled by RenderWidget.
421 virtual void didFocus();
422 virtual void didBlur();
423 virtual void show(WebKit::WebNavigationPolicy policy);
424 virtual void runModal();
425 virtual bool enterFullScreen();
426 virtual void exitFullScreen();
427 virtual bool requestPointerLock();
428 virtual void requestPointerUnlock();
429 virtual bool isPointerLocked();
430 virtual void didActivateCompositor(int input_handler_identifier);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000431 virtual void didHandleGestureEvent(const WebKit::WebGestureEvent& event,
432 bool event_cancelled) OVERRIDE;
Ben Murdocha3f7b4e2013-07-24 10:36:34 +0100433 virtual void initializeLayerTreeView() OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000434
435 // WebKit::WebViewClient implementation --------------------------------------
436
437 virtual WebKit::WebView* createView(
438 WebKit::WebFrame* creator,
439 const WebKit::WebURLRequest& request,
440 const WebKit::WebWindowFeatures& features,
441 const WebKit::WebString& frame_name,
442 WebKit::WebNavigationPolicy policy);
443 virtual WebKit::WebWidget* createPopupMenu(WebKit::WebPopupType popup_type);
444 virtual WebKit::WebExternalPopupMenu* createExternalPopupMenu(
445 const WebKit::WebPopupMenuInfo& popup_menu_info,
446 WebKit::WebExternalPopupMenuClient* popup_menu_client);
Ben Murdocheb525c52013-07-10 11:40:50 +0100447 virtual WebKit::WebStorageNamespace* createSessionStorageNamespace();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000448 virtual void didAddMessageToConsole(
449 const WebKit::WebConsoleMessage& message,
450 const WebKit::WebString& source_name,
451 unsigned source_line);
452 virtual void printPage(WebKit::WebFrame* frame);
453 virtual WebKit::WebNotificationPresenter* notificationPresenter();
454 virtual bool enumerateChosenDirectory(
455 const WebKit::WebString& path,
456 WebKit::WebFileChooserCompletion* chooser_completion);
457 virtual void initializeHelperPluginWebFrame(WebKit::WebHelperPlugin*);
458 virtual void didStartLoading();
459 virtual void didStopLoading();
460 virtual void didChangeLoadProgress(WebKit::WebFrame* frame,
461 double load_progress);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000462 virtual void didCancelCompositionOnSelectionChange();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000463 virtual void didChangeSelection(bool is_selection_empty);
464 virtual void didExecuteCommand(const WebKit::WebString& command_name);
465 virtual bool handleCurrentKeyboardEvent();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000466 virtual WebKit::WebColorChooser* createColorChooser(
467 WebKit::WebColorChooserClient*, const WebKit::WebColor& initial_color);
468 virtual bool runFileChooser(
469 const WebKit::WebFileChooserParams& params,
470 WebKit::WebFileChooserCompletion* chooser_completion);
471 virtual void runModalAlertDialog(WebKit::WebFrame* frame,
472 const WebKit::WebString& message);
473 virtual bool runModalConfirmDialog(WebKit::WebFrame* frame,
474 const WebKit::WebString& message);
475 virtual bool runModalPromptDialog(WebKit::WebFrame* frame,
476 const WebKit::WebString& message,
477 const WebKit::WebString& default_value,
478 WebKit::WebString* actual_value);
479 virtual bool runModalBeforeUnloadDialog(WebKit::WebFrame* frame,
Torne (Richard Coles)a93a17c2013-05-15 11:34:50 +0100480 bool is_reload,
481 const WebKit::WebString& message);
482 // DEPRECATED
483 virtual bool runModalBeforeUnloadDialog(WebKit::WebFrame* frame,
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000484 const WebKit::WebString& message);
485 virtual void showContextMenu(WebKit::WebFrame* frame,
486 const WebKit::WebContextMenuData& data);
487 virtual void setStatusText(const WebKit::WebString& text);
488 virtual void setMouseOverURL(const WebKit::WebURL& url);
489 virtual void setKeyboardFocusURL(const WebKit::WebURL& url);
490 virtual void startDragging(WebKit::WebFrame* frame,
491 const WebKit::WebDragData& data,
492 WebKit::WebDragOperationsMask mask,
493 const WebKit::WebImage& image,
494 const WebKit::WebPoint& imageOffset);
495 virtual bool acceptsLoadDrops();
496 virtual void focusNext();
497 virtual void focusPrevious();
498 virtual void focusedNodeChanged(const WebKit::WebNode& node);
499 virtual void numberOfWheelEventHandlersChanged(unsigned num_handlers);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000500 virtual void didUpdateLayout();
501#if defined(OS_ANDROID)
502 virtual bool didTapMultipleTargets(
503 const WebKit::WebGestureEvent& event,
504 const WebKit::WebVector<WebKit::WebRect>& target_rects);
505#endif
506 virtual void navigateBackForwardSoon(int offset);
507 virtual int historyBackListCount();
508 virtual int historyForwardListCount();
509 virtual void postAccessibilityNotification(
510 const WebKit::WebAccessibilityObject& obj,
511 WebKit::WebAccessibilityNotification notification);
512 virtual void didUpdateInspectorSetting(const WebKit::WebString& key,
513 const WebKit::WebString& value);
514 virtual WebKit::WebGeolocationClient* geolocationClient();
515 virtual WebKit::WebSpeechInputController* speechInputController(
516 WebKit::WebSpeechInputListener* listener);
517 virtual WebKit::WebSpeechRecognizer* speechRecognizer();
518 virtual WebKit::WebDeviceOrientationClient* deviceOrientationClient();
519 virtual void zoomLimitsChanged(double minimum_level, double maximum_level);
520 virtual void zoomLevelChanged();
Ben Murdoch58e6fbe2013-07-26 10:20:38 +0100521 virtual double zoomLevelToZoomFactor(double zoom_level) const;
522 virtual double zoomFactorToZoomLevel(double factor) const;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000523 virtual void registerProtocolHandler(const WebKit::WebString& scheme,
524 const WebKit::WebString& base_url,
525 const WebKit::WebString& url,
526 const WebKit::WebString& title);
527 virtual WebKit::WebPageVisibilityState visibilityState() const;
528 virtual WebKit::WebUserMediaClient* userMediaClient();
Ben Murdoch58e6fbe2013-07-26 10:20:38 +0100529 virtual WebKit::WebMIDIClient* webMIDIClient();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000530 virtual void draggableRegionsChanged();
531
532#if defined(OS_ANDROID)
533 virtual void scheduleContentIntent(const WebKit::WebURL& intent);
534 virtual void cancelScheduledContentIntents();
535 virtual WebKit::WebContentDetectionResult detectContentAround(
536 const WebKit::WebHitTestResult& touch_hit);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000537
538 // Only used on Android since all other platforms implement
539 // date and time input fields using MULTIPLE_FIELDS_UI
540 virtual bool openDateTimeChooser(const WebKit::WebDateTimeChooserParams&,
541 WebKit::WebDateTimeChooserCompletion*);
Torne (Richard Coles)7d4cd472013-06-19 11:58:07 +0100542 virtual void didScrollWithKeyboard(const WebKit::WebSize& delta);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000543#endif
544
545 // WebKit::WebFrameClient implementation -------------------------------------
546
547 virtual WebKit::WebPlugin* createPlugin(
548 WebKit::WebFrame* frame,
549 const WebKit::WebPluginParams& params);
550 virtual WebKit::WebSharedWorker* createSharedWorker(
551 WebKit::WebFrame* frame, const WebKit::WebURL& url,
552 const WebKit::WebString& name, unsigned long long documentId);
553 virtual WebKit::WebMediaPlayer* createMediaPlayer(
554 WebKit::WebFrame* frame,
555 const WebKit::WebURL& url,
556 WebKit::WebMediaPlayerClient* client);
557 virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(
558 WebKit::WebFrame* frame,
559 WebKit::WebApplicationCacheHostClient* client);
560 virtual WebKit::WebCookieJar* cookieJar(WebKit::WebFrame* frame);
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100561 virtual void didAccessInitialDocument(WebKit::WebFrame* frame);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000562 virtual void didCreateFrame(WebKit::WebFrame* parent,
563 WebKit::WebFrame* child);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000564 virtual void didDisownOpener(WebKit::WebFrame* frame);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000565 virtual void frameDetached(WebKit::WebFrame* frame);
566 virtual void willClose(WebKit::WebFrame* frame);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000567 virtual void didChangeName(WebKit::WebFrame* frame,
568 const WebKit::WebString& name);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000569 virtual void loadURLExternally(WebKit::WebFrame* frame,
570 const WebKit::WebURLRequest& request,
571 WebKit::WebNavigationPolicy policy);
572 virtual void loadURLExternally(WebKit::WebFrame* frame,
573 const WebKit::WebURLRequest& request,
574 WebKit::WebNavigationPolicy policy,
575 const WebKit::WebString& suggested_name);
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100576
577 // The WebDataSource::ExtraData* is assumed to be a DocumentState* subclass.
578 virtual WebKit::WebNavigationPolicy decidePolicyForNavigation(
579 WebKit::WebFrame* frame,
580 WebKit::WebDataSource::ExtraData* extraData,
581 const WebKit::WebURLRequest& request,
582 WebKit::WebNavigationType type,
583 WebKit::WebNavigationPolicy default_policy,
584 bool is_redirect);
585 // DEPRECATED.
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000586 virtual WebKit::WebNavigationPolicy decidePolicyForNavigation(
587 WebKit::WebFrame* frame,
588 const WebKit::WebURLRequest& request,
589 WebKit::WebNavigationType type,
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000590 WebKit::WebNavigationPolicy default_policy,
591 bool is_redirect);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000592 virtual void willSendSubmitEvent(WebKit::WebFrame* frame,
593 const WebKit::WebFormElement& form);
594 virtual void willSubmitForm(WebKit::WebFrame* frame,
595 const WebKit::WebFormElement& form);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000596 virtual void didCreateDataSource(WebKit::WebFrame* frame,
597 WebKit::WebDataSource* datasource);
598 virtual void didStartProvisionalLoad(WebKit::WebFrame* frame);
599 virtual void didReceiveServerRedirectForProvisionalLoad(
600 WebKit::WebFrame* frame);
601 virtual void didFailProvisionalLoad(WebKit::WebFrame* frame,
602 const WebKit::WebURLError& error);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000603 virtual void didCommitProvisionalLoad(WebKit::WebFrame* frame,
604 bool is_new_navigation);
605 virtual void didClearWindowObject(WebKit::WebFrame* frame);
606 virtual void didCreateDocumentElement(WebKit::WebFrame* frame);
607 virtual void didReceiveTitle(WebKit::WebFrame* frame,
608 const WebKit::WebString& title,
609 WebKit::WebTextDirection direction);
610 virtual void didChangeIcon(WebKit::WebFrame*,
Ben Murdocheb525c52013-07-10 11:40:50 +0100611 WebKit::WebIconURL::Type);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000612 virtual void didFinishDocumentLoad(WebKit::WebFrame* frame);
613 virtual void didHandleOnloadEvents(WebKit::WebFrame* frame);
614 virtual void didFailLoad(WebKit::WebFrame* frame,
615 const WebKit::WebURLError& error);
616 virtual void didFinishLoad(WebKit::WebFrame* frame);
617 virtual void didNavigateWithinPage(WebKit::WebFrame* frame,
618 bool is_new_navigation);
619 virtual void didUpdateCurrentHistoryItem(WebKit::WebFrame* frame);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000620 virtual void willSendRequest(WebKit::WebFrame* frame,
621 unsigned identifier,
622 WebKit::WebURLRequest& request,
623 const WebKit::WebURLResponse& redirect_response);
624 virtual void didReceiveResponse(WebKit::WebFrame* frame,
625 unsigned identifier,
626 const WebKit::WebURLResponse& response);
627 virtual void didFinishResourceLoad(WebKit::WebFrame* frame,
628 unsigned identifier);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000629 virtual void didLoadResourceFromMemoryCache(
630 WebKit::WebFrame* frame,
631 const WebKit::WebURLRequest& request,
632 const WebKit::WebURLResponse&);
633 virtual void didDisplayInsecureContent(WebKit::WebFrame* frame);
634 virtual void didRunInsecureContent(
635 WebKit::WebFrame* frame,
636 const WebKit::WebSecurityOrigin& origin,
637 const WebKit::WebURL& target);
638 virtual void didExhaustMemoryAvailableForScript(WebKit::WebFrame* frame);
639 virtual void didCreateScriptContext(WebKit::WebFrame* frame,
640 v8::Handle<v8::Context>,
641 int extension_group,
642 int world_id);
643 virtual void willReleaseScriptContext(WebKit::WebFrame* frame,
644 v8::Handle<v8::Context>,
645 int world_id);
646 virtual void didChangeScrollOffset(WebKit::WebFrame* frame);
Ben Murdocheb525c52013-07-10 11:40:50 +0100647 virtual void willInsertBody(WebKit::WebFrame* frame);
648 virtual void didFirstVisuallyNonEmptyLayout(WebKit::WebFrame*);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000649 virtual void didChangeContentsSize(WebKit::WebFrame* frame,
650 const WebKit::WebSize& size);
651 virtual void reportFindInPageMatchCount(int request_id,
652 int count,
653 bool final_update);
654 virtual void reportFindInPageSelection(int request_id,
655 int active_match_ordinal,
656 const WebKit::WebRect& sel);
657 virtual void openFileSystem(WebKit::WebFrame* frame,
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000658 WebKit::WebFileSystemType type,
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000659 long long size,
660 bool create,
661 WebKit::WebFileSystemCallbacks* callbacks);
662 virtual void deleteFileSystem(WebKit::WebFrame* frame,
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000663 WebKit::WebFileSystemType type,
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000664 WebKit::WebFileSystemCallbacks* callbacks);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000665 virtual void requestStorageQuota(
666 WebKit::WebFrame* frame,
667 WebKit::WebStorageQuotaType type,
668 unsigned long long requested_size,
669 WebKit::WebStorageQuotaCallbacks* callbacks);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000670 virtual void willOpenSocketStream(
671 WebKit::WebSocketStreamHandle* handle);
672 virtual void willStartUsingPeerConnectionHandler(WebKit::WebFrame* frame,
Ben Murdocheb525c52013-07-10 11:40:50 +0100673 WebKit::WebRTCPeerConnectionHandler* handler);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000674 virtual bool willCheckAndDispatchMessageEvent(
675 WebKit::WebFrame* sourceFrame,
676 WebKit::WebFrame* targetFrame,
677 WebKit::WebSecurityOrigin targetOrigin,
Ben Murdocheb525c52013-07-10 11:40:50 +0100678 WebKit::WebDOMMessageEvent event);
679 virtual WebKit::WebString acceptLanguages();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000680 virtual WebKit::WebString userAgentOverride(
681 WebKit::WebFrame* frame,
Ben Murdocheb525c52013-07-10 11:40:50 +0100682 const WebKit::WebURL& url);
683 virtual WebKit::WebString doNotTrackValue(WebKit::WebFrame* frame);
684 virtual bool allowWebGL(WebKit::WebFrame* frame, bool default_value);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000685 virtual void didLoseWebGLContext(
686 WebKit::WebFrame* frame,
Ben Murdocheb525c52013-07-10 11:40:50 +0100687 int arb_robustness_status_code);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000688
689 // WebKit::WebPageSerializerClient implementation ----------------------------
690
691 virtual void didSerializeDataForFrame(
692 const WebKit::WebURL& frame_url,
693 const WebKit::WebCString& data,
694 PageSerializationStatus status) OVERRIDE;
695
696 // RenderView implementation -------------------------------------------------
697
698 virtual bool Send(IPC::Message* message) OVERRIDE;
699 virtual int GetRoutingID() const OVERRIDE;
700 virtual int GetPageId() const OVERRIDE;
701 virtual gfx::Size GetSize() const OVERRIDE;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100702 virtual WebPreferences& GetWebkitPreferences() OVERRIDE;
703 virtual void SetWebkitPreferences(const WebPreferences& preferences) OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000704 virtual WebKit::WebView* GetWebView() OVERRIDE;
705 virtual WebKit::WebNode GetFocusedNode() const OVERRIDE;
706 virtual WebKit::WebNode GetContextMenuNode() const OVERRIDE;
707 virtual bool IsEditableNode(const WebKit::WebNode& node) const OVERRIDE;
708 virtual WebKit::WebPlugin* CreatePlugin(
709 WebKit::WebFrame* frame,
Ben Murdochca12bfa2013-07-23 11:17:05 +0100710 const WebPluginInfo& info,
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000711 const WebKit::WebPluginParams& params) OVERRIDE;
712 virtual void EvaluateScript(const string16& frame_xpath,
713 const string16& jscript,
714 int id,
715 bool notify_result) OVERRIDE;
716 virtual bool ShouldDisplayScrollbars(int width, int height) const OVERRIDE;
717 virtual int GetEnabledBindings() const OVERRIDE;
718 virtual bool GetContentStateImmediately() const OVERRIDE;
719 virtual float GetFilteredTimePerFrame() const OVERRIDE;
720 virtual int ShowContextMenu(ContextMenuClient* client,
721 const ContextMenuParams& params) OVERRIDE;
722 virtual void CancelContextMenu(int request_id) OVERRIDE;
723 virtual WebKit::WebPageVisibilityState GetVisibilityState() const OVERRIDE;
724 virtual void RunModalAlertDialog(WebKit::WebFrame* frame,
725 const WebKit::WebString& message) OVERRIDE;
726 virtual void LoadURLExternally(
727 WebKit::WebFrame* frame,
728 const WebKit::WebURLRequest& request,
729 WebKit::WebNavigationPolicy policy) OVERRIDE;
Ben Murdochca12bfa2013-07-23 11:17:05 +0100730 virtual void DidStartLoading() OVERRIDE;
731 virtual void DidStopLoading() OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000732 virtual void Repaint(const gfx::Size& size) OVERRIDE;
733 virtual void SetEditCommandForNextKeyEvent(const std::string& name,
734 const std::string& value) OVERRIDE;
735 virtual void ClearEditCommands() OVERRIDE;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000736 virtual SSLStatus GetSSLStatusOfFrame(WebKit::WebFrame* frame) const OVERRIDE;
737#if defined(OS_ANDROID)
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +0100738 virtual void UpdateTopControlsState(TopControlsState constraints,
739 TopControlsState current,
740 bool animate) OVERRIDE;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000741#endif
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000742
Ben Murdoch7dbb3d52013-07-17 14:55:54 +0100743 // WebMediaPlayerDelegate implementation -----------------------
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000744
745 virtual void DidPlay(WebKit::WebMediaPlayer* player) OVERRIDE;
746 virtual void DidPause(WebKit::WebMediaPlayer* player) OVERRIDE;
747 virtual void PlayerGone(WebKit::WebMediaPlayer* player) OVERRIDE;
748
749 // Please do not add your stuff randomly to the end here. If there is an
750 // appropriate section, add it there. If not, there are some random functions
751 // nearer to the top you can add it to.
752
753 // Cannot use std::set unfortunately since linked_ptr<> does not support
754 // operator<.
Torne (Richard Coles)a93a17c2013-05-15 11:34:50 +0100755 typedef std::vector<linked_ptr<ImageResourceFetcher> >
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000756 ImageResourceFetcherList;
757
758 protected:
759 // RenderWidget overrides:
760 virtual void Close() OVERRIDE;
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +0100761 virtual void OnResize(const ViewMsg_Resize_Params& params) OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000762 virtual void WillInitiatePaint() OVERRIDE;
763 virtual void DidInitiatePaint() OVERRIDE;
764 virtual void DidFlushPaint() OVERRIDE;
Ben Murdoch58e6fbe2013-07-26 10:20:38 +0100765 virtual PepperPluginInstanceImpl* GetBitmapForOptimizedPluginPaint(
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000766 const gfx::Rect& paint_bounds,
767 TransportDIB** dib,
768 gfx::Rect* location,
769 gfx::Rect* clip,
770 float* scale_factor) OVERRIDE;
771 virtual gfx::Vector2d GetScrollOffset() OVERRIDE;
772 virtual void DidHandleKeyEvent() OVERRIDE;
773 virtual bool WillHandleMouseEvent(
774 const WebKit::WebMouseEvent& event) OVERRIDE;
Torne (Richard Coles)7d4cd472013-06-19 11:58:07 +0100775 virtual bool WillHandleKeyEvent(
776 const WebKit::WebKeyboardEvent& event) OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000777 virtual bool WillHandleGestureEvent(
778 const WebKit::WebGestureEvent& event) OVERRIDE;
779 virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event) OVERRIDE;
780 virtual void DidHandleTouchEvent(const WebKit::WebTouchEvent& event) OVERRIDE;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000781 virtual bool HasTouchEventHandlersAt(const gfx::Point& point) const OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000782 virtual void OnSetFocus(bool enable) OVERRIDE;
783 virtual void OnWasHidden() OVERRIDE;
784 virtual void OnWasShown(bool needs_repainting) OVERRIDE;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000785 virtual GURL GetURLForGraphicsContext3D() OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000786 virtual bool ForceCompositingModeEnabled() OVERRIDE;
787 virtual void OnImeSetComposition(
788 const string16& text,
789 const std::vector<WebKit::WebCompositionUnderline>& underlines,
790 int selection_start,
791 int selection_end) OVERRIDE;
Ben Murdoch7dbb3d52013-07-17 14:55:54 +0100792 virtual void OnImeConfirmComposition(const string16& text,
793 const ui::Range& replacement_range,
794 bool keep_selection) OVERRIDE;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000795 virtual void SetDeviceScaleFactor(float device_scale_factor) OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000796 virtual ui::TextInputType GetTextInputType() OVERRIDE;
797 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) OVERRIDE;
Ben Murdoch7dbb3d52013-07-17 14:55:54 +0100798#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000799 virtual void GetCompositionCharacterBounds(
800 std::vector<gfx::Rect>* character_bounds) OVERRIDE;
Ben Murdocheb525c52013-07-10 11:40:50 +0100801 virtual void GetCompositionRange(ui::Range* range) OVERRIDE;
Ben Murdoch7dbb3d52013-07-17 14:55:54 +0100802#endif
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000803 virtual bool CanComposeInline() OVERRIDE;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000804 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;
810
811 protected:
812 explicit RenderViewImpl(RenderViewImplParams* params);
813
814 void Initialize(RenderViewImplParams* params);
815
816 // Do not delete directly. This class is reference counted.
817 virtual ~RenderViewImpl();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000818
819 private:
820 // For unit tests.
821 friend class ExternalPopupMenuTest;
822 friend class PepperDeviceTest;
823 friend class RendererAccessibilityTest;
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000824 friend class RenderViewTest;
825
Ben Murdochbbcdd452013-07-25 10:06:34 +0100826 // TODO(nasko): Temporarily friend RenderFrameImpl, so we don't duplicate
827 // utility functions needed in both classes, while we move frame specific
828 // code away from this class.
829 friend class RenderFrameImpl;
830
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000831 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuRemoveTest, RemoveOnChange);
832 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, NormalCase);
833 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, ShowPopupThenNavigate);
Ben Murdocheb525c52013-07-10 11:40:50 +0100834 FRIEND_TEST_ALL_PREFIXES(RendererAccessibilityTest,
835 AccessibilityMessagesQueueWhileSwappedOut);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000836 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, DecideNavigationPolicyForWebUI);
837 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100838 DidFailProvisionalLoadWithErrorForError);
839 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
840 DidFailProvisionalLoadWithErrorForCancellation);
841 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000842 DontIgnoreBackAfterNavEntryLimit);
843 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, ImeComposition);
844 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, InsertCharacters);
845 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, JSBlockSentAfterPageLoad);
846 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, LastCommittedUpdateState);
847 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnExtendSelectionAndDelete);
848 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnHandleKeyboardEvent);
Torne (Richard Coles)7d4cd472013-06-19 11:58:07 +0100849 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnImeTypeChanged);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000850 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnNavStateChanged);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000851 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnSetTextDirection);
852 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnUpdateWebPreferences);
853 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, SendSwapOutACK);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000854 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, ReloadWhileSwappedOut);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000855 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
856 SetEditableSelectionAndComposition);
857 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, StaleNavigationsIgnored);
858 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, UpdateTargetURLWithInvalidURL);
859 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
860 GetCompositionCharacterBoundsTest);
861 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnNavigationHttpPost);
862#if defined(OS_MACOSX)
863 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, MacTestCmdUp);
864#endif
865 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, SetHistoryLengthAndPrune);
866 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, ZoomLimit);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000867 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, NavigateFrame);
868 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
869 ShouldUpdateSelectionTextFromContextMenuParams);
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100870 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, BasicRenderFrame);
Ben Murdoch9ab55632013-07-18 11:57:30 +0100871 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, TextInputTypeWithPepper);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000872
873 typedef std::map<GURL, double> HostZoomLevels;
874
875 enum ErrorPageType {
876 DNS_ERROR,
877 HTTP_404,
878 CONNECTION_ERROR,
879 };
880
Ben Murdochbbcdd452013-07-25 10:06:34 +0100881 static WebKit::WebReferrerPolicy GetReferrerPolicyFromRequest(
882 WebKit::WebFrame* frame,
883 const WebKit::WebURLRequest& request);
884
885 static Referrer GetReferrerFromRequest(
886 WebKit::WebFrame* frame,
887 const WebKit::WebURLRequest& request);
888
889 static webkit_glue::WebURLResponseExtraDataImpl* GetExtraDataFromResponse(
890 const WebKit::WebURLResponse& response);
891
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000892 void UpdateURL(WebKit::WebFrame* frame);
893 void UpdateTitle(WebKit::WebFrame* frame, const string16& title,
894 WebKit::WebTextDirection title_direction);
895 void UpdateSessionHistory(WebKit::WebFrame* frame);
896 void SendUpdateState(const WebKit::WebHistoryItem& item);
897
898 // Update current main frame's encoding and send it to browser window.
899 // Since we want to let users see the right encoding info from menu
900 // before finishing loading, we call the UpdateEncoding in
901 // a) function:DidCommitLoadForFrame. When this function is called,
902 // that means we have got first data. In here we try to get encoding
903 // of page if it has been specified in http header.
904 // b) function:DidReceiveTitle. When this function is called,
905 // that means we have got specified title. Because in most of webpages,
906 // title tags will follow meta tags. In here we try to get encoding of
907 // page if it has been specified in meta tag.
908 // c) function:DidFinishDocumentLoadForFrame. When this function is
909 // called, that means we have got whole html page. In here we should
910 // finally get right encoding of page.
911 void UpdateEncoding(WebKit::WebFrame* frame,
912 const std::string& encoding_name);
913
914 void OpenURL(WebKit::WebFrame* frame,
915 const GURL& url,
916 const Referrer& referrer,
917 WebKit::WebNavigationPolicy policy);
918
919 bool RunJavaScriptMessage(JavaScriptMessageType type,
920 const string16& message,
921 const string16& default_value,
922 const GURL& frame_url,
923 string16* result);
924
925 // Sends a message and runs a nested message loop.
926 bool SendAndRunNestedMessageLoop(IPC::SyncMessage* message);
927
928 // Called when the "pinned to left/right edge" state needs to be updated.
929 void UpdateScrollState(WebKit::WebFrame* frame);
930
931 // IPC message handlers ------------------------------------------------------
932 //
933 // The documentation for these functions should be in
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100934 // content/common/*_messages.h for the message that the function is handling.
935
936 void OnCopy();
937 void OnCut();
938 void OnDelete();
939 void OnExecuteEditCommand(const std::string& name, const std::string& value);
940 void OnMoveCaret(const gfx::Point& point);
941 void OnPaste();
942 void OnPasteAndMatchStyle();
943 void OnRedo();
944 void OnReplace(const string16& text);
945 void OnReplaceMisspelling(const string16& text);
946 void OnScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect);
947 void OnSelectAll();
948 void OnSelectRange(const gfx::Point& start, const gfx::Point& end);
949 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
950 void OnUndo();
951 void OnUnselect();
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000952
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000953 void OnAllowBindings(int enabled_bindings_flags);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000954 void OnAllowScriptToClose(bool script_can_close);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000955 void OnCancelDownload(int32 download_id);
956 void OnClearFocusedNode();
957 void OnClosePage();
958 void OnContextMenuClosed(const CustomContextMenuContext& custom_context);
Torne (Richard Coles)7d4cd472013-06-19 11:58:07 +0100959 void OnShowContextMenu(const gfx::Point& location);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000960 void OnCopyImageAt(int x, int y);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000961 void OnCSSInsertRequest(const string16& frame_xpath,
962 const std::string& css);
963 void OnCustomContextMenuAction(const CustomContextMenuContext& custom_context,
964 unsigned action);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000965 void OnSetName(const std::string& name);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000966 void OnDeterminePageLanguage();
967 void OnDisableScrollbarsForSmallWindows(
968 const gfx::Size& disable_scrollbars_size_limit);
969 void OnDisassociateFromPopupCount();
970 void OnDragSourceEndedOrMoved(const gfx::Point& client_point,
971 const gfx::Point& screen_point,
972 bool ended,
973 WebKit::WebDragOperation drag_operation);
974 void OnDragSourceSystemDragEnded();
975 void OnDragTargetDrop(const gfx::Point& client_pt,
976 const gfx::Point& screen_pt,
977 int key_modifiers);
Ben Murdocheb525c52013-07-10 11:40:50 +0100978 void OnDragTargetDragEnter(const DropData& drop_data,
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000979 const gfx::Point& client_pt,
980 const gfx::Point& screen_pt,
981 WebKit::WebDragOperationsMask operations_allowed,
982 int key_modifiers);
983 void OnDragTargetDragLeave();
984 void OnDragTargetDragOver(const gfx::Point& client_pt,
985 const gfx::Point& screen_pt,
986 WebKit::WebDragOperationsMask operations_allowed,
987 int key_modifiers);
988 void OnEnablePreferredSizeChangedMode();
989 void OnEnableAutoResize(const gfx::Size& min_size, const gfx::Size& max_size);
990 void OnDisableAutoResize(const gfx::Size& new_size);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000991 void OnEnumerateDirectoryResponse(int id,
992 const std::vector<base::FilePath>& paths);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000993 void OnExtendSelectionAndDelete(int before, int after);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000994 void OnFileChooserResponse(
995 const std::vector<ui::SelectedFileInfo>& files);
996 void OnFind(int request_id, const string16&, const WebKit::WebFindOptions&);
997 void OnGetAllSavableResourceLinksForCurrentPage(const GURL& page_url);
998 void OnGetSerializedHtmlDataForCurrentPageWithLocalLinks(
999 const std::vector<GURL>& links,
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001000 const std::vector<base::FilePath>& local_paths,
1001 const base::FilePath& local_directory_name);
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001002 void OnMediaPlayerActionAt(const gfx::Point& location,
1003 const WebKit::WebMediaPlayerAction& action);
1004
1005 // Screen has rotated. 0 = default (portrait), 90 = one turn right, and so on.
1006 void OnOrientationChangeEvent(int orientation);
1007
1008 void OnPluginActionAt(const gfx::Point& location,
1009 const WebKit::WebPluginAction& action);
1010 void OnMoveOrResizeStarted();
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001011 void OnNavigate(const ViewMsg_Navigate_Params& params);
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001012 void OnPostMessageEvent(const ViewMsg_PostMessage_Params& params);
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001013 void OnReleaseDisambiguationPopupDIB(TransportDIB::Handle dib_handle);
1014 void OnReloadFrame();
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001015 void OnResetPageEncodingToDefault();
1016 void OnScriptEvalRequest(const string16& frame_xpath,
1017 const string16& jscript,
1018 int id,
1019 bool notify_result);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001020 void OnSetAccessibilityMode(AccessibilityMode new_mode);
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001021 void OnSetActive(bool active);
1022 void OnSetAltErrorPageURL(const GURL& gurl);
1023 void OnSetBackground(const SkBitmap& background);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001024 void OnSetCompositionFromExistingText(
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001025 int start, int end,
1026 const std::vector<WebKit::WebCompositionUnderline>& underlines);
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +01001027 void OnExitFullscreen();
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001028 void OnSetEditableSelectionOffsets(int start, int end);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001029 void OnSetHistoryLengthAndPrune(int history_length, int32 minimum_page_id);
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001030 void OnSetInitialFocus(bool reverse);
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001031 void OnSetPageEncoding(const std::string& encoding_name);
1032 void OnSetRendererPrefs(const RendererPreferences& renderer_prefs);
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +01001033 void OnSetWebUIProperty(const std::string& name, const std::string& value);
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001034 void OnSetZoomLevel(double zoom_level);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001035 void OnSetZoomLevelForLoadingURL(const GURL& url, double zoom_level);
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001036 void OnShouldClose();
1037 void OnStop();
1038 void OnStopFinding(StopFindAction action);
Torne (Richard Coles)7d4cd472013-06-19 11:58:07 +01001039 void OnSwapOut();
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001040 void OnThemeChanged();
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001041 void OnUpdateTargetURLAck();
1042 void OnUpdateTimezone();
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +01001043 void OnUpdateWebPreferences(const WebPreferences& prefs);
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001044
1045 void OnZoom(PageZoom zoom);
1046 void OnZoomFactor(PageZoom zoom, int zoom_center_x, int zoom_center_y);
1047
1048 void OnEnableViewSourceMode();
1049
1050 void OnJavaBridgeInit();
1051
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001052 void OnDisownOpener();
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001053
1054#if defined(OS_ANDROID)
1055 void OnActivateNearestFindResult(int request_id, float x, float y);
1056 void OnFindMatchRects(int current_version);
1057 void OnSelectPopupMenuItems(bool canceled,
1058 const std::vector<int>& selected_indices);
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001059 void OnUndoScrollFocusedEditableNodeIntoRect();
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +01001060 void OnUpdateTopControlsState(bool enable_hiding,
1061 bool enable_showing,
1062 bool animate);
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001063#elif defined(OS_MACOSX)
1064 void OnCopyToFindPboard();
1065 void OnPluginImeCompositionCompleted(const string16& text, int plugin_id);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001066 void OnSelectPopupMenuItem(int selected_index);
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001067 void OnSetInLiveResize(bool in_live_resize);
1068 void OnSetWindowVisibility(bool visible);
1069 void OnWindowFrameChanged(const gfx::Rect& window_frame,
1070 const gfx::Rect& view_frame);
1071#endif
1072
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001073 void OnWindowSnapshotCompleted(const int snapshot_id,
1074 const gfx::Size& size, const std::vector<unsigned char>& png);
1075
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001076
1077 // Adding a new message handler? Please add it in alphabetical order above
1078 // and put it in the same position in the .cc file.
1079
1080 // Misc private functions ----------------------------------------------------
1081 void ZoomFactorHelper(PageZoom zoom, int zoom_center_x, int zoom_center_y,
1082 float scaling_increment);
1083
1084 void AltErrorPageFinished(WebKit::WebFrame* frame,
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +01001085 const WebKit::WebURLRequest& original_request,
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001086 const WebKit::WebURLError& original_error,
1087 const std::string& html);
1088
1089 // Check whether the preferred size has changed.
1090 void CheckPreferredSize();
1091
Ben Murdoch7dbb3d52013-07-17 14:55:54 +01001092 // Initializes |media_stream_client_| if needed.
1093 void EnsureMediaStreamClient();
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001094
1095 // This callback is triggered when DownloadFavicon completes, either
1096 // succesfully or with a failure. See DownloadFavicon for more
1097 // details.
Torne (Richard Coles)a93a17c2013-05-15 11:34:50 +01001098 void DidDownloadFavicon(ImageResourceFetcher* fetcher,
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001099 const SkBitmap& image);
1100
1101 // Requests to download a favicon image. When done, the RenderView is notified
1102 // by way of DidDownloadFavicon. Returns true if the request was successfully
1103 // started, false otherwise. id is used to uniquely identify the request and
1104 // passed back to the DidDownloadFavicon method. If the image has multiple
1105 // frames, the frame whose size is image_size is returned. If the image
1106 // doesn't have a frame at the specified size, the first is returned.
1107 bool DownloadFavicon(int id, const GURL& image_url, int image_size);
1108
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001109 GURL GetAlternateErrorPageURL(const GURL& failed_url,
1110 ErrorPageType error_type);
1111
1112 // Locates a sub frame with given xpath
1113 WebKit::WebFrame* GetChildFrame(const string16& frame_xpath) const;
1114
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001115 // Returns the URL being loaded by the given frame's request.
1116 GURL GetLoadingUrl(WebKit::WebFrame* frame) const;
1117
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001118 // Should only be called if this object wraps a PluginDocument.
1119 WebKit::WebPlugin* GetWebPluginFromPluginDocument();
1120
1121 // Returns true if the |params| navigation is to an entry that has been
1122 // cropped due to a recent navigation the browser did not know about.
1123 bool IsBackForwardToStaleEntry(const ViewMsg_Navigate_Params& params,
1124 bool is_reload);
1125
1126 bool MaybeLoadAlternateErrorPage(WebKit::WebFrame* frame,
1127 const WebKit::WebURLError& error,
1128 bool replace);
1129
1130 // Make this RenderView show an empty, unscriptable page.
1131 void NavigateToSwappedOutURL(WebKit::WebFrame* frame);
1132
1133 // If we initiated a navigation, this function will populate |document_state|
1134 // with the navigation information saved in OnNavigate().
1135 void PopulateDocumentStateFromPending(DocumentState* document_state);
1136
1137 // Returns a new NavigationState populated with the navigation information
1138 // saved in OnNavigate().
1139 NavigationState* CreateNavigationStateFromPending();
1140
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001141 // Processes the command-line flags --enable-viewport,
1142 // --enable-fixed-layout[=w,h] and --enable-pinch.
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001143 void ProcessViewLayoutFlags(const CommandLine& command_line);
1144
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001145#if defined(OS_ANDROID)
1146 // Launch an Android content intent with the given URL.
1147 void LaunchAndroidContentIntent(const GURL& intent_url, size_t request_id);
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001148#endif
1149
1150 // Sends a reply to the current find operation handling if it was a
1151 // synchronous find request.
1152 void SendFindReply(int request_id,
1153 int match_count,
1154 int ordinal,
1155 const WebKit::WebRect& selection_rect,
1156 bool final_status_update);
1157
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001158 // Returns whether |params.selection_text| should be synchronized to the
1159 // browser before bringing up the context menu. Static for testing.
1160 static bool ShouldUpdateSelectionTextFromContextMenuParams(
1161 const string16& selection_text,
1162 size_t selection_text_offset,
1163 const ui::Range& selection_range,
1164 const ContextMenuParams& params);
1165
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001166 // Starts nav_state_sync_timer_ if it isn't already running.
1167 void StartNavStateSyncTimerIfNecessary();
1168
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001169 // Dispatches the current state of selection on the webpage to the browser if
1170 // it has changed.
1171 // TODO(varunjain): delete this method once we figure out how to keep
1172 // selection handles in sync with the webpage.
1173 void SyncSelectionIfRequired();
1174
1175#if defined(OS_POSIX) && !defined(OS_MACOSX)
1176 void UpdateFontRenderingFromRendererPrefs();
1177#else
1178 void UpdateFontRenderingFromRendererPrefs() {}
1179#endif
1180
1181 // Update the target url and tell the browser that the target URL has changed.
1182 // If |url| is empty, show |fallback_url|.
1183 void UpdateTargetURL(const GURL& url, const GURL& fallback_url);
1184
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +01001185 // Tells the browser what the new list of favicons for the webpage is.
1186 void SendUpdateFaviconURL(const std::vector<FaviconURL>& urls);
1187
1188 // Invoked from DidStopLoading(). Sends the current list of loaded favicons to
1189 // the browser.
1190 void DidStopLoadingIcons();
1191
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001192 // Coordinate conversion -----------------------------------------------------
1193
1194 gfx::RectF ClientRectToPhysicalWindowRect(const gfx::RectF& rect) const;
1195
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001196 // ---------------------------------------------------------------------------
1197 // ADDING NEW FUNCTIONS? Please keep private functions alphabetized and put
1198 // it in the same order in the .cc file as it was in the header.
1199 // ---------------------------------------------------------------------------
1200
1201 // Settings ------------------------------------------------------------------
1202
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +01001203 WebPreferences webkit_preferences_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001204 RendererPreferences renderer_preferences_;
1205
1206 HostZoomLevels host_zoom_levels_;
1207
1208 // Whether content state (such as form state, scroll position and page
1209 // contents) should be sent to the browser immediately. This is normally
1210 // false, but set to true by some tests.
1211 bool send_content_state_immediately_;
1212
1213 // Bitwise-ORed set of extra bindings that have been enabled. See
1214 // BindingsPolicy for details.
1215 int enabled_bindings_;
1216
1217 // The alternate error page URL, if one exists.
1218 GURL alternate_error_page_url_;
1219
1220 // If true, we send IPC messages when |preferred_size_| changes.
1221 bool send_preferred_size_changes_;
1222
1223 // If non-empty, and |send_preferred_size_changes_| is true, disable drawing
1224 // scroll bars on windows smaller than this size. Used for windows that the
1225 // browser resizes to the size of the content, such as browser action popups.
1226 // If a render view is set to the minimum size of its content, webkit may add
1227 // scroll bars. This makes sense for fixed sized windows, but it does not
1228 // make sense when the size of the view was chosen to fit the content.
1229 // This setting ensures that no scroll bars are drawn. The size limit exists
1230 // because if the view grows beyond a size known to the browser, scroll bars
1231 // should be drawn.
1232 gfx::Size disable_scrollbars_size_limit_;
1233
1234 // Loading state -------------------------------------------------------------
1235
1236 // True if the top level frame is currently being loaded.
1237 bool is_loading_;
1238
1239 // The gesture that initiated the current navigation.
1240 NavigationGesture navigation_gesture_;
1241
1242 // Used for popups.
1243 bool opened_by_user_gesture_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001244
1245 // Whether this RenderView was created by a frame that was suppressing its
1246 // opener. If so, we may want to load pages in a separate process. See
1247 // decidePolicyForNavigation for details.
1248 bool opener_suppressed_;
1249
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001250 // Holds state pertaining to a navigation that we initiated. This is held by
1251 // the WebDataSource::ExtraData attribute. We use pending_navigation_state_
1252 // as a temporary holder for the state until the WebDataSource corresponding
1253 // to the new navigation is created. See DidCreateDataSource.
1254 scoped_ptr<ViewMsg_Navigate_Params> pending_navigation_params_;
1255
1256 // Timer used to delay the updating of nav state (see SyncNavigationState).
1257 base::OneShotTimer<RenderViewImpl> nav_state_sync_timer_;
1258
1259 // Page IDs ------------------------------------------------------------------
1260 // See documentation in RenderView.
1261 int32 page_id_;
1262
1263 // Indicates the ID of the last page that we sent a FrameNavigate to the
1264 // browser for. This is used to determine if the most recent transition
1265 // generated a history entry (less than page_id_), or not (equal to or
1266 // greater than). Note that this will be greater than page_id_ if the user
1267 // goes back.
1268 int32 last_page_id_sent_to_browser_;
1269
1270 // The next available page ID to use for this RenderView. These IDs are
1271 // specific to a given RenderView and the frames within it.
1272 int32 next_page_id_;
1273
1274 // The offset of the current item in the history list.
1275 int history_list_offset_;
1276
1277 // The RenderView's current impression of the history length. This includes
1278 // any items that have committed in this process, but because of cross-process
1279 // navigations, the history may have some entries that were committed in other
1280 // processes. We won't know about them until the next navigation in this
1281 // process.
1282 int history_list_length_;
1283
1284 // The list of page IDs for each history item this RenderView knows about.
1285 // Some entries may be -1 if they were rendered by other processes or were
1286 // restored from a previous session. This lets us detect attempts to
1287 // navigate to stale entries that have been cropped from our history.
1288 std::vector<int32> history_page_ids_;
1289
1290 // Page info -----------------------------------------------------------------
1291
1292 // The last gotten main frame's encoding.
1293 std::string last_encoding_name_;
1294
1295 // UI state ------------------------------------------------------------------
1296
1297 // The state of our target_url transmissions. When we receive a request to
1298 // send a URL to the browser, we set this to TARGET_INFLIGHT until an ACK
1299 // comes back - if a new request comes in before the ACK, we store the new
1300 // URL in pending_target_url_ and set the status to TARGET_PENDING. If an
1301 // ACK comes back and we are in TARGET_PENDING, we send the stored URL and
1302 // revert to TARGET_INFLIGHT.
1303 //
1304 // We don't need a queue of URLs to send, as only the latest is useful.
1305 enum {
1306 TARGET_NONE,
1307 TARGET_INFLIGHT, // We have a request in-flight, waiting for an ACK
1308 TARGET_PENDING // INFLIGHT + we have a URL waiting to be sent
1309 } target_url_status_;
1310
1311 // The URL we show the user in the status bar. We use this to determine if we
1312 // want to send a new one (we do not need to send duplicates). It will be
1313 // equal to either |mouse_over_url_| or |focus_url_|, depending on which was
1314 // updated last.
1315 GURL target_url_;
1316
1317 // The URL the user's mouse is hovering over.
1318 GURL mouse_over_url_;
1319
1320 // The URL that has keyboard focus.
1321 GURL focus_url_;
1322
1323 // The next target URL we want to send to the browser.
1324 GURL pending_target_url_;
1325
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001326 // The text selection the last time DidChangeSelection got called. May contain
1327 // additional characters before and after the selected text, for IMEs. The
1328 // portion of this string that is the actual selected text starts at index
1329 // |selection_range_.GetMin() - selection_text_offset_| and has length
1330 // |selection_range_.length()|.
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001331 string16 selection_text_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001332 // The offset corresponding to the start of |selection_text_| in the document.
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001333 size_t selection_text_offset_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001334 // Range over the document corresponding to the actual selected text (which
1335 // could correspond to a substring of |selection_text_|; see above).
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001336 ui::Range selection_range_;
1337
1338 // External context menu requests we're waiting for. "Internal"
1339 // (WebKit-originated) context menu events will have an ID of 0 and will not
1340 // be in this map.
1341 //
1342 // We don't want to add internal ones since some of the "special" page
1343 // handlers in the browser process just ignore the context menu requests so
1344 // avoid showing context menus, and so this will cause right clicks to leak
1345 // entries in this map. Most users of the custom context menu (e.g. Pepper
1346 // plugins) are normally only on "regular" pages and the regular pages will
1347 // always respond properly to the request, so we don't have to worry so
1348 // much about leaks.
1349 IDMap<ContextMenuClient, IDMapExternalPointer> pending_context_menus_;
1350
Torne (Richard Coles)7d4cd472013-06-19 11:58:07 +01001351#if defined(OS_ANDROID)
1352 // Cache the old top controls state constraints. Used when updating
1353 // current value only without altering the constraints.
1354 cc::TopControlsState top_controls_constraints_;
1355#endif
1356
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001357 // View ----------------------------------------------------------------------
1358
1359 // Cache the preferred size of the page in order to prevent sending the IPC
1360 // when layout() recomputes but doesn't actually change sizes.
1361 gfx::Size preferred_size_;
1362
1363 // Used to delay determining the preferred size (to avoid intermediate
1364 // states for the sizes).
1365 base::OneShotTimer<RenderViewImpl> check_preferred_size_timer_;
1366
1367 // These store the "is main frame is scrolled all the way to the left
1368 // or right" state that was last sent to the browser.
1369 bool cached_is_main_frame_pinned_to_left_;
1370 bool cached_is_main_frame_pinned_to_right_;
1371
1372 // These store the "has scrollbars" state last sent to the browser.
1373 bool cached_has_main_frame_horizontal_scrollbar_;
1374 bool cached_has_main_frame_vertical_scrollbar_;
1375
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001376 // Helper objects ------------------------------------------------------------
1377
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +01001378 scoped_ptr<RenderFrameImpl> main_render_frame_;
1379
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001380 RendererWebCookieJarImpl cookie_jar_;
1381
1382 // The next group of objects all implement RenderViewObserver, so are deleted
1383 // along with the RenderView automatically. This is why we just store
1384 // weak references.
1385
1386 // Holds a reference to the service which provides desktop notifications.
1387 NotificationProvider* notification_provider_;
1388
1389 // The geolocation dispatcher attached to this view, lazily initialized.
1390 GeolocationDispatcher* geolocation_dispatcher_;
1391
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001392 // The speech dispatcher attached to this view, lazily initialized.
1393 InputTagSpeechDispatcher* input_tag_speech_dispatcher_;
1394
1395 // The speech recognition dispatcher attached to this view, lazily
1396 // initialized.
1397 SpeechRecognitionDispatcher* speech_recognition_dispatcher_;
1398
1399 // Device orientation dispatcher attached to this view; lazily initialized.
1400 DeviceOrientationDispatcher* device_orientation_dispatcher_;
1401
1402 // MediaStream dispatcher attached to this view; lazily initialized.
1403 MediaStreamDispatcher* media_stream_dispatcher_;
1404
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001405 // BrowserPluginManager attached to this view; lazily initialized.
1406 scoped_refptr<BrowserPluginManager> browser_plugin_manager_;
1407
Ben Murdoch7dbb3d52013-07-17 14:55:54 +01001408 // MediaStreamClient attached to this view; lazily initialized.
1409 MediaStreamClient* media_stream_client_;
1410 WebKit::WebUserMediaClient* web_user_media_client_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001411
Ben Murdoch58e6fbe2013-07-26 10:20:38 +01001412 // MIDIClient attached to this view; lazily initialized.
1413 MIDIDispatcher* midi_dispatcher_;
1414
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001415 DevToolsAgent* devtools_agent_;
1416
1417 // The current accessibility mode.
1418 AccessibilityMode accessibility_mode_;
1419
1420 // Only valid if |accessibility_mode_| is anything other than
1421 // AccessibilityModeOff.
1422 RendererAccessibility* renderer_accessibility_;
1423
1424 // Java Bridge dispatcher attached to this view; lazily initialized.
1425 JavaBridgeDispatcher* java_bridge_dispatcher_;
1426
1427 // Mouse Lock dispatcher attached to this view.
1428 MouseLockDispatcher* mouse_lock_dispatcher_;
1429
1430#if defined(OS_ANDROID)
1431 // Android Specific ---------------------------------------------------------
1432
1433 // The background color of the document body element. This is used as the
1434 // default background color for filling the screen areas for which we don't
1435 // have the actual content.
1436 SkColor body_background_color_;
1437
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001438 // Expected id of the next content intent launched. Used to prevent scheduled
1439 // intents to be launched if aborted.
1440 size_t expected_content_intent_id_;
1441
1442 // List of click-based content detectors.
1443 typedef std::vector< linked_ptr<ContentDetector> > ContentDetectorList;
1444 ContentDetectorList content_detectors_;
1445
1446 // Proxy class for WebMediaPlayer to communicate with the real media player
1447 // objects in browser process.
Ben Murdocheb525c52013-07-10 11:40:50 +01001448 WebMediaPlayerProxyAndroid* media_player_proxy_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001449
1450 // The media player manager for managing all the media players on this view.
Ben Murdoch7dbb3d52013-07-17 14:55:54 +01001451 scoped_ptr<RendererMediaPlayerManager> media_player_manager_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001452
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001453 // A date/time picker object for date and time related input elements.
1454 scoped_ptr<RendererDateTimePicker> date_time_picker_client_;
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001455#endif
1456
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +01001457 // Plugins -------------------------------------------------------------------
1458
1459 // All the currently active plugin delegates for this RenderView; kept so
1460 // that we can enumerate them to send updates about things like window
1461 // location or tab focus and visibily. These are non-owning references.
1462 std::set<WebPluginDelegateProxy*> plugin_delegates_;
1463
1464#if defined(OS_WIN)
1465 // The ID of the focused NPAPI plug-in.
1466 int focused_plugin_id_;
1467#endif
1468
Ben Murdoch32409262013-08-07 11:04:47 +01001469#if defined(ENABLE_PLUGINS)
1470 typedef std::set<PepperPluginInstanceImpl*> PepperPluginSet;
1471 PepperPluginSet active_pepper_instances_;
1472
1473 // Whether or not the focus is on a PPAPI plugin
1474 PepperPluginInstanceImpl* focused_pepper_plugin_;
1475
1476 // Current text input composition text. Empty if no composition is in
1477 // progress.
1478 string16 pepper_composition_text_;
1479
1480 // The plugin instance that received the last mouse event. It is set to NULL
1481 // if the last mouse event went to elements other than Pepper plugins.
1482 // |pepper_last_mouse_event_target_| is not owned by this class. We can know
1483 // about when it is destroyed via InstanceDeleted().
1484 PepperPluginInstanceImpl* pepper_last_mouse_event_target_;
1485#endif
1486
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001487 // Misc ----------------------------------------------------------------------
1488
1489 // The current and pending file chooser completion objects. If the queue is
1490 // nonempty, the first item represents the currently running file chooser
1491 // callback, and the remaining elements are the other file chooser completion
1492 // still waiting to be run (in order).
1493 struct PendingFileChooser;
1494 std::deque< linked_ptr<PendingFileChooser> > file_chooser_completions_;
1495
1496 // The current directory enumeration callback
1497 std::map<int, WebKit::WebFileChooserCompletion*> enumeration_completions_;
1498 int enumeration_completion_id_;
1499
1500 // Reports load progress to the browser.
1501 scoped_ptr<LoadProgressTracker> load_progress_tracker_;
1502
1503 // The SessionStorage namespace that we're assigned to has an ID, and that ID
1504 // is passed to us upon creation. WebKit asks for this ID upon first use and
1505 // uses it whenever asking the browser process to allocate new storage areas.
1506 int64 session_storage_namespace_id_;
1507
1508 // The total number of unrequested popups that exist and can be followed back
1509 // to a common opener. This count is shared among all RenderViews created with
1510 // createView(). All popups are treated as unrequested until specifically
1511 // instructed otherwise by the Browser process.
1512 scoped_refptr<SharedRenderViewCounter> shared_popup_counter_;
1513
1514 // Whether this is a top level window (instead of a popup). Top level windows
1515 // shouldn't count against their own |shared_popup_counter_|.
1516 bool decrement_shared_popup_at_destruction_;
1517
1518 // Stores edit commands associated to the next key event.
1519 // Shall be cleared as soon as the next key event is processed.
1520 EditCommands edit_commands_;
1521
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001522 // The external popup for the currently showing select popup.
1523 scoped_ptr<ExternalPopupMenu> external_popup_menu_;
1524
1525 // The node that the context menu was pressed over.
1526 WebKit::WebNode context_menu_node_;
1527
1528 // All the registered observers. We expect this list to be small, so vector
1529 // is fine.
1530 ObserverList<RenderViewObserver> observers_;
1531
1532 // Used to inform didChangeSelection() when it is called in the context
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +01001533 // of handling a InputMsg_SelectRange IPC.
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001534 bool handling_select_range_;
1535
1536 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface.
1537 scoped_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_;
1538
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001539 // State associated with the GetWindowSnapshot function.
1540 int next_snapshot_id_;
Ben Murdoch32409262013-08-07 11:04:47 +01001541 typedef std::map<int, WindowSnapshotCallback> PendingSnapshotMap;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001542 PendingSnapshotMap pending_snapshots_;
1543
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +01001544 // Allows to selectively disable partial buffer swap for this renderer's
1545 // compositor.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001546 bool allow_partial_swap_;
1547
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001548 // Allows JS to access DOM automation. The JS object is only exposed when the
1549 // DOM automation bindings are enabled.
1550 scoped_ptr<DomAutomationController> dom_automation_controller_;
1551
Ben Murdoch58e6fbe2013-07-26 10:20:38 +01001552 // Allows JS to read out a variety of internal various metrics. The JS object
1553 // is only exposed when the stats collection bindings are enabled.
1554 scoped_ptr<StatsCollectionController> stats_collection_controller_;
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +01001555
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001556 // This field stores drag/drop related info for the event that is currently
1557 // being handled. If the current event results in starting a drag/drop
1558 // session, this info is sent to the browser along with other drag/drop info.
1559 DragEventSourceInfo possible_drag_event_info_;
1560
Ben Murdoch32409262013-08-07 11:04:47 +01001561 // NOTE: stats_collection_observer_ should be the last members because their
1562 // constructors call the AddObservers method of RenderViewImpl.
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +01001563 scoped_ptr<StatsCollectionObserver> stats_collection_observer_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001564
Ben Murdocheb525c52013-07-10 11:40:50 +01001565 ui::MenuSourceType context_menu_source_type_;
Torne (Richard Coles)7d4cd472013-06-19 11:58:07 +01001566 gfx::Point touch_editing_context_menu_location_;
1567
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001568 // ---------------------------------------------------------------------------
1569 // ADDING NEW DATA? Please see if it fits appropriately in one of the above
1570 // sections rather than throwing it randomly at the end. If you're adding a
1571 // bunch of stuff, you should probably create a helper class and put your
1572 // data and methods on that to avoid bloating RenderView more. You can
1573 // use the Observer interface to filter IPC messages and receive frame change
1574 // notifications.
1575 // ---------------------------------------------------------------------------
1576
1577 DISALLOW_COPY_AND_ASSIGN(RenderViewImpl);
1578};
1579
1580} // namespace content
1581
1582#endif // CONTENT_RENDERER_RENDER_VIEW_IMPL_H_