| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/print_preview_message_handler.h" | 5 #include "chrome/browser/printing/print_preview_message_handler.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 GetDataFromHandle(params.metafile_data_handle, params.data_size); | 159 GetDataFromHandle(params.metafile_data_handle, params.data_size); |
| 160 if (!data_bytes || !data_bytes->size()) | 160 if (!data_bytes || !data_bytes->size()) |
| 161 return; | 161 return; |
| 162 | 162 |
| 163 print_preview_ui->SetPrintPreviewDataForIndex(COMPLETE_PREVIEW_DOCUMENT_INDEX, | 163 print_preview_ui->SetPrintPreviewDataForIndex(COMPLETE_PREVIEW_DOCUMENT_INDEX, |
| 164 std::move(data_bytes)); | 164 std::move(data_bytes)); |
| 165 print_preview_ui->OnPreviewDataIsAvailable( | 165 print_preview_ui->OnPreviewDataIsAvailable( |
| 166 params.expected_pages_count, params.preview_request_id); | 166 params.expected_pages_count, params.preview_request_id); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void PrintPreviewMessageHandler::OnPrintPreviewFailed(int document_cookie) { | 169 void PrintPreviewMessageHandler::OnPrintPreviewFailed(int document_cookie, |
| 170 int request_id) { |
| 170 StopWorker(document_cookie); | 171 StopWorker(document_cookie); |
| 171 | 172 |
| 172 PrintPreviewUI* print_preview_ui = GetPrintPreviewUI(); | 173 PrintPreviewUI* print_preview_ui = GetPrintPreviewUI(); |
| 173 if (!print_preview_ui) | 174 if (!print_preview_ui) |
| 174 return; | 175 return; |
| 175 print_preview_ui->OnPrintPreviewFailed(); | 176 print_preview_ui->OnPrintPreviewFailed(request_id); |
| 176 } | 177 } |
| 177 | 178 |
| 178 void PrintPreviewMessageHandler::OnDidGetDefaultPageLayout( | 179 void PrintPreviewMessageHandler::OnDidGetDefaultPageLayout( |
| 179 const PageSizeMargins& page_layout_in_points, | 180 const PageSizeMargins& page_layout_in_points, |
| 180 const gfx::Rect& printable_area_in_points, | 181 const gfx::Rect& printable_area_in_points, |
| 181 bool has_custom_page_size_style) { | 182 bool has_custom_page_size_style) { |
| 182 PrintPreviewUI* print_preview_ui = GetPrintPreviewUI(); | 183 PrintPreviewUI* print_preview_ui = GetPrintPreviewUI(); |
| 183 if (!print_preview_ui) | 184 if (!print_preview_ui) |
| 184 return; | 185 return; |
| 185 print_preview_ui->OnDidGetDefaultPageLayout(page_layout_in_points, | 186 print_preview_ui->OnDidGetDefaultPageLayout(page_layout_in_points, |
| 186 printable_area_in_points, | 187 printable_area_in_points, |
| 187 has_custom_page_size_style); | 188 has_custom_page_size_style); |
| 188 } | 189 } |
| 189 | 190 |
| 190 void PrintPreviewMessageHandler::OnPrintPreviewCancelled(int document_cookie) { | 191 void PrintPreviewMessageHandler::OnPrintPreviewCancelled(int document_cookie) { |
| 191 // Always need to stop the worker. | 192 // Always need to stop the worker. |
| 192 StopWorker(document_cookie); | 193 StopWorker(document_cookie); |
| 193 } | 194 } |
| 194 | 195 |
| 195 void PrintPreviewMessageHandler::OnInvalidPrinterSettings(int document_cookie) { | 196 void PrintPreviewMessageHandler::OnInvalidPrinterSettings(int document_cookie, |
| 197 int request_id) { |
| 196 StopWorker(document_cookie); | 198 StopWorker(document_cookie); |
| 197 PrintPreviewUI* print_preview_ui = GetPrintPreviewUI(); | 199 PrintPreviewUI* print_preview_ui = GetPrintPreviewUI(); |
| 198 if (!print_preview_ui) | 200 if (!print_preview_ui) |
| 199 return; | 201 return; |
| 200 print_preview_ui->OnInvalidPrinterSettings(); | 202 print_preview_ui->OnInvalidPrinterSettings(request_id); |
| 201 } | 203 } |
| 202 | 204 |
| 203 void PrintPreviewMessageHandler::OnSetOptionsFromDocument( | 205 void PrintPreviewMessageHandler::OnSetOptionsFromDocument( |
| 204 const PrintHostMsg_SetOptionsFromDocument_Params& params) { | 206 const PrintHostMsg_SetOptionsFromDocument_Params& params) { |
| 205 PrintPreviewUI* print_preview_ui = GetPrintPreviewUI(); | 207 PrintPreviewUI* print_preview_ui = GetPrintPreviewUI(); |
| 206 if (!print_preview_ui) | 208 if (!print_preview_ui) |
| 207 return; | 209 return; |
| 208 print_preview_ui->OnSetOptionsFromDocument(params); | 210 print_preview_ui->OnSetOptionsFromDocument(params); |
| 209 } | 211 } |
| 210 | 212 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 237 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewInvalidPrinterSettings, | 239 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewInvalidPrinterSettings, |
| 238 OnInvalidPrinterSettings) | 240 OnInvalidPrinterSettings) |
| 239 IPC_MESSAGE_HANDLER(PrintHostMsg_SetOptionsFromDocument, | 241 IPC_MESSAGE_HANDLER(PrintHostMsg_SetOptionsFromDocument, |
| 240 OnSetOptionsFromDocument) | 242 OnSetOptionsFromDocument) |
| 241 IPC_MESSAGE_UNHANDLED(handled = false) | 243 IPC_MESSAGE_UNHANDLED(handled = false) |
| 242 IPC_END_MESSAGE_MAP() | 244 IPC_END_MESSAGE_MAP() |
| 243 return handled; | 245 return handled; |
| 244 } | 246 } |
| 245 | 247 |
| 246 } // namespace printing | 248 } // namespace printing |
| OLD | NEW |