Skip to content

Made it possible to register a "one-time use" ResourceHandler - #2010

Merged
amaitland merged 2 commits into
cefsharp:masterfrom
merceyz:pr30
Apr 10, 2017
Merged

amaitland merged 2 commits into
cefsharp:masterfrom
merceyz:pr30

Conversation

@merceyz

@merceyz merceyz commented Apr 7, 2017

Copy link
Copy Markdown
Member
  • Added a ResourceFactoryItem class
  • Added a overload to RegisterHandler that takes a bool representing whether or not the handler should be used only once
  • Made GetResourceHandler remove the ResourceFactoryItem if it was specified as a one-time use handler
  • Made LoadHtml register a one-time use handler

@amaitland
amaitland merged commit d03e4a4 into cefsharp:master Apr 10, 2017
amaitland added a commit that referenced this pull request Apr 10, 2017
ResourceFactoryItem renamed to DefaultResourceHandlerFactory - it's only used in the context of that class
Change persist to OneTimeUse and invert logic (false is the default)
Remove unnecessary RegisterHandler overload - user default value instead
@amaitland

Copy link
Copy Markdown
Member

Follow up commit is d03e4a4

Are you in a hurry to see this merged into cefsharp/57?

/// <param name="url">url</param>
/// <param name="handler">handler</param>
/// <returns>returns true if the Url was successfully parsed into a Uri otherwise false</returns>
public virtual bool RegisterHandler(string url, IResourceHandler handler)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed unnecessary overload, can use a default value instead.


namespace CefSharp
{
public class ResourceFactoryItem

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed class, as it's only used in the context of DefaultResourceHandlerFactory.

@amaitland

Copy link
Copy Markdown
Member

Marking this as breaking-change, DefaultResourceHandlerFactory.Handlers was publicly accessible, and it's changed type. It's unlikely anyone was using it directly, it was however possible.

}

if (resourceHandler.RegisterHandler(url, ResourceHandler.FromString(html, encoding, true)))
if (resourceHandler.RegisterHandler(url, ResourceHandler.FromString(html, encoding, true), false))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whilst this change makes sense it is however a subtle change in behavior and could potentially bring some existing users unstuck. There's now a oneTimeUse param with a default value as part of LoadHtml.

@merceyz

merceyz commented Apr 10, 2017

Copy link
Copy Markdown
Member Author

Are you in a hurry to see this merged into cefsharp/57?

I build CefSharp from master so that's all up to you ๐Ÿ‘

@merceyz merceyz added this to the 59.0.0 milestone Apr 12, 2017
@amaitland amaitland modified the milestones: 59.0.0, 62.0.0 Dec 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants