OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/webui/print_preview/print_preview_ui.h" | 5 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 void PrintPreviewUI::OnPrintPreviewDialogClosed() { | 526 void PrintPreviewUI::OnPrintPreviewDialogClosed() { |
527 WebContents* preview_dialog = web_ui()->GetWebContents(); | 527 WebContents* preview_dialog = web_ui()->GetWebContents(); |
528 printing::BackgroundPrintingManager* background_printing_manager = | 528 printing::BackgroundPrintingManager* background_printing_manager = |
529 g_browser_process->background_printing_manager(); | 529 g_browser_process->background_printing_manager(); |
530 if (background_printing_manager->HasPrintPreviewDialog(preview_dialog)) | 530 if (background_printing_manager->HasPrintPreviewDialog(preview_dialog)) |
531 return; | 531 return; |
532 OnClosePrintPreviewDialog(); | 532 OnClosePrintPreviewDialog(); |
533 } | 533 } |
534 | 534 |
535 void PrintPreviewUI::OnInitiatorClosed() { | 535 void PrintPreviewUI::OnInitiatorClosed() { |
| 536 // Should only get here if the initiator was still tracked by the Print |
| 537 // Preview Dialog Controller, so the print job has not yet been sent. |
536 WebContents* preview_dialog = web_ui()->GetWebContents(); | 538 WebContents* preview_dialog = web_ui()->GetWebContents(); |
537 printing::BackgroundPrintingManager* background_printing_manager = | 539 printing::BackgroundPrintingManager* background_printing_manager = |
538 g_browser_process->background_printing_manager(); | 540 g_browser_process->background_printing_manager(); |
539 if (background_printing_manager->HasPrintPreviewDialog(preview_dialog)) | 541 if (background_printing_manager->HasPrintPreviewDialog(preview_dialog)) { |
540 web_ui()->CallJavascriptFunctionUnsafe("cancelPendingPrintRequest"); | 542 // Dialog is hidden but is still generating the preview. Cancel the print |
541 else | 543 // request as it can't be completed. |
| 544 background_printing_manager->OnPrintRequestCancelled(preview_dialog); |
| 545 handler_->OnPrintRequestCancelled(); |
| 546 } else { |
| 547 // Initiator was closed while print preview dialog was still open. |
542 OnClosePrintPreviewDialog(); | 548 OnClosePrintPreviewDialog(); |
| 549 } |
543 } | 550 } |
544 | 551 |
545 void PrintPreviewUI::OnPrintPreviewCancelled() { | 552 void PrintPreviewUI::OnPrintPreviewCancelled() { |
546 handler_->OnPrintPreviewCancelled(); | 553 handler_->OnPrintPreviewCancelled(); |
547 } | 554 } |
548 | 555 |
549 void PrintPreviewUI::OnPrintPreviewRequest(int request_id) { | 556 void PrintPreviewUI::OnPrintPreviewRequest(int request_id) { |
550 if (!initial_preview_start_time_.is_null()) { | 557 if (!initial_preview_start_time_.is_null()) { |
551 UMA_HISTOGRAM_TIMES("PrintPreview.InitializationTime", | 558 UMA_HISTOGRAM_TIMES("PrintPreview.InitializationTime", |
552 base::TimeTicks::Now() - initial_preview_start_time_); | 559 base::TimeTicks::Now() - initial_preview_start_time_); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 } | 676 } |
670 | 677 |
671 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) { | 678 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) { |
672 handler_->FileSelected(path, 0, NULL); | 679 handler_->FileSelected(path, 0, NULL); |
673 } | 680 } |
674 | 681 |
675 void PrintPreviewUI::SetPdfSavedClosureForTesting( | 682 void PrintPreviewUI::SetPdfSavedClosureForTesting( |
676 const base::Closure& closure) { | 683 const base::Closure& closure) { |
677 handler_->SetPdfSavedClosureForTesting(closure); | 684 handler_->SetPdfSavedClosureForTesting(closure); |
678 } | 685 } |
OLD | NEW |