diff --git a/atom/browser/api/atom_api_auto_updater.cc b/atom/browser/api/atom_api_auto_updater.cc index d8407f60b327..9a240a27903c 100644 --- a/atom/browser/api/atom_api_auto_updater.cc +++ b/atom/browser/api/atom_api_auto_updater.cc @@ -11,6 +11,23 @@ #include "native_mate/dictionary.h" #include "native_mate/object_template_builder.h" +namespace mate { + +template<> +struct Converter { + static v8::Local ToV8(v8::Isolate* isolate, + const base::Time& val) { + v8::MaybeLocal date = v8::Date::New( + isolate->GetCurrentContext(), val.ToJsTime()); + if (date.IsEmpty()) + return v8::Null(isolate); + else + return date.ToLocalChecked(); + } +}; + +} // namespace mate + namespace atom { namespace api { @@ -49,11 +66,10 @@ void AutoUpdater::OnUpdateNotAvailable() { void AutoUpdater::OnUpdateDownloaded(const std::string& release_notes, const std::string& release_name, const base::Time& release_date, - const std::string& update_url, + const std::string& url, const base::Closure& quit_and_install) { quit_and_install_ = quit_and_install; - Emit("update-downloaded-raw", release_notes, release_name, - release_date.ToJsTime(), update_url); + Emit("update-downloaded", release_notes, release_name, release_date, url); } mate::ObjectTemplateBuilder AutoUpdater::GetObjectTemplateBuilder( diff --git a/atom/browser/api/lib/auto-updater.coffee b/atom/browser/api/lib/auto-updater.coffee index c039bd12dc46..7e3fa99a76d9 100644 --- a/atom/browser/api/lib/auto-updater.coffee +++ b/atom/browser/api/lib/auto-updater.coffee @@ -1,15 +1,12 @@ -switch process.platform - when 'win32' - autoUpdater = require './auto-updater/auto-updater-win' - else - # take the default binding for the current platform - autoUpdater = process.atomBinding('auto_updater').autoUpdater - EventEmitter = require('events').EventEmitter - autoUpdater.__proto__ = EventEmitter.prototype +if process.platform is 'win32' + module.exports = require './auto-updater/auto-updater-win' + return -autoUpdater.on 'update-downloaded-raw', (args...) -> - args[3] = new Date(args[3]) # releaseDate - @emit 'update-downloaded', args..., => @quitAndInstall() +# Implementation on OS X. +autoUpdater = process.atomBinding('auto_updater').autoUpdater +EventEmitter = require('events').EventEmitter + +autoUpdater.__proto__ = EventEmitter.prototype autoUpdater.quitAndInstall = -> # If we don't have any window then quitAndInstall immediately.