blob: 873c739600ff52fa281f38aaa5b770122941b2f1 [file] [log] [blame]
[email protected]6e24cf12011-03-18 19:57:021// Copyright (c) 2011 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
[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>
11#include <queue>
12#include <set>
13#include <string>
14#include <vector>
15
[email protected]6e24cf12011-03-18 19:57:0216#include "base/basictypes.h"
17#include "base/gtest_prod_util.h"
18#include "base/id_map.h"
[email protected]3b63f8f42011-03-28 01:54:1519#include "base/memory/linked_ptr.h"
20#include "base/memory/weak_ptr.h"
[email protected]6e24cf12011-03-18 19:57:0221#include "base/observer_list.h"
22#include "base/timer.h"
[email protected]6e24cf12011-03-18 19:57:0223#include "build/build_config.h"
[email protected]b781ff282011-08-20 06:19:3624#include "content/renderer/render_view_selection.h"
[email protected]6e24cf12011-03-18 19:57:0225#include "content/renderer/renderer_webcookiejar_impl.h"
[email protected]8d128d62011-09-13 22:11:5726#include "content/common/content_export.h"
[email protected]55722152011-03-22 01:33:5327#include "content/common/edit_command.h"
[email protected]6e24cf12011-03-18 19:57:0228#include "content/common/navigation_gesture.h"
29#include "content/common/page_zoom.h"
[email protected]60916042011-03-19 00:43:3630#include "content/common/renderer_preferences.h"
[email protected]a2ef54c2011-10-10 16:20:3131#include "content/public/renderer/render_view.h"
[email protected]6e24cf12011-03-18 19:57:0232#include "content/renderer/pepper_plugin_delegate_impl.h"
33#include "content/renderer/render_widget.h"
34#include "ipc/ipc_platform_file.h"
[email protected]6e24cf12011-03-18 19:57:0235#include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h"
36#include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystem.h"
37#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h"
[email protected]42054a252011-05-17 18:02:1338#include "third_party/WebKit/Source/WebKit/chromium/public/WebIconURL.h"
[email protected]6e24cf12011-03-18 19:57:0239#include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h"
[email protected]18d5be92011-07-25 18:00:1940#include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializerClient.h"
[email protected]94dec932011-05-26 20:04:2141#include "third_party/WebKit/Source/WebKit/chromium/public/WebPageVisibilityState.h"
[email protected]6e24cf12011-03-18 19:57:0242#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h"
43#include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h"
44#include "third_party/WebKit/Source/WebKit/chromium/public/WebNavigationType.h"
[email protected]b9b751f22011-03-25 14:04:1245#include "ui/gfx/surface/transport_dib.h"
[email protected]6e24cf12011-03-18 19:57:0246#include "webkit/glue/webpreferences.h"
47#include "webkit/plugins/npapi/webplugin_page_delegate.h"
48
49#if defined(OS_WIN)
[email protected]310ebd6302011-10-10 19:06:2850// RenderViewImpl is a diamond-shaped hierarchy, with WebWidgetClient at the
51// root. VS warns when we inherit the WebWidgetClient method implementations
52// from RenderWidget. It's safe to ignore that warning.
[email protected]6e24cf12011-03-18 19:57:0253#pragma warning(disable: 4250)
54#endif
55
56class AudioMessageFilter;
[email protected]6e24cf12011-03-18 19:57:0257class DeviceOrientationDispatcher;
[email protected]c5c1d6d2011-07-28 18:42:4158class DevToolsAgent;
[email protected]55722152011-03-22 01:33:5359class ExternalPopupMenu;
[email protected]6e24cf12011-03-18 19:57:0260class GeolocationDispatcher;
[email protected]6e24cf12011-03-18 19:57:0261class GURL;
[email protected]1ef93132011-09-16 18:33:4762class IntentsDispatcher;
[email protected]6e24cf12011-03-18 19:57:0263class LoadProgressTracker;
[email protected]ab2c4732011-07-20 19:57:4064class MediaStreamImpl;
[email protected]6e24cf12011-03-18 19:57:0265class NotificationProvider;
[email protected]6e24cf12011-03-18 19:57:0266class PepperDeviceTest;
67class PrintWebViewHelper;
[email protected]ea192e82011-04-11 19:16:0268class RenderWidgetFullscreenPepper;
[email protected]063afcb2011-09-29 07:54:3269class RendererAccessibility;
[email protected]6e24cf12011-03-18 19:57:0270class SkBitmap;
71class SpeechInputDispatcher;
[email protected]6e24cf12011-03-18 19:57:0272class WebPluginDelegateProxy;
[email protected]55722152011-03-22 01:33:5373class WebUIBindings;
[email protected]6e24cf12011-03-18 19:57:0274struct ContextMenuMediaParams;
75struct PP_Flash_NetAddress;
[email protected]6e24cf12011-03-18 19:57:0276struct ViewHostMsg_RunFileChooser_Params;
[email protected]992db4c2011-05-12 15:37:1577struct ViewMsg_SwapOut_Params;
[email protected]6e24cf12011-03-18 19:57:0278struct ViewMsg_Navigate_Params;
79struct ViewMsg_StopFinding_Params;
[email protected]6e24cf12011-03-18 19:57:0280struct WebDropData;
81
82namespace base {
83class WaitableEvent;
[email protected]b3f8f9722011-08-25 20:56:0784} // namespace base
85
86namespace content {
[email protected]82ddba1c2011-10-04 00:15:3287class NavigationState;
[email protected]b3f8f9722011-08-25 20:56:0788class P2PSocketDispatcher;
[email protected]3a034ebb2011-10-03 19:19:4489class RenderViewObserver;
[email protected]64ffa0442011-10-03 22:08:3690class RenderViewVisitor;
[email protected]b3f8f9722011-08-25 20:56:0791} // namespace content
[email protected]6e24cf12011-03-18 19:57:0292
[email protected]6e24cf12011-03-18 19:57:0293namespace gfx {
94class Point;
95class Rect;
[email protected]b3f8f9722011-08-25 20:56:0796} // namespace gfx
[email protected]6e24cf12011-03-18 19:57:0297
98namespace webkit {
99
[email protected]6e24cf12011-03-18 19:57:02100namespace ppapi {
[email protected]6e24cf12011-03-18 19:57:02101class PluginInstance;
102class PluginModule;
103} // namespace ppapi
104
105} // namespace webkit
106
107namespace webkit_glue {
108struct CustomContextMenuContext;
109class ImageResourceFetcher;
110struct FileUploadData;
111struct FormData;
112struct PasswordFormFillData;
113class ResourceFetcher;
114}
115
116namespace WebKit {
[email protected]6e24cf12011-03-18 19:57:02117class WebApplicationCacheHost;
118class WebApplicationCacheHostClient;
119class WebDataSource;
120class WebDocument;
121class WebDragData;
[email protected]6e24cf12011-03-18 19:57:02122class WebGeolocationClient;
123class WebGeolocationServiceInterface;
[email protected]42054a252011-05-17 18:02:13124class WebIconURL;
[email protected]6e24cf12011-03-18 19:57:02125class WebImage;
126class WebInputElement;
127class WebKeyboardEvent;
128class WebMediaPlayer;
129class WebMediaPlayerClient;
130class WebMouseEvent;
[email protected]6e24cf12011-03-18 19:57:02131class WebSpeechInputController;
132class WebSpeechInputListener;
133class WebStorageNamespace;
[email protected]2d0f2e92011-10-03 09:02:24134class WebTouchEvent;
[email protected]b00ba702011-08-17 01:41:03135class WebURLLoader;
[email protected]6e24cf12011-03-18 19:57:02136class WebURLRequest;
[email protected]6e24cf12011-03-18 19:57:02137struct WebFileChooserParams;
138struct WebFindOptions;
139struct WebMediaPlayerAction;
[email protected]6e24cf12011-03-18 19:57:02140struct WebPoint;
141struct WebWindowFeatures;
142}
143
144// We need to prevent a page from trying to create infinite popups. It is not
145// as simple as keeping a count of the number of immediate children
146// popups. Having an html file that window.open()s itself would create
147// an unlimited chain of RenderViews who only have one RenderView child.
148//
149// Therefore, each new top level RenderView creates a new counter and shares it
[email protected]310ebd6302011-10-10 19:06:28150// with all its children and grandchildren popup RenderViewImpls created with
[email protected]6e24cf12011-03-18 19:57:02151// createView() to have a sort of global limit for the page so no more than
152// kMaximumNumberOfPopups popups are created.
153//
154// This is a RefCounted holder of an int because I can't say
155// scoped_refptr<int>.
156typedef base::RefCountedData<int> SharedRenderViewCounter;
157
158//
159// RenderView is an object that manages a WebView object, and provides a
160// communication interface with an embedding application process
161//
[email protected]310ebd6302011-10-10 19:06:28162class RenderViewImpl : public RenderWidget,
163 public WebKit::WebViewClient,
164 public WebKit::WebFrameClient,
165 public WebKit::WebPageSerializerClient,
166 public content::RenderView,
167 public webkit::npapi::WebPluginPageDelegate,
168 public base::SupportsWeakPtr<RenderViewImpl> {
[email protected]6e24cf12011-03-18 19:57:02169 public:
170 // Creates a new RenderView. The parent_hwnd specifies a HWND to use as the
[email protected]5f9de5882011-09-30 23:36:28171 // parent of the WebView HWND that will be created. If this is a blocked
[email protected]6e24cf12011-03-18 19:57:02172 // popup or as a new tab, opener_id is the routing ID of the RenderView
173 // responsible for creating this RenderView (corresponding to parent_hwnd).
174 // |counter| is either a currently initialized counter, or NULL (in which case
175 // we treat this RenderView as a top level window).
[email protected]310ebd6302011-10-10 19:06:28176 CONTENT_EXPORT static RenderViewImpl* Create(
[email protected]6e24cf12011-03-18 19:57:02177 gfx::NativeViewId parent_hwnd,
178 int32 opener_id,
179 const RendererPreferences& renderer_prefs,
180 const WebPreferences& webkit_prefs,
181 SharedRenderViewCounter* counter,
182 int32 routing_id,
183 int64 session_storage_namespace_id,
184 const string16& frame_name);
185
[email protected]310ebd6302011-10-10 19:06:28186 // Returns the RenderViewImpl containing the given WebView.
187 CONTENT_EXPORT static RenderViewImpl* FromWebView(WebKit::WebView* webview);
[email protected]6e24cf12011-03-18 19:57:02188
189 // Sets the "next page id" counter.
190 static void SetNextPageID(int32 next_page_id);
191
192 // May return NULL when the view is closing.
[email protected]8d128d62011-09-13 22:11:57193 CONTENT_EXPORT WebKit::WebView* webview() const;
[email protected]6e24cf12011-03-18 19:57:02194
[email protected]65225772011-05-12 21:10:24195 // Called by a GraphicsContext associated with this view when swapbuffers
[email protected]37a6f302011-07-11 23:43:08196 // is posted, completes or is aborted.
197 void OnViewContextSwapBuffersPosted();
[email protected]65225772011-05-12 21:10:24198 void OnViewContextSwapBuffersComplete();
199 void OnViewContextSwapBuffersAborted();
200
[email protected]d466b8a2011-07-15 21:48:03201 int history_list_offset() const { return history_list_offset_; }
[email protected]6e24cf12011-03-18 19:57:02202
[email protected]6e24cf12011-03-18 19:57:02203 const WebPreferences& webkit_preferences() const {
204 return webkit_preferences_;
205 }
206
207 void set_send_content_state_immediately(bool value) {
208 send_content_state_immediately_ = value;
209 }
210
[email protected]6e24cf12011-03-18 19:57:02211 // Current P2PSocketDispatcher. Set to NULL if P2P API is disabled.
[email protected]b3f8f9722011-08-25 20:56:07212 content::P2PSocketDispatcher* p2p_socket_dispatcher() {
[email protected]6e24cf12011-03-18 19:57:02213 return p2p_socket_dispatcher_;
214 }
215
216 // Functions to add and remove observers for this object.
[email protected]3a034ebb2011-10-03 19:19:44217 void AddObserver(content::RenderViewObserver* observer);
218 void RemoveObserver(content::RenderViewObserver* observer);
[email protected]6e24cf12011-03-18 19:57:02219
[email protected]6e24cf12011-03-18 19:57:02220 // Adds the given file chooser request to the file_chooser_completion_ queue
221 // (see that var for more) and requests the chooser be displayed if there are
222 // no other waiting items in the queue.
223 //
224 // Returns true if the chooser was successfully scheduled. False means we
225 // didn't schedule anything.
226 bool ScheduleFileChooser(const ViewHostMsg_RunFileChooser_Params& params,
227 WebKit::WebFileChooserCompletion* completion);
228
[email protected]6e24cf12011-03-18 19:57:02229 // Sets whether the renderer should report load progress to the browser.
230 void SetReportLoadProgressEnabled(bool enabled);
231
[email protected]a2ef54c2011-10-10 16:20:31232 void LoadNavigationErrorPage(
[email protected]8d128d62011-09-13 22:11:57233 WebKit::WebFrame* frame,
234 const WebKit::WebURLRequest& failed_request,
235 const WebKit::WebURLError& error,
236 const std::string& html,
237 bool replace);
[email protected]9966325b2011-04-18 05:00:10238
[email protected]6e24cf12011-03-18 19:57:02239 // Plugin-related functions --------------------------------------------------
240 // (See also WebPluginPageDelegate implementation.)
241
242 // Notification that the given plugin has crashed.
243 void PluginCrashed(const FilePath& plugin_path);
244
[email protected]6e24cf12011-03-18 19:57:02245 // Creates a fullscreen container for a pepper plugin instance.
[email protected]ea192e82011-04-11 19:16:02246 RenderWidgetFullscreenPepper* CreatePepperFullscreenContainer(
[email protected]6e24cf12011-03-18 19:57:02247 webkit::ppapi::PluginInstance* plugin);
248
[email protected]56ea1a62011-05-30 07:05:57249 // Informs the render view that a PPAPI plugin has gained or lost focus.
250 void PpapiPluginFocusChanged();
251
[email protected]08bb1e722011-07-30 19:13:04252 // Request updated policy regarding firewall NAT traversal being enabled.
253 void RequestRemoteAccessClientFirewallTraversal();
254
[email protected]e6ae0f6c2011-10-04 10:39:23255#if defined(OS_MACOSX) || defined(OS_WIN)
[email protected]6e24cf12011-03-18 19:57:02256 // Informs the render view that the given plugin has gained or lost focus.
257 void PluginFocusChanged(bool focused, int plugin_id);
[email protected]e6ae0f6c2011-10-04 10:39:23258#endif
[email protected]6e24cf12011-03-18 19:57:02259
[email protected]e6ae0f6c2011-10-04 10:39:23260#if defined(OS_MACOSX)
[email protected]6e24cf12011-03-18 19:57:02261 // Starts plugin IME.
262 void StartPluginIme();
263
264 // Helper routines for accelerated plugin support. Used by the
265 // WebPluginDelegateProxy, which has a pointer to the RenderView.
266 gfx::PluginWindowHandle AllocateFakePluginWindowHandle(bool opaque,
267 bool root);
268 void DestroyFakePluginWindowHandle(gfx::PluginWindowHandle window);
269 void AcceleratedSurfaceSetIOSurface(gfx::PluginWindowHandle window,
270 int32 width,
271 int32 height,
272 uint64 io_surface_identifier);
273 TransportDIB::Handle AcceleratedSurfaceAllocTransportDIB(size_t size);
274 void AcceleratedSurfaceFreeTransportDIB(TransportDIB::Id dib_id);
275 void AcceleratedSurfaceSetTransportDIB(gfx::PluginWindowHandle window,
276 int32 width,
277 int32 height,
278 TransportDIB::Handle transport_dib);
279 void AcceleratedSurfaceBuffersSwapped(gfx::PluginWindowHandle window,
280 uint64 surface_id);
281#endif
282
283 void RegisterPluginDelegate(WebPluginDelegateProxy* delegate);
284 void UnregisterPluginDelegate(WebPluginDelegateProxy* delegate);
285
[email protected]4a7d6392011-09-19 20:55:08286 // Helper function to retrieve information about a plugin for a URL and mime
287 // type. Returns false if no plugin was found.
288 // |actual_mime_type| is the actual mime type supported by the
289 // plugin found that match the URL given (one for each item in
290 // |info|).
[email protected]84c13c032011-09-23 00:12:22291 CONTENT_EXPORT bool GetPluginInfo(const GURL& url,
292 const GURL& page_url,
293 const std::string& mime_type,
294 webkit::WebPluginInfo* plugin_info,
295 std::string* actual_mime_type);
[email protected]4a7d6392011-09-19 20:55:08296
[email protected]6e24cf12011-03-18 19:57:02297 // IPC::Channel::Listener implementation -------------------------------------
298
299 virtual bool OnMessageReceived(const IPC::Message& msg);
300
301 // WebKit::WebWidgetClient implementation ------------------------------------
302
303 // Most methods are handled by RenderWidget.
304 virtual void didFocus();
305 virtual void didBlur();
306 virtual void show(WebKit::WebNavigationPolicy policy);
307 virtual void runModal();
308
309 // WebKit::WebViewClient implementation --------------------------------------
310
311 virtual WebKit::WebView* createView(
312 WebKit::WebFrame* creator,
313 const WebKit::WebURLRequest& request,
314 const WebKit::WebWindowFeatures& features,
315 const WebKit::WebString& frame_name);
316 virtual WebKit::WebWidget* createPopupMenu(WebKit::WebPopupType popup_type);
317 virtual WebKit::WebWidget* createPopupMenu(
318 const WebKit::WebPopupMenuInfo& info);
319 virtual WebKit::WebExternalPopupMenu* createExternalPopupMenu(
320 const WebKit::WebPopupMenuInfo& popup_menu_info,
321 WebKit::WebExternalPopupMenuClient* popup_menu_client);
322 virtual WebKit::WebStorageNamespace* createSessionStorageNamespace(
323 unsigned quota);
324 virtual void didAddMessageToConsole(
325 const WebKit::WebConsoleMessage& message,
326 const WebKit::WebString& source_name,
327 unsigned source_line);
328 virtual void printPage(WebKit::WebFrame* frame);
329 virtual WebKit::WebNotificationPresenter* notificationPresenter();
[email protected]8a58c1c2011-04-19 18:40:12330 virtual bool enumerateChosenDirectory(
331 const WebKit::WebString& path,
332 WebKit::WebFileChooserCompletion* chooser_completion);
[email protected]6e24cf12011-03-18 19:57:02333 virtual void didStartLoading();
334 virtual void didStopLoading();
335 virtual void didChangeLoadProgress(WebKit::WebFrame* frame,
336 double load_progress);
337 virtual bool isSmartInsertDeleteEnabled();
338 virtual bool isSelectTrailingWhitespaceEnabled();
339 virtual void didChangeSelection(bool is_selection_empty);
340 virtual void didExecuteCommand(const WebKit::WebString& command_name);
341 virtual bool handleCurrentKeyboardEvent();
[email protected]6e24cf12011-03-18 19:57:02342 virtual bool runFileChooser(
343 const WebKit::WebFileChooserParams& params,
344 WebKit::WebFileChooserCompletion* chooser_completion);
345 virtual void runModalAlertDialog(WebKit::WebFrame* frame,
346 const WebKit::WebString& message);
347 virtual bool runModalConfirmDialog(WebKit::WebFrame* frame,
348 const WebKit::WebString& message);
349 virtual bool runModalPromptDialog(WebKit::WebFrame* frame,
350 const WebKit::WebString& message,
351 const WebKit::WebString& default_value,
352 WebKit::WebString* actual_value);
353 virtual bool runModalBeforeUnloadDialog(WebKit::WebFrame* frame,
354 const WebKit::WebString& message);
355 virtual void showContextMenu(WebKit::WebFrame* frame,
356 const WebKit::WebContextMenuData& data);
357 virtual bool supportsFullscreen();
358 virtual void enterFullscreenForNode(const WebKit::WebNode&);
359 virtual void exitFullscreenForNode(const WebKit::WebNode&);
[email protected]8a5e0ca2011-08-25 06:30:47360 virtual void enterFullscreen() OVERRIDE;
361 virtual void exitFullscreen() OVERRIDE;
[email protected]6e24cf12011-03-18 19:57:02362 virtual void setStatusText(const WebKit::WebString& text);
363 virtual void setMouseOverURL(const WebKit::WebURL& url);
364 virtual void setKeyboardFocusURL(const WebKit::WebURL& url);
[email protected]6e24cf12011-03-18 19:57:02365 virtual void startDragging(const WebKit::WebDragData& data,
366 WebKit::WebDragOperationsMask mask,
367 const WebKit::WebImage& image,
368 const WebKit::WebPoint& imageOffset);
369 virtual bool acceptsLoadDrops();
370 virtual void focusNext();
371 virtual void focusPrevious();
372 virtual void focusedNodeChanged(const WebKit::WebNode& node);
373 virtual void navigateBackForwardSoon(int offset);
374 virtual int historyBackListCount();
375 virtual int historyForwardListCount();
376 virtual void postAccessibilityNotification(
377 const WebKit::WebAccessibilityObject& obj,
378 WebKit::WebAccessibilityNotification notification);
379 virtual void didUpdateInspectorSetting(const WebKit::WebString& key,
380 const WebKit::WebString& value);
381 virtual WebKit::WebGeolocationClient* geolocationClient();
382 virtual WebKit::WebSpeechInputController* speechInputController(
383 WebKit::WebSpeechInputListener* listener);
384 virtual WebKit::WebDeviceOrientationClient* deviceOrientationClient();
385 virtual void zoomLimitsChanged(double minimum_level, double maximum_level);
386 virtual void zoomLevelChanged();
387 virtual void registerProtocolHandler(const WebKit::WebString& scheme,
388 const WebKit::WebString& base_url,
389 const WebKit::WebString& url,
390 const WebKit::WebString& title);
[email protected]62af76e2011-08-01 02:34:01391 virtual void registerIntentHandler(const WebKit::WebString& action,
392 const WebKit::WebString& type,
393 const WebKit::WebString& href,
394 const WebKit::WebString& title);
[email protected]94dec932011-05-26 20:04:21395 virtual WebKit::WebPageVisibilityState visibilityState() const;
[email protected]e235c7d02011-08-18 22:38:43396 virtual void startActivity(const WebKit::WebString& action,
397 const WebKit::WebString& type,
398 const WebKit::WebString& data,
399 int intent_id);
[email protected]6e24cf12011-03-18 19:57:02400
401 // WebKit::WebFrameClient implementation -------------------------------------
402
403 virtual WebKit::WebPlugin* createPlugin(
404 WebKit::WebFrame* frame,
405 const WebKit::WebPluginParams& params);
406 virtual WebKit::WebWorker* createWorker(WebKit::WebFrame* frame,
407 WebKit::WebWorkerClient* client);
408 virtual WebKit::WebSharedWorker* createSharedWorker(
409 WebKit::WebFrame* frame, const WebKit::WebURL& url,
410 const WebKit::WebString& name, unsigned long long documentId);
411 virtual WebKit::WebMediaPlayer* createMediaPlayer(
412 WebKit::WebFrame* frame,
413 WebKit::WebMediaPlayerClient* client);
414 virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(
415 WebKit::WebFrame* frame,
416 WebKit::WebApplicationCacheHostClient* client);
417 virtual WebKit::WebCookieJar* cookieJar(WebKit::WebFrame* frame);
418 virtual void frameDetached(WebKit::WebFrame* frame);
419 virtual void willClose(WebKit::WebFrame* frame);
[email protected]6e24cf12011-03-18 19:57:02420 virtual void loadURLExternally(WebKit::WebFrame* frame,
421 const WebKit::WebURLRequest& request,
422 WebKit::WebNavigationPolicy policy);
[email protected]0622875ab2011-07-27 12:10:34423 virtual void loadURLExternally(WebKit::WebFrame* frame,
424 const WebKit::WebURLRequest& request,
425 WebKit::WebNavigationPolicy policy,
426 const WebKit::WebString& suggested_name);
[email protected]6e24cf12011-03-18 19:57:02427 virtual WebKit::WebNavigationPolicy decidePolicyForNavigation(
428 WebKit::WebFrame* frame,
429 const WebKit::WebURLRequest& request,
430 WebKit::WebNavigationType type,
431 const WebKit::WebNode&,
432 WebKit::WebNavigationPolicy default_policy,
433 bool is_redirect);
434 virtual bool canHandleRequest(WebKit::WebFrame* frame,
435 const WebKit::WebURLRequest& request);
436 virtual WebKit::WebURLError cannotHandleRequestError(
437 WebKit::WebFrame* frame,
438 const WebKit::WebURLRequest& request);
439 virtual WebKit::WebURLError cancelledError(
440 WebKit::WebFrame* frame,
441 const WebKit::WebURLRequest& request);
442 virtual void unableToImplementPolicyWithError(
443 WebKit::WebFrame* frame,
444 const WebKit::WebURLError& error);
445 virtual void willSendSubmitEvent(WebKit::WebFrame* frame,
446 const WebKit::WebFormElement& form);
447 virtual void willSubmitForm(WebKit::WebFrame* frame,
448 const WebKit::WebFormElement& form);
449 virtual void willPerformClientRedirect(WebKit::WebFrame* frame,
450 const WebKit::WebURL& from,
451 const WebKit::WebURL& to,
452 double interval,
453 double fire_time);
454 virtual void didCancelClientRedirect(WebKit::WebFrame* frame);
455 virtual void didCompleteClientRedirect(WebKit::WebFrame* frame,
456 const WebKit::WebURL& from);
457 virtual void didCreateDataSource(WebKit::WebFrame* frame,
458 WebKit::WebDataSource* datasource);
459 virtual void didStartProvisionalLoad(WebKit::WebFrame* frame);
460 virtual void didReceiveServerRedirectForProvisionalLoad(
461 WebKit::WebFrame* frame);
462 virtual void didFailProvisionalLoad(WebKit::WebFrame* frame,
463 const WebKit::WebURLError& error);
464 virtual void didReceiveDocumentData(WebKit::WebFrame* frame,
465 const char* data, size_t length,
466 bool& prevent_default);
467 virtual void didCommitProvisionalLoad(WebKit::WebFrame* frame,
468 bool is_new_navigation);
469 virtual void didClearWindowObject(WebKit::WebFrame* frame);
470 virtual void didCreateDocumentElement(WebKit::WebFrame* frame);
471 virtual void didReceiveTitle(WebKit::WebFrame* frame,
[email protected]a3bc4d12011-04-20 17:22:21472 const WebKit::WebString& title,
473 WebKit::WebTextDirection direction);
[email protected]42054a252011-05-17 18:02:13474 virtual void didChangeIcon(WebKit::WebFrame*,
475 WebKit::WebIconURL::Type) OVERRIDE;
[email protected]6e24cf12011-03-18 19:57:02476 virtual void didFinishDocumentLoad(WebKit::WebFrame* frame);
477 virtual void didHandleOnloadEvents(WebKit::WebFrame* frame);
478 virtual void didFailLoad(WebKit::WebFrame* frame,
479 const WebKit::WebURLError& error);
480 virtual void didFinishLoad(WebKit::WebFrame* frame);
481 virtual void didNavigateWithinPage(WebKit::WebFrame* frame,
482 bool is_new_navigation);
483 virtual void didUpdateCurrentHistoryItem(WebKit::WebFrame* frame);
484 virtual void assignIdentifierToRequest(WebKit::WebFrame* frame,
485 unsigned identifier,
486 const WebKit::WebURLRequest& request);
487 virtual void willSendRequest(WebKit::WebFrame* frame,
488 unsigned identifier,
489 WebKit::WebURLRequest& request,
490 const WebKit::WebURLResponse& redirect_response);
491 virtual void didReceiveResponse(WebKit::WebFrame* frame,
492 unsigned identifier,
493 const WebKit::WebURLResponse& response);
494 virtual void didFinishResourceLoad(WebKit::WebFrame* frame,
495 unsigned identifier);
496 virtual void didFailResourceLoad(WebKit::WebFrame* frame,
497 unsigned identifier,
498 const WebKit::WebURLError& error);
499 virtual void didLoadResourceFromMemoryCache(
500 WebKit::WebFrame* frame,
501 const WebKit::WebURLRequest& request,
502 const WebKit::WebURLResponse&);
503 virtual void didDisplayInsecureContent(WebKit::WebFrame* frame);
504 virtual void didRunInsecureContent(
505 WebKit::WebFrame* frame,
506 const WebKit::WebSecurityOrigin& origin,
507 const WebKit::WebURL& target);
[email protected]b00ba702011-08-17 01:41:03508 virtual void didAdoptURLLoader(WebKit::WebURLLoader* loader);
[email protected]6e24cf12011-03-18 19:57:02509 virtual void didExhaustMemoryAvailableForScript(WebKit::WebFrame* frame);
[email protected]5bc10932011-09-21 21:03:30510 virtual void didCreateScriptContext(WebKit::WebFrame* frame,
511 v8::Handle<v8::Context>,
512 int world_id);
513 virtual void willReleaseScriptContext(WebKit::WebFrame* frame,
514 v8::Handle<v8::Context>,
515 int world_id);
[email protected]d812fd12011-05-27 23:05:07516 virtual void didUpdateLayout(WebKit::WebFrame* frame);
[email protected]6e24cf12011-03-18 19:57:02517 virtual void didChangeScrollOffset(WebKit::WebFrame* frame);
[email protected]dd6afca2011-08-13 03:44:31518 virtual void numberOfWheelEventHandlersChanged(unsigned num_handlers);
519 virtual void didChangeContentsSize(WebKit::WebFrame* frame,
520 const WebKit::WebSize& size);
[email protected]6e24cf12011-03-18 19:57:02521 virtual void reportFindInPageMatchCount(int request_id,
522 int count,
523 bool final_update);
524 virtual void reportFindInPageSelection(int request_id,
525 int active_match_ordinal,
526 const WebKit::WebRect& sel);
527
528 virtual void openFileSystem(WebKit::WebFrame* frame,
529 WebKit::WebFileSystem::Type type,
530 long long size,
531 bool create,
532 WebKit::WebFileSystemCallbacks* callbacks);
533
[email protected]10e5cf12011-04-13 04:10:40534 virtual void queryStorageUsageAndQuota(
535 WebKit::WebFrame* frame,
536 WebKit::WebStorageQuotaType type,
537 WebKit::WebStorageQuotaCallbacks* callbacks);
538
539 virtual void requestStorageQuota(
540 WebKit::WebFrame* frame,
541 WebKit::WebStorageQuotaType type,
542 unsigned long long requested_size,
543 WebKit::WebStorageQuotaCallbacks* callbacks);
544
[email protected]18d5be92011-07-25 18:00:19545 // WebKit::WebPageSerializerClient implementation ----------------------------
546
547 virtual void didSerializeDataForFrame(
548 const WebKit::WebURL& frame_url,
549 const WebKit::WebCString& data,
550 PageSerializationStatus status) OVERRIDE;
551
[email protected]a2ef54c2011-10-10 16:20:31552 // content::RenderView implementation ----------------------------------------
553
554 virtual bool Send(IPC::Message* message) OVERRIDE;
555 virtual int GetRoutingId() const OVERRIDE;
556 virtual int GetPageId() OVERRIDE;
557 virtual gfx::Size GetSize() OVERRIDE;
558 virtual gfx::NativeViewId GetHostWindow() OVERRIDE;
559 virtual WebPreferences& GetWebkitPreferences() OVERRIDE;
560 virtual WebKit::WebView* GetWebView() OVERRIDE;
561 virtual WebKit::WebNode GetFocusedNode() const OVERRIDE;
562 virtual WebKit::WebNode GetContextMenuNode() const OVERRIDE;
563 virtual bool IsEditableNode(const WebKit::WebNode& node) OVERRIDE;
564 virtual WebKit::WebPlugin* CreatePlugin(
565 WebKit::WebFrame* frame,
566 const webkit::WebPluginInfo& info,
567 const WebKit::WebPluginParams& params) OVERRIDE;
568 virtual void EvaluateScript(const string16& frame_xpath,
569 const string16& jscript,
570 int id,
571 bool notify_result) OVERRIDE;
572 virtual bool ShouldDisplayScrollbars(int width, int height) const OVERRIDE;
573 virtual int GetEnabledBindings() OVERRIDE;
574 virtual void SetEnabledBindings(int enabled_bindings) OVERRIDE;
575 virtual bool GetContentStateImmediately() OVERRIDE;
576 virtual float GetFilteredTimePerFrame() OVERRIDE;
577 virtual void ShowContextMenu(WebKit::WebFrame* frame,
578 const WebKit::WebContextMenuData& data) OVERRIDE;
579 virtual WebKit::WebPageVisibilityState GetVisibilityState() const OVERRIDE;
580 virtual void RunModalAlertDialog(WebKit::WebFrame* frame,
581 const WebKit::WebString& message) OVERRIDE;
582 virtual void LoadURLExternally(
583 WebKit::WebFrame* frame,
584 const WebKit::WebURLRequest& request,
585 WebKit::WebNavigationPolicy policy) OVERRIDE;
586
[email protected]6e24cf12011-03-18 19:57:02587 // webkit_glue::WebPluginPageDelegate implementation -------------------------
588
589 virtual webkit::npapi::WebPluginDelegate* CreatePluginDelegate(
590 const FilePath& file_path,
591 const std::string& mime_type);
592 virtual void CreatedPluginWindow(gfx::PluginWindowHandle handle);
593 virtual void WillDestroyPluginWindow(gfx::PluginWindowHandle handle);
594 virtual void DidMovePlugin(const webkit::npapi::WebPluginGeometry& move);
595 virtual void DidStartLoadingForPlugin();
596 virtual void DidStopLoadingForPlugin();
597 virtual WebKit::WebCookieJar* GetCookieJar();
598
599 // Please do not add your stuff randomly to the end here. If there is an
600 // appropriate section, add it there. If not, there are some random functions
601 // nearer to the top you can add it to.
[email protected]6e24cf12011-03-18 19:57:02602 virtual void DidFlushPaint();
603
[email protected]38b592902011-04-16 02:08:42604 // Cannot use std::set unfortunately since linked_ptr<> does not support
605 // operator<.
606 typedef std::vector<linked_ptr<webkit_glue::ImageResourceFetcher> >
607 ImageResourceFetcherList;
608
[email protected]6e24cf12011-03-18 19:57:02609 protected:
610 // RenderWidget overrides:
611 virtual void Close();
612 virtual void OnResize(const gfx::Size& new_size,
613 const gfx::Rect& resizer_rect);
614 virtual void DidInitiatePaint();
615 virtual webkit::ppapi::PluginInstance* GetBitmapForOptimizedPluginPaint(
616 const gfx::Rect& paint_bounds,
617 TransportDIB** dib,
618 gfx::Rect* location,
619 gfx::Rect* clip);
620 virtual gfx::Point GetScrollOffset();
621 virtual void DidHandleKeyEvent();
[email protected]67bfb83f2011-09-22 03:36:37622 virtual bool WillHandleMouseEvent(
623 const WebKit::WebMouseEvent& event) OVERRIDE;
[email protected]6e24cf12011-03-18 19:57:02624 virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event);
[email protected]2d0f2e92011-10-03 09:02:24625 virtual void DidHandleTouchEvent(const WebKit::WebTouchEvent& event);
[email protected]6e24cf12011-03-18 19:57:02626 virtual void OnSetFocus(bool enable);
627 virtual void OnWasHidden();
628 virtual void OnWasRestored(bool needs_repainting);
[email protected]65225772011-05-12 21:10:24629 virtual bool SupportsAsynchronousSwapBuffers() OVERRIDE;
[email protected]56ea1a62011-05-30 07:05:57630 virtual void OnImeSetComposition(
631 const string16& text,
632 const std::vector<WebKit::WebCompositionUnderline>& underlines,
633 int selection_start,
634 int selection_end) OVERRIDE;
[email protected]4de6d1692011-10-12 08:45:44635 virtual void OnImeConfirmComposition(
636 const string16& text, const ui::Range& replacement_range) OVERRIDE;
[email protected]ad26ef42011-06-17 07:59:45637 virtual ui::TextInputType GetTextInputType() OVERRIDE;
638 virtual bool CanComposeInline() OVERRIDE;
[email protected]c3d45532011-10-07 19:20:40639 virtual bool WebWidgetHandlesCompositorScheduling() const OVERRIDE;
[email protected]6e24cf12011-03-18 19:57:02640
641 private:
[email protected]6e24cf12011-03-18 19:57:02642 // For unit tests.
643 friend class ExternalPopupMenuTest;
644 friend class PepperDeviceTest;
645 friend class RenderViewTest;
646
647 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuRemoveTest, RemoveOnChange);
648 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, NormalCase);
649 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, ShowPopupThenNavigate);
[email protected]068970d2011-10-11 00:05:16650 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
651 DontIgnoreBackAfterNavEntryLimit);
652 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, ImeComposition);
653 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, InsertCharacters);
654 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, JSBlockSentAfterPageLoad);
655 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, LastCommittedUpdateState);
656 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnHandleKeyboardEvent);
657 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnImeStateChanged);
658 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnNavStateChanged);
659 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnSetTextDirection);
660 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnUpdateWebPreferences);
661 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, StaleNavigationsIgnored);
662 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, UpdateTargetURLWithInvalidURL);
[email protected]6e24cf12011-03-18 19:57:02663#if defined(OS_MACOSX)
664 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, MacTestCmdUp);
665#endif
[email protected]068970d2011-10-11 00:05:16666 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, SetHistoryLengthAndPrune);
[email protected]6e24cf12011-03-18 19:57:02667
[email protected]6e24cf12011-03-18 19:57:02668 typedef std::map<GURL, double> HostZoomLevels;
669
[email protected]6e24cf12011-03-18 19:57:02670 enum ErrorPageType {
671 DNS_ERROR,
672 HTTP_404,
673 CONNECTION_ERROR,
674 };
675
[email protected]310ebd6302011-10-10 19:06:28676 RenderViewImpl(gfx::NativeViewId parent_hwnd,
677 int32 opener_id,
678 const RendererPreferences& renderer_prefs,
679 const WebPreferences& webkit_prefs,
680 SharedRenderViewCounter* counter,
681 int32 routing_id,
682 int64 session_storage_namespace_id,
683 const string16& frame_name);
[email protected]6e24cf12011-03-18 19:57:02684
685 // Do not delete directly. This class is reference counted.
[email protected]310ebd6302011-10-10 19:06:28686 virtual ~RenderViewImpl();
[email protected]6e24cf12011-03-18 19:57:02687
688 void UpdateURL(WebKit::WebFrame* frame);
[email protected]a49e10b2011-08-01 23:57:46689 void UpdateTitle(WebKit::WebFrame* frame, const string16& title,
690 WebKit::WebTextDirection title_direction);
[email protected]6e24cf12011-03-18 19:57:02691 void UpdateSessionHistory(WebKit::WebFrame* frame);
692
693 // Update current main frame's encoding and send it to browser window.
694 // Since we want to let users see the right encoding info from menu
695 // before finishing loading, we call the UpdateEncoding in
696 // a) function:DidCommitLoadForFrame. When this function is called,
697 // that means we have got first data. In here we try to get encoding
698 // of page if it has been specified in http header.
699 // b) function:DidReceiveTitle. When this function is called,
700 // that means we have got specified title. Because in most of webpages,
701 // title tags will follow meta tags. In here we try to get encoding of
702 // page if it has been specified in meta tag.
703 // c) function:DidFinishDocumentLoadForFrame. When this function is
704 // called, that means we have got whole html page. In here we should
705 // finally get right encoding of page.
706 void UpdateEncoding(WebKit::WebFrame* frame,
707 const std::string& encoding_name);
708
[email protected]ae5184d62011-10-06 19:25:58709 void OpenURL(WebKit::WebFrame* frame,
710 const GURL& url,
711 const GURL& referrer,
[email protected]6e24cf12011-03-18 19:57:02712 WebKit::WebNavigationPolicy policy);
713
[email protected]6e24cf12011-03-18 19:57:02714 bool RunJavaScriptMessage(int type,
[email protected]4f5ce842011-05-27 19:34:41715 const string16& message,
716 const string16& default_value,
[email protected]6e24cf12011-03-18 19:57:02717 const GURL& frame_url,
[email protected]4f5ce842011-05-27 19:34:41718 string16* result);
[email protected]6e24cf12011-03-18 19:57:02719
720 // Sends a message and runs a nested message loop.
721 bool SendAndRunNestedMessageLoop(IPC::SyncMessage* message);
722
[email protected]dd6afca2011-08-13 03:44:31723 // Called when the "pinned to left/right edge" state needs to be updated.
724 void UpdateScrollState(WebKit::WebFrame* frame);
725
[email protected]6e24cf12011-03-18 19:57:02726 // IPC message handlers ------------------------------------------------------
727 //
728 // The documentation for these functions should be in
729 // render_messages_internal.h for the message that the function is handling.
730
[email protected]6e24cf12011-03-18 19:57:02731 void OnAllowBindings(int enabled_bindings_flags);
[email protected]6e24cf12011-03-18 19:57:02732 void OnAllowScriptToClose(bool script_can_close);
733 void OnAsyncFileOpened(base::PlatformFileError error_code,
734 IPC::PlatformFileForTransit file_for_transit,
735 int message_id);
[email protected]eb415bf0e2011-04-14 02:45:42736 void OnPpapiBrokerChannelCreated(int request_id,
[email protected]2b657fd2011-04-18 16:00:47737 base::ProcessHandle broker_process_handle,
[email protected]d54305072011-06-22 20:58:43738 const IPC::ChannelHandle& handle);
[email protected]6e24cf12011-03-18 19:57:02739 void OnCancelDownload(int32 download_id);
740 void OnClearFocusedNode();
[email protected]992db4c2011-05-12 15:37:15741 void OnClosePage();
[email protected]6e24cf12011-03-18 19:57:02742#if defined(ENABLE_FLAPPER_HACKS)
743 void OnConnectTcpACK(int request_id,
744 IPC::PlatformFileForTransit socket_for_transit,
745 const PP_Flash_NetAddress& local_addr,
746 const PP_Flash_NetAddress& remote_addr);
747#endif
748 void OnContextMenuClosed(
749 const webkit_glue::CustomContextMenuContext& custom_context);
750 void OnCopy();
751 void OnCopyImageAt(int x, int y);
752#if defined(OS_MACOSX)
753 void OnCopyToFindPboard();
754#endif
755 void OnCut();
[email protected]318bf5802011-08-08 17:12:41756 void OnCSSInsertRequest(const string16& frame_xpath,
[email protected]01cf589c2011-07-28 18:04:03757 const std::string& css);
[email protected]6e24cf12011-03-18 19:57:02758 void OnCustomContextMenuAction(
759 const webkit_glue::CustomContextMenuContext& custom_context,
760 unsigned action);
761 void OnDelete();
762 void OnDeterminePageLanguage();
763 void OnDisableScrollbarsForSmallWindows(
764 const gfx::Size& disable_scrollbars_size_limit);
765 void OnDisassociateFromPopupCount();
[email protected]6e24cf12011-03-18 19:57:02766 void OnDragSourceEndedOrMoved(const gfx::Point& client_point,
767 const gfx::Point& screen_point,
768 bool ended,
769 WebKit::WebDragOperation drag_operation);
770 void OnDragSourceSystemDragEnded();
771 void OnDragTargetDrop(const gfx::Point& client_pt,
772 const gfx::Point& screen_pt);
773 void OnDragTargetDragEnter(const WebDropData& drop_data,
774 const gfx::Point& client_pt,
775 const gfx::Point& screen_pt,
776 WebKit::WebDragOperationsMask operations_allowed);
777 void OnDragTargetDragLeave();
778 void OnDragTargetDragOver(const gfx::Point& client_pt,
779 const gfx::Point& screen_pt,
780 WebKit::WebDragOperationsMask operations_allowed);
781 void OnEnablePreferredSizeChangedMode(int flags);
[email protected]600ea402011-04-12 00:01:51782 void OnEnumerateDirectoryResponse(int id, const std::vector<FilePath>& paths);
[email protected]6e24cf12011-03-18 19:57:02783 void OnExecuteEditCommand(const std::string& name, const std::string& value);
[email protected]6e24cf12011-03-18 19:57:02784 void OnFileChooserResponse(const std::vector<FilePath>& paths);
785 void OnFind(int request_id, const string16&, const WebKit::WebFindOptions&);
786 void OnFindReplyAck();
[email protected]18d5be92011-07-25 18:00:19787 void OnGetAllSavableResourceLinksForCurrentPage(const GURL& page_url);
788 void OnGetSerializedHtmlDataForCurrentPageWithLocalLinks(
789 const std::vector<GURL>& links,
790 const std::vector<FilePath>& local_paths,
791 const FilePath& local_directory_name);
[email protected]67bfb83f2011-09-22 03:36:37792 void OnLockMouseACK(bool succeeded);
[email protected]6e24cf12011-03-18 19:57:02793 void OnMediaPlayerActionAt(const gfx::Point& location,
794 const WebKit::WebMediaPlayerAction& action);
[email protected]67bfb83f2011-09-22 03:36:37795 void OnMouseLockLost();
[email protected]6e24cf12011-03-18 19:57:02796 void OnMoveOrResizeStarted();
[email protected]f3112a52011-09-30 23:47:49797 CONTENT_EXPORT void OnNavigate(const ViewMsg_Navigate_Params& params);
[email protected]6e24cf12011-03-18 19:57:02798 void OnPaste();
799#if defined(OS_MACOSX)
800 void OnPluginImeCompositionCompleted(const string16& text, int plugin_id);
801#endif
802 void OnRedo();
803 void OnReloadFrame();
804 void OnReplace(const string16& text);
805 void OnReservePageIDRange(int size_of_range);
806 void OnResetPageEncodingToDefault();
807 void OnScriptEvalRequest(const string16& frame_xpath,
808 const string16& jscript,
809 int id,
810 bool notify_result);
811 void OnSelectAll();
[email protected]4fb60142011-08-09 02:22:08812 void OnSelectRange(const gfx::Point& start, const gfx::Point& end);
[email protected]6e24cf12011-03-18 19:57:02813 void OnSetActive(bool active);
814 void OnSetAltErrorPageURL(const GURL& gurl);
815 void OnSetBackground(const SkBitmap& background);
[email protected]6e24cf12011-03-18 19:57:02816 void OnSetWebUIProperty(const std::string& name, const std::string& value);
817 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
[email protected]f3112a52011-09-30 23:47:49818 CONTENT_EXPORT void OnSetHistoryLengthAndPrune(int history_length,
819 int32 minimum_page_id);
[email protected]6e24cf12011-03-18 19:57:02820 void OnSetInitialFocus(bool reverse);
[email protected]54ca3ca892011-06-07 21:14:54821#if defined(OS_MACOSX)
822 void OnSetInLiveResize(bool in_live_resize);
823#endif
[email protected]333ec8d02011-09-16 18:59:19824 void OnScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect);
[email protected]6e24cf12011-03-18 19:57:02825 void OnSetPageEncoding(const std::string& encoding_name);
826 void OnSetRendererPrefs(const RendererPreferences& renderer_prefs);
[email protected]6e24cf12011-03-18 19:57:02827#if defined(OS_MACOSX)
828 void OnSetWindowVisibility(bool visible);
829#endif
830 void OnSetZoomLevel(double zoom_level);
831 void OnSetZoomLevelForLoadingURL(const GURL& url, double zoom_level);
[email protected]8a5e0ca2011-08-25 06:30:47832 void OnExitFullscreen();
[email protected]6e24cf12011-03-18 19:57:02833 void OnShouldClose();
834 void OnStop();
835 void OnStopFinding(const ViewMsg_StopFinding_Params& params);
[email protected]992db4c2011-05-12 15:37:15836 void OnSwapOut(const ViewMsg_SwapOut_Params& params);
[email protected]6e24cf12011-03-18 19:57:02837 void OnThemeChanged();
[email protected]6e24cf12011-03-18 19:57:02838 void OnUndo();
[email protected]6e24cf12011-03-18 19:57:02839 void OnUpdateTargetURLAck();
840 void OnUpdateWebPreferences(const WebPreferences& prefs);
[email protected]08bb1e722011-07-30 19:13:04841 void OnUpdateRemoteAccessClientFirewallTraversal(const std::string& policy);
842
[email protected]6e24cf12011-03-18 19:57:02843#if defined(OS_MACOSX)
844 void OnWindowFrameChanged(const gfx::Rect& window_frame,
845 const gfx::Rect& view_frame);
846 void OnSelectPopupMenuItem(int selected_index);
847#endif
848 void OnZoom(PageZoom::Function function);
[email protected]5a7b15a2011-08-22 22:48:18849 void OnEnableViewSourceMode();
[email protected]6e24cf12011-03-18 19:57:02850
851 // Adding a new message handler? Please add it in alphabetical order above
852 // and put it in the same position in the .cc file.
853
854 // Misc private functions ----------------------------------------------------
855
[email protected]6e24cf12011-03-18 19:57:02856 void AltErrorPageFinished(WebKit::WebFrame* frame,
857 const WebKit::WebURLError& original_error,
858 const std::string& html);
859
[email protected]d812fd12011-05-27 23:05:07860 // Check whether the preferred size has changed.
[email protected]6e24cf12011-03-18 19:57:02861 void CheckPreferredSize();
862
[email protected]5e56df82011-04-18 17:00:15863 // This callback is triggered when DownloadFavicon completes, either
864 // succesfully or with a failure. See DownloadFavicon for more
865 // details.
866 void DidDownloadFavicon(webkit_glue::ImageResourceFetcher* fetcher,
867 const SkBitmap& image);
[email protected]6e24cf12011-03-18 19:57:02868
[email protected]310ebd6302011-10-10 19:06:28869 // Requests to download a favicon image. When done, the RenderView is notified
870 // by way of DidDownloadFavicon. Returns true if the request was successfully
871 // started, false otherwise. id is used to uniquely identify the request and
872 // passed back to the DidDownloadFavicon method. If the image has multiple
873 // frames, the frame whose size is image_size is returned. If the image
874 // doesn't have a frame at the specified size, the first is returned.
[email protected]5e56df82011-04-18 17:00:15875 bool DownloadFavicon(int id, const GURL& image_url, int image_size);
[email protected]6e24cf12011-03-18 19:57:02876
[email protected]6e24cf12011-03-18 19:57:02877 GURL GetAlternateErrorPageURL(const GURL& failed_url,
878 ErrorPageType error_type);
879
880 // Locates a sub frame with given xpath
[email protected]318bf5802011-08-08 17:12:41881 WebKit::WebFrame* GetChildFrame(const string16& frame_xpath) const;
[email protected]6e24cf12011-03-18 19:57:02882
[email protected]57b9396c2011-10-07 19:11:59883 // Returns the opener url if present, else an empty url.
884 GURL GetOpenerUrl() const;
885
[email protected]6e24cf12011-03-18 19:57:02886 WebUIBindings* GetWebUIBindings();
887
[email protected]6e24cf12011-03-18 19:57:02888 // Should only be called if this object wraps a PluginDocument.
889 WebKit::WebPlugin* GetWebPluginFromPluginDocument();
890
[email protected]d466b8a2011-07-15 21:48:03891 // Returns true if the |params| navigation is to an entry that has been
892 // cropped due to a recent navigation the browser did not know about.
893 bool IsBackForwardToStaleEntry(const ViewMsg_Navigate_Params& params,
894 bool is_reload);
895
[email protected]6e24cf12011-03-18 19:57:02896 // Returns false unless this is a top-level navigation that crosses origins.
897 bool IsNonLocalTopLevelNavigation(const GURL& url,
898 WebKit::WebFrame* frame,
899 WebKit::WebNavigationType type);
900
[email protected]6e24cf12011-03-18 19:57:02901 bool MaybeLoadAlternateErrorPage(WebKit::WebFrame* frame,
902 const WebKit::WebURLError& error,
903 bool replace);
904
905 // Starts nav_state_sync_timer_ if it isn't already running.
906 void StartNavStateSyncTimerIfNecessary();
907
908 // Dispatches the current navigation state to the browser. Called on a
909 // periodic timer so we don't send too many messages.
910 void SyncNavigationState();
911
[email protected]b781ff282011-08-20 06:19:36912 // Dispatches the current state of selection on the webpage to the browser if
913 // it has changed.
914 // TODO(varunjain): delete this method once we figure out how to keep
915 // selection handles in sync with the webpage.
916 void SyncSelectionIfRequired();
917
[email protected]e63c4d72011-05-31 22:38:29918#if defined(OS_POSIX) && !defined(OS_MACOSX)
[email protected]6e24cf12011-03-18 19:57:02919 void UpdateFontRenderingFromRendererPrefs();
920#else
921 void UpdateFontRenderingFromRendererPrefs() {}
922#endif
923
924 // Update the target url and tell the browser that the target URL has changed.
925 // If |url| is empty, show |fallback_url|.
926 void UpdateTargetURL(const GURL& url, const GURL& fallback_url);
927
[email protected]6e24cf12011-03-18 19:57:02928 // ---------------------------------------------------------------------------
929 // ADDING NEW FUNCTIONS? Please keep private functions alphabetized and put
930 // it in the same order in the .cc file as it was in the header.
931 // ---------------------------------------------------------------------------
932
933 // Settings ------------------------------------------------------------------
934
935 WebPreferences webkit_preferences_;
936 RendererPreferences renderer_preferences_;
937
[email protected]6e24cf12011-03-18 19:57:02938 HostZoomLevels host_zoom_levels_;
939
940 // Whether content state (such as form state, scroll position and page
941 // contents) should be sent to the browser immediately. This is normally
942 // false, but set to true by some tests.
943 bool send_content_state_immediately_;
944
[email protected]6e24cf12011-03-18 19:57:02945 // Bitwise-ORed set of extra bindings that have been enabled. See
946 // BindingsPolicy for details.
947 int enabled_bindings_;
948
949 // The alternate error page URL, if one exists.
950 GURL alternate_error_page_url_;
951
952 // If true, we send IPC messages when |preferred_size_| changes.
953 bool send_preferred_size_changes_;
954
955 // If non-empty, and |send_preferred_size_changes_| is true, disable drawing
956 // scroll bars on windows smaller than this size. Used for windows that the
957 // browser resizes to the size of the content, such as browser action popups.
958 // If a render view is set to the minimum size of its content, webkit may add
959 // scroll bars. This makes sense for fixed sized windows, but it does not
960 // make sense when the size of the view was chosen to fit the content.
961 // This setting ensures that no scroll bars are drawn. The size limit exists
962 // because if the view grows beyond a size known to the browser, scroll bars
963 // should be drawn.
964 gfx::Size disable_scrollbars_size_limit_;
965
[email protected]6e24cf12011-03-18 19:57:02966 // Loading state -------------------------------------------------------------
967
968 // True if the top level frame is currently being loaded.
969 bool is_loading_;
970
971 // The gesture that initiated the current navigation.
972 NavigationGesture navigation_gesture_;
973
974 // Used for popups.
975 bool opened_by_user_gesture_;
976 GURL creator_url_;
977
978 // Whether this RenderView was created by a frame that was suppressing its
979 // opener. If so, we may want to load pages in a separate process. See
980 // decidePolicyForNavigation for details.
981 bool opener_suppressed_;
982
983 // If we are handling a top-level client-side redirect, this tracks the URL
984 // of the page that initiated it. Specifically, when a load is committed this
985 // is used to determine if that load originated from a client-side redirect.
986 // It is empty if there is no top-level client-side redirect.
987 GURL completed_client_redirect_src_;
988
[email protected]6e24cf12011-03-18 19:57:02989 // Holds state pertaining to a navigation that we initiated. This is held by
990 // the WebDataSource::ExtraData attribute. We use pending_navigation_state_
991 // as a temporary holder for the state until the WebDataSource corresponding
992 // to the new navigation is created. See DidCreateDataSource.
[email protected]82ddba1c2011-10-04 00:15:32993 scoped_ptr<content::NavigationState> pending_navigation_state_;
[email protected]6e24cf12011-03-18 19:57:02994
995 // Timer used to delay the updating of nav state (see SyncNavigationState).
[email protected]310ebd6302011-10-10 19:06:28996 base::OneShotTimer<RenderViewImpl> nav_state_sync_timer_;
[email protected]6e24cf12011-03-18 19:57:02997
[email protected]6e24cf12011-03-18 19:57:02998 // Page IDs ------------------------------------------------------------------
[email protected]a813c8e2011-10-08 01:34:11999 // See documentation in content::RenderView.
[email protected]6e24cf12011-03-18 19:57:021000 int32 page_id_;
1001
1002 // Indicates the ID of the last page that we sent a FrameNavigate to the
1003 // browser for. This is used to determine if the most recent transition
1004 // generated a history entry (less than page_id_), or not (equal to or
1005 // greater than). Note that this will be greater than page_id_ if the user
1006 // goes back.
1007 int32 last_page_id_sent_to_browser_;
1008
[email protected]6e24cf12011-03-18 19:57:021009 // The next available page ID to use. This ensures that the page IDs are
1010 // globally unique in the renderer.
1011 static int32 next_page_id_;
1012
[email protected]d466b8a2011-07-15 21:48:031013 // The offset of the current item in the history list.
1014 int history_list_offset_;
1015
1016 // The RenderView's current impression of the history length. This includes
1017 // any items that have committed in this process, but because of cross-process
1018 // navigations, the history may have some entries that were committed in other
1019 // processes. We won't know about them until the next navigation in this
1020 // process.
1021 int history_list_length_;
1022
1023 // The list of page IDs for each history item this RenderView knows about.
1024 // Some entries may be -1 if they were rendered by other processes or were
1025 // restored from a previous session. This lets us detect attempts to
1026 // navigate to stale entries that have been cropped from our history.
1027 std::vector<int32> history_page_ids_;
1028
[email protected]6e24cf12011-03-18 19:57:021029 // Page info -----------------------------------------------------------------
1030
1031 // The last gotten main frame's encoding.
1032 std::string last_encoding_name_;
1033
[email protected]6e24cf12011-03-18 19:57:021034 // UI state ------------------------------------------------------------------
1035
1036 // The state of our target_url transmissions. When we receive a request to
1037 // send a URL to the browser, we set this to TARGET_INFLIGHT until an ACK
1038 // comes back - if a new request comes in before the ACK, we store the new
1039 // URL in pending_target_url_ and set the status to TARGET_PENDING. If an
1040 // ACK comes back and we are in TARGET_PENDING, we send the stored URL and
1041 // revert to TARGET_INFLIGHT.
1042 //
1043 // We don't need a queue of URLs to send, as only the latest is useful.
1044 enum {
1045 TARGET_NONE,
1046 TARGET_INFLIGHT, // We have a request in-flight, waiting for an ACK
1047 TARGET_PENDING // INFLIGHT + we have a URL waiting to be sent
1048 } target_url_status_;
1049
1050 // The URL we show the user in the status bar. We use this to determine if we
1051 // want to send a new one (we do not need to send duplicates). It will be
1052 // equal to either |mouse_over_url_| or |focus_url_|, depending on which was
1053 // updated last.
1054 GURL target_url_;
1055
1056 // The URL the user's mouse is hovering over.
1057 GURL mouse_over_url_;
1058
1059 // The URL that has keyboard focus.
1060 GURL focus_url_;
1061
1062 // The next target URL we want to send to the browser.
1063 GURL pending_target_url_;
1064
[email protected]6e24cf12011-03-18 19:57:021065 // The text selection the last time DidChangeSelection got called.
[email protected]b781ff282011-08-20 06:19:361066 RenderViewSelection last_selection_;
[email protected]6e24cf12011-03-18 19:57:021067
1068 // View ----------------------------------------------------------------------
1069
[email protected]6e24cf12011-03-18 19:57:021070 // Cache the preferred size of the page in order to prevent sending the IPC
1071 // when layout() recomputes but doesn't actually change sizes.
1072 gfx::Size preferred_size_;
1073
[email protected]1e0c8e02011-05-25 07:49:371074 // Used to delay determining the preferred size (to avoid intermediate
1075 // states for the sizes).
[email protected]310ebd6302011-10-10 19:06:281076 base::OneShotTimer<RenderViewImpl> check_preferred_size_timer_;
[email protected]1e0c8e02011-05-25 07:49:371077
[email protected]dd6afca2011-08-13 03:44:311078 // These store the "is main frame is scrolled all the way to the left
1079 // or right" state that was last sent to the browser.
1080 bool cached_is_main_frame_pinned_to_left_;
1081 bool cached_is_main_frame_pinned_to_right_;
1082
1083 // These store the "has scrollbars" state last sent to the browser.
1084 bool cached_has_main_frame_horizontal_scrollbar_;
1085 bool cached_has_main_frame_vertical_scrollbar_;
1086
[email protected]6e24cf12011-03-18 19:57:021087#if defined(OS_MACOSX)
1088 // Track the fake plugin window handles allocated on the browser side for
1089 // the accelerated compositor and (currently) accelerated plugins so that
1090 // we can discard them when the view goes away.
1091 std::set<gfx::PluginWindowHandle> fake_plugin_window_handles_;
1092#endif
1093
1094 // Plugins -------------------------------------------------------------------
1095
[email protected]6e24cf12011-03-18 19:57:021096 PepperPluginDelegateImpl pepper_delegate_;
1097
[email protected]310ebd6302011-10-10 19:06:281098 // All the currently active plugin delegates for this RenderView; kept so
1099 // that we can enumerate them to send updates about things like window
1100 // location or tab focus and visibily. These are non-owning references.
[email protected]6e24cf12011-03-18 19:57:021101 std::set<WebPluginDelegateProxy*> plugin_delegates_;
1102
[email protected]e6ae0f6c2011-10-04 10:39:231103#if defined(OS_WIN)
1104 // The ID of the focused NPAPI plug-in.
1105 int focused_plugin_id_;
1106#endif
1107
[email protected]6e24cf12011-03-18 19:57:021108 // Helper objects ------------------------------------------------------------
1109
[email protected]6e24cf12011-03-18 19:57:021110 RendererWebCookieJarImpl cookie_jar_;
1111
1112 // The next group of objects all implement RenderViewObserver, so are deleted
[email protected]310ebd6302011-10-10 19:06:281113 // along with the RenderView automatically. This is why we just store
1114 // weak references.
[email protected]6e24cf12011-03-18 19:57:021115
[email protected]6e24cf12011-03-18 19:57:021116 // Holds a reference to the service which provides desktop notifications.
1117 NotificationProvider* notification_provider_;
1118
1119 // The geolocation dispatcher attached to this view, lazily initialized.
1120 GeolocationDispatcher* geolocation_dispatcher_;
1121
[email protected]1ef93132011-09-16 18:33:471122 // The intents dispatcher attached to this view. Not lazily initialized.
1123 IntentsDispatcher* intents_dispatcher_;
1124
[email protected]6e24cf12011-03-18 19:57:021125 // The speech dispatcher attached to this view, lazily initialized.
1126 SpeechInputDispatcher* speech_input_dispatcher_;
1127
1128 // Device orientation dispatcher attached to this view; lazily initialized.
1129 DeviceOrientationDispatcher* device_orientation_dispatcher_;
1130
[email protected]ab2c4732011-07-20 19:57:401131 // MediaStreamImpl attached to this view; lazily initialized.
1132 scoped_refptr<MediaStreamImpl> media_stream_impl_;
1133
[email protected]6e24cf12011-03-18 19:57:021134 // Dispatches all P2P socket used by the renderer.
[email protected]b3f8f9722011-08-25 20:56:071135 content::P2PSocketDispatcher* p2p_socket_dispatcher_;
[email protected]6e24cf12011-03-18 19:57:021136
[email protected]c5c1d6d2011-07-28 18:42:411137 DevToolsAgent* devtools_agent_;
1138
[email protected]063afcb2011-09-29 07:54:321139 RendererAccessibility* renderer_accessibility_;
1140
[email protected]6e24cf12011-03-18 19:57:021141 // Misc ----------------------------------------------------------------------
1142
1143 // The current and pending file chooser completion objects. If the queue is
1144 // nonempty, the first item represents the currently running file chooser
1145 // callback, and the remaining elements are the other file chooser completion
1146 // still waiting to be run (in order).
1147 struct PendingFileChooser;
1148 std::deque< linked_ptr<PendingFileChooser> > file_chooser_completions_;
1149
[email protected]600ea402011-04-12 00:01:511150 // The current directory enumeration callback
1151 std::map<int, WebKit::WebFileChooserCompletion*> enumeration_completions_;
1152 int enumeration_completion_id_;
1153
[email protected]6e24cf12011-03-18 19:57:021154 // The SessionStorage namespace that we're assigned to has an ID, and that ID
1155 // is passed to us upon creation. WebKit asks for this ID upon first use and
1156 // uses it whenever asking the browser process to allocate new storage areas.
1157 int64 session_storage_namespace_id_;
1158
1159 // The total number of unrequested popups that exist and can be followed back
[email protected]310ebd6302011-10-10 19:06:281160 // to a common opener. This count is shared among all RenderViews created with
1161 // createView(). All popups are treated as unrequested until specifically
1162 // instructed otherwise by the Browser process.
[email protected]6e24cf12011-03-18 19:57:021163 scoped_refptr<SharedRenderViewCounter> shared_popup_counter_;
1164
1165 // Whether this is a top level window (instead of a popup). Top level windows
1166 // shouldn't count against their own |shared_popup_counter_|.
1167 bool decrement_shared_popup_at_destruction_;
1168
1169 // If the browser hasn't sent us an ACK for the last FindReply we sent
1170 // to it, then we need to queue up the message (keeping only the most
1171 // recent message if new ones come in).
1172 scoped_ptr<IPC::Message> queued_find_reply_message_;
1173
1174 // Stores edit commands associated to the next key event.
1175 // Shall be cleared as soon as the next key event is processed.
1176 EditCommands edit_commands_;
1177
[email protected]6e24cf12011-03-18 19:57:021178 // Allows Web UI pages (new tab page, etc.) to talk to the browser. The JS
1179 // object is only exposed when Web UI bindings are enabled.
1180 scoped_ptr<WebUIBindings> web_ui_bindings_;
1181
[email protected]6e24cf12011-03-18 19:57:021182 // The external popup for the currently showing select popup.
1183 scoped_ptr<ExternalPopupMenu> external_popup_menu_;
1184
1185 // The node that the context menu was pressed over.
1186 WebKit::WebNode context_menu_node_;
1187
1188 // Reports load progress to the browser.
1189 scoped_ptr<LoadProgressTracker> load_progress_tracker_;
1190
1191 // All the registered observers. We expect this list to be small, so vector
1192 // is fine.
[email protected]3a034ebb2011-10-03 19:19:441193 ObserverList<content::RenderViewObserver> observers_;
[email protected]6e24cf12011-03-18 19:57:021194
[email protected]4fb60142011-08-09 02:22:081195 // Used to inform didChangeSelection() when it is called in the context
1196 // of handling a ViewMsg_SelectRange IPC.
1197 bool handling_select_range_;
1198
[email protected]6e24cf12011-03-18 19:57:021199 // ---------------------------------------------------------------------------
1200 // ADDING NEW DATA? Please see if it fits appropriately in one of the above
1201 // sections rather than throwing it randomly at the end. If you're adding a
1202 // bunch of stuff, you should probably create a helper class and put your
[email protected]310ebd6302011-10-10 19:06:281203 // data and methods on that to avoid bloating RenderView more. You can
1204 // use the Observer interface to filter IPC messages and receive frame change
[email protected]6e24cf12011-03-18 19:57:021205 // notifications.
1206 // ---------------------------------------------------------------------------
1207
[email protected]310ebd6302011-10-10 19:06:281208 DISALLOW_COPY_AND_ASSIGN(RenderViewImpl);
[email protected]6e24cf12011-03-18 19:57:021209};
1210
[email protected]310ebd6302011-10-10 19:06:281211#endif // CONTENT_RENDERER_RENDER_VIEW_IMPL_H_