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_BROWSER_NACL_BROWSER_DELEGATE_H_ 6 #define COMPONENTS_NACL_BROWSER_NACL_BROWSER_DELEGATE_H_ 7 8 #include <string> 9 10 #include "base/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/. 27 class NaClBrowserDelegate { 28 public: 29 virtual ~NaClBrowserDelegate() {} 30 31 // Show an infobar to the user to indicate the client architecture was not 32 // covered by the manifest. 33 virtual void ShowMissingArchInfobar(int render_process_id, 34 int render_view_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 // Returns true on success, false otherwise. On success, map |url| to a 59 // full pathname of a file in the local filesystem. |file_path| should not be 60 // changed on failure. This mapping should be a best effort, for example, 61 // "chrome-extension:" could be mapped to the location of unpacked 62 // extensions. If this method is called in a blocking thread you should set 63 // |use_blocking_api| to true, so calling blocking file API is allowed 64 // otherwise non blocking API will be used (which only handles a subset of the 65 // urls checking only the url scheme against kExtensionScheme). 66 virtual bool MapUrlToLocalFilePath(const GURL& url, 67 bool use_blocking_api, 68 const base::FilePath& profile_directory, 69 base::FilePath* file_path) = 0; 70 // Set match patterns which will be checked before enabling debug stub. 71 virtual void SetDebugPatterns(std::string debug_patterns) = 0; 72 73 // Returns whether NaCl application with this manifest URL should be debugged. 74 virtual bool URLMatchesDebugPatterns(const GURL& manifest_url) = 0; 75 76 // Returns a callback that handles NaCl idle state transitions. 77 virtual content::BrowserPpapiHost::OnKeepaliveCallback 78 GetOnKeepaliveCallback() = 0; 79 80 // Returns whether Non-SFI mode is allowed for a given manifest URL. 81 virtual bool IsNonSfiModeAllowed(const base::FilePath& profile_directory, 82 const GURL& manifest_url) = 0; 83 }; 84 85 #endif // COMPONENTS_NACL_BROWSER_NACL_BROWSER_DELEGATE_H_ 86