Example #1
0
QUrl QCefWebView::url() const {
    if (GetBrowser().get()) {
        CefString url = GetBrowser()->GetMainFrame()->GetURL();
        return QUrl(QString::fromStdWString(url.ToWString()));
    }
    return QUrl();
}
bool LifeSpanHandler::OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser,
                                    CefRefPtr<CefFrame> frame,
                                    const CefString& target_url,
                                    const CefString& target_frame_name,
                                    const CefPopupFeatures& popupFeatures,
                                    CefWindowInfo& windowInfo,
                                    CefRefPtr<CefClient>& client,
                                    CefBrowserSettings& settings,
                                    bool* no_javascript_access)
{
	//dont show popups unless its the inspector
	CefStringUTF8 t(ConvertToUtf8(target_url));

	cef3Trace("Url: %s", t.c_str());

	if (!t.empty() && std::string(t.c_str()).find("resources/inspector/devtools.") != std::string::npos)
		return false;

	if (GetCallbackV2())
	{
		if (GetCallbackV2()->onNewWindowUrl(t.c_str()))
			GetBrowser()->GetMainFrame()->LoadURL(target_url);
	}
	else
	{
		if (GetCallback()->onNavigateUrl(t.c_str(), true))
			GetBrowser()->GetMainFrame()->LoadURL(target_url);
	}
	
	return true;
}
Example #3
0
bool QCefWebView::BrowserLoadUrl(const QUrl& url) {
    if (!url.isEmpty() && GetBrowser().get()) {
        CefString cefurl(url_.toString().toStdWString());
        GetBrowser()->GetMainFrame()->LoadURL(cefurl);
        return true;
    }
    return false;
}
Example #4
0
QVariant QCefWebView::evaluateJavaScript(const QString& scriptSource) {
    if (GetBrowser().get()) {
        CefString code(scriptSource.toStdWString());
        GetBrowser()->GetMainFrame()->ExecuteJavaScript(code, "", 0);
        return true;
    }
    return false;
}
Example #5
0
	__declspec(dllexport) void ExecuteRootScript(const std::string& scriptBit)
	{
		auto rootWindow = Instance<NUIWindowManager>::Get()->GetRootWindow();

		if (rootWindow.GetRef() && rootWindow->GetBrowser() && rootWindow->GetBrowser()->GetMainFrame())
		{
			rootWindow->GetBrowser()->GetMainFrame()->ExecuteJavaScript(scriptBit, "internal", 1);
		}
	}
Example #6
0
void QCefWebView::setHtml(const QString& html, const QUrl& baseUrl) {
  // Custom Scheme and Request Handling:
  // https://code.google.com/p/chromiumembedded/wiki/GeneralUsage#Request_Handling
  if (GetBrowser().get()) {
    QUrl url = baseUrl.isEmpty() ? this->url(): baseUrl;
    if (!url.isEmpty()) {
      CefRefPtr<CefFrame> frame = GetBrowser()->GetMainFrame();
      frame->LoadString(CefString(html.toStdWString()),
                        CefString(url.toString().toStdWString()));
    }
  }
}
Example #7
0
void CefClientImpl::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
	if (!message_router_) {
		// Create the browser-side router for query handling.
		CefMessageRouterConfig config;
		message_router_ = CefMessageRouterBrowserSide::Create(config);
		// Register handlers with the router.
		message_router_->AddHandler(new Handler(), false);
	}

 
	if(!GetBrowser())
	{
		base::AutoLock lock_scope(lock_);
		browser_child = browser;
		browser_id_ = browser->GetIdentifier();
	}else if (browser->IsPopup()) {
		// Add to the list of popup browsers.
		popup_browsers_.push_back(browser);

		// Give focus to the popup browser. Perform asynchronously because the
		// parent window may attempt to keep focus after launching the popup.
		CefPostTask(TID_UI,
			base::Bind(&CefBrowserHost::SetFocus, browser->GetHost().get(), true));
	}

	browser_count_++;

	//std::stringstream ss;
	//ss << "<html><body bgcolor=\"white\"><h1>Chatting with xxx</h1>Text:<pre>" << "XXXYY" <<
	//    "</pre></body></html>";
	//browser->GetMainFrame()->LoadString(ss.str(), "http://tests/gettext");
}
Example #8
0
	__declspec(dllexport) CefBrowser* GetBrowser()
	{
		auto rootWindow = Instance<NUIWindowManager>::Get()->GetRootWindow();

		if (!rootWindow.GetRef())
		{
			return nullptr;
		}

		return rootWindow->GetBrowser();
	}
Example #9
0
	__declspec(dllexport) void DestroyFrame(fwString frameName)
	{
		auto procMessage = CefProcessMessage::Create("destroyFrame");
		auto argumentList = procMessage->GetArgumentList();

		argumentList->SetSize(1);
		argumentList->SetString(0, frameName.c_str());

		auto rootWindow = Instance<NUIWindowManager>::Get()->GetRootWindow();
		auto browser = rootWindow->GetBrowser();
		browser->SendProcessMessage(PID_RENDERER, procMessage);

		std::unique_lock<std::shared_mutex> lock(frameListMutex);
		frameList.erase(frameName);
	}
SVNMainDirector*
SVNWDManager::OpenDirectory
	(
	const JCharacter*	path,
	JBoolean*			wasOpen		// can be NULL
	)
{
	SVNMainDirector* dir;
	const JBoolean open = GetBrowser(path, &dir);
	if (wasOpen != NULL)
		{
		*wasOpen = open;
		}

	if (!open)
		{
		dir = new SVNMainDirector(JXGetApplication(), path);
		assert( dir != NULL );
		}

	dir->Activate();
	return dir;
}
void ClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
  CEF_REQUIRE_UI_THREAD();

  if (!message_router_) {
    // Create the browser-side router for query handling.
    CefMessageRouterConfig config;
    message_router_ = CefMessageRouterBrowserSide::Create(config);

    // Register handlers with the router.
    CreateMessageHandlers(message_handler_set_);
    MessageHandlerSet::const_iterator it = message_handler_set_.begin();
    for (; it != message_handler_set_.end(); ++it)
      message_router_->AddHandler(*(it), false);
  }

  // Disable mouse cursor change if requested via the command-line flag.
  if (mouse_cursor_change_disabled_)
    browser->GetHost()->SetMouseCursorChangeDisabled(true);

  if (!GetBrowser())   {
    base::AutoLock lock_scope(lock_);
    // We need to keep the main child window, but not popup windows
    browser_ = browser;
    browser_id_ = browser->GetIdentifier();
  } else if (browser->IsPopup()) {
    // Add to the list of popup browsers.
    popup_browsers_.push_back(browser);

    // Give focus to the popup browser. Perform asynchronously because the
    // parent window may attempt to keep focus after launching the popup.
    CefPostTask(TID_UI,
        base::Bind(&CefBrowserHost::SetFocus, browser->GetHost().get(), true));
  }

  browser_count_++;
}
void ContextMenuHandler::OnBeforeContextMenu(CefRefPtr<CefBrowser> browser,
	CefRefPtr<CefFrame> frame,
	CefRefPtr<CefContextMenuParams> params,
	CefRefPtr<CefMenuModel> model)
{
	if (!GetCallback())
		return;

	ChromiumDLL::RefPtr<ChromiumDLL::ChromiumMenuInfoI> cmi = new ChromiumMenuInfo(params, GetBrowser()->GetHost()->GetWindowHandle());

	if (GetCallback()->handlePopupMenu(cmi))
		model->Clear();
}
Example #13
0
void QCefWebView::forward() {
    CefRefPtr<CefBrowser> browser = GetBrowser();
    if (browser.get())
        browser->GoForward();
}
Example #14
0
	__declspec(dllexport) void ReloadNUI()
	{
		auto rootWindow = Instance<NUIWindowManager>::Get()->GetRootWindow();

		rootWindow->GetBrowser()->ReloadIgnoreCache();
	}
Example #15
0
void QCefWebView::back() {
    CefRefPtr<CefBrowser> browser = GetBrowser();
    if (browser.get())
        browser->GoBack();
}
void LifeSpanHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser)
{
	if (GetBrowser() && GetBrowser()->GetHost()->GetWindowHandle() == 
		browser->GetHost()->GetWindowHandle())
		SetBrowser(NULL);
}
Example #17
0
void QCefWebView::reload() {
    CefRefPtr<CefBrowser> browser = GetBrowser();
    if (browser.get())
        browser->Reload();
}
Example #18
0
void QCefWebView::stop() {
    CefRefPtr<CefBrowser> browser = GetBrowser();
    if (browser.get())
        browser->StopLoad();
}