Add JavaScript binding example to cefclient.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@591 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2012-04-12 21:58:35 +00:00
parent 647c74cf96
commit c7d9fb4abe
6 changed files with 48 additions and 17 deletions

13
cef.gyp
View File

@ -862,6 +862,11 @@
# creation of binary releases easier.
'tests'
],
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/AppKit.framework',
],
},
'sources': [
'<@(cefclient_sources_mac_helper)',
],
@ -907,14 +912,6 @@
'--keystone=0',
'--svn=0'],
},
{
# Make sure there isn't any Objective-C in the helper app's
# executable.
'postbuild_name': 'Verify No Objective-C',
'action': [
'../build/mac/verify_no_objc.sh',
],
},
],
}, # target cefclient_helper_app
{

View File

@ -80,6 +80,8 @@
'cefclient_sources_common': [
'tests/cefclient/cefclient.cpp',
'tests/cefclient/cefclient.h',
'tests/cefclient/binding_test.cpp',
'tests/cefclient/binding_test.h',
'tests/cefclient/client_app.cpp',
'tests/cefclient/client_app.h',
'tests/cefclient/client_app_delegates.cpp',
@ -114,7 +116,22 @@
'tests/cefclient/resource_util_mac.mm',
],
'cefclient_sources_mac_helper': [
'tests/cefclient/binding_test.cpp',
'tests/cefclient/binding_test.h',
'tests/cefclient/client_app.cpp',
'tests/cefclient/client_app.h',
'tests/cefclient/client_app_delegates.cpp',
'tests/cefclient/client_handler.cpp',
'tests/cefclient/client_handler.h',
'tests/cefclient/client_handler_mac.mm',
'tests/cefclient/client_switches.cpp',
'tests/cefclient/client_switches.h',
'tests/cefclient/process_helper_mac.cpp',
'tests/cefclient/resource_util.h',
'tests/cefclient/resource_util_mac.mm',
'tests/cefclient/string_util.cpp',
'tests/cefclient/string_util.h',
'tests/cefclient/util.h',
],
'cefclient_bundle_resources_mac': [
'tests/cefclient/mac/cefclient.icns',

View File

@ -35,7 +35,7 @@ class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate {
std::string result;
CefRefPtr<CefListValue> args = message->GetArgumentList();
if (args->GetSize() >= 0 && args->GetType(0) == VTYPE_STRING) {
if (args->GetSize() > 0 && args->GetType(0) == VTYPE_STRING) {
// Our result is a reverse of the original message.
result = args->GetString(0);
std::reverse(result.begin(), result.end());

View File

@ -11,8 +11,7 @@
#include "include/cef_process_message.h"
#include "include/cef_task.h"
#include "include/cef_v8.h"
#include "base/logging.h"
#include "util.h" // NOLINT(build/include)
namespace {
@ -40,7 +39,7 @@ void SetListValue(CefRefPtr<CefListValue> list, int index,
// Transfer a V8 array to a List.
void SetList(CefRefPtr<CefV8Value> source, CefRefPtr<CefListValue> target) {
DCHECK(source->IsArray());
ASSERT(source->IsArray());
int arg_length = source->GetArrayLength();
if (arg_length == 0)
@ -90,7 +89,7 @@ void SetListValue(CefRefPtr<CefV8Value> list, int index,
// Transfer a List to a V8 array.
void SetList(CefRefPtr<CefListValue> source, CefRefPtr<CefV8Value> target) {
DCHECK(target->IsArray());
ASSERT(target->IsArray());
int arg_length = source->GetSize();
if (arg_length == 0)
@ -121,7 +120,7 @@ class ClientAppExtensionHandler : public CefV8Handler {
arguments[0]->IsString()) {
CefRefPtr<CefBrowser> browser =
CefV8Context::GetCurrentContext()->GetBrowser();
DCHECK(browser.get());
ASSERT(browser.get());
CefString name = arguments[0]->GetStringValue();
if (!name.empty()) {
@ -183,7 +182,7 @@ void ClientApp::SetMessageCallback(const std::string& message_name,
int browser_id,
CefRefPtr<CefV8Context> context,
CefRefPtr<CefV8Value> function) {
DCHECK(CefCurrentlyOn(TID_RENDERER));
ASSERT(CefCurrentlyOn(TID_RENDERER));
callback_map_.insert(
std::make_pair(std::make_pair(message_name, browser_id),
@ -192,7 +191,7 @@ void ClientApp::SetMessageCallback(const std::string& message_name,
bool ClientApp::RemoveMessageCallback(const std::string& message_name,
int browser_id) {
DCHECK(CefCurrentlyOn(TID_RENDERER));
ASSERT(CefCurrentlyOn(TID_RENDERER));
CallbackMap::iterator it =
callback_map_.find(std::make_pair(message_name, browser_id));
@ -274,7 +273,7 @@ bool ClientApp::OnProcessMessageRecieved(
CefRefPtr<CefBrowser> browser,
CefProcessId source_process,
CefRefPtr<CefProcessMessage> message) {
DCHECK(source_process == PID_BROWSER);
ASSERT(source_process == PID_BROWSER);
bool handled = false;

View File

@ -0,0 +1,9 @@
// Copyright (c) 2012 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 "cefclient/client_app.h"
// static
void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) {
}

View File

@ -8,6 +8,15 @@
// a qualified path.
#include "client_app.h" // NOLINT(build/include)
// Stub implementations.
std::string AppGetWorkingDirectory() {
return std::string();
}
CefWindowHandle AppGetMainHwnd() {
return NULL;
}
// Process entry point.
int main(int argc, char* argv[]) {
CefMainArgs main_args(argc, argv);