Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: chrome/browser/ui/webui/print_preview_data_source.cc

Issue 7397021: Re-land r93365 - add RefCountedString (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/options/options_ui.cc ('k') | chrome/browser/ui/webui/sessions_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_data_source.h" 5 #include "chrome/browser/ui/webui/print_preview_data_source.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string_piece.h" 10 #include "base/string_piece.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 151
152 if (path.empty()) { 152 if (path.empty()) {
153 // Print Preview Index page. 153 // Print Preview Index page.
154 DictionaryValue localized_strings; 154 DictionaryValue localized_strings;
155 SetLocalizedStrings(&localized_strings); 155 SetLocalizedStrings(&localized_strings);
156 SetFontAndTextDirection(&localized_strings); 156 SetFontAndTextDirection(&localized_strings);
157 157
158 static const base::StringPiece print_html( 158 static const base::StringPiece print_html(
159 ResourceBundle::GetSharedInstance().GetRawDataResource( 159 ResourceBundle::GetSharedInstance().GetRawDataResource(
160 IDR_PRINT_PREVIEW_HTML)); 160 IDR_PRINT_PREVIEW_HTML));
161 const std::string full_html = jstemplate_builder::GetI18nTemplateHtml( 161 std::string full_html = jstemplate_builder::GetI18nTemplateHtml(
162 print_html, &localized_strings); 162 print_html, &localized_strings);
163 163
164 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); 164 SendResponse(request_id, base::RefCountedString::TakeString(&full_html));
165 html_bytes->data.resize(full_html.size());
166 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin());
167
168 SendResponse(request_id, html_bytes);
169 return; 165 return;
170 } else if (preview_data_requested && data->front()) { 166 } else if (preview_data_requested && data->front()) {
171 // Print Preview data. 167 // Print Preview data.
172 SendResponse(request_id, data); 168 SendResponse(request_id, data);
173 return; 169 return;
174 } else { 170 } else {
175 // Invalid request. 171 // Invalid request.
176 scoped_refptr<RefCountedBytes> empty_bytes(new RefCountedBytes); 172 scoped_refptr<RefCountedBytes> empty_bytes(new RefCountedBytes);
177 SendResponse(request_id, empty_bytes); 173 SendResponse(request_id, empty_bytes);
178 return; 174 return;
179 } 175 }
180 } 176 }
181 177
182 std::string PrintPreviewDataSource::GetMimeType(const std::string& path) const { 178 std::string PrintPreviewDataSource::GetMimeType(const std::string& path) const {
183 if (path.empty()) 179 if (path.empty())
184 return "text/html"; // Print Preview Index Page. 180 return "text/html"; // Print Preview Index Page.
185 return "application/pdf"; // Print Preview data 181 return "application/pdf"; // Print Preview data
186 } 182 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/options_ui.cc ('k') | chrome/browser/ui/webui/sessions_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698