]> khamidou — GitHub mirrors - electron.git/commitdiff
Add platform method to return executable(bundle)'s version.
authorCheng Zhao <zcbenz@gmail.com>
Wed, 19 Jun 2013 05:41:54 +0000 (13:41 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 19 Jun 2013 05:41:54 +0000 (13:41 +0800)
browser/browser.h
browser/browser_mac.mm

index bf879a3753ccccf68f245447461d551b72f144f2..74a1c0bb853dbdb57219b0e0990b5af8449c4069 100644 (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);
 
index f328a17621a74874468dc34077aeb0496ad62db7..5adf34764026b4d62dcc713f7781b6009094ba07 100644 (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