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

Unified Diff: base/file_version_info_mac.mm

Issue 5815001: Fixed file_version_info so that it finds Mac values correctly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed logging to vlog Created 10 years 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 side-by-side diff with in-line comments
Download patch
Index: base/file_version_info_mac.mm
diff --git a/base/file_version_info_mac.mm b/base/file_version_info_mac.mm
index 57be79ad864156d17b48f09bac0b937075a51486..8fc621cecf5e6f5d4da6fa214a982f9048cd8c13 100644
--- a/base/file_version_info_mac.mm
+++ b/base/file_version_info_mac.mm
@@ -4,19 +4,13 @@
#include "base/file_version_info_mac.h"
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
-#include "base/basictypes.h"
#include "base/file_path.h"
-#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
+#include "base/logging.h"
+#include "base/sys_string_conversions.h"
FileVersionInfoMac::FileVersionInfoMac(NSBundle *bundle) : bundle_(bundle) {
- [bundle_ retain];
-}
-
-FileVersionInfoMac::~FileVersionInfoMac() {
- [bundle_ release];
}
// static
@@ -24,22 +18,33 @@ FileVersionInfo* FileVersionInfo::CreateFileVersionInfoForCurrentModule() {
// TODO(erikkay): this should really use bundleForClass, but we don't have
// a class to hang onto yet.
NSBundle* bundle = [NSBundle mainBundle];
- return new FileVersionInfoMac(bundle);
+ if (![bundle bundleIdentifier]) {
Erik does not do reviews 2010/12/14 19:16:32 if mainBundle is bogus, don't we have a big proble
+ VLOG(1) << "Unable to create file version for "
+ << base::SysNSStringToUTF8([bundle description]);
+ return NULL;
+ } else {
+ return new FileVersionInfoMac(bundle);
+ }
}
// static
FileVersionInfo* FileVersionInfo::CreateFileVersionInfo(
const std::wstring& file_path) {
- NSString* path = [NSString stringWithCString:
- reinterpret_cast<const char*>(file_path.c_str())
- encoding:NSUTF32StringEncoding];
- return new FileVersionInfoMac([NSBundle bundleWithPath:path]);
+ NSString* path = base::SysWideToNSString(file_path);
+ NSBundle *bundle = [NSBundle bundleWithPath:path];
+ if (![bundle bundleIdentifier]) {
+ VLOG(1) << "Unable to create file version for "
+ << base::SysNSStringToUTF8([bundle description]);
+ return NULL;
+ } else {
+ return new FileVersionInfoMac(bundle);
+ }
}
// static
FileVersionInfo* FileVersionInfo::CreateFileVersionInfo(
const FilePath& file_path) {
- NSString* path = [NSString stringWithUTF8String:file_path.value().c_str()];
+ NSString* path = base::SysUTF8ToNSString(file_path.value());
return new FileVersionInfoMac([NSBundle bundleWithPath:path]);
}
@@ -114,11 +119,10 @@ bool FileVersionInfoMac::is_official_build() {
bool FileVersionInfoMac::GetValue(const wchar_t* name,
std::wstring* value_str) {
if (bundle_) {
- NSString* value = [bundle_ objectForInfoDictionaryKey:
- [NSString stringWithUTF8String:WideToUTF8(name).c_str()]];
+ NSString* ns_name = base::SysWideToNSString(name);
+ NSString* value = [bundle_ objectForInfoDictionaryKey:ns_name];
if (value) {
- *value_str = reinterpret_cast<const wchar_t*>(
- [value cStringUsingEncoding:NSUTF32StringEncoding]);
+ *value_str = base::SysNSStringToWide(value);
return true;
}
}

Powered by Google App Engine
This is Rietveld 408576698