OLD | NEW |
---|---|
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/renderer_host/render_view_host_manager.h" | 5 #include "chrome/browser/renderer_host/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 14 matching lines...) Expand all Loading... | |
25 } | 25 } |
26 | 26 |
27 RenderViewHostManager::RenderViewHostManager( | 27 RenderViewHostManager::RenderViewHostManager( |
28 RenderViewHostDelegate* render_view_delegate, | 28 RenderViewHostDelegate* render_view_delegate, |
29 Delegate* delegate) | 29 Delegate* delegate) |
30 : delegate_(delegate), | 30 : delegate_(delegate), |
31 cross_navigation_pending_(false), | 31 cross_navigation_pending_(false), |
32 render_view_delegate_(render_view_delegate), | 32 render_view_delegate_(render_view_delegate), |
33 render_view_host_(NULL), | 33 render_view_host_(NULL), |
34 pending_render_view_host_(NULL), | 34 pending_render_view_host_(NULL), |
35 pending_renderer_aborted_(false), | |
35 interstitial_page_(NULL) { | 36 interstitial_page_(NULL) { |
36 registrar_.Add(this, NotificationType::RENDER_VIEW_HOST_DELETED, | 37 registrar_.Add(this, NotificationType::RENDER_VIEW_HOST_DELETED, |
37 NotificationService::AllSources()); | 38 NotificationService::AllSources()); |
38 } | 39 } |
39 | 40 |
40 RenderViewHostManager::~RenderViewHostManager() { | 41 RenderViewHostManager::~RenderViewHostManager() { |
41 if (pending_render_view_host_) | 42 if (pending_render_view_host_) |
42 CancelPending(); | 43 CancelPending(); |
43 | 44 |
44 // We should always have a main RenderViewHost. | 45 // We should always have a main RenderViewHost. |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 // We used to cancel the pending renderer here for cross-site downloads. | 208 // We used to cancel the pending renderer here for cross-site downloads. |
208 // However, it's not safe to do that because the download logic repeatedly | 209 // However, it's not safe to do that because the download logic repeatedly |
209 // looks for this TabContents based on a render view ID. Instead, we just | 210 // looks for this TabContents based on a render view ID. Instead, we just |
210 // leave the pending renderer around until the next navigation event | 211 // leave the pending renderer around until the next navigation event |
211 // (Navigate, DidNavigate, etc), which will clean it up properly. | 212 // (Navigate, DidNavigate, etc), which will clean it up properly. |
212 // TODO(creis): All of this will go away when we move the cross-site logic | 213 // TODO(creis): All of this will go away when we move the cross-site logic |
213 // to ResourceDispatcherHost, so that we intercept responses rather than | 214 // to ResourceDispatcherHost, so that we intercept responses rather than |
214 // navigation events. (That's necessary to support onunload anyway.) Once | 215 // navigation events. (That's necessary to support onunload anyway.) Once |
215 // we've made that change, we won't create a pending renderer until we know | 216 // we've made that change, we won't create a pending renderer until we know |
216 // the response is not a download. | 217 // the response is not a download. |
218 | |
219 // There is one instance where we must be able to pre-emptively clean up a | |
220 // pending renderer: If a cross-site download is initiated from a chrome:// | |
221 // url, and the browser then wants to close. | |
222 if (pending_render_view_host_) { | |
brettw
2009/07/01 15:25:22
Don't add {} here since you didn't below (and the
| |
223 pending_renderer_aborted_ = true; | |
224 } | |
217 } | 225 } |
218 | 226 |
219 void RenderViewHostManager::ShouldClosePage(bool proceed) { | 227 void RenderViewHostManager::ShouldClosePage(bool proceed) { |
220 // Should only see this while we have a pending renderer. Otherwise, we | 228 // Should only see this while we have a pending renderer. Otherwise, we |
221 // should ignore. | 229 // should ignore. |
230 if (pending_render_view_host_ && pending_renderer_aborted_) | |
231 CancelPending(); | |
232 | |
222 if (!pending_render_view_host_) { | 233 if (!pending_render_view_host_) { |
223 bool proceed_to_fire_unload; | 234 bool proceed_to_fire_unload; |
224 delegate_->BeforeUnloadFiredFromRenderManager(proceed, | 235 delegate_->BeforeUnloadFiredFromRenderManager(proceed, |
225 &proceed_to_fire_unload); | 236 &proceed_to_fire_unload); |
226 | 237 |
227 if (proceed_to_fire_unload) { | 238 if (proceed_to_fire_unload) { |
228 // This is not a cross-site navigation, the tab is being closed. | 239 // This is not a cross-site navigation, the tab is being closed. |
229 render_view_host_->FirePageUnload(); | 240 render_view_host_->FirePageUnload(); |
230 } | 241 } |
231 return; | 242 return; |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
573 // 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 |
574 // cross navigating. | 585 // cross navigating. |
575 DCHECK(!cross_navigation_pending_); | 586 DCHECK(!cross_navigation_pending_); |
576 return render_view_host_; | 587 return render_view_host_; |
577 } | 588 } |
578 | 589 |
579 void RenderViewHostManager::CancelPending() { | 590 void RenderViewHostManager::CancelPending() { |
580 RenderViewHost* pending_render_view_host = pending_render_view_host_; | 591 RenderViewHost* pending_render_view_host = pending_render_view_host_; |
581 pending_render_view_host_ = NULL; | 592 pending_render_view_host_ = NULL; |
582 pending_render_view_host->Shutdown(); | 593 pending_render_view_host->Shutdown(); |
583 | 594 pending_renderer_aborted_ = false; |
584 pending_dom_ui_.reset(); | 595 pending_dom_ui_.reset(); |
585 } | 596 } |
586 | 597 |
587 void RenderViewHostManager::CrossSiteNavigationCanceled() { | 598 void RenderViewHostManager::CrossSiteNavigationCanceled() { |
588 DCHECK(cross_navigation_pending_); | 599 DCHECK(cross_navigation_pending_); |
589 cross_navigation_pending_ = false; | 600 cross_navigation_pending_ = false; |
590 if (pending_render_view_host_) | 601 if (pending_render_view_host_) |
591 CancelPending(); | 602 CancelPending(); |
592 } | 603 } |
OLD | NEW |