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

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: Removed use of webkit_scale_factor in print_web_view_helper_mac Created 9 years, 4 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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if
494 // headers and footers are to be displayed.
495 bool display_header_footer = false;
496 if (!settings->GetBoolean(printing::kSettingHeaderFooterEnabled,
497 &display_header_footer)) {
498 NOTREACHED();
499 }
500 if (display_header_footer) {
501 settings->SetString(printing::kSettingHeaderFooterTitle,
502 initiator_tab->GetTitle());
503 std::string url;
504 NavigationEntry* entry = initiator_tab->controller().GetActiveEntry();
505 if (entry)
506 url = entry->virtual_url().spec();
507 settings->SetString(printing::kSettingHeaderFooterURL, url);
508 }
509
492 VLOG(1) << "Print preview request start"; 510 VLOG(1) << "Print preview request start";
493 RenderViewHost* rvh = initiator_tab->render_view_host(); 511 RenderViewHost* rvh = initiator_tab->render_view_host();
494 rvh->Send(new PrintMsg_PrintPreview(rvh->routing_id(), *settings)); 512 rvh->Send(new PrintMsg_PrintPreview(rvh->routing_id(), *settings));
495 } 513 }
496 514
497 void PrintPreviewHandler::HandlePrint(const ListValue* args) { 515 void PrintPreviewHandler::HandlePrint(const ListValue* args) {
498 ReportStats(); 516 ReportStats();
499 517
500 // 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
501 // before printing. 519 // before printing.
502 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint", 520 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint",
503 regenerate_preview_request_count_); 521 regenerate_preview_request_count_);
504 522
505 TabContents* initiator_tab = GetInitiatorTab(); 523 TabContents* initiator_tab = GetInitiatorTab();
506 if (initiator_tab) { 524 if (initiator_tab) {
507 RenderViewHost* rvh = initiator_tab->render_view_host(); 525 RenderViewHost* rvh = initiator_tab->render_view_host();
508 rvh->Send(new PrintMsg_ResetScriptedPrintCount(rvh->routing_id())); 526 rvh->Send(new PrintMsg_ResetScriptedPrintCount(rvh->routing_id()));
509 } 527 }
510 528
511 scoped_ptr<DictionaryValue> settings(GetSettingsDictionary(args)); 529 scoped_ptr<DictionaryValue> settings(GetSettingsDictionary(args));
512 if (!settings.get()) 530 if (!settings.get())
513 return; 531 return;
514 532
515 // Storing last used color setting. 533 // Storing last used color setting.
516 settings->GetBoolean("color", &last_used_color_setting_); 534 settings->GetBoolean("color", &last_used_color_setting_);
517 535
518 bool print_to_pdf = false; 536 bool print_to_pdf = false;
519 settings->GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf); 537 settings->GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf);
520 538
539 settings->SetBoolean(printing::kSettingHeaderFooterEnabled, false);
540
521 TabContentsWrapper* preview_tab_wrapper = 541 TabContentsWrapper* preview_tab_wrapper =
522 TabContentsWrapper::GetCurrentWrapperForContents(preview_tab()); 542 TabContentsWrapper::GetCurrentWrapperForContents(preview_tab());
523 543
524 bool print_to_cloud = settings->HasKey(printing::kSettingCloudPrintId); 544 bool print_to_cloud = settings->HasKey(printing::kSettingCloudPrintId);
525 if (print_to_cloud) { 545 if (print_to_cloud) {
526 std::string print_ticket; 546 std::string print_ticket;
527 args->GetString(1, &print_ticket); 547 args->GetString(1, &print_ticket);
528 SendCloudPrintJob(*settings, print_ticket); 548 SendCloudPrintJob(*settings, print_ticket);
529 } else if (print_to_pdf) { 549 } else if (print_to_pdf) {
530 ReportUserActionHistogram(PRINT_TO_PDF); 550 ReportUserActionHistogram(PRINT_TO_PDF);
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 return; 906 return;
887 907
888 // We no longer require the initiator tab details. Remove those details 908 // We no longer require the initiator tab details. Remove those details
889 // associated with the preview tab to allow the initiator tab to create 909 // associated with the preview tab to allow the initiator tab to create
890 // another preview tab. 910 // another preview tab.
891 printing::PrintPreviewTabController* tab_controller = 911 printing::PrintPreviewTabController* tab_controller =
892 printing::PrintPreviewTabController::GetInstance(); 912 printing::PrintPreviewTabController::GetInstance();
893 if (tab_controller) 913 if (tab_controller)
894 tab_controller->EraseInitiatorTabInfo(preview_tab()); 914 tab_controller->EraseInitiatorTabInfo(preview_tab());
895 } 915 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698