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 == "dummy.pdf") { | |
164 scoped_refptr<RefCountedStaticMemory> blank_bytes( | |
vandebo (ex-Chrome)
2011/05/12 00:07:14
nit: blank_bytes -> dummy_bytes
dpapad
2011/05/12 00:44:09
Done.
| |
165 new RefCountedStaticMemory()); | |
166 SendResponse(request_id, blank_bytes); | |
167 return; | |
163 } else { | 168 } else { |
164 // Invalid request. | 169 // Invalid request. |
165 scoped_refptr<RefCountedBytes> empty_bytes(new RefCountedBytes); | 170 scoped_refptr<RefCountedBytes> empty_bytes(new RefCountedBytes); |
166 SendResponse(request_id, empty_bytes); | 171 SendResponse(request_id, empty_bytes); |
167 return; | 172 return; |
168 } | 173 } |
169 } | 174 } |
170 | 175 |
171 std::string PrintPreviewUIHTMLSource::GetMimeType( | 176 std::string PrintPreviewUIHTMLSource::GetMimeType( |
172 const std::string& path) const { | 177 const std::string& path) const { |
173 // Print Preview Index page. | 178 // Print Preview Index page. |
174 if (path.empty()) | 179 if (path.empty()) |
175 return "text/html"; | 180 return "text/html"; |
176 // Print Preview data. | 181 // Print Preview data. |
177 return "application/pdf"; | 182 return "application/pdf"; |
178 } | 183 } |
OLD | NEW |