Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/file_version_info.h" | 5 #include "base/file_version_info.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 | 11 |
| 12 FileVersionInfo::FileVersionInfo(const std::wstring& file_path) { | |
| 13 NSString* path = [[NSString alloc] | |
| 14 initWithCString:reinterpret_cast<const char*>(file_path.c_str()) | |
| 15 encoding:NSUTF32StringEncoding]; | |
| 16 bundle_ = [NSBundle bundleWithPath: path]; | |
| 17 } | |
| 18 | |
| 19 FileVersionInfo::FileVersionInfo(NSBundle *bundle) : bundle_(bundle) { | 12 FileVersionInfo::FileVersionInfo(NSBundle *bundle) : bundle_(bundle) { |
| 13 [bundle_ retain]; | |
|
Erik does not do reviews
2008/12/19 19:37:05
oops. good catch.
| |
| 20 } | 14 } |
| 21 | 15 |
| 22 FileVersionInfo::~FileVersionInfo() { | 16 FileVersionInfo::~FileVersionInfo() { |
| 23 [bundle_ release]; | 17 [bundle_ release]; |
| 24 } | 18 } |
| 25 | 19 |
| 26 // static | 20 // static |
| 27 FileVersionInfo* FileVersionInfo::CreateFileVersionInfoForCurrentModule() { | 21 FileVersionInfo* FileVersionInfo::CreateFileVersionInfoForCurrentModule() { |
| 28 // TODO(erikkay): this should really use bundleForClass, but we don't have | 22 // TODO(erikkay): this should really use bundleForClass, but we don't have |
| 29 // a class to hang onto yet. | 23 // a class to hang onto yet. |
| 30 NSBundle* bundle = [NSBundle mainBundle]; | 24 NSBundle* bundle = [NSBundle mainBundle]; |
| 31 return new FileVersionInfo(bundle); | 25 return new FileVersionInfo(bundle); |
| 32 } | 26 } |
| 33 | 27 |
| 34 // static | 28 // static |
| 35 FileVersionInfo* FileVersionInfo::CreateFileVersionInfo( | 29 FileVersionInfo* FileVersionInfo::CreateFileVersionInfo( |
| 36 const std::wstring& file_path) { | 30 const std::wstring& file_path) { |
| 37 return new FileVersionInfo(file_path); | 31 NSString* path = [NSString stringWithCString: |
| 32 reinterpret_cast<const char*>(file_path.c_str()) | |
| 33 encoding:NSUTF32StringEncoding]; | |
| 34 return new FileVersionInfo([NSBundle bundleWithPath:path]); | |
| 35 } | |
| 36 | |
| 37 // static | |
| 38 FileVersionInfo* FileVersionInfo::CreateFileVersionInfo( | |
| 39 const FilePath& file_path) { | |
| 40 NSString* path = [NSString stringWithUTF8String:file_path.value().c_str()]; | |
| 41 return new FileVersionInfo([NSBundle bundleWithPath:path]); | |
| 38 } | 42 } |
| 39 | 43 |
| 40 std::wstring FileVersionInfo::company_name() { | 44 std::wstring FileVersionInfo::company_name() { |
| 41 return L""; | 45 return L""; |
| 42 } | 46 } |
| 43 | 47 |
| 44 std::wstring FileVersionInfo::company_short_name() { | 48 std::wstring FileVersionInfo::company_short_name() { |
| 45 return L""; | 49 return L""; |
| 46 } | 50 } |
| 47 | 51 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 } | 117 } |
| 114 return false; | 118 return false; |
| 115 } | 119 } |
| 116 | 120 |
| 117 std::wstring FileVersionInfo::GetStringValue(const wchar_t* name) { | 121 std::wstring FileVersionInfo::GetStringValue(const wchar_t* name) { |
| 118 std::wstring str; | 122 std::wstring str; |
| 119 if (GetValue(name, &str)) | 123 if (GetValue(name, &str)) |
| 120 return str; | 124 return str; |
| 121 return L""; | 125 return L""; |
| 122 } | 126 } |
| OLD | NEW |