diff --git a/base/mac/launchd.cc b/base/mac/launchd.cc index 0337d2e609707..ded130682965a 100644 --- a/base/mac/launchd.cc +++ b/base/mac/launchd.cc @@ -7,6 +7,11 @@ #include "base/logging.h" #include "base/mac/scoped_launch_data.h" +// This file is written in terms of launch_data_t, which is deprecated but has +// no replacement. Ignore the deprecation warnings for now. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + namespace base { namespace mac { @@ -73,3 +78,5 @@ pid_t PIDForJob(const std::string& job_label) { } // namespace mac } // namespace base + +#pragma clang diagnostic pop diff --git a/base/mac/mac_util.mm b/base/mac/mac_util.mm index 4c6a0d1c49d2e..e4177d304f816 100644 --- a/base/mac/mac_util.mm +++ b/base/mac/mac_util.mm @@ -98,13 +98,16 @@ LSSharedFileListItemRef GetLoginItemForApp() { for(NSUInteger i = 0; i < [login_items_array count]; ++i) { LSSharedFileListItemRef item = reinterpret_cast<LSSharedFileListItemRef>(login_items_array[i]); - CFURLRef item_url_ref = NULL; + base::ScopedCFTypeRef<CFErrorRef> error; + CFURLRef item_url_ref = + LSSharedFileListItemCopyResolvedURL(item, 0, error.InitializeInto()); - // It seems that LSSharedFileListItemResolve() can return NULL in - // item_url_ref even if the function itself returns noErr. See - // https://crbug.com/760989 - if (LSSharedFileListItemResolve(item, 0, &item_url_ref, NULL) == noErr && - item_url_ref) { + // This function previously used LSSharedFileListItemResolve(), which could + // return a NULL URL even when returning no error. This caused + // <https://crbug.com/760989>. It's not clear one way or the other whether + // LSSharedFileListItemCopyResolvedURL() shares this behavior, so this check + // remains in place. + if (!error && item_url_ref) { ScopedCFTypeRef<CFURLRef> item_url(item_url_ref); if (CFEqual(item_url, url)) { CFRetain(item); diff --git a/base/mac/scoped_launch_data.h b/base/mac/scoped_launch_data.h index f4db3306d4250..e7ef0a8d4f2b2 100644 --- a/base/mac/scoped_launch_data.h +++ b/base/mac/scoped_launch_data.h @@ -9,6 +9,11 @@ #include "base/scoped_generic.h" +// This file uses launch_data_t and related APIs, which are deprecated with no +// replacement. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + namespace base { namespace mac { @@ -28,4 +33,6 @@ using ScopedLaunchData = } // namespace mac } // namespace base +#pragma clang diagnostic pop // -Wdeprecated-declarations + #endif // BASE_MAC_SCOPED_LAUNCH_DATA_H_ diff --git a/build/config/mac/mac_sdk.gni b/build/config/mac/mac_sdk.gni index 544c524d76eb0..1a6d170a7e3a0 100644 --- a/build/config/mac/mac_sdk.gni +++ b/build/config/mac/mac_sdk.gni @@ -14,7 +14,7 @@ declare_args() { # additional code changes are required to be compliant with the availability # rules. # Must be of the form x.x.x for Info.plist files. - mac_deployment_target = "10.9.0" + mac_deployment_target = "10.10.0" # The value of the LSMinimmumSystemVersion in Info.plist files. This partially # controls the minimum supported version of macOS for Chromium by diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm index 26d3bd7a0e202..7b78848b270c0 100644 --- a/chrome/browser/app_controller_mac.mm +++ b/chrome/browser/app_controller_mac.mm @@ -826,10 +826,15 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session; waitTitle = l10n_util::GetNSString(IDS_ABANDON_DOWNLOAD_DIALOG_CONTINUE_BUTTON); + base::scoped_nsobject<NSAlert> alert([[NSAlert alloc] init]); + [alert setMessageText:titleText]; + [alert setInformativeText:explanationText]; + [alert addButtonWithTitle:waitTitle]; + [alert addButtonWithTitle:exitTitle]; + // 'waitButton' is the default choice. - int choice = NSRunAlertPanel(titleText, @"%@", - waitTitle, exitTitle, nil, explanationText); - return choice == NSAlertDefaultReturn ? YES : NO; + int choice = [alert runModal]; + return choice == NSAlertFirstButtonReturn ? YES : NO; } // Check all profiles for in progress downloads, and if we find any, prompt the diff --git a/chrome/browser/media/router/discovery/discovery_network_list_wifi_mac.mm b/chrome/browser/media/router/discovery/discovery_network_list_wifi_mac.mm index b21b5da13c30a..40610665e04ec 100644 --- a/chrome/browser/media/router/discovery/discovery_network_list_wifi_mac.mm +++ b/chrome/browser/media/router/discovery/discovery_network_list_wifi_mac.mm @@ -12,6 +12,12 @@ #include "base/logging.h" #include "base/strings/sys_string_conversions.h" +// TODO(crbug.com/841631): This file uses the deprecated CWInterface interface; +// it needs to be migrated to CWWiFiClient, which is unfortunately not +// compatible. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + namespace media_router { namespace { @@ -42,3 +48,5 @@ bool MaybeGetWifiSSID(const std::string& if_name, std::string* ssid_out) { } } // namespace media_router + +#pragma clang diagnostic pop diff --git a/chrome/browser/media_galleries/mac/mtp_device_delegate_impl_mac_unittest.mm b/chrome/browser/media_galleries/mac/mtp_device_delegate_impl_mac_unittest.mm index 14eae355bf296..3cac8b3d818ca 100644 --- a/chrome/browser/media_galleries/mac/mtp_device_delegate_impl_mac_unittest.mm +++ b/chrome/browser/media_galleries/mac/mtp_device_delegate_impl_mac_unittest.mm @@ -116,8 +116,11 @@ const char kTestFileContents[] = "test"; - (id)init:(NSString*)name { if ((self = [super init])) { + base::scoped_nsobject<NSDateFormatter> iso8601day( + [[NSDateFormatter alloc] init]); + [iso8601day setDateFormat:@"yyyy-MM-dd"]; name_.reset([name retain]); - date_.reset([[NSDate dateWithNaturalLanguageString:@"12/12/12"] retain]); + date_.reset([[iso8601day dateFromString:@"2012-12-12"] retain]); } return self; } diff --git a/chrome/browser/shell_integration_mac.mm b/chrome/browser/shell_integration_mac.mm index 747450788963f..7d0b4300ebf0a 100644 --- a/chrome/browser/shell_integration_mac.mm +++ b/chrome/browser/shell_integration_mac.mm @@ -121,17 +121,14 @@ DefaultWebClientSetPermission GetDefaultWebClientSetPermission() { base::string16 GetApplicationNameForProtocol(const GURL& url) { NSURL* ns_url = [NSURL URLWithString: base::SysUTF8ToNSString(url.possibly_invalid_spec())]; - CFURLRef openingApp = NULL; - OSStatus status = LSGetApplicationForURL((CFURLRef)ns_url, - kLSRolesAll, - NULL, - &openingApp); - if (status != noErr) { + base::ScopedCFTypeRef<CFErrorRef> out_err; + base::ScopedCFTypeRef<CFURLRef> openingApp(LSCopyDefaultApplicationURLForURL( + (CFURLRef)ns_url, kLSRolesAll, out_err.InitializeInto())); + if (out_err) { // likely kLSApplicationNotFoundErr return base::string16(); } - NSString* appPath = [(NSURL*)openingApp path]; - CFRelease(openingApp); // NOT A BUG; LSGetApplicationForURL retains for us + NSString* appPath = [base::mac::CFToNSCast(openingApp.get()) path]; NSString* appDisplayName = [[NSFileManager defaultManager] displayNameAtPath:appPath]; return base::SysNSStringToUTF16(appDisplayName); diff --git a/chrome/browser/ui/cocoa/touchbar/browser_window_default_touch_bar.mm b/chrome/browser/ui/cocoa/touchbar/browser_window_default_touch_bar.mm index 2bcd809e774e2..490da56009252 100644 --- a/chrome/browser/ui/cocoa/touchbar/browser_window_default_touch_bar.mm +++ b/chrome/browser/ui/cocoa/touchbar/browser_window_default_touch_bar.mm @@ -407,6 +407,11 @@ class API_AVAILABLE(macos(10.12.2)) TouchBarNotificationBridge return touchBar.autorelease(); } +// TODO(crbug.com/921109): Migrate to the new NSAccessibility API for this +// method. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + - (void)setupBackForwardControl { NSMutableArray* images = [NSMutableArray arrayWithArray:@[ CreateNSImageFromIcon(vector_icons::kBackArrowIcon), @@ -451,6 +456,8 @@ class API_AVAILABLE(macos(10.12.2)) TouchBarNotificationBridge backForwardControl_.reset([control retain]); } +#pragma clang diagnostic pop + - (void)updateWebContents:(content::WebContents*)contents { notificationBridge_->UpdateWebContents(contents); } diff --git a/chrome/browser/web_applications/components/web_app_shortcut_mac.mm b/chrome/browser/web_applications/components/web_app_shortcut_mac.mm index 6751a3379d24e..376544ae41fc6 100644 --- a/chrome/browser/web_applications/components/web_app_shortcut_mac.mm +++ b/chrome/browser/web_applications/components/web_app_shortcut_mac.mm @@ -935,17 +935,8 @@ std::vector<base::FilePath> WebAppShortcutCreator::GetAppBundlesByIdUnsorted() base::SysUTF8ToCFStringRef(GetBundleIdentifier())); // Retrieve the URLs found by LaunchServices. - base::scoped_nsobject<NSArray> urls; - if (@available(macOS 10.10, *)) { - urls.reset(base::mac::CFToNSCast( - LSCopyApplicationURLsForBundleIdentifier(bundle_id_cf.get(), nullptr))); - } else { - base::ScopedCFTypeRef<CFURLRef> cf_url; - LSFindApplicationForInfo(kLSUnknownCreator, bundle_id_cf.get(), NULL, NULL, - cf_url.InitializeInto()); - if (cf_url) - urls.reset([@[ base::mac::CFToNSCast(cf_url) ] retain]); - } + base::scoped_nsobject<NSArray> urls(base::mac::CFToNSCast( + LSCopyApplicationURLsForBundleIdentifier(bundle_id_cf.get(), nullptr))); // Store only those results corresponding to this user data dir. std::vector<base::FilePath> paths; diff --git a/chrome/common/importer/firefox_importer_utils_mac.mm b/chrome/common/importer/firefox_importer_utils_mac.mm index ac9cf412246c7..1152a5645edf0 100644 --- a/chrome/common/importer/firefox_importer_utils_mac.mm +++ b/chrome/common/importer/firefox_importer_utils_mac.mm @@ -25,17 +25,17 @@ base::FilePath GetProfilesINI() { } base::FilePath GetFirefoxDylibPath() { - CFURLRef appURL = nil; - if (LSFindApplicationForInfo(kLSUnknownCreator, - CFSTR("org.mozilla.firefox"), - NULL, - NULL, - &appURL) != noErr) { + base::ScopedCFTypeRef<CFErrorRef> out_err; + base::ScopedCFTypeRef<CFArrayRef> app_urls( + LSCopyApplicationURLsForBundleIdentifier(CFSTR("org.mozilla.firefox"), + out_err.InitializeInto())); + if (out_err || CFArrayGetCount(app_urls) == 0) { return base::FilePath(); } - NSBundle *ff_bundle = - [NSBundle bundleWithPath:[base::mac::CFToNSCast(appURL) path]]; - CFRelease(appURL); + CFURLRef app_url = + base::mac::CFCastStrict<CFURLRef>(CFArrayGetValueAtIndex(app_urls, 0)); + NSBundle* ff_bundle = + [NSBundle bundleWithPath:[base::mac::CFToNSCast(app_url) path]]; NSString *ff_library_path = [[ff_bundle executablePath] stringByDeletingLastPathComponent]; char buf[MAXPATHLEN]; diff --git a/chrome/common/mac/service_management.mm b/chrome/common/mac/service_management.mm index 52dbdd6e81f9b..5861c7c849f59 100644 --- a/chrome/common/mac/service_management.mm +++ b/chrome/common/mac/service_management.mm @@ -17,6 +17,11 @@ #include "base/macros.h" #include "base/strings/sys_string_conversions.h" +// This entire file is written in terms of the launch_data_t API, which is +// deprecated with no replacement, so just ignore the warnings for now. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + namespace { class ScopedLaunchData { @@ -260,3 +265,5 @@ bool RemoveJob(const std::string& label) { } // namespace services } // namespace mac + +#pragma clang diagnostic pop diff --git a/components/download/quarantine/common_mac.h b/components/download/quarantine/common_mac.h index 3d51b1c2aab46..179bb137ce085 100644 --- a/components/download/quarantine/common_mac.h +++ b/components/download/quarantine/common_mac.h @@ -15,10 +15,6 @@ class FilePath; namespace download { -bool GetQuarantinePropertiesDeprecated( - const base::FilePath& file, - base::scoped_nsobject<NSMutableDictionary>* properties); - bool GetQuarantineProperties( const base::FilePath& file, base::scoped_nsobject<NSMutableDictionary>* properties); diff --git a/components/download/quarantine/common_mac.mm b/components/download/quarantine/common_mac.mm index 3682e0a886f42..a8ccaeba2b326 100644 --- a/components/download/quarantine/common_mac.mm +++ b/components/download/quarantine/common_mac.mm @@ -17,46 +17,6 @@ namespace download { -// Once Chrome no longer supports macOS 10.9, this code will no longer be -// necessary. Note that LSCopyItemAttribute was deprecated in macOS 10.8, but -// the replacement to kLSItemQuarantineProperties did not exist until macOS -// 10.10. -#if !defined(MAC_OS_X_VERSION_10_10) || \ - MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10 -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" -bool GetQuarantinePropertiesDeprecated( - const base::FilePath& file, - base::scoped_nsobject<NSMutableDictionary>* properties) { - const UInt8* path = reinterpret_cast<const UInt8*>(file.value().c_str()); - FSRef file_ref; - if (FSPathMakeRef(path, &file_ref, nullptr) != noErr) - return false; - - base::ScopedCFTypeRef<CFTypeRef> quarantine_properties; - OSStatus status = - LSCopyItemAttribute(&file_ref, kLSRolesAll, kLSItemQuarantineProperties, - quarantine_properties.InitializeInto()); - if (status != noErr) - return true; - - CFDictionaryRef quarantine_properties_dict = - base::mac::CFCast<CFDictionaryRef>(quarantine_properties.get()); - if (!quarantine_properties_dict) { - LOG(WARNING) << "kLSItemQuarantineProperties is not a dictionary on file " - << file.value(); - return false; - } - - properties->reset( - [base::mac::CFToNSCast(quarantine_properties_dict) mutableCopy]); - return true; -} - -#pragma clang diagnostic pop -#endif - -API_AVAILABLE(macos(10.10)) bool GetQuarantineProperties( const base::FilePath& file, base::scoped_nsobject<NSMutableDictionary>* properties) { diff --git a/components/download/quarantine/quarantine_mac.mm b/components/download/quarantine/quarantine_mac.mm index b4a33417bddfb..c43cac8e91ed1 100644 --- a/components/download/quarantine/quarantine_mac.mm +++ b/components/download/quarantine/quarantine_mac.mm @@ -23,34 +23,6 @@ namespace { -// Once Chrome no longer supports macOS 10.9, this code will no longer be -// necessary. Note that LSCopyItemAttribute was deprecated in macOS 10.8, but -// the replacement to kLSItemQuarantineProperties did not exist until macOS -// 10.10. -#if !defined(MAC_OS_X_VERSION_10_10) || \ - MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10 -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" -bool SetQuarantinePropertiesDeprecated(const base::FilePath& file, - NSDictionary* properties) { - const UInt8* path = reinterpret_cast<const UInt8*>(file.value().c_str()); - FSRef file_ref; - if (FSPathMakeRef(path, &file_ref, nullptr) != noErr) - return false; - - OSStatus os_error = LSSetItemAttribute( - &file_ref, kLSRolesAll, kLSItemQuarantineProperties, properties); - if (os_error != noErr) { - OSSTATUS_LOG(WARNING, os_error) - << "Unable to set quarantine attributes on file " << file.value(); - return false; - } - return true; -} -#pragma clang diagnostic pop -#endif - -API_AVAILABLE(macos(10.10)) bool SetQuarantineProperties(const base::FilePath& file, NSDictionary* properties) { base::scoped_nsobject<NSURL> file_url([[NSURL alloc] @@ -170,12 +142,7 @@ bool AddQuarantineMetadataToFile(const base::FilePath& file, const GURL& referrer) { base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK); base::scoped_nsobject<NSMutableDictionary> properties; - bool success = false; - if (@available(macos 10.10, *)) { - success = GetQuarantineProperties(file, &properties); - } else { - success = GetQuarantinePropertiesDeprecated(file, &properties); - } + bool success = GetQuarantineProperties(file, &properties); if (!success) return false; @@ -213,11 +180,7 @@ bool AddQuarantineMetadataToFile(const base::FilePath& file, [properties setValue:origin_url forKey:(NSString*)kLSQuarantineDataURLKey]; } - if (@available(macos 10.10, *)) { - return SetQuarantineProperties(file, properties); - } else { - return SetQuarantinePropertiesDeprecated(file, properties); - } + return SetQuarantineProperties(file, properties); } } // namespace diff --git a/components/download/quarantine/test_support_mac.mm b/components/download/quarantine/test_support_mac.mm index a1ebbd6d0f55d..7158aba6e135b 100644 --- a/components/download/quarantine/test_support_mac.mm +++ b/components/download/quarantine/test_support_mac.mm @@ -26,11 +26,7 @@ bool IsFileQuarantined(const base::FilePath& file, return false; base::scoped_nsobject<NSMutableDictionary> properties; - bool success = false; - if (@available(macos 10.10, *)) - success = GetQuarantineProperties(file, &properties); - else - success = GetQuarantinePropertiesDeprecated(file, &properties); + bool success = GetQuarantineProperties(file, &properties); if (!success || !properties) return false; diff --git a/components/storage_monitor/image_capture_device_manager_unittest.mm b/components/storage_monitor/image_capture_device_manager_unittest.mm index 02e1726fbd1e8..df886190499d7 100644 --- a/components/storage_monitor/image_capture_device_manager_unittest.mm +++ b/components/storage_monitor/image_capture_device_manager_unittest.mm @@ -157,8 +157,11 @@ const char kTestFileContents[] = "test"; - (instancetype)init:(NSString*)name { if ((self = [super init])) { + base::scoped_nsobject<NSDateFormatter> iso8601day( + [[NSDateFormatter alloc] init]); + [iso8601day setDateFormat:@"yyyy-MM-dd"]; name_.reset([name retain]); - date_.reset([[NSDate dateWithNaturalLanguageString:@"12/12/12"] retain]); + date_.reset([[iso8601day dateFromString:@"2012-12-12"] retain]); } return self; } diff --git a/components/wifi/wifi_service_mac.mm b/components/wifi/wifi_service_mac.mm index 4f46e1c7448f2..ad40c2a9fc5ad 100644 --- a/components/wifi/wifi_service_mac.mm +++ b/components/wifi/wifi_service_mac.mm @@ -165,7 +165,7 @@ WiFiServiceMac::~WiFiServiceMac() { void WiFiServiceMac::Initialize( scoped_refptr<base::SequencedTaskRunner> task_runner) { task_runner_.swap(task_runner); - interface_.reset([[CWInterface interface] retain]); + interface_.reset([[[CWWiFiClient sharedWiFiClient] interface] retain]); if (!interface_) { DVLOG(1) << "Failed to initialize default interface."; return; diff --git a/content/browser/accessibility/accessibility_tree_formatter_mac.mm b/content/browser/accessibility/accessibility_tree_formatter_mac.mm index 28d76d876a0e7..2f36e17bdb402 100644 --- a/content/browser/accessibility/accessibility_tree_formatter_mac.mm +++ b/content/browser/accessibility/accessibility_tree_formatter_mac.mm @@ -17,6 +17,11 @@ #include "content/browser/accessibility/browser_accessibility_mac.h" #include "content/browser/accessibility/browser_accessibility_manager.h" +// This file uses the deprecated NSObject accessibility interface. +// TODO(crbug.com/921109): Migrate to the new NSAccessibility interface. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + using base::StringPrintf; using base::SysNSStringToUTF8; using base::SysNSStringToUTF16; @@ -361,3 +366,5 @@ const string AccessibilityTreeFormatterMac::GetDenyString() { } } // namespace content + +#pragma clang diagnostic pop diff --git a/content/browser/accessibility/browser_accessibility_cocoa.mm b/content/browser/accessibility/browser_accessibility_cocoa.mm index 9e5070bd034c1..d1e716429cd96 100644 --- a/content/browser/accessibility/browser_accessibility_cocoa.mm +++ b/content/browser/accessibility/browser_accessibility_cocoa.mm @@ -2787,6 +2787,11 @@ NSString* const NSAccessibilityRequiredAttributeChrome = @"AXRequired"; return actions; } +// TODO(crbug.com/921109): Migrate from the NSObject accessibility interface to +// the NSAccessibility one, then remove this suppression. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + // Returns a sub-array of values for the given attribute value, starting at // index, with up to maxCount items. If the given index is out of bounds, // or there are no values for the given attribute, it will return nil. @@ -2823,6 +2828,8 @@ NSString* const NSAccessibilityRequiredAttributeChrome = @"AXRequired"; return [fullArray count]; } +#pragma clang diagnostic pop + // Returns the list of accessibility attributes that this object supports. - (NSArray*)accessibilityAttributeNames { if (![self instanceActive]) diff --git a/content/browser/accessibility/browser_accessibility_cocoa_browsertest.mm b/content/browser/accessibility/browser_accessibility_cocoa_browsertest.mm index 8c0e74be5f9ab..7ca5a1ae37796 100644 --- a/content/browser/accessibility/browser_accessibility_cocoa_browsertest.mm +++ b/content/browser/accessibility/browser_accessibility_cocoa_browsertest.mm @@ -19,6 +19,11 @@ #include "testing/gtest_mac.h" #include "url/gurl.h" +// This file uses the deprecated NSObject accessibility APIs: +// https://crbug.com/921109 +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + namespace content { namespace { @@ -119,3 +124,5 @@ IN_PROC_BROWSER_TEST_F(BrowserAccessibilityCocoaBrowserTest, } } // namespace content + +#pragma clang diagnostic pop diff --git a/content/browser/accessibility/browser_accessibility_mac_unittest.mm b/content/browser/accessibility/browser_accessibility_mac_unittest.mm index cbfcdadb0e28c..3c611af690152 100644 --- a/content/browser/accessibility/browser_accessibility_mac_unittest.mm +++ b/content/browser/accessibility/browser_accessibility_mac_unittest.mm @@ -123,6 +123,11 @@ class BrowserAccessibilityMacTest : public ui::CocoaTest { std::unique_ptr<BrowserAccessibilityManager> manager_; }; +// The next few tests all use the deprecated NSObject accessibility APIs: +// https://crbug.com/921109. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + // Standard hit test. TEST_F(BrowserAccessibilityMacTest, HitTestTest) { BrowserAccessibilityCocoa* firstChild = @@ -186,6 +191,8 @@ TEST_F(BrowserAccessibilityMacTest, RetainedDetachedObjectsReturnNil) { [retainedFirstChild release]; } +#pragma clang diagnostic pop + TEST_F(BrowserAccessibilityMacTest, TestComputeTextEdit) { BrowserAccessibility* owner = [accessibility_ owner]; ASSERT_NE(nullptr, owner); diff --git a/content/browser/renderer_host/render_widget_host_view_cocoa.mm b/content/browser/renderer_host/render_widget_host_view_cocoa.mm index 57a608c1a1d44..673c7dacfa323 100644 --- a/content/browser/renderer_host/render_widget_host_view_cocoa.mm +++ b/content/browser/renderer_host/render_widget_host_view_cocoa.mm @@ -1381,6 +1381,11 @@ void ExtractUnderlines(NSAttributedString* string, return client_; } +// TODO(crbug.com/921109): Migrate from the NSObject accessibility API to the +// NSAccessibility API, then remove this suppression. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + - (NSArray*)accessibilityArrayAttributeValues:(NSString*)attribute index:(NSUInteger)index maxCount:(NSUInteger)maxCount { @@ -1451,6 +1456,8 @@ void ExtractUnderlines(NSAttributedString* string, return clientHelper_->GetFocusedBrowserAccessibilityElement(); } +#pragma clang diagnostic pop + // Below is our NSTextInputClient implementation. // // When WebHTMLView receives a NSKeyDown event, WebHTMLView calls the following diff --git a/content/browser/web_contents/web_contents_view_mac_unittest.mm b/content/browser/web_contents/web_contents_view_mac_unittest.mm index 17786bc59fe9d..cf322960dd1d9 100644 --- a/content/browser/web_contents/web_contents_view_mac_unittest.mm +++ b/content/browser/web_contents/web_contents_view_mac_unittest.mm @@ -39,6 +39,10 @@ TEST_F(WebContentsViewCocoaTest, NonWebDragSourceTest) { [view draggingSourceOperationMaskForLocal:NO]); } +// This test uses deprecated NSObject accessibility APIs - see +// https://crbug.com/921109. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" TEST_F(WebContentsViewCocoaTest, AccessibilityParentTest) { // The designated initializer is private but init should be fine in this case. base::scoped_nsobject<WebContentsViewCocoa> view( @@ -60,6 +64,7 @@ TEST_F(WebContentsViewCocoaTest, AccessibilityParentTest) { EXPECT_NSEQ([view accessibilityAttributeValue:NSAccessibilityParentAttribute], parent_view); } +#pragma clang diagnostic pop namespace { diff --git a/content/shell/browser/shell_javascript_dialog_mac.mm b/content/shell/browser/shell_javascript_dialog_mac.mm index 096d2e789620d..d77829d8ff845 100644 --- a/content/shell/browser/shell_javascript_dialog_mac.mm +++ b/content/shell/browser/shell_javascript_dialog_mac.mm @@ -26,9 +26,8 @@ andCallback:(content::JavaScriptDialogManager::DialogClosedCallback)callback; - (NSAlert*)alert; - (NSTextField*)textField; -- (void)alertDidEnd:(NSAlert*)alert - returnCode:(int)returnCode - contextInfo:(void*)contextInfo; +- (void)alertDidEndWithResult:(NSModalResponse)returnCode + dialog:(content::ShellJavaScriptDialog*)dialog; - (void)cancel; @end @@ -60,10 +59,9 @@ return textField_; } -- (void)alertDidEnd:(NSAlert*)alert - returnCode:(int)returnCode - contextInfo:(void*)contextInfo { - if (returnCode == NSRunStoppedResponse) +- (void)alertDidEndWithResult:(NSModalResponse)returnCode + dialog:(content::ShellJavaScriptDialog*)dialog { + if (returnCode == NSModalResponseStop) return; bool success = returnCode == NSAlertFirstButtonReturn; @@ -71,10 +69,8 @@ if (textField_) input = base::SysNSStringToUTF16([textField_ stringValue]); - content::ShellJavaScriptDialog* native_dialog = - reinterpret_cast<content::ShellJavaScriptDialog*>(contextInfo); std::move(callback_).Run(success, input); - manager_->DialogClosed(native_dialog); + manager_->DialogClosed(dialog); } - (void)cancel { @@ -117,11 +113,10 @@ ShellJavaScriptDialog::ShellJavaScriptDialog( [other setKeyEquivalent:@"\e"]; } - [alert - beginSheetModalForWindow:nil // nil here makes it app-modal - modalDelegate:helper_ - didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) - contextInfo:this]; + [alert beginSheetModalForWindow:nil // nil here makes it app-modal + completionHandler:^void(NSModalResponse returnCode) { + [helper_ alertDidEndWithResult:returnCode dialog:this]; + }]; } ShellJavaScriptDialog::~ShellJavaScriptDialog() { diff --git a/content/shell/browser/shell_login_dialog_mac.mm b/content/shell/browser/shell_login_dialog_mac.mm index 695f8bbdca6c1..647b3b70d446c 100644 --- a/content/shell/browser/shell_login_dialog_mac.mm +++ b/content/shell/browser/shell_login_dialog_mac.mm @@ -31,9 +31,8 @@ const int kPasswordFieldTag = 2; - (NSAlert*)alert; - (NSView*)accessoryView; -- (void)alertDidEnd:(NSAlert*)alert - returnCode:(int)returnCode - contextInfo:(void*)contextInfo; +- (void)alertDidEndWithResponse:(NSModalResponse)response + dialog:(content::ShellLoginDialog*)dialog; - (void)cancel; @end @@ -57,20 +56,17 @@ const int kPasswordFieldTag = 2; return accessory_view; } -- (void)alertDidEnd:(NSAlert*)alert - returnCode:(int)returnCode - contextInfo:(void*)contextInfo { - if (returnCode == NSRunStoppedResponse) +- (void)alertDidEndWithResponse:(NSModalResponse)returnCode + dialog:(content::ShellLoginDialog*)dialog { + if (returnCode == NSModalResponseStop) return; - content::ShellLoginDialog* this_dialog = - reinterpret_cast<content::ShellLoginDialog*>(contextInfo); if (returnCode == NSAlertFirstButtonReturn) { - this_dialog->UserAcceptedAuth( + dialog->UserAcceptedAuth( base::SysNSStringToUTF16([usernameField_ stringValue]), base::SysNSStringToUTF16([passwordField_ stringValue])); } else { - this_dialog->UserCancelledAuth(); + dialog->UserCancelledAuth(); } } @@ -95,11 +91,10 @@ void ShellLoginDialog::PlatformCreateDialog(const base::string16& message) { [alert addButtonWithTitle:@"OK"]; NSButton* other = [alert addButtonWithTitle:@"Cancel"]; [other setKeyEquivalent:@"\e"]; - [alert - beginSheetModalForWindow:nil // nil here makes it app-modal - modalDelegate:helper_ - didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) - contextInfo:this]; + [alert beginSheetModalForWindow:nil + completionHandler:^void(NSModalResponse resp) { + [helper_ alertDidEndWithResponse:resp dialog:this]; + }]; } void ShellLoginDialog::PlatformCleanUp() { diff --git a/remoting/host/installer/mac/BUILD.gn b/remoting/host/installer/mac/BUILD.gn index f4b135738b715..357b1f566e3e7 100644 --- a/remoting/host/installer/mac/BUILD.gn +++ b/remoting/host/installer/mac/BUILD.gn @@ -141,6 +141,7 @@ mac_app_bundle("remoting_host_uninstaller") { "//base", "//remoting/host:remoting_infoplist_strings", "//remoting/host/mac:constants", + "//ui/base:base", ] foreach(locale, remoting_locales_with_underscores) { deps += [ ":remoting_uninstaller_strings_${locale}_bundle_data" ] diff --git a/remoting/host/installer/mac/uninstaller/remoting_uninstaller_app.mm b/remoting/host/installer/mac/uninstaller/remoting_uninstaller_app.mm index cf22a9b0e75f9..7724eb5cdf827 100644 --- a/remoting/host/installer/mac/uninstaller/remoting_uninstaller_app.mm +++ b/remoting/host/installer/mac/uninstaller/remoting_uninstaller_app.mm @@ -6,7 +6,10 @@ #import <Cocoa/Cocoa.h> +#include "base/mac/scoped_nsobject.h" +#include "remoting/base/string_resources.h" #include "remoting/host/installer/mac/uninstaller/remoting_uninstaller.h" +#include "ui/base/l10n/l10n_util_mac.h" @implementation RemotingUninstallerAppDelegate @@ -19,13 +22,12 @@ - (void)showSuccess:(bool)success withMessage:(NSString*) message { NSString* summary = success ? @"Uninstall succeeded" : @"Uninstall failed"; - NSAlert* alert = [NSAlert alertWithMessageText:summary - defaultButton:@"OK" - alternateButton:nil - otherButton:nil - informativeTextWithFormat:@"%@", message]; - [alert setAlertStyle: - (success ? NSInformationalAlertStyle : NSCriticalAlertStyle)]; + base::scoped_nsobject<NSAlert> alert([[NSAlert alloc] init]); + [alert setMessageText:summary]; + [alert setInformativeText:message]; + [alert setAlertStyle:(success ? NSInformationalAlertStyle + : NSCriticalAlertStyle)]; + [alert addButtonWithTitle:l10n_util::GetNSString(IDS_OK)]; [alert runModal]; } diff --git a/services/device/geolocation/wifi_data_provider_mac.mm b/services/device/geolocation/wifi_data_provider_mac.mm index ff25310d619e2..278a538570814 100644 --- a/services/device/geolocation/wifi_data_provider_mac.mm +++ b/services/device/geolocation/wifi_data_provider_mac.mm @@ -7,6 +7,12 @@ #import <CoreWLAN/CoreWLAN.h> #import <Foundation/Foundation.h> +// This file uses the deprecated CWInterface API, but CWWiFiClient appears to be +// different in ways that are relevant to this code, so for now ignore the +// deprecation. See <https://crbug.com/841631>. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + #include "base/mac/scoped_nsautorelease_pool.h" #include "base/mac/scoped_nsobject.h" #include "base/macros.h" @@ -135,3 +141,5 @@ std::unique_ptr<WifiPollingPolicy> WifiDataProviderMac::CreatePollingPolicy() { } } // namespace device + +#pragma clang diagnostic pop diff --git a/testing/iossim/iossim.mm b/testing/iossim/iossim.mm index eea905e0f01e6..a6ac57b024b46 100644 --- a/testing/iossim/iossim.mm +++ b/testing/iossim/iossim.mm @@ -306,11 +306,11 @@ int RunApplication(NSString* app_path, forKey:@"TestingEnvironmentVariables"]; [xctestrun setObject:testTargetName forKey:@"TestTargetName"]; - NSString* error; NSData* data = [NSPropertyListSerialization - dataFromPropertyList:xctestrun + dataWithPropertyList:xctestrun format:NSPropertyListXMLFormat_v1_0 - errorDescription:&error]; + options:0 + error:nil]; [data writeToFile:tempFilePath atomically:YES]; XCRunTask* task = [[[XCRunTask alloc] initWithArguments:@[ @"xcodebuild", @"-xctestrun", tempFilePath, @"-destination", diff --git a/third_party/blink/renderer/platform/text/locale_mac.mm b/third_party/blink/renderer/platform/text/locale_mac.mm index ff17c9162a91a..fdd237ec17a78 100644 --- a/third_party/blink/renderer/platform/text/locale_mac.mm +++ b/third_party/blink/renderer/platform/text/locale_mac.mm @@ -89,7 +89,8 @@ LocaleMac::LocaleMac(NSLocale* locale) : locale_(locale), gregorian_calendar_( kAdoptNS, - [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]), + [[NSCalendar alloc] + initWithCalendarIdentifier:NSCalendarIdentifierGregorian]), did_initialize_number_data_(false) { NSArray* available_languages = [NSLocale ISOLanguageCodes]; // NSLocale returns a lower case NSLocaleLanguageCode so we don't have care diff --git a/third_party/breakpad/BUILD.gn b/third_party/breakpad/BUILD.gn index adfbe88cc0a73..de3146ad340d3 100644 --- a/third_party/breakpad/BUILD.gn +++ b/third_party/breakpad/BUILD.gn @@ -455,6 +455,10 @@ if (is_mac) { defines = [ "USE_PROTECTED_ALLOCATIONS=1" ] include_dirs = [ "breakpad/src/client/apple/Framework" ] + # TODO(crbug.com/841631): Breakpad uses bootstrap_subset() and + # bootstrap_create_server(), both of which are deprecated starting in 10.10. + cflags = [ "-Wno-deprecated-declarations" ] + deps = [ ":crash_inspector", ":crash_report_sender", diff --git a/third_party/google_toolbox_for_mac/BUILD.gn b/third_party/google_toolbox_for_mac/BUILD.gn index 67768b13be790..78ca06ab01e11 100644 --- a/third_party/google_toolbox_for_mac/BUILD.gn +++ b/third_party/google_toolbox_for_mac/BUILD.gn @@ -39,6 +39,11 @@ component("google_toolbox_for_mac") { "Cocoa.framework", "QuartzCore.framework", ] + + # TODO(crbug.com/841631): GTM uses accessibility APIs that are deprecated as + # of 10.10. These can't yet be compiled out, so for now, ignore deprecated + # declarations in GTM altogether. + cflags = [ "-Wno-deprecated-declarations" ] } else { # is_ios sources += [ "src/DebugUtils/GTMMethodCheck.h", diff --git a/third_party/mozilla/NSWorkspace+Utils.h b/third_party/mozilla/NSWorkspace+Utils.h index 13096a9de3a12..a1ea48c13e101 100644 --- a/third_party/mozilla/NSWorkspace+Utils.h +++ b/third_party/mozilla/NSWorkspace+Utils.h @@ -43,16 +43,13 @@ - (NSArray*)installedBrowserIdentifiers; // sort order not specified - (NSString*)defaultBrowserIdentifier; -- (NSURL*)defaultBrowserURL; - (NSArray*)installedFeedViewerIdentifiers; - (NSString*)defaultFeedViewerIdentifier; -- (NSURL*)defaultFeedViewerURL; - (void)setDefaultBrowserWithIdentifier:(NSString*)bundleID; - (void)setDefaultFeedViewerWithIdentifier:(NSString*)bundleID; -- (NSURL*)urlOfApplicationWithIdentifier:(NSString*)bundleID; - (NSString*)identifierForBundle:(NSURL*)inBundleURL; - (NSString*)displayNameForFile:(NSURL*)inFileURL; diff --git a/third_party/mozilla/NSWorkspace+Utils.m b/third_party/mozilla/NSWorkspace+Utils.m index f6aab2c09d5fb..f4c49146ccdbf 100644 --- a/third_party/mozilla/NSWorkspace+Utils.m +++ b/third_party/mozilla/NSWorkspace+Utils.m @@ -81,22 +81,6 @@ return [(NSString*)LSCopyDefaultHandlerForURLScheme(CFSTR("feed")) autorelease]; } -- (NSURL*)defaultBrowserURL -{ - NSString* defaultBundleId = [self defaultBrowserIdentifier]; - if (defaultBundleId) - return [self urlOfApplicationWithIdentifier:defaultBundleId]; - return nil; -} - -- (NSURL*)defaultFeedViewerURL -{ - NSString* defaultBundleId = [self defaultFeedViewerIdentifier]; - if (defaultBundleId) - return [self urlOfApplicationWithIdentifier:defaultBundleId]; - return nil; -} - - (void)setDefaultBrowserWithIdentifier:(NSString*)bundleID { LSSetDefaultHandlerForURLScheme(CFSTR("http"), (CFStringRef)bundleID); @@ -110,17 +94,6 @@ LSSetDefaultHandlerForURLScheme(CFSTR("feed"), (CFStringRef)bundleID); } -- (NSURL*)urlOfApplicationWithIdentifier:(NSString*)bundleID -{ - if (!bundleID) - return nil; - NSURL* appURL = nil; - if (LSFindApplicationForInfo(kLSUnknownCreator, (CFStringRef)bundleID, NULL, NULL, (CFURLRef*)&appURL) == noErr) - return [appURL autorelease]; - - return nil; -} - - (NSString*)identifierForBundle:(NSURL*)inBundleURL { if (!inBundleURL) return nil; diff --git a/third_party/mozilla/README.chromium b/third_party/mozilla/README.chromium index 7a44e328ea720..9ea000df3eb56 100644 --- a/third_party/mozilla/README.chromium +++ b/third_party/mozilla/README.chromium @@ -33,3 +33,6 @@ Local modifications: - MOZILLA_EXPORT was added to some constants in NSPasteboard+Utils.h. - +[NSWorkspace(CaminoDefaultBrowserAdditions) isLeopardOrHigher] hidden since it relies on methods deprecated in 10.8 (and is unused in Chrome). +- NSWorkspace(CaminoDefaultBrowserAdditions) methods defaultBrowserURL, + defaultFeedViewerURL, and urlOfApplicationWithIdentifier: removed since they + are unused in Chrome and rely on deprecated APIs as of 10.10. diff --git a/ui/views/controls/tabbed_pane/tabbed_pane_accessibility_mac_unittest.mm b/ui/views/controls/tabbed_pane/tabbed_pane_accessibility_mac_unittest.mm index 8f08e724af29a..f2c79eda6c3b6 100644 --- a/ui/views/controls/tabbed_pane/tabbed_pane_accessibility_mac_unittest.mm +++ b/ui/views/controls/tabbed_pane/tabbed_pane_accessibility_mac_unittest.mm @@ -13,6 +13,11 @@ #include "ui/views/widget/widget.h" #import "testing/gtest_mac.h" +// This file uses the deprecated NSObject accessibility API - see +// https://crbug.com/921109. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + namespace views { namespace test { @@ -163,3 +168,5 @@ TEST_F(TabbedPaneAccessibilityMacTest, WritableValue) { } // namespace test } // namespace views + +#pragma clang diagnostic pop diff --git a/ui/views/widget/ax_native_widget_mac_unittest.mm b/ui/views/widget/ax_native_widget_mac_unittest.mm index 45e70d362e2bf..da25e8ecf7569 100644 --- a/ui/views/widget/ax_native_widget_mac_unittest.mm +++ b/ui/views/widget/ax_native_widget_mac_unittest.mm @@ -97,6 +97,11 @@ class TestWidgetDelegate : public test::TestDesktopWidgetDelegate { constexpr char TestWidgetDelegate::kAccessibleWindowTitle[]; +// This test framework uses the deprecated NSObject accessibility APIs - see +// https://crbug.com/921109. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + class AXNativeWidgetMacTest : public test::WidgetTest { public: AXNativeWidgetMacTest() {} @@ -927,3 +932,5 @@ TEST_F(AXNativeWidgetMacTest, Combobox) { } } // namespace views + +#pragma clang diagnostic pop diff --git a/ui/views/widget/native_widget_mac_unittest.mm b/ui/views/widget/native_widget_mac_unittest.mm index 9bcfb2c437602..85370ab04320f 100644 --- a/ui/views/widget/native_widget_mac_unittest.mm +++ b/ui/views/widget/native_widget_mac_unittest.mm @@ -701,6 +701,11 @@ TEST_F(NativeWidgetMacTest, SetCursor) { widget->CloseNow(); } +// This test uses the deprecated NSObject accessibility API - see +// https://crbug.com/921109. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + // Tests that an accessibility request from the system makes its way through to // a views::Label filling the window. TEST_F(NativeWidgetMacTest, AccessibilityIntegration) { @@ -726,6 +731,8 @@ TEST_F(NativeWidgetMacTest, AccessibilityIntegration) { widget->CloseNow(); } +#pragma clang diagnostic pop + namespace { Widget* AttachPopupToNativeParent(NSWindow* native_parent) { diff --git a/ui/views_bridge_mac/alert.mm b/ui/views_bridge_mac/alert.mm index 328f51b208e08..4868e711b7100 100644 --- a/ui/views_bridge_mac/alert.mm +++ b/ui/views_bridge_mac/alert.mm @@ -209,7 +209,7 @@ const int kMessageTextMaxSlots = 2000; case NSAlertSecondButtonReturn: // Cancel alertBridge_->SendResultAndDestroy(AlertDisposition::SECONDARY_BUTTON); break; - case NSRunStoppedResponse: // Window was closed underneath us + case NSModalResponseStop: // Window was closed underneath us alertBridge_->SendResultAndDestroy(AlertDisposition::CLOSE); break; default: @@ -223,10 +223,15 @@ const int kMessageTextMaxSlots = 2000; NSAlert* alert = [self alert]; [alert layout]; [[alert window] recalculateKeyViewLoop]; + // TODO(crbug.com/841631): Migrate to `[NSWindow + // beginSheetModalForWindow:completionHandler:]` instead. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" [alert beginSheetModalForWindow:nil // nil here makes it app-modal modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:NULL]; +#pragma clang diagnostic pop } - (void)closeWindow { diff --git a/ui/views_bridge_mac/bridged_native_widget_impl.mm b/ui/views_bridge_mac/bridged_native_widget_impl.mm index 3190bf98380d5..4b013297d2c46 100644 --- a/ui/views_bridge_mac/bridged_native_widget_impl.mm +++ b/ui/views_bridge_mac/bridged_native_widget_impl.mm @@ -1338,11 +1338,16 @@ void BridgedNativeWidgetImpl::ShowAsModalSheet() { // Since |this| may destroy [window_ delegate], use |window_| itself as the // delegate, which will forward to ViewsNSWindowDelegate if |this| is still // alive (i.e. it has not set the window delegate to nil). + // TODO(crbug.com/841631): Migrate to `[NSWindow + // beginSheet:completionHandler:]` instead of this method. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" [NSApp beginSheet:window_ modalForWindow:parent_window modalDelegate:window_ didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:nullptr]; +#pragma clang diagnostic pop } } // namespace views