blob: db207a4d42d5bb4ca43ab0890eb5198d06d21950 [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
5#ifndef CONTENT_RENDERER_RENDER_VIEW_H_
6#define CONTENT_RENDERER_RENDER_VIEW_H_
7#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]1ef93132011-09-16 18:33:4728#include "content/common/intents_messages.h"
[email protected]6e24cf12011-03-18 19:57:0229#include "content/common/navigation_gesture.h"
30#include "content/common/page_zoom.h"
[email protected]60916042011-03-19 00:43:3631#include "content/common/renderer_preferences.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"
35#include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityNotification.h"
36#include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h"
37#include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystem.h"
38#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h"
[email protected]42054a252011-05-17 18:02:1339#include "third_party/WebKit/Source/WebKit/chromium/public/WebIconURL.h"
[email protected]6e24cf12011-03-18 19:57:0240#include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h"
[email protected]18d5be92011-07-25 18:00:1941#include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializerClient.h"
[email protected]94dec932011-05-26 20:04:2142#include "third_party/WebKit/Source/WebKit/chromium/public/WebPageVisibilityState.h"
[email protected]6e24cf12011-03-18 19:57:0243#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h"
44#include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h"
45#include "third_party/WebKit/Source/WebKit/chromium/public/WebNavigationType.h"
[email protected]b9b751f22011-03-25 14:04:1246#include "ui/gfx/surface/transport_dib.h"
[email protected]6e24cf12011-03-18 19:57:0247#include "webkit/glue/webpreferences.h"
48#include "webkit/plugins/npapi/webplugin_page_delegate.h"
49
50#if defined(OS_WIN)
51// RenderView is a diamond-shaped hierarchy, with WebWidgetClient at the root.
52// VS warns when we inherit the WebWidgetClient method implementations from
53// RenderWidget. It's safe to ignore that warning.
54#pragma warning(disable: 4250)
55#endif
56
57class AudioMessageFilter;
[email protected]6e24cf12011-03-18 19:57:0258class DeviceOrientationDispatcher;
[email protected]c5c1d6d2011-07-28 18:42:4159class DevToolsAgent;
[email protected]55722152011-03-22 01:33:5360class ExternalPopupMenu;
[email protected]6e24cf12011-03-18 19:57:0261class FilePath;
62class GeolocationDispatcher;
[email protected]6e24cf12011-03-18 19:57:0263class GURL;
[email protected]1ef93132011-09-16 18:33:4764class IntentsDispatcher;
[email protected]6e24cf12011-03-18 19:57:0265class LoadProgressTracker;
[email protected]ab2c4732011-07-20 19:57:4066class MediaStreamImpl;
[email protected]6e24cf12011-03-18 19:57:0267class NavigationState;
68class NotificationProvider;
[email protected]6e24cf12011-03-18 19:57:0269class PepperDeviceTest;
70class PrintWebViewHelper;
71class RenderViewObserver;
72class RenderViewVisitor;
[email protected]ea192e82011-04-11 19:16:0273class RenderWidgetFullscreenPepper;
[email protected]6e24cf12011-03-18 19:57:0274class SkBitmap;
75class SpeechInputDispatcher;
[email protected]6e24cf12011-03-18 19:57:0276class WebPluginDelegateProxy;
[email protected]55722152011-03-22 01:33:5377class WebUIBindings;
[email protected]6e24cf12011-03-18 19:57:0278struct ContextMenuMediaParams;
79struct PP_Flash_NetAddress;
[email protected]6e24cf12011-03-18 19:57:0280struct ViewHostMsg_RunFileChooser_Params;
[email protected]992db4c2011-05-12 15:37:1581struct ViewMsg_SwapOut_Params;
[email protected]6e24cf12011-03-18 19:57:0282struct ViewMsg_Navigate_Params;
83struct ViewMsg_StopFinding_Params;
[email protected]6e24cf12011-03-18 19:57:0284struct WebDropData;
85
86namespace base {
87class WaitableEvent;
[email protected]b3f8f9722011-08-25 20:56:0788} // namespace base
89
90namespace content {
91class P2PSocketDispatcher;
92} // namespace content
[email protected]6e24cf12011-03-18 19:57:0293
[email protected]6e24cf12011-03-18 19:57:0294namespace gfx {
95class Point;
96class Rect;
[email protected]b3f8f9722011-08-25 20:56:0797} // namespace gfx
[email protected]6e24cf12011-03-18 19:57:0298
99namespace webkit {
100
[email protected]6e24cf12011-03-18 19:57:02101namespace ppapi {
[email protected]6e24cf12011-03-18 19:57:02102class PluginInstance;
103class PluginModule;
104} // namespace ppapi
105
106} // namespace webkit
107
108namespace webkit_glue {
109struct CustomContextMenuContext;
110class ImageResourceFetcher;
111struct FileUploadData;
112struct FormData;
113struct PasswordFormFillData;
114class ResourceFetcher;
115}
116
117namespace WebKit {
118class WebAccessibilityCache;
119class WebAccessibilityObject;
120class WebApplicationCacheHost;
121class WebApplicationCacheHostClient;
122class WebDataSource;
123class WebDocument;
124class WebDragData;
125class WebFrame;
126class WebGeolocationClient;
127class WebGeolocationServiceInterface;
[email protected]42054a252011-05-17 18:02:13128class WebIconURL;
[email protected]6e24cf12011-03-18 19:57:02129class WebImage;
130class WebInputElement;
131class WebKeyboardEvent;
132class WebMediaPlayer;
133class WebMediaPlayerClient;
134class WebMouseEvent;
135class WebPlugin;
136class WebSpeechInputController;
137class WebSpeechInputListener;
138class WebStorageNamespace;
[email protected]b00ba702011-08-17 01:41:03139class WebURLLoader;
[email protected]6e24cf12011-03-18 19:57:02140class WebURLRequest;
141class WebView;
142struct WebContextMenuData;
143struct WebFileChooserParams;
144struct WebFindOptions;
145struct WebMediaPlayerAction;
146struct WebPluginParams;
147struct WebPoint;
148struct WebWindowFeatures;
149}
150
151// We need to prevent a page from trying to create infinite popups. It is not
152// as simple as keeping a count of the number of immediate children
153// popups. Having an html file that window.open()s itself would create
154// an unlimited chain of RenderViews who only have one RenderView child.
155//
156// Therefore, each new top level RenderView creates a new counter and shares it
157// with all its children and grandchildren popup RenderViews created with
158// createView() to have a sort of global limit for the page so no more than
159// kMaximumNumberOfPopups popups are created.
160//
161// This is a RefCounted holder of an int because I can't say
162// scoped_refptr<int>.
163typedef base::RefCountedData<int> SharedRenderViewCounter;
164
165//
166// RenderView is an object that manages a WebView object, and provides a
167// communication interface with an embedding application process
168//
169class RenderView : public RenderWidget,
170 public WebKit::WebViewClient,
171 public WebKit::WebFrameClient,
[email protected]18d5be92011-07-25 18:00:19172 public WebKit::WebPageSerializerClient,
[email protected]08bb1e722011-07-30 19:13:04173 public webkit::npapi::WebPluginPageDelegate,
[email protected]6e24cf12011-03-18 19:57:02174 public base::SupportsWeakPtr<RenderView> {
175 public:
176 // Creates a new RenderView. The parent_hwnd specifies a HWND to use as the
177 // parent of the WebView HWND that will be created. If this is a constrained
178 // popup or as a new tab, opener_id is the routing ID of the RenderView
179 // responsible for creating this RenderView (corresponding to parent_hwnd).
180 // |counter| is either a currently initialized counter, or NULL (in which case
181 // we treat this RenderView as a top level window).
182 static RenderView* Create(
183 RenderThreadBase* render_thread,
184 gfx::NativeViewId parent_hwnd,
185 int32 opener_id,
186 const RendererPreferences& renderer_prefs,
187 const WebPreferences& webkit_prefs,
188 SharedRenderViewCounter* counter,
189 int32 routing_id,
190 int64 session_storage_namespace_id,
191 const string16& frame_name);
192
193 // Visit all RenderViews with a live WebView (i.e., RenderViews that have
194 // been closed but not yet destroyed are excluded).
[email protected]8d128d62011-09-13 22:11:57195 CONTENT_EXPORT static void ForEach(RenderViewVisitor* visitor);
[email protected]6e24cf12011-03-18 19:57:02196
197 // Returns the RenderView containing the given WebView.
[email protected]8d128d62011-09-13 22:11:57198 CONTENT_EXPORT static RenderView* FromWebView(WebKit::WebView* webview);
[email protected]6e24cf12011-03-18 19:57:02199
200 // Sets the "next page id" counter.
201 static void SetNextPageID(int32 next_page_id);
202
203 // May return NULL when the view is closing.
[email protected]8d128d62011-09-13 22:11:57204 CONTENT_EXPORT WebKit::WebView* webview() const;
[email protected]6e24cf12011-03-18 19:57:02205
[email protected]65225772011-05-12 21:10:24206 // Called by a GraphicsContext associated with this view when swapbuffers
[email protected]37a6f302011-07-11 23:43:08207 // is posted, completes or is aborted.
208 void OnViewContextSwapBuffersPosted();
[email protected]65225772011-05-12 21:10:24209 void OnViewContextSwapBuffersComplete();
210 void OnViewContextSwapBuffersAborted();
211
[email protected]9966325b2011-04-18 05:00:10212 int page_id() const { return page_id_; }
[email protected]d466b8a2011-07-15 21:48:03213 int history_list_offset() const { return history_list_offset_; }
[email protected]9966325b2011-04-18 05:00:10214 PepperPluginDelegateImpl* pepper_delegate() { return &pepper_delegate_; }
[email protected]6e24cf12011-03-18 19:57:02215
[email protected]6e24cf12011-03-18 19:57:02216 const WebPreferences& webkit_preferences() const {
217 return webkit_preferences_;
218 }
219
[email protected]93b9d692011-04-13 00:44:31220 bool content_state_immediately() { return send_content_state_immediately_; }
[email protected]9966325b2011-04-18 05:00:10221 int enabled_bindings() const { return enabled_bindings_; }
222 void set_enabled_bindings(int b) { enabled_bindings_ = b; }
[email protected]6e24cf12011-03-18 19:57:02223 void set_send_content_state_immediately(bool value) {
224 send_content_state_immediately_ = value;
225 }
226
227 // Returns true if we should display scrollbars for the given view size and
228 // false if the scrollbars should be hidden.
229 bool should_display_scrollbars(int width, int height) const {
230 return (!send_preferred_size_changes_ ||
231 (disable_scrollbars_size_limit_.width() <= width ||
232 disable_scrollbars_size_limit_.height() <= height));
233 }
234
[email protected]6e24cf12011-03-18 19:57:02235 const WebKit::WebNode& context_menu_node() { return context_menu_node_; }
236
237 // Current P2PSocketDispatcher. Set to NULL if P2P API is disabled.
[email protected]b3f8f9722011-08-25 20:56:07238 content::P2PSocketDispatcher* p2p_socket_dispatcher() {
[email protected]6e24cf12011-03-18 19:57:02239 return p2p_socket_dispatcher_;
240 }
241
242 // Functions to add and remove observers for this object.
243 void AddObserver(RenderViewObserver* observer);
244 void RemoveObserver(RenderViewObserver* observer);
245
[email protected]6e24cf12011-03-18 19:57:02246 // Evaluates a string of JavaScript in a particular frame.
[email protected]8d128d62011-09-13 22:11:57247 CONTENT_EXPORT void EvaluateScript(const string16& frame_xpath,
248 const string16& jscript,
249 int id,
250 bool notify_result);
[email protected]6e24cf12011-03-18 19:57:02251
252 // 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.
258 bool ScheduleFileChooser(const ViewHostMsg_RunFileChooser_Params& params,
259 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]38b592902011-04-16 02:08:42264 // Gets the focused node. If no such node exists then the node will be isNull.
[email protected]8d128d62011-09-13 22:11:57265 CONTENT_EXPORT WebKit::WebNode GetFocusedNode() const;
[email protected]38b592902011-04-16 02:08:42266
267 // Returns true if the parameter node is a textfield, text area or a content
268 // editable div.
[email protected]8d128d62011-09-13 22:11:57269 CONTENT_EXPORT bool IsEditableNode(const WebKit::WebNode& node);
[email protected]38b592902011-04-16 02:08:42270
[email protected]8d128d62011-09-13 22:11:57271 CONTENT_EXPORT void LoadNavigationErrorPage(
272 WebKit::WebFrame* frame,
273 const WebKit::WebURLRequest& failed_request,
274 const WebKit::WebURLError& error,
275 const std::string& html,
276 bool replace);
[email protected]9966325b2011-04-18 05:00:10277
[email protected]6e24cf12011-03-18 19:57:02278 // Plugin-related functions --------------------------------------------------
279 // (See also WebPluginPageDelegate implementation.)
280
281 // Notification that the given plugin has crashed.
282 void PluginCrashed(const FilePath& plugin_path);
283
[email protected]9966325b2011-04-18 05:00:10284 // Create a new NPAPI plugin.
[email protected]8d128d62011-09-13 22:11:57285 CONTENT_EXPORT WebKit::WebPlugin* CreateNPAPIPlugin(
286 WebKit::WebFrame* frame,
287 const WebKit::WebPluginParams& params,
288 const FilePath& path,
289 const std::string& mime_type);
[email protected]9966325b2011-04-18 05:00:10290
291 // Create a new Pepper plugin.
[email protected]8d128d62011-09-13 22:11:57292 CONTENT_EXPORT WebKit::WebPlugin* CreatePepperPlugin(
[email protected]9966325b2011-04-18 05:00:10293 WebKit::WebFrame* frame,
294 const WebKit::WebPluginParams& params,
295 const FilePath& path,
296 webkit::ppapi::PluginModule* pepper_module);
297
[email protected]6e24cf12011-03-18 19:57:02298 // Creates a fullscreen container for a pepper plugin instance.
[email protected]ea192e82011-04-11 19:16:02299 RenderWidgetFullscreenPepper* CreatePepperFullscreenContainer(
[email protected]6e24cf12011-03-18 19:57:02300 webkit::ppapi::PluginInstance* plugin);
301
302 // Create a new plugin without checking the content settings.
[email protected]8d128d62011-09-13 22:11:57303 CONTENT_EXPORT WebKit::WebPlugin* CreatePluginNoCheck(
304 WebKit::WebFrame* frame,
305 const WebKit::WebPluginParams& params);
[email protected]6e24cf12011-03-18 19:57:02306
[email protected]56ea1a62011-05-30 07:05:57307 // Informs the render view that a PPAPI plugin has gained or lost focus.
308 void PpapiPluginFocusChanged();
309
[email protected]08bb1e722011-07-30 19:13:04310 // Request updated policy regarding firewall NAT traversal being enabled.
311 void RequestRemoteAccessClientFirewallTraversal();
312
[email protected]6e24cf12011-03-18 19:57:02313#if defined(OS_MACOSX)
314 // Informs the render view that the given plugin has gained or lost focus.
315 void PluginFocusChanged(bool focused, int plugin_id);
316
317 // Starts plugin IME.
318 void StartPluginIme();
319
320 // Helper routines for accelerated plugin support. Used by the
321 // WebPluginDelegateProxy, which has a pointer to the RenderView.
322 gfx::PluginWindowHandle AllocateFakePluginWindowHandle(bool opaque,
323 bool root);
324 void DestroyFakePluginWindowHandle(gfx::PluginWindowHandle window);
325 void AcceleratedSurfaceSetIOSurface(gfx::PluginWindowHandle window,
326 int32 width,
327 int32 height,
328 uint64 io_surface_identifier);
329 TransportDIB::Handle AcceleratedSurfaceAllocTransportDIB(size_t size);
330 void AcceleratedSurfaceFreeTransportDIB(TransportDIB::Id dib_id);
331 void AcceleratedSurfaceSetTransportDIB(gfx::PluginWindowHandle window,
332 int32 width,
333 int32 height,
334 TransportDIB::Handle transport_dib);
335 void AcceleratedSurfaceBuffersSwapped(gfx::PluginWindowHandle window,
336 uint64 surface_id);
337#endif
338
339 void RegisterPluginDelegate(WebPluginDelegateProxy* delegate);
340 void UnregisterPluginDelegate(WebPluginDelegateProxy* delegate);
341
[email protected]4a7d6392011-09-19 20:55:08342 // Helper function to retrieve information about a plugin for a URL and mime
343 // type. Returns false if no plugin was found.
344 // |actual_mime_type| is the actual mime type supported by the
345 // plugin found that match the URL given (one for each item in
346 // |info|).
347 bool GetPluginInfo(const GURL& url,
348 const GURL& page_url,
349 const std::string& mime_type,
350 webkit::WebPluginInfo* plugin_info,
351 std::string* actual_mime_type);
352
353 // Asks the host to create a block of shared memory for the renderer.
354 // The shared memory handle allocated by the host is returned back.
355 base::SharedMemoryHandle HostAllocateSharedMemoryBuffer(uint32 buffer_size);
356
[email protected]6e24cf12011-03-18 19:57:02357 // IPC::Channel::Listener implementation -------------------------------------
358
359 virtual bool OnMessageReceived(const IPC::Message& msg);
360
361 // WebKit::WebWidgetClient implementation ------------------------------------
362
363 // Most methods are handled by RenderWidget.
364 virtual void didFocus();
365 virtual void didBlur();
366 virtual void show(WebKit::WebNavigationPolicy policy);
367 virtual void runModal();
368
369 // WebKit::WebViewClient implementation --------------------------------------
370
371 virtual WebKit::WebView* createView(
372 WebKit::WebFrame* creator,
373 const WebKit::WebURLRequest& request,
374 const WebKit::WebWindowFeatures& features,
375 const WebKit::WebString& frame_name);
376 virtual WebKit::WebWidget* createPopupMenu(WebKit::WebPopupType popup_type);
377 virtual WebKit::WebWidget* createPopupMenu(
378 const WebKit::WebPopupMenuInfo& info);
379 virtual WebKit::WebExternalPopupMenu* createExternalPopupMenu(
380 const WebKit::WebPopupMenuInfo& popup_menu_info,
381 WebKit::WebExternalPopupMenuClient* popup_menu_client);
382 virtual WebKit::WebStorageNamespace* createSessionStorageNamespace(
383 unsigned quota);
384 virtual void didAddMessageToConsole(
385 const WebKit::WebConsoleMessage& message,
386 const WebKit::WebString& source_name,
387 unsigned source_line);
388 virtual void printPage(WebKit::WebFrame* frame);
389 virtual WebKit::WebNotificationPresenter* notificationPresenter();
[email protected]8a58c1c2011-04-19 18:40:12390 virtual bool enumerateChosenDirectory(
391 const WebKit::WebString& path,
392 WebKit::WebFileChooserCompletion* chooser_completion);
[email protected]6e24cf12011-03-18 19:57:02393 virtual void didStartLoading();
394 virtual void didStopLoading();
395 virtual void didChangeLoadProgress(WebKit::WebFrame* frame,
396 double load_progress);
397 virtual bool isSmartInsertDeleteEnabled();
398 virtual bool isSelectTrailingWhitespaceEnabled();
399 virtual void didChangeSelection(bool is_selection_empty);
400 virtual void didExecuteCommand(const WebKit::WebString& command_name);
401 virtual bool handleCurrentKeyboardEvent();
[email protected]6e24cf12011-03-18 19:57:02402 virtual bool runFileChooser(
403 const WebKit::WebFileChooserParams& params,
404 WebKit::WebFileChooserCompletion* chooser_completion);
405 virtual void runModalAlertDialog(WebKit::WebFrame* frame,
406 const WebKit::WebString& message);
407 virtual bool runModalConfirmDialog(WebKit::WebFrame* frame,
408 const WebKit::WebString& message);
409 virtual bool runModalPromptDialog(WebKit::WebFrame* frame,
410 const WebKit::WebString& message,
411 const WebKit::WebString& default_value,
412 WebKit::WebString* actual_value);
413 virtual bool runModalBeforeUnloadDialog(WebKit::WebFrame* frame,
414 const WebKit::WebString& message);
415 virtual void showContextMenu(WebKit::WebFrame* frame,
416 const WebKit::WebContextMenuData& data);
417 virtual bool supportsFullscreen();
418 virtual void enterFullscreenForNode(const WebKit::WebNode&);
419 virtual void exitFullscreenForNode(const WebKit::WebNode&);
[email protected]8a5e0ca2011-08-25 06:30:47420 virtual void enterFullscreen() OVERRIDE;
421 virtual void exitFullscreen() OVERRIDE;
[email protected]6e24cf12011-03-18 19:57:02422 virtual void setStatusText(const WebKit::WebString& text);
423 virtual void setMouseOverURL(const WebKit::WebURL& url);
424 virtual void setKeyboardFocusURL(const WebKit::WebURL& url);
[email protected]6e24cf12011-03-18 19:57:02425 virtual void startDragging(const WebKit::WebDragData& data,
426 WebKit::WebDragOperationsMask mask,
427 const WebKit::WebImage& image,
428 const WebKit::WebPoint& imageOffset);
429 virtual bool acceptsLoadDrops();
430 virtual void focusNext();
431 virtual void focusPrevious();
432 virtual void focusedNodeChanged(const WebKit::WebNode& node);
433 virtual void navigateBackForwardSoon(int offset);
434 virtual int historyBackListCount();
435 virtual int historyForwardListCount();
436 virtual void postAccessibilityNotification(
437 const WebKit::WebAccessibilityObject& obj,
438 WebKit::WebAccessibilityNotification notification);
439 virtual void didUpdateInspectorSetting(const WebKit::WebString& key,
440 const WebKit::WebString& value);
441 virtual WebKit::WebGeolocationClient* geolocationClient();
442 virtual WebKit::WebSpeechInputController* speechInputController(
443 WebKit::WebSpeechInputListener* listener);
444 virtual WebKit::WebDeviceOrientationClient* deviceOrientationClient();
445 virtual void zoomLimitsChanged(double minimum_level, double maximum_level);
446 virtual void zoomLevelChanged();
447 virtual void registerProtocolHandler(const WebKit::WebString& scheme,
448 const WebKit::WebString& base_url,
449 const WebKit::WebString& url,
450 const WebKit::WebString& title);
[email protected]62af76e2011-08-01 02:34:01451 virtual void registerIntentHandler(const WebKit::WebString& action,
452 const WebKit::WebString& type,
453 const WebKit::WebString& href,
454 const WebKit::WebString& title);
[email protected]94dec932011-05-26 20:04:21455 virtual WebKit::WebPageVisibilityState visibilityState() const;
[email protected]e235c7d02011-08-18 22:38:43456 virtual void startActivity(const WebKit::WebString& action,
457 const WebKit::WebString& type,
458 const WebKit::WebString& data,
459 int intent_id);
[email protected]1ef93132011-09-16 18:33:47460 virtual void OnWebIntentReply(
461 IntentsMsg_WebIntentReply_Type::Value reply_type,
462 const WebKit::WebString& data,
463 int intent_id);
[email protected]6e24cf12011-03-18 19:57:02464
465 // WebKit::WebFrameClient implementation -------------------------------------
466
467 virtual WebKit::WebPlugin* createPlugin(
468 WebKit::WebFrame* frame,
469 const WebKit::WebPluginParams& params);
470 virtual WebKit::WebWorker* createWorker(WebKit::WebFrame* frame,
471 WebKit::WebWorkerClient* client);
472 virtual WebKit::WebSharedWorker* createSharedWorker(
473 WebKit::WebFrame* frame, const WebKit::WebURL& url,
474 const WebKit::WebString& name, unsigned long long documentId);
475 virtual WebKit::WebMediaPlayer* createMediaPlayer(
476 WebKit::WebFrame* frame,
477 WebKit::WebMediaPlayerClient* client);
478 virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(
479 WebKit::WebFrame* frame,
480 WebKit::WebApplicationCacheHostClient* client);
481 virtual WebKit::WebCookieJar* cookieJar(WebKit::WebFrame* frame);
482 virtual void frameDetached(WebKit::WebFrame* frame);
483 virtual void willClose(WebKit::WebFrame* frame);
[email protected]6e24cf12011-03-18 19:57:02484 virtual void loadURLExternally(WebKit::WebFrame* frame,
485 const WebKit::WebURLRequest& request,
486 WebKit::WebNavigationPolicy policy);
[email protected]0622875ab2011-07-27 12:10:34487 virtual void loadURLExternally(WebKit::WebFrame* frame,
488 const WebKit::WebURLRequest& request,
489 WebKit::WebNavigationPolicy policy,
490 const WebKit::WebString& suggested_name);
[email protected]6e24cf12011-03-18 19:57:02491 virtual WebKit::WebNavigationPolicy decidePolicyForNavigation(
492 WebKit::WebFrame* frame,
493 const WebKit::WebURLRequest& request,
494 WebKit::WebNavigationType type,
495 const WebKit::WebNode&,
496 WebKit::WebNavigationPolicy default_policy,
497 bool is_redirect);
498 virtual bool canHandleRequest(WebKit::WebFrame* frame,
499 const WebKit::WebURLRequest& request);
500 virtual WebKit::WebURLError cannotHandleRequestError(
501 WebKit::WebFrame* frame,
502 const WebKit::WebURLRequest& request);
503 virtual WebKit::WebURLError cancelledError(
504 WebKit::WebFrame* frame,
505 const WebKit::WebURLRequest& request);
506 virtual void unableToImplementPolicyWithError(
507 WebKit::WebFrame* frame,
508 const WebKit::WebURLError& error);
509 virtual void willSendSubmitEvent(WebKit::WebFrame* frame,
510 const WebKit::WebFormElement& form);
511 virtual void willSubmitForm(WebKit::WebFrame* frame,
512 const WebKit::WebFormElement& form);
513 virtual void willPerformClientRedirect(WebKit::WebFrame* frame,
514 const WebKit::WebURL& from,
515 const WebKit::WebURL& to,
516 double interval,
517 double fire_time);
518 virtual void didCancelClientRedirect(WebKit::WebFrame* frame);
519 virtual void didCompleteClientRedirect(WebKit::WebFrame* frame,
520 const WebKit::WebURL& from);
521 virtual void didCreateDataSource(WebKit::WebFrame* frame,
522 WebKit::WebDataSource* datasource);
523 virtual void didStartProvisionalLoad(WebKit::WebFrame* frame);
524 virtual void didReceiveServerRedirectForProvisionalLoad(
525 WebKit::WebFrame* frame);
526 virtual void didFailProvisionalLoad(WebKit::WebFrame* frame,
527 const WebKit::WebURLError& error);
528 virtual void didReceiveDocumentData(WebKit::WebFrame* frame,
529 const char* data, size_t length,
530 bool& prevent_default);
531 virtual void didCommitProvisionalLoad(WebKit::WebFrame* frame,
532 bool is_new_navigation);
533 virtual void didClearWindowObject(WebKit::WebFrame* frame);
534 virtual void didCreateDocumentElement(WebKit::WebFrame* frame);
535 virtual void didReceiveTitle(WebKit::WebFrame* frame,
[email protected]a3bc4d12011-04-20 17:22:21536 const WebKit::WebString& title,
537 WebKit::WebTextDirection direction);
[email protected]42054a252011-05-17 18:02:13538 virtual void didChangeIcon(WebKit::WebFrame*,
539 WebKit::WebIconURL::Type) OVERRIDE;
[email protected]6e24cf12011-03-18 19:57:02540 virtual void didFinishDocumentLoad(WebKit::WebFrame* frame);
541 virtual void didHandleOnloadEvents(WebKit::WebFrame* frame);
542 virtual void didFailLoad(WebKit::WebFrame* frame,
543 const WebKit::WebURLError& error);
544 virtual void didFinishLoad(WebKit::WebFrame* frame);
545 virtual void didNavigateWithinPage(WebKit::WebFrame* frame,
546 bool is_new_navigation);
547 virtual void didUpdateCurrentHistoryItem(WebKit::WebFrame* frame);
548 virtual void assignIdentifierToRequest(WebKit::WebFrame* frame,
549 unsigned identifier,
550 const WebKit::WebURLRequest& request);
551 virtual void willSendRequest(WebKit::WebFrame* frame,
552 unsigned identifier,
553 WebKit::WebURLRequest& request,
554 const WebKit::WebURLResponse& redirect_response);
555 virtual void didReceiveResponse(WebKit::WebFrame* frame,
556 unsigned identifier,
557 const WebKit::WebURLResponse& response);
558 virtual void didFinishResourceLoad(WebKit::WebFrame* frame,
559 unsigned identifier);
560 virtual void didFailResourceLoad(WebKit::WebFrame* frame,
561 unsigned identifier,
562 const WebKit::WebURLError& error);
563 virtual void didLoadResourceFromMemoryCache(
564 WebKit::WebFrame* frame,
565 const WebKit::WebURLRequest& request,
566 const WebKit::WebURLResponse&);
567 virtual void didDisplayInsecureContent(WebKit::WebFrame* frame);
568 virtual void didRunInsecureContent(
569 WebKit::WebFrame* frame,
570 const WebKit::WebSecurityOrigin& origin,
571 const WebKit::WebURL& target);
[email protected]b00ba702011-08-17 01:41:03572 virtual void didAdoptURLLoader(WebKit::WebURLLoader* loader);
[email protected]6e24cf12011-03-18 19:57:02573 virtual void didExhaustMemoryAvailableForScript(WebKit::WebFrame* frame);
[email protected]5bc10932011-09-21 21:03:30574 virtual void didCreateScriptContext(WebKit::WebFrame* frame,
575 v8::Handle<v8::Context>,
576 int world_id);
577 virtual void willReleaseScriptContext(WebKit::WebFrame* frame,
578 v8::Handle<v8::Context>,
579 int world_id);
[email protected]d812fd12011-05-27 23:05:07580 virtual void didUpdateLayout(WebKit::WebFrame* frame);
[email protected]6e24cf12011-03-18 19:57:02581 virtual void didChangeScrollOffset(WebKit::WebFrame* frame);
[email protected]dd6afca2011-08-13 03:44:31582 virtual void numberOfWheelEventHandlersChanged(unsigned num_handlers);
583 virtual void didChangeContentsSize(WebKit::WebFrame* frame,
584 const WebKit::WebSize& size);
[email protected]6e24cf12011-03-18 19:57:02585 virtual void reportFindInPageMatchCount(int request_id,
586 int count,
587 bool final_update);
588 virtual void reportFindInPageSelection(int request_id,
589 int active_match_ordinal,
590 const WebKit::WebRect& sel);
591
592 virtual void openFileSystem(WebKit::WebFrame* frame,
593 WebKit::WebFileSystem::Type type,
594 long long size,
595 bool create,
596 WebKit::WebFileSystemCallbacks* callbacks);
597
[email protected]10e5cf12011-04-13 04:10:40598 virtual void queryStorageUsageAndQuota(
599 WebKit::WebFrame* frame,
600 WebKit::WebStorageQuotaType type,
601 WebKit::WebStorageQuotaCallbacks* callbacks);
602
603 virtual void requestStorageQuota(
604 WebKit::WebFrame* frame,
605 WebKit::WebStorageQuotaType type,
606 unsigned long long requested_size,
607 WebKit::WebStorageQuotaCallbacks* callbacks);
608
[email protected]18d5be92011-07-25 18:00:19609 // WebKit::WebPageSerializerClient implementation ----------------------------
610
611 virtual void didSerializeDataForFrame(
612 const WebKit::WebURL& frame_url,
613 const WebKit::WebCString& data,
614 PageSerializationStatus status) OVERRIDE;
615
[email protected]6e24cf12011-03-18 19:57:02616 // webkit_glue::WebPluginPageDelegate implementation -------------------------
617
618 virtual webkit::npapi::WebPluginDelegate* CreatePluginDelegate(
619 const FilePath& file_path,
620 const std::string& mime_type);
621 virtual void CreatedPluginWindow(gfx::PluginWindowHandle handle);
622 virtual void WillDestroyPluginWindow(gfx::PluginWindowHandle handle);
623 virtual void DidMovePlugin(const webkit::npapi::WebPluginGeometry& move);
624 virtual void DidStartLoadingForPlugin();
625 virtual void DidStopLoadingForPlugin();
626 virtual WebKit::WebCookieJar* GetCookieJar();
627
628 // Please do not add your stuff randomly to the end here. If there is an
629 // appropriate section, add it there. If not, there are some random functions
630 // nearer to the top you can add it to.
[email protected]6e24cf12011-03-18 19:57:02631 virtual void DidFlushPaint();
632
[email protected]38b592902011-04-16 02:08:42633 // Cannot use std::set unfortunately since linked_ptr<> does not support
634 // operator<.
635 typedef std::vector<linked_ptr<webkit_glue::ImageResourceFetcher> >
636 ImageResourceFetcherList;
637
[email protected]6e24cf12011-03-18 19:57:02638 protected:
639 // RenderWidget overrides:
640 virtual void Close();
641 virtual void OnResize(const gfx::Size& new_size,
642 const gfx::Rect& resizer_rect);
643 virtual void DidInitiatePaint();
644 virtual webkit::ppapi::PluginInstance* GetBitmapForOptimizedPluginPaint(
645 const gfx::Rect& paint_bounds,
646 TransportDIB** dib,
647 gfx::Rect* location,
648 gfx::Rect* clip);
649 virtual gfx::Point GetScrollOffset();
650 virtual void DidHandleKeyEvent();
651 virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event);
652 virtual void OnSetFocus(bool enable);
653 virtual void OnWasHidden();
654 virtual void OnWasRestored(bool needs_repainting);
[email protected]65225772011-05-12 21:10:24655 virtual bool SupportsAsynchronousSwapBuffers() OVERRIDE;
[email protected]56ea1a62011-05-30 07:05:57656 virtual void OnImeSetComposition(
657 const string16& text,
658 const std::vector<WebKit::WebCompositionUnderline>& underlines,
659 int selection_start,
660 int selection_end) OVERRIDE;
661 virtual void OnImeConfirmComposition(const string16& text) OVERRIDE;
[email protected]ad26ef42011-06-17 07:59:45662 virtual ui::TextInputType GetTextInputType() OVERRIDE;
663 virtual bool CanComposeInline() OVERRIDE;
[email protected]6e24cf12011-03-18 19:57:02664
665 private:
[email protected]6e24cf12011-03-18 19:57:02666 // For unit tests.
667 friend class ExternalPopupMenuTest;
668 friend class PepperDeviceTest;
669 friend class RenderViewTest;
670
671 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuRemoveTest, RemoveOnChange);
672 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, NormalCase);
673 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, ShowPopupThenNavigate);
[email protected]9978b8f02011-08-13 16:17:44674 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, DontIgnoreBackAfterNavEntryLimit);
[email protected]6e24cf12011-03-18 19:57:02675 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, ImeComposition);
676 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, InsertCharacters);
677 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, JSBlockSentAfterPageLoad);
678 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, LastCommittedUpdateState);
679 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnHandleKeyboardEvent);
680 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnImeStateChanged);
681 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnNavStateChanged);
[email protected]6e24cf12011-03-18 19:57:02682 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnSetTextDirection);
[email protected]678e68a2011-09-01 15:23:56683 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnUpdateWebPreferences);
[email protected]d466b8a2011-07-15 21:48:03684 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, StaleNavigationsIgnored);
[email protected]6e24cf12011-03-18 19:57:02685 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, UpdateTargetURLWithInvalidURL);
686#if defined(OS_MACOSX)
687 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, MacTestCmdUp);
688#endif
[email protected]9e1ad4b2011-08-14 16:49:19689 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, SetHistoryLengthAndPrune);
[email protected]6e24cf12011-03-18 19:57:02690
[email protected]6e24cf12011-03-18 19:57:02691 typedef std::map<GURL, double> HostZoomLevels;
692
[email protected]6e24cf12011-03-18 19:57:02693 // Identifies an accessibility notification from webkit.
694 struct RendererAccessibilityNotification {
695 public:
696 bool ShouldIncludeChildren();
697
698 // The webkit glue id of the accessibility object.
699 int32 id;
700
701 // The accessibility notification type.
702 WebKit::WebAccessibilityNotification type;
703 };
704
705 enum ErrorPageType {
706 DNS_ERROR,
707 HTTP_404,
708 CONNECTION_ERROR,
709 };
710
711 RenderView(RenderThreadBase* render_thread,
712 gfx::NativeViewId parent_hwnd,
713 int32 opener_id,
714 const RendererPreferences& renderer_prefs,
715 const WebPreferences& webkit_prefs,
716 SharedRenderViewCounter* counter,
717 int32 routing_id,
718 int64 session_storage_namespace_id,
719 const string16& frame_name);
720
721 // Do not delete directly. This class is reference counted.
722 virtual ~RenderView();
723
724 void UpdateURL(WebKit::WebFrame* frame);
[email protected]a49e10b2011-08-01 23:57:46725 void UpdateTitle(WebKit::WebFrame* frame, const string16& title,
726 WebKit::WebTextDirection title_direction);
[email protected]6e24cf12011-03-18 19:57:02727 void UpdateSessionHistory(WebKit::WebFrame* frame);
728
729 // Update current main frame's encoding and send it to browser window.
730 // Since we want to let users see the right encoding info from menu
731 // before finishing loading, we call the UpdateEncoding in
732 // a) function:DidCommitLoadForFrame. When this function is called,
733 // that means we have got first data. In here we try to get encoding
734 // of page if it has been specified in http header.
735 // b) function:DidReceiveTitle. When this function is called,
736 // that means we have got specified title. Because in most of webpages,
737 // title tags will follow meta tags. In here we try to get encoding of
738 // page if it has been specified in meta tag.
739 // c) function:DidFinishDocumentLoadForFrame. When this function is
740 // called, that means we have got whole html page. In here we should
741 // finally get right encoding of page.
742 void UpdateEncoding(WebKit::WebFrame* frame,
743 const std::string& encoding_name);
744
745 void OpenURL(const GURL& url, const GURL& referrer,
746 WebKit::WebNavigationPolicy policy);
747
[email protected]6e24cf12011-03-18 19:57:02748 bool RunJavaScriptMessage(int type,
[email protected]4f5ce842011-05-27 19:34:41749 const string16& message,
750 const string16& default_value,
[email protected]6e24cf12011-03-18 19:57:02751 const GURL& frame_url,
[email protected]4f5ce842011-05-27 19:34:41752 string16* result);
[email protected]6e24cf12011-03-18 19:57:02753
754 // Sends a message and runs a nested message loop.
755 bool SendAndRunNestedMessageLoop(IPC::SyncMessage* message);
756
[email protected]6e24cf12011-03-18 19:57:02757 // Send queued accessibility notifications from the renderer to the browser.
758 void SendPendingAccessibilityNotifications();
759
[email protected]dd6afca2011-08-13 03:44:31760 // Called when the "pinned to left/right edge" state needs to be updated.
761 void UpdateScrollState(WebKit::WebFrame* frame);
762
[email protected]6e24cf12011-03-18 19:57:02763 // IPC message handlers ------------------------------------------------------
764 //
765 // The documentation for these functions should be in
766 // render_messages_internal.h for the message that the function is handling.
767
768 void OnAccessibilityDoDefaultAction(int acc_obj_id);
769 void OnAccessibilityNotificationsAck();
770 void OnAllowBindings(int enabled_bindings_flags);
[email protected]6e24cf12011-03-18 19:57:02771 void OnAllowScriptToClose(bool script_can_close);
772 void OnAsyncFileOpened(base::PlatformFileError error_code,
773 IPC::PlatformFileForTransit file_for_transit,
774 int message_id);
[email protected]eb415bf0e2011-04-14 02:45:42775 void OnPpapiBrokerChannelCreated(int request_id,
[email protected]2b657fd2011-04-18 16:00:47776 base::ProcessHandle broker_process_handle,
[email protected]d54305072011-06-22 20:58:43777 const IPC::ChannelHandle& handle);
[email protected]6e24cf12011-03-18 19:57:02778 void OnCancelDownload(int32 download_id);
779 void OnClearFocusedNode();
[email protected]992db4c2011-05-12 15:37:15780 void OnClosePage();
[email protected]6e24cf12011-03-18 19:57:02781#if defined(ENABLE_FLAPPER_HACKS)
782 void OnConnectTcpACK(int request_id,
783 IPC::PlatformFileForTransit socket_for_transit,
784 const PP_Flash_NetAddress& local_addr,
785 const PP_Flash_NetAddress& remote_addr);
786#endif
787 void OnContextMenuClosed(
788 const webkit_glue::CustomContextMenuContext& custom_context);
789 void OnCopy();
790 void OnCopyImageAt(int x, int y);
791#if defined(OS_MACOSX)
792 void OnCopyToFindPboard();
793#endif
794 void OnCut();
[email protected]318bf5802011-08-08 17:12:41795 void OnCSSInsertRequest(const string16& frame_xpath,
[email protected]01cf589c2011-07-28 18:04:03796 const std::string& css);
[email protected]6e24cf12011-03-18 19:57:02797 void OnCustomContextMenuAction(
798 const webkit_glue::CustomContextMenuContext& custom_context,
799 unsigned action);
800 void OnDelete();
801 void OnDeterminePageLanguage();
802 void OnDisableScrollbarsForSmallWindows(
803 const gfx::Size& disable_scrollbars_size_limit);
804 void OnDisassociateFromPopupCount();
[email protected]6e24cf12011-03-18 19:57:02805 void OnDragSourceEndedOrMoved(const gfx::Point& client_point,
806 const gfx::Point& screen_point,
807 bool ended,
808 WebKit::WebDragOperation drag_operation);
809 void OnDragSourceSystemDragEnded();
810 void OnDragTargetDrop(const gfx::Point& client_pt,
811 const gfx::Point& screen_pt);
812 void OnDragTargetDragEnter(const WebDropData& drop_data,
813 const gfx::Point& client_pt,
814 const gfx::Point& screen_pt,
815 WebKit::WebDragOperationsMask operations_allowed);
816 void OnDragTargetDragLeave();
817 void OnDragTargetDragOver(const gfx::Point& client_pt,
818 const gfx::Point& screen_pt,
819 WebKit::WebDragOperationsMask operations_allowed);
820 void OnEnablePreferredSizeChangedMode(int flags);
[email protected]600ea402011-04-12 00:01:51821 void OnEnumerateDirectoryResponse(int id, const std::vector<FilePath>& paths);
[email protected]6e24cf12011-03-18 19:57:02822 void OnExecuteEditCommand(const std::string& name, const std::string& value);
[email protected]6e24cf12011-03-18 19:57:02823 void OnFileChooserResponse(const std::vector<FilePath>& paths);
824 void OnFind(int request_id, const string16&, const WebKit::WebFindOptions&);
825 void OnFindReplyAck();
826 void OnEnableAccessibility();
[email protected]18d5be92011-07-25 18:00:19827 void OnGetAllSavableResourceLinksForCurrentPage(const GURL& page_url);
828 void OnGetSerializedHtmlDataForCurrentPageWithLocalLinks(
829 const std::vector<GURL>& links,
830 const std::vector<FilePath>& local_paths,
831 const FilePath& local_directory_name);
[email protected]6e24cf12011-03-18 19:57:02832 void OnMediaPlayerActionAt(const gfx::Point& location,
833 const WebKit::WebMediaPlayerAction& action);
834 void OnMoveOrResizeStarted();
835 void OnNavigate(const ViewMsg_Navigate_Params& params);
[email protected]6e24cf12011-03-18 19:57:02836 void OnPaste();
837#if defined(OS_MACOSX)
838 void OnPluginImeCompositionCompleted(const string16& text, int plugin_id);
839#endif
840 void OnRedo();
841 void OnReloadFrame();
842 void OnReplace(const string16& text);
843 void OnReservePageIDRange(int size_of_range);
844 void OnResetPageEncodingToDefault();
845 void OnScriptEvalRequest(const string16& frame_xpath,
846 const string16& jscript,
847 int id,
848 bool notify_result);
849 void OnSelectAll();
[email protected]4fb60142011-08-09 02:22:08850 void OnSelectRange(const gfx::Point& start, const gfx::Point& end);
[email protected]6e24cf12011-03-18 19:57:02851 void OnSetAccessibilityFocus(int acc_obj_id);
852 void OnSetActive(bool active);
853 void OnSetAltErrorPageURL(const GURL& gurl);
854 void OnSetBackground(const SkBitmap& background);
[email protected]6e24cf12011-03-18 19:57:02855 void OnSetWebUIProperty(const std::string& name, const std::string& value);
856 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
[email protected]9e1ad4b2011-08-14 16:49:19857 void OnSetHistoryLengthAndPrune(int history_length, int32 minimum_page_id);
[email protected]6e24cf12011-03-18 19:57:02858 void OnSetInitialFocus(bool reverse);
[email protected]54ca3ca892011-06-07 21:14:54859#if defined(OS_MACOSX)
860 void OnSetInLiveResize(bool in_live_resize);
861#endif
[email protected]333ec8d02011-09-16 18:59:19862 void OnScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect);
[email protected]6e24cf12011-03-18 19:57:02863 void OnSetPageEncoding(const std::string& encoding_name);
864 void OnSetRendererPrefs(const RendererPreferences& renderer_prefs);
[email protected]6e24cf12011-03-18 19:57:02865#if defined(OS_MACOSX)
866 void OnSetWindowVisibility(bool visible);
867#endif
868 void OnSetZoomLevel(double zoom_level);
869 void OnSetZoomLevelForLoadingURL(const GURL& url, double zoom_level);
[email protected]8a5e0ca2011-08-25 06:30:47870 void OnExitFullscreen();
[email protected]6e24cf12011-03-18 19:57:02871 void OnShouldClose();
872 void OnStop();
873 void OnStopFinding(const ViewMsg_StopFinding_Params& params);
[email protected]992db4c2011-05-12 15:37:15874 void OnSwapOut(const ViewMsg_SwapOut_Params& params);
[email protected]6e24cf12011-03-18 19:57:02875 void OnThemeChanged();
[email protected]6e24cf12011-03-18 19:57:02876 void OnUndo();
[email protected]6e24cf12011-03-18 19:57:02877 void OnUpdateTargetURLAck();
878 void OnUpdateWebPreferences(const WebPreferences& prefs);
[email protected]08bb1e722011-07-30 19:13:04879 void OnUpdateRemoteAccessClientFirewallTraversal(const std::string& policy);
880
[email protected]6e24cf12011-03-18 19:57:02881#if defined(OS_MACOSX)
882 void OnWindowFrameChanged(const gfx::Rect& window_frame,
883 const gfx::Rect& view_frame);
884 void OnSelectPopupMenuItem(int selected_index);
885#endif
886 void OnZoom(PageZoom::Function function);
[email protected]5a7b15a2011-08-22 22:48:18887 void OnEnableViewSourceMode();
[email protected]6e24cf12011-03-18 19:57:02888
889 // Adding a new message handler? Please add it in alphabetical order above
890 // and put it in the same position in the .cc file.
891
892 // Misc private functions ----------------------------------------------------
893
[email protected]6e24cf12011-03-18 19:57:02894 void AltErrorPageFinished(WebKit::WebFrame* frame,
895 const WebKit::WebURLError& original_error,
896 const std::string& html);
897
[email protected]d812fd12011-05-27 23:05:07898 // Check whether the preferred size has changed.
[email protected]6e24cf12011-03-18 19:57:02899 void CheckPreferredSize();
900
[email protected]5e56df82011-04-18 17:00:15901 // This callback is triggered when DownloadFavicon completes, either
902 // succesfully or with a failure. See DownloadFavicon for more
903 // details.
904 void DidDownloadFavicon(webkit_glue::ImageResourceFetcher* fetcher,
905 const SkBitmap& image);
[email protected]6e24cf12011-03-18 19:57:02906
[email protected]5e56df82011-04-18 17:00:15907 // Requests to download a favicon image. When done, the RenderView
908 // is notified by way of DidDownloadFavicon. Returns true if the
909 // request was successfully started, false otherwise. id is used to
910 // uniquely identify the request and passed back to the
911 // DidDownloadFavicon method. If the image has multiple frames, the
912 // frame whose size is image_size is returned. If the image doesn't
913 // have a frame at the specified size, the first is returned.
914 bool DownloadFavicon(int id, const GURL& image_url, int image_size);
[email protected]6e24cf12011-03-18 19:57:02915
[email protected]6e24cf12011-03-18 19:57:02916 GURL GetAlternateErrorPageURL(const GURL& failed_url,
917 ErrorPageType error_type);
918
919 // Locates a sub frame with given xpath
[email protected]318bf5802011-08-08 17:12:41920 WebKit::WebFrame* GetChildFrame(const string16& frame_xpath) const;
[email protected]6e24cf12011-03-18 19:57:02921
[email protected]6e24cf12011-03-18 19:57:02922 WebUIBindings* GetWebUIBindings();
923
[email protected]6e24cf12011-03-18 19:57:02924 // Should only be called if this object wraps a PluginDocument.
925 WebKit::WebPlugin* GetWebPluginFromPluginDocument();
926
[email protected]d466b8a2011-07-15 21:48:03927 // Returns true if the |params| navigation is to an entry that has been
928 // cropped due to a recent navigation the browser did not know about.
929 bool IsBackForwardToStaleEntry(const ViewMsg_Navigate_Params& params,
930 bool is_reload);
931
[email protected]6e24cf12011-03-18 19:57:02932 // Returns false unless this is a top-level navigation that crosses origins.
933 bool IsNonLocalTopLevelNavigation(const GURL& url,
934 WebKit::WebFrame* frame,
935 WebKit::WebNavigationType type);
936
[email protected]6e24cf12011-03-18 19:57:02937 bool MaybeLoadAlternateErrorPage(WebKit::WebFrame* frame,
938 const WebKit::WebURLError& error,
939 bool replace);
940
941 // Starts nav_state_sync_timer_ if it isn't already running.
942 void StartNavStateSyncTimerIfNecessary();
943
944 // Dispatches the current navigation state to the browser. Called on a
945 // periodic timer so we don't send too many messages.
946 void SyncNavigationState();
947
[email protected]b781ff282011-08-20 06:19:36948 // Dispatches the current state of selection on the webpage to the browser if
949 // it has changed.
950 // TODO(varunjain): delete this method once we figure out how to keep
951 // selection handles in sync with the webpage.
952 void SyncSelectionIfRequired();
953
[email protected]e63c4d72011-05-31 22:38:29954#if defined(OS_POSIX) && !defined(OS_MACOSX)
[email protected]6e24cf12011-03-18 19:57:02955 void UpdateFontRenderingFromRendererPrefs();
956#else
957 void UpdateFontRenderingFromRendererPrefs() {}
958#endif
959
960 // Update the target url and tell the browser that the target URL has changed.
961 // If |url| is empty, show |fallback_url|.
962 void UpdateTargetURL(const GURL& url, const GURL& fallback_url);
963
[email protected]6e24cf12011-03-18 19:57:02964 // ---------------------------------------------------------------------------
965 // ADDING NEW FUNCTIONS? Please keep private functions alphabetized and put
966 // it in the same order in the .cc file as it was in the header.
967 // ---------------------------------------------------------------------------
968
969 // Settings ------------------------------------------------------------------
970
971 WebPreferences webkit_preferences_;
972 RendererPreferences renderer_preferences_;
973
[email protected]6e24cf12011-03-18 19:57:02974 HostZoomLevels host_zoom_levels_;
975
976 // Whether content state (such as form state, scroll position and page
977 // contents) should be sent to the browser immediately. This is normally
978 // false, but set to true by some tests.
979 bool send_content_state_immediately_;
980
[email protected]6e24cf12011-03-18 19:57:02981 // Bitwise-ORed set of extra bindings that have been enabled. See
982 // BindingsPolicy for details.
983 int enabled_bindings_;
984
985 // The alternate error page URL, if one exists.
986 GURL alternate_error_page_url_;
987
988 // If true, we send IPC messages when |preferred_size_| changes.
989 bool send_preferred_size_changes_;
990
991 // If non-empty, and |send_preferred_size_changes_| is true, disable drawing
992 // scroll bars on windows smaller than this size. Used for windows that the
993 // browser resizes to the size of the content, such as browser action popups.
994 // If a render view is set to the minimum size of its content, webkit may add
995 // scroll bars. This makes sense for fixed sized windows, but it does not
996 // make sense when the size of the view was chosen to fit the content.
997 // This setting ensures that no scroll bars are drawn. The size limit exists
998 // because if the view grows beyond a size known to the browser, scroll bars
999 // should be drawn.
1000 gfx::Size disable_scrollbars_size_limit_;
1001
[email protected]6e24cf12011-03-18 19:57:021002 // Loading state -------------------------------------------------------------
1003
1004 // True if the top level frame is currently being loaded.
1005 bool is_loading_;
1006
1007 // The gesture that initiated the current navigation.
1008 NavigationGesture navigation_gesture_;
1009
1010 // Used for popups.
1011 bool opened_by_user_gesture_;
1012 GURL creator_url_;
1013
1014 // Whether this RenderView was created by a frame that was suppressing its
1015 // opener. If so, we may want to load pages in a separate process. See
1016 // decidePolicyForNavigation for details.
1017 bool opener_suppressed_;
1018
1019 // If we are handling a top-level client-side redirect, this tracks the URL
1020 // of the page that initiated it. Specifically, when a load is committed this
1021 // is used to determine if that load originated from a client-side redirect.
1022 // It is empty if there is no top-level client-side redirect.
1023 GURL completed_client_redirect_src_;
1024
[email protected]6e24cf12011-03-18 19:57:021025 // Holds state pertaining to a navigation that we initiated. This is held by
1026 // the WebDataSource::ExtraData attribute. We use pending_navigation_state_
1027 // as a temporary holder for the state until the WebDataSource corresponding
1028 // to the new navigation is created. See DidCreateDataSource.
1029 scoped_ptr<NavigationState> pending_navigation_state_;
1030
1031 // Timer used to delay the updating of nav state (see SyncNavigationState).
1032 base::OneShotTimer<RenderView> nav_state_sync_timer_;
1033
[email protected]6e24cf12011-03-18 19:57:021034 // Page IDs ------------------------------------------------------------------
1035 //
1036 // Page IDs allow the browser to identify pages in each renderer process for
1037 // keeping back/forward history in sync.
1038
1039 // ID of the current page. Note that this is NOT updated for every main
1040 // frame navigation, only for "regular" navigations that go into session
1041 // history. In particular, client redirects, like the page cycler uses
1042 // (document.location.href="foo") do not count as regular navigations and do
1043 // not increment the page id.
1044 int32 page_id_;
1045
1046 // Indicates the ID of the last page that we sent a FrameNavigate to the
1047 // browser for. This is used to determine if the most recent transition
1048 // generated a history entry (less than page_id_), or not (equal to or
1049 // greater than). Note that this will be greater than page_id_ if the user
1050 // goes back.
1051 int32 last_page_id_sent_to_browser_;
1052
[email protected]6e24cf12011-03-18 19:57:021053 // The next available page ID to use. This ensures that the page IDs are
1054 // globally unique in the renderer.
1055 static int32 next_page_id_;
1056
[email protected]d466b8a2011-07-15 21:48:031057 // The offset of the current item in the history list.
1058 int history_list_offset_;
1059
1060 // The RenderView's current impression of the history length. This includes
1061 // any items that have committed in this process, but because of cross-process
1062 // navigations, the history may have some entries that were committed in other
1063 // processes. We won't know about them until the next navigation in this
1064 // process.
1065 int history_list_length_;
1066
1067 // The list of page IDs for each history item this RenderView knows about.
1068 // Some entries may be -1 if they were rendered by other processes or were
1069 // restored from a previous session. This lets us detect attempts to
1070 // navigate to stale entries that have been cropped from our history.
1071 std::vector<int32> history_page_ids_;
1072
[email protected]6e24cf12011-03-18 19:57:021073 // Page info -----------------------------------------------------------------
1074
1075 // The last gotten main frame's encoding.
1076 std::string last_encoding_name_;
1077
[email protected]6e24cf12011-03-18 19:57:021078 // UI state ------------------------------------------------------------------
1079
1080 // The state of our target_url transmissions. When we receive a request to
1081 // send a URL to the browser, we set this to TARGET_INFLIGHT until an ACK
1082 // comes back - if a new request comes in before the ACK, we store the new
1083 // URL in pending_target_url_ and set the status to TARGET_PENDING. If an
1084 // ACK comes back and we are in TARGET_PENDING, we send the stored URL and
1085 // revert to TARGET_INFLIGHT.
1086 //
1087 // We don't need a queue of URLs to send, as only the latest is useful.
1088 enum {
1089 TARGET_NONE,
1090 TARGET_INFLIGHT, // We have a request in-flight, waiting for an ACK
1091 TARGET_PENDING // INFLIGHT + we have a URL waiting to be sent
1092 } target_url_status_;
1093
1094 // The URL we show the user in the status bar. We use this to determine if we
1095 // want to send a new one (we do not need to send duplicates). It will be
1096 // equal to either |mouse_over_url_| or |focus_url_|, depending on which was
1097 // updated last.
1098 GURL target_url_;
1099
1100 // The URL the user's mouse is hovering over.
1101 GURL mouse_over_url_;
1102
1103 // The URL that has keyboard focus.
1104 GURL focus_url_;
1105
1106 // The next target URL we want to send to the browser.
1107 GURL pending_target_url_;
1108
[email protected]6e24cf12011-03-18 19:57:021109 // The text selection the last time DidChangeSelection got called.
[email protected]b781ff282011-08-20 06:19:361110 RenderViewSelection last_selection_;
[email protected]6e24cf12011-03-18 19:57:021111
1112 // View ----------------------------------------------------------------------
1113
[email protected]6e24cf12011-03-18 19:57:021114 // Cache the preferred size of the page in order to prevent sending the IPC
1115 // when layout() recomputes but doesn't actually change sizes.
1116 gfx::Size preferred_size_;
1117
[email protected]1e0c8e02011-05-25 07:49:371118 // Used to delay determining the preferred size (to avoid intermediate
1119 // states for the sizes).
1120 base::OneShotTimer<RenderView> check_preferred_size_timer_;
1121
[email protected]dd6afca2011-08-13 03:44:311122 // These store the "is main frame is scrolled all the way to the left
1123 // or right" state that was last sent to the browser.
1124 bool cached_is_main_frame_pinned_to_left_;
1125 bool cached_is_main_frame_pinned_to_right_;
1126
1127 // These store the "has scrollbars" state last sent to the browser.
1128 bool cached_has_main_frame_horizontal_scrollbar_;
1129 bool cached_has_main_frame_vertical_scrollbar_;
1130
[email protected]6e24cf12011-03-18 19:57:021131#if defined(OS_MACOSX)
1132 // Track the fake plugin window handles allocated on the browser side for
1133 // the accelerated compositor and (currently) accelerated plugins so that
1134 // we can discard them when the view goes away.
1135 std::set<gfx::PluginWindowHandle> fake_plugin_window_handles_;
1136#endif
1137
1138 // Plugins -------------------------------------------------------------------
1139
[email protected]6e24cf12011-03-18 19:57:021140 PepperPluginDelegateImpl pepper_delegate_;
1141
1142 // All the currently active plugin delegates for this RenderView; kept so that
1143 // we can enumerate them to send updates about things like window location
1144 // or tab focus and visibily. These are non-owning references.
1145 std::set<WebPluginDelegateProxy*> plugin_delegates_;
1146
1147 // Helper objects ------------------------------------------------------------
1148
[email protected]6e24cf12011-03-18 19:57:021149 ScopedRunnableMethodFactory<RenderView> accessibility_method_factory_;
1150
1151 RendererWebCookieJarImpl cookie_jar_;
1152
1153 // The next group of objects all implement RenderViewObserver, so are deleted
1154 // along with the RenderView automatically. This is why we just store weak
1155 // references.
1156
[email protected]6e24cf12011-03-18 19:57:021157 // Holds a reference to the service which provides desktop notifications.
1158 NotificationProvider* notification_provider_;
1159
1160 // The geolocation dispatcher attached to this view, lazily initialized.
1161 GeolocationDispatcher* geolocation_dispatcher_;
1162
[email protected]1ef93132011-09-16 18:33:471163 // The intents dispatcher attached to this view. Not lazily initialized.
1164 IntentsDispatcher* intents_dispatcher_;
1165
[email protected]6e24cf12011-03-18 19:57:021166 // The speech dispatcher attached to this view, lazily initialized.
1167 SpeechInputDispatcher* speech_input_dispatcher_;
1168
1169 // Device orientation dispatcher attached to this view; lazily initialized.
1170 DeviceOrientationDispatcher* device_orientation_dispatcher_;
1171
[email protected]ab2c4732011-07-20 19:57:401172 // MediaStreamImpl attached to this view; lazily initialized.
1173 scoped_refptr<MediaStreamImpl> media_stream_impl_;
1174
[email protected]6e24cf12011-03-18 19:57:021175 // Handles accessibility requests into the renderer side, as well as
1176 // maintains the cache and other features of the accessibility tree.
1177 scoped_ptr<WebKit::WebAccessibilityCache> accessibility_;
1178
1179 // Collect renderer accessibility notifications until they are ready to be
1180 // sent to the browser.
1181 std::vector<RendererAccessibilityNotification>
1182 pending_accessibility_notifications_;
1183
1184 // Set if we are waiting for a accessibility notification ack.
1185 bool accessibility_ack_pending_;
1186
[email protected]ee845122011-09-01 08:44:161187 // True if verbose logging of accessibility events is on.
1188 bool accessibility_logging_;
1189
[email protected]6e24cf12011-03-18 19:57:021190 // Dispatches all P2P socket used by the renderer.
[email protected]b3f8f9722011-08-25 20:56:071191 content::P2PSocketDispatcher* p2p_socket_dispatcher_;
[email protected]6e24cf12011-03-18 19:57:021192
[email protected]c5c1d6d2011-07-28 18:42:411193 DevToolsAgent* devtools_agent_;
1194
[email protected]6e24cf12011-03-18 19:57:021195 // Misc ----------------------------------------------------------------------
1196
1197 // The current and pending file chooser completion objects. If the queue is
1198 // nonempty, the first item represents the currently running file chooser
1199 // callback, and the remaining elements are the other file chooser completion
1200 // still waiting to be run (in order).
1201 struct PendingFileChooser;
1202 std::deque< linked_ptr<PendingFileChooser> > file_chooser_completions_;
1203
[email protected]600ea402011-04-12 00:01:511204 // The current directory enumeration callback
1205 std::map<int, WebKit::WebFileChooserCompletion*> enumeration_completions_;
1206 int enumeration_completion_id_;
1207
[email protected]6e24cf12011-03-18 19:57:021208 // The SessionStorage namespace that we're assigned to has an ID, and that ID
1209 // is passed to us upon creation. WebKit asks for this ID upon first use and
1210 // uses it whenever asking the browser process to allocate new storage areas.
1211 int64 session_storage_namespace_id_;
1212
1213 // The total number of unrequested popups that exist and can be followed back
1214 // to a common opener. This count is shared among all RenderViews created
1215 // with createView(). All popups are treated as unrequested until
1216 // specifically instructed otherwise by the Browser process.
1217 scoped_refptr<SharedRenderViewCounter> shared_popup_counter_;
1218
1219 // Whether this is a top level window (instead of a popup). Top level windows
1220 // shouldn't count against their own |shared_popup_counter_|.
1221 bool decrement_shared_popup_at_destruction_;
1222
1223 // If the browser hasn't sent us an ACK for the last FindReply we sent
1224 // to it, then we need to queue up the message (keeping only the most
1225 // recent message if new ones come in).
1226 scoped_ptr<IPC::Message> queued_find_reply_message_;
1227
1228 // Stores edit commands associated to the next key event.
1229 // Shall be cleared as soon as the next key event is processed.
1230 EditCommands edit_commands_;
1231
[email protected]6e24cf12011-03-18 19:57:021232 // Allows Web UI pages (new tab page, etc.) to talk to the browser. The JS
1233 // object is only exposed when Web UI bindings are enabled.
1234 scoped_ptr<WebUIBindings> web_ui_bindings_;
1235
[email protected]6e24cf12011-03-18 19:57:021236 // The external popup for the currently showing select popup.
1237 scoped_ptr<ExternalPopupMenu> external_popup_menu_;
1238
1239 // The node that the context menu was pressed over.
1240 WebKit::WebNode context_menu_node_;
1241
1242 // Reports load progress to the browser.
1243 scoped_ptr<LoadProgressTracker> load_progress_tracker_;
1244
1245 // All the registered observers. We expect this list to be small, so vector
1246 // is fine.
1247 ObserverList<RenderViewObserver> observers_;
1248
[email protected]4fb60142011-08-09 02:22:081249 // Used to inform didChangeSelection() when it is called in the context
1250 // of handling a ViewMsg_SelectRange IPC.
1251 bool handling_select_range_;
1252
[email protected]6e24cf12011-03-18 19:57:021253 // ---------------------------------------------------------------------------
1254 // ADDING NEW DATA? Please see if it fits appropriately in one of the above
1255 // sections rather than throwing it randomly at the end. If you're adding a
1256 // bunch of stuff, you should probably create a helper class and put your
1257 // data and methods on that to avoid bloating RenderView more. You can use
1258 // the Observer interface to filter IPC messages and receive frame change
1259 // notifications.
1260 // ---------------------------------------------------------------------------
1261
1262 DISALLOW_COPY_AND_ASSIGN(RenderView);
1263};
1264
1265#endif // CONTENT_RENDERER_RENDER_VIEW_H_