return v8::String::New(version.data(), version.size());
}
+// static
+v8::Handle<v8::Value> App::SetVersion(const v8::Arguments &args) {
+ v8::HandleScope scope;
+
+ std::string version;
+ if (!FromV8Arguments(args, &version))
+ return node::ThrowError("Bad argument");
+
+ Browser::Get()->SetVersion(version);
+
+ return v8::Undefined();
+}
+
// static
v8::Handle<v8::Value> App::AppendSwitch(const v8::Arguments &args) {
v8::HandleScope scope;
NODE_SET_PROTOTYPE_METHOD(t, "terminate", Terminate);
NODE_SET_PROTOTYPE_METHOD(t, "focus", Focus);
NODE_SET_PROTOTYPE_METHOD(t, "getVersion", GetVersion);
+ NODE_SET_PROTOTYPE_METHOD(t, "setVersion", SetVersion);
target->Set(v8::String::NewSymbol("Application"), t->GetFunction());
static v8::Handle<v8::Value> Terminate(const v8::Arguments &args);
static v8::Handle<v8::Value> Focus(const v8::Arguments &args);
static v8::Handle<v8::Value> GetVersion(const v8::Arguments &args);
+ static v8::Handle<v8::Value> SetVersion(const v8::Arguments &args);
static v8::Handle<v8::Value> AppendSwitch(const v8::Arguments &args);
static v8::Handle<v8::Value> AppendArgument(const v8::Arguments &args);
window_list->CloseAllWindows();
}
+std::string Browser::GetVersion() const {
+ if (version_override_.empty()) {
+ std::string version = GetExecutableFileVersion();
+ if (!version.empty())
+ return version;
+ }
+
+ return version_override_;
+}
+
+void Browser::SetVersion(const std::string& version) {
+ version_override_ = version;
+}
+
bool Browser::OpenFile(const std::string& file_path) {
bool prevent_default = false;
FOR_EACH_OBSERVER(BrowserObserver,
void Focus();
// Returns the version of the executable (or bundle).
- std::string GetVersion();
+ std::string GetVersion() const;
+
+ // Overrides the application version.
+ void SetVersion(const std::string& version);
#if defined(OS_MACOSX)
// Bounce the dock icon.
bool is_quiting() const { return is_quiting_; }
protected:
+ // Returns the version of application bundle or executable file.
+ std::string GetExecutableFileVersion() const;
+
// Send the will-quit message and then terminate the application.
void NotifyAndTerminate();
// Observers of the browser.
ObserverList<BrowserObserver> observers_;
+ std::string version_override_;
+
DISALLOW_COPY_AND_ASSIGN(Browser);
};
[[AtomApplication sharedApplication] activateIgnoringOtherApps:YES];
}
-std::string Browser::GetVersion() {
+std::string Browser::GetExecutableFileVersion() const {
NSDictionary* infoDictionary = base::mac::OuterBundle().infoDictionary;
NSString *version = [infoDictionary objectForKey:@"CFBundleVersion"];
return base::SysNSStringToUTF8(version);
EnumWindows(&WindowsEnumerationHandler, reinterpret_cast<LPARAM>(&pid));
}
-std::string Browser::GetVersion() {
+std::string Browser::GetExecutableFileVersion() const {
base::FilePath path;
if (PathService::Get(base::FILE_EXE, &path)) {
scoped_ptr<FileVersionInfo> version_info(