Add platform method to return executable(bundle)'s version.

This commit is contained in:
Cheng Zhao 2013-06-19 13:41:54 +08:00
parent c9e9080a35
commit a79649c43f
2 changed files with 11 additions and 0 deletions

View file

@ -30,6 +30,9 @@ class Browser : public WindowListObserver {
// Focus the application.
void Focus();
// Returns the version of the executable (or bundle).
std::string GetVersion();
// Tell the application to open a file.
bool OpenFile(const std::string& file_path);

View file

@ -4,6 +4,8 @@
#include "browser/browser.h"
#import "base/mac/bundle_locations.h"
#include "base/strings/sys_string_conversions.h"
#import "browser/atom_application_mac.h"
namespace atom {
@ -16,4 +18,10 @@ void Browser::Focus() {
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
}
std::string Browser::GetVersion() {
NSDictionary* infoDictionary = base::mac::OuterBundle().infoDictionary;
NSString *version = [infoDictionary objectForKey:@"CFBundleVersion"];
return base::SysNSStringToUTF8(version);
}
} // namespace atom