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

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

Issue 478183005: Added PrintingContext::Delegate to get parent view handle and application locale. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Wed Aug 20 16:46:22 PDT 2014 Created 6 years, 4 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_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
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
264 gfx::Size GetDefaultPdfMediaSizeMicrons() { 273 gfx::Size GetDefaultPdfMediaSizeMicrons() {
274 PrintingContextDelegate delegate;
265 scoped_ptr<printing::PrintingContext> printing_context( 275 scoped_ptr<printing::PrintingContext> printing_context(
266 printing::PrintingContext::Create( 276 printing::PrintingContext::Create(&delegate));
267 g_browser_process->GetApplicationLocale()));
268 if (printing::PrintingContext::OK != printing_context->UsePdfSettings() || 277 if (printing::PrintingContext::OK != printing_context->UsePdfSettings() ||
269 printing_context->settings().device_units_per_inch() <= 0) { 278 printing_context->settings().device_units_per_inch() <= 0) {
270 return gfx::Size(); 279 return gfx::Size();
271 } 280 }
272 gfx::Size pdf_media_size = printing_context->GetPdfPaperSizeDeviceUnits(); 281 gfx::Size pdf_media_size = printing_context->GetPdfPaperSizeDeviceUnits();
273 float deviceMicronsPerDeviceUnit = 282 float deviceMicronsPerDeviceUnit =
274 (printing::kHundrethsMMPerInch * 10.0f) / 283 (printing::kHundrethsMMPerInch * 10.0f) /
275 printing_context->settings().device_units_per_inch(); 284 printing_context->settings().device_units_per_inch();
276 return gfx::Size(pdf_media_size.width() * deviceMicronsPerDeviceUnit, 285 return gfx::Size(pdf_media_size.width() * deviceMicronsPerDeviceUnit,
277 pdf_media_size.height() * deviceMicronsPerDeviceUnit); 286 pdf_media_size.height() * deviceMicronsPerDeviceUnit);
(...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1561 1570
1562 void PrintPreviewHandler::UnregisterForMergeSession() { 1571 void PrintPreviewHandler::UnregisterForMergeSession() {
1563 if (reconcilor_) 1572 if (reconcilor_)
1564 reconcilor_->RemoveMergeSessionObserver(this); 1573 reconcilor_->RemoveMergeSessionObserver(this);
1565 } 1574 }
1566 1575
1567 void PrintPreviewHandler::SetPdfSavedClosureForTesting( 1576 void PrintPreviewHandler::SetPdfSavedClosureForTesting(
1568 const base::Closure& closure) { 1577 const base::Closure& closure) {
1569 pdf_file_saved_closure_ = closure; 1578 pdf_file_saved_closure_ = closure;
1570 } 1579 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698