diff options
author | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-17 02:49:34 +0000 |
---|---|---|
committer | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-17 02:49:34 +0000 |
commit | e3ec725ec3b9e1f84a487ffe94433e3a3d2b21c7 (patch) | |
tree | 2ef2957fa51281f49cde343d193d9410ea8af38e /webkit/plugins | |
parent | 8f70cf2540642898489ff84fb59d99805d5a9b0e (diff) | |
download | chromium_src-e3ec725ec3b9e1f84a487ffe94433e3a3d2b21c7.zip chromium_src-e3ec725ec3b9e1f84a487ffe94433e3a3d2b21c7.tar.gz chromium_src-e3ec725ec3b9e1f84a487ffe94433e3a3d2b21c7.tar.bz2 |
Update PPP_Printing_Dev to always make both versions of types available.
With this change, webkit/plugins/ppapi (and proxy) code does not need to use any precompiler defines, and instead refers to each version by its versioned name.
BUG=80696
TEST=Manually run PDF plugin.
Review URL: http://codereview.chromium.org/7197001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89444 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins')
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.cc | 45 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.h | 23 |
2 files changed, 33 insertions, 35 deletions
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc index 67ff91e..e38317f 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc @@ -739,8 +739,9 @@ 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* print_if = static_cast<const PPP_Printing_Dev*>( - module_->GetPluginInterface(PPP_PRINTING_DEV_INTERFACE)); + 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 { @@ -787,7 +788,7 @@ void PluginInstance::ReportGeometry() { } bool PluginInstance::GetPreferredPrintOutputFormat( - PP_PrintOutputFormat_Dev* format) { + PP_PrintOutputFormat_Dev_0_4* format) { // Keep a reference on the stack. See NOTE above. scoped_refptr<PluginInstance> ref(this); if (!LoadPrintInterface()) @@ -797,11 +798,11 @@ bool PluginInstance::GetPreferredPrintOutputFormat( // available, use it. uint32_t supported_formats = plugin_print_interface_->QuerySupportedFormats(pp_instance()); - if (supported_formats & PP_PRINTOUTPUTFORMAT_PDF) { - *format = PP_PRINTOUTPUTFORMAT_PDF; + if (supported_formats & PP_PRINTOUTPUTFORMAT_PDF_0_4) { + *format = PP_PRINTOUTPUTFORMAT_PDF_0_4; return true; - } else if (supported_formats & PP_PRINTOUTPUTFORMAT_RASTER) { - *format = PP_PRINTOUTPUTFORMAT_RASTER; + } else if (supported_formats & PP_PRINTOUTPUTFORMAT_RASTER_0_4) { + *format = PP_PRINTOUTPUTFORMAT_RASTER_0_4; return true; } return false; @@ -817,16 +818,16 @@ bool PluginInstance::GetPreferredPrintOutputFormat( bool found_supported_format = false; for (uint32_t index = 0; index < format_count; index++) { - if (supported_formats[index] == PP_PRINTOUTPUTFORMAT_PDF_DEPRECATED) { + if (supported_formats[index] == PP_PRINTOUTPUTFORMAT_PDF_0_3) { // If we found PDF, we are done. found_supported_format = true; - *format = PP_PRINTOUTPUTFORMAT_PDF; + *format = PP_PRINTOUTPUTFORMAT_PDF_0_4; break; } else if (supported_formats[index] == - PP_PRINTOUTPUTFORMAT_RASTER_DEPRECATED) { + PP_PRINTOUTPUTFORMAT_RASTER_0_3) { // We found raster. Keep looking. found_supported_format = true; - *format = PP_PRINTOUTPUTFORMAT_RASTER; + *format = PP_PRINTOUTPUTFORMAT_RASTER_0_4; } } PluginModule::GetCore()->MemFree(supported_formats); @@ -836,7 +837,7 @@ bool PluginInstance::GetPreferredPrintOutputFormat( } bool PluginInstance::SupportsPrintInterface() { - PP_PrintOutputFormat_Dev format; + PP_PrintOutputFormat_Dev_0_4 format; return GetPreferredPrintOutputFormat(&format); } @@ -844,7 +845,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 format; + PP_PrintOutputFormat_Dev_0_4 format; if (!GetPreferredPrintOutputFormat(&format)) { // PrintBegin should not have been called since SupportsPrintInterface // would have returned false; @@ -853,7 +854,7 @@ int PluginInstance::PrintBegin(const gfx::Rect& printable_area, } int num_pages = 0; - PP_PrintSettings_Dev print_settings; + PP_PrintSettings_Dev_0_4 print_settings; RectToPPRect(printable_area, &print_settings.printable_area); print_settings.dpi = printer_dpi; print_settings.orientation = PP_PRINTORIENTATION_NORMAL; @@ -872,14 +873,14 @@ int PluginInstance::PrintBegin(const gfx::Rect& printable_area, print_settings_0_3.orientation = PP_PRINTORIENTATION_NORMAL; print_settings_0_3.grayscale = PP_FALSE; switch (format) { - case PP_PRINTOUTPUTFORMAT_RASTER: - print_settings_0_3.format = PP_PRINTOUTPUTFORMAT_RASTER_DEPRECATED; + case PP_PRINTOUTPUTFORMAT_RASTER_0_4: + print_settings_0_3.format = PP_PRINTOUTPUTFORMAT_RASTER_0_3; break; - case PP_PRINTOUTPUTFORMAT_PDF: - print_settings_0_3.format = PP_PRINTOUTPUTFORMAT_PDF_DEPRECATED; + case PP_PRINTOUTPUTFORMAT_PDF_0_4: + print_settings_0_3.format = PP_PRINTOUTPUTFORMAT_PDF_0_3; break; - case PP_PRINTOUTPUTFORMAT_POSTSCRIPT: - print_settings_0_3.format = PP_PRINTOUTPUTFORMAT_POSTSCRIPT_DEPRECATED; + case PP_PRINTOUTPUTFORMAT_POSTSCRIPT_0_4: + print_settings_0_3.format = PP_PRINTOUTPUTFORMAT_POSTSCRIPT_0_3; break; default: return 0; @@ -926,9 +927,9 @@ bool PluginInstance::PrintPageHelper(PP_PrintPageNumberRange_Dev* page_ranges, bool ret = false; - if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_PDF) + if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_PDF_0_4) ret = PrintPDFOutput(print_output, canvas); - else if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_RASTER) + else if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_RASTER_0_4) ret = PrintRasterOutput(print_output, canvas); // Now we need to release the print output resource. diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h index 3088d4c..2ef4710 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.h +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h @@ -18,9 +18,6 @@ #include "googleurl/src/gurl.h" #include "ppapi/c/dev/pp_cursor_type_dev.h" #include "ppapi/c/dev/ppp_graphics_3d_dev.h" -// TODO(dmichael): Remove the 0.3 printing interface and remove the following -// #define. -#define PPP_PRINTING_DEV_USE_0_4 1 #include "ppapi/c/dev/ppp_printing_dev.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" @@ -312,7 +309,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* format); + bool GetPreferredPrintOutputFormat(PP_PrintOutputFormat_Dev_0_4* format); bool PrintPDFOutput(PP_Resource print_output, WebKit::WebCanvas* canvas); bool PrintRasterOutput(PP_Resource print_output, WebKit::WebCanvas* canvas); #if defined(OS_WIN) @@ -397,7 +394,7 @@ class PluginInstance : public base::RefCounted<PluginInstance>, // This is only valid between a successful PrintBegin call and a PrintEnd // call. - PP_PrintSettings_Dev current_print_settings_; + PP_PrintSettings_Dev_0_4 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 @@ -421,21 +418,21 @@ class PluginInstance : public base::RefCounted<PluginInstance>, // The plugin print interface. This nested struct adds functions needed for // backwards compatibility. - struct PPP_Printing_Dev_Combined : public PPP_Printing_Dev { + 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& base_if) - : PPP_Printing_Dev(base_if), + 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(), // NOTE: The parens are important, to zero- - // initialize the struct. - // Except older version of g++ doesn't! - // So do it explicitly in the ctor. + : 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; @@ -449,7 +446,7 @@ class PluginInstance : public base::RefCounted<PluginInstance>, PP_Instance instance, uint32_t* format_count); // The 0.3 version of 'Begin'. int32_t (*Begin_0_3)(PP_Instance instance, - const struct PP_PrintSettings_Dev_0_3* print_settings); + const PP_PrintSettings_Dev_0_3* print_settings); }; scoped_ptr<PPP_Printing_Dev_Combined> plugin_print_interface_; |