nacl_browser_delegate.h 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. #ifndef COMPONENTS_NACL_BROWSER_NACL_BROWSER_DELEGATE_H_
  5. #define COMPONENTS_NACL_BROWSER_NACL_BROWSER_DELEGATE_H_
  6. #include <string>
  7. #include "base/callback_forward.h"
  8. #include "content/public/browser/browser_ppapi_host.h"
  9. class GURL;
  10. namespace base {
  11. class FilePath;
  12. }
  13. namespace ppapi {
  14. namespace host {
  15. class HostFactory;
  16. }
  17. }
  18. // Encapsulates the dependencies of NaCl code on chrome/, to avoid a direct
  19. // dependency on chrome/. All methods should be called on the IO thread unless
  20. // otherwise noted.
  21. class NaClBrowserDelegate {
  22. public:
  23. virtual ~NaClBrowserDelegate() {}
  24. // Show an infobar to the user to indicate the client architecture was not
  25. // covered by the manifest.
  26. virtual void ShowMissingArchInfobar(int render_process_id,
  27. int render_frame_id) = 0;
  28. // Returns whether dialogs are allowed. This is used to decide if to add the
  29. // command line switch kNoErrorDialogs.
  30. virtual bool DialogsAreSuppressed() = 0;
  31. // Returns true on success, false otherwise. On success |cache_dir| contains
  32. // the cache directory. On failure, it is not changed.
  33. virtual bool GetCacheDirectory(base::FilePath* cache_dir) = 0;
  34. // Returns true on success, false otherwise. On success |plugin_dir| contains
  35. // the directory where the plugins are located. On failure, it is not
  36. // changed.
  37. virtual bool GetPluginDirectory(base::FilePath* plugin_dir) = 0;
  38. // Returns true on success, false otherwise. On success |pnacl_dir| contains
  39. // the directory where the PNaCl files are located. On failure, it is not
  40. // changed.
  41. virtual bool GetPnaclDirectory(base::FilePath* pnacl_dir) = 0;
  42. // Returns true on success, false otherwise. On success |user_dir| contains
  43. // the user data directory. On failure, it is not changed.
  44. virtual bool GetUserDirectory(base::FilePath* user_dir) = 0;
  45. // Returns the version as a string. This string is used to invalidate
  46. // validator cache entries when Chromium is upgraded
  47. virtual std::string GetVersionString() const = 0;
  48. // Returns a HostFactory that hides the details of its embedder.
  49. virtual ppapi::host::HostFactory* CreatePpapiHostFactory(
  50. content::BrowserPpapiHost* ppapi_host) = 0;
  51. // Returns true on success, false otherwise. On success, map |url| to a
  52. // full pathname of a file in the local filesystem. |file_path| should not be
  53. // changed on failure. This mapping should be a best effort, for example,
  54. // "chrome-extension:" could be mapped to the location of unpacked
  55. // extensions. If this method is called in a blocking thread you should set
  56. // |use_blocking_api| to true, so calling blocking file API is allowed
  57. // otherwise non blocking API will be used (which only handles a subset of the
  58. // urls checking only the url scheme against kExtensionScheme).
  59. using MapUrlToLocalFilePathCallback = base::RepeatingCallback<
  60. bool(const GURL& url, bool use_blocking_api, base::FilePath* file_path)>;
  61. // Returns a MapUrlToLocalFilePathCallback that can be called on any thread.
  62. // Must be called on the UI thread.
  63. virtual MapUrlToLocalFilePathCallback GetMapUrlToLocalFilePathCallback(
  64. const base::FilePath& profile_directory) = 0;
  65. // Set match patterns which will be checked before enabling debug stub.
  66. virtual void SetDebugPatterns(const std::string& debug_patterns) = 0;
  67. // Returns whether NaCl application with this manifest URL should be debugged.
  68. virtual bool URLMatchesDebugPatterns(const GURL& manifest_url) = 0;
  69. };
  70. #endif // COMPONENTS_NACL_BROWSER_NACL_BROWSER_DELEGATE_H_