Index: webkit/plugins/ppapi/ppapi_plugin_instance.cc |
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc |
index c353ed898e3da5c649f2c935a4fb6975f8a7ff88..f871ce2219e67a7af5d254669373bbcf2ab87417 100644 |
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc |
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc |
@@ -725,30 +725,17 @@ bool PluginInstance::LoadPolicyUpdateInterface() { |
} |
bool PluginInstance::LoadPrintInterface() { |
- if (!plugin_print_interface_.get()) { |
- // Try to get the most recent version first. Fall back to older supported |
- // versions if necessary. |
- const PPP_Printing_Dev_0_4* print_if = |
- static_cast<const PPP_Printing_Dev_0_4*>( |
- module_->GetPluginInterface(PPP_PRINTING_DEV_INTERFACE_0_4)); |
- if (print_if) { |
- plugin_print_interface_.reset(new PPP_Printing_Dev_Combined(*print_if)); |
- } else { |
- const PPP_Printing_Dev_0_3* print_if_0_3 = |
- static_cast<const PPP_Printing_Dev_0_3*>( |
- module_->GetPluginInterface(PPP_PRINTING_DEV_INTERFACE_0_3)); |
- if (print_if_0_3) |
- plugin_print_interface_.reset( |
- new PPP_Printing_Dev_Combined(*print_if_0_3)); |
- } |
+ if (!plugin_print_interface_) { |
+ plugin_print_interface_ = static_cast<const PPP_Printing_Dev*>( |
+ module_->GetPluginInterface(PPP_PRINTING_DEV_INTERFACE)); |
} |
- return !!plugin_print_interface_.get(); |
+ return !!plugin_print_interface_; |
} |
bool PluginInstance::LoadPrivateInterface() { |
if (!plugin_private_interface_) { |
plugin_private_interface_ = static_cast<const PPP_Instance_Private*>( |
- module_->GetPluginInterface(PPP_INSTANCE_PRIVATE_INTERFACE)); |
+ module_->GetPluginInterface(PPP_INSTANCE_PRIVATE_INTERFACE)); |
} |
return !!plugin_private_interface_; |
@@ -787,56 +774,25 @@ void PluginInstance::ReportGeometry() { |
} |
bool PluginInstance::GetPreferredPrintOutputFormat( |
- PP_PrintOutputFormat_Dev_0_4* format) { |
+ PP_PrintOutputFormat_Dev* format) { |
// Keep a reference on the stack. See NOTE above. |
scoped_refptr<PluginInstance> ref(this); |
if (!LoadPrintInterface()) |
return false; |
- if (plugin_print_interface_->QuerySupportedFormats) { |
- // If the most recent version of the QuerySupportedFormats functions is |
- // available, use it. |
- uint32_t supported_formats = |
- plugin_print_interface_->QuerySupportedFormats(pp_instance()); |
- if (supported_formats & PP_PRINTOUTPUTFORMAT_PDF_0_4) { |
- *format = PP_PRINTOUTPUTFORMAT_PDF_0_4; |
- return true; |
- } else if (supported_formats & PP_PRINTOUTPUTFORMAT_RASTER_0_4) { |
- *format = PP_PRINTOUTPUTFORMAT_RASTER_0_4; |
- return true; |
- } |
- return false; |
- } else if (plugin_print_interface_->QuerySupportedFormats_0_3) { |
- // If we couldn't use the latest version of the function, but the 0.3 |
- // version exists, we can use it. |
- uint32_t format_count = 0; |
- PP_PrintOutputFormat_Dev_0_3* supported_formats = |
- plugin_print_interface_->QuerySupportedFormats_0_3(pp_instance(), |
- &format_count); |
- if (!supported_formats) |
- return false; |
- |
- bool found_supported_format = false; |
- for (uint32_t index = 0; index < format_count; index++) { |
- if (supported_formats[index] == PP_PRINTOUTPUTFORMAT_PDF_0_3) { |
- // If we found PDF, we are done. |
- found_supported_format = true; |
- *format = PP_PRINTOUTPUTFORMAT_PDF_0_4; |
- break; |
- } else if (supported_formats[index] == |
- PP_PRINTOUTPUTFORMAT_RASTER_0_3) { |
- // We found raster. Keep looking. |
- found_supported_format = true; |
- *format = PP_PRINTOUTPUTFORMAT_RASTER_0_4; |
- } |
- } |
- PluginModule::GetMemoryDev()->MemFree(supported_formats); |
- return found_supported_format; |
+ uint32_t supported_formats = |
+ plugin_print_interface_->QuerySupportedFormats(pp_instance()); |
+ if (supported_formats & PP_PRINTOUTPUTFORMAT_PDF) { |
+ *format = PP_PRINTOUTPUTFORMAT_PDF; |
+ return true; |
+ } else if (supported_formats & PP_PRINTOUTPUTFORMAT_RASTER) { |
+ *format = PP_PRINTOUTPUTFORMAT_RASTER; |
+ return true; |
} |
return false; |
} |
bool PluginInstance::SupportsPrintInterface() { |
- PP_PrintOutputFormat_Dev_0_4 format; |
+ PP_PrintOutputFormat_Dev format; |
return GetPreferredPrintOutputFormat(&format); |
} |
@@ -844,7 +800,7 @@ int PluginInstance::PrintBegin(const gfx::Rect& printable_area, |
int printer_dpi) { |
// Keep a reference on the stack. See NOTE above. |
scoped_refptr<PluginInstance> ref(this); |
- PP_PrintOutputFormat_Dev_0_4 format; |
+ PP_PrintOutputFormat_Dev format; |
if (!GetPreferredPrintOutputFormat(&format)) { |
// PrintBegin should not have been called since SupportsPrintInterface |
// would have returned false; |
@@ -853,40 +809,14 @@ int PluginInstance::PrintBegin(const gfx::Rect& printable_area, |
} |
int num_pages = 0; |
- PP_PrintSettings_Dev_0_4 print_settings; |
+ PP_PrintSettings_Dev print_settings; |
RectToPPRect(printable_area, &print_settings.printable_area); |
print_settings.dpi = printer_dpi; |
print_settings.orientation = PP_PRINTORIENTATION_NORMAL; |
print_settings.grayscale = PP_FALSE; |
print_settings.format = format; |
- if (plugin_print_interface_->Begin) { |
- // If we have the most current version of Begin, use it. |
- num_pages = plugin_print_interface_->Begin(pp_instance(), |
- &print_settings); |
- } else if (plugin_print_interface_->Begin_0_3) { |
- // Fall back to the 0.3 version of Begin if necessary, and convert the |
- // output format. |
- PP_PrintSettings_Dev_0_3 print_settings_0_3; |
- RectToPPRect(printable_area, &print_settings_0_3.printable_area); |
- print_settings_0_3.dpi = printer_dpi; |
- print_settings_0_3.orientation = PP_PRINTORIENTATION_NORMAL; |
- print_settings_0_3.grayscale = PP_FALSE; |
- switch (format) { |
- case PP_PRINTOUTPUTFORMAT_RASTER_0_4: |
- print_settings_0_3.format = PP_PRINTOUTPUTFORMAT_RASTER_0_3; |
- break; |
- case PP_PRINTOUTPUTFORMAT_PDF_0_4: |
- print_settings_0_3.format = PP_PRINTOUTPUTFORMAT_PDF_0_3; |
- break; |
- case PP_PRINTOUTPUTFORMAT_POSTSCRIPT_0_4: |
- print_settings_0_3.format = PP_PRINTOUTPUTFORMAT_POSTSCRIPT_0_3; |
- break; |
- default: |
- return 0; |
- } |
- num_pages = plugin_print_interface_->Begin_0_3(pp_instance(), |
- &print_settings_0_3); |
- } |
+ num_pages = plugin_print_interface_->Begin(pp_instance(), |
+ &print_settings); |
if (!num_pages) |
return 0; |
current_print_settings_ = print_settings; |
@@ -898,7 +828,7 @@ int PluginInstance::PrintBegin(const gfx::Rect& printable_area, |
} |
bool PluginInstance::PrintPage(int page_number, WebKit::WebCanvas* canvas) { |
- DCHECK(plugin_print_interface_.get()); |
+ DCHECK(plugin_print_interface_); |
PP_PrintPageNumberRange_Dev page_range; |
page_range.first_page_number = page_range.last_page_number = page_number; |
#if defined(OS_LINUX) || defined(OS_WIN) |
@@ -926,9 +856,9 @@ bool PluginInstance::PrintPageHelper(PP_PrintPageNumberRange_Dev* page_ranges, |
bool ret = false; |
- if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_PDF_0_4) |
+ if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_PDF) |
ret = PrintPDFOutput(print_output, canvas); |
- else if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_RASTER_0_4) |
+ else if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_RASTER) |
ret = PrintRasterOutput(print_output, canvas); |
// Now we need to release the print output resource. |
@@ -947,8 +877,8 @@ void PluginInstance::PrintEnd() { |
ranges_.clear(); |
#endif // OS_LINUX || OS_WIN |
- DCHECK(plugin_print_interface_.get()); |
- if (plugin_print_interface_.get()) |
+ DCHECK(plugin_print_interface_); |
+ if (plugin_print_interface_) |
plugin_print_interface_->End(pp_instance()); |
memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); |