diff options
author | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-30 15:16:43 +0000 |
---|---|---|
committer | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-30 15:16:43 +0000 |
commit | f03459840718b545f7976cf543cdec269c7a30a0 (patch) | |
tree | 6ad92cfb6f63d5e2a7752b9f140255352e2986fc /webkit | |
parent | ed3ba9dc605ce32b79188525f1ebf4d01fd8def1 (diff) | |
download | chromium_src-f03459840718b545f7976cf543cdec269c7a30a0.zip chromium_src-f03459840718b545f7976cf543cdec269c7a30a0.tar.gz chromium_src-f03459840718b545f7976cf543cdec269c7a30a0.tar.bz2 |
Remove backwards compatibility for PPP_Printing_Dev 0.3
BUG=80696
TEST=None
Review URL: http://codereview.chromium.org/7794007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98814 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.cc | 118 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.h | 39 |
2 files changed, 28 insertions, 129 deletions
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc index ab6b8e5..84d549a 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc @@ -706,30 +706,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_; @@ -765,56 +752,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); } @@ -822,7 +778,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; @@ -831,40 +787,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; @@ -876,7 +806,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) @@ -904,9 +834,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. @@ -925,8 +855,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_)); diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h index 2ce4751..bd2e54f 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.h +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h @@ -301,7 +301,7 @@ class PluginInstance : public base::RefCounted<PluginInstance>, // Queries the plugin for supported print formats and sets |format| to the // best format to use. Returns false if the plugin does not support any // print format that we can handle (we can handle raster and PDF). - bool GetPreferredPrintOutputFormat(PP_PrintOutputFormat_Dev_0_4* format); + bool GetPreferredPrintOutputFormat(PP_PrintOutputFormat_Dev* format); bool PrintPDFOutput(PP_Resource print_output, WebKit::WebCanvas* canvas); bool PrintRasterOutput(PP_Resource print_output, WebKit::WebCanvas* canvas); #if defined(OS_WIN) @@ -396,7 +396,7 @@ class PluginInstance : public base::RefCounted<PluginInstance>, // This is only valid between a successful PrintBegin call and a PrintEnd // call. - PP_PrintSettings_Dev_0_4 current_print_settings_; + PP_PrintSettings_Dev current_print_settings_; #if defined(OS_MACOSX) // On the Mac, when we draw the bitmap to the PDFContext, it seems necessary // to keep the pixels valid until CGContextEndPage is called. We use this @@ -418,39 +418,8 @@ class PluginInstance : public base::RefCounted<PluginInstance>, std::vector<PP_PrintPageNumberRange_Dev> ranges_; #endif // OS_LINUX || OS_WIN - // The plugin print interface. This nested struct adds functions needed for - // backwards compatibility. - struct PPP_Printing_Dev_Combined : public PPP_Printing_Dev_0_4 { - // Conversion constructor for the most current interface. Sets all old - // functions to NULL, so we know not to try to use them. - PPP_Printing_Dev_Combined(const PPP_Printing_Dev_0_4& base_if) - : PPP_Printing_Dev_0_4(base_if), - QuerySupportedFormats_0_3(NULL), - Begin_0_3(NULL) {} - - // Conversion constructor for version 0.3. Sets unsupported functions to - // NULL, so we know not to try to use them. - PPP_Printing_Dev_Combined(const PPP_Printing_Dev_0_3& old_if) - : PPP_Printing_Dev_0_4(), // NOTE: The parens are important, to zero- - // initialize the struct. - // Except older version of g++ doesn't! - // So do it explicitly in the ctor. - QuerySupportedFormats_0_3(old_if.QuerySupportedFormats), - Begin_0_3(old_if.Begin) { - QuerySupportedFormats = NULL; - Begin = NULL; - PrintPages = old_if.PrintPages; - End = old_if.End; - } - - // The 0.3 version of 'QuerySupportedFormats'. - PP_PrintOutputFormat_Dev_0_3* (*QuerySupportedFormats_0_3)( - PP_Instance instance, uint32_t* format_count); - // The 0.3 version of 'Begin'. - int32_t (*Begin_0_3)(PP_Instance instance, - const PP_PrintSettings_Dev_0_3* print_settings); - }; - scoped_ptr<PPP_Printing_Dev_Combined> plugin_print_interface_; + // The plugin print interface. + const PPP_Printing_Dev* plugin_print_interface_; // The plugin 3D interface. const PPP_Graphics3D_Dev* plugin_graphics_3d_interface_; |