0

Create base/apple and move bridging.h to it

Bug: none
Change-Id: Idb8ff1c781ef5c9767f19e94d212ef9cdba91d2c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4521459
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Code-Coverage: Findit <findit-for-me@appspot.gserviceaccount.com>
Auto-Submit: Avi Drissman <avi@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Avi Drissman <avi@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1142818}
This commit is contained in:
Avi Drissman
2023-05-11 19:04:10 +00:00
committed by Chromium LUCI CQ
parent b03beb814d
commit cfa612588b
45 changed files with 132 additions and 125 deletions

@ -2046,6 +2046,7 @@ component("base") {
# Mac or iOS.
if (is_apple) {
sources += [
"apple/bridging.h",
"file_version_info_mac.h",
"file_version_info_mac.mm",
"files/file_util_mac.mm",
@ -2141,7 +2142,6 @@ component("base") {
"ios/ns_range.h",
"ios/scoped_critical_action.h",
"ios/scoped_critical_action.mm",
"mac/bridging.h",
"native_library_ios.mm",
"power_monitor/power_monitor_device_source_ios.mm",
"process/process_metrics_ios.cc",

3
base/apple/DIR_METADATA Normal file

@ -0,0 +1,3 @@
monorail {
component: "Internals"
}

2
base/apple/OWNERS Normal file

@ -0,0 +1,2 @@
mark@chromium.org
thakis@chromium.org

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BASE_MAC_BRIDGING_H_
#define BASE_MAC_BRIDGING_H_
#ifndef BASE_APPLE_BRIDGING_H_
#define BASE_APPLE_BRIDGING_H_
#include <CoreText/CoreText.h>
#import <Foundation/Foundation.h>
@ -23,7 +23,7 @@
#endif
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "base/mac/bridging.h requires ARC."
#error "base/apple/bridging.h requires ARC."
#endif
// These functions convert pointers of bridged CFTypes to NSTypes and
@ -58,7 +58,7 @@
// works for this purpose.
#define CF_TO_NS_CAST_IMPL(TypeCF, TypeNS) \
namespace base::mac { \
namespace base::apple { \
inline BASE_EXPORT TypeNS* _Nullable CFToNSOwnershipCast( \
TypeCF##Ref CF_CONSUMED _Nullable cf_val) { \
DCHECK(!cf_val || TypeCF##GetTypeID() == CFGetTypeID(cf_val)); \
@ -85,7 +85,7 @@
#define CF_TO_NS_MUTABLE_CAST_IMPL(name) \
CF_TO_NS_CAST_IMPL(CF##name, NS##name) \
namespace base::mac { \
namespace base::apple { \
inline BASE_EXPORT NSMutable##name* _Nullable CFToNSOwnershipCast( \
CFMutable##name##Ref CF_CONSUMED _Nullable cf_val) { \
DCHECK(!cf_val || CF##name##GetTypeID() == CFGetTypeID(cf_val)); \
@ -151,7 +151,7 @@ extern "C" {
Boolean _CFIsObjC(CFTypeID typeID, _Nonnull CFTypeRef obj);
} // extern "C"
namespace base::mac {
namespace base::apple {
inline BASE_EXPORT NSFont* _Nullable CFToNSOwnershipCast(
CTFontRef CF_CONSUMED _Nullable cf_val) {
@ -185,14 +185,14 @@ inline BASE_EXPORT _Nullable CTFontRef NSToCFPtrCast(NSFont* _Nullable ns_val) {
return cf_val;
}
} // namespace base::mac
} // namespace base::apple
#endif // BUILDFLAG(IS_IOS)
#undef CF_TO_NS_CAST_IMPL
#undef CF_TO_NS_MUTABLE_CAST_IMPL
namespace base::mac {
namespace base::apple {
template <typename CFT>
id _Nullable CFToNSOwnershipCast(base::ScopedCFTypeRef<CFT>) {
@ -203,6 +203,6 @@ id _Nullable CFToNSOwnershipCast(base::ScopedCFTypeRef<CFT>) {
return nil;
}
} // namespace base::mac
} // namespace base::apple
#endif // BASE_MAC_BRIDGING_H_
#endif // BASE_APPLE_BRIDGING_H_

@ -135,7 +135,7 @@ BASE_EXPORT void SetBaseBundleID(const char* new_base_bundle_id);
} // namespace base::mac
// These casting functions cannot be implemented in a way that will work with
// ARC. Use the casting functions in base/mac/bridging.h instead.
// ARC. Use the casting functions in base/apple/bridging.h instead.
#if !defined(__has_feature) || !__has_feature(objc_arc)
#if defined(__OBJC__)

@ -11,8 +11,8 @@
#include <string>
#include <vector>
#include "base/apple/bridging.h"
#include "base/containers/span.h"
#include "base/mac/bridging.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/string_piece.h"
@ -103,7 +103,7 @@ base::ScopedCFTypeRef<CFMutableDictionaryRef> CreateAttributesForKey() {
CFDictionarySetValue(attributes, kSecAttrTokenID,
kSecAttrTokenIDSecureEnclave);
CFDictionarySetValue(attributes, kSecAttrKeySizeInBits,
base::mac::NSToCFPtrCast(@256));
base::apple::NSToCFPtrCast(@256));
CFDictionarySetValue(
attributes, kSecAttrLabel,
base::SysUTF8ToCFStringRef(constants::kDeviceTrustSigningKeyLabel));

@ -9,8 +9,8 @@
#include <memory>
#include "base/apple/bridging.h"
#include "base/containers/span.h"
#include "base/mac/bridging.h"
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/strings/sys_string_conversions.h"
@ -67,7 +67,7 @@ class SecureEnclaveClientTest : public testing::Test {
CFDictionarySetValue(test_attributes, kSecAttrKeyType,
kSecAttrKeyTypeECSECPrimeRandom);
CFDictionarySetValue(test_attributes, kSecAttrKeySizeInBits,
base::mac::NSToCFPtrCast(@256));
base::apple::NSToCFPtrCast(@256));
base::ScopedCFTypeRef<CFMutableDictionaryRef> private_key_params(
CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
&kCFTypeDictionaryKeyCallBacks,
@ -121,7 +121,7 @@ TEST_F(SecureEnclaveClientTest, CreateKey_Success) {
EXPECT_TRUE(CFEqual(kSecAttrTokenIDSecureEnclave,
base::mac::GetValueFromDictionary<CFStringRef>(
attributes, kSecAttrTokenID)));
EXPECT_TRUE(CFEqual(base::mac::NSToCFPtrCast(@256),
EXPECT_TRUE(CFEqual(base::apple::NSToCFPtrCast(@256),
base::mac::GetValueFromDictionary<CFNumberRef>(
attributes, kSecAttrKeySizeInBits)));
auto* private_key_attributes =

@ -10,7 +10,7 @@
#include <memory>
#include "base/mac/bridging.h"
#include "base/apple/bridging.h"
#include "base/mac/scoped_cftyperef.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
@ -49,7 +49,7 @@ base::ScopedCFTypeRef<SecKeyRef> SecureEnclaveHelperImpl::CopyKey(
bool SecureEnclaveHelperImpl::IsSecureEnclaveSupported() {
TKTokenWatcher* token_watcher = [[TKTokenWatcher alloc] init];
return ([token_watcher.tokenIDs
containsObject:base::mac::CFToNSPtrCast(kSecAttrTokenIDSecureEnclave)]);
containsObject:base::apple::CFToNSPtrCast(kSecAttrTokenIDSecureEnclave)]);
}
} // namespace enterprise_connectors

@ -12,8 +12,8 @@
#include <utility>
#include <vector>
#include "base/apple/bridging.h"
#include "base/containers/span.h"
#include "base/mac/bridging.h"
#include "base/mac/scoped_cftyperef.h"
#include "chrome/browser/enterprise/connectors/device_trust/key_management/core/mac/mock_secure_enclave_client.h"
#include "chrome/browser/enterprise/connectors/device_trust/key_management/core/mac/secure_enclave_client.h"
@ -54,7 +54,7 @@ class SecureEnclaveSigningKeyTest : public testing::Test {
CFDictionarySetValue(test_attributes, kSecAttrKeyType,
kSecAttrKeyTypeECSECPrimeRandom);
CFDictionarySetValue(test_attributes, kSecAttrKeySizeInBits,
base::mac::NSToCFPtrCast(@256));
base::apple::NSToCFPtrCast(@256));
base::ScopedCFTypeRef<CFMutableDictionaryRef> private_key_params(
CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
&kCFTypeDictionaryKeyCallBacks,

@ -10,8 +10,8 @@
#include <string>
#include <utility>
#include "base/apple/bridging.h"
#include "base/containers/span.h"
#include "base/mac/bridging.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/browser/enterprise/connectors/device_trust/key_management/core/mac/mock_secure_enclave_client.h"
@ -65,7 +65,7 @@ class MacKeyPersistenceDelegateTest : public testing::Test {
CFDictionarySetValue(test_attributes, kSecAttrKeyType,
kSecAttrKeyTypeECSECPrimeRandom);
CFDictionarySetValue(test_attributes, kSecAttrKeySizeInBits,
base::mac::NSToCFPtrCast(@256));
base::apple::NSToCFPtrCast(@256));
base::ScopedCFTypeRef<CFMutableDictionaryRef> private_key_params(
CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
&kCFTypeDictionaryKeyCallBacks,

@ -11,12 +11,12 @@
#include <utility>
#include <vector>
#include "base/apple/bridging.h"
#include "base/file_version_info.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/mac/authorization_util.h"
#include "base/mac/bridging.h"
#include "base/mac/bundle_locations.h"
#include "base/mac/foundation_util.h"
#include "base/mac/mac_logging.h"
@ -818,7 +818,7 @@ NSString* const kVersionKey = @"KSVersion";
// tests can pick it up.
+ (BOOL)isValidSystemKeystone:(NSDictionary*)systemKeystonePlistContents
comparedToBundled:(NSDictionary*)bundledKeystonePlistContents {
NSString* versionKey = base::mac::CFToNSPtrCast(kCFBundleVersionKey);
NSString* versionKey = base::apple::CFToNSPtrCast(kCFBundleVersionKey);
// If the bundled version is missing or broken, this question is irrelevant.
NSString* bundledKeystoneVersionString =
@ -917,7 +917,7 @@ NSString* const kVersionKey = @"KSVersion";
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
base::mac::ScopedAuthorizationRef authorization =
base::mac::AuthorizationCreateToRunAsRoot(
base::mac::NSToCFPtrCast(prompt));
base::apple::NSToCFPtrCast(prompt));
if (!authorization) {
return;
}

@ -9,9 +9,9 @@
#include <set>
#include "base/apple/bridging.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/mac/bridging.h"
#include "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/common/chrome_constants.h"
@ -84,10 +84,10 @@ bool FindChromeBundle(NSString* bundle_id, base::FilePath* out_bundle) {
// Retrieve the last-run Chrome bundle location.
base::FilePath last_run_bundle_path;
{
NSString* cr_bundle_path_ns = base::mac::CFToNSOwnershipCast(
NSString* cr_bundle_path_ns = base::apple::CFToNSOwnershipCast(
base::mac::CFCastStrict<CFStringRef>(CFPreferencesCopyAppValue(
base::mac::NSToCFPtrCast(app_mode::kLastRunAppBundlePathPrefsKey),
base::mac::NSToCFPtrCast(bundle_id))));
base::apple::NSToCFPtrCast(app_mode::kLastRunAppBundlePathPrefsKey),
base::apple::NSToCFPtrCast(bundle_id))));
last_run_bundle_path = base::mac::NSStringToFilePath(cr_bundle_path_ns);
}

@ -7,7 +7,7 @@
#include <string>
#include <vector>
#include "base/mac/bridging.h"
#include "base/apple/bridging.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_refptr.h"
@ -203,21 +203,21 @@ ManagedPreferencePolicyManager::GetAppsWithPolicy() const {
NSDictionary* ReadManagedPreferencePolicyDictionary() {
base::ScopedCFTypeRef<CFPropertyListRef> policies(CFPreferencesCopyAppValue(
base::mac::NSToCFPtrCast(kManagedPreferencesUpdatePolicies),
base::mac::NSToCFPtrCast(kKeystoneSharedPreferenceSuite)));
base::apple::NSToCFPtrCast(kManagedPreferencesUpdatePolicies),
base::apple::NSToCFPtrCast(kKeystoneSharedPreferenceSuite)));
if (!policies)
return nil;
if (!CFPreferencesAppValueIsForced(
base::mac::NSToCFPtrCast(kManagedPreferencesUpdatePolicies),
base::mac::NSToCFPtrCast(kKeystoneSharedPreferenceSuite))) {
base::apple::NSToCFPtrCast(kManagedPreferencesUpdatePolicies),
base::apple::NSToCFPtrCast(kKeystoneSharedPreferenceSuite))) {
return nil;
}
if (CFGetTypeID(policies) != CFDictionaryGetTypeID())
return nil;
return base::mac::CFToNSOwnershipCast((CFDictionaryRef)policies.release());
return base::apple::CFToNSOwnershipCast((CFDictionaryRef)policies.release());
}
scoped_refptr<PolicyManagerInterface> CreateManagedPreferencePolicyManager() {

@ -11,7 +11,7 @@
#include <utility>
#include "base/mac/bridging.h"
#include "base/apple/bridging.h"
#include "base/mac/foundation_util.h"
#include "base/memory/ptr_util.h"
#include "components/power_metrics/m1_sensors_internal_types_mac.h"
@ -66,7 +66,7 @@ std::unique_ptr<M1SensorsReader> M1SensorsReader::Create() {
@kIOHIDPrimaryUsagePageKey : @(kHIDPage_AppleVendor),
@kIOHIDPrimaryUsageKey : @(kHIDUsage_AppleVendor_TemperatureSensor),
};
IOHIDEventSystemClientSetMatching(system, base::mac::NSToCFPtrCast(filter));
IOHIDEventSystemClientSetMatching(system, base::apple::NSToCFPtrCast(filter));
return base::WrapUnique(new M1SensorsReader(std::move(system)));
}

@ -7,10 +7,10 @@
#import <ApplicationServices/ApplicationServices.h>
#import <Foundation/Foundation.h>
#include "base/apple/bridging.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/mac/bridging.h"
#include "base/mac/foundation_util.h"
#include "base/mac/mac_logging.h"
#include "base/mac/mac_util.h"
@ -66,7 +66,7 @@ bool AddOriginMetadataToFile(const base::FilePath& file,
}
base::ScopedCFTypeRef<MDItemRef> md_item(
MDItemCreate(kCFAllocatorDefault, base::mac::NSToCFPtrCast(file_path)));
MDItemCreate(kCFAllocatorDefault, base::apple::NSToCFPtrCast(file_path)));
if (!md_item) {
LOG(WARNING) << "MDItemCreate failed for path " << file.value();
return false;
@ -89,7 +89,7 @@ bool AddOriginMetadataToFile(const base::FilePath& file,
if (list.count) {
return MDItemSetAttribute(md_item, kMDItemWhereFroms,
base::mac::NSToCFPtrCast(list));
base::apple::NSToCFPtrCast(list));
}
return true;

@ -7,11 +7,11 @@
#import <ApplicationServices/ApplicationServices.h>
#import <Foundation/Foundation.h>
#include "base/apple/bridging.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/mac/bridging.h"
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/run_loop.h"
@ -169,7 +169,7 @@ TEST_F(QuarantineMacTest, NoWhereFromsKeyIfNoURLs) {
NSString* file_path = base::mac::FilePathToNSString(test_file_);
ASSERT_NE(nullptr, file_path);
base::ScopedCFTypeRef<MDItemRef> md_item(
MDItemCreate(kCFAllocatorDefault, base::mac::NSToCFPtrCast(file_path)));
MDItemCreate(kCFAllocatorDefault, base::apple::NSToCFPtrCast(file_path)));
if (!md_item) {
// The quarantine code ignores it if adding origin metadata fails. If for
// some reason MDItemCreate fails (which it seems to do on the bots, not

@ -7,9 +7,9 @@
#import <ApplicationServices/ApplicationServices.h>
#import <Foundation/Foundation.h>
#include "base/apple/bridging.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/mac/bridging.h"
#include "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#include "base/threading/scoped_blocking_call.h"
@ -46,7 +46,7 @@ bool IsFileQuarantined(const base::FilePath& file,
// The agent bundle id must always be set.
NSString* bundle_id =
[properties valueForKey:base::mac::CFToNSPtrCast(
[properties valueForKey:base::apple::CFToNSPtrCast(
kLSQuarantineAgentBundleIdentifierKey)];
if (!bundle_id.length) {
return false;
@ -56,7 +56,7 @@ bool IsFileQuarantined(const base::FilePath& file,
GURL expected_source_url =
SanitizeUrlForQuarantine(expected_source_url_unsafe);
NSString* source_url = [[properties
valueForKey:base::mac::CFToNSPtrCast(kLSQuarantineDataURLKey)]
valueForKey:base::apple::CFToNSPtrCast(kLSQuarantineDataURLKey)]
description];
if (expected_source_url.is_valid() && source_url.length) {
if (![source_url isEqualToString:base::SysUTF8ToNSString(
@ -68,7 +68,7 @@ bool IsFileQuarantined(const base::FilePath& file,
GURL expected_referrer_url =
SanitizeUrlForQuarantine(expected_referrer_url_unsafe);
NSString* referrer_url = [[properties
valueForKey:base::mac::CFToNSPtrCast(kLSQuarantineOriginURLKey)]
valueForKey:base::apple::CFToNSPtrCast(kLSQuarantineOriginURLKey)]
description];
if (expected_referrer_url.is_valid() && referrer_url.length) {
if (![referrer_url isEqualToString:base::SysUTF8ToNSString(

@ -6,7 +6,7 @@
#import <Foundation/Foundation.h>
#include "base/mac/bridging.h"
#include "base/apple/bridging.h"
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_cftyperef.h"
@ -74,7 +74,7 @@ base::ScopedCFTypeRef<CFDictionaryRef> MakeKeychainData(
// Set the password.
NSData* password = [NSData dataWithBytes:passwordData length:passwordLength];
CFDictionarySetValue(keychain_data, kSecValueData,
base::mac::NSToCFPtrCast(password));
base::apple::NSToCFPtrCast(password));
// If this is not a creation, no structural information is needed.
if (action != kKeychainActionCreate) {

@ -9,11 +9,11 @@
#import <LocalAuthentication/LocalAuthentication.h>
#import <Security/Security.h>
#include "base/apple/bridging.h"
#include "base/containers/contains.h"
#include "base/containers/cxx20_erase.h"
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/mac/bridging.h"
#include "base/mac/foundation_util.h"
#include "base/mac/mac_logging.h"
#include "base/mac/scoped_cftyperef.h"
@ -230,7 +230,7 @@ TouchIdCredentialStore::CreateCredential(
CFDictionarySetValue(params, kSecAttrKeyType,
kSecAttrKeyTypeECSECPrimeRandom);
CFDictionarySetValue(params, kSecAttrKeySizeInBits,
base::mac::NSToCFPtrCast(@256));
base::apple::NSToCFPtrCast(@256));
CFDictionarySetValue(params, kSecAttrSynchronizable, kCFBooleanFalse);
CFDictionarySetValue(params, kSecAttrTokenID, kSecAttrTokenIDSecureEnclave);
@ -242,15 +242,15 @@ TouchIdCredentialStore::CreateCredential(
user, discoverable == kDiscoverable);
const std::vector<uint8_t> sealed_metadata = SealCredentialMetadata(
config_.metadata_secret, rp_id, credential_metadata);
CFDictionarySetValue(
params, kSecAttrApplicationTag,
base::mac::NSToCFPtrCast([NSData dataWithBytes:sealed_metadata.data()
length:sealed_metadata.size()]));
CFDictionarySetValue(params, kSecAttrApplicationTag,
base::apple::NSToCFPtrCast([NSData
dataWithBytes:sealed_metadata.data()
length:sealed_metadata.size()]));
const std::vector<uint8_t> credential_id = GenerateRandomCredentialId();
CFDictionarySetValue(
params, kSecAttrApplicationLabel,
base::mac::NSToCFPtrCast([NSData dataWithBytes:credential_id.data()
length:credential_id.size()]));
base::apple::NSToCFPtrCast([NSData dataWithBytes:credential_id.data()
length:credential_id.size()]));
base::ScopedCFTypeRef<CFMutableDictionaryRef> private_key_params(
CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
&kCFTypeDictionaryKeyCallBacks,
@ -323,7 +323,7 @@ TouchIdCredentialStore::CreateCredentialLegacyCredentialForTesting(
CFDictionarySetValue(params, kSecAttrKeyType,
kSecAttrKeyTypeECSECPrimeRandom);
CFDictionarySetValue(params, kSecAttrKeySizeInBits,
base::mac::NSToCFPtrCast(@256));
base::apple::NSToCFPtrCast(@256));
CFDictionarySetValue(params, kSecAttrSynchronizable, kCFBooleanFalse);
CFDictionarySetValue(params, kSecAttrTokenID, kSecAttrTokenIDSecureEnclave);
@ -335,8 +335,8 @@ TouchIdCredentialStore::CreateCredentialLegacyCredentialForTesting(
config_.metadata_secret, rp_id, user.id)));
CFDictionarySetValue(
params, kSecAttrApplicationLabel,
base::mac::NSToCFPtrCast([NSData dataWithBytes:credential_id.data()
length:credential_id.size()]));
base::apple::NSToCFPtrCast([NSData dataWithBytes:credential_id.data()
length:credential_id.size()]));
base::ScopedCFTypeRef<CFMutableDictionaryRef> private_key_params(
CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
&kCFTypeDictionaryKeyCallBacks,
@ -654,8 +654,8 @@ bool TouchIdCredentialStore::DeleteCredentialById(
CFDictionarySetValue(query, kSecClass, kSecClassKey);
CFDictionarySetValue(
query, kSecAttrApplicationLabel,
base::mac::NSToCFPtrCast([NSData dataWithBytes:credential_id.data()
length:credential_id.size()]));
base::apple::NSToCFPtrCast([NSData dataWithBytes:credential_id.data()
length:credential_id.size()]));
OSStatus status = Keychain::GetInstance().ItemDelete(query);
if (status != errSecSuccess) {
OSSTATUS_DLOG(ERROR, status) << "SecItemDelete failed";
@ -696,7 +696,7 @@ bool TouchIdCredentialStore::UpdateCredential(
std::vector<uint8_t> sealed_metadata = SealCredentialMetadata(
config_.metadata_secret, credential.rp_id, credential.metadata);
CFDictionarySetValue(params, kSecAttrApplicationTag,
base::mac::NSToCFPtrCast([NSData
base::apple::NSToCFPtrCast([NSData
dataWithBytes:sealed_metadata.data()
length:sealed_metadata.size()]));
found_credential = true;
@ -718,8 +718,8 @@ bool TouchIdCredentialStore::UpdateCredential(
CFDictionarySetValue(query, kSecClass, kSecClassKey);
CFDictionarySetValue(
query, kSecAttrApplicationLabel,
base::mac::NSToCFPtrCast([NSData dataWithBytes:credential_id.data()
length:credential_id.size()]));
base::apple::NSToCFPtrCast([NSData dataWithBytes:credential_id.data()
length:credential_id.size()]));
OSStatus status = Keychain::GetInstance().ItemUpdate(query, params);
if (status != errSecSuccess) {
OSSTATUS_DLOG(ERROR, status) << "SecItemUpdate failed";

@ -8,9 +8,9 @@
#import <Foundation/Foundation.h>
#include <Security/Security.h>
#include "base/apple/bridging.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/mac/bridging.h"
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/memory/ptr_util.h"
@ -50,7 +50,7 @@ bool ExecutableHasKeychainAccessGroupEntitlement(
return false;
}
NSArray* entitlement_value_nsarray = base::mac::CFToNSPtrCast(
NSArray* entitlement_value_nsarray = base::apple::CFToNSPtrCast(
base::mac::CFCast<CFArrayRef>(entitlement_value_cftype));
if (!entitlement_value_nsarray) {
return false;
@ -73,7 +73,7 @@ bool CanCreateSecureEnclaveKeyPairBlocking() {
CFDictionarySetValue(params, kSecAttrKeyType,
kSecAttrKeyTypeECSECPrimeRandom);
CFDictionarySetValue(params, kSecAttrKeySizeInBits,
base::mac::NSToCFPtrCast(@256));
base::apple::NSToCFPtrCast(@256));
CFDictionarySetValue(params, kSecAttrTokenID, kSecAttrTokenIDSecureEnclave);
CFDictionarySetValue(params, kSecAttrIsPermanent, kCFBooleanFalse);
@ -195,7 +195,7 @@ void TouchIdContext::PromptTouchId(const std::u16string& reason,
// were, it would have to be retained first.
DCHECK(error != nil);
DVLOG(1) << "Touch ID prompt failed: "
<< base::mac::NSToCFPtrCast(error);
<< base::apple::NSToCFPtrCast(error);
}
runner->PostTask(
FROM_HERE,

@ -7,7 +7,7 @@
#include <CoreFoundation/CoreFoundation.h>
#import <Foundation/Foundation.h>
#include "base/mac/bridging.h"
#include "base/apple/bridging.h"
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/strings/sys_string_conversions.h"

@ -7,7 +7,7 @@
#include <stdint.h>
#include <string.h>
#include "base/mac/bridging.h"
#include "base/apple/bridging.h"
#include "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#import "base/task/sequenced_task_runner.h"
@ -65,7 +65,7 @@ void GamepadPlatformDataFetcherMac::OnAddedToProvider() {
DeviceMatching(kGenericDesktopUsagePage, kMultiAxisUsageNumber),
];
IOHIDManagerSetDeviceMatchingMultiple(hid_manager_ref_,
base::mac::NSToCFPtrCast(criteria));
base::apple::NSToCFPtrCast(criteria));
RegisterForNotifications();
}
@ -143,8 +143,8 @@ GamepadDeviceMac* GamepadPlatformDataFetcherMac::GetGamepadFromHidDevice(
}
void GamepadPlatformDataFetcherMac::DeviceAdd(IOHIDDeviceRef device) {
using base::apple::CFToNSPtrCast;
using base::mac::CFCastStrict;
using base::mac::CFToNSPtrCast;
if (!enabled_) {
return;

@ -341,7 +341,7 @@ particular order:
ownership management as Objective-C object pointers.
- `CFToNSCast` and `NSToCFCast`: These do not handle ARC ownership; switch to
`CFToNSPtrCast`, `CFToNSOwnershipCast`, `NSToCFPtrCast`, and
`NSToCFOwnershipCast` from `base/mac/bridging.h`.
`NSToCFOwnershipCast` from `base/apple/bridging.h`.
## Further reading {#references}

@ -4,7 +4,7 @@
#import "ios/web/security/crw_cert_verification_controller.h"
#import "base/mac/bridging.h"
#import "base/apple/bridging.h"
#import "base/strings/sys_string_conversions.h"
#import "base/test/ios/wait_util.h"
#import "ios/web/public/session/session_certificate_policy_cache.h"
@ -48,10 +48,10 @@ class CRWCertVerificationControllerTest : public web::WebTest {
cert_.get()));
ASSERT_TRUE(chain);
valid_trust_ = web::CreateServerTrustFromChain(
base::mac::CFToNSPtrCast(chain.get()), kHostName);
base::apple::CFToNSPtrCast(chain.get()), kHostName);
web::EnsureFutureTrustEvaluationSucceeds(valid_trust_.get());
invalid_trust_ = web::CreateServerTrustFromChain(
base::mac::CFToNSPtrCast(chain.get()), kHostName);
base::apple::CFToNSPtrCast(chain.get()), kHostName);
}
// Synchronously returns result of

@ -6,7 +6,7 @@
#import <WebKit/WebKit.h>
#import "base/mac/bridging.h"
#import "base/apple/bridging.h"
#import "base/strings/sys_string_conversions.h"
#import "ios/web/navigation/navigation_manager_impl.h"
#import "ios/web/public/navigation/navigation_item.h"
@ -108,7 +108,7 @@ class CRWSSLStatusUpdaterTest : public web::WebTest {
net::x509_util::CreateSecCertificateArrayForX509Certificate(
cert.get()));
ASSERT_TRUE(chain);
trust_ = CreateServerTrustFromChain(base::mac::CFToNSPtrCast(chain.get()),
trust_ = CreateServerTrustFromChain(base::apple::CFToNSPtrCast(chain.get()),
kHostName);
}

@ -9,7 +9,7 @@
#import <memory>
#import "base/mac/bridging.h"
#import "base/apple/bridging.h"
#import "base/mac/foundation_util.h"
#import "base/mac/scoped_cftyperef.h"
#import "crypto/rsa_private_key.h"
@ -61,7 +61,7 @@ NSDictionary* MakeTestSSLCertErrorUserInfo() {
base::ScopedCFTypeRef<SecTrustRef> CreateTestTrust(NSArray* cert_chain) {
base::ScopedCFTypeRef<SecPolicyRef> policy(SecPolicyCreateBasicX509());
SecTrustRef trust = nullptr;
SecTrustCreateWithCertificates(base::mac::NSToCFPtrCast(cert_chain), policy,
SecTrustCreateWithCertificates(base::apple::NSToCFPtrCast(cert_chain), policy,
&trust);
return base::ScopedCFTypeRef<SecTrustRef>(trust);
}

@ -6,7 +6,7 @@
#import <Foundation/Foundation.h>
#import "base/mac/bridging.h"
#import "base/apple/bridging.h"
#import "ios/net/protocol_handler_util.h"
#import "ios/web/test/test_url_constants.h"
#import "net/base/mac/url_conversions.h"
@ -74,7 +74,7 @@ TEST_F(ErrorTranslationUtilTest, MalformedError) {
// underlying error.
TEST_F(ErrorTranslationUtilTest, UnknownCFNetworkError) {
NSError* error = [[NSError alloc]
initWithDomain:base::mac::CFToNSPtrCast(kCFErrorDomainCFNetwork)
initWithDomain:base::apple::CFToNSPtrCast(kCFErrorDomainCFNetwork)
code:kCFURLErrorUnknown
userInfo:nil];
NSError* net_error = NetErrorFromError(error);

@ -6,7 +6,7 @@
#include <IOKit/IOCFPlugIn.h>
#include "base/mac/bridging.h"
#include "base/apple/bridging.h"
#include "base/mac/foundation_util.h"
#include "base/mac/mac_util.h"
#include "base/mac/scoped_cftyperef.h"
@ -107,9 +107,9 @@ static bool FindDeviceWithVendorAndProductIds(int vendor_id,
base::ScopedCFTypeRef<CFMutableDictionaryRef> query_dictionary(
IOServiceMatching(kIOUSBDeviceClassName));
CFDictionarySetValue(query_dictionary, CFSTR(kUSBVendorName),
base::mac::NSToCFPtrCast(@(vendor_id)));
base::apple::NSToCFPtrCast(@(vendor_id)));
CFDictionarySetValue(query_dictionary, CFSTR(kUSBProductName),
base::mac::NSToCFPtrCast(@(product_id)));
base::apple::NSToCFPtrCast(@(product_id)));
kern_return_t kr = IOServiceGetMatchingServices(
kIOMasterPortDefault, query_dictionary.release(), usb_iterator);

@ -9,7 +9,7 @@
#include <string>
#include "base/mac/bridging.h"
#include "base/apple/bridging.h"
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/notreached.h"
@ -186,7 +186,7 @@ void PlatformMimeUtil::GetPlatformExtensionsForMimeType(
continue;
}
extensions_found = true;
for (NSString* extension in base::mac::CFToNSPtrCast(
for (NSString* extension in base::apple::CFToNSPtrCast(
extensions_list)) {
extensions->insert(base::SysNSStringToUTF8(extension));
}

@ -8,9 +8,9 @@
#include <memory>
#include "base/apple/bridging.h"
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/mac/bridging.h"
#include "base/mac/mac_util.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/run_loop.h"
@ -77,7 +77,7 @@ TEST_F(TextDetectionImplMacTest, ScanOnce) {
attributes:attributes];
base::ScopedCFTypeRef<CTLineRef> line(
CTLineCreateWithAttributedString(base::mac::NSToCFPtrCast(info)));
CTLineCreateWithAttributedString(base::apple::NSToCFPtrCast(info)));
CGContextSetTextPosition(context, 10.0, height / 2.0);
CTLineDraw(line, context);

@ -7,9 +7,9 @@
#include <CoreText/CoreText.h>
#include <Foundation/Foundation.h>
#include "base/apple/bridging.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/mac/bridging.h"
#include "base/mac/foundation_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
@ -32,7 +32,7 @@ void InitializeSkFontMgrForTest() {
if (@available(macOS 10.15, *)) {
CTFontManagerRegisterFontURLs(
base::mac::NSToCFPtrCast(font_urls), kCTFontManagerScopeProcess,
base::apple::NSToCFPtrCast(font_urls), kCTFontManagerScopeProcess,
/*enabled=*/true, ^bool(CFArrayRef errors, bool done) {
if (CFArrayGetCount(errors)) {
DLOG(FATAL) << "Failed to activate fonts.";
@ -40,9 +40,9 @@ void InitializeSkFontMgrForTest() {
return true;
});
} else {
if (!CTFontManagerRegisterFontsForURLs(base::mac::NSToCFPtrCast(font_urls),
kCTFontManagerScopeProcess,
/*errors=*/nullptr)) {
if (!CTFontManagerRegisterFontsForURLs(
base::apple::NSToCFPtrCast(font_urls), kCTFontManagerScopeProcess,
/*errors=*/nullptr)) {
DLOG(FATAL) << "Failed to activate fonts.";
}
}

@ -1,4 +1,5 @@
include_rules = [
"+base/apple/bridging.h",
"+base/atomic_sequence_num.h",
"+base/barrier_closure.h",
"+base/cancelable_callback.h",
@ -6,7 +7,6 @@ include_rules = [
"+base/files/file.h",
"+base/files/file_path.h",
"+base/guid.h",
"+base/mac/bridging.h",
"+base/mac/foundation_util.h",
"+base/mac/scoped_cftyperef.h",
"+base/memory/scoped_refptr.h",

@ -33,7 +33,7 @@
#import <Cocoa/Cocoa.h>
#include "base/mac/bridging.h"
#include "base/apple/bridging.h"
#include "base/mac/scoped_cftyperef.h"
#include "third_party/blink/renderer/core/css/properties/longhands.h"
#include "third_party/blink/renderer/core/dom/document.h"
@ -117,7 +117,7 @@ NSAttributedString* AttributedSubstringFromRange(LocalFrame* frame,
@(primaryFont->GetFontMetrics().Descent() * page_scale_factor);
NSFont* original_font =
base::mac::CFToNSPtrCast(font_platform_data.CtFont());
base::apple::CFToNSPtrCast(font_platform_data.CtFont());
const CGFloat desired_size =
font_platform_data.size() * page_scale_factor / device_scale_factor;
@ -215,7 +215,7 @@ SubstringUtil::AttributedWordAtPoint(WebFrameWidgetImpl* frame_widget,
NSAttributedString* string = AttributedSubstringFromRange(frame, word_range);
baseline_point = GetBaselinePoint(frame->View(), word_range, string);
return base::ScopedCFTypeRef<CFAttributedStringRef>(
base::mac::NSToCFOwnershipCast(string));
base::apple::NSToCFOwnershipCast(string));
}
base::ScopedCFTypeRef<CFAttributedStringRef>
@ -239,7 +239,7 @@ SubstringUtil::AttributedSubstringInRange(LocalFrame* frame,
AttributedSubstringFromRange(frame, ephemeral_range);
baseline_point = GetBaselinePoint(frame->View(), ephemeral_range, string);
return base::ScopedCFTypeRef<CFAttributedStringRef>(
base::mac::NSToCFOwnershipCast(string));
base::apple::NSToCFOwnershipCast(string));
}
} // namespace blink

@ -6,6 +6,7 @@ include_rules = [
"+third_party/blink/renderer/platform/fonts",
# Dependencies.
"+base/apple",
"+base/mac",
"+base/win",
"+cc",

@ -6,7 +6,7 @@
#include <AppKit/AppKit.h>
#include "base/mac/bridging.h"
#include "base/apple/bridging.h"
#include "base/mac/foundation_util.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "ui/gfx/range/range.h"
@ -21,7 +21,7 @@ ui::mojom::blink::AttributedStringPtr
TypeConverter<ui::mojom::blink::AttributedStringPtr, CFAttributedStringRef>::
Convert(CFAttributedStringRef cf_attributed_string) {
NSAttributedString* ns_attributed_string =
base::mac::CFToNSPtrCast(cf_attributed_string);
base::apple::CFToNSPtrCast(cf_attributed_string);
// Create the return value.
ui::mojom::blink::AttributedStringPtr attributed_string =

@ -34,8 +34,8 @@
#import <AppKit/AppKit.h>
#import <CoreText/CoreText.h>
#include "base/apple/bridging.h"
#include "base/location.h"
#include "base/mac/bridging.h"
#include "base/metrics/histogram_macros.h"
#include "base/timer/elapsed_timer.h"
#include "third_party/blink/public/platform/platform.h"
@ -146,7 +146,7 @@ scoped_refptr<SimpleFontData> FontCache::PlatformFallbackFontForCharacter(
const FontPlatformData& platform_data =
font_data_to_substitute->PlatformData();
NSFont* ns_font = base::mac::CFToNSPtrCast(platform_data.CtFont());
NSFont* ns_font = base::apple::CFToNSPtrCast(platform_data.CtFont());
NSString* string = [[NSString alloc]
initWithCharacters:reinterpret_cast<UniChar*>(code_units)

@ -33,7 +33,7 @@
#import <Foundation/Foundation.h>
#import <math.h>
#include "base/mac/bridging.h"
#include "base/apple/bridging.h"
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_cftyperef.h"
#include "third_party/blink/renderer/platform/fonts/font_cache.h"
@ -127,12 +127,12 @@ NSFont* MatchUniqueFont(const AtomicString& unique_font_name, float size) {
// searching for fonts with its value as their display name.
NSString* desired_name = unique_font_name;
NSDictionary* attributes = @{
base::mac::CFToNSPtrCast(kCTFontNameAttribute) : desired_name,
base::mac::CFToNSPtrCast(kCTFontSizeAttribute) : @(size)
base::apple::CFToNSPtrCast(kCTFontNameAttribute) : desired_name,
base::apple::CFToNSPtrCast(kCTFontSizeAttribute) : @(size)
};
base::ScopedCFTypeRef<CTFontDescriptorRef> descriptor(
CTFontDescriptorCreateWithAttributes(
base::mac::NSToCFPtrCast(attributes)));
base::apple::NSToCFPtrCast(attributes)));
base::ScopedCFTypeRef<CTFontRef> matched_font(
CTFontCreateWithFontDescriptor(descriptor, 0, nullptr));
@ -140,9 +140,9 @@ NSFont* MatchUniqueFont(const AtomicString& unique_font_name, float size) {
// CoreText will usually give us *something* but not always an exactly matched
// font.
NSString* matched_postscript_name = base::mac::CFToNSOwnershipCast(
NSString* matched_postscript_name = base::apple::CFToNSOwnershipCast(
CTFontCopyName(matched_font, kCTFontPostScriptNameKey));
NSString* matched_full_font_name = base::mac::CFToNSOwnershipCast(
NSString* matched_full_font_name = base::apple::CFToNSOwnershipCast(
CTFontCopyName(matched_font, kCTFontFullNameKey));
// If the found font does not match in PostScript name or full font name, it's
// not the exact match that is required, so return nullptr.
@ -153,7 +153,7 @@ NSFont* MatchUniqueFont(const AtomicString& unique_font_name, float size) {
return nullptr;
}
return base::mac::CFToNSOwnershipCast(matched_font.release());
return base::apple::CFToNSOwnershipCast(matched_font.release());
}
// Family name is somewhat of a misnomer here. We first attempt to find an

@ -26,7 +26,7 @@
#import <AppKit/AppKit.h>
#import <AvailabilityMacros.h>
#include "base/mac/bridging.h"
#include "base/apple/bridging.h"
#import "base/mac/foundation_util.h"
#include "third_party/blink/renderer/platform/fonts/font.h"
#include "third_party/blink/renderer/platform/fonts/font_platform_data.h"
@ -98,9 +98,9 @@ bool VariableAxisChangeEffective(SkTypeface* typeface,
static bool CanLoadInProcess(NSFont* ns_font) {
base::ScopedCFTypeRef<CGFontRef> cg_font(CTFontCopyGraphicsFont(
base::mac::NSToCFPtrCast(ns_font), /*attributes=*/nullptr));
base::apple::NSToCFPtrCast(ns_font), /*attributes=*/nullptr));
NSString* font_name =
base::mac::CFToNSOwnershipCast(CGFontCopyPostScriptName(cg_font));
base::apple::CFToNSOwnershipCast(CGFontCopyPostScriptName(cg_font));
return ![font_name isEqualToString:@"LastResort"];
}
@ -122,7 +122,7 @@ std::unique_ptr<FontPlatformData> FontPlatformDataFromNSFont(
DCHECK(CanLoadInProcess(ns_font));
sk_sp<SkTypeface> typeface =
SkMakeTypefaceFromCTFont(base::mac::NSToCFPtrCast(ns_font));
SkMakeTypefaceFromCTFont(base::apple::NSToCFPtrCast(ns_font));
auto make_typeface_fontplatformdata = [&typeface, &size, &synthetic_bold,
&synthetic_italic, &text_rendering,

@ -4,7 +4,7 @@
#include "third_party/blink/renderer/platform/fonts/mac/font_platform_data_mac.h"
#include "base/mac/bridging.h"
#include "base/apple/bridging.h"
#include "base/mac/foundation_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/platform/font_family_names.h"
@ -23,7 +23,7 @@ constexpr SkFourByteTag kOpszTag = SkSetFourByteTag('o', 'p', 's', 'z');
constexpr SkFourByteTag kWghtTag = SkSetFourByteTag('w', 'g', 'h', 't');
sk_sp<SkTypeface> MakeSystemFontOfSize(float size) {
return SkMakeTypefaceFromCTFont(base::mac::NSToCFPtrCast(MatchNSFontFamily(
return SkMakeTypefaceFromCTFont(base::apple::NSToCFPtrCast(MatchNSFontFamily(
font_family_names::kSystemUi, 0, FontSelectionValue(400), size)));
}
}

@ -6,6 +6,7 @@ include_rules = [
"+third_party/blink/renderer/platform/text",
# Dependencies.
"+base/apple",
"+base/i18n/rtl.h",
"+base/mac",
"+third_party/blink/renderer/platform/text/date_components.h",

@ -1,13 +1,13 @@
include_rules = [
# To only allow a subset of base/ in Blink, we explicitly list all
# directories and files instead of writing 'base/'.
"+base/apple/bridging.h",
"+base/atomic_ref_count.h",
"+base/auto_reset.h",
"+base/bits.h",
"+base/compiler_specific.h",
"+base/functional/bind.h",
"+base/logging.h",
"+base/mac/bridging.h",
"+base/mac/foundation_util.h",
"+base/mac/scoped_cftyperef.h",
"+base/memory/ptr_util.h",

@ -37,7 +37,7 @@
#include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h"
#ifdef __OBJC__
#include "base/mac/bridging.h"
#include "base/apple/bridging.h"
#endif
namespace WTF {
@ -194,7 +194,7 @@ class WTF_EXPORT AtomicString {
unsigned Hash() const { return string_.Impl()->ExistingHash(); }
#ifdef __OBJC__
AtomicString(NSString* s) : string_(Add(base::mac::NSToCFPtrCast(s))) {}
AtomicString(NSString* s) : string_(Add(base::apple::NSToCFPtrCast(s))) {}
operator NSString*() const { return string_; }
#endif
// AtomicString::fromUTF8 will return a null string if

@ -22,7 +22,7 @@
#include <CoreFoundation/CoreFoundation.h>
#include "base/mac/bridging.h"
#include "base/apple/bridging.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
@ -35,7 +35,7 @@ String::String(NSString* str) {
return;
}
CFStringRef cf_str = base::mac::NSToCFPtrCast(str);
CFStringRef cf_str = base::apple::NSToCFPtrCast(str);
CFIndex size = CFStringGetLength(cf_str);
if (size == 0) {

@ -22,7 +22,7 @@
#import <Foundation/Foundation.h>
#include "base/mac/bridging.h"
#include "base/apple/bridging.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
@ -43,7 +43,7 @@ base::ScopedCFTypeRef<CFStringRef> StringImpl::CreateCFString() {
}
StringImpl::operator NSString*() {
return base::mac::CFToNSOwnershipCast(CreateCFString().release());
return base::apple::CFToNSOwnershipCast(CreateCFString().release());
}
} // namespace WTF

@ -723,7 +723,7 @@ _CONFIG = [
'crash_reporter::.*CrashKey.*',
# Useful for platform-specific code.
'base::mac::(CFToNSPtrCast|NSToCFPtrCast|CFToNSOwnershipCast|NSToCFOwnershipCast)',
'base::apple::(CFToNSPtrCast|NSToCFPtrCast|CFToNSOwnershipCast|NSToCFOwnershipCast)',
'base::mac::Is(AtMost|AtLeast)?OS.+',
'base::ScopedCFTypeRef',
],