blob: 43c1b6643fb9d8896ee5206c2d5bff397708ea7d [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]6e24cf12011-03-18 19:57:0224#include "content/renderer/renderer_webcookiejar_impl.h"
[email protected]55722152011-03-22 01:33:5325#include "content/common/edit_command.h"
[email protected]6e24cf12011-03-18 19:57:0226#include "content/common/navigation_gesture.h"
27#include "content/common/page_zoom.h"
[email protected]60916042011-03-19 00:43:3628#include "content/common/renderer_preferences.h"
[email protected]6e24cf12011-03-18 19:57:0229#include "content/renderer/pepper_plugin_delegate_impl.h"
30#include "content/renderer/render_widget.h"
31#include "ipc/ipc_platform_file.h"
32#include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityNotification.h"
33#include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h"
34#include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystem.h"
35#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h"
[email protected]42054a252011-05-17 18:02:1336#include "third_party/WebKit/Source/WebKit/chromium/public/WebIconURL.h"
[email protected]6e24cf12011-03-18 19:57:0237#include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h"
[email protected]94dec932011-05-26 20:04:2138#include "third_party/WebKit/Source/WebKit/chromium/public/WebPageVisibilityState.h"
[email protected]6e24cf12011-03-18 19:57:0239#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h"
40#include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h"
41#include "third_party/WebKit/Source/WebKit/chromium/public/WebNavigationType.h"
[email protected]b9b751f22011-03-25 14:04:1242#include "ui/gfx/surface/transport_dib.h"
[email protected]6e24cf12011-03-18 19:57:0243#include "webkit/glue/webpreferences.h"
44#include "webkit/plugins/npapi/webplugin_page_delegate.h"
45
46#if defined(OS_WIN)
47// RenderView is a diamond-shaped hierarchy, with WebWidgetClient at the root.
48// VS warns when we inherit the WebWidgetClient method implementations from
49// RenderWidget. It's safe to ignore that warning.
50#pragma warning(disable: 4250)
51#endif
52
53class AudioMessageFilter;
[email protected]6e24cf12011-03-18 19:57:0254class DeviceOrientationDispatcher;
[email protected]55722152011-03-22 01:33:5355class ExternalPopupMenu;
[email protected]6e24cf12011-03-18 19:57:0256class FilePath;
57class GeolocationDispatcher;
[email protected]6e24cf12011-03-18 19:57:0258class GURL;
[email protected]6e24cf12011-03-18 19:57:0259class LoadProgressTracker;
[email protected]ab2c4732011-07-20 19:57:4060class MediaStreamImpl;
[email protected]6e24cf12011-03-18 19:57:0261class NavigationState;
62class NotificationProvider;
63class P2PSocketDispatcher;
64class PepperDeviceTest;
65class PrintWebViewHelper;
66class RenderViewObserver;
67class RenderViewVisitor;
[email protected]ea192e82011-04-11 19:16:0268class RenderWidgetFullscreenPepper;
[email protected]6e24cf12011-03-18 19:57:0269class SkBitmap;
70class SpeechInputDispatcher;
[email protected]6e24cf12011-03-18 19:57:0271class WebPluginDelegatePepper;
72class WebPluginDelegateProxy;
[email protected]55722152011-03-22 01:33:5373class WebUIBindings;
[email protected]6e24cf12011-03-18 19:57:0274struct ContextMenuMediaParams;
75struct PP_Flash_NetAddress;
[email protected]6e24cf12011-03-18 19:57:0276struct ViewHostMsg_RunFileChooser_Params;
[email protected]992db4c2011-05-12 15:37:1577struct ViewMsg_SwapOut_Params;
[email protected]6e24cf12011-03-18 19:57:0278struct ViewMsg_Navigate_Params;
79struct ViewMsg_StopFinding_Params;
[email protected]6e24cf12011-03-18 19:57:0280struct WebDropData;
81
82namespace base {
83class WaitableEvent;
84}
85
86namespace chrome {
87class ChromeContentRendererClient;
88}
89
90namespace gfx {
91class Point;
92class Rect;
93}
94
95namespace webkit {
96
97namespace npapi {
98class PluginGroup;
99} // namespace npapi
100
101namespace 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]6e24cf12011-03-18 19:57:02139class WebURLRequest;
140class WebView;
141struct WebContextMenuData;
142struct WebFileChooserParams;
143struct WebFindOptions;
144struct WebMediaPlayerAction;
145struct WebPluginParams;
146struct WebPoint;
147struct WebWindowFeatures;
148}
149
150// We need to prevent a page from trying to create infinite popups. It is not
151// as simple as keeping a count of the number of immediate children
152// popups. Having an html file that window.open()s itself would create
153// an unlimited chain of RenderViews who only have one RenderView child.
154//
155// Therefore, each new top level RenderView creates a new counter and shares it
156// with all its children and grandchildren popup RenderViews created with
157// createView() to have a sort of global limit for the page so no more than
158// kMaximumNumberOfPopups popups are created.
159//
160// This is a RefCounted holder of an int because I can't say
161// scoped_refptr<int>.
162typedef base::RefCountedData<int> SharedRenderViewCounter;
163
164//
165// RenderView is an object that manages a WebView object, and provides a
166// communication interface with an embedding application process
167//
168class RenderView : public RenderWidget,
169 public WebKit::WebViewClient,
170 public WebKit::WebFrameClient,
[email protected]6e24cf12011-03-18 19:57:02171 public webkit::npapi::WebPluginPageDelegate,
172 public base::SupportsWeakPtr<RenderView> {
173 public:
174 // Creates a new RenderView. The parent_hwnd specifies a HWND to use as the
175 // parent of the WebView HWND that will be created. If this is a constrained
176 // popup or as a new tab, opener_id is the routing ID of the RenderView
177 // responsible for creating this RenderView (corresponding to parent_hwnd).
178 // |counter| is either a currently initialized counter, or NULL (in which case
179 // we treat this RenderView as a top level window).
180 static RenderView* Create(
181 RenderThreadBase* render_thread,
182 gfx::NativeViewId parent_hwnd,
183 int32 opener_id,
184 const RendererPreferences& renderer_prefs,
185 const WebPreferences& webkit_prefs,
186 SharedRenderViewCounter* counter,
187 int32 routing_id,
188 int64 session_storage_namespace_id,
189 const string16& frame_name);
190
191 // Visit all RenderViews with a live WebView (i.e., RenderViews that have
192 // been closed but not yet destroyed are excluded).
193 static void ForEach(RenderViewVisitor* visitor);
194
195 // Returns the RenderView containing the given WebView.
196 static RenderView* FromWebView(WebKit::WebView* webview);
197
198 // Sets the "next page id" counter.
199 static void SetNextPageID(int32 next_page_id);
200
201 // May return NULL when the view is closing.
202 WebKit::WebView* webview() const;
203
[email protected]65225772011-05-12 21:10:24204 // Called by a GraphicsContext associated with this view when swapbuffers
[email protected]37a6f302011-07-11 23:43:08205 // is posted, completes or is aborted.
206 void OnViewContextSwapBuffersPosted();
[email protected]65225772011-05-12 21:10:24207 void OnViewContextSwapBuffersComplete();
208 void OnViewContextSwapBuffersAborted();
209
[email protected]9966325b2011-04-18 05:00:10210 int page_id() const { return page_id_; }
[email protected]d466b8a2011-07-15 21:48:03211 int history_list_offset() const { return history_list_offset_; }
[email protected]9966325b2011-04-18 05:00:10212 PepperPluginDelegateImpl* pepper_delegate() { return &pepper_delegate_; }
[email protected]6e24cf12011-03-18 19:57:02213
[email protected]6e24cf12011-03-18 19:57:02214 const WebPreferences& webkit_preferences() const {
215 return webkit_preferences_;
216 }
217
[email protected]93b9d692011-04-13 00:44:31218 bool content_state_immediately() { return send_content_state_immediately_; }
[email protected]9966325b2011-04-18 05:00:10219 int enabled_bindings() const { return enabled_bindings_; }
220 void set_enabled_bindings(int b) { enabled_bindings_ = b; }
[email protected]6e24cf12011-03-18 19:57:02221 void set_send_content_state_immediately(bool value) {
222 send_content_state_immediately_ = value;
223 }
224
225 // Returns true if we should display scrollbars for the given view size and
226 // false if the scrollbars should be hidden.
227 bool should_display_scrollbars(int width, int height) const {
228 return (!send_preferred_size_changes_ ||
229 (disable_scrollbars_size_limit_.width() <= width ||
230 disable_scrollbars_size_limit_.height() <= height));
231 }
232
[email protected]6e24cf12011-03-18 19:57:02233 const WebKit::WebNode& context_menu_node() { return context_menu_node_; }
234
235 // Current P2PSocketDispatcher. Set to NULL if P2P API is disabled.
236 P2PSocketDispatcher* p2p_socket_dispatcher() {
237 return p2p_socket_dispatcher_;
238 }
239
240 // Functions to add and remove observers for this object.
241 void AddObserver(RenderViewObserver* observer);
242 void RemoveObserver(RenderViewObserver* observer);
243
[email protected]6e24cf12011-03-18 19:57:02244 // Evaluates a string of JavaScript in a particular frame.
245 void EvaluateScript(const string16& frame_xpath,
246 const string16& jscript,
247 int id,
248 bool notify_result);
249
250 // Adds the given file chooser request to the file_chooser_completion_ queue
251 // (see that var for more) and requests the chooser be displayed if there are
252 // no other waiting items in the queue.
253 //
254 // Returns true if the chooser was successfully scheduled. False means we
255 // didn't schedule anything.
256 bool ScheduleFileChooser(const ViewHostMsg_RunFileChooser_Params& params,
257 WebKit::WebFileChooserCompletion* completion);
258
[email protected]6e24cf12011-03-18 19:57:02259 // Sets whether the renderer should report load progress to the browser.
260 void SetReportLoadProgressEnabled(bool enabled);
261
[email protected]38b592902011-04-16 02:08:42262 // Gets the focused node. If no such node exists then the node will be isNull.
263 WebKit::WebNode GetFocusedNode() const;
264
265 // Returns true if the parameter node is a textfield, text area or a content
266 // editable div.
267 bool IsEditableNode(const WebKit::WebNode& node);
268
[email protected]9966325b2011-04-18 05:00:10269 void LoadNavigationErrorPage(WebKit::WebFrame* frame,
270 const WebKit::WebURLRequest& failed_request,
271 const WebKit::WebURLError& error,
272 const std::string& html,
273 bool replace);
274
[email protected]6e24cf12011-03-18 19:57:02275 // Plugin-related functions --------------------------------------------------
276 // (See also WebPluginPageDelegate implementation.)
277
278 // Notification that the given plugin has crashed.
279 void PluginCrashed(const FilePath& plugin_path);
280
281 // Notification that the default plugin has done something about a missing
282 // plugin. See default_plugin_shared.h for possible values of |status|.
283 void OnMissingPluginStatus(WebPluginDelegateProxy* delegate,
284 int status);
285
[email protected]9966325b2011-04-18 05:00:10286 // Create a new NPAPI plugin.
287 WebKit::WebPlugin* CreateNPAPIPlugin(WebKit::WebFrame* frame,
288 const WebKit::WebPluginParams& params,
289 const FilePath& path,
290 const std::string& mime_type);
291
292 // Create a new Pepper plugin.
293 WebKit::WebPlugin* CreatePepperPlugin(
294 WebKit::WebFrame* frame,
295 const WebKit::WebPluginParams& params,
296 const FilePath& path,
297 webkit::ppapi::PluginModule* pepper_module);
298
[email protected]6e24cf12011-03-18 19:57:02299 // Creates a fullscreen container for a pepper plugin instance.
[email protected]ea192e82011-04-11 19:16:02300 RenderWidgetFullscreenPepper* CreatePepperFullscreenContainer(
[email protected]6e24cf12011-03-18 19:57:02301 webkit::ppapi::PluginInstance* plugin);
302
303 // Create a new plugin without checking the content settings.
304 WebKit::WebPlugin* CreatePluginNoCheck(WebKit::WebFrame* frame,
305 const WebKit::WebPluginParams& params);
306
[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]6e24cf12011-03-18 19:57:02310#if defined(OS_MACOSX)
311 // Informs the render view that the given plugin has gained or lost focus.
312 void PluginFocusChanged(bool focused, int plugin_id);
313
314 // Starts plugin IME.
315 void StartPluginIme();
316
317 // Helper routines for accelerated plugin support. Used by the
318 // WebPluginDelegateProxy, which has a pointer to the RenderView.
319 gfx::PluginWindowHandle AllocateFakePluginWindowHandle(bool opaque,
320 bool root);
321 void DestroyFakePluginWindowHandle(gfx::PluginWindowHandle window);
322 void AcceleratedSurfaceSetIOSurface(gfx::PluginWindowHandle window,
323 int32 width,
324 int32 height,
325 uint64 io_surface_identifier);
326 TransportDIB::Handle AcceleratedSurfaceAllocTransportDIB(size_t size);
327 void AcceleratedSurfaceFreeTransportDIB(TransportDIB::Id dib_id);
328 void AcceleratedSurfaceSetTransportDIB(gfx::PluginWindowHandle window,
329 int32 width,
330 int32 height,
331 TransportDIB::Handle transport_dib);
332 void AcceleratedSurfaceBuffersSwapped(gfx::PluginWindowHandle window,
333 uint64 surface_id);
334#endif
335
336 void RegisterPluginDelegate(WebPluginDelegateProxy* delegate);
337 void UnregisterPluginDelegate(WebPluginDelegateProxy* delegate);
338
339 // IPC::Channel::Listener implementation -------------------------------------
340
341 virtual bool OnMessageReceived(const IPC::Message& msg);
342
343 // WebKit::WebWidgetClient implementation ------------------------------------
344
345 // Most methods are handled by RenderWidget.
346 virtual void didFocus();
347 virtual void didBlur();
348 virtual void show(WebKit::WebNavigationPolicy policy);
349 virtual void runModal();
350
351 // WebKit::WebViewClient implementation --------------------------------------
352
353 virtual WebKit::WebView* createView(
354 WebKit::WebFrame* creator,
355 const WebKit::WebURLRequest& request,
356 const WebKit::WebWindowFeatures& features,
357 const WebKit::WebString& frame_name);
358 virtual WebKit::WebWidget* createPopupMenu(WebKit::WebPopupType popup_type);
359 virtual WebKit::WebWidget* createPopupMenu(
360 const WebKit::WebPopupMenuInfo& info);
361 virtual WebKit::WebExternalPopupMenu* createExternalPopupMenu(
362 const WebKit::WebPopupMenuInfo& popup_menu_info,
363 WebKit::WebExternalPopupMenuClient* popup_menu_client);
364 virtual WebKit::WebStorageNamespace* createSessionStorageNamespace(
365 unsigned quota);
366 virtual void didAddMessageToConsole(
367 const WebKit::WebConsoleMessage& message,
368 const WebKit::WebString& source_name,
369 unsigned source_line);
370 virtual void printPage(WebKit::WebFrame* frame);
371 virtual WebKit::WebNotificationPresenter* notificationPresenter();
[email protected]8a58c1c2011-04-19 18:40:12372 virtual bool enumerateChosenDirectory(
373 const WebKit::WebString& path,
374 WebKit::WebFileChooserCompletion* chooser_completion);
[email protected]6e24cf12011-03-18 19:57:02375 virtual void didStartLoading();
376 virtual void didStopLoading();
377 virtual void didChangeLoadProgress(WebKit::WebFrame* frame,
378 double load_progress);
379 virtual bool isSmartInsertDeleteEnabled();
380 virtual bool isSelectTrailingWhitespaceEnabled();
381 virtual void didChangeSelection(bool is_selection_empty);
382 virtual void didExecuteCommand(const WebKit::WebString& command_name);
383 virtual bool handleCurrentKeyboardEvent();
[email protected]6e24cf12011-03-18 19:57:02384 virtual bool runFileChooser(
385 const WebKit::WebFileChooserParams& params,
386 WebKit::WebFileChooserCompletion* chooser_completion);
387 virtual void runModalAlertDialog(WebKit::WebFrame* frame,
388 const WebKit::WebString& message);
389 virtual bool runModalConfirmDialog(WebKit::WebFrame* frame,
390 const WebKit::WebString& message);
391 virtual bool runModalPromptDialog(WebKit::WebFrame* frame,
392 const WebKit::WebString& message,
393 const WebKit::WebString& default_value,
394 WebKit::WebString* actual_value);
395 virtual bool runModalBeforeUnloadDialog(WebKit::WebFrame* frame,
396 const WebKit::WebString& message);
397 virtual void showContextMenu(WebKit::WebFrame* frame,
398 const WebKit::WebContextMenuData& data);
399 virtual bool supportsFullscreen();
400 virtual void enterFullscreenForNode(const WebKit::WebNode&);
401 virtual void exitFullscreenForNode(const WebKit::WebNode&);
402 virtual void setStatusText(const WebKit::WebString& text);
403 virtual void setMouseOverURL(const WebKit::WebURL& url);
404 virtual void setKeyboardFocusURL(const WebKit::WebURL& url);
[email protected]6e24cf12011-03-18 19:57:02405 virtual void startDragging(const WebKit::WebDragData& data,
406 WebKit::WebDragOperationsMask mask,
407 const WebKit::WebImage& image,
408 const WebKit::WebPoint& imageOffset);
409 virtual bool acceptsLoadDrops();
410 virtual void focusNext();
411 virtual void focusPrevious();
412 virtual void focusedNodeChanged(const WebKit::WebNode& node);
413 virtual void navigateBackForwardSoon(int offset);
414 virtual int historyBackListCount();
415 virtual int historyForwardListCount();
416 virtual void postAccessibilityNotification(
417 const WebKit::WebAccessibilityObject& obj,
418 WebKit::WebAccessibilityNotification notification);
419 virtual void didUpdateInspectorSetting(const WebKit::WebString& key,
420 const WebKit::WebString& value);
421 virtual WebKit::WebGeolocationClient* geolocationClient();
422 virtual WebKit::WebSpeechInputController* speechInputController(
423 WebKit::WebSpeechInputListener* listener);
424 virtual WebKit::WebDeviceOrientationClient* deviceOrientationClient();
425 virtual void zoomLimitsChanged(double minimum_level, double maximum_level);
426 virtual void zoomLevelChanged();
427 virtual void registerProtocolHandler(const WebKit::WebString& scheme,
428 const WebKit::WebString& base_url,
429 const WebKit::WebString& url,
430 const WebKit::WebString& title);
[email protected]94dec932011-05-26 20:04:21431 virtual WebKit::WebPageVisibilityState visibilityState() const;
[email protected]6e24cf12011-03-18 19:57:02432
433 // WebKit::WebFrameClient implementation -------------------------------------
434
435 virtual WebKit::WebPlugin* createPlugin(
436 WebKit::WebFrame* frame,
437 const WebKit::WebPluginParams& params);
438 virtual WebKit::WebWorker* createWorker(WebKit::WebFrame* frame,
439 WebKit::WebWorkerClient* client);
440 virtual WebKit::WebSharedWorker* createSharedWorker(
441 WebKit::WebFrame* frame, const WebKit::WebURL& url,
442 const WebKit::WebString& name, unsigned long long documentId);
443 virtual WebKit::WebMediaPlayer* createMediaPlayer(
444 WebKit::WebFrame* frame,
445 WebKit::WebMediaPlayerClient* client);
446 virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(
447 WebKit::WebFrame* frame,
448 WebKit::WebApplicationCacheHostClient* client);
449 virtual WebKit::WebCookieJar* cookieJar(WebKit::WebFrame* frame);
450 virtual void frameDetached(WebKit::WebFrame* frame);
451 virtual void willClose(WebKit::WebFrame* frame);
[email protected]6e24cf12011-03-18 19:57:02452 virtual void loadURLExternally(WebKit::WebFrame* frame,
453 const WebKit::WebURLRequest& request,
454 WebKit::WebNavigationPolicy policy);
455 virtual WebKit::WebNavigationPolicy decidePolicyForNavigation(
456 WebKit::WebFrame* frame,
457 const WebKit::WebURLRequest& request,
458 WebKit::WebNavigationType type,
459 const WebKit::WebNode&,
460 WebKit::WebNavigationPolicy default_policy,
461 bool is_redirect);
462 virtual bool canHandleRequest(WebKit::WebFrame* frame,
463 const WebKit::WebURLRequest& request);
464 virtual WebKit::WebURLError cannotHandleRequestError(
465 WebKit::WebFrame* frame,
466 const WebKit::WebURLRequest& request);
467 virtual WebKit::WebURLError cancelledError(
468 WebKit::WebFrame* frame,
469 const WebKit::WebURLRequest& request);
470 virtual void unableToImplementPolicyWithError(
471 WebKit::WebFrame* frame,
472 const WebKit::WebURLError& error);
473 virtual void willSendSubmitEvent(WebKit::WebFrame* frame,
474 const WebKit::WebFormElement& form);
475 virtual void willSubmitForm(WebKit::WebFrame* frame,
476 const WebKit::WebFormElement& form);
477 virtual void willPerformClientRedirect(WebKit::WebFrame* frame,
478 const WebKit::WebURL& from,
479 const WebKit::WebURL& to,
480 double interval,
481 double fire_time);
482 virtual void didCancelClientRedirect(WebKit::WebFrame* frame);
483 virtual void didCompleteClientRedirect(WebKit::WebFrame* frame,
484 const WebKit::WebURL& from);
485 virtual void didCreateDataSource(WebKit::WebFrame* frame,
486 WebKit::WebDataSource* datasource);
487 virtual void didStartProvisionalLoad(WebKit::WebFrame* frame);
488 virtual void didReceiveServerRedirectForProvisionalLoad(
489 WebKit::WebFrame* frame);
490 virtual void didFailProvisionalLoad(WebKit::WebFrame* frame,
491 const WebKit::WebURLError& error);
492 virtual void didReceiveDocumentData(WebKit::WebFrame* frame,
493 const char* data, size_t length,
494 bool& prevent_default);
495 virtual void didCommitProvisionalLoad(WebKit::WebFrame* frame,
496 bool is_new_navigation);
497 virtual void didClearWindowObject(WebKit::WebFrame* frame);
498 virtual void didCreateDocumentElement(WebKit::WebFrame* frame);
499 virtual void didReceiveTitle(WebKit::WebFrame* frame,
[email protected]a3bc4d12011-04-20 17:22:21500 const WebKit::WebString& title,
501 WebKit::WebTextDirection direction);
[email protected]42054a252011-05-17 18:02:13502 virtual void didChangeIcon(WebKit::WebFrame*,
503 WebKit::WebIconURL::Type) OVERRIDE;
[email protected]6e24cf12011-03-18 19:57:02504 virtual void didFinishDocumentLoad(WebKit::WebFrame* frame);
505 virtual void didHandleOnloadEvents(WebKit::WebFrame* frame);
506 virtual void didFailLoad(WebKit::WebFrame* frame,
507 const WebKit::WebURLError& error);
508 virtual void didFinishLoad(WebKit::WebFrame* frame);
509 virtual void didNavigateWithinPage(WebKit::WebFrame* frame,
510 bool is_new_navigation);
511 virtual void didUpdateCurrentHistoryItem(WebKit::WebFrame* frame);
512 virtual void assignIdentifierToRequest(WebKit::WebFrame* frame,
513 unsigned identifier,
514 const WebKit::WebURLRequest& request);
515 virtual void willSendRequest(WebKit::WebFrame* frame,
516 unsigned identifier,
517 WebKit::WebURLRequest& request,
518 const WebKit::WebURLResponse& redirect_response);
519 virtual void didReceiveResponse(WebKit::WebFrame* frame,
520 unsigned identifier,
521 const WebKit::WebURLResponse& response);
522 virtual void didFinishResourceLoad(WebKit::WebFrame* frame,
523 unsigned identifier);
524 virtual void didFailResourceLoad(WebKit::WebFrame* frame,
525 unsigned identifier,
526 const WebKit::WebURLError& error);
527 virtual void didLoadResourceFromMemoryCache(
528 WebKit::WebFrame* frame,
529 const WebKit::WebURLRequest& request,
530 const WebKit::WebURLResponse&);
531 virtual void didDisplayInsecureContent(WebKit::WebFrame* frame);
532 virtual void didRunInsecureContent(
533 WebKit::WebFrame* frame,
534 const WebKit::WebSecurityOrigin& origin,
535 const WebKit::WebURL& target);
[email protected]6e24cf12011-03-18 19:57:02536 virtual void didExhaustMemoryAvailableForScript(WebKit::WebFrame* frame);
537 virtual void didCreateScriptContext(WebKit::WebFrame* frame);
538 virtual void didDestroyScriptContext(WebKit::WebFrame* frame);
539 virtual void didCreateIsolatedScriptContext(WebKit::WebFrame* frame);
[email protected]6e24cf12011-03-18 19:57:02540 virtual void logCrossFramePropertyAccess(
541 WebKit::WebFrame* frame,
542 WebKit::WebFrame* target,
543 bool cross_origin,
544 const WebKit::WebString& property_name,
545 unsigned long long event_id);
[email protected]d812fd12011-05-27 23:05:07546 virtual void didUpdateLayout(WebKit::WebFrame* frame);
[email protected]6e24cf12011-03-18 19:57:02547 virtual void didChangeScrollOffset(WebKit::WebFrame* frame);
548 virtual void reportFindInPageMatchCount(int request_id,
549 int count,
550 bool final_update);
551 virtual void reportFindInPageSelection(int request_id,
552 int active_match_ordinal,
553 const WebKit::WebRect& sel);
554
555 virtual void openFileSystem(WebKit::WebFrame* frame,
556 WebKit::WebFileSystem::Type type,
557 long long size,
558 bool create,
559 WebKit::WebFileSystemCallbacks* callbacks);
560
[email protected]10e5cf12011-04-13 04:10:40561 virtual void queryStorageUsageAndQuota(
562 WebKit::WebFrame* frame,
563 WebKit::WebStorageQuotaType type,
564 WebKit::WebStorageQuotaCallbacks* callbacks);
565
566 virtual void requestStorageQuota(
567 WebKit::WebFrame* frame,
568 WebKit::WebStorageQuotaType type,
569 unsigned long long requested_size,
570 WebKit::WebStorageQuotaCallbacks* callbacks);
571
[email protected]6e24cf12011-03-18 19:57:02572 // webkit_glue::WebPluginPageDelegate implementation -------------------------
573
574 virtual webkit::npapi::WebPluginDelegate* CreatePluginDelegate(
575 const FilePath& file_path,
576 const std::string& mime_type);
577 virtual void CreatedPluginWindow(gfx::PluginWindowHandle handle);
578 virtual void WillDestroyPluginWindow(gfx::PluginWindowHandle handle);
579 virtual void DidMovePlugin(const webkit::npapi::WebPluginGeometry& move);
580 virtual void DidStartLoadingForPlugin();
581 virtual void DidStopLoadingForPlugin();
582 virtual WebKit::WebCookieJar* GetCookieJar();
583
584 // Please do not add your stuff randomly to the end here. If there is an
585 // appropriate section, add it there. If not, there are some random functions
586 // nearer to the top you can add it to.
[email protected]6e24cf12011-03-18 19:57:02587 virtual void DidFlushPaint();
588
[email protected]38b592902011-04-16 02:08:42589 // Cannot use std::set unfortunately since linked_ptr<> does not support
590 // operator<.
591 typedef std::vector<linked_ptr<webkit_glue::ImageResourceFetcher> >
592 ImageResourceFetcherList;
593
[email protected]6e24cf12011-03-18 19:57:02594 protected:
595 // RenderWidget overrides:
596 virtual void Close();
597 virtual void OnResize(const gfx::Size& new_size,
598 const gfx::Rect& resizer_rect);
599 virtual void DidInitiatePaint();
600 virtual webkit::ppapi::PluginInstance* GetBitmapForOptimizedPluginPaint(
601 const gfx::Rect& paint_bounds,
602 TransportDIB** dib,
603 gfx::Rect* location,
604 gfx::Rect* clip);
605 virtual gfx::Point GetScrollOffset();
606 virtual void DidHandleKeyEvent();
607 virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event);
608 virtual void OnSetFocus(bool enable);
609 virtual void OnWasHidden();
610 virtual void OnWasRestored(bool needs_repainting);
[email protected]65225772011-05-12 21:10:24611 virtual bool SupportsAsynchronousSwapBuffers() OVERRIDE;
[email protected]56ea1a62011-05-30 07:05:57612 virtual void OnImeSetComposition(
613 const string16& text,
614 const std::vector<WebKit::WebCompositionUnderline>& underlines,
615 int selection_start,
616 int selection_end) OVERRIDE;
617 virtual void OnImeConfirmComposition(const string16& text) OVERRIDE;
[email protected]ad26ef42011-06-17 07:59:45618 virtual ui::TextInputType GetTextInputType() OVERRIDE;
619 virtual bool CanComposeInline() OVERRIDE;
[email protected]6e24cf12011-03-18 19:57:02620
621 private:
[email protected]6e24cf12011-03-18 19:57:02622 // For unit tests.
623 friend class ExternalPopupMenuTest;
624 friend class PepperDeviceTest;
625 friend class RenderViewTest;
626
627 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuRemoveTest, RemoveOnChange);
628 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, NormalCase);
629 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, ShowPopupThenNavigate);
[email protected]6e24cf12011-03-18 19:57:02630 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, ImeComposition);
631 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, InsertCharacters);
632 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, JSBlockSentAfterPageLoad);
633 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, LastCommittedUpdateState);
634 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnHandleKeyboardEvent);
635 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnImeStateChanged);
636 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnNavStateChanged);
[email protected]6e24cf12011-03-18 19:57:02637 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnSetTextDirection);
[email protected]d466b8a2011-07-15 21:48:03638 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, StaleNavigationsIgnored);
[email protected]6e24cf12011-03-18 19:57:02639 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, UpdateTargetURLWithInvalidURL);
640#if defined(OS_MACOSX)
641 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, MacTestCmdUp);
642#endif
643
[email protected]6e24cf12011-03-18 19:57:02644 typedef std::map<GURL, double> HostZoomLevels;
645
[email protected]6e24cf12011-03-18 19:57:02646 // Identifies an accessibility notification from webkit.
647 struct RendererAccessibilityNotification {
648 public:
649 bool ShouldIncludeChildren();
650
651 // The webkit glue id of the accessibility object.
652 int32 id;
653
654 // The accessibility notification type.
655 WebKit::WebAccessibilityNotification type;
656 };
657
658 enum ErrorPageType {
659 DNS_ERROR,
660 HTTP_404,
661 CONNECTION_ERROR,
662 };
663
664 RenderView(RenderThreadBase* render_thread,
665 gfx::NativeViewId parent_hwnd,
666 int32 opener_id,
667 const RendererPreferences& renderer_prefs,
668 const WebPreferences& webkit_prefs,
669 SharedRenderViewCounter* counter,
670 int32 routing_id,
671 int64 session_storage_namespace_id,
672 const string16& frame_name);
673
674 // Do not delete directly. This class is reference counted.
675 virtual ~RenderView();
676
677 void UpdateURL(WebKit::WebFrame* frame);
[email protected]6b2f7a82011-04-25 19:30:51678 void UpdateTitle(WebKit::WebFrame* frame, const string16& title);
[email protected]6e24cf12011-03-18 19:57:02679 void UpdateSessionHistory(WebKit::WebFrame* frame);
680
681 // Update current main frame's encoding and send it to browser window.
682 // Since we want to let users see the right encoding info from menu
683 // before finishing loading, we call the UpdateEncoding in
684 // a) function:DidCommitLoadForFrame. When this function is called,
685 // that means we have got first data. In here we try to get encoding
686 // of page if it has been specified in http header.
687 // b) function:DidReceiveTitle. When this function is called,
688 // that means we have got specified title. Because in most of webpages,
689 // title tags will follow meta tags. In here we try to get encoding of
690 // page if it has been specified in meta tag.
691 // c) function:DidFinishDocumentLoadForFrame. When this function is
692 // called, that means we have got whole html page. In here we should
693 // finally get right encoding of page.
694 void UpdateEncoding(WebKit::WebFrame* frame,
695 const std::string& encoding_name);
696
697 void OpenURL(const GURL& url, const GURL& referrer,
698 WebKit::WebNavigationPolicy policy);
699
[email protected]6e24cf12011-03-18 19:57:02700 bool RunJavaScriptMessage(int type,
[email protected]4f5ce842011-05-27 19:34:41701 const string16& message,
702 const string16& default_value,
[email protected]6e24cf12011-03-18 19:57:02703 const GURL& frame_url,
[email protected]4f5ce842011-05-27 19:34:41704 string16* result);
[email protected]6e24cf12011-03-18 19:57:02705
706 // Sends a message and runs a nested message loop.
707 bool SendAndRunNestedMessageLoop(IPC::SyncMessage* message);
708
[email protected]6e24cf12011-03-18 19:57:02709 // Send queued accessibility notifications from the renderer to the browser.
710 void SendPendingAccessibilityNotifications();
711
712 // IPC message handlers ------------------------------------------------------
713 //
714 // The documentation for these functions should be in
715 // render_messages_internal.h for the message that the function is handling.
716
717 void OnAccessibilityDoDefaultAction(int acc_obj_id);
718 void OnAccessibilityNotificationsAck();
719 void OnAllowBindings(int enabled_bindings_flags);
[email protected]6e24cf12011-03-18 19:57:02720 void OnAllowScriptToClose(bool script_can_close);
721 void OnAsyncFileOpened(base::PlatformFileError error_code,
722 IPC::PlatformFileForTransit file_for_transit,
723 int message_id);
[email protected]eb415bf0e2011-04-14 02:45:42724 void OnPpapiBrokerChannelCreated(int request_id,
[email protected]2b657fd2011-04-18 16:00:47725 base::ProcessHandle broker_process_handle,
[email protected]d54305072011-06-22 20:58:43726 const IPC::ChannelHandle& handle);
[email protected]6e24cf12011-03-18 19:57:02727 void OnCancelDownload(int32 download_id);
728 void OnClearFocusedNode();
[email protected]992db4c2011-05-12 15:37:15729 void OnClosePage();
[email protected]6e24cf12011-03-18 19:57:02730#if defined(ENABLE_FLAPPER_HACKS)
731 void OnConnectTcpACK(int request_id,
732 IPC::PlatformFileForTransit socket_for_transit,
733 const PP_Flash_NetAddress& local_addr,
734 const PP_Flash_NetAddress& remote_addr);
735#endif
736 void OnContextMenuClosed(
737 const webkit_glue::CustomContextMenuContext& custom_context);
738 void OnCopy();
739 void OnCopyImageAt(int x, int y);
740#if defined(OS_MACOSX)
741 void OnCopyToFindPboard();
742#endif
743 void OnCut();
[email protected]6e24cf12011-03-18 19:57:02744 void OnCSSInsertRequest(const std::wstring& frame_xpath,
745 const std::string& css,
746 const std::string& id);
747 void OnCustomContextMenuAction(
748 const webkit_glue::CustomContextMenuContext& custom_context,
749 unsigned action);
750 void OnDelete();
751 void OnDeterminePageLanguage();
752 void OnDisableScrollbarsForSmallWindows(
753 const gfx::Size& disable_scrollbars_size_limit);
754 void OnDisassociateFromPopupCount();
[email protected]6e24cf12011-03-18 19:57:02755 void OnDragSourceEndedOrMoved(const gfx::Point& client_point,
756 const gfx::Point& screen_point,
757 bool ended,
758 WebKit::WebDragOperation drag_operation);
759 void OnDragSourceSystemDragEnded();
760 void OnDragTargetDrop(const gfx::Point& client_pt,
761 const gfx::Point& screen_pt);
762 void OnDragTargetDragEnter(const WebDropData& drop_data,
763 const gfx::Point& client_pt,
764 const gfx::Point& screen_pt,
765 WebKit::WebDragOperationsMask operations_allowed);
766 void OnDragTargetDragLeave();
767 void OnDragTargetDragOver(const gfx::Point& client_pt,
768 const gfx::Point& screen_pt,
769 WebKit::WebDragOperationsMask operations_allowed);
770 void OnEnablePreferredSizeChangedMode(int flags);
[email protected]600ea402011-04-12 00:01:51771 void OnEnumerateDirectoryResponse(int id, const std::vector<FilePath>& paths);
[email protected]6e24cf12011-03-18 19:57:02772 void OnExecuteEditCommand(const std::string& name, const std::string& value);
[email protected]6e24cf12011-03-18 19:57:02773 void OnFileChooserResponse(const std::vector<FilePath>& paths);
774 void OnFind(int request_id, const string16&, const WebKit::WebFindOptions&);
775 void OnFindReplyAck();
776 void OnEnableAccessibility();
[email protected]6e24cf12011-03-18 19:57:02777 void OnInstallMissingPlugin();
[email protected]6e24cf12011-03-18 19:57:02778 void OnMediaPlayerActionAt(const gfx::Point& location,
779 const WebKit::WebMediaPlayerAction& action);
780 void OnMoveOrResizeStarted();
781 void OnNavigate(const ViewMsg_Navigate_Params& params);
[email protected]6e24cf12011-03-18 19:57:02782 void OnPaste();
783#if defined(OS_MACOSX)
784 void OnPluginImeCompositionCompleted(const string16& text, int plugin_id);
785#endif
786 void OnRedo();
787 void OnReloadFrame();
788 void OnReplace(const string16& text);
789 void OnReservePageIDRange(int size_of_range);
790 void OnResetPageEncodingToDefault();
791 void OnScriptEvalRequest(const string16& frame_xpath,
792 const string16& jscript,
793 int id,
794 bool notify_result);
795 void OnSelectAll();
796 void OnSetAccessibilityFocus(int acc_obj_id);
797 void OnSetActive(bool active);
798 void OnSetAltErrorPageURL(const GURL& gurl);
799 void OnSetBackground(const SkBitmap& background);
[email protected]6e24cf12011-03-18 19:57:02800 void OnSetWebUIProperty(const std::string& name, const std::string& value);
801 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
802 void OnSetInitialFocus(bool reverse);
[email protected]54ca3ca892011-06-07 21:14:54803#if defined(OS_MACOSX)
804 void OnSetInLiveResize(bool in_live_resize);
805#endif
[email protected]6e24cf12011-03-18 19:57:02806 void OnScrollFocusedEditableNodeIntoView();
807 void OnSetPageEncoding(const std::string& encoding_name);
808 void OnSetRendererPrefs(const RendererPreferences& renderer_prefs);
[email protected]6e24cf12011-03-18 19:57:02809#if defined(OS_MACOSX)
810 void OnSetWindowVisibility(bool visible);
811#endif
812 void OnSetZoomLevel(double zoom_level);
813 void OnSetZoomLevelForLoadingURL(const GURL& url, double zoom_level);
814 void OnShouldClose();
815 void OnStop();
816 void OnStopFinding(const ViewMsg_StopFinding_Params& params);
[email protected]992db4c2011-05-12 15:37:15817 void OnSwapOut(const ViewMsg_SwapOut_Params& params);
[email protected]6e24cf12011-03-18 19:57:02818 void OnThemeChanged();
[email protected]6e24cf12011-03-18 19:57:02819 void OnUndo();
[email protected]6e24cf12011-03-18 19:57:02820 void OnUpdateTargetURLAck();
821 void OnUpdateWebPreferences(const WebPreferences& prefs);
822#if defined(OS_MACOSX)
823 void OnWindowFrameChanged(const gfx::Rect& window_frame,
824 const gfx::Rect& view_frame);
825 void OnSelectPopupMenuItem(int selected_index);
826#endif
827 void OnZoom(PageZoom::Function function);
[email protected]6e24cf12011-03-18 19:57:02828
829 // Adding a new message handler? Please add it in alphabetical order above
830 // and put it in the same position in the .cc file.
831
832 // Misc private functions ----------------------------------------------------
833
[email protected]6e24cf12011-03-18 19:57:02834 void AltErrorPageFinished(WebKit::WebFrame* frame,
835 const WebKit::WebURLError& original_error,
836 const std::string& html);
837
[email protected]d812fd12011-05-27 23:05:07838 // Check whether the preferred size has changed.
[email protected]6e24cf12011-03-18 19:57:02839 void CheckPreferredSize();
840
[email protected]5e56df82011-04-18 17:00:15841 // This callback is triggered when DownloadFavicon completes, either
842 // succesfully or with a failure. See DownloadFavicon for more
843 // details.
844 void DidDownloadFavicon(webkit_glue::ImageResourceFetcher* fetcher,
845 const SkBitmap& image);
[email protected]6e24cf12011-03-18 19:57:02846
[email protected]5e56df82011-04-18 17:00:15847 // Requests to download a favicon image. When done, the RenderView
848 // is notified by way of DidDownloadFavicon. Returns true if the
849 // request was successfully started, false otherwise. id is used to
850 // uniquely identify the request and passed back to the
851 // DidDownloadFavicon method. If the image has multiple frames, the
852 // frame whose size is image_size is returned. If the image doesn't
853 // have a frame at the specified size, the first is returned.
854 bool DownloadFavicon(int id, const GURL& image_url, int image_size);
[email protected]6e24cf12011-03-18 19:57:02855
[email protected]6e24cf12011-03-18 19:57:02856 GURL GetAlternateErrorPageURL(const GURL& failed_url,
857 ErrorPageType error_type);
858
859 // Locates a sub frame with given xpath
860 WebKit::WebFrame* GetChildFrame(const std::wstring& frame_xpath) const;
861
[email protected]6e24cf12011-03-18 19:57:02862 WebUIBindings* GetWebUIBindings();
863
[email protected]6e24cf12011-03-18 19:57:02864 // Should only be called if this object wraps a PluginDocument.
865 WebKit::WebPlugin* GetWebPluginFromPluginDocument();
866
[email protected]d466b8a2011-07-15 21:48:03867 // Returns true if the |params| navigation is to an entry that has been
868 // cropped due to a recent navigation the browser did not know about.
869 bool IsBackForwardToStaleEntry(const ViewMsg_Navigate_Params& params,
870 bool is_reload);
871
[email protected]6e24cf12011-03-18 19:57:02872 // Returns false unless this is a top-level navigation that crosses origins.
873 bool IsNonLocalTopLevelNavigation(const GURL& url,
874 WebKit::WebFrame* frame,
875 WebKit::WebNavigationType type);
876
[email protected]6e24cf12011-03-18 19:57:02877 bool MaybeLoadAlternateErrorPage(WebKit::WebFrame* frame,
878 const WebKit::WebURLError& error,
879 bool replace);
880
881 // Starts nav_state_sync_timer_ if it isn't already running.
882 void StartNavStateSyncTimerIfNecessary();
883
884 // Dispatches the current navigation state to the browser. Called on a
885 // periodic timer so we don't send too many messages.
886 void SyncNavigationState();
887
[email protected]e63c4d72011-05-31 22:38:29888#if defined(OS_POSIX) && !defined(OS_MACOSX)
[email protected]6e24cf12011-03-18 19:57:02889 void UpdateFontRenderingFromRendererPrefs();
890#else
891 void UpdateFontRenderingFromRendererPrefs() {}
892#endif
893
894 // Update the target url and tell the browser that the target URL has changed.
895 // If |url| is empty, show |fallback_url|.
896 void UpdateTargetURL(const GURL& url, const GURL& fallback_url);
897
[email protected]6e24cf12011-03-18 19:57:02898 // ---------------------------------------------------------------------------
899 // ADDING NEW FUNCTIONS? Please keep private functions alphabetized and put
900 // it in the same order in the .cc file as it was in the header.
901 // ---------------------------------------------------------------------------
902
903 // Settings ------------------------------------------------------------------
904
905 WebPreferences webkit_preferences_;
906 RendererPreferences renderer_preferences_;
907
[email protected]6e24cf12011-03-18 19:57:02908 HostZoomLevels host_zoom_levels_;
909
910 // Whether content state (such as form state, scroll position and page
911 // contents) should be sent to the browser immediately. This is normally
912 // false, but set to true by some tests.
913 bool send_content_state_immediately_;
914
[email protected]6e24cf12011-03-18 19:57:02915 // Bitwise-ORed set of extra bindings that have been enabled. See
916 // BindingsPolicy for details.
917 int enabled_bindings_;
918
919 // The alternate error page URL, if one exists.
920 GURL alternate_error_page_url_;
921
922 // If true, we send IPC messages when |preferred_size_| changes.
923 bool send_preferred_size_changes_;
924
925 // If non-empty, and |send_preferred_size_changes_| is true, disable drawing
926 // scroll bars on windows smaller than this size. Used for windows that the
927 // browser resizes to the size of the content, such as browser action popups.
928 // If a render view is set to the minimum size of its content, webkit may add
929 // scroll bars. This makes sense for fixed sized windows, but it does not
930 // make sense when the size of the view was chosen to fit the content.
931 // This setting ensures that no scroll bars are drawn. The size limit exists
932 // because if the view grows beyond a size known to the browser, scroll bars
933 // should be drawn.
934 gfx::Size disable_scrollbars_size_limit_;
935
[email protected]6e24cf12011-03-18 19:57:02936 // Loading state -------------------------------------------------------------
937
938 // True if the top level frame is currently being loaded.
939 bool is_loading_;
940
941 // The gesture that initiated the current navigation.
942 NavigationGesture navigation_gesture_;
943
944 // Used for popups.
945 bool opened_by_user_gesture_;
946 GURL creator_url_;
947
948 // Whether this RenderView was created by a frame that was suppressing its
949 // opener. If so, we may want to load pages in a separate process. See
950 // decidePolicyForNavigation for details.
951 bool opener_suppressed_;
952
953 // If we are handling a top-level client-side redirect, this tracks the URL
954 // of the page that initiated it. Specifically, when a load is committed this
955 // is used to determine if that load originated from a client-side redirect.
956 // It is empty if there is no top-level client-side redirect.
957 GURL completed_client_redirect_src_;
958
[email protected]6e24cf12011-03-18 19:57:02959 // Holds state pertaining to a navigation that we initiated. This is held by
960 // the WebDataSource::ExtraData attribute. We use pending_navigation_state_
961 // as a temporary holder for the state until the WebDataSource corresponding
962 // to the new navigation is created. See DidCreateDataSource.
963 scoped_ptr<NavigationState> pending_navigation_state_;
964
965 // Timer used to delay the updating of nav state (see SyncNavigationState).
966 base::OneShotTimer<RenderView> nav_state_sync_timer_;
967
[email protected]6e24cf12011-03-18 19:57:02968 // Page IDs ------------------------------------------------------------------
969 //
970 // Page IDs allow the browser to identify pages in each renderer process for
971 // keeping back/forward history in sync.
972
973 // ID of the current page. Note that this is NOT updated for every main
974 // frame navigation, only for "regular" navigations that go into session
975 // history. In particular, client redirects, like the page cycler uses
976 // (document.location.href="foo") do not count as regular navigations and do
977 // not increment the page id.
978 int32 page_id_;
979
980 // Indicates the ID of the last page that we sent a FrameNavigate to the
981 // browser for. This is used to determine if the most recent transition
982 // generated a history entry (less than page_id_), or not (equal to or
983 // greater than). Note that this will be greater than page_id_ if the user
984 // goes back.
985 int32 last_page_id_sent_to_browser_;
986
[email protected]6e24cf12011-03-18 19:57:02987 // The next available page ID to use. This ensures that the page IDs are
988 // globally unique in the renderer.
989 static int32 next_page_id_;
990
[email protected]d466b8a2011-07-15 21:48:03991 // The offset of the current item in the history list.
992 int history_list_offset_;
993
994 // The RenderView's current impression of the history length. This includes
995 // any items that have committed in this process, but because of cross-process
996 // navigations, the history may have some entries that were committed in other
997 // processes. We won't know about them until the next navigation in this
998 // process.
999 int history_list_length_;
1000
1001 // The list of page IDs for each history item this RenderView knows about.
1002 // Some entries may be -1 if they were rendered by other processes or were
1003 // restored from a previous session. This lets us detect attempts to
1004 // navigate to stale entries that have been cropped from our history.
1005 std::vector<int32> history_page_ids_;
1006
[email protected]6e24cf12011-03-18 19:57:021007 // Page info -----------------------------------------------------------------
1008
1009 // The last gotten main frame's encoding.
1010 std::string last_encoding_name_;
1011
[email protected]6e24cf12011-03-18 19:57:021012 // UI state ------------------------------------------------------------------
1013
1014 // The state of our target_url transmissions. When we receive a request to
1015 // send a URL to the browser, we set this to TARGET_INFLIGHT until an ACK
1016 // comes back - if a new request comes in before the ACK, we store the new
1017 // URL in pending_target_url_ and set the status to TARGET_PENDING. If an
1018 // ACK comes back and we are in TARGET_PENDING, we send the stored URL and
1019 // revert to TARGET_INFLIGHT.
1020 //
1021 // We don't need a queue of URLs to send, as only the latest is useful.
1022 enum {
1023 TARGET_NONE,
1024 TARGET_INFLIGHT, // We have a request in-flight, waiting for an ACK
1025 TARGET_PENDING // INFLIGHT + we have a URL waiting to be sent
1026 } target_url_status_;
1027
1028 // The URL we show the user in the status bar. We use this to determine if we
1029 // want to send a new one (we do not need to send duplicates). It will be
1030 // equal to either |mouse_over_url_| or |focus_url_|, depending on which was
1031 // updated last.
1032 GURL target_url_;
1033
1034 // The URL the user's mouse is hovering over.
1035 GURL mouse_over_url_;
1036
1037 // The URL that has keyboard focus.
1038 GURL focus_url_;
1039
1040 // The next target URL we want to send to the browser.
1041 GURL pending_target_url_;
1042
[email protected]6e24cf12011-03-18 19:57:021043 // The text selection the last time DidChangeSelection got called.
1044 std::string last_selection_;
1045
1046 // View ----------------------------------------------------------------------
1047
[email protected]6e24cf12011-03-18 19:57:021048 // Cache the preferred size of the page in order to prevent sending the IPC
1049 // when layout() recomputes but doesn't actually change sizes.
1050 gfx::Size preferred_size_;
1051
[email protected]1e0c8e02011-05-25 07:49:371052 // Used to delay determining the preferred size (to avoid intermediate
1053 // states for the sizes).
1054 base::OneShotTimer<RenderView> check_preferred_size_timer_;
1055
[email protected]6e24cf12011-03-18 19:57:021056#if defined(OS_MACOSX)
1057 // Track the fake plugin window handles allocated on the browser side for
1058 // the accelerated compositor and (currently) accelerated plugins so that
1059 // we can discard them when the view goes away.
1060 std::set<gfx::PluginWindowHandle> fake_plugin_window_handles_;
1061#endif
1062
1063 // Plugins -------------------------------------------------------------------
1064
1065 // Remember the first uninstalled plugin, so that we can ask the plugin
1066 // to install itself when user clicks on the info bar.
1067 base::WeakPtr<webkit::npapi::WebPluginDelegate> first_default_plugin_;
1068
1069 PepperPluginDelegateImpl pepper_delegate_;
1070
1071 // All the currently active plugin delegates for this RenderView; kept so that
1072 // we can enumerate them to send updates about things like window location
1073 // or tab focus and visibily. These are non-owning references.
1074 std::set<WebPluginDelegateProxy*> plugin_delegates_;
1075
1076 // Helper objects ------------------------------------------------------------
1077
[email protected]6e24cf12011-03-18 19:57:021078 ScopedRunnableMethodFactory<RenderView> accessibility_method_factory_;
1079
1080 RendererWebCookieJarImpl cookie_jar_;
1081
1082 // The next group of objects all implement RenderViewObserver, so are deleted
1083 // along with the RenderView automatically. This is why we just store weak
1084 // references.
1085
[email protected]6e24cf12011-03-18 19:57:021086 // Holds a reference to the service which provides desktop notifications.
1087 NotificationProvider* notification_provider_;
1088
1089 // The geolocation dispatcher attached to this view, lazily initialized.
1090 GeolocationDispatcher* geolocation_dispatcher_;
1091
1092 // The speech dispatcher attached to this view, lazily initialized.
1093 SpeechInputDispatcher* speech_input_dispatcher_;
1094
1095 // Device orientation dispatcher attached to this view; lazily initialized.
1096 DeviceOrientationDispatcher* device_orientation_dispatcher_;
1097
[email protected]ab2c4732011-07-20 19:57:401098 // MediaStreamImpl attached to this view; lazily initialized.
1099 scoped_refptr<MediaStreamImpl> media_stream_impl_;
1100
[email protected]6e24cf12011-03-18 19:57:021101 // Handles accessibility requests into the renderer side, as well as
1102 // maintains the cache and other features of the accessibility tree.
1103 scoped_ptr<WebKit::WebAccessibilityCache> accessibility_;
1104
1105 // Collect renderer accessibility notifications until they are ready to be
1106 // sent to the browser.
1107 std::vector<RendererAccessibilityNotification>
1108 pending_accessibility_notifications_;
1109
1110 // Set if we are waiting for a accessibility notification ack.
1111 bool accessibility_ack_pending_;
1112
[email protected]6e24cf12011-03-18 19:57:021113 // Dispatches all P2P socket used by the renderer.
1114 P2PSocketDispatcher* p2p_socket_dispatcher_;
1115
1116 // Misc ----------------------------------------------------------------------
1117
1118 // The current and pending file chooser completion objects. If the queue is
1119 // nonempty, the first item represents the currently running file chooser
1120 // callback, and the remaining elements are the other file chooser completion
1121 // still waiting to be run (in order).
1122 struct PendingFileChooser;
1123 std::deque< linked_ptr<PendingFileChooser> > file_chooser_completions_;
1124
[email protected]600ea402011-04-12 00:01:511125 // The current directory enumeration callback
1126 std::map<int, WebKit::WebFileChooserCompletion*> enumeration_completions_;
1127 int enumeration_completion_id_;
1128
[email protected]6e24cf12011-03-18 19:57:021129 // The SessionStorage namespace that we're assigned to has an ID, and that ID
1130 // is passed to us upon creation. WebKit asks for this ID upon first use and
1131 // uses it whenever asking the browser process to allocate new storage areas.
1132 int64 session_storage_namespace_id_;
1133
1134 // The total number of unrequested popups that exist and can be followed back
1135 // to a common opener. This count is shared among all RenderViews created
1136 // with createView(). All popups are treated as unrequested until
1137 // specifically instructed otherwise by the Browser process.
1138 scoped_refptr<SharedRenderViewCounter> shared_popup_counter_;
1139
1140 // Whether this is a top level window (instead of a popup). Top level windows
1141 // shouldn't count against their own |shared_popup_counter_|.
1142 bool decrement_shared_popup_at_destruction_;
1143
1144 // If the browser hasn't sent us an ACK for the last FindReply we sent
1145 // to it, then we need to queue up the message (keeping only the most
1146 // recent message if new ones come in).
1147 scoped_ptr<IPC::Message> queued_find_reply_message_;
1148
1149 // Stores edit commands associated to the next key event.
1150 // Shall be cleared as soon as the next key event is processed.
1151 EditCommands edit_commands_;
1152
[email protected]6e24cf12011-03-18 19:57:021153 // Allows Web UI pages (new tab page, etc.) to talk to the browser. The JS
1154 // object is only exposed when Web UI bindings are enabled.
1155 scoped_ptr<WebUIBindings> web_ui_bindings_;
1156
[email protected]6e24cf12011-03-18 19:57:021157 // The external popup for the currently showing select popup.
1158 scoped_ptr<ExternalPopupMenu> external_popup_menu_;
1159
1160 // The node that the context menu was pressed over.
1161 WebKit::WebNode context_menu_node_;
1162
1163 // Reports load progress to the browser.
1164 scoped_ptr<LoadProgressTracker> load_progress_tracker_;
1165
1166 // All the registered observers. We expect this list to be small, so vector
1167 // is fine.
1168 ObserverList<RenderViewObserver> observers_;
1169
1170 // ---------------------------------------------------------------------------
1171 // ADDING NEW DATA? Please see if it fits appropriately in one of the above
1172 // sections rather than throwing it randomly at the end. If you're adding a
1173 // bunch of stuff, you should probably create a helper class and put your
1174 // data and methods on that to avoid bloating RenderView more. You can use
1175 // the Observer interface to filter IPC messages and receive frame change
1176 // notifications.
1177 // ---------------------------------------------------------------------------
1178
1179 DISALLOW_COPY_AND_ASSIGN(RenderView);
1180};
1181
1182#endif // CONTENT_RENDERER_RENDER_VIEW_H_