blob: 65c7fa1b2a67f6423b2e39d87e89b629d0605616 [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
342 // IPC::Channel::Listener implementation -------------------------------------
343
344 virtual bool OnMessageReceived(const IPC::Message& msg);
345
346 // WebKit::WebWidgetClient implementation ------------------------------------
347
348 // Most methods are handled by RenderWidget.
349 virtual void didFocus();
350 virtual void didBlur();
351 virtual void show(WebKit::WebNavigationPolicy policy);
352 virtual void runModal();
353
354 // WebKit::WebViewClient implementation --------------------------------------
355
356 virtual WebKit::WebView* createView(
357 WebKit::WebFrame* creator,
358 const WebKit::WebURLRequest& request,
359 const WebKit::WebWindowFeatures& features,
360 const WebKit::WebString& frame_name);
361 virtual WebKit::WebWidget* createPopupMenu(WebKit::WebPopupType popup_type);
362 virtual WebKit::WebWidget* createPopupMenu(
363 const WebKit::WebPopupMenuInfo& info);
364 virtual WebKit::WebExternalPopupMenu* createExternalPopupMenu(
365 const WebKit::WebPopupMenuInfo& popup_menu_info,
366 WebKit::WebExternalPopupMenuClient* popup_menu_client);
367 virtual WebKit::WebStorageNamespace* createSessionStorageNamespace(
368 unsigned quota);
369 virtual void didAddMessageToConsole(
370 const WebKit::WebConsoleMessage& message,
371 const WebKit::WebString& source_name,
372 unsigned source_line);
373 virtual void printPage(WebKit::WebFrame* frame);
374 virtual WebKit::WebNotificationPresenter* notificationPresenter();
[email protected]8a58c1c2011-04-19 18:40:12375 virtual bool enumerateChosenDirectory(
376 const WebKit::WebString& path,
377 WebKit::WebFileChooserCompletion* chooser_completion);
[email protected]6e24cf12011-03-18 19:57:02378 virtual void didStartLoading();
379 virtual void didStopLoading();
380 virtual void didChangeLoadProgress(WebKit::WebFrame* frame,
381 double load_progress);
382 virtual bool isSmartInsertDeleteEnabled();
383 virtual bool isSelectTrailingWhitespaceEnabled();
384 virtual void didChangeSelection(bool is_selection_empty);
385 virtual void didExecuteCommand(const WebKit::WebString& command_name);
386 virtual bool handleCurrentKeyboardEvent();
[email protected]6e24cf12011-03-18 19:57:02387 virtual bool runFileChooser(
388 const WebKit::WebFileChooserParams& params,
389 WebKit::WebFileChooserCompletion* chooser_completion);
390 virtual void runModalAlertDialog(WebKit::WebFrame* frame,
391 const WebKit::WebString& message);
392 virtual bool runModalConfirmDialog(WebKit::WebFrame* frame,
393 const WebKit::WebString& message);
394 virtual bool runModalPromptDialog(WebKit::WebFrame* frame,
395 const WebKit::WebString& message,
396 const WebKit::WebString& default_value,
397 WebKit::WebString* actual_value);
398 virtual bool runModalBeforeUnloadDialog(WebKit::WebFrame* frame,
399 const WebKit::WebString& message);
400 virtual void showContextMenu(WebKit::WebFrame* frame,
401 const WebKit::WebContextMenuData& data);
402 virtual bool supportsFullscreen();
403 virtual void enterFullscreenForNode(const WebKit::WebNode&);
404 virtual void exitFullscreenForNode(const WebKit::WebNode&);
[email protected]8a5e0ca2011-08-25 06:30:47405 virtual void enterFullscreen() OVERRIDE;
406 virtual void exitFullscreen() OVERRIDE;
[email protected]6e24cf12011-03-18 19:57:02407 virtual void setStatusText(const WebKit::WebString& text);
408 virtual void setMouseOverURL(const WebKit::WebURL& url);
409 virtual void setKeyboardFocusURL(const WebKit::WebURL& url);
[email protected]6e24cf12011-03-18 19:57:02410 virtual void startDragging(const WebKit::WebDragData& data,
411 WebKit::WebDragOperationsMask mask,
412 const WebKit::WebImage& image,
413 const WebKit::WebPoint& imageOffset);
414 virtual bool acceptsLoadDrops();
415 virtual void focusNext();
416 virtual void focusPrevious();
417 virtual void focusedNodeChanged(const WebKit::WebNode& node);
418 virtual void navigateBackForwardSoon(int offset);
419 virtual int historyBackListCount();
420 virtual int historyForwardListCount();
421 virtual void postAccessibilityNotification(
422 const WebKit::WebAccessibilityObject& obj,
423 WebKit::WebAccessibilityNotification notification);
424 virtual void didUpdateInspectorSetting(const WebKit::WebString& key,
425 const WebKit::WebString& value);
426 virtual WebKit::WebGeolocationClient* geolocationClient();
427 virtual WebKit::WebSpeechInputController* speechInputController(
428 WebKit::WebSpeechInputListener* listener);
429 virtual WebKit::WebDeviceOrientationClient* deviceOrientationClient();
430 virtual void zoomLimitsChanged(double minimum_level, double maximum_level);
431 virtual void zoomLevelChanged();
432 virtual void registerProtocolHandler(const WebKit::WebString& scheme,
433 const WebKit::WebString& base_url,
434 const WebKit::WebString& url,
435 const WebKit::WebString& title);
[email protected]62af76e2011-08-01 02:34:01436 virtual void registerIntentHandler(const WebKit::WebString& action,
437 const WebKit::WebString& type,
438 const WebKit::WebString& href,
439 const WebKit::WebString& title);
[email protected]94dec932011-05-26 20:04:21440 virtual WebKit::WebPageVisibilityState visibilityState() const;
[email protected]e235c7d02011-08-18 22:38:43441 virtual void startActivity(const WebKit::WebString& action,
442 const WebKit::WebString& type,
443 const WebKit::WebString& data,
444 int intent_id);
[email protected]1ef93132011-09-16 18:33:47445 virtual void OnWebIntentReply(
446 IntentsMsg_WebIntentReply_Type::Value reply_type,
447 const WebKit::WebString& data,
448 int intent_id);
[email protected]6e24cf12011-03-18 19:57:02449
450 // WebKit::WebFrameClient implementation -------------------------------------
451
452 virtual WebKit::WebPlugin* createPlugin(
453 WebKit::WebFrame* frame,
454 const WebKit::WebPluginParams& params);
455 virtual WebKit::WebWorker* createWorker(WebKit::WebFrame* frame,
456 WebKit::WebWorkerClient* client);
457 virtual WebKit::WebSharedWorker* createSharedWorker(
458 WebKit::WebFrame* frame, const WebKit::WebURL& url,
459 const WebKit::WebString& name, unsigned long long documentId);
460 virtual WebKit::WebMediaPlayer* createMediaPlayer(
461 WebKit::WebFrame* frame,
462 WebKit::WebMediaPlayerClient* client);
463 virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(
464 WebKit::WebFrame* frame,
465 WebKit::WebApplicationCacheHostClient* client);
466 virtual WebKit::WebCookieJar* cookieJar(WebKit::WebFrame* frame);
467 virtual void frameDetached(WebKit::WebFrame* frame);
468 virtual void willClose(WebKit::WebFrame* frame);
[email protected]6e24cf12011-03-18 19:57:02469 virtual void loadURLExternally(WebKit::WebFrame* frame,
470 const WebKit::WebURLRequest& request,
471 WebKit::WebNavigationPolicy policy);
[email protected]0622875ab2011-07-27 12:10:34472 virtual void loadURLExternally(WebKit::WebFrame* frame,
473 const WebKit::WebURLRequest& request,
474 WebKit::WebNavigationPolicy policy,
475 const WebKit::WebString& suggested_name);
[email protected]6e24cf12011-03-18 19:57:02476 virtual WebKit::WebNavigationPolicy decidePolicyForNavigation(
477 WebKit::WebFrame* frame,
478 const WebKit::WebURLRequest& request,
479 WebKit::WebNavigationType type,
480 const WebKit::WebNode&,
481 WebKit::WebNavigationPolicy default_policy,
482 bool is_redirect);
483 virtual bool canHandleRequest(WebKit::WebFrame* frame,
484 const WebKit::WebURLRequest& request);
485 virtual WebKit::WebURLError cannotHandleRequestError(
486 WebKit::WebFrame* frame,
487 const WebKit::WebURLRequest& request);
488 virtual WebKit::WebURLError cancelledError(
489 WebKit::WebFrame* frame,
490 const WebKit::WebURLRequest& request);
491 virtual void unableToImplementPolicyWithError(
492 WebKit::WebFrame* frame,
493 const WebKit::WebURLError& error);
494 virtual void willSendSubmitEvent(WebKit::WebFrame* frame,
495 const WebKit::WebFormElement& form);
496 virtual void willSubmitForm(WebKit::WebFrame* frame,
497 const WebKit::WebFormElement& form);
498 virtual void willPerformClientRedirect(WebKit::WebFrame* frame,
499 const WebKit::WebURL& from,
500 const WebKit::WebURL& to,
501 double interval,
502 double fire_time);
503 virtual void didCancelClientRedirect(WebKit::WebFrame* frame);
504 virtual void didCompleteClientRedirect(WebKit::WebFrame* frame,
505 const WebKit::WebURL& from);
506 virtual void didCreateDataSource(WebKit::WebFrame* frame,
507 WebKit::WebDataSource* datasource);
508 virtual void didStartProvisionalLoad(WebKit::WebFrame* frame);
509 virtual void didReceiveServerRedirectForProvisionalLoad(
510 WebKit::WebFrame* frame);
511 virtual void didFailProvisionalLoad(WebKit::WebFrame* frame,
512 const WebKit::WebURLError& error);
513 virtual void didReceiveDocumentData(WebKit::WebFrame* frame,
514 const char* data, size_t length,
515 bool& prevent_default);
516 virtual void didCommitProvisionalLoad(WebKit::WebFrame* frame,
517 bool is_new_navigation);
518 virtual void didClearWindowObject(WebKit::WebFrame* frame);
519 virtual void didCreateDocumentElement(WebKit::WebFrame* frame);
520 virtual void didReceiveTitle(WebKit::WebFrame* frame,
[email protected]a3bc4d12011-04-20 17:22:21521 const WebKit::WebString& title,
522 WebKit::WebTextDirection direction);
[email protected]42054a252011-05-17 18:02:13523 virtual void didChangeIcon(WebKit::WebFrame*,
524 WebKit::WebIconURL::Type) OVERRIDE;
[email protected]6e24cf12011-03-18 19:57:02525 virtual void didFinishDocumentLoad(WebKit::WebFrame* frame);
526 virtual void didHandleOnloadEvents(WebKit::WebFrame* frame);
527 virtual void didFailLoad(WebKit::WebFrame* frame,
528 const WebKit::WebURLError& error);
529 virtual void didFinishLoad(WebKit::WebFrame* frame);
530 virtual void didNavigateWithinPage(WebKit::WebFrame* frame,
531 bool is_new_navigation);
532 virtual void didUpdateCurrentHistoryItem(WebKit::WebFrame* frame);
533 virtual void assignIdentifierToRequest(WebKit::WebFrame* frame,
534 unsigned identifier,
535 const WebKit::WebURLRequest& request);
536 virtual void willSendRequest(WebKit::WebFrame* frame,
537 unsigned identifier,
538 WebKit::WebURLRequest& request,
539 const WebKit::WebURLResponse& redirect_response);
540 virtual void didReceiveResponse(WebKit::WebFrame* frame,
541 unsigned identifier,
542 const WebKit::WebURLResponse& response);
543 virtual void didFinishResourceLoad(WebKit::WebFrame* frame,
544 unsigned identifier);
545 virtual void didFailResourceLoad(WebKit::WebFrame* frame,
546 unsigned identifier,
547 const WebKit::WebURLError& error);
548 virtual void didLoadResourceFromMemoryCache(
549 WebKit::WebFrame* frame,
550 const WebKit::WebURLRequest& request,
551 const WebKit::WebURLResponse&);
552 virtual void didDisplayInsecureContent(WebKit::WebFrame* frame);
553 virtual void didRunInsecureContent(
554 WebKit::WebFrame* frame,
555 const WebKit::WebSecurityOrigin& origin,
556 const WebKit::WebURL& target);
[email protected]b00ba702011-08-17 01:41:03557 virtual void didAdoptURLLoader(WebKit::WebURLLoader* loader);
[email protected]6e24cf12011-03-18 19:57:02558 virtual void didExhaustMemoryAvailableForScript(WebKit::WebFrame* frame);
559 virtual void didCreateScriptContext(WebKit::WebFrame* frame);
560 virtual void didDestroyScriptContext(WebKit::WebFrame* frame);
[email protected]5a9ff1d2011-08-17 06:23:30561 virtual void didCreateIsolatedScriptContext(WebKit::WebFrame* frame,
562 int world_id,
563 v8::Handle<v8::Context> context);
[email protected]d812fd12011-05-27 23:05:07564 virtual void didUpdateLayout(WebKit::WebFrame* frame);
[email protected]6e24cf12011-03-18 19:57:02565 virtual void didChangeScrollOffset(WebKit::WebFrame* frame);
[email protected]dd6afca2011-08-13 03:44:31566 virtual void numberOfWheelEventHandlersChanged(unsigned num_handlers);
567 virtual void didChangeContentsSize(WebKit::WebFrame* frame,
568 const WebKit::WebSize& size);
[email protected]6e24cf12011-03-18 19:57:02569 virtual void reportFindInPageMatchCount(int request_id,
570 int count,
571 bool final_update);
572 virtual void reportFindInPageSelection(int request_id,
573 int active_match_ordinal,
574 const WebKit::WebRect& sel);
575
576 virtual void openFileSystem(WebKit::WebFrame* frame,
577 WebKit::WebFileSystem::Type type,
578 long long size,
579 bool create,
580 WebKit::WebFileSystemCallbacks* callbacks);
581
[email protected]10e5cf12011-04-13 04:10:40582 virtual void queryStorageUsageAndQuota(
583 WebKit::WebFrame* frame,
584 WebKit::WebStorageQuotaType type,
585 WebKit::WebStorageQuotaCallbacks* callbacks);
586
587 virtual void requestStorageQuota(
588 WebKit::WebFrame* frame,
589 WebKit::WebStorageQuotaType type,
590 unsigned long long requested_size,
591 WebKit::WebStorageQuotaCallbacks* callbacks);
592
[email protected]18d5be92011-07-25 18:00:19593 // WebKit::WebPageSerializerClient implementation ----------------------------
594
595 virtual void didSerializeDataForFrame(
596 const WebKit::WebURL& frame_url,
597 const WebKit::WebCString& data,
598 PageSerializationStatus status) OVERRIDE;
599
[email protected]6e24cf12011-03-18 19:57:02600 // webkit_glue::WebPluginPageDelegate implementation -------------------------
601
602 virtual webkit::npapi::WebPluginDelegate* CreatePluginDelegate(
603 const FilePath& file_path,
604 const std::string& mime_type);
605 virtual void CreatedPluginWindow(gfx::PluginWindowHandle handle);
606 virtual void WillDestroyPluginWindow(gfx::PluginWindowHandle handle);
607 virtual void DidMovePlugin(const webkit::npapi::WebPluginGeometry& move);
608 virtual void DidStartLoadingForPlugin();
609 virtual void DidStopLoadingForPlugin();
610 virtual WebKit::WebCookieJar* GetCookieJar();
611
612 // Please do not add your stuff randomly to the end here. If there is an
613 // appropriate section, add it there. If not, there are some random functions
614 // nearer to the top you can add it to.
[email protected]6e24cf12011-03-18 19:57:02615 virtual void DidFlushPaint();
616
[email protected]38b592902011-04-16 02:08:42617 // Cannot use std::set unfortunately since linked_ptr<> does not support
618 // operator<.
619 typedef std::vector<linked_ptr<webkit_glue::ImageResourceFetcher> >
620 ImageResourceFetcherList;
621
[email protected]6e24cf12011-03-18 19:57:02622 protected:
623 // RenderWidget overrides:
624 virtual void Close();
625 virtual void OnResize(const gfx::Size& new_size,
626 const gfx::Rect& resizer_rect);
627 virtual void DidInitiatePaint();
628 virtual webkit::ppapi::PluginInstance* GetBitmapForOptimizedPluginPaint(
629 const gfx::Rect& paint_bounds,
630 TransportDIB** dib,
631 gfx::Rect* location,
632 gfx::Rect* clip);
633 virtual gfx::Point GetScrollOffset();
634 virtual void DidHandleKeyEvent();
635 virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event);
636 virtual void OnSetFocus(bool enable);
637 virtual void OnWasHidden();
638 virtual void OnWasRestored(bool needs_repainting);
[email protected]65225772011-05-12 21:10:24639 virtual bool SupportsAsynchronousSwapBuffers() OVERRIDE;
[email protected]56ea1a62011-05-30 07:05:57640 virtual void OnImeSetComposition(
641 const string16& text,
642 const std::vector<WebKit::WebCompositionUnderline>& underlines,
643 int selection_start,
644 int selection_end) OVERRIDE;
645 virtual void OnImeConfirmComposition(const string16& text) OVERRIDE;
[email protected]ad26ef42011-06-17 07:59:45646 virtual ui::TextInputType GetTextInputType() OVERRIDE;
647 virtual bool CanComposeInline() OVERRIDE;
[email protected]6e24cf12011-03-18 19:57:02648
649 private:
[email protected]6e24cf12011-03-18 19:57:02650 // For unit tests.
651 friend class ExternalPopupMenuTest;
652 friend class PepperDeviceTest;
653 friend class RenderViewTest;
654
655 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuRemoveTest, RemoveOnChange);
656 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, NormalCase);
657 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, ShowPopupThenNavigate);
[email protected]9978b8f02011-08-13 16:17:44658 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, DontIgnoreBackAfterNavEntryLimit);
[email protected]6e24cf12011-03-18 19:57:02659 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, ImeComposition);
660 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, InsertCharacters);
661 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, JSBlockSentAfterPageLoad);
662 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, LastCommittedUpdateState);
663 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnHandleKeyboardEvent);
664 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnImeStateChanged);
665 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnNavStateChanged);
[email protected]6e24cf12011-03-18 19:57:02666 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnSetTextDirection);
[email protected]678e68a2011-09-01 15:23:56667 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnUpdateWebPreferences);
[email protected]d466b8a2011-07-15 21:48:03668 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, StaleNavigationsIgnored);
[email protected]6e24cf12011-03-18 19:57:02669 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, UpdateTargetURLWithInvalidURL);
670#if defined(OS_MACOSX)
671 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, MacTestCmdUp);
672#endif
[email protected]9e1ad4b2011-08-14 16:49:19673 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, SetHistoryLengthAndPrune);
[email protected]6e24cf12011-03-18 19:57:02674
[email protected]6e24cf12011-03-18 19:57:02675 typedef std::map<GURL, double> HostZoomLevels;
676
[email protected]6e24cf12011-03-18 19:57:02677 // Identifies an accessibility notification from webkit.
678 struct RendererAccessibilityNotification {
679 public:
680 bool ShouldIncludeChildren();
681
682 // The webkit glue id of the accessibility object.
683 int32 id;
684
685 // The accessibility notification type.
686 WebKit::WebAccessibilityNotification type;
687 };
688
689 enum ErrorPageType {
690 DNS_ERROR,
691 HTTP_404,
692 CONNECTION_ERROR,
693 };
694
695 RenderView(RenderThreadBase* render_thread,
696 gfx::NativeViewId parent_hwnd,
697 int32 opener_id,
698 const RendererPreferences& renderer_prefs,
699 const WebPreferences& webkit_prefs,
700 SharedRenderViewCounter* counter,
701 int32 routing_id,
702 int64 session_storage_namespace_id,
703 const string16& frame_name);
704
705 // Do not delete directly. This class is reference counted.
706 virtual ~RenderView();
707
708 void UpdateURL(WebKit::WebFrame* frame);
[email protected]a49e10b2011-08-01 23:57:46709 void UpdateTitle(WebKit::WebFrame* frame, const string16& title,
710 WebKit::WebTextDirection title_direction);
[email protected]6e24cf12011-03-18 19:57:02711 void UpdateSessionHistory(WebKit::WebFrame* frame);
712
713 // Update current main frame's encoding and send it to browser window.
714 // Since we want to let users see the right encoding info from menu
715 // before finishing loading, we call the UpdateEncoding in
716 // a) function:DidCommitLoadForFrame. When this function is called,
717 // that means we have got first data. In here we try to get encoding
718 // of page if it has been specified in http header.
719 // b) function:DidReceiveTitle. When this function is called,
720 // that means we have got specified title. Because in most of webpages,
721 // title tags will follow meta tags. In here we try to get encoding of
722 // page if it has been specified in meta tag.
723 // c) function:DidFinishDocumentLoadForFrame. When this function is
724 // called, that means we have got whole html page. In here we should
725 // finally get right encoding of page.
726 void UpdateEncoding(WebKit::WebFrame* frame,
727 const std::string& encoding_name);
728
729 void OpenURL(const GURL& url, const GURL& referrer,
730 WebKit::WebNavigationPolicy policy);
731
[email protected]6e24cf12011-03-18 19:57:02732 bool RunJavaScriptMessage(int type,
[email protected]4f5ce842011-05-27 19:34:41733 const string16& message,
734 const string16& default_value,
[email protected]6e24cf12011-03-18 19:57:02735 const GURL& frame_url,
[email protected]4f5ce842011-05-27 19:34:41736 string16* result);
[email protected]6e24cf12011-03-18 19:57:02737
738 // Sends a message and runs a nested message loop.
739 bool SendAndRunNestedMessageLoop(IPC::SyncMessage* message);
740
[email protected]6e24cf12011-03-18 19:57:02741 // Send queued accessibility notifications from the renderer to the browser.
742 void SendPendingAccessibilityNotifications();
743
[email protected]dd6afca2011-08-13 03:44:31744 // Called when the "pinned to left/right edge" state needs to be updated.
745 void UpdateScrollState(WebKit::WebFrame* frame);
746
[email protected]6e24cf12011-03-18 19:57:02747 // IPC message handlers ------------------------------------------------------
748 //
749 // The documentation for these functions should be in
750 // render_messages_internal.h for the message that the function is handling.
751
752 void OnAccessibilityDoDefaultAction(int acc_obj_id);
753 void OnAccessibilityNotificationsAck();
754 void OnAllowBindings(int enabled_bindings_flags);
[email protected]6e24cf12011-03-18 19:57:02755 void OnAllowScriptToClose(bool script_can_close);
756 void OnAsyncFileOpened(base::PlatformFileError error_code,
757 IPC::PlatformFileForTransit file_for_transit,
758 int message_id);
[email protected]eb415bf0e2011-04-14 02:45:42759 void OnPpapiBrokerChannelCreated(int request_id,
[email protected]2b657fd2011-04-18 16:00:47760 base::ProcessHandle broker_process_handle,
[email protected]d54305072011-06-22 20:58:43761 const IPC::ChannelHandle& handle);
[email protected]6e24cf12011-03-18 19:57:02762 void OnCancelDownload(int32 download_id);
763 void OnClearFocusedNode();
[email protected]992db4c2011-05-12 15:37:15764 void OnClosePage();
[email protected]6e24cf12011-03-18 19:57:02765#if defined(ENABLE_FLAPPER_HACKS)
766 void OnConnectTcpACK(int request_id,
767 IPC::PlatformFileForTransit socket_for_transit,
768 const PP_Flash_NetAddress& local_addr,
769 const PP_Flash_NetAddress& remote_addr);
770#endif
771 void OnContextMenuClosed(
772 const webkit_glue::CustomContextMenuContext& custom_context);
773 void OnCopy();
774 void OnCopyImageAt(int x, int y);
775#if defined(OS_MACOSX)
776 void OnCopyToFindPboard();
777#endif
778 void OnCut();
[email protected]318bf5802011-08-08 17:12:41779 void OnCSSInsertRequest(const string16& frame_xpath,
[email protected]01cf589c2011-07-28 18:04:03780 const std::string& css);
[email protected]6e24cf12011-03-18 19:57:02781 void OnCustomContextMenuAction(
782 const webkit_glue::CustomContextMenuContext& custom_context,
783 unsigned action);
784 void OnDelete();
785 void OnDeterminePageLanguage();
786 void OnDisableScrollbarsForSmallWindows(
787 const gfx::Size& disable_scrollbars_size_limit);
788 void OnDisassociateFromPopupCount();
[email protected]6e24cf12011-03-18 19:57:02789 void OnDragSourceEndedOrMoved(const gfx::Point& client_point,
790 const gfx::Point& screen_point,
791 bool ended,
792 WebKit::WebDragOperation drag_operation);
793 void OnDragSourceSystemDragEnded();
794 void OnDragTargetDrop(const gfx::Point& client_pt,
795 const gfx::Point& screen_pt);
796 void OnDragTargetDragEnter(const WebDropData& drop_data,
797 const gfx::Point& client_pt,
798 const gfx::Point& screen_pt,
799 WebKit::WebDragOperationsMask operations_allowed);
800 void OnDragTargetDragLeave();
801 void OnDragTargetDragOver(const gfx::Point& client_pt,
802 const gfx::Point& screen_pt,
803 WebKit::WebDragOperationsMask operations_allowed);
804 void OnEnablePreferredSizeChangedMode(int flags);
[email protected]600ea402011-04-12 00:01:51805 void OnEnumerateDirectoryResponse(int id, const std::vector<FilePath>& paths);
[email protected]6e24cf12011-03-18 19:57:02806 void OnExecuteEditCommand(const std::string& name, const std::string& value);
[email protected]6e24cf12011-03-18 19:57:02807 void OnFileChooserResponse(const std::vector<FilePath>& paths);
808 void OnFind(int request_id, const string16&, const WebKit::WebFindOptions&);
809 void OnFindReplyAck();
810 void OnEnableAccessibility();
[email protected]18d5be92011-07-25 18:00:19811 void OnGetAllSavableResourceLinksForCurrentPage(const GURL& page_url);
812 void OnGetSerializedHtmlDataForCurrentPageWithLocalLinks(
813 const std::vector<GURL>& links,
814 const std::vector<FilePath>& local_paths,
815 const FilePath& local_directory_name);
[email protected]6e24cf12011-03-18 19:57:02816 void OnMediaPlayerActionAt(const gfx::Point& location,
817 const WebKit::WebMediaPlayerAction& action);
818 void OnMoveOrResizeStarted();
819 void OnNavigate(const ViewMsg_Navigate_Params& params);
[email protected]6e24cf12011-03-18 19:57:02820 void OnPaste();
821#if defined(OS_MACOSX)
822 void OnPluginImeCompositionCompleted(const string16& text, int plugin_id);
823#endif
824 void OnRedo();
825 void OnReloadFrame();
826 void OnReplace(const string16& text);
827 void OnReservePageIDRange(int size_of_range);
828 void OnResetPageEncodingToDefault();
829 void OnScriptEvalRequest(const string16& frame_xpath,
830 const string16& jscript,
831 int id,
832 bool notify_result);
833 void OnSelectAll();
[email protected]4fb60142011-08-09 02:22:08834 void OnSelectRange(const gfx::Point& start, const gfx::Point& end);
[email protected]6e24cf12011-03-18 19:57:02835 void OnSetAccessibilityFocus(int acc_obj_id);
836 void OnSetActive(bool active);
837 void OnSetAltErrorPageURL(const GURL& gurl);
838 void OnSetBackground(const SkBitmap& background);
[email protected]6e24cf12011-03-18 19:57:02839 void OnSetWebUIProperty(const std::string& name, const std::string& value);
840 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
[email protected]9e1ad4b2011-08-14 16:49:19841 void OnSetHistoryLengthAndPrune(int history_length, int32 minimum_page_id);
[email protected]6e24cf12011-03-18 19:57:02842 void OnSetInitialFocus(bool reverse);
[email protected]54ca3ca892011-06-07 21:14:54843#if defined(OS_MACOSX)
844 void OnSetInLiveResize(bool in_live_resize);
845#endif
[email protected]6e24cf12011-03-18 19:57:02846 void OnScrollFocusedEditableNodeIntoView();
847 void OnSetPageEncoding(const std::string& encoding_name);
848 void OnSetRendererPrefs(const RendererPreferences& renderer_prefs);
[email protected]6e24cf12011-03-18 19:57:02849#if defined(OS_MACOSX)
850 void OnSetWindowVisibility(bool visible);
851#endif
852 void OnSetZoomLevel(double zoom_level);
853 void OnSetZoomLevelForLoadingURL(const GURL& url, double zoom_level);
[email protected]8a5e0ca2011-08-25 06:30:47854 void OnExitFullscreen();
[email protected]6e24cf12011-03-18 19:57:02855 void OnShouldClose();
856 void OnStop();
857 void OnStopFinding(const ViewMsg_StopFinding_Params& params);
[email protected]992db4c2011-05-12 15:37:15858 void OnSwapOut(const ViewMsg_SwapOut_Params& params);
[email protected]6e24cf12011-03-18 19:57:02859 void OnThemeChanged();
[email protected]6e24cf12011-03-18 19:57:02860 void OnUndo();
[email protected]6e24cf12011-03-18 19:57:02861 void OnUpdateTargetURLAck();
862 void OnUpdateWebPreferences(const WebPreferences& prefs);
[email protected]08bb1e722011-07-30 19:13:04863 void OnUpdateRemoteAccessClientFirewallTraversal(const std::string& policy);
864
[email protected]6e24cf12011-03-18 19:57:02865#if defined(OS_MACOSX)
866 void OnWindowFrameChanged(const gfx::Rect& window_frame,
867 const gfx::Rect& view_frame);
868 void OnSelectPopupMenuItem(int selected_index);
869#endif
870 void OnZoom(PageZoom::Function function);
[email protected]5a7b15a2011-08-22 22:48:18871 void OnEnableViewSourceMode();
[email protected]6e24cf12011-03-18 19:57:02872
873 // Adding a new message handler? Please add it in alphabetical order above
874 // and put it in the same position in the .cc file.
875
876 // Misc private functions ----------------------------------------------------
877
[email protected]6e24cf12011-03-18 19:57:02878 void AltErrorPageFinished(WebKit::WebFrame* frame,
879 const WebKit::WebURLError& original_error,
880 const std::string& html);
881
[email protected]d812fd12011-05-27 23:05:07882 // Check whether the preferred size has changed.
[email protected]6e24cf12011-03-18 19:57:02883 void CheckPreferredSize();
884
[email protected]5e56df82011-04-18 17:00:15885 // This callback is triggered when DownloadFavicon completes, either
886 // succesfully or with a failure. See DownloadFavicon for more
887 // details.
888 void DidDownloadFavicon(webkit_glue::ImageResourceFetcher* fetcher,
889 const SkBitmap& image);
[email protected]6e24cf12011-03-18 19:57:02890
[email protected]5e56df82011-04-18 17:00:15891 // Requests to download a favicon image. When done, the RenderView
892 // is notified by way of DidDownloadFavicon. Returns true if the
893 // request was successfully started, false otherwise. id is used to
894 // uniquely identify the request and passed back to the
895 // DidDownloadFavicon method. If the image has multiple frames, the
896 // frame whose size is image_size is returned. If the image doesn't
897 // have a frame at the specified size, the first is returned.
898 bool DownloadFavicon(int id, const GURL& image_url, int image_size);
[email protected]6e24cf12011-03-18 19:57:02899
[email protected]6e24cf12011-03-18 19:57:02900 GURL GetAlternateErrorPageURL(const GURL& failed_url,
901 ErrorPageType error_type);
902
903 // Locates a sub frame with given xpath
[email protected]318bf5802011-08-08 17:12:41904 WebKit::WebFrame* GetChildFrame(const string16& frame_xpath) const;
[email protected]6e24cf12011-03-18 19:57:02905
[email protected]6e24cf12011-03-18 19:57:02906 WebUIBindings* GetWebUIBindings();
907
[email protected]6e24cf12011-03-18 19:57:02908 // Should only be called if this object wraps a PluginDocument.
909 WebKit::WebPlugin* GetWebPluginFromPluginDocument();
910
[email protected]d466b8a2011-07-15 21:48:03911 // Returns true if the |params| navigation is to an entry that has been
912 // cropped due to a recent navigation the browser did not know about.
913 bool IsBackForwardToStaleEntry(const ViewMsg_Navigate_Params& params,
914 bool is_reload);
915
[email protected]6e24cf12011-03-18 19:57:02916 // Returns false unless this is a top-level navigation that crosses origins.
917 bool IsNonLocalTopLevelNavigation(const GURL& url,
918 WebKit::WebFrame* frame,
919 WebKit::WebNavigationType type);
920
[email protected]6e24cf12011-03-18 19:57:02921 bool MaybeLoadAlternateErrorPage(WebKit::WebFrame* frame,
922 const WebKit::WebURLError& error,
923 bool replace);
924
925 // Starts nav_state_sync_timer_ if it isn't already running.
926 void StartNavStateSyncTimerIfNecessary();
927
928 // Dispatches the current navigation state to the browser. Called on a
929 // periodic timer so we don't send too many messages.
930 void SyncNavigationState();
931
[email protected]b781ff282011-08-20 06:19:36932 // Dispatches the current state of selection on the webpage to the browser if
933 // it has changed.
934 // TODO(varunjain): delete this method once we figure out how to keep
935 // selection handles in sync with the webpage.
936 void SyncSelectionIfRequired();
937
[email protected]e63c4d72011-05-31 22:38:29938#if defined(OS_POSIX) && !defined(OS_MACOSX)
[email protected]6e24cf12011-03-18 19:57:02939 void UpdateFontRenderingFromRendererPrefs();
940#else
941 void UpdateFontRenderingFromRendererPrefs() {}
942#endif
943
944 // Update the target url and tell the browser that the target URL has changed.
945 // If |url| is empty, show |fallback_url|.
946 void UpdateTargetURL(const GURL& url, const GURL& fallback_url);
947
[email protected]6e24cf12011-03-18 19:57:02948 // ---------------------------------------------------------------------------
949 // ADDING NEW FUNCTIONS? Please keep private functions alphabetized and put
950 // it in the same order in the .cc file as it was in the header.
951 // ---------------------------------------------------------------------------
952
953 // Settings ------------------------------------------------------------------
954
955 WebPreferences webkit_preferences_;
956 RendererPreferences renderer_preferences_;
957
[email protected]6e24cf12011-03-18 19:57:02958 HostZoomLevels host_zoom_levels_;
959
960 // Whether content state (such as form state, scroll position and page
961 // contents) should be sent to the browser immediately. This is normally
962 // false, but set to true by some tests.
963 bool send_content_state_immediately_;
964
[email protected]6e24cf12011-03-18 19:57:02965 // Bitwise-ORed set of extra bindings that have been enabled. See
966 // BindingsPolicy for details.
967 int enabled_bindings_;
968
969 // The alternate error page URL, if one exists.
970 GURL alternate_error_page_url_;
971
972 // If true, we send IPC messages when |preferred_size_| changes.
973 bool send_preferred_size_changes_;
974
975 // If non-empty, and |send_preferred_size_changes_| is true, disable drawing
976 // scroll bars on windows smaller than this size. Used for windows that the
977 // browser resizes to the size of the content, such as browser action popups.
978 // If a render view is set to the minimum size of its content, webkit may add
979 // scroll bars. This makes sense for fixed sized windows, but it does not
980 // make sense when the size of the view was chosen to fit the content.
981 // This setting ensures that no scroll bars are drawn. The size limit exists
982 // because if the view grows beyond a size known to the browser, scroll bars
983 // should be drawn.
984 gfx::Size disable_scrollbars_size_limit_;
985
[email protected]6e24cf12011-03-18 19:57:02986 // Loading state -------------------------------------------------------------
987
988 // True if the top level frame is currently being loaded.
989 bool is_loading_;
990
991 // The gesture that initiated the current navigation.
992 NavigationGesture navigation_gesture_;
993
994 // Used for popups.
995 bool opened_by_user_gesture_;
996 GURL creator_url_;
997
998 // Whether this RenderView was created by a frame that was suppressing its
999 // opener. If so, we may want to load pages in a separate process. See
1000 // decidePolicyForNavigation for details.
1001 bool opener_suppressed_;
1002
1003 // If we are handling a top-level client-side redirect, this tracks the URL
1004 // of the page that initiated it. Specifically, when a load is committed this
1005 // is used to determine if that load originated from a client-side redirect.
1006 // It is empty if there is no top-level client-side redirect.
1007 GURL completed_client_redirect_src_;
1008
[email protected]6e24cf12011-03-18 19:57:021009 // Holds state pertaining to a navigation that we initiated. This is held by
1010 // the WebDataSource::ExtraData attribute. We use pending_navigation_state_
1011 // as a temporary holder for the state until the WebDataSource corresponding
1012 // to the new navigation is created. See DidCreateDataSource.
1013 scoped_ptr<NavigationState> pending_navigation_state_;
1014
1015 // Timer used to delay the updating of nav state (see SyncNavigationState).
1016 base::OneShotTimer<RenderView> nav_state_sync_timer_;
1017
[email protected]6e24cf12011-03-18 19:57:021018 // Page IDs ------------------------------------------------------------------
1019 //
1020 // Page IDs allow the browser to identify pages in each renderer process for
1021 // keeping back/forward history in sync.
1022
1023 // ID of the current page. Note that this is NOT updated for every main
1024 // frame navigation, only for "regular" navigations that go into session
1025 // history. In particular, client redirects, like the page cycler uses
1026 // (document.location.href="foo") do not count as regular navigations and do
1027 // not increment the page id.
1028 int32 page_id_;
1029
1030 // Indicates the ID of the last page that we sent a FrameNavigate to the
1031 // browser for. This is used to determine if the most recent transition
1032 // generated a history entry (less than page_id_), or not (equal to or
1033 // greater than). Note that this will be greater than page_id_ if the user
1034 // goes back.
1035 int32 last_page_id_sent_to_browser_;
1036
[email protected]6e24cf12011-03-18 19:57:021037 // The next available page ID to use. This ensures that the page IDs are
1038 // globally unique in the renderer.
1039 static int32 next_page_id_;
1040
[email protected]d466b8a2011-07-15 21:48:031041 // The offset of the current item in the history list.
1042 int history_list_offset_;
1043
1044 // The RenderView's current impression of the history length. This includes
1045 // any items that have committed in this process, but because of cross-process
1046 // navigations, the history may have some entries that were committed in other
1047 // processes. We won't know about them until the next navigation in this
1048 // process.
1049 int history_list_length_;
1050
1051 // The list of page IDs for each history item this RenderView knows about.
1052 // Some entries may be -1 if they were rendered by other processes or were
1053 // restored from a previous session. This lets us detect attempts to
1054 // navigate to stale entries that have been cropped from our history.
1055 std::vector<int32> history_page_ids_;
1056
[email protected]6e24cf12011-03-18 19:57:021057 // Page info -----------------------------------------------------------------
1058
1059 // The last gotten main frame's encoding.
1060 std::string last_encoding_name_;
1061
[email protected]6e24cf12011-03-18 19:57:021062 // UI state ------------------------------------------------------------------
1063
1064 // The state of our target_url transmissions. When we receive a request to
1065 // send a URL to the browser, we set this to TARGET_INFLIGHT until an ACK
1066 // comes back - if a new request comes in before the ACK, we store the new
1067 // URL in pending_target_url_ and set the status to TARGET_PENDING. If an
1068 // ACK comes back and we are in TARGET_PENDING, we send the stored URL and
1069 // revert to TARGET_INFLIGHT.
1070 //
1071 // We don't need a queue of URLs to send, as only the latest is useful.
1072 enum {
1073 TARGET_NONE,
1074 TARGET_INFLIGHT, // We have a request in-flight, waiting for an ACK
1075 TARGET_PENDING // INFLIGHT + we have a URL waiting to be sent
1076 } target_url_status_;
1077
1078 // The URL we show the user in the status bar. We use this to determine if we
1079 // want to send a new one (we do not need to send duplicates). It will be
1080 // equal to either |mouse_over_url_| or |focus_url_|, depending on which was
1081 // updated last.
1082 GURL target_url_;
1083
1084 // The URL the user's mouse is hovering over.
1085 GURL mouse_over_url_;
1086
1087 // The URL that has keyboard focus.
1088 GURL focus_url_;
1089
1090 // The next target URL we want to send to the browser.
1091 GURL pending_target_url_;
1092
[email protected]6e24cf12011-03-18 19:57:021093 // The text selection the last time DidChangeSelection got called.
[email protected]b781ff282011-08-20 06:19:361094 RenderViewSelection last_selection_;
[email protected]6e24cf12011-03-18 19:57:021095
1096 // View ----------------------------------------------------------------------
1097
[email protected]6e24cf12011-03-18 19:57:021098 // Cache the preferred size of the page in order to prevent sending the IPC
1099 // when layout() recomputes but doesn't actually change sizes.
1100 gfx::Size preferred_size_;
1101
[email protected]1e0c8e02011-05-25 07:49:371102 // Used to delay determining the preferred size (to avoid intermediate
1103 // states for the sizes).
1104 base::OneShotTimer<RenderView> check_preferred_size_timer_;
1105
[email protected]dd6afca2011-08-13 03:44:311106 // These store the "is main frame is scrolled all the way to the left
1107 // or right" state that was last sent to the browser.
1108 bool cached_is_main_frame_pinned_to_left_;
1109 bool cached_is_main_frame_pinned_to_right_;
1110
1111 // These store the "has scrollbars" state last sent to the browser.
1112 bool cached_has_main_frame_horizontal_scrollbar_;
1113 bool cached_has_main_frame_vertical_scrollbar_;
1114
[email protected]6e24cf12011-03-18 19:57:021115#if defined(OS_MACOSX)
1116 // Track the fake plugin window handles allocated on the browser side for
1117 // the accelerated compositor and (currently) accelerated plugins so that
1118 // we can discard them when the view goes away.
1119 std::set<gfx::PluginWindowHandle> fake_plugin_window_handles_;
1120#endif
1121
1122 // Plugins -------------------------------------------------------------------
1123
[email protected]6e24cf12011-03-18 19:57:021124 PepperPluginDelegateImpl pepper_delegate_;
1125
1126 // All the currently active plugin delegates for this RenderView; kept so that
1127 // we can enumerate them to send updates about things like window location
1128 // or tab focus and visibily. These are non-owning references.
1129 std::set<WebPluginDelegateProxy*> plugin_delegates_;
1130
1131 // Helper objects ------------------------------------------------------------
1132
[email protected]6e24cf12011-03-18 19:57:021133 ScopedRunnableMethodFactory<RenderView> accessibility_method_factory_;
1134
1135 RendererWebCookieJarImpl cookie_jar_;
1136
1137 // The next group of objects all implement RenderViewObserver, so are deleted
1138 // along with the RenderView automatically. This is why we just store weak
1139 // references.
1140
[email protected]6e24cf12011-03-18 19:57:021141 // Holds a reference to the service which provides desktop notifications.
1142 NotificationProvider* notification_provider_;
1143
1144 // The geolocation dispatcher attached to this view, lazily initialized.
1145 GeolocationDispatcher* geolocation_dispatcher_;
1146
[email protected]1ef93132011-09-16 18:33:471147 // The intents dispatcher attached to this view. Not lazily initialized.
1148 IntentsDispatcher* intents_dispatcher_;
1149
[email protected]6e24cf12011-03-18 19:57:021150 // The speech dispatcher attached to this view, lazily initialized.
1151 SpeechInputDispatcher* speech_input_dispatcher_;
1152
1153 // Device orientation dispatcher attached to this view; lazily initialized.
1154 DeviceOrientationDispatcher* device_orientation_dispatcher_;
1155
[email protected]ab2c4732011-07-20 19:57:401156 // MediaStreamImpl attached to this view; lazily initialized.
1157 scoped_refptr<MediaStreamImpl> media_stream_impl_;
1158
[email protected]6e24cf12011-03-18 19:57:021159 // Handles accessibility requests into the renderer side, as well as
1160 // maintains the cache and other features of the accessibility tree.
1161 scoped_ptr<WebKit::WebAccessibilityCache> accessibility_;
1162
1163 // Collect renderer accessibility notifications until they are ready to be
1164 // sent to the browser.
1165 std::vector<RendererAccessibilityNotification>
1166 pending_accessibility_notifications_;
1167
1168 // Set if we are waiting for a accessibility notification ack.
1169 bool accessibility_ack_pending_;
1170
[email protected]ee845122011-09-01 08:44:161171 // True if verbose logging of accessibility events is on.
1172 bool accessibility_logging_;
1173
[email protected]6e24cf12011-03-18 19:57:021174 // Dispatches all P2P socket used by the renderer.
[email protected]b3f8f9722011-08-25 20:56:071175 content::P2PSocketDispatcher* p2p_socket_dispatcher_;
[email protected]6e24cf12011-03-18 19:57:021176
[email protected]c5c1d6d2011-07-28 18:42:411177 DevToolsAgent* devtools_agent_;
1178
[email protected]6e24cf12011-03-18 19:57:021179 // Misc ----------------------------------------------------------------------
1180
1181 // The current and pending file chooser completion objects. If the queue is
1182 // nonempty, the first item represents the currently running file chooser
1183 // callback, and the remaining elements are the other file chooser completion
1184 // still waiting to be run (in order).
1185 struct PendingFileChooser;
1186 std::deque< linked_ptr<PendingFileChooser> > file_chooser_completions_;
1187
[email protected]600ea402011-04-12 00:01:511188 // The current directory enumeration callback
1189 std::map<int, WebKit::WebFileChooserCompletion*> enumeration_completions_;
1190 int enumeration_completion_id_;
1191
[email protected]6e24cf12011-03-18 19:57:021192 // The SessionStorage namespace that we're assigned to has an ID, and that ID
1193 // is passed to us upon creation. WebKit asks for this ID upon first use and
1194 // uses it whenever asking the browser process to allocate new storage areas.
1195 int64 session_storage_namespace_id_;
1196
1197 // The total number of unrequested popups that exist and can be followed back
1198 // to a common opener. This count is shared among all RenderViews created
1199 // with createView(). All popups are treated as unrequested until
1200 // specifically instructed otherwise by the Browser process.
1201 scoped_refptr<SharedRenderViewCounter> shared_popup_counter_;
1202
1203 // Whether this is a top level window (instead of a popup). Top level windows
1204 // shouldn't count against their own |shared_popup_counter_|.
1205 bool decrement_shared_popup_at_destruction_;
1206
1207 // If the browser hasn't sent us an ACK for the last FindReply we sent
1208 // to it, then we need to queue up the message (keeping only the most
1209 // recent message if new ones come in).
1210 scoped_ptr<IPC::Message> queued_find_reply_message_;
1211
1212 // Stores edit commands associated to the next key event.
1213 // Shall be cleared as soon as the next key event is processed.
1214 EditCommands edit_commands_;
1215
[email protected]6e24cf12011-03-18 19:57:021216 // Allows Web UI pages (new tab page, etc.) to talk to the browser. The JS
1217 // object is only exposed when Web UI bindings are enabled.
1218 scoped_ptr<WebUIBindings> web_ui_bindings_;
1219
[email protected]6e24cf12011-03-18 19:57:021220 // The external popup for the currently showing select popup.
1221 scoped_ptr<ExternalPopupMenu> external_popup_menu_;
1222
1223 // The node that the context menu was pressed over.
1224 WebKit::WebNode context_menu_node_;
1225
1226 // Reports load progress to the browser.
1227 scoped_ptr<LoadProgressTracker> load_progress_tracker_;
1228
1229 // All the registered observers. We expect this list to be small, so vector
1230 // is fine.
1231 ObserverList<RenderViewObserver> observers_;
1232
[email protected]4fb60142011-08-09 02:22:081233 // Used to inform didChangeSelection() when it is called in the context
1234 // of handling a ViewMsg_SelectRange IPC.
1235 bool handling_select_range_;
1236
[email protected]6e24cf12011-03-18 19:57:021237 // ---------------------------------------------------------------------------
1238 // ADDING NEW DATA? Please see if it fits appropriately in one of the above
1239 // sections rather than throwing it randomly at the end. If you're adding a
1240 // bunch of stuff, you should probably create a helper class and put your
1241 // data and methods on that to avoid bloating RenderView more. You can use
1242 // the Observer interface to filter IPC messages and receive frame change
1243 // notifications.
1244 // ---------------------------------------------------------------------------
1245
1246 DISALLOW_COPY_AND_ASSIGN(RenderView);
1247};
1248
1249#endif // CONTENT_RENDERER_RENDER_VIEW_H_