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

Side by Side Diff: base/mac/mac_util.mm

Issue 9240004: Transition to base/mac/bundle_locations.h step 3 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/mac_util.h" 5 #include "base/mac/mac_util.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 #include <string.h> 8 #include <string.h>
9 #include <sys/utsname.h> 9 #include <sys/utsname.h>
10 10
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/mac/bundle_locations.h"
13 #include "base/mac/foundation_util.h" 14 #include "base/mac/foundation_util.h"
14 #include "base/mac/scoped_cftyperef.h" 15 #include "base/mac/scoped_cftyperef.h"
15 #include "base/memory/scoped_nsobject.h" 16 #include "base/memory/scoped_nsobject.h"
16 #include "base/string_number_conversions.h" 17 #include "base/string_number_conversions.h"
17 #include "base/string_piece.h" 18 #include "base/string_piece.h"
18 #include "base/sys_string_conversions.h" 19 #include "base/sys_string_conversions.h"
19 20
20 namespace base { 21 namespace base {
21 namespace mac { 22 namespace mac {
22 23
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 NULL, kLSSharedFileListSessionLoginItems, NULL)); 66 NULL, kLSSharedFileListSessionLoginItems, NULL));
66 67
67 if (!login_items.get()) { 68 if (!login_items.get()) {
68 DLOG(ERROR) << "Couldn't get a Login Items list."; 69 DLOG(ERROR) << "Couldn't get a Login Items list.";
69 return NULL; 70 return NULL;
70 } 71 }
71 72
72 scoped_nsobject<NSArray> login_items_array( 73 scoped_nsobject<NSArray> login_items_array(
73 CFToNSCast(LSSharedFileListCopySnapshot(login_items, NULL))); 74 CFToNSCast(LSSharedFileListCopySnapshot(login_items, NULL)));
74 75
75 NSURL* url = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]; 76 NSURL* url = [NSURL fileURLWithPath:[base::mac::MainBundle() bundlePath]];
76 77
77 for(NSUInteger i = 0; i < [login_items_array count]; ++i) { 78 for(NSUInteger i = 0; i < [login_items_array count]; ++i) {
78 LSSharedFileListItemRef item = reinterpret_cast<LSSharedFileListItemRef>( 79 LSSharedFileListItemRef item = reinterpret_cast<LSSharedFileListItemRef>(
79 [login_items_array objectAtIndex:i]); 80 [login_items_array objectAtIndex:i]);
80 CFURLRef item_url_ref = NULL; 81 CFURLRef item_url_ref = NULL;
81 82
82 if (LSSharedFileListItemResolve(item, 0, &item_url_ref, NULL) == noErr) { 83 if (LSSharedFileListItemResolve(item, 0, &item_url_ref, NULL) == noErr) {
83 ScopedCFTypeRef<CFURLRef> item_url(item_url_ref); 84 ScopedCFTypeRef<CFURLRef> item_url(item_url_ref);
84 if (CFEqual(item_url, url)) { 85 if (CFEqual(item_url, url)) {
85 CFRetain(item); 86 CFRetain(item);
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 if (!login_items.get()) { 410 if (!login_items.get()) {
410 DLOG(ERROR) << "Couldn't get a Login Items list."; 411 DLOG(ERROR) << "Couldn't get a Login Items list.";
411 return; 412 return;
412 } 413 }
413 414
414 // Remove the old item, it has wrong hide flag, we'll create a new one. 415 // Remove the old item, it has wrong hide flag, we'll create a new one.
415 if (item.get()) { 416 if (item.get()) {
416 LSSharedFileListItemRemove(login_items, item); 417 LSSharedFileListItemRemove(login_items, item);
417 } 418 }
418 419
419 NSURL* url = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]; 420 NSURL* url = [NSURL fileURLWithPath:[base::mac::MainBundle() bundlePath]];
420 421
421 BOOL hide = hide_on_startup ? YES : NO; 422 BOOL hide = hide_on_startup ? YES : NO;
422 NSDictionary* properties = 423 NSDictionary* properties =
423 [NSDictionary 424 [NSDictionary
424 dictionaryWithObject:[NSNumber numberWithBool:hide] 425 dictionaryWithObject:[NSNumber numberWithBool:hide]
425 forKey:(NSString*)kLSSharedFileListLoginItemHidden]; 426 forKey:(NSString*)kLSSharedFileListLoginItemHidden];
426 427
427 ScopedCFTypeRef<LSSharedFileListItemRef> new_item; 428 ScopedCFTypeRef<LSSharedFileListItemRef> new_item;
428 new_item.reset(LSSharedFileListInsertItemURL( 429 new_item.reset(LSSharedFileListInsertItemURL(
429 login_items, kLSSharedFileListItemLast, NULL, NULL, 430 login_items, kLSSharedFileListItemLast, NULL, NULL,
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 #endif 617 #endif
617 618
618 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7) 619 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7)
619 bool IsOSLaterThanLion() { 620 bool IsOSLaterThanLion() {
620 return MacOSXMinorVersion() > LION_MINOR_VERSION; 621 return MacOSXMinorVersion() > LION_MINOR_VERSION;
621 } 622 }
622 #endif 623 #endif
623 624
624 } // namespace mac 625 } // namespace mac
625 } // namespace base 626 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/mac/install_from_dmg.mm » ('j') | chrome/browser/shell_integration_mac.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698