From 216c369184095d1d3b932b264a622c796b4ba241 Mon Sep 17 00:00:00 2001 From: "gene@chromium.org" Date: Fri, 15 Apr 2011 22:50:06 +0000 Subject: Added functionality to use "SaveAs..." from PDF plugin. It is exactly the same experience as user right-click and select "SaveAs..." from pop-up menu. No disk access allowed for plugin. DIscussed it with Chris Evans and he is ok with this solution from the security stand point. Also added PDF resources for new UI. BUG=56072,75235 TEST=none, will send PDF cl separately. Review URL: http://codereview.chromium.org/6871020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81822 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/glue/resources/pdf_button_fth.png | Bin 1402 -> 0 bytes webkit/glue/resources/pdf_button_fth_hover.png | Bin 1438 -> 0 bytes webkit/glue/resources/pdf_button_fth_pressed.png | Bin 1203 -> 0 bytes webkit/glue/resources/pdf_button_ftp.png | Bin 0 -> 1445 bytes webkit/glue/resources/pdf_button_ftp_hover.png | Bin 0 -> 1492 bytes webkit/glue/resources/pdf_button_ftp_pressed.png | Bin 0 -> 1195 bytes webkit/glue/resources/pdf_button_ftw.png | Bin 1082 -> 1275 bytes webkit/glue/resources/pdf_button_ftw_hover.png | Bin 1174 -> 1254 bytes webkit/glue/resources/pdf_button_ftw_pressed.png | Bin 914 -> 932 bytes webkit/glue/resources/pdf_button_print.png | Bin 0 -> 1134 bytes webkit/glue/resources/pdf_button_print_hover.png | Bin 0 -> 1113 bytes webkit/glue/resources/pdf_button_print_pressed.png | Bin 0 -> 898 bytes webkit/glue/resources/pdf_button_save.png | Bin 0 -> 923 bytes webkit/glue/resources/pdf_button_save_hover.png | Bin 0 -> 913 bytes webkit/glue/resources/pdf_button_save_pressed.png | Bin 0 -> 655 bytes webkit/glue/resources/pdf_button_zoomin.png | Bin 1655 -> 1604 bytes webkit/glue/resources/pdf_button_zoomin_hover.png | Bin 1682 -> 1570 bytes .../glue/resources/pdf_button_zoomin_pressed.png | Bin 1403 -> 1291 bytes webkit/glue/resources/pdf_button_zoomout.png | Bin 1464 -> 1538 bytes webkit/glue/resources/pdf_button_zoomout_hover.png | Bin 1491 -> 1489 bytes .../glue/resources/pdf_button_zoomout_pressed.png | Bin 1232 -> 1206 bytes webkit/glue/webkit_resources.grd | 12 ++++++++--- webkit/plugins/ppapi/mock_plugin_delegate.cc | 3 +++ webkit/plugins/ppapi/mock_plugin_delegate.h | 1 + webkit/plugins/ppapi/plugin_delegate.h | 3 +++ webkit/plugins/ppapi/ppb_pdf_impl.cc | 22 +++++++++++++++++---- 26 files changed, 34 insertions(+), 7 deletions(-) delete mode 100644 webkit/glue/resources/pdf_button_fth.png delete mode 100644 webkit/glue/resources/pdf_button_fth_hover.png delete mode 100644 webkit/glue/resources/pdf_button_fth_pressed.png create mode 100644 webkit/glue/resources/pdf_button_ftp.png create mode 100644 webkit/glue/resources/pdf_button_ftp_hover.png create mode 100644 webkit/glue/resources/pdf_button_ftp_pressed.png create mode 100644 webkit/glue/resources/pdf_button_print.png create mode 100644 webkit/glue/resources/pdf_button_print_hover.png create mode 100644 webkit/glue/resources/pdf_button_print_pressed.png create mode 100644 webkit/glue/resources/pdf_button_save.png create mode 100644 webkit/glue/resources/pdf_button_save_hover.png create mode 100644 webkit/glue/resources/pdf_button_save_pressed.png (limited to 'webkit') diff --git a/webkit/glue/resources/pdf_button_fth.png b/webkit/glue/resources/pdf_button_fth.png deleted file mode 100644 index 3b2cc9b..0000000 Binary files a/webkit/glue/resources/pdf_button_fth.png and /dev/null differ diff --git a/webkit/glue/resources/pdf_button_fth_hover.png b/webkit/glue/resources/pdf_button_fth_hover.png deleted file mode 100644 index 2904fd7..0000000 Binary files a/webkit/glue/resources/pdf_button_fth_hover.png and /dev/null differ diff --git a/webkit/glue/resources/pdf_button_fth_pressed.png b/webkit/glue/resources/pdf_button_fth_pressed.png deleted file mode 100644 index 6388c3a..0000000 Binary files a/webkit/glue/resources/pdf_button_fth_pressed.png and /dev/null differ diff --git a/webkit/glue/resources/pdf_button_ftp.png b/webkit/glue/resources/pdf_button_ftp.png new file mode 100644 index 0000000..06180b5 Binary files /dev/null and b/webkit/glue/resources/pdf_button_ftp.png differ diff --git a/webkit/glue/resources/pdf_button_ftp_hover.png b/webkit/glue/resources/pdf_button_ftp_hover.png new file mode 100644 index 0000000..e860119 Binary files /dev/null and b/webkit/glue/resources/pdf_button_ftp_hover.png differ diff --git a/webkit/glue/resources/pdf_button_ftp_pressed.png b/webkit/glue/resources/pdf_button_ftp_pressed.png new file mode 100644 index 0000000..8b00560 Binary files /dev/null and b/webkit/glue/resources/pdf_button_ftp_pressed.png differ diff --git a/webkit/glue/resources/pdf_button_ftw.png b/webkit/glue/resources/pdf_button_ftw.png index d4dacc5..6204843 100644 Binary files a/webkit/glue/resources/pdf_button_ftw.png and b/webkit/glue/resources/pdf_button_ftw.png differ diff --git a/webkit/glue/resources/pdf_button_ftw_hover.png b/webkit/glue/resources/pdf_button_ftw_hover.png index e5c98f4..e7a48ab 100644 Binary files a/webkit/glue/resources/pdf_button_ftw_hover.png and b/webkit/glue/resources/pdf_button_ftw_hover.png differ diff --git a/webkit/glue/resources/pdf_button_ftw_pressed.png b/webkit/glue/resources/pdf_button_ftw_pressed.png index 8db22b7..e300247 100644 Binary files a/webkit/glue/resources/pdf_button_ftw_pressed.png and b/webkit/glue/resources/pdf_button_ftw_pressed.png differ diff --git a/webkit/glue/resources/pdf_button_print.png b/webkit/glue/resources/pdf_button_print.png new file mode 100644 index 0000000..025eca1b Binary files /dev/null and b/webkit/glue/resources/pdf_button_print.png differ diff --git a/webkit/glue/resources/pdf_button_print_hover.png b/webkit/glue/resources/pdf_button_print_hover.png new file mode 100644 index 0000000..0328b19 Binary files /dev/null and b/webkit/glue/resources/pdf_button_print_hover.png differ diff --git a/webkit/glue/resources/pdf_button_print_pressed.png b/webkit/glue/resources/pdf_button_print_pressed.png new file mode 100644 index 0000000..c1148f5 Binary files /dev/null and b/webkit/glue/resources/pdf_button_print_pressed.png differ diff --git a/webkit/glue/resources/pdf_button_save.png b/webkit/glue/resources/pdf_button_save.png new file mode 100644 index 0000000..8848bac Binary files /dev/null and b/webkit/glue/resources/pdf_button_save.png differ diff --git a/webkit/glue/resources/pdf_button_save_hover.png b/webkit/glue/resources/pdf_button_save_hover.png new file mode 100644 index 0000000..a6f2527 Binary files /dev/null and b/webkit/glue/resources/pdf_button_save_hover.png differ diff --git a/webkit/glue/resources/pdf_button_save_pressed.png b/webkit/glue/resources/pdf_button_save_pressed.png new file mode 100644 index 0000000..237fad4 Binary files /dev/null and b/webkit/glue/resources/pdf_button_save_pressed.png differ diff --git a/webkit/glue/resources/pdf_button_zoomin.png b/webkit/glue/resources/pdf_button_zoomin.png index 3d399c6..f53382f 100644 Binary files a/webkit/glue/resources/pdf_button_zoomin.png and b/webkit/glue/resources/pdf_button_zoomin.png differ diff --git a/webkit/glue/resources/pdf_button_zoomin_hover.png b/webkit/glue/resources/pdf_button_zoomin_hover.png index 597f489..4534f2f 100644 Binary files a/webkit/glue/resources/pdf_button_zoomin_hover.png and b/webkit/glue/resources/pdf_button_zoomin_hover.png differ diff --git a/webkit/glue/resources/pdf_button_zoomin_pressed.png b/webkit/glue/resources/pdf_button_zoomin_pressed.png index 7847808..ecfa4bb 100644 Binary files a/webkit/glue/resources/pdf_button_zoomin_pressed.png and b/webkit/glue/resources/pdf_button_zoomin_pressed.png differ diff --git a/webkit/glue/resources/pdf_button_zoomout.png b/webkit/glue/resources/pdf_button_zoomout.png index c1b7c7c9..1c31809 100644 Binary files a/webkit/glue/resources/pdf_button_zoomout.png and b/webkit/glue/resources/pdf_button_zoomout.png differ diff --git a/webkit/glue/resources/pdf_button_zoomout_hover.png b/webkit/glue/resources/pdf_button_zoomout_hover.png index aa555cc..12009a5 100644 Binary files a/webkit/glue/resources/pdf_button_zoomout_hover.png and b/webkit/glue/resources/pdf_button_zoomout_hover.png differ diff --git a/webkit/glue/resources/pdf_button_zoomout_pressed.png b/webkit/glue/resources/pdf_button_zoomout_pressed.png index e16d8d6..fa922d74 100644 Binary files a/webkit/glue/resources/pdf_button_zoomout_pressed.png and b/webkit/glue/resources/pdf_button_zoomout_pressed.png differ diff --git a/webkit/glue/webkit_resources.grd b/webkit/glue/webkit_resources.grd index 20b684c..8d4f152 100644 --- a/webkit/glue/webkit_resources.grd +++ b/webkit/glue/webkit_resources.grd @@ -53,9 +53,9 @@ - - - + + + @@ -65,6 +65,12 @@ + + + + + + diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.cc b/webkit/plugins/ppapi/mock_plugin_delegate.cc index e896bcd..a893956 100644 --- a/webkit/plugins/ppapi/mock_plugin_delegate.cc +++ b/webkit/plugins/ppapi/mock_plugin_delegate.cc @@ -219,6 +219,9 @@ void MockPluginDelegate::SetContentRestriction(int restrictions) { void MockPluginDelegate::HasUnsupportedFeature() { } +void MockPluginDelegate::SaveAs() { +} + P2PSocketDispatcher* MockPluginDelegate::GetP2PSocketDispatcher() { return NULL; } diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.h b/webkit/plugins/ppapi/mock_plugin_delegate.h index 101f788..557d7f3 100644 --- a/webkit/plugins/ppapi/mock_plugin_delegate.h +++ b/webkit/plugins/ppapi/mock_plugin_delegate.h @@ -96,6 +96,7 @@ class MockPluginDelegate : public PluginDelegate { virtual void DidStopLoading(); virtual void SetContentRestriction(int restrictions); virtual void HasUnsupportedFeature(); + virtual void SaveAs(); virtual P2PSocketDispatcher* GetP2PSocketDispatcher(); virtual webkit_glue::P2PTransport* CreateP2PTransport(); }; diff --git a/webkit/plugins/ppapi/plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h index a3eaf56..68a6471 100644 --- a/webkit/plugins/ppapi/plugin_delegate.h +++ b/webkit/plugins/ppapi/plugin_delegate.h @@ -372,6 +372,9 @@ class PluginDelegate { // Tells the browser that the PDF has an unsupported feature. virtual void HasUnsupportedFeature() = 0; + // Tells the browser to bring up SaveAs dialog. + virtual void SaveAs() = 0; + // Socket dispatcher for P2P connections. Returns to NULL if P2P API // is disabled. // diff --git a/webkit/plugins/ppapi/ppb_pdf_impl.cc b/webkit/plugins/ppapi/ppb_pdf_impl.cc index f26cc18..9316e3a 100644 --- a/webkit/plugins/ppapi/ppb_pdf_impl.cc +++ b/webkit/plugins/ppapi/ppb_pdf_impl.cc @@ -55,9 +55,9 @@ struct ResourceImageInfo { }; static const ResourceImageInfo 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_FTP, IDR_PDF_BUTTON_FTP }, + { PP_RESOURCEIMAGE_PDF_BUTTON_FTP_HOVER, IDR_PDF_BUTTON_FTP_HOVER }, + { PP_RESOURCEIMAGE_PDF_BUTTON_FTP_PRESSED, IDR_PDF_BUTTON_FTP_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 }, @@ -68,6 +68,12 @@ static const ResourceImageInfo kResourceImageMap[] = { { 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_SAVE, IDR_PDF_BUTTON_SAVE }, + { PP_RESOURCEIMAGE_PDF_BUTTON_SAVE_HOVER, IDR_PDF_BUTTON_SAVE_HOVER }, + { PP_RESOURCEIMAGE_PDF_BUTTON_SAVE_PRESSED, IDR_PDF_BUTTON_SAVE_PRESSED }, + { PP_RESOURCEIMAGE_PDF_BUTTON_PRINT, IDR_PDF_BUTTON_PRINT }, + { PP_RESOURCEIMAGE_PDF_BUTTON_PRINT_HOVER, IDR_PDF_BUTTON_PRINT_HOVER }, + { PP_RESOURCEIMAGE_PDF_BUTTON_PRINT_PRESSED, IDR_PDF_BUTTON_PRINT_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 }, @@ -294,6 +300,13 @@ void HasUnsupportedFeature(PP_Instance instance_id) { instance->delegate()->HasUnsupportedFeature(); } +void SaveAs(PP_Instance instance_id) { + PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); + if (!instance) + return; + instance->delegate()->SaveAs(); +} + const PPB_PDF ppb_pdf = { &GetLocalizedString, &GetResourceImage, @@ -305,7 +318,8 @@ const PPB_PDF ppb_pdf = { &SetContentRestriction, &HistogramPDFPageCount, &UserMetricsRecordAction, - &HasUnsupportedFeature + &HasUnsupportedFeature, + &SaveAs }; } // namespace -- cgit v1.1