diff --git a/CefSharp.BrowserSubprocess.Core/Async/JavascriptAsyncMethodHandler.cpp b/CefSharp.BrowserSubprocess.Core/Async/JavascriptAsyncMethodHandler.cpp index 10ee3da576..7c45a4b01f 100644 --- a/CefSharp.BrowserSubprocess.Core/Async/JavascriptAsyncMethodHandler.cpp +++ b/CefSharp.BrowserSubprocess.Core/Async/JavascriptAsyncMethodHandler.cpp @@ -21,7 +21,7 @@ namespace CefSharp bool JavascriptAsyncMethodHandler::Execute(const CefString& name, CefRefPtr object, const CefV8ValueList& arguments, CefRefPtr& retval, CefString& exception) { auto context = CefV8Context::GetCurrentContext(); - auto browser = context->GetBrowser(); + auto frame = context->GetFrame(); CefRefPtr promiseData; CefRefPtr promiseException; @@ -59,13 +59,12 @@ namespace CefSharp SerializeV8Object(arguments[i], params, i, _callbackRegistry); } - SetInt64(argList, 0, context->GetFrame()->GetIdentifier()); - SetInt64(argList, 1, _objectId); - SetInt64(argList, 2, callbackId); - argList->SetString(3, name); - argList->SetList(4, params); + SetInt64(argList, 0, _objectId); + SetInt64(argList, 1, callbackId); + argList->SetString(2, name); + argList->SetList(3, params); - browser->SendProcessMessage(CefProcessId::PID_BROWSER, request); + frame->SendProcessMessage(CefProcessId::PID_BROWSER, request); return true; } diff --git a/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp b/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp index 7ff7a54e66..b7c6a99677 100644 --- a/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp +++ b/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp @@ -46,7 +46,7 @@ namespace CefSharp }; // CefRenderProcessHandler - void CefAppUnmanagedWrapper::OnBrowserCreated(CefRefPtr browser) + void CefAppUnmanagedWrapper::OnBrowserCreated(CefRefPtr browser, CefRefPtr extraInfo) { auto wrapper = gcnew CefBrowserWrapper(browser); _onBrowserCreated->Invoke(wrapper); @@ -123,9 +123,7 @@ namespace CefSharp //have been created auto contextCreatedMessage = CefProcessMessage::Create(kOnContextCreatedRequest); - SetInt64(contextCreatedMessage->GetArgumentList(), 0, frame->GetIdentifier()); - - browser->SendProcessMessage(CefProcessId::PID_BROWSER, contextCreatedMessage); + frame->SendProcessMessage(CefProcessId::PID_BROWSER, contextCreatedMessage); }; void CefAppUnmanagedWrapper::OnContextReleased(CefRefPtr browser, CefRefPtr frame, CefRefPtr context) @@ -141,9 +139,7 @@ namespace CefSharp auto contextReleasedMessage = CefProcessMessage::Create(kOnContextReleasedRequest); - SetInt64(contextReleasedMessage->GetArgumentList(), 0, frame->GetIdentifier()); - - browser->SendProcessMessage(CefProcessId::PID_BROWSER, contextReleasedMessage); + frame->SendProcessMessage(CefProcessId::PID_BROWSER, contextReleasedMessage); auto browserWrapper = FindBrowserWrapper(browser->GetIdentifier()); @@ -172,19 +168,16 @@ namespace CefSharp auto focusedNodeChangedMessage = CefProcessMessage::Create(kOnFocusedNodeChanged); auto list = focusedNodeChangedMessage->GetArgumentList(); - // Needed in the browser process to get the frame. - SetInt64(list, 0, frame->GetIdentifier()); - // The node will be empty if an element loses focus but another one // doesn't gain focus. Only transfer information if the node is an // element. if (node != nullptr && node->IsElement()) { // True when a node exists, false if it doesn't. - list->SetBool(1, true); + list->SetBool(0, true); // Store the tag name. - list->SetString(2, node->GetElementTagName()); + list->SetString(1, node->GetElementTagName()); // Transfer the attributes in a Dictionary. auto attributes = CefDictionaryValue::Create(); @@ -195,14 +188,14 @@ namespace CefSharp attributes->SetString(iter.first, iter.second); } - list->SetDictionary(3, attributes); + list->SetDictionary(2, attributes); } else { - list->SetBool(1, false); + list->SetBool(0, false); } - browser->SendProcessMessage(CefProcessId::PID_BROWSER, focusedNodeChangedMessage); + frame->SendProcessMessage(CefProcessId::PID_BROWSER, focusedNodeChangedMessage); } void CefAppUnmanagedWrapper::OnUncaughtException(CefRefPtr browser, CefRefPtr frame, CefRefPtr context, CefRefPtr exception, CefRefPtr stackTrace) @@ -210,9 +203,7 @@ namespace CefSharp auto uncaughtExceptionMessage = CefProcessMessage::Create(kOnUncaughtException); auto list = uncaughtExceptionMessage->GetArgumentList(); - // Needed in the browser process to get the frame. - SetInt64(list, 0, frame->GetIdentifier()); - list->SetString(1, exception->GetMessage()); + list->SetString(0, exception->GetMessage()); auto frames = CefListValue::Create(); for (auto i = 0; i < stackTrace->GetFrameCount(); i++) @@ -228,9 +219,9 @@ namespace CefSharp frames->SetList(i, frame); } - list->SetList(2, frames); + list->SetList(1, frames); - browser->SendProcessMessage(CefProcessId::PID_BROWSER, uncaughtExceptionMessage); + frame->SendProcessMessage(CefProcessId::PID_BROWSER, uncaughtExceptionMessage); } JavascriptRootObjectWrapper^ CefAppUnmanagedWrapper::GetJsRootObjectWrapper(int browserId, int64 frameId) @@ -269,7 +260,7 @@ namespace CefSharp return wrapper; } - bool CefAppUnmanagedWrapper::OnProcessMessageReceived(CefRefPtr browser, CefProcessId sourceProcessId, CefRefPtr message) + bool CefAppUnmanagedWrapper::OnProcessMessageReceived(CefRefPtr browser, CefRefPtr frame, CefProcessId sourceProcessId, CefRefPtr message) { auto handled = false; auto name = message->GetName(); @@ -304,7 +295,7 @@ namespace CefSharp throw gcnew Exception("Unsupported message type"); } - auto callbackId = GetInt64(argList, 1); + auto callbackId = GetInt64(argList, 0); auto response = CefProcessMessage::Create(responseName); auto responseArgList = response->GetArgumentList(); auto errorMessage = String::Format("Request BrowserId : {0} not found it's likely the browser is already closed", browser->GetIdentifier()); @@ -313,7 +304,7 @@ namespace CefSharp responseArgList->SetBool(0, false); SetInt64(responseArgList, 1, callbackId); responseArgList->SetString(2, StringUtils::ToNative(errorMessage)); - browser->SendProcessMessage(sourceProcessId, response); + frame->SendProcessMessage(sourceProcessId, response); return true; } @@ -335,13 +326,12 @@ namespace CefSharp response = CefProcessMessage::Create(kJavascriptCallbackResponse); } - //both messages have the frameId stored at 0 and callbackId stored at index 1 - auto frameId = GetInt64(argList, 0); - int64 callbackId = GetInt64(argList, 1); + //both messages have callbackId stored at index 0 + auto frameId = frame->GetIdentifier(); + int64 callbackId = GetInt64(argList, 0); if (name == kEvaluateJavascriptRequest) { - JavascriptRootObjectWrapper^ rootObjectWrapper; browserWrapper->JavascriptRootObjectWrappers->TryGetValue(frameId, rootObjectWrapper); @@ -357,12 +347,11 @@ namespace CefSharp auto callbackRegistry = rootObjectWrapper->CallbackRegistry; - auto script = argList->GetString(2); - auto scriptUrl = argList->GetString(3); - auto startLine = argList->GetInt(4); + auto script = argList->GetString(1); + auto scriptUrl = argList->GetString(2); + auto startLine = argList->GetInt(3); - auto frame = browser->GetFrame(frameId); - if (frame.get()) + if (frame.get() && frame->IsValid()) { auto context = frame->GetV8Context(); @@ -410,7 +399,7 @@ namespace CefSharp } else { - auto jsCallbackId = GetInt64(argList, 2); + auto jsCallbackId = GetInt64(argList, 1); auto callbackWrapper = callbackRegistry->FindWrapper(jsCallbackId); if (callbackWrapper == nullptr) @@ -426,7 +415,7 @@ namespace CefSharp { try { - auto parameterList = argList->GetList(3); + auto parameterList = argList->GetList(2); CefV8ValueList params; //Needs to be called within the context as for Dictionary (mapped to struct) @@ -471,14 +460,14 @@ namespace CefSharp { responseArgList->SetString(2, errorMessage); } - browser->SendProcessMessage(sourceProcessId, response); + frame->SendProcessMessage(sourceProcessId, response); handled = true; } else if (name == kJavascriptCallbackDestroyRequest) { auto jsCallbackId = GetInt64(argList, 0); - auto frameId = GetInt64(argList, 1); + auto frameId = frame->GetIdentifier(); JavascriptRootObjectWrapper^ rootObjectWrapper; browserWrapper->JavascriptRootObjectWrappers->TryGetValue(frameId, rootObjectWrapper); if (rootObjectWrapper != nullptr && rootObjectWrapper->CallbackRegistry != nullptr) @@ -517,10 +506,10 @@ namespace CefSharp } else { - auto browserId = argList->GetInt(1); - auto frameId = GetInt64(argList, 2); - auto callbackId = GetInt64(argList, 3); - auto javascriptObjects = DeserializeJsObjects(argList, 4); + auto browserId = browser->GetIdentifier(); + auto frameId = frame->GetIdentifier(); + auto callbackId = GetInt64(argList, 1); + auto javascriptObjects = DeserializeJsObjects(argList, 2); //Caching of JavascriptObjects //TODO: JSB Should caching be configurable? On a per object basis? @@ -533,8 +522,7 @@ namespace CefSharp _javascriptObjects->Add(obj->JavascriptName, obj); } - auto frame = browser->GetFrame(frameId); - if (frame.get()) + if (frame.get() && frame->IsValid()) { auto rootObject = GetJsRootObjectWrapper(browser->GetIdentifier(), frameId); @@ -594,7 +582,7 @@ namespace CefSharp args->SetList(0, boundObjects); - browser->SendProcessMessage(CefProcessId::PID_BROWSER, msg); + frame->SendProcessMessage(CefProcessId::PID_BROWSER, msg); } } finally @@ -609,8 +597,8 @@ namespace CefSharp } else if (name == kJavascriptAsyncMethodCallResponse) { - auto frameId = GetInt64(argList, 0); - auto callbackId = GetInt64(argList, 1); + auto frameId = frame->GetIdentifier(); + auto callbackId = GetInt64(argList, 0); JavascriptRootObjectWrapper^ rootObjectWrapper; browserWrapper->JavascriptRootObjectWrappers->TryGetValue(frameId, rootObjectWrapper); @@ -620,11 +608,9 @@ namespace CefSharp JavascriptAsyncMethodCallback^ callback; if (rootObjectWrapper->TryGetAndRemoveMethodCallback(callbackId, callback)) { - try { - auto frame = browser->GetFrame(frameId); - if (frame.get()) + if (frame.get() && frame->IsValid()) { auto context = frame->GetV8Context(); @@ -632,14 +618,14 @@ namespace CefSharp { try { - auto success = argList->GetBool(2); + auto success = argList->GetBool(1); if (success) { - callback->Success(DeserializeV8Object(argList, 3)); + callback->Success(DeserializeV8Object(argList, 2)); } else { - callback->Fail(argList->GetString(3)); + callback->Fail(argList->GetString(2)); } } finally diff --git a/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.h b/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.h index ef037e6d19..65929e80d8 100644 --- a/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.h +++ b/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.h @@ -72,11 +72,11 @@ namespace CefSharp JavascriptRootObjectWrapper^ GetJsRootObjectWrapper(int browserId, int64 frameId); virtual DECL CefRefPtr GetRenderProcessHandler() OVERRIDE; - virtual DECL void OnBrowserCreated(CefRefPtr browser) OVERRIDE; + virtual DECL void OnBrowserCreated(CefRefPtr browser, CefRefPtr extraInfo) OVERRIDE; virtual DECL void OnBrowserDestroyed(CefRefPtr browser) OVERRIDE; virtual DECL void OnContextCreated(CefRefPtr browser, CefRefPtr frame, CefRefPtr context) OVERRIDE; virtual DECL void OnContextReleased(CefRefPtr browser, CefRefPtr frame, CefRefPtr context) OVERRIDE; - virtual DECL bool OnProcessMessageReceived(CefRefPtr browser, CefProcessId sourceProcessId, CefRefPtr message) OVERRIDE; + virtual DECL bool OnProcessMessageReceived(CefRefPtr browser, CefRefPtr frame, CefProcessId sourceProcessId, CefRefPtr message) OVERRIDE; virtual DECL void OnRenderThreadCreated(CefRefPtr extraInfo) OVERRIDE; virtual DECL void OnWebKitInitialized() OVERRIDE; virtual DECL void OnRegisterCustomSchemes(CefRawPtr registrar) OVERRIDE; diff --git a/CefSharp.BrowserSubprocess.Core/CefSharp.BrowserSubprocess.Core.vcxproj b/CefSharp.BrowserSubprocess.Core/CefSharp.BrowserSubprocess.Core.vcxproj index e1e0843d22..02dd568f90 100644 --- a/CefSharp.BrowserSubprocess.Core/CefSharp.BrowserSubprocess.Core.vcxproj +++ b/CefSharp.BrowserSubprocess.Core/CefSharp.BrowserSubprocess.Core.vcxproj @@ -1,6 +1,6 @@  - + Debug diff --git a/CefSharp.BrowserSubprocess.Core/JavascriptPostMessageHandler.h b/CefSharp.BrowserSubprocess.Core/JavascriptPostMessageHandler.h index 87f4da786d..81fe6c0ea4 100644 --- a/CefSharp.BrowserSubprocess.Core/JavascriptPostMessageHandler.h +++ b/CefSharp.BrowserSubprocess.Core/JavascriptPostMessageHandler.h @@ -42,9 +42,9 @@ namespace CefSharp auto context = CefV8Context::GetCurrentContext(); if (context.get()) { - auto browser = context->GetBrowser(); + auto frame = context->GetFrame(); - if (context.get() && context->Enter()) + if (frame.get() && frame->IsValid() && context->Enter()) { try { @@ -53,18 +53,16 @@ namespace CefSharp auto request = CefProcessMessage::Create(kJavascriptMessageReceived); auto argList = request->GetArgumentList(); - SetInt64(argList, 0, context->GetFrame()->GetIdentifier()); - auto params = CefListValue::Create(); SerializeV8Object(arguments[0], params, 0, _javascriptCallbackRegistry); //We're only interested in the first param if (params->GetSize() > 0) { - argList->SetValue(1, params->GetValue(0)); + argList->SetValue(0, params->GetValue(0)); } - browser->SendProcessMessage(CefProcessId::PID_BROWSER, request); + frame->SendProcessMessage(CefProcessId::PID_BROWSER, request); retval = CefV8Value::CreateNull(); } diff --git a/CefSharp.BrowserSubprocess.Core/RegisterBoundObjectHandler.h b/CefSharp.BrowserSubprocess.Core/RegisterBoundObjectHandler.h index e0d26eb4a8..4b764b2aba 100644 --- a/CefSharp.BrowserSubprocess.Core/RegisterBoundObjectHandler.h +++ b/CefSharp.BrowserSubprocess.Core/RegisterBoundObjectHandler.h @@ -240,6 +240,7 @@ namespace CefSharp if (cachedObjects->Count == objectCount && ignoreCache == false) { auto frame = context->GetFrame(); + if (frame.get()) { if (Object::ReferenceEquals(_browserWrapper, nullptr)) @@ -268,45 +269,52 @@ namespace CefSharp response->SetValue("Message", CefV8Value::CreateString("OK"), CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_READONLY); callback->Success(response); - NotifyObjectBound(browser, objectNamesWithBoundStatus); + NotifyObjectBound(frame, objectNamesWithBoundStatus); } } } else { - //Obtain a callbackId then send off the Request for objects - auto callbackId = _callbackRegistry->SaveMethodCallback(callback); + auto frame = context->GetFrame(); + if (frame.get() && frame->IsValid()) + { + //Obtain a callbackId then send off the Request for objects + auto callbackId = _callbackRegistry->SaveMethodCallback(callback); - argList->SetInt(0, browser->GetIdentifier()); - SetInt64(argList, 1, context->GetFrame()->GetIdentifier()); - SetInt64(argList, 2, callbackId); - argList->SetList(3, params); + SetInt64(argList, 0, callbackId); + argList->SetList(1, params); - browser->SendProcessMessage(CefProcessId::PID_BROWSER, request); + frame->SendProcessMessage(CefProcessId::PID_BROWSER, request); + } } } else { - //Objects already bound or ignore cache + auto frame = context->GetFrame(); - //Response object has no Accessor or Interceptor - auto response = CefV8Value::CreateObject(NULL, NULL); + if (frame.get() && frame->IsValid()) + { + //Objects already bound or ignore cache - //Objects already bound so we immediately resolve the Promise - response->SetValue("Success", CefV8Value::CreateBool(false), CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_READONLY); - response->SetValue("Count", CefV8Value::CreateInt(0), CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_READONLY); - response->SetValue("Message", CefV8Value::CreateString("Object(s) already bound"), CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_READONLY); + //Response object has no Accessor or Interceptor + auto response = CefV8Value::CreateObject(NULL, NULL); - CefV8ValueList returnArgs; - returnArgs.push_back(response); - //If all the requested objects are bound then we immediately execute resolve - //with Success true and Count of 0 - resolve->ExecuteFunctionWithContext(context, nullptr, returnArgs); + //Objects already bound so we immediately resolve the Promise + response->SetValue("Success", CefV8Value::CreateBool(false), CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_READONLY); + response->SetValue("Count", CefV8Value::CreateInt(0), CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_READONLY); + response->SetValue("Message", CefV8Value::CreateString("Object(s) already bound"), CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_READONLY); - if (notifyIfAlreadyBound) - { - NotifyObjectBound(browser, objectNamesWithBoundStatus); + CefV8ValueList returnArgs; + returnArgs.push_back(response); + //If all the requested objects are bound then we immediately execute resolve + //with Success true and Count of 0 + resolve->ExecuteFunctionWithContext(context, nullptr, returnArgs); + + if (notifyIfAlreadyBound) + { + NotifyObjectBound(frame, objectNamesWithBoundStatus); + } } } } @@ -331,7 +339,7 @@ namespace CefSharp } private: - void NotifyObjectBound(const CefRefPtr browser, List^>^ objectNamesWithBoundStatus) + void NotifyObjectBound(const CefRefPtr frame, List^>^ objectNamesWithBoundStatus) { //Send message notifying Browser Process of which objects were bound //We do this after the objects have been created in the V8Context to gurantee @@ -358,7 +366,7 @@ namespace CefSharp args->SetList(0, boundObjects); - browser->SendProcessMessage(CefProcessId::PID_BROWSER, msg); + frame->SendProcessMessage(CefProcessId::PID_BROWSER, msg); } diff --git a/CefSharp.BrowserSubprocess.Core/Resource.rc b/CefSharp.BrowserSubprocess.Core/Resource.rc index 74368860d4..46646b4a76 100644 --- a/CefSharp.BrowserSubprocess.Core/Resource.rc +++ b/CefSharp.BrowserSubprocess.Core/Resource.rc @@ -1,6 +1,6 @@ 1 VERSIONINFO - FILEVERSION 74.1.130 - PRODUCTVERSION 74.1.130 + FILEVERSION 75.0.30 + PRODUCTVERSION 75.0.30 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -16,10 +16,10 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "FileDescription", "CefSharp.BrowserSubprocess.Core" - VALUE "FileVersion", "74.1.130" + VALUE "FileVersion", "75.0.30" VALUE "LegalCopyright", "Copyright © 2019 The CefSharp Authors" VALUE "ProductName", "CefSharp" - VALUE "ProductVersion", "74.1.130" + VALUE "ProductVersion", "75.0.30" END END BLOCK "VarFileInfo" diff --git a/CefSharp.BrowserSubprocess.Core/packages.config b/CefSharp.BrowserSubprocess.Core/packages.config index 4cbdc1e94e..504ae7da00 100644 --- a/CefSharp.BrowserSubprocess.Core/packages.config +++ b/CefSharp.BrowserSubprocess.Core/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/CefSharp.BrowserSubprocess/app.manifest b/CefSharp.BrowserSubprocess/app.manifest index 89999a1c34..5aa0d3c287 100644 --- a/CefSharp.BrowserSubprocess/app.manifest +++ b/CefSharp.BrowserSubprocess/app.manifest @@ -8,7 +8,7 @@ xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - + diff --git a/CefSharp.Core/AbstractCefSettings.h b/CefSharp.Core/AbstractCefSettings.h index 73f11422ec..9582a86054 100644 --- a/CefSharp.Core/AbstractCefSettings.h +++ b/CefSharp.Core/AbstractCefSettings.h @@ -149,12 +149,13 @@ namespace CefSharp } /// - /// The location where cache data will be stored on disk. If empty then - /// browsers will be created in "incognito mode" where in-memory caches are - /// used for storage and no data is persisted to disk. HTML5 databases such as - /// localStorage will only persist across sessions if a cache path is - /// specified. Can be overridden for individual CefRequestContext instances via - /// the RequestContextSettings.CachePath value. + /// The location where data for the global browser cache will be stored on disk. + /// In non-empty this must be either equal to or a child directory of CefSettings.RootCachePath + /// (if RootCachePath is empty it will default to this value). + /// If empty then browsers will be created in "incognito mode" where in-memory caches are used + /// for storage and no data is persisted to disk. HTML5 databases such as localStorage will + /// only persist across sessions if a cache path is specified. Can be overridden for individual + /// RequestContext instances via the RequestContextSettings.CachePath value. /// property String^ CachePath { @@ -162,6 +163,22 @@ namespace CefSharp void set(String^ value) { StringUtils::AssignNativeFromClr(_cefSettings->cache_path, value); } } + /// + /// The root directory that all CefSettings.CachePath and RequestContextSettings.CachePath values + /// must have in common. If this value is empty and CefSettings.CachePath is non-empty then this + /// value will default to the CefSettings.CachePath value. Failure to set this value correctly + /// may result in the sandbox blocking read/write access to the CachePath directory. + /// NOTE: CefSharp does not implement the CHROMIUM SANDBOX. + /// A non-empty RootCachePath can be used in conjuncation with an empty CefSettings.CachePath + /// in instances where you would like browsers attached to the Global RequestContext (the default) + /// created in "incognito mode" and instances created with a custom RequestContext using a disk based cache. + /// + property String^ RootCachePath + { + String^ get() { return StringUtils::ToClr(_cefSettings->root_cache_path); } + void set(String^ value) { StringUtils::AssignNativeFromClr(_cefSettings->root_cache_path, value); } + } + /// /// The location where user data such as spell checking dictionary files will /// be stored on disk. If empty then the default platform-specific user data @@ -384,6 +401,18 @@ namespace CefSharp void set(uint32 value) { _cefSettings->background_color = value; } } + /// + /// GUID string used for identifying the application. This is passed to the + /// system AV function for scanning downloaded files. By default, the GUID + /// will be an empty string and the file will be treated as an untrusted + /// file when the GUID is empty. + /// + property String^ ApplicationClientIdForFileScanning + { + String^ get() { return StringUtils::ToClr(_cefSettings->application_client_id_for_file_scanning); } + void set(String^ value) { StringUtils::AssignNativeFromClr(_cefSettings->application_client_id_for_file_scanning, value); } + } + /// /// Registers a custom scheme using the provided settings. /// diff --git a/CefSharp.Core/Cef.h b/CefSharp.Core/Cef.h index b16495a54a..9f02a350ce 100644 --- a/CefSharp.Core/Cef.h +++ b/CefSharp.Core/Cef.h @@ -367,7 +367,7 @@ namespace CefSharp /// /// Returns the global cookie manager. By default data will be stored at CefSettings.CachePath if specified or in memory otherwise. - /// Using this method is equivalent to calling Cef.GetGlobalRequestContext().GetDefaultCookieManager() + /// Using this method is equivalent to calling Cef.GetGlobalRequestContext().GetCookieManager() /// The earlier possible place to access the ICookieManager is in IBrowserProcessHandler.OnContextInitialized. /// Alternative use the ChromiumWebBrowser BrowserInitialized (OffScreen) or IsBrowserInitializedChanged (WinForms/WPF) events. /// @@ -383,26 +383,6 @@ namespace CefSharp return nullptr; } - /// - /// Returns a cookie manager that neither stores nor retrieves cookies. All - /// usage of cookies will be blocked including cookies accessed via the network - /// (request/response headers), via JavaScript (document.cookie), and via - /// CefCookieManager methods. No cookies will be displayed in DevTools. If you - /// wish to only block cookies sent via the network use the IRequestHandler - /// CanGetCookies and CanSetCookie methods instead. - /// - /// A blocking cookie manager - static ICookieManager^ GetBlockingCookieManager() - { - auto cookieManager = CefCookieManager::GetBlockingManager(); - if (cookieManager.get()) - { - return gcnew CookieManager(cookieManager); - } - - return nullptr; - } - /// /// Shuts down CefSharp and the underlying CEF infrastructure. This method is safe to call multiple times; it will only /// shut down CEF on the first call (all subsequent calls will be ignored). diff --git a/CefSharp.Core/CefSharp.Core.vcxproj b/CefSharp.Core/CefSharp.Core.vcxproj index b9d6908f53..2b37af5380 100644 --- a/CefSharp.Core/CefSharp.Core.vcxproj +++ b/CefSharp.Core/CefSharp.Core.vcxproj @@ -1,6 +1,6 @@  - + Debug @@ -264,6 +264,7 @@ + diff --git a/CefSharp.Core/CefSharp.Core.vcxproj.filters b/CefSharp.Core/CefSharp.Core.vcxproj.filters index 7bf38ab352..1e85ecb4cb 100644 --- a/CefSharp.Core/CefSharp.Core.vcxproj.filters +++ b/CefSharp.Core/CefSharp.Core.vcxproj.filters @@ -301,6 +301,9 @@ Header Files + + Header Files + diff --git a/CefSharp.Core/CookieManager.cpp b/CefSharp.Core/CookieManager.cpp index 60a6e2003d..0de990c3bd 100644 --- a/CefSharp.Core/CookieManager.cpp +++ b/CefSharp.Core/CookieManager.cpp @@ -57,22 +57,13 @@ namespace CefSharp return _cookieManager->SetCookie(StringUtils::ToNative(url), c, wrapper); } - bool CookieManager::SetStoragePath(String^ path, bool persistSessionCookies, ICompletionCallback^ callback) + void CookieManager::SetSupportedSchemes(cli::array^ schemes, bool includeDefaults, ICompletionCallback^ callback) { ThrowIfDisposed(); CefRefPtr wrapper = callback == nullptr ? NULL : new CefCompletionCallbackAdapter(callback); - return _cookieManager->SetStoragePath(StringUtils::ToNative(path), persistSessionCookies, wrapper); - } - - void CookieManager::SetSupportedSchemes(cli::array^ schemes, ICompletionCallback^ callback) - { - ThrowIfDisposed(); - - CefRefPtr wrapper = callback == nullptr ? NULL : new CefCompletionCallbackAdapter(callback); - - _cookieManager->SetSupportedSchemes(StringUtils::ToNative(schemes), wrapper); + _cookieManager->SetSupportedSchemes(StringUtils::ToNative(schemes), includeDefaults, wrapper); } bool CookieManager::VisitAllCookies(ICookieVisitor^ visitor) diff --git a/CefSharp.Core/CookieManager.h b/CefSharp.Core/CookieManager.h index f3ffc646c5..6bfd34e87b 100644 --- a/CefSharp.Core/CookieManager.h +++ b/CefSharp.Core/CookieManager.h @@ -35,23 +35,6 @@ namespace CefSharp } public: - /// - // Creates a new cookie manager. If |path| is empty data will be stored in - // memory only. Otherwise, data will be stored at the specified |path|. To - // persist session cookies (cookies without an expiry date or validity - // interval) set |persist_session_cookies| to true. Session cookies are - // generally intended to be transient and most Web browsers do not persist - // them. If |callback| is non-NULL it will be executed asnychronously on the - // IO thread after the manager's storage has been initialized. - /// - /*--cef(optional_param=path,optional_param=callback)--*/ - CookieManager(String^ path, bool persistSessionCookies, ICompletionCallback^ callback) - { - CefRefPtr wrapper = callback == nullptr ? NULL : new CefCompletionCallbackAdapter(callback); - - _cookieManager = CefCookieManager::CreateManager(StringUtils::ToNative(path), persistSessionCookies, wrapper); - } - !CookieManager() { this->_cookieManager = nullptr; @@ -64,8 +47,7 @@ namespace CefSharp virtual bool DeleteCookies(String^ url, String^ name, IDeleteCookiesCallback^ callback); virtual bool SetCookie(String^ url, Cookie^ cookie, ISetCookieCallback^ callback); - virtual bool SetStoragePath(String^ path, bool persistSessionSookies, ICompletionCallback^ callback); - virtual void SetSupportedSchemes(cli::array^ schemes, ICompletionCallback^ callback); + virtual void SetSupportedSchemes(cli::array^ schemes, bool includeDefaults, ICompletionCallback^ callback); virtual bool VisitAllCookies(ICookieVisitor^ visitor); virtual bool VisitUrlCookies(String^ url, bool includeHttpOnly, ICookieVisitor^ visitor); virtual bool FlushStore(ICompletionCallback^ callback); @@ -78,4 +60,4 @@ namespace CefSharp } } }; -} \ No newline at end of file +} diff --git a/CefSharp.Core/Internals/CefFrameWrapper.cpp b/CefSharp.Core/Internals/CefFrameWrapper.cpp index 9351f70b7c..14b742e811 100644 --- a/CefSharp.Core/Internals/CefFrameWrapper.cpp +++ b/CefSharp.Core/Internals/CefFrameWrapper.cpp @@ -10,6 +10,11 @@ #include "Internals\CefFrameWrapper.h" #include "Internals\StringVisitor.h" #include "Internals\ClientAdapter.h" +#include "Internals\Serialization\Primitives.h" +#include "Internals\Messaging\Messages.h" + +using namespace CefSharp::Internals::Messaging; +using namespace CefSharp::Internals::Serialization; /// // True if this object is currently attached to a valid frame. @@ -240,9 +245,29 @@ Task^ CefFrameWrapper::EvaluateScriptAsync(String^ script, auto browser = _frame->GetBrowser(); auto host = browser->GetHost(); + //If we're unable to get the underlying browser/browserhost then return null + if (!browser.get() || !host.get()) + { + return nullptr; + } + auto client = static_cast(host->GetClient().get()); - return client->EvaluateScriptAsync(browser->GetIdentifier(), browser->IsPopup(), _frame->GetIdentifier(), script, scriptUrl, startLine, timeout); + auto pendingTaskRepository = client->GetPendingTaskRepository(); + + //create a new taskcompletionsource + auto idAndComplectionSource = pendingTaskRepository->CreatePendingTask(timeout); + + auto message = CefProcessMessage::Create(kEvaluateJavascriptRequest); + auto argList = message->GetArgumentList(); + SetInt64(argList, 0, idAndComplectionSource.Key); + argList->SetString(1, StringUtils::ToNative(script)); + argList->SetString(2, StringUtils::ToNative(scriptUrl)); + argList->SetInt(3, startLine); + + _frame->SendProcessMessage(CefProcessId::PID_RENDERER, message); + + return idAndComplectionSource.Value->Task; } /// @@ -388,4 +413,4 @@ void CefFrameWrapper::ThrowIfFrameInvalid() { throw gcnew Exception(L"The underlying frame is no longer valid - please check the IsValid property before calling!"); } -} \ No newline at end of file +} diff --git a/CefSharp.Core/Internals/CefRequestContextHandlerAdapter.cpp b/CefSharp.Core/Internals/CefRequestContextHandlerAdapter.cpp index 0ace48ffff..6331debc4c 100644 --- a/CefSharp.Core/Internals/CefRequestContextHandlerAdapter.cpp +++ b/CefSharp.Core/Internals/CefRequestContextHandlerAdapter.cpp @@ -14,33 +14,6 @@ namespace CefSharp { namespace Internals { - CefRefPtr CefRequestContextHandlerAdapter::GetCookieManager() - { - if (Object::ReferenceEquals(_requestContextHandler, nullptr)) - { - return NULL; - } - - auto cookieManager = _requestContextHandler->GetCookieManager(); - - if (cookieManager == nullptr) - { - return NULL; - } - - //Cookie manager can only be our managed wrapper - if (cookieManager->GetType() == CookieManager::typeid) - { - return (CookieManager^)cookieManager; - } - - //Report the exception on the thread pool so it can be caught in AppDomain::UnhandledException - auto msg = gcnew String(L"ICookieManager must be of type " + CookieManager::typeid + ". CEF does not support custom implementation"); - ReportUnhandledExceptions::Report(msg, gcnew NotSupportedException(msg)); - - return NULL; - } - bool CefRequestContextHandlerAdapter::OnBeforePluginLoad(const CefString& mime_type, const CefString& plugin_url, bool is_main_frame, @@ -78,4 +51,4 @@ namespace CefSharp } } } -} \ No newline at end of file +} diff --git a/CefSharp.Core/Internals/CefRequestContextHandlerAdapter.h b/CefSharp.Core/Internals/CefRequestContextHandlerAdapter.h index 8b17ada5e8..0938ad9bda 100644 --- a/CefSharp.Core/Internals/CefRequestContextHandlerAdapter.h +++ b/CefSharp.Core/Internals/CefRequestContextHandlerAdapter.h @@ -31,8 +31,6 @@ namespace CefSharp _requestContextHandler = nullptr; } - virtual CefRefPtr GetCookieManager() OVERRIDE; - virtual bool OnBeforePluginLoad(const CefString& mime_type, const CefString& plugin_url, bool is_main_frame, diff --git a/CefSharp.Core/Internals/CefResourceRequestHandlerAdapter.h b/CefSharp.Core/Internals/CefResourceRequestHandlerAdapter.h new file mode 100644 index 0000000000..be786c9a13 --- /dev/null +++ b/CefSharp.Core/Internals/CefResourceRequestHandlerAdapter.h @@ -0,0 +1,225 @@ +// Copyright © 2019 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. + +#pragma once + +#include "Stdafx.h" + +#include "include\cef_resource_request_handler.h" +#include "include\wrapper\cef_stream_resource_handler.h" + +#include "CefResponseWrapper.h" +#include "CefRequestWrapper.h" +#include "CefFrameWrapper.h" +#include "CefSharpBrowserWrapper.h" +#include "ResourceHandlerWrapper.h" +#include "CefResponseFilterAdapter.h" +#include "CefRequestCallbackWrapper.h" + +namespace CefSharp +{ + namespace Internals + { + //TODO: NetworkService + // Deal with browser/frame null for serviceworker + //fix Ibrowser reference + private class CefResourceRequestHandlerAdapter : public CefResourceRequestHandler + { + private: + gcroot _handler; + gcroot _browserControl; + + public: + CefResourceRequestHandlerAdapter(IWebBrowser^ browserControl, IResourceRequestHandler^ handler) : + _handler(handler), _browserControl(browserControl) + { + + } + + ~CefResourceRequestHandlerAdapter() + { + delete _handler; + _handler = nullptr; + } + + CefRefPtr GetCookieAccessFilter(CefRefPtr browser, CefRefPtr frame, CefRefPtr request) OVERRIDE + { + if (!Object::ReferenceEquals(_handler, nullptr)) + { + return NULL; + } + + //TODO: We previously used GetBrowserWrapper - investigate passing in reference to this adapter + CefSharpBrowserWrapper browserWrapper(browser); + CefFrameWrapper frameWrapper(frame); + CefRequestWrapper requestWrapper(request); + + auto resourceHandler = _handler->GetCookieAccessFilter(_browserControl, %browserWrapper, %frameWrapper, %requestWrapper); + + if (resourceHandler == nullptr) + { + return NULL; + } + + throw gcnew NotImplementedException("Implement CefCookieAccessFilter wrapper"); + } + + cef_return_value_t OnBeforeResourceLoad(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, CefRefPtr callback) OVERRIDE + { + if (!Object::ReferenceEquals(_handler, nullptr)) + { + return cef_return_value_t::RV_CONTINUE; + } + + //TODO: We previously used GetBrowserWrapper - investigate passing in reference to this adapter + CefSharpBrowserWrapper browserWrapper(browser); + //We pass the frame and request wrappers to CefRequestCallbackWrapper so they can be disposed of + //when the callback is executed + auto frameWrapper = gcnew CefFrameWrapper(frame); + auto requestWrapper = gcnew CefRequestWrapper(request); + auto requestCallback = gcnew CefRequestCallbackWrapper(callback, frameWrapper, requestWrapper); + + return (cef_return_value_t)_handler->OnBeforeResourceLoad(_browserControl, %browserWrapper, frameWrapper, requestWrapper, requestCallback); + } + + CefRefPtr GetResourceHandler(CefRefPtr browser, CefRefPtr frame, CefRefPtr request) OVERRIDE + { + if (!Object::ReferenceEquals(_handler, nullptr)) + { + return NULL; + } + + //TODO: We previously used GetBrowserWrapper - investigate passing in reference to this adapter + CefSharpBrowserWrapper browserWrapper(browser); + CefFrameWrapper frameWrapper(frame); + CefRequestWrapper requestWrapper(request); + + auto resourceHandler = _handler->GetResourceHandler(_browserControl, %browserWrapper, %frameWrapper, %requestWrapper); + + if (resourceHandler == nullptr) + { + return NULL; + } + + if (resourceHandler->GetType() == FileResourceHandler::typeid) + { + auto fileResourceHandler = static_cast(resourceHandler); + + auto streamReader = CefStreamReader::CreateForFile(StringUtils::ToNative(fileResourceHandler->FilePath)); + + if (streamReader.get()) + { + return new CefStreamResourceHandler(StringUtils::ToNative(fileResourceHandler->MimeType), streamReader); + } + else + { + auto msg = "Unable to load resource CefStreamReader::CreateForFile returned NULL for file:" + fileResourceHandler->FilePath; + LOG(ERROR) << StringUtils::ToNative(msg).ToString(); + + return NULL; + } + } + else if (resourceHandler->GetType() == ByteArrayResourceHandler::typeid) + { + auto byteArrayResourceHandler = static_cast(resourceHandler); + + //NOTE: Prefix with cli:: namespace as VS2015 gets confused with std::array + cli::array^ buffer = byteArrayResourceHandler->Data; + pin_ptr src = &buffer[0]; + + auto streamReader = CefStreamReader::CreateForData(static_cast(src), buffer->Length); + + return new CefStreamResourceHandler(StringUtils::ToNative(byteArrayResourceHandler->MimeType), streamReader); + } + + return new ResourceHandlerWrapper(resourceHandler); + } + + void OnResourceRedirect(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, CefRefPtr response, CefString& newUrl) OVERRIDE + { + if (!Object::ReferenceEquals(_handler, nullptr)) + { + auto managedNewUrl = StringUtils::ToClr(newUrl); + //TODO: We previously used GetBrowserWrapper - investigate passing in reference to this adapter + CefSharpBrowserWrapper browserWrapper(browser); + CefFrameWrapper frameWrapper(frame); + CefRequestWrapper requestWrapper(request); + CefResponseWrapper responseWrapper(response); + + _handler->OnResourceRedirect(_browserControl, %browserWrapper, %frameWrapper, %requestWrapper, %responseWrapper, managedNewUrl); + + newUrl = StringUtils::ToNative(managedNewUrl); + } + } + + bool OnResourceResponse(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, CefRefPtr response) OVERRIDE + { + if (!Object::ReferenceEquals(_handler, nullptr)) + { + return false; + } + + //TODO: We previously used GetBrowserWrapper - investigate passing in reference to this adapter + CefSharpBrowserWrapper browserWrapper(browser); + CefFrameWrapper frameWrapper(frame); + CefRequestWrapper requestWrapper(request); + CefResponseWrapper responseWrapper(response); + + return _handler->OnResourceResponse(_browserControl, %browserWrapper, %frameWrapper, %requestWrapper, %responseWrapper); + } + + CefRefPtr GetResourceResponseFilter(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, CefRefPtr response) OVERRIDE + { + if (!Object::ReferenceEquals(_handler, nullptr)) + { + return NULL; + } + + //TODO: We previously used GetBrowserWrapper - investigate passing in reference to this adapter + CefSharpBrowserWrapper browserWrapper(browser); + CefFrameWrapper frameWrapper(frame); + CefRequestWrapper requestWrapper(request); + CefResponseWrapper responseWrapper(response); + + auto filter = _handler->GetResourceResponseFilter(_browserControl, %browserWrapper, %frameWrapper, %requestWrapper, %responseWrapper); + + if (filter == nullptr) + { + return NULL; + } + + return new CefResponseFilterAdapter(filter); + } + + void OnResourceLoadComplete(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, CefRefPtr response, URLRequestStatus status, int64 receivedContentLength) OVERRIDE + { + if (!Object::ReferenceEquals(_handler, nullptr)) + { + //TODO: We previously used GetBrowserWrapper - investigate passing in reference to this adapter + CefSharpBrowserWrapper browserWrapper(browser); + CefFrameWrapper frameWrapper(frame); + CefRequestWrapper requestWrapper(request); + CefResponseWrapper responseWrapper(response); + + _handler->OnResourceLoadComplete(_browserControl, %browserWrapper, %frameWrapper, %requestWrapper, %responseWrapper, (UrlRequestStatus)status, receivedContentLength); + } + } + + void OnProtocolExecution(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, bool& allowOSExecution) OVERRIDE + { + if (!Object::ReferenceEquals(_handler, nullptr)) + { + //TODO: We previously used GetBrowserWrapper - investigate passing in reference to this adapter + CefSharpBrowserWrapper browserWrapper(browser); + CefFrameWrapper frameWrapper(frame); + CefRequestWrapper requestWrapper(request); + + allowOSExecution = _handler->OnProtocolExecution(_browserControl, %browserWrapper, %frameWrapper, %requestWrapper); + } + } + + IMPLEMENT_REFCOUNTING(CefResourceRequestHandlerAdapter); + }; + } +} diff --git a/CefSharp.Core/Internals/CefSharpBrowserWrapper.cpp b/CefSharp.Core/Internals/CefSharpBrowserWrapper.cpp index b078629aad..9a0b162ee0 100644 --- a/CefSharp.Core/Internals/CefSharpBrowserWrapper.cpp +++ b/CefSharp.Core/Internals/CefSharpBrowserWrapper.cpp @@ -245,18 +245,7 @@ List^ CefSharpBrowserWrapper::GetFrameNames() return StringUtils::ToClr(names); } -// -// Send a message to the specified |target_process|. Returns true if the -// message was sent successfully. -/// -/*--cef()--*/ -bool CefSharpBrowserWrapper::SendProcessMessage(CefProcessId targetProcess, CefRefPtr message) -{ - ThrowIfDisposed(); - return _browser->SendProcessMessage(targetProcess, message); -} - MCefRefPtr CefSharpBrowserWrapper::Browser::get() { return _browser; -} \ No newline at end of file +} diff --git a/CefSharp.Core/Internals/CefSharpBrowserWrapper.h b/CefSharp.Core/Internals/CefSharpBrowserWrapper.h index 92479beea1..76b6338d4e 100644 --- a/CefSharp.Core/Internals/CefSharpBrowserWrapper.h +++ b/CefSharp.Core/Internals/CefSharpBrowserWrapper.h @@ -186,13 +186,6 @@ namespace CefSharp /// /*--cef()--*/ virtual List^ GetFrameNames(); - - // - // Send a message to the specified |target_process|. Returns true if the - // message was sent successfully. - /// - /*--cef()--*/ - virtual bool SendProcessMessage(CefProcessId targetProcess, CefRefPtr message); }; } -} \ No newline at end of file +} diff --git a/CefSharp.Core/Internals/ClientAdapter.cpp b/CefSharp.Core/Internals/ClientAdapter.cpp index c561f84229..7135eacaa3 100644 --- a/CefSharp.Core/Internals/ClientAdapter.cpp +++ b/CefSharp.Core/Internals/ClientAdapter.cpp @@ -19,8 +19,7 @@ #include "CefJSDialogCallbackWrapper.h" #include "CefMenuModelWrapper.h" #include "CefRequestWrapper.h" -#include "CefResponseWrapper.h" -#include "CefResponseFilterAdapter.h" +#include "CefResourceRequestHandlerAdapter.h" #include "CefRequestCallbackWrapper.h" #include "CefRunContextMenuCallbackWrapper.h" #include "CefSslInfoWrapper.h" @@ -28,13 +27,11 @@ #include "ManagedCefBrowserAdapter.h" #include "Messaging\Messages.h" #include "PopupFeatures.h" -#include "ResourceHandlerWrapper.h" #include "Serialization\Primitives.h" #include "Serialization\V8Serialization.h" #include "Serialization\JsObjectsSerialization.h" #include "Serialization\ObjectsSerialization.h" #include "TypeConversion.h" - #include "WindowInfo.h" using namespace CefSharp::Internals::Messaging; @@ -103,7 +100,7 @@ namespace CefSharp bool ClientAdapter::OnBeforePopup(CefRefPtr browser, CefRefPtr frame, const CefString& target_url, const CefString& target_frame_name, CefLifeSpanHandler::WindowOpenDisposition target_disposition, bool user_gesture, const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, - CefRefPtr& client, CefBrowserSettings& settings, bool* no_javascript_access) + CefRefPtr& client, CefBrowserSettings& settings, CefRefPtr& extraInfo, bool* no_javascript_access) { auto handler = _browserControl->LifeSpanHandler; @@ -539,56 +536,62 @@ namespace CefSharp return handler->OnOpenUrlFromTab(_browserControl, browserWrapper, %frameWrapper, StringUtils::ToClr(targetUrl), (CefSharp::WindowOpenDisposition)targetDisposition, userGesture); } - bool ClientAdapter::OnCertificateError(CefRefPtr browser, cef_errorcode_t cert_error, const CefString& request_url, CefRefPtr ssl_info, CefRefPtr callback) + CefRefPtr ClientAdapter::GetResourceRequestHandler(CefRefPtr browser, + CefRefPtr frame, CefRefPtr request, bool isNavigation, bool isDownload, const CefString& requestInitiator, bool& disableDefaultHandling) { auto handler = _browserControl->RequestHandler; if (handler == nullptr) { - return false; + return NULL; } - // If callback is empty the error cannot be recovered from and the request will be canceled automatically. - // Still notify the user of the certificate error just don't provide a callback. - auto requestCallback = callback == NULL ? nullptr : gcnew CefRequestCallbackWrapper(callback); auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup()); - auto sslInfoWrapper = gcnew CefSslInfoWrapper(ssl_info); + CefFrameWrapper frameWrapper(frame); + CefRequestWrapper requestWrapper(request); - return handler->OnCertificateError(_browserControl, browserWrapper, (CefErrorCode)cert_error, StringUtils::ToClr(request_url), sslInfoWrapper, requestCallback); - } + //TODO: Simplify this code - bool ClientAdapter::CanGetCookies(CefRefPtr browser, CefRefPtr frame, CefRefPtr request) - { - auto handler = _browserControl->RequestHandler; + auto resourceRequestHandler = handler->GetResourceRequestHandler(_browserControl, browserWrapper, %frameWrapper, + %requestWrapper, isNavigation, isDownload, StringUtils::ToClr(requestInitiator), disableDefaultHandling); - if (handler == nullptr) + if (resourceRequestHandler != nullptr) { - return true; + return new CefResourceRequestHandlerAdapter(_browserControl, resourceRequestHandler); } - auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup()); - CefFrameWrapper frameWrapper(frame); - CefRequestWrapper requestWrapper(request); + auto resourceRequestHandlerFactory = _browserControl->ResourceRequestHandlerFactory; - return handler->CanGetCookies(_browserControl, browserWrapper, %frameWrapper, %requestWrapper); + if (resourceRequestHandlerFactory != nullptr) + { + auto factoryHandler = resourceRequestHandlerFactory->GetResourceRequestHandler(_browserControl, browserWrapper, %frameWrapper, + %requestWrapper, isNavigation, isDownload, StringUtils::ToClr(requestInitiator), disableDefaultHandling); + + if (factoryHandler != nullptr) + { + return new CefResourceRequestHandlerAdapter(_browserControl, factoryHandler); + } + } + + return NULL; } - bool ClientAdapter::CanSetCookie(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, const CefCookie& cefCookie) + bool ClientAdapter::OnCertificateError(CefRefPtr browser, cef_errorcode_t cert_error, const CefString& request_url, CefRefPtr ssl_info, CefRefPtr callback) { auto handler = _browserControl->RequestHandler; if (handler == nullptr) { - return true; + return false; } + // If callback is empty the error cannot be recovered from and the request will be canceled automatically. + // Still notify the user of the certificate error just don't provide a callback. + auto requestCallback = callback == NULL ? nullptr : gcnew CefRequestCallbackWrapper(callback); auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup()); - CefFrameWrapper frameWrapper(frame); - CefRequestWrapper requestWrapper(request); - - auto cookie = TypeConversion::FromNative(cefCookie); + auto sslInfoWrapper = gcnew CefSslInfoWrapper(ssl_info); - return handler->CanSetCookie(_browserControl, browserWrapper, %frameWrapper, %requestWrapper, cookie); + return handler->OnCertificateError(_browserControl, browserWrapper, (CefErrorCode)cert_error, StringUtils::ToClr(request_url), sslInfoWrapper, requestCallback); } bool ClientAdapter::OnQuotaRequest(CefRefPtr browser, const CefString& originUrl, int64 newSize, CefRefPtr callback) @@ -632,11 +635,10 @@ namespace CefSharp auto msg = CefProcessMessage::Create(kJavascriptRootObjectResponse); auto responseArgList = msg->GetArgumentList(); responseArgList->SetBool(0, true); //Use Legacy Behaviour (auto bind on context creation) - responseArgList->SetInt(1, -1); //BrowserId - SetInt64(responseArgList, 2, 0); //FrameId - SetInt64(responseArgList, 3, 0); //CallbackId - SerializeJsObjects(objectRepository->GetObjects(nullptr), responseArgList, 4); - browser->SendProcessMessage(CefProcessId::PID_RENDERER, msg); + SetInt64(responseArgList, 1, 0); //CallbackId + SerializeJsObjects(objectRepository->GetObjects(nullptr), responseArgList, 2); + + browser->GetMainFrame()->SendProcessMessage(CefProcessId::PID_RENDERER, msg); } } } @@ -663,167 +665,6 @@ namespace CefSharp } } - void ClientAdapter::OnResourceRedirect(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, CefRefPtr response, CefString& newUrl) - { - auto handler = _browserControl->RequestHandler; - - if (handler != nullptr) - { - auto managedNewUrl = StringUtils::ToClr(newUrl); - auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup()); - CefFrameWrapper frameWrapper(frame); - CefRequestWrapper requestWrapper(request); - CefResponseWrapper responseWrapper(response); - - handler->OnResourceRedirect(_browserControl, browserWrapper, %frameWrapper, %requestWrapper, %responseWrapper, managedNewUrl); - - newUrl = StringUtils::ToNative(managedNewUrl); - } - } - - bool ClientAdapter::OnResourceResponse(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, CefRefPtr response) - { - auto handler = _browserControl->RequestHandler; - - if (handler == nullptr) - { - return false; - } - - auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup()); - CefFrameWrapper frameWrapper(frame); - CefRequestWrapper requestWrapper(request); - CefResponseWrapper responseWrapper(response); - - return handler->OnResourceResponse(_browserControl, browserWrapper, %frameWrapper, %requestWrapper, %responseWrapper); - } - - CefRefPtr ClientAdapter::GetResourceResponseFilter(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, CefRefPtr response) - { - auto handler = _browserControl->RequestHandler; - - if (handler == nullptr) - { - return NULL; - } - - auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup()); - CefFrameWrapper frameWrapper(frame); - CefRequestWrapper requestWrapper(request); - CefResponseWrapper responseWrapper(response); - - auto filter = handler->GetResourceResponseFilter(_browserControl, browserWrapper, %frameWrapper, %requestWrapper, %responseWrapper); - - if (filter == nullptr) - { - return NULL; - } - - return new CefResponseFilterAdapter(filter); - } - - void ClientAdapter::OnResourceLoadComplete(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, CefRefPtr response, URLRequestStatus status, int64 receivedContentLength) - { - auto handler = _browserControl->RequestHandler; - - if (handler != nullptr) - { - auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup()); - CefFrameWrapper frameWrapper(frame); - CefRequestWrapper requestWrapper(request); - CefResponseWrapper responseWrapper(response); - - handler->OnResourceLoadComplete(_browserControl, browserWrapper, %frameWrapper, %requestWrapper, %responseWrapper, (UrlRequestStatus)status, receivedContentLength); - } - } - - void ClientAdapter::OnProtocolExecution(CefRefPtr browser, const CefString& url, bool& allowOSExecution) - { - auto handler = _browserControl->RequestHandler; - - if (handler != nullptr) - { - auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup()); - - allowOSExecution = handler->OnProtocolExecution(_browserControl, browserWrapper, StringUtils::ToClr(url)); - } - } - - // Called on the IO thread before a resource is loaded. To allow the resource - // to load normally return NULL. To specify a handler for the resource return - // a CefResourceHandler object. The |request| object should not be modified in - // this callback. - CefRefPtr ClientAdapter::GetResourceHandler(CefRefPtr browser, CefRefPtr frame, CefRefPtr request) - { - auto factory = _browserControl->ResourceHandlerFactory; - - if (factory == nullptr || !factory->HasHandlers) - { - return NULL; - } - - auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup()); - CefFrameWrapper frameWrapper(frame); - CefRequestWrapper requestWrapper(request); - - auto handler = factory->GetResourceHandler(_browserControl, browserWrapper, %frameWrapper, %requestWrapper); - - if (handler == nullptr) - { - return NULL; - } - - if (handler->GetType() == FileResourceHandler::typeid) - { - auto resourceHandler = static_cast(handler); - - auto streamReader = CefStreamReader::CreateForFile(StringUtils::ToNative(resourceHandler->FilePath)); - - if (streamReader.get()) - { - return new CefStreamResourceHandler(StringUtils::ToNative(resourceHandler->MimeType), streamReader); - } - else - { - auto msg = "Unable to load resource CefStreamReader::CreateForFile returned NULL for file:" + resourceHandler->FilePath; - LOG(ERROR) << StringUtils::ToNative(msg).ToString(); - - return NULL; - } - } - else if (handler->GetType() == ByteArrayResourceHandler::typeid) - { - auto resourceHandler = static_cast(handler); - - //NOTE: Prefix with cli:: namespace as VS2015 gets confused with std::array - cli::array^ buffer = resourceHandler->Data; - pin_ptr src = &buffer[0]; - - auto streamReader = CefStreamReader::CreateForData(static_cast(src), buffer->Length); - - return new CefStreamResourceHandler(StringUtils::ToNative(resourceHandler->MimeType), streamReader); - } - - return new ResourceHandlerWrapper(handler); - } - - cef_return_value_t ClientAdapter::OnBeforeResourceLoad(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, CefRefPtr callback) - { - auto handler = _browserControl->RequestHandler; - - if (handler == nullptr) - { - return cef_return_value_t::RV_CONTINUE; - } - - auto frameWrapper = gcnew CefFrameWrapper(frame); - auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup()); - auto requestWrapper = gcnew CefRequestWrapper(request); - auto requestCallback = gcnew CefRequestCallbackWrapper(callback, frameWrapper, requestWrapper); - - return (cef_return_value_t)handler->OnBeforeResourceLoad(_browserControl, browserWrapper, frameWrapper, requestWrapper, requestCallback); - } - bool ClientAdapter::GetAuthCredentials(CefRefPtr browser, CefRefPtr frame, bool isProxy, const CefString& host, int port, const CefString& realm, const CefString& scheme, CefRefPtr callback) { @@ -1099,7 +940,7 @@ namespace CefSharp return handler->OnDragEnter(_browserControl, browserWrapper, %dragDataWrapper, (CefSharp::Enums::DragOperationsMask)mask); } - void ClientAdapter::OnDraggableRegionsChanged(CefRefPtr browser, const std::vector& regions) + void ClientAdapter::OnDraggableRegionsChanged(CefRefPtr browser, CefRefPtr frame, const std::vector& regions) { auto handler = _browserControl->DragHandler; @@ -1107,8 +948,9 @@ namespace CefSharp { auto regionsList = TypeConversion::FromNative(regions); auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup()); + CefFrameWrapper frameWrapper(frame); - return handler->OnDraggableRegionsChanged(_browserControl, browserWrapper, regionsList); + return handler->OnDraggableRegionsChanged(_browserControl, browserWrapper, %frameWrapper, regionsList); } } @@ -1192,7 +1034,7 @@ namespace CefSharp } } - bool ClientAdapter::OnProcessMessageReceived(CefRefPtr browser, CefProcessId source_process, CefRefPtr message) + bool ClientAdapter::OnProcessMessageReceived(CefRefPtr browser, CefRefPtr frame, CefProcessId source_process, CefRefPtr message) { auto handled = false; auto name = message->GetName(); @@ -1206,10 +1048,8 @@ namespace CefSharp { auto objectRepository = _browserAdapter->JavascriptObjectRepository; - auto browserId = argList->GetInt(0); - auto frameId = GetInt64(argList, 1); - auto callbackId = GetInt64(argList, 2); - auto objectNames = argList->GetList(3); + auto callbackId = GetInt64(argList, 0); + auto objectNames = argList->GetList(1); auto names = gcnew List(objectNames->GetSize()); for (auto i = 0; i < objectNames->GetSize(); i++) @@ -1225,11 +1065,9 @@ namespace CefSharp auto msg = CefProcessMessage::Create(kJavascriptRootObjectResponse); auto responseArgList = msg->GetArgumentList(); responseArgList->SetBool(0, false); //Use LegacyBehaviour (false) - responseArgList->SetInt(1, browserId); - SetInt64(responseArgList, 2, frameId); - SetInt64(responseArgList, 3, callbackId); - SerializeJsObjects(objs, responseArgList, 4); - browser->SendProcessMessage(CefProcessId::PID_RENDERER, msg); + SetInt64(responseArgList, 1, callbackId); + SerializeJsObjects(objs, responseArgList, 2); + frame->SendProcessMessage(CefProcessId::PID_RENDERER, msg); } handled = true; @@ -1259,11 +1097,9 @@ namespace CefSharp } else if (name == kOnContextCreatedRequest) { - auto frame = browser->GetFrame(GetInt64(argList, 0)); - //In certain circumstances the frame has already been destroyed by the time //we get here, only continue if we have a valid frame reference - if (frame.get()) + if (frame.get() && frame->IsValid()) { if (frame->IsMain()) { @@ -1285,11 +1121,9 @@ namespace CefSharp } else if (name == kOnContextReleasedRequest) { - auto frame = browser->GetFrame(GetInt64(argList, 0)); - //In certain circumstances the frame has already been destroyed by the time //we get here, only continue if we have a valid frame reference - if (frame.get()) + if (frame.get() && frame->IsValid()) { if (frame->IsMain()) { @@ -1316,19 +1150,18 @@ namespace CefSharp { IDomNode^ node = nullptr; - // 0: frame ID (int 64) - // 1: is a node (bool) - // 2: tag name (string) - // 3: attributes (dictionary) + // 0: is a node (bool) + // 1: tag name (string) + // 2: attributes (dictionary) auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup()); - CefFrameWrapper frameWrapper(browser->GetFrame(GetInt64(argList, 0))); + CefFrameWrapper frameWrapper(frame); - auto notEmpty = argList->GetBool(1); + auto notEmpty = argList->GetBool(0); if (notEmpty) { // Node information was passed from the render process. - auto tagName = StringUtils::ToClr(argList->GetString(2)); - auto argAttributes = argList->GetDictionary(3); + auto tagName = StringUtils::ToClr(argList->GetString(1)); + auto argAttributes = argList->GetDictionary(2); auto attributes = gcnew System::Collections::Generic::Dictionary(); CefDictionaryValue::KeyList keys; argAttributes->GetKeys(keys); @@ -1350,14 +1183,14 @@ namespace CefSharp if (handler != nullptr) { auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup()); - CefFrameWrapper frameWrapper(browser->GetFrame(GetInt64(argList, 0))); + CefFrameWrapper frameWrapper(frame); auto exception = gcnew JavascriptException(); - exception->Message = StringUtils::ToClr(argList->GetString(1)); + exception->Message = StringUtils::ToClr(argList->GetString(0)); auto stackTrace = gcnew System::Collections::Generic::List(); - auto argFrames = argList->GetList(2); + auto argFrames = argList->GetList(1); for (auto i = 0; i < static_cast(argFrames->GetSize()); i++) { @@ -1404,11 +1237,11 @@ namespace CefSharp } else if (name == kJavascriptAsyncMethodCallRequest && !_browserAdapter->IsDisposed) { - auto frameId = GetInt64(argList, 0); - auto objectId = GetInt64(argList, 1); - auto callbackId = GetInt64(argList, 2); - auto methodName = StringUtils::ToClr(argList->GetString(3)); - auto arguments = argList->GetList(4); + auto frameId = frame->GetIdentifier(); + auto objectId = GetInt64(argList, 0); + auto callbackId = GetInt64(argList, 1); + auto methodName = StringUtils::ToClr(argList->GetString(2)); + auto arguments = argList->GetList(3); auto methodInvocation = gcnew MethodInvocation(browser->GetIdentifier(), frameId, objectId, methodName, (callbackId > 0 ? Nullable(callbackId) : Nullable())); for (auto i = 0; i < static_cast(arguments->GetSize()); i++) { @@ -1421,16 +1254,14 @@ namespace CefSharp } else if (name == kJavascriptMessageReceived) { - auto frame = browser->GetFrame(GetInt64(argList, 0)); - //In certain circumstances the frame has already been destroyed by the time //we get here, only continue if we have a valid frame reference - if (frame.get()) + if (frame.get() && frame->IsValid()) { auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup()); CefFrameWrapper frameWrapper(frame); - auto message = DeserializeObject(argList, 1, callbackFactory); + auto message = DeserializeObject(argList, 0, callbackFactory); _browserControl->SetJavascriptMessageReceived(gcnew JavascriptMessageReceivedEventArgs(browserWrapper, %frameWrapper, message)); } @@ -1441,34 +1272,6 @@ namespace CefSharp return handled; } - Task^ ClientAdapter::EvaluateScriptAsync(int browserId, bool isBrowserPopup, int64 frameId, String^ script, String^ scriptUrl, int startLine, Nullable timeout) - { - auto browser = GetBrowserWrapper(browserId, isBrowserPopup); - - //If we're unable to get the underlying browser wrapper then return null - if (browser == nullptr) - { - return nullptr; - } - - auto browserWrapper = static_cast(browser); - - //create a new taskcompletionsource - auto idAndComplectionSource = _pendingTaskRepository->CreatePendingTask(timeout); - - auto message = CefProcessMessage::Create(kEvaluateJavascriptRequest); - auto argList = message->GetArgumentList(); - SetInt64(argList, 0, frameId); - SetInt64(argList, 1, idAndComplectionSource.Key); - argList->SetString(2, StringUtils::ToNative(script)); - argList->SetString(3, StringUtils::ToNative(scriptUrl)); - argList->SetInt(4, startLine); - - browserWrapper->SendProcessMessage(CefProcessId::PID_RENDERER, message); - - return idAndComplectionSource.Value->Task; - } - PendingTaskRepository^ ClientAdapter::GetPendingTaskRepository() { return _pendingTaskRepository; @@ -1480,16 +1283,15 @@ namespace CefSharp { auto message = CefProcessMessage::Create(kJavascriptAsyncMethodCallResponse); auto argList = message->GetArgumentList(); - SetInt64(argList, 0, result->FrameId); - SetInt64(argList, 1, result->CallbackId.Value); - argList->SetBool(2, result->Success); + SetInt64(argList, 0, result->CallbackId.Value); + argList->SetBool(1, result->Success); if (result->Success) { - SerializeV8Object(argList, 3, result->Result); + SerializeV8Object(argList, 2, result->Result); } else { - argList->SetString(3, StringUtils::ToNative(result->Message)); + argList->SetString(2, StringUtils::ToNative(result->Message)); } auto browser = GetBrowserWrapper(result->BrowserId); @@ -1497,8 +1299,9 @@ namespace CefSharp if (browser != nullptr) { auto wrapper = static_cast(browser); + auto frame = wrapper->Browser->GetFrame(result->FrameId); - wrapper->Browser->SendProcessMessage(CefProcessId::PID_RENDERER, message); + frame->SendProcessMessage(CefProcessId::PID_RENDERER, message); } } } diff --git a/CefSharp.Core/Internals/ClientAdapter.h b/CefSharp.Core/Internals/ClientAdapter.h index 93ba97a5e6..2a16876acc 100644 --- a/CefSharp.Core/Internals/ClientAdapter.h +++ b/CefSharp.Core/Internals/ClientAdapter.h @@ -112,7 +112,7 @@ namespace CefSharp return this; } - virtual DECL bool OnProcessMessageReceived(CefRefPtr browser, CefProcessId source_process, CefRefPtr message) OVERRIDE; + virtual DECL bool OnProcessMessageReceived(CefRefPtr browser, CefRefPtr frame, CefProcessId source_process, CefRefPtr message) OVERRIDE; // CefLifeSpanHandler @@ -120,7 +120,7 @@ namespace CefSharp const CefString& target_url, const CefString& target_frame_name, CefLifeSpanHandler::WindowOpenDisposition target_disposition, bool user_gesture, const CefPopupFeatures& popupFeatures, - CefWindowInfo& windowInfo, CefRefPtr& client, CefBrowserSettings& settings, bool* no_javascript_access) OVERRIDE; + CefWindowInfo& windowInfo, CefRefPtr& client, CefBrowserSettings& settings, CefRefPtr& extraInfo, bool* no_javascript_access) OVERRIDE; virtual DECL void OnAfterCreated(CefRefPtr browser) OVERRIDE; virtual DECL bool DoClose(CefRefPtr browser) OVERRIDE; virtual DECL void OnBeforeClose(CefRefPtr browser) OVERRIDE; @@ -131,27 +131,20 @@ namespace CefSharp virtual DECL void OnLoadError(CefRefPtr browser, CefRefPtr frame, ErrorCode errorCode, const CefString& errorText, const CefString& failedUrl) OVERRIDE; // CefRequestHandler - virtual DECL CefRefPtr GetResourceHandler(CefRefPtr browser, CefRefPtr frame, CefRefPtr request) OVERRIDE; - virtual DECL cef_return_value_t OnBeforeResourceLoad(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, CefRefPtr callback) OVERRIDE; - virtual DECL bool GetAuthCredentials(CefRefPtr browser, CefRefPtr frame, bool isProxy, - const CefString& host, int port, const CefString& realm, const CefString& scheme, CefRefPtr callback) OVERRIDE; virtual DECL bool OnBeforeBrowse(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, bool userGesture, bool isRedirect) OVERRIDE; virtual DECL bool OnOpenURLFromTab(CefRefPtr browser, CefRefPtr frame, const CefString& targetUrl, CefRequestHandler::WindowOpenDisposition targetDisposition, bool userGesture) OVERRIDE; - virtual DECL bool OnCertificateError(CefRefPtr browser, cef_errorcode_t cert_error, const CefString& request_url, CefRefPtr ssl_info, CefRefPtr callback) OVERRIDE; - virtual DECL bool CanGetCookies(CefRefPtr browser, CefRefPtr frame, CefRefPtr request) OVERRIDE; - virtual DECL bool CanSetCookie(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, const CefCookie& cookie) OVERRIDE; + virtual DECL CefRefPtr GetResourceRequestHandler(CefRefPtr browser, + CefRefPtr frame, CefRefPtr request, bool isNavigation, bool isDownload, const CefString& requestInitiator, bool& disableDefaultHandling) OVERRIDE; + virtual DECL bool GetAuthCredentials(CefRefPtr browser, CefRefPtr frame, bool isProxy, + const CefString& host, int port, const CefString& realm, const CefString& scheme, CefRefPtr callback) OVERRIDE; virtual DECL bool OnQuotaRequest(CefRefPtr browser, const CefString& originUrl, int64 newSize, CefRefPtr callback) OVERRIDE; - virtual DECL void OnResourceRedirect(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, CefRefPtr response, CefString& newUrl) OVERRIDE; - virtual DECL bool OnResourceResponse(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, CefRefPtr response) OVERRIDE; - virtual DECL CefRefPtr GetResourceResponseFilter(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, CefRefPtr response) OVERRIDE; - virtual DECL void OnResourceLoadComplete(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, CefRefPtr response, URLRequestStatus status, int64 receivedContentLength) OVERRIDE; - virtual DECL void OnProtocolExecution(CefRefPtr browser, const CefString& url, bool& allowOSExecution) OVERRIDE; + virtual DECL bool OnCertificateError(CefRefPtr browser, cef_errorcode_t cert_error, const CefString& request_url, CefRefPtr ssl_info, CefRefPtr callback) OVERRIDE; + virtual DECL bool OnSelectClientCertificate(CefRefPtr browser, bool isProxy, const CefString& host, int port, + const CefRequestHandler::X509CertificateList& certificates, CefRefPtr callback) OVERRIDE; virtual DECL void OnPluginCrashed(CefRefPtr browser, const CefString& plugin_path) OVERRIDE; virtual DECL void OnRenderViewReady(CefRefPtr browser) OVERRIDE; virtual DECL void OnRenderProcessTerminated(CefRefPtr browser, TerminationStatus status) OVERRIDE; - virtual DECL bool OnSelectClientCertificate(CefRefPtr browser, bool isProxy, const CefString& host, int port, - const CefRequestHandler::X509CertificateList& certificates, CefRefPtr callback) OVERRIDE; // CefDisplayHandler virtual DECL void OnLoadingStateChange(CefRefPtr browser, bool isLoading, bool canGoBack, bool canGoForward) OVERRIDE; @@ -198,7 +191,7 @@ namespace CefSharp //CefDragHandler virtual DECL bool OnDragEnter(CefRefPtr browser, CefRefPtr dragData, DragOperationsMask mask) OVERRIDE; - virtual DECL void OnDraggableRegionsChanged(CefRefPtr browser, const std::vector& regions) OVERRIDE; + virtual DECL void OnDraggableRegionsChanged(CefRefPtr browser, CefRefPtr frame, const std::vector& regions) OVERRIDE; //CefDownloadHandler virtual DECL void OnBeforeDownload(CefRefPtr browser, CefRefPtr download_item, @@ -214,9 +207,6 @@ namespace CefSharp virtual DECL void OnAudioStreamPacket(CefRefPtr browser, int audio_stream_id, const float** data, int frames, int64 pts) OVERRIDE; virtual DECL void OnAudioStreamStopped(CefRefPtr browser, int audio_stream_id) OVERRIDE; - //sends out an eval script request to the render process - Task^ EvaluateScriptAsync(int browserId, bool isBrowserPopup, int64 frameId, String^ script, String^ scriptUrl, int startLine, Nullable timeout); - IMPLEMENT_REFCOUNTING(ClientAdapter); }; } diff --git a/CefSharp.Core/Internals/JavascriptCallbackProxy.cpp b/CefSharp.Core/Internals/JavascriptCallbackProxy.cpp index b725f105b0..324801f721 100644 --- a/CefSharp.Core/Internals/JavascriptCallbackProxy.cpp +++ b/CefSharp.Core/Internals/JavascriptCallbackProxy.cpp @@ -31,20 +31,32 @@ namespace CefSharp auto callbackMessage = CefProcessMessage::Create(kJavascriptCallbackRequest); auto argList = callbackMessage->GetArgumentList(); - SetInt64(argList, 0, _callback->FrameId); - SetInt64(argList, 1, doneCallback.Key); - SetInt64(argList, 2, _callback->Id); + SetInt64(argList, 0, doneCallback.Key); + SetInt64(argList, 1, _callback->Id); auto paramList = CefListValue::Create(); for (int i = 0; i < parameters->Length; i++) { auto param = parameters[i]; SerializeV8Object(paramList, i, param); } - argList->SetList(3, paramList); + argList->SetList(2, paramList); - browserWrapper->SendProcessMessage(CefProcessId::PID_RENDERER, callbackMessage); + auto frame = browserWrapper->Browser->GetFrame(_callback->FrameId); - return doneCallback.Value->Task; + if (frame.get() && frame->IsValid()) + { + frame->SendProcessMessage(CefProcessId::PID_RENDERER, callbackMessage); + + return doneCallback.Value->Task; + } + else + { + auto invalidFrameResponse = gcnew JavascriptResponse(); + invalidFrameResponse->Success = false; + invalidFrameResponse->Message = "Frame with Id:" + _callback->FrameId + " is no longer valid."; + + Task::FromResult(invalidFrameResponse); + } } CefRefPtr JavascriptCallbackProxy::CreateDestroyMessage() @@ -52,7 +64,6 @@ namespace CefSharp auto result = CefProcessMessage::Create(kJavascriptCallbackDestroyRequest); auto argList = result->GetArgumentList(); SetInt64(argList, 0, _callback->Id); - SetInt64(argList, 1, _callback->FrameId); return result; } diff --git a/CefSharp.Core/Internals/JavascriptCallbackProxy.h b/CefSharp.Core/Internals/JavascriptCallbackProxy.h index 5ac0369804..81df1d3030 100644 --- a/CefSharp.Core/Internals/JavascriptCallbackProxy.h +++ b/CefSharp.Core/Internals/JavascriptCallbackProxy.h @@ -45,8 +45,12 @@ namespace CefSharp auto browser = GetBrowser(); if (browser != nullptr && !browser->IsDisposed) { - auto browserWrapper = static_cast(browser); - browserWrapper->SendProcessMessage(CefProcessId::PID_RENDERER, CreateDestroyMessage()); + auto browserWrapper = static_cast(browser)->Browser; + auto frame = browserWrapper->GetFrame(_callback->FrameId); + if (frame.get() && frame->IsValid()) + { + frame->SendProcessMessage(CefProcessId::PID_RENDERER, CreateDestroyMessage()); + } } _disposed = true; } @@ -69,4 +73,4 @@ namespace CefSharp } }; } -} \ No newline at end of file +} diff --git a/CefSharp.Core/ManagedCefBrowserAdapter.cpp b/CefSharp.Core/ManagedCefBrowserAdapter.cpp index 920fc1bec2..7868cdcf6a 100644 --- a/CefSharp.Core/ManagedCefBrowserAdapter.cpp +++ b/CefSharp.Core/ManagedCefBrowserAdapter.cpp @@ -35,7 +35,7 @@ void ManagedCefBrowserAdapter::CreateBrowser(IWindowInfo^ windowInfo, BrowserSet } if (!CefBrowserHost::CreateBrowser(*cefWindowInfoWrapper->GetWindowInfo(), _clientAdapter.get(), addressNative, - *browserSettings->_browserSettings, static_cast>(requestContext))) + *browserSettings->_browserSettings, NULL, static_cast>(requestContext))) { throw gcnew InvalidOperationException("CefBrowserHost::CreateBrowser call failed, review the CEF log file for more details."); } diff --git a/CefSharp.Core/RequestContext.cpp b/CefSharp.Core/RequestContext.cpp index 1b3cb672f3..bae40d7364 100644 --- a/CefSharp.Core/RequestContext.cpp +++ b/CefSharp.Core/RequestContext.cpp @@ -49,13 +49,13 @@ namespace CefSharp return _requestContext->IsSharingWith(requestContext); } - ICookieManager^ RequestContext::GetDefaultCookieManager(ICompletionCallback^ callback) + ICookieManager^ RequestContext::GetCookieManager(ICompletionCallback^ callback) { ThrowIfDisposed(); CefRefPtr wrapper = callback == nullptr ? NULL : new CefCompletionCallbackAdapter(callback); - auto cookieManager = _requestContext->GetDefaultCookieManager(wrapper); + auto cookieManager = _requestContext->GetCookieManager(wrapper); if (cookieManager.get()) { return gcnew CookieManager(cookieManager); diff --git a/CefSharp.Core/RequestContext.h b/CefSharp.Core/RequestContext.h index 3471fd76a5..31752cf2d7 100644 --- a/CefSharp.Core/RequestContext.h +++ b/CefSharp.Core/RequestContext.h @@ -134,14 +134,12 @@ namespace CefSharp /// /// Returns the default cookie manager for this object. This will be the global - /// cookie manager if this object is the global request context. Otherwise, - /// this will be the default cookie manager used when this request context does - /// not receive a value via IRequestContextHandler.GetCookieManager(). + /// cookie manager if this object is the global request context. /// /// If callback is non-NULL it will be executed asnychronously on the CEF IO thread /// after the manager's storage has been initialized. /// Returns the default cookie manager for this object - virtual ICookieManager^ GetDefaultCookieManager(ICompletionCallback^ callback); + virtual ICookieManager^ GetCookieManager(ICompletionCallback^ callback); /// /// Returns true if this object is the global context. The global context is diff --git a/CefSharp.Core/RequestContextSettings.h b/CefSharp.Core/RequestContextSettings.h index 4f9ba2fb33..81f8041d2d 100644 --- a/CefSharp.Core/RequestContextSettings.h +++ b/CefSharp.Core/RequestContextSettings.h @@ -68,12 +68,14 @@ namespace CefSharp } /// - /// The location where cache data will be stored on disk. If empty then - /// browsers will be created in "incognito mode" where in-memory caches are - /// used for storage and no data is persisted to disk. HTML5 databases such as - /// localStorage will only persist across sessions if a cache path is - /// specified. To share the global browser cache and related configuration set - /// this value to match the CefSettings.CachePath value. + /// The location where cache data for this request context will be stored on + /// disk. If non-empty this must be either equal to or a child directory of + /// CefSettings.RootCachePath. If empty then browsers will be created in + /// "incognito mode" where in-memory caches are used for storage and no data is + /// persisted to disk. HTML5 databases such as localStorage will only persist + /// across sessions if a cache path is specified. To share the global browser + /// cache and related configuration set this value to match the + /// CefSettings.CachePath value. /// property String^ CachePath { @@ -121,4 +123,4 @@ namespace CefSharp void set(bool value) { _settings->ignore_certificate_errors = value; } } }; -} \ No newline at end of file +} diff --git a/CefSharp.Core/Resource.rc b/CefSharp.Core/Resource.rc index 5a22c831e8..9baadc6def 100644 --- a/CefSharp.Core/Resource.rc +++ b/CefSharp.Core/Resource.rc @@ -1,6 +1,6 @@ 1 VERSIONINFO - FILEVERSION 74.1.130 - PRODUCTVERSION 74.1.130 + FILEVERSION 75.0.30 + PRODUCTVERSION 75.0.30 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -16,10 +16,10 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "FileDescription", "CefSharp.Core" - VALUE "FileVersion", "74.1.130" + VALUE "FileVersion", "75.0.30" VALUE "LegalCopyright", "Copyright © 2019 The CefSharp Authors" VALUE "ProductName", "CefSharp" - VALUE "ProductVersion", "74.1.130" + VALUE "ProductVersion", "75.0.30" END END BLOCK "VarFileInfo" diff --git a/CefSharp.Core/ResourceHandlerWrapper.cpp b/CefSharp.Core/ResourceHandlerWrapper.cpp index d5581d2bc4..3e021d3cc3 100644 --- a/CefSharp.Core/ResourceHandlerWrapper.cpp +++ b/CefSharp.Core/ResourceHandlerWrapper.cpp @@ -42,22 +42,6 @@ namespace CefSharp return _handler->ReadResponse(%writeStream, bytesRead, callbackWrapper); } - bool ResourceHandlerWrapper::CanGetCookie(const CefCookie& cefCookie) - { - auto cookie = GetCookie(cefCookie); - - //Default value is true - return _handler->CanGetCookie(cookie); - } - - bool ResourceHandlerWrapper::CanSetCookie(const CefCookie& cefCookie) - { - auto cookie = GetCookie(cefCookie); - - //Default value is true - return _handler->CanSetCookie(cookie); - } - void ResourceHandlerWrapper::Cancel() { _handler->Cancel(); diff --git a/CefSharp.Core/ResourceHandlerWrapper.h b/CefSharp.Core/ResourceHandlerWrapper.h index a2d91df88e..105050b5b7 100644 --- a/CefSharp.Core/ResourceHandlerWrapper.h +++ b/CefSharp.Core/ResourceHandlerWrapper.h @@ -38,10 +38,8 @@ namespace CefSharp virtual bool ProcessRequest(CefRefPtr request, CefRefPtr callback) OVERRIDE; virtual void GetResponseHeaders(CefRefPtr response, int64& response_length, CefString& redirectUrl) OVERRIDE; virtual bool ReadResponse(void* data_out, int bytes_to_read, int& bytes_read, CefRefPtr callback) OVERRIDE; - virtual bool CanGetCookie(const CefCookie& cookie) OVERRIDE; - virtual bool CanSetCookie(const CefCookie& cookie) OVERRIDE; virtual void Cancel() OVERRIDE; IMPLEMENT_REFCOUNTING(ResourceHandlerWrapper); }; -} \ No newline at end of file +} diff --git a/CefSharp.Core/packages.config b/CefSharp.Core/packages.config index 4cbdc1e94e..504ae7da00 100644 --- a/CefSharp.Core/packages.config +++ b/CefSharp.Core/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/CefSharp.Example/CefExample.cs b/CefSharp.Example/CefExample.cs index 5ee6f40205..d7eb86921c 100644 --- a/CefSharp.Example/CefExample.cs +++ b/CefSharp.Example/CefExample.cs @@ -155,8 +155,14 @@ public static void Init(AbstractCefSettings settings, IBrowserProcessHandler bro { SchemeName = CefSharpSchemeHandlerFactory.SchemeName, SchemeHandlerFactory = new CefSharpSchemeHandlerFactory(), - IsSecure = true //treated with the same security rules as those applied to "https" URLs - //SchemeHandlerFactory = new InMemorySchemeAndResourceHandlerFactory() + IsSecure = true, //treated with the same security rules as those applied to "https" URLs + }); + + settings.RegisterScheme(new CefCustomScheme + { + SchemeName = "https", + SchemeHandlerFactory = new CefSharpSchemeHandlerFactory(), + DomainName = "cefsharp.example" }); settings.RegisterScheme(new CefCustomScheme @@ -217,7 +223,7 @@ public static void Init(AbstractCefSettings settings, IBrowserProcessHandler bro public static async void RegisterTestResources(IWebBrowser browser) { - var handler = browser.ResourceHandlerFactory as DefaultResourceHandlerFactory; + var handler = browser.ResourceRequestHandlerFactory as DefaultResourceRequestHandlerFactory; if (handler != null) { const string renderProcessCrashedBody = "

Render Process Crashed

Your seeing this message as the render process has crashed

"; diff --git a/CefSharp.Example/CefSharp.Example.csproj b/CefSharp.Example/CefSharp.Example.csproj index a6603eec02..8c20ed71d1 100644 --- a/CefSharp.Example/CefSharp.Example.csproj +++ b/CefSharp.Example/CefSharp.Example.csproj @@ -82,10 +82,9 @@ - - + diff --git a/CefSharp.Example/FlashResourceHandlerFactory.cs b/CefSharp.Example/FlashResourceHandlerFactory.cs deleted file mode 100644 index 22ebbe0249..0000000000 --- a/CefSharp.Example/FlashResourceHandlerFactory.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright © 2016 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. - -namespace CefSharp.Example -{ - public class FlashResourceHandlerFactory : IResourceHandlerFactory - { - bool IResourceHandlerFactory.HasHandlers - { - get { return true; } - } - - IResourceHandler IResourceHandlerFactory.GetResourceHandler(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request) - { - if (request.Url.Contains("zeldaADPCM5bit.swf")) - { - return new FlashResourceHandler(); - } - return null; - } - } -} diff --git a/CefSharp.Example/Handlers/BrowserProcessHandler.cs b/CefSharp.Example/Handlers/BrowserProcessHandler.cs index 17f5859f8c..f483cd6784 100644 --- a/CefSharp.Example/Handlers/BrowserProcessHandler.cs +++ b/CefSharp.Example/Handlers/BrowserProcessHandler.cs @@ -24,8 +24,7 @@ void IBrowserProcessHandler.OnContextInitialized() { //The Global CookieManager has been initialized, you can now set cookies var cookieManager = Cef.GetGlobalCookieManager(); - cookieManager.SetStoragePath("cookies", true); - cookieManager.SetSupportedSchemes(new string[] { "custom" }); + cookieManager.SetSupportedSchemes(new string[] { "custom" }, true); if (cookieManager.SetCookie("custom://cefsharp/home.html", new Cookie { Name = "CefSharpTestCookie", diff --git a/CefSharp.Example/Handlers/RequestHandler.cs b/CefSharp.Example/Handlers/RequestHandler.cs index 564cf05688..36c9b91c2b 100644 --- a/CefSharp.Example/Handlers/RequestHandler.cs +++ b/CefSharp.Example/Handlers/RequestHandler.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Security.Cryptography.X509Certificates; -using System.Text; using CefSharp.Example.Filters; using CefSharp.Handler; @@ -22,7 +21,7 @@ public class RequestHandler : DefaultRequestHandler public static readonly string VersionNumberString = String.Format("Chromium: {0}, CEF: {1}, CefSharp: {2}", Cef.ChromiumVersion, Cef.CefVersion, Cef.CefSharpVersion); - private Dictionary responseDictionary = new Dictionary(); + private readonly Dictionary responseDictionary = new Dictionary(); public override bool OnBeforeBrowse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, bool userGesture, bool isRedirect) { @@ -60,79 +59,79 @@ public override void OnPluginCrashed(IWebBrowser browserControl, IBrowser browse // TODO: Add your own code here for handling scenarios where a plugin crashed, for one reason or another. } - public override CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) - { - Uri url; - if (Uri.TryCreate(request.Url, UriKind.Absolute, out url) == false) - { - //If we're unable to parse the Uri then cancel the request - // avoid throwing any exceptions here as we're being called by unmanaged code - return CefReturnValue.Cancel; - } - - //Example of how to set Referer - // Same should work when setting any header - - // For this example only set Referer when using our custom scheme - if (url.Scheme == CefSharpSchemeHandlerFactory.SchemeName) - { - //Referrer is now set using it's own method (was previously set in headers before) - request.SetReferrer("http://google.com", ReferrerPolicy.Default); - } - - //Example of setting User-Agent in every request. - //var headers = request.Headers; - - //var userAgent = headers["User-Agent"]; - //headers["User-Agent"] = userAgent + " CefSharp"; - - //request.Headers = headers; - - //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. - //callback.Dispose(); - //return false; - - //NOTE: When executing the callback in an async fashion need to check to see if it's disposed - if (!callback.IsDisposed) - { - using (callback) - { - if (request.Method == "POST") - { - using (var postData = request.PostData) - { - if (postData != null) - { - var elements = postData.Elements; - - var charSet = request.GetCharSet(); - - foreach (var element in elements) - { - if (element.Type == PostDataElementType.Bytes) - { - var body = element.GetBody(charSet); - } - } - } - } - } - - //Note to Redirect simply set the request Url - //if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase)) - //{ - // request.Url = "https://github.com/"; - //} - - //Callback in async fashion - //callback.Continue(true); - //return CefReturnValue.ContinueAsync; - } - } - - return CefReturnValue.Continue; - } + //public override CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) + //{ + // Uri url; + // if (Uri.TryCreate(request.Url, UriKind.Absolute, out url) == false) + // { + // //If we're unable to parse the Uri then cancel the request + // // avoid throwing any exceptions here as we're being called by unmanaged code + // return CefReturnValue.Cancel; + // } + + // //Example of how to set Referer + // // Same should work when setting any header + + // // For this example only set Referer when using our custom scheme + // if (url.Scheme == CefSharpSchemeHandlerFactory.SchemeName) + // { + // //Referrer is now set using it's own method (was previously set in headers before) + // request.SetReferrer("http://google.com", ReferrerPolicy.Default); + // } + + // //Example of setting User-Agent in every request. + // //var headers = request.Headers; + + // //var userAgent = headers["User-Agent"]; + // //headers["User-Agent"] = userAgent + " CefSharp"; + + // //request.Headers = headers; + + // //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. + // //callback.Dispose(); + // //return false; + + // //NOTE: When executing the callback in an async fashion need to check to see if it's disposed + // if (!callback.IsDisposed) + // { + // using (callback) + // { + // if (request.Method == "POST") + // { + // using (var postData = request.PostData) + // { + // if (postData != null) + // { + // var elements = postData.Elements; + + // var charSet = request.GetCharSet(); + + // foreach (var element in elements) + // { + // if (element.Type == PostDataElementType.Bytes) + // { + // var body = element.GetBody(charSet); + // } + // } + // } + // } + // } + + // //Note to Redirect simply set the request Url + // //if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase)) + // //{ + // // request.Url = "https://github.com/"; + // //} + + // //Callback in async fashion + // //callback.Continue(true); + // //return CefReturnValue.ContinueAsync; + // } + // } + + // return CefReturnValue.Continue; + //} public override bool GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback) { @@ -178,74 +177,74 @@ public override bool OnQuotaRequest(IWebBrowser browserControl, IBrowser browser return false; } - public override void OnResourceRedirect(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response, ref string newUrl) - { - //Example of how to redirect - need to check `newUrl` in the second pass - //if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase) && !newUrl.Contains("github")) - //{ - // newUrl = "https://github.com"; - //} - } + //public override void OnResourceRedirect(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response, ref string newUrl) + //{ + // //Example of how to redirect - need to check `newUrl` in the second pass + // //if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase) && !newUrl.Contains("github")) + // //{ + // // newUrl = "https://github.com"; + // //} + //} - public override bool OnProtocolExecution(IWebBrowser browserControl, IBrowser browser, string url) - { - return url.StartsWith("mailto"); - } + //public override bool OnProtocolExecution(IWebBrowser browserControl, IBrowser browser, string url) + //{ + // return url.StartsWith("mailto"); + //} public override void OnRenderViewReady(IWebBrowser browserControl, IBrowser browser) { } - public override bool OnResourceResponse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response) - { - //NOTE: You cannot modify the response, only the request - // You can now access the headers - //var headers = response.Headers; - - return false; - } - - public override IResponseFilter GetResourceResponseFilter(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response) - { - var url = new Uri(request.Url); - if (url.Scheme == CefSharpSchemeHandlerFactory.SchemeName) - { - if (request.Url.Equals(CefExample.ResponseFilterTestUrl, StringComparison.OrdinalIgnoreCase)) - { - return new FindReplaceResponseFilter("REPLACE_THIS_STRING", "This is the replaced string!"); - } - - if (request.Url.Equals("custom://cefsharp/assets/js/jquery.js", StringComparison.OrdinalIgnoreCase)) - { - return new AppendResponseFilter(System.Environment.NewLine + "//CefSharp Appended this comment."); - } - - //Only called for our customScheme - var dataFilter = new MemoryStreamResponseFilter(); - responseDictionary.Add(request.Identifier, dataFilter); - return dataFilter; - } - - //return new PassThruResponseFilter(); - return null; - } - - public override void OnResourceLoadComplete(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response, UrlRequestStatus status, long receivedContentLength) - { - var url = new Uri(request.Url); - if (url.Scheme == CefSharpSchemeHandlerFactory.SchemeName) - { - MemoryStreamResponseFilter filter; - if (responseDictionary.TryGetValue(request.Identifier, out filter)) - { - //TODO: Do something with the data here - var data = filter.Data; - var dataLength = filter.Data.Length; - //NOTE: You may need to use a different encoding depending on the request - var dataAsUtf8String = Encoding.UTF8.GetString(data); - } - } - } + //public override bool OnResourceResponse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response) + //{ + // //NOTE: You cannot modify the response, only the request + // // You can now access the headers + // //var headers = response.Headers; + + // return false; + //} + + //public override IResponseFilter GetResourceResponseFilter(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response) + //{ + // var url = new Uri(request.Url); + // if (url.Scheme == CefSharpSchemeHandlerFactory.SchemeName) + // { + // if (request.Url.Equals(CefExample.ResponseFilterTestUrl, StringComparison.OrdinalIgnoreCase)) + // { + // return new FindReplaceResponseFilter("REPLACE_THIS_STRING", "This is the replaced string!"); + // } + + // if (request.Url.Equals("custom://cefsharp/assets/js/jquery.js", StringComparison.OrdinalIgnoreCase)) + // { + // return new AppendResponseFilter(System.Environment.NewLine + "//CefSharp Appended this comment."); + // } + + // //Only called for our customScheme + // var dataFilter = new MemoryStreamResponseFilter(); + // responseDictionary.Add(request.Identifier, dataFilter); + // return dataFilter; + // } + + // //return new PassThruResponseFilter(); + // return null; + //} + + //public override void OnResourceLoadComplete(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response, UrlRequestStatus status, long receivedContentLength) + //{ + // var url = new Uri(request.Url); + // if (url.Scheme == CefSharpSchemeHandlerFactory.SchemeName) + // { + // MemoryStreamResponseFilter filter; + // if (responseDictionary.TryGetValue(request.Identifier, out filter)) + // { + // //TODO: Do something with the data here + // var data = filter.Data; + // var dataLength = filter.Data.Length; + // //NOTE: You may need to use a different encoding depending on the request + // var dataAsUtf8String = Encoding.UTF8.GetString(data); + // } + // } + //} } } diff --git a/CefSharp.Example/InMemorySchemeAndResourceHandlerFactory.cs b/CefSharp.Example/InMemorySchemeHandlerFactory.cs similarity index 62% rename from CefSharp.Example/InMemorySchemeAndResourceHandlerFactory.cs rename to CefSharp.Example/InMemorySchemeHandlerFactory.cs index a892a2e5df..667522f570 100644 --- a/CefSharp.Example/InMemorySchemeAndResourceHandlerFactory.cs +++ b/CefSharp.Example/InMemorySchemeHandlerFactory.cs @@ -10,18 +10,18 @@ namespace CefSharp.Example { /// - /// Demo ISchemeHandlerFactory and IResourceHandlerFactory, reads that from resource in memory, could just + /// Demo ISchemeHandlerFactory reads that from resource in memory, could just /// as easily be from files on disk - only use this method if you already have pre loaded data, don't perform /// any web requests here or database lookups, best for static data only. /// - public class InMemorySchemeAndResourceHandlerFactory : ISchemeHandlerFactory, IResourceHandlerFactory + public class InMemorySchemeHandlerFactory : ISchemeHandlerFactory { /// /// Just a simple dictionary for resource lookup /// private static readonly IDictionary ResourceDictionary; - static InMemorySchemeAndResourceHandlerFactory() + static InMemorySchemeHandlerFactory() { ResourceDictionary = new Dictionary { @@ -81,46 +81,5 @@ IResourceHandler ISchemeHandlerFactory.Create(IBrowser browser, IFrame frame, st return null; } - - /// - /// This is typically required for the internal implementation and is here for performance reasons, - /// in general you'd just return true - /// - bool IResourceHandlerFactory.HasHandlers - { - get { return true; } - } - - /// - /// The main method when implementing an IResourceHandlerFactory, use for standard schemes like http/https - /// - /// the ChromiumWebBrowser instance this handler is assocated with - /// browser - /// frame - /// request, we'll use this to check the Url and load the appropriate resource - /// - /// return null to invoke the default behaviour, this is important when you want to only intercept a few specific requests - /// if we have a string that represents our resource in the lookup dictionary then return it as an IResourceHandler - /// - IResourceHandler IResourceHandlerFactory.GetResourceHandler(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request) - { - var uri = new Uri(request.Url); - //Compare scheme and host - if (string.Equals(uri.Scheme, "http", StringComparison.OrdinalIgnoreCase) && string.Equals(uri.Host, "cefsharp", StringComparison.OrdinalIgnoreCase)) - { - var fileName = uri.AbsolutePath; - var extension = Path.GetExtension(fileName); - - string resource; - if (ResourceDictionary.TryGetValue(fileName, out resource) && !string.IsNullOrEmpty(resource)) - { - //For css/js/etc it's important to specify a mime/type, here we use the file extension to perform a lookup - //there are overloads where you can specify more options including Encoding, mimeType - return ResourceHandler.FromString(resource, extension); - } - } - - return null; - } } } diff --git a/CefSharp.Example/RequestEventHandler/RequestEventHandler.cs b/CefSharp.Example/RequestEventHandler/RequestEventHandler.cs index 632d3f4940..cb69f2609e 100644 --- a/CefSharp.Example/RequestEventHandler/RequestEventHandler.cs +++ b/CefSharp.Example/RequestEventHandler/RequestEventHandler.cs @@ -75,15 +75,15 @@ void IRequestHandler.OnPluginCrashed(IWebBrowser browserControl, IBrowser browse OnPluginCrashedEvent?.Invoke(this, args); } - CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) - { - var args = new OnBeforeResourceLoadEventArgs(browserControl, browser, frame, request, callback); + //CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) + //{ + // var args = new OnBeforeResourceLoadEventArgs(browserControl, browser, frame, request, callback); - OnBeforeResourceLoadEvent?.Invoke(this, args); + // OnBeforeResourceLoadEvent?.Invoke(this, args); - EnsureCallbackDisposal(callback); - return args.ContinuationHandling; - } + // EnsureCallbackDisposal(callback); + // return args.ContinuationHandling; + //} bool IRequestHandler.GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback) { @@ -102,23 +102,23 @@ void IRequestHandler.OnRenderProcessTerminated(IWebBrowser browserControl, IBrow OnRenderProcessTerminatedEvent?.Invoke(this, args); } - bool IRequestHandler.CanGetCookies(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request) - { - var args = new CanGetCookiesEventArg(browserControl, browser, frame, request); + //bool IRequestHandler.CanGetCookies(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request) + //{ + // var args = new CanGetCookiesEventArg(browserControl, browser, frame, request); - CanGetCookiesEvent?.Invoke(this, args); + // CanGetCookiesEvent?.Invoke(this, args); - return args.GetCookies; - } + // return args.GetCookies; + //} - bool IRequestHandler.CanSetCookie(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, Cookie cookie) - { - var args = new CanSetCookieEventArg(browserControl, browser, frame, request, cookie); + //bool IRequestHandler.CanSetCookie(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, Cookie cookie) + //{ + // var args = new CanSetCookieEventArg(browserControl, browser, frame, request, cookie); - CanSetCookieEvent?.Invoke(this, args); + // CanSetCookieEvent?.Invoke(this, args); - return args.SetCookie; - } + // return args.SetCookie; + //} bool IRequestHandler.OnQuotaRequest(IWebBrowser browserControl, IBrowser browser, string originUrl, long newSize, IRequestCallback callback) { @@ -129,22 +129,22 @@ bool IRequestHandler.OnQuotaRequest(IWebBrowser browserControl, IBrowser browser return args.ContinueAsync; } - void IRequestHandler.OnResourceRedirect(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response, ref string newUrl) - { - var args = new OnResourceRedirectEventArgs(browserControl, browser, frame, request, response, newUrl); - OnResourceRedirectEvent?.Invoke(this, args); - if (!Equals(newUrl, args.NewUrl)) - { - newUrl = args.NewUrl; - } - } + //void IRequestHandler.OnResourceRedirect(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response, ref string newUrl) + //{ + // var args = new OnResourceRedirectEventArgs(browserControl, browser, frame, request, response, newUrl); + // OnResourceRedirectEvent?.Invoke(this, args); + // if (!Equals(newUrl, args.NewUrl)) + // { + // newUrl = args.NewUrl; + // } + //} - bool IRequestHandler.OnProtocolExecution(IWebBrowser browserControl, IBrowser browser, string url) - { - var args = new OnProtocolExecutionEventArgs(browserControl, browser, url); - OnProtocolExecutionEvent?.Invoke(this, args); - return args.AttemptExecution; - } + //bool IRequestHandler.OnProtocolExecution(IWebBrowser browserControl, IBrowser browser, string url) + //{ + // var args = new OnProtocolExecutionEventArgs(browserControl, browser, url); + // OnProtocolExecutionEvent?.Invoke(this, args); + // return args.AttemptExecution; + //} void IRequestHandler.OnRenderViewReady(IWebBrowser browserControl, IBrowser browser) { @@ -152,26 +152,26 @@ void IRequestHandler.OnRenderViewReady(IWebBrowser browserControl, IBrowser brow OnRenderViewReadyEvent?.Invoke(this, args); } - bool IRequestHandler.OnResourceResponse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response) - { - var args = new OnResourceResponseEventArgs(browserControl, browser, frame, request, response); - OnResourceResponseEvent?.Invoke(this, args); - return args.RedirectOrRetry; - } + //bool IRequestHandler.OnResourceResponse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response) + //{ + // var args = new OnResourceResponseEventArgs(browserControl, browser, frame, request, response); + // OnResourceResponseEvent?.Invoke(this, args); + // return args.RedirectOrRetry; + //} - IResponseFilter IRequestHandler.GetResourceResponseFilter(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response) - { - var args = new GetResourceResponseFilterEventArgs(browserControl, browser, frame, request, response); - GetResourceResponseFilterEvent?.Invoke(this, args); - return args.ResponseFilter; - } + //IResponseFilter IRequestHandler.GetResourceResponseFilter(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response) + //{ + // var args = new GetResourceResponseFilterEventArgs(browserControl, browser, frame, request, response); + // GetResourceResponseFilterEvent?.Invoke(this, args); + // return args.ResponseFilter; + //} - void IRequestHandler.OnResourceLoadComplete(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response, UrlRequestStatus status, long receivedContentLength) - { - var args = new OnResourceLoadCompleteEventArgs(browserControl, browser, frame, request, response, status, receivedContentLength); + //void IRequestHandler.OnResourceLoadComplete(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response, UrlRequestStatus status, long receivedContentLength) + //{ + // var args = new OnResourceLoadCompleteEventArgs(browserControl, browser, frame, request, response, status, receivedContentLength); - OnResourceLoadCompleteEvent?.Invoke(this, args); - } + // OnResourceLoadCompleteEvent?.Invoke(this, args); + //} bool IRequestHandler.OnSelectClientCertificate(IWebBrowser browserControl, IBrowser browser, bool isProxy, string host, int port, X509Certificate2Collection certificates, ISelectClientCertificateCallback callback) { @@ -194,5 +194,10 @@ private static void EnsureCallbackDisposal(IAuthCallback callbackToDispose) callbackToDispose.Dispose(); } } + + IResourceRequestHandler IRequestHandler.GetResourceRequestHandler(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, bool iNavigation, bool isDownload, string requestInitiator, ref bool disableDefaultHandling) + { + return null; + } } } diff --git a/CefSharp.Example/Resources/BindingTestSingle.html b/CefSharp.Example/Resources/BindingTestSingle.html index 7499863105..5160431aaa 100644 --- a/CefSharp.Example/Resources/BindingTestSingle.html +++ b/CefSharp.Example/Resources/BindingTestSingle.html @@ -5,11 +5,6 @@ -
- These tests require CefSharpSettings.ConcurrentTaskExecution = true; - Which by default is set to false -
-
@@ -19,43 +14,15 @@ { await CefSharp.BindObjectAsync("boundAsync"); - QUnit.test("ReturnTaskStringAsync:", function (assert) - { - let asyncCallback = assert.async(); - - boundAsync.returnTaskStringAsync().then(function (actualResult) - { - const expectedResult = 'ReturnTaskStringAsync'; - - assert.equal(expectedResult, actualResult, "Return string " + expectedResult); - - asyncCallback(); - }); - }); - - QUnit.test("VoidReturnAsync Test:", function (assert) + QUnit.test("Async call (Divide 16 / 2):", function (assert) { - let asyncCallback = assert.async(); + var asyncCallback = assert.async(); - boundAsync.voidReturnAsync().then(function (actualResult) + boundAsync.div(16, 2).then(function (actualResult) { - const expectedResult = null; + const expectedResult = 8 - assert.equal(expectedResult, actualResult, "Return null"); - - asyncCallback(); - }); - }); - - QUnit.test("AsyncWaitTwoSeconds Test:", function (assert) - { - let asyncCallback = assert.async(); - - const expectedResult = "This method waited two seconds"; - - boundAsync.asyncWaitTwoSeconds(expectedResult).then(function (actualResult) - { - assert.equal(expectedResult, actualResult, "Return string " + expectedResult); + assert.equal(expectedResult, actualResult, "Divide 16 / 2 resulted in " + expectedResult); asyncCallback(); }); diff --git a/CefSharp.OffScreen.Example/CefSharp.OffScreen.Example.csproj b/CefSharp.OffScreen.Example/CefSharp.OffScreen.Example.csproj index e765bcc086..d81e669eb3 100644 --- a/CefSharp.OffScreen.Example/CefSharp.OffScreen.Example.csproj +++ b/CefSharp.OffScreen.Example/CefSharp.OffScreen.Example.csproj @@ -1,7 +1,7 @@  - - + + diff --git a/CefSharp.OffScreen.Example/app.manifest b/CefSharp.OffScreen.Example/app.manifest index 3fae1d99c6..b72f4f9543 100644 --- a/CefSharp.OffScreen.Example/app.manifest +++ b/CefSharp.OffScreen.Example/app.manifest @@ -7,7 +7,7 @@ xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - + diff --git a/CefSharp.OffScreen.Example/packages.config b/CefSharp.OffScreen.Example/packages.config index 75bf7d42e6..293594aded 100644 --- a/CefSharp.OffScreen.Example/packages.config +++ b/CefSharp.OffScreen.Example/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/CefSharp.OffScreen/ChromiumWebBrowser.cs b/CefSharp.OffScreen/ChromiumWebBrowser.cs index 0eeb3fd69a..99bf6bc005 100644 --- a/CefSharp.OffScreen/ChromiumWebBrowser.cs +++ b/CefSharp.OffScreen/ChromiumWebBrowser.cs @@ -169,10 +169,10 @@ public bool IsDisposed /// The drag handler. public IDragHandler DragHandler { get; set; } /// - /// Implement and control the loading of resources + /// Implement and control the loading of resources /// /// The resource handler factory. - public IResourceHandlerFactory ResourceHandlerFactory { get; set; } + public IResourceRequestHandlerFactory ResourceRequestHandlerFactory { get; set; } /// /// Implement and assign to handle messages from the render process. /// @@ -312,7 +312,6 @@ public ChromiumWebBrowser(string address = "", BrowserSettings browserSettings = } } - ResourceHandlerFactory = new DefaultResourceHandlerFactory(); RequestContext = requestContext; Cef.AddDisposable(this); diff --git a/CefSharp.Test/CefSharp.Test.csproj b/CefSharp.Test/CefSharp.Test.csproj index 826f7df851..8ae1aa116b 100644 --- a/CefSharp.Test/CefSharp.Test.csproj +++ b/CefSharp.Test/CefSharp.Test.csproj @@ -1,7 +1,7 @@  - - + + Debug diff --git a/CefSharp.Test/packages.config b/CefSharp.Test/packages.config index d65b9cc089..1a32c19937 100644 --- a/CefSharp.Test/packages.config +++ b/CefSharp.Test/packages.config @@ -1,8 +1,8 @@  - - + + diff --git a/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj b/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj index b2380319de..6484672700 100644 --- a/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj +++ b/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj @@ -1,7 +1,7 @@  - - + + Debug diff --git a/CefSharp.WinForms.Example/app.manifest b/CefSharp.WinForms.Example/app.manifest index c492c09432..8fc9da82b3 100644 --- a/CefSharp.WinForms.Example/app.manifest +++ b/CefSharp.WinForms.Example/app.manifest @@ -8,7 +8,7 @@ xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - + diff --git a/CefSharp.WinForms.Example/packages.config b/CefSharp.WinForms.Example/packages.config index 75bf7d42e6..293594aded 100644 --- a/CefSharp.WinForms.Example/packages.config +++ b/CefSharp.WinForms.Example/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/CefSharp.WinForms/ChromiumWebBrowser.cs b/CefSharp.WinForms/ChromiumWebBrowser.cs index 33fdcb021c..ebe2cb6966 100644 --- a/CefSharp.WinForms/ChromiumWebBrowser.cs +++ b/CefSharp.WinForms/ChromiumWebBrowser.cs @@ -251,11 +251,11 @@ public IRequestContext RequestContext [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), DefaultValue(null)] public IDragHandler DragHandler { get; set; } /// - /// Implement and control the loading of resources + /// Implement and control the loading of resources /// /// The resource handler factory. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), DefaultValue(null)] - public IResourceHandlerFactory ResourceHandlerFactory { get; set; } + public IResourceRequestHandlerFactory ResourceRequestHandlerFactory { get; set; } /// /// Event handler that will get called when the resource load for a navigation fails or is canceled. @@ -450,11 +450,6 @@ private void InitializeFieldsAndCefIfRequired() FocusHandler = new DefaultFocusHandler(); } - if (ResourceHandlerFactory == null) - { - ResourceHandlerFactory = new DefaultResourceHandlerFactory(); - } - if (browserSettings == null) { browserSettings = new BrowserSettings(frameworkCreated: true); diff --git a/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj b/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj index b9c68d0d0d..231d04e095 100644 --- a/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj +++ b/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj @@ -1,7 +1,7 @@  - - + + Debug diff --git a/CefSharp.Wpf.Example/Handlers/DragHandler.cs b/CefSharp.Wpf.Example/Handlers/DragHandler.cs index ffcb5d6500..6d143acf17 100644 --- a/CefSharp.Wpf.Example/Handlers/DragHandler.cs +++ b/CefSharp.Wpf.Example/Handlers/DragHandler.cs @@ -18,7 +18,7 @@ bool IDragHandler.OnDragEnter(IWebBrowser browserControl, IBrowser browser, IDra return false; } - void IDragHandler.OnDraggableRegionsChanged(IWebBrowser browserControl, IBrowser browser, IList regions) + void IDragHandler.OnDraggableRegionsChanged(IWebBrowser browserControl, IBrowser browser, IFrame frame, IList regions) { //By default popup browers are native windows in WPF so we cannot handle their drag using this method if (browser.IsPopup == false) diff --git a/CefSharp.Wpf.Example/Handlers/RequestContextHandler.cs b/CefSharp.Wpf.Example/Handlers/RequestContextHandler.cs index 358552b0fc..d268ad377a 100644 --- a/CefSharp.Wpf.Example/Handlers/RequestContextHandler.cs +++ b/CefSharp.Wpf.Example/Handlers/RequestContextHandler.cs @@ -6,7 +6,12 @@ namespace CefSharp.Wpf.Example.Handlers { public class RequestContextHandler : IRequestContextHandler { - private ICookieManager customCookieManager; + private readonly ICookieManager customCookieManager; + + IResourceRequestHandler IRequestContextHandler.GetResourceRequestHandler(IBrowser browser, IFrame frame, IRequest request, bool iNavigation, bool isDownload, string requestInitiator, ref bool disableDefaultHandling) + { + return null; + } bool IRequestContextHandler.OnBeforePluginLoad(string mimeType, string url, bool isMainFrame, string topOriginUrl, WebPluginInfo pluginInfo, ref PluginPolicy pluginPolicy) { @@ -16,28 +21,6 @@ bool IRequestContextHandler.OnBeforePluginLoad(string mimeType, string url, bool return false; } - ICookieManager IRequestContextHandler.GetCookieManager() - { - if (customCookieManager == null) - { - //In memory cookie manager - //customCookieManager = new CookieManager(null, persistSessionCookies: false, callback: null); - - //Store cookies in cookies directory (user must have write permission to this folder) - customCookieManager = new CookieManager("cookies", persistSessionCookies: false, callback: null); - } - - return customCookieManager; - - //NOTE: DO NOT RETURN A NEW COOKIE MANAGER EVERY TIME - //This method will be called many times, you should return the same cookie manager within the scope - //of the RequestContext (unless you REALLY know what your doing) - //return new CookieManager("cookies", persistSessionCookies: false, callback: null); - - //Default to using the Global cookieManager (default) - //return null; - } - void IRequestContextHandler.OnRequestContextInitialized(IRequestContext requestContext) { //You can set preferences here on your newly initialized request context. diff --git a/CefSharp.Wpf.Example/app.manifest b/CefSharp.Wpf.Example/app.manifest index 408bb13a74..6880726e0c 100644 --- a/CefSharp.Wpf.Example/app.manifest +++ b/CefSharp.Wpf.Example/app.manifest @@ -7,7 +7,7 @@ xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - + diff --git a/CefSharp.Wpf.Example/packages.config b/CefSharp.Wpf.Example/packages.config index aa9488d1a2..4d28ad7787 100644 --- a/CefSharp.Wpf.Example/packages.config +++ b/CefSharp.Wpf.Example/packages.config @@ -1,7 +1,7 @@  - - + + diff --git a/CefSharp.Wpf/ChromiumWebBrowser.cs b/CefSharp.Wpf/ChromiumWebBrowser.cs index b90896c868..b4c2f8d8b9 100644 --- a/CefSharp.Wpf/ChromiumWebBrowser.cs +++ b/CefSharp.Wpf/ChromiumWebBrowser.cs @@ -250,10 +250,10 @@ public IRequestContext RequestContext /// The drag handler. public IDragHandler DragHandler { get; set; } /// - /// Implement and control the loading of resources + /// Implement and control the loading of resources /// /// The resource handler factory. - public IResourceHandlerFactory ResourceHandlerFactory { get; set; } + public IResourceRequestHandlerFactory ResourceRequestHandlerFactory { get; set; } /// /// Implement and control how the control is rendered /// @@ -564,7 +564,6 @@ private void NoInliningConstructor() managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this, true); - ResourceHandlerFactory = new DefaultResourceHandlerFactory(); browserSettings = new BrowserSettings(frameworkCreated: true); RenderHandler = new InteropBitmapRenderHandler(); diff --git a/CefSharp.shfbproj b/CefSharp.shfbproj index cd459011ca..65da09def8 100644 --- a/CefSharp.shfbproj +++ b/CefSharp.shfbproj @@ -31,7 +31,7 @@ - 74.1.130 + 75.0.30 2 False C#, Managed C++ @@ -57,7 +57,7 @@ InheritedMembers, InheritedFrameworkMembers, Protected, ProtectedInternalAsProtected, EditorBrowsableNever, NonBrowsable - Version 74.1.130 + Version 75.0.30 https://raw.githubusercontent.com/cefsharp/CefSharp/master/LICENSE Interfaces, enums, structs and classes that make up the core API interface diff --git a/CefSharp/CefCustomScheme.cs b/CefSharp/CefCustomScheme.cs index bb9c1828da..bbc47f9eba 100644 --- a/CefSharp/CefCustomScheme.cs +++ b/CefSharp/CefCustomScheme.cs @@ -10,8 +10,11 @@ namespace CefSharp { /// /// Used in conjunction with CefSettings.RegisterScheme to register a scheme. - /// You can register your own custom scheme e.g. custom:// or use an existing - /// scheme e.g. http:// + /// You can register your own custom scheme e.g. custom:// if you are using a build in scheme + /// (http/https) then you should directly register your using + /// Cef.GetGlobalRequestContext().RegisterSchemeHandlerFactory - make sure the Global RequestContext has + /// been initialized before doing so, you can use + /// for notification of RequestContext initialization (Pass an IBrowserProcessHandler instance to Cef.Initialize) /// public sealed class CefCustomScheme { diff --git a/CefSharp/CefSharp.csproj b/CefSharp/CefSharp.csproj index e244b3f8ac..45ce8fe208 100644 --- a/CefSharp/CefSharp.csproj +++ b/CefSharp/CefSharp.csproj @@ -98,6 +98,8 @@ + + @@ -114,11 +116,15 @@ + + + + @@ -126,8 +132,6 @@ - - @@ -235,7 +239,6 @@ - @@ -248,7 +251,6 @@ - @@ -264,7 +266,6 @@ - @@ -311,7 +312,9 @@ - + + +