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

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

Issue 7670045: Revert 97219 - Added Header and Footer support in Linux, Windows and Mac for Skia (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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
« no previous file with comments | « chrome/browser/ui/webui/print_preview_data_source.cc ('k') | chrome/common/print_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
514 VLOG(1) << "Print preview request start"; 496 VLOG(1) << "Print preview request start";
515 RenderViewHost* rvh = initiator_tab->render_view_host(); 497 RenderViewHost* rvh = initiator_tab->render_view_host();
516 rvh->Send(new PrintMsg_PrintPreview(rvh->routing_id(), *settings)); 498 rvh->Send(new PrintMsg_PrintPreview(rvh->routing_id(), *settings));
517 } 499 }
518 500
519 void PrintPreviewHandler::HandlePrint(const ListValue* args) { 501 void PrintPreviewHandler::HandlePrint(const ListValue* args) {
520 ReportStats(); 502 ReportStats();
521 503
522 // Record the number of times the user requests to regenerate preview data 504 // Record the number of times the user requests to regenerate preview data
523 // before printing. 505 // before printing.
524 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint", 506 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint",
525 regenerate_preview_request_count_); 507 regenerate_preview_request_count_);
526 508
527 TabContents* initiator_tab = GetInitiatorTab(); 509 TabContents* initiator_tab = GetInitiatorTab();
528 if (initiator_tab) { 510 if (initiator_tab) {
529 RenderViewHost* rvh = initiator_tab->render_view_host(); 511 RenderViewHost* rvh = initiator_tab->render_view_host();
530 rvh->Send(new PrintMsg_ResetScriptedPrintCount(rvh->routing_id())); 512 rvh->Send(new PrintMsg_ResetScriptedPrintCount(rvh->routing_id()));
531 } 513 }
532 514
533 scoped_ptr<DictionaryValue> settings(GetSettingsDictionary(args)); 515 scoped_ptr<DictionaryValue> settings(GetSettingsDictionary(args));
534 if (!settings.get()) 516 if (!settings.get())
535 return; 517 return;
536 518
537 // Storing last used color setting. 519 // Storing last used color setting.
538 settings->GetBoolean("color", &last_used_color_setting_); 520 settings->GetBoolean("color", &last_used_color_setting_);
539 521
540 bool print_to_pdf = false; 522 bool print_to_pdf = false;
541 settings->GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf); 523 settings->GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf);
542 524
543 settings->SetBoolean(printing::kSettingHeaderFooterEnabled, false);
544
545 TabContentsWrapper* preview_tab_wrapper = 525 TabContentsWrapper* preview_tab_wrapper =
546 TabContentsWrapper::GetCurrentWrapperForContents(preview_tab()); 526 TabContentsWrapper::GetCurrentWrapperForContents(preview_tab());
547 527
548 bool print_to_cloud = settings->HasKey(printing::kSettingCloudPrintId); 528 bool print_to_cloud = settings->HasKey(printing::kSettingCloudPrintId);
549 if (print_to_cloud) { 529 if (print_to_cloud) {
550 std::string print_ticket; 530 std::string print_ticket;
551 args->GetString(1, &print_ticket); 531 args->GetString(1, &print_ticket);
552 SendCloudPrintJob(*settings, print_ticket); 532 SendCloudPrintJob(*settings, print_ticket);
553 } else if (print_to_pdf) { 533 } else if (print_to_pdf) {
554 ReportUserActionHistogram(PRINT_TO_PDF); 534 ReportUserActionHistogram(PRINT_TO_PDF);
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 return; 903 return;
924 904
925 // We no longer require the initiator tab details. Remove those details 905 // We no longer require the initiator tab details. Remove those details
926 // associated with the preview tab to allow the initiator tab to create 906 // associated with the preview tab to allow the initiator tab to create
927 // another preview tab. 907 // another preview tab.
928 printing::PrintPreviewTabController* tab_controller = 908 printing::PrintPreviewTabController* tab_controller =
929 printing::PrintPreviewTabController::GetInstance(); 909 printing::PrintPreviewTabController::GetInstance();
930 if (tab_controller) 910 if (tab_controller)
931 tab_controller->EraseInitiatorTabInfo(preview_tab()); 911 tab_controller->EraseInitiatorTabInfo(preview_tab());
932 } 912 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/print_preview_data_source.cc ('k') | chrome/common/print_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698