Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/renderer_host/resource_message_filter.h" | 5 #include "chrome/browser/renderer_host/resource_message_filter.h" |
| 6 | 6 |
| 7 #include "base/clipboard.h" | 7 #include "base/clipboard.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/gfx/native_widget_types.h" | 9 #include "base/gfx/native_widget_types.h" |
| 10 #include "base/histogram.h" | 10 #include "base/histogram.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 ~WriteClipboardTask() {} | 106 ~WriteClipboardTask() {} |
| 107 | 107 |
| 108 void Run() { | 108 void Run() { |
| 109 g_browser_process->clipboard()->WriteObjects(*objects_.get()); | 109 g_browser_process->clipboard()->WriteObjects(*objects_.get()); |
| 110 } | 110 } |
| 111 | 111 |
| 112 private: | 112 private: |
| 113 scoped_ptr<Clipboard::ObjectMap> objects_; | 113 scoped_ptr<Clipboard::ObjectMap> objects_; |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 void RenderParamsFromPrintSettings(const printing::PrintSettings& settings, | |
| 117 ViewMsg_Print_Params* params) { | |
| 118 DCHECK(params); | |
| 119 #if defined(OS_WIN) | |
|
M-A Ruel
2009/07/09 19:27:59
Actually, why OS_WIN? I don't see much platform sp
Sverrir
2009/07/09 20:13:23
Currently this file is including the temp_scaffold
| |
| 120 params->printable_size.SetSize( | |
| 121 settings.page_setup_pixels().content_area().width(), | |
| 122 settings.page_setup_pixels().content_area().height()); | |
| 123 params->dpi = settings.dpi(); | |
| 124 // Currently hardcoded at 1.25. See PrintSettings' constructor. | |
| 125 params->min_shrink = settings.min_shrink; | |
| 126 // Currently hardcoded at 2.0. See PrintSettings' constructor. | |
| 127 params->max_shrink = settings.max_shrink; | |
| 128 // Currently hardcoded at 72dpi. See PrintSettings' constructor. | |
| 129 params->desired_dpi = settings.desired_dpi; | |
| 130 // Always use an invalid cookie. | |
| 131 params->document_cookie = 0; | |
| 132 params->selection_only = settings.selection_only; | |
| 133 #else | |
| 134 NOTIMPLEMENTED(); | |
| 135 #endif | |
| 136 } | |
| 116 | 137 |
| 117 } // namespace | 138 } // namespace |
| 118 | 139 |
| 119 ResourceMessageFilter::ResourceMessageFilter( | 140 ResourceMessageFilter::ResourceMessageFilter( |
| 120 ResourceDispatcherHost* resource_dispatcher_host, | 141 ResourceDispatcherHost* resource_dispatcher_host, |
| 121 AudioRendererHost* audio_renderer_host, | 142 AudioRendererHost* audio_renderer_host, |
| 122 PluginService* plugin_service, | 143 PluginService* plugin_service, |
| 123 printing::PrintJobManager* print_job_manager, | 144 printing::PrintJobManager* print_job_manager, |
| 124 Profile* profile, | 145 Profile* profile, |
| 125 RenderWidgetHelper* render_widget_helper, | 146 RenderWidgetHelper* render_widget_helper, |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 717 task); | 738 task); |
| 718 } | 739 } |
| 719 | 740 |
| 720 void ResourceMessageFilter::OnGetDefaultPrintSettingsReply( | 741 void ResourceMessageFilter::OnGetDefaultPrintSettingsReply( |
| 721 scoped_refptr<printing::PrinterQuery> printer_query, | 742 scoped_refptr<printing::PrinterQuery> printer_query, |
| 722 IPC::Message* reply_msg) { | 743 IPC::Message* reply_msg) { |
| 723 ViewMsg_Print_Params params; | 744 ViewMsg_Print_Params params; |
| 724 if (printer_query->last_status() != printing::PrintingContext::OK) { | 745 if (printer_query->last_status() != printing::PrintingContext::OK) { |
| 725 memset(¶ms, 0, sizeof(params)); | 746 memset(¶ms, 0, sizeof(params)); |
| 726 } else { | 747 } else { |
| 727 printer_query->settings().RenderParams(¶ms); | 748 RenderParamsFromPrintSettings(printer_query->settings(), ¶ms); |
| 728 params.document_cookie = printer_query->cookie(); | 749 params.document_cookie = printer_query->cookie(); |
| 729 } | 750 } |
| 730 ViewHostMsg_GetDefaultPrintSettings::WriteReplyParams(reply_msg, params); | 751 ViewHostMsg_GetDefaultPrintSettings::WriteReplyParams(reply_msg, params); |
| 731 Send(reply_msg); | 752 Send(reply_msg); |
| 732 // If user hasn't cancelled. | 753 // If user hasn't cancelled. |
| 733 if (printer_query->cookie() && printer_query->settings().dpi()) { | 754 if (printer_query->cookie() && printer_query->settings().dpi()) { |
| 734 print_job_manager_->QueuePrinterQuery(printer_query.get()); | 755 print_job_manager_->QueuePrinterQuery(printer_query.get()); |
| 735 } else { | 756 } else { |
| 736 printer_query->StopWorker(); | 757 printer_query->StopWorker(); |
| 737 } | 758 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 774 } | 795 } |
| 775 | 796 |
| 776 void ResourceMessageFilter::OnScriptedPrintReply( | 797 void ResourceMessageFilter::OnScriptedPrintReply( |
| 777 scoped_refptr<printing::PrinterQuery> printer_query, | 798 scoped_refptr<printing::PrinterQuery> printer_query, |
| 778 IPC::Message* reply_msg) { | 799 IPC::Message* reply_msg) { |
| 779 ViewMsg_PrintPages_Params params; | 800 ViewMsg_PrintPages_Params params; |
| 780 if (printer_query->last_status() != printing::PrintingContext::OK || | 801 if (printer_query->last_status() != printing::PrintingContext::OK || |
| 781 !printer_query->settings().dpi()) { | 802 !printer_query->settings().dpi()) { |
| 782 memset(¶ms, 0, sizeof(params)); | 803 memset(¶ms, 0, sizeof(params)); |
| 783 } else { | 804 } else { |
| 784 printer_query->settings().RenderParams(¶ms.params); | 805 RenderParamsFromPrintSettings(printer_query->settings(), ¶ms.params); |
| 785 params.params.document_cookie = printer_query->cookie(); | 806 params.params.document_cookie = printer_query->cookie(); |
| 786 params.pages = | 807 params.pages = |
| 787 printing::PageRange::GetPages(printer_query->settings().ranges); | 808 printing::PageRange::GetPages(printer_query->settings().ranges); |
| 788 } | 809 } |
| 789 ViewHostMsg_ScriptedPrint::WriteReplyParams(reply_msg, params); | 810 ViewHostMsg_ScriptedPrint::WriteReplyParams(reply_msg, params); |
| 790 Send(reply_msg); | 811 Send(reply_msg); |
| 791 if (params.params.dpi && params.params.document_cookie) { | 812 if (params.params.dpi && params.params.document_cookie) { |
| 792 print_job_manager_->QueuePrinterQuery(printer_query.get()); | 813 print_job_manager_->QueuePrinterQuery(printer_query.get()); |
| 793 } else { | 814 } else { |
| 794 printer_query->StopWorker(); | 815 printer_query->StopWorker(); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 938 } | 959 } |
| 939 | 960 |
| 940 void ResourceMessageFilter::ReplyGetFileSize(int64 result, void* param) { | 961 void ResourceMessageFilter::ReplyGetFileSize(int64 result, void* param) { |
| 941 IPC::Message* reply_msg = static_cast<IPC::Message*>(param); | 962 IPC::Message* reply_msg = static_cast<IPC::Message*>(param); |
| 942 ViewHostMsg_GetFileSize::WriteReplyParams(reply_msg, result); | 963 ViewHostMsg_GetFileSize::WriteReplyParams(reply_msg, result); |
| 943 Send(reply_msg); | 964 Send(reply_msg); |
| 944 | 965 |
| 945 // Getting file size callback done, decrease the ref count. | 966 // Getting file size callback done, decrease the ref count. |
| 946 Release(); | 967 Release(); |
| 947 } | 968 } |
| OLD | NEW |