| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/tab_contents/render_view_host_manager.h" | 5 #include "content/browser/tab_contents/render_view_host_manager.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/logging.h" | 10 #include "base/logging.h" |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 CancelPending(); | 535 CancelPending(); |
| 536 } | 536 } |
| 537 return success; | 537 return success; |
| 538 } | 538 } |
| 539 | 539 |
| 540 bool RenderViewHostManager::InitRenderView(RenderViewHost* render_view_host, | 540 bool RenderViewHostManager::InitRenderView(RenderViewHost* render_view_host, |
| 541 const NavigationEntryImpl& entry) { | 541 const NavigationEntryImpl& entry) { |
| 542 // If the pending navigation is to a WebUI, tell the RenderView about any | 542 // If the pending navigation is to a WebUI, tell the RenderView about any |
| 543 // bindings it will need enabled. | 543 // bindings it will need enabled. |
| 544 if (pending_web_ui_.get()) | 544 if (pending_web_ui_.get()) |
| 545 render_view_host->AllowBindings(pending_web_ui_->bindings()); | 545 render_view_host->AllowBindings(pending_web_ui_->GetBindings()); |
| 546 | 546 |
| 547 return delegate_->CreateRenderViewForRenderManager(render_view_host); | 547 return delegate_->CreateRenderViewForRenderManager(render_view_host); |
| 548 } | 548 } |
| 549 | 549 |
| 550 void RenderViewHostManager::CommitPending() { | 550 void RenderViewHostManager::CommitPending() { |
| 551 // First check whether we're going to want to focus the location bar after | 551 // First check whether we're going to want to focus the location bar after |
| 552 // this commit. We do this now because the navigation hasn't formally | 552 // this commit. We do this now because the navigation hasn't formally |
| 553 // committed yet, so if we've already cleared |pending_web_ui_| the call chain | 553 // committed yet, so if we've already cleared |pending_web_ui_| the call chain |
| 554 // this triggers won't be able to figure out what's going on. | 554 // this triggers won't be able to figure out what's going on. |
| 555 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); | 555 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); |
| 556 | 556 |
| 557 // Next commit the Web UI, if any. | 557 // Next commit the Web UI, if any. |
| 558 web_ui_.swap(pending_web_ui_); | 558 web_ui_.swap(pending_web_ui_); |
| 559 if (web_ui_.get() && pending_web_ui_.get() && !pending_render_view_host_) | 559 if (web_ui_.get() && pending_web_ui_.get() && !pending_render_view_host_) |
| 560 web_ui_->controller()->DidBecomeActiveForReusedRenderView(); | 560 web_ui_->GetController()->DidBecomeActiveForReusedRenderView(); |
| 561 pending_web_ui_.reset(); | 561 pending_web_ui_.reset(); |
| 562 | 562 |
| 563 // It's possible for the pending_render_view_host_ to be NULL when we aren't | 563 // It's possible for the pending_render_view_host_ to be NULL when we aren't |
| 564 // crossing process boundaries. If so, we just needed to handle the Web UI | 564 // crossing process boundaries. If so, we just needed to handle the Web UI |
| 565 // committing above and we're done. | 565 // committing above and we're done. |
| 566 if (!pending_render_view_host_) { | 566 if (!pending_render_view_host_) { |
| 567 if (will_focus_location_bar) | 567 if (will_focus_location_bar) |
| 568 delegate_->SetFocusToLocationBar(false); | 568 delegate_->SetFocusToLocationBar(false); |
| 569 return; | 569 return; |
| 570 } | 570 } |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 // just let the new pending_render_view_host_ immediately navigate. | 730 // just let the new pending_render_view_host_ immediately navigate. |
| 731 } | 731 } |
| 732 | 732 |
| 733 // We now have a pending RVH. | 733 // We now have a pending RVH. |
| 734 DCHECK(!cross_navigation_pending_); | 734 DCHECK(!cross_navigation_pending_); |
| 735 cross_navigation_pending_ = true; | 735 cross_navigation_pending_ = true; |
| 736 | 736 |
| 737 return pending_render_view_host_; | 737 return pending_render_view_host_; |
| 738 } else { | 738 } else { |
| 739 if (pending_web_ui_.get() && render_view_host_->IsRenderViewLive()) | 739 if (pending_web_ui_.get() && render_view_host_->IsRenderViewLive()) |
| 740 pending_web_ui_->controller()->RenderViewReused(render_view_host_); | 740 pending_web_ui_->GetController()->RenderViewReused(render_view_host_); |
| 741 | 741 |
| 742 // The renderer can exit view source mode when any error or cancellation | 742 // The renderer can exit view source mode when any error or cancellation |
| 743 // happen. We must overwrite to recover the mode. | 743 // happen. We must overwrite to recover the mode. |
| 744 if (entry.IsViewSourceMode()) { | 744 if (entry.IsViewSourceMode()) { |
| 745 render_view_host_->Send( | 745 render_view_host_->Send( |
| 746 new ViewMsg_EnableViewSourceMode(render_view_host_->routing_id())); | 746 new ViewMsg_EnableViewSourceMode(render_view_host_->routing_id())); |
| 747 } | 747 } |
| 748 } | 748 } |
| 749 | 749 |
| 750 // Same SiteInstance can be used. Navigate render_view_host_ if we are not | 750 // Same SiteInstance can be used. Navigate render_view_host_ if we are not |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 } | 811 } |
| 812 } | 812 } |
| 813 | 813 |
| 814 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { | 814 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { |
| 815 if (!rvh->site_instance()) | 815 if (!rvh->site_instance()) |
| 816 return false; | 816 return false; |
| 817 | 817 |
| 818 return swapped_out_hosts_.find(rvh->site_instance()->id()) != | 818 return swapped_out_hosts_.find(rvh->site_instance()->id()) != |
| 819 swapped_out_hosts_.end(); | 819 swapped_out_hosts_.end(); |
| 820 } | 820 } |
| OLD | NEW |