mirror of
https://github.com/atom/atom.git
synced 2026-01-14 17:38:03 -05:00
Merge branch 'master' of github.com:github/atom-cef3
Conflicts: native/atom_cef_client.cpp
This commit is contained in:
2
atom.gyp
2
atom.gyp
@@ -66,7 +66,6 @@
|
||||
'native/atom_cef_client.h',
|
||||
'native/message_translation.cpp',
|
||||
'native/message_translation.h',
|
||||
'native/util.h',
|
||||
],
|
||||
'mac_bundle_resources': [
|
||||
'native/mac/atom.icns',
|
||||
@@ -284,7 +283,6 @@
|
||||
'native/path_watcher.mm',
|
||||
'native/path_watcher.h',
|
||||
'native/main_helper_mac.mm',
|
||||
'native/util.h',
|
||||
'native/v8_extensions/native.mm',
|
||||
'native/v8_extensions/native.h',
|
||||
'native/v8_extensions/onig_reg_exp.mm',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef CEF_TESTS_CEFCLIENT_CLIENT_APP_H_
|
||||
#define CEF_TESTS_CEFCLIENT_CLIENT_APP_H_
|
||||
#ifndef ATOM_CEF_APP_H_
|
||||
#define ATOM_CEF_APP_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_app.h"
|
||||
@@ -10,16 +10,13 @@
|
||||
|
||||
class AtomCefApp : public CefApp {
|
||||
|
||||
// CefApp methods
|
||||
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() OVERRIDE {
|
||||
#ifdef PROCESS_HELPER_APP
|
||||
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() OVERRIDE {
|
||||
return CefRefPtr<CefRenderProcessHandler>(new AtomCefRenderProcessHandler);
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
IMPLEMENT_REFCOUNTING(AtomCefApp);
|
||||
};
|
||||
|
||||
#endif // CEF_TESTS_CEFCLIENT_CLIENT_APP_H_
|
||||
#endif
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <assert.h>
|
||||
#include "include/cef_path_util.h"
|
||||
#include "include/cef_process_util.h"
|
||||
#include "include/cef_task.h"
|
||||
#include "include/cef_runnable.h"
|
||||
#include "native/atom_cef_client.h"
|
||||
#include "cef_v8.h"
|
||||
|
||||
AtomCefClient::AtomCefClient(){
|
||||
#define REQUIRE_UI_THREAD() assert(CefCurrentlyOn(TID_UI));
|
||||
#define REQUIRE_IO_THREAD() assert(CefCurrentlyOn(TID_IO));
|
||||
#define REQUIRE_FILE_THREAD() assert(CefCurrentlyOn(TID_FILE));
|
||||
|
||||
AtomCefClient::AtomCefClient(){
|
||||
}
|
||||
|
||||
AtomCefClient::~AtomCefClient() {
|
||||
}
|
||||
|
||||
|
||||
bool AtomCefClient::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
|
||||
CefProcessId source_process,
|
||||
CefRefPtr<CefProcessMessage> message) {
|
||||
@@ -28,20 +28,14 @@ bool AtomCefClient::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
|
||||
if (name == "open") {
|
||||
bool hasArguments = argumentList->GetSize() > 1;
|
||||
hasArguments ? Open(argumentList->GetString(1)) : Open();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (name == "newWindow") {
|
||||
else if (name == "newWindow") {
|
||||
NewWindow();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (name == "toggleDevTools") {
|
||||
else if (name == "toggleDevTools") {
|
||||
ToggleDevTools(browser);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (name == "confirm") {
|
||||
else if (name == "confirm") {
|
||||
std::string message = argumentList->GetString(1).ToString();
|
||||
std::string detailedMessage = argumentList->GetString(2).ToString();
|
||||
std::vector<std::string> buttonLabels(argumentList->GetSize() - 3);
|
||||
@@ -50,18 +44,18 @@ bool AtomCefClient::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
|
||||
}
|
||||
|
||||
Confirm(messageId, message, detailedMessage, buttonLabels, browser);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (name == "showSaveDialog") {
|
||||
else if (name == "showSaveDialog") {
|
||||
ShowSaveDialog(messageId, browser);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void AtomCefClient::OnBeforeContextMenu(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
@@ -118,7 +112,7 @@ void AtomCefClient::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
|
||||
// this was in cefclient... was there a good reason?
|
||||
// TODO: Ask Marshal. This was in cefclient... was there a good reason?
|
||||
// if(m_BrowserHwnd == browser->GetWindowHandle()) {
|
||||
// // Free the browser pointer so that the browser can be destroyed
|
||||
// m_Browser = NULL;
|
||||
@@ -144,18 +138,5 @@ void AtomCefClient::OnLoadError(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& errorText,
|
||||
const CefString& failedUrl) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
if (errorCode == ERR_ABORTED) { // Don't display an error for downloaded files.
|
||||
return;
|
||||
}
|
||||
else if (errorCode == ERR_UNKNOWN_URL_SCHEME) { // Don't display an error for external protocols that we allow the OS to handle. See OnProtocolExecution().
|
||||
return;
|
||||
}
|
||||
else {
|
||||
std::stringstream ss;
|
||||
ss << "<html><body><h2>Failed to load URL " << std::string(failedUrl) <<
|
||||
" with error " << std::string(errorText) << " (" << errorCode <<
|
||||
").</h2></body></html>";
|
||||
frame->LoadString(ss.str(), failedUrl);
|
||||
}
|
||||
frame->LoadString(std::string(errorText) + "<br />" + std::string(failedUrl), failedUrl);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,11 @@
|
||||
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_TESTS_CEFCLIENT_CLIENT_HANDLER_H_
|
||||
#define CEF_TESTS_CEFCLIENT_CLIENT_HANDLER_H_
|
||||
#ifndef ATOM_CEF_CLIENT_H_
|
||||
#define ATOM_CEF_CLIENT_H_
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include "include/cef_client.h"
|
||||
#include "native/util.h"
|
||||
|
||||
|
||||
// AtomCefClient implementation.
|
||||
class AtomCefClient : public CefClient,
|
||||
public CefContextMenuHandler,
|
||||
public CefDisplayHandler,
|
||||
@@ -119,4 +112,4 @@ class AtomCefClient : public CefClient,
|
||||
IMPLEMENT_LOCKING(AtomCefClient);
|
||||
};
|
||||
|
||||
#endif // CEF_TESTS_CEFCLIENT_CLIENT_HANDLER_H_
|
||||
#endif
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
- (id)initWithBootstrapScript:(NSString *)bootstrapScript background:(BOOL)background {
|
||||
self = [super initWithWindowNibName:@"AtomWindow"];
|
||||
|
||||
_bootstrapScript = [bootstrapScript retain];
|
||||
|
||||
if (!background) {
|
||||
@@ -73,22 +72,32 @@
|
||||
|
||||
- (void)toggleDevTools {
|
||||
if (_devToolsView) {
|
||||
[_devToolsView removeFromSuperview];
|
||||
[_devToolsView release];
|
||||
_devToolsView = nil;
|
||||
_cefDevToolsClient = NULL;
|
||||
_cefClient->GetBrowser()->GetHost()->SetFocus(true);
|
||||
[_splitView adjustSubviews];
|
||||
[self hideDevTools];
|
||||
}
|
||||
else if (_cefClient && _cefClient->GetBrowser()) {
|
||||
NSRect frame = NSMakeRect(0, 0, _splitView.frame.size.width, _splitView.frame.size.height);
|
||||
_devToolsView = [[NSView alloc] initWithFrame:frame];
|
||||
else {
|
||||
[self showDevTools];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showDevTools {
|
||||
if (_cefClient && _cefClient->GetBrowser()) {
|
||||
_devToolsView = [[NSView alloc] initWithFrame:_splitView.bounds];
|
||||
[_splitView addSubview:_devToolsView];
|
||||
[_splitView adjustSubviews];
|
||||
std::string devtools_url = _cefClient->GetBrowser()->GetHost()->GetDevToolsURL(true);
|
||||
|
||||
_cefDevToolsClient = new AtomCefClient();
|
||||
std::string devtools_url = _cefClient->GetBrowser()->GetHost()->GetDevToolsURL(true);
|
||||
[self addBrowserToView:_devToolsView url:devtools_url.c_str() cefHandler:_cefDevToolsClient];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)hideDevTools {
|
||||
[_devToolsView removeFromSuperview];
|
||||
[_splitView adjustSubviews];
|
||||
[_devToolsView release];
|
||||
_devToolsView = nil;
|
||||
_cefDevToolsClient = NULL;
|
||||
_cefClient->GetBrowser()->GetHost()->SetFocus(true);
|
||||
}
|
||||
|
||||
# pragma mark NSWindowDelegate
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <assert.h>
|
||||
#include "message_translation.h"
|
||||
#include "util.h"
|
||||
|
||||
// Transfer a V8 value to a List index.
|
||||
void TranslateListValue(CefRefPtr<CefListValue> list, int index, CefRefPtr<CefV8Value> value) {
|
||||
@@ -20,7 +20,7 @@ void TranslateListValue(CefRefPtr<CefListValue> list, int index, CefRefPtr<CefV8
|
||||
|
||||
// Transfer a V8 array to a List.
|
||||
void TranslateList(CefRefPtr<CefV8Value> source, CefRefPtr<CefListValue> target) {
|
||||
ASSERT(source->IsArray());
|
||||
assert(source->IsArray());
|
||||
|
||||
int arg_length = source->GetArrayLength();
|
||||
if (arg_length == 0)
|
||||
@@ -70,7 +70,7 @@ void TranslateListValue(CefRefPtr<CefV8Value> list, int index, CefRefPtr<CefList
|
||||
|
||||
// Transfer a List to a V8 array.
|
||||
void TranslateList(CefRefPtr<CefListValue> source, CefRefPtr<CefV8Value> target) {
|
||||
ASSERT(target->IsArray());
|
||||
assert(target->IsArray());
|
||||
|
||||
int arg_length = source->GetSize();
|
||||
if (arg_length == 0)
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
#ifndef ATOM_CEF_CLIENT_H_
|
||||
#define ATOM_CEF_CLIENT_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_v8.h"
|
||||
|
||||
// IPC data translation functions: translate a V8 array to a List, and vice versa
|
||||
void TranslateList(CefRefPtr<CefV8Value> source, CefRefPtr<CefListValue> target);
|
||||
void TranslateList(CefRefPtr<CefListValue> source, CefRefPtr<CefV8Value> target);
|
||||
|
||||
#endif
|
||||
@@ -1,19 +0,0 @@
|
||||
#ifndef CEF_TESTS_CEFCLIENT_UTIL_H_
|
||||
#define CEF_TESTS_CEFCLIENT_UTIL_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_task.h"
|
||||
|
||||
#include <assert.h> // NOLINT(build/include_order)
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define ASSERT(condition) if (!(condition)) { assert(false); }
|
||||
#else
|
||||
#define ASSERT(condition) ((void)0)
|
||||
#endif
|
||||
|
||||
#define REQUIRE_UI_THREAD() ASSERT(CefCurrentlyOn(TID_UI));
|
||||
#define REQUIRE_IO_THREAD() ASSERT(CefCurrentlyOn(TID_IO));
|
||||
#define REQUIRE_FILE_THREAD() ASSERT(CefCurrentlyOn(TID_FILE));
|
||||
|
||||
#endif // CEF_TESTS_CEFCLIENT_UTIL_H_
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#import "atom.h"
|
||||
#import "atom_application.h"
|
||||
#import "util.h"
|
||||
#import "message_translation.h"
|
||||
|
||||
namespace v8_extensions {
|
||||
|
||||
Reference in New Issue
Block a user