Home | History | Annotate | Download | only in common
      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 COMPONENTS_NACL_COMMON_NACL_BROWSER_DELEGATE_H_
      6 #define COMPONENTS_NACL_COMMON_NACL_BROWSER_DELEGATE_H_
      7 
      8 #include <string>
      9 
     10 #include "base/callback_forward.h"
     11 
     12 namespace base {
     13 class FilePath;
     14 }
     15 
     16 namespace ppapi {
     17 namespace host {
     18 class HostFactory;
     19 }
     20 }
     21 
     22 namespace content {
     23 class BrowserPpapiHost;
     24 }
     25 
     26 // Encapsulates the dependencies of NaCl code on chrome/, to avoid a direct
     27 // dependency on chrome/.
     28 class NaClBrowserDelegate {
     29  public:
     30   virtual ~NaClBrowserDelegate() {}
     31 
     32   // Show an infobar to the user.
     33   virtual void ShowNaClInfobar(int render_process_id, int render_view_id,
     34                                int error_id) = 0;
     35   // Returns whether dialogs are allowed. This is used to decide if to add the
     36   // command line switch kNoErrorDialogs.
     37   virtual bool DialogsAreSuppressed() = 0;
     38   // Returns true on success, false otherwise. On success |cache_dir| contains
     39   // the cache directory. On failure, it is not changed.
     40   virtual bool GetCacheDirectory(base::FilePath* cache_dir) = 0;
     41   // Returns true on success, false otherwise. On success |plugin_dir| contains
     42   // the directory where the plugins are located. On failure, it is not
     43   // changed.
     44   virtual bool GetPluginDirectory(base::FilePath* plugin_dir) = 0;
     45   // Returns true on success, false otherwise. On success |pnacl_dir| contains
     46   // the directory where the PNaCl files are located. On failure, it is not
     47   // changed.
     48   virtual bool GetPnaclDirectory(base::FilePath* pnacl_dir) = 0;
     49   // Returns true on success, false otherwise. On success |user_dir| contains
     50   // the user data directory. On failure, it is not changed.
     51   virtual bool GetUserDirectory(base::FilePath* user_dir) = 0;
     52   // Returns the version as a string. This string is used to invalidate
     53   // validator cache entries when Chromium is upgraded
     54   virtual std::string GetVersionString() const = 0;
     55   // Returns a HostFactory that hides the details of its embedder.
     56   virtual ppapi::host::HostFactory* CreatePpapiHostFactory(
     57       content::BrowserPpapiHost* ppapi_host) = 0;
     58   // Install PNaCl if this operation is supported. On success, the |installed|
     59   // callback should be called with true, and on failure (or not supported),
     60   // the |installed| callback should be called with false.
     61   // TODO(jvoung): Add the progress callback as well.
     62   virtual void TryInstallPnacl(
     63       const base::Callback<void(bool)>& installed) = 0;
     64 };
     65 
     66 #endif  // COMPONENTS_NACL_COMMON_NACL_BROWSER_DELEGATE_H_
     67