New issue
Advanced search Search tips

Issue 650854 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Oct 2016
Cc:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 3
Type: Bug

Blocked on:
issue 650790
issue 650801

Blocking:
issue 547071



Sign in to add a comment

Prepare base/mac/mac_util.mm for 10.9 deployment target.

Project Member Reported by erikc...@chromium.org, Sep 27 2016

Issue description

[65/38613] OBJCXX obj/base/base/mac_util.o
../../base/mac/mac_util.mm:127:7: warning: 'CFURLCreateFromFSRef' is deprecated: first deprecated in macOS 10.9 [-Wdeprecated-declarations]
      CFURLCreateFromFSRef(kCFAllocatorDefault, &ref));
      ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h:472:10: note: 'CFURLCreateFromFSRef' has been explicitly marked deprecated here
CFURLRef CFURLCreateFromFSRef(CFAllocatorRef allocator, const struct FSRef *fsRef) CF_DEPRECATED(10_0, 10_9, 2_0, 7_0);
         ^
../../base/mac/mac_util.mm:133:21: warning: 'FSPathMakeRef' is deprecated: first deprecated in macOS 10.8 [-Wdeprecated-declarations]
  OSStatus status = FSPathMakeRef((const UInt8*)path.c_str(),
                    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Files.h:4115:18: note: 'FSPathMakeRef' has been explicitly marked deprecated here
extern OSStatus  FSPathMakeRef(const UInt8 *path, FSRef *ref, Boolean *isDirectory)        __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA);
                 ^
../../base/mac/mac_util.mm:223:15: warning: 'GetFrontProcess' is deprecated: first deprecated in macOS 10.9 [-Wdeprecated-declarations]
  OSErr err = GetFrontProcess(&foreground_psn);
              ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/ApplicationServices.framework/Frameworks/HIServices.framework/Headers/Processes.h:434:1: note: 'GetFrontProcess' has been explicitly marked deprecated here
GetFrontProcess(ProcessSerialNumber * PSN)                    AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9;
^
../../base/mac/mac_util.mm:232:9: warning: 'SameProcess' is deprecated: first deprecated in macOS 10.9 [-Wdeprecated-declarations]
  err = SameProcess(&foreground_psn, &my_psn, &result);
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/ApplicationServices.framework/Frameworks/HIServices.framework/Headers/Processes.h:696:1: note: 'SameProcess' has been explicitly marked deprecated here
SameProcess(
^
../../base/mac/mac_util.mm:332:7: warning: 'GetProcessInformation' is deprecated: first deprecated in macOS 10.9 [-Wdeprecated-declarations]
  if (GetProcessInformation(&psn, &info) == noErr) {
      ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/ApplicationServices.framework/Frameworks/HIServices.framework/Headers/Processes.h:513:1: note: 'GetProcessInformation' has been explicitly marked deprecated here
GetProcessInformation(
^
../../base/mac/mac_util.mm:335:9: warning: 'GetProcessInformation' is deprecated: first deprecated in macOS 10.9 [-Wdeprecated-declarations]
    if (GetProcessInformation(&info.processLauncher, &parent_info) == noErr)
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/ApplicationServices.framework/Frameworks/HIServices.framework/Headers/Processes.h:513:1: note: 'GetProcessInformation' has been explicitly marked deprecated here
GetProcessInformation(
^
6 warnings generated.
 
Labels: OS-Mac
Owner: eugene...@chromium.org
Status: Assigned (was: Untriaged)
Blockedon: 650801
base::mac::PathFromFSRef is used by service_process_util_mac.mm ( crbug.com/650801 )
Project Member

Comment 3 by bugdroid1@chromium.org, Oct 6 2016

Project Member

Comment 4 by bugdroid1@chromium.org, Oct 6 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/1cc274c36c784591ed4a0fcd6dab7465e033c823

commit 1cc274c36c784591ed4a0fcd6dab7465e033c823
Author: eugenebut <eugenebut@chromium.org>
Date: Thu Oct 06 04:02:20 2016

[Mac Fix-It] removed base::mac::AmIForeground function.

Use [[NSRunningApplication currentApplication] isActive]
call instead.

BUG= 650854 

Review-Url: https://codereview.chromium.org/2394733002
Cr-Commit-Position: refs/heads/master@{#423425}

[modify] https://crrev.com/1cc274c36c784591ed4a0fcd6dab7465e033c823/base/mac/mac_util.h
[modify] https://crrev.com/1cc274c36c784591ed4a0fcd6dab7465e033c823/base/mac/mac_util.mm
[modify] https://crrev.com/1cc274c36c784591ed4a0fcd6dab7465e033c823/chrome/browser/mac/relauncher.mm

Project Member

Comment 5 by bugdroid1@chromium.org, Oct 6 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/1cc274c36c784591ed4a0fcd6dab7465e033c823

commit 1cc274c36c784591ed4a0fcd6dab7465e033c823
Author: eugenebut <eugenebut@chromium.org>
Date: Thu Oct 06 04:02:20 2016

[Mac Fix-It] removed base::mac::AmIForeground function.

Use [[NSRunningApplication currentApplication] isActive]
call instead.

BUG= 650854 

Review-Url: https://codereview.chromium.org/2394733002
Cr-Commit-Position: refs/heads/master@{#423425}

[modify] https://crrev.com/1cc274c36c784591ed4a0fcd6dab7465e033c823/base/mac/mac_util.h
[modify] https://crrev.com/1cc274c36c784591ed4a0fcd6dab7465e033c823/base/mac/mac_util.mm
[modify] https://crrev.com/1cc274c36c784591ed4a0fcd6dab7465e033c823/chrome/browser/mac/relauncher.mm

Comment 6 Deleted

Comment 7 Deleted

Project Member

Comment 8 by bugdroid1@chromium.org, Oct 6 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/fe109cbea3a8e708609bfc16673684f274f18a6d

commit fe109cbea3a8e708609bfc16673684f274f18a6d
Author: eugenebut <eugenebut@chromium.org>
Date: Thu Oct 06 22:44:26 2016

[mac] Use -[NSApp isActive] for checking if current app is active.

Use short version in RelaunchAppWithHelper() instead of
[[NSRunningApplication currentApplication] isActive]

BUG= 650854 

Review-Url: https://codereview.chromium.org/2398943002
Cr-Commit-Position: refs/heads/master@{#423716}

[modify] https://crrev.com/fe109cbea3a8e708609bfc16673684f274f18a6d/chrome/browser/mac/relauncher.mm

Project Member

Comment 9 by bugdroid1@chromium.org, Oct 7 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/2f7ce1d11fd3b346468569389e8cc97f97453377

commit 2f7ce1d11fd3b346468569389e8cc97f97453377
Author: eugenebut <eugenebut@chromium.org>
Date: Fri Oct 07 01:04:56 2016

[Mac Fix-It] Use FSPathMakeRef instead of base::mac::FSRefFromPath.

base::mac::FSRefFromPath will be removed as it is relied on deprecated
API. The only place where FSPathMakeRef needed is
QuarantinePropertiesDeprecated API. So instead of having shared
base::mac::FSRefFromPath function which depends on deprecated API it is
better to use FSPathMakeRef right in place where it's needed as it will
be easier to clean up that code later.

BUG= 650854 

Review-Url: https://codereview.chromium.org/2389123002
Cr-Commit-Position: refs/heads/master@{#423769}

[modify] https://crrev.com/2f7ce1d11fd3b346468569389e8cc97f97453377/content/browser/download/quarantine_mac.mm

Status: Started (was: Fixed)
Was closed by mistake
Removing GetProcessInformation from WasLaunchedAsLoginOrResumeItem is problematic. 

Modern API for checking if the app launch is a login launch relies on NSApplicationDidFinishLaunchingNotification, which is called much later than GetProcessInformation.
NSApplicationDidFinishLaunchingNotification is not exactly a drop in replacement for GetProcessInformation.

NSApplicationDidFinishLaunchingNotification only allows to tell if the app was launched as a part of Lion App Restoration flow. It does not allow to tell if the app was launched as Login item.


Also when app was launched via Lion App Restoration flow one of command line arguments is -psn_0_32776. And this number is always the same, so maybe we can check for this argument instead of using GetProcessInformation or NSApplicationDidFinishLaunchingNotification.

Another thing I'm going to look at is Apple Events received during the launch.

AppKit relies on a private (NSPersistentUIManager) class to tell if the app is launched via Lion App Restoration flow. So the fact that app is going to restore the state is known as early as when WasLaunchedAsLoginOrResumeItem is called. However there is no reliable way to get this information.

Will try exploring alternative approaches (f.e. inspecting parent process information, which could be one of macOS services).
Cc: tapted@chromium.org eugene...@chromium.org
Owner: ----
Status: Available (was: Started)
Autolaunched app does not have a parent process. ProcessInfoRec.processLauncher points to a launcher process. This launcher process has distinct NSRunningApplication.bundleIdentifier which could be used to identify Lion App Restoration flow, but I could not find a way to get launcher process ID with modern API.

I will be switching back to iOS work and unassigning this bug.
Owner: erikc...@chromium.org
Status: Assigned (was: Available)
Cc: mark@chromium.org rsesek@chromium.org
+ mark, rsesek: If you have any ideas, please speak up. Otherwise I'm going to suppress this deprecated declaration warning. Note that this discussion pertains to c#11.

I spent some time looking into this and came to the same conclusion as eugenebut. I couldn't find any non-deprecated APIs that would provide this same information as GetProcessInformation.

Note that the replacement API NSRunningApplication doesn't return any information about non-user processes. 

Comment 17 by mark@chromium.org, Oct 18 2016

Suppressing the warning for GetProcessInformation() sounds OK given the results of the exhaustive investigation. Special thanks to Eugene.
Project Member

Comment 18 by bugdroid1@chromium.org, Oct 21 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/98b75a2586d9ad1b051708df2572fcdbc0dcd7da

commit 98b75a2586d9ad1b051708df2572fcdbc0dcd7da
Author: erikchen <erikchen@chromium.org>
Date: Fri Oct 21 04:14:55 2016

Suppress a declarated-declaration warning for GetProcessInformation.

There's no replacement method that does what we need. See bug for more details.

BUG= 650854 

Review-Url: https://chromiumcodereview.appspot.com/2433773008
Cr-Commit-Position: refs/heads/master@{#426726}

[modify] https://crrev.com/98b75a2586d9ad1b051708df2572fcdbc0dcd7da/base/mac/mac_util.mm

Status: Fixed (was: Assigned)
Project Member

Comment 20 by bugdroid1@chromium.org, Oct 27 2016

Project Member

Comment 21 by bugdroid1@chromium.org, Oct 27 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/1cc274c36c784591ed4a0fcd6dab7465e033c823

commit 1cc274c36c784591ed4a0fcd6dab7465e033c823
Author: eugenebut <eugenebut@chromium.org>
Date: Thu Oct 06 04:02:20 2016

[Mac Fix-It] removed base::mac::AmIForeground function.

Use [[NSRunningApplication currentApplication] isActive]
call instead.

BUG= 650854 

Review-Url: https://codereview.chromium.org/2394733002
Cr-Commit-Position: refs/heads/master@{#423425}

[modify] https://crrev.com/1cc274c36c784591ed4a0fcd6dab7465e033c823/base/mac/mac_util.h
[modify] https://crrev.com/1cc274c36c784591ed4a0fcd6dab7465e033c823/base/mac/mac_util.mm
[modify] https://crrev.com/1cc274c36c784591ed4a0fcd6dab7465e033c823/chrome/browser/mac/relauncher.mm

Project Member

Comment 22 by bugdroid1@chromium.org, Oct 27 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/fe109cbea3a8e708609bfc16673684f274f18a6d

commit fe109cbea3a8e708609bfc16673684f274f18a6d
Author: eugenebut <eugenebut@chromium.org>
Date: Thu Oct 06 22:44:26 2016

[mac] Use -[NSApp isActive] for checking if current app is active.

Use short version in RelaunchAppWithHelper() instead of
[[NSRunningApplication currentApplication] isActive]

BUG= 650854 

Review-Url: https://codereview.chromium.org/2398943002
Cr-Commit-Position: refs/heads/master@{#423716}

[modify] https://crrev.com/fe109cbea3a8e708609bfc16673684f274f18a6d/chrome/browser/mac/relauncher.mm

Comment 23 by dimu@google.com, Nov 4 2016

Labels: -merge-merged-2840
[Automated comment] removing mislabelled merge-merged-2840

Sign in to add a comment