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