#include "extensions/browser/path_util.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/path_service.h"
#include "base/strings/sys_string_conversions.h"
#include "build/build_config.h"
#include "extensions/browser/extension_file_task_runner.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/text/bytes_formatting.h"
#if BUILDFLAG(IS_MAC)
#include <CoreFoundation/CoreFoundation.h>
#include "base/apple/foundation_util.h"
#include "base/apple/scoped_cftyperef.h"
#endif
namespace extensions {
namespace path_util {
namespace {
#if BUILDFLAG(IS_MAC)
std::string GetDisplayBaseName(const base::FilePath& path) {
base::apple::ScopedCFTypeRef<CFURLRef> url =
base::apple::FilePathToCFURL(path);
if (!url) {
return path.BaseName().value();
}
base::apple::ScopedCFTypeRef<CFStringRef> str;
if (!CFURLCopyResourcePropertyForKey(url.get(), kCFURLLocalizedNameKey,
str.InitializeInto(),
nullptr)) {
return path.BaseName().value();
}
return base::SysCFStringRefToUTF8(str.get());
}
#endif
const base::FilePath::CharType kHomeShortcut[] = …);
void OnDirectorySizeCalculated(
int message_id,
base::OnceCallback<void(const std::u16string&)> callback,
int64_t size_in_bytes) { … }
}
base::FilePath PrettifyPath(const base::FilePath& source_path) { … }
void CalculateExtensionDirectorySize(
const base::FilePath& extension_path,
base::OnceCallback<void(const int64_t)> callback) { … }
void CalculateAndFormatExtensionDirectorySize(
const base::FilePath& extension_path,
int message_id,
base::OnceCallback<void(const std::u16string&)> callback) { … }
base::FilePath ResolveHomeDirectory(const base::FilePath& path) { … }
}
}