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

Side by Side Diff: chrome/browser/tab_contents/render_view_host_manager.cc

Issue 159426: Reverting 21683. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/browser/tab_contents/render_view_host_manager.h" 5 #include "chrome/browser/tab_contents/render_view_host_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/browser/dom_ui/dom_ui.h" 9 #include "chrome/browser/dom_ui/dom_ui.h"
10 #include "chrome/browser/dom_ui/dom_ui_factory.h" 10 #include "chrome/browser/dom_ui/dom_ui_factory.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 IPC::Message* reply_msg, 204 IPC::Message* reply_msg,
205 bool success, 205 bool success,
206 const std::wstring& prompt) { 206 const std::wstring& prompt) {
207 render_view_host_->JavaScriptMessageBoxClosed(reply_msg, success, prompt); 207 render_view_host_->JavaScriptMessageBoxClosed(reply_msg, success, prompt);
208 } 208 }
209 209
210 void RenderViewHostManager::OnJavaScriptMessageBoxWindowDestroyed() { 210 void RenderViewHostManager::OnJavaScriptMessageBoxWindowDestroyed() {
211 render_view_host_->JavaScriptMessageBoxWindowDestroyed(); 211 render_view_host_->JavaScriptMessageBoxWindowDestroyed();
212 } 212 }
213 213
214 void RenderViewHostManager::ShouldClosePage(bool proceed) { 214 void RenderViewHostManager::ShouldClosePage(bool for_cross_site_transition,
215 // Should only see this while we have a pending renderer. Otherwise, we 215 bool proceed) {
216 // should ignore. 216 if (for_cross_site_transition) {
217 if (!pending_render_view_host_) { 217 if (proceed) {
218 // Ok to unload the current page, so proceed with the cross-site
219 // navigation. Note that if navigations are not currently suspended, it
220 // might be because the renderer was deemed unresponsive and this call was
221 // already made by ShouldCloseTabOnUnresponsiveRenderer. In that case, it
222 // is ok to do nothing here.
223 if (pending_render_view_host_->are_navigations_suspended())
224 pending_render_view_host_->SetNavigationsSuspended(false);
225 } else {
226 // Current page says to cancel.
227 CancelPending();
228 cross_navigation_pending_ = false;
229 }
230 } else {
231 // Non-cross site transition means closing the entire tab.
218 bool proceed_to_fire_unload; 232 bool proceed_to_fire_unload;
219 delegate_->BeforeUnloadFiredFromRenderManager(proceed, 233 delegate_->BeforeUnloadFiredFromRenderManager(proceed,
220 &proceed_to_fire_unload); 234 &proceed_to_fire_unload);
221 235
222 if (proceed_to_fire_unload) { 236 if (proceed_to_fire_unload) {
223 // This is not a cross-site navigation, the tab is being closed. 237 // This is not a cross-site navigation, the tab is being closed.
224 render_view_host_->ClosePage(true, -1, -1); 238 render_view_host_->ClosePage(false, -1, -1);
225 } 239 }
226 return;
227 }
228
229 if (proceed) {
230 // Ok to unload the current page, so proceed with the cross-site
231 // navigation. Note that if navigations are not currently suspended, it
232 // might be because the renderer was deemed unresponsive and this call was
233 // already made by ShouldCloseTabOnUnresponsiveRenderer. In that case, it
234 // is ok to do nothing here.
235 if (pending_render_view_host_->are_navigations_suspended())
236 pending_render_view_host_->SetNavigationsSuspended(false);
237 } else {
238 // Current page says to cancel.
239 CancelPending();
240 cross_navigation_pending_ = false;
241 } 240 }
242 } 241 }
243 242
244 void RenderViewHostManager::OnCrossSiteResponse(int new_render_process_host_id, 243 void RenderViewHostManager::OnCrossSiteResponse(int new_render_process_host_id,
245 int new_request_id) { 244 int new_request_id) {
246 // Should only see this while we have a pending renderer. 245 // Should only see this while we have a pending renderer.
247 if (!cross_navigation_pending_) 246 if (!cross_navigation_pending_)
248 return; 247 return;
249 DCHECK(pending_render_view_host_); 248 DCHECK(pending_render_view_host_);
250 249
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 // old page's onunload handler before it sends the response. 559 // old page's onunload handler before it sends the response.
561 pending_render_view_host_->SetHasPendingCrossSiteRequest(true, -1); 560 pending_render_view_host_->SetHasPendingCrossSiteRequest(true, -1);
562 561
563 // We now have a pending RVH. 562 // We now have a pending RVH.
564 DCHECK(!cross_navigation_pending_); 563 DCHECK(!cross_navigation_pending_);
565 cross_navigation_pending_ = true; 564 cross_navigation_pending_ = true;
566 565
567 // Tell the old render view to run its onbeforeunload handler, since it 566 // Tell the old render view to run its onbeforeunload handler, since it
568 // doesn't otherwise know that the cross-site request is happening. This 567 // doesn't otherwise know that the cross-site request is happening. This
569 // will trigger a call to ShouldClosePage with the reply. 568 // will trigger a call to ShouldClosePage with the reply.
570 render_view_host_->FirePageBeforeUnload(); 569 render_view_host_->FirePageBeforeUnload(true);
571 570
572 return pending_render_view_host_; 571 return pending_render_view_host_;
573 } else { 572 } else {
574 if (pending_dom_ui_.get() && render_view_host_->IsRenderViewLive()) 573 if (pending_dom_ui_.get() && render_view_host_->IsRenderViewLive())
575 pending_dom_ui_->RenderViewReused(render_view_host_); 574 pending_dom_ui_->RenderViewReused(render_view_host_);
576 575
577 // The renderer can exit view source mode when any error or cancellation 576 // The renderer can exit view source mode when any error or cancellation
578 // happen. We must overwrite to recover the mode. 577 // happen. We must overwrite to recover the mode.
579 if (entry.IsViewSourceMode()) { 578 if (entry.IsViewSourceMode()) {
580 render_view_host_->Send( 579 render_view_host_->Send(
581 new ViewMsg_EnableViewSourceMode(render_view_host_->routing_id())); 580 new ViewMsg_EnableViewSourceMode(render_view_host_->routing_id()));
582 } 581 }
583 } 582 }
584 583
585 // Same SiteInstance can be used. Navigate render_view_host_ if we are not 584 // Same SiteInstance can be used. Navigate render_view_host_ if we are not
586 // cross navigating. 585 // cross navigating.
587 DCHECK(!cross_navigation_pending_); 586 DCHECK(!cross_navigation_pending_);
588 return render_view_host_; 587 return render_view_host_;
589 } 588 }
590 589
591 void RenderViewHostManager::CancelPending() { 590 void RenderViewHostManager::CancelPending() {
592 RenderViewHost* pending_render_view_host = pending_render_view_host_; 591 RenderViewHost* pending_render_view_host = pending_render_view_host_;
593 pending_render_view_host_ = NULL; 592 pending_render_view_host_ = NULL;
594 pending_render_view_host->Shutdown(); 593 pending_render_view_host->Shutdown();
595 594
596 pending_dom_ui_.reset(); 595 pending_dom_ui_.reset();
597 } 596 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/render_view_host_manager.h ('k') | chrome/browser/tab_contents/tab_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698