1 // Copyright 2013 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.
5 #ifndef CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_ISOLATED_FILE_SYSTEM_MESSAGE_FILTER_H_
6 #define CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_ISOLATED_FILE_SYSTEM_MESSAGE_FILTER_H_
11 #include "base/files/file_path.h"
12 #include "ppapi/c/pp_instance.h"
13 #include "ppapi/c/pp_resource.h"
14 #include "ppapi/c/private/ppb_isolated_file_system_private.h"
15 #include "ppapi/host/resource_host.h"
16 #include "ppapi/host/resource_message_filter.h"
22 class BrowserPpapiHost;
27 struct HostMessageContext;
33 class PepperIsolatedFileSystemMessageFilter
34 : public ppapi::host::ResourceMessageFilter {
36 static PepperIsolatedFileSystemMessageFilter* Create(
38 content::BrowserPpapiHost* host);
40 // ppapi::host::ResourceMessageFilter implementation.
41 virtual scoped_refptr<base::TaskRunner> OverrideTaskRunnerForMessage(
42 const IPC::Message& msg) OVERRIDE;
43 virtual int32_t OnResourceMessageReceived(
44 const IPC::Message& msg,
45 ppapi::host::HostMessageContext* context) OVERRIDE;
48 PepperIsolatedFileSystemMessageFilter(int render_process_id,
49 const base::FilePath& profile_directory,
50 const GURL& document_url,
51 ppapi::host::PpapiHost* ppapi_host_);
53 virtual ~PepperIsolatedFileSystemMessageFilter();
55 Profile* GetProfile();
57 // Returns filesystem id of isolated filesystem if valid, or empty string
58 // otherwise. This must run on the UI thread because ProfileManager only
59 // allows access on that thread.
60 std::string CreateCrxFileSystem(Profile* profile);
62 int32_t OnOpenFileSystem(ppapi::host::HostMessageContext* context,
63 PP_IsolatedFileSystemType_Private type);
64 int32_t OpenCrxFileSystem(ppapi::host::HostMessageContext* context);
65 int32_t OpenPluginPrivateFileSystem(ppapi::host::HostMessageContext* context);
67 const int render_process_id_;
68 // Keep a copy from original thread.
69 const base::FilePath profile_directory_;
70 const GURL document_url_;
72 // Not owned by this object.
73 ppapi::host::PpapiHost* ppapi_host_;
75 // Set of origins that can use CrxFs private APIs from NaCl.
76 std::set<std::string> allowed_crxfs_origins_;
78 DISALLOW_COPY_AND_ASSIGN(PepperIsolatedFileSystemMessageFilter);
83 #endif // CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_ISOLATED_FILE_SYSTEM_MESSAGE_FILTER_H_