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 // Retrieve the page title and url and send it to the renderer process. |
| 488 settings->SetString(printing::kSettingHeaderFooterTitle, |
| 489 initiator_tab->GetTitle()); |
| 490 std::string url; |
| 491 NavigationEntry* entry = initiator_tab->controller().GetActiveEntry(); |
| 492 if (entry) |
| 493 url = entry->virtual_url().spec(); |
| 494 settings->SetString(printing::kSettingHeaderFooterURL, url); |
| 495 |
486 VLOG(1) << "Print preview request start"; | 496 VLOG(1) << "Print preview request start"; |
487 RenderViewHost* rvh = initiator_tab->render_view_host(); | 497 RenderViewHost* rvh = initiator_tab->render_view_host(); |
488 rvh->Send(new PrintMsg_PrintPreview(rvh->routing_id(), *settings)); | 498 rvh->Send(new PrintMsg_PrintPreview(rvh->routing_id(), *settings)); |
489 } | 499 } |
490 | 500 |
491 void PrintPreviewHandler::HandlePrint(const ListValue* args) { | 501 void PrintPreviewHandler::HandlePrint(const ListValue* args) { |
492 ReportStats(); | 502 ReportStats(); |
493 | 503 |
494 // Record the number of times the user requests to regenerate preview data | 504 // Record the number of times the user requests to regenerate preview data |
495 // before printing. | 505 // before printing. |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 return; | 885 return; |
876 | 886 |
877 // We no longer require the initiator tab details. Remove those details | 887 // We no longer require the initiator tab details. Remove those details |
878 // associated with the preview tab to allow the initiator tab to create | 888 // associated with the preview tab to allow the initiator tab to create |
879 // another preview tab. | 889 // another preview tab. |
880 printing::PrintPreviewTabController* tab_controller = | 890 printing::PrintPreviewTabController* tab_controller = |
881 printing::PrintPreviewTabController::GetInstance(); | 891 printing::PrintPreviewTabController::GetInstance(); |
882 if (tab_controller) | 892 if (tab_controller) |
883 tab_controller->EraseInitiatorTabInfo(preview_tab()); | 893 tab_controller->EraseInitiatorTabInfo(preview_tab()); |
884 } | 894 } |
OLD | NEW |