summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-26 00:16:05 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-26 00:16:05 +0000
commit494184c1d68dfbdaa51af78f680e59dd0bfc6143 (patch)
treef897b02dc34dbc4e860c9dad561311d1a9e16e34 /chrome/renderer
parent287b86bfa8405f38377eb4b6c33c28b8a926fb2a (diff)
downloadchromium_src-494184c1d68dfbdaa51af78f680e59dd0bfc6143.zip
chromium_src-494184c1d68dfbdaa51af78f680e59dd0bfc6143.tar.gz
chromium_src-494184c1d68dfbdaa51af78f680e59dd0bfc6143.tar.bz2
Pepper/Flapper: Refactor module-local file stuff to make it easier/nicer to add file ref versions.
BUG=none TEST=everything still works Review URL: http://codereview.chromium.org/6599015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76124 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/pepper_plugin_delegate_impl.cc102
-rw-r--r--chrome/renderer/pepper_plugin_delegate_impl.h39
2 files changed, 42 insertions, 99 deletions
diff --git a/chrome/renderer/pepper_plugin_delegate_impl.cc b/chrome/renderer/pepper_plugin_delegate_impl.cc
index 50dcd3d..e442cb2 100644
--- a/chrome/renderer/pepper_plugin_delegate_impl.cc
+++ b/chrome/renderer/pepper_plugin_delegate_impl.cc
@@ -14,7 +14,6 @@
#include "base/string_split.h"
#include "base/task.h"
#include "base/time.h"
-#include "base/utf_string_conversions.h"
#include "chrome/common/child_thread.h"
#include "chrome/common/file_system/file_system_dispatcher.h"
#include "chrome/common/pepper_file_messages.h"
@@ -47,6 +46,7 @@
#include "webkit/fileapi/file_system_callback_dispatcher.h"
#include "webkit/glue/context_menu.h"
#include "webkit/plugins/npapi/webplugin.h"
+#include "webkit/plugins/ppapi/file_path.h"
#include "webkit/plugins/ppapi/ppb_file_io_impl.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
@@ -690,31 +690,14 @@ bool PepperPluginDelegateImpl::ReadDirectory(
return file_system_dispatcher->ReadDirectory(directory_path, dispatcher);
}
-FilePath GetModuleLocalFilePath(const std::string& module_name,
- const FilePath& path) {
-#if defined(OS_WIN)
- FilePath full_path(UTF8ToUTF16(module_name));
-#else
- FilePath full_path(module_name);
-#endif
- full_path = full_path.Append(path);
- return full_path;
-}
-
-base::PlatformFileError PepperPluginDelegateImpl::OpenModuleLocalFile(
- const std::string& module_name,
- const FilePath& path,
+base::PlatformFileError PepperPluginDelegateImpl::OpenFile(
+ const webkit::ppapi::PepperFilePath& path,
int flags,
base::PlatformFile* file) {
- FilePath full_path = GetModuleLocalFilePath(module_name, path);
- if (full_path.empty()) {
- *file = base::kInvalidPlatformFileValue;
- return base::PLATFORM_FILE_ERROR_ACCESS_DENIED;
- }
IPC::PlatformFileForTransit transit_file;
base::PlatformFileError error;
IPC::Message* msg = new PepperFileMsg_OpenFile(
- full_path, flags, &error, &transit_file);
+ path, flags, &error, &transit_file);
if (!render_view_->Send(msg)) {
*file = base::kInvalidPlatformFileValue;
return base::PLATFORM_FILE_ERROR_FAILED;
@@ -723,86 +706,53 @@ base::PlatformFileError PepperPluginDelegateImpl::OpenModuleLocalFile(
return error;
}
-base::PlatformFileError PepperPluginDelegateImpl::RenameModuleLocalFile(
- const std::string& module_name,
- const FilePath& path_from,
- const FilePath& path_to) {
- FilePath full_path_from = GetModuleLocalFilePath(module_name, path_from);
- FilePath full_path_to = GetModuleLocalFilePath(module_name, path_to);
- if (full_path_from.empty() || full_path_to.empty()) {
- return base::PLATFORM_FILE_ERROR_ACCESS_DENIED;
- }
+base::PlatformFileError PepperPluginDelegateImpl::RenameFile(
+ const webkit::ppapi::PepperFilePath& from_path,
+ const webkit::ppapi::PepperFilePath& to_path) {
base::PlatformFileError error;
- IPC::Message* msg = new PepperFileMsg_RenameFile(
- full_path_from, full_path_to, &error);
- if (!render_view_->Send(msg)) {
+ IPC::Message* msg = new PepperFileMsg_RenameFile(from_path, to_path, &error);
+ if (!render_view_->Send(msg))
return base::PLATFORM_FILE_ERROR_FAILED;
- }
return error;
}
-base::PlatformFileError PepperPluginDelegateImpl::DeleteModuleLocalFileOrDir(
- const std::string& module_name,
- const FilePath& path,
+base::PlatformFileError PepperPluginDelegateImpl::DeleteFileOrDir(
+ const webkit::ppapi::PepperFilePath& path,
bool recursive) {
- FilePath full_path = GetModuleLocalFilePath(module_name, path);
- if (full_path.empty()) {
- return base::PLATFORM_FILE_ERROR_ACCESS_DENIED;
- }
base::PlatformFileError error;
IPC::Message* msg = new PepperFileMsg_DeleteFileOrDir(
- full_path, recursive, &error);
- if (!render_view_->Send(msg)) {
+ path, recursive, &error);
+ if (!render_view_->Send(msg))
return base::PLATFORM_FILE_ERROR_FAILED;
- }
return error;
}
-base::PlatformFileError PepperPluginDelegateImpl::CreateModuleLocalDir(
- const std::string& module_name,
- const FilePath& path) {
- FilePath full_path = GetModuleLocalFilePath(module_name, path);
- if (full_path.empty()) {
- return base::PLATFORM_FILE_ERROR_ACCESS_DENIED;
- }
+base::PlatformFileError PepperPluginDelegateImpl::CreateDir(
+ const webkit::ppapi::PepperFilePath& path) {
base::PlatformFileError error;
- IPC::Message* msg = new PepperFileMsg_CreateDir(full_path, &error);
- if (!render_view_->Send(msg)) {
+ IPC::Message* msg = new PepperFileMsg_CreateDir(path, &error);
+ if (!render_view_->Send(msg))
return base::PLATFORM_FILE_ERROR_FAILED;
- }
return error;
}
-base::PlatformFileError PepperPluginDelegateImpl::QueryModuleLocalFile(
- const std::string& module_name,
- const FilePath& path,
+base::PlatformFileError PepperPluginDelegateImpl::QueryFile(
+ const webkit::ppapi::PepperFilePath& path,
base::PlatformFileInfo* info) {
- FilePath full_path = GetModuleLocalFilePath(module_name, path);
- if (full_path.empty()) {
- return base::PLATFORM_FILE_ERROR_ACCESS_DENIED;
- }
base::PlatformFileError error;
- IPC::Message* msg = new PepperFileMsg_QueryFile(full_path, info, &error);
- if (!render_view_->Send(msg)) {
+ IPC::Message* msg = new PepperFileMsg_QueryFile(path, info, &error);
+ if (!render_view_->Send(msg))
return base::PLATFORM_FILE_ERROR_FAILED;
- }
return error;
}
-base::PlatformFileError PepperPluginDelegateImpl::GetModuleLocalDirContents(
- const std::string& module_name,
- const FilePath& path,
- webkit::ppapi::DirContents* contents) {
- FilePath full_path = GetModuleLocalFilePath(module_name, path);
- if (full_path.empty()) {
- return base::PLATFORM_FILE_ERROR_ACCESS_DENIED;
- }
+base::PlatformFileError PepperPluginDelegateImpl::GetDirContents(
+ const webkit::ppapi::PepperFilePath& path,
+ webkit::ppapi::DirContents* contents) {
base::PlatformFileError error;
- IPC::Message* msg =
- new PepperFileMsg_GetDirContents(full_path, contents, &error);
- if (!render_view_->Send(msg)) {
+ IPC::Message* msg = new PepperFileMsg_GetDirContents(path, contents, &error);
+ if (!render_view_->Send(msg))
return base::PLATFORM_FILE_ERROR_FAILED;
- }
return error;
}
diff --git a/chrome/renderer/pepper_plugin_delegate_impl.h b/chrome/renderer/pepper_plugin_delegate_impl.h
index f589687..30f2c94 100644
--- a/chrome/renderer/pepper_plugin_delegate_impl.h
+++ b/chrome/renderer/pepper_plugin_delegate_impl.h
@@ -28,12 +28,11 @@ class Rect;
namespace webkit {
namespace ppapi {
-
+class PepperFilePath;
class PluginInstance;
class PluginModule;
-
-} // namespace ppapi
-} // namespace webkit
+}
+}
namespace WebKit {
class WebFileChooserCompletion;
@@ -122,29 +121,23 @@ class PepperPluginDelegateImpl
fileapi::FileSystemCallbackDispatcher* dispatcher);
virtual bool ReadDirectory(const FilePath& directory_path,
fileapi::FileSystemCallbackDispatcher* dispatcher);
- virtual base::PlatformFileError OpenModuleLocalFile(
- const std::string& module_name,
- const FilePath& path,
+ virtual base::PlatformFileError OpenFile(
+ const webkit::ppapi::PepperFilePath& path,
int flags,
base::PlatformFile* file);
- virtual base::PlatformFileError RenameModuleLocalFile(
- const std::string& module_name,
- const FilePath& path_from,
- const FilePath& path_to);
- virtual base::PlatformFileError DeleteModuleLocalFileOrDir(
- const std::string& module_name,
- const FilePath& path,
+ virtual base::PlatformFileError RenameFile(
+ const webkit::ppapi::PepperFilePath& from_path,
+ const webkit::ppapi::PepperFilePath& to_path);
+ virtual base::PlatformFileError DeleteFileOrDir(
+ const webkit::ppapi::PepperFilePath& path,
bool recursive);
- virtual base::PlatformFileError CreateModuleLocalDir(
- const std::string& module_name,
- const FilePath& path);
- virtual base::PlatformFileError QueryModuleLocalFile(
- const std::string& module_name,
- const FilePath& path,
+ virtual base::PlatformFileError CreateDir(
+ const webkit::ppapi::PepperFilePath& path);
+ virtual base::PlatformFileError QueryFile(
+ const webkit::ppapi::PepperFilePath& path,
base::PlatformFileInfo* info);
- virtual base::PlatformFileError GetModuleLocalDirContents(
- const std::string& module_name,
- const FilePath& path,
+ virtual base::PlatformFileError GetDirContents(
+ const webkit::ppapi::PepperFilePath& path,
webkit::ppapi::DirContents* contents);
virtual scoped_refptr<base::MessageLoopProxy> GetFileThreadMessageLoopProxy();
virtual int32_t ConnectTcp(