summaryrefslogtreecommitdiffstats
path: root/components/nacl/browser/nacl_browser_delegate.h
blob: 45c93b5676608d62e3ad7e901b01982946ab841d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_NACL_BROWSER_NACL_BROWSER_DELEGATE_H_
#define COMPONENTS_NACL_BROWSER_NACL_BROWSER_DELEGATE_H_

#include <string>

#include "base/callback_forward.h"
#include "content/public/browser/browser_ppapi_host.h"

class GURL;

namespace base {
class FilePath;
}

namespace ppapi {
namespace host {
class HostFactory;
}
}

// Encapsulates the dependencies of NaCl code on chrome/, to avoid a direct
// dependency on chrome/.
class NaClBrowserDelegate {
 public:
  virtual ~NaClBrowserDelegate() {}

  // Show an infobar to the user to indicate the client architecture was not
  // covered by the manifest.
  virtual void ShowMissingArchInfobar(int render_process_id,
                                      int render_view_id) = 0;
  // Returns whether dialogs are allowed. This is used to decide if to add the
  // command line switch kNoErrorDialogs.
  virtual bool DialogsAreSuppressed() = 0;
  // Returns true on success, false otherwise. On success |cache_dir| contains
  // the cache directory. On failure, it is not changed.
  virtual bool GetCacheDirectory(base::FilePath* cache_dir) = 0;
  // Returns true on success, false otherwise. On success |plugin_dir| contains
  // the directory where the plugins are located. On failure, it is not
  // changed.
  virtual bool GetPluginDirectory(base::FilePath* plugin_dir) = 0;
  // Returns true on success, false otherwise. On success |pnacl_dir| contains
  // the directory where the PNaCl files are located. On failure, it is not
  // changed.
  virtual bool GetPnaclDirectory(base::FilePath* pnacl_dir) = 0;
  // Returns true on success, false otherwise. On success |user_dir| contains
  // the user data directory. On failure, it is not changed.
  virtual bool GetUserDirectory(base::FilePath* user_dir) = 0;
  // Returns the version as a string. This string is used to invalidate
  // validator cache entries when Chromium is upgraded
  virtual std::string GetVersionString() const = 0;
  // Returns a HostFactory that hides the details of its embedder.
  virtual ppapi::host::HostFactory* CreatePpapiHostFactory(
      content::BrowserPpapiHost* ppapi_host) = 0;
  // Returns true on success, false otherwise. On success, map |url| to a
  // full pathname of a file in the local filesystem. |file_path| should not be
  // changed on failure. This mapping should be a best effort, for example,
  // "chrome-extension:" could be mapped to the location of unpacked
  // extensions. If this method is called in a blocking thread you should set
  // |use_blocking_api| to true, so calling blocking file API is allowed
  // otherwise non blocking API will be used (which only handles a subset of the
  // urls checking only the url scheme against kExtensionScheme).
  virtual bool MapUrlToLocalFilePath(const GURL& url,
                                     bool use_blocking_api,
                                     const base::FilePath& profile_directory,
                                     base::FilePath* file_path) = 0;
  // Set match patterns which will be checked before enabling debug stub.
  virtual void SetDebugPatterns(const std::string& debug_patterns) = 0;

  // Returns whether NaCl application with this manifest URL should be debugged.
  virtual bool URLMatchesDebugPatterns(const GURL& manifest_url) = 0;

  // Returns a callback that handles NaCl idle state transitions.
  virtual content::BrowserPpapiHost::OnKeepaliveCallback
      GetOnKeepaliveCallback() = 0;

  // Returns whether Non-SFI mode is allowed for a given manifest URL.
  virtual bool IsNonSfiModeAllowed(const base::FilePath& profile_directory,
                                   const GURL& manifest_url) = 0;
};

#endif  // COMPONENTS_NACL_BROWSER_NACL_BROWSER_DELEGATE_H_