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

Unified Diff: chrome/browser/ui/webui/print_preview_handler.cc

Issue 8136027: Print Preview: Make print preview tab modal. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix print to pdf for window.print Created 9 years, 2 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
« no previous file with comments | « chrome/browser/ui/webui/print_preview_handler.h ('k') | chrome/browser/ui/webui/print_preview_ui.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/print_preview_handler.cc
===================================================================
--- chrome/browser/ui/webui/print_preview_handler.cc (revision 105575)
+++ chrome/browser/ui/webui/print_preview_handler.cc (working copy)
@@ -21,9 +21,7 @@
#include "base/threading/thread_restrictions.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
-#include "chrome/browser/browser_process.h"
#include "chrome/browser/platform_util.h"
-#include "chrome/browser/printing/background_printing_manager.h"
#include "chrome/browser/printing/cloud_print/cloud_print_url.h"
#include "chrome/browser/printing/print_dialog_cloud.h"
#include "chrome/browser/printing/print_job_manager.h"
@@ -31,8 +29,6 @@
#include "chrome/browser/printing/print_system_task_proxy.h"
#include "chrome/browser/printing/print_view_manager.h"
#include "chrome/browser/printing/printer_manager_dialog.h"
-#include "chrome/browser/sessions/restore_tab_helper.h"
-#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/webui/cloud_print_signin_dialog.h"
@@ -62,7 +58,7 @@
FALLBACK_TO_ADVANCED_SETTINGS_DIALOG,
PREVIEW_FAILED,
PREVIEW_STARTED,
- INITIATOR_TAB_CRASHED,
+ INITIATOR_TAB_CRASHED, // UNUSED
INITIATOR_TAB_CLOSED,
PRINT_WITH_CLOUD_PRINT,
USERACTION_BUCKET_BOUNDARY
@@ -157,10 +153,6 @@
}
}
-printing::BackgroundPrintingManager* GetBackgroundPrintingManager() {
- return g_browser_process->background_printing_manager();
-}
-
} // namespace
// A Task implementation that stores a PDF file on disk.
@@ -240,9 +232,6 @@
web_ui_->RegisterMessageCallback("manageLocalPrinters",
base::Bind(&PrintPreviewHandler::HandleManagePrinters,
base::Unretained(this)));
- web_ui_->RegisterMessageCallback("reloadCrashedInitiatorTab",
- base::Bind(&PrintPreviewHandler::HandleReloadCrashedInitiatorTab,
- base::Unretained(this)));
web_ui_->RegisterMessageCallback("closePrintPreviewTab",
base::Bind(&PrintPreviewHandler::HandleClosePreviewTab,
base::Unretained(this)));
@@ -312,7 +301,7 @@
TabContentsWrapper* initiator_tab = GetInitiatorTab();
if (!initiator_tab) {
ReportUserActionHistogram(INITIATOR_TAB_CLOSED);
- print_preview_ui->OnInitiatorTabClosed();
+ print_preview_ui->OnClosePrintPreviewTab();
return;
}
@@ -407,7 +396,8 @@
// This tries to activate the initiator tab as well, so do not clear the
// association with the initiator tab yet.
- HidePreviewTab();
+ PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_);
+ print_preview_ui->OnHidePreviewTab();
// Do this so the initiator tab can open a new print preview tab.
ClearInitiatorTabDetails();
@@ -417,6 +407,8 @@
settings->Remove(printing::kSettingPageRange, NULL);
RenderViewHost* rvh = web_ui_->tab_contents()->render_view_host();
rvh->Send(new PrintMsg_PrintForPrintPreview(rvh->routing_id(), *settings));
+ if (initiator_tab)
+ initiator_tab->print_view_manager()->PrintPreviewDone();
kmadhusu 2011/10/14 22:48:13 How do you exit the nested loop in other cases?
Lei Zhang 2011/10/14 23:22:07 The other cases all close the print preview dialog
}
}
@@ -451,7 +443,8 @@
}
void PrintPreviewHandler::HandleHidePreview(const ListValue* /*args*/) {
- HidePreviewTab();
+ PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_);
+ print_preview_ui->OnHidePreviewTab();
}
void PrintPreviewHandler::HandleCancelPendingPrintRequest(
@@ -562,21 +555,6 @@
printing::PrinterManagerDialog::ShowPrinterManagerDialog();
}
-void PrintPreviewHandler::HandleReloadCrashedInitiatorTab(
- const ListValue* /*args*/) {
- ReportStats();
- ReportUserActionHistogram(INITIATOR_TAB_CRASHED);
-
- TabContentsWrapper* initiator_tab = GetInitiatorTab();
- if (!initiator_tab)
- return;
-
- TabContents* contents = initiator_tab->tab_contents();
- contents->OpenURL(contents->GetURL(), GURL(), CURRENT_TAB,
- content::PAGE_TRANSITION_RELOAD);
- ActivateInitiatorTabAndClosePreviewTab();
-}
-
void PrintPreviewHandler::HandleClosePreviewTab(const ListValue* /*args*/) {
ReportStats();
ReportUserActionHistogram(CANCEL);
@@ -585,8 +563,6 @@
// before cancelling.
UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforeCancel",
regenerate_preview_request_count_);
-
- ActivateInitiatorTabAndClosePreviewTab();
}
void PrintPreviewHandler::ReportStats() {
@@ -607,7 +583,8 @@
static_cast<RenderViewHostDelegate*>(
initiator_tab->tab_contents())->Activate();
}
- ClosePrintPreviewTab();
+ PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_);
+ print_preview_ui->OnClosePrintPreviewTab();
}
void PrintPreviewHandler::SendPrinterCapabilities(
@@ -703,25 +680,6 @@
return tab_controller->GetInitiatorTab(preview_tab_wrapper());
}
-void PrintPreviewHandler::ClosePrintPreviewTab() {
- TabContentsWrapper* tab =
- TabContentsWrapper::GetCurrentWrapperForContents(preview_tab());
- if (!tab)
- return;
- Browser* preview_tab_browser = BrowserList::FindBrowserWithID(
- tab->restore_tab_helper()->window_id().id());
- if (!preview_tab_browser)
- return;
- TabStripModel* tabstrip = preview_tab_browser->tabstrip_model();
- int index = tabstrip->GetIndexOfTabContents(tab);
- if (index == TabStripModel::kNoTab)
- return;
-
- // Keep print preview tab out of the recently closed tab list, because
- // re-opening that page will just display a non-functional print preview page.
- tabstrip->CloseTabContentsAt(index, TabStripModel::CLOSE_NONE);
-}
-
void PrintPreviewHandler::OnPrintDialogShown() {
ActivateInitiatorTabAndClosePreviewTab();
}
@@ -810,12 +768,6 @@
print_preview_ui->OnFileSelectionCancelled();
}
-void PrintPreviewHandler::HidePreviewTab() {
- if (GetBackgroundPrintingManager()->HasPrintPreviewTab(preview_tab_wrapper()))
- return;
- GetBackgroundPrintingManager()->OwnPrintPreviewTab(preview_tab_wrapper());
-}
-
void PrintPreviewHandler::ClearInitiatorTabDetails() {
TabContentsWrapper* initiator_tab = GetInitiatorTab();
if (!initiator_tab)
« no previous file with comments | « chrome/browser/ui/webui/print_preview_handler.h ('k') | chrome/browser/ui/webui/print_preview_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698