2012-06-26 18:47:05 +02:00
|
|
|
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
2013-02-27 18:56:03 +01:00
|
|
|
#include "base/files/file_path.h"
|
2012-06-26 18:47:05 +02:00
|
|
|
#include "base/logging.h"
|
2020-07-08 19:23:29 +02:00
|
|
|
#include "base/notreached.h"
|
2012-06-26 18:47:05 +02:00
|
|
|
#include "base/path_service.h"
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/include/cef_path_util.h"
|
2015-03-02 21:25:14 +01:00
|
|
|
#include "chrome/common/chrome_paths.h"
|
2012-06-26 18:47:05 +02:00
|
|
|
|
|
|
|
bool CefGetPath(PathKey key, CefString& path) {
|
|
|
|
int pref_key = base::PATH_START;
|
2017-05-17 11:29:28 +02:00
|
|
|
switch (key) {
|
2012-06-26 18:47:05 +02:00
|
|
|
case PK_DIR_CURRENT:
|
|
|
|
pref_key = base::DIR_CURRENT;
|
|
|
|
break;
|
|
|
|
case PK_DIR_EXE:
|
|
|
|
pref_key = base::DIR_EXE;
|
|
|
|
break;
|
|
|
|
case PK_DIR_MODULE:
|
|
|
|
pref_key = base::DIR_MODULE;
|
|
|
|
break;
|
|
|
|
case PK_DIR_TEMP:
|
|
|
|
pref_key = base::DIR_TEMP;
|
|
|
|
break;
|
|
|
|
case PK_FILE_EXE:
|
|
|
|
pref_key = base::FILE_EXE;
|
|
|
|
break;
|
|
|
|
case PK_FILE_MODULE:
|
|
|
|
pref_key = base::FILE_MODULE;
|
|
|
|
break;
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_WIN)
|
2015-03-02 21:25:14 +01:00
|
|
|
case PK_LOCAL_APP_DATA:
|
|
|
|
pref_key = base::DIR_LOCAL_APP_DATA;
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case PK_USER_DATA:
|
|
|
|
pref_key = chrome::DIR_USER_DATA;
|
|
|
|
break;
|
2017-08-04 00:55:19 +02:00
|
|
|
case PK_DIR_RESOURCES:
|
|
|
|
pref_key = chrome::DIR_RESOURCES;
|
|
|
|
break;
|
2012-06-26 18:47:05 +02:00
|
|
|
default:
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false) << "invalid argument";
|
2012-06-26 18:47:05 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-02-23 01:43:28 +01:00
|
|
|
base::FilePath file_path;
|
2018-05-14 13:24:05 +02:00
|
|
|
if (base::PathService::Get(pref_key, &file_path)) {
|
2012-06-26 18:47:05 +02:00
|
|
|
path = file_path.value();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|