forked from cefsharp/CefSharp
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
133 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.IO; | ||
|
||
namespace CefSharp.Example | ||
{ | ||
class DownloadHandler : IDownloadHandler | ||
{ | ||
private readonly string _path; | ||
private Stream _stream; | ||
|
||
public DownloadHandler(string fileName) | ||
{ | ||
_path = Path.Combine(Path.GetTempPath(), fileName); | ||
_stream = File.Create(_path); | ||
} | ||
|
||
public bool ReceivedData(byte[] data) | ||
{ | ||
_stream.Write(data, 0, data.GetLength(0)); | ||
return true; | ||
|
||
} | ||
public void Complete() | ||
{ | ||
_stream.Dispose(); | ||
_stream = null; | ||
|
||
Console.WriteLine("Downloaded: {0}", _path); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "stdafx.h" | ||
#include "DownloadAdapter.h" | ||
|
||
using namespace System::Runtime::InteropServices; | ||
|
||
namespace CefSharp | ||
{ | ||
bool DownloadAdapter::ReceivedData(void* data, int data_size) | ||
{ | ||
array<Byte>^ bytes = gcnew array<Byte>(data_size); | ||
Marshal::Copy(IntPtr(data), bytes, 0, data_size); | ||
|
||
return _handler->ReceivedData(bytes); | ||
} | ||
|
||
void DownloadAdapter::Complete() | ||
{ | ||
_handler->Complete(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "stdafx.h" | ||
#pragma once | ||
|
||
#include "include/cef_download_handler.h" | ||
#include "IDownloadHandler.h" | ||
|
||
namespace CefSharp | ||
{ | ||
class DownloadAdapter : public CefDownloadHandler | ||
{ | ||
gcroot<IDownloadHandler^> _handler; | ||
|
||
public: | ||
DownloadAdapter(IDownloadHandler^ handler) : _handler(handler) { } | ||
|
||
virtual bool ReceivedData(void* data, int data_size); | ||
virtual void Complete(); | ||
|
||
IMPLEMENT_REFCOUNTING(DownloadAdapter); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include "stdafx.h" | ||
#pragma once | ||
|
||
namespace CefSharp | ||
{ | ||
public interface class IDownloadHandler | ||
{ | ||
public: | ||
bool ReceivedData(array<Byte>^ data); | ||
void Complete(); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters