forked from QL-Win/QuickLook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
638 additions
and
49 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/MenuHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// 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 | ||
{ | ||
internal class MenuHandler : IContextMenuHandler | ||
{ | ||
public void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, | ||
IContextMenuParams parameters, | ||
IMenuModel model) | ||
{ | ||
} | ||
|
||
public bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, | ||
IContextMenuParams parameters, | ||
CefMenuCommand commandId, CefEventFlags eventFlags) | ||
{ | ||
return false; | ||
} | ||
|
||
public void OnContextMenuDismissed(IWebBrowser browserControl, IBrowser browser, IFrame frame) | ||
{ | ||
} | ||
|
||
public bool RunContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, | ||
IContextMenuParams parameters, | ||
IMenuModel model, IRunContextMenuCallback callback) | ||
{ | ||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/Properties/Settings.settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/RequestHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
// 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 System.Security.Cryptography.X509Certificates; | ||
using CefSharp; | ||
|
||
namespace QuickLook.Plugin.HtmlViewer | ||
{ | ||
public class RequestHandler : IRequestHandler | ||
{ | ||
bool IRequestHandler.OnBeforeBrowse(IWebBrowser browserControl, IBrowser browser, IFrame frame, | ||
IRequest request, bool isRedirect) | ||
{ | ||
return request.TransitionType != TransitionType.Explicit; | ||
} | ||
|
||
bool IRequestHandler.OnOpenUrlFromTab(IWebBrowser browserControl, IBrowser browser, IFrame frame, | ||
string targetUrl, WindowOpenDisposition targetDisposition, bool userGesture) | ||
{ | ||
return OnOpenUrlFromTab(browserControl, browser, frame, targetUrl, targetDisposition, userGesture); | ||
} | ||
|
||
bool IRequestHandler.OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, | ||
string requestUrl, ISslInfo sslInfo, IRequestCallback callback) | ||
{ | ||
callback.Dispose(); | ||
return false; | ||
} | ||
|
||
void IRequestHandler.OnPluginCrashed(IWebBrowser browserControl, IBrowser browser, string pluginPath) | ||
{ | ||
} | ||
|
||
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, | ||
IRequest request, IRequestCallback callback) | ||
{ | ||
return CefReturnValue.Continue; | ||
} | ||
|
||
bool IRequestHandler.GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, | ||
bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback) | ||
{ | ||
callback.Dispose(); | ||
return false; | ||
} | ||
|
||
bool IRequestHandler.OnSelectClientCertificate(IWebBrowser browserControl, IBrowser browser, bool isProxy, | ||
string host, int port, X509Certificate2Collection certificates, ISelectClientCertificateCallback callback) | ||
{ | ||
//NOTE: If you do not wish to implement this method returning false is the default behaviour | ||
// We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource. | ||
|
||
return OnSelectClientCertificate(browserControl, browser, isProxy, host, port, certificates, callback); | ||
} | ||
|
||
void IRequestHandler.OnRenderProcessTerminated(IWebBrowser browserControl, IBrowser browser, | ||
CefTerminationStatus status) | ||
{ | ||
} | ||
|
||
bool IRequestHandler.OnQuotaRequest(IWebBrowser browserControl, IBrowser browser, string originUrl, | ||
long newSize, IRequestCallback callback) | ||
{ | ||
callback.Dispose(); | ||
return false; | ||
} | ||
|
||
void IRequestHandler.OnResourceRedirect(IWebBrowser browserControl, IBrowser browser, IFrame frame, | ||
IRequest request, IResponse response, ref string newUrl) | ||
{ | ||
} | ||
|
||
bool IRequestHandler.OnProtocolExecution(IWebBrowser browserControl, IBrowser browser, string url) | ||
{ | ||
return false; | ||
} | ||
|
||
void IRequestHandler.OnRenderViewReady(IWebBrowser browserControl, IBrowser browser) | ||
{ | ||
} | ||
|
||
bool IRequestHandler.OnResourceResponse(IWebBrowser browserControl, IBrowser browser, IFrame frame, | ||
IRequest request, IResponse response) | ||
{ | ||
return false; | ||
} | ||
|
||
IResponseFilter IRequestHandler.GetResourceResponseFilter(IWebBrowser browserControl, IBrowser browser, | ||
IFrame frame, IRequest request, IResponse response) | ||
{ | ||
return null; | ||
} | ||
|
||
void IRequestHandler.OnResourceLoadComplete(IWebBrowser browserControl, IBrowser browser, IFrame frame, | ||
IRequest request, IResponse response, UrlRequestStatus status, long receivedContentLength) | ||
{ | ||
} | ||
|
||
protected virtual bool OnOpenUrlFromTab(IWebBrowser browserControl, IBrowser browser, IFrame frame, | ||
string targetUrl, WindowOpenDisposition targetDisposition, bool userGesture) | ||
{ | ||
return false; | ||
} | ||
|
||
protected virtual bool OnSelectClientCertificate(IWebBrowser browserControl, IBrowser browser, bool isProxy, | ||
string host, int port, X509Certificate2Collection certificates, ISelectClientCertificateCallback callback) | ||
{ | ||
callback.Dispose(); | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.IO; | ||
using System.Text; | ||
|
||
namespace QuickLook.Plugin.HtmlViewer | ||
{ | ||
internal static class UrlHelper | ||
{ | ||
internal static string FilePathToFileUrl(string filePath) | ||
{ | ||
var uri = new StringBuilder(); | ||
foreach (var v in filePath) | ||
if (v >= 'a' && v <= 'z' || v >= 'A' && v <= 'Z' || v >= '0' && v <= '9' || | ||
v == '+' || v == '/' || v == ':' || v == '.' || v == '-' || v == '_' || v == '~' || | ||
v > '\xFF') | ||
uri.Append(v); | ||
else if (v == Path.DirectorySeparatorChar || v == Path.AltDirectorySeparatorChar) | ||
uri.Append('/'); | ||
else | ||
uri.Append($"%{(int) v:X2}"); | ||
if (uri.Length >= 2 && uri[0] == '/' && uri[1] == '/') // UNC path | ||
uri.Insert(0, "file:"); | ||
else | ||
uri.Insert(0, "file:///"); | ||
return uri.ToString(); | ||
} | ||
} | ||
} |
8 changes: 4 additions & 4 deletions
8
QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/WebkitPanel.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
<UserControl x:Class="QuickLook.Plugin.HtmlViewer.WebkitPanel" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:QuickLook.Plugin.HtmlViewer" | ||
xmlns:cef="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf" | ||
mc:Ignorable="d" | ||
mc:Ignorable="d" | ||
d:DesignHeight="300" d:DesignWidth="300"> | ||
<Grid> | ||
<cef:ChromiumWebBrowser x:Name="browser" /> | ||
</Grid> | ||
</UserControl> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.