private void InitializeContext(CefBrowser browser, CefFrame frame, CefV8Context context) { if (_pluginContext == null) { Logger.Error("Could not locate plugin context for V8. Browser {0} Frame {1}", browser.Identifier, frame.Identifier); return; } // TODO : Put in an optimization to not create the JS Object model if the current browser is a DEV TOOLS instance var window = context.GetGlobal(); foreach (var pluginId in _pluginContext.GetPluginIds()) { var pluginPath = pluginId.Split('.'); var pluginV8HostObject = window; var clashDetected = false; for (var pluginPathSectionIndex = 0; pluginPathSectionIndex < pluginPath.Length; pluginPathSectionIndex++) { var pathSection = pluginPath[pluginPathSectionIndex]; if (pluginPathSectionIndex == 0 && pathSection == "window") { // Fully scoped path - parent should stay as the root/global object until next section continue; } if (pluginV8HostObject.HasValue(pathSection)) { pluginV8HostObject = pluginV8HostObject.GetValue(pathSection); if (!pluginV8HostObject.IsObject) { // Most likely a clash of JS paths between plugins // TODO: warn that this current plugin could not be added clashDetected = true; break; } } else { var child = CefV8Value.CreateObject(null); pluginV8HostObject.SetValue(pathSection, child, CefV8PropertyAttribute.DontEnum | CefV8PropertyAttribute.DontDelete); pluginV8HostObject = child; } } if (clashDetected) { continue; } V8PluginAdapter.Create(_pluginContext.GetPluginById(pluginId), pluginV8HostObject); } }