Home | History | Annotate | Download | only in nacl_host
      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 CHROME_BROWSER_NACL_HOST_NACL_FILE_HOST_H_
      6 #define CHROME_BROWSER_NACL_HOST_NACL_FILE_HOST_H_
      7 
      8 #include <string>
      9 
     10 #include "base/callback_forward.h"
     11 #include "base/memory/ref_counted.h"
     12 
     13 class ExtensionInfoMap;
     14 class GURL;
     15 class NaClHostMessageFilter;
     16 
     17 namespace base {
     18 class FilePath;
     19 }
     20 
     21 namespace IPC {
     22 class Message;
     23 }
     24 
     25 namespace nacl {
     26 struct PnaclInstallProgress;
     27 }
     28 
     29 // Opens NaCl Files in the Browser process, on behalf of the NaCl plugin.
     30 
     31 namespace nacl_file_host {
     32 typedef base::Callback<void(bool)> InstallCallback;
     33 typedef base::Callback<void(const nacl::PnaclInstallProgress&)>
     34     InstallProgressCallback;
     35 
     36 // Ensure that PNaCl is installed.  Calls |done_callback| if PNaCl is already
     37 // installed.  Otherwise, issues a request to install and calls |done_callback|
     38 // after that request completes w/ success or failure.
     39 // If a request to install is issued, then |progress_callback| is called
     40 // with progress updates.
     41 void EnsurePnaclInstalled(
     42     const InstallCallback& done_callback,
     43     const InstallProgressCallback& progress_callback);
     44 
     45 // Open a PNaCl file (readonly) on behalf of the NaCl plugin.
     46 void GetReadonlyPnaclFd(
     47     scoped_refptr<NaClHostMessageFilter> nacl_host_message_filter,
     48     const std::string& filename,
     49     IPC::Message* reply_msg);
     50 
     51 // Return true if the filename requested is valid for opening.
     52 // Sets file_to_open to the base::FilePath which we will attempt to open.
     53 bool PnaclCanOpenFile(const std::string& filename,
     54                       base::FilePath* file_to_open);
     55 
     56 // Opens a NaCl executable file for reading and executing.
     57 void OpenNaClExecutable(
     58     scoped_refptr<NaClHostMessageFilter> nacl_host_message_filter,
     59     scoped_refptr<ExtensionInfoMap> extension_info_map,
     60     int render_view_id,
     61     const GURL& file_url,
     62     IPC::Message* reply_msg);
     63 
     64 }  // namespace nacl_file_host
     65 
     66 #endif  // CHROME_BROWSER_NACL_HOST_NACL_FILE_HOST_H_
     67