1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FLASH_FILE_MESSAGE_FILTER_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FLASH_FILE_MESSAGE_FILTER_H_ 7 8 #include "base/callback_forward.h" 9 #include "base/compiler_specific.h" 10 #include "base/files/file_path.h" 11 #include "base/memory/ref_counted.h" 12 #include "base/process/process.h" 13 #include "ppapi/c/pp_instance.h" 14 #include "ppapi/host/resource_host.h" 15 #include "ppapi/host/resource_message_filter.h" 16 17 namespace content { 18 class BrowserPpapiHost; 19 } 20 21 namespace ppapi { 22 class PepperFilePath; 23 } 24 25 namespace ppapi { 26 namespace host { 27 struct HostMessageContext; 28 } 29 } 30 31 namespace content { 32 33 class BrowserPpapiHost; 34 35 // All file messages are handled by BrowserThread's blocking pool. 36 class PepperFlashFileMessageFilter : public ppapi::host::ResourceMessageFilter { 37 public: 38 PepperFlashFileMessageFilter(PP_Instance instance, 39 BrowserPpapiHost* host); 40 41 static base::FilePath GetDataDirName(const base::FilePath& profile_path); 42 43 private: 44 typedef base::Callback<bool(int, const base::FilePath&)> 45 CheckPermissionsCallback; 46 47 virtual ~PepperFlashFileMessageFilter(); 48 49 // ppapi::host::ResourceMessageFilter overrides. 50 virtual scoped_refptr<base::TaskRunner> OverrideTaskRunnerForMessage( 51 const IPC::Message& msg) OVERRIDE; 52 virtual int32_t OnResourceMessageReceived( 53 const IPC::Message& msg, 54 ppapi::host::HostMessageContext* context) OVERRIDE; 55 56 int32_t OnOpenFile(ppapi::host::HostMessageContext* context, 57 const ppapi::PepperFilePath& path, 58 int pp_open_flags); 59 int32_t OnRenameFile(ppapi::host::HostMessageContext* context, 60 const ppapi::PepperFilePath& from_path, 61 const ppapi::PepperFilePath& to_path); 62 int32_t OnDeleteFileOrDir(ppapi::host::HostMessageContext* context, 63 const ppapi::PepperFilePath& path, 64 bool recursive); 65 int32_t OnCreateDir(ppapi::host::HostMessageContext* context, 66 const ppapi::PepperFilePath& path); 67 int32_t OnQueryFile(ppapi::host::HostMessageContext* context, 68 const ppapi::PepperFilePath& path); 69 int32_t OnGetDirContents(ppapi::host::HostMessageContext* context, 70 const ppapi::PepperFilePath& path); 71 int32_t OnCreateTemporaryFile(ppapi::host::HostMessageContext* context); 72 73 base::FilePath ValidateAndConvertPepperFilePath( 74 const ppapi::PepperFilePath& pepper_path, 75 const CheckPermissionsCallback& check_permissions_callback) const; 76 77 base::FilePath plugin_data_directory_; 78 int render_process_id_; 79 base::ProcessHandle plugin_process_handle_; 80 81 DISALLOW_COPY_AND_ASSIGN(PepperFlashFileMessageFilter); 82 }; 83 84 } // namespace content 85 86 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FLASH_FILE_MESSAGE_FILTER_H_ 87