| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/frame_host/render_frame_host_manager.h" | 5 #include "content/browser/frame_host/render_frame_host_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 2155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2166 | 2166 |
| 2167 if (will_focus_location_bar) | 2167 if (will_focus_location_bar) |
| 2168 delegate_->SetFocusToLocationBar(false); | 2168 delegate_->SetFocusToLocationBar(false); |
| 2169 } | 2169 } |
| 2170 | 2170 |
| 2171 void RenderFrameHostManager::CommitPending() { | 2171 void RenderFrameHostManager::CommitPending() { |
| 2172 TRACE_EVENT1("navigation", "RenderFrameHostManager::CommitPending", | 2172 TRACE_EVENT1("navigation", "RenderFrameHostManager::CommitPending", |
| 2173 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); | 2173 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); |
| 2174 DCHECK(pending_render_frame_host_ || speculative_render_frame_host_); | 2174 DCHECK(pending_render_frame_host_ || speculative_render_frame_host_); |
| 2175 | 2175 |
| 2176 bool is_main_frame = frame_tree_node_->IsMainFrame(); |
| 2177 |
| 2176 // First check whether we're going to want to focus the location bar after | 2178 // First check whether we're going to want to focus the location bar after |
| 2177 // this commit. We do this now because the navigation hasn't formally | 2179 // this commit. We do this now because the navigation hasn't formally |
| 2178 // committed yet, so if we've already cleared the pending WebUI the call chain | 2180 // committed yet, so if we've already cleared the pending WebUI the call chain |
| 2179 // this triggers won't be able to figure out what's going on. | 2181 // this triggers won't be able to figure out what's going on. Note that |
| 2180 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); | 2182 // subframe commits should not be allowed to steal focus from the main frame |
| 2183 // by focusing the location bar (see https://crbug.com/700124). |
| 2184 bool will_focus_location_bar = |
| 2185 is_main_frame && delegate_->FocusLocationBarByDefault(); |
| 2181 | 2186 |
| 2182 // Remember if the page was focused so we can focus the new renderer in | 2187 // Remember if the page was focused so we can focus the new renderer in |
| 2183 // that case. | 2188 // that case. |
| 2184 bool focus_render_view = !will_focus_location_bar && | 2189 bool focus_render_view = !will_focus_location_bar && |
| 2185 render_frame_host_->GetView() && | 2190 render_frame_host_->GetView() && |
| 2186 render_frame_host_->GetView()->HasFocus(); | 2191 render_frame_host_->GetView()->HasFocus(); |
| 2187 | 2192 |
| 2188 bool is_main_frame = frame_tree_node_->IsMainFrame(); | |
| 2189 | |
| 2190 // While the old frame is still current, remove its children from the tree. | 2193 // While the old frame is still current, remove its children from the tree. |
| 2191 frame_tree_node_->ResetForNewProcess(); | 2194 frame_tree_node_->ResetForNewProcess(); |
| 2192 | 2195 |
| 2193 // Swap in the pending or speculative frame and make it active. Also ensure | 2196 // Swap in the pending or speculative frame and make it active. Also ensure |
| 2194 // the FrameTree stays in sync. | 2197 // the FrameTree stays in sync. |
| 2195 std::unique_ptr<RenderFrameHostImpl> old_render_frame_host; | 2198 std::unique_ptr<RenderFrameHostImpl> old_render_frame_host; |
| 2196 if (!IsBrowserSideNavigationEnabled()) { | 2199 if (!IsBrowserSideNavigationEnabled()) { |
| 2197 DCHECK(!speculative_render_frame_host_); | 2200 DCHECK(!speculative_render_frame_host_); |
| 2198 old_render_frame_host = | 2201 old_render_frame_host = |
| 2199 SetRenderFrameHost(std::move(pending_render_frame_host_)); | 2202 SetRenderFrameHost(std::move(pending_render_frame_host_)); |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2826 resolved_url)) { | 2829 resolved_url)) { |
| 2827 DCHECK(!dest_instance || | 2830 DCHECK(!dest_instance || |
| 2828 dest_instance == render_frame_host_->GetSiteInstance()); | 2831 dest_instance == render_frame_host_->GetSiteInstance()); |
| 2829 return false; | 2832 return false; |
| 2830 } | 2833 } |
| 2831 | 2834 |
| 2832 return true; | 2835 return true; |
| 2833 } | 2836 } |
| 2834 | 2837 |
| 2835 } // namespace content | 2838 } // namespace content |
| OLD | NEW |