From a79649c43fd0830fd95b93ae1565a27fb1a745fd Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 19 Jun 2013 13:41:54 +0800 Subject: [PATCH] Add platform method to return executable(bundle)'s version. --- browser/browser.h | 3 +++ browser/browser_mac.mm | 8 ++++++++ 2 files changed, 11 insertions(+) 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 -- 2.43.0