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 scoped_refptr<RefCountedBytes> dummy_bytes(new RefCountedBytes); | |
vandebo (ex-Chrome)
2011/05/11 18:37:18
dummy_bytes != blank_pdf
vandebo (ex-Chrome)
2011/05/11 19:04:55
Nevermind, I read it wrong.
| |
165 std::string blank_pdf("%PDF-1.4\n3 0 obj<</Type/Catalog/Pages 1 0 R>>" | |
vandebo (ex-Chrome)
2011/05/11 19:04:55
Should this be a constant? const char kBlankPdf[]
dpapad
2011/05/11 22:08:20
Done.
| |
166 "endobj 2 0 obj<</Type/Page/Parent 1 0 R/Resources" | |
167 "<<>>/MediaBox[0 0 612 792]>>endobj 1 0 obj<</Type" | |
168 "/Pages/Kids[2 0 R]/Count 1>>endobj\nxref\n0 4" | |
169 "0000000000 65535 f \n0000000129 00000 n \n" | |
170 "0000000052 00000 n \n0000000009 00000 n \ntrailer<<" | |
171 "/Size 4/Root 3 0 R>>startxref\n178\n%%EOF\n"); | |
172 const char* dummy_data = blank_pdf.c_str(); | |
173 dummy_bytes->data.resize(blank_pdf.length()); | |
174 std::vector<unsigned char>::iterator it = dummy_bytes->data.begin(); | |
175 for (uint32 i = 0; i < blank_pdf.length(); ++i, ++it) | |
176 *it = *(dummy_data + i); | |
177 SendResponse(request_id, dummy_bytes); | |
178 return; | |
163 } else { | 179 } else { |
164 // Invalid request. | 180 // Invalid request. |
165 scoped_refptr<RefCountedBytes> empty_bytes(new RefCountedBytes); | 181 scoped_refptr<RefCountedBytes> empty_bytes(new RefCountedBytes); |
166 SendResponse(request_id, empty_bytes); | 182 SendResponse(request_id, empty_bytes); |
167 return; | 183 return; |
168 } | 184 } |
169 } | 185 } |
170 | 186 |
171 std::string PrintPreviewUIHTMLSource::GetMimeType( | 187 std::string PrintPreviewUIHTMLSource::GetMimeType( |
172 const std::string& path) const { | 188 const std::string& path) const { |
173 // Print Preview Index page. | 189 // Print Preview Index page. |
174 if (path.empty()) | 190 if (path.empty()) |
175 return "text/html"; | 191 return "text/html"; |
176 // Print Preview data. | 192 // Print Preview data. |
177 return "application/pdf"; | 193 return "application/pdf"; |
178 } | 194 } |
OLD | NEW |