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

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

Issue 108483008: Make RenderFrameHostManager swap RenderFrameHosts, not RenderViewHosts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 enabled_(true), 155 enabled_(true),
156 action_taken_(NO_ACTION), 156 action_taken_(NO_ACTION),
157 render_view_host_(NULL), 157 render_view_host_(NULL),
158 // TODO(nasko): The InterstitialPageImpl will need to provide its own 158 // TODO(nasko): The InterstitialPageImpl will need to provide its own
159 // NavigationControllerImpl to the Navigator, which is separate from 159 // NavigationControllerImpl to the Navigator, which is separate from
160 // the WebContents one, so we can enforce no navigation policy here. 160 // the WebContents one, so we can enforce no navigation policy here.
161 // While we get the code to a point to do this, pass NULL for it. 161 // While we get the code to a point to do this, pass NULL for it.
162 // TODO(creis): We will also need to pass delegates for the RVHM as we 162 // TODO(creis): We will also need to pass delegates for the RVHM as we
163 // start to use it. 163 // start to use it.
164 frame_tree_(new InterstitialPageNavigatorImpl(this, controller_), 164 frame_tree_(new InterstitialPageNavigatorImpl(this, controller_),
165 NULL, NULL, NULL, NULL), 165 this, this, this, NULL),
166 original_child_id_(web_contents->GetRenderProcessHost()->GetID()), 166 original_child_id_(web_contents->GetRenderProcessHost()->GetID()),
167 original_rvh_id_(web_contents->GetRenderViewHost()->GetRoutingID()), 167 original_rvh_id_(web_contents->GetRenderViewHost()->GetRoutingID()),
168 should_revert_web_contents_title_(false), 168 should_revert_web_contents_title_(false),
169 web_contents_was_loading_(false), 169 web_contents_was_loading_(false),
170 resource_dispatcher_host_notified_(false), 170 resource_dispatcher_host_notified_(false),
171 rvh_delegate_view_(new InterstitialPageRVHDelegateView(this)), 171 rvh_delegate_view_(new InterstitialPageRVHDelegateView(this)),
172 create_view_(true), 172 create_view_(true),
173 delegate_(delegate), 173 delegate_(delegate),
174 weak_ptr_factory_(this) { 174 weak_ptr_factory_(this) {
175 InitInterstitialPageMap(); 175 InitInterstitialPageMap();
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 277
278 // If the focus was on the interstitial, let's keep it to the page. 278 // If the focus was on the interstitial, let's keep it to the page.
279 // (Note that in unit-tests the RVH may not have a view). 279 // (Note that in unit-tests the RVH may not have a view).
280 if (render_view_host_->GetView() && 280 if (render_view_host_->GetView() &&
281 render_view_host_->GetView()->HasFocus() && 281 render_view_host_->GetView()->HasFocus() &&
282 controller_->delegate()->GetRenderViewHost()->GetView()) { 282 controller_->delegate()->GetRenderViewHost()->GetView()) {
283 RenderWidgetHostViewPort::FromRWHV( 283 RenderWidgetHostViewPort::FromRWHV(
284 controller_->delegate()->GetRenderViewHost()->GetView())->Focus(); 284 controller_->delegate()->GetRenderViewHost()->GetView())->Focus();
285 } 285 }
286 286
287 // Shutdown the RVH asynchronously, as we may have been called from a RVH 287 // Delete this and call Shutdown on the RVH asynchronously, as we may have
288 // delegate method, and we can't delete the RVH out from under itself. 288 // been called from a RVH delegate method, and we can't delete the RVH out
289 // from under itself.
289 base::MessageLoop::current()->PostNonNestableTask( 290 base::MessageLoop::current()->PostNonNestableTask(
290 FROM_HERE, 291 FROM_HERE,
291 base::Bind(&InterstitialPageImpl::Shutdown, 292 base::Bind(&InterstitialPageImpl::Shutdown,
292 weak_ptr_factory_.GetWeakPtr(), 293 weak_ptr_factory_.GetWeakPtr()));
293 render_view_host_));
294 render_view_host_ = NULL; 294 render_view_host_ = NULL;
295 frame_tree_.SwapMainFrame(NULL); 295 frame_tree_.ResetForMainFrameSwap();
296 controller_->delegate()->DetachInterstitialPage(); 296 controller_->delegate()->DetachInterstitialPage();
297 // Let's revert to the original title if necessary. 297 // Let's revert to the original title if necessary.
298 NavigationEntry* entry = controller_->GetVisibleEntry(); 298 NavigationEntry* entry = controller_->GetVisibleEntry();
299 if (!new_navigation_ && should_revert_web_contents_title_) { 299 if (!new_navigation_ && should_revert_web_contents_title_) {
300 entry->SetTitle(original_web_contents_title_); 300 entry->SetTitle(original_web_contents_title_);
301 controller_->delegate()->NotifyNavigationStateChanged( 301 controller_->delegate()->NotifyNavigationStateChanged(
302 INVALIDATE_TYPE_TITLE); 302 INVALIDATE_TYPE_TITLE);
303 } 303 }
304 304
305 InterstitialPageMap::iterator iter = 305 InterstitialPageMap::iterator iter =
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 472
473 WebPreferences InterstitialPageImpl::GetWebkitPrefs() { 473 WebPreferences InterstitialPageImpl::GetWebkitPrefs() {
474 if (!enabled()) 474 if (!enabled())
475 return WebPreferences(); 475 return WebPreferences();
476 476
477 return render_view_host_->GetWebkitPrefs(url_); 477 return render_view_host_->GetWebkitPrefs(url_);
478 } 478 }
479 479
480 void InterstitialPageImpl::RenderWidgetDeleted( 480 void InterstitialPageImpl::RenderWidgetDeleted(
481 RenderWidgetHostImpl* render_widget_host) { 481 RenderWidgetHostImpl* render_widget_host) {
482 delete this; 482 // TODO(creis): Remove this method once we verify the shutdown path is sane.
483 CHECK(!web_contents_);
483 } 484 }
484 485
485 bool InterstitialPageImpl::PreHandleKeyboardEvent( 486 bool InterstitialPageImpl::PreHandleKeyboardEvent(
486 const NativeWebKeyboardEvent& event, 487 const NativeWebKeyboardEvent& event,
487 bool* is_keyboard_shortcut) { 488 bool* is_keyboard_shortcut) {
488 if (!enabled()) 489 if (!enabled())
489 return false; 490 return false;
490 return render_widget_host_delegate_->PreHandleKeyboardEvent( 491 return render_widget_host_delegate_->PreHandleKeyboardEvent(
491 event, is_keyboard_shortcut); 492 event, is_keyboard_shortcut);
492 } 493 }
(...skipping 24 matching lines...) Expand all
517 BrowserContext* browser_context = web_contents()->GetBrowserContext(); 518 BrowserContext* browser_context = web_contents()->GetBrowserContext();
518 scoped_refptr<SiteInstance> site_instance = 519 scoped_refptr<SiteInstance> site_instance =
519 SiteInstance::Create(browser_context); 520 SiteInstance::Create(browser_context);
520 DOMStorageContextWrapper* dom_storage_context = 521 DOMStorageContextWrapper* dom_storage_context =
521 static_cast<DOMStorageContextWrapper*>( 522 static_cast<DOMStorageContextWrapper*>(
522 BrowserContext::GetStoragePartition( 523 BrowserContext::GetStoragePartition(
523 browser_context, site_instance.get())->GetDOMStorageContext()); 524 browser_context, site_instance.get())->GetDOMStorageContext());
524 session_storage_namespace_ = 525 session_storage_namespace_ =
525 new SessionStorageNamespaceImpl(dom_storage_context); 526 new SessionStorageNamespaceImpl(dom_storage_context);
526 527
527 return RenderViewHostFactory::Create(site_instance.get(), 528 // Use the RenderViewHost from our FrameTree.
528 this, 529 frame_tree_.root()->render_manager()->Init(
529 this, 530 browser_context, site_instance.get(), MSG_ROUTING_NONE, MSG_ROUTING_NONE);
530 this, 531 return frame_tree_.root()->current_frame_host()->render_view_host();
531 MSG_ROUTING_NONE,
532 MSG_ROUTING_NONE,
533 false,
534 false);
535 } 532 }
536 533
537 WebContentsView* InterstitialPageImpl::CreateWebContentsView() { 534 WebContentsView* InterstitialPageImpl::CreateWebContentsView() {
538 if (!enabled() || !create_view_) 535 if (!enabled() || !create_view_)
539 return NULL; 536 return NULL;
540 WebContentsView* web_contents_view = web_contents()->GetView(); 537 WebContentsView* web_contents_view = web_contents()->GetView();
541 WebContentsViewPort* web_contents_view_port = 538 WebContentsViewPort* web_contents_view_port =
542 static_cast<WebContentsViewPort*>(web_contents_view); 539 static_cast<WebContentsViewPort*>(web_contents_view);
543 RenderWidgetHostView* view = 540 RenderWidgetHostView* view =
544 web_contents_view_port->CreateViewForWidget(render_view_host_); 541 web_contents_view_port->CreateViewForWidget(render_view_host_);
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 } 739 }
743 740
744 FrameTree* InterstitialPageImpl::GetFrameTree() { 741 FrameTree* InterstitialPageImpl::GetFrameTree() {
745 return &frame_tree_; 742 return &frame_tree_;
746 } 743 }
747 744
748 void InterstitialPageImpl::Disable() { 745 void InterstitialPageImpl::Disable() {
749 enabled_ = false; 746 enabled_ = false;
750 } 747 }
751 748
752 void InterstitialPageImpl::Shutdown(RenderViewHostImpl* render_view_host) { 749 void InterstitialPageImpl::Shutdown() {
753 render_view_host->Shutdown(); 750 delete this;
754 // We are deleted now.
755 } 751 }
756 752
757 void InterstitialPageImpl::OnNavigatingAwayOrTabClosing() { 753 void InterstitialPageImpl::OnNavigatingAwayOrTabClosing() {
758 if (action_taken_ == NO_ACTION) { 754 if (action_taken_ == NO_ACTION) {
759 // We are navigating away from the interstitial or closing a tab with an 755 // We are navigating away from the interstitial or closing a tab with an
760 // interstitial. Default to DontProceed(). We don't just call Hide as 756 // interstitial. Default to DontProceed(). We don't just call Hide as
761 // subclasses will almost certainly override DontProceed to do some work 757 // subclasses will almost certainly override DontProceed to do some work
762 // (ex: close pending connections). 758 // (ex: close pending connections).
763 DontProceed(); 759 DontProceed();
764 } else { 760 } else {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 843
848 web_contents->GetDelegateView()->TakeFocus(reverse); 844 web_contents->GetDelegateView()->TakeFocus(reverse);
849 } 845 }
850 846
851 void InterstitialPageImpl::InterstitialPageRVHDelegateView::OnFindReply( 847 void InterstitialPageImpl::InterstitialPageRVHDelegateView::OnFindReply(
852 int request_id, int number_of_matches, const gfx::Rect& selection_rect, 848 int request_id, int number_of_matches, const gfx::Rect& selection_rect,
853 int active_match_ordinal, bool final_update) { 849 int active_match_ordinal, bool final_update) {
854 } 850 }
855 851
856 } // namespace content 852 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698