diff options
author | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-11 15:38:27 +0000 |
---|---|---|
committer | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-11 15:38:27 +0000 |
commit | 6723f835ff0247e5bffad9e92d8d42a8c3ae1b3b (patch) | |
tree | 874b2b79287e69bd58ca6419c764ed26e2573829 /base/file_version_info_mac.mm | |
parent | abfd15b40f52900239ec1fb443ade9eab11711f6 (diff) | |
download | chromium_src-6723f835ff0247e5bffad9e92d8d42a8c3ae1b3b.zip chromium_src-6723f835ff0247e5bffad9e92d8d42a8c3ae1b3b.tar.gz chromium_src-6723f835ff0247e5bffad9e92d8d42a8c3ae1b3b.tar.bz2 |
recursive_mutex
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@650 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_version_info_mac.mm')
-rw-r--r-- | base/file_version_info_mac.mm | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/base/file_version_info_mac.mm b/base/file_version_info_mac.mm new file mode 100644 index 0000000..a3e3e0c --- /dev/null +++ b/base/file_version_info_mac.mm @@ -0,0 +1,148 @@ +// Copyright 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Copied from base/basictypes.h with some modifications + +#import <Cocoa/Cocoa.h> + +#include "base/file_version_info.h" + +#include "base/logging.h" +#include "base/string_util.h" + +FileVersionInfo::FileVersionInfo(const std::wstring& file_path, NSBundle *bundle) + : file_path_(file_path), bundle_(bundle) { + if (!bundle_) { + NSString* path = [[NSString alloc] + initWithCString:reinterpret_cast<const char*>(file_path_.c_str()) + encoding:NSUTF32StringEncoding]; + bundle_ = [NSBundle bundleWithPath: path]; + } +} + +FileVersionInfo::~FileVersionInfo() { + +} + +// static +FileVersionInfo* FileVersionInfo::CreateFileVersionInfoForCurrentModule() { + NSBundle* bundle = [NSBundle mainBundle]; + return new FileVersionInfo(L"", bundle); +} + +// static +FileVersionInfo* FileVersionInfo::CreateFileVersionInfo( + const std::wstring& file_path) { + return new FileVersionInfo(file_path, nil); +} + +std::wstring FileVersionInfo::company_name() { + return L""; +} + +std::wstring FileVersionInfo::company_short_name() { + return L""; +} + +std::wstring FileVersionInfo::internal_name() { + return L""; +} + +std::wstring FileVersionInfo::product_name() { + return GetStringValue(L"CFBundleName"); +} + +std::wstring FileVersionInfo::product_short_name() { + return GetStringValue(L"CFBundleName"); +} + +std::wstring FileVersionInfo::comments() { + return L""; +} + +std::wstring FileVersionInfo::legal_copyright() { + return GetStringValue(L"CFBundleGetInfoString"); +} + +std::wstring FileVersionInfo::product_version() { + return GetStringValue(L"CFBundleShortVersionString"); +} + +std::wstring FileVersionInfo::file_description() { + return L""; +} + +std::wstring FileVersionInfo::legal_trademarks() { + return L""; +} + +std::wstring FileVersionInfo::private_build() { + return L""; +} + +std::wstring FileVersionInfo::file_version() { + return GetStringValue(L"CFBundleVersion"); +} + +std::wstring FileVersionInfo::original_filename() { + return GetStringValue(L"CFBundleName"); +} + +std::wstring FileVersionInfo::special_build() { + return L""; +} + +std::wstring FileVersionInfo::last_change() { + return L""; +} + +bool FileVersionInfo::is_official_build() { + return false; +} + +bool FileVersionInfo::GetValue(const wchar_t* name, std::wstring* value_str) { + std::wstring str; + if (bundle_) { + NSString* value = [bundle_ objectForInfoDictionaryKey: + [NSString stringWithUTF8String:WideToUTF8(name).c_str()]]; + if (value) { + *value_str = reinterpret_cast<const wchar_t*>( + [value cStringUsingEncoding:NSUTF32StringEncoding]); + return true; + } + } + return false; +} + +std::wstring FileVersionInfo::GetStringValue(const wchar_t* name) { + std::wstring str; + if (GetValue(name, &str)) + return str; + return L""; +} + |