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 "content/browser/renderer_host/pepper/pepper_print_settings_manager.h" | 5 #include "content/browser/renderer_host/pepper/pepper_print_settings_manager.h" |
6 | 6 |
7 #include "content/public/browser/browser_thread.h" | 7 #include "content/public/browser/browser_thread.h" |
8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
9 #include "printing/printing_context.h" | 9 #include "printing/printing_context.h" |
10 #include "printing/units.h" | 10 #include "printing/units.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 result.point.y = DeviceUnitsInPoints(print_area.origin().y(), | 38 result.point.y = DeviceUnitsInPoints(print_area.origin().y(), |
39 device_units_per_inch); | 39 device_units_per_inch); |
40 result.size = PrintSizeToPPPrintSize(print_area.size(), | 40 result.size = PrintSizeToPPPrintSize(print_area.size(), |
41 device_units_per_inch); | 41 device_units_per_inch); |
42 return result; | 42 return result; |
43 } | 43 } |
44 | 44 |
45 PepperPrintSettingsManager::Result ComputeDefaultPrintSettings() { | 45 PepperPrintSettingsManager::Result ComputeDefaultPrintSettings() { |
46 // This function should run on the UI thread because |PrintingContext| methods | 46 // This function should run on the UI thread because |PrintingContext| methods |
47 // call into platform APIs. | 47 // call into platform APIs. |
48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 48 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
49 scoped_ptr<printing::PrintingContext> context( | 49 scoped_ptr<printing::PrintingContext> context( |
50 printing::PrintingContext::Create(std::string())); | 50 printing::PrintingContext::Create(std::string())); |
51 if (!context.get() || | 51 if (!context.get() || |
52 context->UseDefaultSettings() != printing::PrintingContext::OK) { | 52 context->UseDefaultSettings() != printing::PrintingContext::OK) { |
53 return PepperPrintSettingsManager::Result(PP_PrintSettings_Dev(), | 53 return PepperPrintSettingsManager::Result(PP_PrintSettings_Dev(), |
54 PP_ERROR_FAILED); | 54 PP_ERROR_FAILED); |
55 } | 55 } |
56 const printing::PrintSettings& print_settings = context->settings(); | 56 const printing::PrintSettings& print_settings = context->settings(); |
57 const printing::PageSetup& page_setup = | 57 const printing::PageSetup& page_setup = |
58 print_settings.page_setup_device_units(); | 58 print_settings.page_setup_device_units(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 } // namespace | 93 } // namespace |
94 | 94 |
95 void PepperPrintSettingsManagerImpl::GetDefaultPrintSettings( | 95 void PepperPrintSettingsManagerImpl::GetDefaultPrintSettings( |
96 PepperPrintSettingsManager::Callback callback) { | 96 PepperPrintSettingsManager::Callback callback) { |
97 BrowserThread::PostTaskAndReplyWithResult(BrowserThread::UI, FROM_HERE, | 97 BrowserThread::PostTaskAndReplyWithResult(BrowserThread::UI, FROM_HERE, |
98 base::Bind(ComputeDefaultPrintSettings), callback); | 98 base::Bind(ComputeDefaultPrintSettings), callback); |
99 } | 99 } |
100 | 100 |
101 } // namespace content | 101 } // namespace content |
OLD | NEW |