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

Side by Side Diff: content/browser/frame_host/render_frame_host_manager.cc

Issue 1418853003: Remove RFHM::GetNavigatingWebUI() and RFHM::web_ui(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webui-refactor
Patch Set: Remove RFHM::web_ui(). Created 5 years, 1 month 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
OLDNEW
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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 return nullptr; 276 return nullptr;
277 return render_frame_host_->render_view_host(); 277 return render_frame_host_->render_view_host();
278 } 278 }
279 279
280 RenderViewHostImpl* RenderFrameHostManager::pending_render_view_host() const { 280 RenderViewHostImpl* RenderFrameHostManager::pending_render_view_host() const {
281 if (!pending_render_frame_host_) 281 if (!pending_render_frame_host_)
282 return nullptr; 282 return nullptr;
283 return pending_render_frame_host_->render_view_host(); 283 return pending_render_frame_host_->render_view_host();
284 } 284 }
285 285
286 WebUIImpl* RenderFrameHostManager::GetNavigatingWebUI() const {
287 if (current_web_ui_is_navigating_)
288 return render_frame_host_->web_ui();
289
290 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
291 switches::kEnableBrowserSideNavigation)) {
292 if (speculative_render_frame_host_)
293 return speculative_render_frame_host_->web_ui();
294 } else {
295 if (pending_render_frame_host_)
296 return pending_render_frame_host_->web_ui();
297 }
298 return nullptr;
299 }
300
301 RenderWidgetHostView* RenderFrameHostManager::GetRenderWidgetHostView() const { 286 RenderWidgetHostView* RenderFrameHostManager::GetRenderWidgetHostView() const {
302 if (interstitial_page_) 287 if (interstitial_page_)
303 return interstitial_page_->GetView(); 288 return interstitial_page_->GetView();
304 if (render_frame_host_) 289 if (render_frame_host_)
305 return render_frame_host_->GetView(); 290 return render_frame_host_->GetView();
306 return nullptr; 291 return nullptr;
307 } 292 }
308 293
309 bool RenderFrameHostManager::ForInnerDelegate() { 294 bool RenderFrameHostManager::ForInnerDelegate() {
310 return delegate_->GetOuterDelegateFrameTreeNodeID() != 295 return delegate_->GetOuterDelegateFrameTreeNodeID() !=
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 // site that is handled via Mojo, then Mojo WebUI code in //chrome will 386 // site that is handled via Mojo, then Mojo WebUI code in //chrome will
402 // add a service to this RFH's ServiceRegistry). 387 // add a service to this RFH's ServiceRegistry).
403 dest_render_frame_host->SetUpMojoIfNeeded(); 388 dest_render_frame_host->SetUpMojoIfNeeded();
404 389
405 // Recreate the opener chain. 390 // Recreate the opener chain.
406 CreateOpenerProxies(dest_render_frame_host->GetSiteInstance(), 391 CreateOpenerProxies(dest_render_frame_host->GetSiteInstance(),
407 frame_tree_node_); 392 frame_tree_node_);
408 if (!InitRenderView(dest_render_frame_host->render_view_host(), nullptr)) 393 if (!InitRenderView(dest_render_frame_host->render_view_host(), nullptr))
409 return nullptr; 394 return nullptr;
410 395
411 if (GetNavigatingWebUI()) { 396 if (dest_render_frame_host->web_ui()) {
412 GetNavigatingWebUI()->RenderViewCreated( 397 dest_render_frame_host->web_ui()->RenderViewCreated(
413 dest_render_frame_host->render_view_host()); 398 dest_render_frame_host->render_view_host());
414 } 399 }
415 400
416 // Now that we've created a new renderer, be sure to hide it if it isn't 401 // Now that we've created a new renderer, be sure to hide it if it isn't
417 // our primary one. Otherwise, we might crash if we try to call Show() 402 // our primary one. Otherwise, we might crash if we try to call Show()
418 // on it later. 403 // on it later.
419 if (dest_render_frame_host != render_frame_host_) { 404 if (dest_render_frame_host != render_frame_host_) {
420 if (dest_render_frame_host->GetView()) 405 if (dest_render_frame_host->GetView())
421 dest_render_frame_host->GetView()->Hide(); 406 dest_render_frame_host->GetView()->Hide();
422 } else { 407 } else {
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 646
662 void RenderFrameHostManager::CommitPendingIfNecessary( 647 void RenderFrameHostManager::CommitPendingIfNecessary(
663 RenderFrameHostImpl* render_frame_host, 648 RenderFrameHostImpl* render_frame_host,
664 bool was_caused_by_user_gesture) { 649 bool was_caused_by_user_gesture) {
665 if (!pending_render_frame_host_ && !speculative_render_frame_host_) { 650 if (!pending_render_frame_host_ && !speculative_render_frame_host_) {
666 DCHECK(!current_web_ui_is_navigating_ || render_frame_host_->web_ui()); 651 DCHECK(!current_web_ui_is_navigating_ || render_frame_host_->web_ui());
667 652
668 // We should only hear this from our current renderer. 653 // We should only hear this from our current renderer.
669 DCHECK_EQ(render_frame_host_, render_frame_host); 654 DCHECK_EQ(render_frame_host_, render_frame_host);
670 655
671 // Even when there is no pending RVH, there may be a pending Web UI. 656 // If the current RenderFrameHost has a WebUI it must be committed (for
672 if (GetNavigatingWebUI()) 657 // proper focus setting).
658 if (render_frame_host_->web_ui())
673 CommitPending(); 659 CommitPending();
674 return; 660 return;
675 } 661 }
676 662
677 if (render_frame_host == pending_render_frame_host_ || 663 if (render_frame_host == pending_render_frame_host_ ||
678 render_frame_host == speculative_render_frame_host_) { 664 render_frame_host == speculative_render_frame_host_) {
679 // The pending cross-process navigation completed, so show the renderer. 665 // The pending cross-process navigation completed, so show the renderer.
680 CommitPending(); 666 CommitPending();
681 } else if (render_frame_host == render_frame_host_) { 667 } else if (render_frame_host == render_frame_host_) {
682 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 668 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 request.common_params().url, request.bindings()); 1009 request.common_params().url, request.bindings());
1024 1010
1025 // If a change in WebUI happened, check this is an acceptable case. 1011 // If a change in WebUI happened, check this is an acceptable case.
1026 DCHECK(!changed_web_ui || 1012 DCHECK(!changed_web_ui ||
1027 (IsAcceptableWebUITransition( 1013 (IsAcceptableWebUITransition(
1028 previous_web_ui_type, request.common_params().url, 1014 previous_web_ui_type, request.common_params().url,
1029 request.restore_type() != NavigationEntryImpl::RESTORE_NONE))); 1015 request.restore_type() != NavigationEntryImpl::RESTORE_NONE)));
1030 1016
1031 // If there is a WebUI in the current RenderFrameHost, it will navigate. 1017 // If there is a WebUI in the current RenderFrameHost, it will navigate.
1032 current_web_ui_is_navigating_ = !!render_frame_host_->web_ui(); 1018 current_web_ui_is_navigating_ = !!render_frame_host_->web_ui();
1033 DCHECK_EQ(GetNavigatingWebUI(), render_frame_host_->web_ui());
1034 1019
1035 // If the current RenderFrameHost has a WebUI and the associated RenderFrame 1020 // If the current RenderFrameHost has a WebUI and the associated RenderFrame
1036 // is alive, notify to the WebUI that the RenderView is being created or 1021 // is alive, notify to the WebUI that the RenderView is being created or
1037 // reused depending on whether the WebUI was changed or not. 1022 // reused depending on whether the WebUI was changed or not.
1038 if (GetNavigatingWebUI() && render_frame_host_->IsRenderFrameLive()) { 1023 if (render_frame_host_->web_ui() &&
1024 render_frame_host_->IsRenderFrameLive()) {
1039 if (changed_web_ui) { 1025 if (changed_web_ui) {
1040 GetNavigatingWebUI()->RenderViewCreated( 1026 render_frame_host_->web_ui()->RenderViewCreated(
1041 render_frame_host_->render_view_host()); 1027 render_frame_host_->render_view_host());
1042 } else { 1028 } else {
1043 GetNavigatingWebUI()->RenderViewReused( 1029 render_frame_host_->web_ui()->RenderViewReused(
1044 render_frame_host_->render_view_host(), 1030 render_frame_host_->render_view_host(),
1045 frame_tree_node_->IsMainFrame()); 1031 frame_tree_node_->IsMainFrame());
1046 } 1032 }
1047 } 1033 }
1048 1034
1049 DCHECK(!speculative_render_frame_host_); 1035 DCHECK(!speculative_render_frame_host_);
1050 } else { 1036 } else {
1051 // If the SiteInstance for the final URL doesn't match the one from the 1037 // If the SiteInstance for the final URL doesn't match the one from the
1052 // speculatively created RenderFrameHost, create a new RenderFrameHost using 1038 // speculatively created RenderFrameHost, create a new RenderFrameHost using
1053 // this new SiteInstance. 1039 // this new SiteInstance.
(...skipping 16 matching lines...) Expand all
1070 } else { 1056 } else {
1071 // Reuses the previous speculative RenderFrameHost. 1057 // Reuses the previous speculative RenderFrameHost.
1072 bool changed_web_ui = speculative_render_frame_host_->UpdateWebUI( 1058 bool changed_web_ui = speculative_render_frame_host_->UpdateWebUI(
1073 request.common_params().url, request.bindings()); 1059 request.common_params().url, request.bindings());
1074 if (changed_web_ui && speculative_render_frame_host_->web_ui()) { 1060 if (changed_web_ui && speculative_render_frame_host_->web_ui()) {
1075 speculative_render_frame_host_->web_ui()->RenderViewCreated( 1061 speculative_render_frame_host_->web_ui()->RenderViewCreated(
1076 speculative_render_frame_host_->render_view_host()); 1062 speculative_render_frame_host_->render_view_host());
1077 } 1063 }
1078 } 1064 }
1079 DCHECK(speculative_render_frame_host_); 1065 DCHECK(speculative_render_frame_host_);
1080 DCHECK_EQ(GetNavigatingWebUI(), speculative_render_frame_host_->web_ui());
1081 1066
1082 navigation_rfh = speculative_render_frame_host_.get(); 1067 navigation_rfh = speculative_render_frame_host_.get();
1083 1068
1084 // Check if our current RFH is live. 1069 // Check if our current RFH is live.
1085 if (!render_frame_host_->IsRenderFrameLive()) { 1070 if (!render_frame_host_->IsRenderFrameLive()) {
1086 // The current RFH is not live. There's no reason to sit around with a 1071 // The current RFH is not live. There's no reason to sit around with a
1087 // sad tab or a newly created RFH while we wait for the navigation to 1072 // sad tab or a newly created RFH while we wait for the navigation to
1088 // complete. Just switch to the speculative RFH now and go back to normal. 1073 // complete. Just switch to the speculative RFH now and go back to normal.
1089 // (Note that we don't care about on{before}unload handlers if the current 1074 // (Note that we don't care about on{before}unload handlers if the current
1090 // RFH isn't live.) 1075 // RFH isn't live.)
1091 CommitPending(); 1076 CommitPending();
1092 } 1077 }
1093 DCHECK(!current_web_ui_is_navigating_); 1078 DCHECK(!current_web_ui_is_navigating_);
1094 } 1079 }
1095 DCHECK(navigation_rfh && 1080 DCHECK(navigation_rfh &&
1096 (navigation_rfh == render_frame_host_.get() || 1081 (navigation_rfh == render_frame_host_.get() ||
1097 navigation_rfh == speculative_render_frame_host_.get())); 1082 navigation_rfh == speculative_render_frame_host_.get()));
1098 1083
1099 // If the RenderFrame that needs to navigate is not live (its process was just 1084 // If the RenderFrame that needs to navigate is not live (its process was just
1100 // created or has crashed), initialize it. 1085 // created or has crashed), initialize it.
1101 if (!navigation_rfh->IsRenderFrameLive()) { 1086 if (!navigation_rfh->IsRenderFrameLive()) {
1102 // Recreate the opener chain. 1087 // Recreate the opener chain.
1103 CreateOpenerProxies(navigation_rfh->GetSiteInstance(), frame_tree_node_); 1088 CreateOpenerProxies(navigation_rfh->GetSiteInstance(), frame_tree_node_);
1104 if (!InitRenderView(navigation_rfh->render_view_host(), nullptr)) 1089 if (!InitRenderView(navigation_rfh->render_view_host(), nullptr))
1105 return nullptr; 1090 return nullptr;
1106 1091
1107 if (GetNavigatingWebUI()) { 1092 if (navigation_rfh->web_ui()) {
1108 GetNavigatingWebUI()->RenderViewCreated( 1093 navigation_rfh->web_ui()->RenderViewCreated(
1109 navigation_rfh->render_view_host()); 1094 navigation_rfh->render_view_host());
1110 } 1095 }
1111 1096
1112 if (navigation_rfh == render_frame_host_) { 1097 if (navigation_rfh == render_frame_host_) {
1113 // TODO(nasko): This is a very ugly hack. The Chrome extensions process 1098 // TODO(nasko): This is a very ugly hack. The Chrome extensions process
1114 // manager still uses NotificationService and expects to see a 1099 // manager still uses NotificationService and expects to see a
1115 // RenderViewHost changed notification after WebContents and 1100 // RenderViewHost changed notification after WebContents and
1116 // RenderFrameHostManager are completely initialized. This should be 1101 // RenderFrameHostManager are completely initialized. This should be
1117 // removed once the process manager moves away from NotificationService. 1102 // removed once the process manager moves away from NotificationService.
1118 // See https://crbug.com/462682. 1103 // See https://crbug.com/462682.
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
2104 void RenderFrameHostManager::CommitPending() { 2089 void RenderFrameHostManager::CommitPending() {
2105 TRACE_EVENT1("navigation", "RenderFrameHostManager::CommitPending", 2090 TRACE_EVENT1("navigation", "RenderFrameHostManager::CommitPending",
2106 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); 2091 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id());
2107 // First check whether we're going to want to focus the location bar after 2092 // First check whether we're going to want to focus the location bar after
2108 // this commit. We do this now because the navigation hasn't formally 2093 // this commit. We do this now because the navigation hasn't formally
2109 // committed yet, so if we've already cleared the pending WebUI the call chain 2094 // committed yet, so if we've already cleared the pending WebUI the call chain
2110 // this triggers won't be able to figure out what's going on. 2095 // this triggers won't be able to figure out what's going on.
2111 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); 2096 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault();
2112 2097
2113 if (!pending_render_frame_host_ && !speculative_render_frame_host_) { 2098 if (!pending_render_frame_host_ && !speculative_render_frame_host_) {
2114 DCHECK_EQ(current_web_ui_is_navigating_, !!render_frame_host_->web_ui()); 2099 DCHECK(!current_web_ui_is_navigating_ || render_frame_host_->web_ui());
2115 current_web_ui_is_navigating_ = false; 2100 current_web_ui_is_navigating_ = false;
2116 // If there's no pending/speculative RenderFrameHost then the current 2101 // If there's no pending/speculative RenderFrameHost then the current
2117 // RenderFrameHost is committing. 2102 // RenderFrameHost is committing.
2118 if (will_focus_location_bar) 2103 if (will_focus_location_bar)
2119 delegate_->SetFocusToLocationBar(false); 2104 delegate_->SetFocusToLocationBar(false);
2120 return; 2105 return;
2121 } 2106 }
2122 2107
2123 // Remember if the page was focused so we can focus the new renderer in 2108 // Remember if the page was focused so we can focus the new renderer in
2124 // that case. 2109 // that case.
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
2320 return nullptr; 2305 return nullptr;
2321 2306
2322 pending_render_frame_host_->UpdateWebUI(dest_url, bindings); 2307 pending_render_frame_host_->UpdateWebUI(dest_url, bindings);
2323 if (pending_render_frame_host_->web_ui()) { 2308 if (pending_render_frame_host_->web_ui()) {
2324 pending_render_frame_host_->web_ui()->RenderViewCreated( 2309 pending_render_frame_host_->web_ui()->RenderViewCreated(
2325 pending_render_frame_host_->render_view_host()); 2310 pending_render_frame_host_->render_view_host());
2326 } 2311 }
2327 2312
2328 // We now have a pending RFH and possibly an associated pending WebUI. 2313 // We now have a pending RFH and possibly an associated pending WebUI.
2329 DCHECK(pending_render_frame_host_); 2314 DCHECK(pending_render_frame_host_);
2330 DCHECK_EQ(GetNavigatingWebUI(), pending_render_frame_host_->web_ui());
2331 2315
2332 // Check if our current RFH is live before we set up a transition. 2316 // Check if our current RFH is live before we set up a transition.
2333 if (!render_frame_host_->IsRenderFrameLive()) { 2317 if (!render_frame_host_->IsRenderFrameLive()) {
2334 // The current RFH is not live. There's no reason to sit around with a 2318 // The current RFH is not live. There's no reason to sit around with a
2335 // sad tab or a newly created RFH while we wait for the pending RFH to 2319 // sad tab or a newly created RFH while we wait for the pending RFH to
2336 // navigate. Just switch to the pending RFH now and go back to normal. 2320 // navigate. Just switch to the pending RFH now and go back to normal.
2337 // (Note that we don't care about on{before}unload handlers if the current 2321 // (Note that we don't care about on{before}unload handlers if the current
2338 // RFH isn't live.) 2322 // RFH isn't live.)
2339 CommitPending(); 2323 CommitPending();
2340 return render_frame_host_.get(); 2324 return render_frame_host_.get();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2384 WebUI::TypeID previous_web_ui_type = render_frame_host_->web_ui_type(); 2368 WebUI::TypeID previous_web_ui_type = render_frame_host_->web_ui_type();
2385 bool changed_web_ui = render_frame_host_->UpdateWebUI(dest_url, bindings); 2369 bool changed_web_ui = render_frame_host_->UpdateWebUI(dest_url, bindings);
2386 2370
2387 // If a change in WebUI happened, check this is an acceptable case. 2371 // If a change in WebUI happened, check this is an acceptable case.
2388 DCHECK(!changed_web_ui || 2372 DCHECK(!changed_web_ui ||
2389 IsAcceptableWebUITransition(previous_web_ui_type, dest_url, 2373 IsAcceptableWebUITransition(previous_web_ui_type, dest_url,
2390 dest_is_restore)); 2374 dest_is_restore));
2391 2375
2392 // If there is a WebUI in the current RenderFrameHost, it will navigate. 2376 // If there is a WebUI in the current RenderFrameHost, it will navigate.
2393 current_web_ui_is_navigating_ = !!render_frame_host_->web_ui(); 2377 current_web_ui_is_navigating_ = !!render_frame_host_->web_ui();
2394 DCHECK_EQ(GetNavigatingWebUI(), render_frame_host_->web_ui());
2395 2378
2396 // If the current RenderFrameHost has a WebUI and the associated RenderFrame 2379 // If the current RenderFrameHost has a WebUI and the associated RenderFrame
2397 // is alive, notify to the WebUI that the RenderView is being created or 2380 // is alive, notify to the WebUI that the RenderView is being created or
2398 // reused depending on whether the WebUI was changed or not. 2381 // reused depending on whether the WebUI was changed or not.
2399 if (GetNavigatingWebUI() && render_frame_host_->IsRenderFrameLive()) { 2382 if (render_frame_host_->web_ui() && render_frame_host_->IsRenderFrameLive()) {
2400 if (changed_web_ui) { 2383 if (changed_web_ui) {
2401 GetNavigatingWebUI()->RenderViewCreated( 2384 render_frame_host_->web_ui()->RenderViewCreated(
2402 render_frame_host_->render_view_host()); 2385 render_frame_host_->render_view_host());
2403 } else { 2386 } else {
2404 GetNavigatingWebUI()->RenderViewReused( 2387 render_frame_host_->web_ui()->RenderViewReused(
2405 render_frame_host_->render_view_host(), 2388 render_frame_host_->render_view_host(),
2406 frame_tree_node_->IsMainFrame()); 2389 frame_tree_node_->IsMainFrame());
2407 } 2390 }
2408 } 2391 }
2409 2392
2410 // The renderer can exit view source mode when any error or cancellation 2393 // The renderer can exit view source mode when any error or cancellation
2411 // happen. We must overwrite to recover the mode. 2394 // happen. We must overwrite to recover the mode.
2412 if (dest_is_view_source_mode) { 2395 if (dest_is_view_source_mode) {
2413 render_frame_host_->render_view_host()->Send( 2396 render_frame_host_->render_view_host()->Send(
2414 new ViewMsg_EnableViewSourceMode( 2397 new ViewMsg_EnableViewSourceMode(
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
2666 } else { 2649 } else {
2667 // Going from having to not having a WebUI is acceptable for: 2650 // Going from having to not having a WebUI is acceptable for:
2668 // - Navigating to a special, renderer controlled URL. 2651 // - Navigating to a special, renderer controlled URL.
2669 DCHECK(IsRendererDebugURL( 2652 DCHECK(IsRendererDebugURL(
2670 SiteInstanceImpl::GetEffectiveURL(browser_context, dest_url))); 2653 SiteInstanceImpl::GetEffectiveURL(browser_context, dest_url)));
2671 } 2654 }
2672 return true; 2655 return true;
2673 } 2656 }
2674 2657
2675 } // namespace content 2658 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698