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/utility/utility_thread.h" | 5 #include "chrome/utility/utility_thread.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 return false; | 258 return false; |
259 | 259 |
260 int total_page_count = 0; | 260 int total_page_count = 0; |
261 if (!get_info_proc(&buffer.front(), buffer.size(), &total_page_count, NULL)) | 261 if (!get_info_proc(&buffer.front(), buffer.size(), &total_page_count, NULL)) |
262 return false; | 262 return false; |
263 | 263 |
264 metafile->CreateFileBackedDc(NULL, NULL, metafile_path); | 264 metafile->CreateFileBackedDc(NULL, NULL, metafile_path); |
265 // Since we created the metafile using the screen DPI (but we actually want | 265 // Since we created the metafile using the screen DPI (but we actually want |
266 // the PDF DLL to print using the passed in render_dpi, we apply the following | 266 // the PDF DLL to print using the passed in render_dpi, we apply the following |
267 // transformation. | 267 // transformation. |
268 SetGraphicsMode(metafile->hdc(), GM_ADVANCED); | 268 SetGraphicsMode(metafile->context(), GM_ADVANCED); |
269 XFORM xform = {0}; | 269 XFORM xform = {0}; |
270 int screen_dpi = GetDeviceCaps(GetDC(NULL), LOGPIXELSX); | 270 int screen_dpi = GetDeviceCaps(GetDC(NULL), LOGPIXELSX); |
271 xform.eM11 = xform.eM22 = | 271 xform.eM11 = xform.eM22 = |
272 static_cast<float>(screen_dpi) / static_cast<float>(render_dpi); | 272 static_cast<float>(screen_dpi) / static_cast<float>(render_dpi); |
273 ModifyWorldTransform(metafile->hdc(), &xform, MWT_LEFTMULTIPLY); | 273 ModifyWorldTransform(metafile->context(), &xform, MWT_LEFTMULTIPLY); |
274 | 274 |
275 bool ret = false; | 275 bool ret = false; |
276 std::vector<printing::PageRange>::const_iterator iter; | 276 std::vector<printing::PageRange>::const_iterator iter; |
277 for (iter = page_ranges.begin(); iter != page_ranges.end(); ++iter) { | 277 for (iter = page_ranges.begin(); iter != page_ranges.end(); ++iter) { |
278 for (int page_number = iter->from; page_number <= iter->to; ++page_number) { | 278 for (int page_number = iter->from; page_number <= iter->to; ++page_number) { |
279 if (page_number >= total_page_count) | 279 if (page_number >= total_page_count) |
280 break; | 280 break; |
281 metafile->StartPage(); | 281 metafile->StartPage(); |
282 if (render_proc(&buffer.front(), buffer.size(), page_number, | 282 if (render_proc(&buffer.front(), buffer.size(), page_number, |
283 metafile->hdc(), render_dpi, render_dpi, | 283 metafile->context(), render_dpi, render_dpi, |
284 render_area.x(), render_area.y(), render_area.width(), | 284 render_area.x(), render_area.y(), render_area.width(), |
285 render_area.height(), true, false, true, true)) | 285 render_area.height(), true, false, true, true)) |
286 if (*highest_rendered_page_number < page_number) | 286 if (*highest_rendered_page_number < page_number) |
287 *highest_rendered_page_number = page_number; | 287 *highest_rendered_page_number = page_number; |
288 ret = true; | 288 ret = true; |
289 metafile->EndPage(); | 289 metafile->FinishPage(); |
290 } | 290 } |
291 } | 291 } |
292 metafile->CloseDc(); | 292 metafile->Close(); |
293 return ret; | 293 return ret; |
294 } | 294 } |
295 #endif // defined(OS_WIN) | 295 #endif // defined(OS_WIN) |
296 | 296 |
297 void UtilityThread::OnIDBKeysFromValuesAndKeyPath( | 297 void UtilityThread::OnIDBKeysFromValuesAndKeyPath( |
298 int id, | 298 int id, |
299 const std::vector<SerializedScriptValue>& serialized_script_values, | 299 const std::vector<SerializedScriptValue>& serialized_script_values, |
300 const string16& idb_key_path) { | 300 const string16& idb_key_path) { |
301 std::vector<WebKit::WebSerializedScriptValue> web_values; | 301 std::vector<WebKit::WebSerializedScriptValue> web_values; |
302 ConvertVector(serialized_script_values, &web_values); | 302 ConvertVector(serialized_script_values, &web_values); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 } else { | 341 } else { |
342 Send(new UtilityHostMsg_GetPrinterCapsAndDefaults_Failed(printer_name)); | 342 Send(new UtilityHostMsg_GetPrinterCapsAndDefaults_Failed(printer_name)); |
343 } | 343 } |
344 ReleaseProcessIfNeeded(); | 344 ReleaseProcessIfNeeded(); |
345 } | 345 } |
346 | 346 |
347 void UtilityThread::ReleaseProcessIfNeeded() { | 347 void UtilityThread::ReleaseProcessIfNeeded() { |
348 if (!batch_mode_) | 348 if (!batch_mode_) |
349 ChildProcess::current()->ReleaseProcess(); | 349 ChildProcess::current()->ReleaseProcess(); |
350 } | 350 } |
OLD | NEW |