Home | History | Annotate | Download | only in pepper
      1 // Copyright (c) 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_CRX_FILE_SYSTEM_MESSAGE_FILTER_H_
      6 #define CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_CRX_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/host/resource_host.h"
     15 #include "ppapi/host/resource_message_filter.h"
     16 #include "url/gurl.h"
     17 
     18 class Profile;
     19 
     20 namespace content {
     21 class BrowserPpapiHost;
     22 }
     23 
     24 namespace ppapi {
     25 namespace host {
     26 struct HostMessageContext;
     27 }  // namespace host
     28 }  // namespace ppapi
     29 
     30 namespace chrome {
     31 
     32 class PepperCrxFileSystemMessageFilter
     33     : public ppapi::host::ResourceMessageFilter {
     34  public:
     35   static PepperCrxFileSystemMessageFilter* Create(
     36       PP_Instance instance,
     37       content::BrowserPpapiHost* host);
     38 
     39   // ppapi::host::ResourceMessageFilter implementation.
     40   virtual scoped_refptr<base::TaskRunner> OverrideTaskRunnerForMessage(
     41       const IPC::Message& msg) OVERRIDE;
     42   virtual int32_t OnResourceMessageReceived(
     43       const IPC::Message& msg,
     44       ppapi::host::HostMessageContext* context) OVERRIDE;
     45 
     46  private:
     47   PepperCrxFileSystemMessageFilter(
     48       int render_process_id,
     49       const base::FilePath& profile_directory,
     50       const GURL& document_url);
     51 
     52   virtual ~PepperCrxFileSystemMessageFilter();
     53 
     54   Profile* GetProfile();
     55 
     56   // Returns filesystem id of isolated filesystem if valid, or empty string
     57   // otherwise.  This must run on the UI thread because ProfileManager only
     58   // allows access on that thread.
     59   std::string CreateIsolatedFileSystem(Profile* profile);
     60 
     61   int32_t OnOpenFileSystem(ppapi::host::HostMessageContext* context);
     62 
     63   const int render_process_id_;
     64   const base::FilePath& profile_directory_;
     65   const GURL document_url_;
     66 
     67   // Set of origins that can use CrxFs private APIs from NaCl.
     68   std::set<std::string> allowed_crxfs_origins_;
     69 
     70   DISALLOW_COPY_AND_ASSIGN(PepperCrxFileSystemMessageFilter);
     71 };
     72 
     73 }  // namespace chrome
     74 
     75 #endif  // CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_CRX_FILE_SYSTEM_MESSAGE_FILTER_H_
     76