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

Added DownloadItem .OriginalUrl #1877

Merged
merged 2 commits into from
Dec 4, 2016
Merged

Conversation

philipbeber
Copy link
Contributor

This property is very valuable and I need it in the project I am working on right now!

Also:

Added a sidebar to the example app which shows the DownloadItems as received by CefSharp.Core/Internals/TypeConversion.h

Added a View menu for hiding/showing the regular sidebar and the new download info sidebar.

…Url" in CEF.

Added a sidebar to the example app which shows the DownloadItems as received by CefSharp.Core/Internals/TypeConversion.h

Added a View menu for hiding/showing the regular sidebar and the new download info sidebar.
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.

Thanks for the PR.

Ideally this would have been multiple commits, one adding the feature, one adding the UI changes and one the git ignore update. They can be squashed when merged. No need to change now, just push additional commits with your changes.

@@ -24,6 +24,7 @@ public static class CefExample
public const string BasicSchemeTestUrl = "custom://cefsharp/SchemeTest.html";
public const string ResponseFilterTestUrl = "custom://cefsharp/ResponseFilterTest.html";
public const string DraggableRegionTestUrl = "custom://cefsharp/DraggableRegionTest.html";
public const string DownloadHandlerTestUrl = "custom://cefsharp/DownloadHandlerTest.html";
Copy link
Member

Choose a reason for hiding this comment

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

Where is this used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, meant to revert this. I had added a new test html file but it didn't turn out to be a very good addition.

@@ -14,7 +14,7 @@
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<ObjectDataProvider x:Key="BitmapScalingModeEnum" MethodName="GetValues" ObjectType="{x:Type system:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="BitmapScalingMode"/>
<x:Type TypeName="BitmapScalingMode" />
Copy link
Member

Choose a reason for hiding this comment

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

Please revert whitespace changes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@@ -44,8 +44,7 @@
GotKeyboardFocus="OnTextBoxGotKeyboardFocus"
GotMouseCapture="OnTextBoxGotMouseCapture">
<TextBox.InputBindings>
<KeyBinding Key="Enter"
Command="{Binding GoCommand}" />
<KeyBinding Key="Enter" Command="{Binding GoCommand}" />
Copy link
Member

Choose a reason for hiding this comment

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

Please revert whitespace changes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!


private void UpdateDownloadAction(string downloadAction, DownloadItem downloadItem)
{
this.Dispatcher.Invoke(() =>
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason to update in a sync fashion? UI updates should be async where possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Changed to InvokeAsync now.

@@ -16,6 +16,8 @@
*.swp
*.user
*.xml
*.VC.opendb
Copy link
Member

Choose a reason for hiding this comment

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

Would ideally be in it's own PR, though leave it for now. (Doesn't relate to the feature your adding).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay!

public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback)
{
if (this.OnBeforeDownloadFired != null)
Copy link
Member

Choose a reason for hiding this comment

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

Would prefer firing of event handlers to look like below for consistency and best practice.

var handler = LoadingStateChanged;
if (handler != null)
{
    handler(this, args);
}

I know this is a demo, though I prefer to take a reference to a handler before executing as it's possible in a multithreaded environment for the handler reference to be cleared between the null check and executing. There's no

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I update to match that style. Presumably using a null-conditional would also be okay? E.g.

OnBeforeDownloadFired?.Invoke(this, downloadItem);

@@ -19,7 +30,10 @@ public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBefor

public void OnDownloadUpdated(IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback)
{

if (this.OnDownloadUpdatedFired != null)
Copy link
Member

Choose a reason for hiding this comment

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

For consistency this has typically only been used when referencing a private variable.

@amaitland amaitland changed the title Added "OriginalUrl" property to DownloadItem which wraps "GetOriginalUrl" in CEF Added DownloadItem .OriginalUrl Dec 2, 2016
@amaitland amaitland added this to the 55.0.0 milestone Dec 2, 2016
@philipbeber
Copy link
Contributor Author

Thanks for the feedback Alex! I have pushed fixes for those problems.

@amaitland amaitland merged commit b47731d into cefsharp:master Dec 4, 2016
@amaitland
Copy link
Member

Thanks, merged 👍

@philipbeber
Copy link
Contributor Author

Awesome, thanks Alex!

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