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

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

Powered by Google App Engine
This is Rietveld 408576698