summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-17 17:11:39 +0000
committerdmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-17 17:11:39 +0000
commit51288faa2157b0649f02d10ce934caa22a50344b (patch)
treeef03488f581e3bf48a3c37a5d6c182c5158f0adb
parent1340071ae15389bc71bac04738b0c3306494f3d8 (diff)
downloadchromium_src-51288faa2157b0649f02d10ce934caa22a50344b.zip
chromium_src-51288faa2157b0649f02d10ce934caa22a50344b.tar.gz
chromium_src-51288faa2157b0649f02d10ce934caa22a50344b.tar.bz2
Revert 69552 - Add support for easily casting CFTypes to NSTypes
BUG=NONE TEST=BUILD Review URL: http://codereview.chromium.org/5857006 TBR=dmaclach@chromium.org Review URL: http://codereview.chromium.org/5958004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69553 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/mac_util.h48
-rw-r--r--chrome/browser/ui/cocoa/authorization_util.mm3
2 files changed, 2 insertions, 49 deletions
diff --git a/base/mac_util.h b/base/mac_util.h
index 9da90d2..d31bf82 100644
--- a/base/mac_util.h
+++ b/base/mac_util.h
@@ -10,8 +10,6 @@
#include <string>
#include <vector>
-#include "base/logging.h"
-
class FilePath;
#ifdef __OBJC__
@@ -190,52 +188,6 @@ bool WasLaunchedAsHiddenLoginItem();
void NSObjectRetain(void* obj);
void NSObjectRelease(void* obj);
-// Convert toll-free bridged CFTypes to NSTypes. This does not autorelease
-// |cf_val|. This is useful for the case where there is a CFType in a call that
-// expects an NSType and the compiler is complaining about const casting
-// problems.
-// The call is used like this:
-// NSString *foo = CFToNSCast(CFSTR("Hello"));
-// The macro magic below is to enforce safe casting. It could possibly have
-// been done using template function specialization, but template function
-// specialization doesn't always work intuitively,
-// (http://www.gotw.ca/publications/mill17.htm) so the trusty combination
-// of macros and function overloading is used instead.
-
-#define CF_TO_NS_CAST(TypeCF, TypeNS) \
-TypeNS* CFToNSCast(TypeCF cf_val) { \
- TypeNS* ns_val = \
- const_cast<id>(reinterpret_cast<const struct objc_object*>(cf_val)); \
- DCHECK(!ns_val || [ns_val isKindOfClass:[TypeNS class]]); \
- return ns_val; \
-}
-
-// List of toll-free bridged types taken from:
-// http://www.cocoadev.com/index.pl?TollFreeBridged
-
-CF_TO_NS_CAST(CFArrayRef, NSArray);
-CF_TO_NS_CAST(CFMutableArrayRef, NSMutableArray);
-CF_TO_NS_CAST(CFAttributedStringRef, NSAttributedString);
-CF_TO_NS_CAST(CFMutableAttributedStringRef, NSMutableAttributedString);
-CF_TO_NS_CAST(CFCalendarRef, NSCalendar);
-CF_TO_NS_CAST(CFCharacterSetRef, NSCharacterSet);
-CF_TO_NS_CAST(CFMutableCharacterSetRef, NSMutableCharacterSet);
-CF_TO_NS_CAST(CFDataRef, NSData);
-CF_TO_NS_CAST(CFMutableDataRef, NSMutableData);
-CF_TO_NS_CAST(CFDateRef, NSDate);
-CF_TO_NS_CAST(CFDictionaryRef, NSDictionary);
-CF_TO_NS_CAST(CFMutableDictionaryRef, NSMutableDictionary);
-CF_TO_NS_CAST(CFNumberRef, NSNumber);
-CF_TO_NS_CAST(CFRunLoopTimerRef, NSTimer);
-CF_TO_NS_CAST(CFSetRef, NSSet);
-CF_TO_NS_CAST(CFMutableSetRef, NSMutableSet);
-CF_TO_NS_CAST(CFStringRef, NSString);
-CF_TO_NS_CAST(CFMutableStringRef, NSMutableString);
-CF_TO_NS_CAST(CFURLRef, NSURL);
-CF_TO_NS_CAST(CFTimeZoneRef, NSTimeZone);
-CF_TO_NS_CAST(CFReadStreamRef, NSInputStream);
-CF_TO_NS_CAST(CFWriteStreamRef, NSOutputStream);
-
} // namespace mac_util
#endif // BASE_MAC_UTIL_H_
diff --git a/chrome/browser/ui/cocoa/authorization_util.mm b/chrome/browser/ui/cocoa/authorization_util.mm
index 5893711..e92dd53 100644
--- a/chrome/browser/ui/cocoa/authorization_util.mm
+++ b/chrome/browser/ui/cocoa/authorization_util.mm
@@ -48,7 +48,8 @@ AuthorizationRef AuthorizationCreateToRunAsRoot(CFStringRef prompt) {
// The OS will append " Type an administrator's name and password to allow
// <CFBundleDisplayName> to make changes."
- NSString* prompt_ns = mac_util::CFToNSCast(prompt);
+ NSString* prompt_ns = const_cast<NSString*>(
+ reinterpret_cast<const NSString*>(prompt));
const char* prompt_c = [prompt_ns UTF8String];
size_t prompt_length = prompt_c ? strlen(prompt_c) : 0;