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 #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h" 6 7 #include "base/path_service.h" 8 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h" 10 #include "chrome/browser/nacl_host/nacl_infobar_delegate.h" 11 #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h" 12 #include "chrome/common/chrome_paths.h" 13 #include "chrome/common/chrome_paths_internal.h" 14 #include "chrome/common/chrome_version_info.h" 15 #include "chrome/common/logging_chrome.h" 16 #include "content/public/browser/browser_thread.h" 17 #include "ppapi/c/private/ppb_nacl_private.h" 18 19 void NaClBrowserDelegateImpl::ShowNaClInfobar(int render_process_id, 20 int render_view_id, 21 int error_id) { 22 DCHECK_EQ(PP_NACL_MANIFEST_MISSING_ARCH, error_id); 23 content::BrowserThread::PostTask( 24 content::BrowserThread::UI, FROM_HERE, 25 base::Bind(&NaClInfoBarDelegate::Create, render_process_id, 26 render_view_id)); 27 } 28 29 bool NaClBrowserDelegateImpl::DialogsAreSuppressed() { 30 return logging::DialogsAreSuppressed(); 31 } 32 33 bool NaClBrowserDelegateImpl::GetCacheDirectory(base::FilePath* cache_dir) { 34 base::FilePath user_data_dir; 35 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) 36 return false; 37 chrome::GetUserCacheDirectory(user_data_dir, cache_dir); 38 return true; 39 } 40 41 bool NaClBrowserDelegateImpl::GetPluginDirectory(base::FilePath* plugin_dir) { 42 return PathService::Get(chrome::DIR_INTERNAL_PLUGINS, plugin_dir); 43 } 44 45 bool NaClBrowserDelegateImpl::GetPnaclDirectory(base::FilePath* pnacl_dir) { 46 return PathService::Get(chrome::DIR_PNACL_COMPONENT, pnacl_dir); 47 } 48 49 bool NaClBrowserDelegateImpl::GetUserDirectory(base::FilePath* user_dir) { 50 return PathService::Get(chrome::DIR_USER_DATA, user_dir); 51 } 52 53 std::string NaClBrowserDelegateImpl::GetVersionString() const { 54 return chrome::VersionInfo().CreateVersionString(); 55 } 56 57 ppapi::host::HostFactory* NaClBrowserDelegateImpl::CreatePpapiHostFactory( 58 content::BrowserPpapiHost* ppapi_host) { 59 return new chrome::ChromeBrowserPepperHostFactory(ppapi_host); 60 } 61 62 void NaClBrowserDelegateImpl::TryInstallPnacl( 63 const base::Callback<void(bool)>& installed) { 64 PnaclComponentInstaller* pci = 65 g_browser_process->pnacl_component_installer(); 66 if (pci) 67 pci->RequestFirstInstall(installed); 68 else 69 installed.Run(false); 70 } 71