| 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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 | 482 |
| 483 TabContents* initiator_tab = GetInitiatorTab(); | 483 TabContents* initiator_tab = GetInitiatorTab(); |
| 484 if (!initiator_tab) { | 484 if (!initiator_tab) { |
| 485 if (!reported_failed_preview_) { | 485 if (!reported_failed_preview_) { |
| 486 ReportUserActionHistogram(PREVIEW_FAILED); | 486 ReportUserActionHistogram(PREVIEW_FAILED); |
| 487 reported_failed_preview_ = true; | 487 reported_failed_preview_ = true; |
| 488 } | 488 } |
| 489 print_preview_ui->OnPrintPreviewFailed(); | 489 print_preview_ui->OnPrintPreviewFailed(); |
| 490 return; | 490 return; |
| 491 } | 491 } |
| 492 |
| 493 // Retrieve the page title and url and send it to the renderer process. |
| 494 settings->SetString(printing::kSettingHeaderFooterTitle, |
| 495 initiator_tab->GetTitle()); |
| 496 std::string url; |
| 497 NavigationEntry* entry = initiator_tab->controller().GetActiveEntry(); |
| 498 if (entry) |
| 499 url = entry->virtual_url().spec(); |
| 500 settings->SetString(printing::kSettingHeaderFooterURL, url); |
| 501 |
| 492 VLOG(1) << "Print preview request start"; | 502 VLOG(1) << "Print preview request start"; |
| 493 RenderViewHost* rvh = initiator_tab->render_view_host(); | 503 RenderViewHost* rvh = initiator_tab->render_view_host(); |
| 494 rvh->Send(new PrintMsg_PrintPreview(rvh->routing_id(), *settings)); | 504 rvh->Send(new PrintMsg_PrintPreview(rvh->routing_id(), *settings)); |
| 495 } | 505 } |
| 496 | 506 |
| 497 void PrintPreviewHandler::HandlePrint(const ListValue* args) { | 507 void PrintPreviewHandler::HandlePrint(const ListValue* args) { |
| 498 ReportStats(); | 508 ReportStats(); |
| 499 | 509 |
| 500 // Record the number of times the user requests to regenerate preview data | 510 // Record the number of times the user requests to regenerate preview data |
| 501 // before printing. | 511 // before printing. |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 return; | 894 return; |
| 885 | 895 |
| 886 // We no longer require the initiator tab details. Remove those details | 896 // We no longer require the initiator tab details. Remove those details |
| 887 // associated with the preview tab to allow the initiator tab to create | 897 // associated with the preview tab to allow the initiator tab to create |
| 888 // another preview tab. | 898 // another preview tab. |
| 889 printing::PrintPreviewTabController* tab_controller = | 899 printing::PrintPreviewTabController* tab_controller = |
| 890 printing::PrintPreviewTabController::GetInstance(); | 900 printing::PrintPreviewTabController::GetInstance(); |
| 891 if (tab_controller) | 901 if (tab_controller) |
| 892 tab_controller->EraseInitiatorTabInfo(preview_tab()); | 902 tab_controller->EraseInitiatorTabInfo(preview_tab()); |
| 893 } | 903 } |
| OLD | NEW |