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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 | 476 |
477 TabContents* initiator_tab = GetInitiatorTab(); | 477 TabContents* initiator_tab = GetInitiatorTab(); |
478 if (!initiator_tab) { | 478 if (!initiator_tab) { |
479 if (!reported_failed_preview_) { | 479 if (!reported_failed_preview_) { |
480 ReportUserActionHistogram(PREVIEW_FAILED); | 480 ReportUserActionHistogram(PREVIEW_FAILED); |
481 reported_failed_preview_ = true; | 481 reported_failed_preview_ = true; |
482 } | 482 } |
483 print_preview_ui->OnPrintPreviewFailed(); | 483 print_preview_ui->OnPrintPreviewFailed(); |
484 return; | 484 return; |
485 } | 485 } |
| 486 |
| 487 bool display_header_footer; |
| 488 if (!settings->GetBoolean(printing::kSettingHeaderFooter, |
| 489 &display_header_footer)) { |
| 490 NOTREACHED(); |
| 491 } |
| 492 |
| 493 // If headers and footers option is checked then retrieve the page title and |
| 494 // url and send it to the renderer process. |
| 495 DictionaryValue header_footer_info; |
| 496 if (display_header_footer) { |
| 497 header_footer_info.SetString(printing::kSettingHeaderFooterTitle, |
| 498 initiator_tab->GetTitle()); |
| 499 |
| 500 std::string footer_url; |
| 501 NavigationEntry* entry = initiator_tab->controller().GetActiveEntry(); |
| 502 if (entry) |
| 503 footer_url = entry->virtual_url().spec(); |
| 504 |
| 505 header_footer_info.SetString(printing::kSettingHeaderFooterURL, |
| 506 footer_url); |
| 507 } |
| 508 |
486 VLOG(1) << "Print preview request start"; | 509 VLOG(1) << "Print preview request start"; |
487 RenderViewHost* rvh = initiator_tab->render_view_host(); | 510 RenderViewHost* rvh = initiator_tab->render_view_host(); |
488 rvh->Send(new PrintMsg_PrintPreview(rvh->routing_id(), *settings)); | 511 rvh->Send(new PrintMsg_PrintPreview(rvh->routing_id(), *settings, |
| 512 header_footer_info)); |
489 } | 513 } |
490 | 514 |
491 void PrintPreviewHandler::HandlePrint(const ListValue* args) { | 515 void PrintPreviewHandler::HandlePrint(const ListValue* args) { |
492 ReportStats(); | 516 ReportStats(); |
493 | 517 |
494 // Record the number of times the user requests to regenerate preview data | 518 // Record the number of times the user requests to regenerate preview data |
495 // before printing. | 519 // before printing. |
496 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint", | 520 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint", |
497 regenerate_preview_request_count_); | 521 regenerate_preview_request_count_); |
498 | 522 |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 return; | 899 return; |
876 | 900 |
877 // We no longer require the initiator tab details. Remove those details | 901 // We no longer require the initiator tab details. Remove those details |
878 // associated with the preview tab to allow the initiator tab to create | 902 // associated with the preview tab to allow the initiator tab to create |
879 // another preview tab. | 903 // another preview tab. |
880 printing::PrintPreviewTabController* tab_controller = | 904 printing::PrintPreviewTabController* tab_controller = |
881 printing::PrintPreviewTabController::GetInstance(); | 905 printing::PrintPreviewTabController::GetInstance(); |
882 if (tab_controller) | 906 if (tab_controller) |
883 tab_controller->EraseInitiatorTabInfo(preview_tab()); | 907 tab_controller->EraseInitiatorTabInfo(preview_tab()); |
884 } | 908 } |
OLD | NEW |