blob: 620ed2441d73794bc0c7ac3f72091ecfca339d0b [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"
24#include "chrome/common/content_settings.h"
[email protected]c08e7932011-03-29 04:08:1425#include "chrome/common/search_provider.h"
[email protected]6e24cf12011-03-18 19:57:0226#include "chrome/common/view_types.h"
[email protected]6e24cf12011-03-18 19:57:0227#include "content/renderer/renderer_webcookiejar_impl.h"
[email protected]55722152011-03-22 01:33:5328#include "content/common/edit_command.h"
[email protected]6e24cf12011-03-18 19:57:0229#include "content/common/navigation_gesture.h"
30#include "content/common/page_zoom.h"
[email protected]60916042011-03-19 00:43:3631#include "content/common/renderer_preferences.h"
[email protected]6e24cf12011-03-18 19:57:0232#include "content/renderer/pepper_plugin_delegate_impl.h"
33#include "content/renderer/render_widget.h"
34#include "ipc/ipc_platform_file.h"
35#include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityNotification.h"
36#include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h"
37#include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystem.h"
38#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h"
39#include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializerClient.h"
40#include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h"
41#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h"
42#include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h"
43#include "third_party/WebKit/Source/WebKit/chromium/public/WebNavigationType.h"
[email protected]b9b751f22011-03-25 14:04:1244#include "ui/gfx/surface/transport_dib.h"
[email protected]6e24cf12011-03-18 19:57:0245#include "webkit/glue/webpreferences.h"
46#include "webkit/plugins/npapi/webplugin_page_delegate.h"
47
48#if defined(OS_WIN)
49// RenderView is a diamond-shaped hierarchy, with WebWidgetClient at the root.
50// VS warns when we inherit the WebWidgetClient method implementations from
51// RenderWidget. It's safe to ignore that warning.
52#pragma warning(disable: 4250)
53#endif
54
55class AudioMessageFilter;
[email protected]6e24cf12011-03-18 19:57:0256class DeviceOrientationDispatcher;
[email protected]6e24cf12011-03-18 19:57:0257class DomAutomationController;
[email protected]6e24cf12011-03-18 19:57:0258class ExternalHostBindings;
[email protected]55722152011-03-22 01:33:5359class ExternalPopupMenu;
[email protected]6e24cf12011-03-18 19:57:0260class FilePath;
61class GeolocationDispatcher;
[email protected]6e24cf12011-03-18 19:57:0262class GURL;
[email protected]6e24cf12011-03-18 19:57:0263class LoadProgressTracker;
64class NavigationState;
65class NotificationProvider;
66class P2PSocketDispatcher;
67class PepperDeviceTest;
68class PrintWebViewHelper;
69class RenderViewObserver;
70class RenderViewVisitor;
[email protected]ea192e82011-04-11 19:16:0271class RenderWidgetFullscreenPepper;
[email protected]6e24cf12011-03-18 19:57:0272class SkBitmap;
73class SpeechInputDispatcher;
[email protected]6e24cf12011-03-18 19:57:0274class WebPluginDelegatePepper;
75class WebPluginDelegateProxy;
[email protected]55722152011-03-22 01:33:5376class WebUIBindings;
[email protected]6e24cf12011-03-18 19:57:0277struct ContextMenuMediaParams;
78struct PP_Flash_NetAddress;
[email protected]6e24cf12011-03-18 19:57:0279struct ViewHostMsg_RunFileChooser_Params;
80struct ViewMsg_ClosePage_Params;
[email protected]6e24cf12011-03-18 19:57:0281struct ViewMsg_Navigate_Params;
82struct ViewMsg_StopFinding_Params;
[email protected]6e24cf12011-03-18 19:57:0283struct WebDropData;
84
85namespace base {
86class WaitableEvent;
87}
88
89namespace chrome {
90class ChromeContentRendererClient;
91}
92
93namespace gfx {
94class Point;
95class Rect;
96}
97
98namespace webkit {
99
100namespace npapi {
101class PluginGroup;
102} // namespace npapi
103
104namespace ppapi {
[email protected]6e24cf12011-03-18 19:57:02105class PluginInstance;
106class PluginModule;
107} // namespace ppapi
108
109} // namespace webkit
110
111namespace webkit_glue {
112struct CustomContextMenuContext;
113class ImageResourceFetcher;
114struct FileUploadData;
115struct FormData;
116struct PasswordFormFillData;
117class ResourceFetcher;
118}
119
120namespace WebKit {
121class WebAccessibilityCache;
122class WebAccessibilityObject;
123class WebApplicationCacheHost;
124class WebApplicationCacheHostClient;
125class WebDataSource;
126class WebDocument;
127class WebDragData;
128class WebFrame;
129class WebGeolocationClient;
130class WebGeolocationServiceInterface;
131class WebImage;
132class WebInputElement;
133class WebKeyboardEvent;
134class WebMediaPlayer;
135class WebMediaPlayerClient;
136class WebMouseEvent;
137class WebPlugin;
138class WebSpeechInputController;
139class WebSpeechInputListener;
140class WebStorageNamespace;
[email protected]6e24cf12011-03-18 19:57:02141class WebURLRequest;
142class WebView;
143struct WebContextMenuData;
144struct WebFileChooserParams;
145struct WebFindOptions;
146struct WebMediaPlayerAction;
147struct WebPluginParams;
148struct WebPoint;
149struct WebWindowFeatures;
150}
151
152// We need to prevent a page from trying to create infinite popups. It is not
153// as simple as keeping a count of the number of immediate children
154// popups. Having an html file that window.open()s itself would create
155// an unlimited chain of RenderViews who only have one RenderView child.
156//
157// Therefore, each new top level RenderView creates a new counter and shares it
158// with all its children and grandchildren popup RenderViews created with
159// createView() to have a sort of global limit for the page so no more than
160// kMaximumNumberOfPopups popups are created.
161//
162// This is a RefCounted holder of an int because I can't say
163// scoped_refptr<int>.
164typedef base::RefCountedData<int> SharedRenderViewCounter;
165
166//
167// RenderView is an object that manages a WebView object, and provides a
168// communication interface with an embedding application process
169//
170class RenderView : public RenderWidget,
171 public WebKit::WebViewClient,
172 public WebKit::WebFrameClient,
173 public WebKit::WebPageSerializerClient,
174 public webkit::npapi::WebPluginPageDelegate,
175 public base::SupportsWeakPtr<RenderView> {
176 public:
177 // Creates a new RenderView. The parent_hwnd specifies a HWND to use as the
178 // parent of the WebView HWND that will be created. If this is a constrained
179 // popup or as a new tab, opener_id is the routing ID of the RenderView
180 // responsible for creating this RenderView (corresponding to parent_hwnd).
181 // |counter| is either a currently initialized counter, or NULL (in which case
182 // we treat this RenderView as a top level window).
183 static RenderView* Create(
184 RenderThreadBase* render_thread,
185 gfx::NativeViewId parent_hwnd,
186 int32 opener_id,
187 const RendererPreferences& renderer_prefs,
188 const WebPreferences& webkit_prefs,
189 SharedRenderViewCounter* counter,
190 int32 routing_id,
191 int64 session_storage_namespace_id,
192 const string16& frame_name);
193
194 // Visit all RenderViews with a live WebView (i.e., RenderViews that have
195 // been closed but not yet destroyed are excluded).
196 static void ForEach(RenderViewVisitor* visitor);
197
198 // Returns the RenderView containing the given WebView.
199 static RenderView* FromWebView(WebKit::WebView* webview);
200
201 // Sets the "next page id" counter.
202 static void SetNextPageID(int32 next_page_id);
203
204 // May return NULL when the view is closing.
205 WebKit::WebView* webview() const;
206
207 int browser_window_id() const {
208 return browser_window_id_;
209 }
210
211 ViewType::Type view_type() const {
212 return view_type_;
213 }
214
215 int page_id() const {
216 return page_id_;
217 }
218
219 AudioMessageFilter* audio_message_filter() {
220 return audio_message_filter_;
221 }
222
223 const WebPreferences& webkit_preferences() const {
224 return webkit_preferences_;
225 }
226
[email protected]93b9d692011-04-13 00:44:31227 bool content_state_immediately() { return send_content_state_immediately_; }
[email protected]6e24cf12011-03-18 19:57:02228 void set_send_content_state_immediately(bool value) {
229 send_content_state_immediately_ = value;
230 }
231
232 // Returns true if we should display scrollbars for the given view size and
233 // false if the scrollbars should be hidden.
234 bool should_display_scrollbars(int width, int height) const {
235 return (!send_preferred_size_changes_ ||
236 (disable_scrollbars_size_limit_.width() <= width ||
237 disable_scrollbars_size_limit_.height() <= height));
238 }
239
[email protected]6e24cf12011-03-18 19:57:02240 const WebKit::WebNode& context_menu_node() { return context_menu_node_; }
241
242 // Current P2PSocketDispatcher. Set to NULL if P2P API is disabled.
243 P2PSocketDispatcher* p2p_socket_dispatcher() {
244 return p2p_socket_dispatcher_;
245 }
246
247 // Functions to add and remove observers for this object.
248 void AddObserver(RenderViewObserver* observer);
249 void RemoveObserver(RenderViewObserver* observer);
250
251 // Called from JavaScript window.external.AddSearchProvider() to add a
252 // keyword for a provider described in the given OpenSearch document.
253 void AddSearchProvider(const std::string& url,
[email protected]c08e7932011-03-29 04:08:14254 search_provider::OSDDType provider_type);
[email protected]6e24cf12011-03-18 19:57:02255
256 // Returns the install state for the given search provider url.
[email protected]c08e7932011-03-29 04:08:14257 search_provider::InstallState GetSearchProviderInstallState(
258 WebKit::WebFrame* frame,
259 const std::string& url);
[email protected]6e24cf12011-03-18 19:57:02260
261 // Evaluates a string of JavaScript in a particular frame.
262 void EvaluateScript(const string16& frame_xpath,
263 const string16& jscript,
264 int id,
265 bool notify_result);
266
267 // Adds the given file chooser request to the file_chooser_completion_ queue
268 // (see that var for more) and requests the chooser be displayed if there are
269 // no other waiting items in the queue.
270 //
271 // Returns true if the chooser was successfully scheduled. False means we
272 // didn't schedule anything.
273 bool ScheduleFileChooser(const ViewHostMsg_RunFileChooser_Params& params,
274 WebKit::WebFileChooserCompletion* completion);
275
[email protected]6e24cf12011-03-18 19:57:02276 // Sets the content settings that back allowScripts(), allowImages(), and
277 // allowPlugins().
278 void SetContentSettings(const ContentSettings& settings);
279
280 // Notifies the browser that the given action has been performed. This is
281 // aggregated to the user metrics service.
282 void UserMetricsRecordAction(const std::string& action);
283
[email protected]6e24cf12011-03-18 19:57:02284 // Sets whether the renderer should report load progress to the browser.
285 void SetReportLoadProgressEnabled(bool enabled);
286
[email protected]38b592902011-04-16 02:08:42287 // Gets the focused node. If no such node exists then the node will be isNull.
288 WebKit::WebNode GetFocusedNode() const;
289
290 // Returns true if the parameter node is a textfield, text area or a content
291 // editable div.
292 bool IsEditableNode(const WebKit::WebNode& node);
293
[email protected]6e24cf12011-03-18 19:57:02294 // Plugin-related functions --------------------------------------------------
295 // (See also WebPluginPageDelegate implementation.)
296
297 // Notification that the given plugin has crashed.
298 void PluginCrashed(const FilePath& plugin_path);
299
300 // Notification that the default plugin has done something about a missing
301 // plugin. See default_plugin_shared.h for possible values of |status|.
302 void OnMissingPluginStatus(WebPluginDelegateProxy* delegate,
303 int status);
304
305 // Creates a fullscreen container for a pepper plugin instance.
[email protected]ea192e82011-04-11 19:16:02306 RenderWidgetFullscreenPepper* CreatePepperFullscreenContainer(
[email protected]6e24cf12011-03-18 19:57:02307 webkit::ppapi::PluginInstance* plugin);
308
309 // Create a new plugin without checking the content settings.
310 WebKit::WebPlugin* CreatePluginNoCheck(WebKit::WebFrame* frame,
311 const WebKit::WebPluginParams& params);
312
313#if defined(OS_MACOSX)
314 // Informs the render view that the given plugin has gained or lost focus.
315 void PluginFocusChanged(bool focused, int plugin_id);
316
317 // Starts plugin IME.
318 void StartPluginIme();
319
320 // Helper routines for accelerated plugin support. Used by the
321 // WebPluginDelegateProxy, which has a pointer to the RenderView.
322 gfx::PluginWindowHandle AllocateFakePluginWindowHandle(bool opaque,
323 bool root);
324 void DestroyFakePluginWindowHandle(gfx::PluginWindowHandle window);
325 void AcceleratedSurfaceSetIOSurface(gfx::PluginWindowHandle window,
326 int32 width,
327 int32 height,
328 uint64 io_surface_identifier);
329 TransportDIB::Handle AcceleratedSurfaceAllocTransportDIB(size_t size);
330 void AcceleratedSurfaceFreeTransportDIB(TransportDIB::Id dib_id);
331 void AcceleratedSurfaceSetTransportDIB(gfx::PluginWindowHandle window,
332 int32 width,
333 int32 height,
334 TransportDIB::Handle transport_dib);
335 void AcceleratedSurfaceBuffersSwapped(gfx::PluginWindowHandle window,
336 uint64 surface_id);
337#endif
338
339 void RegisterPluginDelegate(WebPluginDelegateProxy* delegate);
340 void UnregisterPluginDelegate(WebPluginDelegateProxy* delegate);
341
342 // IPC::Channel::Listener implementation -------------------------------------
343
344 virtual bool OnMessageReceived(const IPC::Message& msg);
345
346 // WebKit::WebWidgetClient implementation ------------------------------------
347
348 // Most methods are handled by RenderWidget.
349 virtual void didFocus();
350 virtual void didBlur();
351 virtual void show(WebKit::WebNavigationPolicy policy);
352 virtual void runModal();
353
354 // WebKit::WebViewClient implementation --------------------------------------
355
356 virtual WebKit::WebView* createView(
357 WebKit::WebFrame* creator,
358 const WebKit::WebURLRequest& request,
359 const WebKit::WebWindowFeatures& features,
360 const WebKit::WebString& frame_name);
361 virtual WebKit::WebWidget* createPopupMenu(WebKit::WebPopupType popup_type);
362 virtual WebKit::WebWidget* createPopupMenu(
363 const WebKit::WebPopupMenuInfo& info);
364 virtual WebKit::WebExternalPopupMenu* createExternalPopupMenu(
365 const WebKit::WebPopupMenuInfo& popup_menu_info,
366 WebKit::WebExternalPopupMenuClient* popup_menu_client);
367 virtual WebKit::WebStorageNamespace* createSessionStorageNamespace(
368 unsigned quota);
369 virtual void didAddMessageToConsole(
370 const WebKit::WebConsoleMessage& message,
371 const WebKit::WebString& source_name,
372 unsigned source_line);
373 virtual void printPage(WebKit::WebFrame* frame);
374 virtual WebKit::WebNotificationPresenter* notificationPresenter();
375 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);
[email protected]600ea402011-04-12 00:01:51387 virtual bool enumerateDirectory(
388 const WebKit::WebString& path,
389 WebKit::WebFileChooserCompletion* chooser_completion);
[email protected]6e24cf12011-03-18 19:57:02390 virtual void runModalAlertDialog(WebKit::WebFrame* frame,
391 const WebKit::WebString& message);
392 virtual bool runModalConfirmDialog(WebKit::WebFrame* frame,
393 const WebKit::WebString& message);
394 virtual bool runModalPromptDialog(WebKit::WebFrame* frame,
395 const WebKit::WebString& message,
396 const WebKit::WebString& default_value,
397 WebKit::WebString* actual_value);
398 virtual bool runModalBeforeUnloadDialog(WebKit::WebFrame* frame,
399 const WebKit::WebString& message);
400 virtual void showContextMenu(WebKit::WebFrame* frame,
401 const WebKit::WebContextMenuData& data);
402 virtual bool supportsFullscreen();
403 virtual void enterFullscreenForNode(const WebKit::WebNode&);
404 virtual void exitFullscreenForNode(const WebKit::WebNode&);
405 virtual void setStatusText(const WebKit::WebString& text);
406 virtual void setMouseOverURL(const WebKit::WebURL& url);
407 virtual void setKeyboardFocusURL(const WebKit::WebURL& url);
408 virtual void setToolTipText(const WebKit::WebString& text,
409 WebKit::WebTextDirection hint);
410 virtual void startDragging(const WebKit::WebDragData& data,
411 WebKit::WebDragOperationsMask mask,
412 const WebKit::WebImage& image,
413 const WebKit::WebPoint& imageOffset);
414 virtual bool acceptsLoadDrops();
415 virtual void focusNext();
416 virtual void focusPrevious();
417 virtual void focusedNodeChanged(const WebKit::WebNode& node);
418 virtual void navigateBackForwardSoon(int offset);
419 virtual int historyBackListCount();
420 virtual int historyForwardListCount();
421 virtual void postAccessibilityNotification(
422 const WebKit::WebAccessibilityObject& obj,
423 WebKit::WebAccessibilityNotification notification);
424 virtual void didUpdateInspectorSetting(const WebKit::WebString& key,
425 const WebKit::WebString& value);
426 virtual WebKit::WebGeolocationClient* geolocationClient();
427 virtual WebKit::WebSpeechInputController* speechInputController(
428 WebKit::WebSpeechInputListener* listener);
429 virtual WebKit::WebDeviceOrientationClient* deviceOrientationClient();
430 virtual void zoomLimitsChanged(double minimum_level, double maximum_level);
431 virtual void zoomLevelChanged();
432 virtual void registerProtocolHandler(const WebKit::WebString& scheme,
433 const WebKit::WebString& base_url,
434 const WebKit::WebString& url,
435 const WebKit::WebString& title);
436
437 // WebKit::WebFrameClient implementation -------------------------------------
438
439 virtual WebKit::WebPlugin* createPlugin(
440 WebKit::WebFrame* frame,
441 const WebKit::WebPluginParams& params);
442 virtual WebKit::WebWorker* createWorker(WebKit::WebFrame* frame,
443 WebKit::WebWorkerClient* client);
444 virtual WebKit::WebSharedWorker* createSharedWorker(
445 WebKit::WebFrame* frame, const WebKit::WebURL& url,
446 const WebKit::WebString& name, unsigned long long documentId);
447 virtual WebKit::WebMediaPlayer* createMediaPlayer(
448 WebKit::WebFrame* frame,
449 WebKit::WebMediaPlayerClient* client);
450 virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(
451 WebKit::WebFrame* frame,
452 WebKit::WebApplicationCacheHostClient* client);
453 virtual WebKit::WebCookieJar* cookieJar(WebKit::WebFrame* frame);
454 virtual void frameDetached(WebKit::WebFrame* frame);
455 virtual void willClose(WebKit::WebFrame* frame);
456 virtual bool allowImages(WebKit::WebFrame* frame, bool enabled_per_settings);
457 virtual bool allowPlugins(WebKit::WebFrame* frame, bool enabled_per_settings);
458 virtual void loadURLExternally(WebKit::WebFrame* frame,
459 const WebKit::WebURLRequest& request,
460 WebKit::WebNavigationPolicy policy);
461 virtual WebKit::WebNavigationPolicy decidePolicyForNavigation(
462 WebKit::WebFrame* frame,
463 const WebKit::WebURLRequest& request,
464 WebKit::WebNavigationType type,
465 const WebKit::WebNode&,
466 WebKit::WebNavigationPolicy default_policy,
467 bool is_redirect);
468 virtual bool canHandleRequest(WebKit::WebFrame* frame,
469 const WebKit::WebURLRequest& request);
470 virtual WebKit::WebURLError cannotHandleRequestError(
471 WebKit::WebFrame* frame,
472 const WebKit::WebURLRequest& request);
473 virtual WebKit::WebURLError cancelledError(
474 WebKit::WebFrame* frame,
475 const WebKit::WebURLRequest& request);
476 virtual void unableToImplementPolicyWithError(
477 WebKit::WebFrame* frame,
478 const WebKit::WebURLError& error);
479 virtual void willSendSubmitEvent(WebKit::WebFrame* frame,
480 const WebKit::WebFormElement& form);
481 virtual void willSubmitForm(WebKit::WebFrame* frame,
482 const WebKit::WebFormElement& form);
483 virtual void willPerformClientRedirect(WebKit::WebFrame* frame,
484 const WebKit::WebURL& from,
485 const WebKit::WebURL& to,
486 double interval,
487 double fire_time);
488 virtual void didCancelClientRedirect(WebKit::WebFrame* frame);
489 virtual void didCompleteClientRedirect(WebKit::WebFrame* frame,
490 const WebKit::WebURL& from);
491 virtual void didCreateDataSource(WebKit::WebFrame* frame,
492 WebKit::WebDataSource* datasource);
493 virtual void didStartProvisionalLoad(WebKit::WebFrame* frame);
494 virtual void didReceiveServerRedirectForProvisionalLoad(
495 WebKit::WebFrame* frame);
496 virtual void didFailProvisionalLoad(WebKit::WebFrame* frame,
497 const WebKit::WebURLError& error);
498 virtual void didReceiveDocumentData(WebKit::WebFrame* frame,
499 const char* data, size_t length,
500 bool& prevent_default);
501 virtual void didCommitProvisionalLoad(WebKit::WebFrame* frame,
502 bool is_new_navigation);
503 virtual void didClearWindowObject(WebKit::WebFrame* frame);
504 virtual void didCreateDocumentElement(WebKit::WebFrame* frame);
505 virtual void didReceiveTitle(WebKit::WebFrame* frame,
506 const WebKit::WebString& title);
507 virtual void didChangeIcons(WebKit::WebFrame*);
508 virtual void didFinishDocumentLoad(WebKit::WebFrame* frame);
509 virtual void didHandleOnloadEvents(WebKit::WebFrame* frame);
510 virtual void didFailLoad(WebKit::WebFrame* frame,
511 const WebKit::WebURLError& error);
512 virtual void didFinishLoad(WebKit::WebFrame* frame);
513 virtual void didNavigateWithinPage(WebKit::WebFrame* frame,
514 bool is_new_navigation);
515 virtual void didUpdateCurrentHistoryItem(WebKit::WebFrame* frame);
516 virtual void assignIdentifierToRequest(WebKit::WebFrame* frame,
517 unsigned identifier,
518 const WebKit::WebURLRequest& request);
519 virtual void willSendRequest(WebKit::WebFrame* frame,
520 unsigned identifier,
521 WebKit::WebURLRequest& request,
522 const WebKit::WebURLResponse& redirect_response);
523 virtual void didReceiveResponse(WebKit::WebFrame* frame,
524 unsigned identifier,
525 const WebKit::WebURLResponse& response);
526 virtual void didFinishResourceLoad(WebKit::WebFrame* frame,
527 unsigned identifier);
528 virtual void didFailResourceLoad(WebKit::WebFrame* frame,
529 unsigned identifier,
530 const WebKit::WebURLError& error);
531 virtual void didLoadResourceFromMemoryCache(
532 WebKit::WebFrame* frame,
533 const WebKit::WebURLRequest& request,
534 const WebKit::WebURLResponse&);
535 virtual void didDisplayInsecureContent(WebKit::WebFrame* frame);
536 virtual void didRunInsecureContent(
537 WebKit::WebFrame* frame,
538 const WebKit::WebSecurityOrigin& origin,
539 const WebKit::WebURL& target);
540
541 virtual bool allowScript(WebKit::WebFrame* frame, bool enabled_per_settings);
542 virtual bool allowDatabase(WebKit::WebFrame* frame,
543 const WebKit::WebString& name,
544 const WebKit::WebString& display_name,
545 unsigned long estimated_size);
546 virtual void didNotAllowScript(WebKit::WebFrame* frame);
547 virtual void didNotAllowPlugins(WebKit::WebFrame* frame);
548 virtual void didExhaustMemoryAvailableForScript(WebKit::WebFrame* frame);
549 virtual void didCreateScriptContext(WebKit::WebFrame* frame);
550 virtual void didDestroyScriptContext(WebKit::WebFrame* frame);
551 virtual void didCreateIsolatedScriptContext(WebKit::WebFrame* frame);
552 virtual bool allowScriptExtension(WebKit::WebFrame*,
553 const WebKit::WebString& extension_name,
554 int extensionGroup);
555 virtual void logCrossFramePropertyAccess(
556 WebKit::WebFrame* frame,
557 WebKit::WebFrame* target,
558 bool cross_origin,
559 const WebKit::WebString& property_name,
560 unsigned long long event_id);
561 virtual void didChangeContentsSize(WebKit::WebFrame* frame,
562 const WebKit::WebSize& size);
563 virtual void didChangeScrollOffset(WebKit::WebFrame* frame);
564 virtual void reportFindInPageMatchCount(int request_id,
565 int count,
566 bool final_update);
567 virtual void reportFindInPageSelection(int request_id,
568 int active_match_ordinal,
569 const WebKit::WebRect& sel);
570
571 virtual void openFileSystem(WebKit::WebFrame* frame,
572 WebKit::WebFileSystem::Type type,
573 long long size,
574 bool create,
575 WebKit::WebFileSystemCallbacks* callbacks);
576
[email protected]10e5cf12011-04-13 04:10:40577 virtual void queryStorageUsageAndQuota(
578 WebKit::WebFrame* frame,
579 WebKit::WebStorageQuotaType type,
580 WebKit::WebStorageQuotaCallbacks* callbacks);
581
582 virtual void requestStorageQuota(
583 WebKit::WebFrame* frame,
584 WebKit::WebStorageQuotaType type,
585 unsigned long long requested_size,
586 WebKit::WebStorageQuotaCallbacks* callbacks);
587
[email protected]6e24cf12011-03-18 19:57:02588 // WebKit::WebPageSerializerClient implementation ----------------------------
589
590 virtual void didSerializeDataForFrame(const WebKit::WebURL& frame_url,
591 const WebKit::WebCString& data,
592 PageSerializationStatus status);
593
594 // webkit_glue::WebPluginPageDelegate implementation -------------------------
595
596 virtual webkit::npapi::WebPluginDelegate* CreatePluginDelegate(
597 const FilePath& file_path,
598 const std::string& mime_type);
599 virtual void CreatedPluginWindow(gfx::PluginWindowHandle handle);
600 virtual void WillDestroyPluginWindow(gfx::PluginWindowHandle handle);
601 virtual void DidMovePlugin(const webkit::npapi::WebPluginGeometry& move);
602 virtual void DidStartLoadingForPlugin();
603 virtual void DidStopLoadingForPlugin();
604 virtual WebKit::WebCookieJar* GetCookieJar();
605
606 // Please do not add your stuff randomly to the end here. If there is an
607 // appropriate section, add it there. If not, there are some random functions
608 // nearer to the top you can add it to.
609
610 virtual void DidFlushPaint();
611
[email protected]38b592902011-04-16 02:08:42612 // Cannot use std::set unfortunately since linked_ptr<> does not support
613 // operator<.
614 typedef std::vector<linked_ptr<webkit_glue::ImageResourceFetcher> >
615 ImageResourceFetcherList;
616
[email protected]6e24cf12011-03-18 19:57:02617 protected:
618 // RenderWidget overrides:
619 virtual void Close();
620 virtual void OnResize(const gfx::Size& new_size,
621 const gfx::Rect& resizer_rect);
622 virtual void DidInitiatePaint();
623 virtual webkit::ppapi::PluginInstance* GetBitmapForOptimizedPluginPaint(
624 const gfx::Rect& paint_bounds,
625 TransportDIB** dib,
626 gfx::Rect* location,
627 gfx::Rect* clip);
628 virtual gfx::Point GetScrollOffset();
629 virtual void DidHandleKeyEvent();
630 virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event);
631 virtual void OnSetFocus(bool enable);
632 virtual void OnWasHidden();
633 virtual void OnWasRestored(bool needs_repainting);
634
635 private:
636 // TODO(jam): temporary friend class to ease with the file move. Remove soon.
637 friend class chrome::ChromeContentRendererClient;
638
639 // For unit tests.
640 friend class ExternalPopupMenuTest;
641 friend class PepperDeviceTest;
642 friend class RenderViewTest;
643
644 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuRemoveTest, RemoveOnChange);
645 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, NormalCase);
646 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, ShowPopupThenNavigate);
[email protected]6e24cf12011-03-18 19:57:02647 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, ImeComposition);
648 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, InsertCharacters);
649 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, JSBlockSentAfterPageLoad);
650 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, LastCommittedUpdateState);
651 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnHandleKeyboardEvent);
652 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnImeStateChanged);
653 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnNavStateChanged);
[email protected]6e24cf12011-03-18 19:57:02654 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnSetTextDirection);
[email protected]6e24cf12011-03-18 19:57:02655 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, UpdateTargetURLWithInvalidURL);
656#if defined(OS_MACOSX)
657 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, MacTestCmdUp);
658#endif
659
660 typedef std::map<GURL, ContentSettings> HostContentSettings;
661 typedef std::map<GURL, double> HostZoomLevels;
662
[email protected]6e24cf12011-03-18 19:57:02663 // Identifies an accessibility notification from webkit.
664 struct RendererAccessibilityNotification {
665 public:
666 bool ShouldIncludeChildren();
667
668 // The webkit glue id of the accessibility object.
669 int32 id;
670
671 // The accessibility notification type.
672 WebKit::WebAccessibilityNotification type;
673 };
674
675 enum ErrorPageType {
676 DNS_ERROR,
677 HTTP_404,
678 CONNECTION_ERROR,
679 };
680
681 RenderView(RenderThreadBase* render_thread,
682 gfx::NativeViewId parent_hwnd,
683 int32 opener_id,
684 const RendererPreferences& renderer_prefs,
685 const WebPreferences& webkit_prefs,
686 SharedRenderViewCounter* counter,
687 int32 routing_id,
688 int64 session_storage_namespace_id,
689 const string16& frame_name);
690
691 // Do not delete directly. This class is reference counted.
692 virtual ~RenderView();
693
694 void UpdateURL(WebKit::WebFrame* frame);
695 void UpdateTitle(WebKit::WebFrame* frame, const string16& title);
696 void UpdateSessionHistory(WebKit::WebFrame* frame);
697
698 // Update current main frame's encoding and send it to browser window.
699 // Since we want to let users see the right encoding info from menu
700 // before finishing loading, we call the UpdateEncoding in
701 // a) function:DidCommitLoadForFrame. When this function is called,
702 // that means we have got first data. In here we try to get encoding
703 // of page if it has been specified in http header.
704 // b) function:DidReceiveTitle. When this function is called,
705 // that means we have got specified title. Because in most of webpages,
706 // title tags will follow meta tags. In here we try to get encoding of
707 // page if it has been specified in meta tag.
708 // c) function:DidFinishDocumentLoadForFrame. When this function is
709 // called, that means we have got whole html page. In here we should
710 // finally get right encoding of page.
711 void UpdateEncoding(WebKit::WebFrame* frame,
712 const std::string& encoding_name);
713
714 void OpenURL(const GURL& url, const GURL& referrer,
715 WebKit::WebNavigationPolicy policy);
716
[email protected]6e24cf12011-03-18 19:57:02717 bool RunJavaScriptMessage(int type,
718 const std::wstring& message,
719 const std::wstring& default_value,
720 const GURL& frame_url,
721 std::wstring* result);
722
723 // Sends a message and runs a nested message loop.
724 bool SendAndRunNestedMessageLoop(IPC::SyncMessage* message);
725
726 // Adds search provider from the given OpenSearch description URL as a
727 // keyword search.
728 void AddGURLSearchProvider(const GURL& osd_url,
[email protected]c08e7932011-03-29 04:08:14729 search_provider::OSDDType provider_type);
[email protected]6e24cf12011-03-18 19:57:02730
731 // Send queued accessibility notifications from the renderer to the browser.
732 void SendPendingAccessibilityNotifications();
733
734 // IPC message handlers ------------------------------------------------------
735 //
736 // The documentation for these functions should be in
737 // render_messages_internal.h for the message that the function is handling.
738
739 void OnAccessibilityDoDefaultAction(int acc_obj_id);
740 void OnAccessibilityNotificationsAck();
741 void OnAllowBindings(int enabled_bindings_flags);
[email protected]6e24cf12011-03-18 19:57:02742 void OnAllowScriptToClose(bool script_can_close);
743 void OnAsyncFileOpened(base::PlatformFileError error_code,
744 IPC::PlatformFileForTransit file_for_transit,
745 int message_id);
[email protected]eb415bf0e2011-04-14 02:45:42746 void OnPpapiBrokerChannelCreated(int request_id,
747 const IPC::ChannelHandle& handle);
[email protected]6e24cf12011-03-18 19:57:02748 void OnCancelDownload(int32 download_id);
749 void OnClearFocusedNode();
750 void OnClosePage(const ViewMsg_ClosePage_Params& params);
751#if defined(ENABLE_FLAPPER_HACKS)
752 void OnConnectTcpACK(int request_id,
753 IPC::PlatformFileForTransit socket_for_transit,
754 const PP_Flash_NetAddress& local_addr,
755 const PP_Flash_NetAddress& remote_addr);
756#endif
757 void OnContextMenuClosed(
758 const webkit_glue::CustomContextMenuContext& custom_context);
759 void OnCopy();
760 void OnCopyImageAt(int x, int y);
761#if defined(OS_MACOSX)
762 void OnCopyToFindPboard();
763#endif
764 void OnCut();
[email protected]6e24cf12011-03-18 19:57:02765 void OnCSSInsertRequest(const std::wstring& frame_xpath,
766 const std::string& css,
767 const std::string& id);
768 void OnCustomContextMenuAction(
769 const webkit_glue::CustomContextMenuContext& custom_context,
770 unsigned action);
771 void OnDelete();
772 void OnDeterminePageLanguage();
773 void OnDisableScrollbarsForSmallWindows(
774 const gfx::Size& disable_scrollbars_size_limit);
775 void OnDisassociateFromPopupCount();
776 void OnDownloadFavicon(int id, const GURL& image_url, int image_size);
777 void OnDragSourceEndedOrMoved(const gfx::Point& client_point,
778 const gfx::Point& screen_point,
779 bool ended,
780 WebKit::WebDragOperation drag_operation);
781 void OnDragSourceSystemDragEnded();
782 void OnDragTargetDrop(const gfx::Point& client_pt,
783 const gfx::Point& screen_pt);
784 void OnDragTargetDragEnter(const WebDropData& drop_data,
785 const gfx::Point& client_pt,
786 const gfx::Point& screen_pt,
787 WebKit::WebDragOperationsMask operations_allowed);
788 void OnDragTargetDragLeave();
789 void OnDragTargetDragOver(const gfx::Point& client_pt,
790 const gfx::Point& screen_pt,
791 WebKit::WebDragOperationsMask operations_allowed);
792 void OnEnablePreferredSizeChangedMode(int flags);
793 void OnEnableViewSourceMode();
[email protected]600ea402011-04-12 00:01:51794 void OnEnumerateDirectoryResponse(int id, const std::vector<FilePath>& paths);
[email protected]6e24cf12011-03-18 19:57:02795 void OnExecuteEditCommand(const std::string& name, const std::string& value);
[email protected]6e24cf12011-03-18 19:57:02796 void OnFileChooserResponse(const std::vector<FilePath>& paths);
797 void OnFind(int request_id, const string16&, const WebKit::WebFindOptions&);
798 void OnFindReplyAck();
799 void OnEnableAccessibility();
800 void OnGetAllSavableResourceLinksForCurrentPage(const GURL& page_url);
[email protected]6e24cf12011-03-18 19:57:02801 void OnGetSerializedHtmlDataForCurrentPageWithLocalLinks(
802 const std::vector<GURL>& links,
803 const std::vector<FilePath>& local_paths,
804 const FilePath& local_directory_name);
805 void OnHandleMessageFromExternalHost(const std::string& message,
806 const std::string& origin,
807 const std::string& target);
808 void OnInstallMissingPlugin();
809 void OnDisplayPrerenderedPage();
810 void OnMediaPlayerActionAt(const gfx::Point& location,
811 const WebKit::WebMediaPlayerAction& action);
812 void OnMoveOrResizeStarted();
813 void OnNavigate(const ViewMsg_Navigate_Params& params);
814 void OnNetworkStateChanged(bool online);
815 void OnNotifyRendererViewType(ViewType::Type view_type);
816 void OnPaste();
817#if defined(OS_MACOSX)
818 void OnPluginImeCompositionCompleted(const string16& text, int plugin_id);
819#endif
820 void OnRedo();
821 void OnReloadFrame();
822 void OnReplace(const string16& text);
823 void OnReservePageIDRange(int size_of_range);
824 void OnResetPageEncodingToDefault();
825 void OnScriptEvalRequest(const string16& frame_xpath,
826 const string16& jscript,
827 int id,
828 bool notify_result);
829 void OnSelectAll();
830 void OnSetAccessibilityFocus(int acc_obj_id);
831 void OnSetActive(bool active);
832 void OnSetAltErrorPageURL(const GURL& gurl);
833 void OnSetBackground(const SkBitmap& background);
834 void OnSetContentSettingsForLoadingURL(
835 const GURL& url,
836 const ContentSettings& content_settings);
837 void OnSetWebUIProperty(const std::string& name, const std::string& value);
838 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
839 void OnSetInitialFocus(bool reverse);
840 void OnScrollFocusedEditableNodeIntoView();
841 void OnSetPageEncoding(const std::string& encoding_name);
842 void OnSetRendererPrefs(const RendererPreferences& renderer_prefs);
[email protected]6e24cf12011-03-18 19:57:02843#if defined(OS_MACOSX)
844 void OnSetWindowVisibility(bool visible);
845#endif
846 void OnSetZoomLevel(double zoom_level);
847 void OnSetZoomLevelForLoadingURL(const GURL& url, double zoom_level);
848 void OnShouldClose();
849 void OnStop();
850 void OnStopFinding(const ViewMsg_StopFinding_Params& params);
851 void OnThemeChanged();
[email protected]6e24cf12011-03-18 19:57:02852 void OnUndo();
853 void OnUpdateBrowserWindowId(int window_id);
854 void OnUpdateTargetURLAck();
855 void OnUpdateWebPreferences(const WebPreferences& prefs);
856#if defined(OS_MACOSX)
857 void OnWindowFrameChanged(const gfx::Rect& window_frame,
858 const gfx::Rect& view_frame);
859 void OnSelectPopupMenuItem(int selected_index);
860#endif
861 void OnZoom(PageZoom::Function function);
862 void OnJavaScriptStressTestControl(int cmd, int param);
863
864 // Adding a new message handler? Please add it in alphabetical order above
865 // and put it in the same position in the .cc file.
866
867 // Misc private functions ----------------------------------------------------
868
869 // Helper method that returns if the user wants to block content of type
870 // |content_type|.
871 bool AllowContentType(ContentSettingsType settings_type);
872
873 void AltErrorPageFinished(WebKit::WebFrame* frame,
874 const WebKit::WebURLError& original_error,
875 const std::string& html);
876
877 // Exposes the DOMAutomationController object that allows JS to send
878 // information to the browser process.
879 void BindDOMAutomationController(WebKit::WebFrame* webframe);
880
881 // Check whether the preferred size has changed. This is called periodically
882 // by preferred_size_change_timer_.
883 void CheckPreferredSize();
884
885 // Resets the |content_blocked_| array.
886 void ClearBlockedContentSettings();
887
[email protected]6e24cf12011-03-18 19:57:02888 // Create a new NPAPI plugin.
889 WebKit::WebPlugin* CreateNPAPIPlugin(WebKit::WebFrame* frame,
890 const WebKit::WebPluginParams& params,
891 const FilePath& path,
892 const std::string& mime_type);
893
894 // Create a new Pepper plugin.
895 WebKit::WebPlugin* CreatePepperPlugin(
896 WebKit::WebFrame* frame,
897 const WebKit::WebPluginParams& params,
898 const FilePath& path,
899 webkit::ppapi::PluginModule* pepper_module);
900
901 // Sends an IPC notification that the specified content type was blocked.
902 // If the content type requires it, |resource_identifier| names the specific
903 // resource that was blocked (the plugin path in the case of plugins),
904 // otherwise it's the empty string.
905 void DidBlockContentType(ContentSettingsType settings_type,
906 const std::string& resource_identifier);
907
[email protected]e5cd7b52011-04-13 15:35:20908 // This callback is triggered when DownloadFavicon completes, either
909 // succesfully or with a failure. See DownloadFavicon for more
910 // details.
911 void DidDownloadFavicon(webkit_glue::ImageResourceFetcher* fetcher,
912 const SkBitmap& image);
[email protected]6e24cf12011-03-18 19:57:02913
[email protected]e5cd7b52011-04-13 15:35:20914 // Requests to download a favicon image. When done, the RenderView
915 // is notified by way of DidDownloadFavicon. Returns true if the
916 // request was successfully started, false otherwise. id is used to
917 // uniquely identify the request and passed back to the
918 // DidDownloadFavicon method. If the image has multiple frames, the
919 // frame whose size is image_size is returned. If the image doesn't
920 // have a frame at the specified size, the first is returned.
921 bool DownloadFavicon(int id, const GURL& image_url, int image_size);
[email protected]6e24cf12011-03-18 19:57:02922
[email protected]6e24cf12011-03-18 19:57:02923 GURL GetAlternateErrorPageURL(const GURL& failed_url,
924 ErrorPageType error_type);
925
926 // Locates a sub frame with given xpath
927 WebKit::WebFrame* GetChildFrame(const std::wstring& frame_xpath) const;
928
[email protected]6e24cf12011-03-18 19:57:02929 WebUIBindings* GetWebUIBindings();
930
931 ExternalHostBindings* GetExternalHostBindings();
932
933 // Should only be called if this object wraps a PluginDocument.
934 WebKit::WebPlugin* GetWebPluginFromPluginDocument();
935
936 // Decodes a data: URL image or returns an empty image in case of failure.
937 SkBitmap ImageFromDataUrl(const GURL&) const;
938
939 // Inserts a string of CSS in a particular frame. |id| can be specified to
940 // give the CSS style element an id, and (if specified) will replace the
941 // element with the same id.
942 void InsertCSS(const std::wstring& frame_xpath,
943 const std::string& css,
944 const std::string& id);
945
946 // Returns false unless this is a top-level navigation that crosses origins.
947 bool IsNonLocalTopLevelNavigation(const GURL& url,
948 WebKit::WebFrame* frame,
949 WebKit::WebNavigationType type);
950
951 void LoadNavigationErrorPage(WebKit::WebFrame* frame,
952 const WebKit::WebURLRequest& failed_request,
953 const WebKit::WebURLError& error,
954 const std::string& html,
955 bool replace);
956
957 bool MaybeLoadAlternateErrorPage(WebKit::WebFrame* frame,
958 const WebKit::WebURLError& error,
959 bool replace);
960
961 // Starts nav_state_sync_timer_ if it isn't already running.
962 void StartNavStateSyncTimerIfNecessary();
963
964 // Dispatches the current navigation state to the browser. Called on a
965 // periodic timer so we don't send too many messages.
966 void SyncNavigationState();
967
968#if defined(OS_LINUX)
969 void UpdateFontRenderingFromRendererPrefs();
970#else
971 void UpdateFontRenderingFromRendererPrefs() {}
972#endif
973
974 // Update the target url and tell the browser that the target URL has changed.
975 // If |url| is empty, show |fallback_url|.
976 void UpdateTargetURL(const GURL& url, const GURL& fallback_url);
977
[email protected]6e24cf12011-03-18 19:57:02978 // ---------------------------------------------------------------------------
979 // ADDING NEW FUNCTIONS? Please keep private functions alphabetized and put
980 // it in the same order in the .cc file as it was in the header.
981 // ---------------------------------------------------------------------------
982
983 // Settings ------------------------------------------------------------------
984
985 WebPreferences webkit_preferences_;
986 RendererPreferences renderer_preferences_;
987
988 HostContentSettings host_content_settings_;
989 HostZoomLevels host_zoom_levels_;
990
991 // Whether content state (such as form state, scroll position and page
992 // contents) should be sent to the browser immediately. This is normally
993 // false, but set to true by some tests.
994 bool send_content_state_immediately_;
995
996 // Stores if loading of images, scripts, and plugins is allowed.
997 ContentSettings current_content_settings_;
998
999 // Bitwise-ORed set of extra bindings that have been enabled. See
1000 // BindingsPolicy for details.
1001 int enabled_bindings_;
1002
1003 // The alternate error page URL, if one exists.
1004 GURL alternate_error_page_url_;
1005
1006 // If true, we send IPC messages when |preferred_size_| changes.
1007 bool send_preferred_size_changes_;
1008
1009 // If non-empty, and |send_preferred_size_changes_| is true, disable drawing
1010 // scroll bars on windows smaller than this size. Used for windows that the
1011 // browser resizes to the size of the content, such as browser action popups.
1012 // If a render view is set to the minimum size of its content, webkit may add
1013 // scroll bars. This makes sense for fixed sized windows, but it does not
1014 // make sense when the size of the view was chosen to fit the content.
1015 // This setting ensures that no scroll bars are drawn. The size limit exists
1016 // because if the view grows beyond a size known to the browser, scroll bars
1017 // should be drawn.
1018 gfx::Size disable_scrollbars_size_limit_;
1019
1020 // We need to prevent windows from closing themselves with a window.close()
1021 // call while a blocked popup notification is being displayed. We cannot
1022 // synchronously query the Browser process. We cannot wait for the Browser
1023 // process to send a message to us saying that a blocked popup notification
1024 // is being displayed. We instead assume that when we create a window off
1025 // this RenderView, that it is going to be blocked until we get a message
1026 // from the Browser process telling us otherwise.
1027 bool script_can_close_;
1028
1029 // Loading state -------------------------------------------------------------
1030
1031 // True if the top level frame is currently being loaded.
1032 bool is_loading_;
1033
1034 // The gesture that initiated the current navigation.
1035 NavigationGesture navigation_gesture_;
1036
1037 // Used for popups.
1038 bool opened_by_user_gesture_;
1039 GURL creator_url_;
1040
1041 // Whether this RenderView was created by a frame that was suppressing its
1042 // opener. If so, we may want to load pages in a separate process. See
1043 // decidePolicyForNavigation for details.
1044 bool opener_suppressed_;
1045
1046 // If we are handling a top-level client-side redirect, this tracks the URL
1047 // of the page that initiated it. Specifically, when a load is committed this
1048 // is used to determine if that load originated from a client-side redirect.
1049 // It is empty if there is no top-level client-side redirect.
1050 GURL completed_client_redirect_src_;
1051
1052 // Stores if images, scripts, and plugins have actually been blocked.
1053 bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES];
1054
1055 // Holds state pertaining to a navigation that we initiated. This is held by
1056 // the WebDataSource::ExtraData attribute. We use pending_navigation_state_
1057 // as a temporary holder for the state until the WebDataSource corresponding
1058 // to the new navigation is created. See DidCreateDataSource.
1059 scoped_ptr<NavigationState> pending_navigation_state_;
1060
1061 // Timer used to delay the updating of nav state (see SyncNavigationState).
1062 base::OneShotTimer<RenderView> nav_state_sync_timer_;
1063
1064 // True if the RenderView is currently prerendering a page.
1065 bool is_prerendering_;
1066
1067 // Page IDs ------------------------------------------------------------------
1068 //
1069 // Page IDs allow the browser to identify pages in each renderer process for
1070 // keeping back/forward history in sync.
1071
1072 // ID of the current page. Note that this is NOT updated for every main
1073 // frame navigation, only for "regular" navigations that go into session
1074 // history. In particular, client redirects, like the page cycler uses
1075 // (document.location.href="foo") do not count as regular navigations and do
1076 // not increment the page id.
1077 int32 page_id_;
1078
1079 // Indicates the ID of the last page that we sent a FrameNavigate to the
1080 // browser for. This is used to determine if the most recent transition
1081 // generated a history entry (less than page_id_), or not (equal to or
1082 // greater than). Note that this will be greater than page_id_ if the user
1083 // goes back.
1084 int32 last_page_id_sent_to_browser_;
1085
[email protected]6e24cf12011-03-18 19:57:021086 // The next available page ID to use. This ensures that the page IDs are
1087 // globally unique in the renderer.
1088 static int32 next_page_id_;
1089
1090 // Page info -----------------------------------------------------------------
1091
1092 // The last gotten main frame's encoding.
1093 std::string last_encoding_name_;
1094
1095 int history_list_offset_;
1096 int history_list_length_;
1097
1098 // True if the page has any frame-level unload or beforeunload listeners.
1099 bool has_unload_listener_;
1100
[email protected]6e24cf12011-03-18 19:57:021101 // UI state ------------------------------------------------------------------
1102
1103 // The state of our target_url transmissions. When we receive a request to
1104 // send a URL to the browser, we set this to TARGET_INFLIGHT until an ACK
1105 // comes back - if a new request comes in before the ACK, we store the new
1106 // URL in pending_target_url_ and set the status to TARGET_PENDING. If an
1107 // ACK comes back and we are in TARGET_PENDING, we send the stored URL and
1108 // revert to TARGET_INFLIGHT.
1109 //
1110 // We don't need a queue of URLs to send, as only the latest is useful.
1111 enum {
1112 TARGET_NONE,
1113 TARGET_INFLIGHT, // We have a request in-flight, waiting for an ACK
1114 TARGET_PENDING // INFLIGHT + we have a URL waiting to be sent
1115 } target_url_status_;
1116
1117 // The URL we show the user in the status bar. We use this to determine if we
1118 // want to send a new one (we do not need to send duplicates). It will be
1119 // equal to either |mouse_over_url_| or |focus_url_|, depending on which was
1120 // updated last.
1121 GURL target_url_;
1122
1123 // The URL the user's mouse is hovering over.
1124 GURL mouse_over_url_;
1125
1126 // The URL that has keyboard focus.
1127 GURL focus_url_;
1128
1129 // The next target URL we want to send to the browser.
1130 GURL pending_target_url_;
1131
[email protected]6e24cf12011-03-18 19:57:021132 // The text selection the last time DidChangeSelection got called.
1133 std::string last_selection_;
1134
1135 // View ----------------------------------------------------------------------
1136
1137 // Type of view attached with RenderView. See view_types.h
1138 ViewType::Type view_type_;
1139
1140 // Id number of browser window which RenderView is attached to. This is used
1141 // for extensions.
1142 int browser_window_id_;
1143
1144 // Cache the preferred size of the page in order to prevent sending the IPC
1145 // when layout() recomputes but doesn't actually change sizes.
1146 gfx::Size preferred_size_;
1147
1148 // Nasty hack. WebKit does not send us events when the preferred size changes,
1149 // so we must poll it. See also:
1150 // https://bugs.webkit.org/show_bug.cgi?id=32807.
1151 base::RepeatingTimer<RenderView> preferred_size_change_timer_;
1152
1153#if defined(OS_MACOSX)
1154 // Track the fake plugin window handles allocated on the browser side for
1155 // the accelerated compositor and (currently) accelerated plugins so that
1156 // we can discard them when the view goes away.
1157 std::set<gfx::PluginWindowHandle> fake_plugin_window_handles_;
1158#endif
1159
1160 // Plugins -------------------------------------------------------------------
1161
1162 // Remember the first uninstalled plugin, so that we can ask the plugin
1163 // to install itself when user clicks on the info bar.
1164 base::WeakPtr<webkit::npapi::WebPluginDelegate> first_default_plugin_;
1165
1166 PepperPluginDelegateImpl pepper_delegate_;
1167
1168 // All the currently active plugin delegates for this RenderView; kept so that
1169 // we can enumerate them to send updates about things like window location
1170 // or tab focus and visibily. These are non-owning references.
1171 std::set<WebPluginDelegateProxy*> plugin_delegates_;
1172
1173 // Helper objects ------------------------------------------------------------
1174
[email protected]6e24cf12011-03-18 19:57:021175 ScopedRunnableMethodFactory<RenderView> accessibility_method_factory_;
1176
1177 RendererWebCookieJarImpl cookie_jar_;
1178
1179 // The next group of objects all implement RenderViewObserver, so are deleted
1180 // along with the RenderView automatically. This is why we just store weak
1181 // references.
1182
[email protected]6e24cf12011-03-18 19:57:021183 // Holds a reference to the service which provides desktop notifications.
1184 NotificationProvider* notification_provider_;
1185
1186 // The geolocation dispatcher attached to this view, lazily initialized.
1187 GeolocationDispatcher* geolocation_dispatcher_;
1188
1189 // The speech dispatcher attached to this view, lazily initialized.
1190 SpeechInputDispatcher* speech_input_dispatcher_;
1191
1192 // Device orientation dispatcher attached to this view; lazily initialized.
1193 DeviceOrientationDispatcher* device_orientation_dispatcher_;
1194
[email protected]6e24cf12011-03-18 19:57:021195 scoped_refptr<AudioMessageFilter> audio_message_filter_;
1196
1197 // Handles accessibility requests into the renderer side, as well as
1198 // maintains the cache and other features of the accessibility tree.
1199 scoped_ptr<WebKit::WebAccessibilityCache> accessibility_;
1200
1201 // Collect renderer accessibility notifications until they are ready to be
1202 // sent to the browser.
1203 std::vector<RendererAccessibilityNotification>
1204 pending_accessibility_notifications_;
1205
1206 // Set if we are waiting for a accessibility notification ack.
1207 bool accessibility_ack_pending_;
1208
[email protected]6e24cf12011-03-18 19:57:021209 // Dispatches all P2P socket used by the renderer.
1210 P2PSocketDispatcher* p2p_socket_dispatcher_;
1211
1212 // Misc ----------------------------------------------------------------------
1213
1214 // The current and pending file chooser completion objects. If the queue is
1215 // nonempty, the first item represents the currently running file chooser
1216 // callback, and the remaining elements are the other file chooser completion
1217 // still waiting to be run (in order).
1218 struct PendingFileChooser;
1219 std::deque< linked_ptr<PendingFileChooser> > file_chooser_completions_;
1220
[email protected]600ea402011-04-12 00:01:511221 // The current directory enumeration callback
1222 std::map<int, WebKit::WebFileChooserCompletion*> enumeration_completions_;
1223 int enumeration_completion_id_;
1224
[email protected]6e24cf12011-03-18 19:57:021225 // ImageResourceFetchers schedule via DownloadImage.
1226 ImageResourceFetcherList image_fetchers_;
1227
[email protected]6e24cf12011-03-18 19:57:021228 // The SessionStorage namespace that we're assigned to has an ID, and that ID
1229 // is passed to us upon creation. WebKit asks for this ID upon first use and
1230 // uses it whenever asking the browser process to allocate new storage areas.
1231 int64 session_storage_namespace_id_;
1232
1233 // The total number of unrequested popups that exist and can be followed back
1234 // to a common opener. This count is shared among all RenderViews created
1235 // with createView(). All popups are treated as unrequested until
1236 // specifically instructed otherwise by the Browser process.
1237 scoped_refptr<SharedRenderViewCounter> shared_popup_counter_;
1238
1239 // Whether this is a top level window (instead of a popup). Top level windows
1240 // shouldn't count against their own |shared_popup_counter_|.
1241 bool decrement_shared_popup_at_destruction_;
1242
1243 // If the browser hasn't sent us an ACK for the last FindReply we sent
1244 // to it, then we need to queue up the message (keeping only the most
1245 // recent message if new ones come in).
1246 scoped_ptr<IPC::Message> queued_find_reply_message_;
1247
1248 // Stores edit commands associated to the next key event.
1249 // Shall be cleared as soon as the next key event is processed.
1250 EditCommands edit_commands_;
1251
1252 // Allows JS to access DOM automation. The JS object is only exposed when the
1253 // DOM automation bindings are enabled.
1254 scoped_ptr<DomAutomationController> dom_automation_controller_;
1255
1256 // Allows Web UI pages (new tab page, etc.) to talk to the browser. The JS
1257 // object is only exposed when Web UI bindings are enabled.
1258 scoped_ptr<WebUIBindings> web_ui_bindings_;
1259
1260 // External host exposed through automation controller.
1261 scoped_ptr<ExternalHostBindings> external_host_bindings_;
1262
1263 // The external popup for the currently showing select popup.
1264 scoped_ptr<ExternalPopupMenu> external_popup_menu_;
1265
1266 // The node that the context menu was pressed over.
1267 WebKit::WebNode context_menu_node_;
1268
1269 // Reports load progress to the browser.
1270 scoped_ptr<LoadProgressTracker> load_progress_tracker_;
1271
1272 // All the registered observers. We expect this list to be small, so vector
1273 // is fine.
1274 ObserverList<RenderViewObserver> observers_;
1275
1276 // ---------------------------------------------------------------------------
1277 // ADDING NEW DATA? Please see if it fits appropriately in one of the above
1278 // sections rather than throwing it randomly at the end. If you're adding a
1279 // bunch of stuff, you should probably create a helper class and put your
1280 // data and methods on that to avoid bloating RenderView more. You can use
1281 // the Observer interface to filter IPC messages and receive frame change
1282 // notifications.
1283 // ---------------------------------------------------------------------------
1284
1285 DISALLOW_COPY_AND_ASSIGN(RenderView);
1286};
1287
1288#endif // CONTENT_RENDERER_RENDER_VIEW_H_