1 // Copyright (c) 2012 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_IMPL_H_ 6 #define CONTENT_RENDERER_RENDER_VIEW_IMPL_H_ 7 8 #include <deque> 9 #include <map> 10 #include <set> 11 #include <string> 12 #include <vector> 13 14 #include "base/basictypes.h" 15 #include "base/gtest_prod_util.h" 16 #include "base/id_map.h" 17 #include "base/memory/linked_ptr.h" 18 #include "base/memory/weak_ptr.h" 19 #include "base/observer_list.h" 20 #include "base/process/process.h" 21 #include "base/strings/string16.h" 22 #include "base/timer/timer.h" 23 #include "build/build_config.h" 24 #include "cc/input/top_controls_state.h" 25 #include "cc/resources/shared_bitmap.h" 26 #include "content/common/content_export.h" 27 #include "content/common/drag_event_source_info.h" 28 #include "content/common/edit_command.h" 29 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 30 #include "content/common/navigation_gesture.h" 31 #include "content/common/view_message_enums.h" 32 #include "content/public/common/page_zoom.h" 33 #include "content/public/common/referrer.h" 34 #include "content/public/common/renderer_preferences.h" 35 #include "content/public/common/stop_find_action.h" 36 #include "content/public/common/top_controls_state.h" 37 #include "content/public/renderer/render_view.h" 38 #include "content/renderer/mouse_lock_dispatcher.h" 39 #include "content/renderer/render_frame_impl.h" 40 #include "content/renderer/render_widget.h" 41 #include "content/renderer/renderer_date_time_picker.h" 42 #include "content/renderer/stats_collection_observer.h" 43 #include "ipc/ipc_platform_file.h" 44 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" 45 #include "third_party/WebKit/public/web/WebAXObject.h" 46 #include "third_party/WebKit/public/web/WebConsoleMessage.h" 47 #include "third_party/WebKit/public/web/WebDataSource.h" 48 #include "third_party/WebKit/public/web/WebElement.h" 49 #include "third_party/WebKit/public/web/WebHistoryItem.h" 50 #include "third_party/WebKit/public/web/WebIconURL.h" 51 #include "third_party/WebKit/public/web/WebInputEvent.h" 52 #include "third_party/WebKit/public/web/WebNavigationType.h" 53 #include "third_party/WebKit/public/web/WebNode.h" 54 #include "third_party/WebKit/public/web/WebPageSerializerClient.h" 55 #include "third_party/WebKit/public/web/WebPageVisibilityState.h" 56 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" 57 #include "third_party/WebKit/public/web/WebViewClient.h" 58 #include "ui/base/window_open_disposition.h" 59 #include "ui/surface/transport_dib.h" 60 #include "webkit/common/webpreferences.h" 61 62 #if defined(OS_ANDROID) 63 #include "content/renderer/android/content_detector.h" 64 #include "third_party/WebKit/public/web/WebContentDetectionResult.h" 65 #endif 66 67 #if defined(COMPILER_MSVC) 68 // RenderViewImpl is a diamond-shaped hierarchy, with WebWidgetClient at the 69 // root. VS warns when we inherit the WebWidgetClient method implementations 70 // from RenderWidget. It's safe to ignore that warning. 71 #pragma warning(disable: 4250) 72 #endif 73 74 class PepperDeviceTest; 75 class SkBitmap; 76 struct PP_NetAddress_Private; 77 struct FrameMsg_Navigate_Params; 78 struct ViewMsg_PostMessage_Params; 79 struct ViewMsg_StopFinding_Params; 80 81 namespace base { 82 class CommandLine; 83 } 84 85 namespace ui { 86 struct SelectedFileInfo; 87 } // namespace ui 88 89 namespace blink { 90 class WebApplicationCacheHost; 91 class WebApplicationCacheHostClient; 92 class WebDOMMessageEvent; 93 class WebDataSource; 94 class WebDateTimeChooserCompletion; 95 class WebDragData; 96 class WebGestureEvent; 97 class WebIconURL; 98 class WebImage; 99 class WebPeerConnection00Handler; 100 class WebPeerConnection00HandlerClient; 101 class WebMouseEvent; 102 class WebPeerConnectionHandler; 103 class WebPeerConnectionHandlerClient; 104 class WebSocketStreamHandle; 105 class WebSpeechRecognizer; 106 class WebStorageNamespace; 107 class WebTouchEvent; 108 class WebURLRequest; 109 struct WebActiveWheelFlingParameters; 110 struct WebDateTimeChooserParams; 111 struct WebFileChooserParams; 112 struct WebFindOptions; 113 struct WebMediaPlayerAction; 114 struct WebPluginAction; 115 struct WebPoint; 116 struct WebWindowFeatures; 117 118 #if defined(OS_ANDROID) 119 class WebHitTestResult; 120 #endif 121 } 122 123 namespace webkit_glue { 124 class WebURLResponseExtraDataImpl; 125 } 126 127 namespace content { 128 class BrowserPluginManager; 129 class DevToolsAgent; 130 class DocumentState; 131 class ExternalPopupMenu; 132 class FaviconHelper; 133 class HistoryController; 134 class HistoryEntry; 135 class ImageResourceFetcher; 136 class MediaStreamDispatcher; 137 class MouseLockDispatcher; 138 class NavigationState; 139 class PepperPluginInstanceImpl; 140 class PushMessagingDispatcher; 141 class RenderViewObserver; 142 class RenderViewTest; 143 class RendererAccessibility; 144 class RendererDateTimePicker; 145 class RendererWebColorChooserImpl; 146 class SpeechRecognitionDispatcher; 147 class WebPluginDelegateProxy; 148 struct DropData; 149 struct FaviconURL; 150 struct FileChooserParams; 151 struct RenderViewImplParams; 152 153 #if defined(OS_ANDROID) 154 class WebMediaPlayerProxyAndroid; 155 #endif 156 157 // 158 // RenderView is an object that manages a WebView object, and provides a 159 // communication interface with an embedding application process 160 // 161 class CONTENT_EXPORT RenderViewImpl 162 : public RenderWidget, 163 NON_EXPORTED_BASE(public blink::WebViewClient), 164 NON_EXPORTED_BASE(public blink::WebPageSerializerClient), 165 public RenderView, 166 public base::SupportsWeakPtr<RenderViewImpl> { 167 public: 168 // Creates a new RenderView. |opener_id| is the routing ID of the RenderView 169 // responsible for creating this RenderView. Note that if the original opener 170 // has been closed, |window_was_created_with_opener| will be true and 171 // |opener_id| will be MSG_ROUTING_NONE. When |swapped_out| is true, the 172 // |proxy_routing_id| is specified, so a RenderFrameProxy can be created for 173 // this RenderView's main RenderFrame. 174 static RenderViewImpl* Create(int32 opener_id, 175 bool window_was_created_with_opener, 176 const RendererPreferences& renderer_prefs, 177 const WebPreferences& webkit_prefs, 178 int32 routing_id, 179 int32 main_frame_routing_id, 180 int32 surface_id, 181 int64 session_storage_namespace_id, 182 const base::string16& frame_name, 183 bool is_renderer_created, 184 bool swapped_out, 185 int32 proxy_routing_id, 186 bool hidden, 187 bool never_visible, 188 int32 next_page_id, 189 const blink::WebScreenInfo& screen_info, 190 AccessibilityMode accessibility_mode); 191 192 // Used by content_layouttest_support to hook into the creation of 193 // RenderViewImpls. 194 static void InstallCreateHook( 195 RenderViewImpl* (*create_render_view_impl)(RenderViewImplParams*)); 196 197 // Returns the RenderViewImpl containing the given WebView. 198 static RenderViewImpl* FromWebView(blink::WebView* webview); 199 200 // Returns the RenderViewImpl for the given routing ID. 201 static RenderViewImpl* FromRoutingID(int routing_id); 202 203 static size_t GetRenderViewCount(); 204 205 // May return NULL when the view is closing. 206 blink::WebView* webview() const; 207 208 int history_list_offset() const { return history_list_offset_; } 209 210 const WebPreferences& webkit_preferences() const { 211 return webkit_preferences_; 212 } 213 214 const RendererPreferences& renderer_preferences() const { 215 return renderer_preferences_; 216 } 217 218 void set_send_content_state_immediately(bool value) { 219 send_content_state_immediately_ = value; 220 } 221 222 RenderFrameImpl* main_render_frame() { return main_render_frame_.get(); } 223 224 // TODO(jam): move to RenderFrameImpl 225 MediaStreamDispatcher* media_stream_dispatcher() { 226 return media_stream_dispatcher_; 227 } 228 229 AccessibilityMode accessibility_mode() { 230 return accessibility_mode_; 231 } 232 233 RendererAccessibility* renderer_accessibility() { 234 return renderer_accessibility_; 235 } 236 237 MouseLockDispatcher* mouse_lock_dispatcher() { 238 return mouse_lock_dispatcher_; 239 } 240 241 HistoryController* history_controller() { 242 return history_controller_.get(); 243 } 244 245 // Lazily initialize this view's BrowserPluginManager and return it. 246 BrowserPluginManager* GetBrowserPluginManager(); 247 248 // Functions to add and remove observers for this object. 249 void AddObserver(RenderViewObserver* observer); 250 void RemoveObserver(RenderViewObserver* observer); 251 252 // Returns the StatsCollectionObserver associated with this view, or NULL 253 // if one wasn't created; 254 StatsCollectionObserver* GetStatsCollectionObserver() { 255 return stats_collection_observer_.get(); 256 } 257 258 // Adds the given file chooser request to the file_chooser_completion_ queue 259 // (see that var for more) and requests the chooser be displayed if there are 260 // no other waiting items in the queue. 261 // 262 // Returns true if the chooser was successfully scheduled. False means we 263 // didn't schedule anything. 264 bool ScheduleFileChooser(const FileChooserParams& params, 265 blink::WebFileChooserCompletion* completion); 266 267 #if defined(OS_ANDROID) 268 void DismissDateTimeDialog(); 269 #endif 270 #if defined(OS_MACOSX) || defined(OS_ANDROID) 271 void DidHideExternalPopupMenu(); 272 #endif 273 274 bool is_loading() const { return frames_in_progress_ != 0; } 275 276 void FrameDidStartLoading(blink::WebFrame* frame); 277 void FrameDidStopLoading(blink::WebFrame* frame); 278 279 // Plugin-related functions -------------------------------------------------- 280 281 #if defined(ENABLE_PLUGINS) 282 // Get/set the plugin which will be used as to handle document find requests. 283 void set_plugin_find_handler(PepperPluginInstanceImpl* plugin) { 284 plugin_find_handler_ = plugin; 285 } 286 PepperPluginInstanceImpl* plugin_find_handler() { 287 return plugin_find_handler_; 288 } 289 290 PepperPluginInstanceImpl* focused_pepper_plugin() { 291 return focused_pepper_plugin_; 292 } 293 PepperPluginInstanceImpl* pepper_last_mouse_event_target() { 294 return pepper_last_mouse_event_target_; 295 } 296 void set_pepper_last_mouse_event_target(PepperPluginInstanceImpl* plugin) { 297 pepper_last_mouse_event_target_ = plugin; 298 } 299 300 #if defined(OS_MACOSX) || defined(OS_WIN) 301 // Informs the render view that the given plugin has gained or lost focus. 302 void PluginFocusChanged(bool focused, int plugin_id); 303 #endif 304 305 #if defined(OS_MACOSX) 306 // Starts plugin IME. 307 void StartPluginIme(); 308 #endif 309 310 // Indicates that the given instance has been created. 311 void PepperInstanceCreated(PepperPluginInstanceImpl* instance); 312 313 // Indicates that the given instance is being destroyed. This is called from 314 // the destructor, so it's important that the instance is not dereferenced 315 // from this call. 316 void PepperInstanceDeleted(PepperPluginInstanceImpl* instance); 317 318 // Notification that the given plugin is focused or unfocused. 319 void PepperFocusChanged(PepperPluginInstanceImpl* instance, bool focused); 320 321 void RegisterPluginDelegate(WebPluginDelegateProxy* delegate); 322 void UnregisterPluginDelegate(WebPluginDelegateProxy* delegate); 323 #endif // ENABLE_PLUGINS 324 325 void TransferActiveWheelFlingAnimation( 326 const blink::WebActiveWheelFlingParameters& params); 327 328 // Returns true if the focused element is editable text from the perspective 329 // of IME support (also used for on-screen keyboard). Works correctly inside 330 // supported PPAPI plug-ins. 331 bool HasIMETextFocus(); 332 333 // Callback for use with GetWindowSnapshot. 334 typedef base::Callback<void( 335 const gfx::Size&, const std::vector<unsigned char>&)> 336 WindowSnapshotCallback; 337 338 void GetWindowSnapshot(const WindowSnapshotCallback& callback); 339 340 // Dispatches the current navigation state to the browser. Called on a 341 // periodic timer so we don't send too many messages. 342 void SyncNavigationState(); 343 344 // Returns the length of the session history of this RenderView. Note that 345 // this only coincides with the actual length of the session history if this 346 // RenderView is the currently active RenderView of a WebContents. 347 unsigned GetLocalSessionHistoryLengthForTesting() const; 348 349 // Invokes OnSetFocus and marks the widget as active depending on the value 350 // of |enable|. This is used for layout tests that need to control the focus 351 // synchronously from the renderer. 352 void SetFocusAndActivateForTesting(bool enable); 353 354 // Change the device scale factor and force the compositor to resize. 355 void SetDeviceScaleFactorForTesting(float factor); 356 357 // Change screen orientation and force the compositor to resize. 358 void SetScreenOrientationForTesting( 359 const blink::WebScreenOrientationType& orientation); 360 361 // Change the device ICC color profile while running a layout test. 362 void SetDeviceColorProfileForTesting(const std::vector<char>& color_profile); 363 364 // Used to force the size of a window when running layout tests. 365 void ForceResizeForTesting(const gfx::Size& new_size); 366 367 void UseSynchronousResizeModeForTesting(bool enable); 368 369 // Control autoresize mode. 370 void EnableAutoResizeForTesting(const gfx::Size& min_size, 371 const gfx::Size& max_size); 372 void DisableAutoResizeForTesting(const gfx::Size& new_size); 373 374 // IPC::Listener implementation ---------------------------------------------- 375 376 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 377 378 // blink::WebWidgetClient implementation ------------------------------------ 379 380 // Most methods are handled by RenderWidget. 381 virtual void didFocus(); 382 virtual void didBlur(); 383 virtual void show(blink::WebNavigationPolicy policy); 384 virtual void runModal(); 385 virtual bool enterFullScreen(); 386 virtual void exitFullScreen(); 387 virtual bool requestPointerLock(); 388 virtual void requestPointerUnlock(); 389 virtual bool isPointerLocked(); 390 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event, 391 bool event_cancelled) OVERRIDE; 392 virtual void initializeLayerTreeView() OVERRIDE; 393 394 // blink::WebViewClient implementation -------------------------------------- 395 396 virtual blink::WebView* createView(blink::WebLocalFrame* creator, 397 const blink::WebURLRequest& request, 398 const blink::WebWindowFeatures& features, 399 const blink::WebString& frame_name, 400 blink::WebNavigationPolicy policy, 401 bool suppress_opener); 402 virtual blink::WebWidget* createPopupMenu(blink::WebPopupType popup_type); 403 virtual blink::WebExternalPopupMenu* createExternalPopupMenu( 404 const blink::WebPopupMenuInfo& popup_menu_info, 405 blink::WebExternalPopupMenuClient* popup_menu_client); 406 virtual blink::WebStorageNamespace* createSessionStorageNamespace(); 407 virtual void printPage(blink::WebLocalFrame* frame); 408 virtual bool enumerateChosenDirectory( 409 const blink::WebString& path, 410 blink::WebFileChooserCompletion* chooser_completion); 411 virtual void didCancelCompositionOnSelectionChange(); 412 virtual bool handleCurrentKeyboardEvent(); 413 virtual bool runFileChooser( 414 const blink::WebFileChooserParams& params, 415 blink::WebFileChooserCompletion* chooser_completion); 416 virtual void showValidationMessage(const blink::WebRect& anchor_in_root_view, 417 const blink::WebString& main_text, 418 const blink::WebString& sub_text, 419 blink::WebTextDirection hint) OVERRIDE; 420 virtual void hideValidationMessage() OVERRIDE; 421 virtual void moveValidationMessage( 422 const blink::WebRect& anchor_in_root_view) OVERRIDE; 423 virtual void setStatusText(const blink::WebString& text); 424 virtual void setMouseOverURL(const blink::WebURL& url); 425 virtual void setKeyboardFocusURL(const blink::WebURL& url); 426 virtual void startDragging(blink::WebLocalFrame* frame, 427 const blink::WebDragData& data, 428 blink::WebDragOperationsMask mask, 429 const blink::WebImage& image, 430 const blink::WebPoint& imageOffset); 431 virtual bool acceptsLoadDrops(); 432 virtual void focusNext(); 433 virtual void focusPrevious(); 434 virtual void focusedNodeChanged(const blink::WebNode& node); 435 virtual void didUpdateLayout(); 436 #if defined(OS_ANDROID) 437 virtual bool didTapMultipleTargets( 438 const blink::WebGestureEvent& event, 439 const blink::WebVector<blink::WebRect>& target_rects); 440 #endif 441 virtual blink::WebString acceptLanguages(); 442 virtual void navigateBackForwardSoon(int offset); 443 virtual int historyBackListCount(); 444 virtual int historyForwardListCount(); 445 virtual void postAccessibilityEvent( 446 const blink::WebAXObject& obj, blink::WebAXEvent event); 447 virtual void didUpdateInspectorSetting(const blink::WebString& key, 448 const blink::WebString& value); 449 virtual blink::WebSpeechRecognizer* speechRecognizer(); 450 virtual void zoomLimitsChanged(double minimum_level, double maximum_level); 451 virtual void zoomLevelChanged(); 452 virtual double zoomLevelToZoomFactor(double zoom_level) const; 453 virtual double zoomFactorToZoomLevel(double factor) const; 454 virtual void registerProtocolHandler(const blink::WebString& scheme, 455 const blink::WebURL& base_url, 456 const blink::WebURL& url, 457 const blink::WebString& title); 458 virtual blink::WebPageVisibilityState visibilityState() const; 459 virtual blink::WebPushClient* webPushClient(); 460 virtual void draggableRegionsChanged(); 461 462 #if defined(OS_ANDROID) 463 virtual void scheduleContentIntent(const blink::WebURL& intent); 464 virtual void cancelScheduledContentIntents(); 465 virtual blink::WebContentDetectionResult detectContentAround( 466 const blink::WebHitTestResult& touch_hit); 467 468 // Only used on Android since all other platforms implement 469 // date and time input fields using MULTIPLE_FIELDS_UI 470 virtual bool openDateTimeChooser(const blink::WebDateTimeChooserParams&, 471 blink::WebDateTimeChooserCompletion*); 472 virtual void didScrollWithKeyboard(const blink::WebSize& delta); 473 #endif 474 475 // blink::WebPageSerializerClient implementation ---------------------------- 476 477 virtual void didSerializeDataForFrame( 478 const blink::WebURL& frame_url, 479 const blink::WebCString& data, 480 PageSerializationStatus status) OVERRIDE; 481 482 // RenderView implementation ------------------------------------------------- 483 484 virtual bool Send(IPC::Message* message) OVERRIDE; 485 virtual RenderFrame* GetMainRenderFrame() OVERRIDE; 486 virtual int GetRoutingID() const OVERRIDE; 487 virtual int GetPageId() const OVERRIDE; 488 virtual gfx::Size GetSize() const OVERRIDE; 489 virtual WebPreferences& GetWebkitPreferences() OVERRIDE; 490 virtual void SetWebkitPreferences(const WebPreferences& preferences) OVERRIDE; 491 virtual blink::WebView* GetWebView() OVERRIDE; 492 virtual blink::WebElement GetFocusedElement() const OVERRIDE; 493 virtual bool IsEditableNode(const blink::WebNode& node) const OVERRIDE; 494 virtual bool ShouldDisplayScrollbars(int width, int height) const OVERRIDE; 495 virtual int GetEnabledBindings() const OVERRIDE; 496 virtual bool GetContentStateImmediately() const OVERRIDE; 497 virtual blink::WebPageVisibilityState GetVisibilityState() const OVERRIDE; 498 virtual void DidStartLoading() OVERRIDE; 499 virtual void DidStopLoading() OVERRIDE; 500 virtual void Repaint(const gfx::Size& size) OVERRIDE; 501 virtual void SetEditCommandForNextKeyEvent(const std::string& name, 502 const std::string& value) OVERRIDE; 503 virtual void ClearEditCommands() OVERRIDE; 504 virtual SSLStatus GetSSLStatusOfFrame(blink::WebFrame* frame) const OVERRIDE; 505 virtual const std::string& GetAcceptLanguages() const OVERRIDE; 506 #if defined(OS_ANDROID) 507 virtual void UpdateTopControlsState(TopControlsState constraints, 508 TopControlsState current, 509 bool animate) OVERRIDE; 510 #endif 511 bool uses_temporary_zoom_level() const { return uses_temporary_zoom_level_; } 512 513 // Please do not add your stuff randomly to the end here. If there is an 514 // appropriate section, add it there. If not, there are some random functions 515 // nearer to the top you can add it to. 516 517 // Cannot use std::set unfortunately since linked_ptr<> does not support 518 // operator<. 519 typedef std::vector<linked_ptr<ImageResourceFetcher> > 520 ImageResourceFetcherList; 521 522 protected: 523 // RenderWidget overrides: 524 virtual void OnClose() OVERRIDE; 525 virtual void Close() OVERRIDE; 526 virtual void OnResize(const ViewMsg_Resize_Params& params) OVERRIDE; 527 virtual void DidInitiatePaint() OVERRIDE; 528 virtual void DidFlushPaint() OVERRIDE; 529 virtual gfx::Vector2d GetScrollOffset() OVERRIDE; 530 virtual void DidHandleKeyEvent() OVERRIDE; 531 virtual bool WillHandleMouseEvent( 532 const blink::WebMouseEvent& event) OVERRIDE; 533 virtual bool WillHandleGestureEvent( 534 const blink::WebGestureEvent& event) OVERRIDE; 535 virtual void DidHandleMouseEvent(const blink::WebMouseEvent& event) OVERRIDE; 536 virtual void DidHandleTouchEvent(const blink::WebTouchEvent& event) OVERRIDE; 537 virtual bool HasTouchEventHandlersAt(const gfx::Point& point) const OVERRIDE; 538 virtual void OnSetFocus(bool enable) OVERRIDE; 539 virtual void OnWasHidden() OVERRIDE; 540 virtual void OnWasShown(bool needs_repainting) OVERRIDE; 541 virtual GURL GetURLForGraphicsContext3D() OVERRIDE; 542 virtual void OnImeSetComposition( 543 const base::string16& text, 544 const std::vector<blink::WebCompositionUnderline>& underlines, 545 int selection_start, 546 int selection_end) OVERRIDE; 547 virtual void OnImeConfirmComposition(const base::string16& text, 548 const gfx::Range& replacement_range, 549 bool keep_selection) OVERRIDE; 550 virtual void SetDeviceScaleFactor(float device_scale_factor) OVERRIDE; 551 virtual bool SetDeviceColorProfile( 552 const std::vector<char>& color_profile) OVERRIDE; 553 virtual void OnOrientationChange() OVERRIDE; 554 virtual ui::TextInputType GetTextInputType() OVERRIDE; 555 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) OVERRIDE; 556 #if defined(OS_MACOSX) || defined(USE_AURA) 557 virtual void GetCompositionCharacterBounds( 558 std::vector<gfx::Rect>* character_bounds) OVERRIDE; 559 virtual void GetCompositionRange(gfx::Range* range) OVERRIDE; 560 #endif 561 virtual bool CanComposeInline() OVERRIDE; 562 virtual void DidCommitCompositorFrame() OVERRIDE; 563 virtual void InstrumentWillBeginFrame(int frame_id) OVERRIDE; 564 virtual void InstrumentDidBeginFrame() OVERRIDE; 565 virtual void InstrumentDidCancelFrame() OVERRIDE; 566 virtual void InstrumentWillComposite() OVERRIDE; 567 568 protected: 569 explicit RenderViewImpl(RenderViewImplParams* params); 570 571 void Initialize(RenderViewImplParams* params); 572 virtual void SetScreenMetricsEmulationParameters( 573 float device_scale_factor, 574 const gfx::Point& root_layer_offset, 575 float root_layer_scale) OVERRIDE; 576 577 // Do not delete directly. This class is reference counted. 578 virtual ~RenderViewImpl(); 579 580 private: 581 // For unit tests. 582 friend class ExternalPopupMenuTest; 583 friend class PepperDeviceTest; 584 friend class RendererAccessibilityTest; 585 friend class RenderViewTest; 586 587 // TODO(nasko): Temporarily friend RenderFrameImpl, so we don't duplicate 588 // utility functions needed in both classes, while we move frame specific 589 // code away from this class. 590 friend class RenderFrameImpl; 591 592 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuRemoveTest, RemoveOnChange); 593 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, NormalCase); 594 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, ShowPopupThenNavigate); 595 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, DecideNavigationPolicyForWebUI); 596 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, 597 DidFailProvisionalLoadWithErrorForError); 598 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, 599 DidFailProvisionalLoadWithErrorForCancellation); 600 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, 601 DontIgnoreBackAfterNavEntryLimit); 602 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, ImeComposition); 603 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, InsertCharacters); 604 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, JSBlockSentAfterPageLoad); 605 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, LastCommittedUpdateState); 606 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnHandleKeyboardEvent); 607 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnImeTypeChanged); 608 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnNavStateChanged); 609 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnSetAccessibilityMode); 610 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnSetTextDirection); 611 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnUpdateWebPreferences); 612 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, 613 SetEditableSelectionAndComposition); 614 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, StaleNavigationsIgnored); 615 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, UpdateTargetURLWithInvalidURL); 616 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, 617 GetCompositionCharacterBoundsTest); 618 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnNavigationHttpPost); 619 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, 620 DecideNavigationPolicyHandlesAllTopLevel); 621 #if defined(OS_MACOSX) 622 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, MacTestCmdUp); 623 #endif 624 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, SetHistoryLengthAndPrune); 625 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, ZoomLimit); 626 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, NavigateFrame); 627 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, BasicRenderFrame); 628 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, TextInputTypeWithPepper); 629 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, 630 MessageOrderInDidChangeSelection); 631 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, SendCandidateWindowEvents); 632 FRIEND_TEST_ALL_PREFIXES(SuppressErrorPageTest, Suppresses); 633 FRIEND_TEST_ALL_PREFIXES(SuppressErrorPageTest, DoesNotSuppress); 634 635 typedef std::map<GURL, double> HostZoomLevels; 636 637 enum ErrorPageType { 638 DNS_ERROR, 639 HTTP_404, 640 CONNECTION_ERROR, 641 }; 642 643 // Old WebFrameClient implementations ---------------------------------------- 644 645 // RenderViewImpl used to be a WebFrameClient, but now RenderFrameImpl is the 646 // WebFrameClient. However, many implementations of WebFrameClient methods 647 // still live here and are called from RenderFrameImpl. These implementations 648 // are to be moved to RenderFrameImpl <http://crbug.com/361761>. 649 650 void didCreateDataSource(blink::WebLocalFrame* frame, 651 blink::WebDataSource* datasource); 652 void didClearWindowObject(blink::WebLocalFrame* frame); 653 void didChangeIcon(blink::WebLocalFrame*, blink::WebIconURL::Type); 654 void didUpdateCurrentHistoryItem(blink::WebLocalFrame* frame); 655 void didChangeScrollOffset(blink::WebLocalFrame* frame); 656 657 static bool IsReload(const FrameMsg_Navigate_Params& params); 658 659 static Referrer GetReferrerFromRequest( 660 blink::WebFrame* frame, 661 const blink::WebURLRequest& request); 662 663 static WindowOpenDisposition NavigationPolicyToDisposition( 664 blink::WebNavigationPolicy policy); 665 666 void UpdateSessionHistory(blink::WebFrame* frame); 667 void SendUpdateState(HistoryEntry* entry); 668 669 // Sends a message and runs a nested message loop. 670 bool SendAndRunNestedMessageLoop(IPC::SyncMessage* message); 671 672 // Called when the "pinned to left/right edge" state needs to be updated. 673 void UpdateScrollState(blink::WebFrame* frame); 674 675 // IPC message handlers ------------------------------------------------------ 676 // 677 // The documentation for these functions should be in 678 // content/common/*_messages.h for the message that the function is handling. 679 void OnExecuteEditCommand(const std::string& name, const std::string& value); 680 void OnMoveCaret(const gfx::Point& point); 681 void OnScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect); 682 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands); 683 void OnAllowBindings(int enabled_bindings_flags); 684 void OnAllowScriptToClose(bool script_can_close); 685 void OnCancelDownload(int32 download_id); 686 void OnClearFocusedElement(); 687 void OnClosePage(); 688 void OnShowContextMenu(ui::MenuSourceType source_type, 689 const gfx::Point& location); 690 void OnCopyImageAt(int x, int y); 691 void OnSaveImageAt(int x, int y); 692 void OnDeterminePageLanguage(); 693 void OnDisableScrollbarsForSmallWindows( 694 const gfx::Size& disable_scrollbars_size_limit); 695 void OnDragSourceEnded(const gfx::Point& client_point, 696 const gfx::Point& screen_point, 697 blink::WebDragOperation drag_operation); 698 void OnDragSourceSystemDragEnded(); 699 void OnDragTargetDrop(const gfx::Point& client_pt, 700 const gfx::Point& screen_pt, 701 int key_modifiers); 702 void OnDragTargetDragEnter(const DropData& drop_data, 703 const gfx::Point& client_pt, 704 const gfx::Point& screen_pt, 705 blink::WebDragOperationsMask operations_allowed, 706 int key_modifiers); 707 void OnDragTargetDragLeave(); 708 void OnDragTargetDragOver(const gfx::Point& client_pt, 709 const gfx::Point& screen_pt, 710 blink::WebDragOperationsMask operations_allowed, 711 int key_modifiers); 712 void OnEnablePreferredSizeChangedMode(); 713 void OnEnableAutoResize(const gfx::Size& min_size, const gfx::Size& max_size); 714 void OnDisableAutoResize(const gfx::Size& new_size); 715 void OnEnumerateDirectoryResponse(int id, 716 const std::vector<base::FilePath>& paths); 717 void OnFileChooserResponse( 718 const std::vector<ui::SelectedFileInfo>& files); 719 void OnFind(int request_id, 720 const base::string16&, 721 const blink::WebFindOptions&); 722 void OnGetAllSavableResourceLinksForCurrentPage(const GURL& page_url); 723 void OnGetSerializedHtmlDataForCurrentPageWithLocalLinks( 724 const std::vector<GURL>& links, 725 const std::vector<base::FilePath>& local_paths, 726 const base::FilePath& local_directory_name); 727 void OnMediaPlayerActionAt(const gfx::Point& location, 728 const blink::WebMediaPlayerAction& action); 729 void OnPluginActionAt(const gfx::Point& location, 730 const blink::WebPluginAction& action); 731 void OnMoveOrResizeStarted(); 732 void OnPostMessageEvent(const ViewMsg_PostMessage_Params& params); 733 void OnReleaseDisambiguationPopupBitmap(const cc::SharedBitmapId& id); 734 void OnResetPageEncodingToDefault(); 735 void OnSetAccessibilityMode(AccessibilityMode new_mode); 736 void OnSetActive(bool active); 737 void OnSetBackgroundOpaque(bool opaque); 738 void OnExitFullscreen(); 739 void OnSetHistoryLengthAndPrune(int history_length, int32 minimum_page_id); 740 void OnSetInitialFocus(bool reverse); 741 void OnSetPageEncoding(const std::string& encoding_name); 742 void OnSetRendererPrefs(const RendererPreferences& renderer_prefs); 743 void OnSetWebUIProperty(const std::string& name, const std::string& value); 744 void OnSetZoomLevelForLoadingURL(const GURL& url, double zoom_level); 745 void OnSetZoomLevelForView(bool uses_temporary_zoom_level, double level); 746 void OnStop(); 747 void OnStopFinding(StopFindAction action); 748 void OnSuppressDialogsUntilSwapOut(); 749 void OnThemeChanged(); 750 void OnUpdateTargetURLAck(); 751 void OnUpdateWebPreferences(const WebPreferences& prefs); 752 void OnZoom(PageZoom zoom); 753 void OnEnableViewSourceMode(); 754 void OnDisownOpener(); 755 void OnWindowSnapshotCompleted(const int snapshot_id, 756 const gfx::Size& size, const std::vector<unsigned char>& png); 757 void OnSelectWordAroundCaret(); 758 #if defined(OS_ANDROID) 759 void OnActivateNearestFindResult(int request_id, float x, float y); 760 void OnFindMatchRects(int current_version); 761 void OnSelectPopupMenuItems(bool canceled, 762 const std::vector<int>& selected_indices); 763 void OnUndoScrollFocusedEditableNodeIntoRect(); 764 void OnUpdateTopControlsState(bool enable_hiding, 765 bool enable_showing, 766 bool animate); 767 void OnExtractSmartClipData(const gfx::Rect& rect); 768 void OnPauseVideoCaptureStream(); 769 void OnResumeVideoCaptureStream(); 770 #elif defined(OS_MACOSX) 771 void OnPluginImeCompositionCompleted(const base::string16& text, 772 int plugin_id); 773 void OnSelectPopupMenuItem(int selected_index); 774 void OnSetInLiveResize(bool in_live_resize); 775 void OnSetWindowVisibility(bool visible); 776 void OnWindowFrameChanged(const gfx::Rect& window_frame, 777 const gfx::Rect& view_frame); 778 #endif 779 780 // Adding a new message handler? Please add it in alphabetical order above 781 // and put it in the same position in the .cc file. 782 783 // Misc private functions ---------------------------------------------------- 784 // Check whether the preferred size has changed. 785 void CheckPreferredSize(); 786 787 // This callback is triggered when DownloadFavicon completes, either 788 // succesfully or with a failure. See DownloadFavicon for more 789 // details. 790 void DidDownloadFavicon(ImageResourceFetcher* fetcher, 791 const SkBitmap& image); 792 793 // Requests to download a favicon image. When done, the RenderView is notified 794 // by way of DidDownloadFavicon. Returns true if the request was successfully 795 // started, false otherwise. id is used to uniquely identify the request and 796 // passed back to the DidDownloadFavicon method. If the image has multiple 797 // frames, the frame whose size is image_size is returned. If the image 798 // doesn't have a frame at the specified size, the first is returned. 799 bool DownloadFavicon(int id, const GURL& image_url, int image_size); 800 801 // Called to get the WebPlugin to handle find requests in the document. 802 // Returns NULL if there is no such WebPlugin. 803 blink::WebPlugin* GetWebPluginForFind(); 804 805 // Returns true if the |params| navigation is to an entry that has been 806 // cropped due to a recent navigation the browser did not know about. 807 bool IsBackForwardToStaleEntry(const FrameMsg_Navigate_Params& params, 808 bool is_reload); 809 810 // Make the given |frame| show an empty, unscriptable page. 811 // TODO(creis): Move this to RenderFrame. 812 void NavigateToSwappedOutURL(blink::WebFrame* frame); 813 814 // If we initiated a navigation, this function will populate |document_state| 815 // with the navigation information saved in OnNavigate(). 816 void PopulateDocumentStateFromPending(DocumentState* document_state); 817 818 // Returns a new NavigationState populated with the navigation information 819 // saved in OnNavigate(). 820 NavigationState* CreateNavigationStateFromPending(); 821 822 // Processes the command-line flags --enable-viewport, 823 // --enable-fixed-layout[=w,h] and --enable-pinch. 824 void ProcessViewLayoutFlags(const base::CommandLine& command_line); 825 826 #if defined(OS_ANDROID) 827 // Launch an Android content intent with the given URL. 828 void LaunchAndroidContentIntent(const GURL& intent_url, size_t request_id); 829 #endif 830 831 // Sends a reply to the current find operation handling if it was a 832 // synchronous find request. 833 void SendFindReply(int request_id, 834 int match_count, 835 int ordinal, 836 const blink::WebRect& selection_rect, 837 bool final_status_update); 838 839 // Starts nav_state_sync_timer_ if it isn't already running. 840 void StartNavStateSyncTimerIfNecessary(); 841 842 #if defined(OS_POSIX) && !defined(OS_MACOSX) 843 void UpdateFontRenderingFromRendererPrefs(); 844 #else 845 void UpdateFontRenderingFromRendererPrefs() {} 846 #endif 847 848 // Update the target url and tell the browser that the target URL has changed. 849 // If |url| is empty, show |fallback_url|. 850 void UpdateTargetURL(const GURL& url, const GURL& fallback_url); 851 852 // Tells the browser what the new list of favicons for the webpage is. 853 void SendUpdateFaviconURL(const std::vector<FaviconURL>& urls); 854 855 // Invoked from DidStopLoading(). Sends the current list of loaded favicons to 856 // the browser. 857 void DidStopLoadingIcons(); 858 859 // Coordinate conversion ----------------------------------------------------- 860 861 gfx::RectF ClientRectToPhysicalWindowRect(const gfx::RectF& rect) const; 862 863 // RenderFrameImpl accessible state ------------------------------------------ 864 // The following section is the set of methods that RenderFrameImpl needs 865 // to access RenderViewImpl state. The set of state variables are page-level 866 // specific, so they don't belong in RenderFrameImpl and should remain in 867 // this object. 868 ObserverList<RenderViewObserver>& observers() { 869 return observers_; 870 } 871 872 // TODO(nasko): Remove this method when we move to frame proxy objects, since 873 // the concept of swapped out will be eliminated. 874 void set_is_swapped_out(bool swapped_out) { 875 is_swapped_out_ = swapped_out; 876 } 877 878 NavigationGesture navigation_gesture() { 879 return navigation_gesture_; 880 } 881 void set_navigation_gesture(NavigationGesture gesture) { 882 navigation_gesture_ = gesture; 883 } 884 885 // --------------------------------------------------------------------------- 886 // ADDING NEW FUNCTIONS? Please keep private functions alphabetized and put 887 // it in the same order in the .cc file as it was in the header. 888 // --------------------------------------------------------------------------- 889 890 // Settings ------------------------------------------------------------------ 891 892 WebPreferences webkit_preferences_; 893 RendererPreferences renderer_preferences_; 894 895 HostZoomLevels host_zoom_levels_; 896 897 // Whether content state (such as form state, scroll position and page 898 // contents) should be sent to the browser immediately. This is normally 899 // false, but set to true by some tests. 900 bool send_content_state_immediately_; 901 902 // Bitwise-ORed set of extra bindings that have been enabled. See 903 // BindingsPolicy for details. 904 int enabled_bindings_; 905 906 // If true, we send IPC messages when |preferred_size_| changes. 907 bool send_preferred_size_changes_; 908 909 // If non-empty, and |send_preferred_size_changes_| is true, disable drawing 910 // scroll bars on windows smaller than this size. Used for windows that the 911 // browser resizes to the size of the content, such as browser action popups. 912 // If a render view is set to the minimum size of its content, webkit may add 913 // scroll bars. This makes sense for fixed sized windows, but it does not 914 // make sense when the size of the view was chosen to fit the content. 915 // This setting ensures that no scroll bars are drawn. The size limit exists 916 // because if the view grows beyond a size known to the browser, scroll bars 917 // should be drawn. 918 gfx::Size disable_scrollbars_size_limit_; 919 920 // Loading state ------------------------------------------------------------- 921 922 // The gesture that initiated the current navigation. 923 // TODO(nasko): Move to RenderFrame, as this is per-frame state. 924 NavigationGesture navigation_gesture_; 925 926 // Used for popups. 927 bool opened_by_user_gesture_; 928 929 // Whether this RenderView was created by a frame that was suppressing its 930 // opener. If so, we may want to load pages in a separate process. See 931 // decidePolicyForNavigation for details. 932 bool opener_suppressed_; 933 934 // Whether we must stop creating nested message loops for modal dialogs until 935 // OnSwapOut is called. This is necessary because modal dialogs have a 936 // PageGroupLoadDeferrer on the stack that interferes with swapping out. 937 bool suppress_dialogs_until_swap_out_; 938 939 // Holds state pertaining to a navigation that we initiated. This is held by 940 // the WebDataSource::ExtraData attribute. We use pending_navigation_state_ 941 // as a temporary holder for the state until the WebDataSource corresponding 942 // to the new navigation is created. See DidCreateDataSource. 943 // TODO(nasko): Move to RenderFrame, as this is per-frame state. 944 scoped_ptr<FrameMsg_Navigate_Params> pending_navigation_params_; 945 946 // Timer used to delay the updating of nav state (see SyncNavigationState). 947 base::OneShotTimer<RenderViewImpl> nav_state_sync_timer_; 948 949 // Page IDs ------------------------------------------------------------------ 950 // See documentation in RenderView. 951 int32 page_id_; 952 953 // Indicates the ID of the last page that we sent a FrameNavigate to the 954 // browser for. This is used to determine if the most recent transition 955 // generated a history entry (less than page_id_), or not (equal to or 956 // greater than). Note that this will be greater than page_id_ if the user 957 // goes back. 958 int32 last_page_id_sent_to_browser_; 959 960 // The next available page ID to use for this RenderView. These IDs are 961 // specific to a given RenderView and the frames within it. 962 int32 next_page_id_; 963 964 // The offset of the current item in the history list. 965 int history_list_offset_; 966 967 // The RenderView's current impression of the history length. This includes 968 // any items that have committed in this process, but because of cross-process 969 // navigations, the history may have some entries that were committed in other 970 // processes. We won't know about them until the next navigation in this 971 // process. 972 int history_list_length_; 973 974 // Counter to track how many frames have sent start notifications but not stop 975 // notifications. TODO(avi): Remove this once DidStartLoading/DidStopLoading 976 // are gone. 977 int frames_in_progress_; 978 979 // The list of page IDs for each history item this RenderView knows about. 980 // Some entries may be -1 if they were rendered by other processes or were 981 // restored from a previous session. This lets us detect attempts to 982 // navigate to stale entries that have been cropped from our history. 983 std::vector<int32> history_page_ids_; 984 985 // UI state ------------------------------------------------------------------ 986 987 // The state of our target_url transmissions. When we receive a request to 988 // send a URL to the browser, we set this to TARGET_INFLIGHT until an ACK 989 // comes back - if a new request comes in before the ACK, we store the new 990 // URL in pending_target_url_ and set the status to TARGET_PENDING. If an 991 // ACK comes back and we are in TARGET_PENDING, we send the stored URL and 992 // revert to TARGET_INFLIGHT. 993 // 994 // We don't need a queue of URLs to send, as only the latest is useful. 995 enum { 996 TARGET_NONE, 997 TARGET_INFLIGHT, // We have a request in-flight, waiting for an ACK 998 TARGET_PENDING // INFLIGHT + we have a URL waiting to be sent 999 } target_url_status_; 1000 1001 // The URL we show the user in the status bar. We use this to determine if we 1002 // want to send a new one (we do not need to send duplicates). It will be 1003 // equal to either |mouse_over_url_| or |focus_url_|, depending on which was 1004 // updated last. 1005 GURL target_url_; 1006 1007 // The URL the user's mouse is hovering over. 1008 GURL mouse_over_url_; 1009 1010 // The URL that has keyboard focus. 1011 GURL focus_url_; 1012 1013 // The next target URL we want to send to the browser. 1014 GURL pending_target_url_; 1015 1016 // Indicates whether this view overrides url-based zoom settings. 1017 bool uses_temporary_zoom_level_; 1018 1019 #if defined(OS_ANDROID) 1020 // Cache the old top controls state constraints. Used when updating 1021 // current value only without altering the constraints. 1022 cc::TopControlsState top_controls_constraints_; 1023 #endif 1024 1025 // View ---------------------------------------------------------------------- 1026 1027 // Cache the preferred size of the page in order to prevent sending the IPC 1028 // when layout() recomputes but doesn't actually change sizes. 1029 gfx::Size preferred_size_; 1030 1031 // Used to delay determining the preferred size (to avoid intermediate 1032 // states for the sizes). 1033 base::OneShotTimer<RenderViewImpl> check_preferred_size_timer_; 1034 1035 // Bookkeeping to suppress redundant scroll and focus requests for an already 1036 // scrolled and focused editable node. 1037 bool has_scrolled_focused_editable_node_into_rect_; 1038 gfx::Rect rect_for_scrolled_focused_editable_node_; 1039 1040 // Helper objects ------------------------------------------------------------ 1041 1042 scoped_ptr<RenderFrameImpl> main_render_frame_; 1043 1044 // The next group of objects all implement RenderViewObserver, so are deleted 1045 // along with the RenderView automatically. This is why we just store 1046 // weak references. 1047 1048 // The push messaging dispatcher attached to this view, lazily initialized. 1049 PushMessagingDispatcher* push_messaging_dispatcher_; 1050 1051 // The speech recognition dispatcher attached to this view, lazily 1052 // initialized. 1053 SpeechRecognitionDispatcher* speech_recognition_dispatcher_; 1054 1055 // MediaStream dispatcher attached to this view; lazily initialized. 1056 MediaStreamDispatcher* media_stream_dispatcher_; 1057 1058 // BrowserPluginManager attached to this view; lazily initialized. 1059 scoped_refptr<BrowserPluginManager> browser_plugin_manager_; 1060 1061 DevToolsAgent* devtools_agent_; 1062 1063 // The current accessibility mode. 1064 AccessibilityMode accessibility_mode_; 1065 1066 // Only valid if |accessibility_mode_| is anything other than 1067 // AccessibilityModeOff. 1068 RendererAccessibility* renderer_accessibility_; 1069 1070 // Mouse Lock dispatcher attached to this view. 1071 MouseLockDispatcher* mouse_lock_dispatcher_; 1072 1073 scoped_ptr<HistoryController> history_controller_; 1074 1075 #if defined(OS_ANDROID) 1076 // Android Specific --------------------------------------------------------- 1077 1078 // Expected id of the next content intent launched. Used to prevent scheduled 1079 // intents to be launched if aborted. 1080 size_t expected_content_intent_id_; 1081 1082 // List of click-based content detectors. 1083 typedef std::vector< linked_ptr<ContentDetector> > ContentDetectorList; 1084 ContentDetectorList content_detectors_; 1085 1086 // A date/time picker object for date and time related input elements. 1087 scoped_ptr<RendererDateTimePicker> date_time_picker_client_; 1088 #endif 1089 1090 // Plugins ------------------------------------------------------------------- 1091 1092 // All the currently active plugin delegates for this RenderView; kept so 1093 // that we can enumerate them to send updates about things like window 1094 // location or tab focus and visibily. These are non-owning references. 1095 std::set<WebPluginDelegateProxy*> plugin_delegates_; 1096 1097 #if defined(OS_WIN) 1098 // The ID of the focused NPAPI plug-in. 1099 int focused_plugin_id_; 1100 #endif 1101 1102 #if defined(ENABLE_PLUGINS) 1103 PepperPluginInstanceImpl* plugin_find_handler_; 1104 1105 typedef std::set<PepperPluginInstanceImpl*> PepperPluginSet; 1106 PepperPluginSet active_pepper_instances_; 1107 1108 // TODO(jam): these belong on RenderFrame, once the browser knows which frame 1109 // is focused and sends the IPCs which use these to the correct frame. Until 1110 // then, we must store these on RenderView as that's the one place that knows 1111 // about all the RenderFrames for a page. 1112 1113 // Whether or not the focus is on a PPAPI plugin 1114 PepperPluginInstanceImpl* focused_pepper_plugin_; 1115 1116 // The plugin instance that received the last mouse event. It is set to NULL 1117 // if the last mouse event went to elements other than Pepper plugins. 1118 // |pepper_last_mouse_event_target_| is not owned by this class. We depend on 1119 // the RenderFrameImpl to NULL it out when it destructs. 1120 PepperPluginInstanceImpl* pepper_last_mouse_event_target_; 1121 #endif 1122 1123 // Misc ---------------------------------------------------------------------- 1124 1125 // The current and pending file chooser completion objects. If the queue is 1126 // nonempty, the first item represents the currently running file chooser 1127 // callback, and the remaining elements are the other file chooser completion 1128 // still waiting to be run (in order). 1129 struct PendingFileChooser; 1130 std::deque< linked_ptr<PendingFileChooser> > file_chooser_completions_; 1131 1132 // The current directory enumeration callback 1133 std::map<int, blink::WebFileChooserCompletion*> enumeration_completions_; 1134 int enumeration_completion_id_; 1135 1136 // The SessionStorage namespace that we're assigned to has an ID, and that ID 1137 // is passed to us upon creation. WebKit asks for this ID upon first use and 1138 // uses it whenever asking the browser process to allocate new storage areas. 1139 int64 session_storage_namespace_id_; 1140 1141 // Stores edit commands associated to the next key event. 1142 // Shall be cleared as soon as the next key event is processed. 1143 EditCommands edit_commands_; 1144 1145 #if defined(OS_MACOSX) || defined(OS_ANDROID) 1146 // The external popup for the currently showing select popup. 1147 scoped_ptr<ExternalPopupMenu> external_popup_menu_; 1148 #endif 1149 1150 // All the registered observers. We expect this list to be small, so vector 1151 // is fine. 1152 ObserverList<RenderViewObserver> observers_; 1153 1154 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface. 1155 scoped_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_; 1156 1157 // State associated with the GetWindowSnapshot function. 1158 int next_snapshot_id_; 1159 typedef std::map<int, WindowSnapshotCallback> PendingSnapshotMap; 1160 PendingSnapshotMap pending_snapshots_; 1161 1162 // This field stores drag/drop related info for the event that is currently 1163 // being handled. If the current event results in starting a drag/drop 1164 // session, this info is sent to the browser along with other drag/drop info. 1165 DragEventSourceInfo possible_drag_event_info_; 1166 1167 // NOTE: stats_collection_observer_ should be the last members because their 1168 // constructors call the AddObservers method of RenderViewImpl. 1169 scoped_ptr<StatsCollectionObserver> stats_collection_observer_; 1170 1171 typedef std::map<cc::SharedBitmapId, cc::SharedBitmap*> BitmapMap; 1172 BitmapMap disambiguation_bitmaps_; 1173 1174 // --------------------------------------------------------------------------- 1175 // ADDING NEW DATA? Please see if it fits appropriately in one of the above 1176 // sections rather than throwing it randomly at the end. If you're adding a 1177 // bunch of stuff, you should probably create a helper class and put your 1178 // data and methods on that to avoid bloating RenderView more. You can 1179 // use the Observer interface to filter IPC messages and receive frame change 1180 // notifications. 1181 // --------------------------------------------------------------------------- 1182 1183 DISALLOW_COPY_AND_ASSIGN(RenderViewImpl); 1184 }; 1185 1186 } // namespace content 1187 1188 #endif // CONTENT_RENDERER_RENDER_VIEW_IMPL_H_ 1189