Пример #1
0
void CMainFrame::OnCefCallJavaScriptFunction()
{
  CCEFView *pView = CCEFView::GetView();
  CefRefPtr<CefBrowser> browser = pView->m_clientHandler->GetBrowser();
  CefRefPtr<CefFrame> frame = browser->GetMainFrame();
  CefPostTask(TID_UI, NewCefRunnableMethod(pView->m_clientHandler.get(), &ClientHandler::GetURL));
  frame->ExecuteJavaScript("foo();", "", 0);
  CefPostTask(TID_UI, NewCefRunnableMethod(pView->m_clientHandler.get(), &ClientHandler::JavaScriptTest));
}
Пример #2
0
  // The download is complete.
  virtual void Complete() {
    REQUIRE_UI_THREAD();

    // Flush and close the file on the FILE thread.
    CefPostTask(TID_FILE,
        NewCefRunnableMethod(this, &ClientDownloadHandler::OnComplete));
  }
Пример #3
0
  // A portion of the file contents have been received. This method will be
  // called multiple times until the download is complete. Return |true| to
  // continue receiving data and |false| to cancel.
  virtual bool ReceivedData(void* data, int data_size) {
    REQUIRE_UI_THREAD();

    if (data_size == 0)
      return true;
    received_size += data_size;
    buffer_size += data_size;

    // Create a new vector for the data.
    std::vector<char>* buffer = new std::vector<char>(data_size);
    memcpy(&(*buffer)[0], data, data_size);

    // Add the new data vector to the pending data queue.
    {
      AutoLock lock_scope(this);
      pending_data_.push_back(buffer);
    }

    // Write data to file on the FILE thread.
    if (buffer_size > flush_size) {
      buffer_size = 0;
      CefPostTask(TID_FILE,
          NewCefRunnableMethod(this, &ClientDownloadHandler::OnReceivedData));
    }
    return bcontinue;
  }
Пример #4
0
 void Initialize() {
   received_size = 0;
   buffer_size = 0;
   bcontinue = true;
   // Open the file on the FILE thread.
   CefPostTask(TID_FILE,
       NewCefRunnableMethod(this, &ClientDownloadHandler::OnOpen));
 }
Пример #5
0
    void LootHandler::CloseAllBrowsers(bool force_close) {
        if (!CefCurrentlyOn(TID_UI)) {
            // Execute on the UI thread.
            CefPostTask(TID_UI,
                        NewCefRunnableMethod(this, &LootHandler::CloseAllBrowsers, force_close));
            return;
        }

        if (browser_list_.empty())
            return;

        for (BrowserList::const_iterator it = browser_list_.begin(); it != browser_list_.end(); ++it) {
            (*it)->GetHost()->CloseBrowser(force_close);
        }
    }
Пример #6
0
  void OnComplete() {
    REQUIRE_FILE_THREAD();

    if (!file_)
      return;

    // Make sure any pending data is written.
    OnReceivedData();

    fclose(file_);
    file_ = NULL;

    // Notify the listener that the download completed.
    CefPostTask(TID_UI,
        NewCefRunnableMethod(this, &ClientDownloadHandler::SendComplete));
  }
void ApkAnalyzerHandler::CloseAllBrowsers(const
  bool force_close) {
  
  CefCurrentlyOn(TID_UI);
  if (!CefCurrentlyOn(TID_UI)) {
    CefPostTask(TID_UI, NewCefRunnableMethod(this, & ApkAnalyzerHandler::CloseAllBrowsers, force_close));
    return;
  }

  if (browser_list_.empty()) {
    return;
  }

  for (BrowserList::const_iterator iter = browser_list_.begin();
    iter != browser_list_.end(); ++iter) {
    (*iter)->GetHost()->CloseBrowser(force_close);
  }
}
Пример #8
0
void ClientHandler::CloseAllBrowsers(bool force_close) {
    qDebug() << __FUNCTION__ << __LINE__ << QThread::currentThreadId() << QCoreApplication::applicationPid ();
    if (!CefCurrentlyOn(TID_UI)) {
        // Execute on the UI thread.
        CefPostTask(TID_UI,
                    NewCefRunnableMethod(this, &ClientHandler::CloseAllBrowsers,
                                         force_close));
        return;
    }
    if (!m_PopupBrowsers.empty()) {
        // Request that any popup browsers close.
        BrowserList::const_iterator it = m_PopupBrowsers.begin();
        for (; it != m_PopupBrowsers.end(); ++it)
            (*it)->GetHost()->CloseBrowser(force_close);
    }
    if (m_Browser.get()) {
        // Request that the main browser close.
        m_Browser->GetHost()->CloseBrowser(force_close);
    }
}
Пример #9
0
void ClientHandler::CloseAllBrowsers(bool force_close)
{
	if (!CefCurrentlyOn(TID_UI)) {
		// Execute on the UI thread.
		CefPostTask(TID_UI,
		            NewCefRunnableMethod(this, &ClientHandler::CloseAllBrowsers,
		                                 force_close));
		return;
	}

	if (!m_PopupBrowsers.empty()) {
		// Request that any popup browsers close.
		BrowserList::const_iterator it = m_PopupBrowsers.begin();
		for (; it != m_PopupBrowsers.end(); ++it)
			(*it)->GetHost()->CloseBrowser(force_close);
	}

	for (auto it : ofxClientBrowserMap) {
		for (auto &cefbrowser : it.second) {
			DoClose(cefbrowser);
		}
		ofxClientBrowserMap.erase(it.first);
	}
}
Пример #10
0
JNIEXPORT void JNICALL Java_org_cef_browser_CefBrowser_1N_N_1ViewSource
  (JNIEnv *env, jobject obj) {
  CefRefPtr<CefBrowser> browser = JNI_GET_BROWSER_OR_RETURN(env, obj);
  CefRefPtr<CefFrame> mainFrame = browser->GetMainFrame();
  CefPostTask(TID_UI, NewCefRunnableMethod(mainFrame.get(), &CefFrame::ViewSource));
}
Пример #11
0
 void Initialize()
 {
   // Open the file on the FILE thread.
   CefPostTask(TID_FILE,
       NewCefRunnableMethod(this, &ClientDownloadHandler::OnOpen));
 }