-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: allow defining RequestContext preferences #4
base: master
Are you sure you want to change the base?
Conversation
d9e5da9
to
b0ab809
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR
👍
In future I'd ask that you perform your own review before submitting your Pull Request
.
Make sure code formatting is consistent with current formatting, remove any formatting only or unrelated code changes (there are multiple in this case).
In terms of functionality it looks like you've only added to the WPF
implementation, The WinForms
implementation should also be updated to support the same functionality (no mention of this being WPF
only in your comments or title).
@@ -44,7 +44,7 @@ protected override void Dispose(bool disposing) | |||
{ | |||
base.Dispose(disposing); | |||
|
|||
if(disposing) | |||
if (disposing) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In future please avoid formatting only changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forgot to disable the autoformatter, pardon, should now be cleaned, i resolved all other formatting comments and left this one open for you to confirm it's ok now
/// Modify Global RequestContext-Preferences | ||
/// </summary> | ||
/// /// <param name="requestContextPreferences">Request Context Preferences to set.</param> | ||
void UpdateGlobalRequestContextPreferences(IDictionary<string, object> requestContextPreferences); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the use case for this method exactly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't have one atm, just added it because CEF allows setting global requestContext preferences.
should i remove it?
/// </summary> | ||
/// <param name="browserId">browser id</param> | ||
/// <param name="requestContextPreferences">Request Context Preferences to set.</param> | ||
void UpdateRequestContextPreferences(int browserId, IDictionary<string, object> requestContextPreferences); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename method to SetRequestContextPreferences
so it matches RequestContext.SetPreference
naming.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
{ | ||
foreach (KeyValuePair<string, object> pref in preferences) | ||
{ | ||
requestContext?.SetPreference(pref.Key, pref.Value, out _); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no point looping through all the kvps in the dict if the request context is null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i removed the null-conditional operator, because the "is"-clause makes sure we only proceed with a non-null requestContext
IRequestContext requestContext = null; | ||
if (requestContextPreferences != null) | ||
{ | ||
requestContext = new RequestContext(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assigning a new RequestContext
here dramatically changes the behaviour, you've not provided any way to manage the RequestContextSettings
, so you'll always end up with an in memory cache.
This needs a rethink.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it use the previous configured cefsettings if i use the globalrequestcontext values?
and therefore use the cachePath set there
0ecbeb9
to
87ca41d
Compare
87ca41d
to
1ff7d8a
Compare
Thanks for your reply. Excuse my first attempt, i didn't expect such a fast response and should have opened it as a draft first. Awaiting your thoughts with Best Regards |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments inline
@@ -35,8 +36,22 @@ public interface IOutOfProcessClientRpc | |||
/// <param name="parentHwnd">parent Hwnd</param> | |||
/// <param name="url">start url</param> | |||
/// <param name="browserId">browser id</param> | |||
/// <param name="requestContextPreferences">Request Context Preferences to set.</param> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment needs to be updated to describe the actual behaviour, a new RequestContext
sharing the same settings as the Global
.
@@ -85,11 +86,12 @@ public string ChromiumVersion | |||
/// <param name="handle">handle used to host the control</param> | |||
/// <param name="url"></param> | |||
/// <param name="id"></param> | |||
/// <param name="requestContextPreferences">request context preference.</param> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment needs to be updated to describe the actual behaviour, a new RequestContext
sharing the same settings as the Global
.
@@ -64,13 +70,15 @@ public class ChromiumWebBrowser : Control, IChromiumWebBrowserInternal | |||
/// </summary> | |||
/// <param name="host">Out of process host</param> | |||
/// <param name="initialAddress">address that will be initially loaded in the browser</param> | |||
public ChromiumWebBrowser(OutOfProcessHost host, string initialAddress) | |||
/// <param name="requestContextPreferences">requestContextPreferences to set</param> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment needs to be updated to describe the actual behaviour, a new RequestContext
sharing the same settings as the Global
.
@@ -279,13 +285,15 @@ public bool IsDisposed | |||
/// </summary> | |||
/// <param name="host">Out of process host</param> | |||
/// <param name="initialAddress">address to load initially</param> | |||
public ChromiumWebBrowser(OutOfProcessHost host, string initialAddress = null) | |||
/// <param name="requestContextPreferences">requestContextPreferences to set</param> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment needs to be updated to describe the actual behaviour, a new RequestContext
sharing the same settings as the Global
.
/// </summary> | ||
/// <param name="browserId">browser id</param> | ||
/// <param name="requestContextPreferences">Request Context Preferences to set.</param> | ||
void SetRequestContextPreferences(int browserId, IDictionary<string, object> requestContextPreferences); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How often do you need to set multiple preferences at once? If I'm honest I don't love this. There's no error reporting, absolutely no idea if the preferences were set.
Personally I'd prefer to see something like the following where you get the bool and error string returned from the SetPreference
call.
Task<SetRequestContextPreferenceResponse> SetRequestContextPreferenceAsync(int browserId, string name, object value);
Thanks for your great work.
For our case we would like to set some RequestContext properties for our browser instances.
We have the feeling others could use that feature too and would be happy to share if you agree.
It would be great if you could review it and if it meets your standards merge it.
If you have any suggestions, let us know so we can improve this PR.
Best Regards