blob: 8d3d9c6d431d844b7da3dbb4006f5b3ebd52b132 [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;
60class NavigationState;
61class NotificationProvider;
62class P2PSocketDispatcher;
63class PepperDeviceTest;
64class PrintWebViewHelper;
65class RenderViewObserver;
66class RenderViewVisitor;
[email protected]ea192e82011-04-11 19:16:0267class RenderWidgetFullscreenPepper;
[email protected]6e24cf12011-03-18 19:57:0268class SkBitmap;
69class SpeechInputDispatcher;
[email protected]6e24cf12011-03-18 19:57:0270class WebPluginDelegatePepper;
71class WebPluginDelegateProxy;
[email protected]55722152011-03-22 01:33:5372class WebUIBindings;
[email protected]6e24cf12011-03-18 19:57:0273struct ContextMenuMediaParams;
74struct PP_Flash_NetAddress;
[email protected]6e24cf12011-03-18 19:57:0275struct ViewHostMsg_RunFileChooser_Params;
[email protected]992db4c2011-05-12 15:37:1576struct ViewMsg_SwapOut_Params;
[email protected]6e24cf12011-03-18 19:57:0277struct ViewMsg_Navigate_Params;
78struct ViewMsg_StopFinding_Params;
[email protected]6e24cf12011-03-18 19:57:0279struct WebDropData;
80
81namespace base {
82class WaitableEvent;
83}
84
85namespace chrome {
86class ChromeContentRendererClient;
87}
88
89namespace gfx {
90class Point;
91class Rect;
92}
93
94namespace webkit {
95
96namespace npapi {
97class PluginGroup;
98} // namespace npapi
99
100namespace ppapi {
[email protected]6e24cf12011-03-18 19:57:02101class PluginInstance;
102class PluginModule;
103} // namespace ppapi
104
105} // namespace webkit
106
107namespace webkit_glue {
108struct CustomContextMenuContext;
109class ImageResourceFetcher;
110struct FileUploadData;
111struct FormData;
112struct PasswordFormFillData;
113class ResourceFetcher;
114}
115
116namespace WebKit {
117class WebAccessibilityCache;
118class WebAccessibilityObject;
119class WebApplicationCacheHost;
120class WebApplicationCacheHostClient;
121class WebDataSource;
122class WebDocument;
123class WebDragData;
124class WebFrame;
125class WebGeolocationClient;
126class WebGeolocationServiceInterface;
[email protected]42054a252011-05-17 18:02:13127class WebIconURL;
[email protected]6e24cf12011-03-18 19:57:02128class WebImage;
129class WebInputElement;
130class WebKeyboardEvent;
131class WebMediaPlayer;
132class WebMediaPlayerClient;
133class WebMouseEvent;
134class WebPlugin;
135class WebSpeechInputController;
136class WebSpeechInputListener;
137class WebStorageNamespace;
[email protected]6e24cf12011-03-18 19:57:02138class WebURLRequest;
139class WebView;
140struct WebContextMenuData;
141struct WebFileChooserParams;
142struct WebFindOptions;
143struct WebMediaPlayerAction;
144struct WebPluginParams;
145struct WebPoint;
146struct WebWindowFeatures;
147}
148
149// We need to prevent a page from trying to create infinite popups. It is not
150// as simple as keeping a count of the number of immediate children
151// popups. Having an html file that window.open()s itself would create
152// an unlimited chain of RenderViews who only have one RenderView child.
153//
154// Therefore, each new top level RenderView creates a new counter and shares it
155// with all its children and grandchildren popup RenderViews created with
156// createView() to have a sort of global limit for the page so no more than
157// kMaximumNumberOfPopups popups are created.
158//
159// This is a RefCounted holder of an int because I can't say
160// scoped_refptr<int>.
161typedef base::RefCountedData<int> SharedRenderViewCounter;
162
163//
164// RenderView is an object that manages a WebView object, and provides a
165// communication interface with an embedding application process
166//
167class RenderView : public RenderWidget,
168 public WebKit::WebViewClient,
169 public WebKit::WebFrameClient,
[email protected]6e24cf12011-03-18 19:57:02170 public webkit::npapi::WebPluginPageDelegate,
171 public base::SupportsWeakPtr<RenderView> {
172 public:
173 // Creates a new RenderView. The parent_hwnd specifies a HWND to use as the
174 // parent of the WebView HWND that will be created. If this is a constrained
175 // popup or as a new tab, opener_id is the routing ID of the RenderView
176 // responsible for creating this RenderView (corresponding to parent_hwnd).
177 // |counter| is either a currently initialized counter, or NULL (in which case
178 // we treat this RenderView as a top level window).
179 static RenderView* Create(
180 RenderThreadBase* render_thread,
181 gfx::NativeViewId parent_hwnd,
[email protected]c03a6e72011-04-19 21:42:06182 gfx::PluginWindowHandle compositing_surface,
[email protected]6e24cf12011-03-18 19:57:02183 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
205 // completes or is aborted.
206 void OnViewContextSwapBuffersComplete();
207 void OnViewContextSwapBuffersAborted();
208
[email protected]9966325b2011-04-18 05:00:10209 int page_id() const { return page_id_; }
210 PepperPluginDelegateImpl* pepper_delegate() { return &pepper_delegate_; }
[email protected]6e24cf12011-03-18 19:57:02211
212 AudioMessageFilter* audio_message_filter() {
213 return audio_message_filter_;
214 }
215
216 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.
238 P2PSocketDispatcher* p2p_socket_dispatcher() {
239 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.
247 void EvaluateScript(const string16& frame_xpath,
248 const string16& jscript,
249 int id,
250 bool notify_result);
251
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.
265 WebKit::WebNode GetFocusedNode() const;
266
267 // Returns true if the parameter node is a textfield, text area or a content
268 // editable div.
269 bool IsEditableNode(const WebKit::WebNode& node);
270
[email protected]9966325b2011-04-18 05:00:10271 void LoadNavigationErrorPage(WebKit::WebFrame* frame,
272 const WebKit::WebURLRequest& failed_request,
273 const WebKit::WebURLError& error,
274 const std::string& html,
275 bool replace);
276
[email protected]6e24cf12011-03-18 19:57:02277 // Plugin-related functions --------------------------------------------------
278 // (See also WebPluginPageDelegate implementation.)
279
280 // Notification that the given plugin has crashed.
281 void PluginCrashed(const FilePath& plugin_path);
282
283 // Notification that the default plugin has done something about a missing
284 // plugin. See default_plugin_shared.h for possible values of |status|.
285 void OnMissingPluginStatus(WebPluginDelegateProxy* delegate,
286 int status);
287
[email protected]9966325b2011-04-18 05:00:10288 // Create a new NPAPI plugin.
289 WebKit::WebPlugin* CreateNPAPIPlugin(WebKit::WebFrame* frame,
290 const WebKit::WebPluginParams& params,
291 const FilePath& path,
292 const std::string& mime_type);
293
294 // Create a new Pepper plugin.
295 WebKit::WebPlugin* CreatePepperPlugin(
296 WebKit::WebFrame* frame,
297 const WebKit::WebPluginParams& params,
298 const FilePath& path,
299 webkit::ppapi::PluginModule* pepper_module);
300
[email protected]6e24cf12011-03-18 19:57:02301 // Creates a fullscreen container for a pepper plugin instance.
[email protected]ea192e82011-04-11 19:16:02302 RenderWidgetFullscreenPepper* CreatePepperFullscreenContainer(
[email protected]6e24cf12011-03-18 19:57:02303 webkit::ppapi::PluginInstance* plugin);
304
305 // Create a new plugin without checking the content settings.
306 WebKit::WebPlugin* CreatePluginNoCheck(WebKit::WebFrame* frame,
307 const WebKit::WebPluginParams& params);
308
[email protected]56ea1a62011-05-30 07:05:57309 // Informs the render view that a PPAPI plugin has gained or lost focus.
310 void PpapiPluginFocusChanged();
311
[email protected]6e24cf12011-03-18 19:57:02312#if defined(OS_MACOSX)
313 // Informs the render view that the given plugin has gained or lost focus.
314 void PluginFocusChanged(bool focused, int plugin_id);
315
316 // Starts plugin IME.
317 void StartPluginIme();
318
319 // Helper routines for accelerated plugin support. Used by the
320 // WebPluginDelegateProxy, which has a pointer to the RenderView.
321 gfx::PluginWindowHandle AllocateFakePluginWindowHandle(bool opaque,
322 bool root);
323 void DestroyFakePluginWindowHandle(gfx::PluginWindowHandle window);
324 void AcceleratedSurfaceSetIOSurface(gfx::PluginWindowHandle window,
325 int32 width,
326 int32 height,
327 uint64 io_surface_identifier);
328 TransportDIB::Handle AcceleratedSurfaceAllocTransportDIB(size_t size);
329 void AcceleratedSurfaceFreeTransportDIB(TransportDIB::Id dib_id);
330 void AcceleratedSurfaceSetTransportDIB(gfx::PluginWindowHandle window,
331 int32 width,
332 int32 height,
333 TransportDIB::Handle transport_dib);
334 void AcceleratedSurfaceBuffersSwapped(gfx::PluginWindowHandle window,
335 uint64 surface_id);
336#endif
337
338 void RegisterPluginDelegate(WebPluginDelegateProxy* delegate);
339 void UnregisterPluginDelegate(WebPluginDelegateProxy* delegate);
340
341 // IPC::Channel::Listener implementation -------------------------------------
342
343 virtual bool OnMessageReceived(const IPC::Message& msg);
344
345 // WebKit::WebWidgetClient implementation ------------------------------------
346
347 // Most methods are handled by RenderWidget.
348 virtual void didFocus();
349 virtual void didBlur();
350 virtual void show(WebKit::WebNavigationPolicy policy);
351 virtual void runModal();
352
353 // WebKit::WebViewClient implementation --------------------------------------
354
355 virtual WebKit::WebView* createView(
356 WebKit::WebFrame* creator,
357 const WebKit::WebURLRequest& request,
358 const WebKit::WebWindowFeatures& features,
359 const WebKit::WebString& frame_name);
360 virtual WebKit::WebWidget* createPopupMenu(WebKit::WebPopupType popup_type);
361 virtual WebKit::WebWidget* createPopupMenu(
362 const WebKit::WebPopupMenuInfo& info);
363 virtual WebKit::WebExternalPopupMenu* createExternalPopupMenu(
364 const WebKit::WebPopupMenuInfo& popup_menu_info,
365 WebKit::WebExternalPopupMenuClient* popup_menu_client);
366 virtual WebKit::WebStorageNamespace* createSessionStorageNamespace(
367 unsigned quota);
368 virtual void didAddMessageToConsole(
369 const WebKit::WebConsoleMessage& message,
370 const WebKit::WebString& source_name,
371 unsigned source_line);
372 virtual void printPage(WebKit::WebFrame* frame);
373 virtual WebKit::WebNotificationPresenter* notificationPresenter();
[email protected]8a58c1c2011-04-19 18:40:12374 virtual bool enumerateChosenDirectory(
375 const WebKit::WebString& path,
376 WebKit::WebFileChooserCompletion* chooser_completion);
[email protected]6e24cf12011-03-18 19:57:02377 virtual void didStartLoading();
378 virtual void didStopLoading();
379 virtual void didChangeLoadProgress(WebKit::WebFrame* frame,
380 double load_progress);
381 virtual bool isSmartInsertDeleteEnabled();
382 virtual bool isSelectTrailingWhitespaceEnabled();
383 virtual void didChangeSelection(bool is_selection_empty);
384 virtual void didExecuteCommand(const WebKit::WebString& command_name);
385 virtual bool handleCurrentKeyboardEvent();
[email protected]6e24cf12011-03-18 19:57:02386 virtual bool runFileChooser(
387 const WebKit::WebFileChooserParams& params,
388 WebKit::WebFileChooserCompletion* chooser_completion);
389 virtual void runModalAlertDialog(WebKit::WebFrame* frame,
390 const WebKit::WebString& message);
391 virtual bool runModalConfirmDialog(WebKit::WebFrame* frame,
392 const WebKit::WebString& message);
393 virtual bool runModalPromptDialog(WebKit::WebFrame* frame,
394 const WebKit::WebString& message,
395 const WebKit::WebString& default_value,
396 WebKit::WebString* actual_value);
397 virtual bool runModalBeforeUnloadDialog(WebKit::WebFrame* frame,
398 const WebKit::WebString& message);
399 virtual void showContextMenu(WebKit::WebFrame* frame,
400 const WebKit::WebContextMenuData& data);
401 virtual bool supportsFullscreen();
402 virtual void enterFullscreenForNode(const WebKit::WebNode&);
403 virtual void exitFullscreenForNode(const WebKit::WebNode&);
404 virtual void setStatusText(const WebKit::WebString& text);
405 virtual void setMouseOverURL(const WebKit::WebURL& url);
406 virtual void setKeyboardFocusURL(const WebKit::WebURL& url);
[email protected]6e24cf12011-03-18 19:57:02407 virtual void startDragging(const WebKit::WebDragData& data,
408 WebKit::WebDragOperationsMask mask,
409 const WebKit::WebImage& image,
410 const WebKit::WebPoint& imageOffset);
411 virtual bool acceptsLoadDrops();
412 virtual void focusNext();
413 virtual void focusPrevious();
414 virtual void focusedNodeChanged(const WebKit::WebNode& node);
415 virtual void navigateBackForwardSoon(int offset);
416 virtual int historyBackListCount();
417 virtual int historyForwardListCount();
418 virtual void postAccessibilityNotification(
419 const WebKit::WebAccessibilityObject& obj,
420 WebKit::WebAccessibilityNotification notification);
421 virtual void didUpdateInspectorSetting(const WebKit::WebString& key,
422 const WebKit::WebString& value);
423 virtual WebKit::WebGeolocationClient* geolocationClient();
424 virtual WebKit::WebSpeechInputController* speechInputController(
425 WebKit::WebSpeechInputListener* listener);
426 virtual WebKit::WebDeviceOrientationClient* deviceOrientationClient();
427 virtual void zoomLimitsChanged(double minimum_level, double maximum_level);
428 virtual void zoomLevelChanged();
429 virtual void registerProtocolHandler(const WebKit::WebString& scheme,
430 const WebKit::WebString& base_url,
431 const WebKit::WebString& url,
432 const WebKit::WebString& title);
[email protected]94dec932011-05-26 20:04:21433 virtual WebKit::WebPageVisibilityState visibilityState() const;
[email protected]6e24cf12011-03-18 19:57:02434
435 // WebKit::WebFrameClient implementation -------------------------------------
436
437 virtual WebKit::WebPlugin* createPlugin(
438 WebKit::WebFrame* frame,
439 const WebKit::WebPluginParams& params);
440 virtual WebKit::WebWorker* createWorker(WebKit::WebFrame* frame,
441 WebKit::WebWorkerClient* client);
442 virtual WebKit::WebSharedWorker* createSharedWorker(
443 WebKit::WebFrame* frame, const WebKit::WebURL& url,
444 const WebKit::WebString& name, unsigned long long documentId);
445 virtual WebKit::WebMediaPlayer* createMediaPlayer(
446 WebKit::WebFrame* frame,
447 WebKit::WebMediaPlayerClient* client);
448 virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(
449 WebKit::WebFrame* frame,
450 WebKit::WebApplicationCacheHostClient* client);
451 virtual WebKit::WebCookieJar* cookieJar(WebKit::WebFrame* frame);
452 virtual void frameDetached(WebKit::WebFrame* frame);
453 virtual void willClose(WebKit::WebFrame* frame);
[email protected]6e24cf12011-03-18 19:57:02454 virtual void loadURLExternally(WebKit::WebFrame* frame,
455 const WebKit::WebURLRequest& request,
456 WebKit::WebNavigationPolicy policy);
457 virtual WebKit::WebNavigationPolicy decidePolicyForNavigation(
458 WebKit::WebFrame* frame,
459 const WebKit::WebURLRequest& request,
460 WebKit::WebNavigationType type,
461 const WebKit::WebNode&,
462 WebKit::WebNavigationPolicy default_policy,
463 bool is_redirect);
464 virtual bool canHandleRequest(WebKit::WebFrame* frame,
465 const WebKit::WebURLRequest& request);
466 virtual WebKit::WebURLError cannotHandleRequestError(
467 WebKit::WebFrame* frame,
468 const WebKit::WebURLRequest& request);
469 virtual WebKit::WebURLError cancelledError(
470 WebKit::WebFrame* frame,
471 const WebKit::WebURLRequest& request);
472 virtual void unableToImplementPolicyWithError(
473 WebKit::WebFrame* frame,
474 const WebKit::WebURLError& error);
475 virtual void willSendSubmitEvent(WebKit::WebFrame* frame,
476 const WebKit::WebFormElement& form);
477 virtual void willSubmitForm(WebKit::WebFrame* frame,
478 const WebKit::WebFormElement& form);
479 virtual void willPerformClientRedirect(WebKit::WebFrame* frame,
480 const WebKit::WebURL& from,
481 const WebKit::WebURL& to,
482 double interval,
483 double fire_time);
484 virtual void didCancelClientRedirect(WebKit::WebFrame* frame);
485 virtual void didCompleteClientRedirect(WebKit::WebFrame* frame,
486 const WebKit::WebURL& from);
487 virtual void didCreateDataSource(WebKit::WebFrame* frame,
488 WebKit::WebDataSource* datasource);
489 virtual void didStartProvisionalLoad(WebKit::WebFrame* frame);
490 virtual void didReceiveServerRedirectForProvisionalLoad(
491 WebKit::WebFrame* frame);
492 virtual void didFailProvisionalLoad(WebKit::WebFrame* frame,
493 const WebKit::WebURLError& error);
494 virtual void didReceiveDocumentData(WebKit::WebFrame* frame,
495 const char* data, size_t length,
496 bool& prevent_default);
497 virtual void didCommitProvisionalLoad(WebKit::WebFrame* frame,
498 bool is_new_navigation);
499 virtual void didClearWindowObject(WebKit::WebFrame* frame);
500 virtual void didCreateDocumentElement(WebKit::WebFrame* frame);
501 virtual void didReceiveTitle(WebKit::WebFrame* frame,
[email protected]a3bc4d12011-04-20 17:22:21502 const WebKit::WebString& title,
503 WebKit::WebTextDirection direction);
[email protected]42054a252011-05-17 18:02:13504 virtual void didChangeIcon(WebKit::WebFrame*,
505 WebKit::WebIconURL::Type) OVERRIDE;
[email protected]6e24cf12011-03-18 19:57:02506 virtual void didFinishDocumentLoad(WebKit::WebFrame* frame);
507 virtual void didHandleOnloadEvents(WebKit::WebFrame* frame);
508 virtual void didFailLoad(WebKit::WebFrame* frame,
509 const WebKit::WebURLError& error);
510 virtual void didFinishLoad(WebKit::WebFrame* frame);
511 virtual void didNavigateWithinPage(WebKit::WebFrame* frame,
512 bool is_new_navigation);
513 virtual void didUpdateCurrentHistoryItem(WebKit::WebFrame* frame);
514 virtual void assignIdentifierToRequest(WebKit::WebFrame* frame,
515 unsigned identifier,
516 const WebKit::WebURLRequest& request);
517 virtual void willSendRequest(WebKit::WebFrame* frame,
518 unsigned identifier,
519 WebKit::WebURLRequest& request,
520 const WebKit::WebURLResponse& redirect_response);
521 virtual void didReceiveResponse(WebKit::WebFrame* frame,
522 unsigned identifier,
523 const WebKit::WebURLResponse& response);
524 virtual void didFinishResourceLoad(WebKit::WebFrame* frame,
525 unsigned identifier);
526 virtual void didFailResourceLoad(WebKit::WebFrame* frame,
527 unsigned identifier,
528 const WebKit::WebURLError& error);
529 virtual void didLoadResourceFromMemoryCache(
530 WebKit::WebFrame* frame,
531 const WebKit::WebURLRequest& request,
532 const WebKit::WebURLResponse&);
533 virtual void didDisplayInsecureContent(WebKit::WebFrame* frame);
534 virtual void didRunInsecureContent(
535 WebKit::WebFrame* frame,
536 const WebKit::WebSecurityOrigin& origin,
537 const WebKit::WebURL& target);
[email protected]6e24cf12011-03-18 19:57:02538 virtual void didExhaustMemoryAvailableForScript(WebKit::WebFrame* frame);
539 virtual void didCreateScriptContext(WebKit::WebFrame* frame);
540 virtual void didDestroyScriptContext(WebKit::WebFrame* frame);
541 virtual void didCreateIsolatedScriptContext(WebKit::WebFrame* frame);
[email protected]6e24cf12011-03-18 19:57:02542 virtual void logCrossFramePropertyAccess(
543 WebKit::WebFrame* frame,
544 WebKit::WebFrame* target,
545 bool cross_origin,
546 const WebKit::WebString& property_name,
547 unsigned long long event_id);
[email protected]d812fd12011-05-27 23:05:07548 virtual void didUpdateLayout(WebKit::WebFrame* frame);
[email protected]6e24cf12011-03-18 19:57:02549 virtual void didChangeScrollOffset(WebKit::WebFrame* frame);
550 virtual void reportFindInPageMatchCount(int request_id,
551 int count,
552 bool final_update);
553 virtual void reportFindInPageSelection(int request_id,
554 int active_match_ordinal,
555 const WebKit::WebRect& sel);
556
557 virtual void openFileSystem(WebKit::WebFrame* frame,
558 WebKit::WebFileSystem::Type type,
559 long long size,
560 bool create,
561 WebKit::WebFileSystemCallbacks* callbacks);
562
[email protected]10e5cf12011-04-13 04:10:40563 virtual void queryStorageUsageAndQuota(
564 WebKit::WebFrame* frame,
565 WebKit::WebStorageQuotaType type,
566 WebKit::WebStorageQuotaCallbacks* callbacks);
567
568 virtual void requestStorageQuota(
569 WebKit::WebFrame* frame,
570 WebKit::WebStorageQuotaType type,
571 unsigned long long requested_size,
572 WebKit::WebStorageQuotaCallbacks* callbacks);
573
[email protected]6e24cf12011-03-18 19:57:02574 // webkit_glue::WebPluginPageDelegate implementation -------------------------
575
576 virtual webkit::npapi::WebPluginDelegate* CreatePluginDelegate(
577 const FilePath& file_path,
578 const std::string& mime_type);
579 virtual void CreatedPluginWindow(gfx::PluginWindowHandle handle);
580 virtual void WillDestroyPluginWindow(gfx::PluginWindowHandle handle);
581 virtual void DidMovePlugin(const webkit::npapi::WebPluginGeometry& move);
582 virtual void DidStartLoadingForPlugin();
583 virtual void DidStopLoadingForPlugin();
584 virtual WebKit::WebCookieJar* GetCookieJar();
585
586 // Please do not add your stuff randomly to the end here. If there is an
587 // appropriate section, add it there. If not, there are some random functions
588 // nearer to the top you can add it to.
[email protected]6e24cf12011-03-18 19:57:02589 virtual void DidFlushPaint();
590
[email protected]38b592902011-04-16 02:08:42591 // Cannot use std::set unfortunately since linked_ptr<> does not support
592 // operator<.
593 typedef std::vector<linked_ptr<webkit_glue::ImageResourceFetcher> >
594 ImageResourceFetcherList;
595
[email protected]6e24cf12011-03-18 19:57:02596 protected:
597 // RenderWidget overrides:
598 virtual void Close();
599 virtual void OnResize(const gfx::Size& new_size,
600 const gfx::Rect& resizer_rect);
601 virtual void DidInitiatePaint();
602 virtual webkit::ppapi::PluginInstance* GetBitmapForOptimizedPluginPaint(
603 const gfx::Rect& paint_bounds,
604 TransportDIB** dib,
605 gfx::Rect* location,
606 gfx::Rect* clip);
607 virtual gfx::Point GetScrollOffset();
608 virtual void DidHandleKeyEvent();
609 virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event);
610 virtual void OnSetFocus(bool enable);
611 virtual void OnWasHidden();
612 virtual void OnWasRestored(bool needs_repainting);
[email protected]65225772011-05-12 21:10:24613 virtual bool SupportsAsynchronousSwapBuffers() OVERRIDE;
[email protected]56ea1a62011-05-30 07:05:57614 virtual void OnImeSetComposition(
615 const string16& text,
616 const std::vector<WebKit::WebCompositionUnderline>& underlines,
617 int selection_start,
618 int selection_end) OVERRIDE;
619 virtual void OnImeConfirmComposition(const string16& text) OVERRIDE;
[email protected]ad26ef42011-06-17 07:59:45620 virtual ui::TextInputType GetTextInputType() OVERRIDE;
621 virtual bool CanComposeInline() OVERRIDE;
[email protected]6e24cf12011-03-18 19:57:02622
623 private:
[email protected]6e24cf12011-03-18 19:57:02624 // For unit tests.
625 friend class ExternalPopupMenuTest;
626 friend class PepperDeviceTest;
627 friend class RenderViewTest;
628
629 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuRemoveTest, RemoveOnChange);
630 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, NormalCase);
631 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, ShowPopupThenNavigate);
[email protected]6e24cf12011-03-18 19:57:02632 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, ImeComposition);
633 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, InsertCharacters);
634 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, JSBlockSentAfterPageLoad);
635 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, LastCommittedUpdateState);
636 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnHandleKeyboardEvent);
637 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnImeStateChanged);
638 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnNavStateChanged);
[email protected]6e24cf12011-03-18 19:57:02639 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnSetTextDirection);
[email protected]6e24cf12011-03-18 19:57:02640 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, UpdateTargetURLWithInvalidURL);
641#if defined(OS_MACOSX)
642 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, MacTestCmdUp);
643#endif
644
[email protected]6e24cf12011-03-18 19:57:02645 typedef std::map<GURL, double> HostZoomLevels;
646
[email protected]6e24cf12011-03-18 19:57:02647 // Identifies an accessibility notification from webkit.
648 struct RendererAccessibilityNotification {
649 public:
650 bool ShouldIncludeChildren();
651
652 // The webkit glue id of the accessibility object.
653 int32 id;
654
655 // The accessibility notification type.
656 WebKit::WebAccessibilityNotification type;
657 };
658
659 enum ErrorPageType {
660 DNS_ERROR,
661 HTTP_404,
662 CONNECTION_ERROR,
663 };
664
665 RenderView(RenderThreadBase* render_thread,
666 gfx::NativeViewId parent_hwnd,
[email protected]c03a6e72011-04-19 21:42:06667 gfx::PluginWindowHandle compositing_surface,
[email protected]6e24cf12011-03-18 19:57:02668 int32 opener_id,
669 const RendererPreferences& renderer_prefs,
670 const WebPreferences& webkit_prefs,
671 SharedRenderViewCounter* counter,
672 int32 routing_id,
673 int64 session_storage_namespace_id,
674 const string16& frame_name);
675
676 // Do not delete directly. This class is reference counted.
677 virtual ~RenderView();
678
679 void UpdateURL(WebKit::WebFrame* frame);
[email protected]6b2f7a82011-04-25 19:30:51680 void UpdateTitle(WebKit::WebFrame* frame, const string16& title);
[email protected]6e24cf12011-03-18 19:57:02681 void UpdateSessionHistory(WebKit::WebFrame* frame);
682
683 // Update current main frame's encoding and send it to browser window.
684 // Since we want to let users see the right encoding info from menu
685 // before finishing loading, we call the UpdateEncoding in
686 // a) function:DidCommitLoadForFrame. When this function is called,
687 // that means we have got first data. In here we try to get encoding
688 // of page if it has been specified in http header.
689 // b) function:DidReceiveTitle. When this function is called,
690 // that means we have got specified title. Because in most of webpages,
691 // title tags will follow meta tags. In here we try to get encoding of
692 // page if it has been specified in meta tag.
693 // c) function:DidFinishDocumentLoadForFrame. When this function is
694 // called, that means we have got whole html page. In here we should
695 // finally get right encoding of page.
696 void UpdateEncoding(WebKit::WebFrame* frame,
697 const std::string& encoding_name);
698
699 void OpenURL(const GURL& url, const GURL& referrer,
700 WebKit::WebNavigationPolicy policy);
701
[email protected]6e24cf12011-03-18 19:57:02702 bool RunJavaScriptMessage(int type,
[email protected]4f5ce842011-05-27 19:34:41703 const string16& message,
704 const string16& default_value,
[email protected]6e24cf12011-03-18 19:57:02705 const GURL& frame_url,
[email protected]4f5ce842011-05-27 19:34:41706 string16* result);
[email protected]6e24cf12011-03-18 19:57:02707
708 // Sends a message and runs a nested message loop.
709 bool SendAndRunNestedMessageLoop(IPC::SyncMessage* message);
710
[email protected]6e24cf12011-03-18 19:57:02711 // Send queued accessibility notifications from the renderer to the browser.
712 void SendPendingAccessibilityNotifications();
713
714 // IPC message handlers ------------------------------------------------------
715 //
716 // The documentation for these functions should be in
717 // render_messages_internal.h for the message that the function is handling.
718
719 void OnAccessibilityDoDefaultAction(int acc_obj_id);
720 void OnAccessibilityNotificationsAck();
721 void OnAllowBindings(int enabled_bindings_flags);
[email protected]6e24cf12011-03-18 19:57:02722 void OnAllowScriptToClose(bool script_can_close);
723 void OnAsyncFileOpened(base::PlatformFileError error_code,
724 IPC::PlatformFileForTransit file_for_transit,
725 int message_id);
[email protected]eb415bf0e2011-04-14 02:45:42726 void OnPpapiBrokerChannelCreated(int request_id,
[email protected]2b657fd2011-04-18 16:00:47727 base::ProcessHandle broker_process_handle,
728 IPC::ChannelHandle handle);
[email protected]6e24cf12011-03-18 19:57:02729 void OnCancelDownload(int32 download_id);
730 void OnClearFocusedNode();
[email protected]992db4c2011-05-12 15:37:15731 void OnClosePage();
[email protected]6e24cf12011-03-18 19:57:02732#if defined(ENABLE_FLAPPER_HACKS)
733 void OnConnectTcpACK(int request_id,
734 IPC::PlatformFileForTransit socket_for_transit,
735 const PP_Flash_NetAddress& local_addr,
736 const PP_Flash_NetAddress& remote_addr);
737#endif
738 void OnContextMenuClosed(
739 const webkit_glue::CustomContextMenuContext& custom_context);
740 void OnCopy();
741 void OnCopyImageAt(int x, int y);
742#if defined(OS_MACOSX)
743 void OnCopyToFindPboard();
744#endif
745 void OnCut();
[email protected]6e24cf12011-03-18 19:57:02746 void OnCSSInsertRequest(const std::wstring& frame_xpath,
747 const std::string& css,
748 const std::string& id);
749 void OnCustomContextMenuAction(
750 const webkit_glue::CustomContextMenuContext& custom_context,
751 unsigned action);
752 void OnDelete();
753 void OnDeterminePageLanguage();
754 void OnDisableScrollbarsForSmallWindows(
755 const gfx::Size& disable_scrollbars_size_limit);
756 void OnDisassociateFromPopupCount();
[email protected]6e24cf12011-03-18 19:57:02757 void OnDragSourceEndedOrMoved(const gfx::Point& client_point,
758 const gfx::Point& screen_point,
759 bool ended,
760 WebKit::WebDragOperation drag_operation);
761 void OnDragSourceSystemDragEnded();
762 void OnDragTargetDrop(const gfx::Point& client_pt,
763 const gfx::Point& screen_pt);
764 void OnDragTargetDragEnter(const WebDropData& drop_data,
765 const gfx::Point& client_pt,
766 const gfx::Point& screen_pt,
767 WebKit::WebDragOperationsMask operations_allowed);
768 void OnDragTargetDragLeave();
769 void OnDragTargetDragOver(const gfx::Point& client_pt,
770 const gfx::Point& screen_pt,
771 WebKit::WebDragOperationsMask operations_allowed);
772 void OnEnablePreferredSizeChangedMode(int flags);
[email protected]600ea402011-04-12 00:01:51773 void OnEnumerateDirectoryResponse(int id, const std::vector<FilePath>& paths);
[email protected]6e24cf12011-03-18 19:57:02774 void OnExecuteEditCommand(const std::string& name, const std::string& value);
[email protected]6e24cf12011-03-18 19:57:02775 void OnFileChooserResponse(const std::vector<FilePath>& paths);
776 void OnFind(int request_id, const string16&, const WebKit::WebFindOptions&);
777 void OnFindReplyAck();
778 void OnEnableAccessibility();
[email protected]6e24cf12011-03-18 19:57:02779 void OnInstallMissingPlugin();
[email protected]6e24cf12011-03-18 19:57:02780 void OnMediaPlayerActionAt(const gfx::Point& location,
781 const WebKit::WebMediaPlayerAction& action);
782 void OnMoveOrResizeStarted();
783 void OnNavigate(const ViewMsg_Navigate_Params& params);
784 void OnNetworkStateChanged(bool online);
[email protected]6e24cf12011-03-18 19:57:02785 void OnPaste();
786#if defined(OS_MACOSX)
787 void OnPluginImeCompositionCompleted(const string16& text, int plugin_id);
788#endif
789 void OnRedo();
790 void OnReloadFrame();
791 void OnReplace(const string16& text);
792 void OnReservePageIDRange(int size_of_range);
793 void OnResetPageEncodingToDefault();
794 void OnScriptEvalRequest(const string16& frame_xpath,
795 const string16& jscript,
796 int id,
797 bool notify_result);
798 void OnSelectAll();
799 void OnSetAccessibilityFocus(int acc_obj_id);
800 void OnSetActive(bool active);
801 void OnSetAltErrorPageURL(const GURL& gurl);
802 void OnSetBackground(const SkBitmap& background);
[email protected]6e24cf12011-03-18 19:57:02803 void OnSetWebUIProperty(const std::string& name, const std::string& value);
804 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
805 void OnSetInitialFocus(bool reverse);
[email protected]54ca3ca892011-06-07 21:14:54806#if defined(OS_MACOSX)
807 void OnSetInLiveResize(bool in_live_resize);
808#endif
[email protected]6e24cf12011-03-18 19:57:02809 void OnScrollFocusedEditableNodeIntoView();
810 void OnSetPageEncoding(const std::string& encoding_name);
811 void OnSetRendererPrefs(const RendererPreferences& renderer_prefs);
[email protected]6e24cf12011-03-18 19:57:02812#if defined(OS_MACOSX)
813 void OnSetWindowVisibility(bool visible);
814#endif
815 void OnSetZoomLevel(double zoom_level);
816 void OnSetZoomLevelForLoadingURL(const GURL& url, double zoom_level);
817 void OnShouldClose();
818 void OnStop();
819 void OnStopFinding(const ViewMsg_StopFinding_Params& params);
[email protected]992db4c2011-05-12 15:37:15820 void OnSwapOut(const ViewMsg_SwapOut_Params& params);
[email protected]6e24cf12011-03-18 19:57:02821 void OnThemeChanged();
[email protected]6e24cf12011-03-18 19:57:02822 void OnUndo();
[email protected]6e24cf12011-03-18 19:57:02823 void OnUpdateTargetURLAck();
824 void OnUpdateWebPreferences(const WebPreferences& prefs);
825#if defined(OS_MACOSX)
826 void OnWindowFrameChanged(const gfx::Rect& window_frame,
827 const gfx::Rect& view_frame);
828 void OnSelectPopupMenuItem(int selected_index);
829#endif
830 void OnZoom(PageZoom::Function function);
[email protected]6e24cf12011-03-18 19:57:02831
832 // Adding a new message handler? Please add it in alphabetical order above
833 // and put it in the same position in the .cc file.
834
835 // Misc private functions ----------------------------------------------------
836
[email protected]6e24cf12011-03-18 19:57:02837 void AltErrorPageFinished(WebKit::WebFrame* frame,
838 const WebKit::WebURLError& original_error,
839 const std::string& html);
840
[email protected]d812fd12011-05-27 23:05:07841 // Check whether the preferred size has changed.
[email protected]6e24cf12011-03-18 19:57:02842 void CheckPreferredSize();
843
[email protected]5e56df82011-04-18 17:00:15844 // This callback is triggered when DownloadFavicon completes, either
845 // succesfully or with a failure. See DownloadFavicon for more
846 // details.
847 void DidDownloadFavicon(webkit_glue::ImageResourceFetcher* fetcher,
848 const SkBitmap& image);
[email protected]6e24cf12011-03-18 19:57:02849
[email protected]5e56df82011-04-18 17:00:15850 // Requests to download a favicon image. When done, the RenderView
851 // is notified by way of DidDownloadFavicon. Returns true if the
852 // request was successfully started, false otherwise. id is used to
853 // uniquely identify the request and passed back to the
854 // DidDownloadFavicon method. If the image has multiple frames, the
855 // frame whose size is image_size is returned. If the image doesn't
856 // have a frame at the specified size, the first is returned.
857 bool DownloadFavicon(int id, const GURL& image_url, int image_size);
[email protected]6e24cf12011-03-18 19:57:02858
[email protected]6e24cf12011-03-18 19:57:02859 GURL GetAlternateErrorPageURL(const GURL& failed_url,
860 ErrorPageType error_type);
861
862 // Locates a sub frame with given xpath
863 WebKit::WebFrame* GetChildFrame(const std::wstring& frame_xpath) const;
864
[email protected]6e24cf12011-03-18 19:57:02865 WebUIBindings* GetWebUIBindings();
866
[email protected]6e24cf12011-03-18 19:57:02867 // Should only be called if this object wraps a PluginDocument.
868 WebKit::WebPlugin* GetWebPluginFromPluginDocument();
869
[email protected]6e24cf12011-03-18 19:57:02870 // Returns false unless this is a top-level navigation that crosses origins.
871 bool IsNonLocalTopLevelNavigation(const GURL& url,
872 WebKit::WebFrame* frame,
873 WebKit::WebNavigationType type);
874
[email protected]6e24cf12011-03-18 19:57:02875 bool MaybeLoadAlternateErrorPage(WebKit::WebFrame* frame,
876 const WebKit::WebURLError& error,
877 bool replace);
878
879 // Starts nav_state_sync_timer_ if it isn't already running.
880 void StartNavStateSyncTimerIfNecessary();
881
882 // Dispatches the current navigation state to the browser. Called on a
883 // periodic timer so we don't send too many messages.
884 void SyncNavigationState();
885
[email protected]e63c4d72011-05-31 22:38:29886#if defined(OS_POSIX) && !defined(OS_MACOSX)
[email protected]6e24cf12011-03-18 19:57:02887 void UpdateFontRenderingFromRendererPrefs();
888#else
889 void UpdateFontRenderingFromRendererPrefs() {}
890#endif
891
892 // Update the target url and tell the browser that the target URL has changed.
893 // If |url| is empty, show |fallback_url|.
894 void UpdateTargetURL(const GURL& url, const GURL& fallback_url);
895
[email protected]6e24cf12011-03-18 19:57:02896 // ---------------------------------------------------------------------------
897 // ADDING NEW FUNCTIONS? Please keep private functions alphabetized and put
898 // it in the same order in the .cc file as it was in the header.
899 // ---------------------------------------------------------------------------
900
901 // Settings ------------------------------------------------------------------
902
903 WebPreferences webkit_preferences_;
904 RendererPreferences renderer_preferences_;
905
[email protected]6e24cf12011-03-18 19:57:02906 HostZoomLevels host_zoom_levels_;
907
908 // Whether content state (such as form state, scroll position and page
909 // contents) should be sent to the browser immediately. This is normally
910 // false, but set to true by some tests.
911 bool send_content_state_immediately_;
912
[email protected]6e24cf12011-03-18 19:57:02913 // Bitwise-ORed set of extra bindings that have been enabled. See
914 // BindingsPolicy for details.
915 int enabled_bindings_;
916
917 // The alternate error page URL, if one exists.
918 GURL alternate_error_page_url_;
919
920 // If true, we send IPC messages when |preferred_size_| changes.
921 bool send_preferred_size_changes_;
922
923 // If non-empty, and |send_preferred_size_changes_| is true, disable drawing
924 // scroll bars on windows smaller than this size. Used for windows that the
925 // browser resizes to the size of the content, such as browser action popups.
926 // If a render view is set to the minimum size of its content, webkit may add
927 // scroll bars. This makes sense for fixed sized windows, but it does not
928 // make sense when the size of the view was chosen to fit the content.
929 // This setting ensures that no scroll bars are drawn. The size limit exists
930 // because if the view grows beyond a size known to the browser, scroll bars
931 // should be drawn.
932 gfx::Size disable_scrollbars_size_limit_;
933
[email protected]6e24cf12011-03-18 19:57:02934 // Loading state -------------------------------------------------------------
935
936 // True if the top level frame is currently being loaded.
937 bool is_loading_;
938
939 // The gesture that initiated the current navigation.
940 NavigationGesture navigation_gesture_;
941
942 // Used for popups.
943 bool opened_by_user_gesture_;
944 GURL creator_url_;
945
946 // Whether this RenderView was created by a frame that was suppressing its
947 // opener. If so, we may want to load pages in a separate process. See
948 // decidePolicyForNavigation for details.
949 bool opener_suppressed_;
950
951 // If we are handling a top-level client-side redirect, this tracks the URL
952 // of the page that initiated it. Specifically, when a load is committed this
953 // is used to determine if that load originated from a client-side redirect.
954 // It is empty if there is no top-level client-side redirect.
955 GURL completed_client_redirect_src_;
956
[email protected]6e24cf12011-03-18 19:57:02957 // Holds state pertaining to a navigation that we initiated. This is held by
958 // the WebDataSource::ExtraData attribute. We use pending_navigation_state_
959 // as a temporary holder for the state until the WebDataSource corresponding
960 // to the new navigation is created. See DidCreateDataSource.
961 scoped_ptr<NavigationState> pending_navigation_state_;
962
963 // Timer used to delay the updating of nav state (see SyncNavigationState).
964 base::OneShotTimer<RenderView> nav_state_sync_timer_;
965
[email protected]6e24cf12011-03-18 19:57:02966 // Page IDs ------------------------------------------------------------------
967 //
968 // Page IDs allow the browser to identify pages in each renderer process for
969 // keeping back/forward history in sync.
970
971 // ID of the current page. Note that this is NOT updated for every main
972 // frame navigation, only for "regular" navigations that go into session
973 // history. In particular, client redirects, like the page cycler uses
974 // (document.location.href="foo") do not count as regular navigations and do
975 // not increment the page id.
976 int32 page_id_;
977
978 // Indicates the ID of the last page that we sent a FrameNavigate to the
979 // browser for. This is used to determine if the most recent transition
980 // generated a history entry (less than page_id_), or not (equal to or
981 // greater than). Note that this will be greater than page_id_ if the user
982 // goes back.
983 int32 last_page_id_sent_to_browser_;
984
[email protected]6e24cf12011-03-18 19:57:02985 // The next available page ID to use. This ensures that the page IDs are
986 // globally unique in the renderer.
987 static int32 next_page_id_;
988
989 // Page info -----------------------------------------------------------------
990
991 // The last gotten main frame's encoding.
992 std::string last_encoding_name_;
993
994 int history_list_offset_;
995 int history_list_length_;
996
997 // True if the page has any frame-level unload or beforeunload listeners.
998 bool has_unload_listener_;
999
[email protected]6e24cf12011-03-18 19:57:021000 // UI state ------------------------------------------------------------------
1001
1002 // The state of our target_url transmissions. When we receive a request to
1003 // send a URL to the browser, we set this to TARGET_INFLIGHT until an ACK
1004 // comes back - if a new request comes in before the ACK, we store the new
1005 // URL in pending_target_url_ and set the status to TARGET_PENDING. If an
1006 // ACK comes back and we are in TARGET_PENDING, we send the stored URL and
1007 // revert to TARGET_INFLIGHT.
1008 //
1009 // We don't need a queue of URLs to send, as only the latest is useful.
1010 enum {
1011 TARGET_NONE,
1012 TARGET_INFLIGHT, // We have a request in-flight, waiting for an ACK
1013 TARGET_PENDING // INFLIGHT + we have a URL waiting to be sent
1014 } target_url_status_;
1015
1016 // The URL we show the user in the status bar. We use this to determine if we
1017 // want to send a new one (we do not need to send duplicates). It will be
1018 // equal to either |mouse_over_url_| or |focus_url_|, depending on which was
1019 // updated last.
1020 GURL target_url_;
1021
1022 // The URL the user's mouse is hovering over.
1023 GURL mouse_over_url_;
1024
1025 // The URL that has keyboard focus.
1026 GURL focus_url_;
1027
1028 // The next target URL we want to send to the browser.
1029 GURL pending_target_url_;
1030
[email protected]6e24cf12011-03-18 19:57:021031 // The text selection the last time DidChangeSelection got called.
1032 std::string last_selection_;
1033
1034 // View ----------------------------------------------------------------------
1035
[email protected]6e24cf12011-03-18 19:57:021036 // Cache the preferred size of the page in order to prevent sending the IPC
1037 // when layout() recomputes but doesn't actually change sizes.
1038 gfx::Size preferred_size_;
1039
[email protected]1e0c8e02011-05-25 07:49:371040 // Used to delay determining the preferred size (to avoid intermediate
1041 // states for the sizes).
1042 base::OneShotTimer<RenderView> check_preferred_size_timer_;
1043
[email protected]6e24cf12011-03-18 19:57:021044#if defined(OS_MACOSX)
1045 // Track the fake plugin window handles allocated on the browser side for
1046 // the accelerated compositor and (currently) accelerated plugins so that
1047 // we can discard them when the view goes away.
1048 std::set<gfx::PluginWindowHandle> fake_plugin_window_handles_;
1049#endif
1050
1051 // Plugins -------------------------------------------------------------------
1052
1053 // Remember the first uninstalled plugin, so that we can ask the plugin
1054 // to install itself when user clicks on the info bar.
1055 base::WeakPtr<webkit::npapi::WebPluginDelegate> first_default_plugin_;
1056
1057 PepperPluginDelegateImpl pepper_delegate_;
1058
1059 // All the currently active plugin delegates for this RenderView; kept so that
1060 // we can enumerate them to send updates about things like window location
1061 // or tab focus and visibily. These are non-owning references.
1062 std::set<WebPluginDelegateProxy*> plugin_delegates_;
1063
1064 // Helper objects ------------------------------------------------------------
1065
[email protected]6e24cf12011-03-18 19:57:021066 ScopedRunnableMethodFactory<RenderView> accessibility_method_factory_;
1067
1068 RendererWebCookieJarImpl cookie_jar_;
1069
1070 // The next group of objects all implement RenderViewObserver, so are deleted
1071 // along with the RenderView automatically. This is why we just store weak
1072 // references.
1073
[email protected]6e24cf12011-03-18 19:57:021074 // Holds a reference to the service which provides desktop notifications.
1075 NotificationProvider* notification_provider_;
1076
1077 // The geolocation dispatcher attached to this view, lazily initialized.
1078 GeolocationDispatcher* geolocation_dispatcher_;
1079
1080 // The speech dispatcher attached to this view, lazily initialized.
1081 SpeechInputDispatcher* speech_input_dispatcher_;
1082
1083 // Device orientation dispatcher attached to this view; lazily initialized.
1084 DeviceOrientationDispatcher* device_orientation_dispatcher_;
1085
[email protected]6e24cf12011-03-18 19:57:021086 scoped_refptr<AudioMessageFilter> audio_message_filter_;
1087
1088 // Handles accessibility requests into the renderer side, as well as
1089 // maintains the cache and other features of the accessibility tree.
1090 scoped_ptr<WebKit::WebAccessibilityCache> accessibility_;
1091
1092 // Collect renderer accessibility notifications until they are ready to be
1093 // sent to the browser.
1094 std::vector<RendererAccessibilityNotification>
1095 pending_accessibility_notifications_;
1096
1097 // Set if we are waiting for a accessibility notification ack.
1098 bool accessibility_ack_pending_;
1099
[email protected]6e24cf12011-03-18 19:57:021100 // Dispatches all P2P socket used by the renderer.
1101 P2PSocketDispatcher* p2p_socket_dispatcher_;
1102
1103 // Misc ----------------------------------------------------------------------
1104
1105 // The current and pending file chooser completion objects. If the queue is
1106 // nonempty, the first item represents the currently running file chooser
1107 // callback, and the remaining elements are the other file chooser completion
1108 // still waiting to be run (in order).
1109 struct PendingFileChooser;
1110 std::deque< linked_ptr<PendingFileChooser> > file_chooser_completions_;
1111
[email protected]600ea402011-04-12 00:01:511112 // The current directory enumeration callback
1113 std::map<int, WebKit::WebFileChooserCompletion*> enumeration_completions_;
1114 int enumeration_completion_id_;
1115
[email protected]6e24cf12011-03-18 19:57:021116 // The SessionStorage namespace that we're assigned to has an ID, and that ID
1117 // is passed to us upon creation. WebKit asks for this ID upon first use and
1118 // uses it whenever asking the browser process to allocate new storage areas.
1119 int64 session_storage_namespace_id_;
1120
1121 // The total number of unrequested popups that exist and can be followed back
1122 // to a common opener. This count is shared among all RenderViews created
1123 // with createView(). All popups are treated as unrequested until
1124 // specifically instructed otherwise by the Browser process.
1125 scoped_refptr<SharedRenderViewCounter> shared_popup_counter_;
1126
1127 // Whether this is a top level window (instead of a popup). Top level windows
1128 // shouldn't count against their own |shared_popup_counter_|.
1129 bool decrement_shared_popup_at_destruction_;
1130
1131 // If the browser hasn't sent us an ACK for the last FindReply we sent
1132 // to it, then we need to queue up the message (keeping only the most
1133 // recent message if new ones come in).
1134 scoped_ptr<IPC::Message> queued_find_reply_message_;
1135
1136 // Stores edit commands associated to the next key event.
1137 // Shall be cleared as soon as the next key event is processed.
1138 EditCommands edit_commands_;
1139
[email protected]6e24cf12011-03-18 19:57:021140 // Allows Web UI pages (new tab page, etc.) to talk to the browser. The JS
1141 // object is only exposed when Web UI bindings are enabled.
1142 scoped_ptr<WebUIBindings> web_ui_bindings_;
1143
[email protected]6e24cf12011-03-18 19:57:021144 // The external popup for the currently showing select popup.
1145 scoped_ptr<ExternalPopupMenu> external_popup_menu_;
1146
1147 // The node that the context menu was pressed over.
1148 WebKit::WebNode context_menu_node_;
1149
1150 // Reports load progress to the browser.
1151 scoped_ptr<LoadProgressTracker> load_progress_tracker_;
1152
1153 // All the registered observers. We expect this list to be small, so vector
1154 // is fine.
1155 ObserverList<RenderViewObserver> observers_;
1156
1157 // ---------------------------------------------------------------------------
1158 // ADDING NEW DATA? Please see if it fits appropriately in one of the above
1159 // sections rather than throwing it randomly at the end. If you're adding a
1160 // bunch of stuff, you should probably create a helper class and put your
1161 // data and methods on that to avoid bloating RenderView more. You can use
1162 // the Observer interface to filter IPC messages and receive frame change
1163 // notifications.
1164 // ---------------------------------------------------------------------------
1165
1166 DISALLOW_COPY_AND_ASSIGN(RenderView);
1167};
1168
1169#endif // CONTENT_RENDERER_RENDER_VIEW_H_