| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #if !defined(OS_CHROMEOS) | 10 #if !defined(OS_CHROMEOS) |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 FilePath::StringType print_job_title = UTF16ToUTF8(print_job_title_utf16); | 572 FilePath::StringType print_job_title = UTF16ToUTF8(print_job_title_utf16); |
| 573 #endif | 573 #endif |
| 574 | 574 |
| 575 file_util::ReplaceIllegalCharactersInPath(&print_job_title, '_'); | 575 file_util::ReplaceIllegalCharactersInPath(&print_job_title, '_'); |
| 576 FilePath default_filename(print_job_title); | 576 FilePath default_filename(print_job_title); |
| 577 default_filename = | 577 default_filename = |
| 578 default_filename.ReplaceExtension(FILE_PATH_LITERAL("pdf")); | 578 default_filename.ReplaceExtension(FILE_PATH_LITERAL("pdf")); |
| 579 | 579 |
| 580 SelectFile(default_filename); | 580 SelectFile(default_filename); |
| 581 } else { | 581 } else { |
| 582 ClearInitiatorTabDetails(); | |
| 583 ReportPrintSettingsStats(*settings); | 582 ReportPrintSettingsStats(*settings); |
| 584 ReportUserActionHistogram(PRINT_TO_PRINTER); | 583 ReportUserActionHistogram(PRINT_TO_PRINTER); |
| 585 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPrinter", | 584 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPrinter", |
| 586 GetPageCountFromSettingsDictionary(*settings)); | 585 GetPageCountFromSettingsDictionary(*settings)); |
| 587 | 586 |
| 587 // This tries to activate the initiator tab as well, so do not clear the |
| 588 // association with the initiator tab yet. |
| 588 HidePreviewTab(); | 589 HidePreviewTab(); |
| 589 | 590 |
| 591 // Do this so the initiator tab can open a new print preview tab. |
| 592 ClearInitiatorTabDetails(); |
| 593 |
| 590 // The PDF being printed contains only the pages that the user selected, | 594 // The PDF being printed contains only the pages that the user selected, |
| 591 // so ignore the page range and print all pages. | 595 // so ignore the page range and print all pages. |
| 592 settings->Remove(printing::kSettingPageRange, NULL); | 596 settings->Remove(printing::kSettingPageRange, NULL); |
| 593 RenderViewHost* rvh = web_ui_->tab_contents()->render_view_host(); | 597 RenderViewHost* rvh = web_ui_->tab_contents()->render_view_host(); |
| 594 rvh->Send(new PrintMsg_PrintForPrintPreview(rvh->routing_id(), *settings)); | 598 rvh->Send(new PrintMsg_PrintForPrintPreview(rvh->routing_id(), *settings)); |
| 595 } | 599 } |
| 596 } | 600 } |
| 597 | 601 |
| 598 void PrintPreviewHandler::HandleHidePreview(const ListValue*) { | 602 void PrintPreviewHandler::HandleHidePreview(const ListValue*) { |
| 599 HidePreviewTab(); | 603 HidePreviewTab(); |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 return; | 945 return; |
| 942 | 946 |
| 943 // We no longer require the initiator tab details. Remove those details | 947 // We no longer require the initiator tab details. Remove those details |
| 944 // associated with the preview tab to allow the initiator tab to create | 948 // associated with the preview tab to allow the initiator tab to create |
| 945 // another preview tab. | 949 // another preview tab. |
| 946 printing::PrintPreviewTabController* tab_controller = | 950 printing::PrintPreviewTabController* tab_controller = |
| 947 printing::PrintPreviewTabController::GetInstance(); | 951 printing::PrintPreviewTabController::GetInstance(); |
| 948 if (tab_controller) | 952 if (tab_controller) |
| 949 tab_controller->EraseInitiatorTabInfo(preview_tab()); | 953 tab_controller->EraseInitiatorTabInfo(preview_tab()); |
| 950 } | 954 } |
| OLD | NEW |