Skip to content
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

Expanded proxy support, made it easier to set proxy settings #2007

Merged
merged 8 commits into from
Apr 12, 2017
Merged

Expanded proxy support, made it easier to set proxy settings #2007

merged 8 commits into from
Apr 12, 2017

Conversation

merceyz
Copy link
Member

@merceyz merceyz commented Apr 5, 2017

  • Added a ProxyOptions class
  • Added a CefSettings.Proxy property
  • Made ClientAdapter::GetAuthCredentials take care of the authentication for the proxy

@amaitland
Copy link
Member

Will look at this sometime next week 👍

Copy link
Member

@amaitland amaitland left a comment

Choose a reason for hiding this comment

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

Comments made inline, feedback welcome.

/// <param name="username">The username required for authentication</param>
/// <param name="password">The password required for authentication</param>
/// <param name="bypassList">The list of domains that shouldn't be affected by the proxy, Format: example.com;example2.com</param>
public ProxyOptions(string ip, string port, string username, string password, string bypassList)
Copy link
Member

Choose a reason for hiding this comment

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

Can we just use default values and get rid of the overloads?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -732,6 +733,16 @@ namespace CefSharp
bool ClientAdapter::GetAuthCredentials(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, bool isProxy,
const CefString& host, int port, const CefString& realm, const CefString& scheme, CefRefPtr<CefAuthCallback> callback)
{
if (isProxy && Cef::proxyOptions != nullptr && Cef::proxyOptions->IP == StringUtils::ToClr(host) && !String::IsNullOrEmpty(Cef::proxyOptions->Username)
Copy link
Member

Choose a reason for hiding this comment

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

What if you wanted to provide a different username and password after you've initialized CEF?

I'd rather not having additional code here, specially that adds a new behavior.

It probably makes more sense to provide a default implementation of IRequestHandler that contains this logic. (If we do go down that path, probably should add default implementations for all the handlers.)

Copy link
Member Author

@merceyz merceyz Apr 10, 2017

Choose a reason for hiding this comment

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

What if you wanted to provide a different username and password after you've initialized CEF?

That's now possible by doing CefSharpSettings.Proxy.Username = "x" and CefSharpSettings.Proxy.Password = "y"

I don't quite agree with you, I'm hoping this can stay as is so that anyone using the IRequestHandler doesn't have to implement this logic themself

@@ -368,6 +369,15 @@ namespace CefSharp
}

/// <summary>
/// The proxy options that will be used for all connections
/// </summary>
property ProxyOptions^ Proxy
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather see this as part of CefSharpSettings.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -41,5 +41,10 @@ static CefSharpSettings()
/// the event handlers are hooked in the static constructor for the ChromiumWebBrowser class
/// </summary>
public static bool ShutdownOnExit { get; set; }

/// <summary>
/// The proxy options that will be used for all connections
Copy link
Member

Choose a reason for hiding this comment

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

A think we should expand on this, explain what's going on. Command line arguments are set, if you set username/password then GetAuthCredentials will be called automatically. Also note that if you use this option it's impossible to change the proxy at dynamically at runtime.

Copy link
Member

Choose a reason for hiding this comment

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

Also say that GetAuthCredentials won't be called, for a proxy server that matches the IP

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

if (isProxy && CefSharpSettings::Proxy != nullptr && CefSharpSettings::Proxy->IP == StringUtils::ToClr(host) && !String::IsNullOrEmpty(CefSharpSettings::Proxy->Username)
&& !String::IsNullOrEmpty(CefSharpSettings::Proxy->Password))
{
auto frameWrapper = gcnew CefFrameWrapper(frame);
Copy link
Member

Choose a reason for hiding this comment

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

Seems unnecessary to create these wrappers, can just execute the callback directly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -732,6 +732,16 @@ namespace CefSharp
bool ClientAdapter::GetAuthCredentials(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, bool isProxy,
const CefString& host, int port, const CefString& realm, const CefString& scheme, CefRefPtr<CefAuthCallback> callback)
{
if (isProxy && CefSharpSettings::Proxy != nullptr && CefSharpSettings::Proxy->IP == StringUtils::ToClr(host) && !String::IsNullOrEmpty(CefSharpSettings::Proxy->Username)
Copy link
Member

Choose a reason for hiding this comment

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

What about creating a HasUsernameAndPassword() method (or property) to ProxySettings, make this a little cleaner, little less C++

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@amaitland
Copy link
Member

@merceyz I've granted you access to all of the CefSharp repositories (assuming you accept the invitation of course).

Once your happy this is ready to release into the wild then feel free to merge yourself 👍

@merceyz
Copy link
Member Author

merceyz commented Apr 11, 2017

@merceyz I've granted you access to all of the CefSharp repositories (assuming you accept the invitation of course).

Thank you, though I haven't gotten an invitation yet I appreciate it.

@amaitland
Copy link
Member

I haven't gotten an invitation yet

Check https://github.com/cefsharp

Tried sending you another one, would only let me edit the existing invite, so it's def been sent.

@merceyz
Copy link
Member Author

merceyz commented Apr 12, 2017

Check https://github.com/cefsharp

There it was, cheers

Tried sending you another one, would only let me edit the existing invite, so it's def been sent.

Didn't get an E-mail nor a notification, so I suppose one would have to know the invite was sent and where to find it

@amaitland
Copy link
Member

Didn't get an E-mail nor a notification, so I suppose one would have to know the invite was sent and where to find it

It said an email was sent, maybe it got lost along the way.

@merceyz merceyz merged commit 8df4ec5 into cefsharp:master Apr 12, 2017
@merceyz
Copy link
Member Author

merceyz commented Apr 12, 2017

It said an email was sent, maybe it got lost along the way.

Probably

Would you like this to be a part of 57?

@amaitland
Copy link
Member

Would you like this to be a part of 57?

I'm reluctant to merge anything other than bug fixes this late in the release process. Plan is to generate the 57.0.0 release packages early next week.

@amaitland amaitland 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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants