0

Move ScopedTypeRef and ScopedCFTypeRef into base:🍎:

This moves these two types into the base:🍎: namespace.

This also rolls Crashpad:

Update Crashpad to a736f7d070c872a4cc786c31755fd769fb2e50b3

50ce1550a1ca [fuchsia] Move //zircon/public/lib/zx to
             //zircon/system/ulib/zx
a736f7d070c8 Roll mini_chromium putting /base/apple files into
             base:🍎:

Fixed: 1474628
Change-Id: I3d529e6b6f4a6e48bc9edc2df830f9c2418ca678
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4799213
Owners-Override: Avi Drissman <avi@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1186262}
This commit is contained in:
Avi Drissman
2023-08-22 04:06:45 +00:00
committed by Chromium LUCI CQ
parent 1d56cda2d6
commit 28154a6fbb
325 changed files with 1489 additions and 1360 deletions
base
chrome
app
browser
common
extensions
test
updater
device_management
mac
privileged_helper
policy
utility
components
content
crypto
device
extensions/browser
gpu
headless/lib/browser/policy
ios
media
audio
base
capture
cast
filters
gpu
net
printing
remoting
rlz/mac/lib
services
skia/ext
third_party
tools/mac/power/power_sampler
ui

@ -116,7 +116,7 @@ bool UseMapJit() {
// executable fails with EPERM. Although this is not enforced on x86_64,
// MAP_JIT is harmless in that case.
base::ScopedCFTypeRef<SecTaskRef> task(
base::apple::ScopedCFTypeRef<SecTaskRef> task(
SecTaskCreateFromSelf(kCFAllocatorDefault));
if (!task) {
return true;
@ -134,7 +134,7 @@ bool UseMapJit() {
// (EINVAL) to use MAP_JIT with the hardened runtime unless the JIT
// entitlement is specified.
base::ScopedCFTypeRef<CFTypeRef> jit_entitlement(
base::apple::ScopedCFTypeRef<CFTypeRef> jit_entitlement(
SecTaskCopyValueForEntitlement(
task.get(), CFSTR("com.apple.security.cs.allow-jit"), nullptr));
if (!jit_entitlement) {

@ -9,7 +9,7 @@
#include "base/allocator/partition_allocator/partition_alloc_base/apple/scoped_typeref.h"
namespace partition_alloc::internal::base {
namespace partition_alloc::internal::base::apple {
// ScopedCFTypeRef<> is patterned after std::unique_ptr<>, but maintains
// ownership of a CoreFoundation object: any object that can be represented
@ -43,6 +43,6 @@ template <typename CFT>
using ScopedCFTypeRef =
ScopedTypeRef<CFT, internal::ScopedCFTypeRefTraits<CFT>>;
} // namespace partition_alloc::internal::base
} // namespace partition_alloc::internal::base::apple
#endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_PARTITION_ALLOC_BASE_APPLE_SCOPED_CFTYPEREF_H_

@ -8,7 +8,7 @@
#include "base/allocator/partition_allocator/partition_alloc_base/check.h"
#include "base/allocator/partition_allocator/partition_alloc_base/memory/scoped_policy.h"
namespace partition_alloc::internal::base {
namespace partition_alloc::internal::base::apple {
// ScopedTypeRef<> is patterned after std::unique_ptr<>, but maintains ownership
// of a reference to any type that is maintained by Retain and Release methods.
@ -33,7 +33,7 @@ namespace partition_alloc::internal::base {
// of ownership of the object. For example, continuing to use the above
// CGLContextObj specialization:
//
// base::ScopedTypeRef<CGLContextObj> context;
// base::apple::ScopedTypeRef<CGLContextObj> context;
// CGLCreateContext(pixel_format, share_group, context.InitializeInto());
//
// For initialization with an existing object, the caller may specify whether
@ -146,6 +146,6 @@ class ScopedTypeRef {
element_type object_;
};
} // namespace partition_alloc::internal::base
} // namespace partition_alloc::internal::base::apple
#endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_PARTITION_ALLOC_BASE_APPLE_SCOPED_TYPEREF_H_

@ -44,7 +44,7 @@ TEST_F(BackupUtilTest, TestExcludeFileFromBackups_NotByPath) {
ScopedTempDir temp_dir_;
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
FilePath excluded_file_path = temp_dir_.GetPath().Append("excluded");
base::ScopedCFTypeRef<CFURLRef> excluded_url =
ScopedCFTypeRef<CFURLRef> excluded_url =
apple::FilePathToCFURL(excluded_file_path);
constexpr char placeholder_data[] = "All your base are belong to us!";

@ -144,7 +144,7 @@ CF_TO_NS_CAST_IMPL(CTFont, NSFont)
namespace base::apple {
template <typename CFT>
id _Nullable CFToNSOwnershipCast(base::ScopedCFTypeRef<CFT>) {
id _Nullable CFToNSOwnershipCast(ScopedCFTypeRef<CFT>) {
static_assert(
AlwaysFalse<CFT>,
"Error: Do not pass a ScopedCFTypeRef to CFToNSOwnershipCast. "

@ -432,8 +432,9 @@ std::ostream& operator<<(std::ostream& o, const CFStringRef string) {
}
std::ostream& operator<<(std::ostream& o, const CFErrorRef err) {
base::ScopedCFTypeRef<CFStringRef> desc(CFErrorCopyDescription(err));
base::ScopedCFTypeRef<CFDictionaryRef> user_info(CFErrorCopyUserInfo(err));
base::apple::ScopedCFTypeRef<CFStringRef> desc(CFErrorCopyDescription(err));
base::apple::ScopedCFTypeRef<CFDictionaryRef> user_info(
CFErrorCopyUserInfo(err));
CFStringRef errorDesc = nullptr;
if (user_info.get()) {
errorDesc = reinterpret_cast<CFStringRef>(

@ -9,7 +9,7 @@
#include "base/apple/scoped_typeref.h"
namespace base {
namespace base::apple {
// ScopedCFTypeRef<> is patterned after std::unique_ptr<>, but maintains
// ownership of a CoreFoundation object: any object that can be represented
@ -43,6 +43,6 @@ template <typename CFT>
using ScopedCFTypeRef =
ScopedTypeRef<CFT, internal::ScopedCFTypeRefTraits<CFT>>;
} // namespace base
} // namespace base::apple
#endif // BASE_APPLE_SCOPED_CFTYPEREF_H_

@ -8,7 +8,7 @@
#include "base/check.h"
#include "base/memory/scoped_policy.h"
namespace base {
namespace base::apple {
// ScopedTypeRef<> is patterned after std::unique_ptr<>, but maintains ownership
// of a reference to any type that is maintained by Retain and Release methods.
@ -33,7 +33,7 @@ namespace base {
// of ownership of the object. For example, continuing to use the above
// CGLContextObj specialization:
//
// base::ScopedTypeRef<CGLContextObj> context;
// base::apple::ScopedTypeRef<CGLContextObj> context;
// CGLCreateContext(pixel_format, share_group, context.InitializeInto());
//
// For initialization with an existing object, the caller may specify whether
@ -146,6 +146,6 @@ class ScopedTypeRef {
element_type object_;
};
} // namespace base
} // namespace base::apple
#endif // BASE_APPLE_SCOPED_TYPEREF_H_

@ -1267,7 +1267,7 @@ int FilePath::HFSFastUnicodeCompare(StringPieceType string1,
StringType FilePath::GetHFSDecomposedForm(StringPieceType string) {
StringType result;
ScopedCFTypeRef<CFStringRef> cfstring(CFStringCreateWithBytesNoCopy(
apple::ScopedCFTypeRef<CFStringRef> cfstring(CFStringCreateWithBytesNoCopy(
NULL, reinterpret_cast<const UInt8*>(string.data()),
checked_cast<CFIndex>(string.length()), kCFStringEncodingUTF8, false,
kCFAllocatorNull));
@ -1310,11 +1310,11 @@ int FilePath::CompareIgnoreCase(StringPieceType string1,
// GetHFSDecomposedForm() returns an empty string in an error case.
if (hfs1.empty() || hfs2.empty()) {
ScopedCFTypeRef<CFStringRef> cfstring1(CFStringCreateWithBytesNoCopy(
apple::ScopedCFTypeRef<CFStringRef> cfstring1(CFStringCreateWithBytesNoCopy(
NULL, reinterpret_cast<const UInt8*>(string1.data()),
checked_cast<CFIndex>(string1.length()), kCFStringEncodingUTF8, false,
kCFAllocatorNull));
ScopedCFTypeRef<CFStringRef> cfstring2(CFStringCreateWithBytesNoCopy(
apple::ScopedCFTypeRef<CFStringRef> cfstring2(CFStringCreateWithBytesNoCopy(
NULL, reinterpret_cast<const UInt8*>(string2.data()),
checked_cast<CFIndex>(string2.length()), kCFStringEncodingUTF8, false,
kCFAllocatorNull));

@ -213,13 +213,13 @@ void FilePathWatcherFSEvents::UpdateEventStream(
if (fsevent_stream_)
DestroyEventStream();
ScopedCFTypeRef<CFStringRef> cf_path(CFStringCreateWithCString(
apple::ScopedCFTypeRef<CFStringRef> cf_path(CFStringCreateWithCString(
NULL, resolved_target_.value().c_str(), kCFStringEncodingMacHFS));
ScopedCFTypeRef<CFStringRef> cf_dir_path(CFStringCreateWithCString(
apple::ScopedCFTypeRef<CFStringRef> cf_dir_path(CFStringCreateWithCString(
NULL, resolved_target_.DirName().value().c_str(),
kCFStringEncodingMacHFS));
CFStringRef paths_array[] = { cf_path.get(), cf_dir_path.get() };
ScopedCFTypeRef<CFArrayRef> watched_paths(
apple::ScopedCFTypeRef<CFArrayRef> watched_paths(
CFArrayCreate(NULL, reinterpret_cast<const void**>(paths_array),
std::size(paths_array), &kCFTypeArrayCallBacks));

@ -129,9 +129,9 @@ std::string GetMacAddress(const std::string& interface_name) {
}
std::string GetRandomId() {
base::ScopedCFTypeRef<CFUUIDRef> uuid_object(
base::apple::ScopedCFTypeRef<CFUUIDRef> uuid_object(
CFUUIDCreate(kCFAllocatorDefault));
base::ScopedCFTypeRef<CFStringRef> uuid_string(
base::apple::ScopedCFTypeRef<CFStringRef> uuid_string(
CFUUIDCreateString(kCFAllocatorDefault, uuid_object));
return base::SysCFStringRefToUTF8(uuid_string);
}
@ -177,9 +177,9 @@ std::string GetSaltedString(const std::string& in_string,
hash);
CFUUIDBytes* uuid_bytes = reinterpret_cast<CFUUIDBytes*>(hash);
base::ScopedCFTypeRef<CFUUIDRef> uuid_object(
base::apple::ScopedCFTypeRef<CFUUIDRef> uuid_object(
CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault, *uuid_bytes));
base::ScopedCFTypeRef<CFStringRef> device_id(
base::apple::ScopedCFTypeRef<CFStringRef> device_id(
CFUUIDCreateString(kCFAllocatorDefault, uuid_object));
return base::SysCFStringRefToUTF8(device_id);
}

@ -65,12 +65,13 @@ class LoginItemsFileList {
// representing the specified bundle. If such an item is found, returns a
// retained reference to it. Caller is responsible for releasing the
// reference.
ScopedCFTypeRef<LSSharedFileListItemRef> GetLoginItemForApp(NSURL* url) {
apple::ScopedCFTypeRef<LSSharedFileListItemRef> GetLoginItemForApp(
NSURL* url) {
DCHECK(login_items_.get()) << "Initialize() failed or not called.";
#pragma clang diagnostic push // https://crbug.com/1154377
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
ScopedCFTypeRef<CFArrayRef> login_items_array(
apple::ScopedCFTypeRef<CFArrayRef> login_items_array(
LSSharedFileListCopySnapshot(login_items_, /*inList=*/nullptr));
#pragma clang diagnostic pop
@ -88,27 +89,27 @@ class LoginItemsFileList {
#pragma clang diagnostic pop
if (item_url && [item_url isEqual:url]) {
return ScopedCFTypeRef<LSSharedFileListItemRef>(
return apple::ScopedCFTypeRef<LSSharedFileListItemRef>(
item, base::scoped_policy::RETAIN);
}
}
return ScopedCFTypeRef<LSSharedFileListItemRef>();
return apple::ScopedCFTypeRef<LSSharedFileListItemRef>();
}
ScopedCFTypeRef<LSSharedFileListItemRef> GetLoginItemForMainApp() {
apple::ScopedCFTypeRef<LSSharedFileListItemRef> GetLoginItemForMainApp() {
NSURL* url = [NSURL fileURLWithPath:base::apple::MainBundle().bundlePath];
return GetLoginItemForApp(url);
}
private:
ScopedCFTypeRef<LSSharedFileListRef> login_items_;
apple::ScopedCFTypeRef<LSSharedFileListRef> login_items_;
};
bool IsHiddenLoginItem(LSSharedFileListItemRef item) {
#pragma clang diagnostic push // https://crbug.com/1154377
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
ScopedCFTypeRef<CFBooleanRef> hidden(
apple::ScopedCFTypeRef<CFBooleanRef> hidden(
reinterpret_cast<CFBooleanRef>(LSSharedFileListItemCopyProperty(
item, kLSSharedFileListLoginItemHidden)));
#pragma clang diagnostic pop
@ -164,7 +165,7 @@ void AddToLoginItems(const FilePath& app_bundle_file_path,
}
NSURL* app_bundle_url = base::apple::FilePathToNSURL(app_bundle_file_path);
base::ScopedCFTypeRef<LSSharedFileListItemRef> item =
apple::ScopedCFTypeRef<LSSharedFileListItemRef> item =
login_items.GetLoginItemForApp(app_bundle_url);
if (item.get() && (IsHiddenLoginItem(item) == hide_on_startup)) {
@ -185,7 +186,7 @@ void AddToLoginItems(const FilePath& app_bundle_file_path,
NSDictionary* properties =
@{apple::CFToNSPtrCast(kLSSharedFileListLoginItemHidden) : @(hide)};
ScopedCFTypeRef<LSSharedFileListItemRef> new_item(
apple::ScopedCFTypeRef<LSSharedFileListItemRef> new_item(
LSSharedFileListInsertItemURL(
login_items.GetLoginFileList(), kLSSharedFileListItemLast,
/*inDisplayName=*/nullptr,
@ -205,7 +206,7 @@ void RemoveFromLoginItems(const FilePath& app_bundle_file_path) {
}
NSURL* app_bundle_url = base::apple::FilePathToNSURL(app_bundle_file_path);
base::ScopedCFTypeRef<LSSharedFileListItemRef> item =
apple::ScopedCFTypeRef<LSSharedFileListItemRef> item =
login_items.GetLoginItemForApp(app_bundle_url);
if (!item.get()) {
return;
@ -250,7 +251,7 @@ bool WasLaunchedAsLoginItemRestoreState() {
CFStringRef app = CFSTR("com.apple.loginwindow");
CFStringRef save_state = CFSTR("TALLogoutSavesState");
ScopedCFTypeRef<CFPropertyListRef> plist(
apple::ScopedCFTypeRef<CFPropertyListRef> plist(
CFPreferencesCopyAppValue(save_state, app));
// According to documentation, com.apple.loginwindow.plist does not exist on a
// fresh installation until the user changes a login window setting. The
@ -278,7 +279,7 @@ bool WasLaunchedAsHiddenLoginItem() {
return false;
}
base::ScopedCFTypeRef<LSSharedFileListItemRef> item(
apple::ScopedCFTypeRef<LSSharedFileListItemRef> item(
login_items.GetLoginItemForMainApp());
if (!item.get()) {
// The OS itself can launch items, usually for the resume feature.
@ -407,7 +408,7 @@ std::string GetModelIdentifier() {
ScopedIOObject<io_service_t> platform_expert(IOServiceGetMatchingService(
kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice")));
if (platform_expert) {
ScopedCFTypeRef<CFDataRef> model_data(
apple::ScopedCFTypeRef<CFDataRef> model_data(
static_cast<CFDataRef>(IORegistryEntryCreateCFProperty(
platform_expert, CFSTR("model"), kCFAllocatorDefault, 0)));
if (model_data) {
@ -462,7 +463,7 @@ std::string GetPlatformSerialNumber() {
return std::string();
}
base::ScopedCFTypeRef<CFTypeRef> serial_number(
apple::ScopedCFTypeRef<CFTypeRef> serial_number(
IORegistryEntryCreateCFProperty(expert_device,
CFSTR(kIOPlatformSerialNumberKey),
kCFAllocatorDefault, 0));

@ -27,7 +27,8 @@ struct ScopedIOObjectTraits {
// Just like ScopedCFTypeRef but for io_object_t and subclasses.
template <typename IOT>
using ScopedIOObject = ScopedTypeRef<IOT, internal::ScopedIOObjectTraits<IOT>>;
using ScopedIOObject =
apple::ScopedTypeRef<IOT, internal::ScopedIOObjectTraits<IOT>>;
} // namespace base::mac

@ -29,7 +29,7 @@ struct ScopedIOPluginInterfaceTraits {
// (IOUSBInterfaceStruct and IOUSBDeviceStruct320 in particular).
template <typename T>
using ScopedIOPluginInterface =
ScopedTypeRef<T**, internal::ScopedIOPluginInterfaceTraits<T**>>;
apple::ScopedTypeRef<T**, internal::ScopedIOPluginInterfaceTraits<T**>>;
} // namespace base::mac

@ -219,20 +219,20 @@ class BASE_EXPORT MessagePumpCFRunLoopBase : public MessagePump {
void PushWorkItemScope();
// The thread's run loop.
base::ScopedCFTypeRef<CFRunLoopRef> run_loop_;
apple::ScopedCFTypeRef<CFRunLoopRef> run_loop_;
// The enabled modes. Posted tasks may run in any non-null entry.
std::unique_ptr<ScopedModeEnabler> enabled_modes_[kNumModes];
// The timer, sources, and observers are described above alongside their
// callbacks.
base::ScopedCFTypeRef<CFRunLoopTimerRef> delayed_work_timer_;
base::ScopedCFTypeRef<CFRunLoopSourceRef> work_source_;
base::ScopedCFTypeRef<CFRunLoopSourceRef> nesting_deferred_work_source_;
base::ScopedCFTypeRef<CFRunLoopObserverRef> pre_wait_observer_;
base::ScopedCFTypeRef<CFRunLoopObserverRef> after_wait_observer_;
base::ScopedCFTypeRef<CFRunLoopObserverRef> pre_source_observer_;
base::ScopedCFTypeRef<CFRunLoopObserverRef> enter_exit_observer_;
apple::ScopedCFTypeRef<CFRunLoopTimerRef> delayed_work_timer_;
apple::ScopedCFTypeRef<CFRunLoopSourceRef> work_source_;
apple::ScopedCFTypeRef<CFRunLoopSourceRef> nesting_deferred_work_source_;
apple::ScopedCFTypeRef<CFRunLoopObserverRef> pre_wait_observer_;
apple::ScopedCFTypeRef<CFRunLoopObserverRef> after_wait_observer_;
apple::ScopedCFTypeRef<CFRunLoopObserverRef> pre_source_observer_;
apple::ScopedCFTypeRef<CFRunLoopObserverRef> enter_exit_observer_;
// (weak) Delegate passed as an argument to the innermost Run call.
raw_ptr<Delegate> delegate_ = nullptr;
@ -310,7 +310,7 @@ class BASE_EXPORT MessagePumpNSRunLoop : public MessagePumpCFRunLoopBase {
// A source that doesn't do anything but provide something signalable
// attached to the run loop. This source will be signalled when Quit
// is called, to cause the loop to wake up so that it can stop.
base::ScopedCFTypeRef<CFRunLoopSourceRef> quit_source_;
apple::ScopedCFTypeRef<CFRunLoopSourceRef> quit_source_;
};
#if BUILDFLAG(IS_IOS)

@ -91,9 +91,9 @@ bool MessagePumpIOSForIO::WatchFileDescriptor(int fd,
CFFileDescriptorRef fdref = controller->fdref_.get();
if (fdref == NULL) {
base::ScopedCFTypeRef<CFFileDescriptorRef> scoped_fdref(
CFFileDescriptorCreate(
kCFAllocatorDefault, fd, false, HandleFdIOEvent, &source_context));
apple::ScopedCFTypeRef<CFFileDescriptorRef> scoped_fdref(
CFFileDescriptorCreate(kCFAllocatorDefault, fd, false, HandleFdIOEvent,
&source_context));
if (scoped_fdref == NULL) {
NOTREACHED() << "CFFileDescriptorCreate failed";
return false;
@ -102,9 +102,9 @@ bool MessagePumpIOSForIO::WatchFileDescriptor(int fd,
CFFileDescriptorEnableCallBacks(scoped_fdref, callback_types);
// TODO(wtc): what should the 'order' argument be?
base::ScopedCFTypeRef<CFRunLoopSourceRef> scoped_fd_source(
CFFileDescriptorCreateRunLoopSource(
kCFAllocatorDefault, scoped_fdref, 0));
apple::ScopedCFTypeRef<CFRunLoopSourceRef> scoped_fd_source(
CFFileDescriptorCreateRunLoopSource(kCFAllocatorDefault, scoped_fdref,
0));
if (scoped_fd_source == NULL) {
NOTREACHED() << "CFFileDescriptorCreateRunLoopSource failed";
return false;
@ -154,7 +154,7 @@ void MessagePumpIOSForIO::HandleFdIOEvent(CFFileDescriptorRef fdref,
// Ensure that |fdref| will remain live for the duration of this function
// call even if |controller| is deleted or |StopWatchingFileDescriptor()| is
// called, either of which will cause |fdref| to be released.
ScopedCFTypeRef<CFFileDescriptorRef> scoped_fdref(
apple::ScopedCFTypeRef<CFFileDescriptorRef> scoped_fdref(
fdref, base::scoped_policy::RETAIN);
int fd = CFFileDescriptorGetNativeDescriptor(fdref);

@ -53,10 +53,10 @@ class BASE_EXPORT MessagePumpIOSForIO : public MessagePumpNSRunLoop,
void OnFileCanWriteWithoutBlocking(int fd, MessagePumpIOSForIO* pump);
bool is_persistent_ = false; // false if this event is one-shot.
base::apple::ScopedCFFileDescriptorRef fdref_;
apple::ScopedCFFileDescriptorRef fdref_;
CFOptionFlags callback_types_ = 0;
base::ScopedCFTypeRef<CFRunLoopSourceRef> fd_source_;
base::WeakPtr<MessagePumpIOSForIO> pump_;
apple::ScopedCFTypeRef<CFRunLoopSourceRef> fd_source_;
WeakPtr<MessagePumpIOSForIO> pump_;
FdWatcher* watcher_ = nullptr;
};

@ -64,7 +64,7 @@ NativeLibrary LoadNativeLibraryWithOptions(const FilePath& library_path,
native_lib->objc_status = OBJC_UNKNOWN;
return native_lib;
}
ScopedCFTypeRef<CFURLRef> url(CFURLCreateFromFileSystemRepresentation(
apple::ScopedCFTypeRef<CFURLRef> url(CFURLCreateFromFileSystemRepresentation(
kCFAllocatorDefault, (const UInt8*)library_path.value().c_str(),
checked_cast<CFIndex>(library_path.value().length()), true));
if (!url)
@ -103,7 +103,7 @@ void* GetFunctionPointerFromNativeLibrary(NativeLibrary library,
// Get the function pointer using the right API for the type.
if (library->type == BUNDLE) {
ScopedCFTypeRef<CFStringRef> symbol_name(CFStringCreateWithCString(
apple::ScopedCFTypeRef<CFStringRef> symbol_name(CFStringCreateWithCString(
kCFAllocatorDefault, name, kCFStringEncodingUTF8));
function_pointer =
CFBundleGetFunctionPointerForName(library->bundle, symbol_name);

@ -71,7 +71,7 @@ BatteryLevelProviderMac::GetBatteryStateImpl() {
return MakeBatteryState(/* battery_details=*/{});
}
base::ScopedCFTypeRef<CFMutableDictionaryRef> dict;
apple::ScopedCFTypeRef<CFMutableDictionaryRef> dict;
kern_return_t result =
IORegistryEntryCreateCFProperties(service.get(), dict.InitializeInto(),
/*allocator=*/nullptr, /*options=*/0);

@ -111,7 +111,7 @@ ThermalStateObserverMac::GetCurrentThermalState() {
}
int ThermalStateObserverMac::GetCurrentSpeedLimit() {
base::ScopedCFTypeRef<CFDictionaryRef> dictionary;
apple::ScopedCFTypeRef<CFDictionaryRef> dictionary;
IOReturn result = IOPMCopyCPUPowerStatus(dictionary.InitializeInto());
if (result != kIOReturnSuccess) {
DVLOG(1) << __func__

@ -63,10 +63,10 @@ namespace base {
// Converts between strings and CFStringRefs/NSStrings.
// Converts a string to a CFStringRef. Returns null on failure.
[[nodiscard]] BASE_EXPORT ScopedCFTypeRef<CFStringRef> SysUTF8ToCFStringRef(
StringPiece utf8);
[[nodiscard]] BASE_EXPORT ScopedCFTypeRef<CFStringRef> SysUTF16ToCFStringRef(
StringPiece16 utf16);
[[nodiscard]] BASE_EXPORT apple::ScopedCFTypeRef<CFStringRef>
SysUTF8ToCFStringRef(StringPiece utf8);
[[nodiscard]] BASE_EXPORT apple::ScopedCFTypeRef<CFStringRef>
SysUTF16ToCFStringRef(StringPiece16 utf16);
// Converts a CFStringRef to a string. Returns an empty string on failure. It is
// not valid to call these with a null `ref`.

@ -81,7 +81,7 @@ OutStringType StringToStringWithEncodingsT(const InStringType& in,
return OutStringType();
}
base::ScopedCFTypeRef<CFStringRef> cfstring(CFStringCreateWithBytesNoCopy(
apple::ScopedCFTypeRef<CFStringRef> cfstring(CFStringCreateWithBytesNoCopy(
kCFAllocatorDefault, reinterpret_cast<const UInt8*>(in.data()),
checked_cast<CFIndex>(in_length *
sizeof(typename InStringType::value_type)),
@ -97,15 +97,16 @@ OutStringType StringToStringWithEncodingsT(const InStringType& in,
// Given a StringPiece `in` with an encoding specified by `in_encoding`, returns
// it as a CFStringRef. Returns null on failure.
template <typename CharT>
ScopedCFTypeRef<CFStringRef> StringPieceToCFStringWithEncodingsT(
apple::ScopedCFTypeRef<CFStringRef> StringPieceToCFStringWithEncodingsT(
BasicStringPiece<CharT> in,
CFStringEncoding in_encoding) {
const auto in_length = in.length();
if (in_length == 0) {
return ScopedCFTypeRef<CFStringRef>(CFSTR(""), base::scoped_policy::RETAIN);
return apple::ScopedCFTypeRef<CFStringRef>(CFSTR(""),
base::scoped_policy::RETAIN);
}
return ScopedCFTypeRef<CFStringRef>(CFStringCreateWithBytes(
return apple::ScopedCFTypeRef<CFStringRef>(CFStringCreateWithBytes(
kCFAllocatorDefault, reinterpret_cast<const UInt8*>(in.data()),
checked_cast<CFIndex>(in_length * sizeof(CharT)), in_encoding, false));
}
@ -136,11 +137,11 @@ std::wstring SysNativeMBToWide(StringPiece native_mb) {
return SysUTF8ToWide(native_mb);
}
ScopedCFTypeRef<CFStringRef> SysUTF8ToCFStringRef(StringPiece utf8) {
apple::ScopedCFTypeRef<CFStringRef> SysUTF8ToCFStringRef(StringPiece utf8) {
return StringPieceToCFStringWithEncodingsT(utf8, kCFStringEncodingUTF8);
}
ScopedCFTypeRef<CFStringRef> SysUTF16ToCFStringRef(StringPiece16 utf16) {
apple::ScopedCFTypeRef<CFStringRef> SysUTF16ToCFStringRef(StringPiece16 utf16) {
return StringPieceToCFStringWithEncodingsT(utf16, kCFStringEncodingUTF16LE);
}

@ -26,11 +26,11 @@ namespace base {
// static
bool Time::FromExploded(bool is_local, const Exploded& exploded, Time* time) {
base::ScopedCFTypeRef<CFTimeZoneRef> time_zone(
ScopedCFTypeRef<CFTimeZoneRef> time_zone(
is_local
? CFTimeZoneCopySystem()
: CFTimeZoneCreateWithTimeIntervalFromGMT(kCFAllocatorDefault, 0));
base::ScopedCFTypeRef<CFCalendarRef> gregorian(CFCalendarCreateWithIdentifier(
ScopedCFTypeRef<CFCalendarRef> gregorian(CFCalendarCreateWithIdentifier(
kCFAllocatorDefault, kCFGregorianCalendar));
CFCalendarSetTimeZone(gregorian, time_zone);
CFAbsoluteTime absolute_time;
@ -83,11 +83,11 @@ void Time::Explode(bool is_local, Exploded* exploded) const {
kMicrosecondsPerSecond) -
kCFAbsoluteTimeIntervalSince1970;
base::ScopedCFTypeRef<CFTimeZoneRef> time_zone(
ScopedCFTypeRef<CFTimeZoneRef> time_zone(
is_local
? CFTimeZoneCopySystem()
: CFTimeZoneCreateWithTimeIntervalFromGMT(kCFAllocatorDefault, 0));
base::ScopedCFTypeRef<CFCalendarRef> gregorian(CFCalendarCreateWithIdentifier(
ScopedCFTypeRef<CFCalendarRef> gregorian(CFCalendarCreateWithIdentifier(
kCFAllocatorDefault, kCFGregorianCalendar));
CFCalendarSetTimeZone(gregorian, time_zone);
int second, day_of_week;

@ -17,7 +17,7 @@
bool ChromeCrashReporterClient::ReportingIsEnforcedByPolicy(
bool* breakpad_enabled) {
base::ScopedCFTypeRef<CFStringRef> key =
base::apple::ScopedCFTypeRef<CFStringRef> key =
base::SysUTF8ToCFStringRef(policy::key::kMetricsReportingEnabled);
Boolean key_valid;
Boolean metrics_reporting_enabled = CFPreferencesGetAppBooleanValue(key,

@ -271,7 +271,7 @@ void RecordLastRunAppBundlePath() {
.DirName()
.DirName()
.DirName();
base::ScopedCFTypeRef<CFStringRef> app_bundle_path_cfstring =
base::apple::ScopedCFTypeRef<CFStringRef> app_bundle_path_cfstring =
base::SysUTF8ToCFStringRef(app_bundle_path.value());
CFPreferencesSetAppValue(
base::apple::NSToCFPtrCast(app_mode::kLastRunAppBundlePathPrefsKey),

@ -28,7 +28,7 @@ AppShimHostBootstrap::Client* g_client = nullptr;
// TODO(https://crbug.com/1052131): Remove NSLog logging, and move to an
// internal debugging URL.
void LogToNSLog(std::string format, ...) {
base::ScopedCFTypeRef<CFStringRef> cf_format(
base::apple::ScopedCFTypeRef<CFStringRef> cf_format(
base::SysUTF8ToCFStringRef(format));
va_list arguments;

@ -109,14 +109,14 @@ void DumpError(std::string error_details) {
// * "has_value() == true" app shim validation should occur.
// * "has_value() == false" app shim validation should be skipped.
// * "has_value() == true && value() == null" validation should always fail.
absl::optional<base::ScopedCFTypeRef<SecRequirementRef>>
absl::optional<base::apple::ScopedCFTypeRef<SecRequirementRef>>
CreateAppShimRequirement() {
// Note: Don't validate |framework_code|: We don't need to waste time
// validating. We are only interested in discovering if the framework bundle
// is code-signed, and if so what the designated requirement is.
base::ScopedCFTypeRef<CFURLRef> framework_url =
base::apple::ScopedCFTypeRef<CFURLRef> framework_url =
base::apple::FilePathToCFURL(base::apple::FrameworkBundlePath());
base::ScopedCFTypeRef<SecStaticCodeRef> framework_code;
base::apple::ScopedCFTypeRef<SecStaticCodeRef> framework_code;
OSStatus status = SecStaticCodeCreateWithPath(
framework_url, kSecCSDefaultFlags, framework_code.InitializeInto());
@ -132,18 +132,18 @@ CreateAppShimRequirement() {
if (status != errSecSuccess) {
DumpOSStatusError(status, "SecStaticCodeCreateWithPath");
// has_value() == true
return base::ScopedCFTypeRef<SecRequirementRef>(nullptr);
return base::apple::ScopedCFTypeRef<SecRequirementRef>(nullptr);
}
// Copy the signing info from the SecStaticCodeRef.
base::ScopedCFTypeRef<CFDictionaryRef> framework_signing_info;
base::apple::ScopedCFTypeRef<CFDictionaryRef> framework_signing_info;
status = SecCodeCopySigningInformation(
framework_code.get(), kSecCSSigningInformation,
framework_signing_info.InitializeInto());
if (status != errSecSuccess) {
DumpOSStatusError(status, "SecCodeCopySigningInformation");
// has_value() == true
return base::ScopedCFTypeRef<SecRequirementRef>(nullptr);
return base::apple::ScopedCFTypeRef<SecRequirementRef>(nullptr);
}
// Look up the code signing flags. If the flags are absent treat this as
@ -168,7 +168,7 @@ CreateAppShimRequirement() {
&flags)) {
DumpError("CFNumberGetValue");
// has_value() == true
return base::ScopedCFTypeRef<SecRequirementRef>(nullptr);
return base::apple::ScopedCFTypeRef<SecRequirementRef>(nullptr);
}
if (static_cast<uint32_t>(flags) & kSecCodeSignatureAdhoc) {
return absl::nullopt; // has_value() == false
@ -178,24 +178,24 @@ CreateAppShimRequirement() {
// validate the app shim's code signature. First let's get the framework
// bundle requirement. We will build a suitable requirement for the app shim
// based off that.
base::ScopedCFTypeRef<SecRequirementRef> framework_requirement;
base::apple::ScopedCFTypeRef<SecRequirementRef> framework_requirement;
status =
SecCodeCopyDesignatedRequirement(framework_code, kSecCSDefaultFlags,
framework_requirement.InitializeInto());
if (status != errSecSuccess) {
DumpOSStatusError(status, "SecCodeCopyDesignatedRequirement");
// has_value() == true
return base::ScopedCFTypeRef<SecRequirementRef>(nullptr);
return base::apple::ScopedCFTypeRef<SecRequirementRef>(nullptr);
}
base::ScopedCFTypeRef<CFStringRef> framework_requirement_string;
base::apple::ScopedCFTypeRef<CFStringRef> framework_requirement_string;
status =
SecRequirementCopyString(framework_requirement, kSecCSDefaultFlags,
framework_requirement_string.InitializeInto());
if (status != errSecSuccess) {
DumpOSStatusError(status, "SecRequirementCopyString");
// has_value() == true
return base::ScopedCFTypeRef<SecRequirementRef>(nullptr);
return base::apple::ScopedCFTypeRef<SecRequirementRef>(nullptr);
}
// Always returns has_value() == true.
@ -212,7 +212,7 @@ CreateAppShimRequirement() {
// requirement).
bool IsAcceptablyCodeSignedInternal(pid_t app_shim_pid) {
static base::NoDestructor<
absl::optional<base::ScopedCFTypeRef<SecRequirementRef>>>
absl::optional<base::apple::ScopedCFTypeRef<SecRequirementRef>>>
app_shim_requirement(CreateAppShimRequirement());
if (!app_shim_requirement->has_value()) {
// App shim validation is not required because framework bundle is not
@ -229,15 +229,16 @@ bool IsAcceptablyCodeSignedInternal(pid_t app_shim_pid) {
}
// Verify the app shim.
base::ScopedCFTypeRef<CFNumberRef> app_shim_pid_cf(
base::apple::ScopedCFTypeRef<CFNumberRef> app_shim_pid_cf(
CFNumberCreate(nullptr, kCFNumberIntType, &app_shim_pid));
const void* app_shim_attribute_keys[] = {kSecGuestAttributePid};
const void* app_shim_attribute_values[] = {app_shim_pid_cf};
base::ScopedCFTypeRef<CFDictionaryRef> app_shim_attributes(CFDictionaryCreate(
nullptr, app_shim_attribute_keys, app_shim_attribute_values,
std::size(app_shim_attribute_keys), &kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks));
base::ScopedCFTypeRef<SecCodeRef> app_shim_code;
base::apple::ScopedCFTypeRef<CFDictionaryRef> app_shim_attributes(
CFDictionaryCreate(
nullptr, app_shim_attribute_keys, app_shim_attribute_values,
std::size(app_shim_attribute_keys), &kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks));
base::apple::ScopedCFTypeRef<SecCodeRef> app_shim_code;
OSStatus status = SecCodeCopyGuestWithAttributes(
nullptr, app_shim_attributes, kSecCSDefaultFlags,
app_shim_code.InitializeInto());
@ -1667,7 +1668,7 @@ bool AppShimManager::LoadAndLaunchAppParams::HasFilesOrURLs() const {
return !files.empty() || !urls.empty() || !override_url.is_empty();
}
base::ScopedCFTypeRef<SecRequirementRef>
base::apple::ScopedCFTypeRef<SecRequirementRef>
AppShimManager::BuildAppShimRequirementFromFrameworkRequirementString(
CFStringRef framwork_requirement) {
// Make sure the framework bundle requirement is in the expected format.
@ -1676,13 +1677,13 @@ AppShimManager::BuildAppShimRequirementFromFrameworkRequirementString(
// we can swap in the desired app shim identifier leaving rest of the
// requirement unmodified.
CFIndex len = CFStringGetLength(framwork_requirement);
base::ScopedCFTypeRef<CFArrayRef> quote_ranges(
base::apple::ScopedCFTypeRef<CFArrayRef> quote_ranges(
CFStringCreateArrayWithFindResults(nullptr, framwork_requirement,
CFSTR("\""), CFRangeMake(0, len), 0));
if (!CFStringHasPrefix(framwork_requirement, CFSTR("identifier \"")) ||
!quote_ranges || CFArrayGetCount(quote_ranges) < 2) {
DumpError("Framework bundle requirement is malformed.");
return base::ScopedCFTypeRef<SecRequirementRef>(nullptr);
return base::apple::ScopedCFTypeRef<SecRequirementRef>(nullptr);
}
// Get the index of the second quote.
@ -1693,22 +1694,22 @@ AppShimManager::BuildAppShimRequirementFromFrameworkRequirementString(
// Make sure there is something to read after the second quote.
if (second_quote_index + 1 >= len) {
DumpError("Framework bundle requirement is too short");
return base::ScopedCFTypeRef<SecRequirementRef>(nullptr);
return base::apple::ScopedCFTypeRef<SecRequirementRef>(nullptr);
}
// Build the app shim requirement. Keep the data from the framework bundle
// requirement starting after second quote.
base::ScopedCFTypeRef<CFStringRef> right_of_second_quote(
base::apple::ScopedCFTypeRef<CFStringRef> right_of_second_quote(
CFStringCreateWithSubstring(
nullptr, framwork_requirement,
CFRangeMake(second_quote_index + 1, len - second_quote_index - 1)));
base::ScopedCFTypeRef<CFMutableStringRef> shim_requirement_string(
base::apple::ScopedCFTypeRef<CFMutableStringRef> shim_requirement_string(
CFStringCreateMutableCopy(nullptr, 0,
CFSTR("identifier \"app_mode_loader\"")));
CFStringAppend(shim_requirement_string, right_of_second_quote);
// Parse the requirement.
base::ScopedCFTypeRef<SecRequirementRef> shim_requirement;
base::apple::ScopedCFTypeRef<SecRequirementRef> shim_requirement;
OSStatus status = SecRequirementCreateWithString(
shim_requirement_string, kSecCSDefaultFlags,
shim_requirement.InitializeInto());
@ -1716,7 +1717,7 @@ AppShimManager::BuildAppShimRequirementFromFrameworkRequirementString(
DumpOSStatusError(status,
std::string("SecRequirementCreateWithString: ") +
base::SysCFStringRefToUTF8(shim_requirement_string));
return base::ScopedCFTypeRef<SecRequirementRef>(nullptr);
return base::apple::ScopedCFTypeRef<SecRequirementRef>(nullptr);
}
return shim_requirement;
}

@ -231,7 +231,7 @@ class AppShimManager
// AvatarMenuObserver:
void OnAvatarMenuChanged(AvatarMenu* menu) override;
static base::ScopedCFTypeRef<SecRequirementRef>
static base::apple::ScopedCFTypeRef<SecRequirementRef>
BuildAppShimRequirementFromFrameworkRequirementString(CFStringRef);
class AppShimObserver {

@ -1790,11 +1790,11 @@ TEST_F(AppShimManagerTest,
"apple generic and certificate 1[field.1.2.840.113635.100.6.2.6] /* "
"exists */ and certificate leaf[field.1.2.840.113635.100.6.1.13] "
"/* exists */ and certificate leaf[subject.OU] = EQHXZ8M8AV");
base::ScopedCFTypeRef<SecRequirementRef> got_req(
base::apple::ScopedCFTypeRef<SecRequirementRef> got_req(
manager_->BuildAppShimRequirementFromFrameworkRequirementString(
framework_req_string));
ASSERT_TRUE(got_req);
base::ScopedCFTypeRef<CFStringRef> got_req_string;
base::apple::ScopedCFTypeRef<CFStringRef> got_req_string;
ASSERT_EQ(SecRequirementCopyString(got_req, kSecCSDefaultFlags,
got_req_string.InitializeInto()),
errSecSuccess);

@ -24,11 +24,11 @@ class MockSecureEnclaveClient : public SecureEnclaveClient {
MockSecureEnclaveClient();
~MockSecureEnclaveClient() override;
MOCK_METHOD(base::ScopedCFTypeRef<SecKeyRef>,
MOCK_METHOD(base::apple::ScopedCFTypeRef<SecKeyRef>,
CreatePermanentKey,
(),
(override));
MOCK_METHOD(base::ScopedCFTypeRef<SecKeyRef>,
MOCK_METHOD(base::apple::ScopedCFTypeRef<SecKeyRef>,
CopyStoredKey,
(KeyType),
(override));

@ -21,11 +21,11 @@ class MockSecureEnclaveHelper : public SecureEnclaveHelper {
MockSecureEnclaveHelper();
~MockSecureEnclaveHelper() override;
MOCK_METHOD(base::ScopedCFTypeRef<SecKeyRef>,
MOCK_METHOD(base::apple::ScopedCFTypeRef<SecKeyRef>,
CreateSecureKey,
(CFDictionaryRef, OSStatus*),
(override));
MOCK_METHOD(base::ScopedCFTypeRef<SecKeyRef>,
MOCK_METHOD(base::apple::ScopedCFTypeRef<SecKeyRef>,
CopyKey,
(CFDictionaryRef, OSStatus*),
(override));

@ -43,11 +43,12 @@ class SecureEnclaveClient {
base::span<const uint8_t> wrapped_key_label);
// Creates a new Secure Enclave private key with a permanent key label.
virtual base::ScopedCFTypeRef<SecKeyRef> CreatePermanentKey() = 0;
virtual base::apple::ScopedCFTypeRef<SecKeyRef> CreatePermanentKey() = 0;
// Queries for the secure key using its label determined by the key `type`.
// Returns the secure key reference or a nullptr if no key was found.
virtual base::ScopedCFTypeRef<SecKeyRef> CopyStoredKey(KeyType type) = 0;
virtual base::apple::ScopedCFTypeRef<SecKeyRef> CopyStoredKey(
KeyType type) = 0;
// Deletes any key stored in `new_key_type` and updates the private key
// storage in `current_key_type` to `new_key_type` and modifies the key label

@ -27,8 +27,8 @@ class SecureEnclaveClientImpl : public SecureEnclaveClient {
~SecureEnclaveClientImpl() override;
// SecureEnclaveClient:
base::ScopedCFTypeRef<SecKeyRef> CreatePermanentKey() override;
base::ScopedCFTypeRef<SecKeyRef> CopyStoredKey(KeyType type) override;
base::apple::ScopedCFTypeRef<SecKeyRef> CreatePermanentKey() override;
base::apple::ScopedCFTypeRef<SecKeyRef> CopyStoredKey(KeyType type) override;
bool UpdateStoredKeyLabel(KeyType current_key_type,
KeyType new_key_type) override;
bool DeleteKey(KeyType type) override;

@ -56,8 +56,8 @@ base::StringPiece GetLabelFromKeyType(SecureEnclaveClient::KeyType type) {
// Creates and returns the secure enclave private key attributes used
// for key creation. These key attributes represent the key created in
// the permanent key location.
base::ScopedCFTypeRef<CFMutableDictionaryRef> CreateAttributesForKey() {
base::ScopedCFTypeRef<CFMutableDictionaryRef> attributes(
base::apple::ScopedCFTypeRef<CFMutableDictionaryRef> CreateAttributesForKey() {
base::apple::ScopedCFTypeRef<CFMutableDictionaryRef> attributes(
CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks));
@ -75,13 +75,13 @@ base::ScopedCFTypeRef<CFMutableDictionaryRef> CreateAttributesForKey() {
attributes, kSecAttrLabel,
base::SysUTF8ToCFStringRef(constants::kDeviceTrustSigningKeyLabel));
base::ScopedCFTypeRef<CFMutableDictionaryRef> private_key_params(
base::apple::ScopedCFTypeRef<CFMutableDictionaryRef> private_key_params(
CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks));
CFDictionarySetValue(attributes, kSecPrivateKeyAttrs, private_key_params);
CFDictionarySetValue(private_key_params, kSecAttrIsPermanent, kCFBooleanTrue);
base::ScopedCFTypeRef<SecAccessControlRef> access_control(
base::apple::ScopedCFTypeRef<SecAccessControlRef> access_control(
SecAccessControlCreateWithFlags(
kCFAllocatorDefault,
// Private key can only be used when the device is unlocked.
@ -95,11 +95,12 @@ base::ScopedCFTypeRef<CFMutableDictionaryRef> CreateAttributesForKey() {
// Creates the query used for querying the keychain for the secure key
// reference.
base::ScopedCFTypeRef<CFMutableDictionaryRef> CreateQueryForKey(
base::apple::ScopedCFTypeRef<CFMutableDictionaryRef> CreateQueryForKey(
SecureEnclaveClient::KeyType type) {
base::ScopedCFTypeRef<CFMutableDictionaryRef> query(CFDictionaryCreateMutable(
kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks));
base::apple::ScopedCFTypeRef<CFMutableDictionaryRef> query(
CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks));
CFDictionarySetValue(query, kSecClass, kSecClassKey);
CFDictionarySetValue(query, kSecAttrKeyType, kSecAttrKeyTypeECSECPrimeRandom);
CFDictionarySetValue(query, kSecAttrLabel,
@ -118,10 +119,11 @@ SecureEnclaveClientImpl::SecureEnclaveClientImpl()
SecureEnclaveClientImpl::~SecureEnclaveClientImpl() = default;
base::ScopedCFTypeRef<SecKeyRef> SecureEnclaveClientImpl::CreatePermanentKey() {
base::apple::ScopedCFTypeRef<SecKeyRef>
SecureEnclaveClientImpl::CreatePermanentKey() {
auto attributes = CreateAttributesForKey();
if (!attributes)
return base::ScopedCFTypeRef<SecKeyRef>();
return base::apple::ScopedCFTypeRef<SecKeyRef>();
// Deletes a permanent Secure Enclave key if it exists from a previous
// key rotation.
@ -137,7 +139,7 @@ base::ScopedCFTypeRef<SecKeyRef> SecureEnclaveClientImpl::CreatePermanentKey() {
return key;
}
base::ScopedCFTypeRef<SecKeyRef> SecureEnclaveClientImpl::CopyStoredKey(
base::apple::ScopedCFTypeRef<SecKeyRef> SecureEnclaveClientImpl::CopyStoredKey(
KeyType type) {
OSStatus status;
auto key_ref = helper_->CopyKey(CreateQueryForKey(type), &status);
@ -153,7 +155,7 @@ bool SecureEnclaveClientImpl::UpdateStoredKeyLabel(KeyType current_key_type,
// Deletes the `new_key_type` label if it exists in the keychain.
DeleteKey(new_key_type);
base::ScopedCFTypeRef<CFMutableDictionaryRef> attributes_to_update(
base::apple::ScopedCFTypeRef<CFMutableDictionaryRef> attributes_to_update(
CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks));
@ -202,10 +204,10 @@ bool SecureEnclaveClientImpl::GetStoredKeyLabel(KeyType type,
bool SecureEnclaveClientImpl::ExportPublicKey(SecKeyRef key,
std::vector<uint8_t>& output) {
base::ScopedCFTypeRef<SecKeyRef> public_key =
base::ScopedCFTypeRef<SecKeyRef>(SecKeyCopyPublicKey(key));
base::ScopedCFTypeRef<CFErrorRef> error;
base::ScopedCFTypeRef<CFDataRef> data_ref(
base::apple::ScopedCFTypeRef<SecKeyRef> public_key =
base::apple::ScopedCFTypeRef<SecKeyRef>(SecKeyCopyPublicKey(key));
base::apple::ScopedCFTypeRef<CFErrorRef> error;
base::apple::ScopedCFTypeRef<CFDataRef> data_ref(
SecKeyCopyExternalRepresentation(public_key, error.InitializeInto()));
if (!data_ref)
@ -244,12 +246,12 @@ bool SecureEnclaveClientImpl::ExportPublicKey(SecKeyRef key,
bool SecureEnclaveClientImpl::SignDataWithKey(SecKeyRef key,
base::span<const uint8_t> data,
std::vector<uint8_t>& output) {
base::ScopedCFTypeRef<CFDataRef> data_ref(
base::apple::ScopedCFTypeRef<CFDataRef> data_ref(
CFDataCreate(kCFAllocatorDefault, data.data(),
base::checked_cast<CFIndex>(data.size())));
base::ScopedCFTypeRef<CFErrorRef> error;
base::ScopedCFTypeRef<CFDataRef> signature(SecKeyCreateSignature(
base::apple::ScopedCFTypeRef<CFErrorRef> error;
base::apple::ScopedCFTypeRef<CFDataRef> signature(SecKeyCreateSignature(
key, kSecKeyAlgorithmECDSASignatureMessageX962SHA256, data_ref,
error.InitializeInto()));

@ -65,7 +65,7 @@ class SecureEnclaveClientTest : public testing::Test {
// Creates a test key.
void CreateAndSetTestKey() {
base::ScopedCFTypeRef<CFMutableDictionaryRef> test_attributes(
base::apple::ScopedCFTypeRef<CFMutableDictionaryRef> test_attributes(
CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks));
@ -75,7 +75,7 @@ class SecureEnclaveClientTest : public testing::Test {
kSecAttrKeyTypeECSECPrimeRandom);
CFDictionarySetValue(test_attributes, kSecAttrKeySizeInBits,
base::apple::NSToCFPtrCast(@256));
base::ScopedCFTypeRef<CFMutableDictionaryRef> private_key_params(
base::apple::ScopedCFTypeRef<CFMutableDictionaryRef> private_key_params(
CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks));
@ -83,7 +83,7 @@ class SecureEnclaveClientTest : public testing::Test {
kCFBooleanFalse);
CFDictionarySetValue(test_attributes, kSecPrivateKeyAttrs,
private_key_params);
test_key_ = base::ScopedCFTypeRef<SecKeyRef>(
test_key_ = base::apple::ScopedCFTypeRef<SecKeyRef>(
SecKeyCreateRandomKey(test_attributes, nullptr));
}
@ -99,7 +99,7 @@ class SecureEnclaveClientTest : public testing::Test {
raw_ptr<MockSecureEnclaveHelper, DanglingUntriaged>
mock_secure_enclave_helper_ = nullptr;
std::unique_ptr<SecureEnclaveClient> secure_enclave_client_;
base::ScopedCFTypeRef<SecKeyRef> test_key_;
base::apple::ScopedCFTypeRef<SecKeyRef> test_key_;
};
// Tests that the CreatePermanentKey method invokes both the SE helper's
@ -165,7 +165,7 @@ TEST_F(SecureEnclaveClientTest, CreateKey_Failure) {
.Times(1)
.WillOnce([](CFDictionaryRef attributes, OSStatus* status) {
*status = errSecItemNotFound;
return base::ScopedCFTypeRef<SecKeyRef>();
return base::apple::ScopedCFTypeRef<SecKeyRef>();
});
EXPECT_FALSE(secure_enclave_client_->CreatePermanentKey());
@ -214,7 +214,7 @@ TEST_F(SecureEnclaveClientTest, CopyStoredKey_KeyNotFound) {
.Times(2)
.WillRepeatedly([](CFDictionaryRef query, OSStatus* status) {
*status = errSecItemNotFound;
return base::ScopedCFTypeRef<SecKeyRef>();
return base::apple::ScopedCFTypeRef<SecKeyRef>();
});
EXPECT_FALSE(secure_enclave_client_->CopyStoredKey(
SecureEnclaveClient::KeyType::kPermanent));
@ -506,7 +506,7 @@ TEST_F(SecureEnclaveClientTest, GetStoredKeyLabel_TemporaryKeyNotFound) {
.Times(1)
.WillOnce([](CFDictionaryRef query, OSStatus* status) {
*status = errSecItemNotFound;
return base::ScopedCFTypeRef<SecKeyRef>();
return base::apple::ScopedCFTypeRef<SecKeyRef>();
});
EXPECT_FALSE(secure_enclave_client_->GetStoredKeyLabel(
SecureEnclaveClient::KeyType::kTemporary, output));
@ -565,7 +565,7 @@ TEST_F(SecureEnclaveClientTest, GetStoredKeyLabel_PermanentKeyNotFound) {
.Times(1)
.WillOnce([](CFDictionaryRef query, OSStatus* status) {
*status = errSecItemNotFound;
return base::ScopedCFTypeRef<SecKeyRef>();
return base::apple::ScopedCFTypeRef<SecKeyRef>();
});
EXPECT_FALSE(secure_enclave_client_->GetStoredKeyLabel(
SecureEnclaveClient::KeyType::kPermanent, output));

@ -29,7 +29,7 @@ class SecureEnclaveHelper {
// `attributes`. Returns the key or a nullptr on failure. If an `error`
// pointer is given, its value will be set to the OSStatus returned by the
// Keychain API call.
virtual base::ScopedCFTypeRef<SecKeyRef> CreateSecureKey(
virtual base::apple::ScopedCFTypeRef<SecKeyRef> CreateSecureKey(
CFDictionaryRef attributes,
OSStatus* error) = 0;
@ -38,8 +38,8 @@ class SecureEnclaveHelper {
// if the key is not found. If an `error` pointer
// is given, its value will be set to the OSStatus returned by the Keychain
// API call.
virtual base::ScopedCFTypeRef<SecKeyRef> CopyKey(CFDictionaryRef query,
OSStatus* error) = 0;
virtual base::apple::ScopedCFTypeRef<SecKeyRef> CopyKey(CFDictionaryRef query,
OSStatus* error) = 0;
// Uses the SecItemUpdate API to update the the key retrieved with the
// `query` with its `attributes_to_update`. Returns the OSStatus value

@ -20,10 +20,11 @@ class SecureEnclaveHelperImpl : public SecureEnclaveHelper {
~SecureEnclaveHelperImpl() override;
// SecureEnclaveHelper:
base::ScopedCFTypeRef<SecKeyRef> CreateSecureKey(CFDictionaryRef attributes,
OSStatus* error) override;
base::ScopedCFTypeRef<SecKeyRef> CopyKey(CFDictionaryRef query,
OSStatus* error) override;
base::apple::ScopedCFTypeRef<SecKeyRef> CreateSecureKey(
CFDictionaryRef attributes,
OSStatus* error) override;
base::apple::ScopedCFTypeRef<SecKeyRef> CopyKey(CFDictionaryRef query,
OSStatus* error) override;
OSStatus Update(CFDictionaryRef query,
CFDictionaryRef attributes_to_update) override;
OSStatus Delete(CFDictionaryRef query) override;

@ -17,11 +17,11 @@ namespace enterprise_connectors {
SecureEnclaveHelperImpl::~SecureEnclaveHelperImpl() = default;
base::ScopedCFTypeRef<SecKeyRef> SecureEnclaveHelperImpl::CreateSecureKey(
CFDictionaryRef attributes,
OSStatus* error) {
base::ScopedCFTypeRef<CFErrorRef> error_ref;
base::ScopedCFTypeRef<SecKeyRef> key(
base::apple::ScopedCFTypeRef<SecKeyRef>
SecureEnclaveHelperImpl::CreateSecureKey(CFDictionaryRef attributes,
OSStatus* error) {
base::apple::ScopedCFTypeRef<CFErrorRef> error_ref;
base::apple::ScopedCFTypeRef<SecKeyRef> key(
SecKeyCreateRandomKey(attributes, error_ref.InitializeInto()));
if (error && error_ref) {
@ -31,10 +31,10 @@ base::ScopedCFTypeRef<SecKeyRef> SecureEnclaveHelperImpl::CreateSecureKey(
return key;
}
base::ScopedCFTypeRef<SecKeyRef> SecureEnclaveHelperImpl::CopyKey(
base::apple::ScopedCFTypeRef<SecKeyRef> SecureEnclaveHelperImpl::CopyKey(
CFDictionaryRef query,
OSStatus* error) {
base::ScopedCFTypeRef<SecKeyRef> key;
base::apple::ScopedCFTypeRef<SecKeyRef> key;
OSStatus status = SecItemCopyMatching(
query, const_cast<CFTypeRef*>(
reinterpret_cast<const CFTypeRef*>(key.InitializeInto())));

@ -23,7 +23,7 @@ namespace {
// An implementation of crypto::UnexportableSigningKey.
class SecureEnclaveSigningKey : public crypto::UnexportableSigningKey {
public:
SecureEnclaveSigningKey(base::ScopedCFTypeRef<SecKeyRef> key,
SecureEnclaveSigningKey(base::apple::ScopedCFTypeRef<SecKeyRef> key,
std::unique_ptr<SecureEnclaveClient> client,
SecureEnclaveClient::KeyType type);
~SecureEnclaveSigningKey() override;
@ -36,13 +36,13 @@ class SecureEnclaveSigningKey : public crypto::UnexportableSigningKey {
base::span<const uint8_t> data) override;
private:
base::ScopedCFTypeRef<SecKeyRef> key_;
base::apple::ScopedCFTypeRef<SecKeyRef> key_;
std::unique_ptr<SecureEnclaveClient> client_;
SecureEnclaveClient::KeyType key_type_;
};
SecureEnclaveSigningKey::SecureEnclaveSigningKey(
base::ScopedCFTypeRef<SecKeyRef> key,
base::apple::ScopedCFTypeRef<SecKeyRef> key,
std::unique_ptr<SecureEnclaveClient> client,
SecureEnclaveClient::KeyType type)
: key_(std::move(key)), client_(std::move(client)), key_type_(type) {

@ -43,7 +43,7 @@ class SecureEnclaveSigningKeyTest : public testing::Test {
protected:
// Creates a test key.
void CreateTestKey() {
base::ScopedCFTypeRef<CFMutableDictionaryRef> test_attributes(
base::apple::ScopedCFTypeRef<CFMutableDictionaryRef> test_attributes(
CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks));
@ -52,7 +52,7 @@ class SecureEnclaveSigningKeyTest : public testing::Test {
kSecAttrKeyTypeECSECPrimeRandom);
CFDictionarySetValue(test_attributes, kSecAttrKeySizeInBits,
base::apple::NSToCFPtrCast(@256));
base::ScopedCFTypeRef<CFMutableDictionaryRef> private_key_params(
base::apple::ScopedCFTypeRef<CFMutableDictionaryRef> private_key_params(
CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks));
@ -60,7 +60,7 @@ class SecureEnclaveSigningKeyTest : public testing::Test {
kCFBooleanFalse);
CFDictionarySetValue(test_attributes, kSecPrivateKeyAttrs,
private_key_params);
test_key_ = base::ScopedCFTypeRef<SecKeyRef>(
test_key_ = base::apple::ScopedCFTypeRef<SecKeyRef>(
SecKeyCreateRandomKey(test_attributes, nullptr));
}
@ -78,7 +78,7 @@ class SecureEnclaveSigningKeyTest : public testing::Test {
raw_ptr<MockSecureEnclaveClient, DanglingUntriaged>
mock_secure_enclave_client_ = nullptr;
std::unique_ptr<crypto::UnexportableSigningKey> key_;
base::ScopedCFTypeRef<SecKeyRef> test_key_;
base::apple::ScopedCFTypeRef<SecKeyRef> test_key_;
};
// Tests that the GenerateSigningKeySlowly method invokes the SE client's

@ -53,8 +53,8 @@ class MacKeyPersistenceDelegateTest : public testing::Test {
}
// Creates a test key.
base::ScopedCFTypeRef<SecKeyRef> CreateTestKey() {
base::ScopedCFTypeRef<CFMutableDictionaryRef> test_attributes(
base::apple::ScopedCFTypeRef<SecKeyRef> CreateTestKey() {
base::apple::ScopedCFTypeRef<CFMutableDictionaryRef> test_attributes(
CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks));
@ -63,7 +63,7 @@ class MacKeyPersistenceDelegateTest : public testing::Test {
kSecAttrKeyTypeECSECPrimeRandom);
CFDictionarySetValue(test_attributes, kSecAttrKeySizeInBits,
base::apple::NSToCFPtrCast(@256));
base::ScopedCFTypeRef<CFMutableDictionaryRef> private_key_params(
base::apple::ScopedCFTypeRef<CFMutableDictionaryRef> private_key_params(
CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks));
@ -71,7 +71,7 @@ class MacKeyPersistenceDelegateTest : public testing::Test {
kCFBooleanFalse);
CFDictionarySetValue(test_attributes, kSecPrivateKeyAttrs,
private_key_params);
return base::ScopedCFTypeRef<SecKeyRef>(
return base::apple::ScopedCFTypeRef<SecKeyRef>(
SecKeyCreateRandomKey(test_attributes, nullptr));
}
@ -227,7 +227,7 @@ TEST_F(MacKeyPersistenceDelegateTest, CreateKeyPair__EmptySigningKey) {
SetMockClient();
EXPECT_CALL(*mock_secure_enclave_client_, CreatePermanentKey())
.WillOnce([]() { return base::ScopedCFTypeRef<SecKeyRef>(); });
.WillOnce([]() { return base::apple::ScopedCFTypeRef<SecKeyRef>(); });
EXPECT_FALSE(persistence_delegate_->CreateKeyPair());
}

@ -170,7 +170,7 @@ int32_t ReadEncryptedSecret(std::string* password, bool force_recreate) {
crypto::AppleKeychain keychain;
UInt32 password_length = 0;
void* password_data = nullptr;
base::ScopedCFTypeRef<SecKeychainItemRef> item_ref;
base::apple::ScopedCFTypeRef<SecKeychainItemRef> item_ref;
status = keychain.FindGenericPassword(
strlen(kServiceName), kServiceName, strlen(kAccountName), kAccountName,
&password_length, &password_data, item_ref.InitializeInto());

@ -30,7 +30,7 @@ OSStatus CreateTargetAccess(CFStringRef service_name,
return status;
}
base::ScopedCFTypeRef<CFArrayRef> acl_list;
base::apple::ScopedCFTypeRef<CFArrayRef> acl_list;
status = SecAccessCopyACLList(*access_ref, acl_list.InitializeInto());
if (status != noErr) {
return status;
@ -39,8 +39,8 @@ OSStatus CreateTargetAccess(CFStringRef service_name,
for (CFIndex i = 0; i < CFArrayGetCount(acl_list); ++i) {
SecACLRef acl = (SecACLRef)CFArrayGetValueAtIndex(acl_list, i);
base::ScopedCFTypeRef<CFArrayRef> app_list;
base::ScopedCFTypeRef<CFStringRef> description;
base::apple::ScopedCFTypeRef<CFArrayRef> app_list;
base::apple::ScopedCFTypeRef<CFStringRef> description;
SecKeychainPromptSelector dummy_prompt_selector;
status = SecACLCopyContents(acl, app_list.InitializeInto(),
description.InitializeInto(),
@ -93,7 +93,7 @@ OSStatus WriteKeychainItem(const std::string& service_name,
const_cast<char*>(account_name.data())}};
SecKeychainAttributeList attribute_list = {std::size(attributes), attributes};
base::ScopedCFTypeRef<SecAccessRef> access_ref;
base::apple::ScopedCFTypeRef<SecAccessRef> access_ref;
OSStatus status = CreateTargetAccess(base::SysUTF8ToCFStringRef(service_name),
access_ref.InitializeInto());
if (status != noErr) {
@ -107,7 +107,7 @@ OSStatus WriteKeychainItem(const std::string& service_name,
OSStatus VerifyKeychainForItemUnlocked(SecKeychainItemRef item_ref,
bool* unlocked) {
base::ScopedCFTypeRef<SecKeychainRef> keychain;
base::apple::ScopedCFTypeRef<SecKeychainRef> keychain;
OSStatus status =
SecKeychainItemCopyKeychain(item_ref, keychain.InitializeInto());
if (status != noErr) {
@ -118,7 +118,7 @@ OSStatus VerifyKeychainForItemUnlocked(SecKeychainItemRef item_ref,
}
OSStatus VerifyDefaultKeychainUnlocked(bool* unlocked) {
base::ScopedCFTypeRef<SecKeychainRef> keychain;
base::apple::ScopedCFTypeRef<SecKeychainRef> keychain;
OSStatus status = SecKeychainCopyDefault(keychain.InitializeInto());
if (status != noErr) {
return status;

@ -27,7 +27,7 @@ RemovableStorageProvider::PopulateDeviceList() {
base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
base::BlockingType::MAY_BLOCK);
// Match only writable whole-disks.
base::ScopedCFTypeRef<CFMutableDictionaryRef> matching(
base::apple::ScopedCFTypeRef<CFMutableDictionaryRef> matching(
IOServiceMatching(kIOMediaClass));
CFDictionaryAddValue(matching, CFSTR(kIOMediaWholeKey), kCFBooleanTrue);
CFDictionaryAddValue(matching, CFSTR(kIOMediaWritableKey), kCFBooleanTrue);
@ -54,7 +54,7 @@ RemovableStorageProvider::PopulateDeviceList() {
if (!is_suitable)
continue;
base::ScopedCFTypeRef<CFMutableDictionaryRef> dict;
base::apple::ScopedCFTypeRef<CFMutableDictionaryRef> dict;
if (IORegistryEntryCreateCFProperties(disk_obj, dict.InitializeInto(),
kCFAllocatorDefault,
0) != KERN_SUCCESS) {
@ -62,12 +62,10 @@ RemovableStorageProvider::PopulateDeviceList() {
continue;
}
base::ScopedCFTypeRef<CFDictionaryRef> characteristics(
base::apple::ScopedCFTypeRef<CFDictionaryRef> characteristics(
static_cast<CFDictionaryRef>(IORegistryEntrySearchCFProperty(
disk_obj,
kIOServicePlane,
CFSTR(kIOPropertyDeviceCharacteristicsKey),
kCFAllocatorDefault,
disk_obj, kIOServicePlane,
CFSTR(kIOPropertyDeviceCharacteristicsKey), kCFAllocatorDefault,
kIORegistryIterateParents | kIORegistryIterateRecursively)));
if (!characteristics) {

@ -62,9 +62,9 @@ IconLoader::IconGroup IconLoader::GroupForFilepath(
// Remove the leading dot.
extension_string.erase(extension_string.begin());
base::ScopedCFTypeRef<CFStringRef> extension_cf =
base::apple::ScopedCFTypeRef<CFStringRef> extension_cf =
base::SysUTF8ToCFStringRef(extension_string);
base::ScopedCFTypeRef<CFStringRef> cftype(
base::apple::ScopedCFTypeRef<CFStringRef> cftype(
UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension,
extension_cf,
/*inConformingToUTI=*/nullptr));

@ -16,7 +16,7 @@
namespace bluetooth_utility {
BluetoothAvailability GetBluetoothAvailability() {
base::ScopedCFTypeRef<CFMutableDictionaryRef> matching_dict(
base::apple::ScopedCFTypeRef<CFMutableDictionaryRef> matching_dict(
IOServiceMatching("IOBluetoothHCIController"));
if (!matching_dict)
return BLUETOOTH_AVAILABILITY_ERROR;
@ -34,7 +34,7 @@ BluetoothAvailability GetBluetoothAvailability() {
while (device.reset(IOIteratorNext(scoped_iter.get())), device) {
bluetooth_available = true;
base::ScopedCFTypeRef<CFMutableDictionaryRef> dict;
base::apple::ScopedCFTypeRef<CFMutableDictionaryRef> dict;
kr = IORegistryEntryCreateCFProperties(device, dict.InitializeInto(),
kCFAllocatorDefault, kNilOptions);
if (kr != KERN_SUCCESS)

@ -50,7 +50,7 @@ NSString* const kDockPersistentAppsKey = @"persistent-apps";
// A wrapper around _CFURLCopyPropertyListRepresentation that operates on
// Foundation data types and returns an autoreleased NSDictionary.
NSDictionary* DockFileDataDictionaryForURL(NSURL* url) {
base::ScopedCFTypeRef<CFPropertyListRef> property_list(
base::apple::ScopedCFTypeRef<CFPropertyListRef> property_list(
_CFURLCopyPropertyListRepresentation(base::apple::NSToCFPtrCast(url)));
CFDictionaryRef dictionary =
base::apple::CFCast<CFDictionaryRef>(property_list);
@ -64,7 +64,7 @@ NSDictionary* DockFileDataDictionaryForURL(NSURL* url) {
// A wrapper around _CFURLCreateFromPropertyListRepresentation that operates
// on Foundation data types and returns an autoreleased NSURL.
NSURL* URLFromDockFileDataDictionary(NSDictionary* dictionary) {
base::ScopedCFTypeRef<CFURLRef> url(
base::apple::ScopedCFTypeRef<CFURLRef> url(
_CFURLCreateFromPropertyListRepresentation(
kCFAllocatorDefault, base::apple::NSToCFPtrCast(dictionary)));
if (!url)

@ -125,7 +125,7 @@ bool MediaResidesOnDiskImage(base::mac::ScopedIOObject<io_service_t> media,
GetDiskImageAncestorForMedia("AppleDiskImageDevice", media);
if (di_device) {
if (image_path) {
base::ScopedCFTypeRef<CFTypeRef> disk_image_url_cftyperef(
base::apple::ScopedCFTypeRef<CFTypeRef> disk_image_url_cftyperef(
IORegistryEntryCreateCFProperty(di_device, CFSTR("DiskImageURL"),
/*allocator=*/nullptr,
/*options=*/0));
@ -138,21 +138,23 @@ bool MediaResidesOnDiskImage(base::mac::ScopedIOObject<io_service_t> media,
CFStringRef disk_image_url_string =
base::apple::CFCast<CFStringRef>(disk_image_url_cftyperef.get());
if (!disk_image_url_string) {
base::ScopedCFTypeRef<CFStringRef> observed_type_cf(
base::apple::ScopedCFTypeRef<CFStringRef> observed_type_cf(
CFCopyTypeIDDescription(CFGetTypeID(disk_image_url_cftyperef)));
LOG(ERROR) << "DiskImageURL: expected CFString, observed "
<< base::SysCFStringRefToUTF8(observed_type_cf);
return true;
}
base::ScopedCFTypeRef<CFURLRef> disk_image_url(CFURLCreateWithString(
/*allocator=*/nullptr, disk_image_url_string, /*baseURL=*/nullptr));
base::apple::ScopedCFTypeRef<CFURLRef> disk_image_url(
CFURLCreateWithString(
/*allocator=*/nullptr, disk_image_url_string,
/*baseURL=*/nullptr));
if (!disk_image_url) {
LOG(ERROR) << "CFURLCreateWithString failed";
return true;
}
base::ScopedCFTypeRef<CFStringRef> disk_image_path(
base::apple::ScopedCFTypeRef<CFStringRef> disk_image_path(
CFURLCopyFileSystemPath(disk_image_url, kCFURLPOSIXPathStyle));
if (!disk_image_path) {
LOG(ERROR) << "CFURLCopyFileSystemPath failed";
@ -173,7 +175,7 @@ bool MediaResidesOnDiskImage(base::mac::ScopedIOObject<io_service_t> media,
GetDiskImageAncestorForMedia("IOHDIXHDDrive", media);
if (hdix_drive) {
if (image_path) {
base::ScopedCFTypeRef<CFTypeRef> image_path_cftyperef(
base::apple::ScopedCFTypeRef<CFTypeRef> image_path_cftyperef(
IORegistryEntryCreateCFProperty(hdix_drive, CFSTR("image-path"),
/*allocator=*/nullptr,
/*options=*/0));
@ -185,7 +187,7 @@ bool MediaResidesOnDiskImage(base::mac::ScopedIOObject<io_service_t> media,
CFDataRef image_path_data =
base::apple::CFCast<CFDataRef>(image_path_cftyperef.get());
if (!image_path_data) {
base::ScopedCFTypeRef<CFStringRef> observed_type_cf(
base::apple::ScopedCFTypeRef<CFStringRef> observed_type_cf(
CFCopyTypeIDDescription(CFGetTypeID(image_path_cftyperef)));
LOG(ERROR) << "image-path: expected CFData, observed "
<< base::SysCFStringRefToUTF8(observed_type_cf);
@ -244,8 +246,9 @@ DiskImageStatus IsPathOnReadOnlyDiskImage(
out_dmg_bsd_device_name->assign(dmg_bsd_device_name);
}
base::ScopedCFTypeRef<CFMutableDictionaryRef> match_dict(IOBSDNameMatching(
kIOMasterPortDefault, /*options=*/0, dmg_bsd_device_name));
base::apple::ScopedCFTypeRef<CFMutableDictionaryRef> match_dict(
IOBSDNameMatching(kIOMasterPortDefault, /*options=*/0,
dmg_bsd_device_name));
if (!match_dict) {
LOG(ERROR) << "IOBSDNameMatching " << dmg_bsd_device_name;
return DiskImageStatusFailure;
@ -554,7 +557,7 @@ class ScopedDASessionScheduleWithRunLoop {
// A small structure used to ferry data between SynchronousDAOperation and
// SynchronousDACallbackAdapter.
struct SynchronousDACallbackData {
base::ScopedCFTypeRef<DADissenterRef> dissenter;
base::apple::ScopedCFTypeRef<DADissenterRef> dissenter;
bool callback_called = false;
bool run_loop_running = false;
bool can_log = true;
@ -645,14 +648,14 @@ bool SynchronousDADiskEject(DADiskRef disk, DADiskEjectOptions options) {
} // namespace
void EjectAndTrashDiskImage(const std::string& dmg_bsd_device_name) {
base::ScopedCFTypeRef<DASessionRef> session(
base::apple::ScopedCFTypeRef<DASessionRef> session(
DASessionCreate(/*allocator=*/nullptr));
if (!session.get()) {
LOG(ERROR) << "DASessionCreate";
return;
}
base::ScopedCFTypeRef<DADiskRef> disk(DADiskCreateFromBSDName(
base::apple::ScopedCFTypeRef<DADiskRef> disk(DADiskCreateFromBSDName(
/*allocator=*/nullptr, session, dmg_bsd_device_name.c_str()));
if (!disk.get()) {
LOG(ERROR) << "DADiskCreateFromBSDName";

@ -16,9 +16,9 @@ gfx::ImageSkia GetWindowIcon(content::DesktopMediaID id) {
CGWindowID ids[1];
ids[0] = id.id;
base::ScopedCFTypeRef<CFArrayRef> window_id_array(CFArrayCreate(
base::apple::ScopedCFTypeRef<CFArrayRef> window_id_array(CFArrayCreate(
nullptr, reinterpret_cast<const void**>(&ids), std::size(ids), nullptr));
base::ScopedCFTypeRef<CFArrayRef> window_array(
base::apple::ScopedCFTypeRef<CFArrayRef> window_array(
CGWindowListCreateDescriptionFromArray(window_id_array));
if (!window_array || 0 == CFArrayGetCount(window_array)) {
return gfx::ImageSkia();
@ -59,7 +59,8 @@ gfx::ImageSkia GetWindowIcon(content::DesktopMediaID id) {
}
CGDataProviderRef provider = CGImageGetDataProvider(cg_icon_image);
base::ScopedCFTypeRef<CFDataRef> cf_data(CGDataProviderCopyData(provider));
base::apple::ScopedCFTypeRef<CFDataRef> cf_data(
CGDataProviderCopyData(provider));
int width = CGImageGetWidth(cg_icon_image);
int height = CGImageGetHeight(cg_icon_image);

@ -70,7 +70,7 @@ bool AuthenticateUser(std::u16string prompt_string) {
AuthorizationItem right_items[] = {{rightName.UTF8String, 0, nullptr, 0}};
AuthorizationRights rights = {std::size(right_items), right_items};
base::ScopedCFTypeRef<CFStringRef> prompt =
base::apple::ScopedCFTypeRef<CFStringRef> prompt =
base::SysUTF16ToCFStringRef(prompt_string);
// Pass kAuthorizationFlagDestroyRights to prevent the OS from saving the

@ -106,7 +106,7 @@ bool DeleteDMTokenFromAppDataDir(const std::string& client_id) {
bool GetEnrollmentTokenFromPolicy(std::string* enrollment_token) {
// Since the configuration management infrastructure is not initialized when
// this code runs, read the policy preference directly.
base::ScopedCFTypeRef<CFPropertyListRef> value(
base::apple::ScopedCFTypeRef<CFPropertyListRef> value(
CFPreferencesCopyAppValue(kEnrollmentTokenPolicyName, kBundleId));
// Read the enrollment token from the new location. If that fails, try the old
@ -138,8 +138,9 @@ bool GetEnrollmentTokenFromFile(std::string* enrollment_token) {
}
absl::optional<bool> IsEnrollmentMandatoryByPolicy() {
base::ScopedCFTypeRef<CFPropertyListRef> value(CFPreferencesCopyAppValue(
kEnrollmentMandatoryOptionPolicyName, kBundleId));
base::apple::ScopedCFTypeRef<CFPropertyListRef> value(
CFPreferencesCopyAppValue(kEnrollmentMandatoryOptionPolicyName,
kBundleId));
if (!value || !CFPreferencesAppValueIsForced(
kEnrollmentMandatoryOptionPolicyName, kBundleId)) {

@ -323,7 +323,7 @@ ChromeBrowserPolicyConnector::CreatePlatformProvider() {
// policies.
CFStringRef bundle_id = CFSTR("com.google.Chrome");
#else
base::ScopedCFTypeRef<CFStringRef> bundle_id(
base::apple::ScopedCFTypeRef<CFStringRef> bundle_id(
base::SysUTF8ToCFStringRef(base::apple::BaseBundleID()));
#endif
auto loader = std::make_unique<PolicyLoaderMac>(

@ -76,9 +76,9 @@ base::FilePath::StringType ExpandPathVariables(
position = result.find(kMachineNamePolicyVarName);
if (position != std::string::npos) {
SCDynamicStoreContext context = {0, nullptr, nullptr, nullptr};
base::ScopedCFTypeRef<SCDynamicStoreRef> store(SCDynamicStoreCreate(
base::apple::ScopedCFTypeRef<SCDynamicStoreRef> store(SCDynamicStoreCreate(
kCFAllocatorDefault, CFSTR("policy_subsystem"), nullptr, &context));
base::ScopedCFTypeRef<CFStringRef> machine_name(
base::apple::ScopedCFTypeRef<CFStringRef> machine_name(
SCDynamicStoreCopyLocalHostName(store));
if (machine_name) {
result.replace(position, strlen(kMachineNamePolicyVarName),
@ -103,13 +103,13 @@ void CheckUserDataDirPolicy(base::FilePath* user_data_dir) {
// policies.
CFStringRef bundle_id = CFSTR("com.google.Chrome");
#else
base::ScopedCFTypeRef<CFStringRef> bundle_id(
base::apple::ScopedCFTypeRef<CFStringRef> bundle_id(
base::SysUTF8ToCFStringRef(base::apple::BaseBundleID()));
#endif
base::ScopedCFTypeRef<CFStringRef> key(
base::apple::ScopedCFTypeRef<CFStringRef> key(
base::SysUTF8ToCFStringRef(policy::key::kUserDataDir));
base::ScopedCFTypeRef<CFPropertyListRef> value(
base::apple::ScopedCFTypeRef<CFPropertyListRef> value(
CFPreferencesCopyAppValue(key, bundle_id));
if (!value || !CFPreferencesAppValueIsForced(key, bundle_id))

@ -146,8 +146,9 @@ class ChromeRenderWidgetHostViewMacHistorySwiperTest
// Creates a mock scroll wheel event that is backed by a real CGEvent.
id MockScrollWheelEvent(NSPoint delta, NSEventType type) {
base::ScopedCFTypeRef<CGEventRef> cg_event(CGEventCreateScrollWheelEvent(
nullptr, kCGScrollEventUnitLine, 2, 0, 0));
base::apple::ScopedCFTypeRef<CGEventRef> cg_event(
CGEventCreateScrollWheelEvent(nullptr, kCGScrollEventUnitLine, 2, 0,
0));
CGEventSetIntegerValueField(cg_event, kCGScrollWheelEventIsContinuous, 1);
CGEventSetIntegerValueField(
cg_event, kCGScrollWheelEventPointDeltaAxis2, delta.x);

@ -106,7 +106,7 @@ TEST_F(BinaryIntegrityAnalyzerMacTest, GetCriticalPathsAndRequirements) {
EXPECT_EQ(paths_and_requirements[i].requirement,
paths_and_requirements_expected[i].requirement);
base::ScopedCFTypeRef<SecRequirementRef> requirement;
base::apple::ScopedCFTypeRef<SecRequirementRef> requirement;
EXPECT_EQ(
errSecSuccess,
SecRequirementCreateWithString(

@ -59,10 +59,10 @@ class MacSignatureEvaluator {
bool has_requirement_;
// The static code object constructed from the code object on disk.
base::ScopedCFTypeRef<SecStaticCodeRef> code_;
base::apple::ScopedCFTypeRef<SecStaticCodeRef> code_;
// The requirement object constructed from the requirement string.
base::ScopedCFTypeRef<SecRequirementRef> requirement_;
base::apple::ScopedCFTypeRef<SecRequirementRef> requirement_;
};
} // namespace safe_browsing

@ -176,7 +176,7 @@ bool MacSignatureEvaluator::GetRelativePathComponent(
}
bool MacSignatureEvaluator::Initialize() {
base::ScopedCFTypeRef<CFURLRef> code_url =
base::apple::ScopedCFTypeRef<CFURLRef> code_url =
base::apple::FilePathToCFURL(path_);
if (!code_url)
return false;
@ -199,7 +199,7 @@ bool MacSignatureEvaluator::Initialize() {
bool MacSignatureEvaluator::PerformEvaluation(
ClientIncidentReport_IncidentData_BinaryIntegrityIncident* incident) {
DCHECK(incident->contained_file_size() == 0);
base::ScopedCFTypeRef<CFErrorRef> errors;
base::apple::ScopedCFTypeRef<CFErrorRef> errors;
OSStatus err = SecStaticCodeCheckValidityWithErrors(
code_, kSecCSCheckAllArchitectures, requirement_,
errors.InitializeInto());
@ -210,7 +210,7 @@ bool MacSignatureEvaluator::PerformEvaluation(
incident->set_sec_error(err);
// We heuristically detect if we are in a bundle or not by checking if
// the main executable is different from the path_.
base::ScopedCFTypeRef<CFDictionaryRef> info_dict;
base::apple::ScopedCFTypeRef<CFDictionaryRef> info_dict;
base::FilePath exec_path;
if (SecCodeCopySigningInformation(code_, kSecCSDefaultFlags,
info_dict.InitializeInto()) ==
@ -232,7 +232,8 @@ bool MacSignatureEvaluator::PerformEvaluation(
}
if (errors) {
base::ScopedCFTypeRef<CFDictionaryRef> info(CFErrorCopyUserInfo(errors));
base::apple::ScopedCFTypeRef<CFDictionaryRef> info(
CFErrorCopyUserInfo(errors));
static const CFStringRef keys[] = {
kSecCFErrorResourceAltered, kSecCFErrorResourceMissing,
};

@ -74,7 +74,7 @@ const CGFloat kShieldHeightCompletionAdjust = 10;
[super setFrameSize:newSize];
if (!_shapeLayer.path || !NSEqualSizes(oldSize, newSize)) {
base::ScopedCFTypeRef<CGMutablePathRef> oval(CGPathCreateMutable());
base::apple::ScopedCFTypeRef<CGMutablePathRef> oval(CGPathCreateMutable());
CGRect ovalRect = CGRectMake(0, 0, newSize.width, newSize.height);
CGPathAddEllipseInRect(oval, nullptr, ovalRect);
_shapeLayer.path = oval;
@ -84,7 +84,7 @@ const CGFloat kShieldHeightCompletionAdjust = 10;
- (void)setShieldAlpha:(CGFloat)shieldAlpha {
if (shieldAlpha != _shieldAlpha) {
_shieldAlpha = shieldAlpha;
base::ScopedCFTypeRef<CGColorRef> fillColor(
base::apple::ScopedCFTypeRef<CGColorRef> fillColor(
CGColorCreateGenericGray(0, shieldAlpha));
_shapeLayer.fillColor = fillColor;
}

@ -275,12 +275,13 @@ void SetupSystemUpdater() {
return;
}
base::ScopedCFTypeRef<CFErrorRef> error;
base::apple::ScopedCFTypeRef<CFErrorRef> error;
Boolean result = SMJobBless(kSMDomainSystemLaunchd,
base::SysUTF8ToCFStringRef(kPrivilegedHelperName),
authorization, error.InitializeInto());
if (!result) {
base::ScopedCFTypeRef<CFStringRef> desc(CFErrorCopyDescription(error));
base::apple::ScopedCFTypeRef<CFStringRef> desc(
CFErrorCopyDescription(error));
VLOG(0) << "Could not bless the privileged helper. Resulting error: "
<< base::SysCFStringRefToUTF8(desc);
}

@ -111,16 +111,17 @@ TEST(IcnsEncoderTest, RoundTrip) {
EXPECT_TRUE(encoder.WriteToFile(icon_path));
// Now use Image I/O methods to load the .icns file back in.
base::ScopedCFTypeRef<CFDictionaryRef> empty_dict(
base::apple::ScopedCFTypeRef<CFDictionaryRef> empty_dict(
CFDictionaryCreate(nullptr, nullptr, nullptr, 0, nullptr, nullptr));
base::ScopedCFTypeRef<CFURLRef> url = base::apple::FilePathToCFURL(icon_path);
base::ScopedCFTypeRef<CGImageSourceRef> source(
base::apple::ScopedCFTypeRef<CFURLRef> url =
base::apple::FilePathToCFURL(icon_path);
base::apple::ScopedCFTypeRef<CGImageSourceRef> source(
CGImageSourceCreateWithURL(url, nullptr));
// And make sure we got back the same images that were written to the file.
EXPECT_EQ(3u, CGImageSourceGetCount(source));
for (size_t i = 0; i < CGImageSourceGetCount(source); ++i) {
base::ScopedCFTypeRef<CGImageRef> cg_image(
base::apple::ScopedCFTypeRef<CGImageRef> cg_image(
CGImageSourceCreateImageAtIndex(source, i, empty_dict));
SkBitmap bitmap = skia::CGImageToSkBitmap(cg_image);
EXPECT_EQ(bitmap.width(), bitmap.height());

@ -785,16 +785,17 @@ SkColor OsIntegrationTestOverrideImpl::GetIconTopLeftColorFromShortcutFile(
#if BUILDFLAG(IS_MAC)
base::FilePath icon_path =
shortcut_path.AppendASCII("Contents/Resources/app.icns");
base::ScopedCFTypeRef<CFDictionaryRef> empty_dict(
base::apple::ScopedCFTypeRef<CFDictionaryRef> empty_dict(
CFDictionaryCreate(nullptr, nullptr, nullptr, 0, nullptr, nullptr));
base::ScopedCFTypeRef<CFURLRef> url = base::apple::FilePathToCFURL(icon_path);
base::ScopedCFTypeRef<CGImageSourceRef> source(
base::apple::ScopedCFTypeRef<CFURLRef> url =
base::apple::FilePathToCFURL(icon_path);
base::apple::ScopedCFTypeRef<CGImageSourceRef> source(
CGImageSourceCreateWithURL(url, nullptr));
if (!source) {
return 0;
}
// Get the first icon in the .icns file (index 0)
base::ScopedCFTypeRef<CGImageRef> cg_image(
base::apple::ScopedCFTypeRef<CGImageRef> cg_image(
CGImageSourceCreateImageAtIndex(source, 0, empty_dict));
if (!cg_image) {
return 0;

@ -30,7 +30,7 @@ bool IsUsbDevice(io_object_t disk_obj) {
current_obj = parent_obj;
parent_obj_ref.reset(parent_obj);
base::ScopedCFTypeRef<CFStringRef> class_name(
base::apple::ScopedCFTypeRef<CFStringRef> class_name(
IOObjectCopyClass(current_obj));
if (!class_name) {
LOG(ERROR) << "Could not get object class of IO Registry Entry.";
@ -52,7 +52,7 @@ bool IsSuitableRemovableStorageDevice(io_object_t disk_obj,
std::string* out_bsd_name,
uint64_t* out_size_in_bytes,
bool* out_removable) {
base::ScopedCFTypeRef<CFMutableDictionaryRef> dict;
base::apple::ScopedCFTypeRef<CFMutableDictionaryRef> dict;
kern_return_t result = IORegistryEntryCreateCFProperties(
disk_obj, dict.InitializeInto(), kCFAllocatorDefault, 0);
if (result != KERN_SUCCESS) {

@ -79,9 +79,10 @@ bool ClearKeyEventModifiers() {
for (const auto& known_modifier : kKnownModifiers) {
if (known_modifier.flag_mask & event_flags) {
had_modifier = true;
CGEventPost(kCGSessionEventTap,
base::ScopedCFTypeRef<CGEventRef>(CGEventCreateKeyboardEvent(
nullptr, known_modifier.key_code, false)));
CGEventPost(
kCGSessionEventTap,
base::apple::ScopedCFTypeRef<CGEventRef>(CGEventCreateKeyboardEvent(
nullptr, known_modifier.key_code, false)));
LOG(ERROR) << "Modifier " << known_modifier.name
<< " is hanging down, and may cause problems for any "
"subsequent test.";

@ -19,7 +19,7 @@ UniChar GetCharacter(UInt16 mac_key_code, UInt32 modifier_key_state) {
UInt32 dead_key_state = 0;
base::AutoLock lock(tis_lock_);
base::ScopedCFTypeRef<TISInputSourceRef> input_source(
base::apple::ScopedCFTypeRef<TISInputSourceRef> input_source(
TISCopyCurrentKeyboardLayoutInputSource());
return ui::TranslatedUnicodeCharFromKeyCode(
input_source.get(), mac_key_code, kUCKeyActionDown, modifier_key_state,

@ -30,7 +30,7 @@ const CFStringRef kBrowserBundleId =
CFSTR(MAC_BROWSER_BUNDLE_IDENTIFIER_STRING);
bool LoadEnrollmentTokenFromPolicy(std::string* enrollment_token) {
base::ScopedCFTypeRef<CFPropertyListRef> token_value(
base::apple::ScopedCFTypeRef<CFPropertyListRef> token_value(
CFPreferencesCopyAppValue(kEnrollmentTokenKey, kBrowserBundleId));
if (!token_value || CFGetTypeID(token_value) != CFStringGetTypeID() ||
!CFPreferencesAppValueIsForced(kEnrollmentTokenKey, kBrowserBundleId)) {

@ -189,9 +189,9 @@ int InstallUpdater(const base::FilePath& browser_path) {
} // namespace
bool VerifyUpdaterSignature(const base::FilePath& updater_app_bundle) {
base::ScopedCFTypeRef<SecRequirementRef> requirement;
base::ScopedCFTypeRef<SecStaticCodeRef> code;
base::ScopedCFTypeRef<CFErrorRef> errors;
base::apple::ScopedCFTypeRef<SecRequirementRef> requirement;
base::apple::ScopedCFTypeRef<SecStaticCodeRef> code;
base::apple::ScopedCFTypeRef<CFErrorRef> errors;
if (SecStaticCodeCreateWithPath(
base::apple::FilePathToCFURL(updater_app_bundle), kSecCSDefaultFlags,
code.InitializeInto()) != errSecSuccess) {

@ -206,9 +206,10 @@ ManagedPreferencePolicyManager::GetAppsWithPolicy() const {
}
NSDictionary* ReadManagedPreferencePolicyDictionary() {
base::ScopedCFTypeRef<CFPropertyListRef> policies(CFPreferencesCopyAppValue(
base::apple::NSToCFPtrCast(kManagedPreferencesUpdatePolicies),
base::apple::NSToCFPtrCast(kKeystoneSharedPreferenceSuite)));
base::apple::ScopedCFTypeRef<CFPropertyListRef> policies(
CFPreferencesCopyAppValue(
base::apple::NSToCFPtrCast(kManagedPreferencesUpdatePolicies),
base::apple::NSToCFPtrCast(kKeystoneSharedPreferenceSuite)));
if (!policies)
return nil;

@ -58,8 +58,8 @@ class DiskUnmounterMac {
base::OnceClosure success_continuation_;
base::OnceClosure failure_continuation_;
base::ScopedCFTypeRef<DADiskRef> disk_;
base::ScopedCFTypeRef<DASessionRef> session_;
base::apple::ScopedCFTypeRef<DADiskRef> disk_;
base::apple::ScopedCFTypeRef<DASessionRef> session_;
// Thread is last to ensure it is stopped before the data members are
// destroyed.

@ -33,9 +33,9 @@ namespace image_writer {
static const char kAuthOpenPath[] = "/usr/libexec/authopen";
bool ImageWriter::IsValidDevice() {
base::ScopedCFTypeRef<CFStringRef> cf_bsd_name(
base::apple::ScopedCFTypeRef<CFStringRef> cf_bsd_name(
base::SysUTF8ToCFStringRef(device_path_.value()));
base::ScopedCFTypeRef<CFMutableDictionaryRef> matching(
base::apple::ScopedCFTypeRef<CFMutableDictionaryRef> matching(
IOServiceMatching(kIOMediaClass));
CFDictionaryAddValue(matching, CFSTR(kIOMediaWholeKey), kCFBooleanTrue);
CFDictionaryAddValue(matching, CFSTR(kIOMediaWritableKey), kCFBooleanTrue);

@ -457,7 +457,7 @@ bool UDIFParser::ParseBlkx() {
return false;
}
base::ScopedCFTypeRef<CFDataRef> plist_data(
base::apple::ScopedCFTypeRef<CFDataRef> plist_data(
CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, plist_bytes.data(),
plist_bytes.size(), kCFAllocatorNull));
if (!plist_data) {
@ -466,15 +466,15 @@ bool UDIFParser::ParseBlkx() {
}
CFErrorRef error = nullptr;
base::ScopedCFTypeRef<CFPropertyListRef> plist(
base::apple::ScopedCFTypeRef<CFPropertyListRef> plist(
CFPropertyListCreateWithData(kCFAllocatorDefault, plist_data,
kCFPropertyListImmutable, nullptr, &error));
CFDictionaryRef plist_dict =
base::apple::CFCast<CFDictionaryRef>(plist.get());
base::ScopedCFTypeRef<CFErrorRef> error_ref(error);
base::apple::ScopedCFTypeRef<CFErrorRef> error_ref(error);
if (error) {
base::ScopedCFTypeRef<CFStringRef> error_string(
base::apple::ScopedCFTypeRef<CFStringRef> error_string(
CFErrorCopyDescription(error));
DLOG(ERROR) << "Failed to parse XML plist: "
<< base::SysCFStringRefToUTF8(error_string);

@ -157,7 +157,7 @@ int GetCurrentCountryID() {
#elif BUILDFLAG(IS_APPLE)
int GetCurrentCountryID() {
base::ScopedCFTypeRef<CFLocaleRef> locale(CFLocaleCopyCurrent());
base::apple::ScopedCFTypeRef<CFLocaleRef> locale(CFLocaleCopyCurrent());
CFStringRef country =
(CFStringRef)CFLocaleGetValue(locale.get(), kCFLocaleCountryCode);
if (!country)

@ -92,16 +92,16 @@ MacPlatformDelegate::GetSigningCertificatesPublicKeys(
const base::FilePath& file_path) {
SigningCertificatesPublicKeys public_keys;
base::ScopedCFTypeRef<CFURLRef> file_url =
base::apple::ScopedCFTypeRef<CFURLRef> file_url =
base::apple::FilePathToCFURL(file_path);
base::ScopedCFTypeRef<SecStaticCodeRef> file_code;
base::apple::ScopedCFTypeRef<SecStaticCodeRef> file_code;
if (SecStaticCodeCreateWithPath(file_url, kSecCSDefaultFlags,
file_code.InitializeInto()) !=
errSecSuccess) {
return public_keys;
}
base::ScopedCFTypeRef<CFDictionaryRef> signing_information;
base::apple::ScopedCFTypeRef<CFDictionaryRef> signing_information;
if (SecCodeCopySigningInformation(file_code, kSecCSSigningInformation,
signing_information.InitializeInto()) !=
errSecSuccess) {
@ -123,7 +123,8 @@ MacPlatformDelegate::GetSigningCertificatesPublicKeys(
SecCertificateRef leaf_cert = reinterpret_cast<SecCertificateRef>(
const_cast<void*>(CFArrayGetValueAtIndex(cert_chain, 0)));
base::ScopedCFTypeRef<CFDataRef> der_data(SecCertificateCopyData(leaf_cert));
base::apple::ScopedCFTypeRef<CFDataRef> der_data(
SecCertificateCopyData(leaf_cert));
if (!der_data) {
return public_keys;
}

@ -225,7 +225,7 @@ id<MTLRenderPipelineState> CreateRenderPipelineState(id<MTLDevice> device) {
self.opaque = NO;
self.presentsWithTransaction = YES;
self.pixelFormat = MTLPixelFormatRGBA16Float;
base::ScopedCFTypeRef<CGColorSpaceRef> colorSpace(
base::apple::ScopedCFTypeRef<CGColorSpaceRef> colorSpace(
CGColorSpaceCreateWithName(kCGColorSpaceExtendedLinearSRGB));
self.colorspace = colorSpace;
}
@ -251,9 +251,9 @@ id<MTLRenderPipelineState> CreateRenderPipelineState(id<MTLDevice> device) {
CAEDRMetadata* edrMetadata = nil;
switch (colorSpace.GetTransferID()) {
case gfx::ColorSpace::TransferID::PQ: {
base::ScopedCFTypeRef<CFDataRef> display_info =
base::apple::ScopedCFTypeRef<CFDataRef> display_info =
gfx::GenerateMasteringDisplayColorVolume(hdrMetadata);
base::ScopedCFTypeRef<CFDataRef> content_info =
base::apple::ScopedCFTypeRef<CFDataRef> content_info =
gfx::GenerateContentLightLevelInfo(hdrMetadata);
edrMetadata = [CAEDRMetadata
HDR10MetadataWithDisplayInfo:base::apple::CFToNSPtrCast(

@ -35,18 +35,18 @@ bool DriveMetricsProvider::HasSeekPenalty(const base::FilePath& path,
std::string bsd_name("/dev/");
bsd_name.append(dev_name);
base::ScopedCFTypeRef<DASessionRef> session(
base::apple::ScopedCFTypeRef<DASessionRef> session(
DASessionCreate(kCFAllocatorDefault));
if (!session)
return false;
base::ScopedCFTypeRef<DADiskRef> disk(
base::apple::ScopedCFTypeRef<DADiskRef> disk(
DADiskCreateFromBSDName(kCFAllocatorDefault, session, bsd_name.c_str()));
if (!disk)
return false;
base::mac::ScopedIOObject<io_object_t> io_media(DADiskCopyIOMedia(disk));
base::ScopedCFTypeRef<CFDictionaryRef> characteristics(
base::apple::ScopedCFTypeRef<CFDictionaryRef> characteristics(
static_cast<CFDictionaryRef>(IORegistryEntrySearchCFProperty(
io_media, kIOServicePlane, CFSTR(kIOPropertyDeviceCharacteristicsKey),
kCFAllocatorDefault,

@ -21,7 +21,7 @@
#include "components/password_manager/core/common/passwords_directory_util_ios.h"
#include "sql/statement.h"
using base::ScopedCFTypeRef;
using base::apple::ScopedCFTypeRef;
namespace password_manager {

@ -26,8 +26,8 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
using base::ScopedCFTypeRef;
using base::UTF16ToUTF8;
using base::apple::ScopedCFTypeRef;
namespace password_manager {

@ -93,15 +93,15 @@ std::string GetMachineName() {
#elif BUILDFLAG(IS_MAC)
// Do not use NSHost currentHost, as it's very slow. http://crbug.com/138570
SCDynamicStoreContext context = {0, NULL, NULL, NULL};
base::ScopedCFTypeRef<SCDynamicStoreRef> store(SCDynamicStoreCreate(
base::apple::ScopedCFTypeRef<SCDynamicStoreRef> store(SCDynamicStoreCreate(
kCFAllocatorDefault, CFSTR("chrome_sync"), NULL, &context));
base::ScopedCFTypeRef<CFStringRef> machine_name(
base::apple::ScopedCFTypeRef<CFStringRef> machine_name(
SCDynamicStoreCopyLocalHostName(store.get()));
if (machine_name.get())
return base::SysCFStringRefToUTF8(machine_name.get());
// Fall back to get computer name.
base::ScopedCFTypeRef<CFStringRef> computer_name(
base::apple::ScopedCFTypeRef<CFStringRef> computer_name(
SCDynamicStoreCopyComputerName(store.get(), NULL));
if (computer_name.get())
return base::SysCFStringRefToUTF8(computer_name.get());

@ -61,7 +61,8 @@ TEST(PolicyMacUtilTest, ValueToPropertyRoundTrip) {
const base::Value root_val(std::move(root));
// base::Value -> property list -> base::Value.
base::ScopedCFTypeRef<CFPropertyListRef> property(ValueToProperty(root_val));
base::apple::ScopedCFTypeRef<CFPropertyListRef> property(
ValueToProperty(root_val));
ASSERT_TRUE(property);
std::unique_ptr<base::Value> value = PropertyToValue(property);
ASSERT_TRUE(value);

@ -132,7 +132,7 @@ void TestHarness::InstallStringListPolicy(
const std::string& policy_name,
const base::Value::List& policy_value) {
NSString* key = base::SysUTF8ToNSString(policy_name);
base::ScopedCFTypeRef<CFPropertyListRef> value(
base::apple::ScopedCFTypeRef<CFPropertyListRef> value(
ValueToProperty(base::Value(policy_value.Clone())));
if (encode_complex_data_as_json_) {
@ -160,7 +160,7 @@ void TestHarness::InstallDictionaryPolicy(
AddPolicies(@{key : base::SysUTF8ToNSString(json_string)});
} else {
base::ScopedCFTypeRef<CFPropertyListRef> value(
base::apple::ScopedCFTypeRef<CFPropertyListRef> value(
ValueToProperty(base::Value(policy_value.Clone())));
AddPolicies(@{key : (__bridge NSDictionary*)(value.get())});
}

@ -86,7 +86,7 @@ class POLICY_EXPORT PolicyLoaderMac : public AsyncPolicyLoader {
base::FilePathWatcher watcher_;
// Application ID to pass into Mac's Preference Utilities API.
base::ScopedCFTypeRef<CFStringRef> application_id_;
base::apple::ScopedCFTypeRef<CFStringRef> application_id_;
};
} // namespace policy

@ -111,9 +111,9 @@ PolicyBundle PolicyLoaderMac::Load() {
schema_map()->GetSchema(PolicyNamespace(POLICY_DOMAIN_CHROME, ""));
for (Schema::Iterator it = schema->GetPropertiesIterator(); !it.IsAtEnd();
it.Advance()) {
base::ScopedCFTypeRef<CFStringRef> name(
base::apple::ScopedCFTypeRef<CFStringRef> name(
base::SysUTF8ToCFStringRef(it.key()));
base::ScopedCFTypeRef<CFPropertyListRef> value(
base::apple::ScopedCFTypeRef<CFPropertyListRef> value(
preferences_->CopyAppValue(name, application_id_));
if (!value)
continue;
@ -204,15 +204,15 @@ void PolicyLoaderMac::LoadPolicyForComponent(
if (!schema.valid())
return;
base::ScopedCFTypeRef<CFStringRef> bundle_id =
base::apple::ScopedCFTypeRef<CFStringRef> bundle_id =
base::SysUTF8ToCFStringRef(bundle_id_string);
preferences_->AppSynchronize(bundle_id);
for (Schema::Iterator it = schema.GetPropertiesIterator(); !it.IsAtEnd();
it.Advance()) {
base::ScopedCFTypeRef<CFStringRef> pref_name =
base::apple::ScopedCFTypeRef<CFStringRef> pref_name =
base::SysUTF8ToCFStringRef(it.key());
base::ScopedCFTypeRef<CFPropertyListRef> value(
base::apple::ScopedCFTypeRef<CFPropertyListRef> value(
preferences_->CopyAppValue(pref_name, bundle_id));
if (!value)
continue;

@ -27,7 +27,7 @@
#include "components/policy/core/common/preferences_mock_mac.h"
#include "testing/gtest/include/gtest/gtest.h"
using base::ScopedCFTypeRef;
using base::apple::ScopedCFTypeRef;
namespace policy {

@ -91,9 +91,9 @@ CFPropertyListRef ValueToProperty(const base::Value& value) {
for (const auto key_value_pair : value_dict) {
// CFDictionaryAddValue() retains both |key| and |value|, so make sure
// the references are balanced.
base::ScopedCFTypeRef<CFStringRef> key(
base::apple::ScopedCFTypeRef<CFStringRef> key(
base::SysUTF8ToCFStringRef(key_value_pair.first));
base::ScopedCFTypeRef<CFPropertyListRef> cf_value(
base::apple::ScopedCFTypeRef<CFPropertyListRef> cf_value(
ValueToProperty(key_value_pair.second));
if (cf_value)
CFDictionaryAddValue(dict, key, cf_value);
@ -108,7 +108,7 @@ CFPropertyListRef ValueToProperty(const base::Value& value) {
for (const base::Value& entry : list) {
// CFArrayAppendValue() retains |cf_value|, so make sure the reference
// created by ValueToProperty() is released.
base::ScopedCFTypeRef<CFPropertyListRef> cf_value(
base::apple::ScopedCFTypeRef<CFPropertyListRef> cf_value(
ValueToProperty(entry));
if (cf_value)
CFArrayAppendValue(array, cf_value);

@ -30,9 +30,9 @@ class POLICY_EXPORT MockPreferences : public MacPreferences {
bool is_machine);
private:
base::ScopedCFTypeRef<CFMutableDictionaryRef> values_;
base::ScopedCFTypeRef<CFMutableSetRef> forced_;
base::ScopedCFTypeRef<CFMutableSetRef> machine_;
base::apple::ScopedCFTypeRef<CFMutableDictionaryRef> values_;
base::apple::ScopedCFTypeRef<CFMutableSetRef> forced_;
base::apple::ScopedCFTypeRef<CFMutableSetRef> machine_;
};
#endif // COMPONENTS_POLICY_CORE_COMMON_PREFERENCES_MOCK_MAC_H_

@ -182,7 +182,7 @@ absl::optional<std::string> GetBoardIdForThisMachine() {
// This is what libpmenergy is observed to do in order to retrieve the correct
// coefficients file for the local computer.
base::ScopedCFTypeRef<CFDataRef> board_id_data(
base::apple::ScopedCFTypeRef<CFDataRef> board_id_data(
base::apple::CFCast<CFDataRef>(IORegistryEntryCreateCFProperty(
platform_expert, CFSTR("board-id"), kCFAllocatorDefault, 0)));

@ -38,10 +38,10 @@ class M1SensorsReader {
protected:
explicit M1SensorsReader(
base::ScopedCFTypeRef<IOHIDEventSystemClientRef> system);
base::apple::ScopedCFTypeRef<IOHIDEventSystemClientRef> system);
private:
base::ScopedCFTypeRef<IOHIDEventSystemClientRef> system_;
base::apple::ScopedCFTypeRef<IOHIDEventSystemClientRef> system_;
};
} // namespace power_metrics

@ -34,7 +34,7 @@ namespace {
absl::optional<double> GetEventFloatValue(IOHIDServiceClientRef service,
int64_t event_type) {
base::ScopedCFTypeRef<CFTypeRef> event(
base::apple::ScopedCFTypeRef<CFTypeRef> event(
IOHIDServiceClientCopyEvent(service, event_type, 0, 0));
if (!event)
return absl::nullopt;
@ -52,7 +52,7 @@ M1SensorsReader::~M1SensorsReader() = default;
// static
std::unique_ptr<M1SensorsReader> M1SensorsReader::Create() {
base::ScopedCFTypeRef<IOHIDEventSystemClientRef> system(
base::apple::ScopedCFTypeRef<IOHIDEventSystemClientRef> system(
IOHIDEventSystemClientCreate(kCFAllocatorDefault));
if (system == nil)
@ -68,7 +68,7 @@ std::unique_ptr<M1SensorsReader> M1SensorsReader::Create() {
}
M1SensorsReader::TemperaturesCelsius M1SensorsReader::ReadTemperatures() {
base::ScopedCFTypeRef<CFArrayRef> services(
base::apple::ScopedCFTypeRef<CFArrayRef> services(
IOHIDEventSystemClientCopyServices(system_.get()));
// There are multiple temperature sensors on P-Cores and E-Cores. Count and
@ -82,8 +82,9 @@ M1SensorsReader::TemperaturesCelsius M1SensorsReader::ReadTemperatures() {
IOHIDServiceClientRef service =
(IOHIDServiceClientRef)CFArrayGetValueAtIndex(services, i);
base::ScopedCFTypeRef<CFStringRef> product(base::apple::CFCast<CFStringRef>(
IOHIDServiceClientCopyProperty(service, CFSTR(kIOHIDProductKey))));
base::apple::ScopedCFTypeRef<CFStringRef> product(
base::apple::CFCast<CFStringRef>(
IOHIDServiceClientCopyProperty(service, CFSTR(kIOHIDProductKey))));
if (product == nil) {
continue;
}
@ -117,7 +118,7 @@ M1SensorsReader::TemperaturesCelsius M1SensorsReader::ReadTemperatures() {
}
M1SensorsReader::M1SensorsReader(
base::ScopedCFTypeRef<IOHIDEventSystemClientRef> system)
base::apple::ScopedCFTypeRef<IOHIDEventSystemClientRef> system)
: system_(std::move(system)) {}
} // namespace power_metrics

@ -38,7 +38,7 @@ void ShowCertificateViewerForWindow(NSWindow* owning_window,
// the certificate viewer UI from displaying which certificate is revoked.
// This is acceptable, as certificate revocation will still be shown in
// the page info bubble if a certificate in the chain is actually revoked.
base::ScopedCFTypeRef<CFMutableArrayRef> policies(
base::apple::ScopedCFTypeRef<CFMutableArrayRef> policies(
CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks));
if (!policies.get()) {
NOTREACHED();
@ -46,7 +46,8 @@ void ShowCertificateViewerForWindow(NSWindow* owning_window,
}
// Add a basic X.509 policy, in order to match the behaviour of
// SFCertificatePanel when no policies are specified.
base::ScopedCFTypeRef<SecPolicyRef> basic_policy(SecPolicyCreateBasicX509());
base::apple::ScopedCFTypeRef<SecPolicyRef> basic_policy(
SecPolicyCreateBasicX509());
if (!basic_policy) {
NOTREACHED();
return;

@ -29,7 +29,8 @@ const int kFileTypePopupTag = 1234;
// TODO(macOS 11): Remove this.
CFStringRef CreateUTIFromExtension(const base::FilePath::StringType& ext) {
base::ScopedCFTypeRef<CFStringRef> ext_cf(base::SysUTF8ToCFStringRef(ext));
base::apple::ScopedCFTypeRef<CFStringRef> ext_cf(
base::SysUTF8ToCFStringRef(ext));
return UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension,
ext_cf.get(), nullptr);
}
@ -44,7 +45,7 @@ NSString* GetDescriptionFromExtension(const base::FilePath::StringType& ext) {
return description;
}
} else {
base::ScopedCFTypeRef<CFStringRef> uti(CreateUTIFromExtension(ext));
base::apple::ScopedCFTypeRef<CFStringRef> uti(CreateUTIFromExtension(ext));
NSString* description =
base::apple::CFToNSOwnershipCast(UTTypeCopyDescription(uti.get()));

@ -61,7 +61,7 @@ bool AddOriginMetadataToFile(const base::FilePath& file,
return false;
}
base::ScopedCFTypeRef<MDItemRef> md_item(
base::apple::ScopedCFTypeRef<MDItemRef> md_item(
MDItemCreate(kCFAllocatorDefault, base::apple::NSToCFPtrCast(file_path)));
if (!md_item) {
LOG(WARNING) << "MDItemCreate failed for path " << file.value();

@ -164,7 +164,7 @@ TEST_F(QuarantineMacTest, NoWhereFromsKeyIfNoURLs) {
NSString* file_path = base::apple::FilePathToNSString(test_file_);
ASSERT_NE(nullptr, file_path);
base::ScopedCFTypeRef<MDItemRef> md_item(
base::apple::ScopedCFTypeRef<MDItemRef> md_item(
MDItemCreate(kCFAllocatorDefault, base::apple::NSToCFPtrCast(file_path)));
if (!md_item) {
// The quarantine code ignores it if adding origin metadata fails. If for
@ -173,7 +173,7 @@ TEST_F(QuarantineMacTest, NoWhereFromsKeyIfNoURLs) {
return;
}
base::ScopedCFTypeRef<CFTypeRef> attr(
base::apple::ScopedCFTypeRef<CFTypeRef> attr(
MDItemCopyAttribute(md_item, kMDItemWhereFroms));
EXPECT_FALSE(attr);
}

@ -61,7 +61,7 @@ class StorageMonitorMac : public StorageMonitor,
bool FindDiskWithMountPoint(const base::FilePath& mount_point,
StorageInfo* info) const;
base::ScopedCFTypeRef<DASessionRef> session_;
base::apple::ScopedCFTypeRef<DASessionRef> session_;
// Maps disk bsd names to disk info objects. This map tracks all mountable
// devices on the system, though only notifications for removable devices are
// posted.

@ -87,7 +87,7 @@ StorageInfo BuildStorageInfo(
dict, kDADiskDescriptionVolumeUUIDKey);
std::string unique_id;
if (uuid) {
base::ScopedCFTypeRef<CFStringRef> uuid_string(
base::apple::ScopedCFTypeRef<CFStringRef> uuid_string(
CFUUIDCreateString(nullptr, uuid));
if (uuid_string.get())
unique_id = base::SysCFStringRefToUTF8(uuid_string);
@ -119,7 +119,7 @@ StorageInfo BuildStorageInfo(
struct EjectDiskOptions {
std::string bsd_name;
base::OnceCallback<void(StorageMonitor::EjectStatus)> callback;
base::ScopedCFTypeRef<DADiskRef> disk;
base::apple::ScopedCFTypeRef<DADiskRef> disk;
};
void PostEjectCallback(DADiskRef disk,
@ -291,7 +291,7 @@ void StorageMonitorMac::EjectDevice(
receiver()->ProcessDetach(device_id);
base::ScopedCFTypeRef<DADiskRef> disk(
base::apple::ScopedCFTypeRef<DADiskRef> disk(
DADiskCreateFromBSDName(nullptr, session_, bsd_name.c_str()));
if (!disk.get()) {
std::move(callback).Run(StorageMonitor::EJECT_FAILURE);
@ -339,7 +339,8 @@ void StorageMonitorMac::GetDiskInfoAndUpdate(
pending_disk_updates_++;
base::ScopedCFTypeRef<CFDictionaryRef> dict(DADiskCopyDescription(disk));
base::apple::ScopedCFTypeRef<CFDictionaryRef> dict(
DADiskCopyDescription(disk));
std::string* bsd_name = new std::string;
base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},

@ -21,17 +21,17 @@ namespace syncer {
std::string GetPersonalizableDeviceNameInternal() {
// Do not use NSHost currentHost, as it's very slow. http://crbug.com/138570
SCDynamicStoreContext context = {0};
base::ScopedCFTypeRef<SCDynamicStoreRef> store(
base::apple::ScopedCFTypeRef<SCDynamicStoreRef> store(
SCDynamicStoreCreate(kCFAllocatorDefault, CFSTR("chrome_sync"),
/*callout=*/nullptr, &context));
base::ScopedCFTypeRef<CFStringRef> machine_name(
base::apple::ScopedCFTypeRef<CFStringRef> machine_name(
SCDynamicStoreCopyLocalHostName(store));
if (machine_name) {
return base::SysCFStringRefToUTF8(machine_name);
}
// Fall back to get computer name.
base::ScopedCFTypeRef<CFStringRef> computer_name(
base::apple::ScopedCFTypeRef<CFStringRef> computer_name(
SCDynamicStoreCopyComputerName(store, /*nameEncoding=*/nullptr));
if (computer_name) {
return base::SysCFStringRefToUTF8(computer_name);

@ -52,7 +52,7 @@ class VIZ_SERVICE_EXPORT SoftwareOutputDeviceMac : public SoftwareOutputDevice {
struct Buffer {
Buffer();
~Buffer();
base::ScopedCFTypeRef<IOSurfaceRef> io_surface;
base::apple::ScopedCFTypeRef<IOSurfaceRef> io_surface;
// The damage of all BeginPaints since this buffer was the back buffer.
SkRegion accumulated_damage;
};

@ -443,7 +443,7 @@ std::string WiFiServiceMac::GetNetworkConnectionState(
local_wifi_address.sin_len = sizeof(local_wifi_address);
local_wifi_address.sin_family = AF_INET;
local_wifi_address.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM);
base::ScopedCFTypeRef<SCNetworkReachabilityRef> reachability(
base::apple::ScopedCFTypeRef<SCNetworkReachabilityRef> reachability(
SCNetworkReachabilityCreateWithAddress(
kCFAllocatorDefault,
reinterpret_cast<const struct sockaddr*>(&local_wifi_address)));

@ -137,7 +137,7 @@
[UTType typeWithMIMEType:base::SysUTF8ToNSString(mimeType)];
_fileUTType = type.identifier;
} else {
base::ScopedCFTypeRef<CFStringRef> mimeTypeCF(
base::apple::ScopedCFTypeRef<CFStringRef> mimeTypeCF(
base::SysUTF8ToCFStringRef(mimeType));
_fileUTType = base::apple::CFToNSOwnershipCast(
UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType,

@ -40,10 +40,10 @@ class CONTENT_EXPORT FontEnumerationDataSourceMac
// Font attributes for a font. Set post-validation. Used only during
// enumeration.
base::ScopedCFTypeRef<CFStringRef> cf_postscript_name_;
base::ScopedCFTypeRef<CFStringRef> cf_full_name_;
base::ScopedCFTypeRef<CFStringRef> cf_family_;
base::ScopedCFTypeRef<CFStringRef> cf_style_;
base::apple::ScopedCFTypeRef<CFStringRef> cf_postscript_name_;
base::apple::ScopedCFTypeRef<CFStringRef> cf_full_name_;
base::apple::ScopedCFTypeRef<CFStringRef> cf_family_;
base::apple::ScopedCFTypeRef<CFStringRef> cf_style_;
};
} // namespace content

@ -20,17 +20,19 @@ namespace content {
namespace {
base::ScopedCFTypeRef<CFStringRef> GetLocalizedString(CTFontDescriptorRef fd,
CFStringRef attribute) {
return base::ScopedCFTypeRef<CFStringRef>(
base::apple::ScopedCFTypeRef<CFStringRef> GetLocalizedString(
CTFontDescriptorRef fd,
CFStringRef attribute) {
return base::apple::ScopedCFTypeRef<CFStringRef>(
base::apple::CFCast<CFStringRef>(CTFontDescriptorCopyLocalizedAttribute(
fd, attribute, /*language=*/nullptr)));
}
base::ScopedCFTypeRef<CFStringRef> GetString(CTFontDescriptorRef fd,
CFStringRef attribute) {
return base::ScopedCFTypeRef<CFStringRef>(base::apple::CFCast<CFStringRef>(
CTFontDescriptorCopyAttribute(fd, attribute)));
base::apple::ScopedCFTypeRef<CFStringRef> GetString(CTFontDescriptorRef fd,
CFStringRef attribute) {
return base::apple::ScopedCFTypeRef<CFStringRef>(
base::apple::CFCast<CFStringRef>(
CTFontDescriptorCopyAttribute(fd, attribute)));
}
} // namespace
@ -45,13 +47,13 @@ FontEnumerationDataSourceMac::~FontEnumerationDataSourceMac() {
bool FontEnumerationDataSourceMac::IsValidFontMac(
const CTFontDescriptorRef& fd) {
base::ScopedCFTypeRef<CFStringRef> cf_postscript_name =
base::apple::ScopedCFTypeRef<CFStringRef> cf_postscript_name =
GetString(fd, kCTFontNameAttribute);
base::ScopedCFTypeRef<CFStringRef> cf_full_name =
base::apple::ScopedCFTypeRef<CFStringRef> cf_full_name =
GetLocalizedString(fd, kCTFontDisplayNameAttribute);
base::ScopedCFTypeRef<CFStringRef> cf_family =
base::apple::ScopedCFTypeRef<CFStringRef> cf_family =
GetString(fd, kCTFontFamilyNameAttribute);
base::ScopedCFTypeRef<CFStringRef> cf_style =
base::apple::ScopedCFTypeRef<CFStringRef> cf_style =
GetString(fd, kCTFontStyleNameAttribute);
if (!cf_postscript_name || !cf_full_name || !cf_family || !cf_style) {
@ -77,11 +79,11 @@ blink::FontEnumerationTable FontEnumerationDataSourceMac::GetFonts(
base::apple::CFToNSPtrCast(kCTFontCollectionRemoveDuplicatesOption) : @YES
};
base::ScopedCFTypeRef<CTFontCollectionRef> collection(
base::apple::ScopedCFTypeRef<CTFontCollectionRef> collection(
CTFontCollectionCreateFromAvailableFonts(
base::apple::NSToCFPtrCast(options)));
base::ScopedCFTypeRef<CFArrayRef> font_descs(
base::apple::ScopedCFTypeRef<CFArrayRef> font_descs(
CTFontCollectionCreateMatchingFontDescriptors(collection));
// Used to filter duplicates.

@ -51,7 +51,7 @@ class DesktopCaptureDeviceMac : public IOSurfaceCaptureDeviceBase {
};
// Retrieve the source display's size.
base::ScopedCFTypeRef<CGDisplayModeRef> mode(
base::apple::ScopedCFTypeRef<CGDisplayModeRef> mode(
CGDisplayCopyDisplayMode(display_id_));
const gfx::Size source_size = mode ? gfx::Size(CGDisplayModeGetWidth(mode),
CGDisplayModeGetHeight(mode))
@ -62,14 +62,14 @@ class DesktopCaptureDeviceMac : public IOSurfaceCaptureDeviceBase {
ComputeFrameSizeAndDestRect(source_size, requested_format_.frame_size,
dest_rect_in_frame);
base::ScopedCFTypeRef<CFDictionaryRef> properties;
base::apple::ScopedCFTypeRef<CFDictionaryRef> properties;
{
float max_frame_time = 1.f / requested_format_.frame_rate;
base::ScopedCFTypeRef<CFNumberRef> cf_max_frame_time(
base::apple::ScopedCFTypeRef<CFNumberRef> cf_max_frame_time(
CFNumberCreate(nullptr, kCFNumberFloat32Type, &max_frame_time));
base::ScopedCFTypeRef<CGColorSpaceRef> cg_color_space(
base::apple::ScopedCFTypeRef<CGColorSpaceRef> cg_color_space(
CGColorSpaceCreateWithName(kCGColorSpaceSRGB));
base::ScopedCFTypeRef<CFDictionaryRef> dest_rect_in_frame_dict(
base::apple::ScopedCFTypeRef<CFDictionaryRef> dest_rect_in_frame_dict(
CGRectCreateDictionaryRepresentation(dest_rect_in_frame.ToCGRect()));
const size_t kNumKeys = 5;
@ -138,7 +138,7 @@ class DesktopCaptureDeviceMac : public IOSurfaceCaptureDeviceBase {
const CGDirectDisplayID display_id_;
const scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_;
base::ScopedCFTypeRef<CGDisplayStreamRef> display_stream_;
base::apple::ScopedCFTypeRef<CGDisplayStreamRef> display_stream_;
media::VideoCaptureFormat requested_format_;
base::WeakPtrFactory<DesktopCaptureDeviceMac> weak_factory_;
};

Some files were not shown because too many files have changed in this diff Show More