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/ui/webui/print_preview_ui_html_source.h" | 5 #include "chrome/browser/ui/webui/print_preview_ui_html_source.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 char* preview_data = reinterpret_cast<char*>(data_.first->memory()); | 153 char* preview_data = reinterpret_cast<char*>(data_.first->memory()); |
154 uint32 preview_data_size = data_.second; | 154 uint32 preview_data_size = data_.second; |
155 | 155 |
156 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); | 156 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); |
157 html_bytes->data.resize(preview_data_size); | 157 html_bytes->data.resize(preview_data_size); |
158 std::vector<unsigned char>::iterator it = html_bytes->data.begin(); | 158 std::vector<unsigned char>::iterator it = html_bytes->data.begin(); |
159 for (uint32 i = 0; i < preview_data_size; ++i, ++it) | 159 for (uint32 i = 0; i < preview_data_size; ++i, ++it) |
160 *it = *(preview_data + i); | 160 *it = *(preview_data + i); |
161 SendResponse(request_id, html_bytes); | 161 SendResponse(request_id, html_bytes); |
162 return; | 162 return; |
163 } else if (path == "blank.pdf") { | |
164 const unsigned char blank_pdf[] = "%PDF-1.4\n3 0 obj<</Type/Catalog/Pages" | |
vandebo (ex-Chrome)
2011/05/11 22:13:54
kBlankPDF
All the start quotes should line up.
dpapad
2011/05/11 23:31:03
It seems like there is no need to pass actual pdf
| |
165 " 1 0 R>>endobj 2 0 obj<</Type/Page/Parent 1 0 R/Resources" | |
166 "<<>>/MediaBox[0 0 612 792]>>endobj 1 0 obj<</Type" | |
167 "/Pages/Kids[2 0 R]/Count 1>>endobj\nxref\n0 4\n" | |
168 "0000000000 65535 f \n0000000129 00000 n \n" | |
169 "0000000052 00000 n \n0000000009 00000 n \ntrailer<<" | |
170 "/Size 4/Root 3 0 R>>startxref\n178\n%%EOF\n"; | |
171 scoped_refptr<RefCountedStaticMemory> dummy_bytes( | |
vandebo (ex-Chrome)
2011/05/11 22:13:54
dummy_bytes -> blank_bytes.
dpapad
2011/05/11 23:31:03
Done.
| |
172 new RefCountedStaticMemory(blank_pdf, sizeof(blank_pdf))); | |
173 SendResponse(request_id, dummy_bytes); | |
174 return; | |
163 } else { | 175 } else { |
164 // Invalid request. | 176 // Invalid request. |
165 scoped_refptr<RefCountedBytes> empty_bytes(new RefCountedBytes); | 177 scoped_refptr<RefCountedBytes> empty_bytes(new RefCountedBytes); |
166 SendResponse(request_id, empty_bytes); | 178 SendResponse(request_id, empty_bytes); |
167 return; | 179 return; |
168 } | 180 } |
169 } | 181 } |
170 | 182 |
171 std::string PrintPreviewUIHTMLSource::GetMimeType( | 183 std::string PrintPreviewUIHTMLSource::GetMimeType( |
172 const std::string& path) const { | 184 const std::string& path) const { |
173 // Print Preview Index page. | 185 // Print Preview Index page. |
174 if (path.empty()) | 186 if (path.empty()) |
175 return "text/html"; | 187 return "text/html"; |
176 // Print Preview data. | 188 // Print Preview data. |
177 return "application/pdf"; | 189 return "application/pdf"; |
178 } | 190 } |
OLD | NEW |