Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Side by Side Diff: chrome/browser/ui/webui/print_preview_handler.cc

Issue 7348010: Added Header and Footer support using Skia (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixed style issues. Added check to see if there is enough space to print headers and footers. Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 displayHeaderFooter;
488 if (!settings->GetBoolean(printing::kSettingHeaderFooter,
489 &displayHeaderFooter)) {
490 NOTREACHED();
491 }
492
493 // If headers and footers option is checked then we retrieve the page title
494 // and url and send it to the renderer process.
495 DictionaryValue header_footer_info;
496 if (displayHeaderFooter) {
497 header_footer_info.SetString(printing::kSettingHeaderFooterTitle,
vandebo (ex-Chrome) 2011/07/19 21:31:20 Why not just put this in settings?
vandebo (ex-Chrome) 2011/07/22 22:58:33 You didn't address this comment.
Aayush Kumar 2011/07/24 02:09:02 Sorry about that - I somehow seemed to have missed
498 initiator_tab->GetTitle());
499
500 std::string footer_url;
vandebo (ex-Chrome) 2011/07/19 21:31:20 nit: url
Aayush Kumar 2011/07/24 02:09:02 Done.
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698