| OLD | NEW |
| (Empty) |
| 1 // 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 | |
| 16 #include "base/basictypes.h" | |
| 17 #include "base/gtest_prod_util.h" | |
| 18 #include "base/id_map.h" | |
| 19 #include "base/memory/linked_ptr.h" | |
| 20 #include "base/memory/weak_ptr.h" | |
| 21 #include "base/observer_list.h" | |
| 22 #include "base/timer.h" | |
| 23 #include "build/build_config.h" | |
| 24 #include "content/renderer/render_view_selection.h" | |
| 25 #include "content/renderer/renderer_webcookiejar_impl.h" | |
| 26 #include "content/common/content_export.h" | |
| 27 #include "content/common/edit_command.h" | |
| 28 #include "content/common/navigation_gesture.h" | |
| 29 #include "content/common/page_zoom.h" | |
| 30 #include "content/common/renderer_preferences.h" | |
| 31 #include "content/public/renderer/render_view.h" | |
| 32 #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/WebConsoleMessage.h" | |
| 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystem.h" | |
| 37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" | |
| 38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIconURL.h" | |
| 39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" | |
| 40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializerClie
nt.h" | |
| 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageVisibilityStat
e.h" | |
| 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h" | |
| 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h" | |
| 44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNavigationType.h" | |
| 45 #include "ui/gfx/surface/transport_dib.h" | |
| 46 #include "webkit/glue/webpreferences.h" | |
| 47 #include "webkit/plugins/npapi/webplugin_page_delegate.h" | |
| 48 | |
| 49 #if defined(OS_WIN) | |
| 50 // RenderView is a diamond-shaped hierarchy, with WebWidgetClient at the root. | |
| 51 // VS warns when we inherit the WebWidgetClient method implementations from | |
| 52 // RenderWidget. It's safe to ignore that warning. | |
| 53 #pragma warning(disable: 4250) | |
| 54 #endif | |
| 55 | |
| 56 class AudioMessageFilter; | |
| 57 class DeviceOrientationDispatcher; | |
| 58 class DevToolsAgent; | |
| 59 class ExternalPopupMenu; | |
| 60 class GeolocationDispatcher; | |
| 61 class GURL; | |
| 62 class IntentsDispatcher; | |
| 63 class LoadProgressTracker; | |
| 64 class MediaStreamImpl; | |
| 65 class NotificationProvider; | |
| 66 class PepperDeviceTest; | |
| 67 class PrintWebViewHelper; | |
| 68 class RenderWidgetFullscreenPepper; | |
| 69 class RendererAccessibility; | |
| 70 class SkBitmap; | |
| 71 class SpeechInputDispatcher; | |
| 72 class WebPluginDelegateProxy; | |
| 73 class WebUIBindings; | |
| 74 struct ContextMenuMediaParams; | |
| 75 struct PP_Flash_NetAddress; | |
| 76 struct ViewHostMsg_RunFileChooser_Params; | |
| 77 struct ViewMsg_SwapOut_Params; | |
| 78 struct ViewMsg_Navigate_Params; | |
| 79 struct ViewMsg_StopFinding_Params; | |
| 80 struct WebDropData; | |
| 81 | |
| 82 namespace base { | |
| 83 class WaitableEvent; | |
| 84 } // namespace base | |
| 85 | |
| 86 namespace content { | |
| 87 class NavigationState; | |
| 88 class P2PSocketDispatcher; | |
| 89 class RenderViewObserver; | |
| 90 class RenderViewVisitor; | |
| 91 } // namespace content | |
| 92 | |
| 93 namespace gfx { | |
| 94 class Point; | |
| 95 class Rect; | |
| 96 } // namespace gfx | |
| 97 | |
| 98 namespace webkit { | |
| 99 | |
| 100 namespace ppapi { | |
| 101 class PluginInstance; | |
| 102 class PluginModule; | |
| 103 } // namespace ppapi | |
| 104 | |
| 105 } // namespace webkit | |
| 106 | |
| 107 namespace webkit_glue { | |
| 108 struct CustomContextMenuContext; | |
| 109 class ImageResourceFetcher; | |
| 110 struct FileUploadData; | |
| 111 struct FormData; | |
| 112 struct PasswordFormFillData; | |
| 113 class ResourceFetcher; | |
| 114 } | |
| 115 | |
| 116 namespace WebKit { | |
| 117 class WebApplicationCacheHost; | |
| 118 class WebApplicationCacheHostClient; | |
| 119 class WebDataSource; | |
| 120 class WebDocument; | |
| 121 class WebDragData; | |
| 122 class WebGeolocationClient; | |
| 123 class WebGeolocationServiceInterface; | |
| 124 class WebIconURL; | |
| 125 class WebImage; | |
| 126 class WebInputElement; | |
| 127 class WebKeyboardEvent; | |
| 128 class WebMediaPlayer; | |
| 129 class WebMediaPlayerClient; | |
| 130 class WebMouseEvent; | |
| 131 class WebSpeechInputController; | |
| 132 class WebSpeechInputListener; | |
| 133 class WebStorageNamespace; | |
| 134 class WebTouchEvent; | |
| 135 class WebURLLoader; | |
| 136 class WebURLRequest; | |
| 137 struct WebFileChooserParams; | |
| 138 struct WebFindOptions; | |
| 139 struct WebMediaPlayerAction; | |
| 140 struct WebPoint; | |
| 141 struct WebWindowFeatures; | |
| 142 } | |
| 143 | |
| 144 // We need to prevent a page from trying to create infinite popups. It is not | |
| 145 // as simple as keeping a count of the number of immediate children | |
| 146 // popups. Having an html file that window.open()s itself would create | |
| 147 // an unlimited chain of RenderViews who only have one RenderView child. | |
| 148 // | |
| 149 // Therefore, each new top level RenderView creates a new counter and shares it | |
| 150 // with all its children and grandchildren popup RenderViews created with | |
| 151 // createView() to have a sort of global limit for the page so no more than | |
| 152 // kMaximumNumberOfPopups popups are created. | |
| 153 // | |
| 154 // This is a RefCounted holder of an int because I can't say | |
| 155 // scoped_refptr<int>. | |
| 156 typedef base::RefCountedData<int> SharedRenderViewCounter; | |
| 157 | |
| 158 // | |
| 159 // RenderView is an object that manages a WebView object, and provides a | |
| 160 // communication interface with an embedding application process | |
| 161 // | |
| 162 class RenderView : public RenderWidget, | |
| 163 public WebKit::WebViewClient, | |
| 164 public WebKit::WebFrameClient, | |
| 165 public WebKit::WebPageSerializerClient, | |
| 166 public content::RenderView, | |
| 167 public webkit::npapi::WebPluginPageDelegate, | |
| 168 public base::SupportsWeakPtr<RenderView> { | |
| 169 public: | |
| 170 // Creates a new RenderView. The parent_hwnd specifies a HWND to use as the | |
| 171 // parent of the WebView HWND that will be created. If this is a blocked | |
| 172 // popup or as a new tab, opener_id is the routing ID of the RenderView | |
| 173 // responsible for creating this RenderView (corresponding to parent_hwnd). | |
| 174 // |counter| is either a currently initialized counter, or NULL (in which case | |
| 175 // we treat this RenderView as a top level window). | |
| 176 CONTENT_EXPORT static RenderView* Create( | |
| 177 gfx::NativeViewId parent_hwnd, | |
| 178 int32 opener_id, | |
| 179 const RendererPreferences& renderer_prefs, | |
| 180 const WebPreferences& webkit_prefs, | |
| 181 SharedRenderViewCounter* counter, | |
| 182 int32 routing_id, | |
| 183 int64 session_storage_namespace_id, | |
| 184 const string16& frame_name); | |
| 185 | |
| 186 // Returns the RenderView containing the given WebView. | |
| 187 CONTENT_EXPORT static RenderView* FromWebView(WebKit::WebView* webview); | |
| 188 | |
| 189 // Sets the "next page id" counter. | |
| 190 static void SetNextPageID(int32 next_page_id); | |
| 191 | |
| 192 // May return NULL when the view is closing. | |
| 193 CONTENT_EXPORT WebKit::WebView* webview() const; | |
| 194 | |
| 195 // Called by a GraphicsContext associated with this view when swapbuffers | |
| 196 // is posted, completes or is aborted. | |
| 197 void OnViewContextSwapBuffersPosted(); | |
| 198 void OnViewContextSwapBuffersComplete(); | |
| 199 void OnViewContextSwapBuffersAborted(); | |
| 200 | |
| 201 int history_list_offset() const { return history_list_offset_; } | |
| 202 | |
| 203 const WebPreferences& webkit_preferences() const { | |
| 204 return webkit_preferences_; | |
| 205 } | |
| 206 | |
| 207 void set_send_content_state_immediately(bool value) { | |
| 208 send_content_state_immediately_ = value; | |
| 209 } | |
| 210 | |
| 211 // Current P2PSocketDispatcher. Set to NULL if P2P API is disabled. | |
| 212 content::P2PSocketDispatcher* p2p_socket_dispatcher() { | |
| 213 return p2p_socket_dispatcher_; | |
| 214 } | |
| 215 | |
| 216 // Functions to add and remove observers for this object. | |
| 217 void AddObserver(content::RenderViewObserver* observer); | |
| 218 void RemoveObserver(content::RenderViewObserver* observer); | |
| 219 | |
| 220 // Adds the given file chooser request to the file_chooser_completion_ queue | |
| 221 // (see that var for more) and requests the chooser be displayed if there are | |
| 222 // no other waiting items in the queue. | |
| 223 // | |
| 224 // Returns true if the chooser was successfully scheduled. False means we | |
| 225 // didn't schedule anything. | |
| 226 bool ScheduleFileChooser(const ViewHostMsg_RunFileChooser_Params& params, | |
| 227 WebKit::WebFileChooserCompletion* completion); | |
| 228 | |
| 229 // Sets whether the renderer should report load progress to the browser. | |
| 230 void SetReportLoadProgressEnabled(bool enabled); | |
| 231 | |
| 232 void LoadNavigationErrorPage( | |
| 233 WebKit::WebFrame* frame, | |
| 234 const WebKit::WebURLRequest& failed_request, | |
| 235 const WebKit::WebURLError& error, | |
| 236 const std::string& html, | |
| 237 bool replace); | |
| 238 | |
| 239 // Plugin-related functions -------------------------------------------------- | |
| 240 // (See also WebPluginPageDelegate implementation.) | |
| 241 | |
| 242 // Notification that the given plugin has crashed. | |
| 243 void PluginCrashed(const FilePath& plugin_path); | |
| 244 | |
| 245 // Creates a fullscreen container for a pepper plugin instance. | |
| 246 RenderWidgetFullscreenPepper* CreatePepperFullscreenContainer( | |
| 247 webkit::ppapi::PluginInstance* plugin); | |
| 248 | |
| 249 // Informs the render view that a PPAPI plugin has gained or lost focus. | |
| 250 void PpapiPluginFocusChanged(); | |
| 251 | |
| 252 // Request updated policy regarding firewall NAT traversal being enabled. | |
| 253 void RequestRemoteAccessClientFirewallTraversal(); | |
| 254 | |
| 255 #if defined(OS_MACOSX) || defined(OS_WIN) | |
| 256 // Informs the render view that the given plugin has gained or lost focus. | |
| 257 void PluginFocusChanged(bool focused, int plugin_id); | |
| 258 #endif | |
| 259 | |
| 260 #if defined(OS_MACOSX) | |
| 261 // Starts plugin IME. | |
| 262 void StartPluginIme(); | |
| 263 | |
| 264 // Helper routines for accelerated plugin support. Used by the | |
| 265 // WebPluginDelegateProxy, which has a pointer to the RenderView. | |
| 266 gfx::PluginWindowHandle AllocateFakePluginWindowHandle(bool opaque, | |
| 267 bool root); | |
| 268 void DestroyFakePluginWindowHandle(gfx::PluginWindowHandle window); | |
| 269 void AcceleratedSurfaceSetIOSurface(gfx::PluginWindowHandle window, | |
| 270 int32 width, | |
| 271 int32 height, | |
| 272 uint64 io_surface_identifier); | |
| 273 TransportDIB::Handle AcceleratedSurfaceAllocTransportDIB(size_t size); | |
| 274 void AcceleratedSurfaceFreeTransportDIB(TransportDIB::Id dib_id); | |
| 275 void AcceleratedSurfaceSetTransportDIB(gfx::PluginWindowHandle window, | |
| 276 int32 width, | |
| 277 int32 height, | |
| 278 TransportDIB::Handle transport_dib); | |
| 279 void AcceleratedSurfaceBuffersSwapped(gfx::PluginWindowHandle window, | |
| 280 uint64 surface_id); | |
| 281 #endif | |
| 282 | |
| 283 void RegisterPluginDelegate(WebPluginDelegateProxy* delegate); | |
| 284 void UnregisterPluginDelegate(WebPluginDelegateProxy* delegate); | |
| 285 | |
| 286 // Helper function to retrieve information about a plugin for a URL and mime | |
| 287 // type. Returns false if no plugin was found. | |
| 288 // |actual_mime_type| is the actual mime type supported by the | |
| 289 // plugin found that match the URL given (one for each item in | |
| 290 // |info|). | |
| 291 CONTENT_EXPORT bool GetPluginInfo(const GURL& url, | |
| 292 const GURL& page_url, | |
| 293 const std::string& mime_type, | |
| 294 webkit::WebPluginInfo* plugin_info, | |
| 295 std::string* actual_mime_type); | |
| 296 | |
| 297 // IPC::Channel::Listener implementation ------------------------------------- | |
| 298 | |
| 299 virtual bool OnMessageReceived(const IPC::Message& msg); | |
| 300 | |
| 301 // WebKit::WebWidgetClient implementation ------------------------------------ | |
| 302 | |
| 303 // Most methods are handled by RenderWidget. | |
| 304 virtual void didFocus(); | |
| 305 virtual void didBlur(); | |
| 306 virtual void show(WebKit::WebNavigationPolicy policy); | |
| 307 virtual void runModal(); | |
| 308 | |
| 309 // WebKit::WebViewClient implementation -------------------------------------- | |
| 310 | |
| 311 virtual WebKit::WebView* createView( | |
| 312 WebKit::WebFrame* creator, | |
| 313 const WebKit::WebURLRequest& request, | |
| 314 const WebKit::WebWindowFeatures& features, | |
| 315 const WebKit::WebString& frame_name); | |
| 316 virtual WebKit::WebWidget* createPopupMenu(WebKit::WebPopupType popup_type); | |
| 317 virtual WebKit::WebWidget* createPopupMenu( | |
| 318 const WebKit::WebPopupMenuInfo& info); | |
| 319 virtual WebKit::WebExternalPopupMenu* createExternalPopupMenu( | |
| 320 const WebKit::WebPopupMenuInfo& popup_menu_info, | |
| 321 WebKit::WebExternalPopupMenuClient* popup_menu_client); | |
| 322 virtual WebKit::WebStorageNamespace* createSessionStorageNamespace( | |
| 323 unsigned quota); | |
| 324 virtual void didAddMessageToConsole( | |
| 325 const WebKit::WebConsoleMessage& message, | |
| 326 const WebKit::WebString& source_name, | |
| 327 unsigned source_line); | |
| 328 virtual void printPage(WebKit::WebFrame* frame); | |
| 329 virtual WebKit::WebNotificationPresenter* notificationPresenter(); | |
| 330 virtual bool enumerateChosenDirectory( | |
| 331 const WebKit::WebString& path, | |
| 332 WebKit::WebFileChooserCompletion* chooser_completion); | |
| 333 virtual void didStartLoading(); | |
| 334 virtual void didStopLoading(); | |
| 335 virtual void didChangeLoadProgress(WebKit::WebFrame* frame, | |
| 336 double load_progress); | |
| 337 virtual bool isSmartInsertDeleteEnabled(); | |
| 338 virtual bool isSelectTrailingWhitespaceEnabled(); | |
| 339 virtual void didChangeSelection(bool is_selection_empty); | |
| 340 virtual void didExecuteCommand(const WebKit::WebString& command_name); | |
| 341 virtual bool handleCurrentKeyboardEvent(); | |
| 342 virtual bool runFileChooser( | |
| 343 const WebKit::WebFileChooserParams& params, | |
| 344 WebKit::WebFileChooserCompletion* chooser_completion); | |
| 345 virtual void runModalAlertDialog(WebKit::WebFrame* frame, | |
| 346 const WebKit::WebString& message); | |
| 347 virtual bool runModalConfirmDialog(WebKit::WebFrame* frame, | |
| 348 const WebKit::WebString& message); | |
| 349 virtual bool runModalPromptDialog(WebKit::WebFrame* frame, | |
| 350 const WebKit::WebString& message, | |
| 351 const WebKit::WebString& default_value, | |
| 352 WebKit::WebString* actual_value); | |
| 353 virtual bool runModalBeforeUnloadDialog(WebKit::WebFrame* frame, | |
| 354 const WebKit::WebString& message); | |
| 355 virtual void showContextMenu(WebKit::WebFrame* frame, | |
| 356 const WebKit::WebContextMenuData& data); | |
| 357 virtual bool supportsFullscreen(); | |
| 358 virtual void enterFullscreenForNode(const WebKit::WebNode&); | |
| 359 virtual void exitFullscreenForNode(const WebKit::WebNode&); | |
| 360 virtual void enterFullscreen() OVERRIDE; | |
| 361 virtual void exitFullscreen() OVERRIDE; | |
| 362 virtual void setStatusText(const WebKit::WebString& text); | |
| 363 virtual void setMouseOverURL(const WebKit::WebURL& url); | |
| 364 virtual void setKeyboardFocusURL(const WebKit::WebURL& url); | |
| 365 virtual void startDragging(const WebKit::WebDragData& data, | |
| 366 WebKit::WebDragOperationsMask mask, | |
| 367 const WebKit::WebImage& image, | |
| 368 const WebKit::WebPoint& imageOffset); | |
| 369 virtual bool acceptsLoadDrops(); | |
| 370 virtual void focusNext(); | |
| 371 virtual void focusPrevious(); | |
| 372 virtual void focusedNodeChanged(const WebKit::WebNode& node); | |
| 373 virtual void navigateBackForwardSoon(int offset); | |
| 374 virtual int historyBackListCount(); | |
| 375 virtual int historyForwardListCount(); | |
| 376 virtual void postAccessibilityNotification( | |
| 377 const WebKit::WebAccessibilityObject& obj, | |
| 378 WebKit::WebAccessibilityNotification notification); | |
| 379 virtual void didUpdateInspectorSetting(const WebKit::WebString& key, | |
| 380 const WebKit::WebString& value); | |
| 381 virtual WebKit::WebGeolocationClient* geolocationClient(); | |
| 382 virtual WebKit::WebSpeechInputController* speechInputController( | |
| 383 WebKit::WebSpeechInputListener* listener); | |
| 384 virtual WebKit::WebDeviceOrientationClient* deviceOrientationClient(); | |
| 385 virtual void zoomLimitsChanged(double minimum_level, double maximum_level); | |
| 386 virtual void zoomLevelChanged(); | |
| 387 virtual void registerProtocolHandler(const WebKit::WebString& scheme, | |
| 388 const WebKit::WebString& base_url, | |
| 389 const WebKit::WebString& url, | |
| 390 const WebKit::WebString& title); | |
| 391 virtual void registerIntentHandler(const WebKit::WebString& action, | |
| 392 const WebKit::WebString& type, | |
| 393 const WebKit::WebString& href, | |
| 394 const WebKit::WebString& title); | |
| 395 virtual WebKit::WebPageVisibilityState visibilityState() const; | |
| 396 virtual void startActivity(const WebKit::WebString& action, | |
| 397 const WebKit::WebString& type, | |
| 398 const WebKit::WebString& data, | |
| 399 int intent_id); | |
| 400 | |
| 401 // WebKit::WebFrameClient implementation ------------------------------------- | |
| 402 | |
| 403 virtual WebKit::WebPlugin* createPlugin( | |
| 404 WebKit::WebFrame* frame, | |
| 405 const WebKit::WebPluginParams& params); | |
| 406 virtual WebKit::WebWorker* createWorker(WebKit::WebFrame* frame, | |
| 407 WebKit::WebWorkerClient* client); | |
| 408 virtual WebKit::WebSharedWorker* createSharedWorker( | |
| 409 WebKit::WebFrame* frame, const WebKit::WebURL& url, | |
| 410 const WebKit::WebString& name, unsigned long long documentId); | |
| 411 virtual WebKit::WebMediaPlayer* createMediaPlayer( | |
| 412 WebKit::WebFrame* frame, | |
| 413 WebKit::WebMediaPlayerClient* client); | |
| 414 virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost( | |
| 415 WebKit::WebFrame* frame, | |
| 416 WebKit::WebApplicationCacheHostClient* client); | |
| 417 virtual WebKit::WebCookieJar* cookieJar(WebKit::WebFrame* frame); | |
| 418 virtual void frameDetached(WebKit::WebFrame* frame); | |
| 419 virtual void willClose(WebKit::WebFrame* frame); | |
| 420 virtual void loadURLExternally(WebKit::WebFrame* frame, | |
| 421 const WebKit::WebURLRequest& request, | |
| 422 WebKit::WebNavigationPolicy policy); | |
| 423 virtual void loadURLExternally(WebKit::WebFrame* frame, | |
| 424 const WebKit::WebURLRequest& request, | |
| 425 WebKit::WebNavigationPolicy policy, | |
| 426 const WebKit::WebString& suggested_name); | |
| 427 virtual WebKit::WebNavigationPolicy decidePolicyForNavigation( | |
| 428 WebKit::WebFrame* frame, | |
| 429 const WebKit::WebURLRequest& request, | |
| 430 WebKit::WebNavigationType type, | |
| 431 const WebKit::WebNode&, | |
| 432 WebKit::WebNavigationPolicy default_policy, | |
| 433 bool is_redirect); | |
| 434 virtual bool canHandleRequest(WebKit::WebFrame* frame, | |
| 435 const WebKit::WebURLRequest& request); | |
| 436 virtual WebKit::WebURLError cannotHandleRequestError( | |
| 437 WebKit::WebFrame* frame, | |
| 438 const WebKit::WebURLRequest& request); | |
| 439 virtual WebKit::WebURLError cancelledError( | |
| 440 WebKit::WebFrame* frame, | |
| 441 const WebKit::WebURLRequest& request); | |
| 442 virtual void unableToImplementPolicyWithError( | |
| 443 WebKit::WebFrame* frame, | |
| 444 const WebKit::WebURLError& error); | |
| 445 virtual void willSendSubmitEvent(WebKit::WebFrame* frame, | |
| 446 const WebKit::WebFormElement& form); | |
| 447 virtual void willSubmitForm(WebKit::WebFrame* frame, | |
| 448 const WebKit::WebFormElement& form); | |
| 449 virtual void willPerformClientRedirect(WebKit::WebFrame* frame, | |
| 450 const WebKit::WebURL& from, | |
| 451 const WebKit::WebURL& to, | |
| 452 double interval, | |
| 453 double fire_time); | |
| 454 virtual void didCancelClientRedirect(WebKit::WebFrame* frame); | |
| 455 virtual void didCompleteClientRedirect(WebKit::WebFrame* frame, | |
| 456 const WebKit::WebURL& from); | |
| 457 virtual void didCreateDataSource(WebKit::WebFrame* frame, | |
| 458 WebKit::WebDataSource* datasource); | |
| 459 virtual void didStartProvisionalLoad(WebKit::WebFrame* frame); | |
| 460 virtual void didReceiveServerRedirectForProvisionalLoad( | |
| 461 WebKit::WebFrame* frame); | |
| 462 virtual void didFailProvisionalLoad(WebKit::WebFrame* frame, | |
| 463 const WebKit::WebURLError& error); | |
| 464 virtual void didReceiveDocumentData(WebKit::WebFrame* frame, | |
| 465 const char* data, size_t length, | |
| 466 bool& prevent_default); | |
| 467 virtual void didCommitProvisionalLoad(WebKit::WebFrame* frame, | |
| 468 bool is_new_navigation); | |
| 469 virtual void didClearWindowObject(WebKit::WebFrame* frame); | |
| 470 virtual void didCreateDocumentElement(WebKit::WebFrame* frame); | |
| 471 virtual void didReceiveTitle(WebKit::WebFrame* frame, | |
| 472 const WebKit::WebString& title, | |
| 473 WebKit::WebTextDirection direction); | |
| 474 virtual void didChangeIcon(WebKit::WebFrame*, | |
| 475 WebKit::WebIconURL::Type) OVERRIDE; | |
| 476 virtual void didFinishDocumentLoad(WebKit::WebFrame* frame); | |
| 477 virtual void didHandleOnloadEvents(WebKit::WebFrame* frame); | |
| 478 virtual void didFailLoad(WebKit::WebFrame* frame, | |
| 479 const WebKit::WebURLError& error); | |
| 480 virtual void didFinishLoad(WebKit::WebFrame* frame); | |
| 481 virtual void didNavigateWithinPage(WebKit::WebFrame* frame, | |
| 482 bool is_new_navigation); | |
| 483 virtual void didUpdateCurrentHistoryItem(WebKit::WebFrame* frame); | |
| 484 virtual void assignIdentifierToRequest(WebKit::WebFrame* frame, | |
| 485 unsigned identifier, | |
| 486 const WebKit::WebURLRequest& request); | |
| 487 virtual void willSendRequest(WebKit::WebFrame* frame, | |
| 488 unsigned identifier, | |
| 489 WebKit::WebURLRequest& request, | |
| 490 const WebKit::WebURLResponse& redirect_response); | |
| 491 virtual void didReceiveResponse(WebKit::WebFrame* frame, | |
| 492 unsigned identifier, | |
| 493 const WebKit::WebURLResponse& response); | |
| 494 virtual void didFinishResourceLoad(WebKit::WebFrame* frame, | |
| 495 unsigned identifier); | |
| 496 virtual void didFailResourceLoad(WebKit::WebFrame* frame, | |
| 497 unsigned identifier, | |
| 498 const WebKit::WebURLError& error); | |
| 499 virtual void didLoadResourceFromMemoryCache( | |
| 500 WebKit::WebFrame* frame, | |
| 501 const WebKit::WebURLRequest& request, | |
| 502 const WebKit::WebURLResponse&); | |
| 503 virtual void didDisplayInsecureContent(WebKit::WebFrame* frame); | |
| 504 virtual void didRunInsecureContent( | |
| 505 WebKit::WebFrame* frame, | |
| 506 const WebKit::WebSecurityOrigin& origin, | |
| 507 const WebKit::WebURL& target); | |
| 508 virtual void didAdoptURLLoader(WebKit::WebURLLoader* loader); | |
| 509 virtual void didExhaustMemoryAvailableForScript(WebKit::WebFrame* frame); | |
| 510 virtual void didCreateScriptContext(WebKit::WebFrame* frame, | |
| 511 v8::Handle<v8::Context>, | |
| 512 int world_id); | |
| 513 virtual void willReleaseScriptContext(WebKit::WebFrame* frame, | |
| 514 v8::Handle<v8::Context>, | |
| 515 int world_id); | |
| 516 virtual void didUpdateLayout(WebKit::WebFrame* frame); | |
| 517 virtual void didChangeScrollOffset(WebKit::WebFrame* frame); | |
| 518 virtual void numberOfWheelEventHandlersChanged(unsigned num_handlers); | |
| 519 virtual void didChangeContentsSize(WebKit::WebFrame* frame, | |
| 520 const WebKit::WebSize& size); | |
| 521 virtual void reportFindInPageMatchCount(int request_id, | |
| 522 int count, | |
| 523 bool final_update); | |
| 524 virtual void reportFindInPageSelection(int request_id, | |
| 525 int active_match_ordinal, | |
| 526 const WebKit::WebRect& sel); | |
| 527 | |
| 528 virtual void openFileSystem(WebKit::WebFrame* frame, | |
| 529 WebKit::WebFileSystem::Type type, | |
| 530 long long size, | |
| 531 bool create, | |
| 532 WebKit::WebFileSystemCallbacks* callbacks); | |
| 533 | |
| 534 virtual void queryStorageUsageAndQuota( | |
| 535 WebKit::WebFrame* frame, | |
| 536 WebKit::WebStorageQuotaType type, | |
| 537 WebKit::WebStorageQuotaCallbacks* callbacks); | |
| 538 | |
| 539 virtual void requestStorageQuota( | |
| 540 WebKit::WebFrame* frame, | |
| 541 WebKit::WebStorageQuotaType type, | |
| 542 unsigned long long requested_size, | |
| 543 WebKit::WebStorageQuotaCallbacks* callbacks); | |
| 544 | |
| 545 // WebKit::WebPageSerializerClient implementation ---------------------------- | |
| 546 | |
| 547 virtual void didSerializeDataForFrame( | |
| 548 const WebKit::WebURL& frame_url, | |
| 549 const WebKit::WebCString& data, | |
| 550 PageSerializationStatus status) OVERRIDE; | |
| 551 | |
| 552 // content::RenderView implementation ---------------------------------------- | |
| 553 | |
| 554 virtual bool Send(IPC::Message* message) OVERRIDE; | |
| 555 virtual int GetRoutingId() const OVERRIDE; | |
| 556 virtual int GetPageId() OVERRIDE; | |
| 557 virtual gfx::Size GetSize() OVERRIDE; | |
| 558 virtual gfx::NativeViewId GetHostWindow() OVERRIDE; | |
| 559 virtual WebPreferences& GetWebkitPreferences() OVERRIDE; | |
| 560 virtual WebKit::WebView* GetWebView() OVERRIDE; | |
| 561 virtual WebKit::WebNode GetFocusedNode() const OVERRIDE; | |
| 562 virtual WebKit::WebNode GetContextMenuNode() const OVERRIDE; | |
| 563 virtual bool IsEditableNode(const WebKit::WebNode& node) OVERRIDE; | |
| 564 virtual WebKit::WebPlugin* CreatePlugin( | |
| 565 WebKit::WebFrame* frame, | |
| 566 const webkit::WebPluginInfo& info, | |
| 567 const WebKit::WebPluginParams& params) OVERRIDE; | |
| 568 virtual void EvaluateScript(const string16& frame_xpath, | |
| 569 const string16& jscript, | |
| 570 int id, | |
| 571 bool notify_result) OVERRIDE; | |
| 572 virtual bool ShouldDisplayScrollbars(int width, int height) const OVERRIDE; | |
| 573 virtual int GetEnabledBindings() OVERRIDE; | |
| 574 virtual void SetEnabledBindings(int enabled_bindings) OVERRIDE; | |
| 575 virtual bool GetContentStateImmediately() OVERRIDE; | |
| 576 virtual float GetFilteredTimePerFrame() OVERRIDE; | |
| 577 virtual void ShowContextMenu(WebKit::WebFrame* frame, | |
| 578 const WebKit::WebContextMenuData& data) OVERRIDE; | |
| 579 virtual WebKit::WebPageVisibilityState GetVisibilityState() const OVERRIDE; | |
| 580 virtual void RunModalAlertDialog(WebKit::WebFrame* frame, | |
| 581 const WebKit::WebString& message) OVERRIDE; | |
| 582 virtual void LoadURLExternally( | |
| 583 WebKit::WebFrame* frame, | |
| 584 const WebKit::WebURLRequest& request, | |
| 585 WebKit::WebNavigationPolicy policy) OVERRIDE; | |
| 586 | |
| 587 // webkit_glue::WebPluginPageDelegate implementation ------------------------- | |
| 588 | |
| 589 virtual webkit::npapi::WebPluginDelegate* CreatePluginDelegate( | |
| 590 const FilePath& file_path, | |
| 591 const std::string& mime_type); | |
| 592 virtual void CreatedPluginWindow(gfx::PluginWindowHandle handle); | |
| 593 virtual void WillDestroyPluginWindow(gfx::PluginWindowHandle handle); | |
| 594 virtual void DidMovePlugin(const webkit::npapi::WebPluginGeometry& move); | |
| 595 virtual void DidStartLoadingForPlugin(); | |
| 596 virtual void DidStopLoadingForPlugin(); | |
| 597 virtual WebKit::WebCookieJar* GetCookieJar(); | |
| 598 | |
| 599 // Please do not add your stuff randomly to the end here. If there is an | |
| 600 // appropriate section, add it there. If not, there are some random functions | |
| 601 // nearer to the top you can add it to. | |
| 602 virtual void DidFlushPaint(); | |
| 603 | |
| 604 // Cannot use std::set unfortunately since linked_ptr<> does not support | |
| 605 // operator<. | |
| 606 typedef std::vector<linked_ptr<webkit_glue::ImageResourceFetcher> > | |
| 607 ImageResourceFetcherList; | |
| 608 | |
| 609 protected: | |
| 610 // RenderWidget overrides: | |
| 611 virtual void Close(); | |
| 612 virtual void OnResize(const gfx::Size& new_size, | |
| 613 const gfx::Rect& resizer_rect); | |
| 614 virtual void DidInitiatePaint(); | |
| 615 virtual webkit::ppapi::PluginInstance* GetBitmapForOptimizedPluginPaint( | |
| 616 const gfx::Rect& paint_bounds, | |
| 617 TransportDIB** dib, | |
| 618 gfx::Rect* location, | |
| 619 gfx::Rect* clip); | |
| 620 virtual gfx::Point GetScrollOffset(); | |
| 621 virtual void DidHandleKeyEvent(); | |
| 622 virtual bool WillHandleMouseEvent( | |
| 623 const WebKit::WebMouseEvent& event) OVERRIDE; | |
| 624 virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event); | |
| 625 virtual void DidHandleTouchEvent(const WebKit::WebTouchEvent& event); | |
| 626 virtual void OnSetFocus(bool enable); | |
| 627 virtual void OnWasHidden(); | |
| 628 virtual void OnWasRestored(bool needs_repainting); | |
| 629 virtual bool SupportsAsynchronousSwapBuffers() OVERRIDE; | |
| 630 virtual void OnImeSetComposition( | |
| 631 const string16& text, | |
| 632 const std::vector<WebKit::WebCompositionUnderline>& underlines, | |
| 633 int selection_start, | |
| 634 int selection_end) OVERRIDE; | |
| 635 virtual void OnImeConfirmComposition(const string16& text) OVERRIDE; | |
| 636 virtual ui::TextInputType GetTextInputType() OVERRIDE; | |
| 637 virtual bool CanComposeInline() OVERRIDE; | |
| 638 virtual bool WebWidgetHandlesCompositorScheduling() const OVERRIDE; | |
| 639 | |
| 640 private: | |
| 641 // For unit tests. | |
| 642 friend class ExternalPopupMenuTest; | |
| 643 friend class PepperDeviceTest; | |
| 644 friend class RenderViewTest; | |
| 645 | |
| 646 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuRemoveTest, RemoveOnChange); | |
| 647 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, NormalCase); | |
| 648 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, ShowPopupThenNavigate); | |
| 649 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, DontIgnoreBackAfterNavEntryLimit); | |
| 650 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, ImeComposition); | |
| 651 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, InsertCharacters); | |
| 652 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, JSBlockSentAfterPageLoad); | |
| 653 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, LastCommittedUpdateState); | |
| 654 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnHandleKeyboardEvent); | |
| 655 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnImeStateChanged); | |
| 656 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnNavStateChanged); | |
| 657 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnSetTextDirection); | |
| 658 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnUpdateWebPreferences); | |
| 659 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, StaleNavigationsIgnored); | |
| 660 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, UpdateTargetURLWithInvalidURL); | |
| 661 #if defined(OS_MACOSX) | |
| 662 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, MacTestCmdUp); | |
| 663 #endif | |
| 664 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, SetHistoryLengthAndPrune); | |
| 665 | |
| 666 typedef std::map<GURL, double> HostZoomLevels; | |
| 667 | |
| 668 enum ErrorPageType { | |
| 669 DNS_ERROR, | |
| 670 HTTP_404, | |
| 671 CONNECTION_ERROR, | |
| 672 }; | |
| 673 | |
| 674 RenderView(gfx::NativeViewId parent_hwnd, | |
| 675 int32 opener_id, | |
| 676 const RendererPreferences& renderer_prefs, | |
| 677 const WebPreferences& webkit_prefs, | |
| 678 SharedRenderViewCounter* counter, | |
| 679 int32 routing_id, | |
| 680 int64 session_storage_namespace_id, | |
| 681 const string16& frame_name); | |
| 682 | |
| 683 // Do not delete directly. This class is reference counted. | |
| 684 virtual ~RenderView(); | |
| 685 | |
| 686 void UpdateURL(WebKit::WebFrame* frame); | |
| 687 void UpdateTitle(WebKit::WebFrame* frame, const string16& title, | |
| 688 WebKit::WebTextDirection title_direction); | |
| 689 void UpdateSessionHistory(WebKit::WebFrame* frame); | |
| 690 | |
| 691 // Update current main frame's encoding and send it to browser window. | |
| 692 // Since we want to let users see the right encoding info from menu | |
| 693 // before finishing loading, we call the UpdateEncoding in | |
| 694 // a) function:DidCommitLoadForFrame. When this function is called, | |
| 695 // that means we have got first data. In here we try to get encoding | |
| 696 // of page if it has been specified in http header. | |
| 697 // b) function:DidReceiveTitle. When this function is called, | |
| 698 // that means we have got specified title. Because in most of webpages, | |
| 699 // title tags will follow meta tags. In here we try to get encoding of | |
| 700 // page if it has been specified in meta tag. | |
| 701 // c) function:DidFinishDocumentLoadForFrame. When this function is | |
| 702 // called, that means we have got whole html page. In here we should | |
| 703 // finally get right encoding of page. | |
| 704 void UpdateEncoding(WebKit::WebFrame* frame, | |
| 705 const std::string& encoding_name); | |
| 706 | |
| 707 void OpenURL(WebKit::WebFrame* frame, | |
| 708 const GURL& url, | |
| 709 const GURL& referrer, | |
| 710 WebKit::WebNavigationPolicy policy); | |
| 711 | |
| 712 bool RunJavaScriptMessage(int type, | |
| 713 const string16& message, | |
| 714 const string16& default_value, | |
| 715 const GURL& frame_url, | |
| 716 string16* result); | |
| 717 | |
| 718 // Sends a message and runs a nested message loop. | |
| 719 bool SendAndRunNestedMessageLoop(IPC::SyncMessage* message); | |
| 720 | |
| 721 // Called when the "pinned to left/right edge" state needs to be updated. | |
| 722 void UpdateScrollState(WebKit::WebFrame* frame); | |
| 723 | |
| 724 // IPC message handlers ------------------------------------------------------ | |
| 725 // | |
| 726 // The documentation for these functions should be in | |
| 727 // render_messages_internal.h for the message that the function is handling. | |
| 728 | |
| 729 void OnAllowBindings(int enabled_bindings_flags); | |
| 730 void OnAllowScriptToClose(bool script_can_close); | |
| 731 void OnAsyncFileOpened(base::PlatformFileError error_code, | |
| 732 IPC::PlatformFileForTransit file_for_transit, | |
| 733 int message_id); | |
| 734 void OnPpapiBrokerChannelCreated(int request_id, | |
| 735 base::ProcessHandle broker_process_handle, | |
| 736 const IPC::ChannelHandle& handle); | |
| 737 void OnCancelDownload(int32 download_id); | |
| 738 void OnClearFocusedNode(); | |
| 739 void OnClosePage(); | |
| 740 #if defined(ENABLE_FLAPPER_HACKS) | |
| 741 void OnConnectTcpACK(int request_id, | |
| 742 IPC::PlatformFileForTransit socket_for_transit, | |
| 743 const PP_Flash_NetAddress& local_addr, | |
| 744 const PP_Flash_NetAddress& remote_addr); | |
| 745 #endif | |
| 746 void OnContextMenuClosed( | |
| 747 const webkit_glue::CustomContextMenuContext& custom_context); | |
| 748 void OnCopy(); | |
| 749 void OnCopyImageAt(int x, int y); | |
| 750 #if defined(OS_MACOSX) | |
| 751 void OnCopyToFindPboard(); | |
| 752 #endif | |
| 753 void OnCut(); | |
| 754 void OnCSSInsertRequest(const string16& frame_xpath, | |
| 755 const std::string& css); | |
| 756 void OnCustomContextMenuAction( | |
| 757 const webkit_glue::CustomContextMenuContext& custom_context, | |
| 758 unsigned action); | |
| 759 void OnDelete(); | |
| 760 void OnDeterminePageLanguage(); | |
| 761 void OnDisableScrollbarsForSmallWindows( | |
| 762 const gfx::Size& disable_scrollbars_size_limit); | |
| 763 void OnDisassociateFromPopupCount(); | |
| 764 void OnDragSourceEndedOrMoved(const gfx::Point& client_point, | |
| 765 const gfx::Point& screen_point, | |
| 766 bool ended, | |
| 767 WebKit::WebDragOperation drag_operation); | |
| 768 void OnDragSourceSystemDragEnded(); | |
| 769 void OnDragTargetDrop(const gfx::Point& client_pt, | |
| 770 const gfx::Point& screen_pt); | |
| 771 void OnDragTargetDragEnter(const WebDropData& drop_data, | |
| 772 const gfx::Point& client_pt, | |
| 773 const gfx::Point& screen_pt, | |
| 774 WebKit::WebDragOperationsMask operations_allowed); | |
| 775 void OnDragTargetDragLeave(); | |
| 776 void OnDragTargetDragOver(const gfx::Point& client_pt, | |
| 777 const gfx::Point& screen_pt, | |
| 778 WebKit::WebDragOperationsMask operations_allowed); | |
| 779 void OnEnablePreferredSizeChangedMode(int flags); | |
| 780 void OnEnumerateDirectoryResponse(int id, const std::vector<FilePath>& paths); | |
| 781 void OnExecuteEditCommand(const std::string& name, const std::string& value); | |
| 782 void OnFileChooserResponse(const std::vector<FilePath>& paths); | |
| 783 void OnFind(int request_id, const string16&, const WebKit::WebFindOptions&); | |
| 784 void OnFindReplyAck(); | |
| 785 void OnGetAllSavableResourceLinksForCurrentPage(const GURL& page_url); | |
| 786 void OnGetSerializedHtmlDataForCurrentPageWithLocalLinks( | |
| 787 const std::vector<GURL>& links, | |
| 788 const std::vector<FilePath>& local_paths, | |
| 789 const FilePath& local_directory_name); | |
| 790 void OnLockMouseACK(bool succeeded); | |
| 791 void OnMediaPlayerActionAt(const gfx::Point& location, | |
| 792 const WebKit::WebMediaPlayerAction& action); | |
| 793 void OnMouseLockLost(); | |
| 794 void OnMoveOrResizeStarted(); | |
| 795 CONTENT_EXPORT void OnNavigate(const ViewMsg_Navigate_Params& params); | |
| 796 void OnPaste(); | |
| 797 #if defined(OS_MACOSX) | |
| 798 void OnPluginImeCompositionCompleted(const string16& text, int plugin_id); | |
| 799 #endif | |
| 800 void OnRedo(); | |
| 801 void OnReloadFrame(); | |
| 802 void OnReplace(const string16& text); | |
| 803 void OnReservePageIDRange(int size_of_range); | |
| 804 void OnResetPageEncodingToDefault(); | |
| 805 void OnScriptEvalRequest(const string16& frame_xpath, | |
| 806 const string16& jscript, | |
| 807 int id, | |
| 808 bool notify_result); | |
| 809 void OnSelectAll(); | |
| 810 void OnSelectRange(const gfx::Point& start, const gfx::Point& end); | |
| 811 void OnSetActive(bool active); | |
| 812 void OnSetAltErrorPageURL(const GURL& gurl); | |
| 813 void OnSetBackground(const SkBitmap& background); | |
| 814 void OnSetWebUIProperty(const std::string& name, const std::string& value); | |
| 815 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands); | |
| 816 CONTENT_EXPORT void OnSetHistoryLengthAndPrune(int history_length, | |
| 817 int32 minimum_page_id); | |
| 818 void OnSetInitialFocus(bool reverse); | |
| 819 #if defined(OS_MACOSX) | |
| 820 void OnSetInLiveResize(bool in_live_resize); | |
| 821 #endif | |
| 822 void OnScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect); | |
| 823 void OnSetPageEncoding(const std::string& encoding_name); | |
| 824 void OnSetRendererPrefs(const RendererPreferences& renderer_prefs); | |
| 825 #if defined(OS_MACOSX) | |
| 826 void OnSetWindowVisibility(bool visible); | |
| 827 #endif | |
| 828 void OnSetZoomLevel(double zoom_level); | |
| 829 void OnSetZoomLevelForLoadingURL(const GURL& url, double zoom_level); | |
| 830 void OnExitFullscreen(); | |
| 831 void OnShouldClose(); | |
| 832 void OnStop(); | |
| 833 void OnStopFinding(const ViewMsg_StopFinding_Params& params); | |
| 834 void OnSwapOut(const ViewMsg_SwapOut_Params& params); | |
| 835 void OnThemeChanged(); | |
| 836 void OnUndo(); | |
| 837 void OnUpdateTargetURLAck(); | |
| 838 void OnUpdateWebPreferences(const WebPreferences& prefs); | |
| 839 void OnUpdateRemoteAccessClientFirewallTraversal(const std::string& policy); | |
| 840 | |
| 841 #if defined(OS_MACOSX) | |
| 842 void OnWindowFrameChanged(const gfx::Rect& window_frame, | |
| 843 const gfx::Rect& view_frame); | |
| 844 void OnSelectPopupMenuItem(int selected_index); | |
| 845 #endif | |
| 846 void OnZoom(PageZoom::Function function); | |
| 847 void OnEnableViewSourceMode(); | |
| 848 | |
| 849 // Adding a new message handler? Please add it in alphabetical order above | |
| 850 // and put it in the same position in the .cc file. | |
| 851 | |
| 852 // Misc private functions ---------------------------------------------------- | |
| 853 | |
| 854 void AltErrorPageFinished(WebKit::WebFrame* frame, | |
| 855 const WebKit::WebURLError& original_error, | |
| 856 const std::string& html); | |
| 857 | |
| 858 // Check whether the preferred size has changed. | |
| 859 void CheckPreferredSize(); | |
| 860 | |
| 861 // This callback is triggered when DownloadFavicon completes, either | |
| 862 // succesfully or with a failure. See DownloadFavicon for more | |
| 863 // details. | |
| 864 void DidDownloadFavicon(webkit_glue::ImageResourceFetcher* fetcher, | |
| 865 const SkBitmap& image); | |
| 866 | |
| 867 // Requests to download a favicon image. When done, the RenderView | |
| 868 // is notified by way of DidDownloadFavicon. Returns true if the | |
| 869 // request was successfully started, false otherwise. id is used to | |
| 870 // uniquely identify the request and passed back to the | |
| 871 // DidDownloadFavicon method. If the image has multiple frames, the | |
| 872 // frame whose size is image_size is returned. If the image doesn't | |
| 873 // have a frame at the specified size, the first is returned. | |
| 874 bool DownloadFavicon(int id, const GURL& image_url, int image_size); | |
| 875 | |
| 876 GURL GetAlternateErrorPageURL(const GURL& failed_url, | |
| 877 ErrorPageType error_type); | |
| 878 | |
| 879 // Locates a sub frame with given xpath | |
| 880 WebKit::WebFrame* GetChildFrame(const string16& frame_xpath) const; | |
| 881 | |
| 882 // Returns the opener url if present, else an empty url. | |
| 883 GURL GetOpenerUrl() const; | |
| 884 | |
| 885 WebUIBindings* GetWebUIBindings(); | |
| 886 | |
| 887 // Should only be called if this object wraps a PluginDocument. | |
| 888 WebKit::WebPlugin* GetWebPluginFromPluginDocument(); | |
| 889 | |
| 890 // Returns true if the |params| navigation is to an entry that has been | |
| 891 // cropped due to a recent navigation the browser did not know about. | |
| 892 bool IsBackForwardToStaleEntry(const ViewMsg_Navigate_Params& params, | |
| 893 bool is_reload); | |
| 894 | |
| 895 // Returns false unless this is a top-level navigation that crosses origins. | |
| 896 bool IsNonLocalTopLevelNavigation(const GURL& url, | |
| 897 WebKit::WebFrame* frame, | |
| 898 WebKit::WebNavigationType type); | |
| 899 | |
| 900 bool MaybeLoadAlternateErrorPage(WebKit::WebFrame* frame, | |
| 901 const WebKit::WebURLError& error, | |
| 902 bool replace); | |
| 903 | |
| 904 // Starts nav_state_sync_timer_ if it isn't already running. | |
| 905 void StartNavStateSyncTimerIfNecessary(); | |
| 906 | |
| 907 // Dispatches the current navigation state to the browser. Called on a | |
| 908 // periodic timer so we don't send too many messages. | |
| 909 void SyncNavigationState(); | |
| 910 | |
| 911 // Dispatches the current state of selection on the webpage to the browser if | |
| 912 // it has changed. | |
| 913 // TODO(varunjain): delete this method once we figure out how to keep | |
| 914 // selection handles in sync with the webpage. | |
| 915 void SyncSelectionIfRequired(); | |
| 916 | |
| 917 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
| 918 void UpdateFontRenderingFromRendererPrefs(); | |
| 919 #else | |
| 920 void UpdateFontRenderingFromRendererPrefs() {} | |
| 921 #endif | |
| 922 | |
| 923 // Update the target url and tell the browser that the target URL has changed. | |
| 924 // If |url| is empty, show |fallback_url|. | |
| 925 void UpdateTargetURL(const GURL& url, const GURL& fallback_url); | |
| 926 | |
| 927 // --------------------------------------------------------------------------- | |
| 928 // ADDING NEW FUNCTIONS? Please keep private functions alphabetized and put | |
| 929 // it in the same order in the .cc file as it was in the header. | |
| 930 // --------------------------------------------------------------------------- | |
| 931 | |
| 932 // Settings ------------------------------------------------------------------ | |
| 933 | |
| 934 WebPreferences webkit_preferences_; | |
| 935 RendererPreferences renderer_preferences_; | |
| 936 | |
| 937 HostZoomLevels host_zoom_levels_; | |
| 938 | |
| 939 // Whether content state (such as form state, scroll position and page | |
| 940 // contents) should be sent to the browser immediately. This is normally | |
| 941 // false, but set to true by some tests. | |
| 942 bool send_content_state_immediately_; | |
| 943 | |
| 944 // Bitwise-ORed set of extra bindings that have been enabled. See | |
| 945 // BindingsPolicy for details. | |
| 946 int enabled_bindings_; | |
| 947 | |
| 948 // The alternate error page URL, if one exists. | |
| 949 GURL alternate_error_page_url_; | |
| 950 | |
| 951 // If true, we send IPC messages when |preferred_size_| changes. | |
| 952 bool send_preferred_size_changes_; | |
| 953 | |
| 954 // If non-empty, and |send_preferred_size_changes_| is true, disable drawing | |
| 955 // scroll bars on windows smaller than this size. Used for windows that the | |
| 956 // browser resizes to the size of the content, such as browser action popups. | |
| 957 // If a render view is set to the minimum size of its content, webkit may add | |
| 958 // scroll bars. This makes sense for fixed sized windows, but it does not | |
| 959 // make sense when the size of the view was chosen to fit the content. | |
| 960 // This setting ensures that no scroll bars are drawn. The size limit exists | |
| 961 // because if the view grows beyond a size known to the browser, scroll bars | |
| 962 // should be drawn. | |
| 963 gfx::Size disable_scrollbars_size_limit_; | |
| 964 | |
| 965 // Loading state ------------------------------------------------------------- | |
| 966 | |
| 967 // True if the top level frame is currently being loaded. | |
| 968 bool is_loading_; | |
| 969 | |
| 970 // The gesture that initiated the current navigation. | |
| 971 NavigationGesture navigation_gesture_; | |
| 972 | |
| 973 // Used for popups. | |
| 974 bool opened_by_user_gesture_; | |
| 975 GURL creator_url_; | |
| 976 | |
| 977 // Whether this RenderView was created by a frame that was suppressing its | |
| 978 // opener. If so, we may want to load pages in a separate process. See | |
| 979 // decidePolicyForNavigation for details. | |
| 980 bool opener_suppressed_; | |
| 981 | |
| 982 // If we are handling a top-level client-side redirect, this tracks the URL | |
| 983 // of the page that initiated it. Specifically, when a load is committed this | |
| 984 // is used to determine if that load originated from a client-side redirect. | |
| 985 // It is empty if there is no top-level client-side redirect. | |
| 986 GURL completed_client_redirect_src_; | |
| 987 | |
| 988 // Holds state pertaining to a navigation that we initiated. This is held by | |
| 989 // the WebDataSource::ExtraData attribute. We use pending_navigation_state_ | |
| 990 // as a temporary holder for the state until the WebDataSource corresponding | |
| 991 // to the new navigation is created. See DidCreateDataSource. | |
| 992 scoped_ptr<content::NavigationState> pending_navigation_state_; | |
| 993 | |
| 994 // Timer used to delay the updating of nav state (see SyncNavigationState). | |
| 995 base::OneShotTimer<RenderView> nav_state_sync_timer_; | |
| 996 | |
| 997 // Page IDs ------------------------------------------------------------------ | |
| 998 // See documentation in content::RenderView. | |
| 999 int32 page_id_; | |
| 1000 | |
| 1001 // Indicates the ID of the last page that we sent a FrameNavigate to the | |
| 1002 // browser for. This is used to determine if the most recent transition | |
| 1003 // generated a history entry (less than page_id_), or not (equal to or | |
| 1004 // greater than). Note that this will be greater than page_id_ if the user | |
| 1005 // goes back. | |
| 1006 int32 last_page_id_sent_to_browser_; | |
| 1007 | |
| 1008 // The next available page ID to use. This ensures that the page IDs are | |
| 1009 // globally unique in the renderer. | |
| 1010 static int32 next_page_id_; | |
| 1011 | |
| 1012 // The offset of the current item in the history list. | |
| 1013 int history_list_offset_; | |
| 1014 | |
| 1015 // The RenderView's current impression of the history length. This includes | |
| 1016 // any items that have committed in this process, but because of cross-process | |
| 1017 // navigations, the history may have some entries that were committed in other | |
| 1018 // processes. We won't know about them until the next navigation in this | |
| 1019 // process. | |
| 1020 int history_list_length_; | |
| 1021 | |
| 1022 // The list of page IDs for each history item this RenderView knows about. | |
| 1023 // Some entries may be -1 if they were rendered by other processes or were | |
| 1024 // restored from a previous session. This lets us detect attempts to | |
| 1025 // navigate to stale entries that have been cropped from our history. | |
| 1026 std::vector<int32> history_page_ids_; | |
| 1027 | |
| 1028 // Page info ----------------------------------------------------------------- | |
| 1029 | |
| 1030 // The last gotten main frame's encoding. | |
| 1031 std::string last_encoding_name_; | |
| 1032 | |
| 1033 // UI state ------------------------------------------------------------------ | |
| 1034 | |
| 1035 // The state of our target_url transmissions. When we receive a request to | |
| 1036 // send a URL to the browser, we set this to TARGET_INFLIGHT until an ACK | |
| 1037 // comes back - if a new request comes in before the ACK, we store the new | |
| 1038 // URL in pending_target_url_ and set the status to TARGET_PENDING. If an | |
| 1039 // ACK comes back and we are in TARGET_PENDING, we send the stored URL and | |
| 1040 // revert to TARGET_INFLIGHT. | |
| 1041 // | |
| 1042 // We don't need a queue of URLs to send, as only the latest is useful. | |
| 1043 enum { | |
| 1044 TARGET_NONE, | |
| 1045 TARGET_INFLIGHT, // We have a request in-flight, waiting for an ACK | |
| 1046 TARGET_PENDING // INFLIGHT + we have a URL waiting to be sent | |
| 1047 } target_url_status_; | |
| 1048 | |
| 1049 // The URL we show the user in the status bar. We use this to determine if we | |
| 1050 // want to send a new one (we do not need to send duplicates). It will be | |
| 1051 // equal to either |mouse_over_url_| or |focus_url_|, depending on which was | |
| 1052 // updated last. | |
| 1053 GURL target_url_; | |
| 1054 | |
| 1055 // The URL the user's mouse is hovering over. | |
| 1056 GURL mouse_over_url_; | |
| 1057 | |
| 1058 // The URL that has keyboard focus. | |
| 1059 GURL focus_url_; | |
| 1060 | |
| 1061 // The next target URL we want to send to the browser. | |
| 1062 GURL pending_target_url_; | |
| 1063 | |
| 1064 // The text selection the last time DidChangeSelection got called. | |
| 1065 RenderViewSelection last_selection_; | |
| 1066 | |
| 1067 // View ---------------------------------------------------------------------- | |
| 1068 | |
| 1069 // Cache the preferred size of the page in order to prevent sending the IPC | |
| 1070 // when layout() recomputes but doesn't actually change sizes. | |
| 1071 gfx::Size preferred_size_; | |
| 1072 | |
| 1073 // Used to delay determining the preferred size (to avoid intermediate | |
| 1074 // states for the sizes). | |
| 1075 base::OneShotTimer<RenderView> check_preferred_size_timer_; | |
| 1076 | |
| 1077 // These store the "is main frame is scrolled all the way to the left | |
| 1078 // or right" state that was last sent to the browser. | |
| 1079 bool cached_is_main_frame_pinned_to_left_; | |
| 1080 bool cached_is_main_frame_pinned_to_right_; | |
| 1081 | |
| 1082 // These store the "has scrollbars" state last sent to the browser. | |
| 1083 bool cached_has_main_frame_horizontal_scrollbar_; | |
| 1084 bool cached_has_main_frame_vertical_scrollbar_; | |
| 1085 | |
| 1086 #if defined(OS_MACOSX) | |
| 1087 // Track the fake plugin window handles allocated on the browser side for | |
| 1088 // the accelerated compositor and (currently) accelerated plugins so that | |
| 1089 // we can discard them when the view goes away. | |
| 1090 std::set<gfx::PluginWindowHandle> fake_plugin_window_handles_; | |
| 1091 #endif | |
| 1092 | |
| 1093 // Plugins ------------------------------------------------------------------- | |
| 1094 | |
| 1095 PepperPluginDelegateImpl pepper_delegate_; | |
| 1096 | |
| 1097 // All the currently active plugin delegates for this RenderView; kept so that | |
| 1098 // we can enumerate them to send updates about things like window location | |
| 1099 // or tab focus and visibily. These are non-owning references. | |
| 1100 std::set<WebPluginDelegateProxy*> plugin_delegates_; | |
| 1101 | |
| 1102 #if defined(OS_WIN) | |
| 1103 // The ID of the focused NPAPI plug-in. | |
| 1104 int focused_plugin_id_; | |
| 1105 #endif | |
| 1106 | |
| 1107 // Helper objects ------------------------------------------------------------ | |
| 1108 | |
| 1109 RendererWebCookieJarImpl cookie_jar_; | |
| 1110 | |
| 1111 // The next group of objects all implement RenderViewObserver, so are deleted | |
| 1112 // along with the RenderView automatically. This is why we just store weak | |
| 1113 // references. | |
| 1114 | |
| 1115 // Holds a reference to the service which provides desktop notifications. | |
| 1116 NotificationProvider* notification_provider_; | |
| 1117 | |
| 1118 // The geolocation dispatcher attached to this view, lazily initialized. | |
| 1119 GeolocationDispatcher* geolocation_dispatcher_; | |
| 1120 | |
| 1121 // The intents dispatcher attached to this view. Not lazily initialized. | |
| 1122 IntentsDispatcher* intents_dispatcher_; | |
| 1123 | |
| 1124 // The speech dispatcher attached to this view, lazily initialized. | |
| 1125 SpeechInputDispatcher* speech_input_dispatcher_; | |
| 1126 | |
| 1127 // Device orientation dispatcher attached to this view; lazily initialized. | |
| 1128 DeviceOrientationDispatcher* device_orientation_dispatcher_; | |
| 1129 | |
| 1130 // MediaStreamImpl attached to this view; lazily initialized. | |
| 1131 scoped_refptr<MediaStreamImpl> media_stream_impl_; | |
| 1132 | |
| 1133 // Dispatches all P2P socket used by the renderer. | |
| 1134 content::P2PSocketDispatcher* p2p_socket_dispatcher_; | |
| 1135 | |
| 1136 DevToolsAgent* devtools_agent_; | |
| 1137 | |
| 1138 RendererAccessibility* renderer_accessibility_; | |
| 1139 | |
| 1140 // Misc ---------------------------------------------------------------------- | |
| 1141 | |
| 1142 // The current and pending file chooser completion objects. If the queue is | |
| 1143 // nonempty, the first item represents the currently running file chooser | |
| 1144 // callback, and the remaining elements are the other file chooser completion | |
| 1145 // still waiting to be run (in order). | |
| 1146 struct PendingFileChooser; | |
| 1147 std::deque< linked_ptr<PendingFileChooser> > file_chooser_completions_; | |
| 1148 | |
| 1149 // The current directory enumeration callback | |
| 1150 std::map<int, WebKit::WebFileChooserCompletion*> enumeration_completions_; | |
| 1151 int enumeration_completion_id_; | |
| 1152 | |
| 1153 // The SessionStorage namespace that we're assigned to has an ID, and that ID | |
| 1154 // is passed to us upon creation. WebKit asks for this ID upon first use and | |
| 1155 // uses it whenever asking the browser process to allocate new storage areas. | |
| 1156 int64 session_storage_namespace_id_; | |
| 1157 | |
| 1158 // The total number of unrequested popups that exist and can be followed back | |
| 1159 // to a common opener. This count is shared among all RenderViews created | |
| 1160 // with createView(). All popups are treated as unrequested until | |
| 1161 // specifically instructed otherwise by the Browser process. | |
| 1162 scoped_refptr<SharedRenderViewCounter> shared_popup_counter_; | |
| 1163 | |
| 1164 // Whether this is a top level window (instead of a popup). Top level windows | |
| 1165 // shouldn't count against their own |shared_popup_counter_|. | |
| 1166 bool decrement_shared_popup_at_destruction_; | |
| 1167 | |
| 1168 // If the browser hasn't sent us an ACK for the last FindReply we sent | |
| 1169 // to it, then we need to queue up the message (keeping only the most | |
| 1170 // recent message if new ones come in). | |
| 1171 scoped_ptr<IPC::Message> queued_find_reply_message_; | |
| 1172 | |
| 1173 // Stores edit commands associated to the next key event. | |
| 1174 // Shall be cleared as soon as the next key event is processed. | |
| 1175 EditCommands edit_commands_; | |
| 1176 | |
| 1177 // Allows Web UI pages (new tab page, etc.) to talk to the browser. The JS | |
| 1178 // object is only exposed when Web UI bindings are enabled. | |
| 1179 scoped_ptr<WebUIBindings> web_ui_bindings_; | |
| 1180 | |
| 1181 // The external popup for the currently showing select popup. | |
| 1182 scoped_ptr<ExternalPopupMenu> external_popup_menu_; | |
| 1183 | |
| 1184 // The node that the context menu was pressed over. | |
| 1185 WebKit::WebNode context_menu_node_; | |
| 1186 | |
| 1187 // Reports load progress to the browser. | |
| 1188 scoped_ptr<LoadProgressTracker> load_progress_tracker_; | |
| 1189 | |
| 1190 // All the registered observers. We expect this list to be small, so vector | |
| 1191 // is fine. | |
| 1192 ObserverList<content::RenderViewObserver> observers_; | |
| 1193 | |
| 1194 // Used to inform didChangeSelection() when it is called in the context | |
| 1195 // of handling a ViewMsg_SelectRange IPC. | |
| 1196 bool handling_select_range_; | |
| 1197 | |
| 1198 // --------------------------------------------------------------------------- | |
| 1199 // ADDING NEW DATA? Please see if it fits appropriately in one of the above | |
| 1200 // sections rather than throwing it randomly at the end. If you're adding a | |
| 1201 // bunch of stuff, you should probably create a helper class and put your | |
| 1202 // data and methods on that to avoid bloating RenderView more. You can use | |
| 1203 // the Observer interface to filter IPC messages and receive frame change | |
| 1204 // notifications. | |
| 1205 // --------------------------------------------------------------------------- | |
| 1206 | |
| 1207 DISALLOW_COPY_AND_ASSIGN(RenderView); | |
| 1208 }; | |
| 1209 | |
| 1210 #endif // CONTENT_RENDERER_RENDER_VIEW_H_ | |
| OLD | NEW |