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

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

Issue 10873097: Merge 153342 - Print preview: Use an ID instead of memory pointer string in WebUI. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1229/src/
Patch Set: Created 8 years, 3 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
OLDNEW
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/ui/webui/print_preview/print_preview_data_source.h" 5 #include "chrome/browser/ui/webui/print_preview/print_preview_data_source.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ref_counted_memory.h" 10 #include "base/memory/ref_counted_memory.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // Parent class handles most requests except for the print preview data. 188 // Parent class handles most requests except for the print preview data.
189 if (!EndsWith(path, "/print.pdf", true)) { 189 if (!EndsWith(path, "/print.pdf", true)) {
190 ChromeWebUIDataSource::StartDataRequest(path, is_incognito, request_id); 190 ChromeWebUIDataSource::StartDataRequest(path, is_incognito, request_id);
191 return; 191 return;
192 } 192 }
193 193
194 // Print Preview data. 194 // Print Preview data.
195 scoped_refptr<base::RefCountedBytes> data; 195 scoped_refptr<base::RefCountedBytes> data;
196 std::vector<std::string> url_substr; 196 std::vector<std::string> url_substr;
197 base::SplitString(path, '/', &url_substr); 197 base::SplitString(path, '/', &url_substr);
198 int preview_ui_id = -1;
198 int page_index = 0; 199 int page_index = 0;
199 if (url_substr.size() == 3 && base::StringToInt(url_substr[1], &page_index)) { 200 if (url_substr.size() == 3 &&
201 base::StringToInt(url_substr[0], &preview_ui_id),
202 base::StringToInt(url_substr[1], &page_index) &&
203 preview_ui_id >= 0) {
200 PrintPreviewDataService::GetInstance()->GetDataEntry( 204 PrintPreviewDataService::GetInstance()->GetDataEntry(
201 url_substr[0], page_index, &data); 205 preview_ui_id, page_index, &data);
202 } 206 }
203 if (data.get()) { 207 if (data.get()) {
204 SendResponse(request_id, data); 208 SendResponse(request_id, data);
205 return; 209 return;
206 } 210 }
207 // Invalid request. 211 // Invalid request.
208 scoped_refptr<base::RefCountedBytes> empty_bytes(new base::RefCountedBytes); 212 scoped_refptr<base::RefCountedBytes> empty_bytes(new base::RefCountedBytes);
209 SendResponse(request_id, empty_bytes); 213 SendResponse(request_id, empty_bytes);
210 } 214 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698