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

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

Powered by Google App Engine
This is Rietveld 408576698