summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-02 21:55:46 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-02 21:55:46 +0000
commited92ad5574e373640f54e67856c3610a4b055ebb (patch)
treea65f1032f09197ba5c3a5655b7fa3d5e3916fa20 /webkit
parentb38feea4e79a698281b4de90a0e18f097c98bffb (diff)
downloadchromium_src-ed92ad5574e373640f54e67856c3610a4b055ebb.zip
chromium_src-ed92ad5574e373640f54e67856c3610a4b055ebb.tar.gz
chromium_src-ed92ad5574e373640f54e67856c3610a4b055ebb.tar.bz2
Allow PDF files to open in Acrobat Reader.
This fixes http://code.google.com/p/chromium/issues/detail?id=3977, which is an issue with Acrobat Reader internet preferences being set to always open PDF files in Reader. This operation when performed in chrome and Safari brings up an error message from the Acrobat Reader plugin that the file could not be found. The plugin in this case returns NP_ASFILE as the plugin mode from NPP_NewStream. The data is written accordingly to the temp file created. When we finish receiving the data we pass the file name in NPP_StreamAsFile to the plugin. The plugin does not open the file immediately as per our expectation. It opens the file after the stream has been destroyed which ends up deleting the temp file created above. Debugged Firefox and found that it never deletes these temp files and leaves them around in the cache. We can go one step forward and track all these files on a per instance basis. These are deleted when the plugin instance is destroyed. Bug=3977 R=jam Review URL: http://codereview.chromium.org/12875 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6245 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/plugins/plugin_instance.cc12
-rw-r--r--webkit/glue/plugins/plugin_instance.h5
-rw-r--r--webkit/glue/plugins/plugin_stream.cc4
-rw-r--r--webkit/glue/plugins/plugin_stream.h3
-rw-r--r--webkit/glue/plugins/plugin_stream_posix.cc6
-rw-r--r--webkit/glue/plugins/plugin_stream_win.cc8
6 files changed, 19 insertions, 19 deletions
diff --git a/webkit/glue/plugins/plugin_instance.cc b/webkit/glue/plugins/plugin_instance.cc
index 893b6ec..54711b7 100644
--- a/webkit/glue/plugins/plugin_instance.cc
+++ b/webkit/glue/plugins/plugin_instance.cc
@@ -4,6 +4,7 @@
#include "webkit/glue/plugins/plugin_instance.h"
+#include "base/file_util.h"
#include "base/message_loop.h"
#include "base/string_util.h"
#include "base/thread_local_storage.h"
@@ -205,6 +206,11 @@ void PluginInstance::NPP_Destroy() {
mozilla_extenstions_ = NULL;
}
#endif
+
+ for (unsigned int file_index = 0; file_index < files_created_.size();
+ file_index++) {
+ file_util::Delete(files_created_[file_index], false);
+ }
}
NPError PluginInstance::NPP_SetWindow(NPWindow *window) {
@@ -272,6 +278,12 @@ void PluginInstance::NPP_StreamAsFile(NPStream *stream, const char *fname) {
if (npp_functions_->asfile != 0) {
npp_functions_->asfile(npp_, stream, fname);
}
+
+ // Creating a temporary FilePath instance on the stack as the explicit
+ // FilePath constructor with StringType as an argument causes a compiler
+ // error when invoked via vector push back.
+ FilePath file_name(UTF8ToWide(fname));
+ files_created_.push_back(file_name);
}
void PluginInstance::NPP_URLNotify(const char *url,
diff --git a/webkit/glue/plugins/plugin_instance.h b/webkit/glue/plugins/plugin_instance.h
index 953c303..82042c2 100644
--- a/webkit/glue/plugins/plugin_instance.h
+++ b/webkit/glue/plugins/plugin_instance.h
@@ -13,6 +13,7 @@
#include <stack>
#include "base/basictypes.h"
+#include "base/file_path.h"
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "base/thread_local_storage.h"
@@ -254,6 +255,10 @@ class PluginInstance : public base::RefCountedThreadSafe<PluginInstance> {
// True if in CloseStreams().
bool in_close_streams_;
+ // List of files created for the current plugin instance. File names are
+ // added to the list every time the NPP_StreamAsFile function is called.
+ std::vector<FilePath> files_created_;
+
DISALLOW_EVIL_CONSTRUCTORS(PluginInstance);
};
diff --git a/webkit/glue/plugins/plugin_stream.cc b/webkit/glue/plugins/plugin_stream.cc
index 0af76c5..bc12ace 100644
--- a/webkit/glue/plugins/plugin_stream.cc
+++ b/webkit/glue/plugins/plugin_stream.cc
@@ -17,8 +17,8 @@
namespace NPAPI {
PluginStream::~PluginStream() {
- // always cleanup our temporary files.
- CleanupTempFile();
+ // always close our temporary files.
+ CloseTempFile();
free(const_cast<char*>(stream_.url));
}
diff --git a/webkit/glue/plugins/plugin_stream.h b/webkit/glue/plugins/plugin_stream.h
index 6c5875b..7b1250f 100644
--- a/webkit/glue/plugins/plugin_stream.h
+++ b/webkit/glue/plugins/plugin_stream.h
@@ -87,9 +87,6 @@ class PluginStream : public base::RefCounted<PluginStream> {
// Closes the temporary file if it is open.
void CloseTempFile();
- // Closes the temporary file if it is open and deletes the file.
- void CleanupTempFile();
-
// Sends the data to the file. Called From WriteToFile.
size_t WriteBytes(const char *buf, size_t length);
diff --git a/webkit/glue/plugins/plugin_stream_posix.cc b/webkit/glue/plugins/plugin_stream_posix.cc
index 3eb7c4a..10bcdfd7 100644
--- a/webkit/glue/plugins/plugin_stream_posix.cc
+++ b/webkit/glue/plugins/plugin_stream_posix.cc
@@ -67,12 +67,6 @@ void PluginStream::CloseTempFile() {
temp_file_ = NULL;
}
-void PluginStream::CleanupTempFile() {
- CloseTempFile();
- file_util::Delete(temp_file_path_, false);
- temp_file_path_ = FilePath("");
-}
-
bool PluginStream::TempFileIsValid() {
return temp_file_ != NULL;
}
diff --git a/webkit/glue/plugins/plugin_stream_win.cc b/webkit/glue/plugins/plugin_stream_win.cc
index d1c7519..2ab4a92 100644
--- a/webkit/glue/plugins/plugin_stream_win.cc
+++ b/webkit/glue/plugins/plugin_stream_win.cc
@@ -89,14 +89,6 @@ void PluginStream::CloseTempFile() {
}
}
-void PluginStream::CleanupTempFile() {
- CloseTempFile();
- if (temp_file_name_[0] != '\0') {
- DeleteFileA(temp_file_name_);
- temp_file_name_[0] = '\0';
- }
-}
-
bool PluginStream::TempFileIsValid() {
return temp_file_handle_ != INVALID_HANDLE_VALUE;
}