| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_handler.h" | 5 #include "chrome/browser/ui/webui/print_preview_handler.h" |
| 6 | 6 |
| 7 #include <ctype.h> | 7 #include <ctype.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 if (last_used_margins_type_ == printing::CUSTOM_MARGINS) { | 394 if (last_used_margins_type_ == printing::CUSTOM_MARGINS) { |
| 395 if (!last_used_page_size_margins_) | 395 if (!last_used_page_size_margins_) |
| 396 last_used_page_size_margins_ = new printing::PageSizeMargins(); | 396 last_used_page_size_margins_ = new printing::PageSizeMargins(); |
| 397 GetCustomMarginsFromJobSettings(*settings, last_used_page_size_margins_); | 397 GetCustomMarginsFromJobSettings(*settings, last_used_page_size_margins_); |
| 398 } | 398 } |
| 399 } | 399 } |
| 400 | 400 |
| 401 bool print_to_pdf = false; | 401 bool print_to_pdf = false; |
| 402 settings->GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf); | 402 settings->GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf); |
| 403 | 403 |
| 404 bool open_pdf_in_preview = false; |
| 405 #if defined(OS_MACOSX) |
| 406 open_pdf_in_preview = settings->HasKey(printing::kSettingOpenPDFInPreview); |
| 407 #endif |
| 408 |
| 404 settings->SetBoolean(printing::kSettingHeaderFooterEnabled, false); | 409 settings->SetBoolean(printing::kSettingHeaderFooterEnabled, false); |
| 405 | 410 |
| 406 bool is_cloud_printer = settings->HasKey(printing::kSettingCloudPrintId); | 411 bool is_cloud_printer = settings->HasKey(printing::kSettingCloudPrintId); |
| 407 bool is_cloud_dialog = false; | 412 bool is_cloud_dialog = false; |
| 408 settings->GetBoolean(printing::kSettingCloudPrintDialog, &is_cloud_dialog); | 413 settings->GetBoolean(printing::kSettingCloudPrintDialog, &is_cloud_dialog); |
| 409 if (is_cloud_printer) { | 414 if (is_cloud_printer && !open_pdf_in_preview) { |
| 410 std::string print_ticket; | 415 std::string print_ticket; |
| 411 args->GetString(1, &print_ticket); | 416 args->GetString(1, &print_ticket); |
| 412 SendCloudPrintJob(*settings, print_ticket); | 417 SendCloudPrintJob(*settings, print_ticket); |
| 413 } else if (print_to_pdf) { | 418 } else if (print_to_pdf && !open_pdf_in_preview) { |
| 414 HandlePrintToPdf(*settings); | 419 HandlePrintToPdf(*settings); |
| 415 } else if (is_cloud_dialog) { | 420 } else if (is_cloud_dialog && !open_pdf_in_preview) { |
| 416 HandlePrintWithCloudPrint(); | 421 HandlePrintWithCloudPrint(); |
| 417 } else { | 422 } else { |
| 418 ReportPrintSettingsStats(*settings); | 423 ReportPrintSettingsStats(*settings); |
| 419 ReportUserActionHistogram(PRINT_TO_PRINTER); | 424 ReportUserActionHistogram(PRINT_TO_PRINTER); |
| 420 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPrinter", | 425 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPrinter", |
| 421 GetPageCountFromSettingsDictionary(*settings)); | 426 GetPageCountFromSettingsDictionary(*settings)); |
| 422 | 427 |
| 423 // This tries to activate the initiator tab as well, so do not clear the | 428 // This tries to activate the initiator tab as well, so do not clear the |
| 424 // association with the initiator tab yet. | 429 // association with the initiator tab yet. |
| 425 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_); | 430 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_); |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 return; | 854 return; |
| 850 | 855 |
| 851 // We no longer require the initiator tab details. Remove those details | 856 // We no longer require the initiator tab details. Remove those details |
| 852 // associated with the preview tab to allow the initiator tab to create | 857 // associated with the preview tab to allow the initiator tab to create |
| 853 // another preview tab. | 858 // another preview tab. |
| 854 printing::PrintPreviewTabController* tab_controller = | 859 printing::PrintPreviewTabController* tab_controller = |
| 855 printing::PrintPreviewTabController::GetInstance(); | 860 printing::PrintPreviewTabController::GetInstance(); |
| 856 if (tab_controller) | 861 if (tab_controller) |
| 857 tab_controller->EraseInitiatorTabInfo(preview_tab_wrapper()); | 862 tab_controller->EraseInitiatorTabInfo(preview_tab_wrapper()); |
| 858 } | 863 } |
| OLD | NEW |