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