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

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

Issue 1413643002: Separate RenderViewHost from RenderWidgetHost, part 2: public implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 2 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
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/interstitial_page_impl.h" 5 #include "content/browser/frame_host/interstitial_page_impl.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 // Show the original RVH since we're going away. Note it might not exist if 281 // Show the original RVH since we're going away. Note it might not exist if
282 // the renderer crashed while the interstitial was showing. 282 // the renderer crashed while the interstitial was showing.
283 // Note that it is important that we don't call Show() if the view is 283 // Note that it is important that we don't call Show() if the view is
284 // already showing. That would result in bad things (unparented HWND on 284 // already showing. That would result in bad things (unparented HWND on
285 // Windows for example) happening. 285 // Windows for example) happening.
286 old_view->Show(); 286 old_view->Show();
287 } 287 }
288 288
289 // If the focus was on the interstitial, let's keep it to the page. 289 // If the focus was on the interstitial, let's keep it to the page.
290 // (Note that in unit-tests the RVH may not have a view). 290 // (Note that in unit-tests the RVH may not have a view).
291 if (render_view_host_->GetView() && 291 if (render_view_host_->GetWidget()->GetView() &&
292 render_view_host_->GetView()->HasFocus() && 292 render_view_host_->GetWidget()->GetView()->HasFocus() &&
293 controller_->delegate()->GetRenderViewHost()->GetWidget()->GetView()) { 293 controller_->delegate()->GetRenderViewHost()->GetWidget()->GetView()) {
294 controller_->delegate() 294 controller_->delegate()
295 ->GetRenderViewHost() 295 ->GetRenderViewHost()
296 ->GetWidget() 296 ->GetWidget()
297 ->GetView() 297 ->GetView()
298 ->Focus(); 298 ->Focus();
299 } 299 }
300 300
301 // Delete this and call Shutdown on the RVH asynchronously, as we may have 301 // Delete this and call Shutdown on the RVH asynchronously, as we may have
302 // been called from a RVH delegate method, and we can't delete the RVH out 302 // been called from a RVH delegate method, and we can't delete the RVH out
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 // navigating arrives in the ResourceDispatcherHost. This ensures that 343 // navigating arrives in the ResourceDispatcherHost. This ensures that
344 // request won't be blocked if the same RenderViewHost was used for the 344 // request won't be blocked if the same RenderViewHost was used for the
345 // new navigation. 345 // new navigation.
346 Disable(); 346 Disable();
347 TakeActionOnResourceDispatcher(CANCEL); 347 TakeActionOnResourceDispatcher(CANCEL);
348 break; 348 break;
349 case NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED: 349 case NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED:
350 if (action_taken_ == NO_ACTION) { 350 if (action_taken_ == NO_ACTION) {
351 // The RenderViewHost is being destroyed (as part of the tab being 351 // The RenderViewHost is being destroyed (as part of the tab being
352 // closed); make sure we clear the blocked requests. 352 // closed); make sure we clear the blocked requests.
353 RenderViewHost* rvh = static_cast<RenderViewHost*>( 353 RenderViewHost* rvh =
354 static_cast<RenderViewHostImpl*>( 354 RenderViewHost::From(Source<RenderWidgetHost>(source).ptr());
355 RenderWidgetHostImpl::From(
356 Source<RenderWidgetHost>(source).ptr())));
357 DCHECK(rvh->GetProcess()->GetID() == original_child_id_ && 355 DCHECK(rvh->GetProcess()->GetID() == original_child_id_ &&
358 rvh->GetRoutingID() == original_rvh_id_); 356 rvh->GetRoutingID() == original_rvh_id_);
359 TakeActionOnResourceDispatcher(CANCEL); 357 TakeActionOnResourceDispatcher(CANCEL);
360 } 358 }
361 break; 359 break;
362 default: 360 default:
363 NOTREACHED(); 361 NOTREACHED();
364 } 362 }
365 } 363 }
366 364
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 return; 504 return;
507 } 505 }
508 if (ui::PageTransitionCoreTypeIs(params.transition, 506 if (ui::PageTransitionCoreTypeIs(params.transition,
509 ui::PAGE_TRANSITION_AUTO_SUBFRAME)) { 507 ui::PAGE_TRANSITION_AUTO_SUBFRAME)) {
510 // No need to handle navigate message from iframe in the interstitial page. 508 // No need to handle navigate message from iframe in the interstitial page.
511 return; 509 return;
512 } 510 }
513 511
514 // The RenderViewHost has loaded its contents, we can show it now. 512 // The RenderViewHost has loaded its contents, we can show it now.
515 if (!controller_->delegate()->IsHidden()) 513 if (!controller_->delegate()->IsHidden())
516 render_view_host_->GetView()->Show(); 514 render_view_host_->GetWidget()->GetView()->Show();
517 controller_->delegate()->AttachInterstitialPage(this); 515 controller_->delegate()->AttachInterstitialPage(this);
518 516
519 RenderWidgetHostView* rwh_view = 517 RenderWidgetHostView* rwh_view =
520 controller_->delegate()->GetRenderViewHost()->GetWidget()->GetView(); 518 controller_->delegate()->GetRenderViewHost()->GetWidget()->GetView();
521 519
522 // The RenderViewHost may already have crashed before we even get here. 520 // The RenderViewHost may already have crashed before we even get here.
523 if (rwh_view) { 521 if (rwh_view) {
524 // If the page has focus, focus the interstitial. 522 // If the page has focus, focus the interstitial.
525 if (rwh_view->HasFocus()) 523 if (rwh_view->HasFocus())
526 Focus(); 524 Focus();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 MSG_ROUTING_NONE); 600 MSG_ROUTING_NONE);
603 return frame_tree_.root()->current_frame_host()->render_view_host(); 601 return frame_tree_.root()->current_frame_host()->render_view_host();
604 } 602 }
605 603
606 WebContentsView* InterstitialPageImpl::CreateWebContentsView() { 604 WebContentsView* InterstitialPageImpl::CreateWebContentsView() {
607 if (!enabled() || !create_view_) 605 if (!enabled() || !create_view_)
608 return NULL; 606 return NULL;
609 WebContentsView* wcv = 607 WebContentsView* wcv =
610 static_cast<WebContentsImpl*>(web_contents())->GetView(); 608 static_cast<WebContentsImpl*>(web_contents())->GetView();
611 RenderWidgetHostViewBase* view = 609 RenderWidgetHostViewBase* view =
612 wcv->CreateViewForWidget(render_view_host_, false); 610 wcv->CreateViewForWidget(render_view_host_->GetWidget(), false);
613 render_view_host_->SetView(view); 611 RenderWidgetHostImpl::From(render_view_host_->GetWidget())->SetView(view);
614 render_view_host_->AllowBindings(BINDINGS_POLICY_DOM_AUTOMATION); 612 render_view_host_->AllowBindings(BINDINGS_POLICY_DOM_AUTOMATION);
615 613
616 int32 max_page_id = web_contents()-> 614 int32 max_page_id = web_contents()->
617 GetMaxPageIDForSiteInstance(render_view_host_->GetSiteInstance()); 615 GetMaxPageIDForSiteInstance(render_view_host_->GetSiteInstance());
618 render_view_host_->CreateRenderView(MSG_ROUTING_NONE, 616 render_view_host_->CreateRenderView(MSG_ROUTING_NONE,
619 MSG_ROUTING_NONE, 617 MSG_ROUTING_NONE,
620 max_page_id, 618 max_page_id,
621 FrameReplicationState(), 619 FrameReplicationState(),
622 false); 620 false);
623 controller_->delegate()->RenderFrameForInterstitialPageCreated( 621 controller_->delegate()->RenderFrameForInterstitialPageCreated(
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 else 711 else
714 TakeActionOnResourceDispatcher(CANCEL); 712 TakeActionOnResourceDispatcher(CANCEL);
715 } 713 }
716 714
717 void InterstitialPageImpl::SetSize(const gfx::Size& size) { 715 void InterstitialPageImpl::SetSize(const gfx::Size& size) {
718 if (!enabled()) 716 if (!enabled())
719 return; 717 return;
720 #if !defined(OS_MACOSX) 718 #if !defined(OS_MACOSX)
721 // When a tab is closed, we might be resized after our view was NULLed 719 // When a tab is closed, we might be resized after our view was NULLed
722 // (typically if there was an info-bar). 720 // (typically if there was an info-bar).
723 if (render_view_host_->GetView()) 721 if (render_view_host_->GetWidget()->GetView())
724 render_view_host_->GetView()->SetSize(size); 722 render_view_host_->GetWidget()->GetView()->SetSize(size);
725 #else 723 #else
726 // TODO(port): Does Mac need to SetSize? 724 // TODO(port): Does Mac need to SetSize?
727 NOTIMPLEMENTED(); 725 NOTIMPLEMENTED();
728 #endif 726 #endif
729 } 727 }
730 728
731 void InterstitialPageImpl::Focus() { 729 void InterstitialPageImpl::Focus() {
732 // Focus the native window. 730 // Focus the native window.
733 if (!enabled()) 731 if (!enabled())
734 return; 732 return;
735 render_view_host_->GetView()->Focus(); 733 render_view_host_->GetWidget()->GetView()->Focus();
736 } 734 }
737 735
738 void InterstitialPageImpl::FocusThroughTabTraversal(bool reverse) { 736 void InterstitialPageImpl::FocusThroughTabTraversal(bool reverse) {
739 if (!enabled()) 737 if (!enabled())
740 return; 738 return;
741 render_view_host_->SetInitialFocus(reverse); 739 render_view_host_->SetInitialFocus(reverse);
742 } 740 }
743 741
744 RenderWidgetHostView* InterstitialPageImpl::GetView() { 742 RenderWidgetHostView* InterstitialPageImpl::GetView() {
745 return render_view_host_->GetView(); 743 return render_view_host_->GetWidget()->GetView();
746 } 744 }
747 745
748 RenderFrameHost* InterstitialPageImpl::GetMainFrame() const { 746 RenderFrameHost* InterstitialPageImpl::GetMainFrame() const {
749 return render_view_host_->GetMainFrame(); 747 return render_view_host_->GetMainFrame();
750 } 748 }
751 749
752 InterstitialPageDelegate* InterstitialPageImpl::GetDelegateForTesting() { 750 InterstitialPageDelegate* InterstitialPageImpl::GetDelegateForTesting() {
753 return delegate_.get(); 751 return delegate_.get();
754 } 752 }
755 753
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 void InterstitialPageImpl::UnderlyingContentObserver::NavigationEntryCommitted( 943 void InterstitialPageImpl::UnderlyingContentObserver::NavigationEntryCommitted(
946 const LoadCommittedDetails& load_details) { 944 const LoadCommittedDetails& load_details) {
947 interstitial_->OnNavigatingAwayOrTabClosing(); 945 interstitial_->OnNavigatingAwayOrTabClosing();
948 } 946 }
949 947
950 void InterstitialPageImpl::UnderlyingContentObserver::WebContentsDestroyed() { 948 void InterstitialPageImpl::UnderlyingContentObserver::WebContentsDestroyed() {
951 interstitial_->OnNavigatingAwayOrTabClosing(); 949 interstitial_->OnNavigatingAwayOrTabClosing();
952 } 950 }
953 951
954 } // namespace content 952 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/cross_process_frame_connector.cc ('k') | content/browser/frame_host/render_frame_host_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698