Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(545)

Side by Side Diff: base/mac_util.mm

Issue 3473006: Fix a bunch of clang warnings/errors. (Closed)
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/mac_util.h" 5 #include "base/mac_util.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 desired_mode = kUIModeAllHidden; 46 desired_mode = kUIModeAllHidden;
47 } 47 }
48 48
49 if (current_mode != desired_mode) 49 if (current_mode != desired_mode)
50 SetSystemUIMode(desired_mode, desired_options); 50 SetSystemUIMode(desired_mode, desired_options);
51 } 51 }
52 52
53 bool WasLaunchedAsLoginItem() { 53 bool WasLaunchedAsLoginItem() {
54 ProcessSerialNumber psn = { 0, kCurrentProcess }; 54 ProcessSerialNumber psn = { 0, kCurrentProcess };
55 55
56 scoped_nsobject<NSDictionary> process_info( 56 scoped_nsobject<const NSDictionary> process_info(
57 reinterpret_cast<const NSDictionary*>( 57 reinterpret_cast<const NSDictionary*>(
58 ProcessInformationCopyDictionary(&psn, 58 ProcessInformationCopyDictionary(&psn,
59 kProcessDictionaryIncludeAllInformationMask))); 59 kProcessDictionaryIncludeAllInformationMask)));
60 60
61 long long temp = [[process_info objectForKey:@"ParentPSN"] longLongValue]; 61 long long temp = [[process_info objectForKey:@"ParentPSN"] longLongValue];
62 ProcessSerialNumber parent_psn = 62 ProcessSerialNumber parent_psn =
63 { (temp >> 32) & 0x00000000FFFFFFFFLL, temp & 0x00000000FFFFFFFFLL }; 63 { (temp >> 32) & 0x00000000FFFFFFFFLL, temp & 0x00000000FFFFFFFFLL };
64 64
65 scoped_nsobject<NSDictionary> parent_info( 65 scoped_nsobject<const NSDictionary> parent_info(
66 reinterpret_cast<const NSDictionary*>( 66 reinterpret_cast<const NSDictionary*>(
67 ProcessInformationCopyDictionary(&parent_psn, 67 ProcessInformationCopyDictionary(&parent_psn,
68 kProcessDictionaryIncludeAllInformationMask))); 68 kProcessDictionaryIncludeAllInformationMask)));
69 69
70 // Check that creator process code is that of loginwindow. 70 // Check that creator process code is that of loginwindow.
71 BOOL result = 71 BOOL result =
72 [[parent_info objectForKey:@"FileCreator"] isEqualToString:@"lgnw"]; 72 [[parent_info objectForKey:@"FileCreator"] isEqualToString:@"lgnw"];
73 73
74 return result == YES; 74 return result == YES;
75 } 75 }
76 76
77 // Looks into Shared File Lists corresponding to Login Items for the item 77 // Looks into Shared File Lists corresponding to Login Items for the item
78 // representing the current application. If such an item is found, returns 78 // representing the current application. If such an item is found, returns
79 // retained reference to it. Caller is responsible for releasing the reference. 79 // retained reference to it. Caller is responsible for releasing the reference.
80 LSSharedFileListItemRef GetLoginItemForApp() { 80 LSSharedFileListItemRef GetLoginItemForApp() {
81 scoped_cftyperef<LSSharedFileListRef> login_items(LSSharedFileListCreate( 81 scoped_cftyperef<LSSharedFileListRef> login_items(LSSharedFileListCreate(
82 NULL, kLSSharedFileListSessionLoginItems, NULL)); 82 NULL, kLSSharedFileListSessionLoginItems, NULL));
83 83
84 if (!login_items.get()) { 84 if (!login_items.get()) {
85 LOG(ERROR) << "Couldn't get a Login Items list."; 85 LOG(ERROR) << "Couldn't get a Login Items list.";
86 return NULL; 86 return NULL;
87 } 87 }
88 88
89 scoped_nsobject<NSArray> login_items_array(reinterpret_cast<const NSArray*>( 89 scoped_nsobject<const NSArray> login_items_array(
90 LSSharedFileListCopySnapshot(login_items, NULL))); 90 reinterpret_cast<const NSArray*>(
91 LSSharedFileListCopySnapshot(login_items, NULL)));
91 92
92 NSURL* url = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]; 93 NSURL* url = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
93 94
94 for(NSUInteger i = 0; i < [login_items_array count]; ++i) { 95 for(NSUInteger i = 0; i < [login_items_array count]; ++i) {
95 LSSharedFileListItemRef item = reinterpret_cast<LSSharedFileListItemRef>( 96 LSSharedFileListItemRef item = reinterpret_cast<LSSharedFileListItemRef>(
96 [login_items_array objectAtIndex:i]); 97 [login_items_array objectAtIndex:i]);
97 CFURLRef item_url_ref = NULL; 98 CFURLRef item_url_ref = NULL;
98 99
99 if (LSSharedFileListItemResolve(item, 0, &item_url_ref, NULL) == noErr) { 100 if (LSSharedFileListItemResolve(item, 0, &item_url_ref, NULL) == noErr) {
100 scoped_cftyperef<CFURLRef> item_url(item_url_ref); 101 scoped_cftyperef<CFURLRef> item_url(item_url_ref);
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 663
663 scoped_cftyperef<LSSharedFileListItemRef> item(GetLoginItemForApp()); 664 scoped_cftyperef<LSSharedFileListItemRef> item(GetLoginItemForApp());
664 if (!item.get()) { 665 if (!item.get()) {
665 LOG(ERROR) << "Process launched at Login but can't access Login Item List."; 666 LOG(ERROR) << "Process launched at Login but can't access Login Item List.";
666 return false; 667 return false;
667 } 668 }
668 return IsHiddenLoginItem(item); 669 return IsHiddenLoginItem(item);
669 } 670 }
670 671
671 } // namespace mac_util 672 } // namespace mac_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698