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

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 Headers and Footers support - New Snapshot Uploaded 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/i18n/file_util_icu.h" 9 #include "base/i18n/file_util_icu.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
15 #include "base/threading/thread_restrictions.h" 15 #include "base/threading/thread_restrictions.h"
16 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 #include "base/values.h"
Lei Zhang 2011/07/12 22:04:50 Why did you remove this?
Aayush Kumar 2011/07/13 21:52:16 Done.
18 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/platform_util.h" 18 #include "chrome/browser/platform_util.h"
20 #include "chrome/browser/printing/background_printing_manager.h" 19 #include "chrome/browser/printing/background_printing_manager.h"
21 #include "chrome/browser/printing/printer_manager_dialog.h" 20 #include "chrome/browser/printing/printer_manager_dialog.h"
22 #include "chrome/browser/printing/print_preview_tab_controller.h" 21 #include "chrome/browser/printing/print_preview_tab_controller.h"
23 #include "chrome/browser/sessions/restore_tab_helper.h" 22 #include "chrome/browser/sessions/restore_tab_helper.h"
24 #include "chrome/browser/tabs/tab_strip_model.h" 23 #include "chrome/browser/tabs/tab_strip_model.h"
25 #include "chrome/browser/ui/browser_list.h" 24 #include "chrome/browser/ui/browser_list.h"
26 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 25 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
27 #include "chrome/browser/ui/webui/print_preview_ui.h" 26 #include "chrome/browser/ui/webui/print_preview_ui.h"
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 441
443 TabContents* initiator_tab = GetInitiatorTab(); 442 TabContents* initiator_tab = GetInitiatorTab();
444 if (!initiator_tab) { 443 if (!initiator_tab) {
445 if (!reported_failed_preview_) { 444 if (!reported_failed_preview_) {
446 ReportUserActionHistogram(PREVIEW_FAILED); 445 ReportUserActionHistogram(PREVIEW_FAILED);
447 reported_failed_preview_ = true; 446 reported_failed_preview_ = true;
448 } 447 }
449 print_preview_ui->OnPrintPreviewFailed(); 448 print_preview_ui->OnPrintPreviewFailed();
450 return; 449 return;
451 } 450 }
451
452 bool isHeaderFooter;
453 if (!(settings.get())->GetBoolean(printing::kSettingHeaderFooter,
kmadhusu 2011/07/13 18:47:53 "(settings.get())->" == "settings->"
Aayush Kumar 2011/07/13 21:52:16 Done.
454 &isHeaderFooter))
Lei Zhang 2011/07/12 22:04:50 nit: indentation nit: braces around NOTREACHED()
Aayush Kumar 2011/07/13 21:52:16 Done.
455 NOTREACHED();
456
457 // If the user has checked the Headers and footers option then we go ahead
458 // and retrieve the page URL and title since we're already in the browser
459 // process and send it along to the renderer along with other print settings.
460 // No point going back to the renderer and then making an explicit call to
461 // the browser process again to retrieve this information.
462 DictionaryValue header_footer_info;
463 if (isHeaderFooter) {
464 header_footer_info.SetString(printing::kSettingHeaderFooterTitle,
465 initiator_tab->GetTitle());
466
467 NavigationEntry* entry = initiator_tab->controller().GetActiveEntry();
468 if (entry)
Lei Zhang 2011/07/12 22:04:50 nit: braces
Aayush Kumar 2011/07/13 21:52:16 Done.
469 header_footer_info.SetString(printing::kSettingHeaderFooterURL,
470 entry->virtual_url().spec());
471 else
472 header_footer_info.SetString(printing::kSettingHeaderFooterURL, "");
473 }
474
452 VLOG(1) << "Print preview request start"; 475 VLOG(1) << "Print preview request start";
453 RenderViewHost* rvh = initiator_tab->render_view_host(); 476 RenderViewHost* rvh = initiator_tab->render_view_host();
454 rvh->Send(new PrintMsg_PrintPreview(rvh->routing_id(), *settings)); 477 rvh->Send(new PrintMsg_PrintPreview(rvh->routing_id(), *settings,
478 header_footer_info));
Lei Zhang 2011/07/12 22:04:50 nit: indentation
Aayush Kumar 2011/07/13 21:52:16 Done.
455 } 479 }
456 480
457 void PrintPreviewHandler::HandlePrint(const ListValue* args) { 481 void PrintPreviewHandler::HandlePrint(const ListValue* args) {
458 ReportStats(); 482 ReportStats();
459 483
460 // Record the number of times the user requests to regenerate preview data 484 // Record the number of times the user requests to regenerate preview data
461 // before printing. 485 // before printing.
462 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint", 486 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint",
463 regenerate_preview_request_count_); 487 regenerate_preview_request_count_);
464 488
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 return; 762 return;
739 763
740 // We no longer require the initiator tab details. Remove those details 764 // We no longer require the initiator tab details. Remove those details
741 // associated with the preview tab to allow the initiator tab to create 765 // associated with the preview tab to allow the initiator tab to create
742 // another preview tab. 766 // another preview tab.
743 printing::PrintPreviewTabController* tab_controller = 767 printing::PrintPreviewTabController* tab_controller =
744 printing::PrintPreviewTabController::GetInstance(); 768 printing::PrintPreviewTabController::GetInstance();
745 if (tab_controller) 769 if (tab_controller)
746 tab_controller->EraseInitiatorTabInfo(preview_tab()); 770 tab_controller->EraseInitiatorTabInfo(preview_tab());
747 } 771 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698