Пример #1
0
void ClientHandler::AddDOMVisitor(const std::string& path,
                                  CefRefPtr<CefDOMVisitor> visitor)
{
  AutoLock lock_scope(this);
  DOMVisitorMap::iterator it = m_DOMVisitors.find(path);
  if (it == m_DOMVisitors.end())
    m_DOMVisitors.insert(std::make_pair(path, visitor));
  else
    it->second = visitor;
}
Пример #2
0
void ClientHandler::SetButtonHwnds(CefWindowHandle backHwnd,
                                   CefWindowHandle forwardHwnd,
                                   CefWindowHandle reloadHwnd,
                                   CefWindowHandle stopHwnd) {
  AutoLock lock_scope(this);
  m_BackHwnd = backHwnd;
  m_ForwardHwnd = forwardHwnd;
  m_ReloadHwnd = reloadHwnd;
  m_StopHwnd = stopHwnd;
}
Пример #3
0
void ClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
  REQUIRE_UI_THREAD();

  AutoLock lock_scope(this);
  if (!m_Browser.get())   {
    // We need to keep the main child window, but not popup windows
    m_Browser = browser;
    m_BrowserHwnd = browser->GetWindowHandle();
  }
}
Пример #4
0
void
Condition::setFalse(void)
{
    MutexLock lock_scope(_mutex);

    _state = 0;

#if defined(POSIX_THREADS)
    cond_broadcast((cond_t *)_condition); // Wake all sleepers.
#endif
}
Пример #5
0
void WebKitHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) 
{
	REQUIRE_UI_THREAD();
	AutoLock lock_scope(this);
	if (!control->m_Browser.get())   					
	{
		debugPrint("Browser Created.\n");						   
		control->m_Browser = browser;
		control->m_BrowserHwnd = WINDOW_HANDLE(browser);		
	}
}
Пример #6
0
	void IBrowserHandler::SetButtonHwnds(	CefWindowHandle backHwnd,
											CefWindowHandle forwardHwnd,
											CefWindowHandle reloadHwnd,
											CefWindowHandle stopHwnd) 
	{
			AutoLock lock_scope(this);
			m_backHwnd = backHwnd;
			m_forwardHwnd = forwardHwnd;
			m_reloadHwnd = reloadHwnd;
			m_stopHwnd = stopHwnd;
	}
Пример #7
0
bool CefClientImpl::DoClose(CefRefPtr<CefBrowser> browser) {
	CEF_REQUIRE_UI_THREAD();

	if (GetBrowserId() == browser->GetIdentifier()) {
		base::AutoLock lock_scope(lock_);
		// Set a flag to indicate that the window close should be allowed.
		is_closing_ = true;
	}

	return false;
}
Пример #8
0
    void LootState::ChangeGame(const std::string& newGameFolder) {
        // Acquire the lock for the scope of this method.
        base::AutoLock lock_scope(_lock);

        BOOST_LOG_TRIVIAL(debug) << "Changing current game to that with folder: " << newGameFolder;
        _currentGame = find(_games.begin(), _games.end(), newGameFolder);
        _currentGame->Init(true);

        // Update game path in settings object.
        _settings["games"] = ToGameSettings(_games);
        BOOST_LOG_TRIVIAL(debug) << "New game is " << _currentGame->Name();
    }
Пример #9
0
int
DtMail::Session::lookupImpl(const char * impl)
{
    MutexLock lock_scope(_obj_mutex);
    for(int i = 0; i < _num_impls; i++) {
	if (strcmp(_impls[i].impl_name, impl) == 0) {
	    return(i);
	}
    }

    return(-1);
}
Пример #10
0
bool ClientHandler::OnConsoleMessage(CefRefPtr<CefBrowser> browser,
                                     const CefString& message,
                                     const CefString& source,
                                     int line)
{
  REQUIRE_UI_THREAD();

  bool first_message;
  std::string logFile;

  {
    AutoLock lock_scope(this);
    
    first_message = m_LogFile.empty();
    if(first_message) {
      std::stringstream ss;
      ss << AppGetWorkingDirectory();
#if defined(OS_WIN)
      ss << "\\";
#else
      ss << "/";
#endif
      ss << "console.log";
      m_LogFile = ss.str();
    }
    logFile = m_LogFile;
}
  
  FILE* file = fopen(logFile.c_str(), "a");
  if(file) {
    std::stringstream ss;
    ss << "Message: " << std::string(message) << "\r\nSource: " <<
        std::string(source) << "\r\nLine: " << line <<
        "\r\n-----------------------\r\n";
    fputs(ss.str().c_str(), file);
    fclose(file);

    if(first_message)
      SendNotification(NOTIFY_CONSOLE_MESSAGE);
  }

  if( browser ) {
    //auto show console if something is Uncaught
    std::string strMsg(message);
    const char * err = "Uncaught ";
    if( 0 == strncmp(strMsg.c_str(), err, strlen(err) ) ) {
      browser->ShowDevTools();
    }
  }

  return false;
}
Пример #11
0
int
Condition::operator+=(int new_state)
{
    MutexLock lock_scope(_mutex);

    _state += new_state;

#if defined(POSIX_THREADS)
    cond_broadcast((cond_t *)_condition); // Wake all sleepers.
#endif

    return(_state);
}
Пример #12
0
size_t BytesWriteHandler::Write(const void* ptr, size_t size, size_t n) {
  base::AutoLock lock_scope(lock_);
  size_t rv;
  if (offset_ + static_cast<int64>(size * n) >= datasize_ &&
      Grow(size * n) == 0) {
    rv = 0;
  } else {
    memcpy(reinterpret_cast<char*>(data_) + offset_, ptr, size * n);
    offset_ += size * n;
    rv = n;
  }

  return rv;
}
Пример #13
0
/*virtual*/ void CWebClient::OnAfterCreated(CefRefPtr<CefBrowser> browser) /*OVERRIDE*/
{
	CEF_REQUIRE_UI_THREAD();
	base::AutoLock lock_scope(lock_);
	if (!main_browser_.get())
	{
		
		main_browser_ = browser;
	}
	else
	{
		browsers_list_.push_back(browser);
	}
}
Пример #14
0
  void OnOpen()
  {
    REQUIRE_FILE_THREAD();

    if(file_)
      return;
    
#if defined(OS_WIN)
    TCHAR szFolderPath[MAX_PATH];

    // Save the file in the user's "My Documents" folder.
    if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL|CSIDL_FLAG_CREATE, 
                                 NULL, 0, szFolderPath))) {
      std::wstring fileNameStr = filename_;
      LPWSTR name = PathFindFileName(fileNameStr.c_str());
      LPWSTR ext = PathFindExtension(fileNameStr.c_str());
      int ct = 0;
      std::wstringstream ss;

      if(ext) {
        name[ext-name] = 0;
        ext++;
      }

      // Make sure the file name is unique.
      do {
        if(ct > 0)
          ss.str(L"");
        ss << szFolderPath << L"\\" << name;
        if(ct > 0)
          ss << L" (" << ct << L")";
        if(ext)
          ss << L"." << ext;
        ct++;
      } while(PathFileExists(ss.str().c_str()));

      {
        AutoLock lock_scope(this);
        filename_ = ss.str();
      }

      file_ = _wfopen(ss.str().c_str(), L"wb");
      ASSERT(file_ != NULL);
    }
#else
    // TODO(port): Implement this.
    ASSERT(false); // Not implemented
#endif
  }
Пример #15
0
bool ClientHandler::OnProcessMessageReceived(
    CefRefPtr<CefBrowser> browser,
    CefProcessId source_process,
    CefRefPtr<CefProcessMessage> message) {
  std::set<CefRefPtr<CefMessageRouterBrowserSide> >::iterator iter;
  bool handled = false;
  
  base::AutoLock lock_scope(lock_);
  for (iter = message_router_.begin(); iter != message_router_.end(); iter++) {
    handled = (*iter)->OnProcessMessageReceived(browser, source_process, message);
    if (handled)
      break;
  }
  return handled;
}
void ClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
  REQUIRE_UI_THREAD();

  AutoLock lock_scope(this);
  if (!m_Browser.get())   {
    // We need to keep the main child window, but not popup windows
    m_Browser = browser;
    m_BrowserId = browser->GetIdentifier();
  } else {
    // Call the platform-specific code to hook up popup windows
    PopupCreated(browser);
  }

  browser_window_map_[browser->GetHost()->GetWindowHandle()] = browser;
}
Пример #17
0
    void ClientAdapter::OnLoadStart(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame)
    {
        if (browser->IsPopup())
        {
            return;
        }

        AutoLock lock_scope(this);
        if (frame->IsMain())
        {
            _browserControl->SetNavState(true, false, false);
        }

        _browserControl->AddFrame(frame);
    }
Пример #18
0
    void ClientAdapter::OnLoadEnd(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, int httpStatusCode)
    {
        if(browser->IsPopup())
        {
            return;
        }

        AutoLock lock_scope(this);
        if (frame->IsMain())
        {
            _browserControl->SetNavState(false, browser->CanGoBack(), browser->CanGoForward());        
        }

        _browserControl->FrameLoadComplete(frame);
    }
Пример #19
0
void
Condition::waitLT(int new_state)
{
    // Wait for the condition to become true.
    //
#if defined(POSIX_THREADS)
    MutexLock lock_scope(_mutex);

    while(_state < new_state) {
	cond_wait((cond_t *)_condition, (mutex_t *)_mutex);
    }
#endif

    return;
}
Пример #20
0
void
DtMail::Session::setDefaultImpl(DtMailEnv & error, const char * impl)
{
    int slot = lookupImpl(impl);

    if (slot < 0) {
	error.setError(DTME_NoSuchImplementation);
	return;
    }

    MutexLock lock_scope(_obj_mutex);

    _default_impl = slot;
    error.clear();
}
Пример #21
0
size_t BytesWriteHandler::Grow(size_t size) {
  base::AutoLock lock_scope(lock_);
  size_t rv;
  size_t s = (size > grow_ ? size : grow_);
  void* tmp = realloc(data_, datasize_ + s);
  DCHECK(tmp != NULL);
  if (tmp) {
    data_ = tmp;
    datasize_ += s;
    rv = datasize_;
  } else {
    rv = 0;
  }

  return rv;
}
Пример #22
0
    size_t StreamAdapter::Read(void* ptr, size_t size, size_t n)
    {
        AutoLock lock_scope(this);

        try {
            array<Byte>^ buffer = gcnew array<Byte>(n * size);
            int ret = _stream->Read(buffer, 0, n);
            pin_ptr<Byte> src = &buffer[0];
            memcpy(ptr, static_cast<void*>(src), ret);
            return ret / size;	
        } 
        catch(Exception^)
        {
            return -1;
        }
    }
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()) {
    base::AutoLock lock_scope(lock_);
    // 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;
}
Пример #24
0
void
Condition::wait(void)
{
    // Wait for anything to change.
    //
#if defined(POSIX_THREADS)
    MutexLock lock_scope(_mutex);

    timestruc_t	abstime;
    abstime.tv_sec = time(NULL) + 1; // Wait for 1 second.
    abstime.tv_nsec = 0;

    cond_timedwait((cond_t *)_condition, (mutex_t *)_mutex, &abstime);
#endif

    return;
}
Пример #25
0
size_t WriteHandler::Write(const void* ptr, size_t size, size_t n) {
  base::AutoLock lock_scope(lock_);
  size_t rv = n;
  BEGIN_ENV(env)
  jbyteArray jbyteArray = env->NewByteArray((jsize)(size * n));
  env->SetByteArrayRegion(jbyteArray, 0, (jsize)(size * n), (const jbyte*)ptr);

  JNI_CALL_VOID_METHOD_EX(env, jOutputStream_, "write", "([B)V", jbyteArray);
  if (env->ExceptionOccurred()) {
    env->ExceptionClear();
    rv = 0;
  }
  offset_ += (rv * size);
  END_ENV(env)

  return rv;
}
Пример #26
0
void
Condition::waitProcStatus(void)
{
    // Wait for the condition to become true.
    //
#if defined(POSIX_THREADS)
    MutexLock lock_scope(_mutex);

    while(_state < 0) {
	cond_wait((cond_t *)_condition, (mutex_t *)_mutex);
    }
#else
    _state = 0;
#endif

    return;
}
Пример #27
0
void
Condition::waitTrue(void)
{
    // Wait for the condition to become true.
    //
#if defined(POSIX_THREADS)
    MutexLock lock_scope(_mutex);

    while(!_state) {
	cond_wait((cond_t *)_condition, (mutex_t *)_mutex);
    }
#else
    _state = 1; // Must set of single threaded apps.
#endif

    return;
}
Пример #28
0
void Client::OnAfterCreated( CefRefPtr<CefBrowser> browser )
{
  CEF_REQUIRE_UI_THREAD();
  AutoLock lock_scope(this);
  if (!_browser.get())
  {
    // We need to keep the main child window, but not popup windows
    _browser = browser;
    _browserId = browser->GetIdentifier();
  } 
  else if (browser->IsPopup())
  {
    // Add to the list of popup browsers.
    _popupBrowsers.push_back(browser);
  }

  _browserCount++;
}
Пример #29
0
void ClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
  REQUIRE_UI_THREAD();

  AutoLock lock_scope(this);
  if (!m_Browser.get())   {
    // We need to keep the main child window, but not popup windows
    m_Browser = browser;
    m_BrowserId = browser->GetIdentifier();
    if (listener_) {
      listener_->OnAfterCreated();
    }
  } else if (browser->IsPopup()) {
    // Add to the list of popup browsers.
    m_PopupBrowsers.push_back(browser);
  }

  m_BrowserCount++;
}
void ClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
  REQUIRE_UI_THREAD();

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

  AutoLock lock_scope(this);
  if (!m_Browser.get())   {
    // We need to keep the main child window, but not popup windows
    m_Browser = browser;
    m_BrowserId = browser->GetIdentifier();
  } else if (browser->IsPopup()) {
    // Add to the list of popup browsers.
    m_PopupBrowsers.push_back(browser);
  }

  m_BrowserCount++;
}