当前位置: 首页>>代码示例>>C++>>正文


C++ CEF_REQUIRE_UI_THREAD函数代码示例

本文整理汇总了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:
开发者ID:CRDNicolasBourbaki,项目名称:chromiumembedded,代码行数:48,代码来源:client_handler.cpp

示例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;
}
开发者ID:Xinkai,项目名称:QtMetaObjectWithCef,代码行数:7,代码来源:ClientHandler.cpp

示例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);
}
开发者ID:KDAB,项目名称:phantomjs-cef,代码行数:26,代码来源:handler.cpp

示例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;
	}
}
开发者ID:Zion-007,项目名称:XCef,代码行数:25,代码来源:WebClient.cpp

示例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);
	}
}
开发者ID:yangjian123,项目名称:soui-cef,代码行数:29,代码来源:CefClientImpl.cpp

示例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());
}
开发者ID:captainwong,项目名称:AlarmCenterTestTools,代码行数:7,代码来源:simple_handler_win.cpp

示例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);
}
开发者ID:CRDNicolasBourbaki,项目名称:chromiumembedded,代码行数:27,代码来源:client_handler.cpp

示例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;
}
开发者ID:kaviththiranga,项目名称:developer-studio-cef-client,代码行数:27,代码来源:client_handler.cpp

示例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);
}
开发者ID:CRDNicolasBourbaki,项目名称:chromiumembedded,代码行数:8,代码来源:client_handler_gtk.cpp

示例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);
		}
	}
开发者ID:quartorz,项目名称:reveal-viewer,代码行数:9,代码来源:cef_handler.hpp

示例11: CEF_REQUIRE_UI_THREAD

void BrowserClient::OnBeforeClose(CefRefPtr<CefBrowser> browser)
{
	CEF_REQUIRE_UI_THREAD();
	if (m_BrowserId == browser->GetIdentifier())
	{
		m_Browser = NULL;
	}
}
开发者ID:492580195,项目名称:BLUI,代码行数:8,代码来源:RenderHandler.cpp

示例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);
}
开发者ID:bigfatbrowncat,项目名称:test_cef,代码行数:9,代码来源:client_handler.cpp


注:本文中的CEF_REQUIRE_UI_THREAD函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。