From c7d9fb4abe05f93a9b131fce1755acd790c36fc2 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 12 Apr 2012 21:58:35 +0000 Subject: [PATCH] Add JavaScript binding example to cefclient. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@591 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- cef.gyp | 13 +++++-------- cef_paths2.gypi | 17 +++++++++++++++++ tests/cefclient/binding_test.cpp | 2 +- tests/cefclient/client_app.cpp | 15 +++++++-------- tests/cefclient/client_app_delegates.cpp | 9 +++++++++ tests/cefclient/process_helper_mac.cpp | 9 +++++++++ 6 files changed, 48 insertions(+), 17 deletions(-) create mode 100644 tests/cefclient/client_app_delegates.cpp diff --git a/cef.gyp b/cef.gyp index ae86e7a3e..5dfc472f3 100644 --- a/cef.gyp +++ b/cef.gyp @@ -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 { diff --git a/cef_paths2.gypi b/cef_paths2.gypi index 34e1230f8..860101fb1 100644 --- a/cef_paths2.gypi +++ b/cef_paths2.gypi @@ -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', diff --git a/tests/cefclient/binding_test.cpp b/tests/cefclient/binding_test.cpp index bb9c1d770..ca8634686 100644 --- a/tests/cefclient/binding_test.cpp +++ b/tests/cefclient/binding_test.cpp @@ -35,7 +35,7 @@ class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate { std::string result; CefRefPtr 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()); diff --git a/tests/cefclient/client_app.cpp b/tests/cefclient/client_app.cpp index fae16cf22..2a8829a6e 100644 --- a/tests/cefclient/client_app.cpp +++ b/tests/cefclient/client_app.cpp @@ -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 list, int index, // Transfer a V8 array to a List. void SetList(CefRefPtr source, CefRefPtr target) { - DCHECK(source->IsArray()); + ASSERT(source->IsArray()); int arg_length = source->GetArrayLength(); if (arg_length == 0) @@ -90,7 +89,7 @@ void SetListValue(CefRefPtr list, int index, // Transfer a List to a V8 array. void SetList(CefRefPtr source, CefRefPtr 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 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 context, CefRefPtr 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 browser, CefProcessId source_process, CefRefPtr message) { - DCHECK(source_process == PID_BROWSER); + ASSERT(source_process == PID_BROWSER); bool handled = false; diff --git a/tests/cefclient/client_app_delegates.cpp b/tests/cefclient/client_app_delegates.cpp new file mode 100644 index 000000000..35ca35ba0 --- /dev/null +++ b/tests/cefclient/client_app_delegates.cpp @@ -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) { +} diff --git a/tests/cefclient/process_helper_mac.cpp b/tests/cefclient/process_helper_mac.cpp index d4ed60847..7354b036a 100644 --- a/tests/cefclient/process_helper_mac.cpp +++ b/tests/cefclient/process_helper_mac.cpp @@ -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);