0

mac: bump deployment target to 10.10

This change:
1) Marks uses of launch_data_t as deprecated with no replacement (so ignored);
2) Marks uses of the NSObject accessibility API as deprecated to be replaced
   (per bug 921109)
3) Replaces one use of CWInterface with a corresponding use of CWWiFiClient, and
   marks another as ignored for now;
4) Replaces some LaunchServices invocations with their new equivalents;
5) Marks GTM to ignore deprecation warnings, since the GTM dependency will go
   away soon anyway;
6) Fixes how blink refers to NSCalendarIdentifierGregorian;
7) Replaces some uses of NSRunAlertPanel with explicit constructions of NSAlert;
8) Bumps the deployment target to 10.10

An earlier version of this change attempted to incrementally upgrade, but many
of the replacement APIs are themselves only @available on 10.10, so it proved
to be significantly uglier.

Bug: 841631
Change-Id: Ic6e96efbb84ba0a077eda3528b452137d64f5f02
Reviewed-on: https://chromium-review.googlesource.com/c/1407177
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: Mike Pinkerton <pinkerton@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#625380}
This commit is contained in:
Elly Fong-Jones
2019-01-23 22:10:28 +00:00
committed by Commit Bot
parent c8970c8ff8
commit bd6d39d548
41 changed files with 210 additions and 202 deletions

@@ -7,6 +7,11 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/mac/scoped_launch_data.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 base {
namespace mac { namespace mac {
@@ -73,3 +78,5 @@ pid_t PIDForJob(const std::string& job_label) {
} // namespace mac } // namespace mac
} // namespace base } // namespace base
#pragma clang diagnostic pop

@@ -98,13 +98,16 @@ LSSharedFileListItemRef GetLoginItemForApp() {
for(NSUInteger i = 0; i < [login_items_array count]; ++i) { for(NSUInteger i = 0; i < [login_items_array count]; ++i) {
LSSharedFileListItemRef item = LSSharedFileListItemRef item =
reinterpret_cast<LSSharedFileListItemRef>(login_items_array[i]); 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 // This function previously used LSSharedFileListItemResolve(), which could
// item_url_ref even if the function itself returns noErr. See // return a NULL URL even when returning no error. This caused
// https://crbug.com/760989 // <https://crbug.com/760989>. It's not clear one way or the other whether
if (LSSharedFileListItemResolve(item, 0, &item_url_ref, NULL) == noErr && // LSSharedFileListItemCopyResolvedURL() shares this behavior, so this check
item_url_ref) { // remains in place.
if (!error && item_url_ref) {
ScopedCFTypeRef<CFURLRef> item_url(item_url_ref); ScopedCFTypeRef<CFURLRef> item_url(item_url_ref);
if (CFEqual(item_url, url)) { if (CFEqual(item_url, url)) {
CFRetain(item); CFRetain(item);

@@ -9,6 +9,11 @@
#include "base/scoped_generic.h" #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 base {
namespace mac { namespace mac {
@@ -28,4 +33,6 @@ using ScopedLaunchData =
} // namespace mac } // namespace mac
} // namespace base } // namespace base
#pragma clang diagnostic pop // -Wdeprecated-declarations
#endif // BASE_MAC_SCOPED_LAUNCH_DATA_H_ #endif // BASE_MAC_SCOPED_LAUNCH_DATA_H_

@@ -14,7 +14,7 @@ declare_args() {
# additional code changes are required to be compliant with the availability # additional code changes are required to be compliant with the availability
# rules. # rules.
# Must be of the form x.x.x for Info.plist files. # 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 # The value of the LSMinimmumSystemVersion in Info.plist files. This partially
# controls the minimum supported version of macOS for Chromium by # controls the minimum supported version of macOS for Chromium by

@@ -826,10 +826,15 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
waitTitle = waitTitle =
l10n_util::GetNSString(IDS_ABANDON_DOWNLOAD_DIALOG_CONTINUE_BUTTON); 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. // 'waitButton' is the default choice.
int choice = NSRunAlertPanel(titleText, @"%@", int choice = [alert runModal];
waitTitle, exitTitle, nil, explanationText); return choice == NSAlertFirstButtonReturn ? YES : NO;
return choice == NSAlertDefaultReturn ? YES : NO;
} }
// Check all profiles for in progress downloads, and if we find any, prompt the // Check all profiles for in progress downloads, and if we find any, prompt the

@@ -12,6 +12,12 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/strings/sys_string_conversions.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 media_router {
namespace { namespace {
@@ -42,3 +48,5 @@ bool MaybeGetWifiSSID(const std::string& if_name, std::string* ssid_out) {
} }
} // namespace media_router } // namespace media_router
#pragma clang diagnostic pop

@@ -116,8 +116,11 @@ const char kTestFileContents[] = "test";
- (id)init:(NSString*)name { - (id)init:(NSString*)name {
if ((self = [super init])) { if ((self = [super init])) {
base::scoped_nsobject<NSDateFormatter> iso8601day(
[[NSDateFormatter alloc] init]);
[iso8601day setDateFormat:@"yyyy-MM-dd"];
name_.reset([name retain]); name_.reset([name retain]);
date_.reset([[NSDate dateWithNaturalLanguageString:@"12/12/12"] retain]); date_.reset([[iso8601day dateFromString:@"2012-12-12"] retain]);
} }
return self; return self;
} }

@@ -121,17 +121,14 @@ DefaultWebClientSetPermission GetDefaultWebClientSetPermission() {
base::string16 GetApplicationNameForProtocol(const GURL& url) { base::string16 GetApplicationNameForProtocol(const GURL& url) {
NSURL* ns_url = [NSURL URLWithString: NSURL* ns_url = [NSURL URLWithString:
base::SysUTF8ToNSString(url.possibly_invalid_spec())]; base::SysUTF8ToNSString(url.possibly_invalid_spec())];
CFURLRef openingApp = NULL; base::ScopedCFTypeRef<CFErrorRef> out_err;
OSStatus status = LSGetApplicationForURL((CFURLRef)ns_url, base::ScopedCFTypeRef<CFURLRef> openingApp(LSCopyDefaultApplicationURLForURL(
kLSRolesAll, (CFURLRef)ns_url, kLSRolesAll, out_err.InitializeInto()));
NULL, if (out_err) {
&openingApp);
if (status != noErr) {
// likely kLSApplicationNotFoundErr // likely kLSApplicationNotFoundErr
return base::string16(); return base::string16();
} }
NSString* appPath = [(NSURL*)openingApp path]; NSString* appPath = [base::mac::CFToNSCast(openingApp.get()) path];
CFRelease(openingApp); // NOT A BUG; LSGetApplicationForURL retains for us
NSString* appDisplayName = NSString* appDisplayName =
[[NSFileManager defaultManager] displayNameAtPath:appPath]; [[NSFileManager defaultManager] displayNameAtPath:appPath];
return base::SysNSStringToUTF16(appDisplayName); return base::SysNSStringToUTF16(appDisplayName);

@@ -407,6 +407,11 @@ class API_AVAILABLE(macos(10.12.2)) TouchBarNotificationBridge
return touchBar.autorelease(); 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 { - (void)setupBackForwardControl {
NSMutableArray* images = [NSMutableArray arrayWithArray:@[ NSMutableArray* images = [NSMutableArray arrayWithArray:@[
CreateNSImageFromIcon(vector_icons::kBackArrowIcon), CreateNSImageFromIcon(vector_icons::kBackArrowIcon),
@@ -451,6 +456,8 @@ class API_AVAILABLE(macos(10.12.2)) TouchBarNotificationBridge
backForwardControl_.reset([control retain]); backForwardControl_.reset([control retain]);
} }
#pragma clang diagnostic pop
- (void)updateWebContents:(content::WebContents*)contents { - (void)updateWebContents:(content::WebContents*)contents {
notificationBridge_->UpdateWebContents(contents); notificationBridge_->UpdateWebContents(contents);
} }

@@ -935,17 +935,8 @@ std::vector<base::FilePath> WebAppShortcutCreator::GetAppBundlesByIdUnsorted()
base::SysUTF8ToCFStringRef(GetBundleIdentifier())); base::SysUTF8ToCFStringRef(GetBundleIdentifier()));
// Retrieve the URLs found by LaunchServices. // Retrieve the URLs found by LaunchServices.
base::scoped_nsobject<NSArray> urls; base::scoped_nsobject<NSArray> urls(base::mac::CFToNSCast(
if (@available(macOS 10.10, *)) { LSCopyApplicationURLsForBundleIdentifier(bundle_id_cf.get(), nullptr)));
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]);
}
// Store only those results corresponding to this user data dir. // Store only those results corresponding to this user data dir.
std::vector<base::FilePath> paths; std::vector<base::FilePath> paths;

@@ -25,17 +25,17 @@ base::FilePath GetProfilesINI() {
} }
base::FilePath GetFirefoxDylibPath() { base::FilePath GetFirefoxDylibPath() {
CFURLRef appURL = nil; base::ScopedCFTypeRef<CFErrorRef> out_err;
if (LSFindApplicationForInfo(kLSUnknownCreator, base::ScopedCFTypeRef<CFArrayRef> app_urls(
CFSTR("org.mozilla.firefox"), LSCopyApplicationURLsForBundleIdentifier(CFSTR("org.mozilla.firefox"),
NULL, out_err.InitializeInto()));
NULL, if (out_err || CFArrayGetCount(app_urls) == 0) {
&appURL) != noErr) {
return base::FilePath(); return base::FilePath();
} }
NSBundle *ff_bundle = CFURLRef app_url =
[NSBundle bundleWithPath:[base::mac::CFToNSCast(appURL) path]]; base::mac::CFCastStrict<CFURLRef>(CFArrayGetValueAtIndex(app_urls, 0));
CFRelease(appURL); NSBundle* ff_bundle =
[NSBundle bundleWithPath:[base::mac::CFToNSCast(app_url) path]];
NSString *ff_library_path = NSString *ff_library_path =
[[ff_bundle executablePath] stringByDeletingLastPathComponent]; [[ff_bundle executablePath] stringByDeletingLastPathComponent];
char buf[MAXPATHLEN]; char buf[MAXPATHLEN];

@@ -17,6 +17,11 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/sys_string_conversions.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 { namespace {
class ScopedLaunchData { class ScopedLaunchData {
@@ -260,3 +265,5 @@ bool RemoveJob(const std::string& label) {
} // namespace services } // namespace services
} // namespace mac } // namespace mac
#pragma clang diagnostic pop

@@ -15,10 +15,6 @@ class FilePath;
namespace download { namespace download {
bool GetQuarantinePropertiesDeprecated(
const base::FilePath& file,
base::scoped_nsobject<NSMutableDictionary>* properties);
bool GetQuarantineProperties( bool GetQuarantineProperties(
const base::FilePath& file, const base::FilePath& file,
base::scoped_nsobject<NSMutableDictionary>* properties); base::scoped_nsobject<NSMutableDictionary>* properties);

@@ -17,46 +17,6 @@
namespace download { 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( bool GetQuarantineProperties(
const base::FilePath& file, const base::FilePath& file,
base::scoped_nsobject<NSMutableDictionary>* properties) { base::scoped_nsobject<NSMutableDictionary>* properties) {

@@ -23,34 +23,6 @@
namespace { 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, bool SetQuarantineProperties(const base::FilePath& file,
NSDictionary* properties) { NSDictionary* properties) {
base::scoped_nsobject<NSURL> file_url([[NSURL alloc] base::scoped_nsobject<NSURL> file_url([[NSURL alloc]
@@ -170,12 +142,7 @@ bool AddQuarantineMetadataToFile(const base::FilePath& file,
const GURL& referrer) { const GURL& referrer) {
base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK); base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
base::scoped_nsobject<NSMutableDictionary> properties; base::scoped_nsobject<NSMutableDictionary> properties;
bool success = false; bool success = GetQuarantineProperties(file, &properties);
if (@available(macos 10.10, *)) {
success = GetQuarantineProperties(file, &properties);
} else {
success = GetQuarantinePropertiesDeprecated(file, &properties);
}
if (!success) if (!success)
return false; return false;
@@ -213,11 +180,7 @@ bool AddQuarantineMetadataToFile(const base::FilePath& file,
[properties setValue:origin_url forKey:(NSString*)kLSQuarantineDataURLKey]; [properties setValue:origin_url forKey:(NSString*)kLSQuarantineDataURLKey];
} }
if (@available(macos 10.10, *)) { return SetQuarantineProperties(file, properties);
return SetQuarantineProperties(file, properties);
} else {
return SetQuarantinePropertiesDeprecated(file, properties);
}
} }
} // namespace } // namespace

@@ -26,11 +26,7 @@ bool IsFileQuarantined(const base::FilePath& file,
return false; return false;
base::scoped_nsobject<NSMutableDictionary> properties; base::scoped_nsobject<NSMutableDictionary> properties;
bool success = false; bool success = GetQuarantineProperties(file, &properties);
if (@available(macos 10.10, *))
success = GetQuarantineProperties(file, &properties);
else
success = GetQuarantinePropertiesDeprecated(file, &properties);
if (!success || !properties) if (!success || !properties)
return false; return false;

@@ -157,8 +157,11 @@ const char kTestFileContents[] = "test";
- (instancetype)init:(NSString*)name { - (instancetype)init:(NSString*)name {
if ((self = [super init])) { if ((self = [super init])) {
base::scoped_nsobject<NSDateFormatter> iso8601day(
[[NSDateFormatter alloc] init]);
[iso8601day setDateFormat:@"yyyy-MM-dd"];
name_.reset([name retain]); name_.reset([name retain]);
date_.reset([[NSDate dateWithNaturalLanguageString:@"12/12/12"] retain]); date_.reset([[iso8601day dateFromString:@"2012-12-12"] retain]);
} }
return self; return self;
} }

@@ -165,7 +165,7 @@ WiFiServiceMac::~WiFiServiceMac() {
void WiFiServiceMac::Initialize( void WiFiServiceMac::Initialize(
scoped_refptr<base::SequencedTaskRunner> task_runner) { scoped_refptr<base::SequencedTaskRunner> task_runner) {
task_runner_.swap(task_runner); task_runner_.swap(task_runner);
interface_.reset([[CWInterface interface] retain]); interface_.reset([[[CWWiFiClient sharedWiFiClient] interface] retain]);
if (!interface_) { if (!interface_) {
DVLOG(1) << "Failed to initialize default interface."; DVLOG(1) << "Failed to initialize default interface.";
return; return;

@@ -17,6 +17,11 @@
#include "content/browser/accessibility/browser_accessibility_mac.h" #include "content/browser/accessibility/browser_accessibility_mac.h"
#include "content/browser/accessibility/browser_accessibility_manager.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::StringPrintf;
using base::SysNSStringToUTF8; using base::SysNSStringToUTF8;
using base::SysNSStringToUTF16; using base::SysNSStringToUTF16;
@@ -361,3 +366,5 @@ const string AccessibilityTreeFormatterMac::GetDenyString() {
} }
} // namespace content } // namespace content
#pragma clang diagnostic pop

@@ -2787,6 +2787,11 @@ NSString* const NSAccessibilityRequiredAttributeChrome = @"AXRequired";
return actions; 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 // 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, // 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. // or there are no values for the given attribute, it will return nil.
@@ -2823,6 +2828,8 @@ NSString* const NSAccessibilityRequiredAttributeChrome = @"AXRequired";
return [fullArray count]; return [fullArray count];
} }
#pragma clang diagnostic pop
// Returns the list of accessibility attributes that this object supports. // Returns the list of accessibility attributes that this object supports.
- (NSArray*)accessibilityAttributeNames { - (NSArray*)accessibilityAttributeNames {
if (![self instanceActive]) if (![self instanceActive])

@@ -19,6 +19,11 @@
#include "testing/gtest_mac.h" #include "testing/gtest_mac.h"
#include "url/gurl.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 content {
namespace { namespace {
@@ -119,3 +124,5 @@ IN_PROC_BROWSER_TEST_F(BrowserAccessibilityCocoaBrowserTest,
} }
} // namespace content } // namespace content
#pragma clang diagnostic pop

@@ -123,6 +123,11 @@ class BrowserAccessibilityMacTest : public ui::CocoaTest {
std::unique_ptr<BrowserAccessibilityManager> manager_; 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. // Standard hit test.
TEST_F(BrowserAccessibilityMacTest, HitTestTest) { TEST_F(BrowserAccessibilityMacTest, HitTestTest) {
BrowserAccessibilityCocoa* firstChild = BrowserAccessibilityCocoa* firstChild =
@@ -186,6 +191,8 @@ TEST_F(BrowserAccessibilityMacTest, RetainedDetachedObjectsReturnNil) {
[retainedFirstChild release]; [retainedFirstChild release];
} }
#pragma clang diagnostic pop
TEST_F(BrowserAccessibilityMacTest, TestComputeTextEdit) { TEST_F(BrowserAccessibilityMacTest, TestComputeTextEdit) {
BrowserAccessibility* owner = [accessibility_ owner]; BrowserAccessibility* owner = [accessibility_ owner];
ASSERT_NE(nullptr, owner); ASSERT_NE(nullptr, owner);

@@ -1381,6 +1381,11 @@ void ExtractUnderlines(NSAttributedString* string,
return client_; 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 - (NSArray*)accessibilityArrayAttributeValues:(NSString*)attribute
index:(NSUInteger)index index:(NSUInteger)index
maxCount:(NSUInteger)maxCount { maxCount:(NSUInteger)maxCount {
@@ -1451,6 +1456,8 @@ void ExtractUnderlines(NSAttributedString* string,
return clientHelper_->GetFocusedBrowserAccessibilityElement(); return clientHelper_->GetFocusedBrowserAccessibilityElement();
} }
#pragma clang diagnostic pop
// Below is our NSTextInputClient implementation. // Below is our NSTextInputClient implementation.
// //
// When WebHTMLView receives a NSKeyDown event, WebHTMLView calls the following // When WebHTMLView receives a NSKeyDown event, WebHTMLView calls the following

@@ -39,6 +39,10 @@ TEST_F(WebContentsViewCocoaTest, NonWebDragSourceTest) {
[view draggingSourceOperationMaskForLocal:NO]); [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) { TEST_F(WebContentsViewCocoaTest, AccessibilityParentTest) {
// The designated initializer is private but init should be fine in this case. // The designated initializer is private but init should be fine in this case.
base::scoped_nsobject<WebContentsViewCocoa> view( base::scoped_nsobject<WebContentsViewCocoa> view(
@@ -60,6 +64,7 @@ TEST_F(WebContentsViewCocoaTest, AccessibilityParentTest) {
EXPECT_NSEQ([view accessibilityAttributeValue:NSAccessibilityParentAttribute], EXPECT_NSEQ([view accessibilityAttributeValue:NSAccessibilityParentAttribute],
parent_view); parent_view);
} }
#pragma clang diagnostic pop
namespace { namespace {

@@ -26,9 +26,8 @@
andCallback:(content::JavaScriptDialogManager::DialogClosedCallback)callback; andCallback:(content::JavaScriptDialogManager::DialogClosedCallback)callback;
- (NSAlert*)alert; - (NSAlert*)alert;
- (NSTextField*)textField; - (NSTextField*)textField;
- (void)alertDidEnd:(NSAlert*)alert - (void)alertDidEndWithResult:(NSModalResponse)returnCode
returnCode:(int)returnCode dialog:(content::ShellJavaScriptDialog*)dialog;
contextInfo:(void*)contextInfo;
- (void)cancel; - (void)cancel;
@end @end
@@ -60,10 +59,9 @@
return textField_; return textField_;
} }
- (void)alertDidEnd:(NSAlert*)alert - (void)alertDidEndWithResult:(NSModalResponse)returnCode
returnCode:(int)returnCode dialog:(content::ShellJavaScriptDialog*)dialog {
contextInfo:(void*)contextInfo { if (returnCode == NSModalResponseStop)
if (returnCode == NSRunStoppedResponse)
return; return;
bool success = returnCode == NSAlertFirstButtonReturn; bool success = returnCode == NSAlertFirstButtonReturn;
@@ -71,10 +69,8 @@
if (textField_) if (textField_)
input = base::SysNSStringToUTF16([textField_ stringValue]); input = base::SysNSStringToUTF16([textField_ stringValue]);
content::ShellJavaScriptDialog* native_dialog =
reinterpret_cast<content::ShellJavaScriptDialog*>(contextInfo);
std::move(callback_).Run(success, input); std::move(callback_).Run(success, input);
manager_->DialogClosed(native_dialog); manager_->DialogClosed(dialog);
} }
- (void)cancel { - (void)cancel {
@@ -117,11 +113,10 @@ ShellJavaScriptDialog::ShellJavaScriptDialog(
[other setKeyEquivalent:@"\e"]; [other setKeyEquivalent:@"\e"];
} }
[alert [alert beginSheetModalForWindow:nil // nil here makes it app-modal
beginSheetModalForWindow:nil // nil here makes it app-modal completionHandler:^void(NSModalResponse returnCode) {
modalDelegate:helper_ [helper_ alertDidEndWithResult:returnCode dialog:this];
didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) }];
contextInfo:this];
} }
ShellJavaScriptDialog::~ShellJavaScriptDialog() { ShellJavaScriptDialog::~ShellJavaScriptDialog() {

@@ -31,9 +31,8 @@ const int kPasswordFieldTag = 2;
- (NSAlert*)alert; - (NSAlert*)alert;
- (NSView*)accessoryView; - (NSView*)accessoryView;
- (void)alertDidEnd:(NSAlert*)alert - (void)alertDidEndWithResponse:(NSModalResponse)response
returnCode:(int)returnCode dialog:(content::ShellLoginDialog*)dialog;
contextInfo:(void*)contextInfo;
- (void)cancel; - (void)cancel;
@end @end
@@ -57,20 +56,17 @@ const int kPasswordFieldTag = 2;
return accessory_view; return accessory_view;
} }
- (void)alertDidEnd:(NSAlert*)alert - (void)alertDidEndWithResponse:(NSModalResponse)returnCode
returnCode:(int)returnCode dialog:(content::ShellLoginDialog*)dialog {
contextInfo:(void*)contextInfo { if (returnCode == NSModalResponseStop)
if (returnCode == NSRunStoppedResponse)
return; return;
content::ShellLoginDialog* this_dialog =
reinterpret_cast<content::ShellLoginDialog*>(contextInfo);
if (returnCode == NSAlertFirstButtonReturn) { if (returnCode == NSAlertFirstButtonReturn) {
this_dialog->UserAcceptedAuth( dialog->UserAcceptedAuth(
base::SysNSStringToUTF16([usernameField_ stringValue]), base::SysNSStringToUTF16([usernameField_ stringValue]),
base::SysNSStringToUTF16([passwordField_ stringValue])); base::SysNSStringToUTF16([passwordField_ stringValue]));
} else { } else {
this_dialog->UserCancelledAuth(); dialog->UserCancelledAuth();
} }
} }
@@ -95,11 +91,10 @@ void ShellLoginDialog::PlatformCreateDialog(const base::string16& message) {
[alert addButtonWithTitle:@"OK"]; [alert addButtonWithTitle:@"OK"];
NSButton* other = [alert addButtonWithTitle:@"Cancel"]; NSButton* other = [alert addButtonWithTitle:@"Cancel"];
[other setKeyEquivalent:@"\e"]; [other setKeyEquivalent:@"\e"];
[alert [alert beginSheetModalForWindow:nil
beginSheetModalForWindow:nil // nil here makes it app-modal completionHandler:^void(NSModalResponse resp) {
modalDelegate:helper_ [helper_ alertDidEndWithResponse:resp dialog:this];
didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) }];
contextInfo:this];
} }
void ShellLoginDialog::PlatformCleanUp() { void ShellLoginDialog::PlatformCleanUp() {

@@ -141,6 +141,7 @@ mac_app_bundle("remoting_host_uninstaller") {
"//base", "//base",
"//remoting/host:remoting_infoplist_strings", "//remoting/host:remoting_infoplist_strings",
"//remoting/host/mac:constants", "//remoting/host/mac:constants",
"//ui/base:base",
] ]
foreach(locale, remoting_locales_with_underscores) { foreach(locale, remoting_locales_with_underscores) {
deps += [ ":remoting_uninstaller_strings_${locale}_bundle_data" ] deps += [ ":remoting_uninstaller_strings_${locale}_bundle_data" ]

@@ -6,7 +6,10 @@
#import <Cocoa/Cocoa.h> #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 "remoting/host/installer/mac/uninstaller/remoting_uninstaller.h"
#include "ui/base/l10n/l10n_util_mac.h"
@implementation RemotingUninstallerAppDelegate @implementation RemotingUninstallerAppDelegate
@@ -19,13 +22,12 @@
- (void)showSuccess:(bool)success withMessage:(NSString*) message { - (void)showSuccess:(bool)success withMessage:(NSString*) message {
NSString* summary = success ? @"Uninstall succeeded" : @"Uninstall failed"; NSString* summary = success ? @"Uninstall succeeded" : @"Uninstall failed";
NSAlert* alert = [NSAlert alertWithMessageText:summary base::scoped_nsobject<NSAlert> alert([[NSAlert alloc] init]);
defaultButton:@"OK" [alert setMessageText:summary];
alternateButton:nil [alert setInformativeText:message];
otherButton:nil [alert setAlertStyle:(success ? NSInformationalAlertStyle
informativeTextWithFormat:@"%@", message]; : NSCriticalAlertStyle)];
[alert setAlertStyle: [alert addButtonWithTitle:l10n_util::GetNSString(IDS_OK)];
(success ? NSInformationalAlertStyle : NSCriticalAlertStyle)];
[alert runModal]; [alert runModal];
} }

@@ -7,6 +7,12 @@
#import <CoreWLAN/CoreWLAN.h> #import <CoreWLAN/CoreWLAN.h>
#import <Foundation/Foundation.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_nsautorelease_pool.h"
#include "base/mac/scoped_nsobject.h" #include "base/mac/scoped_nsobject.h"
#include "base/macros.h" #include "base/macros.h"
@@ -135,3 +141,5 @@ std::unique_ptr<WifiPollingPolicy> WifiDataProviderMac::CreatePollingPolicy() {
} }
} // namespace device } // namespace device
#pragma clang diagnostic pop

@@ -306,11 +306,11 @@ int RunApplication(NSString* app_path,
forKey:@"TestingEnvironmentVariables"]; forKey:@"TestingEnvironmentVariables"];
[xctestrun setObject:testTargetName forKey:@"TestTargetName"]; [xctestrun setObject:testTargetName forKey:@"TestTargetName"];
NSString* error;
NSData* data = [NSPropertyListSerialization NSData* data = [NSPropertyListSerialization
dataFromPropertyList:xctestrun dataWithPropertyList:xctestrun
format:NSPropertyListXMLFormat_v1_0 format:NSPropertyListXMLFormat_v1_0
errorDescription:&error]; options:0
error:nil];
[data writeToFile:tempFilePath atomically:YES]; [data writeToFile:tempFilePath atomically:YES];
XCRunTask* task = [[[XCRunTask alloc] initWithArguments:@[ XCRunTask* task = [[[XCRunTask alloc] initWithArguments:@[
@"xcodebuild", @"-xctestrun", tempFilePath, @"-destination", @"xcodebuild", @"-xctestrun", tempFilePath, @"-destination",

@@ -89,7 +89,8 @@ LocaleMac::LocaleMac(NSLocale* locale)
: locale_(locale), : locale_(locale),
gregorian_calendar_( gregorian_calendar_(
kAdoptNS, kAdoptNS,
[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]), [[NSCalendar alloc]
initWithCalendarIdentifier:NSCalendarIdentifierGregorian]),
did_initialize_number_data_(false) { did_initialize_number_data_(false) {
NSArray* available_languages = [NSLocale ISOLanguageCodes]; NSArray* available_languages = [NSLocale ISOLanguageCodes];
// NSLocale returns a lower case NSLocaleLanguageCode so we don't have care // NSLocale returns a lower case NSLocaleLanguageCode so we don't have care

@@ -455,6 +455,10 @@ if (is_mac) {
defines = [ "USE_PROTECTED_ALLOCATIONS=1" ] defines = [ "USE_PROTECTED_ALLOCATIONS=1" ]
include_dirs = [ "breakpad/src/client/apple/Framework" ] 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 = [ deps = [
":crash_inspector", ":crash_inspector",
":crash_report_sender", ":crash_report_sender",

@@ -39,6 +39,11 @@ component("google_toolbox_for_mac") {
"Cocoa.framework", "Cocoa.framework",
"QuartzCore.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 } else { # is_ios
sources += [ sources += [
"src/DebugUtils/GTMMethodCheck.h", "src/DebugUtils/GTMMethodCheck.h",

@@ -43,16 +43,13 @@
- (NSArray*)installedBrowserIdentifiers; // sort order not specified - (NSArray*)installedBrowserIdentifiers; // sort order not specified
- (NSString*)defaultBrowserIdentifier; - (NSString*)defaultBrowserIdentifier;
- (NSURL*)defaultBrowserURL;
- (NSArray*)installedFeedViewerIdentifiers; - (NSArray*)installedFeedViewerIdentifiers;
- (NSString*)defaultFeedViewerIdentifier; - (NSString*)defaultFeedViewerIdentifier;
- (NSURL*)defaultFeedViewerURL;
- (void)setDefaultBrowserWithIdentifier:(NSString*)bundleID; - (void)setDefaultBrowserWithIdentifier:(NSString*)bundleID;
- (void)setDefaultFeedViewerWithIdentifier:(NSString*)bundleID; - (void)setDefaultFeedViewerWithIdentifier:(NSString*)bundleID;
- (NSURL*)urlOfApplicationWithIdentifier:(NSString*)bundleID;
- (NSString*)identifierForBundle:(NSURL*)inBundleURL; - (NSString*)identifierForBundle:(NSURL*)inBundleURL;
- (NSString*)displayNameForFile:(NSURL*)inFileURL; - (NSString*)displayNameForFile:(NSURL*)inFileURL;

@@ -81,22 +81,6 @@
return [(NSString*)LSCopyDefaultHandlerForURLScheme(CFSTR("feed")) autorelease]; 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 - (void)setDefaultBrowserWithIdentifier:(NSString*)bundleID
{ {
LSSetDefaultHandlerForURLScheme(CFSTR("http"), (CFStringRef)bundleID); LSSetDefaultHandlerForURLScheme(CFSTR("http"), (CFStringRef)bundleID);
@@ -110,17 +94,6 @@
LSSetDefaultHandlerForURLScheme(CFSTR("feed"), (CFStringRef)bundleID); 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 - (NSString*)identifierForBundle:(NSURL*)inBundleURL
{ {
if (!inBundleURL) return nil; if (!inBundleURL) return nil;

@@ -33,3 +33,6 @@ Local modifications:
- MOZILLA_EXPORT was added to some constants in NSPasteboard+Utils.h. - MOZILLA_EXPORT was added to some constants in NSPasteboard+Utils.h.
- +[NSWorkspace(CaminoDefaultBrowserAdditions) isLeopardOrHigher] hidden since - +[NSWorkspace(CaminoDefaultBrowserAdditions) isLeopardOrHigher] hidden since
it relies on methods deprecated in 10.8 (and is unused in Chrome). 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.

@@ -13,6 +13,11 @@
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
#import "testing/gtest_mac.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 views {
namespace test { namespace test {
@@ -163,3 +168,5 @@ TEST_F(TabbedPaneAccessibilityMacTest, WritableValue) {
} // namespace test } // namespace test
} // namespace views } // namespace views
#pragma clang diagnostic pop

@@ -97,6 +97,11 @@ class TestWidgetDelegate : public test::TestDesktopWidgetDelegate {
constexpr char TestWidgetDelegate::kAccessibleWindowTitle[]; 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 { class AXNativeWidgetMacTest : public test::WidgetTest {
public: public:
AXNativeWidgetMacTest() {} AXNativeWidgetMacTest() {}
@@ -927,3 +932,5 @@ TEST_F(AXNativeWidgetMacTest, Combobox) {
} }
} // namespace views } // namespace views
#pragma clang diagnostic pop

@@ -701,6 +701,11 @@ TEST_F(NativeWidgetMacTest, SetCursor) {
widget->CloseNow(); 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 // Tests that an accessibility request from the system makes its way through to
// a views::Label filling the window. // a views::Label filling the window.
TEST_F(NativeWidgetMacTest, AccessibilityIntegration) { TEST_F(NativeWidgetMacTest, AccessibilityIntegration) {
@@ -726,6 +731,8 @@ TEST_F(NativeWidgetMacTest, AccessibilityIntegration) {
widget->CloseNow(); widget->CloseNow();
} }
#pragma clang diagnostic pop
namespace { namespace {
Widget* AttachPopupToNativeParent(NSWindow* native_parent) { Widget* AttachPopupToNativeParent(NSWindow* native_parent) {

@@ -209,7 +209,7 @@ const int kMessageTextMaxSlots = 2000;
case NSAlertSecondButtonReturn: // Cancel case NSAlertSecondButtonReturn: // Cancel
alertBridge_->SendResultAndDestroy(AlertDisposition::SECONDARY_BUTTON); alertBridge_->SendResultAndDestroy(AlertDisposition::SECONDARY_BUTTON);
break; break;
case NSRunStoppedResponse: // Window was closed underneath us case NSModalResponseStop: // Window was closed underneath us
alertBridge_->SendResultAndDestroy(AlertDisposition::CLOSE); alertBridge_->SendResultAndDestroy(AlertDisposition::CLOSE);
break; break;
default: default:
@@ -223,10 +223,15 @@ const int kMessageTextMaxSlots = 2000;
NSAlert* alert = [self alert]; NSAlert* alert = [self alert];
[alert layout]; [alert layout];
[[alert window] recalculateKeyViewLoop]; [[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 [alert beginSheetModalForWindow:nil // nil here makes it app-modal
modalDelegate:self modalDelegate:self
didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
contextInfo:NULL]; contextInfo:NULL];
#pragma clang diagnostic pop
} }
- (void)closeWindow { - (void)closeWindow {

@@ -1338,11 +1338,16 @@ void BridgedNativeWidgetImpl::ShowAsModalSheet() {
// Since |this| may destroy [window_ delegate], use |window_| itself as the // Since |this| may destroy [window_ delegate], use |window_| itself as the
// delegate, which will forward to ViewsNSWindowDelegate if |this| is still // delegate, which will forward to ViewsNSWindowDelegate if |this| is still
// alive (i.e. it has not set the window delegate to nil). // 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_ [NSApp beginSheet:window_
modalForWindow:parent_window modalForWindow:parent_window
modalDelegate:window_ modalDelegate:window_
didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
contextInfo:nullptr]; contextInfo:nullptr];
#pragma clang diagnostic pop
} }
} // namespace views } // namespace views