feat: add new ElectronSquirrelPreventDowngrades flag (#38625)

* sketch

* feat: add new ElectronSquirrelPreventDowngrades flag

* test: remove only

* chore: fix lint
This commit is contained in:
Samuel Attard 2023-09-11 11:54:51 -07:00 committed by GitHub
parent 16aec702b4
commit 5bff0fe342
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 449 additions and 15 deletions

View file

@ -95,10 +95,6 @@ void AutoUpdater::OnWindowAllClosed() {
QuitAndInstall();
}
void AutoUpdater::SetFeedURL(gin::Arguments* args) {
auto_updater::AutoUpdater::SetFeedURL(args);
}
void AutoUpdater::QuitAndInstall() {
Emit("before-quit-for-update");
@ -124,7 +120,11 @@ gin::ObjectTemplateBuilder AutoUpdater::GetObjectTemplateBuilder(
isolate)
.SetMethod("checkForUpdates", &auto_updater::AutoUpdater::CheckForUpdates)
.SetMethod("getFeedURL", &auto_updater::AutoUpdater::GetFeedURL)
.SetMethod("setFeedURL", &AutoUpdater::SetFeedURL)
.SetMethod("setFeedURL", &auto_updater::AutoUpdater::SetFeedURL)
#if DCHECK_IS_ON()
.SetMethod("isVersionAllowedForUpdate",
&auto_updater::AutoUpdater::IsVersionAllowedForUpdate)
#endif
.SetMethod("quitAndInstall", &AutoUpdater::QuitAndInstall);
}

View file

@ -54,7 +54,6 @@ class AutoUpdater : public gin::Wrappable<AutoUpdater>,
private:
std::string GetFeedURL();
void SetFeedURL(gin::Arguments* args);
void QuitAndInstall();
};

View file

@ -26,6 +26,11 @@ void AutoUpdater::SetFeedURL(gin::Arguments* args) {}
void AutoUpdater::CheckForUpdates() {}
void AutoUpdater::QuitAndInstall() {}
bool AutoUpdater::IsVersionAllowedForUpdate(const std::string& current_version,
const std::string& target_version) {
return false;
}
#endif
} // namespace auto_updater

View file

@ -70,6 +70,9 @@ class AutoUpdater {
static void CheckForUpdates();
static void QuitAndInstall();
static bool IsVersionAllowedForUpdate(const std::string& current_version,
const std::string& target_version);
private:
static Delegate* delegate_;
};

View file

@ -179,4 +179,11 @@ void AutoUpdater::QuitAndInstall() {
}
}
bool AutoUpdater::IsVersionAllowedForUpdate(const std::string& current_version,
const std::string& target_version) {
return [SQRLUpdater
isVersionAllowedForUpdate:base::SysUTF8ToNSString(target_version)
from:base::SysUTF8ToNSString(current_version)];
}
} // namespace auto_updater