blob: 54945e282a73bb1712875ecbb204edd2f662ebc8 [file] [log] [blame]
[email protected]81375e872012-01-11 21:40:361// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]6e24cf12011-03-18 19:57:022// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]310ebd6302011-10-10 19:06:285#ifndef CONTENT_RENDERER_RENDER_VIEW_IMPL_H_
6#define CONTENT_RENDERER_RENDER_VIEW_IMPL_H_
[email protected]6e24cf12011-03-18 19:57:027#pragma once
8
9#include <deque>
10#include <map>
[email protected]6e24cf12011-03-18 19:57:0211#include <set>
12#include <string>
13#include <vector>
14
[email protected]6e24cf12011-03-18 19:57:0215#include "base/basictypes.h"
16#include "base/gtest_prod_util.h"
17#include "base/id_map.h"
[email protected]3b63f8f42011-03-28 01:54:1518#include "base/memory/linked_ptr.h"
19#include "base/memory/weak_ptr.h"
[email protected]6e24cf12011-03-18 19:57:0220#include "base/observer_list.h"
21#include "base/timer.h"
[email protected]6e24cf12011-03-18 19:57:0222#include "build/build_config.h"
[email protected]8d128d62011-09-13 22:11:5723#include "content/common/content_export.h"
[email protected]55722152011-03-22 01:33:5324#include "content/common/edit_command.h"
[email protected]c26ad882012-02-07 06:41:2025#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
[email protected]6e24cf12011-03-18 19:57:0226#include "content/common/navigation_gesture.h"
[email protected]3e3c4522012-04-13 21:16:2927#include "content/common/view_message_enums.h"
[email protected]54087fe2011-10-28 22:02:4828#include "content/public/common/page_zoom.h"
[email protected]445e1042011-12-03 21:03:1529#include "content/public/common/referrer.h"
[email protected]daf82f82011-10-31 22:35:3130#include "content/public/common/renderer_preferences.h"
[email protected]815dd9872011-11-23 18:40:3031#include "content/public/common/stop_find_action.h"
[email protected]a2ef54c2011-10-10 16:20:3132#include "content/public/renderer/render_view.h"
[email protected]1e7e3572012-02-22 00:25:0833#include "content/renderer/pepper/pepper_plugin_delegate_impl.h"
[email protected]1e7e3572012-02-22 00:25:0834#include "content/renderer/render_view_selection.h"
[email protected]6e24cf12011-03-18 19:57:0235#include "content/renderer/render_widget.h"
[email protected]d353541f2012-05-03 22:45:4136#include "content/renderer/renderer_webcookiejar_impl.h"
[email protected]6e24cf12011-03-18 19:57:0237#include "ipc/ipc_platform_file.h"
[email protected]1e7e3572012-02-22 00:25:0838#include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h"
[email protected]6e24cf12011-03-18 19:57:0239#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h"
[email protected]6459800a2012-03-27 23:57:0540#include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h"
[email protected]42054a252011-05-17 18:02:1341#include "third_party/WebKit/Source/WebKit/chromium/public/WebIconURL.h"
[email protected]d353541f2012-05-03 22:45:4142#include "third_party/WebKit/Source/WebKit/chromium/public/WebNavigationType.h"
[email protected]6e24cf12011-03-18 19:57:0243#include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h"
[email protected]18d5be92011-07-25 18:00:1944#include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializerClient.h"
[email protected]94dec932011-05-26 20:04:2145#include "third_party/WebKit/Source/WebKit/chromium/public/WebPageVisibilityState.h"
[email protected]f546640b2012-05-15 00:03:4946#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
[email protected]6e24cf12011-03-18 19:57:0247#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h"
48#include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h"
[email protected]d353541f2012-05-03 22:45:4149#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSystem.h"
[email protected]7e8b4d12012-01-20 23:39:5150#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h"
[email protected]269f86d2011-12-07 02:43:4751#include "ui/base/javascript_message_type.h"
[email protected]d353541f2012-05-03 22:45:4152#include "ui/surface/transport_dib.h"
[email protected]6e24cf12011-03-18 19:57:0253#include "webkit/glue/webpreferences.h"
[email protected]a9288f52011-11-17 05:18:1654#include "webkit/media/webmediaplayer_delegate.h"
[email protected]6e24cf12011-03-18 19:57:0255#include "webkit/plugins/npapi/webplugin_page_delegate.h"
56
[email protected]9f76c1e2012-03-05 15:15:5857#if defined(COMPILER_MSVC)
[email protected]310ebd6302011-10-10 19:06:2858// RenderViewImpl is a diamond-shaped hierarchy, with WebWidgetClient at the
59// root. VS warns when we inherit the WebWidgetClient method implementations
60// from RenderWidget. It's safe to ignore that warning.
[email protected]6e24cf12011-03-18 19:57:0261#pragma warning(disable: 4250)
62#endif
63
[email protected]5b52cd2f712012-03-28 02:12:4864class CommandLine;
[email protected]6e24cf12011-03-18 19:57:0265class DeviceOrientationDispatcher;
[email protected]c5c1d6d2011-07-28 18:42:4166class DevToolsAgent;
[email protected]766a7082012-02-03 23:39:1567class DomAutomationController;
[email protected]55722152011-03-22 01:33:5368class ExternalPopupMenu;
[email protected]6e24cf12011-03-18 19:57:0269class GeolocationDispatcher;
[email protected]6e24cf12011-03-18 19:57:0270class GURL;
[email protected]7f3c7af2011-10-20 22:52:5171class JavaBridgeDispatcher;
[email protected]6e24cf12011-03-18 19:57:0272class LoadProgressTracker;
[email protected]273558fb2012-01-12 15:03:5173class MediaStreamDispatcher;
[email protected]ab2c4732011-07-20 19:57:4074class MediaStreamImpl;
[email protected]217690d2012-01-27 07:33:1175class MouseLockDispatcher;
[email protected]6e24cf12011-03-18 19:57:0276class NotificationProvider;
[email protected]6e24cf12011-03-18 19:57:0277class PepperDeviceTest;
[email protected]83f93d32011-11-11 00:43:3078struct PP_NetAddress_Private;
[email protected]ea192e82011-04-11 19:16:0279class RenderWidgetFullscreenPepper;
[email protected]063afcb2011-09-29 07:54:3280class RendererAccessibility;
[email protected]da8543762012-03-20 08:52:2081class RendererWebColorChooserImpl;
[email protected]6e24cf12011-03-18 19:57:0282class SkBitmap;
[email protected]c52b2892012-03-07 11:01:0283class InputTagSpeechDispatcher;
[email protected]6e24cf12011-03-18 19:57:0284struct ViewMsg_Navigate_Params;
[email protected]f546640b2012-05-15 00:03:4985struct ViewMsg_PostMessage_Params;
[email protected]6e24cf12011-03-18 19:57:0286struct ViewMsg_StopFinding_Params;
[email protected]83f93d32011-11-11 00:43:3087struct ViewMsg_SwapOut_Params;
[email protected]6e24cf12011-03-18 19:57:0288struct WebDropData;
[email protected]0d9989d2011-12-21 20:26:0089class WebIntentsHost;
[email protected]83f93d32011-11-11 00:43:3090class WebPluginDelegateProxy;
91class WebUIBindings;
[email protected]b3f8f9722011-08-25 20:56:0792
93namespace content {
[email protected]007733c2011-11-17 00:34:0794class DocumentState;
[email protected]45d83a12012-04-06 22:57:5795class NavigationState;
[email protected]b3f8f9722011-08-25 20:56:0796class P2PSocketDispatcher;
[email protected]3a034ebb2011-10-03 19:19:4497class RenderViewObserver;
[email protected]007733c2011-11-17 00:34:0798class RenderViewTest;
[email protected]35be7ec2012-02-12 20:42:5199struct CustomContextMenuContext;
[email protected]8caadeb2011-11-22 02:45:23100struct FileChooserParams;
[email protected]fb11b6a42012-03-14 07:25:12101struct SelectedFileInfo;
[email protected]b3f8f9722011-08-25 20:56:07102} // namespace content
[email protected]6e24cf12011-03-18 19:57:02103
[email protected]6e24cf12011-03-18 19:57:02104namespace gfx {
105class Point;
106class Rect;
[email protected]b3f8f9722011-08-25 20:56:07107} // namespace gfx
[email protected]6e24cf12011-03-18 19:57:02108
109namespace webkit {
110
[email protected]6e24cf12011-03-18 19:57:02111namespace ppapi {
[email protected]6e24cf12011-03-18 19:57:02112class PluginInstance;
[email protected]6e24cf12011-03-18 19:57:02113} // namespace ppapi
114
115} // namespace webkit
116
117namespace webkit_glue {
[email protected]6e24cf12011-03-18 19:57:02118class ImageResourceFetcher;
[email protected]6e24cf12011-03-18 19:57:02119class ResourceFetcher;
120}
121
122namespace WebKit {
[email protected]6e24cf12011-03-18 19:57:02123class WebApplicationCacheHost;
124class WebApplicationCacheHostClient;
[email protected]f546640b2012-05-15 00:03:49125class WebDOMMessageEvent;
[email protected]6e24cf12011-03-18 19:57:02126class WebDataSource;
[email protected]6e24cf12011-03-18 19:57:02127class WebDragData;
[email protected]6e24cf12011-03-18 19:57:02128class WebGeolocationClient;
[email protected]42054a252011-05-17 18:02:13129class WebIconURL;
[email protected]6e24cf12011-03-18 19:57:02130class WebImage;
[email protected]50da23d02012-04-13 17:47:48131class WebPeerConnection00Handler;
132class WebPeerConnection00HandlerClient;
[email protected]6e24cf12011-03-18 19:57:02133class WebMediaPlayer;
134class WebMediaPlayerClient;
135class WebMouseEvent;
[email protected]273558fb2012-01-12 15:03:51136class WebPeerConnectionHandler;
137class WebPeerConnectionHandlerClient;
[email protected]5fa3a062012-03-21 15:39:34138class WebSocketStreamHandle;
[email protected]6e24cf12011-03-18 19:57:02139class WebSpeechInputController;
140class WebSpeechInputListener;
141class WebStorageNamespace;
[email protected]2d0f2e92011-10-03 09:02:24142class WebTouchEvent;
[email protected]b00ba702011-08-17 01:41:03143class WebURLLoader;
[email protected]6e24cf12011-03-18 19:57:02144class WebURLRequest;
[email protected]273558fb2012-01-12 15:03:51145class WebUserMediaClient;
[email protected]7a1ec28a2012-03-28 21:10:24146struct WebActiveWheelFlingParameters;
[email protected]6e24cf12011-03-18 19:57:02147struct WebFileChooserParams;
148struct WebFindOptions;
149struct WebMediaPlayerAction;
[email protected]81375e872012-01-11 21:40:36150struct WebPluginAction;
[email protected]6e24cf12011-03-18 19:57:02151struct WebPoint;
152struct WebWindowFeatures;
153}
154
155// We need to prevent a page from trying to create infinite popups. It is not
156// as simple as keeping a count of the number of immediate children
157// popups. Having an html file that window.open()s itself would create
158// an unlimited chain of RenderViews who only have one RenderView child.
159//
160// Therefore, each new top level RenderView creates a new counter and shares it
[email protected]310ebd6302011-10-10 19:06:28161// with all its children and grandchildren popup RenderViewImpls created with
[email protected]6e24cf12011-03-18 19:57:02162// createView() to have a sort of global limit for the page so no more than
163// kMaximumNumberOfPopups popups are created.
164//
165// This is a RefCounted holder of an int because I can't say
166// scoped_refptr<int>.
167typedef base::RefCountedData<int> SharedRenderViewCounter;
168
169//
170// RenderView is an object that manages a WebView object, and provides a
171// communication interface with an embedding application process
172//
[email protected]310ebd6302011-10-10 19:06:28173class RenderViewImpl : public RenderWidget,
174 public WebKit::WebViewClient,
175 public WebKit::WebFrameClient,
176 public WebKit::WebPageSerializerClient,
177 public content::RenderView,
178 public webkit::npapi::WebPluginPageDelegate,
[email protected]a9288f52011-11-17 05:18:16179 public webkit_media::WebMediaPlayerDelegate,
[email protected]b3e83de2012-02-07 03:33:28180 public WebGraphicsContext3DSwapBuffersClient,
[email protected]310ebd6302011-10-10 19:06:28181 public base::SupportsWeakPtr<RenderViewImpl> {
[email protected]6e24cf12011-03-18 19:57:02182 public:
183 // Creates a new RenderView. The parent_hwnd specifies a HWND to use as the
[email protected]5f9de5882011-09-30 23:36:28184 // parent of the WebView HWND that will be created. If this is a blocked
[email protected]6e24cf12011-03-18 19:57:02185 // popup or as a new tab, opener_id is the routing ID of the RenderView
186 // responsible for creating this RenderView (corresponding to parent_hwnd).
187 // |counter| is either a currently initialized counter, or NULL (in which case
188 // we treat this RenderView as a top level window).
[email protected]310ebd6302011-10-10 19:06:28189 CONTENT_EXPORT static RenderViewImpl* Create(
[email protected]6e24cf12011-03-18 19:57:02190 gfx::NativeViewId parent_hwnd,
191 int32 opener_id,
[email protected]daf82f82011-10-31 22:35:31192 const content::RendererPreferences& renderer_prefs,
[email protected]6717bf272012-05-11 23:31:25193 const webkit_glue::WebPreferences& webkit_prefs,
[email protected]6e24cf12011-03-18 19:57:02194 SharedRenderViewCounter* counter,
195 int32 routing_id,
[email protected]9f4f3322012-01-18 22:29:56196 int32 surface_id,
[email protected]6e24cf12011-03-18 19:57:02197 int64 session_storage_namespace_id,
[email protected]74ce1ad2011-12-16 21:51:46198 const string16& frame_name,
[email protected]14392a52012-05-02 20:28:44199 bool is_renderer_created,
200 bool swapped_out,
[email protected]6fd35b72012-03-01 19:46:41201 int32 next_page_id,
[email protected]8cca3da2012-03-20 08:26:34202 const WebKit::WebScreenInfo& screen_info,
[email protected]3e3c4522012-04-13 21:16:29203 bool guest,
204 AccessibilityMode accessibility_mode);
[email protected]6e24cf12011-03-18 19:57:02205
[email protected]310ebd6302011-10-10 19:06:28206 // Returns the RenderViewImpl containing the given WebView.
207 CONTENT_EXPORT static RenderViewImpl* FromWebView(WebKit::WebView* webview);
[email protected]6e24cf12011-03-18 19:57:02208
[email protected]6e24cf12011-03-18 19:57:02209 // May return NULL when the view is closing.
[email protected]8d128d62011-09-13 22:11:57210 CONTENT_EXPORT WebKit::WebView* webview() const;
[email protected]6e24cf12011-03-18 19:57:02211
[email protected]b3e83de2012-02-07 03:33:28212 // WebGraphicsContext3DSwapBuffersClient implementation.
213
[email protected]65225772011-05-12 21:10:24214 // Called by a GraphicsContext associated with this view when swapbuffers
[email protected]37a6f302011-07-11 23:43:08215 // is posted, completes or is aborted.
[email protected]b3e83de2012-02-07 03:33:28216 virtual void OnViewContextSwapBuffersPosted() OVERRIDE;
217 virtual void OnViewContextSwapBuffersComplete() OVERRIDE;
218 virtual void OnViewContextSwapBuffersAborted() OVERRIDE;
[email protected]65225772011-05-12 21:10:24219
[email protected]d466b8a2011-07-15 21:48:03220 int history_list_offset() const { return history_list_offset_; }
[email protected]6e24cf12011-03-18 19:57:02221
[email protected]6717bf272012-05-11 23:31:25222 const webkit_glue::WebPreferences& webkit_preferences() const {
[email protected]6e24cf12011-03-18 19:57:02223 return webkit_preferences_;
224 }
225
226 void set_send_content_state_immediately(bool value) {
227 send_content_state_immediately_ = value;
228 }
229
[email protected]273558fb2012-01-12 15:03:51230 MediaStreamDispatcher* media_stream_dispatcher() {
231 return media_stream_dispatcher_;
232 }
233
[email protected]6e24cf12011-03-18 19:57:02234 // Current P2PSocketDispatcher. Set to NULL if P2P API is disabled.
[email protected]b3f8f9722011-08-25 20:56:07235 content::P2PSocketDispatcher* p2p_socket_dispatcher() {
[email protected]6e24cf12011-03-18 19:57:02236 return p2p_socket_dispatcher_;
237 }
238
[email protected]217690d2012-01-27 07:33:11239 MouseLockDispatcher* mouse_lock_dispatcher() {
240 return mouse_lock_dispatcher_;
241 }
242
[email protected]273558fb2012-01-12 15:03:51243 WebKit::WebPeerConnectionHandler* CreatePeerConnectionHandler(
244 WebKit::WebPeerConnectionHandlerClient* client);
[email protected]50da23d02012-04-13 17:47:48245 WebKit::WebPeerConnection00Handler* CreatePeerConnectionHandlerJsep(
246 WebKit::WebPeerConnection00HandlerClient* client);
[email protected]273558fb2012-01-12 15:03:51247
[email protected]6e24cf12011-03-18 19:57:02248 // Functions to add and remove observers for this object.
[email protected]3a034ebb2011-10-03 19:19:44249 void AddObserver(content::RenderViewObserver* observer);
250 void RemoveObserver(content::RenderViewObserver* observer);
[email protected]6e24cf12011-03-18 19:57:02251
[email protected]6e24cf12011-03-18 19:57:02252 // Adds the given file chooser request to the file_chooser_completion_ queue
253 // (see that var for more) and requests the chooser be displayed if there are
254 // no other waiting items in the queue.
255 //
256 // Returns true if the chooser was successfully scheduled. False means we
257 // didn't schedule anything.
[email protected]8caadeb2011-11-22 02:45:23258 bool ScheduleFileChooser(const content::FileChooserParams& params,
[email protected]6e24cf12011-03-18 19:57:02259 WebKit::WebFileChooserCompletion* completion);
260
[email protected]6e24cf12011-03-18 19:57:02261 // Sets whether the renderer should report load progress to the browser.
262 void SetReportLoadProgressEnabled(bool enabled);
263
[email protected]2ac2be8b2012-03-21 23:11:28264 bool guest() const { return guest_; }
265
[email protected]a2ef54c2011-10-10 16:20:31266 void LoadNavigationErrorPage(
[email protected]8d128d62011-09-13 22:11:57267 WebKit::WebFrame* frame,
268 const WebKit::WebURLRequest& failed_request,
269 const WebKit::WebURLError& error,
270 const std::string& html,
271 bool replace);
[email protected]9966325b2011-04-18 05:00:10272
[email protected]6e24cf12011-03-18 19:57:02273 // Plugin-related functions --------------------------------------------------
274 // (See also WebPluginPageDelegate implementation.)
275
276 // Notification that the given plugin has crashed.
277 void PluginCrashed(const FilePath& plugin_path);
278
[email protected]6e24cf12011-03-18 19:57:02279 // Creates a fullscreen container for a pepper plugin instance.
[email protected]ea192e82011-04-11 19:16:02280 RenderWidgetFullscreenPepper* CreatePepperFullscreenContainer(
[email protected]6e24cf12011-03-18 19:57:02281 webkit::ppapi::PluginInstance* plugin);
282
[email protected]56ea1a62011-05-30 07:05:57283 // Informs the render view that a PPAPI plugin has gained or lost focus.
284 void PpapiPluginFocusChanged();
285
[email protected]73bf95812011-10-12 11:38:32286 // Informs the render view that a PPAPI plugin has changed text input status.
287 void PpapiPluginTextInputTypeChanged();
[email protected]3f783362011-10-21 22:40:50288 void PpapiPluginCaretPositionChanged();
[email protected]73bf95812011-10-12 11:38:32289
290 // Cancels current composition.
291 void PpapiPluginCancelComposition();
292
[email protected]3c8c74c2012-03-15 07:34:52293 // Informs the render view that a PPAPI plugin has changed selection.
294 void PpapiPluginSelectionChanged();
295
[email protected]b25b3ee2012-01-13 05:19:54296 // Retrieves the current caret position if a PPAPI plugin has focus.
297 bool GetPpapiPluginCaretBounds(gfx::Rect* rect);
298
[email protected]e6ae0f6c2011-10-04 10:39:23299#if defined(OS_MACOSX) || defined(OS_WIN)
[email protected]6e24cf12011-03-18 19:57:02300 // Informs the render view that the given plugin has gained or lost focus.
301 void PluginFocusChanged(bool focused, int plugin_id);
[email protected]e6ae0f6c2011-10-04 10:39:23302#endif
[email protected]6e24cf12011-03-18 19:57:02303
[email protected]e6ae0f6c2011-10-04 10:39:23304#if defined(OS_MACOSX)
[email protected]6e24cf12011-03-18 19:57:02305 // Starts plugin IME.
306 void StartPluginIme();
307
308 // Helper routines for accelerated plugin support. Used by the
309 // WebPluginDelegateProxy, which has a pointer to the RenderView.
310 gfx::PluginWindowHandle AllocateFakePluginWindowHandle(bool opaque,
311 bool root);
312 void DestroyFakePluginWindowHandle(gfx::PluginWindowHandle window);
313 void AcceleratedSurfaceSetIOSurface(gfx::PluginWindowHandle window,
314 int32 width,
315 int32 height,
316 uint64 io_surface_identifier);
317 TransportDIB::Handle AcceleratedSurfaceAllocTransportDIB(size_t size);
318 void AcceleratedSurfaceFreeTransportDIB(TransportDIB::Id dib_id);
319 void AcceleratedSurfaceSetTransportDIB(gfx::PluginWindowHandle window,
320 int32 width,
321 int32 height,
322 TransportDIB::Handle transport_dib);
323 void AcceleratedSurfaceBuffersSwapped(gfx::PluginWindowHandle window,
324 uint64 surface_id);
325#endif
326
327 void RegisterPluginDelegate(WebPluginDelegateProxy* delegate);
328 void UnregisterPluginDelegate(WebPluginDelegateProxy* delegate);
329
[email protected]4a7d6392011-09-19 20:55:08330 // Helper function to retrieve information about a plugin for a URL and mime
331 // type. Returns false if no plugin was found.
332 // |actual_mime_type| is the actual mime type supported by the
333 // plugin found that match the URL given (one for each item in
334 // |info|).
[email protected]84c13c032011-09-23 00:12:22335 CONTENT_EXPORT bool GetPluginInfo(const GURL& url,
336 const GURL& page_url,
337 const std::string& mime_type,
338 webkit::WebPluginInfo* plugin_info,
339 std::string* actual_mime_type);
[email protected]4a7d6392011-09-19 20:55:08340
[email protected]7a1ec28a2012-03-28 21:10:24341 void TransferActiveWheelFlingAnimation(
342 const WebKit::WebActiveWheelFlingParameters& params);
343
[email protected]6e24cf12011-03-18 19:57:02344 // IPC::Channel::Listener implementation -------------------------------------
345
[email protected]edc64de2011-11-17 20:07:38346 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
[email protected]6e24cf12011-03-18 19:57:02347
348 // WebKit::WebWidgetClient implementation ------------------------------------
349
350 // Most methods are handled by RenderWidget.
351 virtual void didFocus();
352 virtual void didBlur();
353 virtual void show(WebKit::WebNavigationPolicy policy);
354 virtual void runModal();
[email protected]2b624c562011-10-27 22:58:26355 virtual bool enterFullScreen();
356 virtual void exitFullScreen();
[email protected]217690d2012-01-27 07:33:11357 virtual bool requestPointerLock();
358 virtual void requestPointerUnlock();
359 virtual bool isPointerLocked();
[email protected]7a1ec28a2012-03-28 21:10:24360 virtual void didActivateCompositor(int input_handler_identifier);
[email protected]6e24cf12011-03-18 19:57:02361
362 // WebKit::WebViewClient implementation --------------------------------------
363
364 virtual WebKit::WebView* createView(
365 WebKit::WebFrame* creator,
366 const WebKit::WebURLRequest& request,
367 const WebKit::WebWindowFeatures& features,
[email protected]916dfb62012-03-05 03:39:37368 const WebKit::WebString& frame_name,
369 WebKit::WebNavigationPolicy policy);
[email protected]6e24cf12011-03-18 19:57:02370 virtual WebKit::WebWidget* createPopupMenu(WebKit::WebPopupType popup_type);
[email protected]6e24cf12011-03-18 19:57:02371 virtual WebKit::WebExternalPopupMenu* createExternalPopupMenu(
372 const WebKit::WebPopupMenuInfo& popup_menu_info,
373 WebKit::WebExternalPopupMenuClient* popup_menu_client);
374 virtual WebKit::WebStorageNamespace* createSessionStorageNamespace(
375 unsigned quota);
[email protected]7e8b4d12012-01-20 23:39:51376 virtual WebKit::WebGraphicsContext3D* createGraphicsContext3D(
[email protected]40ec0c12012-03-08 12:34:40377 const WebKit::WebGraphicsContext3D::Attributes& attributes);
[email protected]6e24cf12011-03-18 19:57:02378 virtual void didAddMessageToConsole(
379 const WebKit::WebConsoleMessage& message,
380 const WebKit::WebString& source_name,
381 unsigned source_line);
382 virtual void printPage(WebKit::WebFrame* frame);
383 virtual WebKit::WebNotificationPresenter* notificationPresenter();
[email protected]8a58c1c2011-04-19 18:40:12384 virtual bool enumerateChosenDirectory(
385 const WebKit::WebString& path,
386 WebKit::WebFileChooserCompletion* chooser_completion);
[email protected]6e24cf12011-03-18 19:57:02387 virtual void didStartLoading();
388 virtual void didStopLoading();
389 virtual void didChangeLoadProgress(WebKit::WebFrame* frame,
390 double load_progress);
391 virtual bool isSmartInsertDeleteEnabled();
392 virtual bool isSelectTrailingWhitespaceEnabled();
393 virtual void didChangeSelection(bool is_selection_empty);
394 virtual void didExecuteCommand(const WebKit::WebString& command_name);
395 virtual bool handleCurrentKeyboardEvent();
[email protected]da8543762012-03-20 08:52:20396 virtual WebKit::WebColorChooser* createColorChooser(
397 WebKit::WebColorChooserClient*, const WebKit::WebColor& initial_color);
[email protected]6e24cf12011-03-18 19:57:02398 virtual bool runFileChooser(
399 const WebKit::WebFileChooserParams& params,
400 WebKit::WebFileChooserCompletion* chooser_completion);
401 virtual void runModalAlertDialog(WebKit::WebFrame* frame,
402 const WebKit::WebString& message);
403 virtual bool runModalConfirmDialog(WebKit::WebFrame* frame,
404 const WebKit::WebString& message);
405 virtual bool runModalPromptDialog(WebKit::WebFrame* frame,
406 const WebKit::WebString& message,
407 const WebKit::WebString& default_value,
408 WebKit::WebString* actual_value);
409 virtual bool runModalBeforeUnloadDialog(WebKit::WebFrame* frame,
410 const WebKit::WebString& message);
411 virtual void showContextMenu(WebKit::WebFrame* frame,
412 const WebKit::WebContextMenuData& data);
[email protected]6e24cf12011-03-18 19:57:02413 virtual void setStatusText(const WebKit::WebString& text);
414 virtual void setMouseOverURL(const WebKit::WebURL& url);
415 virtual void setKeyboardFocusURL(const WebKit::WebURL& url);
[email protected]6e24cf12011-03-18 19:57:02416 virtual void startDragging(const WebKit::WebDragData& data,
417 WebKit::WebDragOperationsMask mask,
418 const WebKit::WebImage& image,
419 const WebKit::WebPoint& imageOffset);
420 virtual bool acceptsLoadDrops();
421 virtual void focusNext();
422 virtual void focusPrevious();
423 virtual void focusedNodeChanged(const WebKit::WebNode& node);
[email protected]169d4282011-11-30 19:33:59424 virtual void didUpdateLayout();
[email protected]6e24cf12011-03-18 19:57:02425 virtual void navigateBackForwardSoon(int offset);
426 virtual int historyBackListCount();
427 virtual int historyForwardListCount();
428 virtual void postAccessibilityNotification(
429 const WebKit::WebAccessibilityObject& obj,
430 WebKit::WebAccessibilityNotification notification);
431 virtual void didUpdateInspectorSetting(const WebKit::WebString& key,
432 const WebKit::WebString& value);
433 virtual WebKit::WebGeolocationClient* geolocationClient();
434 virtual WebKit::WebSpeechInputController* speechInputController(
435 WebKit::WebSpeechInputListener* listener);
436 virtual WebKit::WebDeviceOrientationClient* deviceOrientationClient();
437 virtual void zoomLimitsChanged(double minimum_level, double maximum_level);
438 virtual void zoomLevelChanged();
439 virtual void registerProtocolHandler(const WebKit::WebString& scheme,
440 const WebKit::WebString& base_url,
441 const WebKit::WebString& url,
442 const WebKit::WebString& title);
[email protected]94dec932011-05-26 20:04:21443 virtual WebKit::WebPageVisibilityState visibilityState() const;
[email protected]273558fb2012-01-12 15:03:51444 virtual WebKit::WebUserMediaClient* userMediaClient();
[email protected]6e24cf12011-03-18 19:57:02445
446 // WebKit::WebFrameClient implementation -------------------------------------
447
448 virtual WebKit::WebPlugin* createPlugin(
449 WebKit::WebFrame* frame,
450 const WebKit::WebPluginParams& params);
[email protected]6ac77cb2012-05-01 14:49:01451 virtual WebKit::WebPlugin* createPluginReplacement(
452 WebKit::WebFrame* frame,
453 const WebKit::WebPluginParams& params);
[email protected]6e24cf12011-03-18 19:57:02454 virtual WebKit::WebSharedWorker* createSharedWorker(
455 WebKit::WebFrame* frame, const WebKit::WebURL& url,
456 const WebKit::WebString& name, unsigned long long documentId);
457 virtual WebKit::WebMediaPlayer* createMediaPlayer(
458 WebKit::WebFrame* frame,
459 WebKit::WebMediaPlayerClient* client);
460 virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(
461 WebKit::WebFrame* frame,
462 WebKit::WebApplicationCacheHostClient* client);
463 virtual WebKit::WebCookieJar* cookieJar(WebKit::WebFrame* frame);
464 virtual void frameDetached(WebKit::WebFrame* frame);
465 virtual void willClose(WebKit::WebFrame* frame);
[email protected]6e24cf12011-03-18 19:57:02466 virtual void loadURLExternally(WebKit::WebFrame* frame,
467 const WebKit::WebURLRequest& request,
468 WebKit::WebNavigationPolicy policy);
[email protected]0622875ab2011-07-27 12:10:34469 virtual void loadURLExternally(WebKit::WebFrame* frame,
470 const WebKit::WebURLRequest& request,
471 WebKit::WebNavigationPolicy policy,
472 const WebKit::WebString& suggested_name);
[email protected]6e24cf12011-03-18 19:57:02473 virtual WebKit::WebNavigationPolicy decidePolicyForNavigation(
474 WebKit::WebFrame* frame,
475 const WebKit::WebURLRequest& request,
476 WebKit::WebNavigationType type,
477 const WebKit::WebNode&,
478 WebKit::WebNavigationPolicy default_policy,
479 bool is_redirect);
480 virtual bool canHandleRequest(WebKit::WebFrame* frame,
481 const WebKit::WebURLRequest& request);
482 virtual WebKit::WebURLError cannotHandleRequestError(
483 WebKit::WebFrame* frame,
484 const WebKit::WebURLRequest& request);
485 virtual WebKit::WebURLError cancelledError(
486 WebKit::WebFrame* frame,
487 const WebKit::WebURLRequest& request);
488 virtual void unableToImplementPolicyWithError(
489 WebKit::WebFrame* frame,
490 const WebKit::WebURLError& error);
491 virtual void willSendSubmitEvent(WebKit::WebFrame* frame,
492 const WebKit::WebFormElement& form);
493 virtual void willSubmitForm(WebKit::WebFrame* frame,
494 const WebKit::WebFormElement& form);
495 virtual void willPerformClientRedirect(WebKit::WebFrame* frame,
496 const WebKit::WebURL& from,
497 const WebKit::WebURL& to,
498 double interval,
499 double fire_time);
500 virtual void didCancelClientRedirect(WebKit::WebFrame* frame);
501 virtual void didCompleteClientRedirect(WebKit::WebFrame* frame,
502 const WebKit::WebURL& from);
503 virtual void didCreateDataSource(WebKit::WebFrame* frame,
504 WebKit::WebDataSource* datasource);
505 virtual void didStartProvisionalLoad(WebKit::WebFrame* frame);
506 virtual void didReceiveServerRedirectForProvisionalLoad(
507 WebKit::WebFrame* frame);
508 virtual void didFailProvisionalLoad(WebKit::WebFrame* frame,
509 const WebKit::WebURLError& error);
510 virtual void didReceiveDocumentData(WebKit::WebFrame* frame,
511 const char* data, size_t length,
512 bool& prevent_default);
513 virtual void didCommitProvisionalLoad(WebKit::WebFrame* frame,
514 bool is_new_navigation);
515 virtual void didClearWindowObject(WebKit::WebFrame* frame);
516 virtual void didCreateDocumentElement(WebKit::WebFrame* frame);
517 virtual void didReceiveTitle(WebKit::WebFrame* frame,
[email protected]a3bc4d12011-04-20 17:22:21518 const WebKit::WebString& title,
519 WebKit::WebTextDirection direction);
[email protected]42054a252011-05-17 18:02:13520 virtual void didChangeIcon(WebKit::WebFrame*,
521 WebKit::WebIconURL::Type) OVERRIDE;
[email protected]6e24cf12011-03-18 19:57:02522 virtual void didFinishDocumentLoad(WebKit::WebFrame* frame);
523 virtual void didHandleOnloadEvents(WebKit::WebFrame* frame);
524 virtual void didFailLoad(WebKit::WebFrame* frame,
525 const WebKit::WebURLError& error);
526 virtual void didFinishLoad(WebKit::WebFrame* frame);
527 virtual void didNavigateWithinPage(WebKit::WebFrame* frame,
528 bool is_new_navigation);
529 virtual void didUpdateCurrentHistoryItem(WebKit::WebFrame* frame);
530 virtual void assignIdentifierToRequest(WebKit::WebFrame* frame,
531 unsigned identifier,
532 const WebKit::WebURLRequest& request);
533 virtual void willSendRequest(WebKit::WebFrame* frame,
534 unsigned identifier,
535 WebKit::WebURLRequest& request,
536 const WebKit::WebURLResponse& redirect_response);
537 virtual void didReceiveResponse(WebKit::WebFrame* frame,
538 unsigned identifier,
539 const WebKit::WebURLResponse& response);
540 virtual void didFinishResourceLoad(WebKit::WebFrame* frame,
541 unsigned identifier);
542 virtual void didFailResourceLoad(WebKit::WebFrame* frame,
543 unsigned identifier,
544 const WebKit::WebURLError& error);
545 virtual void didLoadResourceFromMemoryCache(
546 WebKit::WebFrame* frame,
547 const WebKit::WebURLRequest& request,
548 const WebKit::WebURLResponse&);
549 virtual void didDisplayInsecureContent(WebKit::WebFrame* frame);
550 virtual void didRunInsecureContent(
551 WebKit::WebFrame* frame,
552 const WebKit::WebSecurityOrigin& origin,
553 const WebKit::WebURL& target);
[email protected]b00ba702011-08-17 01:41:03554 virtual void didAdoptURLLoader(WebKit::WebURLLoader* loader);
[email protected]6e24cf12011-03-18 19:57:02555 virtual void didExhaustMemoryAvailableForScript(WebKit::WebFrame* frame);
[email protected]5bc10932011-09-21 21:03:30556 virtual void didCreateScriptContext(WebKit::WebFrame* frame,
557 v8::Handle<v8::Context>,
[email protected]a00fe692012-02-27 05:52:58558 int extension_group,
559 int world_id);
560 // TODO(koz): Remove once WebKit no longer calls this.
561 virtual void didCreateScriptContext(WebKit::WebFrame* frame,
562 v8::Handle<v8::Context>,
[email protected]5bc10932011-09-21 21:03:30563 int world_id);
564 virtual void willReleaseScriptContext(WebKit::WebFrame* frame,
565 v8::Handle<v8::Context>,
566 int world_id);
[email protected]6e24cf12011-03-18 19:57:02567 virtual void didChangeScrollOffset(WebKit::WebFrame* frame);
[email protected]dd6afca2011-08-13 03:44:31568 virtual void numberOfWheelEventHandlersChanged(unsigned num_handlers);
[email protected]ea931252012-02-15 22:01:03569 virtual void numberOfTouchEventHandlersChanged(unsigned num_handlers);
[email protected]dd6afca2011-08-13 03:44:31570 virtual void didChangeContentsSize(WebKit::WebFrame* frame,
571 const WebKit::WebSize& size);
[email protected]6e24cf12011-03-18 19:57:02572 virtual void reportFindInPageMatchCount(int request_id,
573 int count,
574 bool final_update);
575 virtual void reportFindInPageSelection(int request_id,
576 int active_match_ordinal,
577 const WebKit::WebRect& sel);
[email protected]6e24cf12011-03-18 19:57:02578 virtual void openFileSystem(WebKit::WebFrame* frame,
579 WebKit::WebFileSystem::Type type,
580 long long size,
581 bool create,
582 WebKit::WebFileSystemCallbacks* callbacks);
[email protected]10e5cf12011-04-13 04:10:40583 virtual void queryStorageUsageAndQuota(
584 WebKit::WebFrame* frame,
585 WebKit::WebStorageQuotaType type,
586 WebKit::WebStorageQuotaCallbacks* callbacks);
[email protected]10e5cf12011-04-13 04:10:40587 virtual void requestStorageQuota(
588 WebKit::WebFrame* frame,
589 WebKit::WebStorageQuotaType type,
590 unsigned long long requested_size,
591 WebKit::WebStorageQuotaCallbacks* callbacks);
[email protected]8b5af492011-11-28 21:50:58592 virtual void registerIntentService(
593 WebKit::WebFrame* frame,
594 const WebKit::WebIntentServiceInfo& service);
595 virtual void dispatchIntent(WebKit::WebFrame* frame,
[email protected]ffc8bed2012-01-21 01:23:15596 const WebKit::WebIntentRequest& intentRequest);
[email protected]5fa3a062012-03-21 15:39:34597 virtual void willOpenSocketStream(
598 WebKit::WebSocketStreamHandle* handle);
[email protected]f546640b2012-05-15 00:03:49599 virtual bool willCheckAndDispatchMessageEvent(
600 WebKit::WebFrame* source,
601 WebKit::WebSecurityOrigin targetOrigin,
602 WebKit::WebDOMMessageEvent event) OVERRIDE;
[email protected]8b5af492011-11-28 21:50:58603
[email protected]18d5be92011-07-25 18:00:19604 // WebKit::WebPageSerializerClient implementation ----------------------------
605
606 virtual void didSerializeDataForFrame(
607 const WebKit::WebURL& frame_url,
608 const WebKit::WebCString& data,
609 PageSerializationStatus status) OVERRIDE;
610
[email protected]a2ef54c2011-10-10 16:20:31611 // content::RenderView implementation ----------------------------------------
612
613 virtual bool Send(IPC::Message* message) OVERRIDE;
[email protected]9f76c1e2012-03-05 15:15:58614 virtual int GetRoutingID() const OVERRIDE;
[email protected]82114f52012-03-20 22:53:41615 virtual int GetPageId() const OVERRIDE;
616 virtual gfx::Size GetSize() const OVERRIDE;
617 virtual gfx::NativeViewId GetHostWindow() const OVERRIDE;
[email protected]6717bf272012-05-11 23:31:25618 virtual webkit_glue::WebPreferences& GetWebkitPreferences() OVERRIDE;
[email protected]a2ef54c2011-10-10 16:20:31619 virtual WebKit::WebView* GetWebView() OVERRIDE;
620 virtual WebKit::WebNode GetFocusedNode() const OVERRIDE;
621 virtual WebKit::WebNode GetContextMenuNode() const OVERRIDE;
[email protected]82114f52012-03-20 22:53:41622 virtual bool IsEditableNode(const WebKit::WebNode& node) const OVERRIDE;
[email protected]a2ef54c2011-10-10 16:20:31623 virtual WebKit::WebPlugin* CreatePlugin(
624 WebKit::WebFrame* frame,
625 const webkit::WebPluginInfo& info,
626 const WebKit::WebPluginParams& params) OVERRIDE;
627 virtual void EvaluateScript(const string16& frame_xpath,
628 const string16& jscript,
629 int id,
630 bool notify_result) OVERRIDE;
631 virtual bool ShouldDisplayScrollbars(int width, int height) const OVERRIDE;
[email protected]82114f52012-03-20 22:53:41632 virtual int GetEnabledBindings() const OVERRIDE;
633 virtual bool GetContentStateImmediately() const OVERRIDE;
634 virtual float GetFilteredTimePerFrame() const OVERRIDE;
[email protected]a2ef54c2011-10-10 16:20:31635 virtual void ShowContextMenu(WebKit::WebFrame* frame,
636 const WebKit::WebContextMenuData& data) OVERRIDE;
637 virtual WebKit::WebPageVisibilityState GetVisibilityState() const OVERRIDE;
638 virtual void RunModalAlertDialog(WebKit::WebFrame* frame,
639 const WebKit::WebString& message) OVERRIDE;
640 virtual void LoadURLExternally(
641 WebKit::WebFrame* frame,
642 const WebKit::WebURLRequest& request,
643 WebKit::WebNavigationPolicy policy) OVERRIDE;
644
[email protected]6e24cf12011-03-18 19:57:02645 // webkit_glue::WebPluginPageDelegate implementation -------------------------
646
647 virtual webkit::npapi::WebPluginDelegate* CreatePluginDelegate(
648 const FilePath& file_path,
[email protected]edc64de2011-11-17 20:07:38649 const std::string& mime_type) OVERRIDE;
[email protected]6ac77cb2012-05-01 14:49:01650 virtual WebKit::WebPlugin* CreatePluginReplacement(
651 const FilePath& file_path) OVERRIDE;
[email protected]edc64de2011-11-17 20:07:38652 virtual void CreatedPluginWindow(gfx::PluginWindowHandle handle) OVERRIDE;
653 virtual void WillDestroyPluginWindow(gfx::PluginWindowHandle handle) OVERRIDE;
654 virtual void DidMovePlugin(
655 const webkit::npapi::WebPluginGeometry& move) OVERRIDE;
656 virtual void DidStartLoadingForPlugin() OVERRIDE;
657 virtual void DidStopLoadingForPlugin() OVERRIDE;
658 virtual WebKit::WebCookieJar* GetCookieJar() OVERRIDE;
[email protected]6e24cf12011-03-18 19:57:02659
[email protected]a9288f52011-11-17 05:18:16660 // webkit_media::WebMediaPlayerDelegate implementation -----------------------
[email protected]baff4512011-10-19 18:21:07661
[email protected]a9288f52011-11-17 05:18:16662 virtual void DidPlay(webkit_media::WebMediaPlayerImpl* player) OVERRIDE;
663 virtual void DidPause(webkit_media::WebMediaPlayerImpl* player) OVERRIDE;
664 virtual void PlayerGone(webkit_media::WebMediaPlayerImpl* player) OVERRIDE;
[email protected]baff4512011-10-19 18:21:07665
[email protected]6e24cf12011-03-18 19:57:02666 // Please do not add your stuff randomly to the end here. If there is an
667 // appropriate section, add it there. If not, there are some random functions
668 // nearer to the top you can add it to.
[email protected]6e24cf12011-03-18 19:57:02669
[email protected]38b592902011-04-16 02:08:42670 // Cannot use std::set unfortunately since linked_ptr<> does not support
671 // operator<.
672 typedef std::vector<linked_ptr<webkit_glue::ImageResourceFetcher> >
673 ImageResourceFetcherList;
674
[email protected]6e24cf12011-03-18 19:57:02675 protected:
676 // RenderWidget overrides:
[email protected]edc64de2011-11-17 20:07:38677 virtual void Close() OVERRIDE;
[email protected]6e24cf12011-03-18 19:57:02678 virtual void OnResize(const gfx::Size& new_size,
[email protected]ee41e7d22011-10-14 19:34:09679 const gfx::Rect& resizer_rect,
[email protected]edc64de2011-11-17 20:07:38680 bool is_fullscreen) OVERRIDE;
[email protected]29ed96a2012-02-04 18:12:16681 virtual void WillInitiatePaint() OVERRIDE;
[email protected]edc64de2011-11-17 20:07:38682 virtual void DidInitiatePaint() OVERRIDE;
[email protected]29ed96a2012-02-04 18:12:16683 virtual void DidFlushPaint() OVERRIDE;
[email protected]6e24cf12011-03-18 19:57:02684 virtual webkit::ppapi::PluginInstance* GetBitmapForOptimizedPluginPaint(
685 const gfx::Rect& paint_bounds,
686 TransportDIB** dib,
687 gfx::Rect* location,
[email protected]edc64de2011-11-17 20:07:38688 gfx::Rect* clip) OVERRIDE;
689 virtual gfx::Point GetScrollOffset() OVERRIDE;
690 virtual void DidHandleKeyEvent() OVERRIDE;
[email protected]67bfb83f2011-09-22 03:36:37691 virtual bool WillHandleMouseEvent(
692 const WebKit::WebMouseEvent& event) OVERRIDE;
[email protected]edc64de2011-11-17 20:07:38693 virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event) OVERRIDE;
694 virtual void DidHandleTouchEvent(const WebKit::WebTouchEvent& event) OVERRIDE;
695 virtual void OnSetFocus(bool enable) OVERRIDE;
696 virtual void OnWasHidden() OVERRIDE;
697 virtual void OnWasRestored(bool needs_repainting) OVERRIDE;
[email protected]65225772011-05-12 21:10:24698 virtual bool SupportsAsynchronousSwapBuffers() OVERRIDE;
[email protected]56ea1a62011-05-30 07:05:57699 virtual void OnImeSetComposition(
700 const string16& text,
701 const std::vector<WebKit::WebCompositionUnderline>& underlines,
702 int selection_start,
703 int selection_end) OVERRIDE;
[email protected]4de6d1692011-10-12 08:45:44704 virtual void OnImeConfirmComposition(
705 const string16& text, const ui::Range& replacement_range) OVERRIDE;
[email protected]ad26ef42011-06-17 07:59:45706 virtual ui::TextInputType GetTextInputType() OVERRIDE;
[email protected]3f783362011-10-21 22:40:50707 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) OVERRIDE;
[email protected]ad26ef42011-06-17 07:59:45708 virtual bool CanComposeInline() OVERRIDE;
[email protected]c3d45532011-10-07 19:20:40709 virtual bool WebWidgetHandlesCompositorScheduling() const OVERRIDE;
[email protected]6e24cf12011-03-18 19:57:02710
711 private:
[email protected]6e24cf12011-03-18 19:57:02712 // For unit tests.
713 friend class ExternalPopupMenuTest;
714 friend class PepperDeviceTest;
[email protected]c6d068ff2011-10-14 17:28:23715 friend class content::RenderViewTest;
[email protected]6e24cf12011-03-18 19:57:02716
717 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuRemoveTest, RemoveOnChange);
718 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, NormalCase);
719 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, ShowPopupThenNavigate);
[email protected]744c2a22012-03-15 18:42:04720 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, DecideNavigationPolicyForWebUI);
[email protected]068970d2011-10-11 00:05:16721 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
722 DontIgnoreBackAfterNavEntryLimit);
723 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, ImeComposition);
724 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, InsertCharacters);
725 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, JSBlockSentAfterPageLoad);
726 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, LastCommittedUpdateState);
727 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnHandleKeyboardEvent);
728 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnImeStateChanged);
729 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnNavStateChanged);
730 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnSetTextDirection);
731 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnUpdateWebPreferences);
[email protected]73eb2602012-02-09 19:50:55732 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, SendSwapOutACK);
[email protected]068970d2011-10-11 00:05:16733 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, StaleNavigationsIgnored);
734 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, UpdateTargetURLWithInvalidURL);
[email protected]6e24cf12011-03-18 19:57:02735#if defined(OS_MACOSX)
736 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, MacTestCmdUp);
737#endif
[email protected]068970d2011-10-11 00:05:16738 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, SetHistoryLengthAndPrune);
[email protected]6e24cf12011-03-18 19:57:02739
[email protected]6e24cf12011-03-18 19:57:02740 typedef std::map<GURL, double> HostZoomLevels;
741
[email protected]6e24cf12011-03-18 19:57:02742 enum ErrorPageType {
743 DNS_ERROR,
744 HTTP_404,
745 CONNECTION_ERROR,
746 };
747
[email protected]310ebd6302011-10-10 19:06:28748 RenderViewImpl(gfx::NativeViewId parent_hwnd,
749 int32 opener_id,
[email protected]daf82f82011-10-31 22:35:31750 const content::RendererPreferences& renderer_prefs,
[email protected]6717bf272012-05-11 23:31:25751 const webkit_glue::WebPreferences& webkit_prefs,
[email protected]310ebd6302011-10-10 19:06:28752 SharedRenderViewCounter* counter,
753 int32 routing_id,
[email protected]9f4f3322012-01-18 22:29:56754 int32 surface_id,
[email protected]310ebd6302011-10-10 19:06:28755 int64 session_storage_namespace_id,
[email protected]74ce1ad2011-12-16 21:51:46756 const string16& frame_name,
[email protected]14392a52012-05-02 20:28:44757 bool is_renderer_created,
758 bool swapped_out,
[email protected]6fd35b72012-03-01 19:46:41759 int32 next_page_id,
[email protected]8cca3da2012-03-20 08:26:34760 const WebKit::WebScreenInfo& screen_info,
[email protected]3e3c4522012-04-13 21:16:29761 bool guest,
762 AccessibilityMode accessibility_mode);
[email protected]6e24cf12011-03-18 19:57:02763
764 // Do not delete directly. This class is reference counted.
[email protected]310ebd6302011-10-10 19:06:28765 virtual ~RenderViewImpl();
[email protected]6e24cf12011-03-18 19:57:02766
767 void UpdateURL(WebKit::WebFrame* frame);
[email protected]a49e10b2011-08-01 23:57:46768 void UpdateTitle(WebKit::WebFrame* frame, const string16& title,
769 WebKit::WebTextDirection title_direction);
[email protected]6e24cf12011-03-18 19:57:02770 void UpdateSessionHistory(WebKit::WebFrame* frame);
[email protected]6459800a2012-03-27 23:57:05771 void SendUpdateState(const WebKit::WebHistoryItem& item);
[email protected]6e24cf12011-03-18 19:57:02772
773 // Update current main frame's encoding and send it to browser window.
774 // Since we want to let users see the right encoding info from menu
775 // before finishing loading, we call the UpdateEncoding in
776 // a) function:DidCommitLoadForFrame. When this function is called,
777 // that means we have got first data. In here we try to get encoding
778 // of page if it has been specified in http header.
779 // b) function:DidReceiveTitle. When this function is called,
780 // that means we have got specified title. Because in most of webpages,
781 // title tags will follow meta tags. In here we try to get encoding of
782 // page if it has been specified in meta tag.
783 // c) function:DidFinishDocumentLoadForFrame. When this function is
784 // called, that means we have got whole html page. In here we should
785 // finally get right encoding of page.
786 void UpdateEncoding(WebKit::WebFrame* frame,
787 const std::string& encoding_name);
788
[email protected]ae5184d62011-10-06 19:25:58789 void OpenURL(WebKit::WebFrame* frame,
790 const GURL& url,
[email protected]445e1042011-12-03 21:03:15791 const content::Referrer& referrer,
[email protected]6e24cf12011-03-18 19:57:02792 WebKit::WebNavigationPolicy policy);
793
[email protected]269f86d2011-12-07 02:43:47794 bool RunJavaScriptMessage(ui::JavascriptMessageType type,
[email protected]4f5ce842011-05-27 19:34:41795 const string16& message,
796 const string16& default_value,
[email protected]6e24cf12011-03-18 19:57:02797 const GURL& frame_url,
[email protected]4f5ce842011-05-27 19:34:41798 string16* result);
[email protected]6e24cf12011-03-18 19:57:02799
800 // Sends a message and runs a nested message loop.
801 bool SendAndRunNestedMessageLoop(IPC::SyncMessage* message);
802
[email protected]dd6afca2011-08-13 03:44:31803 // Called when the "pinned to left/right edge" state needs to be updated.
804 void UpdateScrollState(WebKit::WebFrame* frame);
805
[email protected]6e24cf12011-03-18 19:57:02806 // IPC message handlers ------------------------------------------------------
807 //
808 // The documentation for these functions should be in
809 // render_messages_internal.h for the message that the function is handling.
810
[email protected]744c2a22012-03-15 18:42:04811 CONTENT_EXPORT void OnAllowBindings(int enabled_bindings_flags);
[email protected]6e24cf12011-03-18 19:57:02812 void OnAllowScriptToClose(bool script_can_close);
813 void OnAsyncFileOpened(base::PlatformFileError error_code,
814 IPC::PlatformFileForTransit file_for_transit,
815 int message_id);
[email protected]eb415bf0e2011-04-14 02:45:42816 void OnPpapiBrokerChannelCreated(int request_id,
[email protected]d54305072011-06-22 20:58:43817 const IPC::ChannelHandle& handle);
[email protected]6e24cf12011-03-18 19:57:02818 void OnCancelDownload(int32 download_id);
819 void OnClearFocusedNode();
[email protected]992db4c2011-05-12 15:37:15820 void OnClosePage();
[email protected]6e24cf12011-03-18 19:57:02821 void OnContextMenuClosed(
[email protected]35be7ec2012-02-12 20:42:51822 const content::CustomContextMenuContext& custom_context);
[email protected]6e24cf12011-03-18 19:57:02823 void OnCopy();
824 void OnCopyImageAt(int x, int y);
825#if defined(OS_MACOSX)
826 void OnCopyToFindPboard();
827#endif
828 void OnCut();
[email protected]318bf5802011-08-08 17:12:41829 void OnCSSInsertRequest(const string16& frame_xpath,
[email protected]01cf589c2011-07-28 18:04:03830 const std::string& css);
[email protected]6e24cf12011-03-18 19:57:02831 void OnCustomContextMenuAction(
[email protected]35be7ec2012-02-12 20:42:51832 const content::CustomContextMenuContext& custom_context,
[email protected]6e24cf12011-03-18 19:57:02833 unsigned action);
834 void OnDelete();
835 void OnDeterminePageLanguage();
836 void OnDisableScrollbarsForSmallWindows(
837 const gfx::Size& disable_scrollbars_size_limit);
838 void OnDisassociateFromPopupCount();
[email protected]6e24cf12011-03-18 19:57:02839 void OnDragSourceEndedOrMoved(const gfx::Point& client_point,
840 const gfx::Point& screen_point,
841 bool ended,
842 WebKit::WebDragOperation drag_operation);
843 void OnDragSourceSystemDragEnded();
844 void OnDragTargetDrop(const gfx::Point& client_pt,
845 const gfx::Point& screen_pt);
846 void OnDragTargetDragEnter(const WebDropData& drop_data,
847 const gfx::Point& client_pt,
848 const gfx::Point& screen_pt,
849 WebKit::WebDragOperationsMask operations_allowed);
850 void OnDragTargetDragLeave();
851 void OnDragTargetDragOver(const gfx::Point& client_pt,
852 const gfx::Point& screen_pt,
853 WebKit::WebDragOperationsMask operations_allowed);
[email protected]2bf834f2011-11-17 20:02:21854 void OnEnablePreferredSizeChangedMode();
[email protected]244ac1892011-12-02 17:04:47855 void OnEnableAutoResize(const gfx::Size& min_size, const gfx::Size& max_size);
[email protected]61e2b3cc2012-03-02 16:13:34856 void OnDisableAutoResize(const gfx::Size& new_size);
[email protected]600ea402011-04-12 00:01:51857 void OnEnumerateDirectoryResponse(int id, const std::vector<FilePath>& paths);
[email protected]6e24cf12011-03-18 19:57:02858 void OnExecuteEditCommand(const std::string& name, const std::string& value);
[email protected]fb11b6a42012-03-14 07:25:12859 void OnFileChooserResponse(
860 const std::vector<content::SelectedFileInfo>& files);
[email protected]6e24cf12011-03-18 19:57:02861 void OnFind(int request_id, const string16&, const WebKit::WebFindOptions&);
862 void OnFindReplyAck();
[email protected]18d5be92011-07-25 18:00:19863 void OnGetAllSavableResourceLinksForCurrentPage(const GURL& page_url);
864 void OnGetSerializedHtmlDataForCurrentPageWithLocalLinks(
865 const std::vector<GURL>& links,
866 const std::vector<FilePath>& local_paths,
867 const FilePath& local_directory_name);
[email protected]6e24cf12011-03-18 19:57:02868 void OnMediaPlayerActionAt(const gfx::Point& location,
869 const WebKit::WebMediaPlayerAction& action);
[email protected]81375e872012-01-11 21:40:36870 void OnPluginActionAt(const gfx::Point& location,
871 const WebKit::WebPluginAction& action);
[email protected]6e24cf12011-03-18 19:57:02872 void OnMoveOrResizeStarted();
[email protected]f3112a52011-09-30 23:47:49873 CONTENT_EXPORT void OnNavigate(const ViewMsg_Navigate_Params& params);
[email protected]6e24cf12011-03-18 19:57:02874 void OnPaste();
[email protected]44bf7002011-10-16 02:46:15875 void OnPasteAndMatchStyle();
[email protected]6e24cf12011-03-18 19:57:02876#if defined(OS_MACOSX)
877 void OnPluginImeCompositionCompleted(const string16& text, int plugin_id);
878#endif
[email protected]f546640b2012-05-15 00:03:49879 void OnPostMessageEvent(const ViewMsg_PostMessage_Params& params);
[email protected]6e24cf12011-03-18 19:57:02880 void OnRedo();
881 void OnReloadFrame();
882 void OnReplace(const string16& text);
[email protected]6e24cf12011-03-18 19:57:02883 void OnResetPageEncodingToDefault();
884 void OnScriptEvalRequest(const string16& frame_xpath,
885 const string16& jscript,
886 int id,
887 bool notify_result);
888 void OnSelectAll();
[email protected]4fb60142011-08-09 02:22:08889 void OnSelectRange(const gfx::Point& start, const gfx::Point& end);
[email protected]6e24cf12011-03-18 19:57:02890 void OnSetActive(bool active);
891 void OnSetAltErrorPageURL(const GURL& gurl);
892 void OnSetBackground(const SkBitmap& background);
[email protected]7a17bac02012-03-07 21:58:12893 void OnSetNavigationStartTime(
894 const base::TimeTicks& browser_navigation_start);
[email protected]6e24cf12011-03-18 19:57:02895 void OnSetWebUIProperty(const std::string& name, const std::string& value);
[email protected]c5d463e2012-03-15 21:05:56896 CONTENT_EXPORT void OnSetEditCommandsForNextKeyEvent(
897 const EditCommands& edit_commands);
[email protected]f3112a52011-09-30 23:47:49898 CONTENT_EXPORT void OnSetHistoryLengthAndPrune(int history_length,
899 int32 minimum_page_id);
[email protected]6e24cf12011-03-18 19:57:02900 void OnSetInitialFocus(bool reverse);
[email protected]54ca3ca892011-06-07 21:14:54901#if defined(OS_MACOSX)
902 void OnSetInLiveResize(bool in_live_resize);
903#endif
[email protected]333ec8d02011-09-16 18:59:19904 void OnScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect);
[email protected]6e24cf12011-03-18 19:57:02905 void OnSetPageEncoding(const std::string& encoding_name);
[email protected]daf82f82011-10-31 22:35:31906 void OnSetRendererPrefs(const content::RendererPreferences& renderer_prefs);
[email protected]6e24cf12011-03-18 19:57:02907#if defined(OS_MACOSX)
908 void OnSetWindowVisibility(bool visible);
909#endif
910 void OnSetZoomLevel(double zoom_level);
911 void OnSetZoomLevelForLoadingURL(const GURL& url, double zoom_level);
[email protected]8a5e0ca2011-08-25 06:30:47912 void OnExitFullscreen();
[email protected]6e24cf12011-03-18 19:57:02913 void OnShouldClose();
914 void OnStop();
[email protected]815dd9872011-11-23 18:40:30915 void OnStopFinding(content::StopFindAction action);
[email protected]73eb2602012-02-09 19:50:55916 CONTENT_EXPORT void OnSwapOut(const ViewMsg_SwapOut_Params& params);
[email protected]6e24cf12011-03-18 19:57:02917 void OnThemeChanged();
[email protected]6e24cf12011-03-18 19:57:02918 void OnUndo();
[email protected]6e24cf12011-03-18 19:57:02919 void OnUpdateTargetURLAck();
[email protected]6717bf272012-05-11 23:31:25920 CONTENT_EXPORT void OnUpdateWebPreferences(
921 const webkit_glue::WebPreferences& prefs);
[email protected]08bb1e722011-07-30 19:13:04922
[email protected]6e24cf12011-03-18 19:57:02923#if defined(OS_MACOSX)
924 void OnWindowFrameChanged(const gfx::Rect& window_frame,
925 const gfx::Rect& view_frame);
[email protected]c5d463e2012-03-15 21:05:56926 CONTENT_EXPORT void OnSelectPopupMenuItem(int selected_index);
[email protected]6e24cf12011-03-18 19:57:02927#endif
[email protected]54087fe2011-10-28 22:02:48928 void OnZoom(content::PageZoom zoom);
[email protected]47578fa02011-11-02 19:34:41929 void OnZoomFactor(content::PageZoom zoom, int zoom_center_x,
930 int zoom_center_y);
931
[email protected]5a7b15a2011-08-22 22:48:18932 void OnEnableViewSourceMode();
[email protected]6e24cf12011-03-18 19:57:02933
[email protected]64d0e192011-12-09 14:44:20934 void OnJavaBridgeInit();
[email protected]7f3c7af2011-10-20 22:52:51935
[email protected]6e24cf12011-03-18 19:57:02936 // Adding a new message handler? Please add it in alphabetical order above
937 // and put it in the same position in the .cc file.
938
939 // Misc private functions ----------------------------------------------------
[email protected]47578fa02011-11-02 19:34:41940 void ZoomFactorHelper(content::PageZoom zoom, int zoom_center_x,
941 int zoom_center_y, float scaling_increment);
[email protected]6e24cf12011-03-18 19:57:02942
[email protected]6e24cf12011-03-18 19:57:02943 void AltErrorPageFinished(WebKit::WebFrame* frame,
944 const WebKit::WebURLError& original_error,
945 const std::string& html);
946
[email protected]d812fd12011-05-27 23:05:07947 // Check whether the preferred size has changed.
[email protected]6e24cf12011-03-18 19:57:02948 void CheckPreferredSize();
949
[email protected]273558fb2012-01-12 15:03:51950 void EnsureMediaStreamImpl();
951
[email protected]5e56df82011-04-18 17:00:15952 // This callback is triggered when DownloadFavicon completes, either
953 // succesfully or with a failure. See DownloadFavicon for more
954 // details.
955 void DidDownloadFavicon(webkit_glue::ImageResourceFetcher* fetcher,
956 const SkBitmap& image);
[email protected]6e24cf12011-03-18 19:57:02957
[email protected]310ebd6302011-10-10 19:06:28958 // Requests to download a favicon image. When done, the RenderView is notified
959 // by way of DidDownloadFavicon. Returns true if the request was successfully
960 // started, false otherwise. id is used to uniquely identify the request and
961 // passed back to the DidDownloadFavicon method. If the image has multiple
962 // frames, the frame whose size is image_size is returned. If the image
963 // doesn't have a frame at the specified size, the first is returned.
[email protected]5e56df82011-04-18 17:00:15964 bool DownloadFavicon(int id, const GURL& image_url, int image_size);
[email protected]6e24cf12011-03-18 19:57:02965
[email protected]6e24cf12011-03-18 19:57:02966 GURL GetAlternateErrorPageURL(const GURL& failed_url,
967 ErrorPageType error_type);
968
969 // Locates a sub frame with given xpath
[email protected]318bf5802011-08-08 17:12:41970 WebKit::WebFrame* GetChildFrame(const string16& frame_xpath) const;
[email protected]6e24cf12011-03-18 19:57:02971
[email protected]57b9396c2011-10-07 19:11:59972 // Returns the opener url if present, else an empty url.
973 GURL GetOpenerUrl() const;
974
[email protected]69ddf852012-02-21 23:21:31975 // Returns the URL being loaded by the given frame's request.
976 GURL GetLoadingUrl(WebKit::WebFrame* frame) const;
977
[email protected]6e24cf12011-03-18 19:57:02978 WebUIBindings* GetWebUIBindings();
979
[email protected]6e24cf12011-03-18 19:57:02980 // Should only be called if this object wraps a PluginDocument.
981 WebKit::WebPlugin* GetWebPluginFromPluginDocument();
982
[email protected]d466b8a2011-07-15 21:48:03983 // Returns true if the |params| navigation is to an entry that has been
984 // cropped due to a recent navigation the browser did not know about.
985 bool IsBackForwardToStaleEntry(const ViewMsg_Navigate_Params& params,
986 bool is_reload);
987
[email protected]6e24cf12011-03-18 19:57:02988 // Returns false unless this is a top-level navigation that crosses origins.
989 bool IsNonLocalTopLevelNavigation(const GURL& url,
990 WebKit::WebFrame* frame,
991 WebKit::WebNavigationType type);
992
[email protected]6e24cf12011-03-18 19:57:02993 bool MaybeLoadAlternateErrorPage(WebKit::WebFrame* frame,
994 const WebKit::WebURLError& error,
995 bool replace);
996
[email protected]14392a52012-05-02 20:28:44997 // Make this RenderView show an empty, unscriptable page.
998 void NavigateToSwappedOutURL();
999
[email protected]007733c2011-11-17 00:34:071000 // If we initiated a navigation, this function will populate |document_state|
1001 // with the navigation information saved in OnNavigate().
[email protected]45d83a12012-04-06 22:57:571002 void PopulateDocumentStateFromPending(content::DocumentState* document_state);
1003
1004 // Returns a new NavigationState populated with the navigation information
1005 // saved in OnNavigate().
1006 content::NavigationState* CreateNavigationStateFromPending();
[email protected]007733c2011-11-17 00:34:071007
[email protected]5b52cd2f712012-03-28 02:12:481008 // Processes the command-line flags --enable-viewport and
1009 // --enable-fixed-layout[=w,h].
1010 void ProcessViewLayoutFlags(const CommandLine& command_line);
1011
[email protected]6e24cf12011-03-18 19:57:021012 // Starts nav_state_sync_timer_ if it isn't already running.
1013 void StartNavStateSyncTimerIfNecessary();
1014
1015 // Dispatches the current navigation state to the browser. Called on a
1016 // periodic timer so we don't send too many messages.
1017 void SyncNavigationState();
1018
[email protected]b781ff282011-08-20 06:19:361019 // Dispatches the current state of selection on the webpage to the browser if
1020 // it has changed.
1021 // TODO(varunjain): delete this method once we figure out how to keep
1022 // selection handles in sync with the webpage.
1023 void SyncSelectionIfRequired();
1024
[email protected]c4dabe452012-02-08 23:58:121025#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
[email protected]6e24cf12011-03-18 19:57:021026 void UpdateFontRenderingFromRendererPrefs();
1027#else
1028 void UpdateFontRenderingFromRendererPrefs() {}
1029#endif
1030
1031 // Update the target url and tell the browser that the target URL has changed.
1032 // If |url| is empty, show |fallback_url|.
1033 void UpdateTargetURL(const GURL& url, const GURL& fallback_url);
1034
[email protected]6e24cf12011-03-18 19:57:021035 // ---------------------------------------------------------------------------
1036 // ADDING NEW FUNCTIONS? Please keep private functions alphabetized and put
1037 // it in the same order in the .cc file as it was in the header.
1038 // ---------------------------------------------------------------------------
1039
1040 // Settings ------------------------------------------------------------------
1041
[email protected]6717bf272012-05-11 23:31:251042 webkit_glue::WebPreferences webkit_preferences_;
[email protected]daf82f82011-10-31 22:35:311043 content::RendererPreferences renderer_preferences_;
[email protected]6e24cf12011-03-18 19:57:021044
[email protected]6e24cf12011-03-18 19:57:021045 HostZoomLevels host_zoom_levels_;
1046
1047 // Whether content state (such as form state, scroll position and page
1048 // contents) should be sent to the browser immediately. This is normally
1049 // false, but set to true by some tests.
1050 bool send_content_state_immediately_;
1051
[email protected]6e24cf12011-03-18 19:57:021052 // Bitwise-ORed set of extra bindings that have been enabled. See
1053 // BindingsPolicy for details.
1054 int enabled_bindings_;
1055
1056 // The alternate error page URL, if one exists.
1057 GURL alternate_error_page_url_;
1058
1059 // If true, we send IPC messages when |preferred_size_| changes.
1060 bool send_preferred_size_changes_;
1061
1062 // If non-empty, and |send_preferred_size_changes_| is true, disable drawing
1063 // scroll bars on windows smaller than this size. Used for windows that the
1064 // browser resizes to the size of the content, such as browser action popups.
1065 // If a render view is set to the minimum size of its content, webkit may add
1066 // scroll bars. This makes sense for fixed sized windows, but it does not
1067 // make sense when the size of the view was chosen to fit the content.
1068 // This setting ensures that no scroll bars are drawn. The size limit exists
1069 // because if the view grows beyond a size known to the browser, scroll bars
1070 // should be drawn.
1071 gfx::Size disable_scrollbars_size_limit_;
1072
[email protected]6e24cf12011-03-18 19:57:021073 // Loading state -------------------------------------------------------------
1074
1075 // True if the top level frame is currently being loaded.
1076 bool is_loading_;
1077
1078 // The gesture that initiated the current navigation.
1079 NavigationGesture navigation_gesture_;
1080
1081 // Used for popups.
1082 bool opened_by_user_gesture_;
1083 GURL creator_url_;
1084
1085 // Whether this RenderView was created by a frame that was suppressing its
1086 // opener. If so, we may want to load pages in a separate process. See
1087 // decidePolicyForNavigation for details.
1088 bool opener_suppressed_;
1089
1090 // If we are handling a top-level client-side redirect, this tracks the URL
1091 // of the page that initiated it. Specifically, when a load is committed this
1092 // is used to determine if that load originated from a client-side redirect.
1093 // It is empty if there is no top-level client-side redirect.
[email protected]445e1042011-12-03 21:03:151094 content::Referrer completed_client_redirect_src_;
[email protected]6e24cf12011-03-18 19:57:021095
[email protected]6e24cf12011-03-18 19:57:021096 // Holds state pertaining to a navigation that we initiated. This is held by
1097 // the WebDataSource::ExtraData attribute. We use pending_navigation_state_
1098 // as a temporary holder for the state until the WebDataSource corresponding
1099 // to the new navigation is created. See DidCreateDataSource.
[email protected]007733c2011-11-17 00:34:071100 scoped_ptr<ViewMsg_Navigate_Params> pending_navigation_params_;
[email protected]6e24cf12011-03-18 19:57:021101
1102 // Timer used to delay the updating of nav state (see SyncNavigationState).
[email protected]310ebd6302011-10-10 19:06:281103 base::OneShotTimer<RenderViewImpl> nav_state_sync_timer_;
[email protected]6e24cf12011-03-18 19:57:021104
[email protected]6e24cf12011-03-18 19:57:021105 // Page IDs ------------------------------------------------------------------
[email protected]a813c8e2011-10-08 01:34:111106 // See documentation in content::RenderView.
[email protected]6e24cf12011-03-18 19:57:021107 int32 page_id_;
1108
1109 // Indicates the ID of the last page that we sent a FrameNavigate to the
1110 // browser for. This is used to determine if the most recent transition
1111 // generated a history entry (less than page_id_), or not (equal to or
1112 // greater than). Note that this will be greater than page_id_ if the user
1113 // goes back.
1114 int32 last_page_id_sent_to_browser_;
1115
[email protected]74ce1ad2011-12-16 21:51:461116 // The next available page ID to use for this RenderView. These IDs are
1117 // specific to a given RenderView and the frames within it.
1118 int32 next_page_id_;
[email protected]6e24cf12011-03-18 19:57:021119
[email protected]d466b8a2011-07-15 21:48:031120 // The offset of the current item in the history list.
1121 int history_list_offset_;
1122
1123 // The RenderView's current impression of the history length. This includes
1124 // any items that have committed in this process, but because of cross-process
1125 // navigations, the history may have some entries that were committed in other
1126 // processes. We won't know about them until the next navigation in this
1127 // process.
1128 int history_list_length_;
1129
1130 // The list of page IDs for each history item this RenderView knows about.
1131 // Some entries may be -1 if they were rendered by other processes or were
1132 // restored from a previous session. This lets us detect attempts to
1133 // navigate to stale entries that have been cropped from our history.
1134 std::vector<int32> history_page_ids_;
1135
[email protected]6e24cf12011-03-18 19:57:021136 // Page info -----------------------------------------------------------------
1137
1138 // The last gotten main frame's encoding.
1139 std::string last_encoding_name_;
1140
[email protected]6e24cf12011-03-18 19:57:021141 // UI state ------------------------------------------------------------------
1142
1143 // The state of our target_url transmissions. When we receive a request to
1144 // send a URL to the browser, we set this to TARGET_INFLIGHT until an ACK
1145 // comes back - if a new request comes in before the ACK, we store the new
1146 // URL in pending_target_url_ and set the status to TARGET_PENDING. If an
1147 // ACK comes back and we are in TARGET_PENDING, we send the stored URL and
1148 // revert to TARGET_INFLIGHT.
1149 //
1150 // We don't need a queue of URLs to send, as only the latest is useful.
1151 enum {
1152 TARGET_NONE,
1153 TARGET_INFLIGHT, // We have a request in-flight, waiting for an ACK
1154 TARGET_PENDING // INFLIGHT + we have a URL waiting to be sent
1155 } target_url_status_;
1156
1157 // The URL we show the user in the status bar. We use this to determine if we
1158 // want to send a new one (we do not need to send duplicates). It will be
1159 // equal to either |mouse_over_url_| or |focus_url_|, depending on which was
1160 // updated last.
1161 GURL target_url_;
1162
1163 // The URL the user's mouse is hovering over.
1164 GURL mouse_over_url_;
1165
1166 // The URL that has keyboard focus.
1167 GURL focus_url_;
1168
1169 // The next target URL we want to send to the browser.
1170 GURL pending_target_url_;
1171
[email protected]6e24cf12011-03-18 19:57:021172 // The text selection the last time DidChangeSelection got called.
[email protected]e99ef6f2011-10-16 01:13:001173 string16 selection_text_;
1174 size_t selection_text_offset_;
1175 ui::Range selection_range_;
[email protected]6e24cf12011-03-18 19:57:021176
1177 // View ----------------------------------------------------------------------
1178
[email protected]6e24cf12011-03-18 19:57:021179 // Cache the preferred size of the page in order to prevent sending the IPC
1180 // when layout() recomputes but doesn't actually change sizes.
1181 gfx::Size preferred_size_;
1182
[email protected]1e0c8e02011-05-25 07:49:371183 // Used to delay determining the preferred size (to avoid intermediate
1184 // states for the sizes).
[email protected]310ebd6302011-10-10 19:06:281185 base::OneShotTimer<RenderViewImpl> check_preferred_size_timer_;
[email protected]1e0c8e02011-05-25 07:49:371186
[email protected]dd6afca2011-08-13 03:44:311187 // These store the "is main frame is scrolled all the way to the left
1188 // or right" state that was last sent to the browser.
1189 bool cached_is_main_frame_pinned_to_left_;
1190 bool cached_is_main_frame_pinned_to_right_;
1191
1192 // These store the "has scrollbars" state last sent to the browser.
1193 bool cached_has_main_frame_horizontal_scrollbar_;
1194 bool cached_has_main_frame_vertical_scrollbar_;
1195
[email protected]6e24cf12011-03-18 19:57:021196#if defined(OS_MACOSX)
1197 // Track the fake plugin window handles allocated on the browser side for
1198 // the accelerated compositor and (currently) accelerated plugins so that
1199 // we can discard them when the view goes away.
1200 std::set<gfx::PluginWindowHandle> fake_plugin_window_handles_;
1201#endif
1202
[email protected]05a980d7a2012-02-07 22:16:421203 // When this view is composited, the context used for compositing may or may
1204 // not support the GL_CHROMIUM_swapbuffers_complete_callback extension. Since
1205 // querying for the existence of this extension is expensive we cache the
1206 // result. These are used to implement SupportsAsynchronousSwapBuffers().
1207 bool context_has_swapbuffers_complete_callback_;
1208 bool queried_for_swapbuffers_complete_callback_;
1209
[email protected]d0fb8a72012-03-10 18:54:521210 // Whether the WebGraphicsContext3D handed out by createGraphicsContext3D() a
1211 // WebGraphicsContext3DCommandBufferImpl. This is a HACK required by the fact
1212 // that there's no other way to tell whether webview()->graphicsContext3D()
1213 // has a ContentGLContext (and thus a CommandBufferProxy & associated
1214 // route_id) or not.
1215 bool context_is_web_graphics_context_3d_command_buffer_impl_;
1216
[email protected]6e24cf12011-03-18 19:57:021217 // Helper objects ------------------------------------------------------------
1218
[email protected]6e24cf12011-03-18 19:57:021219 RendererWebCookieJarImpl cookie_jar_;
1220
1221 // The next group of objects all implement RenderViewObserver, so are deleted
[email protected]310ebd6302011-10-10 19:06:281222 // along with the RenderView automatically. This is why we just store
1223 // weak references.
[email protected]6e24cf12011-03-18 19:57:021224
[email protected]6e24cf12011-03-18 19:57:021225 // Holds a reference to the service which provides desktop notifications.
1226 NotificationProvider* notification_provider_;
1227
1228 // The geolocation dispatcher attached to this view, lazily initialized.
1229 GeolocationDispatcher* geolocation_dispatcher_;
1230
[email protected]0d9989d2011-12-21 20:26:001231 // The intents host attached to this view. Not lazily initialized.
1232 WebIntentsHost* intents_host_;
[email protected]1ef93132011-09-16 18:33:471233
[email protected]6e24cf12011-03-18 19:57:021234 // The speech dispatcher attached to this view, lazily initialized.
[email protected]c52b2892012-03-07 11:01:021235 InputTagSpeechDispatcher* input_tag_speech_dispatcher_;
[email protected]6e24cf12011-03-18 19:57:021236
1237 // Device orientation dispatcher attached to this view; lazily initialized.
1238 DeviceOrientationDispatcher* device_orientation_dispatcher_;
1239
[email protected]273558fb2012-01-12 15:03:511240 // MediaStream dispatcher attached to this view; lazily initialized.
1241 MediaStreamDispatcher* media_stream_dispatcher_;
1242
[email protected]ab2c4732011-07-20 19:57:401243 // MediaStreamImpl attached to this view; lazily initialized.
[email protected]1bc65a42012-04-23 09:31:251244 MediaStreamImpl* media_stream_impl_;
[email protected]ab2c4732011-07-20 19:57:401245
[email protected]6e24cf12011-03-18 19:57:021246 // Dispatches all P2P socket used by the renderer.
[email protected]b3f8f9722011-08-25 20:56:071247 content::P2PSocketDispatcher* p2p_socket_dispatcher_;
[email protected]6e24cf12011-03-18 19:57:021248
[email protected]c5c1d6d2011-07-28 18:42:411249 DevToolsAgent* devtools_agent_;
1250
[email protected]063afcb2011-09-29 07:54:321251 RendererAccessibility* renderer_accessibility_;
1252
[email protected]7f3c7af2011-10-20 22:52:511253 // Java Bridge dispatcher attached to this view; lazily initialized.
[email protected]7e9c5bb02012-05-14 13:58:311254 JavaBridgeDispatcher* java_bridge_dispatcher_;
[email protected]7f3c7af2011-10-20 22:52:511255
[email protected]217690d2012-01-27 07:33:111256 // Mouse Lock dispatcher attached to this view.
1257 MouseLockDispatcher* mouse_lock_dispatcher_;
1258
[email protected]6e24cf12011-03-18 19:57:021259 // Misc ----------------------------------------------------------------------
1260
1261 // The current and pending file chooser completion objects. If the queue is
1262 // nonempty, the first item represents the currently running file chooser
1263 // callback, and the remaining elements are the other file chooser completion
1264 // still waiting to be run (in order).
1265 struct PendingFileChooser;
1266 std::deque< linked_ptr<PendingFileChooser> > file_chooser_completions_;
1267
[email protected]600ea402011-04-12 00:01:511268 // The current directory enumeration callback
1269 std::map<int, WebKit::WebFileChooserCompletion*> enumeration_completions_;
1270 int enumeration_completion_id_;
1271
[email protected]6e24cf12011-03-18 19:57:021272 // The SessionStorage namespace that we're assigned to has an ID, and that ID
1273 // is passed to us upon creation. WebKit asks for this ID upon first use and
1274 // uses it whenever asking the browser process to allocate new storage areas.
1275 int64 session_storage_namespace_id_;
1276
1277 // The total number of unrequested popups that exist and can be followed back
[email protected]310ebd6302011-10-10 19:06:281278 // to a common opener. This count is shared among all RenderViews created with
1279 // createView(). All popups are treated as unrequested until specifically
1280 // instructed otherwise by the Browser process.
[email protected]6e24cf12011-03-18 19:57:021281 scoped_refptr<SharedRenderViewCounter> shared_popup_counter_;
1282
1283 // Whether this is a top level window (instead of a popup). Top level windows
1284 // shouldn't count against their own |shared_popup_counter_|.
1285 bool decrement_shared_popup_at_destruction_;
1286
1287 // If the browser hasn't sent us an ACK for the last FindReply we sent
1288 // to it, then we need to queue up the message (keeping only the most
1289 // recent message if new ones come in).
1290 scoped_ptr<IPC::Message> queued_find_reply_message_;
1291
1292 // Stores edit commands associated to the next key event.
1293 // Shall be cleared as soon as the next key event is processed.
1294 EditCommands edit_commands_;
1295
[email protected]6e24cf12011-03-18 19:57:021296 // Allows Web UI pages (new tab page, etc.) to talk to the browser. The JS
1297 // object is only exposed when Web UI bindings are enabled.
1298 scoped_ptr<WebUIBindings> web_ui_bindings_;
1299
[email protected]6e24cf12011-03-18 19:57:021300 // The external popup for the currently showing select popup.
1301 scoped_ptr<ExternalPopupMenu> external_popup_menu_;
1302
1303 // The node that the context menu was pressed over.
1304 WebKit::WebNode context_menu_node_;
1305
1306 // Reports load progress to the browser.
1307 scoped_ptr<LoadProgressTracker> load_progress_tracker_;
1308
1309 // All the registered observers. We expect this list to be small, so vector
1310 // is fine.
[email protected]3a034ebb2011-10-03 19:19:441311 ObserverList<content::RenderViewObserver> observers_;
[email protected]6e24cf12011-03-18 19:57:021312
[email protected]4fb60142011-08-09 02:22:081313 // Used to inform didChangeSelection() when it is called in the context
1314 // of handling a ViewMsg_SelectRange IPC.
1315 bool handling_select_range_;
1316
[email protected]217690d2012-01-27 07:33:111317 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface.
1318 scoped_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_;
1319
[email protected]ef5e98e2011-12-06 09:49:181320 // Plugins -------------------------------------------------------------------
1321
1322 // All the currently active plugin delegates for this RenderView; kept so
1323 // that we can enumerate them to send updates about things like window
1324 // location or tab focus and visibily. These are non-owning references.
1325 std::set<WebPluginDelegateProxy*> plugin_delegates_;
1326
1327#if defined(OS_WIN)
1328 // The ID of the focused NPAPI plug-in.
1329 int focused_plugin_id_;
1330#endif
1331
[email protected]766a7082012-02-03 23:39:151332 // Allows JS to access DOM automation. The JS object is only exposed when the
1333 // DOM automation bindings are enabled.
1334 scoped_ptr<DomAutomationController> dom_automation_controller_;
1335
[email protected]8cca3da2012-03-20 08:26:341336 // Indicates whether this RenderView is a guest of another RenderView.
1337 bool guest_;
1338
[email protected]3e3c4522012-04-13 21:16:291339 // The accessibility mode.
1340 AccessibilityMode accessibility_mode_;
1341
[email protected]ef5e98e2011-12-06 09:49:181342 // NOTE: pepper_delegate_ should be last member because its constructor calls
1343 // AddObservers method of RenderViewImpl from c-tor.
[email protected]ca00e9162012-04-03 05:35:361344 content::PepperPluginDelegateImpl pepper_delegate_;
[email protected]ef5e98e2011-12-06 09:49:181345
[email protected]6e24cf12011-03-18 19:57:021346 // ---------------------------------------------------------------------------
1347 // ADDING NEW DATA? Please see if it fits appropriately in one of the above
1348 // sections rather than throwing it randomly at the end. If you're adding a
1349 // bunch of stuff, you should probably create a helper class and put your
[email protected]310ebd6302011-10-10 19:06:281350 // data and methods on that to avoid bloating RenderView more. You can
1351 // use the Observer interface to filter IPC messages and receive frame change
[email protected]6e24cf12011-03-18 19:57:021352 // notifications.
1353 // ---------------------------------------------------------------------------
1354
[email protected]310ebd6302011-10-10 19:06:281355 DISALLOW_COPY_AND_ASSIGN(RenderViewImpl);
[email protected]6e24cf12011-03-18 19:57:021356};
1357
[email protected]310ebd6302011-10-10 19:06:281358#endif // CONTENT_RENDERER_RENDER_VIEW_IMPL_H_