Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 218093002: Ensure fullscreen mode is exited for same-site navigations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Better approach: DidNavigateMainFramePreCommit Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 2215 matching lines...) Expand 10 before | Expand all | Expand 10 after
2226 WebContentsObserver, 2226 WebContentsObserver,
2227 observers_, 2227 observers_,
2228 DidCommitProvisionalLoadForFrame(render_frame_id, 2228 DidCommitProvisionalLoadForFrame(render_frame_id,
2229 frame_unique_name, 2229 frame_unique_name,
2230 is_main_frame, 2230 is_main_frame,
2231 url, 2231 url,
2232 transition_type, 2232 transition_type,
2233 render_view_host)); 2233 render_view_host));
2234 } 2234 }
2235 2235
2236 void WebContentsImpl::DidNavigateMainFramePreCommit(
2237 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {
2238 // Ensure fullscreen mode is exited before committing the navigation to a
2239 // different page. The next page will not start out assuming it is in
2240 // fullscreen mode.
2241 if (params.was_within_same_page) {
2242 // No document change? Then, the renderer shall decide whether to exit
2243 // fullscreen.
2244 return;
2245 }
2246 RenderViewHost* const old_render_view_host = GetRenderViewHost();
2247 if (old_render_view_host && IsFullscreenForCurrentTab())
2248 old_render_view_host->ExitFullscreen();
Charlie Reis 2014/04/01 23:12:38 GetRenderViewHost() will never return null in this
miu 2014/04/01 23:39:35 Done.
2249 DCHECK(!IsFullscreenForCurrentTab());
2250 // TODO(creis): How to handle subframes that go fullscreen?
Charlie Reis 2014/04/01 23:12:38 You may know the answer to this, actually. Can su
miu 2014/04/01 23:39:35 Removed TODO. I just looked at the W3C spec, and
2251 }
2252
2236 void WebContentsImpl::DidNavigateMainFramePostCommit( 2253 void WebContentsImpl::DidNavigateMainFramePostCommit(
2237 const LoadCommittedDetails& details, 2254 const LoadCommittedDetails& details,
2238 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { 2255 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {
2239 if (details.is_navigation_to_different_page()) { 2256 if (details.is_navigation_to_different_page()) {
2240 // Clear the status bubble. This is a workaround for a bug where WebKit 2257 // Clear the status bubble. This is a workaround for a bug where WebKit
2241 // doesn't let us know that the cursor left an element during a 2258 // doesn't let us know that the cursor left an element during a
2242 // transition (this is also why the mouse cursor remains as a hand after 2259 // transition (this is also why the mouse cursor remains as a hand after
2243 // clicking on a link); see bugs 1184641 and 980803. We don't want to 2260 // clicking on a link); see bugs 1184641 and 980803. We don't want to
2244 // clear the bubble when a user navigates to a named anchor in the same 2261 // clear the bubble when a user navigates to a named anchor in the same
2245 // page. 2262 // page.
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
3041 return; 3058 return;
3042 } 3059 }
3043 #endif 3060 #endif
3044 3061
3045 // Ignore this if it comes from a RenderViewHost that we aren't showing. 3062 // Ignore this if it comes from a RenderViewHost that we aren't showing.
3046 if (delegate_ && rvh == GetRenderViewHost()) 3063 if (delegate_ && rvh == GetRenderViewHost())
3047 delegate_->CloseContents(this); 3064 delegate_->CloseContents(this);
3048 } 3065 }
3049 3066
3050 void WebContentsImpl::SwappedOut(RenderFrameHost* rfh) { 3067 void WebContentsImpl::SwappedOut(RenderFrameHost* rfh) {
3051 // TODO(creis): Handle subframes that go fullscreen. 3068 if (delegate_ && rfh->GetRenderViewHost() == GetRenderViewHost())
3052 if (rfh->GetRenderViewHost() == GetRenderViewHost()) { 3069 delegate_->SwappedOut(this);
3053 // Exit fullscreen mode before the current RVH is swapped out. For numerous
3054 // cases, there is no guarantee the renderer would/could initiate an exit.
3055 // Example: http://crbug.com/347232
3056 if (IsFullscreenForCurrentTab()) {
3057 rfh->GetRenderViewHost()->ExitFullscreen();
3058 DCHECK(!IsFullscreenForCurrentTab());
3059 }
3060
3061 if (delegate_)
3062 delegate_->SwappedOut(this);
3063 }
3064 } 3070 }
3065 3071
3066 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { 3072 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) {
3067 if (delegate_ && delegate_->IsPopupOrPanel(this)) 3073 if (delegate_ && delegate_->IsPopupOrPanel(this))
3068 delegate_->MoveContents(this, new_bounds); 3074 delegate_->MoveContents(this, new_bounds);
3069 } 3075 }
3070 3076
3071 void WebContentsImpl::DidStartLoading(RenderFrameHost* render_frame_host, 3077 void WebContentsImpl::DidStartLoading(RenderFrameHost* render_frame_host,
3072 bool to_different_document) { 3078 bool to_different_document) {
3073 SetIsLoading(render_frame_host->GetRenderViewHost(), true, 3079 SetIsLoading(render_frame_host->GetRenderViewHost(), true,
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
3670 3676
3671 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { 3677 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) {
3672 if (!delegate_) 3678 if (!delegate_)
3673 return; 3679 return;
3674 const gfx::Size new_size = GetPreferredSize(); 3680 const gfx::Size new_size = GetPreferredSize();
3675 if (new_size != old_size) 3681 if (new_size != old_size)
3676 delegate_->UpdatePreferredSize(this, new_size); 3682 delegate_->UpdatePreferredSize(this, new_size);
3677 } 3683 }
3678 3684
3679 } // namespace content 3685 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698