Chromium Code Reviews| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 2143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2154 // aren't crossing process boundaries. If so, we just needed to handle the Web | 2154 // aren't crossing process boundaries. If so, we just needed to handle the Web |
| 2155 // UI committing above and we're done. | 2155 // UI committing above and we're done. |
| 2156 if (!pending_render_frame_host_ && !speculative_render_frame_host_) { | 2156 if (!pending_render_frame_host_ && !speculative_render_frame_host_) { |
| 2157 if (will_focus_location_bar) | 2157 if (will_focus_location_bar) |
| 2158 delegate_->SetFocusToLocationBar(false); | 2158 delegate_->SetFocusToLocationBar(false); |
| 2159 return; | 2159 return; |
| 2160 } | 2160 } |
| 2161 | 2161 |
| 2162 // Remember if the page was focused so we can focus the new renderer in | 2162 // Remember if the page was focused so we can focus the new renderer in |
| 2163 // that case. | 2163 // that case. |
| 2164 bool focus_render_view = !will_focus_location_bar && | 2164 RenderWidgetHostView* root_view = frame_tree_node_->frame_tree() |
| 2165 render_frame_host_->GetView() && | 2165 ->root() |
| 2166 render_frame_host_->GetView()->HasFocus(); | 2166 ->render_manager() |
|
alexmos
2015/10/22 21:33:40
For subframes, this routed to RWHVChildFrame, whic
Charlie Reis
2015/10/23 21:41:52
That sounds like a better change to me, since anyo
alexmos
2015/10/24 00:41:43
I went ahead and did that to see what it'll look l
| |
| 2167 ->GetRenderWidgetHostView(); | |
| 2168 bool focus_render_view = | |
| 2169 !will_focus_location_bar && root_view && root_view->HasFocus(); | |
| 2167 | 2170 |
| 2168 bool is_main_frame = frame_tree_node_->IsMainFrame(); | 2171 bool is_main_frame = frame_tree_node_->IsMainFrame(); |
| 2169 | 2172 |
| 2170 // Swap in the pending or speculative frame and make it active. Also ensure | 2173 // Swap in the pending or speculative frame and make it active. Also ensure |
| 2171 // the FrameTree stays in sync. | 2174 // the FrameTree stays in sync. |
| 2172 scoped_ptr<RenderFrameHostImpl> old_render_frame_host; | 2175 scoped_ptr<RenderFrameHostImpl> old_render_frame_host; |
| 2173 if (!browser_side_navigation) { | 2176 if (!browser_side_navigation) { |
| 2174 DCHECK(!speculative_render_frame_host_); | 2177 DCHECK(!speculative_render_frame_host_); |
| 2175 old_render_frame_host = | 2178 old_render_frame_host = |
| 2176 SetRenderFrameHost(pending_render_frame_host_.Pass()); | 2179 SetRenderFrameHost(pending_render_frame_host_.Pass()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2210 old_render_frame_host->render_view_host()->GetWidget()->GetView()) { | 2213 old_render_frame_host->render_view_host()->GetWidget()->GetView()) { |
| 2211 old_render_frame_host->render_view_host()->GetWidget()->GetView()->Hide(); | 2214 old_render_frame_host->render_view_host()->GetWidget()->GetView()->Hide(); |
| 2212 } | 2215 } |
| 2213 | 2216 |
| 2214 // Make sure the size is up to date. (Fix for bug 1079768.) | 2217 // Make sure the size is up to date. (Fix for bug 1079768.) |
| 2215 delegate_->UpdateRenderViewSizeForRenderManager(); | 2218 delegate_->UpdateRenderViewSizeForRenderManager(); |
| 2216 | 2219 |
| 2217 if (will_focus_location_bar) { | 2220 if (will_focus_location_bar) { |
| 2218 delegate_->SetFocusToLocationBar(false); | 2221 delegate_->SetFocusToLocationBar(false); |
| 2219 } else if (focus_render_view && render_frame_host_->GetView()) { | 2222 } else if (focus_render_view && render_frame_host_->GetView()) { |
| 2220 render_frame_host_->GetView()->Focus(); | 2223 if (is_main_frame) { |
| 2224 render_frame_host_->GetView()->Focus(); | |
| 2225 } else { | |
| 2226 // The main frame's view is already focused, but we need to set | |
| 2227 // page-level focus in the subframe's renderer. | |
| 2228 frame_tree_node_->frame_tree()->SetPageFocus( | |
| 2229 render_frame_host_->GetSiteInstance(), true); | |
| 2230 } | |
| 2221 } | 2231 } |
| 2222 | 2232 |
| 2223 // Notify that we've swapped RenderFrameHosts. We do this before shutting down | 2233 // Notify that we've swapped RenderFrameHosts. We do this before shutting down |
| 2224 // the RFH so that we can clean up RendererResources related to the RFH first. | 2234 // the RFH so that we can clean up RendererResources related to the RFH first. |
| 2225 delegate_->NotifySwappedFromRenderManager( | 2235 delegate_->NotifySwappedFromRenderManager( |
| 2226 old_render_frame_host.get(), render_frame_host_.get(), is_main_frame); | 2236 old_render_frame_host.get(), render_frame_host_.get(), is_main_frame); |
| 2227 | 2237 |
| 2228 // The RenderViewHost keeps track of the main RenderFrameHost routing id. | 2238 // The RenderViewHost keeps track of the main RenderFrameHost routing id. |
| 2229 // If this is committing a main frame navigation, update it and set the | 2239 // If this is committing a main frame navigation, update it and set the |
| 2230 // routing id in the RenderViewHost associated with the old RenderFrameHost | 2240 // routing id in the RenderViewHost associated with the old RenderFrameHost |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2650 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { | 2660 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { |
| 2651 if (!frame_tree_node_->opener()) | 2661 if (!frame_tree_node_->opener()) |
| 2652 return MSG_ROUTING_NONE; | 2662 return MSG_ROUTING_NONE; |
| 2653 | 2663 |
| 2654 return frame_tree_node_->opener() | 2664 return frame_tree_node_->opener() |
| 2655 ->render_manager() | 2665 ->render_manager() |
| 2656 ->GetRoutingIdForSiteInstance(instance); | 2666 ->GetRoutingIdForSiteInstance(instance); |
| 2657 } | 2667 } |
| 2658 | 2668 |
| 2659 } // namespace content | 2669 } // namespace content |
| OLD | NEW |