Google Plugin Support #4937
Replies: 4 comments 3 replies
-
It means that with the alloy runtime gone there is no longer the extension loading support. Alloy style does not support it but chrome style does work with extensions and as of 126 there is a devtools load extension call that is pretty sexy: https://chromedevtools.github.io/devtools-protocol/tot/Extensions/#method-loadUnpacked It should have much better extension support now. |
Beta Was this translation helpful? Give feedback.
-
OK so the following are required: Now it may be you still get that error. I did also try to set the entire raw preference blob in a var json = @"{
""oejmofjkmijelromghaoncbbecjiial"": {
""active_permissions"": {
""api"": [
""storage""
],
""explicit_host"": [],
""manifest_permissions"": [],
""scriptable_host"": [
""file:///*"",
""http://*/*"",
""https://*/*""
]
},
""commands"": {},
""content_settings"": [],
""creation_flags"": 38,
""events"": [],
""first_install_time"": ""13372343007931350"",
""from_webstore"": false,
""granted_permissions"": {
""api"": [
""storage""
],
""explicit_host"": [],
""manifest_permissions"": [],
""scriptable_host"": [
""file:///*"",
""http://*/*"",
""https://*/*""
]
},
""incognito_content_settings"": [],
""incognito_preferences"": {},
""last_update_time"": ""13372343007931350"",
""location"": 4,
""newAllowFileAccess"": true,
""path"": ""F:\\my\\extension"",
""preferences"": {},
""regular_only_preferences"": {},
""state"": 1,
""was_installed_by_default"": false,
""was_installed_by_oem"": false,
""withholding_permissions"": false
}
}";
var jObj = JsonSerializer.Deserialize<Dictionary<string, object>>(json);
context.SetPreference("extensions.settings", jStr, out var errSet); It does give an args error but I haven't had time to track down if that is a CEF issue, a CEFSharp thing, or just totally not allowed by chrome. I did try to set the extension id directly but get key now found in those cases. At first I thought CEFSharp wasn't recursively serializing the dictionaries but looking at the code I don't think that is it. I really need to modify the prefs.html cefclient test to take a dictionary and see if that also errors. I haven't found a way to test devtools protocol with the cefclient to see about the loadExtension call. path = char.ToUpper(path[0]) + path.Substring(1);
var bytes = Encoding.Unicode.GetBytes(path);
using var hash = SHA256.Create();
var hashed_bytes = hash.ComputeHash(bytes);
var hexDigits = "abcdefghijklmnop".ToCharArray();
var extID = String.Join("",hashed_bytes.Take(16).Select(b=> $"{hexDigits[b >> 4]}{hexDigits[b & 0xF]}")); |
Beta Was this translation helpful? Give feedback.
-
OK! so not quite working in cefsharp but confirmed it works with the preference setting in cefclient to synthetically load an extension without other commands. Granted cefclient must be restarted and seems to crash for the first close but it is added. More things to debug:) In terms of CEFSharp I have learned to avoid microsofts json solution like the plague did not expect it to serialize json to a string/object dictionary so oddly. CEFSharp is still doing some awkward things with complex serialization objects that I need to debug as at greater depths it does literal 'key' 'value' sets. Expando should be fine going to the dictionary but something is screwed up. Just doing a call to get preference / set preference like: var curExtSettings = (Dictionary<string,object>) context.GetPreference("extensions.settings");
context.SetPreference("extensions.settings", curExtSettings, out errSet); results in the prefs store being corrupted to (oddly chrome even stores this to disk): {
"owoawenfoawenfoanwefonwaefe": [
{
"Key": "active_permissions",
"Value": [
{
"Key": "api",
"Value": [
"management",
"system.display",
"system.storage",
"webstorePrivate",
"system.cpu",
"system.memory",
"system.network"
]
},
{
"Key": "explicit_host",
"Value": [
]
},
{
"Key": "manifest_permissions",
"Value": [
]
},
{
"Key": "scriptable_host",
"Value": [
]
}
] A temporary fix as simple as converting it to a literal dictionary<string,object> recursively would probably work but I can probably get the CEFSharp serializer to handle it better. |
Beta Was this translation helpful? Give feedback.
-
Ok somewhat obvious the crash on exit was due to it trying to cleanup the extension and use its lock which doesnt exist as it wasnt properly loaded:
It actually does a null check for the lock but only as a debug assert not to avoid trying it. This might mean that setting the preference in protected override void OnRequestContextInitialized(IRequestContext requestContext)
{
var curExtSettings = (Dictionary<string,object>) requestContext.GetPreference("extensions.settings");
curExtSettings["asdfasdfasdfasdf"] = Newtonsoft.Json.JsonConvert.DeserializeObject<IDictionary<string, object>>(extJson);
if (! requestContext.SetPreference("extensions.settings",curExtSettings, out var err))
throw new System.Exception(err);
base.OnRequestContextInitialized(requestContext);
} might just work to get it to load on first run. I tried some initial testing but not quite yet. |
Beta Was this translation helpful? Give feedback.
-
In earlier versions of CefSharp, there was an IExtensionHandler for extending Chrome extensions. In the new version, IExtensionHandler has been removed. Does this mean that extension support is no longer available, or is there a new method for this? Please let me know, thank you.
Beta Was this translation helpful? Give feedback.
All reactions