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