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

添加响应数据拦截接口。修复RenderHandler重写函数名错误的BUG。完成DownloadHandler接口函数。 #9

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions include/CefViewBrowserClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,20 @@ class CefViewBrowserClient
const CefString& url,
int64_t context);

/// <summary>
///
/// </summary>
/// <param name="browser"></param>
/// <param name="frame"></param>
/// <param name="request"></param>
/// <param name="response"></param>
/// <returns></returns>
virtual CefRefPtr<CefResponseFilter> GetResourceResponseFilter(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
CefRefPtr<CefResponse> response) override;


protected:
bool DispatchRenderMessage(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
Expand Down Expand Up @@ -351,13 +365,21 @@ class CefViewBrowserClient
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request) override;

virtual void OnResourceLoadComplete(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
CefRefPtr<CefResponse> response,
URLRequestStatus status,
int64 received_content_length) override;

virtual void OnProtocolExecution(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
bool& allow_os_execution) override;

// CefDownloadHandler
virtual CefRefPtr<CefDownloadHandler> GetDownloadHandler() override;

void OnBeforeDownload(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDownloadItem> download_item,
const CefString& suggested_name,
Expand Down
21 changes: 19 additions & 2 deletions include/CefViewBrowserClientDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,26 @@ class CefViewBrowserClientDelegateInterface
{}
virtual void onTextSelectionChanged(CefRefPtr<CefBrowser> browser,
const CefString& selected_text,
const CefRange& selected_range)
{}
const CefRange& selected_range){}

virtual void onVirtualKeyboardRequested(CefRefPtr<CefBrowser> browser, CefRenderHandler::TextInputMode input_mode) {}

//CefResourceRequestHandler
virtual void onResourceLoadComplete(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
CefRefPtr<CefResponse> response,
CefResourceRequestHandler::URLRequestStatus status,
int64 received_content_length)
{}

virtual CefRefPtr<CefResponseFilter> onGetResourceResponseFilter(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
CefRefPtr<CefResponse> response)
{
return nullptr;
}
};

#endif
2 changes: 1 addition & 1 deletion src/CefView/CefBrowserApp/CefViewBrowserClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ CefViewBrowserClient::OnRenderReportJSResultMessage(CefRefPtr<CefBrowser> browse
return false;

// get the JS result
auto context = arguments->GetDouble(0);
auto context = arguments->GetInt(0);
auto result = arguments->GetValue(1);

delegate->reportJSResult(browser, frame->GetIdentifier(), static_cast<int64_t>(context), result);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <CefViewBrowserClient.h>
#include <CefViewBrowserClient.h>

#pragma region std_headers
#include <sstream>
Expand Down Expand Up @@ -49,3 +49,34 @@ CefViewBrowserClient::OnProtocolExecution(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefRequest> request,
bool& allow_os_execution)
{}

void
CefViewBrowserClient::OnResourceLoadComplete(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
CefRefPtr<CefResponse> response,
URLRequestStatus status,
int64 received_content_length)
{
auto delegate = client_delegate_.lock();
if (delegate)
{
delegate->onResourceLoadComplete(browser, frame, request, response, status, received_content_length);
}
}


CefRefPtr<CefResponseFilter>
CefViewBrowserClient::GetResourceResponseFilter(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
CefRefPtr<CefResponse> response)
{
auto delegate = client_delegate_.lock();
if (delegate)
{
return delegate->onGetResourceResponseFilter(browser, frame, request, response);
}

return nullptr;
}