本文整理汇总了C++中CEF_REQUIRE_UI_THREAD函数的典型用法代码示例。如果您正苦于以下问题:C++ CEF_REQUIRE_UI_THREAD函数的具体用法?C++ CEF_REQUIRE_UI_THREAD怎么用?C++ CEF_REQUIRE_UI_THREAD使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CEF_REQUIRE_UI_THREAD函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CefPostTask
void ClientHandler::EndTracing() {
if (!CefCurrentlyOn(TID_UI)) {
// Execute on the UI thread.
CefPostTask(TID_UI, base::Bind(&ClientHandler::EndTracing, this));
return;
}
class Client : public CefEndTracingCallback,
public CefRunFileDialogCallback {
public:
explicit Client(CefRefPtr<ClientHandler> handler)
: handler_(handler) {
RunDialog();
}
void RunDialog() {
static const char kDefaultFileName[] = "trace.txt";
std::string path = handler_->GetDownloadPath(kDefaultFileName);
if (path.empty())
path = kDefaultFileName;
// Results in a call to OnFileDialogDismissed.
handler_->GetBrowser()->GetHost()->RunFileDialog(
FILE_DIALOG_SAVE, CefString(), path, std::vector<CefString>(),
this);
}
virtual void OnFileDialogDismissed(
CefRefPtr<CefBrowserHost> browser_host,
const std::vector<CefString>& file_paths) OVERRIDE {
CEF_REQUIRE_UI_THREAD();
if (!file_paths.empty()) {
// File selected. Results in a call to OnEndTracingComplete.
CefEndTracing(file_paths.front(), this);
} else {
// No file selected. Discard the trace data.
CefEndTracing(CefString(), NULL);
}
}
virtual void OnEndTracingComplete(
const CefString& tracing_file) OVERRIDE {
CEF_REQUIRE_UI_THREAD();
handler_->SetLastDownloadFile(tracing_file.ToString());
handler_->SendNotification(NOTIFY_DOWNLOAD_COMPLETE);
}
private:
示例2: CEF_REQUIRE_UI_THREAD
void ClientHandler::OnTitleChange(CefRefPtr<CefBrowser> browser,
const CefString& title) {
CEF_REQUIRE_UI_THREAD();
std::string titleStr(title);
std::cout << "title changed to %s" << titleStr;
}
示例3: CEF_REQUIRE_UI_THREAD
void PhantomJSHandler::OnLoadError(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
ErrorCode errorCode,
const CefString& errorText,
const CefString& failedUrl)
{
CEF_REQUIRE_UI_THREAD();
qCDebug(handler) << browser->GetIdentifier() << isMain(frame) << errorCode << errorText << failedUrl;
if (isMain(frame)) {
handleLoadEnd(browser, errorCode, failedUrl, false);
}
// 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);
}
示例4: CEF_REQUIRE_UI_THREAD
bool CWebClient::OnContextMenuCommand(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefContextMenuParams> params,
int command_id,
EventFlags event_flags) {
CEF_REQUIRE_UI_THREAD();
switch (command_id) {
case CLIENT_ID_SHOW_DEVTOOLS:
ShowDevTools(this, browser, CefPoint());
return true;
case CLIENT_ID_CLOSE_DEVTOOLS:
CloseDevTools(browser);
return true;
case CLIENT_ID_INSPECT_ELEMENT:
ShowDevTools(this, browser, CefPoint(params->GetXCoord(), params->GetYCoord()));
return true;
case CLIENT_ID_RELOAD:
RefreshPage(browser, true);
return true;
default: // Allow default handling, if any.
return false;
}
}
示例5: CEF_REQUIRE_UI_THREAD
void CefClientImpl::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
CEF_REQUIRE_UI_THREAD();
if (GetBrowserId() == browser->GetIdentifier())
{
base::AutoLock lock_scope(lock_);
// Free the browser pointer so that the browser can be destroyed
browser_child = NULL;
}
else if(browser->IsPopup())
{
// Remove from the browser popup list.
BrowserList::iterator bit = popup_browsers_.begin();
for (; bit != popup_browsers_.end(); ++bit) {
if ((*bit)->IsSame(browser)) {
popup_browsers_.erase(bit);
break;
}
}
}
if (--browser_count_ == 0) {
// All browser windows have closed.
// Remove and delete message router handlers.
message_router_ = NULL;
// Quit the application message loop.
PostMessage(hMessageWnd,WM_COMMAND,ID_QUIT,0);
}
}
示例6: CEF_REQUIRE_UI_THREAD
void SimpleHandler::OnTitleChange(CefRefPtr<CefBrowser> browser,
const CefString& title) {
CEF_REQUIRE_UI_THREAD();
CefWindowHandle hwnd = browser->GetHost()->GetWindowHandle();
SetWindowText(hwnd, std::wstring(title).c_str());
}
示例7: CEF_REQUIRE_UI_THREAD
void ClientHandler::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;
// Don't display an error for external protocols that we allow the OS to
// handle. See OnProtocolExecution().
if (errorCode == ERR_UNKNOWN_URL_SCHEME) {
std::string urlStr = frame->GetURL();
if (urlStr.find("spotify:") == 0)
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);
}
示例8: CEF_REQUIRE_UI_THREAD
bool ClientHandler::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 (GetBrowserId() == browser->GetIdentifier()) {
if (!popup_browsers_.empty()) {
// Request that any popup browsers close.
BrowserList::const_iterator it = popup_browsers_.begin();
for (; it != popup_browsers_.end(); ++it)
(*it)->GetHost()->CloseBrowser(true);
}
base::AutoLock lock_scope(lock_);
// Set a flag to indicate that the window close should be allowed.
is_closing_ = true;
developerStudioProcess->StopProcess();
}
// Allow the close. For windowed browsers this will result in the OS close
// event being sent.
return false;
}
示例9: CEF_REQUIRE_UI_THREAD
void ClientHandler::SetLoading(bool isLoading) {
CEF_REQUIRE_UI_THREAD();
if (isLoading)
gtk_widget_set_sensitive(GTK_WIDGET(stop_handle_), true);
else
gtk_widget_set_sensitive(GTK_WIDGET(stop_handle_), false);
}
示例10: OnAfterCreated
// CefLifeSpanHandler
void OnAfterCreated(CefRefPtr<CefBrowser> browser) override
{
CEF_REQUIRE_UI_THREAD();
if (!owner_.on_cef_after_created(browser)) {
browser_list_.push_back(browser);
}
}
示例11: CEF_REQUIRE_UI_THREAD
void BrowserClient::OnBeforeClose(CefRefPtr<CefBrowser> browser)
{
CEF_REQUIRE_UI_THREAD();
if (m_BrowserId == browser->GetIdentifier())
{
m_Browser = NULL;
}
}
示例12: CEF_REQUIRE_UI_THREAD
void ClientHandler::OnLoadingStateChange(CefRefPtr<CefBrowser> browser,
bool isLoading,
bool canGoBack,
bool canGoForward) {
CEF_REQUIRE_UI_THREAD();
SetLoading(isLoading);
SetNavState(canGoBack, canGoForward);
}