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 "components/nacl/common/nacl_paths.h" 6 7 #include "base/file_util.h" 8 #include "base/path_service.h" 9 10 namespace { 11 12 #if defined(OS_POSIX) && !defined(OS_MACOSX) 13 // File name of the nacl_helper and nacl_helper_bootstrap, Linux only. 14 const base::FilePath::CharType kInternalNaClHelperFileName[] = 15 FILE_PATH_LITERAL("nacl_helper"); 16 const base::FilePath::CharType kInternalNaClHelperBootstrapFileName[] = 17 FILE_PATH_LITERAL("nacl_helper_bootstrap"); 18 #endif 19 20 } // namespace 21 22 namespace nacl { 23 24 bool PathProvider(int key, base::FilePath* result) { 25 base::FilePath cur; 26 switch (key) { 27 #if defined(OS_LINUX) 28 case FILE_NACL_HELPER: 29 if (!PathService::Get(base::DIR_MODULE, &cur)) 30 return false; 31 cur = cur.Append(kInternalNaClHelperFileName); 32 break; 33 case FILE_NACL_HELPER_BOOTSTRAP: 34 if (!PathService::Get(base::DIR_MODULE, &cur)) 35 return false; 36 cur = cur.Append(kInternalNaClHelperBootstrapFileName); 37 break; 38 #endif 39 default: 40 return false; 41 } 42 43 *result = cur; 44 return true; 45 } 46 47 // This cannot be done as a static initializer sadly since Visual Studio will 48 // eliminate this object file if there is no direct entry point into it. 49 void RegisterPathProvider() { 50 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); 51 } 52 53 } // namespace nacl 54