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