mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-14 20:29:07 +00:00
Fix #22: disable all JS dialogs
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
// Copyright © 2010-2017 The CefSharp Authors. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
using CefSharp;
|
||||||
|
|
||||||
|
namespace QuickLook.Plugin.HtmlViewer
|
||||||
|
{
|
||||||
|
public class JsDialogHandler : IJsDialogHandler
|
||||||
|
{
|
||||||
|
public bool OnJSDialog(IWebBrowser browserControl, IBrowser browser, string originUrl,
|
||||||
|
CefJsDialogType dialogType, string messageText, string defaultPromptText, IJsDialogCallback callback,
|
||||||
|
ref bool suppressMessage)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool OnJSBeforeUnload(IWebBrowser browserControl, IBrowser browser, string message, bool isReload,
|
||||||
|
IJsDialogCallback callback)
|
||||||
|
{
|
||||||
|
//NOTE: No need to execute the callback if you return false
|
||||||
|
// callback.Continue(true);
|
||||||
|
|
||||||
|
//NOTE: Returning false will trigger the default behaviour, you need to return true to handle yourself.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnResetDialogState(IWebBrowser browserControl, IBrowser browser)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnDialogClosed(IWebBrowser browserControl, IBrowser browser)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -63,6 +63,7 @@
|
|||||||
<Compile Include="..\..\GitVersion.cs">
|
<Compile Include="..\..\GitVersion.cs">
|
||||||
<Link>Properties\GitVersion.cs</Link>
|
<Link>Properties\GitVersion.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="JsDialogHandler.cs" />
|
||||||
<Compile Include="MenuHandler.cs" />
|
<Compile Include="MenuHandler.cs" />
|
||||||
<Compile Include="Plugin.cs" />
|
<Compile Include="Plugin.cs" />
|
||||||
<Compile Include="RequestHandler.cs" />
|
<Compile Include="RequestHandler.cs" />
|
||||||
|
@@ -36,6 +36,7 @@ namespace QuickLook.Plugin.HtmlViewer
|
|||||||
|
|
||||||
browser.RequestHandler = new RequestHandler();
|
browser.RequestHandler = new RequestHandler();
|
||||||
browser.MenuHandler = new MenuHandler();
|
browser.MenuHandler = new MenuHandler();
|
||||||
|
browser.JsDialogHandler = new JsDialogHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
Reference in New Issue
Block a user