Add setting to auto-unblock Protected View #1832

Introduce an "AlwaysUnblockProtectedView" setting (default: false, scope: QuickLook.Plugin.OfficeViewer) and use it to skip the confirmation dialog and automatically unblock the ZoneIdentifier for internet-downloaded files. If the setting is false, preserve the existing prompt flow and keep the previous behavior of showing a warning and only unblocking on user confirmation.
This commit is contained in:
ema
2026-04-27 02:21:25 +08:00
parent 7212ee82e4
commit 792c841277
@@ -107,34 +107,42 @@ public sealed class Plugin : IViewer
if (ZoneIdentifierManager.IsZoneBlocked(path))
{
context.Title = $"[PROTECTED VIEW] {Path.GetFileName(path)}";
var alwaysUnblockProtectedView = SettingHelper.Get("AlwaysUnblockProtectedView", false, "QuickLook.Plugin.OfficeViewer");
MessageBoxResult result = MessageBox.Show(
"""
Be careful - files from the Internet can contain viruses.
The Office interface prevents loading in Protected View.
Would you like OfficeViewer-Native to unblock the ZoneIdentifier of Internet?
""",
"PROTECTED VIEW",
MessageBoxButton.YesNo,
MessageBoxImage.Question
);
if (result == MessageBoxResult.Yes)
if (alwaysUnblockProtectedView)
{
_ = ZoneIdentifierManager.UnblockZone(path);
}
else
{
context.ViewerContent = new Label()
MessageBoxResult result = MessageBox.Show(
"""
Be careful - files from the Internet can contain viruses.
The Office interface prevents loading in Protected View.
Would you like OfficeViewer-Native to unblock the ZoneIdentifier of Internet?
""",
"PROTECTED VIEW",
MessageBoxButton.YesNo,
MessageBoxImage.Question
);
if (result == MessageBoxResult.Yes)
{
Content = "The Office interface prevents loading in Protected View.",
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center,
};
context.Title = $"[PROTECTED VIEW] {Path.GetFileName(path)}";
context.IsBusy = false;
return;
_ = ZoneIdentifierManager.UnblockZone(path);
}
else
{
context.ViewerContent = new Label()
{
Content = "The Office interface prevents loading in Protected View.",
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center,
};
context.Title = $"[PROTECTED VIEW] {Path.GetFileName(path)}";
context.IsBusy = false;
return;
}
}
}