diff options
author | gene@chromium.org <gene@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-10 17:34:57 +0000 |
---|---|---|
committer | gene@chromium.org <gene@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-10 17:34:57 +0000 |
commit | e932f077ac1794b19e10318cf81049b3b63df2a7 (patch) | |
tree | 491731cc239d57d042be0daaee4e342193fbd4fb | |
parent | 98f83b3d9b3b8499ad1fef2c2ec007b5fa4debc8 (diff) | |
download | chromium_src-e932f077ac1794b19e10318cf81049b3b63df2a7.zip chromium_src-e932f077ac1794b19e10318cf81049b3b63df2a7.tar.gz chromium_src-e932f077ac1794b19e10318cf81049b3b63df2a7.tar.bz2 |
Added PDF resources to Chrome.
Added private interface to access resources from pepper plugin.
Added example to PDF srting resource.
BUG=54322
TEST=none
Review URL: http://codereview.chromium.org/3305029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59111 0039d316-1c4b-4281-b951-d872f2087c98
27 files changed, 128 insertions, 1 deletions
diff --git a/webkit/glue/plugins/pepper_private.cc b/webkit/glue/plugins/pepper_private.cc index e88eb61..b8f46cd 100644 --- a/webkit/glue/plugins/pepper_private.cc +++ b/webkit/glue/plugins/pepper_private.cc @@ -6,9 +6,14 @@ #include "webkit/glue/plugins/pepper_private.h" +#include "app/resource_bundle.h" #include "base/utf_string_conversions.h" +#include "grit/webkit_resources.h" #include "grit/webkit_strings.h" +#include "skia/ext/platform_canvas.h" +#include "third_party/skia/include/core/SkBitmap.h" #include "webkit/glue/webkit_glue.h" +#include "webkit/glue/plugins/pepper_image_data.h" #include "webkit/glue/plugins/pepper_plugin_module.h" #include "webkit/glue/plugins/pepper_var.h" #include "webkit/glue/plugins/ppb_private.h" @@ -33,6 +38,37 @@ class PrivateFontFile : public Resource { }; #endif +static const struct { + PP_ResourceImage pp_id; + int res_id; +} kResourceImageMap[] = { + { PP_RESOURCEIMAGE_PDF_BUTTON_FTH, IDR_PDF_BUTTON_FTH }, + { PP_RESOURCEIMAGE_PDF_BUTTON_FTH_HOVER, IDR_PDF_BUTTON_FTH_HOVER }, + { PP_RESOURCEIMAGE_PDF_BUTTON_FTH_PRESSED, IDR_PDF_BUTTON_FTH_PRESSED }, + { PP_RESOURCEIMAGE_PDF_BUTTON_FTW, IDR_PDF_BUTTON_FTW }, + { PP_RESOURCEIMAGE_PDF_BUTTON_FTW_HOVER, IDR_PDF_BUTTON_FTW_HOVER }, + { PP_RESOURCEIMAGE_PDF_BUTTON_FTW_PRESSED, IDR_PDF_BUTTON_FTW_PRESSED }, + { PP_RESOURCEIMAGE_PDF_BUTTON_ZOOMIN, IDR_PDF_BUTTON_ZOOMIN }, + { PP_RESOURCEIMAGE_PDF_BUTTON_ZOOMIN_HOVER, IDR_PDF_BUTTON_ZOOMIN_HOVER }, + { PP_RESOURCEIMAGE_PDF_BUTTON_ZOOMIN_PRESSED, IDR_PDF_BUTTON_ZOOMIN_PRESSED }, + { PP_RESOURCEIMAGE_PDF_BUTTON_ZOOMOUT, IDR_PDF_BUTTON_ZOOMOUT }, + { PP_RESOURCEIMAGE_PDF_BUTTON_ZOOMOUT_HOVER, IDR_PDF_BUTTON_ZOOMOUT_HOVER }, + { PP_RESOURCEIMAGE_PDF_BUTTON_ZOOMOUT_PRESSED, + IDR_PDF_BUTTON_ZOOMOUT_PRESSED }, + { PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_0, IDR_PDF_THUMBNAIL_0 }, + { PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_1, IDR_PDF_THUMBNAIL_1 }, + { PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_2, IDR_PDF_THUMBNAIL_2 }, + { PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_3, IDR_PDF_THUMBNAIL_3 }, + { PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_4, IDR_PDF_THUMBNAIL_4 }, + { PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_5, IDR_PDF_THUMBNAIL_5 }, + { PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_6, IDR_PDF_THUMBNAIL_6 }, + { PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_7, IDR_PDF_THUMBNAIL_7 }, + { PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_8, IDR_PDF_THUMBNAIL_8 }, + { PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_9, IDR_PDF_THUMBNAIL_9 }, + { PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_NUM_BACKGROUND, + IDR_PDF_THUMBNAIL_NUM_BACKGROUND }, +}; + namespace { PP_Var GetLocalizedString(PP_ResourceString string_id) { @@ -43,6 +79,43 @@ PP_Var GetLocalizedString(PP_ResourceString string_id) { return StringToPPVar(rv); } +PP_Resource GetResourceImage(PP_Module module_id, PP_ResourceImage image_id) { + int res_id = 0; + for (int i = 0; i < arraysize(kResourceImageMap); ++i) { + if (kResourceImageMap[i].pp_id == image_id) { + res_id = kResourceImageMap[i].res_id; + break; + } + } + if (res_id == 0) + return NULL; + + SkBitmap* res_bitmap = + ResourceBundle::GetSharedInstance().GetBitmapNamed(res_id); + + PluginModule* module = PluginModule::FromPPModule(module_id); + if (!module) + return NULL; + scoped_refptr<pepper::ImageData> image_data(new pepper::ImageData(module)); + if (!image_data->Init(PP_IMAGEDATAFORMAT_BGRA_PREMUL, + res_bitmap->width(), res_bitmap->height(), false)) { + return NULL; + } + + ImageDataAutoMapper mapper(image_data); + if (!mapper.is_valid()) + return NULL; + + skia::PlatformCanvas* canvas = image_data->mapped_canvas(); + SkBitmap& ret_bitmap = + const_cast<SkBitmap&>(canvas->getTopPlatformDevice().accessBitmap(true)); + if (!res_bitmap->copyTo(&ret_bitmap, SkBitmap::kARGB_8888_Config, NULL)) { + return NULL; + } + + return image_data->GetReference(); +} + PP_Resource GetFontFileWithFallback( PP_Module module_id, const PP_PrivateFontFileDescription* description) { @@ -85,6 +158,7 @@ bool GetFontTableForPrivateFontFile(PP_Resource font_file, const PPB_Private ppb_private = { &GetLocalizedString, + &GetResourceImage, &GetFontFileWithFallback, &GetFontTableForPrivateFontFile, }; diff --git a/webkit/glue/plugins/ppb_private.h b/webkit/glue/plugins/ppb_private.h index 41ef0df..94c95bf 100644 --- a/webkit/glue/plugins/ppb_private.h +++ b/webkit/glue/plugins/ppb_private.h @@ -15,6 +15,32 @@ typedef enum { } PP_ResourceString; typedef enum { + PP_RESOURCEIMAGE_PDF_BUTTON_FTH = 0, + PP_RESOURCEIMAGE_PDF_BUTTON_FTH_HOVER = 1, + PP_RESOURCEIMAGE_PDF_BUTTON_FTH_PRESSED = 2, + PP_RESOURCEIMAGE_PDF_BUTTON_FTW = 3, + PP_RESOURCEIMAGE_PDF_BUTTON_FTW_HOVER = 4, + PP_RESOURCEIMAGE_PDF_BUTTON_FTW_PRESSED = 5, + PP_RESOURCEIMAGE_PDF_BUTTON_ZOOMIN = 6, + PP_RESOURCEIMAGE_PDF_BUTTON_ZOOMIN_HOVER = 7, + PP_RESOURCEIMAGE_PDF_BUTTON_ZOOMIN_PRESSED = 8, + PP_RESOURCEIMAGE_PDF_BUTTON_ZOOMOUT = 9, + PP_RESOURCEIMAGE_PDF_BUTTON_ZOOMOUT_HOVER = 10, + PP_RESOURCEIMAGE_PDF_BUTTON_ZOOMOUT_PRESSED = 11, + PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_0 = 12, + PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_1 = 13, + PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_2 = 14, + PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_3 = 15, + PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_4 = 16, + PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_5 = 17, + PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_6 = 18, + PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_7 = 19, + PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_8 = 20, + PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_9 = 21, + PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_NUM_BACKGROUND = 22, +} PP_ResourceImage; + +typedef enum { PP_PRIVATEFONTPITCH_DEFAULT = 0, PP_PRIVATEFONTPITCH_FIXED = 1 } PP_PrivateFontPitch; @@ -60,6 +86,10 @@ struct PPB_Private { // Returns a localized string. PP_Var (*GetLocalizedString)(PP_ResourceString string_id); + // Returns a resource image. + PP_Resource (*GetResourceImage)(PP_Module module, + PP_ResourceImage image_id); + // Returns a resource identifying a font file corresponding to the given font // request after applying the browser-specific fallback. Linux only. PP_Resource (*GetFontFileWithFallback)( diff --git a/webkit/glue/resources/pdf_button_fth.png b/webkit/glue/resources/pdf_button_fth.png Binary files differnew file mode 100644 index 0000000..3b2cc9b --- /dev/null +++ b/webkit/glue/resources/pdf_button_fth.png diff --git a/webkit/glue/resources/pdf_button_fth_hover.png b/webkit/glue/resources/pdf_button_fth_hover.png Binary files differnew file mode 100644 index 0000000..2904fd7 --- /dev/null +++ b/webkit/glue/resources/pdf_button_fth_hover.png diff --git a/webkit/glue/resources/pdf_button_fth_pressed.png b/webkit/glue/resources/pdf_button_fth_pressed.png Binary files differnew file mode 100644 index 0000000..6388c3a --- /dev/null +++ b/webkit/glue/resources/pdf_button_fth_pressed.png diff --git a/webkit/glue/resources/pdf_button_ftw.png b/webkit/glue/resources/pdf_button_ftw.png Binary files differnew file mode 100644 index 0000000..d4dacc5 --- /dev/null +++ b/webkit/glue/resources/pdf_button_ftw.png diff --git a/webkit/glue/resources/pdf_button_ftw_hover.png b/webkit/glue/resources/pdf_button_ftw_hover.png Binary files differnew file mode 100644 index 0000000..e5c98f4 --- /dev/null +++ b/webkit/glue/resources/pdf_button_ftw_hover.png diff --git a/webkit/glue/resources/pdf_button_ftw_pressed.png b/webkit/glue/resources/pdf_button_ftw_pressed.png Binary files differnew file mode 100644 index 0000000..8db22b7 --- /dev/null +++ b/webkit/glue/resources/pdf_button_ftw_pressed.png diff --git a/webkit/glue/resources/pdf_button_zoomin.png b/webkit/glue/resources/pdf_button_zoomin.png Binary files differnew file mode 100644 index 0000000..3d399c6 --- /dev/null +++ b/webkit/glue/resources/pdf_button_zoomin.png diff --git a/webkit/glue/resources/pdf_button_zoomin_hover.png b/webkit/glue/resources/pdf_button_zoomin_hover.png Binary files differnew file mode 100644 index 0000000..597f489 --- /dev/null +++ b/webkit/glue/resources/pdf_button_zoomin_hover.png diff --git a/webkit/glue/resources/pdf_button_zoomin_pressed.png b/webkit/glue/resources/pdf_button_zoomin_pressed.png Binary files differnew file mode 100644 index 0000000..7847808 --- /dev/null +++ b/webkit/glue/resources/pdf_button_zoomin_pressed.png diff --git a/webkit/glue/resources/pdf_button_zoomout.png b/webkit/glue/resources/pdf_button_zoomout.png Binary files differnew file mode 100644 index 0000000..c1b7c7c9 --- /dev/null +++ b/webkit/glue/resources/pdf_button_zoomout.png diff --git a/webkit/glue/resources/pdf_button_zoomout_hover.png b/webkit/glue/resources/pdf_button_zoomout_hover.png Binary files differnew file mode 100644 index 0000000..aa555cc --- /dev/null +++ b/webkit/glue/resources/pdf_button_zoomout_hover.png diff --git a/webkit/glue/resources/pdf_button_zoomout_pressed.png b/webkit/glue/resources/pdf_button_zoomout_pressed.png Binary files differnew file mode 100644 index 0000000..e16d8d6 --- /dev/null +++ b/webkit/glue/resources/pdf_button_zoomout_pressed.png diff --git a/webkit/glue/resources/pdf_thumbnail_0.png b/webkit/glue/resources/pdf_thumbnail_0.png Binary files differnew file mode 100644 index 0000000..0670def --- /dev/null +++ b/webkit/glue/resources/pdf_thumbnail_0.png diff --git a/webkit/glue/resources/pdf_thumbnail_1.png b/webkit/glue/resources/pdf_thumbnail_1.png Binary files differnew file mode 100644 index 0000000..328ba75 --- /dev/null +++ b/webkit/glue/resources/pdf_thumbnail_1.png diff --git a/webkit/glue/resources/pdf_thumbnail_2.png b/webkit/glue/resources/pdf_thumbnail_2.png Binary files differnew file mode 100644 index 0000000..1c81dde --- /dev/null +++ b/webkit/glue/resources/pdf_thumbnail_2.png diff --git a/webkit/glue/resources/pdf_thumbnail_3.png b/webkit/glue/resources/pdf_thumbnail_3.png Binary files differnew file mode 100644 index 0000000..e46b856 --- /dev/null +++ b/webkit/glue/resources/pdf_thumbnail_3.png diff --git a/webkit/glue/resources/pdf_thumbnail_4.png b/webkit/glue/resources/pdf_thumbnail_4.png Binary files differnew file mode 100644 index 0000000..095c9ec --- /dev/null +++ b/webkit/glue/resources/pdf_thumbnail_4.png diff --git a/webkit/glue/resources/pdf_thumbnail_5.png b/webkit/glue/resources/pdf_thumbnail_5.png Binary files differnew file mode 100644 index 0000000..2e55d49 --- /dev/null +++ b/webkit/glue/resources/pdf_thumbnail_5.png diff --git a/webkit/glue/resources/pdf_thumbnail_6.png b/webkit/glue/resources/pdf_thumbnail_6.png Binary files differnew file mode 100644 index 0000000..c147854 --- /dev/null +++ b/webkit/glue/resources/pdf_thumbnail_6.png diff --git a/webkit/glue/resources/pdf_thumbnail_7.png b/webkit/glue/resources/pdf_thumbnail_7.png Binary files differnew file mode 100644 index 0000000..6db3919 --- /dev/null +++ b/webkit/glue/resources/pdf_thumbnail_7.png diff --git a/webkit/glue/resources/pdf_thumbnail_8.png b/webkit/glue/resources/pdf_thumbnail_8.png Binary files differnew file mode 100644 index 0000000..63f58db --- /dev/null +++ b/webkit/glue/resources/pdf_thumbnail_8.png diff --git a/webkit/glue/resources/pdf_thumbnail_9.png b/webkit/glue/resources/pdf_thumbnail_9.png Binary files differnew file mode 100644 index 0000000..120ec7b --- /dev/null +++ b/webkit/glue/resources/pdf_thumbnail_9.png diff --git a/webkit/glue/resources/pdf_thumbnail_num_background.png b/webkit/glue/resources/pdf_thumbnail_num_background.png Binary files differnew file mode 100644 index 0000000..ec22c24 --- /dev/null +++ b/webkit/glue/resources/pdf_thumbnail_num_background.png diff --git a/webkit/glue/webkit_resources.grd b/webkit/glue/webkit_resources.grd index 8337d8e..94d4286 100644 --- a/webkit/glue/webkit_resources.grd +++ b/webkit/glue/webkit_resources.grd @@ -53,6 +53,29 @@ <include name="IDR_AUTOFILL_CC_MASTERCARD" file="resources\mastercard.png" type="BINDATA" /> <include name="IDR_AUTOFILL_CC_SOLO" file="resources\solo.png" type="BINDATA" /> <include name="IDR_AUTOFILL_CC_VISA" file="resources\visa.png" type="BINDATA" /> + <include name="IDR_PDF_BUTTON_FTH" file="resources\pdf_button_fth.png" type="BINDATA" /> + <include name="IDR_PDF_BUTTON_FTH_HOVER" file="resources\pdf_button_fth_hover.png" type="BINDATA" /> + <include name="IDR_PDF_BUTTON_FTH_PRESSED" file="resources\pdf_button_fth_pressed.png" type="BINDATA" /> + <include name="IDR_PDF_BUTTON_FTW" file="resources\pdf_button_ftw.png" type="BINDATA" /> + <include name="IDR_PDF_BUTTON_FTW_HOVER" file="resources\pdf_button_ftw_hover.png" type="BINDATA" /> + <include name="IDR_PDF_BUTTON_FTW_PRESSED" file="resources\pdf_button_ftw_pressed.png" type="BINDATA" /> + <include name="IDR_PDF_BUTTON_ZOOMIN" file="resources\pdf_button_zoomin.png" type="BINDATA" /> + <include name="IDR_PDF_BUTTON_ZOOMIN_HOVER" file="resources\pdf_button_zoomin_hover.png" type="BINDATA" /> + <include name="IDR_PDF_BUTTON_ZOOMIN_PRESSED" file="resources\pdf_button_zoomin_pressed.png" type="BINDATA" /> + <include name="IDR_PDF_BUTTON_ZOOMOUT" file="resources\pdf_button_zoomout.png" type="BINDATA" /> + <include name="IDR_PDF_BUTTON_ZOOMOUT_HOVER" file="resources\pdf_button_zoomout_hover.png" type="BINDATA" /> + <include name="IDR_PDF_BUTTON_ZOOMOUT_PRESSED" file="resources\pdf_button_zoomout_pressed.png" type="BINDATA" /> + <include name="IDR_PDF_THUMBNAIL_0" file="resources\pdf_thumbnail_0.png" type="BINDATA" /> + <include name="IDR_PDF_THUMBNAIL_1" file="resources\pdf_thumbnail_1.png" type="BINDATA" /> + <include name="IDR_PDF_THUMBNAIL_2" file="resources\pdf_thumbnail_2.png" type="BINDATA" /> + <include name="IDR_PDF_THUMBNAIL_3" file="resources\pdf_thumbnail_3.png" type="BINDATA" /> + <include name="IDR_PDF_THUMBNAIL_4" file="resources\pdf_thumbnail_4.png" type="BINDATA" /> + <include name="IDR_PDF_THUMBNAIL_5" file="resources\pdf_thumbnail_5.png" type="BINDATA" /> + <include name="IDR_PDF_THUMBNAIL_6" file="resources\pdf_thumbnail_6.png" type="BINDATA" /> + <include name="IDR_PDF_THUMBNAIL_7" file="resources\pdf_thumbnail_7.png" type="BINDATA" /> + <include name="IDR_PDF_THUMBNAIL_8" file="resources\pdf_thumbnail_8.png" type="BINDATA" /> + <include name="IDR_PDF_THUMBNAIL_9" file="resources\pdf_thumbnail_9.png" type="BINDATA" /> + <include name="IDR_PDF_THUMBNAIL_NUM_BACKGROUND" file="resources\pdf_thumbnail_num_background.png" type="BINDATA" /> <if expr="os == 'linux2' or os.find('bsd') != -1 or os == 'sunos5'"> <include name="IDR_LINUX_CHECKBOX_DISABLED_INDETERMINATE" file="resources\linux-checkbox-disabled-indeterminate.png" type="BINDATA" /> diff --git a/webkit/glue/webkit_strings.grd b/webkit/glue/webkit_strings.grd index 2d5e421..3cc2a98 100644 --- a/webkit/glue/webkit_strings.grd +++ b/webkit/glue/webkit_strings.grd @@ -368,7 +368,7 @@ below: </message> <message name="IDS_PDF_LOADING_PROGRESS" desc="A message displayed on the PDF control to indicate loading progress."> - Loading document: %d/%d pages... + Loading document: <ph name="PAGE_NUMBER">%d<ex>3</ex></ph>/<ph name="NUMBER_OF_PAGES">%d<ex>15</ex></ph> pages... </message> </messages> </release> |