Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / browser / renderer_host / pepper / pepper_flash_file_message_filter.h
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, BrowserPpapiHost* host);
39
40   static base::FilePath GetDataDirName(const base::FilePath& profile_path);
41
42  private:
43   typedef base::Callback<bool(int, const base::FilePath&)>
44       CheckPermissionsCallback;
45
46   virtual ~PepperFlashFileMessageFilter();
47
48   // ppapi::host::ResourceMessageFilter overrides.
49   virtual scoped_refptr<base::TaskRunner> OverrideTaskRunnerForMessage(
50       const IPC::Message& msg) OVERRIDE;
51   virtual int32_t OnResourceMessageReceived(
52       const IPC::Message& msg,
53       ppapi::host::HostMessageContext* context) OVERRIDE;
54
55   int32_t OnOpenFile(ppapi::host::HostMessageContext* context,
56                      const ppapi::PepperFilePath& path,
57                      int pp_open_flags);
58   int32_t OnRenameFile(ppapi::host::HostMessageContext* context,
59                        const ppapi::PepperFilePath& from_path,
60                        const ppapi::PepperFilePath& to_path);
61   int32_t OnDeleteFileOrDir(ppapi::host::HostMessageContext* context,
62                             const ppapi::PepperFilePath& path,
63                             bool recursive);
64   int32_t OnCreateDir(ppapi::host::HostMessageContext* context,
65                       const ppapi::PepperFilePath& path);
66   int32_t OnQueryFile(ppapi::host::HostMessageContext* context,
67                       const ppapi::PepperFilePath& path);
68   int32_t OnGetDirContents(ppapi::host::HostMessageContext* context,
69                            const ppapi::PepperFilePath& path);
70   int32_t OnCreateTemporaryFile(ppapi::host::HostMessageContext* context);
71
72   base::FilePath ValidateAndConvertPepperFilePath(
73       const ppapi::PepperFilePath& pepper_path,
74       const CheckPermissionsCallback& check_permissions_callback) const;
75
76   base::FilePath plugin_data_directory_;
77   int render_process_id_;
78   base::ProcessHandle plugin_process_handle_;
79
80   DISALLOW_COPY_AND_ASSIGN(PepperFlashFileMessageFilter);
81 };
82
83 }  // namespace content
84
85 #endif  // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FLASH_FILE_MESSAGE_FILTER_H_