Home | History | Annotate | Download | only in pepper
      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.
      4 
      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_
      7 
      8 #include <set>
      9 #include <string>
     10 
     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"
     17 #include "url/gurl.h"
     18 
     19 class Profile;
     20 
     21 namespace content {
     22 class BrowserPpapiHost;
     23 }
     24 
     25 namespace ppapi {
     26 namespace host {
     27 struct HostMessageContext;
     28 }  // namespace host
     29 }  // namespace ppapi
     30 
     31 namespace chrome {
     32 
     33 class PepperIsolatedFileSystemMessageFilter
     34     : public ppapi::host::ResourceMessageFilter {
     35  public:
     36   static PepperIsolatedFileSystemMessageFilter* Create(
     37       PP_Instance instance,
     38       content::BrowserPpapiHost* host);
     39 
     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;
     46 
     47  private:
     48   PepperIsolatedFileSystemMessageFilter(int render_process_id,
     49                                         const base::FilePath& profile_directory,
     50                                         const GURL& document_url,
     51                                         ppapi::host::PpapiHost* ppapi_host_);
     52 
     53   virtual ~PepperIsolatedFileSystemMessageFilter();
     54 
     55   Profile* GetProfile();
     56 
     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);
     61 
     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);
     66 
     67   const int render_process_id_;
     68   // Keep a copy from original thread.
     69   const base::FilePath profile_directory_;
     70   const GURL document_url_;
     71 
     72   // Not owned by this object.
     73   ppapi::host::PpapiHost* ppapi_host_;
     74 
     75   // Set of origins that can use CrxFs private APIs from NaCl.
     76   std::set<std::string> allowed_crxfs_origins_;
     77 
     78   DISALLOW_COPY_AND_ASSIGN(PepperIsolatedFileSystemMessageFilter);
     79 };
     80 
     81 }  // namespace chrome
     82 
     83 #endif  // CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_ISOLATED_FILE_SYSTEM_MESSAGE_FILTER_H_
     84