Add 'ready-for-update-on-quit' event for auto-updater.

This commit is contained in:
Cheng Zhao 2013-06-03 21:51:46 +08:00
parent f435ed8667
commit a1dc4b88be
6 changed files with 51 additions and 3 deletions

View file

@ -23,16 +23,25 @@ AutoUpdater::~AutoUpdater() {
void AutoUpdater::WillInstallUpdate(const std::string& version,
const base::Closure& install) {
continue_update_ = install;
base::ListValue args;
args.AppendString(version);
bool prevent_default = Emit("will-install-update-raw", &args);
if (prevent_default)
continue_update_ = install;
else
if (!prevent_default)
install.Run();
}
void AutoUpdater::ReadyForUpdateOnQuit(const std::string& version,
const base::Closure& quit_and_install) {
quit_and_install_ = quit_and_install;
base::ListValue args;
args.AppendString(version);
Emit("ready-for-update-on-quit-raw", &args);
}
// static
v8::Handle<v8::Value> AutoUpdater::New(const v8::Arguments &args) {
v8::HandleScope scope;
@ -87,6 +96,13 @@ v8::Handle<v8::Value> AutoUpdater::ContinueUpdate(const v8::Arguments &args) {
return v8::Undefined();
}
// static
v8::Handle<v8::Value> AutoUpdater::QuitAndInstall(const v8::Arguments &args) {
AutoUpdater* self = AutoUpdater::Unwrap<AutoUpdater>(args.This());
self->quit_and_install_.Run();
return v8::Undefined();
}
// static
void AutoUpdater::Initialize(v8::Handle<v8::Object> target) {
v8::HandleScope scope;
@ -109,6 +125,7 @@ void AutoUpdater::Initialize(v8::Handle<v8::Object> target) {
CheckForUpdatesInBackground);
NODE_SET_PROTOTYPE_METHOD(t, "continueUpdate", ContinueUpdate);
NODE_SET_PROTOTYPE_METHOD(t, "quitAndInstall", QuitAndInstall);
target->Set(v8::String::NewSymbol("AutoUpdater"), t->GetFunction());
}