diff --git a/atom/browser/api/atom_api_auto_updater.cc b/atom/browser/api/atom_api_auto_updater.cc index fd2125b64d10..bc708b128f73 100644 --- a/atom/browser/api/atom_api_auto_updater.cc +++ b/atom/browser/api/atom_api_auto_updater.cc @@ -21,7 +21,7 @@ struct Converter { static v8::Local ToV8(v8::Isolate* isolate, const base::Time& val) { v8::MaybeLocal date = v8::Date::New( - isolate->GetCurrentContext(), val.ToJsTime()); + isolate->GetCurrentContext(), val.ToJsTime()); if (date.IsEmpty()) return v8::Null(isolate); else @@ -49,11 +49,12 @@ void AutoUpdater::OnError(const std::string& message) { v8::HandleScope handle_scope(isolate()); auto error = v8::Exception::Error(mate::StringToV8(isolate(), message)); mate::EmitEvent( - isolate(), - GetWrapper(), - "error", - error->ToObject(isolate()->GetCurrentContext()).ToLocalChecked(), - message); + isolate(), + GetWrapper(), + "error", + error->ToObject(isolate()->GetCurrentContext()).ToLocalChecked(), + // Message is also emitted to keep compatibility with old code. + message); } void AutoUpdater::OnError(const std::string& message, @@ -89,8 +90,9 @@ void AutoUpdater::OnUpdateDownloaded(const std::string& release_notes, const std::string& release_name, const base::Time& release_date, const std::string& url) { - Emit("update-downloaded", release_notes, release_name, release_date, - url, base::Bind(&AutoUpdater::QuitAndInstall, base::Unretained(this))); + Emit("update-downloaded", release_notes, release_name, release_date, url, + // Keep compatibility with old APIs. + base::Bind(&AutoUpdater::QuitAndInstall, base::Unretained(this))); } void AutoUpdater::OnWindowAllClosed() { @@ -122,13 +124,13 @@ mate::Handle AutoUpdater::Create(v8::Isolate* isolate) { // static void AutoUpdater::BuildPrototype( - v8::Isolate* isolate, v8::Local prototype) { + v8::Isolate* isolate, v8::Local prototype) { prototype->SetClassName(mate::StringToV8(isolate, "AutoUpdater")); mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate()) - .SetMethod("checkForUpdates", &auto_updater::AutoUpdater::CheckForUpdates) - .SetMethod("getFeedURL", &auto_updater::AutoUpdater::GetFeedURL) - .SetMethod("setFeedURL", &AutoUpdater::SetFeedURL) - .SetMethod("quitAndInstall", &AutoUpdater::QuitAndInstall); + .SetMethod("checkForUpdates", &auto_updater::AutoUpdater::CheckForUpdates) + .SetMethod("getFeedURL", &auto_updater::AutoUpdater::GetFeedURL) + .SetMethod("setFeedURL", &AutoUpdater::SetFeedURL) + .SetMethod("quitAndInstall", &AutoUpdater::QuitAndInstall); } } // namespace api diff --git a/atom/browser/api/atom_api_auto_updater.h b/atom/browser/api/atom_api_auto_updater.h index 9f708e3e6c3b..e9e5c53ade0a 100644 --- a/atom/browser/api/atom_api_auto_updater.h +++ b/atom/browser/api/atom_api_auto_updater.h @@ -32,8 +32,8 @@ class AutoUpdater : public mate::EventEmitter, // Delegate implementations. void OnError(const std::string& error) override; - void OnError(const std::string& message, - const int code, const std::string& domain); + void OnError(const std::string& message, const int code, + const std::string& domain); void OnCheckingForUpdate() override; void OnUpdateAvailable() override; void OnUpdateNotAvailable() override; diff --git a/atom/browser/auto_updater.h b/atom/browser/auto_updater.h index e5f6a44dad02..389e39d31eb0 100644 --- a/atom/browser/auto_updater.h +++ b/atom/browser/auto_updater.h @@ -22,8 +22,8 @@ class Delegate { // An error happened. virtual void OnError(const std::string& error) {} - virtual void OnError(const std::string& error, - const int code, const std::string& domain) {} + virtual void OnError(const std::string& error, const int code, + const std::string& domain) {} // Checking to see if there is an update virtual void OnCheckingForUpdate() {} diff --git a/atom/browser/auto_updater_mac.mm b/atom/browser/auto_updater_mac.mm index 26aa42fdb58e..e0317f42b03d 100644 --- a/atom/browser/auto_updater_mac.mm +++ b/atom/browser/auto_updater_mac.mm @@ -104,7 +104,8 @@ void AutoUpdater::CheckForUpdates() { delegate->OnUpdateNotAvailable(); } } error:^(NSError *error) { - NSMutableString *failureString = [NSMutableString stringWithString:error.localizedDescription]; + NSMutableString *failureString = + [NSMutableString stringWithString:error.localizedDescription]; if (error.localizedFailureReason) { [failureString appendString:@": "]; [failureString appendString:error.localizedFailureReason]; @@ -115,7 +116,8 @@ void AutoUpdater::CheckForUpdates() { [failureString appendString:@" "]; [failureString appendString:error.localizedRecoverySuggestion]; } - delegate->OnError(base::SysNSStringToUTF8(failureString), error.code, base::SysNSStringToUTF8(error.domain)); + delegate->OnError(base::SysNSStringToUTF8(failureString), error.code, + base::SysNSStringToUTF8(error.domain)); }]; } @@ -124,7 +126,8 @@ void AutoUpdater::QuitAndInstall() { if (g_update_available) { [[g_updater relaunchToInstallUpdate] subscribeError:^(NSError* error) { if (delegate) - delegate->OnError(base::SysNSStringToUTF8(error.localizedDescription), error.code, base::SysNSStringToUTF8(error.domain)); + delegate->OnError(base::SysNSStringToUTF8(error.localizedDescription), + error.code, base::SysNSStringToUTF8(error.domain)); }]; } else { if (delegate)