OLD | NEW |
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_handler.h" | 5 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 254 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
255 | 255 |
256 scoped_refptr<printing::PrintBackend> print_backend( | 256 scoped_refptr<printing::PrintBackend> print_backend( |
257 printing::PrintBackend::CreateInstance(NULL)); | 257 printing::PrintBackend::CreateInstance(NULL)); |
258 | 258 |
259 std::string default_printer = print_backend->GetDefaultPrinterName(); | 259 std::string default_printer = print_backend->GetDefaultPrinterName(); |
260 VLOG(1) << "Default Printer: " << default_printer; | 260 VLOG(1) << "Default Printer: " << default_printer; |
261 return default_printer; | 261 return default_printer; |
262 } | 262 } |
263 | 263 |
264 class PrintingContextDelegate : public printing::PrintingContext::Delegate { | |
265 public: | |
266 // PrintingContext::Delegate methods. | |
267 virtual gfx::NativeView GetParentView() OVERRIDE { return NULL; } | |
268 virtual std::string GetAppLocale() OVERRIDE { | |
269 return g_browser_process->GetApplicationLocale(); | |
270 } | |
271 }; | |
272 | |
273 gfx::Size GetDefaultPdfMediaSizeMicrons() { | 264 gfx::Size GetDefaultPdfMediaSizeMicrons() { |
274 PrintingContextDelegate delegate; | |
275 scoped_ptr<printing::PrintingContext> printing_context( | 265 scoped_ptr<printing::PrintingContext> printing_context( |
276 printing::PrintingContext::Create(&delegate)); | 266 printing::PrintingContext::Create( |
| 267 g_browser_process->GetApplicationLocale())); |
277 if (printing::PrintingContext::OK != printing_context->UsePdfSettings() || | 268 if (printing::PrintingContext::OK != printing_context->UsePdfSettings() || |
278 printing_context->settings().device_units_per_inch() <= 0) { | 269 printing_context->settings().device_units_per_inch() <= 0) { |
279 return gfx::Size(); | 270 return gfx::Size(); |
280 } | 271 } |
281 gfx::Size pdf_media_size = printing_context->GetPdfPaperSizeDeviceUnits(); | 272 gfx::Size pdf_media_size = printing_context->GetPdfPaperSizeDeviceUnits(); |
282 float deviceMicronsPerDeviceUnit = | 273 float deviceMicronsPerDeviceUnit = |
283 (printing::kHundrethsMMPerInch * 10.0f) / | 274 (printing::kHundrethsMMPerInch * 10.0f) / |
284 printing_context->settings().device_units_per_inch(); | 275 printing_context->settings().device_units_per_inch(); |
285 return gfx::Size(pdf_media_size.width() * deviceMicronsPerDeviceUnit, | 276 return gfx::Size(pdf_media_size.width() * deviceMicronsPerDeviceUnit, |
286 pdf_media_size.height() * deviceMicronsPerDeviceUnit); | 277 pdf_media_size.height() * deviceMicronsPerDeviceUnit); |
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1565 | 1556 |
1566 void PrintPreviewHandler::UnregisterForMergeSession() { | 1557 void PrintPreviewHandler::UnregisterForMergeSession() { |
1567 if (reconcilor_) | 1558 if (reconcilor_) |
1568 reconcilor_->RemoveMergeSessionObserver(this); | 1559 reconcilor_->RemoveMergeSessionObserver(this); |
1569 } | 1560 } |
1570 | 1561 |
1571 void PrintPreviewHandler::SetPdfSavedClosureForTesting( | 1562 void PrintPreviewHandler::SetPdfSavedClosureForTesting( |
1572 const base::Closure& closure) { | 1563 const base::Closure& closure) { |
1573 pdf_file_saved_closure_ = closure; | 1564 pdf_file_saved_closure_ = closure; |
1574 } | 1565 } |
OLD | NEW |