Chromium Code Reviews| Index: chrome/browser/printing/print_preview_tab_controller.cc |
| diff --git a/chrome/browser/printing/print_preview_tab_controller.cc b/chrome/browser/printing/print_preview_tab_controller.cc |
| index 365f51e6ccd3a45a9295dda2cf94674b050f6690..55545d335f39bf7c8e947724ba183ea0ccf3da46 100644 |
| --- a/chrome/browser/printing/print_preview_tab_controller.cc |
| +++ b/chrome/browser/printing/print_preview_tab_controller.cc |
| @@ -10,6 +10,7 @@ |
| #include "base/utf_string_conversions.h" |
| #include "chrome/browser/browser_process.h" |
| #include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/printing/background_printing_manager.h" |
|
Lei Zhang
2011/08/26 10:01:54
nit: alphabetical order
Sheridan Rawlins
2011/08/26 23:45:39
Done.
|
| #include "chrome/browser/sessions/restore_tab_helper.h" |
| #include "chrome/browser/tabs/tab_strip_model.h" |
| #include "chrome/browser/ui/browser.h" |
| @@ -158,7 +159,16 @@ void PrintPreviewTabController::OnRendererProcessClosed( |
| iter != preview_tab_map_.end(); ++iter) { |
| if (iter->second != NULL && |
| iter->second->render_view_host()->process() == rph) { |
| - TabContents* preview_tab = GetPrintPreviewForTab(iter->second); |
| + TabContents* initiator_tab = iter->second; |
|
Lei Zhang
2011/08/26 10:01:54
move this up to between line 159/160 and then you
Sheridan Rawlins
2011/08/26 23:45:39
Done.
|
| + // Release the initiator tab contents, possibly deleting if owned. |
| + if (initiator_tab) { |
|
Lei Zhang
2011/08/26 10:01:54
this will always be true, we already tested this c
Sheridan Rawlins
2011/08/26 23:45:39
Yeah, the previous comment made this obvious :)
D
|
| + RemoveObservers(initiator_tab); |
| + TabContentsWrapper* initiator_wrapper = |
| + TabContentsWrapper::GetCurrentWrapperForContents(initiator_tab); |
| + g_browser_process->background_printing_manager()-> |
| + ReleaseInitiatorTabContents(initiator_wrapper); |
| + } |
| + TabContents* preview_tab = GetPrintPreviewForTab(initiator_tab); |
| PrintPreviewUI* print_preview_ui = |
| static_cast<PrintPreviewUI*>(preview_tab->web_ui()); |
| print_preview_ui->OnInitiatorTabCrashed(); |
| @@ -172,11 +182,6 @@ void PrintPreviewTabController::OnTabContentsDestroyed(TabContents* tab) { |
| return; |
| if (tab == preview_tab) { |
| - // Remove the initiator tab's observers before erasing the mapping. |
| - TabContents* initiator_tab = GetInitiatorTab(tab); |
| - if (initiator_tab) |
| - RemoveObservers(initiator_tab); |
| - |
| // Print preview tab contents are destroyed. Notify |PrintPreviewUI| to |
| // abort the initiator tab preview request. |
| if (IsPrintPreviewTab(tab) && tab->web_ui()) { |
| @@ -185,6 +190,16 @@ void PrintPreviewTabController::OnTabContentsDestroyed(TabContents* tab) { |
| print_preview_ui->OnTabDestroyed(); |
| } |
| + // Remove the initiator tab's observers before erasing the mapping. Also |
| + // release the initiator tab contents, possibly deleting if owned. |
| + TabContents* initiator_tab = GetInitiatorTab(tab); |
| + if (initiator_tab) { |
| + RemoveObservers(initiator_tab); |
| + TabContentsWrapper* initiator_wrapper = |
| + TabContentsWrapper::GetCurrentWrapperForContents(initiator_tab); |
| + g_browser_process->background_printing_manager()-> |
| + ReleaseInitiatorTabContents(initiator_wrapper); |
| + } |
| // Erase the map entry. |
| preview_tab_map_.erase(tab); |
| } else { |
| @@ -248,8 +263,13 @@ void PrintPreviewTabController::OnNavEntryCommitted( |
| if (source_tab_is_preview_tab) { |
| // Remove the initiator tab's observers before erasing the mapping. |
| TabContents* initiator_tab = GetInitiatorTab(tab); |
| - if (initiator_tab) |
| + if (initiator_tab) { |
| RemoveObservers(initiator_tab); |
| + TabContentsWrapper* initiator_wrapper = |
| + TabContentsWrapper::GetCurrentWrapperForContents(initiator_tab); |
| + g_browser_process->background_printing_manager()-> |
| + ReleaseInitiatorTabContents(initiator_wrapper); |
| + } |
| preview_tab_map_.erase(tab); |
| } else { |
| preview_tab_map_[preview_tab] = NULL; |