mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
Upgrade to cef3
This commit is contained in:
@@ -27,17 +27,17 @@ 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_BrowserHwnd = browser->GetWindowHandle();
|
||||
m_BrowserId = browser->GetIdentifier();
|
||||
}
|
||||
}
|
||||
|
||||
bool ClientHandler::DoClose(CefRefPtr<CefBrowser> browser) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
if (m_BrowserHwnd == browser->GetWindowHandle()) {
|
||||
if (m_BrowserId == browser->GetIdentifier()) {
|
||||
// Since the main window contains the browser window, we need to close
|
||||
// the parent window instead of the browser window.
|
||||
CloseMainWindow();
|
||||
@@ -56,9 +56,15 @@ bool ClientHandler::DoClose(CefRefPtr<CefBrowser> browser) {
|
||||
void ClientHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
if (m_BrowserHwnd == browser->GetWindowHandle()) {
|
||||
if (m_BrowserId == browser->GetIdentifier()) {
|
||||
// Free the browser pointer so that the browser can be destroyed
|
||||
m_Browser = NULL;
|
||||
} else if (browser->IsPopup()) {
|
||||
// Remove the record for DevTools popup windows.
|
||||
//std::set<std::string>::iterator it =
|
||||
// m_OpenDevToolsURLs.find(browser->GetMainFrame()->GetURL());
|
||||
//if (it != m_OpenDevToolsURLs.end())
|
||||
// m_OpenDevToolsURLs.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +72,7 @@ void ClientHandler::OnLoadStart(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
if (m_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain()) {
|
||||
if (m_BrowserId == browser->GetIdentifier() && frame->IsMain()) {
|
||||
CefRefPtr<CefV8Context> context = frame->GetV8Context();
|
||||
CefRefPtr<CefV8Value> global = context->GetGlobal();
|
||||
context->Enter();
|
||||
@@ -86,7 +92,7 @@ void ClientHandler::OnLoadStart(CefRefPtr<CefBrowser> browser,
|
||||
m_nativeHandler->window = window;
|
||||
m_nativeHandler->path = path;
|
||||
|
||||
CefRefPtr<CefV8Value> atom = CefV8Value::CreateObject(NULL, NULL);
|
||||
CefRefPtr<CefV8Value> atom = CefV8Value::CreateObject(NULL);
|
||||
global->SetValue("atom", atom, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
CefRefPtr<CefV8Value> loadPath = CefV8Value::CreateString(AppPath());
|
||||
@@ -152,52 +158,6 @@ void ClientHandler::OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
|
||||
REQUIRE_UI_THREAD();
|
||||
}
|
||||
|
||||
bool ClientHandler::OnKeyEvent(CefRefPtr<CefBrowser> browser, KeyEventType type,
|
||||
int code, int modifiers, bool isSystemKey, bool isAfterJavaScript) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ClientHandler::GetPrintHeaderFooter(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, const CefPrintInfo& printInfo,
|
||||
const CefString& url, const CefString& title, int currentPage, int maxPages,
|
||||
CefString& topLeft, CefString& topCenter, CefString& topRight,
|
||||
CefString& bottomLeft, CefString& bottomCenter, CefString& bottomRight) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
// Place the page title at top left
|
||||
topLeft = title;
|
||||
// Place the page URL at top right
|
||||
topRight = url;
|
||||
|
||||
// Place "Page X of Y" at bottom center
|
||||
std::stringstream strstream;
|
||||
strstream << "Page " << currentPage << " of " << maxPages;
|
||||
bottomCenter = strstream.str();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ClientHandler::OnContextCreated(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) {
|
||||
REQUIRE_UI_THREAD();
|
||||
}
|
||||
|
||||
bool ClientHandler::OnDragStart(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefDragData> dragData, DragOperationsMask mask) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ClientHandler::OnDragEnter(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefDragData> dragData, DragOperationsMask mask) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ClientHandler::SetWindow(GtkWidget* widget) {
|
||||
window = widget;
|
||||
}
|
||||
@@ -250,7 +210,7 @@ void ClientHandler::OnTitleChange(CefRefPtr<CefBrowser> browser,
|
||||
formatted.append(" - atom");
|
||||
|
||||
GtkWidget* window = gtk_widget_get_ancestor(
|
||||
GTK_WIDGET(browser->GetWindowHandle()), GTK_TYPE_WINDOW);
|
||||
GTK_WIDGET(browser->GetHost()->GetWindowHandle()), GTK_TYPE_WINDOW);
|
||||
gtk_window_set_title(GTK_WINDOW(window), formatted.c_str());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user