IndexedDBFactory now ForceCloses databases.
[chromium-blink-merge.git] / content / browser / renderer_host / render_view_host_impl.h
bloba5bdfa1a12a70e23dc5fd252f0e09a43556a1a2a
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_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_IMPL_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_IMPL_H_
8 #include <map>
9 #include <string>
10 #include <vector>
12 #include "base/compiler_specific.h"
13 #include "base/logging.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/process/kill.h"
16 #include "content/browser/renderer_host/render_widget_host_impl.h"
17 #include "content/browser/site_instance_impl.h"
18 #include "content/common/drag_event_source_info.h"
19 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/render_view_host.h"
21 #include "content/public/common/javascript_message_type.h"
22 #include "content/public/common/page_transition_types.h"
23 #include "content/public/common/window_container_type.h"
24 #include "net/base/load_states.h"
25 #include "third_party/WebKit/public/web/WebAXEnums.h"
26 #include "third_party/WebKit/public/web/WebConsoleMessage.h"
27 #include "third_party/WebKit/public/web/WebPopupType.h"
28 #include "third_party/WebKit/public/web/WebTextDirection.h"
29 #include "third_party/skia/include/core/SkColor.h"
30 #include "ui/accessibility/ax_node_data.h"
31 #include "ui/base/window_open_disposition.h"
33 class SkBitmap;
34 class ViewMsg_Navigate;
35 struct AccessibilityHostMsg_EventParams;
36 struct AccessibilityHostMsg_LocationChangeParams;
37 struct MediaPlayerAction;
38 struct ViewHostMsg_CreateWindow_Params;
39 struct ViewHostMsg_OpenURL_Params;
40 struct ViewHostMsg_SelectionBounds_Params;
41 struct ViewHostMsg_ShowPopup_Params;
42 struct ViewMsg_Navigate_Params;
43 struct ViewMsg_PostMessage_Params;
45 namespace base {
46 class ListValue;
49 namespace gfx {
50 class Range;
53 namespace ui {
54 class AXTree;
55 struct SelectedFileInfo;
58 namespace content {
60 class BrowserMediaPlayerManager;
61 class ChildProcessSecurityPolicyImpl;
62 class PageState;
63 class RenderWidgetHostDelegate;
64 class SessionStorageNamespace;
65 class SessionStorageNamespaceImpl;
66 class TestRenderViewHost;
67 struct ContextMenuParams;
68 struct FileChooserParams;
69 struct Referrer;
70 struct ShowDesktopNotificationHostMsgParams;
72 #if defined(COMPILER_MSVC)
73 // RenderViewHostImpl is the bottom of a diamond-shaped hierarchy,
74 // with RenderWidgetHost at the root. VS warns when methods from the
75 // root are overridden in only one of the base classes and not both
76 // (in this case, RenderWidgetHostImpl provides implementations of
77 // many of the methods). This is a silly warning when dealing with
78 // pure virtual methods that only have a single implementation in the
79 // hierarchy above this class, and is safe to ignore in this case.
80 #pragma warning(push)
81 #pragma warning(disable: 4250)
82 #endif
84 // This implements the RenderViewHost interface that is exposed to
85 // embedders of content, and adds things only visible to content.
87 // The exact API of this object needs to be more thoroughly designed. Right
88 // now it mimics what WebContentsImpl exposed, which is a fairly large API and
89 // may contain things that are not relevant to a common subset of views. See
90 // also the comment in render_view_host_delegate.h about the size and scope of
91 // the delegate API.
93 // Right now, the concept of page navigation (both top level and frame) exists
94 // in the WebContentsImpl still, so if you instantiate one of these elsewhere,
95 // you will not be able to traverse pages back and forward. We need to determine
96 // if we want to bring that and other functionality down into this object so it
97 // can be shared by others.
98 class CONTENT_EXPORT RenderViewHostImpl
99 : public RenderViewHost,
100 public RenderWidgetHostImpl {
101 public:
102 // Convenience function, just like RenderViewHost::FromID.
103 static RenderViewHostImpl* FromID(int render_process_id, int render_view_id);
105 // |routing_id| could be a valid route id, or it could be MSG_ROUTING_NONE, in
106 // which case RenderWidgetHost will create a new one. |swapped_out| indicates
107 // whether the view should initially be swapped out (e.g., for an opener
108 // frame being rendered by another process). |hidden| indicates whether the
109 // view is initially hidden or visible.
111 // The |session_storage_namespace| parameter allows multiple render views and
112 // WebContentses to share the same session storage (part of the WebStorage
113 // spec) space. This is useful when restoring contentses, but most callers
114 // should pass in NULL which will cause a new SessionStorageNamespace to be
115 // created.
116 RenderViewHostImpl(
117 SiteInstance* instance,
118 RenderViewHostDelegate* delegate,
119 RenderWidgetHostDelegate* widget_delegate,
120 int routing_id,
121 int main_frame_routing_id,
122 bool swapped_out,
123 bool hidden);
124 virtual ~RenderViewHostImpl();
126 // RenderViewHost implementation.
127 virtual void AllowBindings(int binding_flags) OVERRIDE;
128 virtual void ClearFocusedNode() OVERRIDE;
129 virtual void ClosePage() OVERRIDE;
130 virtual void CopyImageAt(int x, int y) OVERRIDE;
131 virtual void DesktopNotificationPermissionRequestDone(
132 int callback_context) OVERRIDE;
133 virtual void DesktopNotificationPostDisplay(int callback_context) OVERRIDE;
134 virtual void DesktopNotificationPostError(
135 int notification_id,
136 const base::string16& message) OVERRIDE;
137 virtual void DesktopNotificationPostClose(int notification_id,
138 bool by_user) OVERRIDE;
139 virtual void DesktopNotificationPostClick(int notification_id) OVERRIDE;
140 virtual void DirectoryEnumerationFinished(
141 int request_id,
142 const std::vector<base::FilePath>& files) OVERRIDE;
143 virtual void DisableScrollbarsForThreshold(const gfx::Size& size) OVERRIDE;
144 virtual void DragSourceEndedAt(
145 int client_x, int client_y, int screen_x, int screen_y,
146 blink::WebDragOperation operation) OVERRIDE;
147 virtual void DragSourceMovedTo(
148 int client_x, int client_y, int screen_x, int screen_y) OVERRIDE;
149 virtual void DragSourceSystemDragEnded() OVERRIDE;
150 virtual void DragTargetDragEnter(
151 const DropData& drop_data,
152 const gfx::Point& client_pt,
153 const gfx::Point& screen_pt,
154 blink::WebDragOperationsMask operations_allowed,
155 int key_modifiers) OVERRIDE;
156 virtual void DragTargetDragOver(
157 const gfx::Point& client_pt,
158 const gfx::Point& screen_pt,
159 blink::WebDragOperationsMask operations_allowed,
160 int key_modifiers) OVERRIDE;
161 virtual void DragTargetDragLeave() OVERRIDE;
162 virtual void DragTargetDrop(const gfx::Point& client_pt,
163 const gfx::Point& screen_pt,
164 int key_modifiers) OVERRIDE;
165 virtual void EnableAutoResize(const gfx::Size& min_size,
166 const gfx::Size& max_size) OVERRIDE;
167 virtual void DisableAutoResize(const gfx::Size& new_size) OVERRIDE;
168 virtual void EnablePreferredSizeMode() OVERRIDE;
169 virtual void ExecuteCustomContextMenuCommand(
170 int action, const CustomContextMenuContext& context) OVERRIDE;
171 virtual void ExecuteMediaPlayerActionAtLocation(
172 const gfx::Point& location,
173 const blink::WebMediaPlayerAction& action) OVERRIDE;
174 virtual void ExecuteJavascriptInWebFrame(
175 const base::string16& frame_xpath,
176 const base::string16& jscript) OVERRIDE;
177 virtual void ExecuteJavascriptInWebFrameCallbackResult(
178 const base::string16& frame_xpath,
179 const base::string16& jscript,
180 const JavascriptResultCallback& callback) OVERRIDE;
181 virtual void ExecutePluginActionAtLocation(
182 const gfx::Point& location,
183 const blink::WebPluginAction& action) OVERRIDE;
184 virtual void ExitFullscreen() OVERRIDE;
185 virtual void FirePageBeforeUnload(bool for_cross_site_transition) OVERRIDE;
186 virtual void FilesSelectedInChooser(
187 const std::vector<ui::SelectedFileInfo>& files,
188 FileChooserParams::Mode permissions) OVERRIDE;
189 virtual RenderViewHostDelegate* GetDelegate() const OVERRIDE;
190 virtual int GetEnabledBindings() const OVERRIDE;
191 virtual SiteInstance* GetSiteInstance() const OVERRIDE;
192 virtual void InsertCSS(const base::string16& frame_xpath,
193 const std::string& css) OVERRIDE;
194 virtual bool IsRenderViewLive() const OVERRIDE;
195 virtual void NotifyContextMenuClosed(
196 const CustomContextMenuContext& context) OVERRIDE;
197 virtual void NotifyMoveOrResizeStarted() OVERRIDE;
198 virtual void ReloadFrame() OVERRIDE;
199 virtual void SetAltErrorPageURL(const GURL& url) OVERRIDE;
200 virtual void SetWebUIProperty(const std::string& name,
201 const std::string& value) OVERRIDE;
202 virtual void Zoom(PageZoom zoom) OVERRIDE;
203 virtual void SyncRendererPrefs() OVERRIDE;
204 virtual void ToggleSpeechInput() OVERRIDE;
205 virtual WebPreferences GetWebkitPreferences() OVERRIDE;
206 virtual void UpdateWebkitPreferences(
207 const WebPreferences& prefs) OVERRIDE;
208 virtual void NotifyTimezoneChange() OVERRIDE;
209 virtual void GetAudioOutputControllers(
210 const GetAudioOutputControllersCallback& callback) const OVERRIDE;
212 #if defined(OS_ANDROID)
213 virtual void ActivateNearestFindResult(int request_id,
214 float x,
215 float y) OVERRIDE;
216 virtual void RequestFindMatchRects(int current_version) OVERRIDE;
217 virtual void DisableFullscreenEncryptedMediaPlayback() OVERRIDE;
218 #endif
220 void set_delegate(RenderViewHostDelegate* d) {
221 CHECK(d); // http://crbug.com/82827
222 delegate_ = d;
225 // Set up the RenderView child process. Virtual because it is overridden by
226 // TestRenderViewHost. If the |frame_name| parameter is non-empty, it is used
227 // as the name of the new top-level frame.
228 // The |opener_route_id| parameter indicates which RenderView created this
229 // (MSG_ROUTING_NONE if none). If |max_page_id| is larger than -1, the
230 // RenderView is told to start issuing page IDs at |max_page_id| + 1.
231 virtual bool CreateRenderView(const base::string16& frame_name,
232 int opener_route_id,
233 int32 max_page_id);
235 base::TerminationStatus render_view_termination_status() const {
236 return render_view_termination_status_;
239 // Returns the content specific prefs for this RenderViewHost.
240 WebPreferences GetWebkitPrefs(const GURL& url);
242 // Sends the given navigation message. Use this rather than sending it
243 // yourself since this does the internal bookkeeping described below. This
244 // function takes ownership of the provided message pointer.
246 // If a cross-site request is in progress, we may be suspended while waiting
247 // for the onbeforeunload handler, so this function might buffer the message
248 // rather than sending it.
249 void Navigate(const ViewMsg_Navigate_Params& message);
251 // Load the specified URL, this is a shortcut for Navigate().
252 void NavigateToURL(const GURL& url);
254 // Returns whether navigation messages are currently suspended for this
255 // RenderViewHost. Only true during a cross-site navigation, while waiting
256 // for the onbeforeunload handler.
257 bool are_navigations_suspended() const { return navigations_suspended_; }
259 // Suspends (or unsuspends) any navigation messages from being sent from this
260 // RenderViewHost. This is called when a pending RenderViewHost is created
261 // for a cross-site navigation, because we must suspend any navigations until
262 // we hear back from the old renderer's onbeforeunload handler. Note that it
263 // is important that only one navigation event happen after calling this
264 // method with |suspend| equal to true. If |suspend| is false and there is
265 // a suspended_nav_message_, this will send the message. This function
266 // should only be called to toggle the state; callers should check
267 // are_navigations_suspended() first. If |suspend| is false, the time that the
268 // user decided the navigation should proceed should be passed as
269 // |proceed_time|.
270 void SetNavigationsSuspended(bool suspend,
271 const base::TimeTicks& proceed_time);
273 // Clears any suspended navigation state after a cross-site navigation is
274 // canceled or suspended. This is important if we later return to this
275 // RenderViewHost.
276 void CancelSuspendedNavigations();
278 // Whether the initial empty page of this view has been accessed by another
279 // page, making it unsafe to show the pending URL. Always false after the
280 // first commit.
281 bool has_accessed_initial_document() {
282 return has_accessed_initial_document_;
285 // Whether this RenderViewHost has been swapped out to be displayed by a
286 // different process.
287 bool is_swapped_out() const { return is_swapped_out_; }
289 // Called on the pending RenderViewHost when the network response is ready to
290 // commit. We should ensure that the old RenderViewHost runs its unload
291 // handler and determine whether a transfer to a different RenderViewHost is
292 // needed.
293 void OnCrossSiteResponse(
294 const GlobalRequestID& global_request_id,
295 bool is_transfer,
296 const std::vector<GURL>& transfer_url_chain,
297 const Referrer& referrer,
298 PageTransition page_transition,
299 int64 frame_id,
300 bool should_replace_current_entry);
302 // Tells the renderer that this RenderView will soon be swapped out, and thus
303 // not to create any new modal dialogs until it happens. This must be done
304 // separately so that the PageGroupLoadDeferrers of any current dialogs are no
305 // longer on the stack when we attempt to swap it out.
306 void SuppressDialogsUntilSwapOut();
308 // Tells the renderer that this RenderView is being swapped out for one in a
309 // different renderer process. It should run its unload handler and move to
310 // a blank document. The renderer should preserve the Frame object until it
311 // exits, in case we come back. The renderer can exit if it has no other
312 // active RenderViews, but not until WasSwappedOut is called (when it is no
313 // longer visible).
314 void SwapOut();
316 // Called when either the SwapOut request has been acknowledged or has timed
317 // out.
318 void OnSwappedOut(bool timed_out);
320 // Called to notify the renderer that it has been visibly swapped out and
321 // replaced by another RenderViewHost, after an earlier call to SwapOut.
322 // It is now safe for the process to exit if there are no other active
323 // RenderViews.
324 void WasSwappedOut();
326 // Close the page ignoring whether it has unload events registers.
327 // This is called after the beforeunload and unload events have fired
328 // and the user has agreed to continue with closing the page.
329 void ClosePageIgnoringUnloadEvents();
331 // Returns whether this RenderViewHost has an outstanding cross-site request.
332 // Cleared when we hear the response and start to swap out the old
333 // RenderViewHost, or if we hear a commit here without a network request.
334 bool HasPendingCrossSiteRequest();
336 // Sets whether this RenderViewHost has an outstanding cross-site request,
337 // for which another renderer will need to run an onunload event handler.
338 // This is called before the first navigation event for this RenderViewHost,
339 // and cleared when we hear the response or commit.
340 void SetHasPendingCrossSiteRequest(bool has_pending_request);
342 // Notifies the RenderView that the JavaScript message that was shown was
343 // closed by the user.
344 void JavaScriptDialogClosed(IPC::Message* reply_msg,
345 bool success,
346 const base::string16& user_input);
348 // Tells the renderer view to focus the first (last if reverse is true) node.
349 void SetInitialFocus(bool reverse);
351 // Get html data by serializing all frames of current page with lists
352 // which contain all resource links that have local copy.
353 // The parameter links contain original URLs of all saved links.
354 // The parameter local_paths contain corresponding local file paths of
355 // all saved links, which matched with vector:links one by one.
356 // The parameter local_directory_name is relative path of directory which
357 // contain all saved auxiliary files included all sub frames and resouces.
358 void GetSerializedHtmlDataForCurrentPageWithLocalLinks(
359 const std::vector<GURL>& links,
360 const std::vector<base::FilePath>& local_paths,
361 const base::FilePath& local_directory_name);
363 // Notifies the RenderViewHost that its load state changed.
364 void LoadStateChanged(const GURL& url,
365 const net::LoadStateWithParam& load_state,
366 uint64 upload_position,
367 uint64 upload_size);
369 bool SuddenTerminationAllowed() const;
370 void set_sudden_termination_allowed(bool enabled) {
371 sudden_termination_allowed_ = enabled;
374 // RenderWidgetHost public overrides.
375 virtual void Init() OVERRIDE;
376 virtual void Shutdown() OVERRIDE;
377 virtual bool IsRenderView() const OVERRIDE;
378 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
379 virtual void GotFocus() OVERRIDE;
380 virtual void LostCapture() OVERRIDE;
381 virtual void LostMouseLock() OVERRIDE;
382 virtual void ForwardMouseEvent(
383 const blink::WebMouseEvent& mouse_event) OVERRIDE;
384 virtual void OnPointerEventActivate() OVERRIDE;
385 virtual void ForwardKeyboardEvent(
386 const NativeWebKeyboardEvent& key_event) OVERRIDE;
387 virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
389 // Creates a new RenderView with the given route id.
390 void CreateNewWindow(
391 int route_id,
392 int main_frame_route_id,
393 const ViewHostMsg_CreateWindow_Params& params,
394 SessionStorageNamespace* session_storage_namespace);
396 // Creates a new RenderWidget with the given route id. |popup_type| indicates
397 // if this widget is a popup and what kind of popup it is (select, autofill).
398 void CreateNewWidget(int route_id, blink::WebPopupType popup_type);
400 // Creates a full screen RenderWidget.
401 void CreateNewFullscreenWidget(int route_id);
403 #if defined(OS_MACOSX)
404 // Select popup menu related methods (for external popup menus).
405 void DidSelectPopupMenuItem(int selected_index);
406 void DidCancelPopupMenu();
407 #endif
409 #if defined(OS_ANDROID)
410 BrowserMediaPlayerManager* media_player_manager() {
411 return media_player_manager_.get();
414 void DidSelectPopupMenuItems(const std::vector<int>& selected_indices);
415 void DidCancelPopupMenu();
416 #endif
418 // User rotated the screen. Calls the "onorientationchange" Javascript hook.
419 void SendOrientationChangeEvent(int orientation);
421 // TODO(creis): Remove this when we replace frame IDs with RenderFrameHost
422 // routing IDs.
423 int64 main_frame_id() const {
424 return main_frame_id_;
427 // Set the opener to null in the renderer process.
428 void DisownOpener();
430 // Turn on accessibility testing. The given callback will be run
431 // every time an accessibility notification is received from the
432 // renderer process, and the accessibility tree it sent can be
433 // retrieved using accessibility_tree_for_testing().
434 void SetAccessibilityCallbackForTesting(
435 const base::Callback<void(ui::AXEvent)>& callback);
437 // Only valid if SetAccessibilityCallbackForTesting was called and
438 // the callback was run at least once. Returns a snapshot of the
439 // accessibility tree received from the renderer as of the last time
440 // an accessibility notification was received.
441 const ui::AXTree& ax_tree_for_testing() {
442 CHECK(ax_tree_.get());
443 return *ax_tree_.get();
446 // Set accessibility callbacks.
447 void SetAccessibilityLayoutCompleteCallbackForTesting(
448 const base::Closure& callback);
449 void SetAccessibilityLoadCompleteCallbackForTesting(
450 const base::Closure& callback);
451 void SetAccessibilityOtherCallbackForTesting(
452 const base::Closure& callback);
454 bool is_waiting_for_beforeunload_ack() {
455 return is_waiting_for_beforeunload_ack_;
458 bool is_waiting_for_unload_ack() {
459 return is_waiting_for_unload_ack_;
462 // Returns whether the given URL is allowed to commit in the current process.
463 // This is a more conservative check than RenderProcessHost::FilterURL, since
464 // it will be used to kill processes that commit unauthorized URLs.
465 bool CanCommitURL(const GURL& url);
467 // Update the FrameTree to use this RenderViewHost's main frame
468 // RenderFrameHost. Called when the RenderViewHost is committed.
470 // TODO(ajwong): Remove once RenderViewHost no longer owns the main frame
471 // RenderFrameHost.
472 void AttachToFrameTree();
474 // The following IPC handlers are public so RenderFrameHost can call them,
475 // while we transition the code to not use RenderViewHost.
477 // TODO(nasko): Remove those methods once we are done moving navigation
478 // into RenderFrameHost.
479 void OnDidStartProvisionalLoadForFrame(int64 frame_id,
480 int64 parent_frame_id,
481 bool main_frame,
482 const GURL& url);
484 // NOTE: Do not add functions that just send an IPC message that are called in
485 // one or two places. Have the caller send the IPC message directly (unless
486 // the caller places are in different platforms, in which case it's better
487 // to keep them consistent).
489 protected:
490 // RenderWidgetHost protected overrides.
491 virtual void OnUserGesture() OVERRIDE;
492 virtual void NotifyRendererUnresponsive() OVERRIDE;
493 virtual void NotifyRendererResponsive() OVERRIDE;
494 virtual void OnRenderAutoResized(const gfx::Size& size) OVERRIDE;
495 virtual void RequestToLockMouse(bool user_gesture,
496 bool last_unlocked_by_target) OVERRIDE;
497 virtual bool IsFullscreen() const OVERRIDE;
498 virtual void OnFocus() OVERRIDE;
499 virtual void OnBlur() OVERRIDE;
501 // IPC message handlers.
502 void OnShowView(int route_id,
503 WindowOpenDisposition disposition,
504 const gfx::Rect& initial_pos,
505 bool user_gesture);
506 void OnShowWidget(int route_id, const gfx::Rect& initial_pos);
507 void OnShowFullscreenWidget(int route_id);
508 void OnRunModal(int opener_id, IPC::Message* reply_msg);
509 void OnRenderViewReady();
510 void OnRenderProcessGone(int status, int error_code);
511 void OnDidRedirectProvisionalLoad(int32 page_id,
512 const GURL& source_url,
513 const GURL& target_url);
514 void OnNavigate(const IPC::Message& msg);
515 void OnUpdateState(int32 page_id, const PageState& state);
516 void OnUpdateTitle(int32 page_id,
517 const base::string16& title,
518 blink::WebTextDirection title_direction);
519 void OnUpdateEncoding(const std::string& encoding);
520 void OnUpdateTargetURL(int32 page_id, const GURL& url);
521 void OnClose();
522 void OnRequestMove(const gfx::Rect& pos);
523 void OnDidStartLoading();
524 void OnDidStopLoading();
525 void OnDidChangeLoadProgress(double load_progress);
526 void OnDidDisownOpener();
527 void OnDocumentAvailableInMainFrame();
528 void OnDocumentOnLoadCompletedInMainFrame(int32 page_id);
529 void OnContextMenu(const ContextMenuParams& params);
530 void OnToggleFullscreen(bool enter_fullscreen);
531 void OnOpenURL(const ViewHostMsg_OpenURL_Params& params);
532 void OnDidContentsPreferredSizeChange(const gfx::Size& new_size);
533 void OnDidChangeScrollOffset();
534 void OnDidChangeScrollbarsForMainFrame(bool has_horizontal_scrollbar,
535 bool has_vertical_scrollbar);
536 void OnDidChangeScrollOffsetPinningForMainFrame(bool is_pinned_to_left,
537 bool is_pinned_to_right);
538 void OnDidChangeNumWheelEvents(int count);
539 void OnSelectionChanged(const base::string16& text,
540 size_t offset,
541 const gfx::Range& range);
542 void OnSelectionBoundsChanged(
543 const ViewHostMsg_SelectionBounds_Params& params);
544 void OnPasteFromSelectionClipboard();
545 void OnRouteCloseEvent();
546 void OnRouteMessageEvent(const ViewMsg_PostMessage_Params& params);
547 void OnRunJavaScriptMessage(const base::string16& message,
548 const base::string16& default_prompt,
549 const GURL& frame_url,
550 JavaScriptMessageType type,
551 IPC::Message* reply_msg);
552 void OnRunBeforeUnloadConfirm(const GURL& frame_url,
553 const base::string16& message,
554 bool is_reload,
555 IPC::Message* reply_msg);
556 void OnStartDragging(const DropData& drop_data,
557 blink::WebDragOperationsMask operations_allowed,
558 const SkBitmap& bitmap,
559 const gfx::Vector2d& bitmap_offset_in_dip,
560 const DragEventSourceInfo& event_info);
561 void OnUpdateDragCursor(blink::WebDragOperation drag_operation);
562 void OnTargetDropACK();
563 void OnTakeFocus(bool reverse);
564 void OnFocusedNodeChanged(bool is_editable_node);
565 void OnAddMessageToConsole(int32 level,
566 const base::string16& message,
567 int32 line_no,
568 const base::string16& source_id);
569 void OnUpdateInspectorSetting(const std::string& key,
570 const std::string& value);
571 void OnShouldCloseACK(
572 bool proceed,
573 const base::TimeTicks& renderer_before_unload_start_time,
574 const base::TimeTicks& renderer_before_unload_end_time);
575 void OnClosePageACK();
576 void OnSwapOutACK();
577 void OnAccessibilityEvents(
578 const std::vector<AccessibilityHostMsg_EventParams>& params);
579 void OnAccessibilityLocationChanges(
580 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params);
581 void OnScriptEvalResponse(int id, const base::ListValue& result);
582 void OnDidZoomURL(double zoom_level, bool remember, const GURL& url);
583 void OnRequestDesktopNotificationPermission(const GURL& origin,
584 int callback_id);
585 void OnShowDesktopNotification(
586 const ShowDesktopNotificationHostMsgParams& params);
587 void OnCancelDesktopNotification(int notification_id);
588 void OnRunFileChooser(const FileChooserParams& params);
589 void OnDidAccessInitialDocument();
590 void OnDomOperationResponse(const std::string& json_string,
591 int automation_id);
592 void OnFocusedNodeTouched(bool editable);
594 #if defined(OS_MACOSX) || defined(OS_ANDROID)
595 void OnShowPopup(const ViewHostMsg_ShowPopup_Params& params);
596 #endif
598 private:
599 friend class TestRenderViewHost;
600 FRIEND_TEST_ALL_PREFIXES(RenderViewHostTest, BasicRenderFrameHost);
601 FRIEND_TEST_ALL_PREFIXES(RenderViewHostTest, RoutingIdSane);
603 // Sets whether this RenderViewHost is swapped out in favor of another,
604 // and clears any waiting state that is no longer relevant.
605 void SetSwappedOut(bool is_swapped_out);
607 bool CanAccessFilesOfPageState(const PageState& state) const;
609 // Our delegate, which wants to know about changes in the RenderView.
610 RenderViewHostDelegate* delegate_;
612 // The SiteInstance associated with this RenderViewHost. All pages drawn
613 // in this RenderViewHost are part of this SiteInstance. Should not change
614 // over time.
615 scoped_refptr<SiteInstanceImpl> instance_;
617 // true if we are currently waiting for a response for drag context
618 // information.
619 bool waiting_for_drag_context_response_;
621 // A bitwise OR of bindings types that have been enabled for this RenderView.
622 // See BindingsPolicy for details.
623 int enabled_bindings_;
625 // Whether we should buffer outgoing Navigate messages rather than sending
626 // them. This will be true when a RenderViewHost is created for a cross-site
627 // request, until we hear back from the onbeforeunload handler of the old
628 // RenderViewHost.
629 bool navigations_suspended_;
631 // We only buffer the params for a suspended navigation while we have a
632 // pending RVH for a WebContentsImpl. There will only ever be one suspended
633 // navigation, because WebContentsImpl will destroy the pending RVH and create
634 // a new one if a second navigation occurs.
635 scoped_ptr<ViewMsg_Navigate_Params> suspended_nav_params_;
637 // Whether the initial empty page of this view has been accessed by another
638 // page, making it unsafe to show the pending URL. Usually false unless
639 // another window tries to modify the blank page. Always false after the
640 // first commit.
641 bool has_accessed_initial_document_;
643 // Whether this RenderViewHost is currently swapped out, such that the view is
644 // being rendered by another process.
645 bool is_swapped_out_;
647 // The frame id of the main (top level) frame. This value is set on the
648 // initial navigation of a RenderView and reset when the RenderView's
649 // process is terminated (in RenderProcessGone).
650 // TODO(creis): Remove this when we switch to routing IDs for frames.
651 int64 main_frame_id_;
653 // Routing ID for the main frame's RenderFrameHost.
654 int main_frame_routing_id_;
656 // If we were asked to RunModal, then this will hold the reply_msg that we
657 // must return to the renderer to unblock it.
658 IPC::Message* run_modal_reply_msg_;
659 // This will hold the routing id of the RenderView that opened us.
660 int run_modal_opener_id_;
662 // Set to true when there is a pending ViewMsg_ShouldClose message. This
663 // ensures we don't spam the renderer with multiple beforeunload requests.
664 // When either this value or is_waiting_for_unload_ack_ is true, the value of
665 // unload_ack_is_for_cross_site_transition_ indicates whether this is for a
666 // cross-site transition or a tab close attempt.
667 bool is_waiting_for_beforeunload_ack_;
669 // Set to true when there is a pending ViewMsg_Close message. Also see
670 // is_waiting_for_beforeunload_ack_, unload_ack_is_for_cross_site_transition_.
671 bool is_waiting_for_unload_ack_;
673 // Set to true when waiting for ViewHostMsg_SwapOut_ACK has timed out.
674 bool has_timed_out_on_unload_;
676 // Valid only when is_waiting_for_beforeunload_ack_ or
677 // is_waiting_for_unload_ack_ is true. This tells us if the unload request
678 // is for closing the entire tab ( = false), or only this RenderViewHost in
679 // the case of a cross-site transition ( = true).
680 bool unload_ack_is_for_cross_site_transition_;
682 bool are_javascript_messages_suppressed_;
684 // The mapping of pending javascript calls created by
685 // ExecuteJavascriptInWebFrameCallbackResult and their corresponding
686 // callbacks.
687 std::map<int, JavascriptResultCallback> javascript_callbacks_;
689 // Accessibility callback for testing.
690 base::Callback<void(ui::AXEvent)> accessibility_testing_callback_;
692 // The most recently received accessibility tree - for testing only.
693 scoped_ptr<ui::AXTree> ax_tree_;
695 // True if the render view can be shut down suddenly.
696 bool sudden_termination_allowed_;
698 // The termination status of the last render view that terminated.
699 base::TerminationStatus render_view_termination_status_;
701 // When the last ShouldClose message was sent.
702 base::TimeTicks send_should_close_start_time_;
704 // Set to true if we requested the on screen keyboard to be displayed.
705 bool virtual_keyboard_requested_;
707 #if defined(OS_ANDROID)
708 // Manages all the android mediaplayer objects and handling IPCs for video.
709 scoped_ptr<BrowserMediaPlayerManager> media_player_manager_;
710 #endif
712 DISALLOW_COPY_AND_ASSIGN(RenderViewHostImpl);
715 #if defined(COMPILER_MSVC)
716 #pragma warning(pop)
717 #endif
719 } // namespace content
721 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_IMPL_H_