Upstream version 9.37.195.0
[platform/framework/web/crosswalk.git] / src / content / renderer / render_view_impl.h
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 #elif defined(OS_MACOSX)
769   void OnPluginImeCompositionCompleted(const base::string16& text,
770                                        int plugin_id);
771   void OnSelectPopupMenuItem(int selected_index);
772   void OnSetInLiveResize(bool in_live_resize);
773   void OnSetWindowVisibility(bool visible);
774   void OnWindowFrameChanged(const gfx::Rect& window_frame,
775                             const gfx::Rect& view_frame);
776 #endif
777
778   // Adding a new message handler? Please add it in alphabetical order above
779   // and put it in the same position in the .cc file.
780
781   // Misc private functions ----------------------------------------------------
782   // Check whether the preferred size has changed.
783   void CheckPreferredSize();
784
785   // This callback is triggered when DownloadFavicon completes, either
786   // succesfully or with a failure. See DownloadFavicon for more
787   // details.
788   void DidDownloadFavicon(ImageResourceFetcher* fetcher,
789                           const SkBitmap& image);
790
791   // Requests to download a favicon image. When done, the RenderView is notified
792   // by way of DidDownloadFavicon. Returns true if the request was successfully
793   // started, false otherwise. id is used to uniquely identify the request and
794   // passed back to the DidDownloadFavicon method. If the image has multiple
795   // frames, the frame whose size is image_size is returned. If the image
796   // doesn't have a frame at the specified size, the first is returned.
797   bool DownloadFavicon(int id, const GURL& image_url, int image_size);
798
799   // Called to get the WebPlugin to handle find requests in the document.
800   // Returns NULL if there is no such WebPlugin.
801   blink::WebPlugin* GetWebPluginForFind();
802
803   // Returns true if the |params| navigation is to an entry that has been
804   // cropped due to a recent navigation the browser did not know about.
805   bool IsBackForwardToStaleEntry(const FrameMsg_Navigate_Params& params,
806                                  bool is_reload);
807
808   // Make the given |frame| show an empty, unscriptable page.
809   // TODO(creis): Move this to RenderFrame.
810   void NavigateToSwappedOutURL(blink::WebFrame* frame);
811
812   // If we initiated a navigation, this function will populate |document_state|
813   // with the navigation information saved in OnNavigate().
814   void PopulateDocumentStateFromPending(DocumentState* document_state);
815
816   // Returns a new NavigationState populated with the navigation information
817   // saved in OnNavigate().
818   NavigationState* CreateNavigationStateFromPending();
819
820   // Processes the command-line flags --enable-viewport,
821   // --enable-fixed-layout[=w,h] and --enable-pinch.
822   void ProcessViewLayoutFlags(const base::CommandLine& command_line);
823
824 #if defined(OS_ANDROID)
825   // Launch an Android content intent with the given URL.
826   void LaunchAndroidContentIntent(const GURL& intent_url, size_t request_id);
827 #endif
828
829   // Sends a reply to the current find operation handling if it was a
830   // synchronous find request.
831   void SendFindReply(int request_id,
832                      int match_count,
833                      int ordinal,
834                      const blink::WebRect& selection_rect,
835                      bool final_status_update);
836
837   // Starts nav_state_sync_timer_ if it isn't already running.
838   void StartNavStateSyncTimerIfNecessary();
839
840 #if defined(OS_POSIX) && !defined(OS_MACOSX)
841   void UpdateFontRenderingFromRendererPrefs();
842 #else
843   void UpdateFontRenderingFromRendererPrefs() {}
844 #endif
845
846   // Update the target url and tell the browser that the target URL has changed.
847   // If |url| is empty, show |fallback_url|.
848   void UpdateTargetURL(const GURL& url, const GURL& fallback_url);
849
850   // Tells the browser what the new list of favicons for the webpage is.
851   void SendUpdateFaviconURL(const std::vector<FaviconURL>& urls);
852
853   // Invoked from DidStopLoading(). Sends the current list of loaded favicons to
854   // the browser.
855   void DidStopLoadingIcons();
856
857   // Coordinate conversion -----------------------------------------------------
858
859   gfx::RectF ClientRectToPhysicalWindowRect(const gfx::RectF& rect) const;
860
861   // RenderFrameImpl accessible state ------------------------------------------
862   // The following section is the set of methods that RenderFrameImpl needs
863   // to access RenderViewImpl state. The set of state variables are page-level
864   // specific, so they don't belong in RenderFrameImpl and should remain in
865   // this object.
866   ObserverList<RenderViewObserver>& observers() {
867     return observers_;
868   }
869
870   // TODO(nasko): Remove this method when we move to frame proxy objects, since
871   // the concept of swapped out will be eliminated.
872   void set_is_swapped_out(bool swapped_out) {
873     is_swapped_out_ = swapped_out;
874   }
875
876   NavigationGesture navigation_gesture() {
877     return navigation_gesture_;
878   }
879   void set_navigation_gesture(NavigationGesture gesture) {
880     navigation_gesture_ = gesture;
881   }
882
883   // ---------------------------------------------------------------------------
884   // ADDING NEW FUNCTIONS? Please keep private functions alphabetized and put
885   // it in the same order in the .cc file as it was in the header.
886   // ---------------------------------------------------------------------------
887
888   // Settings ------------------------------------------------------------------
889
890   WebPreferences webkit_preferences_;
891   RendererPreferences renderer_preferences_;
892
893   HostZoomLevels host_zoom_levels_;
894
895   // Whether content state (such as form state, scroll position and page
896   // contents) should be sent to the browser immediately. This is normally
897   // false, but set to true by some tests.
898   bool send_content_state_immediately_;
899
900   // Bitwise-ORed set of extra bindings that have been enabled.  See
901   // BindingsPolicy for details.
902   int enabled_bindings_;
903
904   // If true, we send IPC messages when |preferred_size_| changes.
905   bool send_preferred_size_changes_;
906
907   // If non-empty, and |send_preferred_size_changes_| is true, disable drawing
908   // scroll bars on windows smaller than this size.  Used for windows that the
909   // browser resizes to the size of the content, such as browser action popups.
910   // If a render view is set to the minimum size of its content, webkit may add
911   // scroll bars.  This makes sense for fixed sized windows, but it does not
912   // make sense when the size of the view was chosen to fit the content.
913   // This setting ensures that no scroll bars are drawn.  The size limit exists
914   // because if the view grows beyond a size known to the browser, scroll bars
915   // should be drawn.
916   gfx::Size disable_scrollbars_size_limit_;
917
918   // Loading state -------------------------------------------------------------
919
920   // The gesture that initiated the current navigation.
921   // TODO(nasko): Move to RenderFrame, as this is per-frame state.
922   NavigationGesture navigation_gesture_;
923
924   // Used for popups.
925   bool opened_by_user_gesture_;
926
927   // Whether this RenderView was created by a frame that was suppressing its
928   // opener. If so, we may want to load pages in a separate process.  See
929   // decidePolicyForNavigation for details.
930   bool opener_suppressed_;
931
932   // Whether we must stop creating nested message loops for modal dialogs until
933   // OnSwapOut is called.  This is necessary because modal dialogs have a
934   // PageGroupLoadDeferrer on the stack that interferes with swapping out.
935   bool suppress_dialogs_until_swap_out_;
936
937   // Holds state pertaining to a navigation that we initiated.  This is held by
938   // the WebDataSource::ExtraData attribute.  We use pending_navigation_state_
939   // as a temporary holder for the state until the WebDataSource corresponding
940   // to the new navigation is created.  See DidCreateDataSource.
941   // TODO(nasko): Move to RenderFrame, as this is per-frame state.
942   scoped_ptr<FrameMsg_Navigate_Params> pending_navigation_params_;
943
944   // Timer used to delay the updating of nav state (see SyncNavigationState).
945   base::OneShotTimer<RenderViewImpl> nav_state_sync_timer_;
946
947   // Page IDs ------------------------------------------------------------------
948   // See documentation in RenderView.
949   int32 page_id_;
950
951   // Indicates the ID of the last page that we sent a FrameNavigate to the
952   // browser for. This is used to determine if the most recent transition
953   // generated a history entry (less than page_id_), or not (equal to or
954   // greater than). Note that this will be greater than page_id_ if the user
955   // goes back.
956   int32 last_page_id_sent_to_browser_;
957
958   // The next available page ID to use for this RenderView.  These IDs are
959   // specific to a given RenderView and the frames within it.
960   int32 next_page_id_;
961
962   // The offset of the current item in the history list.
963   int history_list_offset_;
964
965   // The RenderView's current impression of the history length.  This includes
966   // any items that have committed in this process, but because of cross-process
967   // navigations, the history may have some entries that were committed in other
968   // processes.  We won't know about them until the next navigation in this
969   // process.
970   int history_list_length_;
971
972   // Counter to track how many frames have sent start notifications but not stop
973   // notifications. TODO(avi): Remove this once DidStartLoading/DidStopLoading
974   // are gone.
975   int frames_in_progress_;
976
977   // The list of page IDs for each history item this RenderView knows about.
978   // Some entries may be -1 if they were rendered by other processes or were
979   // restored from a previous session.  This lets us detect attempts to
980   // navigate to stale entries that have been cropped from our history.
981   std::vector<int32> history_page_ids_;
982
983   // UI state ------------------------------------------------------------------
984
985   // The state of our target_url transmissions. When we receive a request to
986   // send a URL to the browser, we set this to TARGET_INFLIGHT until an ACK
987   // comes back - if a new request comes in before the ACK, we store the new
988   // URL in pending_target_url_ and set the status to TARGET_PENDING. If an
989   // ACK comes back and we are in TARGET_PENDING, we send the stored URL and
990   // revert to TARGET_INFLIGHT.
991   //
992   // We don't need a queue of URLs to send, as only the latest is useful.
993   enum {
994     TARGET_NONE,
995     TARGET_INFLIGHT,  // We have a request in-flight, waiting for an ACK
996     TARGET_PENDING    // INFLIGHT + we have a URL waiting to be sent
997   } target_url_status_;
998
999   // The URL we show the user in the status bar. We use this to determine if we
1000   // want to send a new one (we do not need to send duplicates). It will be
1001   // equal to either |mouse_over_url_| or |focus_url_|, depending on which was
1002   // updated last.
1003   GURL target_url_;
1004
1005   // The URL the user's mouse is hovering over.
1006   GURL mouse_over_url_;
1007
1008   // The URL that has keyboard focus.
1009   GURL focus_url_;
1010
1011   // The next target URL we want to send to the browser.
1012   GURL pending_target_url_;
1013
1014   // Indicates whether this view overrides url-based zoom settings.
1015   bool uses_temporary_zoom_level_;
1016
1017 #if defined(OS_ANDROID)
1018   // Cache the old top controls state constraints. Used when updating
1019   // current value only without altering the constraints.
1020   cc::TopControlsState top_controls_constraints_;
1021 #endif
1022
1023   // View ----------------------------------------------------------------------
1024
1025   // Cache the preferred size of the page in order to prevent sending the IPC
1026   // when layout() recomputes but doesn't actually change sizes.
1027   gfx::Size preferred_size_;
1028
1029   // Used to delay determining the preferred size (to avoid intermediate
1030   // states for the sizes).
1031   base::OneShotTimer<RenderViewImpl> check_preferred_size_timer_;
1032
1033   // Bookkeeping to suppress redundant scroll and focus requests for an already
1034   // scrolled and focused editable node.
1035   bool has_scrolled_focused_editable_node_into_rect_;
1036   gfx::Rect rect_for_scrolled_focused_editable_node_;
1037
1038   // Helper objects ------------------------------------------------------------
1039
1040   scoped_ptr<RenderFrameImpl> main_render_frame_;
1041
1042   // The next group of objects all implement RenderViewObserver, so are deleted
1043   // along with the RenderView automatically.  This is why we just store
1044   // weak references.
1045
1046   // The push messaging dispatcher attached to this view, lazily initialized.
1047   PushMessagingDispatcher* push_messaging_dispatcher_;
1048
1049   // The speech recognition dispatcher attached to this view, lazily
1050   // initialized.
1051   SpeechRecognitionDispatcher* speech_recognition_dispatcher_;
1052
1053   // MediaStream dispatcher attached to this view; lazily initialized.
1054   MediaStreamDispatcher* media_stream_dispatcher_;
1055
1056   // BrowserPluginManager attached to this view; lazily initialized.
1057   scoped_refptr<BrowserPluginManager> browser_plugin_manager_;
1058
1059   DevToolsAgent* devtools_agent_;
1060
1061   // The current accessibility mode.
1062   AccessibilityMode accessibility_mode_;
1063
1064   // Only valid if |accessibility_mode_| is anything other than
1065   // AccessibilityModeOff.
1066   RendererAccessibility* renderer_accessibility_;
1067
1068   // Mouse Lock dispatcher attached to this view.
1069   MouseLockDispatcher* mouse_lock_dispatcher_;
1070
1071   scoped_ptr<HistoryController> history_controller_;
1072
1073 #if defined(OS_ANDROID)
1074   // Android Specific ---------------------------------------------------------
1075
1076   // Expected id of the next content intent launched. Used to prevent scheduled
1077   // intents to be launched if aborted.
1078   size_t expected_content_intent_id_;
1079
1080   // List of click-based content detectors.
1081   typedef std::vector< linked_ptr<ContentDetector> > ContentDetectorList;
1082   ContentDetectorList content_detectors_;
1083
1084   // A date/time picker object for date and time related input elements.
1085   scoped_ptr<RendererDateTimePicker> date_time_picker_client_;
1086 #endif
1087
1088   // Plugins -------------------------------------------------------------------
1089
1090   // All the currently active plugin delegates for this RenderView; kept so
1091   // that we can enumerate them to send updates about things like window
1092   // location or tab focus and visibily. These are non-owning references.
1093   std::set<WebPluginDelegateProxy*> plugin_delegates_;
1094
1095 #if defined(OS_WIN)
1096   // The ID of the focused NPAPI plug-in.
1097   int focused_plugin_id_;
1098 #endif
1099
1100 #if defined(ENABLE_PLUGINS)
1101   PepperPluginInstanceImpl* plugin_find_handler_;
1102
1103   typedef std::set<PepperPluginInstanceImpl*> PepperPluginSet;
1104   PepperPluginSet active_pepper_instances_;
1105
1106   // TODO(jam): these belong on RenderFrame, once the browser knows which frame
1107   // is focused and sends the IPCs which use these to the correct frame. Until
1108   // then, we must store these on RenderView as that's the one place that knows
1109   // about all the RenderFrames for a page.
1110
1111   // Whether or not the focus is on a PPAPI plugin
1112   PepperPluginInstanceImpl* focused_pepper_plugin_;
1113
1114   // The plugin instance that received the last mouse event. It is set to NULL
1115   // if the last mouse event went to elements other than Pepper plugins.
1116   // |pepper_last_mouse_event_target_| is not owned by this class. We depend on
1117   // the RenderFrameImpl to NULL it out when it destructs.
1118   PepperPluginInstanceImpl* pepper_last_mouse_event_target_;
1119 #endif
1120
1121   // Misc ----------------------------------------------------------------------
1122
1123   // The current and pending file chooser completion objects. If the queue is
1124   // nonempty, the first item represents the currently running file chooser
1125   // callback, and the remaining elements are the other file chooser completion
1126   // still waiting to be run (in order).
1127   struct PendingFileChooser;
1128   std::deque< linked_ptr<PendingFileChooser> > file_chooser_completions_;
1129
1130   // The current directory enumeration callback
1131   std::map<int, blink::WebFileChooserCompletion*> enumeration_completions_;
1132   int enumeration_completion_id_;
1133
1134   // The SessionStorage namespace that we're assigned to has an ID, and that ID
1135   // is passed to us upon creation.  WebKit asks for this ID upon first use and
1136   // uses it whenever asking the browser process to allocate new storage areas.
1137   int64 session_storage_namespace_id_;
1138
1139   // Stores edit commands associated to the next key event.
1140   // Shall be cleared as soon as the next key event is processed.
1141   EditCommands edit_commands_;
1142
1143 #if defined(OS_MACOSX) || defined(OS_ANDROID)
1144   // The external popup for the currently showing select popup.
1145   scoped_ptr<ExternalPopupMenu> external_popup_menu_;
1146 #endif
1147
1148   // All the registered observers.  We expect this list to be small, so vector
1149   // is fine.
1150   ObserverList<RenderViewObserver> observers_;
1151
1152   // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface.
1153   scoped_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_;
1154
1155   // State associated with the GetWindowSnapshot function.
1156   int next_snapshot_id_;
1157   typedef std::map<int, WindowSnapshotCallback> PendingSnapshotMap;
1158   PendingSnapshotMap pending_snapshots_;
1159
1160   // This field stores drag/drop related info for the event that is currently
1161   // being handled. If the current event results in starting a drag/drop
1162   // session, this info is sent to the browser along with other drag/drop info.
1163   DragEventSourceInfo possible_drag_event_info_;
1164
1165   // NOTE: stats_collection_observer_ should be the last members because their
1166   // constructors call the AddObservers method of RenderViewImpl.
1167   scoped_ptr<StatsCollectionObserver> stats_collection_observer_;
1168
1169   typedef std::map<cc::SharedBitmapId, cc::SharedBitmap*> BitmapMap;
1170   BitmapMap disambiguation_bitmaps_;
1171
1172   // ---------------------------------------------------------------------------
1173   // ADDING NEW DATA? Please see if it fits appropriately in one of the above
1174   // sections rather than throwing it randomly at the end. If you're adding a
1175   // bunch of stuff, you should probably create a helper class and put your
1176   // data and methods on that to avoid bloating RenderView more.  You can
1177   // use the Observer interface to filter IPC messages and receive frame change
1178   // notifications.
1179   // ---------------------------------------------------------------------------
1180
1181   DISALLOW_COPY_AND_ASSIGN(RenderViewImpl);
1182 };
1183
1184 }  // namespace content
1185
1186 #endif  // CONTENT_RENDERER_RENDER_VIEW_IMPL_H_