#include "StdAfx.h"
#include "TestCefHandler.h"
#include "include/base/cef_bind.h"
#include "include/cef_app.h"
#include "include/views/cef_browser_view.h"
#include "include/views/cef_window.h"
#include "include/wrapper/cef_closure_task.h"
#include "include/wrapper/cef_helpers.h"
#include "include/internal/cef_win.h"
#include <winuser.h>
namespace {
TestCefHandler* g_instance = NULL;
} // namespace
TestCefHandler::TestCefHandler(bool use_views)
: use_views_(use_views),
is_closing_(false) {
DCHECK(!g_instance);
g_instance = this;
}
TestCefHandler::~TestCefHandler() {
g_instance = NULL;
}
// static
TestCefHandler* TestCefHandler::GetInstance() {
return g_instance;
}
void TestCefHandler::OnTitleChange(CefRefPtr<CefBrowser> browser,
const CefString& title) {
CEF_REQUIRE_UI_THREAD();
if (use_views_) {
// Set the title of the window using the Views framework.
CefRefPtr<CefBrowserView> browser_view =
CefBrowserView::GetForBrowser(browser);
if (browser_view) {
CefRefPtr<CefWindow> window = browser_view->GetWindow();
if (window)
window->SetTitle(title);
}
} else {
// Set the title of the window using platform APIs.
PlatformTitleChange(browser, title);
}
}
void TestCefHandler::PlatformTitleChange(CefRefPtr<CefBrowser> browser,
const CefString& title)
{
CefWindowHandle hwnd = browser->GetHost()->GetWindowHandle();
SetWindowText(hwnd, std::wstring(title).c_str());
}
void TestCefHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
CEF_REQUIRE_UI_THREAD();
// Add to the list of existing browsers.
browser_list_.push_back(browser);
}
bool TestCefHandler::DoClose(CefRefPtr<CefBrowser> browser) {
CEF_REQUIRE_UI_THREAD();
// Closing the main window requires special handling. See the DoClose()
// documentation in the CEF header for a detailed destription of this
// process.
if (browser_list_.size() == 1) {
// Set a flag to indicate that the window close should be allowed.
is_closing_ = true;
}
// Allow the close. For windowed browsers this will result in the OS close
// event being sent.
return false;
}
void TestCefHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
CEF_REQUIRE_UI_THREAD();
// Remove from the list of existing browsers.
BrowserList::iterator bit = browser_list_.begin();
for (; bit != browser_list_.end(); ++bit) {
if ((*bit)->IsSame(browser)) {
browser_list_.erase(bit);
break;
}
}
if (browser_list_.empty()) {
// All browser windows have closed. Quit the application message loop.
CefQuitMessageLoop();
}
}
void TestCefHandler::OnLoadError(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
ErrorCode errorCode,
const CefString& errorText,
const CefString& failedUrl) {
CEF_REQUIRE_UI_THREAD();
// Don't display an error for downloaded files.
if (errorCode == ERR_ABORTED)
return;
// Display a load error message.
std::stringstream ss;
ss << "<html><body bgcolor=\"white\">"
"<h2>Failed to load URL " << std::string(failedUrl) <<
" with error " << std::string(errorText) << " (" << errorCode <<
").</h2></body></html>";
frame->LoadString(ss.str(), failedUrl);
}
void TestCefHandler::CloseAllBrowsers(bool force_close) {
if (!CefCurrentlyOn(TID_UI)) {
// Execute on the UI thread.
CefPostTask(TID_UI,
base::Bind(&TestCefHandler::CloseAllBrowsers, this, force_close));
return;
}
if (browser_list_.empty())
return;
BrowserList::const_iterator it = browser_list_.begin();
for (; it != browser_list_.end(); ++it)
(*it)->GetHost()->CloseBrowser(force_close);
}
没有合适的资源?快使用搜索试试~ 我知道了~
CEF3嵌入win32项目
共375个文件
h:239个
pak:58个
tlog:27个
5星 · 超过95%的资源 需积分: 47 80 下载量 42 浏览量
2018-06-25
22:57:52
上传
评论 3
收藏 69.44MB RAR 举报
温馨提示
将CEF3嵌入到win32项目中,解决了系统兼容性问题,可以在win10下调试运行
资源推荐
资源详情
资源评论
收起资源包目录
CEF3嵌入win32项目 (375个子文件)
snapshot_blob.bin 645KB
natives_blob.bin 332KB
TestCef.vcxprojResolveAssemblyReference.cache 713B
TestCefHandler.cpp 3KB
TestCefAPP.cpp 3KB
TestCef.cpp 2KB
stdafx.cpp 212B
icudtl.dat 9.66MB
libcef.dll 85.65MB
d3dcompiler_47.dll 3.54MB
libGLESv2.dll 2.13MB
d3dcompiler_43.dll 2.01MB
chrome_elf.dll 441KB
libEGL.dll 77KB
TestCef.exe 2.53MB
TestCef.vcxproj.filters 2KB
cef_pack_strings.h 267KB
cef_bind_internal.h 108KB
cef_pack_resources.h 86KB
cef_types.h 74KB
cef_tuple.h 53KB
cef_v8_capi.h 33KB
cef_callback.h 33KB
cef_v8.h 31KB
cef_browser_capi.h 30KB
cef_types_wrappers.h 30KB
cef_browser.h 29KB
cef_bind.h 28KB
cef_logging.h 28KB
cef_values_capi.h 26KB
cef_scoped_ptr.h 24KB
cef_values.h 23KB
cef_string_wrappers.h 22KB
cef_trace_event.h 20KB
cef_bind_helpers.h 19KB
cef_message_router.h 18KB
cef_request_handler.h 15KB
cef_request_handler_capi.h 14KB
cef_resource_manager.h 14KB
cef_callback_list.h 14KB
cef_translator_test_capi.h 13KB
cef_view_capi.h 13KB
cef_weak_ptr.h 13KB
cef_menu_model_capi.h 13KB
cef_translator_test.h 13KB
cef_menu_model.h 12KB
cef_request_context_capi.h 12KB
cef_view.h 12KB
cef_bind_internal_win.h 12KB
cef_request_context.h 11KB
cef_context_menu_handler_capi.h 11KB
cef_move.h 11KB
cef_dom_capi.h 10KB
cef_life_span_handler_capi.h 10KB
cef_ref_counted.h 10KB
cef_life_span_handler.h 10KB
cef_request_capi.h 10KB
cef_cancelable_callback.h 10KB
cef_xml_reader_capi.h 10KB
cef_context_menu_handler.h 10KB
cef_thread_collision_warner.h 9KB
cef_cookie_capi.h 9KB
cef_window_capi.h 9KB
cef_cookie.h 9KB
cef_request.h 9KB
cef_textfield_capi.h 9KB
cef_atomicops.h 9KB
cef_web_plugin_capi.h 9KB
cef_callback_internal.h 9KB
cef_string16.h 9KB
cef_window.h 9KB
cef_app.h 8KB
cef_app_capi.h 8KB
cef_dom.h 8KB
cef_xml_reader.h 8KB
cef_macros.h 8KB
cef_web_plugin.h 8KB
cef_textfield.h 8KB
cef_image.h 8KB
cef_scheme_capi.h 8KB
cef_atomicops_x86_msvc.h 8KB
cef_render_handler.h 8KB
cef_urlrequest_capi.h 8KB
cef_scheme.h 8KB
cef_urlrequest.h 8KB
cef_render_handler_capi.h 7KB
cef_image_capi.h 7KB
cef_command_line_capi.h 7KB
cef_stream_capi.h 7KB
cef_string_types.h 7KB
cef_frame_capi.h 7KB
cef_template_util.h 7KB
cef_xml_object.h 7KB
cef_x509_certificate_capi.h 7KB
cef_drag_data_capi.h 7KB
cef_render_process_handler_capi.h 7KB
cef_parser_capi.h 7KB
cef_render_process_handler.h 7KB
cef_stream.h 7KB
cef_command_line.h 7KB
共 375 条
- 1
- 2
- 3
- 4
资源评论
- 懒人精灵2019-04-24好用谢谢!!!落寞书生2019-04-25能帮助就好
- du198812102019-02-26感谢,很有用落寞书生2019-04-25能帮助就好
落寞书生
- 粉丝: 32
- 资源: 14
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功