| 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/renderer/pepper/pepper_plugin_instance_impl.h" | 5 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bit_cast.h" | 10 #include "base/bit_cast.h" |
| (...skipping 1729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1740 | 1740 |
| 1741 void PepperPluginInstanceImpl::ReportGeometry() { | 1741 void PepperPluginInstanceImpl::ReportGeometry() { |
| 1742 // If this call was delayed, we may have transitioned back to fullscreen in | 1742 // If this call was delayed, we may have transitioned back to fullscreen in |
| 1743 // the mean time, so only report the geometry if we are actually in normal | 1743 // the mean time, so only report the geometry if we are actually in normal |
| 1744 // mode. | 1744 // mode. |
| 1745 if (container_ && !fullscreen_container_ && !flash_fullscreen_) | 1745 if (container_ && !fullscreen_container_ && !flash_fullscreen_) |
| 1746 container_->reportGeometry(); | 1746 container_->reportGeometry(); |
| 1747 } | 1747 } |
| 1748 | 1748 |
| 1749 bool PepperPluginInstanceImpl::GetPreferredPrintOutputFormat( | 1749 bool PepperPluginInstanceImpl::GetPreferredPrintOutputFormat( |
| 1750 PP_PrintOutputFormat_Dev* format) { | 1750 PP_PrintOutputFormat_Dev* format, const WebPrintParams& print_params) { |
| 1751 // Keep a reference on the stack. See NOTE above. | 1751 // Keep a reference on the stack. See NOTE above. |
| 1752 scoped_refptr<PepperPluginInstanceImpl> ref(this); | 1752 scoped_refptr<PepperPluginInstanceImpl> ref(this); |
| 1753 if (!LoadPrintInterface()) | 1753 if (!LoadPrintInterface()) |
| 1754 return false; | 1754 return false; |
| 1755 uint32_t supported_formats = | 1755 uint32_t supported_formats = |
| 1756 plugin_print_interface_->QuerySupportedFormats(pp_instance()); | 1756 plugin_print_interface_->QuerySupportedFormats(pp_instance()); |
| 1757 if (supported_formats & PP_PRINTOUTPUTFORMAT_PDF) { | 1757 if ((supported_formats & PP_PRINTOUTPUTFORMAT_PDF) && |
| 1758 !print_params.rasterizePDF) { |
| 1758 *format = PP_PRINTOUTPUTFORMAT_PDF; | 1759 *format = PP_PRINTOUTPUTFORMAT_PDF; |
| 1759 return true; | 1760 return true; |
| 1760 } | 1761 } |
| 1762 if (supported_formats & PP_PRINTOUTPUTFORMAT_RASTER) { |
| 1763 *format = PP_PRINTOUTPUTFORMAT_RASTER; |
| 1764 return true; |
| 1765 } |
| 1761 return false; | 1766 return false; |
| 1762 } | 1767 } |
| 1763 | 1768 |
| 1764 bool PepperPluginInstanceImpl::SupportsPrintInterface() { | 1769 bool PepperPluginInstanceImpl::SupportsPrintInterface() { |
| 1765 PP_PrintOutputFormat_Dev format; | 1770 PP_PrintOutputFormat_Dev format; |
| 1766 return GetPreferredPrintOutputFormat(&format); | 1771 WebPrintParams params; |
| 1772 params.rasterizePDF = false; |
| 1773 return GetPreferredPrintOutputFormat(&format, params); |
| 1767 } | 1774 } |
| 1768 | 1775 |
| 1769 bool PepperPluginInstanceImpl::IsPrintScalingDisabled() { | 1776 bool PepperPluginInstanceImpl::IsPrintScalingDisabled() { |
| 1770 DCHECK(plugin_print_interface_); | 1777 DCHECK(plugin_print_interface_); |
| 1771 if (!plugin_print_interface_) | 1778 if (!plugin_print_interface_) |
| 1772 return false; | 1779 return false; |
| 1773 return plugin_print_interface_->IsScalingDisabled(pp_instance()) == PP_TRUE; | 1780 return plugin_print_interface_->IsScalingDisabled(pp_instance()) == PP_TRUE; |
| 1774 } | 1781 } |
| 1775 | 1782 |
| 1776 int PepperPluginInstanceImpl::PrintBegin(const WebPrintParams& print_params) { | 1783 int PepperPluginInstanceImpl::PrintBegin(const WebPrintParams& print_params) { |
| 1777 // Keep a reference on the stack. See NOTE above. | 1784 // Keep a reference on the stack. See NOTE above. |
| 1778 scoped_refptr<PepperPluginInstanceImpl> ref(this); | 1785 scoped_refptr<PepperPluginInstanceImpl> ref(this); |
| 1779 PP_PrintOutputFormat_Dev format; | 1786 PP_PrintOutputFormat_Dev format; |
| 1780 if (!GetPreferredPrintOutputFormat(&format)) { | 1787 if (!GetPreferredPrintOutputFormat(&format, print_params)) { |
| 1781 // PrintBegin should not have been called since SupportsPrintInterface | 1788 // PrintBegin should not have been called since SupportsPrintInterface |
| 1782 // would have returned false; | 1789 // would have returned false; |
| 1783 NOTREACHED(); | 1790 NOTREACHED(); |
| 1784 return 0; | 1791 return 0; |
| 1785 } | 1792 } |
| 1786 int num_pages = 0; | 1793 int num_pages = 0; |
| 1787 PP_PrintSettings_Dev print_settings; | 1794 PP_PrintSettings_Dev print_settings; |
| 1788 print_settings.printable_area = PP_FromGfxRect(print_params.printableArea); | 1795 print_settings.printable_area = PP_FromGfxRect(print_params.printableArea); |
| 1789 print_settings.content_area = PP_FromGfxRect(print_params.printContentArea); | 1796 print_settings.content_area = PP_FromGfxRect(print_params.printContentArea); |
| 1790 print_settings.paper_size = PP_FromGfxSize(print_params.paperSize); | 1797 print_settings.paper_size = PP_FromGfxSize(print_params.paperSize); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1832 // Keep a reference on the stack. See NOTE above. | 1839 // Keep a reference on the stack. See NOTE above. |
| 1833 scoped_refptr<PepperPluginInstanceImpl> ref(this); | 1840 scoped_refptr<PepperPluginInstanceImpl> ref(this); |
| 1834 DCHECK(plugin_print_interface_); | 1841 DCHECK(plugin_print_interface_); |
| 1835 if (!plugin_print_interface_) | 1842 if (!plugin_print_interface_) |
| 1836 return; | 1843 return; |
| 1837 PP_Resource print_output = plugin_print_interface_->PrintPages( | 1844 PP_Resource print_output = plugin_print_interface_->PrintPages( |
| 1838 pp_instance(), page_ranges, num_ranges); | 1845 pp_instance(), page_ranges, num_ranges); |
| 1839 if (!print_output) | 1846 if (!print_output) |
| 1840 return; | 1847 return; |
| 1841 | 1848 |
| 1842 if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_PDF) | 1849 if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_PDF || |
| 1850 current_print_settings_.format == PP_PRINTOUTPUTFORMAT_RASTER) |
| 1843 PrintPDFOutput(print_output, metafile); | 1851 PrintPDFOutput(print_output, metafile); |
| 1844 | 1852 |
| 1845 // Now we need to release the print output resource. | 1853 // Now we need to release the print output resource. |
| 1846 PluginModule::GetCore()->ReleaseResource(print_output); | 1854 PluginModule::GetCore()->ReleaseResource(print_output); |
| 1847 } | 1855 } |
| 1848 | 1856 |
| 1849 void PepperPluginInstanceImpl::PrintEnd() { | 1857 void PepperPluginInstanceImpl::PrintEnd() { |
| 1850 // Keep a reference on the stack. See NOTE above. | 1858 // Keep a reference on the stack. See NOTE above. |
| 1851 scoped_refptr<PepperPluginInstanceImpl> ref(this); | 1859 scoped_refptr<PepperPluginInstanceImpl> ref(this); |
| 1852 if (!ranges_.empty()) | 1860 if (!ranges_.empty()) |
| (...skipping 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3436 const cc::TextureMailbox& mailbox) const { | 3444 const cc::TextureMailbox& mailbox) const { |
| 3437 auto it = | 3445 auto it = |
| 3438 std::find_if(texture_ref_counts_.begin(), texture_ref_counts_.end(), | 3446 std::find_if(texture_ref_counts_.begin(), texture_ref_counts_.end(), |
| 3439 [&mailbox](const TextureMailboxRefCount& ref_count) { | 3447 [&mailbox](const TextureMailboxRefCount& ref_count) { |
| 3440 return ref_count.first.mailbox() == mailbox.mailbox(); | 3448 return ref_count.first.mailbox() == mailbox.mailbox(); |
| 3441 }); | 3449 }); |
| 3442 return it != texture_ref_counts_.end(); | 3450 return it != texture_ref_counts_.end(); |
| 3443 } | 3451 } |
| 3444 | 3452 |
| 3445 } // namespace content | 3453 } // namespace content |
| OLD | NEW |