0

Move foundation_util to base/apple, leave a forwarding header

Crashpad is not yet updated for the new location, so leave a
forwarding header to be removed later.

Skipping trybots. This is a Mac change, and it’s passing all
trybots except for android_optional_gpu_tests_rel that is
repeatedly failing on an unrelated issue.

NOTRY=true

Bug: 1444927
Cq-Include-Trybots: luci.chrome.try:mac-chrome
Change-Id: Iad0c903187b0e1e5584c68f2eb00b5b026085596
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4790744
Owners-Override: Avi Drissman <avi@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1185029}
This commit is contained in:
Avi Drissman
2023-08-18 02:56:21 +00:00
committed by Chromium LUCI CQ
parent 273826f753
commit eac566b060
811 changed files with 2751 additions and 2604 deletions
base
chrome
app
app_shim
browser
app_controller_mac.mmapp_controller_mac_browsertest.mm
apps
autofill
browser_process_platform_part_mac.mmchrome_browser_main_mac.mm
component_updater
download
enterprise
connectors
device_trust
extensions
file_select_helper_mac.mmglobal_keyboard_shortcuts_mac.mmicon_loader_mac.mm
importer
local_discovery
mac
media
media_galleries
memory_details_mac.cc
password_manager
platform_util_mac.mm
policy
safe_browsing
shell_integration_mac.mm
ui
updater
web_applications
common
test
updater
utility
components
autofill
bookmarks
crash
cronet
device_signals
dom_distiller
download
internal
metal_util
metrics
open_from_clipboard
optimization_guide
password_manager
policy
power_metrics
remote_cocoa
services
shared_highlighting
signin
spellcheck
storage_monitor
viz
service
wifi
content
crypto
device
docs/ios
extensions
gin
google_apis
gpu
headless/lib/browser/policy
ios
chrome
app
browser
autofill
browser_state
browsing_data
credential_provider
default_browser
download
drag_and_drop
favicon
find_in_page
flags
metrics
passwords
policy
providers
reading_list
safe_mode
sessions
share_extension
shared
signin
snapshots
tabs
ui
app_store_rating
appearance
authentication
autofill
badges
bookmarks
bring_android_tabs
broadcaster
browser_container
browser_view
bubble
content_suggestions
context_menu
download
find_bar
first_run
fullscreen
history
incognito_interstitial
infobars
keyboard
main
ntp
omnibox
overlays
page_info
partial_translate
passwords
popup_menu
price_notifications
promos_manager
qr_scanner
reading_list
recent_tabs
safe_mode
scanner
search_with
send_tab_to_self
settings
about_chrome_table_view_controller.mm
autofill
bandwidth
cells
clear_browsing_data
content_settings
default_browser
elements
google_services
import_data_table_view_controller.mmimport_data_table_view_controller_unittest.mm
language
notifications
password
privacy
safety_check
search_engine_table_view_controller.mmsearch_engine_table_view_controller_unittest.mmsettings_egtest.mmsettings_navigation_controller.mmsettings_root_table_view_controller.mmsettings_table_view_controller.mmsettings_table_view_controller_unittest.mm
sync
table_cell_catalog_view_controller.mm
tabs
translate_table_view_controller.mmtranslate_table_view_controller_unittest.mmvoice_search_table_view_controller.mmvoice_search_table_view_controller_unittest.mm
sharing
spotlight_debugger
tab_switcher
tabs
toolbar
voice
webui
whats_new
upgrade
voice
web
web_state_list
window_activities
common
content_widget_extension
credential_provider_extension
search_widget_extension
share_extension
test
tools
net
showcase
testing
web
web_view
media
mojo/public/cpp/platform
net
printing
remoting/host
rlz/mac/lib
services
skia/ext
third_party/blink/renderer
tools/mac/power/power_sampler
ui

@ -1953,6 +1953,8 @@ component("base") {
"apple/call_with_eh_frame_asm.S",
"apple/dispatch_source_mach.cc",
"apple/dispatch_source_mach.h",
"apple/foundation_util.h",
"apple/foundation_util.mm",
"apple/mach_logging.cc",
"apple/mach_logging.h",
"apple/osstatus_logging.h",
@ -1975,8 +1977,6 @@ component("base") {
"file_version_info_apple.h",
"file_version_info_apple.mm",
"files/file_util_apple.mm",
"mac/foundation_util.h",
"mac/foundation_util.mm",
"memory/platform_shared_memory_mapper_apple.cc",
"memory/platform_shared_memory_region_apple.cc",
"message_loop/message_pump_apple.h",

6
base/apple/DEPS Normal file

@ -0,0 +1,6 @@
include_rules = [
# base/apple is a base on which base/mac and base/ios build, so don't allow
# dependencies on them.
"-mac",
"-ios",
]

@ -6,9 +6,9 @@
#import <Foundation/Foundation.h>
#include "base/apple/foundation_util.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#include "base/threading/scoped_blocking_call.h"
@ -18,7 +18,7 @@ bool GetBackupExclusion(const FilePath& file_path) {
base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
base::BlockingType::MAY_BLOCK);
NSURL* file_url = mac::FilePathToNSURL(file_path);
NSURL* file_url = apple::FilePathToNSURL(file_path);
DCHECK([file_url checkPromisedItemIsReachableAndReturnError:nil]);
NSError* error = nil;
@ -40,7 +40,7 @@ bool SetBackupState(const FilePath& file_path, bool excluded) {
base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
base::BlockingType::MAY_BLOCK);
NSURL* file_url = mac::FilePathToNSURL(file_path);
NSURL* file_url = apple::FilePathToNSURL(file_path);
DCHECK([file_url checkPromisedItemIsReachableAndReturnError:nil]);
NSError* error = nil;

@ -7,11 +7,11 @@
#include <stddef.h>
#include <stdint.h>
#include "base/apple/foundation_util.h"
#include "base/apple/scoped_cftyperef.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/mac/foundation_util.h"
#include "base/numerics/safe_conversions.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
@ -45,7 +45,7 @@ TEST_F(BackupUtilTest, TestExcludeFileFromBackups_NotByPath) {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
FilePath excluded_file_path = temp_dir_.GetPath().Append("excluded");
base::ScopedCFTypeRef<CFURLRef> excluded_url =
mac::FilePathToCFURL(excluded_file_path);
apple::FilePathToCFURL(excluded_file_path);
constexpr char placeholder_data[] = "All your base are belong to us!";
ASSERT_EQ(checked_cast<int>(std::size(placeholder_data)),

@ -4,8 +4,8 @@
#include "base/apple/bundle_locations.h"
#include "base/apple/foundation_util.h"
#include "base/check.h"
#include "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
namespace base::apple {
@ -26,7 +26,7 @@ NSURL* MainBundleURL() {
}
FilePath MainBundlePath() {
return mac::NSStringToFilePath(MainBundle().bundlePath);
return apple::NSStringToFilePath(MainBundle().bundlePath);
}
NSBundle* OuterBundle() {
@ -41,7 +41,7 @@ NSURL* OuterBundleURL() {
}
FilePath OuterBundlePath() {
return mac::NSStringToFilePath(OuterBundle().bundlePath);
return apple::NSStringToFilePath(OuterBundle().bundlePath);
}
NSBundle* FrameworkBundle() {
@ -52,7 +52,7 @@ NSBundle* FrameworkBundle() {
}
FilePath FrameworkBundlePath() {
return mac::NSStringToFilePath(FrameworkBundle().bundlePath);
return apple::NSStringToFilePath(FrameworkBundle().bundlePath);
}
namespace {
@ -62,7 +62,7 @@ NSBundle* BundleFromPath(const FilePath& file_path) {
return nil;
}
NSBundle* bundle = [NSBundle bundleWithURL:mac::FilePathToNSURL(file_path)];
NSBundle* bundle = [NSBundle bundleWithURL:apple::FilePathToNSURL(file_path)];
CHECK(bundle) << "Failed to load the bundle at " << file_path.value();
return bundle;

@ -0,0 +1,321 @@
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BASE_APPLE_FOUNDATION_UTIL_H_
#define BASE_APPLE_FOUNDATION_UTIL_H_
#include <AvailabilityMacros.h>
#include <CoreFoundation/CoreFoundation.h>
#include <CoreText/CoreText.h>
#include <Security/Security.h>
#include <string>
#include "base/apple/scoped_cftyperef.h"
#include "base/base_export.h"
#include "base/logging.h"
#include "build/build_config.h"
#if defined(__OBJC__)
#import <Foundation/Foundation.h>
@class NSFont;
@class UIFont;
#endif // __OBJC__
namespace base {
class FilePath;
}
namespace base::apple {
// Returns true if the application is running from a bundle
BASE_EXPORT bool AmIBundled();
BASE_EXPORT void SetOverrideAmIBundled(bool value);
#if defined(UNIT_TEST)
// This is required because instantiating some tests requires checking the
// directory structure, which sets the AmIBundled cache state. Individual tests
// may or may not be bundled, and this would trip them up if the cache weren't
// cleared. This should not be called from individual tests, just from test
// instantiation code that gets a path from PathService.
BASE_EXPORT void ClearAmIBundledCache();
#endif
// Returns true if this process is marked as a "Background only process".
BASE_EXPORT bool IsBackgroundOnlyProcess();
// Returns the path to a resource within the framework bundle.
BASE_EXPORT FilePath PathForFrameworkBundleResource(const char* resource_name);
// Returns the creator code associated with the CFBundleRef at bundle.
OSType CreatorCodeForCFBundleRef(CFBundleRef bundle);
// Returns the creator code associated with this application, by calling
// CreatorCodeForCFBundleRef for the application's main bundle. If this
// information cannot be determined, returns kUnknownType ('????'). This
// does not respect the override app bundle because it's based on CFBundle
// instead of NSBundle, and because callers probably don't want the override
// app bundle's creator code anyway.
BASE_EXPORT OSType CreatorCodeForApplication();
#if defined(__OBJC__)
// Searches for directories for the given key in only the given |domain_mask|.
// If found, fills result (which must always be non-NULL) with the
// first found directory and returns true. Otherwise, returns false.
BASE_EXPORT bool GetSearchPathDirectory(NSSearchPathDirectory directory,
NSSearchPathDomainMask domain_mask,
FilePath* result);
// Searches for directories for the given key in only the local domain.
// If found, fills result (which must always be non-NULL) with the
// first found directory and returns true. Otherwise, returns false.
BASE_EXPORT bool GetLocalDirectory(NSSearchPathDirectory directory,
FilePath* result);
// Searches for directories for the given key in only the user domain.
// If found, fills result (which must always be non-NULL) with the
// first found directory and returns true. Otherwise, returns false.
BASE_EXPORT bool GetUserDirectory(NSSearchPathDirectory directory,
FilePath* result);
#endif // __OBJC__
// Returns the ~/Library directory.
BASE_EXPORT FilePath GetUserLibraryPath();
// Returns the ~/Documents directory.
BASE_EXPORT FilePath GetUserDocumentPath();
// Takes a path to an (executable) binary and tries to provide the path to an
// application bundle containing it. It takes the outermost bundle that it can
// find (so for "/Foo/Bar.app/.../Baz.app/..." it produces "/Foo/Bar.app").
// |exec_name| - path to the binary
// returns - path to the application bundle, or empty on error
BASE_EXPORT FilePath GetAppBundlePath(const FilePath& exec_name);
// Takes a path to an (executable) binary and tries to provide the path to an
// application bundle containing it. It takes the innermost bundle that it can
// find (so for "/Foo/Bar.app/.../Baz.app/..." it produces
// "/Foo/Bar.app/.../Baz.app").
// |exec_name| - path to the binary
// returns - path to the application bundle, or empty on error
BASE_EXPORT FilePath GetInnermostAppBundlePath(const FilePath& exec_name);
#define TYPE_NAME_FOR_CF_TYPE_DECL(TypeCF) \
BASE_EXPORT std::string TypeNameForCFType(TypeCF##Ref)
TYPE_NAME_FOR_CF_TYPE_DECL(CFArray);
TYPE_NAME_FOR_CF_TYPE_DECL(CFBag);
TYPE_NAME_FOR_CF_TYPE_DECL(CFBoolean);
TYPE_NAME_FOR_CF_TYPE_DECL(CFData);
TYPE_NAME_FOR_CF_TYPE_DECL(CFDate);
TYPE_NAME_FOR_CF_TYPE_DECL(CFDictionary);
TYPE_NAME_FOR_CF_TYPE_DECL(CFNull);
TYPE_NAME_FOR_CF_TYPE_DECL(CFNumber);
TYPE_NAME_FOR_CF_TYPE_DECL(CFSet);
TYPE_NAME_FOR_CF_TYPE_DECL(CFString);
TYPE_NAME_FOR_CF_TYPE_DECL(CFURL);
TYPE_NAME_FOR_CF_TYPE_DECL(CFUUID);
TYPE_NAME_FOR_CF_TYPE_DECL(CGColor);
TYPE_NAME_FOR_CF_TYPE_DECL(CTFont);
TYPE_NAME_FOR_CF_TYPE_DECL(CTRun);
TYPE_NAME_FOR_CF_TYPE_DECL(SecAccessControl);
TYPE_NAME_FOR_CF_TYPE_DECL(SecCertificate);
TYPE_NAME_FOR_CF_TYPE_DECL(SecKey);
TYPE_NAME_FOR_CF_TYPE_DECL(SecPolicy);
#undef TYPE_NAME_FOR_CF_TYPE_DECL
// Returns the base bundle ID, which can be set by SetBaseBundleID but
// defaults to a reasonable string. This never returns NULL. BaseBundleID
// returns a pointer to static storage that must not be freed.
BASE_EXPORT const char* BaseBundleID();
// Sets the base bundle ID to override the default. The implementation will
// make its own copy of new_base_bundle_id.
BASE_EXPORT void SetBaseBundleID(const char* new_base_bundle_id);
// CFCast<>() and CFCastStrict<>() cast a basic CFTypeRef to a more
// specific CoreFoundation type. The compatibility of the passed
// object is found by comparing its opaque type against the
// requested type identifier. If the supplied object is not
// compatible with the requested return type, CFCast<>() returns
// NULL and CFCastStrict<>() will DCHECK. Providing a NULL pointer
// to either variant results in NULL being returned without
// triggering any DCHECK.
//
// Example usage:
// CFNumberRef some_number = base::apple::CFCast<CFNumberRef>(
// CFArrayGetValueAtIndex(array, index));
//
// CFTypeRef hello = CFSTR("hello world");
// CFStringRef some_string = base::apple::CFCastStrict<CFStringRef>(hello);
template <typename T>
T CFCast(const CFTypeRef& cf_val);
template <typename T>
T CFCastStrict(const CFTypeRef& cf_val);
#define CF_CAST_DECL(TypeCF) \
template <> \
BASE_EXPORT TypeCF##Ref CFCast<TypeCF##Ref>(const CFTypeRef& cf_val); \
\
template <> \
BASE_EXPORT TypeCF##Ref CFCastStrict<TypeCF##Ref>(const CFTypeRef& cf_val)
CF_CAST_DECL(CFArray);
CF_CAST_DECL(CFBag);
CF_CAST_DECL(CFBoolean);
CF_CAST_DECL(CFData);
CF_CAST_DECL(CFDate);
CF_CAST_DECL(CFDictionary);
CF_CAST_DECL(CFNull);
CF_CAST_DECL(CFNumber);
CF_CAST_DECL(CFSet);
CF_CAST_DECL(CFString);
CF_CAST_DECL(CFURL);
CF_CAST_DECL(CFUUID);
CF_CAST_DECL(CGColor);
CF_CAST_DECL(CTFont);
CF_CAST_DECL(CTFontDescriptor);
CF_CAST_DECL(CTRun);
CF_CAST_DECL(SecAccessControl);
CF_CAST_DECL(SecCertificate);
CF_CAST_DECL(SecKey);
CF_CAST_DECL(SecPolicy);
#undef CF_CAST_DECL
#if defined(__OBJC__)
// ObjCCast<>() and ObjCCastStrict<>() cast a basic id to a more
// specific (NSObject-derived) type. The compatibility of the passed
// object is found by checking if it's a kind of the requested type
// identifier. If the supplied object is not compatible with the
// requested return type, ObjCCast<>() returns nil and
// ObjCCastStrict<>() will DCHECK. Providing a nil pointer to either
// variant results in nil being returned without triggering any DCHECK.
//
// The strict variant is useful when retrieving a value from a
// collection which only has values of a specific type, e.g. an
// NSArray of NSStrings. The non-strict variant is useful when
// retrieving values from data that you can't fully control. For
// example, a plist read from disk may be beyond your exclusive
// control, so you'd only want to check that the values you retrieve
// from it are of the expected types, but not crash if they're not.
//
// Example usage:
// NSString* version = base::apple::ObjCCast<NSString>(
// [bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"]);
//
// NSString* str = base::apple::ObjCCastStrict<NSString>(
// [ns_arr_of_ns_strs objectAtIndex:0]);
template <typename T>
T* ObjCCast(id objc_val) {
if ([objc_val isKindOfClass:[T class]]) {
return reinterpret_cast<T*>(objc_val);
}
return nil;
}
template <typename T>
T* ObjCCastStrict(id objc_val) {
T* rv = ObjCCast<T>(objc_val);
DCHECK(objc_val == nil || rv);
return rv;
}
#endif // defined(__OBJC__)
// Helper function for GetValueFromDictionary to create the error message
// that appears when a type mismatch is encountered.
BASE_EXPORT std::string GetValueFromDictionaryErrorMessage(
CFStringRef key,
const std::string& expected_type,
CFTypeRef value);
// Utility function to pull out a value from a dictionary, check its type, and
// return it. Returns NULL if the key is not present or of the wrong type.
template <typename T>
T GetValueFromDictionary(CFDictionaryRef dict, CFStringRef key) {
CFTypeRef value = CFDictionaryGetValue(dict, key);
T value_specific = CFCast<T>(value);
if (value && !value_specific) {
std::string expected_type = TypeNameForCFType(value_specific);
DLOG(WARNING) << GetValueFromDictionaryErrorMessage(key, expected_type,
value);
}
return value_specific;
}
#if defined(__OBJC__)
// Converts |path| to an autoreleased NSURL. Returns nil if |path| is empty.
BASE_EXPORT NSURL* FilePathToNSURL(const FilePath& path);
// Converts |path| to an autoreleased NSString. Returns nil if |path| is empty.
BASE_EXPORT NSString* FilePathToNSString(const FilePath& path);
// Converts |str| to a FilePath. Returns an empty path if |str| is nil.
BASE_EXPORT FilePath NSStringToFilePath(NSString* str);
// Converts |url| to a FilePath. Returns an empty path if |url| is nil or if
// |url| is not of scheme "file".
BASE_EXPORT FilePath NSURLToFilePath(NSURL* url);
#endif // __OBJC__
// Converts a non-null |path| to a CFURLRef. |path| must not be empty.
//
// This function only uses manually-owned resources, so it does not depend on an
// NSAutoreleasePool being set up on the current thread.
BASE_EXPORT ScopedCFTypeRef<CFURLRef> FilePathToCFURL(const FilePath& path);
#if defined(__OBJC__)
// Converts |range| to an NSRange, returning the new range in |range_out|.
// Returns true if conversion was successful, false if the values of |range|
// could not be converted to NSUIntegers.
[[nodiscard]] BASE_EXPORT bool CFRangeToNSRange(CFRange range,
NSRange* range_out);
#endif // defined(__OBJC__)
} // namespace base::apple
// Stream operations for CFTypes. They can be used with Objective-C types as
// well by using the casting methods in base/apple/bridging.h.
//
// For example: LOG(INFO) << base::apple::NSToCFPtrCast(@"foo");
//
// operator<<() can not be overloaded for Objective-C types as the compiler
// cannot distinguish between overloads for id with overloads for void*.
BASE_EXPORT extern std::ostream& operator<<(std::ostream& o,
const CFErrorRef err);
BASE_EXPORT extern std::ostream& operator<<(std::ostream& o,
const CFStringRef str);
BASE_EXPORT extern std::ostream& operator<<(std::ostream& o, CFRange);
#if defined(__OBJC__)
BASE_EXPORT extern std::ostream& operator<<(std::ostream& o, id);
BASE_EXPORT extern std::ostream& operator<<(std::ostream& o, NSRange);
BASE_EXPORT extern std::ostream& operator<<(std::ostream& o, SEL);
#if BUILDFLAG(IS_MAC)
BASE_EXPORT extern std::ostream& operator<<(std::ostream& o, NSPoint);
BASE_EXPORT extern std::ostream& operator<<(std::ostream& o, NSRect);
BASE_EXPORT extern std::ostream& operator<<(std::ostream& o, NSSize);
#endif // IS_MAC
#endif // __OBJC__
#endif // BASE_APPLE_FOUNDATION_UTIL_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
#include <stddef.h>
#include <stdlib.h>
@ -32,7 +32,7 @@ extern "C" {
CFTypeID SecKeyGetTypeID();
} // extern "C"
namespace base::mac {
namespace base::apple {
namespace {
@ -46,8 +46,9 @@ bool UncachedAmIBundled() {
// All apps are bundled on iOS.
return true;
#else
if (g_override_am_i_bundled)
if (g_override_am_i_bundled) {
return g_override_am_i_bundled_value;
}
// Yes, this is cheap.
return [apple::OuterBundle().bundlePath hasSuffix:@".app"];
@ -74,8 +75,9 @@ bool AmIBundled() {
void SetOverrideAmIBundled(bool value) {
#if BUILDFLAG(IS_IOS)
// It doesn't make sense not to be bundled on iOS.
if (!value)
if (!value) {
NOTREACHED();
}
#endif
g_override_am_i_bundled = true;
g_override_am_i_bundled_value = value;
@ -110,8 +112,9 @@ OSType CreatorCodeForCFBundleRef(CFBundleRef bundle) {
OSType CreatorCodeForApplication() {
CFBundleRef bundle = CFBundleGetMainBundle();
if (!bundle)
if (!bundle) {
return kUnknownType;
}
return CreatorCodeForCFBundleRef(bundle);
}
@ -166,8 +169,9 @@ FilePath GetAppBundlePath(const FilePath& exec_name) {
std::vector<std::string> components = exec_name.GetComponents();
// It's an error if we don't get any components.
if (components.empty())
if (components.empty()) {
return FilePath();
}
// Don't prepend '/' to the first component.
std::vector<std::string>::const_iterator it = components.begin();
@ -175,13 +179,15 @@ FilePath GetAppBundlePath(const FilePath& exec_name) {
DCHECK_GT(it->length(), 0U);
// If the first component ends in ".app", we're already done.
if (it->length() > kExtLength &&
!it->compare(it->length() - kExtLength, kExtLength, kExt, kExtLength))
!it->compare(it->length() - kExtLength, kExtLength, kExt, kExtLength)) {
return FilePath(bundle_name);
}
// The first component may be "/" or "//", etc. Only append '/' if it doesn't
// already end in '/'.
if (bundle_name.back() != '/')
if (bundle_name.back() != '/') {
bundle_name += '/';
}
// Go through the remaining components.
for (++it; it != components.end(); ++it) {
@ -191,8 +197,9 @@ FilePath GetAppBundlePath(const FilePath& exec_name) {
// If the current component ends in ".app", we're done.
if (it->length() > kExtLength &&
!it->compare(it->length() - kExtLength, kExtLength, kExt, kExtLength))
!it->compare(it->length() - kExtLength, kExtLength, kExt, kExtLength)) {
return FilePath(bundle_name);
}
// Separate this component from the next one.
bundle_name += '/';
@ -246,10 +253,10 @@ FilePath GetInnermostAppBundlePath(const FilePath& exec_name) {
return FilePath(bundle_path);
}
#define TYPE_NAME_FOR_CF_TYPE_DEFN(TypeCF) \
std::string TypeNameForCFType(TypeCF##Ref) { \
return #TypeCF; \
}
#define TYPE_NAME_FOR_CF_TYPE_DEFN(TypeCF) \
std::string TypeNameForCFType(TypeCF##Ref) { \
return #TypeCF; \
}
TYPE_NAME_FOR_CF_TYPE_DEFN(CFArray)
TYPE_NAME_FOR_CF_TYPE_DEFN(CFBag)
@ -299,24 +306,24 @@ void SetBaseBundleID(const char* new_base_bundle_id) {
}
}
#define CF_CAST_DEFN(TypeCF) \
template<> TypeCF##Ref \
CFCast<TypeCF##Ref>(const CFTypeRef& cf_val) { \
if (cf_val == NULL) { \
return NULL; \
} \
if (CFGetTypeID(cf_val) == TypeCF##GetTypeID()) { \
return (TypeCF##Ref)(cf_val); \
} \
return NULL; \
} \
\
template<> TypeCF##Ref \
CFCastStrict<TypeCF##Ref>(const CFTypeRef& cf_val) { \
TypeCF##Ref rv = CFCast<TypeCF##Ref>(cf_val); \
DCHECK(cf_val == NULL || rv); \
return rv; \
}
#define CF_CAST_DEFN(TypeCF) \
template <> \
TypeCF##Ref CFCast<TypeCF##Ref>(const CFTypeRef& cf_val) { \
if (cf_val == NULL) { \
return NULL; \
} \
if (CFGetTypeID(cf_val) == TypeCF##GetTypeID()) { \
return (TypeCF##Ref)(cf_val); \
} \
return NULL; \
} \
\
template <> \
TypeCF##Ref CFCastStrict<TypeCF##Ref>(const CFTypeRef& cf_val) { \
TypeCF##Ref rv = CFCast<TypeCF##Ref>(cf_val); \
DCHECK(cf_val == NULL || rv); \
return rv; \
}
CF_CAST_DEFN(CFArray)
CF_CAST_DEFN(CFBag)
@ -347,8 +354,9 @@ CF_CAST_DEFN(SecPolicy)
#undef CF_CAST_DEFN
std::string GetValueFromDictionaryErrorMessage(
CFStringRef key, const std::string& expected_type, CFTypeRef value) {
std::string GetValueFromDictionaryErrorMessage(CFStringRef key,
const std::string& expected_type,
CFTypeRef value) {
ScopedCFTypeRef<CFStringRef> actual_type_ref(
CFCopyTypeIDDescription(CFGetTypeID(value)));
return "Expected value for key " + SysCFStringRefToUTF8(key) + " to be " +
@ -357,14 +365,16 @@ std::string GetValueFromDictionaryErrorMessage(
}
NSURL* FilePathToNSURL(const FilePath& path) {
if (NSString* path_string = FilePathToNSString(path))
if (NSString* path_string = FilePathToNSString(path)) {
return [NSURL fileURLWithPath:path_string];
}
return nil;
}
NSString* FilePathToNSString(const FilePath& path) {
if (path.empty())
if (path.empty()) {
return nil;
}
return @(path.value().c_str()); // @() does UTF8 conversion.
}
@ -393,8 +403,9 @@ ScopedCFTypeRef<CFURLRef> FilePathToCFURL(const FilePath& path) {
kCFAllocatorDefault, reinterpret_cast<const UInt8*>(path_string.data()),
checked_cast<CFIndex>(path_string.length()), kCFStringEncodingUTF8,
/*isExternalRepresentation=*/FALSE));
if (!path_cfstring)
if (!path_cfstring) {
return ScopedCFTypeRef<CFURLRef>();
}
return ScopedCFTypeRef<CFURLRef>(CFURLCreateWithFileSystemPath(
kCFAllocatorDefault, path_cfstring, kCFURLPOSIXPathStyle,
@ -414,7 +425,7 @@ bool CFRangeToNSRange(CFRange range, NSRange* range_out) {
return false;
}
} // namespace base::mac
} // namespace base::apple
std::ostream& operator<<(std::ostream& o, const CFStringRef string) {
return o << base::SysCFStringRefToUTF8(string);
@ -428,10 +439,9 @@ std::ostream& operator<<(std::ostream& o, const CFErrorRef err) {
errorDesc = reinterpret_cast<CFStringRef>(
CFDictionaryGetValue(user_info.get(), kCFErrorDescriptionKey));
}
o << "Code: " << CFErrorGetCode(err)
<< " Domain: " << CFErrorGetDomain(err)
o << "Code: " << CFErrorGetCode(err) << " Domain: " << CFErrorGetDomain(err)
<< " Desc: " << desc.get();
if(errorDesc) {
if (errorDesc) {
o << "(" << errorDesc << ")";
}
return o;

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
#include <CoreFoundation/CoreFoundation.h>
#include <Foundation/Foundation.h>
@ -17,7 +17,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#import "testing/gtest_mac.h"
namespace base::mac {
namespace base::apple {
TEST(FoundationUtilTest, CFCast) {
// Build out the CF types to be tested as empty containers.
@ -418,4 +418,4 @@ TEST(FoundationLoggingTest, NSRange) {
EXPECT_LOG_EQ("{0, 100}", NSMakeRange(0, 100));
}
} // namespace base::mac
} // namespace base::apple

@ -8,11 +8,11 @@
#import <Foundation/Foundation.h>
#include "base/apple/bundle_locations.h"
#include "base/apple/foundation_util.h"
#include "base/base_paths.h"
#include "base/base_paths_apple.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/mac/foundation_util.h"
#include "base/path_service.h"
namespace base {
@ -25,7 +25,8 @@ bool PathProviderIOS(int key, base::FilePath* result) {
case base::DIR_APP_DATA: {
base::FilePath path;
if (!base::mac::GetUserDirectory(NSApplicationSupportDirectory, &path)) {
if (!base::apple::GetUserDirectory(NSApplicationSupportDirectory,
&path)) {
return false;
}
@ -58,7 +59,7 @@ bool PathProviderIOS(int key, base::FilePath* result) {
return true;
case base::DIR_CACHE:
return base::mac::GetUserDirectory(NSCachesDirectory, result);
return base::apple::GetUserDirectory(NSCachesDirectory, result);
default:
return false;

@ -8,11 +8,11 @@
#import <Foundation/Foundation.h>
#include "base/apple/bundle_locations.h"
#include "base/apple/foundation_util.h"
#include "base/base_paths.h"
#include "base/base_paths_apple.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/mac/foundation_util.h"
#include "base/notreached.h"
#include "base/path_service.h"
@ -28,7 +28,7 @@ bool PathProviderMac(int key, base::FilePath* result) {
result, reinterpret_cast<const void*>(&base::PathProviderMac));
case base::DIR_APP_DATA: {
bool success =
base::mac::GetUserDirectory(NSApplicationSupportDirectory, result);
base::apple::GetUserDirectory(NSApplicationSupportDirectory, result);
return success;
}
case base::DIR_SRC_TEST_DATA_ROOT:
@ -40,7 +40,7 @@ bool PathProviderMac(int key, base::FilePath* result) {
// Start with the executable's directory.
*result = result->DirName();
if (base::mac::AmIBundled()) {
if (base::apple::AmIBundled()) {
// The bundled app executables (Chromium, TestShell, etc) live five
// levels down, eg:
// src/xcodebuild/{Debug|Release}/Chromium.app/Contents/MacOS/Chromium
@ -52,16 +52,16 @@ bool PathProviderMac(int key, base::FilePath* result) {
}
return true;
case base::DIR_USER_DESKTOP:
return base::mac::GetUserDirectory(NSDesktopDirectory, result);
return base::apple::GetUserDirectory(NSDesktopDirectory, result);
case base::DIR_ASSETS:
if (!base::mac::AmIBundled()) {
if (!base::apple::AmIBundled()) {
return PathService::Get(base::DIR_MODULE, result);
}
*result = base::apple::FrameworkBundlePath().Append(
FILE_PATH_LITERAL("Resources"));
return true;
case base::DIR_CACHE:
return base::mac::GetUserDirectory(NSCachesDirectory, result);
return base::apple::GetUserDirectory(NSCachesDirectory, result);
default:
return false;
}

@ -9,8 +9,8 @@
#include <string>
#include <vector>
#include "base/apple/foundation_util.h"
#include "base/logging.h"
#include "base/mac/foundation_util.h"
#include "base/process/launch.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
@ -181,12 +181,13 @@ DeviceUserDomainJoinState AreDeviceAndUserJoinedToDomain() {
}
for (id element in results) {
ODRecord* record = mac::ObjCCastStrict<ODRecord>(element);
ODRecord* record = base::apple::ObjCCastStrict<ODRecord>(element);
NSArray* attributes =
[record valuesForAttribute:kODAttributeTypeMetaRecordName
error:nil];
for (id attribute in attributes) {
NSString* attribute_value = mac::ObjCCastStrict<NSString>(attribute);
NSString* attribute_value =
base::apple::ObjCCastStrict<NSString>(attribute);
// Example: "uid=johnsmith,ou=People,dc=chromium,dc=org
NSRange domain_controller =
[attribute_value rangeOfString:@"(^|,)\\s*dc="
@ -201,7 +202,8 @@ DeviceUserDomainJoinState AreDeviceAndUserJoinedToDomain() {
[record valuesForAttribute:kODAttributeTypeAltSecurityIdentities
error:nil];
for (id attribute in attributes) {
NSString* attribute_value = mac::ObjCCastStrict<NSString>(attribute);
NSString* attribute_value =
base::apple::ObjCCastStrict<NSString>(attribute);
NSRange icloud =
[attribute_value rangeOfString:@"CN=com.apple.idms.appleid.prd"
options:NSCaseInsensitiveSearch];

@ -8,8 +8,8 @@
#include "base/apple/bridging.h"
#include "base/apple/bundle_locations.h"
#include "base/apple/foundation_util.h"
#include "base/files/file_path.h"
#include "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#include "build/build_config.h"

@ -9,9 +9,9 @@
#include <stdlib.h>
#include <string.h>
#include "base/apple/foundation_util.h"
#include "base/check_op.h"
#include "base/files/file_path.h"
#include "base/mac/foundation_util.h"
#include "base/strings/string_util.h"
#include "base/threading/scoped_blocking_call.h"
@ -45,14 +45,14 @@ bool GetTempDir(base::FilePath* path) {
if (tmp == nil) {
return false;
}
*path = base::mac::NSStringToFilePath(tmp);
*path = base::apple::NSStringToFilePath(tmp);
return true;
}
FilePath GetHomeDir() {
NSString* tmp = NSHomeDirectory();
if (tmp != nil) {
FilePath mac_home_dir = base::mac::NSStringToFilePath(tmp);
FilePath mac_home_dir = base::apple::NSStringToFilePath(tmp);
if (!mac_home_dir.empty()) {
return mac_home_dir;
}

@ -51,7 +51,7 @@
#if BUILDFLAG(IS_APPLE)
#include <AvailabilityMacros.h>
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
#endif
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
@ -690,7 +690,7 @@ bool CreateTemporaryFileInDir(const FilePath& dir, FilePath* temp_file) {
FilePath FormatTemporaryFileName(FilePath::StringPieceType identifier) {
#if BUILDFLAG(IS_APPLE)
StringPiece prefix = base::mac::BaseBundleID();
StringPiece prefix = base::apple::BaseBundleID();
#elif BUILDFLAG(GOOGLE_CHROME_BRANDING)
StringPiece prefix = "com.google.Chrome";
#else

@ -40,7 +40,7 @@
#endif
#if BUILDFLAG(IS_APPLE)
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
#endif
#if BUILDFLAG(IS_FUCHSIA)
@ -167,7 +167,7 @@ void LazyInitIcuDataFile() {
#else // !BUILDFLAG(IS_APPLE)
// Assume it is in the framework bundle's Resources directory.
FilePath data_path = mac::PathForFrameworkBundleResource(kIcuDataFileName);
FilePath data_path = apple::PathForFrameworkBundleResource(kIcuDataFileName);
#if BUILDFLAG(IS_IOS)
FilePath override_data_path = ios::FilePathOfEmbeddedICU();
if (!override_data_path.empty()) {

@ -8,8 +8,8 @@
#import <UIKit/UIKit.h>
#include <stddef.h>
#include "base/apple/foundation_util.h"
#import "base/ios/device_util.h"
#include "base/mac/foundation_util.h"
#include "base/system/sys_info.h"
namespace {

@ -11,9 +11,9 @@
#include <string>
#include "base/apple/bundle_locations.h"
#include "base/apple/foundation_util.h"
#include "base/apple/osstatus_logging.h"
#include "base/logging.h"
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_authorizationref.h"
#include "base/posix/eintr_wrapper.h"
#include "base/strings/string_number_conversions.h"

@ -1,320 +1,43 @@
// Copyright 2012 The Chromium Authors
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BASE_MAC_FOUNDATION_UTIL_H_
#define BASE_MAC_FOUNDATION_UTIL_H_
#include <AvailabilityMacros.h>
#include <CoreFoundation/CoreFoundation.h>
#include <CoreText/CoreText.h>
#include <Security/Security.h>
#include <string>
#include "base/apple/scoped_cftyperef.h"
#include "base/base_export.h"
#include "base/logging.h"
#include "build/build_config.h"
#include "base/apple/foundation_util.h"
#if defined(__OBJC__)
#import <Foundation/Foundation.h>
@class NSFont;
@class UIFont;
#endif // __OBJC__
namespace base {
class FilePath;
}
// This is a forwarding header so that Crashpad can continue to build correctly
// until mini_chromium and then it are updated and rolled.
// TODO(https://crbug.com/1444927): Update mini_chromium, update Crashpad, roll
// Crashpad, and then delete this forwarding header.
namespace base::mac {
// Returns true if the application is running from a bundle
BASE_EXPORT bool AmIBundled();
BASE_EXPORT void SetOverrideAmIBundled(bool value);
template <typename T>
T CFCast(const CFTypeRef& cf_val) {
return base::apple::CFCast<T>(cf_val);
}
#if defined(UNIT_TEST)
// This is required because instantiating some tests requires checking the
// directory structure, which sets the AmIBundled cache state. Individual tests
// may or may not be bundled, and this would trip them up if the cache weren't
// cleared. This should not be called from individual tests, just from test
// instantiation code that gets a path from PathService.
BASE_EXPORT void ClearAmIBundledCache();
#endif
// Returns true if this process is marked as a "Background only process".
BASE_EXPORT bool IsBackgroundOnlyProcess();
// Returns the path to a resource within the framework bundle.
BASE_EXPORT FilePath PathForFrameworkBundleResource(const char* resource_name);
// Returns the creator code associated with the CFBundleRef at bundle.
OSType CreatorCodeForCFBundleRef(CFBundleRef bundle);
// Returns the creator code associated with this application, by calling
// CreatorCodeForCFBundleRef for the application's main bundle. If this
// information cannot be determined, returns kUnknownType ('????'). This
// does not respect the override app bundle because it's based on CFBundle
// instead of NSBundle, and because callers probably don't want the override
// app bundle's creator code anyway.
BASE_EXPORT OSType CreatorCodeForApplication();
template <typename T>
T CFCastStrict(const CFTypeRef& cf_val) {
return base::apple::CFCastStrict<T>(cf_val);
}
#if defined(__OBJC__)
// Searches for directories for the given key in only the given |domain_mask|.
// If found, fills result (which must always be non-NULL) with the
// first found directory and returns true. Otherwise, returns false.
BASE_EXPORT bool GetSearchPathDirectory(NSSearchPathDirectory directory,
NSSearchPathDomainMask domain_mask,
FilePath* result);
// Searches for directories for the given key in only the local domain.
// If found, fills result (which must always be non-NULL) with the
// first found directory and returns true. Otherwise, returns false.
BASE_EXPORT bool GetLocalDirectory(NSSearchPathDirectory directory,
FilePath* result);
// Searches for directories for the given key in only the user domain.
// If found, fills result (which must always be non-NULL) with the
// first found directory and returns true. Otherwise, returns false.
BASE_EXPORT bool GetUserDirectory(NSSearchPathDirectory directory,
FilePath* result);
#endif // __OBJC__
// Returns the ~/Library directory.
BASE_EXPORT FilePath GetUserLibraryPath();
// Returns the ~/Documents directory.
BASE_EXPORT FilePath GetUserDocumentPath();
// Takes a path to an (executable) binary and tries to provide the path to an
// application bundle containing it. It takes the outermost bundle that it can
// find (so for "/Foo/Bar.app/.../Baz.app/..." it produces "/Foo/Bar.app").
// |exec_name| - path to the binary
// returns - path to the application bundle, or empty on error
BASE_EXPORT FilePath GetAppBundlePath(const FilePath& exec_name);
// Takes a path to an (executable) binary and tries to provide the path to an
// application bundle containing it. It takes the innermost bundle that it can
// find (so for "/Foo/Bar.app/.../Baz.app/..." it produces
// "/Foo/Bar.app/.../Baz.app").
// |exec_name| - path to the binary
// returns - path to the application bundle, or empty on error
BASE_EXPORT FilePath GetInnermostAppBundlePath(const FilePath& exec_name);
#define TYPE_NAME_FOR_CF_TYPE_DECL(TypeCF) \
BASE_EXPORT std::string TypeNameForCFType(TypeCF##Ref)
TYPE_NAME_FOR_CF_TYPE_DECL(CFArray);
TYPE_NAME_FOR_CF_TYPE_DECL(CFBag);
TYPE_NAME_FOR_CF_TYPE_DECL(CFBoolean);
TYPE_NAME_FOR_CF_TYPE_DECL(CFData);
TYPE_NAME_FOR_CF_TYPE_DECL(CFDate);
TYPE_NAME_FOR_CF_TYPE_DECL(CFDictionary);
TYPE_NAME_FOR_CF_TYPE_DECL(CFNull);
TYPE_NAME_FOR_CF_TYPE_DECL(CFNumber);
TYPE_NAME_FOR_CF_TYPE_DECL(CFSet);
TYPE_NAME_FOR_CF_TYPE_DECL(CFString);
TYPE_NAME_FOR_CF_TYPE_DECL(CFURL);
TYPE_NAME_FOR_CF_TYPE_DECL(CFUUID);
TYPE_NAME_FOR_CF_TYPE_DECL(CGColor);
TYPE_NAME_FOR_CF_TYPE_DECL(CTFont);
TYPE_NAME_FOR_CF_TYPE_DECL(CTRun);
TYPE_NAME_FOR_CF_TYPE_DECL(SecAccessControl);
TYPE_NAME_FOR_CF_TYPE_DECL(SecCertificate);
TYPE_NAME_FOR_CF_TYPE_DECL(SecKey);
TYPE_NAME_FOR_CF_TYPE_DECL(SecPolicy);
#undef TYPE_NAME_FOR_CF_TYPE_DECL
// Returns the base bundle ID, which can be set by SetBaseBundleID but
// defaults to a reasonable string. This never returns NULL. BaseBundleID
// returns a pointer to static storage that must not be freed.
BASE_EXPORT const char* BaseBundleID();
// Sets the base bundle ID to override the default. The implementation will
// make its own copy of new_base_bundle_id.
BASE_EXPORT void SetBaseBundleID(const char* new_base_bundle_id);
// CFCast<>() and CFCastStrict<>() cast a basic CFTypeRef to a more
// specific CoreFoundation type. The compatibility of the passed
// object is found by comparing its opaque type against the
// requested type identifier. If the supplied object is not
// compatible with the requested return type, CFCast<>() returns
// NULL and CFCastStrict<>() will DCHECK. Providing a NULL pointer
// to either variant results in NULL being returned without
// triggering any DCHECK.
//
// Example usage:
// CFNumberRef some_number = base::mac::CFCast<CFNumberRef>(
// CFArrayGetValueAtIndex(array, index));
//
// CFTypeRef hello = CFSTR("hello world");
// CFStringRef some_string = base::mac::CFCastStrict<CFStringRef>(hello);
template<typename T>
T CFCast(const CFTypeRef& cf_val);
template<typename T>
T CFCastStrict(const CFTypeRef& cf_val);
#define CF_CAST_DECL(TypeCF) \
template <> \
BASE_EXPORT TypeCF##Ref CFCast<TypeCF##Ref>(const CFTypeRef& cf_val); \
\
template <> \
BASE_EXPORT TypeCF##Ref CFCastStrict<TypeCF##Ref>(const CFTypeRef& cf_val)
CF_CAST_DECL(CFArray);
CF_CAST_DECL(CFBag);
CF_CAST_DECL(CFBoolean);
CF_CAST_DECL(CFData);
CF_CAST_DECL(CFDate);
CF_CAST_DECL(CFDictionary);
CF_CAST_DECL(CFNull);
CF_CAST_DECL(CFNumber);
CF_CAST_DECL(CFSet);
CF_CAST_DECL(CFString);
CF_CAST_DECL(CFURL);
CF_CAST_DECL(CFUUID);
CF_CAST_DECL(CGColor);
CF_CAST_DECL(CTFont);
CF_CAST_DECL(CTFontDescriptor);
CF_CAST_DECL(CTRun);
CF_CAST_DECL(SecAccessControl);
CF_CAST_DECL(SecCertificate);
CF_CAST_DECL(SecKey);
CF_CAST_DECL(SecPolicy);
#undef CF_CAST_DECL
#if defined(__OBJC__)
// ObjCCast<>() and ObjCCastStrict<>() cast a basic id to a more
// specific (NSObject-derived) type. The compatibility of the passed
// object is found by checking if it's a kind of the requested type
// identifier. If the supplied object is not compatible with the
// requested return type, ObjCCast<>() returns nil and
// ObjCCastStrict<>() will DCHECK. Providing a nil pointer to either
// variant results in nil being returned without triggering any DCHECK.
//
// The strict variant is useful when retrieving a value from a
// collection which only has values of a specific type, e.g. an
// NSArray of NSStrings. The non-strict variant is useful when
// retrieving values from data that you can't fully control. For
// example, a plist read from disk may be beyond your exclusive
// control, so you'd only want to check that the values you retrieve
// from it are of the expected types, but not crash if they're not.
//
// Example usage:
// NSString* version = base::mac::ObjCCast<NSString>(
// [bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"]);
//
// NSString* str = base::mac::ObjCCastStrict<NSString>(
// [ns_arr_of_ns_strs objectAtIndex:0]);
template<typename T>
template <typename T>
T* ObjCCast(id objc_val) {
if ([objc_val isKindOfClass:[T class]]) {
return reinterpret_cast<T*>(objc_val);
}
return nil;
return base::apple::ObjCCast<T>(objc_val);
}
template<typename T>
T* ObjCCastStrict(id objc_val) {
T* rv = ObjCCast<T>(objc_val);
DCHECK(objc_val == nil || rv);
return rv;
}
#endif // defined(__OBJC__)
// Helper function for GetValueFromDictionary to create the error message
// that appears when a type mismatch is encountered.
BASE_EXPORT std::string GetValueFromDictionaryErrorMessage(
CFStringRef key, const std::string& expected_type, CFTypeRef value);
// Utility function to pull out a value from a dictionary, check its type, and
// return it. Returns NULL if the key is not present or of the wrong type.
template<typename T>
T GetValueFromDictionary(CFDictionaryRef dict, CFStringRef key) {
CFTypeRef value = CFDictionaryGetValue(dict, key);
T value_specific = CFCast<T>(value);
if (value && !value_specific) {
std::string expected_type = TypeNameForCFType(value_specific);
DLOG(WARNING) << GetValueFromDictionaryErrorMessage(key,
expected_type,
value);
}
return value_specific;
}
#if defined(__OBJC__)
// Converts |path| to an autoreleased NSURL. Returns nil if |path| is empty.
BASE_EXPORT NSURL* FilePathToNSURL(const FilePath& path);
// Converts |path| to an autoreleased NSString. Returns nil if |path| is empty.
BASE_EXPORT NSString* FilePathToNSString(const FilePath& path);
// Converts |str| to a FilePath. Returns an empty path if |str| is nil.
BASE_EXPORT FilePath NSStringToFilePath(NSString* str);
// Converts |url| to a FilePath. Returns an empty path if |url| is nil or if
// |url| is not of scheme "file".
BASE_EXPORT FilePath NSURLToFilePath(NSURL* url);
#endif // __OBJC__
// Converts a non-null |path| to a CFURLRef. |path| must not be empty.
//
// This function only uses manually-owned resources, so it does not depend on an
// NSAutoreleasePool being set up on the current thread.
BASE_EXPORT ScopedCFTypeRef<CFURLRef> FilePathToCFURL(const FilePath& path);
#if defined(__OBJC__)
// Converts |range| to an NSRange, returning the new range in |range_out|.
// Returns true if conversion was successful, false if the values of |range|
// could not be converted to NSUIntegers.
[[nodiscard]] BASE_EXPORT bool CFRangeToNSRange(CFRange range,
NSRange* range_out);
#endif // defined(__OBJC__)
} // namespace base::mac
// Stream operations for CFTypes. They can be used with Objective-C types as
// well by using the casting methods in base/apple/bridging.h.
//
// For example: LOG(INFO) << base::apple::NSToCFPtrCast(@"foo");
//
// operator<<() can not be overloaded for Objective-C types as the compiler
// cannot distinguish between overloads for id with overloads for void*.
BASE_EXPORT extern std::ostream& operator<<(std::ostream& o,
const CFErrorRef err);
BASE_EXPORT extern std::ostream& operator<<(std::ostream& o,
const CFStringRef str);
BASE_EXPORT extern std::ostream& operator<<(std::ostream& o, CFRange);
#if defined(__OBJC__)
BASE_EXPORT extern std::ostream& operator<<(std::ostream& o, id);
BASE_EXPORT extern std::ostream& operator<<(std::ostream& o, NSRange);
BASE_EXPORT extern std::ostream& operator<<(std::ostream& o, SEL);
#if BUILDFLAG(IS_MAC)
BASE_EXPORT extern std::ostream& operator<<(std::ostream& o, NSPoint);
BASE_EXPORT extern std::ostream& operator<<(std::ostream& o, NSRect);
BASE_EXPORT extern std::ostream& operator<<(std::ostream& o, NSSize);
#endif // IS_MAC
#endif // __OBJC__
#endif // BASE_MAC_FOUNDATION_UTIL_H_

@ -5,10 +5,10 @@
#import "base/mac/launch_application.h"
#include "base/apple/bridging.h"
#include "base/apple/foundation_util.h"
#include "base/command_line.h"
#include "base/functional/callback.h"
#include "base/logging.h"
#include "base/mac/foundation_util.h"
#include "base/mac/launch_services_spi.h"
#include "base/mac/mac_util.h"
#include "base/metrics/histogram_functions.h"
@ -128,7 +128,7 @@ void LogResultAndInvokeCallback(const base::FilePath& app_bundle_path,
NSArray<NSRunningApplication*>* all_apps =
NSWorkspace.sharedWorkspace.runningApplications;
for (NSRunningApplication* running_app in all_apps) {
if (NSURLToFilePath(running_app.bundleURL) == app_bundle_path) {
if (apple::NSURLToFilePath(running_app.bundleURL) == app_bundle_path) {
LOG(ERROR) << "Launch succeeded despite error: "
<< base::SysNSStringToUTF8(error.localizedDescription);
app = running_app;
@ -163,7 +163,7 @@ void LaunchApplication(const base::FilePath& app_bundle_path,
base::BindOnce(&LogResultAndInvokeCallback, app_bundle_path,
options.create_new_instance, std::move(callback));
NSURL* bundle_url = FilePathToNSURL(app_bundle_path);
NSURL* bundle_url = apple::FilePathToNSURL(app_bundle_path);
if (!bundle_url) {
dispatch_async(dispatch_get_main_queue(), ^{
std::move(callback_block_access)
@ -199,7 +199,7 @@ void LaunchApplication(const base::FilePath& app_bundle_path,
_LSOpenURLsWithCompletionHandler(
base::apple::NSToCFPtrCast(ns_urls ? ns_urls : @[]),
mac::FilePathToCFURL(app_bundle_path),
apple::FilePathToCFURL(app_bundle_path),
base::apple::NSToCFPtrCast(GetOpenOptions(options, command_line_args)),
action_block);
return;

@ -7,13 +7,13 @@
#include <sys/select.h>
#include "base/apple/bridging.h"
#include "base/apple/foundation_util.h"
#include "base/base_paths.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/mac/foundation_util.h"
#include "base/mac/mac_util.h"
#include "base/path_service.h"
#include "base/process/launch.h"
@ -53,7 +53,7 @@ void ReadLaunchEventsFromFifo(
while ((end_of_plist = data.find("</plist>")) != std::string::npos) {
std::string plist = data.substr(0, end_of_plist + 8);
data = data.substr(plist.length());
NSDictionary* event = ObjCCastStrict<NSDictionary>(
NSDictionary* event = apple::ObjCCastStrict<NSDictionary>(
SysUTF8ToNSString(TrimWhitespaceASCII(plist, TRIM_ALL))
.propertyList);
callback.Run(event);
@ -107,7 +107,7 @@ class LaunchApplicationTest : public testing::Test {
// base::CreateDirectory() routine forces mode 0700.
NSError* error = nil;
ASSERT_TRUE([NSFileManager.defaultManager
createDirectoryAtURL:base::mac::FilePathToNSURL(
createDirectoryAtURL:base::apple::FilePathToNSURL(
destination_executable_path)
withIntermediateDirectories:YES
attributes:@{
@ -138,16 +138,16 @@ class LaunchApplicationTest : public testing::Test {
// Generate the Plist file
NSDictionary* plist = @{
@"CFBundleExecutable" :
FilePathToNSString(helper_app_executable.BaseName()),
apple::FilePathToNSString(helper_app_executable.BaseName()),
@"CFBundleIdentifier" : helper_bundle_id_,
};
ASSERT_TRUE([plist
writeToURL:FilePathToNSURL(
writeToURL:apple::FilePathToNSURL(
destination_contents_path.AppendASCII("Info.plist"))
error:nil]);
// Register the app with LaunchServices.
LSRegisterURL(base::mac::FilePathToCFURL(helper_app_bundle_path_), true);
LSRegisterURL(base::apple::FilePathToCFURL(helper_app_bundle_path_), true);
// Ensure app was registered with LaunchServices. Sometimes it takes a
// little bit of time for this to happen, and some tests might fail if the
@ -193,7 +193,8 @@ class LaunchApplicationTest : public testing::Test {
NSArray<NSRunningApplication*>* apps =
NSWorkspace.sharedWorkspace.runningApplications;
for (NSRunningApplication* app in apps) {
if (temp_dir_.GetPath().IsParent(NSURLToFilePath(app.bundleURL)) ||
if (temp_dir_.GetPath().IsParent(
apple::NSURLToFilePath(app.bundleURL)) ||
[app.bundleIdentifier isEqualToString:helper_bundle_id_]) {
[app forceTerminate];
}
@ -256,13 +257,13 @@ class LaunchApplicationTest : public testing::Test {
if (i >= launch_events_.count) {
return nil;
}
return ObjCCastStrict<NSString>(launch_events_[i][@"name"]);
return apple::ObjCCastStrict<NSString>(launch_events_[i][@"name"]);
}
NSDictionary* LaunchEventData(unsigned i) {
if (i >= launch_events_.count) {
return nil;
}
return ObjCCastStrict<NSDictionary>(launch_events_[i][@"data"]);
return apple::ObjCCastStrict<NSDictionary>(launch_events_[i][@"data"]);
}
protected:
@ -295,7 +296,7 @@ TEST_F(LaunchApplicationTest, Basic) {
helper_app_bundle_path_, command_line_args, {}, {});
ASSERT_TRUE(app);
EXPECT_NSEQ(app.bundleIdentifier, helper_bundle_id_);
EXPECT_EQ(NSURLToFilePath(app.bundleURL), helper_app_bundle_path_);
EXPECT_EQ(apple::NSURLToFilePath(app.bundleURL), helper_app_bundle_path_);
WaitForLaunchEvents(1);
EXPECT_NSEQ(LaunchEventName(0), @"applicationDidFinishLaunching");
@ -303,7 +304,7 @@ TEST_F(LaunchApplicationTest, Basic) {
@(NSApplicationActivationPolicyRegular));
EXPECT_EQ(app.activationPolicy, NSApplicationActivationPolicyRegular);
EXPECT_NSEQ(LaunchEventData(0)[@"commandLine"],
(@[ FilePathToNSString(helper_app_executable_path_) ]));
(@[ apple::FilePathToNSString(helper_app_executable_path_) ]));
EXPECT_NSEQ(LaunchEventData(0)[@"processIdentifier"],
@(app.processIdentifier));
}
@ -340,10 +341,10 @@ TEST_F(LaunchApplicationTest, CommandLineArgs_StringVector) {
WaitForLaunchEvents(1);
EXPECT_NSEQ(LaunchEventName(0), @"applicationDidFinishLaunching");
EXPECT_NSEQ(
LaunchEventData(0)[@"commandLine"], (@[
FilePathToNSString(helper_app_executable_path_), @"--foo", @"bar", @"-v"
]));
EXPECT_NSEQ(LaunchEventData(0)[@"commandLine"], (@[
apple::FilePathToNSString(helper_app_executable_path_),
@"--foo", @"bar", @"-v"
]));
}
TEST_F(LaunchApplicationTest, CommandLineArgs_BaseCommandLine) {
@ -359,8 +360,8 @@ TEST_F(LaunchApplicationTest, CommandLineArgs_BaseCommandLine) {
WaitForLaunchEvents(1);
EXPECT_NSEQ(LaunchEventName(0), @"applicationDidFinishLaunching");
EXPECT_NSEQ(LaunchEventData(0)[@"commandLine"], (@[
FilePathToNSString(helper_app_executable_path_), @"--foo=bar",
@"--v", @"--path=/tmp"
apple::FilePathToNSString(helper_app_executable_path_),
@"--foo=bar", @"--v", @"--path=/tmp"
]));
}
@ -381,12 +382,12 @@ TEST_F(LaunchApplicationTest, UrlSpecs) {
// macOS 11 (and only macOS 11) appears to sometimes trigger the openURLs
// calls in reverse order.
std::vector<std::string> received_urls;
for (NSString* url in ObjCCastStrict<NSArray>(
for (NSString* url in apple::ObjCCastStrict<NSArray>(
LaunchEventData(0)[@"urls"])) {
received_urls.push_back(SysNSStringToUTF8(url));
}
EXPECT_EQ(received_urls.size(), 1u);
for (NSString* url in ObjCCastStrict<NSArray>(
for (NSString* url in apple::ObjCCastStrict<NSArray>(
LaunchEventData(2)[@"urls"])) {
received_urls.push_back(SysNSStringToUTF8(url));
}
@ -436,17 +437,17 @@ TEST_F(LaunchApplicationTest, HiddenInBackground) {
{.hidden_in_background = true});
ASSERT_TRUE(app);
EXPECT_NSEQ(app.bundleIdentifier, helper_bundle_id_);
EXPECT_EQ(helper_app_bundle_path_, NSURLToFilePath(app.bundleURL));
EXPECT_EQ(helper_app_bundle_path_, apple::NSURLToFilePath(app.bundleURL));
WaitForLaunchEvents(1);
EXPECT_NSEQ(LaunchEventName(0), @"applicationDidFinishLaunching");
EXPECT_NSEQ(LaunchEventData(0)[@"activationPolicy"],
@(NSApplicationActivationPolicyProhibited));
EXPECT_EQ(app.activationPolicy, NSApplicationActivationPolicyProhibited);
EXPECT_NSEQ(
LaunchEventData(0)[@"commandLine"], (@[
FilePathToNSString(helper_app_executable_path_), @"--test", @"--foo"
]));
EXPECT_NSEQ(LaunchEventData(0)[@"commandLine"], (@[
apple::FilePathToNSString(helper_app_executable_path_),
@"--test", @"--foo"
]));
EXPECT_NSEQ(LaunchEventData(0)[@"processIdentifier"],
@(app.processIdentifier));
@ -484,17 +485,17 @@ TEST_F(LaunchApplicationTest,
{.hidden_in_background = true});
ASSERT_TRUE(app);
EXPECT_NSEQ(app.bundleIdentifier, helper_bundle_id_);
EXPECT_EQ(helper_app_bundle_path_, NSURLToFilePath(app.bundleURL));
EXPECT_EQ(helper_app_bundle_path_, apple::NSURLToFilePath(app.bundleURL));
WaitForLaunchEvents(1);
EXPECT_NSEQ(LaunchEventName(0), @"applicationDidFinishLaunching");
EXPECT_NSEQ(LaunchEventData(0)[@"activationPolicy"],
@(NSApplicationActivationPolicyProhibited));
EXPECT_EQ(app.activationPolicy, NSApplicationActivationPolicyProhibited);
EXPECT_NSEQ(
LaunchEventData(0)[@"commandLine"], (@[
FilePathToNSString(helper_app_executable_path_), @"--test", @"--foo"
]));
EXPECT_NSEQ(LaunchEventData(0)[@"commandLine"], (@[
apple::FilePathToNSString(helper_app_executable_path_),
@"--test", @"--foo"
]));
EXPECT_NSEQ(LaunchEventData(0)[@"processIdentifier"],
@(app.processIdentifier));

@ -17,11 +17,11 @@
#include "base/apple/bridging.h"
#include "base/apple/bundle_locations.h"
#include "base/apple/foundation_util.h"
#include "base/apple/osstatus_logging.h"
#include "base/apple/scoped_cftyperef.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_aedesc.h"
#include "base/mac/scoped_ioobject.h"
#include "base/strings/string_number_conversions.h"
@ -163,7 +163,7 @@ void AddToLoginItems(const FilePath& app_bundle_file_path,
return;
}
NSURL* app_bundle_url = base::mac::FilePathToNSURL(app_bundle_file_path);
NSURL* app_bundle_url = base::apple::FilePathToNSURL(app_bundle_file_path);
base::ScopedCFTypeRef<LSSharedFileListItemRef> item =
login_items.GetLoginItemForApp(app_bundle_url);
@ -204,7 +204,7 @@ void RemoveFromLoginItems(const FilePath& app_bundle_file_path) {
return;
}
NSURL* app_bundle_url = base::mac::FilePathToNSURL(app_bundle_file_path);
NSURL* app_bundle_url = base::apple::FilePathToNSURL(app_bundle_file_path);
base::ScopedCFTypeRef<LSSharedFileListItemRef> item =
login_items.GetLoginItemForApp(app_bundle_url);
if (!item.get()) {
@ -261,7 +261,7 @@ bool WasLaunchedAsLoginItemRestoreState() {
return true;
}
if (CFBooleanRef restore_state = base::mac::CFCast<CFBooleanRef>(plist)) {
if (CFBooleanRef restore_state = base::apple::CFCast<CFBooleanRef>(plist)) {
return CFBooleanGetValue(restore_state);
}
@ -467,7 +467,7 @@ std::string GetPlatformSerialNumber() {
CFSTR(kIOPlatformSerialNumberKey),
kCFAllocatorDefault, 0));
CFStringRef serial_number_cfstring =
base::mac::CFCast<CFStringRef>(serial_number);
base::apple::CFCast<CFStringRef>(serial_number);
if (!serial_number_cfstring) {
DLOG(ERROR) << "Error retrieving the machine serial number.";
return std::string();

@ -10,11 +10,11 @@
#include <stdint.h>
#include <sys/xattr.h>
#include "base/apple/foundation_util.h"
#include "base/apple/scoped_cftyperef.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/mac/foundation_util.h"
#include "base/system/sys_info.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@ -28,21 +28,21 @@ using MacUtilTest = PlatformTest;
TEST_F(MacUtilTest, GetUserDirectoryTest) {
// Try a few keys, make sure they come back with non-empty paths.
FilePath caches_dir;
EXPECT_TRUE(GetUserDirectory(NSCachesDirectory, &caches_dir));
EXPECT_TRUE(apple::GetUserDirectory(NSCachesDirectory, &caches_dir));
EXPECT_FALSE(caches_dir.empty());
FilePath application_support_dir;
EXPECT_TRUE(GetUserDirectory(NSApplicationSupportDirectory,
&application_support_dir));
EXPECT_TRUE(apple::GetUserDirectory(NSApplicationSupportDirectory,
&application_support_dir));
EXPECT_FALSE(application_support_dir.empty());
FilePath library_dir;
EXPECT_TRUE(GetUserDirectory(NSLibraryDirectory, &library_dir));
EXPECT_TRUE(apple::GetUserDirectory(NSLibraryDirectory, &library_dir));
EXPECT_FALSE(library_dir.empty());
}
TEST_F(MacUtilTest, TestLibraryPath) {
FilePath library_dir = GetUserLibraryPath();
FilePath library_dir = apple::GetUserLibraryPath();
// Make sure the string isn't empty.
EXPECT_FALSE(library_dir.value().empty());
}
@ -51,7 +51,7 @@ TEST_F(MacUtilTest, TestGetAppBundlePath) {
FilePath out;
// Make sure it doesn't crash.
out = GetAppBundlePath(FilePath());
out = apple::GetAppBundlePath(FilePath());
EXPECT_TRUE(out.empty());
// Some more invalid inputs.
@ -60,7 +60,7 @@ TEST_F(MacUtilTest, TestGetAppBundlePath) {
"foo/bar./bazquux", "foo/.app", "//foo",
};
for (size_t i = 0; i < std::size(invalid_inputs); i++) {
out = GetAppBundlePath(FilePath(invalid_inputs[i]));
out = apple::GetAppBundlePath(FilePath(invalid_inputs[i]));
EXPECT_TRUE(out.empty()) << "loop: " << i;
}
@ -84,7 +84,7 @@ TEST_F(MacUtilTest, TestGetAppBundlePath) {
"/Applications/Google Foo.app" },
};
for (size_t i = 0; i < std::size(valid_inputs); i++) {
out = GetAppBundlePath(FilePath(valid_inputs[i].in));
out = apple::GetAppBundlePath(FilePath(valid_inputs[i].in));
EXPECT_FALSE(out.empty()) << "loop: " << i;
EXPECT_STREQ(valid_inputs[i].expected_out,
out.value().c_str()) << "loop: " << i;
@ -95,7 +95,7 @@ TEST_F(MacUtilTest, TestGetInnermostAppBundlePath) {
FilePath out;
// Make sure it doesn't crash.
out = GetInnermostAppBundlePath(FilePath());
out = apple::GetInnermostAppBundlePath(FilePath());
EXPECT_TRUE(out.empty());
// Some more invalid inputs.
@ -113,7 +113,7 @@ TEST_F(MacUtilTest, TestGetInnermostAppBundlePath) {
for (size_t i = 0; i < std::size(invalid_inputs); i++) {
SCOPED_TRACE(testing::Message()
<< "case #" << i << ", input: " << invalid_inputs[i]);
out = GetInnermostAppBundlePath(FilePath(invalid_inputs[i]));
out = apple::GetInnermostAppBundlePath(FilePath(invalid_inputs[i]));
EXPECT_TRUE(out.empty());
}
@ -139,7 +139,7 @@ TEST_F(MacUtilTest, TestGetInnermostAppBundlePath) {
for (size_t i = 0; i < std::size(valid_inputs); i++) {
SCOPED_TRACE(testing::Message()
<< "case #" << i << ", input " << valid_inputs[i].in);
out = GetInnermostAppBundlePath(FilePath(valid_inputs[i].in));
out = apple::GetInnermostAppBundlePath(FilePath(valid_inputs[i].in));
EXPECT_FALSE(out.empty());
EXPECT_STREQ(valid_inputs[i].expected_out, out.value().c_str());
}

@ -9,10 +9,10 @@
#include <utility>
#include "base/apple/foundation_util.h"
#include "base/apple/mach_logging.h"
#include "base/containers/buffer_iterator.h"
#include "base/logging.h"
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_mach_msg_destroy.h"
#include "base/notreached.h"
#include "base/strings/stringprintf.h"
@ -140,7 +140,7 @@ MachPortRendezvousServer::ClientData::~ClientData() = default;
MachPortRendezvousServer::MachPortRendezvousServer() {
std::string bootstrap_name =
StringPrintf(kBootstrapNameFormat, mac::BaseBundleID(), getpid());
StringPrintf(kBootstrapNameFormat, apple::BaseBundleID(), getpid());
kern_return_t kr = bootstrap_check_in(
bootstrap_port, bootstrap_name.c_str(),
apple::ScopedMachReceiveRight::Receiver(server_port_).get());
@ -301,7 +301,7 @@ size_t MachPortRendezvousClient::GetPortCount() {
// static
std::string MachPortRendezvousClient::GetBootstrapName() {
return StringPrintf(kBootstrapNameFormat, mac::BaseBundleID(), getppid());
return StringPrintf(kBootstrapNameFormat, apple::BaseBundleID(), getppid());
}
bool MachPortRendezvousClient::AcquirePorts() {

@ -8,9 +8,9 @@
#include <utility>
#include "base/apple/foundation_util.h"
#include "base/apple/mach_logging.h"
#include "base/at_exit.h"
#include "base/mac/foundation_util.h"
#include "base/strings/stringprintf.h"
#include "base/test/multiprocess_test.h"
#include "base/test/test_timeouts.h"
@ -224,7 +224,7 @@ TEST_F(MachPortRendezvousServerTest, DestroyRight) {
MULTIPROCESS_TEST_MAIN(FailToRendezvous) {
// The rendezvous system uses the BaseBundleID to construct the bootstrap
// server name, so changing it will result in a failure to look it up.
base::mac::SetBaseBundleID("org.chromium.totallyfake");
base::apple::SetBaseBundleID("org.chromium.totallyfake");
CHECK_EQ(nullptr, base::MachPortRendezvousClient::GetInstance());
return 0;
}

@ -8,8 +8,8 @@
#include <IOKit/IOKitLib.h>
#include <IOKit/ps/IOPSKeys.h>
#include "base/apple/foundation_util.h"
#include "base/apple/scoped_cftyperef.h"
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_ioobject.h"
namespace base {
@ -21,7 +21,7 @@ namespace {
absl::optional<SInt64> GetValueAsSInt64(CFDictionaryRef description,
CFStringRef key) {
CFNumberRef number_ref =
base::mac::GetValueFromDictionary<CFNumberRef>(description, key);
base::apple::GetValueFromDictionary<CFNumberRef>(description, key);
SInt64 value;
if (number_ref && CFNumberGetValue(number_ref, kCFNumberSInt64Type, &value))
@ -33,7 +33,7 @@ absl::optional<SInt64> GetValueAsSInt64(CFDictionaryRef description,
absl::optional<bool> GetValueAsBoolean(CFDictionaryRef description,
CFStringRef key) {
CFBooleanRef boolean =
base::mac::GetValueFromDictionary<CFBooleanRef>(description, key);
base::apple::GetValueFromDictionary<CFBooleanRef>(description, key);
if (!boolean)
return absl::nullopt;
return CFBooleanGetValue(boolean);

@ -7,8 +7,8 @@
#include "base/power_monitor/power_monitor_device_source.h"
#include "base/apple/foundation_util.h"
#include "base/apple/scoped_cftyperef.h"
#include "base/mac/foundation_util.h"
#include "base/power_monitor/power_monitor.h"
#include "base/power_monitor/power_monitor_source.h"

@ -10,8 +10,8 @@
#include <vector>
#include "base/apple/bridging.h"
#include "base/apple/foundation_util.h"
#include "base/apple/scoped_cftyperef.h"
#include "base/mac/foundation_util.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/string_piece.h"

@ -4,11 +4,11 @@
#include "base/test/launcher/unit_test_launcher.h"
#include "base/apple/foundation_util.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/mac/foundation_util.h"
#include "base/test/allow_check_is_test_for_testing.h"
#include "base/test/gtest_util.h"
#include "base/test/test_support_ios.h"
@ -57,14 +57,14 @@ int LaunchUnitTestsSerially(int argc,
only_write_tests
? (command_line->GetSwitchValuePath(
switches::kTestLauncherListTests))
: mac::GetUserDocumentPath().Append("compiled_tests.json");
: apple::GetUserDocumentPath().Append("compiled_tests.json");
int write_result = WriteCompiledInTestsToFileAndLog(list_path);
if (only_write_tests) {
return write_result;
}
} else if (command_line->HasSwitch(
switches::kTestLauncherPrintWritablePath)) {
fprintf(stdout, "%s", mac::GetUserLibraryPath().value().c_str());
fprintf(stdout, "%s", apple::GetUserLibraryPath().value().c_str());
fflush(stdout);
return 0;
}

@ -15,11 +15,11 @@
#include <algorithm>
#include <atomic>
#include "base/apple/foundation_util.h"
#include "base/apple/mach_logging.h"
#include "base/feature_list.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/mac/foundation_util.h"
#include "base/mac/mac_util.h"
#include "base/metrics/histogram_functions.h"
#include "base/threading/thread_id_name_manager.h"
@ -171,7 +171,7 @@ void PlatformThreadApple::SetCurrentThreadRealtimePeriodValue(
namespace {
TimeDelta GetCurrentThreadRealtimePeriod() {
NSNumber* period = mac::ObjCCast<NSNumber>(
NSNumber* period = apple::ObjCCast<NSNumber>(
NSThread.currentThread.threadDictionary[kRealtimePeriodNsKey]);
return period ? Nanoseconds(period.longLongValue) : TimeDelta();
@ -354,7 +354,7 @@ void SetCurrentThreadTypeImpl(ThreadType thread_type,
// static
ThreadPriorityForTest PlatformThreadBase::GetCurrentThreadPriorityForTest() {
NSNumber* priority = base::mac::ObjCCast<NSNumber>(
NSNumber* priority = base::apple::ObjCCast<NSNumber>(
NSThread.currentThread.threadDictionary[kThreadPriorityForTestKey]);
if (!priority) {

@ -117,7 +117,7 @@
#endif
#if BUILDFLAG(IS_MAC)
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
#include "base/message_loop/message_pump_apple.h"
#include "base/message_loop/message_pump_default.h"
#include "base/message_loop/message_pump_kqueue.h"
@ -1263,15 +1263,15 @@ void ChromeMainDelegate::InitMacCrashReporter(
// the helper should always have a --type switch.
//
// This check is done this late so there is already a call to
// base::mac::IsBackgroundOnlyProcess(), so there is no change in
// base::apple::IsBackgroundOnlyProcess(), so there is no change in
// startup/initialization order.
// The helper's Info.plist marks it as a background only app.
if (base::mac::IsBackgroundOnlyProcess()) {
if (base::apple::IsBackgroundOnlyProcess()) {
CHECK(command_line.HasSwitch(switches::kProcessType) &&
!process_type.empty())
<< "Helper application requires --type.";
} else if (base::mac::AmIBundled()) {
} else if (base::apple::AmIBundled()) {
CHECK(!command_line.HasSwitch(switches::kProcessType) &&
process_type.empty())
<< "Main application forbids --type, saw " << process_type;

@ -14,10 +14,10 @@ class FilePath;
void CheckUserDataDirPolicy(base::FilePath* user_data_dir);
// Sets the app bundle (base::apple::FrameworkBundle()) to the framework's
// bundle, and sets the base bundle ID (base::mac::BaseBundleID()) to the proper
// value based on the running application. The base bundle ID is the outer
// browser application's bundle ID even when running in a non-browser (helper)
// process.
// bundle, and sets the base bundle ID (base::apple::BaseBundleID()) to the
// proper value based on the running application. The base bundle ID is the
// outer browser application's bundle ID even when running in a non-browser
// (helper) process.
void SetUpBundleOverrides();
// Checks if the system launched the alerts helper app via a notification

@ -9,9 +9,9 @@
#include <string>
#import "base/apple/bundle_locations.h"
#import "base/apple/foundation_util.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#import "base/mac/foundation_util.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/strings/sys_string_conversions.h"
@ -26,7 +26,7 @@ void SetUpBundleOverrides() {
chrome::GetFrameworkBundlePath());
NSBundle* base_bundle = chrome::OuterAppBundle();
base::mac::SetBaseBundleID(base_bundle.bundleIdentifier.UTF8String);
base::apple::SetBaseBundleID(base_bundle.bundleIdentifier.UTF8String);
base::FilePath child_exe_path =
chrome::GetFrameworkBundlePath().Append("Helpers").Append(
@ -44,8 +44,9 @@ bool IsAlertsHelperLaunchedViaNotificationAction() {
// We allow the main Chrome app to be launched via a notification action. We
// detect and log that to UMA by checking the passed in NSNotification in
// -applicationDidFinishLaunching: (//chrome/browser/app_controller_mac.mm).
if (!base::mac::IsBackgroundOnlyProcess())
if (!base::apple::IsBackgroundOnlyProcess()) {
return false;
}
// If we have a process type then we were not launched by the system.
if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessType))

@ -13,11 +13,11 @@
#import <Cocoa/Cocoa.h>
#include "base/allocator/early_zone_registration_apple.h"
#include "base/apple/foundation_util.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/mac/foundation_util.h"
#include "base/process/launch.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/sys_string_conversions.h"
@ -43,10 +43,10 @@ int LoadFrameworkAndStart(int argc, char** argv) {
return kErrorReturnValue;
}
const base::FilePath app_mode_bundle_path =
base::mac::NSStringToFilePath([app_bundle bundlePath]);
base::apple::NSStringToFilePath([app_bundle bundlePath]);
// Get the bundle ID of the browser that created this app bundle.
NSString* cr_bundle_id = base::mac::ObjCCast<NSString>(
NSString* cr_bundle_id = base::apple::ObjCCast<NSString>(
[app_bundle objectForInfoDictionaryKey:app_mode::kBrowserBundleIDKey]);
if (!cr_bundle_id) {
NSLog(@"Couldn't get browser bundle ID");
@ -79,7 +79,7 @@ int LoadFrameworkAndStart(int argc, char** argv) {
{
// The user_data_dir for shims actually contains the app_data_path.
// I.e. <user_data_dir>/<profile_dir>/Web Applications/_crx_extensionid/
base::FilePath app_data_dir = base::mac::NSStringToFilePath([app_bundle
base::FilePath app_data_dir = base::apple::NSStringToFilePath([app_bundle
objectForInfoDictionaryKey:app_mode::kCrAppModeUserDataDirKey]);
user_data_dir = app_data_dir.DirName().DirName().DirName();
NSLog(@"Using user data dir %s", user_data_dir.value().c_str());
@ -170,10 +170,10 @@ int LoadFrameworkAndStart(int argc, char** argv) {
const std::string app_mode_url =
base::SysNSStringToUTF8(info_plist[app_mode::kCrAppModeShortcutURLKey]);
base::FilePath plist_user_data_dir = base::mac::NSStringToFilePath(
base::FilePath plist_user_data_dir = base::apple::NSStringToFilePath(
info_plist[app_mode::kCrAppModeUserDataDirKey]);
base::FilePath profile_dir = base::mac::NSStringToFilePath(
base::FilePath profile_dir = base::apple::NSStringToFilePath(
info_plist[app_mode::kCrAppModeProfileDirKey]);
// ** 5: Open the framework.

@ -10,13 +10,13 @@
#include <utility>
#include "base/apple/bundle_locations.h"
#include "base/apple/foundation_util.h"
#include "base/apple/mach_logging.h"
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/hash/md5.h"
#include "base/mac/foundation_util.h"
#include "base/mac/launch_application.h"
#include "base/mac/mac_util.h"
#include "base/memory/raw_ptr.h"
@ -314,7 +314,7 @@ void AppShimController::PollForChromeReady(
{
mojo::PlatformChannelEndpoint endpoint;
NSString* browser_bundle_id =
base::mac::ObjCCast<NSString>([NSBundle.mainBundle
base::apple::ObjCCast<NSString>([NSBundle.mainBundle
objectForInfoDictionaryKey:app_mode::kBrowserBundleIDKey]);
CHECK(browser_bundle_id);
const std::string server_name = base::StringPrintf(

@ -4,7 +4,7 @@
#include "chrome/app_shim/app_shim_delegate.h"
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
#include "base/memory/raw_ptr.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/app_shim/app_shim_controller.h"
@ -26,7 +26,7 @@
- (BOOL)application:(NSApplication*)app openFile:(NSString*)filename {
std::vector<base::FilePath> filePaths = {
base::mac::NSStringToFilePath(filename)};
base::apple::NSStringToFilePath(filename)};
_appShimController->OpenFiles(filePaths);
return YES;
}
@ -34,7 +34,7 @@
- (void)application:(NSApplication*)app openFiles:(NSArray*)filenames {
std::vector<base::FilePath> filePaths;
for (NSString* filename in filenames)
filePaths.push_back(base::mac::NSStringToFilePath(filename));
filePaths.push_back(base::apple::NSStringToFilePath(filename));
_appShimController->OpenFiles(filePaths);
[app replyToOpenOrPrint:NSApplicationDelegateReplySuccess];
}

@ -11,13 +11,13 @@
#include <vector>
#include "base/apple/bridging.h"
#include "base/apple/foundation_util.h"
#include "base/auto_reset.h"
#include "base/check_op.h"
#include "base/command_line.h"
#include "base/debug/dump_without_crashing.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/mac/foundation_util.h"
#include "base/mac/mac_util.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_macros.h"
@ -276,7 +276,7 @@ void RecordLastRunAppBundlePath() {
CFPreferencesSetAppValue(
base::apple::NSToCFPtrCast(app_mode::kLastRunAppBundlePathPrefsKey),
app_bundle_path_cfstring,
base::SysUTF8ToCFStringRef(base::mac::BaseBundleID()));
base::SysUTF8ToCFStringRef(base::apple::BaseBundleID()));
}
bool IsProfileSignedOut(const base::FilePath& profile_path) {
@ -1018,7 +1018,7 @@ class AppControllerNativeThemeObserver : public ui::NativeThemeObserver {
// Record the path to the (browser) app bundle; this is used by the app mode
// shim.
if (base::mac::AmIBundled()) {
if (base::apple::AmIBundled()) {
base::ThreadPool::PostTask(
FROM_HERE,
{base::MayBlock(), base::TaskPriority::BEST_EFFORT,
@ -1284,7 +1284,7 @@ class AppControllerNativeThemeObserver : public ui::NativeThemeObserver {
// This is handled outside of the switch statement because we want to hide
// this regardless if the command is supported or not.
if (tag == IDC_SHOW_AS_TAB) {
NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item);
NSMenuItem* menuItem = base::apple::ObjCCast<NSMenuItem>(item);
[menuItem setHidden:YES];
}
} else if (action == @selector(terminate:)) {
@ -1915,10 +1915,10 @@ class AppControllerNativeThemeObserver : public ui::NativeThemeObserver {
NSWindow* targetWindow = nil;
if ([target isKindOfClass:[NSPopover class]]) {
targetWindow =
[[[base::mac::ObjCCast<NSPopover>(target) contentViewController] view]
[[[base::apple::ObjCCast<NSPopover>(target) contentViewController] view]
window];
} else {
targetWindow = base::mac::ObjCCast<NSWindow>(target);
targetWindow = base::apple::ObjCCast<NSWindow>(target);
}
if (targetWindow != nil) {
@ -1970,7 +1970,7 @@ class AppControllerNativeThemeObserver : public ui::NativeThemeObserver {
return NO;
}
NSString* originString = base::mac::ObjCCast<NSString>(
NSString* originString = base::apple::ObjCCast<NSString>(
(userActivity.userInfo)[handoff::kOriginKey]);
handoff::Origin origin = handoff::OriginFromString(originString);
UMA_HISTOGRAM_ENUMERATION(

@ -9,11 +9,11 @@
#include <string>
#include "base/apple/foundation_util.h"
#include "base/apple/scoped_objc_class_swizzler.h"
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/mac/foundation_util.h"
#include "base/memory/raw_ptr.h"
#include "base/path_service.h"
#include "base/run_loop.h"
@ -791,7 +791,7 @@ IN_PROC_BROWSER_TEST_F(AppControllerReplaceNTPBrowserTest,
IN_PROC_BROWSER_TEST_F(AppControllerBrowserTest, OpenInRegularBrowser) {
ASSERT_TRUE(embedded_test_server()->Start());
AppController* ac =
base::mac::ObjCCastStrict<AppController>([NSApp delegate]);
base::apple::ObjCCastStrict<AppController>([NSApp delegate]);
ASSERT_TRUE(ac);
// Create an incognito browser and make it the last active browser.
Browser* incognito_browser = CreateIncognitoBrowser(browser()->profile());
@ -830,7 +830,7 @@ IN_PROC_BROWSER_TEST_F(AppControllerBrowserTest,
OpenInRegularBrowserWhenOnlyIncognitoBrowserIsOpened) {
ASSERT_TRUE(embedded_test_server()->Start());
AppController* ac =
base::mac::ObjCCastStrict<AppController>([NSApp delegate]);
base::apple::ObjCCastStrict<AppController>([NSApp delegate]);
ASSERT_TRUE(ac);
EXPECT_EQ(BrowserList::GetInstance()->size(), 1u);
// Close the current browser.
@ -874,7 +874,7 @@ IN_PROC_BROWSER_TEST_F(AppControllerBrowserTest,
IN_PROC_BROWSER_TEST_F(AppControllerBrowserTest, OpenUrlInGuestBrowser) {
ASSERT_TRUE(embedded_test_server()->Start());
AppController* ac =
base::mac::ObjCCastStrict<AppController>([NSApp delegate]);
base::apple::ObjCCastStrict<AppController>([NSApp delegate]);
ASSERT_TRUE(ac);
// Create a guest browser and make it the last active browser.
Browser* guest_browser = CreateGuestBrowser();

@ -8,12 +8,12 @@
#include <memory>
#include "base/apple/foundation_util.h"
#include "base/check.h"
#include "base/check_op.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/mac/foundation_util.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/strcat.h"
@ -140,9 +140,10 @@ TestShimClient::TestShimClient() {
base::FilePath user_data_dir;
CHECK(base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir));
std::string name_fragment = base::StrCat(
{base::mac::BaseBundleID(), ".", app_mode::kAppShimBootstrapNameFragment,
".", base::MD5String(user_data_dir.value())});
std::string name_fragment =
base::StrCat({base::apple::BaseBundleID(), ".",
app_mode::kAppShimBootstrapNameFragment, ".",
base::MD5String(user_data_dir.value())});
mojo::PlatformChannelEndpoint endpoint = ConnectToBrowser(name_fragment);
mojo::ScopedMessagePipeHandle message_pipe;

@ -12,6 +12,7 @@
#include "apps/app_lifetime_monitor_factory.h"
#include "base/apple/bundle_locations.h"
#include "base/apple/foundation_util.h"
#include "base/apple/osstatus_logging.h"
#include "base/barrier_closure.h"
#include "base/debug/dump_without_crashing.h"
@ -22,7 +23,6 @@
#include "base/functional/callback_helpers.h"
#include "base/hash/sha1.h"
#include "base/logging.h"
#include "base/mac/foundation_util.h"
#include "base/memory/raw_ptr.h"
#include "base/no_destructor.h"
#include "base/strings/stringprintf.h"
@ -115,7 +115,7 @@ CreateAppShimRequirement() {
// 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::mac::FilePathToCFURL(base::apple::FrameworkBundlePath());
base::apple::FilePathToCFURL(base::apple::FrameworkBundlePath());
base::ScopedCFTypeRef<SecStaticCodeRef> framework_code;
OSStatus status = SecStaticCodeCreateWithPath(
framework_url, kSecCSDefaultFlags, framework_code.InitializeInto());
@ -150,8 +150,8 @@ CreateAppShimRequirement() {
// unsigned. This decision is consistent with the StaticCode source:
// https://github.com/apple-oss-distributions/Security/blob/Security-60157.40.30.0.1/OSX/libsecurity_codesigning/lib/StaticCode.cpp#L2270
CFNumberRef framework_signing_info_flags =
base::mac::GetValueFromDictionary<CFNumberRef>(framework_signing_info,
kSecCodeInfoFlags);
base::apple::GetValueFromDictionary<CFNumberRef>(framework_signing_info,
kSecCodeInfoFlags);
if (!framework_signing_info_flags) {
return absl::nullopt; // has_value() == false
}

@ -10,8 +10,8 @@
#include <memory>
#include <utility>
#include "base/apple/foundation_util.h"
#include "base/apple/mach_logging.h"
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_mach_msg_destroy.h"
#include "base/strings/stringprintf.h"
#include "chrome/common/mac/app_mode_common.h"
@ -21,7 +21,7 @@ namespace apps {
MachBootstrapAcceptor::MachBootstrapAcceptor(const std::string& name_fragment,
Delegate* delegate)
: server_name_(base::StringPrintf("%s.%s",
base::mac::BaseBundleID(),
base::apple::BaseBundleID(),
name_fragment.c_str())
.c_str()),
delegate_(delegate) {

@ -49,7 +49,7 @@
#include "media/media_buildflags.h"
#if BUILDFLAG(IS_MAC)
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#endif // BUILDFLAG(IS_MAC)

@ -45,7 +45,7 @@
#include "url/gurl.h"
#if BUILDFLAG(IS_MAC)
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
#endif
namespace autofill {
@ -95,7 +95,7 @@ std::vector<base::FilePath> GetTestFiles() {
std::sort(files.begin(), files.end());
#if BUILDFLAG(IS_MAC)
base::mac::ClearAmIBundledCache();
base::apple::ClearAmIBundledCache();
#endif // BUILDFLAG(IS_MAC)
return files;

@ -4,7 +4,7 @@
#include "chrome/browser/browser_process_platform_part_mac.h"
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/time/time.h"
#import "chrome/browser/app_controller_mac.h"

@ -7,11 +7,11 @@
#import <Cocoa/Cocoa.h>
#include "base/apple/bundle_locations.h"
#import "base/apple/foundation_util.h"
#include "base/check_op.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#import "base/mac/foundation_util.h"
#include "base/mac/mac_util.h"
#include "base/metrics/histogram_functions.h"
#include "base/path_service.h"

@ -4,10 +4,10 @@
#include "chrome/browser/component_updater/recovery_improved_component_installer.h"
#include "base/apple/foundation_util.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/mac/foundation_util.h"
#include "base/mac/mac_util.h"
#include "base/memory/ref_counted.h"
#include "components/update_client/update_client.h"
@ -44,7 +44,7 @@ base::CommandLine RecoveryComponentActionHandlerMac::MakeCommandLine(
command_line.AppendSwitchASCII("browser-version",
version_info::GetVersion().GetString());
command_line.AppendSwitchASCII("sessionid", session_id());
command_line.AppendSwitchASCII("appguid", base::mac::BaseBundleID());
command_line.AppendSwitchASCII("appguid", base::apple::BaseBundleID());
command_line.AppendSwitch("enable-logging");
command_line.AppendSwitchASCII(
"vmodule", "*/components/update_client/*=2,*/chrome/updater/*=2");

@ -7,10 +7,10 @@
#import <Foundation/Foundation.h>
#include "base/apple/bridging.h"
#include "base/apple/foundation_util.h"
#include "base/enterprise_util.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#include "base/version.h"
@ -29,7 +29,7 @@ T* GetUpdaterSettingsValue(NSString* value_name) {
CFPreferencesCopyAppValue(base::apple::NSToCFPtrCast(value_name),
CFSTR("com.google.Keystone.Agent")));
return base::mac::ObjCCastStrict<T>(plist_type);
return base::apple::ObjCCastStrict<T>(plist_type);
}
base::Time GetUpdaterSettingsTime(NSString* value_name) {
@ -43,12 +43,12 @@ base::Time GetUpdaterSettingsTime(NSString* value_name) {
base::Version GetVersionFromPlist(const base::FilePath& info_plist) {
@autoreleasepool {
NSData* data = [NSData
dataWithContentsOfFile:base::mac::FilePathToNSString(info_plist)];
dataWithContentsOfFile:base::apple::FilePathToNSString(info_plist)];
if ([data length] == 0) {
return base::Version();
}
NSDictionary* all_keys =
base::mac::ObjCCastStrict<NSDictionary>([NSPropertyListSerialization
base::apple::ObjCCastStrict<NSDictionary>([NSPropertyListSerialization
propertyListWithData:data
options:NSPropertyListImmutable
format:nil
@ -56,7 +56,7 @@ base::Version GetVersionFromPlist(const base::FilePath& info_plist) {
if (all_keys == nil) {
return base::Version();
}
CFStringRef version = base::mac::GetValueFromDictionary<CFStringRef>(
CFStringRef version = base::apple::GetValueFromDictionary<CFStringRef>(
base::apple::NSToCFPtrCast(all_keys), kCFBundleVersionKey);
if (version == nullptr) {
return base::Version();
@ -76,7 +76,7 @@ base::Version UpdaterState::StateReaderKeystone::GetUpdaterVersion(
// System Keystone trumps user one, so check this one first
base::FilePath local_library;
bool success =
base::mac::GetLocalDirectory(NSLibraryDirectory, &local_library);
base::apple::GetLocalDirectory(NSLibraryDirectory, &local_library);
DCHECK(success);
base::FilePath system_bundle_plist = local_library.Append(kKeystonePlist);
base::Version system_keystone = GetVersionFromPlist(system_bundle_plist);
@ -85,7 +85,7 @@ base::Version UpdaterState::StateReaderKeystone::GetUpdaterVersion(
}
base::FilePath user_bundle_plist =
base::mac::GetUserLibraryPath().Append(kKeystonePlist);
base::apple::GetUserLibraryPath().Append(kKeystonePlist);
return GetVersionFromPlist(user_bundle_plist);
}

@ -6,7 +6,7 @@
#import <Foundation/Foundation.h>
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
#include "base/memory/scoped_policy.h"
#include "base/supports_user_data.h"
#include "base/time/time.h"
@ -52,7 +52,7 @@ CrNSProgressUserData* CreateOrGetNSProgress(download::DownloadItem* download) {
return progress_data;
base::FilePath destination_path = download->GetFullPath();
NSURL* destination_url = base::mac::FilePathToNSURL(destination_path);
NSURL* destination_url = base::apple::FilePathToNSURL(destination_path);
NSProgress* progress = [NSProgress progressWithTotalUnitCount:-1];
progress.kind = NSProgressKindFile;
@ -101,7 +101,7 @@ void UpdateNSProgress(download::DownloadItem* download) {
base::FilePath download_path = download->GetFullPath();
if (progress_data->target() != download_path) {
progress_data->setTarget(download_path);
NSURL* download_url = base::mac::FilePathToNSURL(download_path);
NSURL* download_url = base::apple::FilePathToNSURL(download_path);
progress.fileURL = download_url;
}
}
@ -145,7 +145,7 @@ void DownloadStatusUpdater::UpdateAppIconDownloadProgress(
if (download->GetState() != download::DownloadItem::IN_PROGRESS &&
!download->GetTargetFilePath().empty()) {
NSString* download_path =
base::mac::FilePathToNSString(download->GetTargetFilePath());
base::apple::FilePathToNSString(download->GetTargetFilePath());
if (download->GetState() == download::DownloadItem::COMPLETE) {
// Bounce the dock icon.
[NSDistributedNotificationCenter.defaultCenter

@ -6,7 +6,7 @@
#import <Cocoa/Cocoa.h>
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
#include "components/download/public/common/download_item.h"
#include "ui/gfx/image/image.h"
#include "ui/views/widget/widget.h"
@ -53,7 +53,7 @@ void DragDownloadItem(const download::DownloadItem* download,
if (widget)
widget->ReleaseCapture();
NSURL* file_url = base::mac::FilePathToNSURL(download->GetTargetFilePath());
NSURL* file_url = base::apple::FilePathToNSURL(download->GetTargetFilePath());
NSDraggingItem* file_item =
[[NSDraggingItem alloc] initWithPasteboardWriter:file_url];
if (icon) {

@ -10,9 +10,9 @@
#include <memory>
#include "base/apple/bridging.h"
#include "base/apple/foundation_util.h"
#include "base/apple/scoped_cftyperef.h"
#include "base/containers/span.h"
#include "base/mac/foundation_util.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/stringprintf.h"
#include "base/strings/sys_string_conversions.h"
@ -88,10 +88,10 @@ class SecureEnclaveClientTest : public testing::Test {
}
void VerifyQuery(CFDictionaryRef query, CFStringRef label) {
EXPECT_TRUE(CFEqual(label, base::mac::GetValueFromDictionary<CFStringRef>(
EXPECT_TRUE(CFEqual(label, base::apple::GetValueFromDictionary<CFStringRef>(
query, kSecAttrLabel)));
EXPECT_TRUE(CFEqual(kSecAttrKeyTypeECSECPrimeRandom,
base::mac::GetValueFromDictionary<CFStringRef>(
base::apple::GetValueFromDictionary<CFStringRef>(
query, kSecAttrKeyType)));
}
@ -119,22 +119,22 @@ TEST_F(SecureEnclaveClientTest, CreateKey_Success) {
.WillOnce([this](CFDictionaryRef attributes, OSStatus* status) {
EXPECT_TRUE(CFEqual(
base::SysUTF8ToCFStringRef(constants::kDeviceTrustSigningKeyLabel),
base::mac::GetValueFromDictionary<CFStringRef>(attributes,
kSecAttrLabel)));
base::apple::GetValueFromDictionary<CFStringRef>(attributes,
kSecAttrLabel)));
EXPECT_TRUE(CFEqual(kSecAttrKeyTypeECSECPrimeRandom,
base::mac::GetValueFromDictionary<CFStringRef>(
base::apple::GetValueFromDictionary<CFStringRef>(
attributes, kSecAttrKeyType)));
EXPECT_TRUE(CFEqual(kSecAttrTokenIDSecureEnclave,
base::mac::GetValueFromDictionary<CFStringRef>(
base::apple::GetValueFromDictionary<CFStringRef>(
attributes, kSecAttrTokenID)));
EXPECT_TRUE(CFEqual(base::apple::NSToCFPtrCast(@256),
base::mac::GetValueFromDictionary<CFNumberRef>(
base::apple::GetValueFromDictionary<CFNumberRef>(
attributes, kSecAttrKeySizeInBits)));
auto* private_key_attributes =
base::mac::GetValueFromDictionary<CFDictionaryRef>(
base::apple::GetValueFromDictionary<CFDictionaryRef>(
attributes, kSecPrivateKeyAttrs);
EXPECT_TRUE(CFEqual(kCFBooleanTrue,
base::mac::GetValueFromDictionary<CFBooleanRef>(
base::apple::GetValueFromDictionary<CFBooleanRef>(
private_key_attributes, kSecAttrIsPermanent)));
*status = errSecSuccess;
@ -257,7 +257,7 @@ TEST_F(SecureEnclaveClientTest,
EXPECT_TRUE(
CFEqual(base::SysUTF8ToCFStringRef(
constants::kTemporaryDeviceTrustSigningKeyLabel),
base::mac::GetValueFromDictionary<CFStringRef>(
base::apple::GetValueFromDictionary<CFStringRef>(
attribute_to_update, kSecAttrLabel)));
VerifyQuery(query, base::SysUTF8ToCFStringRef(
constants::kDeviceTrustSigningKeyLabel));
@ -324,8 +324,8 @@ TEST_F(SecureEnclaveClientTest,
CFDictionaryRef attribute_to_update) {
EXPECT_TRUE(CFEqual(
base::SysUTF8ToCFStringRef(constants::kDeviceTrustSigningKeyLabel),
base::mac::GetValueFromDictionary<CFStringRef>(attribute_to_update,
kSecAttrLabel)));
base::apple::GetValueFromDictionary<CFStringRef>(
attribute_to_update, kSecAttrLabel)));
VerifyQuery(query,
base::SysUTF8ToCFStringRef(
constants::kTemporaryDeviceTrustSigningKeyLabel));

@ -30,7 +30,7 @@
#endif
#if BUILDFLAG(IS_MAC)
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
#include "chrome/browser/extensions/api/enterprise_reporting_private/keychain_data_helper_mac.h"
#include "crypto/apple_keychain.h"
#endif

@ -7,8 +7,8 @@
#include <CoreFoundation/CoreFoundation.h>
#include <Security/Security.h>
#include "base/apple/foundation_util.h"
#include "base/apple/scoped_cftyperef.h"
#include "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
namespace extensions {

@ -32,7 +32,7 @@
#if BUILDFLAG(IS_MAC)
#include <CoreFoundation/CoreFoundation.h>
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
#endif
#if BUILDFLAG(IS_CHROMEOS)

@ -11,8 +11,8 @@
#include <IOKit/storage/IOStorageProtocolCharacteristics.h>
#include <stdint.h>
#include "base/apple/foundation_util.h"
#include "base/apple/scoped_cftyperef.h"
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_ioobject.h"
#include "base/memory/scoped_refptr.h"
#include "base/strings/sys_string_conversions.h"
@ -75,11 +75,11 @@ RemovableStorageProvider::PopulateDeviceList() {
continue;
}
CFStringRef cf_vendor = base::mac::GetValueFromDictionary<CFStringRef>(
CFStringRef cf_vendor = base::apple::GetValueFromDictionary<CFStringRef>(
characteristics, CFSTR(kIOPropertyVendorNameKey));
std::string vendor = base::SysCFStringRefToUTF8(cf_vendor);
CFStringRef cf_model = base::mac::GetValueFromDictionary<CFStringRef>(
CFStringRef cf_model = base::apple::GetValueFromDictionary<CFStringRef>(
characteristics, CFSTR(kIOPropertyProductNameKey));
std::string model = base::SysCFStringRefToUTF8(cf_model);

@ -8,7 +8,7 @@
#import <Cocoa/Cocoa.h>
#include <IOKit/hidsystem/ev_keymap.h>
#import "base/mac/foundation_util.h"
#import "base/apple/foundation_util.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/media_keys_listener_manager.h"
#include "extensions/common/command.h"
@ -173,7 +173,7 @@ bool GlobalShortcutListenerMac::RegisterHotKey(
EventHotKeyID event_hot_key_id;
// Signature uniquely identifies the application that owns this hot_key.
event_hot_key_id.signature = base::mac::CreatorCodeForApplication();
event_hot_key_id.signature = base::apple::CreatorCodeForApplication();
event_hot_key_id.id = hot_key_id;
// Translate ui::Accelerator modifiers to cmdKey, altKey, etc.

@ -7,11 +7,11 @@
#include <Cocoa/Cocoa.h>
#include <sys/stat.h>
#include "base/apple/foundation_util.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/mac/foundation_util.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "third_party/zlib/google/zip.h"
@ -106,7 +106,7 @@ void FileSelectHelper::ProcessSelectedFilesMac(
std::vector<base::FilePath> temporary_files;
for (auto& file_info : files_out) {
NSString* filename = base::mac::FilePathToNSString(file_info.local_path);
NSString* filename = base::apple::FilePathToNSString(file_info.local_path);
BOOL isPackage =
[[NSWorkspace sharedWorkspace] isFilePackageAtPath:filename];
if (isPackage && base::DirectoryExists(file_info.local_path)) {

@ -7,9 +7,9 @@
#import <AppKit/AppKit.h>
#include <Carbon/Carbon.h>
#include "base/apple/foundation_util.h"
#include "base/check.h"
#include "base/feature_list.h"
#include "base/mac/foundation_util.h"
#include "base/no_destructor.h"
#include "build/buildflag.h"
#include "chrome/app/chrome_command_ids.h"

@ -8,10 +8,10 @@
#import <CoreServices/CoreServices.h> // pre-macOS 11
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h> // macOS 11
#include "base/apple/foundation_util.h"
#include "base/apple/scoped_cftyperef.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#include "base/task/thread_pool.h"
#include "base/threading/thread.h"
@ -28,7 +28,7 @@ IconLoader::IconGroup IconLoader::GroupForFilepath(
if (@available(macOS 11, *)) {
UTType* type;
NSURL* file_url = base::mac::FilePathToNSURL(file_path);
NSURL* file_url = base::apple::FilePathToNSURL(file_path);
if (file_url && [file_url getResourceValue:&type
forKey:NSURLContentTypeKey
error:nil]) {
@ -50,7 +50,7 @@ IconLoader::IconGroup IconLoader::GroupForFilepath(
return base::SysNSStringToUTF8(UTTypeContent.identifier);
} else {
NSString* type;
NSURL* file_url = base::mac::FilePathToNSURL(file_path);
NSURL* file_url = base::apple::FilePathToNSURL(file_path);
if (file_url && [file_url getResourceValue:&type
forKey:NSURLTypeIdentifierKey
error:nil]) {

@ -19,7 +19,7 @@
#include "ui/base/l10n/l10n_util.h"
#if BUILDFLAG(IS_MAC)
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
#include "chrome/common/importer/safari_importer_utils.h"
#endif
@ -73,8 +73,9 @@ void DetectSafariProfiles(std::vector<importer::SourceProfile>* profiles) {
base::BlockingType::MAY_BLOCK);
uint16_t items = importer::NONE;
if (!SafariImporterCanImport(base::mac::GetUserLibraryPath(), &items))
if (!SafariImporterCanImport(base::apple::GetUserLibraryPath(), &items)) {
return;
}
importer::SourceProfile safari;
safari.importer_name = l10n_util::GetStringUTF16(IDS_IMPORT_FROM_SAFARI);

@ -12,8 +12,8 @@
#include <memory>
#include "base/apple/foundation_util.h"
#include "base/functional/bind.h"
#include "base/mac/foundation_util.h"
#include "base/message_loop/message_pump_type.h"
#include "base/strings/sys_string_conversions.h"
#import "base/task/single_thread_task_runner.h"

@ -4,7 +4,7 @@
#import "chrome/browser/app_controller_mac.h"
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_test_util.h"

@ -9,7 +9,7 @@
#include <IOKit/IOKitLib.h>
#include "base/apple/bridging.h"
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
#include "base/mac/mac_util.h"
#include "base/mac/scoped_ioobject.h"
@ -42,7 +42,7 @@ BluetoothAvailability GetBluetoothAvailability() {
NSDictionary* objc_dict = base::apple::CFToNSPtrCast(dict.get());
NSNumber* lmp_version =
base::mac::ObjCCast<NSNumber>(objc_dict[@"LMPVersion"]);
base::apple::ObjCCast<NSNumber>(objc_dict[@"LMPVersion"]);
if (!lmp_version)
continue;
@ -51,7 +51,7 @@ BluetoothAvailability GetBluetoothAvailability() {
continue;
NSData* data =
base::mac::ObjCCast<NSData>(objc_dict[@"HCISupportedFeatures"]);
base::apple::ObjCCast<NSData>(objc_dict[@"HCISupportedFeatures"]);
NSUInteger supported_features_index = 4;
NSUInteger length = [data length];

@ -13,9 +13,9 @@
#include "base/apple/bridging.h"
#include "base/apple/bundle_locations.h"
#include "base/apple/foundation_util.h"
#include "base/apple/scoped_cftyperef.h"
#include "base/logging.h"
#include "base/mac/foundation_util.h"
#include "base/mac/launchd.h"
#include "build/branding_buildflags.h"
@ -53,7 +53,7 @@ NSDictionary* DockFileDataDictionaryForURL(NSURL* url) {
base::ScopedCFTypeRef<CFPropertyListRef> property_list(
_CFURLCopyPropertyListRepresentation(base::apple::NSToCFPtrCast(url)));
CFDictionaryRef dictionary =
base::mac::CFCast<CFDictionaryRef>(property_list);
base::apple::CFCast<CFDictionaryRef>(property_list);
if (!dictionary)
return nil;
@ -128,7 +128,7 @@ BOOL IsAppAtPathAWebBrowser(NSString* app_path) {
if (!app_bundle)
return NO;
NSArray* activities = base::mac::ObjCCast<NSArray>(
NSArray* activities = base::apple::ObjCCast<NSArray>(
[app_bundle objectForInfoDictionaryKey:@"NSUserActivityTypes"]);
if (!activities)
return NO;

@ -4,8 +4,8 @@
#include "chrome/browser/mac/initial_prefs.h"
#include "base/apple/foundation_util.h"
#include "base/files/file_util.h"
#include "base/mac/foundation_util.h"
#include "build/branding_buildflags.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/chrome_paths_internal.h"
@ -67,8 +67,9 @@ base::FilePath InitialPrefsPath() {
// On chromium builds, try
// /Library/Application Support/Chromium/Chromium Master Preferences
base::FilePath search_path;
if (!base::mac::GetLocalDirectory(kSearchPath, &search_path))
if (!base::apple::GetLocalDirectory(kSearchPath, &search_path)) {
return base::FilePath();
}
base::FilePath new_path = search_path.Append(kInitialPreferencesDirectory)
.Append(kInitialPreferencesFileName);

@ -21,6 +21,7 @@
#include "base/apple/bridging.h"
#include "base/apple/bundle_locations.h"
#include "base/apple/foundation_util.h"
#include "base/apple/mach_logging.h"
#include "base/apple/osstatus_logging.h"
#include "base/apple/scoped_cftyperef.h"
@ -29,7 +30,6 @@
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/mac/authorization_util.h"
#include "base/mac/foundation_util.h"
#include "base/mac/mac_util.h"
#include "base/mac/scoped_authorizationref.h"
#include "base/mac/scoped_ioobject.h"
@ -136,7 +136,7 @@ bool MediaResidesOnDiskImage(base::mac::ScopedIOObject<io_service_t> media,
}
CFStringRef disk_image_url_string =
base::mac::CFCast<CFStringRef>(disk_image_url_cftyperef.get());
base::apple::CFCast<CFStringRef>(disk_image_url_cftyperef.get());
if (!disk_image_url_string) {
base::ScopedCFTypeRef<CFStringRef> observed_type_cf(
CFCopyTypeIDDescription(CFGetTypeID(disk_image_url_cftyperef)));
@ -183,7 +183,7 @@ bool MediaResidesOnDiskImage(base::mac::ScopedIOObject<io_service_t> media,
}
CFDataRef image_path_data =
base::mac::CFCast<CFDataRef>(image_path_cftyperef.get());
base::apple::CFCast<CFDataRef>(image_path_cftyperef.get());
if (!image_path_data) {
base::ScopedCFTypeRef<CFStringRef> observed_type_cf(
CFCopyTypeIDDescription(CFGetTypeID(image_path_cftyperef)));
@ -388,7 +388,7 @@ bool InstallFromDiskImage(base::mac::ScopedAuthorizationRef authorization,
// call EjectAndTrashDiskImage on dmg_bsd_device_name.
bool LaunchInstalledApp(NSString* installed_path,
const std::string& dmg_bsd_device_name) {
base::FilePath browser_path = base::mac::NSStringToFilePath(installed_path);
base::FilePath browser_path = base::apple::NSStringToFilePath(installed_path);
base::FilePath helper_path = browser_path.Append("Contents/Frameworks");
helper_path = helper_path.Append(chrome::kFrameworkName);

@ -13,13 +13,13 @@
#include "base/apple/bridging.h"
#include "base/apple/bundle_locations.h"
#include "base/apple/foundation_util.h"
#include "base/apple/osstatus_logging.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/foundation_util.h"
#include "base/memory/ref_counted.h"
#include "base/no_destructor.h"
#include "base/strings/string_number_conversions.h"
@ -302,15 +302,16 @@ NSString* const kVersionKey = @"KSVersion";
NSDictionary* infoDictionary = self.infoDictionary;
NSString* productID =
base::mac::ObjCCast<NSString>(infoDictionary[@"KSProductID"]);
base::apple::ObjCCast<NSString>(infoDictionary[@"KSProductID"]);
if (productID == nil) {
productID = appBundle.bundleIdentifier;
}
NSString* appPath = appBundle.bundlePath;
NSString* url = base::mac::ObjCCast<NSString>(infoDictionary[@"KSUpdateURL"]);
NSString* url =
base::apple::ObjCCast<NSString>(infoDictionary[@"KSUpdateURL"]);
NSString* version =
base::mac::ObjCCast<NSString>(infoDictionary[kVersionKey]);
base::apple::ObjCCast<NSString>(infoDictionary[kVersionKey]);
if (!productID || !appPath || !url || !version) {
// If parameters required for Keystone are missing, don't use it.
@ -386,14 +387,14 @@ NSString* const kVersionKey = @"KSVersion";
NSDictionary* infoDictionary = [self infoDictionary];
NSString* appBundleBrandID =
base::mac::ObjCCast<NSString>(infoDictionary[kBrandKey]);
base::apple::ObjCCast<NSString>(infoDictionary[kBrandKey]);
NSString* storedBrandID = nil;
if ([fm fileExistsAtPath:userBrandFile]) {
NSDictionary* storedBrandDict =
[NSDictionary dictionaryWithContentsOfFile:userBrandFile];
storedBrandID =
base::mac::ObjCCast<NSString>(storedBrandDict[kBrandKey]);
base::apple::ObjCCast<NSString>(storedBrandDict[kBrandKey]);
}
if ((appBundleBrandID != nil) &&
@ -543,8 +544,8 @@ NSString* const kVersionKey = @"KSVersion";
- (void)registrationComplete:(NSNotification*)notification {
NSDictionary* userInfo = notification.userInfo;
NSNumber* status =
base::mac::ObjCCast<NSNumber>(userInfo[ksr::KSRegistrationStatusKey]);
NSString* errorMessages = base::mac::ObjCCast<NSString>(
base::apple::ObjCCast<NSNumber>(userInfo[ksr::KSRegistrationStatusKey]);
NSString* errorMessages = base::apple::ObjCCast<NSString>(
userInfo[ksr::KSRegistrationUpdateCheckRawErrorMessagesKey]);
if (status.boolValue) {
@ -596,11 +597,11 @@ NSString* const kVersionKey = @"KSVersion";
- (void)checkForUpdateComplete:(NSNotification*)notification {
NSDictionary* userInfo = notification.userInfo;
NSNumber* error = base::mac::ObjCCast<NSNumber>(
NSNumber* error = base::apple::ObjCCast<NSNumber>(
userInfo[ksr::KSRegistrationUpdateCheckErrorKey]);
NSNumber* status =
base::mac::ObjCCast<NSNumber>(userInfo[ksr::KSRegistrationStatusKey]);
NSString* errorMessages = base::mac::ObjCCast<NSString>(
base::apple::ObjCCast<NSNumber>(userInfo[ksr::KSRegistrationStatusKey]);
NSString* errorMessages = base::apple::ObjCCast<NSString>(
userInfo[ksr::KSRegistrationUpdateCheckRawErrorMessagesKey]);
if (error.boolValue) {
@ -610,8 +611,8 @@ NSString* const kVersionKey = @"KSVersion";
} else if (status.boolValue) {
// If an update is known to be available, go straight to
// -updateStatus:version:. It doesn't matter what's currently on disk.
NSString* version =
base::mac::ObjCCast<NSString>(userInfo[ksr::KSRegistrationVersionKey]);
NSString* version = base::apple::ObjCCast<NSString>(
userInfo[ksr::KSRegistrationVersionKey]);
[self updateStatus:kAutoupdateAvailable
version:version
error:errorMessages];
@ -641,9 +642,9 @@ NSString* const kVersionKey = @"KSVersion";
- (void)installUpdateComplete:(NSNotification*)notification {
NSDictionary* userInfo = notification.userInfo;
NSNumber* successfulInstall = base::mac::ObjCCast<NSNumber>(
NSNumber* successfulInstall = base::apple::ObjCCast<NSNumber>(
userInfo[ksr::KSUpdateCheckSuccessfullyInstalledKey]);
NSString* errorMessages = base::mac::ObjCCast<NSString>(
NSString* errorMessages = base::apple::ObjCCast<NSString>(
userInfo[ksr::KSRegistrationUpdateCheckRawErrorMessagesKey]);
// http://crbug.com/160308 and b/7517358: when using system Keystone and on
@ -667,7 +668,7 @@ NSString* const kVersionKey = @"KSVersion";
NSString* appInfoPlistPath = [self appInfoPlistPath];
NSDictionary* infoPlist =
[NSDictionary dictionaryWithContentsOfFile:appInfoPlistPath];
return base::mac::ObjCCast<NSString>(
return base::apple::ObjCCast<NSString>(
infoPlist[@"CFBundleShortVersionString"]);
}
@ -752,8 +753,8 @@ NSString* const kVersionKey = @"KSVersion";
- (AutoupdateStatus)recentStatus {
NSDictionary* dictionary = _recentNotification.userInfo;
NSNumber* status =
base::mac::ObjCCastStrict<NSNumber>(dictionary[kAutoupdateStatusStatus]);
NSNumber* status = base::apple::ObjCCastStrict<NSNumber>(
dictionary[kAutoupdateStatusStatus]);
return static_cast<AutoupdateStatus>(status.intValue);
}
@ -818,7 +819,7 @@ NSString* const kVersionKey = @"KSVersion";
// If the bundled version is missing or broken, this question is irrelevant.
NSString* bundledKeystoneVersionString =
base::mac::ObjCCast<NSString>(bundledKeystonePlistContents[versionKey]);
base::apple::ObjCCast<NSString>(bundledKeystonePlistContents[versionKey]);
if (!bundledKeystoneVersionString.length)
return YES;
base::Version bundled_version(
@ -827,7 +828,7 @@ NSString* const kVersionKey = @"KSVersion";
return YES;
NSString* systemKeystoneVersionString =
base::mac::ObjCCast<NSString>(systemKeystonePlistContents[versionKey]);
base::apple::ObjCCast<NSString>(systemKeystonePlistContents[versionKey]);
if (!systemKeystoneVersionString.length)
return NO;
@ -1040,7 +1041,7 @@ NSString* const kVersionKey = @"KSVersion";
- (void)promotionComplete:(NSNotification*)notification {
NSDictionary* userInfo = notification.userInfo;
NSNumber* status =
base::mac::ObjCCast<NSNumber>(userInfo[ksr::KSRegistrationStatusKey]);
base::apple::ObjCCast<NSNumber>(userInfo[ksr::KSRegistrationStatusKey]);
if (status.boolValue) {
if (_synchronousPromotion) {
@ -1173,7 +1174,7 @@ std::string BrandCodeInternal() {
NSDictionary* dict =
[NSDictionary dictionaryWithContentsOfFile:brand_path];
NSString* brand_code = base::mac::ObjCCast<NSString>(dict[kBrandKey]);
NSString* brand_code = base::apple::ObjCCast<NSString>(dict[kBrandKey]);
if (brand_code)
return base::SysNSStringToUTF8(brand_code);

@ -6,13 +6,13 @@
#import <AVFoundation/AVFoundation.h>
#include "base/apple/foundation_util.h"
#include "base/apple/scoped_cftyperef.h"
#include "base/check.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/mac/foundation_util.h"
#include "base/no_destructor.h"
#import "base/task/sequenced_task_runner.h"
#include "base/task/sequenced_task_runner.h"

@ -6,8 +6,8 @@
#import <Cocoa/Cocoa.h>
#include "base/apple/foundation_util.h"
#include "base/apple/scoped_cftyperef.h"
#include "base/mac/foundation_util.h"
#include "third_party/libyuv/include/libyuv/convert_argb.h"
#include "third_party/skia/include/core/SkBitmap.h"
@ -24,10 +24,10 @@ gfx::ImageSkia GetWindowIcon(content::DesktopMediaID id) {
return gfx::ImageSkia();
}
CFDictionaryRef window = base::mac::CFCastStrict<CFDictionaryRef>(
CFDictionaryRef window = base::apple::CFCastStrict<CFDictionaryRef>(
CFArrayGetValueAtIndex(window_array, 0));
CFNumberRef pid_ref =
base::mac::GetValueFromDictionary<CFNumberRef>(window, kCGWindowOwnerPID);
CFNumberRef pid_ref = base::apple::GetValueFromDictionary<CFNumberRef>(
window, kCGWindowOwnerPID);
int pid;
CFNumberGetValue(pid_ref, kCFNumberIntType, &pid);

@ -18,7 +18,7 @@
#include "net/test/python_utils.h"
#if BUILDFLAG(IS_APPLE)
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
#endif
namespace {
@ -46,8 +46,9 @@ bool GetPyProtoPath(base::FilePath* dir) {
}
#if BUILDFLAG(IS_APPLE)
if (base::mac::AmIBundled())
if (base::apple::AmIBundled()) {
generated_code_dir = generated_code_dir.DirName().DirName().DirName();
}
#endif
const base::FilePath kPyProto(FILE_PATH_LITERAL("pyproto"));

@ -7,11 +7,11 @@
#include "base/files/file_path.h"
#include "base/apple/bridging.h"
#include "base/apple/foundation_util.h"
#include "base/files/file.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/mac/foundation_util.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/sys_string_conversions.h"
#include "base/synchronization/waitable_event.h"
@ -87,7 +87,7 @@ const char kTestFileContents[] = "test";
didDownloadSelector:(SEL)selector
contextInfo:(void*)contextInfo {
base::FilePath saveDir =
base::mac::NSURLToFilePath(options[ICDownloadsDirectoryURL]);
base::apple::NSURLToFilePath(options[ICDownloadsDirectoryURL]);
std::string saveAsFilename =
base::SysNSStringToUTF8(options[ICSaveAsFilename]);
// It appears that the ImageCapture library adds an extension to the requested

@ -29,7 +29,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(IS_MAC)
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#endif // BUILDFLAG(IS_MAC)

@ -10,10 +10,10 @@
#include <set>
#include <string>
#include "base/apple/foundation_util.h"
#include "base/file_version_info.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/mac/foundation_util.h"
#include "base/process/process_iterator.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"

@ -9,9 +9,9 @@
#include <Security/Authorization.h>
#include "base/apple/bundle_locations.h"
#include "base/apple/foundation_util.h"
#include "base/apple/osstatus_logging.h"
#include "base/mac/authorization_util.h"
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_authorizationref.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/grit/chromium_strings.h"

@ -6,13 +6,13 @@
#import <Cocoa/Cocoa.h>
#include "base/apple/foundation_util.h"
#include "base/apple/osstatus_logging.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/browser/platform_util_internal.h"
#include "content/public/browser/browser_task_traits.h"
@ -38,7 +38,7 @@ bool WorkspacePathRevealDisabledForTest() {
void ShowItemInFolder(Profile* profile, const base::FilePath& full_path) {
DCHECK([NSThread isMainThread]);
NSURL* url = base::mac::FilePathToNSURL(full_path);
NSURL* url = base::apple::FilePathToNSURL(full_path);
// The Finder creates a new window on each `full_path` reveal. Skip
// revealing the path during testing to avoid an avalanche of new
@ -52,7 +52,7 @@ void ShowItemInFolder(Profile* profile, const base::FilePath& full_path) {
void OpenFileOnMainThread(const base::FilePath& full_path) {
DCHECK([NSThread isMainThread]);
NSURL* url = base::mac::FilePathToNSURL(full_path);
NSURL* url = base::apple::FilePathToNSURL(full_path);
if (!url)
return;
@ -71,7 +71,7 @@ void PlatformOpenVerifiedItem(const base::FilePath& path, OpenItemType type) {
FROM_HERE, base::BindOnce(&OpenFileOnMainThread, path));
return;
case OPEN_FOLDER:
NSURL* url = base::mac::FilePathToNSURL(path);
NSURL* url = base::apple::FilePathToNSURL(path);
if (!url)
return;

@ -6,6 +6,7 @@
#include <string>
#include "base/apple/foundation_util.h"
#include "base/apple/scoped_cftyperef.h"
#include "base/base64url.h"
#include "base/files/file_util.h"
@ -14,7 +15,6 @@
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/hash/sha1.h"
#include "base/mac/foundation_util.h"
#include "base/mac/mac_util.h"
#include "base/mac/scoped_ioobject.h"
#include "base/metrics/histogram_functions.h"
@ -116,7 +116,7 @@ bool GetEnrollmentTokenFromPolicy(std::string* enrollment_token) {
!CFPreferencesAppValueIsForced(kEnrollmentTokenPolicyName, kBundleId)) {
return false;
}
CFStringRef value_string = base::mac::CFCast<CFStringRef>(value);
CFStringRef value_string = base::apple::CFCast<CFStringRef>(value);
if (!value_string)
return false;
@ -146,7 +146,7 @@ absl::optional<bool> IsEnrollmentMandatoryByPolicy() {
return absl::optional<bool>();
}
CFBooleanRef value_bool = base::mac::CFCast<CFBooleanRef>(value);
CFBooleanRef value_bool = base::apple::CFCast<CFBooleanRef>(value);
if (!value_bool)
return absl::optional<bool>();
return value_bool == kCFBooleanTrue;

@ -7,12 +7,12 @@
#include <iostream>
#include <memory>
#include "base/apple/foundation_util.h"
#include "base/base64url.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/hash/sha1.h"
#include "base/mac/foundation_util.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"

@ -49,7 +49,7 @@
#include "components/policy/core/common/policy_loader_win.h"
#elif BUILDFLAG(IS_MAC)
#include <CoreFoundation/CoreFoundation.h>
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#include "components/policy/core/common/policy_loader_mac.h"
#include "components/policy/core/common/preferences_mac.h"
@ -324,7 +324,7 @@ ChromeBrowserPolicyConnector::CreatePlatformProvider() {
CFStringRef bundle_id = CFSTR("com.google.Chrome");
#else
base::ScopedCFTypeRef<CFStringRef> bundle_id(
base::SysUTF8ToCFStringRef(base::mac::BaseBundleID()));
base::SysUTF8ToCFStringRef(base::apple::BaseBundleID()));
#endif
auto loader = std::make_unique<PolicyLoaderMac>(
base::ThreadPool::CreateSequencedTaskRunner(

@ -10,10 +10,10 @@
#include <string>
#include "base/apple/foundation_util.h"
#include "base/apple/scoped_cftyperef.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#include "build/branding_buildflags.h"
#include "components/policy/policy_constants.h"
@ -104,7 +104,7 @@ void CheckUserDataDirPolicy(base::FilePath* user_data_dir) {
CFStringRef bundle_id = CFSTR("com.google.Chrome");
#else
base::ScopedCFTypeRef<CFStringRef> bundle_id(
base::SysUTF8ToCFStringRef(base::mac::BaseBundleID()));
base::SysUTF8ToCFStringRef(base::apple::BaseBundleID()));
#endif
base::ScopedCFTypeRef<CFStringRef> key(
@ -114,7 +114,7 @@ void CheckUserDataDirPolicy(base::FilePath* user_data_dir) {
if (!value || !CFPreferencesAppValueIsForced(key, bundle_id))
return;
CFStringRef value_string = base::mac::CFCast<CFStringRef>(value);
CFStringRef value_string = base::apple::CFCast<CFStringRef>(value);
if (!value_string)
return;

@ -10,11 +10,11 @@
#include <memory>
#include "base/apple/bundle_locations.h"
#include "base/apple/foundation_util.h"
#include "base/apple/scoped_cftyperef.h"
#include "base/files/file.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/mac/foundation_util.h"
#include "base/path_service.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/browser/safe_browsing/incident_reporting/incident.h"

@ -12,8 +12,8 @@
#include <sys/xattr.h>
#include "base/apple/bridging.h"
#include "base/apple/foundation_util.h"
#include "base/apple/scoped_cftyperef.h"
#include "base/mac/foundation_util.h"
#include "base/mac/mac_util.h"
#include "base/strings/string_util.h"
#include "base/strings/sys_string_conversions.h"
@ -49,15 +49,15 @@ bool GetPathFromCFObject(CFTypeRef obj, std::string* output) {
// cheat by bridging to Foundation types.
id ns_obj = (__bridge id)obj;
if (NSString* str = base::mac::ObjCCast<NSString>(ns_obj)) {
if (NSString* str = base::apple::ObjCCast<NSString>(ns_obj)) {
output->assign(str.fileSystemRepresentation);
return true;
}
if (NSURL* url = base::mac::ObjCCast<NSURL>(ns_obj)) {
if (NSURL* url = base::apple::ObjCCast<NSURL>(ns_obj)) {
output->assign(url.path.fileSystemRepresentation);
return true;
}
if (NSBundle* bundle = base::mac::ObjCCast<NSBundle>(ns_obj)) {
if (NSBundle* bundle = base::apple::ObjCCast<NSBundle>(ns_obj)) {
output->assign(bundle.bundlePath.fileSystemRepresentation);
return true;
}
@ -101,7 +101,7 @@ void ReportAlteredFiles(
CFTypeRef detail,
const base::FilePath& bundle_path,
ClientIncidentReport_IncidentData_BinaryIntegrityIncident* incident) {
if (CFArrayRef array = base::mac::CFCast<CFArrayRef>(detail)) {
if (CFArrayRef array = base::apple::CFCast<CFArrayRef>(detail)) {
for (CFIndex i = 0; i < CFArrayGetCount(array); ++i) {
ReportAlteredFiles(CFArrayGetValueAtIndex(array, i), bundle_path,
incident);
@ -176,7 +176,8 @@ bool MacSignatureEvaluator::GetRelativePathComponent(
}
bool MacSignatureEvaluator::Initialize() {
base::ScopedCFTypeRef<CFURLRef> code_url = base::mac::FilePathToCFURL(path_);
base::ScopedCFTypeRef<CFURLRef> code_url =
base::apple::FilePathToCFURL(path_);
if (!code_url)
return false;
@ -214,13 +215,13 @@ bool MacSignatureEvaluator::PerformEvaluation(
if (SecCodeCopySigningInformation(code_, kSecCSDefaultFlags,
info_dict.InitializeInto()) ==
errSecSuccess) {
CFURLRef exec_url = base::mac::CFCastStrict<CFURLRef>(
CFURLRef exec_url = base::apple::CFCastStrict<CFURLRef>(
CFDictionaryGetValue(info_dict, kSecCodeInfoMainExecutable));
if (!exec_url)
return false;
exec_path =
base::mac::NSURLToFilePath(base::apple::CFToNSPtrCast(exec_url));
base::apple::NSURLToFilePath(base::apple::CFToNSPtrCast(exec_url));
if (exec_path != path_) {
ReportAlteredFiles(exec_url, path_, incident);
} else {

@ -9,8 +9,8 @@
#include "base/apple/bridging.h"
#include "base/apple/bundle_locations.h"
#include "base/apple/foundation_util.h"
#include "base/apple/scoped_cftyperef.h"
#include "base/mac/foundation_util.h"
#include "base/mac/mac_util.h"
#include "base/strings/sys_string_conversions.h"
#include "build/branding_buildflags.h"
@ -187,14 +187,14 @@ std::vector<base::FilePath> GetAllApplicationPathsForURL(const GURL& url) {
std::vector<base::FilePath> app_paths;
app_paths.reserve(app_urls.count);
for (NSURL* app_url in app_urls) {
app_paths.push_back(base::mac::NSURLToFilePath(app_url));
app_paths.push_back(base::apple::NSURLToFilePath(app_url));
}
return app_paths;
}
bool CanApplicationHandleURL(const base::FilePath& app_path, const GURL& url) {
NSURL* ns_item_url = net::NSURLWithGURL(url);
NSURL* ns_app_url = base::mac::FilePathToNSURL(app_path);
NSURL* ns_app_url = base::apple::FilePathToNSURL(app_path);
Boolean result = FALSE;
LSCanURLAcceptURL(base::apple::NSToCFPtrCast(ns_item_url),
base::apple::NSToCFPtrCast(ns_app_url), kLSRolesAll,

@ -4,7 +4,7 @@
#import "chrome/browser/ui/cocoa/applescript/bookmark_item_applescript.h"
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#import "chrome/browser/app_controller_mac.h"
#import "chrome/browser/ui/cocoa/applescript/apple_event_util.h"

@ -4,9 +4,9 @@
#import "chrome/browser/ui/cocoa/applescript/bookmark_node_applescript.h"
#import "base/apple/foundation_util.h"
#include "base/check.h"
#include "base/check_op.h"
#import "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#include "base/uuid.h"
#import "chrome/browser/app_controller_mac.h"

@ -8,7 +8,7 @@
#include <map>
#import "base/mac/foundation_util.h"
#import "base/apple/foundation_util.h"
#include "base/notreached.h"
#import "chrome/browser/app_controller_mac.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"

@ -4,7 +4,7 @@
#import <Foundation/Foundation.h>
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
@ -109,9 +109,9 @@ IN_PROC_BROWSER_TEST_F(BrowserCrApplicationAppleScriptTest, BookmarkFolders) {
}
BookmarkFolderAppleScript* other_bookmarks =
base::mac::ObjCCast<BookmarkFolderAppleScript>([NSApp otherBookmarks]);
base::apple::ObjCCast<BookmarkFolderAppleScript>([NSApp otherBookmarks]);
EXPECT_NSEQ(@"Other Bookmarks", other_bookmarks.title);
BookmarkFolderAppleScript* bookmarks_bar =
base::mac::ObjCCast<BookmarkFolderAppleScript>([NSApp bookmarksBar]);
base::apple::ObjCCast<BookmarkFolderAppleScript>([NSApp bookmarksBar]);
EXPECT_NSEQ(@"Bookmarks Bar", bookmarks_bar.title);
}

@ -6,7 +6,7 @@
#include <Foundation/Foundation.h>
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
@implementation ElementAppleScript
@ -19,7 +19,7 @@
// you can call this method.
- (NSScriptObjectSpecifier*)objectSpecifier {
return [[NSUniqueIDSpecifier alloc]
initWithContainerClassDescription:base::mac::ObjCCast<
initWithContainerClassDescription:base::apple::ObjCCast<
NSScriptClassDescription>(
self.container.classDescription)
containerSpecifier:self.container.objectSpecifier

@ -4,10 +4,10 @@
#import "chrome/browser/ui/cocoa/applescript/tab_applescript.h"
#include "base/apple/foundation_util.h"
#include "base/check.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/mac/foundation_util.h"
#include "base/memory/weak_ptr.h"
#include "base/notreached.h"
#include "base/strings/sys_string_conversions.h"
@ -310,7 +310,7 @@ void ResumeAppleEventAndSendReply(NSAppleEventManagerSuspensionID suspension_id,
return;
}
base::FilePath mainFile = base::mac::NSURLToFilePath(fileURL);
base::FilePath mainFile = base::apple::NSURLToFilePath(fileURL);
// We create a directory path at the folder within which the file exists.
// Eg. if main_file = '/Users/Foo/Documents/Google.html'
// then directory_path = '/Users/Foo/Documents/Google_files/'.

@ -6,7 +6,7 @@
#include <memory>
#import "base/mac/foundation_util.h"
#import "base/apple/foundation_util.h"
#include "base/memory/weak_ptr.h"
#include "base/notreached.h"
#include "base/strings/sys_string_conversions.h"

@ -4,7 +4,7 @@
#import <Foundation/Foundation.h>
#import "base/mac/foundation_util.h"
#import "base/apple/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#import "chrome/browser/app_controller_mac.h"
#import "chrome/browser/chrome_browser_application_mac.h"

@ -6,9 +6,9 @@
#import <Cocoa/Cocoa.h>
#import "base/apple/foundation_util.h"
#import "base/apple/scoped_objc_class_swizzler.h"
#include "base/command_line.h"
#import "base/mac/foundation_util.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"

@ -8,9 +8,9 @@
#include <memory>
#import "base/apple/foundation_util.h"
#import "base/apple/scoped_cftyperef.h"
#include "base/functional/callback_helpers.h"
#import "base/mac/foundation_util.h"
#include "base/memory/raw_ptr.h"
#include "chrome/browser/apps/app_service/app_launch_params.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h"

@ -4,8 +4,8 @@
#include "chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac.h"
#import "base/apple/foundation_util.h"
#include "base/command_line.h"
#import "base/mac/foundation_util.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#import "chrome/browser/app_controller_mac.h"

@ -4,7 +4,7 @@
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h"
#import "base/mac/foundation_util.h"
#import "base/apple/foundation_util.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/user_metrics.h"
#include "base/strings/sys_string_conversions.h"

@ -4,8 +4,8 @@
#import "chrome/browser/ui/cocoa/browser_window_command_handler.h"
#import "base/apple/foundation_util.h"
#include "base/check.h"
#import "base/mac/foundation_util.h"
#include "base/notreached.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
@ -22,8 +22,8 @@
namespace {
void SetToggleState(bool toggled, id item) {
NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item);
NSButton* buttonItem = base::mac::ObjCCast<NSButton>(item);
NSMenuItem* menuItem = base::apple::ObjCCast<NSMenuItem>(item);
NSButton* buttonItem = base::apple::ObjCCast<NSButton>(item);
if (menuItem) {
NSControlStateValue old_state = [menuItem state];
NSControlStateValue new_state =
@ -87,7 +87,7 @@ remote_cocoa::NativeWidgetNSWindowBridge* FindBridgeForSender(
if (result->set_toggle_state)
SetToggleState(result->new_toggle_state, item);
if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) {
if (NSMenuItem* menuItem = base::apple::ObjCCast<NSMenuItem>(item)) {
if (result->disable_if_has_no_key_equivalent)
result->enable &= !![[menuItem keyEquivalent] length];

@ -59,7 +59,7 @@ IN_PROC_BROWSER_TEST_F(BrowserWindowMacTest, MenuCommandsAfterDestroy) {
IN_PROC_BROWSER_TEST_F(BrowserWindowMacTest,
DISABLED_MenuCommandsFromChildWindow) {
NativeWidgetMacNSWindow* window =
base::mac::ObjCCastStrict<NativeWidgetMacNSWindow>(
base::apple::ObjCCastStrict<NativeWidgetMacNSWindow>(
browser()->window()->GetNativeWindow().GetNativeNSWindow());
// Create a child window.

@ -7,8 +7,8 @@
#include <stdint.h>
#include "base/apple/bundle_locations.h"
#include "base/apple/foundation_util.h"
#include "base/check_op.h"
#include "base/mac/foundation_util.h"
#include "content/public/browser/browser_thread.h"
#include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
@ -209,7 +209,7 @@ constexpr int64_t kUpdateFrequencyMs = 200;
- (void)setDownloads:(int)downloads {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DockTileView* dockTileView =
base::mac::ObjCCast<DockTileView>(NSApp.dockTile.contentView);
base::apple::ObjCCast<DockTileView>(NSApp.dockTile.contentView);
if (downloads != [dockTileView downloads]) {
[dockTileView setDownloads:downloads];
@ -220,7 +220,7 @@ constexpr int64_t kUpdateFrequencyMs = 200;
- (void)setIndeterminate:(BOOL)indeterminate {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DockTileView* dockTileView =
base::mac::ObjCCast<DockTileView>(NSApp.dockTile.contentView);
base::apple::ObjCCast<DockTileView>(NSApp.dockTile.contentView);
if (indeterminate != [dockTileView indeterminate]) {
[dockTileView setIndeterminate:indeterminate];
@ -231,7 +231,7 @@ constexpr int64_t kUpdateFrequencyMs = 200;
- (void)setProgress:(float)progress {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DockTileView* dockTileView =
base::mac::ObjCCast<DockTileView>(NSApp.dockTile.contentView);
base::apple::ObjCCast<DockTileView>(NSApp.dockTile.contentView);
[dockTileView setProgress:progress];
}

@ -7,8 +7,8 @@
#include <stddef.h>
#include <string>
#include "base/apple/foundation_util.h"
#include "base/functional/bind.h"
#include "base/mac/foundation_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/sys_string_conversions.h"

@ -4,7 +4,7 @@
#import "chrome/browser/ui/cocoa/history_menu_cocoa_controller.h"
#import "base/mac/foundation_util.h"
#import "base/apple/foundation_util.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/user_metrics.h"
#include "chrome/app/chrome_command_ids.h" // IDC_HISTORY_MENU

@ -4,7 +4,7 @@
#include "chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac_cocoa.h"
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/extensions/application_launch.h"
@ -90,7 +90,8 @@ IN_PROC_BROWSER_TEST_F(RenderViewContextMenuMacCocoaBrowserTest,
// Bring up the contextual menu from the textfield (actually its field
// editor).
NSView* firstResponder = base::mac::ObjCCast<NSView>([window firstResponder]);
NSView* firstResponder =
base::apple::ObjCCast<NSView>([window firstResponder]);
[NSMenu popUpContextMenu:popupMenu
withEvent:[NSApp currentEvent]
forView:firstResponder];

@ -6,7 +6,7 @@
#import <ScreenTime/ScreenTime.h>
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/cocoa/screentime/history_deleter.h"

@ -6,7 +6,7 @@
#import <ScreenTime/ScreenTime.h>
#include "base/mac/foundation_util.h"
#include "base/apple/foundation_util.h"
#include "base/memory/ptr_util.h"
#include "base/notreached.h"
#include "base/strings/sys_string_conversions.h"
@ -53,7 +53,7 @@ void HistoryDeleterImpl::DeleteHistoryForURL(const GURL& url) {
HistoryDeleterImpl::HistoryDeleterImpl() {
if (@available(macOS 12.1, *)) {
NSError* error = nil;
NSString* bundle_id = base::SysUTF8ToNSString(base::mac::BaseBundleID());
NSString* bundle_id = base::SysUTF8ToNSString(base::apple::BaseBundleID());
platform_deleter_ = [[STWebHistory alloc] initWithBundleIdentifier:bundle_id
error:&error];
DCHECK(!error);

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