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

Unified Diff: chrome/browser/printing/print_preview_tab_controller.cc

Issue 7574002: Be able to print items that do window.print(); window.close() (airline tix e.g.) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Lei's comments. Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
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 eec05e538bc0d4fad3323a4a9afca7ac6439c0dd..ef6f43eb76fe73571b29c2db9414a756447bbc23 100644
--- a/chrome/browser/printing/print_preview_tab_controller.cc
+++ b/chrome/browser/printing/print_preview_tab_controller.cc
@@ -9,6 +9,7 @@
#include "base/command_line.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/printing/background_printing_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/tabs/tab_strip_model.h"
@@ -162,9 +163,17 @@ void PrintPreviewTabController::OnRendererProcessClosed(
RenderProcessHost* rph) {
for (PrintPreviewTabMap::iterator iter = preview_tab_map_.begin();
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;
+ if (initiator_tab != NULL &&
+ initiator_tab->render_view_host()->process() == rph) {
+ // Release the initiator tab contents, possibly deleting if owned.
+ 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();
@@ -178,11 +187,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()) {
@@ -191,6 +195,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 +262,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;

Powered by Google App Engine
This is Rietveld 408576698