1 // Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights 2 // reserved. Use of this source code is governed by a BSD-style license that 3 // can be found in the LICENSE file. 4 5 #include "include/cef_path_util.h" 6 7 #include "base/files/file_path.h" 8 #include "base/logging.h" 9 #include "base/notreached.h" 10 #include "base/path_service.h" 11 #include "chrome/common/chrome_paths.h" 12 CefGetPath(PathKey key,CefString & path)13bool CefGetPath(PathKey key, CefString& path) { 14 int pref_key = base::PATH_START; 15 switch (key) { 16 case PK_DIR_CURRENT: 17 pref_key = base::DIR_CURRENT; 18 break; 19 case PK_DIR_EXE: 20 pref_key = base::DIR_EXE; 21 break; 22 case PK_DIR_MODULE: 23 pref_key = base::DIR_MODULE; 24 break; 25 case PK_DIR_TEMP: 26 pref_key = base::DIR_TEMP; 27 break; 28 case PK_FILE_EXE: 29 pref_key = base::FILE_EXE; 30 break; 31 case PK_FILE_MODULE: 32 pref_key = base::FILE_MODULE; 33 break; 34 #if BUILDFLAG(IS_WIN) 35 case PK_LOCAL_APP_DATA: 36 pref_key = base::DIR_LOCAL_APP_DATA; 37 break; 38 #endif 39 case PK_USER_DATA: 40 pref_key = chrome::DIR_USER_DATA; 41 break; 42 case PK_DIR_RESOURCES: 43 pref_key = chrome::DIR_RESOURCES; 44 break; 45 default: 46 NOTREACHED() << "invalid argument"; 47 return false; 48 } 49 50 base::FilePath file_path; 51 if (base::PathService::Get(pref_key, &file_path)) { 52 path = file_path.value(); 53 return true; 54 } 55 56 return false; 57 } 58