render_view_host));
}
+void WebContentsImpl::DidNavigateMainFramePreCommit(
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {
+ // Ensure fullscreen mode is exited before committing the navigation to a
+ // different page. The next page will not start out assuming it is in
+ // fullscreen mode.
+ if (controller_.IsURLInPageNavigation(params.url,
+ params.was_within_same_page,
+ NAVIGATION_TYPE_UNKNOWN)) {
+ // No page change? Then, the renderer and browser can remain in fullscreen.
+ return;
+ }
+ if (IsFullscreenForCurrentTab())
+ GetRenderViewHost()->ExitFullscreen();
+ DCHECK(!IsFullscreenForCurrentTab());
+}
+
void WebContentsImpl::DidNavigateMainFramePostCommit(
const LoadCommittedDetails& details,
const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {
}
void WebContentsImpl::SwappedOut(RenderFrameHost* rfh) {
- // TODO(creis): Handle subframes that go fullscreen.
- if (rfh->GetRenderViewHost() == GetRenderViewHost()) {
- // Exit fullscreen mode before the current RVH is swapped out. For numerous
- // cases, there is no guarantee the renderer would/could initiate an exit.
- // Example: http://crbug.com/347232
- if (IsFullscreenForCurrentTab()) {
- rfh->GetRenderViewHost()->ExitFullscreen();
- DCHECK(!IsFullscreenForCurrentTab());
- }
-
- if (delegate_)
- delegate_->SwappedOut(this);
- }
+ if (delegate_ && rfh->GetRenderViewHost() == GetRenderViewHost())
+ delegate_->SwappedOut(this);
}
void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) {
default_prompt,
base::Bind(&WebContentsImpl::OnDialogClosed,
base::Unretained(this),
- rvh,
+ rvh->GetProcess()->GetID(),
+ rvh->GetRoutingID(),
reply_msg),
&suppress_this_message);
}
if (suppress_this_message) {
// If we are suppressing messages, just reply as if the user immediately
// pressed "Cancel".
- OnDialogClosed(rvh, reply_msg, false, base::string16());
+ OnDialogClosed(rvh->GetProcess()->GetID(), rvh->GetRoutingID(), reply_msg,
+ false, base::string16());
}
// OnDialogClosed (two lines up) may have caused deletion of this object (see
dialog_manager_ = delegate_->GetJavaScriptDialogManager();
dialog_manager_->RunBeforeUnloadDialog(
this, message, is_reload,
- base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), rvh,
- reply_msg));
+ base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this),
+ rvh->GetProcess()->GetID(), rvh->GetRoutingID(), reply_msg));
}
bool WebContentsImpl::AddMessageToConsole(int32 level,
}
#endif
-void WebContentsImpl::OnDialogClosed(RenderViewHost* rvh,
+void WebContentsImpl::OnDialogClosed(int render_process_id,
+ int render_view_id,
IPC::Message* reply_msg,
bool success,
const base::string16& user_input) {
+ RenderViewHostImpl* rvh = RenderViewHostImpl::FromID(render_process_id,
+ render_view_id);
if (is_showing_before_unload_dialog_ && !success) {
// If a beforeunload dialog is canceled, we need to stop the throbber from
// spinning, since we forced it to start spinning in Navigate.
- DidStopLoading(rvh->GetMainFrame());
+ if (rvh)
+ DidStopLoading(rvh->GetMainFrame());
controller_.DiscardNonCommittedEntries();
FOR_EACH_OBSERVER(WebContentsObserver, observers_,
BeforeUnloadDialogCancelled());
}
is_showing_before_unload_dialog_ = false;
- static_cast<RenderViewHostImpl*>(
- rvh)->JavaScriptDialogClosed(reply_msg, success, user_input);
+ if (rvh) {
+ rvh->JavaScriptDialogClosed(reply_msg, success, user_input);
+ } else {
+ // Don't leak the sync IPC reply if the RVH or process is gone.
+ delete reply_msg;
+ }
}
void WebContentsImpl::SetEncoding(const std::string& encoding) {