From d9e84a5a10aa77d4d628c8990edaffca0d111317 Mon Sep 17 00:00:00 2001 From: rassilon Date: Mon, 23 Feb 2015 22:25:41 -0500 Subject: [PATCH 1/2] Expose Cross-Origin Whitelist from Cef.XXX as static methods. --- CefSharp.Core/Cef.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/CefSharp.Core/Cef.h b/CefSharp.Core/Cef.h index 329d01328..b3e335d8d 100644 --- a/CefSharp.Core/Cef.h +++ b/CefSharp.Core/Cef.h @@ -7,6 +7,7 @@ #include #include #include +#include #include "Internals/CefSharpApp.h" #include "Internals/CookieVisitor.h" @@ -168,6 +169,49 @@ namespace CefSharp return success; } + /// + // See documentation in cef_origin_whitelist.h + /// + /*--cef(optional_param=target_domain)--*/ + static bool AddCrossOriginWhitelistEntry(String^ source_origin, + String^ target_protocol, + String^ target_domain, + bool allow_target_subdomains) + { + return CefAddCrossOriginWhitelistEntry( + StringUtils::ToNative(source_origin), + StringUtils::ToNative(target_protocol), + StringUtils::ToNative(target_domain), + allow_target_subdomains); + } + + /// + // Remove an entry from the cross-origin access whitelist. Returns false if + // |source_origin| is invalid or the whitelist cannot be accessed. + /// + /*--cef(optional_param=target_domain)--*/ + static bool RemoveCrossOriginWhitelistEntry(String^ source_origin, + String^ target_protocol, + String^ target_domain, + bool allow_target_subdomains) + { + return CefRemoveCrossOriginWhitelistEntry( + StringUtils::ToNative(source_origin), + StringUtils::ToNative(target_protocol), + StringUtils::ToNative(target_domain), + allow_target_subdomains); + } + + /// + // Remove all entries from the cross-origin access whitelist. Returns false if + // the whitelist cannot be accessed. + /// + /*--cef()--*/ + static bool ClearCrossOriginWhitelist() + { + return CefClearCrossOriginWhitelist(); + } + /// Visits all cookies using the provided Cookie Visitor. The returned cookies are sorted by longest path, then by earliest creation date. /// A user-provided Cookie Visitor implementation. /// Returns false if the CookieManager is not available; otherwise, true. From e582c6cf8e433941ec771ecf0658a4dd3114ad42 Mon Sep 17 00:00:00 2001 From: rassilon Date: Mon, 23 Feb 2015 23:13:00 -0500 Subject: [PATCH 2/2] Adjust parameter names and reformat CEF docs to .net notation. --- CefSharp.Core/Cef.h | 103 +++++++++++++++++++++++++++++++------------- 1 file changed, 74 insertions(+), 29 deletions(-) diff --git a/CefSharp.Core/Cef.h b/CefSharp.Core/Cef.h index b3e335d8d..d5ff05a07 100644 --- a/CefSharp.Core/Cef.h +++ b/CefSharp.Core/Cef.h @@ -169,44 +169,89 @@ namespace CefSharp return success; } + /// Add an entry to the cross-origin whitelist. + /// The origin allowed to be accessed by the target protocol/domain. + /// The target protocol allowed to access the source origin. + /// The optional target domain allowed to access the source origin. + /// If set to true would allow a blah.example.com if the + /// URL (like http://www.example.com) will be allowed access to + /// all resources hosted on the specified and . + /// If is non-empty and if false only + /// exact domain matches will be allowed. If contains a top- + /// level domain component (like "example.com") and is + /// true sub-domain matches will be allowed. If is empty and + /// "/> if true all domains and IP addresses will be + /// allowed. + // + /// This method cannot be used to bypass the restrictions on local or display + /// isolated schemes. See the comments on for more + /// information. /// - // See documentation in cef_origin_whitelist.h - /// - /*--cef(optional_param=target_domain)--*/ - static bool AddCrossOriginWhitelistEntry(String^ source_origin, - String^ target_protocol, - String^ target_domain, - bool allow_target_subdomains) + /// This function may be called on any thread. Returns false if + /// is invalid or the whitelist cannot be accessed. + /// + static bool AddCrossOriginWhitelistEntry( + String^ sourceOrigin, + String^ targetProtocol, + String^ targetDomain, + bool allowTargetSubdomains) { return CefAddCrossOriginWhitelistEntry( - StringUtils::ToNative(source_origin), - StringUtils::ToNative(target_protocol), - StringUtils::ToNative(target_domain), - allow_target_subdomains); + StringUtils::ToNative(sourceOrigin), + StringUtils::ToNative(targetProtocol), + StringUtils::ToNative(targetDomain), + allowTargetSubdomains); } - /// - // Remove an entry from the cross-origin access whitelist. Returns false if - // |source_origin| is invalid or the whitelist cannot be accessed. - /// - /*--cef(optional_param=target_domain)--*/ - static bool RemoveCrossOriginWhitelistEntry(String^ source_origin, - String^ target_protocol, - String^ target_domain, - bool allow_target_subdomains) + /// Remove entry from cross-origin whitelist + /// The origin allowed to be accessed by the target protocol/domain. + /// The target protocol allowed to access the source origin. + /// The optional target domain allowed to access the source origin. + /// If set to true would allow a blah.example.com if the + /// is invalid or the whitelist cannot be accessed. + /// + static bool RemoveCrossOriginWhitelistEntry(String^ sourceOrigin, + String^ targetProtocol, + String^ targetDomain, + bool allowTargetSubdomains) + { return CefRemoveCrossOriginWhitelistEntry( - StringUtils::ToNative(source_origin), - StringUtils::ToNative(target_protocol), - StringUtils::ToNative(target_domain), - allow_target_subdomains); + StringUtils::ToNative(sourceOrigin), + StringUtils::ToNative(targetProtocol), + StringUtils::ToNative(targetDomain), + allowTargetSubdomains); } - /// - // Remove all entries from the cross-origin access whitelist. Returns false if - // the whitelist cannot be accessed. - /// - /*--cef()--*/ + /// Remove all entries from the cross-origin access whitelist. + /// + /// Remove all entries from the cross-origin access whitelist. Returns false if + /// the whitelist cannot be accessed. + /// static bool ClearCrossOriginWhitelist() { return CefClearCrossOriginWhitelist();