| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 1724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1735 print_settings.format = format; | 1735 print_settings.format = format; |
| 1736 num_pages = plugin_print_interface_->Begin(pp_instance(), &print_settings); | 1736 num_pages = plugin_print_interface_->Begin(pp_instance(), &print_settings); |
| 1737 if (!num_pages) | 1737 if (!num_pages) |
| 1738 return 0; | 1738 return 0; |
| 1739 current_print_settings_ = print_settings; | 1739 current_print_settings_ = print_settings; |
| 1740 canvas_.clear(); | 1740 canvas_.clear(); |
| 1741 ranges_.clear(); | 1741 ranges_.clear(); |
| 1742 return num_pages; | 1742 return num_pages; |
| 1743 } | 1743 } |
| 1744 | 1744 |
| 1745 bool PepperPluginInstanceImpl::PrintPage(int page_number, | 1745 void PepperPluginInstanceImpl::PrintPage(int page_number, |
| 1746 blink::WebCanvas* canvas) { | 1746 blink::WebCanvas* canvas) { |
| 1747 #if defined(ENABLE_PRINTING) | 1747 #if defined(ENABLE_PRINTING) |
| 1748 DCHECK(plugin_print_interface_); | 1748 DCHECK(plugin_print_interface_); |
| 1749 PP_PrintPageNumberRange_Dev page_range; | 1749 PP_PrintPageNumberRange_Dev page_range; |
| 1750 page_range.first_page_number = page_range.last_page_number = page_number; | 1750 page_range.first_page_number = page_range.last_page_number = page_number; |
| 1751 // The canvas only has a metafile on it for print preview. | 1751 // The canvas only has a metafile on it for print preview. |
| 1752 bool save_for_later = | 1752 bool save_for_later = |
| 1753 (printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas) != NULL); | 1753 (printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas) != NULL); |
| 1754 #if defined(OS_MACOSX) | 1754 #if defined(OS_MACOSX) |
| 1755 save_for_later = save_for_later && skia::IsPreviewMetafile(*canvas); | 1755 save_for_later = save_for_later && skia::IsPreviewMetafile(*canvas); |
| 1756 #endif // defined(OS_MACOSX) | 1756 #endif // defined(OS_MACOSX) |
| 1757 if (save_for_later) { | 1757 if (save_for_later) { |
| 1758 ranges_.push_back(page_range); | 1758 ranges_.push_back(page_range); |
| 1759 canvas_ = skia::SharePtr(canvas); | 1759 canvas_ = skia::SharePtr(canvas); |
| 1760 return true; | |
| 1761 } else { | 1760 } else { |
| 1762 return PrintPageHelper(&page_range, 1, canvas); | 1761 PrintPageHelper(&page_range, 1, canvas); |
| 1763 } | 1762 } |
| 1764 #else // ENABLE_PRINTING | |
| 1765 return false; | |
| 1766 #endif | 1763 #endif |
| 1767 } | 1764 } |
| 1768 | 1765 |
| 1769 bool PepperPluginInstanceImpl::PrintPageHelper( | 1766 void PepperPluginInstanceImpl::PrintPageHelper( |
| 1770 PP_PrintPageNumberRange_Dev* page_ranges, | 1767 PP_PrintPageNumberRange_Dev* page_ranges, |
| 1771 int num_ranges, | 1768 int num_ranges, |
| 1772 blink::WebCanvas* canvas) { | 1769 blink::WebCanvas* canvas) { |
| 1773 // Keep a reference on the stack. See NOTE above. | 1770 // Keep a reference on the stack. See NOTE above. |
| 1774 scoped_refptr<PepperPluginInstanceImpl> ref(this); | 1771 scoped_refptr<PepperPluginInstanceImpl> ref(this); |
| 1775 DCHECK(plugin_print_interface_); | 1772 DCHECK(plugin_print_interface_); |
| 1776 if (!plugin_print_interface_) | 1773 if (!plugin_print_interface_) |
| 1777 return false; | 1774 return; |
| 1778 PP_Resource print_output = plugin_print_interface_->PrintPages( | 1775 PP_Resource print_output = plugin_print_interface_->PrintPages( |
| 1779 pp_instance(), page_ranges, num_ranges); | 1776 pp_instance(), page_ranges, num_ranges); |
| 1780 if (!print_output) | 1777 if (!print_output) |
| 1781 return false; | 1778 return; |
| 1782 | |
| 1783 bool ret = false; | |
| 1784 | 1779 |
| 1785 if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_PDF) | 1780 if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_PDF) |
| 1786 ret = PrintPDFOutput(print_output, canvas); | 1781 PrintPDFOutput(print_output, canvas); |
| 1787 | 1782 |
| 1788 // Now we need to release the print output resource. | 1783 // Now we need to release the print output resource. |
| 1789 PluginModule::GetCore()->ReleaseResource(print_output); | 1784 PluginModule::GetCore()->ReleaseResource(print_output); |
| 1790 | |
| 1791 return ret; | |
| 1792 } | 1785 } |
| 1793 | 1786 |
| 1794 void PepperPluginInstanceImpl::PrintEnd() { | 1787 void PepperPluginInstanceImpl::PrintEnd() { |
| 1795 // Keep a reference on the stack. See NOTE above. | 1788 // Keep a reference on the stack. See NOTE above. |
| 1796 scoped_refptr<PepperPluginInstanceImpl> ref(this); | 1789 scoped_refptr<PepperPluginInstanceImpl> ref(this); |
| 1797 if (!ranges_.empty()) | 1790 if (!ranges_.empty()) |
| 1798 PrintPageHelper(&(ranges_.front()), ranges_.size(), canvas_.get()); | 1791 PrintPageHelper(&(ranges_.front()), ranges_.size(), canvas_.get()); |
| 1799 canvas_.clear(); | 1792 canvas_.clear(); |
| 1800 ranges_.clear(); | 1793 ranges_.clear(); |
| 1801 | 1794 |
| (...skipping 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3304 | 3297 |
| 3305 void PepperPluginInstanceImpl::RecordFlashJavaScriptUse() { | 3298 void PepperPluginInstanceImpl::RecordFlashJavaScriptUse() { |
| 3306 if (initialized_ && !javascript_used_ && is_flash_plugin_) { | 3299 if (initialized_ && !javascript_used_ && is_flash_plugin_) { |
| 3307 javascript_used_ = true; | 3300 javascript_used_ = true; |
| 3308 RenderThread::Get()->RecordAction( | 3301 RenderThread::Get()->RecordAction( |
| 3309 base::UserMetricsAction("Flash.JavaScriptUsed")); | 3302 base::UserMetricsAction("Flash.JavaScriptUsed")); |
| 3310 } | 3303 } |
| 3311 } | 3304 } |
| 3312 | 3305 |
| 3313 } // namespace content | 3306 } // namespace content |
| OLD | NEW |