Repository navigation
Expand file tree
/
Copy pathExtensionHandler.cs
More file actions
70 lines (55 loc) · 2.24 KB
/
Copy pathExtensionHandler.cs
File metadata and controls
70 lines (55 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright © 2018 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;
namespace CefSharp.Example.Handlers
{
public class ExtensionHandler : IExtensionHandler
{
public Func<IExtension, bool, IBrowser> GetActiveBrowser;
public Action<string> LoadExtensionPopup;
public void Dispose()
{
GetActiveBrowser = null;
LoadExtensionPopup = null;
}
bool IExtensionHandler.CanAccessBrowser(IExtension extension, IBrowser browser, bool includeIncognito, IBrowser targetBrowser)
{
return false;
}
IBrowser IExtensionHandler.GetActiveBrowser(IExtension extension, IBrowser browser, bool includeIncognito)
{
return GetActiveBrowser?.Invoke(extension, includeIncognito);
return null;
}
bool IExtensionHandler.GetExtensionResource(IExtension extension, IBrowser browser, string file, IGetExtensionResourceCallback callback)
{
return false;
}
bool IExtensionHandler.OnBeforeBackgroundBrowser(IExtension extension, string url, IBrowserSettings settings)
{
return false;
}
bool IExtensionHandler.OnBeforeBrowser(IExtension extension, IBrowser browser, IBrowser activeBrowser, int index, string url, bool active, IWindowInfo windowInfo, IBrowserSettings settings)
{
return false;
}
void IExtensionHandler.OnExtensionLoaded(IExtension extension)
{
var manifest = extension.Manifest;
var browserAction = manifest["browser_action"].GetDictionary();
if (browserAction.ContainsKey("default_popup"))
{
var popupUrl = browserAction["default_popup"].GetString();
popupUrl = "chrome-extension://" + extension.Identifier + "/" + popupUrl;
LoadExtensionPopup?.Invoke(popupUrl);
}
}
void IExtensionHandler.OnExtensionLoadFailed(CefErrorCode errorCode)
{
}
void IExtensionHandler.OnExtensionUnloaded(IExtension extension)
{
}
}
}