-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,8 @@ | |
*.swp | ||
*.user | ||
*.xml | ||
*.VC.opendb | ||
*.VC.db | ||
_ReSharper* | ||
|
||
bin/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is this used? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
public const string TestResourceUrl = "http://test/resource/load"; | ||
public const string RenderProcessCrashedUrl = "http://processcrashed"; | ||
public const string TestUnicodeResourceUrl = "http://test/resource/loadUnicode"; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,23 @@ | |
// | ||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. | ||
|
||
using System; | ||
|
||
namespace CefSharp.Example | ||
{ | ||
public class DownloadHandler : IDownloadHandler | ||
{ | ||
public event EventHandler<DownloadItem> OnBeforeDownloadFired; | ||
|
||
public event EventHandler<DownloadItem> OnDownloadUpdatedFired; | ||
|
||
public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) | ||
{ | ||
if (this.OnBeforeDownloadFired != null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
|
||
{ | ||
this.OnBeforeDownloadFired.Invoke(this, downloadItem); | ||
} | ||
|
||
if (!callback.IsDisposed) | ||
{ | ||
using (callback) | ||
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency |
||
{ | ||
this.OnDownloadUpdatedFired.Invoke(this, downloadItem); | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert whitespace changes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
</ObjectDataProvider.MethodParameters> | ||
</ObjectDataProvider> | ||
</UserControl.Resources> | ||
|
@@ -44,8 +44,7 @@ | |
GotKeyboardFocus="OnTextBoxGotKeyboardFocus" | ||
GotMouseCapture="OnTextBoxGotMouseCapture"> | ||
<TextBox.InputBindings> | ||
<KeyBinding Key="Enter" | ||
Command="{Binding GoCommand}" /> | ||
<KeyBinding Key="Enter" Command="{Binding GoCommand}" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert whitespace changes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
</TextBox.InputBindings> | ||
</TextBox> | ||
</DockPanel> | ||
|
@@ -154,6 +153,238 @@ | |
</Grid> | ||
</GroupBox> | ||
</StackPanel> | ||
<StackPanel | ||
Margin="6,3" | ||
DockPanel.Dock="Right" | ||
Visibility="{Binding ShowDownloadInfo, Converter={StaticResource BooleanToVisibilityConverter}}" | ||
> | ||
<GroupBox Header="Download info"> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
</Grid.RowDefinitions> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="Auto" /> | ||
<ColumnDefinition Width="*" MinWidth="50" /> | ||
</Grid.ColumnDefinitions> | ||
<Label | ||
Grid.Row="0" | ||
Grid.Column="0" | ||
Content="Last action:" | ||
/> | ||
<TextBox | ||
Grid.Row="0" | ||
Grid.Column="1" | ||
IsReadOnly="True" | ||
Text="{Binding LastDownloadAction}" | ||
/> | ||
<Label | ||
Grid.Row="1" | ||
Grid.Column="0" | ||
Content="IsInProgress:" | ||
/> | ||
<TextBox | ||
Grid.Row="1" | ||
Grid.Column="1" | ||
IsReadOnly="True" | ||
Text="{Binding DownloadItem.IsInProgress}" | ||
/> | ||
<Label | ||
Grid.Row="2" | ||
Grid.Column="0" | ||
Content="IsComplete:" | ||
/> | ||
<TextBox | ||
Grid.Row="2" | ||
Grid.Column="1" | ||
IsReadOnly="True" | ||
Text="{Binding DownloadItem.IsComplete}" | ||
/> | ||
<Label | ||
Grid.Row="3" | ||
Grid.Column="0" | ||
Content="IsCancelled:" | ||
/> | ||
<TextBox | ||
Grid.Row="3" | ||
Grid.Column="1" | ||
IsReadOnly="True" | ||
Text="{Binding DownloadItem.IsCancelled}" | ||
/> | ||
<Label | ||
Grid.Row="4" | ||
Grid.Column="0" | ||
Content="CurrentSpeed:" | ||
/> | ||
<TextBox | ||
Grid.Row="4" | ||
Grid.Column="1" | ||
IsReadOnly="True" | ||
Text="{Binding DownloadItem.CurrentSpeed}" | ||
/> | ||
<Label | ||
Grid.Row="5" | ||
Grid.Column="0" | ||
Content="PercentComplete:" | ||
/> | ||
<TextBox | ||
Grid.Row="5" | ||
Grid.Column="1" | ||
IsReadOnly="True" | ||
Text="{Binding DownloadItem.PercentComplete}" | ||
/> | ||
<Label | ||
Grid.Row="6" | ||
Grid.Column="0" | ||
Content="TotalBytes:" | ||
/> | ||
<TextBox | ||
Grid.Row="6" | ||
Grid.Column="1" | ||
IsReadOnly="True" | ||
Text="{Binding DownloadItem.TotalBytes}" | ||
/> | ||
<Label | ||
Grid.Row="7" | ||
Grid.Column="0" | ||
Content="ReceivedBytes:" | ||
/> | ||
<TextBox | ||
Grid.Row="7" | ||
Grid.Column="1" | ||
IsReadOnly="True" | ||
Text="{Binding DownloadItem.ReceivedBytes}" | ||
/> | ||
<Label | ||
Grid.Row="8" | ||
Grid.Column="0" | ||
Content="StartTime:" | ||
/> | ||
<TextBox | ||
Grid.Row="8" | ||
Grid.Column="1" | ||
IsReadOnly="True" | ||
Text="{Binding DownloadItem.StartTime}" | ||
/> | ||
<Label | ||
Grid.Row="9" | ||
Grid.Column="0" | ||
Content="EndTime:" | ||
/> | ||
<TextBox | ||
Grid.Row="9" | ||
Grid.Column="1" | ||
IsReadOnly="True" | ||
Text="{Binding DownloadItem.EndTime}" | ||
/> | ||
<Label | ||
Grid.Row="10" | ||
Grid.Column="0" | ||
Content="FullPath:" | ||
/> | ||
<TextBox | ||
Grid.Row="10" | ||
Grid.Column="1" | ||
IsReadOnly="True" | ||
Text="{Binding DownloadItem.FullPath}" | ||
/> | ||
<Label | ||
Grid.Row="11" | ||
Grid.Column="0" | ||
Content="Id:" | ||
/> | ||
<TextBox | ||
Grid.Row="11" | ||
Grid.Column="1" | ||
IsReadOnly="True" | ||
Text="{Binding DownloadItem.Id}" | ||
/> | ||
<Label | ||
Grid.Row="12" | ||
Grid.Column="0" | ||
Content="Url:" | ||
/> | ||
<TextBox | ||
Grid.Row="12" | ||
Grid.Column="1" | ||
IsReadOnly="True" | ||
Text="{Binding DownloadItem.Url}" | ||
/> | ||
<Label | ||
Grid.Row="13" | ||
Grid.Column="0" | ||
Content="OriginalUrl:" | ||
/> | ||
<TextBox | ||
Grid.Row="13" | ||
Grid.Column="1" | ||
IsReadOnly="True" | ||
Text="{Binding DownloadItem.OriginalUrl}" | ||
/> | ||
<Label | ||
Grid.Row="14" | ||
Grid.Column="0" | ||
Content="SuggestedFileName:" | ||
/> | ||
<TextBox | ||
Grid.Row="14" | ||
Grid.Column="1" | ||
IsReadOnly="True" | ||
Text="{Binding DownloadItem.SuggestedFileName}" | ||
/> | ||
<Label | ||
Grid.Row="15" | ||
Grid.Column="0" | ||
Content="ContentDisposition:" | ||
/> | ||
<TextBox | ||
Grid.Row="15" | ||
Grid.Column="1" | ||
IsReadOnly="True" | ||
Text="{Binding DownloadItem.ContentDisposition}" | ||
/> | ||
<Label | ||
Grid.Row="16" | ||
Grid.Column="0" | ||
Content="MimeType:" | ||
/> | ||
<TextBox | ||
Grid.Row="16" | ||
Grid.Column="1" | ||
IsReadOnly="True" | ||
Text="{Binding DownloadItem.MimeType}" | ||
/> | ||
<Label | ||
Grid.Row="17" | ||
Grid.Column="0" | ||
Content="IsValid:" | ||
/> | ||
<TextBox | ||
Grid.Row="17" | ||
Grid.Column="1" | ||
IsReadOnly="True" | ||
Text="{Binding DownloadItem.IsValid}" | ||
/> | ||
</Grid> | ||
</GroupBox> | ||
</StackPanel> | ||
<StatusBar DockPanel.Dock="Bottom"> | ||
<ProgressBar HorizontalAlignment="Right" | ||
IsIndeterminate="{Binding WebBrowser.IsLoading}" | ||
|
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 ideally be in it's own
PR
, though leave it for now. (Doesn't relate to the feature your adding).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.
Okay!