OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #import "chrome/browser/mac/dock.h" | 5 #import "chrome/browser/mac/dock.h" |
6 | 6 |
7 #include <ApplicationServices/ApplicationServices.h> | 7 #include <ApplicationServices/ApplicationServices.h> |
8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
9 #include <CoreFoundation/CoreFoundation.h> | 9 #include <CoreFoundation/CoreFoundation.h> |
10 #include <signal.h> | 10 #include <signal.h> |
(...skipping 29 matching lines...) Expand all Loading... |
40 namespace dock { | 40 namespace dock { |
41 namespace { | 41 namespace { |
42 | 42 |
43 NSString* const kDockTileDataKey = @"tile-data"; | 43 NSString* const kDockTileDataKey = @"tile-data"; |
44 NSString* const kDockFileDataKey = @"file-data"; | 44 NSString* const kDockFileDataKey = @"file-data"; |
45 | 45 |
46 // A wrapper around _CFURLCopyPropertyListRepresentation that operates on | 46 // A wrapper around _CFURLCopyPropertyListRepresentation that operates on |
47 // Foundation data types and returns an autoreleased NSDictionary. | 47 // Foundation data types and returns an autoreleased NSDictionary. |
48 NSDictionary* NSURLCopyDictionary(NSURL* url) { | 48 NSDictionary* NSURLCopyDictionary(NSURL* url) { |
49 CFURLRef url_cf = base::mac::NSToCFCast(url); | 49 CFURLRef url_cf = base::mac::NSToCFCast(url); |
50 base::mac::ScopedCFTypeRef<CFPropertyListRef> property_list( | 50 base::ScopedCFTypeRef<CFPropertyListRef> property_list( |
51 _CFURLCopyPropertyListRepresentation(url_cf)); | 51 _CFURLCopyPropertyListRepresentation(url_cf)); |
52 CFDictionaryRef dictionary_cf = | 52 CFDictionaryRef dictionary_cf = |
53 base::mac::CFCast<CFDictionaryRef>(property_list); | 53 base::mac::CFCast<CFDictionaryRef>(property_list); |
54 NSDictionary* dictionary = base::mac::CFToNSCast(dictionary_cf); | 54 NSDictionary* dictionary = base::mac::CFToNSCast(dictionary_cf); |
55 | 55 |
56 if (!dictionary) { | 56 if (!dictionary) { |
57 return nil; | 57 return nil; |
58 } | 58 } |
59 | 59 |
60 NSMakeCollectable(property_list.release()); | 60 NSMakeCollectable(property_list.release()); |
61 return [dictionary autorelease]; | 61 return [dictionary autorelease]; |
62 } | 62 } |
63 | 63 |
64 // A wrapper around _CFURLCreateFromPropertyListRepresentation that operates | 64 // A wrapper around _CFURLCreateFromPropertyListRepresentation that operates |
65 // on Foundation data types and returns an autoreleased NSURL. | 65 // on Foundation data types and returns an autoreleased NSURL. |
66 NSURL* NSURLCreateFromDictionary(NSDictionary* dictionary) { | 66 NSURL* NSURLCreateFromDictionary(NSDictionary* dictionary) { |
67 CFDictionaryRef dictionary_cf = base::mac::NSToCFCast(dictionary); | 67 CFDictionaryRef dictionary_cf = base::mac::NSToCFCast(dictionary); |
68 base::mac::ScopedCFTypeRef<CFURLRef> url_cf( | 68 base::ScopedCFTypeRef<CFURLRef> url_cf( |
69 _CFURLCreateFromPropertyListRepresentation(NULL, dictionary_cf)); | 69 _CFURLCreateFromPropertyListRepresentation(NULL, dictionary_cf)); |
70 NSURL* url = base::mac::CFToNSCast(url_cf); | 70 NSURL* url = base::mac::CFToNSCast(url_cf); |
71 | 71 |
72 if (!url) { | 72 if (!url) { |
73 return nil; | 73 return nil; |
74 } | 74 } |
75 | 75 |
76 NSMakeCollectable(url_cf.release()); | 76 NSMakeCollectable(url_cf.release()); |
77 return [url autorelease]; | 77 return [url autorelease]; |
78 } | 78 } |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 } | 326 } |
327 | 327 |
328 // Rewrite the plist. | 328 // Rewrite the plist. |
329 [dock_plist setObject:persistent_apps forKey:kDockPersistentAppsKey]; | 329 [dock_plist setObject:persistent_apps forKey:kDockPersistentAppsKey]; |
330 [user_defaults setPersistentDomain:dock_plist forName:kDockDomain]; | 330 [user_defaults setPersistentDomain:dock_plist forName:kDockDomain]; |
331 | 331 |
332 Restart(); | 332 Restart(); |
333 } | 333 } |
334 | 334 |
335 } // namespace dock | 335 } // namespace dock |
OLD | NEW |