| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 if (params.expected_pages_count <= 0) { | 140 if (params.expected_pages_count <= 0) { |
| 141 NOTREACHED(); | 141 NOTREACHED(); |
| 142 return; | 142 return; |
| 143 } | 143 } |
| 144 | 144 |
| 145 PrintPreviewUI* print_preview_ui = GetPrintPreviewUI(); | 145 PrintPreviewUI* print_preview_ui = GetPrintPreviewUI(); |
| 146 if (!print_preview_ui) | 146 if (!print_preview_ui) |
| 147 return; | 147 return; |
| 148 | 148 |
| 149 if (params.reuse_existing_data) { | |
| 150 // Need to match normal rendering where we are expected to send this. | |
| 151 PrintHostMsg_DidGetPreviewPageCount_Params temp_params; | |
| 152 temp_params.page_count = params.expected_pages_count; | |
| 153 temp_params.document_cookie = params.document_cookie; | |
| 154 temp_params.is_modifiable = params.modifiable; | |
| 155 temp_params.preview_request_id = params.preview_request_id; | |
| 156 print_preview_ui->OnDidGetPreviewPageCount(temp_params); | |
| 157 print_preview_ui->OnReusePreviewData(params.preview_request_id); | |
| 158 return; | |
| 159 } | |
| 160 | |
| 161 // TODO(joth): This seems like a good match for using RefCountedStaticMemory | 149 // TODO(joth): This seems like a good match for using RefCountedStaticMemory |
| 162 // to avoid the memory copy, but the SetPrintPreviewData call chain below | 150 // to avoid the memory copy, but the SetPrintPreviewData call chain below |
| 163 // needs updating to accept the RefCountedMemory* base class. | 151 // needs updating to accept the RefCountedMemory* base class. |
| 164 base::RefCountedBytes* data_bytes = | 152 base::RefCountedBytes* data_bytes = |
| 165 GetDataFromHandle(params.metafile_data_handle, params.data_size); | 153 GetDataFromHandle(params.metafile_data_handle, params.data_size); |
| 166 if (!data_bytes || !data_bytes->size()) | 154 if (!data_bytes || !data_bytes->size()) |
| 167 return; | 155 return; |
| 168 | 156 |
| 169 print_preview_ui->SetPrintPreviewDataForIndex(COMPLETE_PREVIEW_DOCUMENT_INDEX, | 157 print_preview_ui->SetPrintPreviewDataForIndex(COMPLETE_PREVIEW_DOCUMENT_INDEX, |
| 170 data_bytes); | 158 data_bytes); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewInvalidPrinterSettings, | 222 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewInvalidPrinterSettings, |
| 235 OnInvalidPrinterSettings) | 223 OnInvalidPrinterSettings) |
| 236 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewScalingDisabled, | 224 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewScalingDisabled, |
| 237 OnPrintPreviewScalingDisabled) | 225 OnPrintPreviewScalingDisabled) |
| 238 IPC_MESSAGE_UNHANDLED(handled = false) | 226 IPC_MESSAGE_UNHANDLED(handled = false) |
| 239 IPC_END_MESSAGE_MAP() | 227 IPC_END_MESSAGE_MAP() |
| 240 return handled; | 228 return handled; |
| 241 } | 229 } |
| 242 | 230 |
| 243 } // namespace printing | 231 } // namespace printing |
| OLD | NEW |