| OLD | NEW |
| 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/printing/printing_message_filter.h" | 5 #include "chrome/browser/printing/printing_message_filter.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 static base::LazyInstance<PrintingSequencePathMap> | 40 static base::LazyInstance<PrintingSequencePathMap> |
| 41 g_printing_file_descriptor_map(base::LINKER_INITIALIZED); | 41 g_printing_file_descriptor_map(base::LINKER_INITIALIZED); |
| 42 #endif | 42 #endif |
| 43 | 43 |
| 44 void RenderParamsFromPrintSettings(const printing::PrintSettings& settings, | 44 void RenderParamsFromPrintSettings(const printing::PrintSettings& settings, |
| 45 PrintMsg_Print_Params* params) { | 45 PrintMsg_Print_Params* params) { |
| 46 params->page_size = settings.page_setup_device_units().physical_size(); | 46 params->page_size = settings.page_setup_device_units().physical_size(); |
| 47 params->printable_size.SetSize( | 47 params->printable_size.SetSize( |
| 48 settings.page_setup_device_units().content_area().width(), | 48 settings.page_setup_device_units().content_area().width(), |
| 49 settings.page_setup_device_units().content_area().height()); | 49 settings.page_setup_device_units().content_area().height()); |
| 50 params->margin_top = settings.page_setup_device_units().content_area().x(); | 50 params->margin_top = settings.page_setup_device_units().content_area().y(); |
| 51 params->margin_left = settings.page_setup_device_units().content_area().y(); | 51 params->margin_left = settings.page_setup_device_units().content_area().x(); |
| 52 params->dpi = settings.dpi(); | 52 params->dpi = settings.dpi(); |
| 53 // Currently hardcoded at 1.25. See PrintSettings' constructor. | 53 // Currently hardcoded at 1.25. See PrintSettings' constructor. |
| 54 params->min_shrink = settings.min_shrink; | 54 params->min_shrink = settings.min_shrink; |
| 55 // Currently hardcoded at 2.0. See PrintSettings' constructor. | 55 // Currently hardcoded at 2.0. See PrintSettings' constructor. |
| 56 params->max_shrink = settings.max_shrink; | 56 params->max_shrink = settings.max_shrink; |
| 57 // Currently hardcoded at 72dpi. See PrintSettings' constructor. | 57 // Currently hardcoded at 72dpi. See PrintSettings' constructor. |
| 58 params->desired_dpi = settings.desired_dpi; | 58 params->desired_dpi = settings.desired_dpi; |
| 59 // Always use an invalid cookie. | 59 // Always use an invalid cookie. |
| 60 params->document_cookie = 0; | 60 params->document_cookie = 0; |
| 61 params->selection_only = settings.selection_only; | 61 params->selection_only = settings.selection_only; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 this, | 190 this, |
| 191 &PrintingMessageFilter::OnGetDefaultPrintSettingsReply, | 191 &PrintingMessageFilter::OnGetDefaultPrintSettingsReply, |
| 192 printer_query, | 192 printer_query, |
| 193 reply_msg); | 193 reply_msg); |
| 194 // Loads default settings. This is asynchronous, only the IPC message sender | 194 // Loads default settings. This is asynchronous, only the IPC message sender |
| 195 // will hang until the settings are retrieved. | 195 // will hang until the settings are retrieved. |
| 196 printer_query->GetSettings(printing::PrinterQuery::DEFAULTS, | 196 printer_query->GetSettings(printing::PrinterQuery::DEFAULTS, |
| 197 NULL, | 197 NULL, |
| 198 0, | 198 0, |
| 199 false, | 199 false, |
| 200 true, | 200 printing::DEFAULT_MARGINS, |
| 201 task); | 201 task); |
| 202 } | 202 } |
| 203 | 203 |
| 204 void PrintingMessageFilter::OnGetDefaultPrintSettingsReply( | 204 void PrintingMessageFilter::OnGetDefaultPrintSettingsReply( |
| 205 scoped_refptr<printing::PrinterQuery> printer_query, | 205 scoped_refptr<printing::PrinterQuery> printer_query, |
| 206 IPC::Message* reply_msg) { | 206 IPC::Message* reply_msg) { |
| 207 PrintMsg_Print_Params params; | 207 PrintMsg_Print_Params params; |
| 208 if (!printer_query.get() || | 208 if (!printer_query.get() || |
| 209 printer_query->last_status() != printing::PrintingContext::OK) { | 209 printer_query->last_status() != printing::PrintingContext::OK) { |
| 210 params.Reset(); | 210 params.Reset(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 241 this, | 241 this, |
| 242 &PrintingMessageFilter::OnScriptedPrintReply, | 242 &PrintingMessageFilter::OnScriptedPrintReply, |
| 243 printer_query, | 243 printer_query, |
| 244 params.routing_id, | 244 params.routing_id, |
| 245 reply_msg); | 245 reply_msg); |
| 246 | 246 |
| 247 printer_query->GetSettings(printing::PrinterQuery::ASK_USER, | 247 printer_query->GetSettings(printing::PrinterQuery::ASK_USER, |
| 248 host_view, | 248 host_view, |
| 249 params.expected_pages_count, | 249 params.expected_pages_count, |
| 250 params.has_selection, | 250 params.has_selection, |
| 251 params.use_overlays, | 251 params.margin_type, |
| 252 task); | 252 task); |
| 253 } | 253 } |
| 254 | 254 |
| 255 void PrintingMessageFilter::OnScriptedPrintReply( | 255 void PrintingMessageFilter::OnScriptedPrintReply( |
| 256 scoped_refptr<printing::PrinterQuery> printer_query, | 256 scoped_refptr<printing::PrinterQuery> printer_query, |
| 257 int routing_id, | 257 int routing_id, |
| 258 IPC::Message* reply_msg) { | 258 IPC::Message* reply_msg) { |
| 259 PrintMsg_PrintPages_Params params; | 259 PrintMsg_PrintPages_Params params; |
| 260 if (printer_query->last_status() != printing::PrintingContext::OK || | 260 if (printer_query->last_status() != printing::PrintingContext::OK || |
| 261 !printer_query->settings().dpi()) { | 261 !printer_query->settings().dpi()) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 } | 320 } |
| 321 } | 321 } |
| 322 | 322 |
| 323 void PrintingMessageFilter::OnCheckForCancel(const std::string& preview_ui_addr, | 323 void PrintingMessageFilter::OnCheckForCancel(const std::string& preview_ui_addr, |
| 324 int preview_request_id, | 324 int preview_request_id, |
| 325 bool* cancel) { | 325 bool* cancel) { |
| 326 PrintPreviewUI::GetCurrentPrintPreviewStatus(preview_ui_addr, | 326 PrintPreviewUI::GetCurrentPrintPreviewStatus(preview_ui_addr, |
| 327 preview_request_id, | 327 preview_request_id, |
| 328 cancel); | 328 cancel); |
| 329 } | 329 } |
| OLD | NEW |