summaryrefslogtreecommitdiffstats
path: root/base/mac
diff options
context:
space:
mode:
authorleng@chromium.org <leng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-01 22:05:39 +0000
committerleng@chromium.org <leng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-01 22:05:39 +0000
commit0ca686837dfcc6874791c0d92bc973c2a830fa74 (patch)
tree81c6abb6fc1a5721b188f26219d6aba788a834eb /base/mac
parentfecd3110636f2db89326f8959274ae8f0a02908c (diff)
downloadchromium_src-0ca686837dfcc6874791c0d92bc973c2a830fa74.zip
chromium_src-0ca686837dfcc6874791c0d92bc973c2a830fa74.tar.gz
chromium_src-0ca686837dfcc6874791c0d92bc973c2a830fa74.tar.bz2
Re-land "Replaces use of ProcessInformationCopyDictionary ..."
This reverts commit 5c1848ea87157db1a455a73b1868a4a962afa215. Original CL was reverted because ProcessInfoRec::processAppSpec does not exist on x64. (Google search results claim it is named processAppRec instead.) This patch changes the original CL by initializing the whole ProcessInfoRect struct to 0 before use, rather than setting individual members to NULL. Original CL: https://codereview.chromium.org/354243003/ Replaces use of ProcessInformationCopyDictionary with GetProcessInformation. ProcessInformationCopyDictionary is crashing on 10.7. This changes WasLaunchedAsLoginOrResumeItem to use lower-level calls instead of ProcessInformationCopyDictionary, with the hope that it will bypass the 10.7 crash. Other reports of crashes in this function on 10.7 claim to have been worked around, so there is reason to believe this will not crash. BUG=383029 Review URL: https://codereview.chromium.org/363503003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@280897 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/mac')
-rw-r--r--base/mac/mac_util.mm28
1 files changed, 10 insertions, 18 deletions
diff --git a/base/mac/mac_util.mm b/base/mac/mac_util.mm
index 4ff1c87..55c4b7d 100644
--- a/base/mac/mac_util.mm
+++ b/base/mac/mac_util.mm
@@ -356,24 +356,16 @@ void RemoveFromLoginItems() {
bool WasLaunchedAsLoginOrResumeItem() {
ProcessSerialNumber psn = { 0, kCurrentProcess };
-
- base::scoped_nsobject<NSDictionary> process_info(
- CFToNSCast(ProcessInformationCopyDictionary(
- &psn, kProcessDictionaryIncludeAllInformationMask)));
-
- long long temp = [[process_info objectForKey:@"ParentPSN"] longLongValue];
- ProcessSerialNumber parent_psn =
- { (temp >> 32) & 0x00000000FFFFFFFFLL, temp & 0x00000000FFFFFFFFLL };
-
- base::scoped_nsobject<NSDictionary> parent_info(
- CFToNSCast(ProcessInformationCopyDictionary(
- &parent_psn, kProcessDictionaryIncludeAllInformationMask)));
-
- // Check that creator process code is that of loginwindow.
- BOOL result =
- [[parent_info objectForKey:@"FileCreator"] isEqualToString:@"lgnw"];
-
- return result == YES;
+ ProcessInfoRec info = {};
+ info.processInfoLength = sizeof(info);
+
+ if (GetProcessInformation(&psn, &info) == noErr) {
+ ProcessInfoRec parent_info = {};
+ parent_info.processInfoLength = sizeof(parent_info);
+ if (GetProcessInformation(&info.processLauncher, &parent_info) == noErr)
+ return parent_info.processSignature == 'lgnw';
+ }
+ return false;
}
bool WasLaunchedAsLoginItemRestoreState() {