From: Cheng Zhao Date: Wed, 19 Jun 2013 05:41:54 +0000 (+0800) Subject: Add platform method to return executable(bundle)'s version. X-Git-Tag: v0.1.0~89 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=a79649c43fd0830fd95b93ae1565a27fb1a745fd;p=electron.git Add platform method to return executable(bundle)'s version. --- diff --git a/browser/browser.h b/browser/browser.h index bf879a37..74a1c0bb 100644 --- a/browser/browser.h +++ b/browser/browser.h @@ -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); diff --git a/browser/browser_mac.mm b/browser/browser_mac.mm index f328a176..5adf3476 100644 --- a/browser/browser_mac.mm +++ b/browser/browser_mac.mm @@ -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