mirror of
https://github.com/atom/atom.git
synced 2026-01-25 14:59:03 -05:00
Update cef3 artifacts
This commit is contained in:
@@ -10,24 +10,39 @@
|
||||
#include "include/cef_browser.h"
|
||||
#include "include/cef_frame.h"
|
||||
#include "atom.h"
|
||||
#include "native_handler.h"
|
||||
#include "atom.h"
|
||||
#include <stdlib.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
ClientHandler::ClientHandler() :
|
||||
m_MainHwnd(NULL), m_BrowserHwnd(NULL) {
|
||||
m_nativeHandler = new NativeHandler();
|
||||
}
|
||||
|
||||
ClientHandler::~ClientHandler() {
|
||||
}
|
||||
|
||||
bool ClientHandler::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
|
||||
CefProcessId source_process, CefRefPtr<CefProcessMessage> message) {
|
||||
std::string name = message->GetName().ToString();
|
||||
std::cout << "Message " << name << std::endl;
|
||||
if (name == "showDevTools") {
|
||||
std::string devtools_url = browser->GetHost()->GetDevToolsURL(true);
|
||||
std::cout << "url" << devtools_url << std::endl;
|
||||
if (!devtools_url.empty()) {
|
||||
browser->GetMainFrame()->ExecuteJavaScript(
|
||||
"window.open('" + devtools_url + "');", "about:blank", 0);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
AutoLock lock_scope(this);
|
||||
if (!m_Browser.get()) {
|
||||
if (!m_Browser.get()) {
|
||||
// We need to keep the main child window, but not popup windows
|
||||
m_Browser = browser;
|
||||
m_BrowserId = browser->GetIdentifier();
|
||||
@@ -72,39 +87,6 @@ void ClientHandler::OnLoadStart(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
if (m_BrowserId == browser->GetIdentifier() && frame->IsMain()) {
|
||||
CefRefPtr<CefV8Context> context = frame->GetV8Context();
|
||||
CefRefPtr<CefV8Value> global = context->GetGlobal();
|
||||
context->Enter();
|
||||
|
||||
CefRefPtr<CefV8Value> windowNumber = CefV8Value::CreateInt(0);
|
||||
global->SetValue("$windowNumber", windowNumber, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
std::string path;
|
||||
if (m_nativeHandler && !m_nativeHandler->path.empty())
|
||||
path = m_nativeHandler->path;
|
||||
else
|
||||
path.append(PathToOpen());
|
||||
|
||||
CefRefPtr<CefV8Value> pathToOpen = CefV8Value::CreateString(path);
|
||||
global->SetValue("$pathToOpen", pathToOpen, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
m_nativeHandler->window = window;
|
||||
m_nativeHandler->path = path;
|
||||
|
||||
CefRefPtr<CefV8Value> atom = CefV8Value::CreateObject(NULL);
|
||||
global->SetValue("atom", atom, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
CefRefPtr<CefV8Value> loadPath = CefV8Value::CreateString(AppPath());
|
||||
atom->SetValue("loadPath", loadPath, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
CefRefPtr<CefV8Value> bootstrapScript = CefV8Value::CreateString(
|
||||
"single-window-bootstrap");
|
||||
global->SetValue("$bootstrapScript", bootstrapScript,
|
||||
V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
context->Exit();
|
||||
}
|
||||
}
|
||||
|
||||
void ClientHandler::OnLoadEnd(CefRefPtr<CefBrowser> browser,
|
||||
|
||||
Reference in New Issue
Block a user