Skip to content

Commit

Permalink
IDownloadHandler - Add IWebBrowser param to methods
Browse files Browse the repository at this point in the history
Resolves #2470
  • Loading branch information
amaitland committed Jul 24, 2018
1 parent 430c439 commit 9d4504d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
16 changes: 8 additions & 8 deletions CefSharp.Core/Internals/ClientAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -978,9 +978,9 @@ namespace CefSharp
return;
}

auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup());
auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup());

handler->OnGotFocus(_browserControl, browserWrapper);
handler->OnGotFocus(_browserControl, browserWrapper);
}

bool ClientAdapter::OnSetFocus(CefRefPtr<CefBrowser> browser, FocusSource source)
Expand All @@ -993,9 +993,9 @@ namespace CefSharp
return false;
}

auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup());
auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup());

return handler->OnSetFocus(_browserControl, browserWrapper, (CefFocusSource)source);
return handler->OnSetFocus(_browserControl, browserWrapper, (CefFocusSource)source);
}

void ClientAdapter::OnTakeFocus(CefRefPtr<CefBrowser> browser, bool next)
Expand All @@ -1007,9 +1007,9 @@ namespace CefSharp
return;
}

auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup());
auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup());

handler->OnTakeFocus(_browserControl, browserWrapper, next);
handler->OnTakeFocus(_browserControl, browserWrapper, next);
}

bool ClientAdapter::OnJSDialog(CefRefPtr<CefBrowser> browser, const CefString& origin_url,
Expand Down Expand Up @@ -1139,7 +1139,7 @@ namespace CefSharp
auto callbackWrapper = gcnew CefBeforeDownloadCallbackWrapper(callback);
auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup());

handler->OnBeforeDownload(browserWrapper, downloadItem, callbackWrapper);
handler->OnBeforeDownload(_browserControl, browserWrapper, downloadItem, callbackWrapper);
}
};

Expand All @@ -1153,7 +1153,7 @@ namespace CefSharp
auto callbackWrapper = gcnew CefDownloadItemCallbackWrapper(callback);
auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup());

handler->OnDownloadUpdated(browserWrapper, TypeConversion::FromNative(download_item), callbackWrapper);
handler->OnDownloadUpdated(_browserControl, browserWrapper, TypeConversion::FromNative(download_item), callbackWrapper);
}
}

Expand Down
16 changes: 4 additions & 12 deletions CefSharp.Example/DownloadHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ public class DownloadHandler : IDownloadHandler

public event EventHandler<DownloadItem> OnDownloadUpdatedFired;

public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback)
public void OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback)
{
var handler = OnBeforeDownloadFired;
if (handler != null)
{
handler(this, downloadItem);
}
OnBeforeDownloadFired?.Invoke(this, downloadItem);

if (!callback.IsDisposed)
{
Expand All @@ -29,13 +25,9 @@ public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBefor
}
}

public void OnDownloadUpdated(IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback)
public void OnDownloadUpdated(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback)
{
var handler = OnDownloadUpdatedFired;
if (handler != null)
{
handler(this, downloadItem);
}
OnDownloadUpdatedFired?.Invoke(this, downloadItem);
}
}
}
6 changes: 4 additions & 2 deletions CefSharp/Handler/IDownloadHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ public interface IDownloadHandler
/// <summary>
/// Called before a download begins.
/// </summary>
/// <param name="chromiumWebBrowser">the ChromiumWebBrowser control</param>
/// <param name="browser">The browser instance</param>
/// <param name="downloadItem">Represents the file being downloaded.</param>
/// <param name="callback">Callback interface used to asynchronously continue a download.</param>
void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback);
void OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback);

/// <summary>
/// Called when a download's status or progress information has been updated. This may be called multiple times before and after <see cref="OnBeforeDownload"/>.
/// </summary>
/// <param name="chromiumWebBrowser">the ChromiumWebBrowser control</param>
/// <param name="browser">The browser instance</param>
/// <param name="downloadItem">Represents the file being downloaded.</param>
/// <param name="callback">The callback used to Cancel/Pause/Resume the process</param>
void OnDownloadUpdated(IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback);
void OnDownloadUpdated(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback);
}
}

0 comments on commit 9d4504d

Please sign in to comment.