diff --git a/cef3/AUTHORS.txt b/cef3/AUTHORS.txt new file mode 100644 index 000000000..d4559e2a4 --- /dev/null +++ b/cef3/AUTHORS.txt @@ -0,0 +1,27 @@ +# This file is an addendum to the Chromium AUTHORS file. +# Names should be added to this file like so: +# Name or Organization + +Marshall Greenblatt +Jamie Kirkpatrick +Johan Lindström +Igor Pavlov +Yanko Yankov +Emerick Rogul +Valve Corporation +Anthony Taranto +Joe Andrieu +Keith Poole +Aviv Rind +Michael Kaminski +ADInstruments Ltd. +Gus Verdun +Joinerysoft Ltd. +Johan Björk +Dmitry Azaraev +David Xue +Russell (Rusty) Richards +Brian Power +Corey Lucier +Mihai Tica +Czarek Tomczak diff --git a/cef3/CHROMIUM_BUILD_COMPATIBILITY.txt b/cef3/CHROMIUM_BUILD_COMPATIBILITY.txt new file mode 100644 index 000000000..6b91a5a8c --- /dev/null +++ b/cef3/CHROMIUM_BUILD_COMPATIBILITY.txt @@ -0,0 +1,20 @@ +# The Chromium Embedded Framework (CEF) project is built on top of the Chromium +# project source tree. Chromium should be updated to the URL and revision listed +# below before building CEF. Chromium compatibility information for older CEF +# revisions is available by viewing this file's change history. +# +# To configure a specific Chromium URL: +# gclient config chromium_url +# +# To update to a specific Chromium revision: +# gclient sync --revision src@chromium_revision --jobs 8 --force +# +# This file is integrated with the CEF Automation Tool. See the +# tools/automate/automate.README.txt file for more information. +# +# For general gclient usage information visit: +# http://dev.chromium.org/developers/how-tos/get-the-code + +{ + 'release_url': 'http://src.chromium.org/svn/releases/27.0.1453.15', +} diff --git a/cef3/DEPS b/cef3/DEPS new file mode 100644 index 000000000..0a7dc22e3 --- /dev/null +++ b/cef3/DEPS @@ -0,0 +1,7 @@ +hooks = [ + { + # A change to a .gyp, .gypi, or to GYP itself should run the generator. + "pattern": ".", + "action": ["python", "src/cef/tools/gclient_hook.py"], + }, +] diff --git a/cef3/LICENSE.txt b/cef3/LICENSE.txt new file mode 100644 index 000000000..a5d84adab --- /dev/null +++ b/cef3/LICENSE.txt @@ -0,0 +1,29 @@ +// Copyright (c) 2008-2013 Marshall A. Greenblatt. Portions Copyright (c) +// 2006-2009 Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/cef3/VERSION b/cef3/VERSION new file mode 100644 index 000000000..2ecb9806b --- /dev/null +++ b/cef3/VERSION @@ -0,0 +1 @@ +CEF_MAJOR=3 diff --git a/cef3/cef.gyp b/cef3/cef.gyp new file mode 100644 index 000000000..ede1df185 --- /dev/null +++ b/cef3/cef.gyp @@ -0,0 +1,1339 @@ +# 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. + +{ + 'variables': { + 'pkg-config': 'pkg-config', + 'chromium_code': 1, + 'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/cef', + 'about_credits_file': '<(SHARED_INTERMEDIATE_DIR)/about_credits.html', + 'revision': '!@(<(repack_locales_cmd) -i -g \"<(grit_out_dir)\" -s \"<(SHARED_INTERMEDIATE_DIR)\" -x \"<(INTERMEDIATE_DIR)\" <(locales))', + ], + 'outputs': [ + '>!@(<(repack_locales_cmd) -o -g \"<(grit_out_dir)\" -s \"<(SHARED_INTERMEDIATE_DIR)\" -x \"<(INTERMEDIATE_DIR)\" <(locales))', + ], + 'action': [ + '<@(repack_locales_cmd)', + '-g', '<(grit_out_dir)', + '-s', '<(SHARED_INTERMEDIATE_DIR)', + '-x', '<(INTERMEDIATE_DIR)', + '<@(locales)', + ], + }, + ], + }, { # OS!="win" + 'actions': [ + { + 'action_name': 'repack_locales', + 'inputs': [ + 'tools/repack_locales.py', + # NOTE: Ideally the common command args would be shared + # amongst inputs/outputs/action, but the args include shell + # variables which need to be passed intact, and command + # expansion wants to expand the shell variables. Adding the + # explicit quoting here was the only way it seemed to work. + '>!@(<(repack_locales_cmd) -i -g \'<(grit_out_dir)\' -s \'<(SHARED_INTERMEDIATE_DIR)\' -x \'<(INTERMEDIATE_DIR)\' <(locales))', + ], + 'outputs': [ + '>!@(<(repack_locales_cmd) -o -g \'<(grit_out_dir)\' -s \'<(SHARED_INTERMEDIATE_DIR)\' -x \'<(INTERMEDIATE_DIR)\' <(locales))', + ], + 'action': [ + '<@(repack_locales_cmd)', + '-g', '<(grit_out_dir)', + '-s', '<(SHARED_INTERMEDIATE_DIR)', + '-x', '<(INTERMEDIATE_DIR)', + '<@(locales)', + ], + }, + ], + }], + ['OS != "mac"', { + 'copies': [ + { + 'destination': '<(PRODUCT_DIR)/locales', + 'files': [ + '=46', { + 'target_defaults': { + # Disable warnings about c++0x compatibility, as some names (such + # as nullptr) conflict with upcoming c++0x types. + 'cflags_cc': ['-Wno-c++0x-compat'], + }, + }], + ['OS=="mac"', { + 'targets': [ + { + # Dummy target to allow cefclient to require plugin_carbon_interpose + # to build without actually linking to the resulting library. + 'target_name': 'interpose_dependency_shim', + 'type': 'executable', + 'variables': { 'enable_wexit_time_destructors': 1, }, + 'dependencies': [ + 'plugin_carbon_interpose', + ], + # In release, we end up with a strip step that is unhappy if there is + # no binary. Rather than check in a new file for this temporary hack, + # just generate a source file on the fly. + 'actions': [ + { + 'action_name': 'generate_stub_main', + 'process_outputs_as_sources': 1, + 'inputs': [], + 'outputs': [ '<(INTERMEDIATE_DIR)/dummy_main.c' ], + 'action': [ + 'bash', '-c', + 'echo "int main() { return 0; }" > <(INTERMEDIATE_DIR)/dummy_main.c' + ], + }, + ], + }, + { + # dylib for interposing Carbon calls in the plugin process. + 'target_name': 'plugin_carbon_interpose', + 'type': 'shared_library', + 'variables': { 'enable_wexit_time_destructors': 1, }, + # This target must not depend on static libraries, else the code in + # those libraries would appear twice in plugin processes: Once from + # Chromium Framework, and once from this dylib. + 'dependencies': [ + 'libcef', + ], + 'conditions': [ + ['component=="shared_library"', { + 'dependencies': [ + '<(DEPTH)/webkit/support/webkit_support.gyp:glue', + '<(DEPTH)/content/content.gyp:content_plugin', + ], + }], + ], + 'sources': [ + '<(DEPTH)/content/plugin/plugin_carbon_interpose_mac.cc', + ], + 'include_dirs': [ + '..', + ], + 'link_settings': { + 'libraries': [ + '$(SDKROOT)/System/Library/Frameworks/Carbon.framework', + ], + }, + 'xcode_settings': { + 'DYLIB_COMPATIBILITY_VERSION': '<(version_mac_dylib)', + 'DYLIB_CURRENT_VERSION': '<(version_mac_dylib)', + }, + 'postbuilds': [ + { + # The framework defines its load-time path + # (DYLIB_INSTALL_NAME_BASE) relative to the main executable + # (chrome). A different relative path needs to be used in + # libplugin_carbon_interpose.dylib. + 'postbuild_name': 'Fix Framework Link', + 'action': [ + 'install_name_tool', + '-change', + '@executable_path/libcef.dylib', + '@executable_path/../../../../Frameworks/Chromium Embedded Framework.framework/Libraries/libcef.dylib', + '${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}' + ], + }, + ], + }, + { + 'target_name': 'cefclient_helper_app', + 'type': 'executable', + 'variables': { 'enable_wexit_time_destructors': 1, }, + 'product_name': 'cefclient Helper', + 'mac_bundle': 1, + 'dependencies': [ + 'cef_pak', + 'libcef', + 'libcef_dll_wrapper', + ], + 'defines': [ + 'USING_CEF_SHARED', + ], + 'include_dirs': [ + '.', + # cefclient includes are relative to the tests directory to make + # creation of binary releases easier. + 'tests' + ], + 'link_settings': { + 'libraries': [ + '$(SDKROOT)/System/Library/Frameworks/AppKit.framework', + ], + }, + 'sources': [ + '<@(cefclient_sources_mac_helper)', + ], + # TODO(mark): Come up with a fancier way to do this. It should only + # be necessary to list helper-Info.plist once, not the three times it + # is listed here. + 'mac_bundle_resources!': [ + 'tests/cefclient/mac/helper-Info.plist', + ], + # TODO(mark): For now, don't put any resources into this app. Its + # resources directory will be a symbolic link to the browser app's + # resources directory. + 'mac_bundle_resources/': [ + ['exclude', '.*'], + ], + 'xcode_settings': { + 'INFOPLIST_FILE': 'tests/cefclient/mac/helper-Info.plist', + # Necessary to avoid an "install_name_tool: changing install names or + # rpaths can't be redone" error. + 'OTHER_LDFLAGS': ['-Wl,-headerpad_max_install_names'], + }, + 'postbuilds': [ + { + # The framework defines its load-time path + # (DYLIB_INSTALL_NAME_BASE) relative to the main executable + # (chrome). A different relative path needs to be used in + # cefclient_helper_app. + 'postbuild_name': 'Fix Framework Link', + 'action': [ + 'install_name_tool', + '-change', + '@executable_path/libcef.dylib', + '@executable_path/../../../../Frameworks/Chromium Embedded Framework.framework/Libraries/libcef.dylib', + '${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}' + ], + }, + { + # Modify the Info.plist as needed. The script explains why this + # is needed. This is also done in the chrome and chrome_dll + # targets. In this case, --breakpad=0, --keystone=0, and --scm=0 + # are used because Breakpad, Keystone, and SCM keys are + # never placed into the helper. + 'postbuild_name': 'Tweak Info.plist', + 'action': ['../build/mac/tweak_info_plist.py', + '--breakpad=0', + '--keystone=0', + '--scm=0'], + }, + ], + }, # target cefclient_helper_app + { + 'target_name': 'cef_unittests_helper_app', + 'type': 'executable', + 'product_name': 'cef_unittests Helper', + 'mac_bundle': 1, + 'dependencies': [ + '<(DEPTH)/base/base.gyp:base', + '<(DEPTH)/base/base.gyp:base_i18n', + '<(DEPTH)/base/base.gyp:test_support_base', + '<(DEPTH)/testing/gtest.gyp:gtest', + '<(DEPTH)/third_party/icu/icu.gyp:icui18n', + '<(DEPTH)/third_party/icu/icu.gyp:icuuc', + 'cef_pak', + 'libcef', + 'libcef_dll_wrapper', + ], + 'defines': [ + 'USING_CEF_SHARED', + ], + 'include_dirs': [ + '.', + ], + 'sources': [ + 'tests/cefclient/client_app.cpp', + 'tests/cefclient/client_app.h', + 'tests/cefclient/client_switches.cpp', + 'tests/cefclient/client_switches.h', + 'tests/cefclient/process_helper_mac.cpp', + 'tests/unittests/client_app_delegates.cc', + 'tests/unittests/cookie_unittest.cc', + 'tests/unittests/dom_unittest.cc', + 'tests/unittests/navigation_unittest.cc', + 'tests/unittests/process_message_unittest.cc', + 'tests/unittests/scheme_handler_unittest.cc', + 'tests/unittests/urlrequest_unittest.cc', + 'tests/unittests/test_handler.cc', + 'tests/unittests/test_handler.h', + 'tests/unittests/test_suite.cc', + 'tests/unittests/test_suite.h', + 'tests/unittests/test_util.cc', + 'tests/unittests/test_util.h', + 'tests/unittests/tracing_unittest.cc', + 'tests/unittests/v8_unittest.cc', + ], + # TODO(mark): Come up with a fancier way to do this. It should only + # be necessary to list helper-Info.plist once, not the three times it + # is listed here. + 'mac_bundle_resources!': [ + 'tests/cefclient/mac/helper-Info.plist', + ], + # TODO(mark): For now, don't put any resources into this app. Its + # resources directory will be a symbolic link to the browser app's + # resources directory. + 'mac_bundle_resources/': [ + ['exclude', '.*'], + ], + 'xcode_settings': { + 'INFOPLIST_FILE': 'tests/cefclient/mac/helper-Info.plist', + # Necessary to avoid an "install_name_tool: changing install names or + # rpaths can't be redone" error. + 'OTHER_LDFLAGS': ['-Wl,-headerpad_max_install_names'], + }, + 'postbuilds': [ + { + # The framework defines its load-time path + # (DYLIB_INSTALL_NAME_BASE) relative to the main executable + # (chrome). A different relative path needs to be used in + # cefclient_helper_app. + 'postbuild_name': 'Fix Framework Link', + 'action': [ + 'install_name_tool', + '-change', + '@executable_path/libcef.dylib', + '@executable_path/../../../../Frameworks/Chromium Embedded Framework.framework/Libraries/libcef.dylib', + '${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}' + ], + }, + { + # Modify the Info.plist as needed. The script explains why this + # is needed. This is also done in the chrome and chrome_dll + # targets. In this case, --breakpad=0, --keystone=0, and --scm=0 + # are used because Breakpad, Keystone, and SCM keys are + # never placed into the helper. + 'postbuild_name': 'Tweak Info.plist', + 'action': ['../build/mac/tweak_info_plist.py', + '--breakpad=0', + '--keystone=0', + '--scm=0'], + }, + ], + }, # target cef_unittests_helper_app + ], + }], # OS=="mac" + ], +} diff --git a/cef3/cef.gypi b/cef3/cef.gypi new file mode 100644 index 000000000..6cfe6b3b6 --- /dev/null +++ b/cef3/cef.gypi @@ -0,0 +1,28 @@ +# Copyright (c) 2009 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. + +{ + 'variables': { + 'conditions': [ + # Directory for CEF source files. + [ 'OS=="win"', { + 'cef_directory' : 'f) - (intptr_t)(s) + sizeof((s)->f) <= (s)->base.size) + +#define CEF_MEMBER_MISSING(s, f) (!CEF_MEMBER_EXISTS(s, f) || !((s)->f)) + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_BASE_CAPI_H_ diff --git a/cef3/include/capi/cef_browser_capi.h b/cef3/include/capi/cef_browser_capi.h new file mode 100644 index 000000000..1e16fab86 --- /dev/null +++ b/cef3/include/capi/cef_browser_capi.h @@ -0,0 +1,426 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Structure used to represent a browser window. When used in the browser +// process the functions of this structure may be called on any thread unless +// otherwise indicated in the comments. When used in the render process the +// functions of this structure may only be called on the main thread. +/// +typedef struct _cef_browser_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns the browser host object. This function can only be called in the + // browser process. + /// + struct _cef_browser_host_t* (CEF_CALLBACK *get_host)( + struct _cef_browser_t* self); + + /// + // Returns true (1) if the browser can navigate backwards. + /// + int (CEF_CALLBACK *can_go_back)(struct _cef_browser_t* self); + + /// + // Navigate backwards. + /// + void (CEF_CALLBACK *go_back)(struct _cef_browser_t* self); + + /// + // Returns true (1) if the browser can navigate forwards. + /// + int (CEF_CALLBACK *can_go_forward)(struct _cef_browser_t* self); + + /// + // Navigate forwards. + /// + void (CEF_CALLBACK *go_forward)(struct _cef_browser_t* self); + + /// + // Returns true (1) if the browser is currently loading. + /// + int (CEF_CALLBACK *is_loading)(struct _cef_browser_t* self); + + /// + // Reload the current page. + /// + void (CEF_CALLBACK *reload)(struct _cef_browser_t* self); + + /// + // Reload the current page ignoring any cached data. + /// + void (CEF_CALLBACK *reload_ignore_cache)(struct _cef_browser_t* self); + + /// + // Stop loading the page. + /// + void (CEF_CALLBACK *stop_load)(struct _cef_browser_t* self); + + /// + // Returns the globally unique identifier for this browser. + /// + int (CEF_CALLBACK *get_identifier)(struct _cef_browser_t* self); + + /// + // Returns true (1) if this object is pointing to the same handle as |that| + // object. + /// + int (CEF_CALLBACK *is_same)(struct _cef_browser_t* self, + struct _cef_browser_t* that); + + /// + // Returns true (1) if the window is a popup window. + /// + int (CEF_CALLBACK *is_popup)(struct _cef_browser_t* self); + + /// + // Returns true (1) if a document has been loaded in the browser. + /// + int (CEF_CALLBACK *has_document)(struct _cef_browser_t* self); + + /// + // Returns the main (top-level) frame for the browser window. + /// + struct _cef_frame_t* (CEF_CALLBACK *get_main_frame)( + struct _cef_browser_t* self); + + /// + // Returns the focused frame for the browser window. + /// + struct _cef_frame_t* (CEF_CALLBACK *get_focused_frame)( + struct _cef_browser_t* self); + + /// + // Returns the frame with the specified identifier, or NULL if not found. + /// + struct _cef_frame_t* (CEF_CALLBACK *get_frame_byident)( + struct _cef_browser_t* self, int64 identifier); + + /// + // Returns the frame with the specified name, or NULL if not found. + /// + struct _cef_frame_t* (CEF_CALLBACK *get_frame)(struct _cef_browser_t* self, + const cef_string_t* name); + + /// + // Returns the number of frames that currently exist. + /// + size_t (CEF_CALLBACK *get_frame_count)(struct _cef_browser_t* self); + + /// + // Returns the identifiers of all existing frames. + /// + void (CEF_CALLBACK *get_frame_identifiers)(struct _cef_browser_t* self, + size_t* identifiersCount, int64* identifiers); + + /// + // Returns the names of all existing frames. + /// + void (CEF_CALLBACK *get_frame_names)(struct _cef_browser_t* self, + cef_string_list_t names); + + // + // Send a message to the specified |target_process|. Returns true (1) if the + // message was sent successfully. + /// + int (CEF_CALLBACK *send_process_message)(struct _cef_browser_t* self, + enum cef_process_id_t target_process, + struct _cef_process_message_t* message); +} cef_browser_t; + + +/// +// Callback structure for cef_browser_host_t::RunFileDialog. The functions of +// this structure will be called on the browser process UI thread. +/// +typedef struct _cef_run_file_dialog_callback_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Called asynchronously after the file dialog is dismissed. If the selection + // was successful |file_paths| will be a single value or a list of values + // depending on the dialog mode. If the selection was cancelled |file_paths| + // will be NULL. + /// + void (CEF_CALLBACK *cont)(struct _cef_run_file_dialog_callback_t* self, + struct _cef_browser_host_t* browser_host, cef_string_list_t file_paths); +} cef_run_file_dialog_callback_t; + + +/// +// Structure used to represent the browser process aspects of a browser window. +// The functions of this structure can only be called in the browser process. +// They may be called on any thread in that process unless otherwise indicated +// in the comments. +/// +typedef struct _cef_browser_host_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns the hosted browser object. + /// + struct _cef_browser_t* (CEF_CALLBACK *get_browser)( + struct _cef_browser_host_t* self); + + /// + // Call this function before destroying a contained browser window. This + // function performs any internal cleanup that may be needed before the + // browser window is destroyed. See cef_life_span_handler_t::do_close() + // documentation for additional usage information. + /// + void (CEF_CALLBACK *parent_window_will_close)( + struct _cef_browser_host_t* self); + + /// + // Request that the browser close. The JavaScript 'onbeforeunload' event will + // be fired. If |force_close| is false (0) the event handler, if any, will be + // allowed to prompt the user and the user can optionally cancel the close. If + // |force_close| is true (1) the prompt will not be displayed and the close + // will proceed. Results in a call to cef_life_span_handler_t::do_close() if + // the event handler allows the close or if |force_close| is true (1). See + // cef_life_span_handler_t::do_close() documentation for additional usage + // information. + /// + void (CEF_CALLBACK *close_browser)(struct _cef_browser_host_t* self, + int force_close); + + /// + // Set focus for the browser window. If |enable| is true (1) focus will be set + // to the window. Otherwise, focus will be removed. + /// + void (CEF_CALLBACK *set_focus)(struct _cef_browser_host_t* self, int enable); + + /// + // Retrieve the window handle for this browser. + /// + cef_window_handle_t (CEF_CALLBACK *get_window_handle)( + struct _cef_browser_host_t* self); + + /// + // Retrieve the window handle of the browser that opened this browser. Will + // return NULL for non-popup windows. This function can be used in combination + // with custom handling of modal windows. + /// + cef_window_handle_t (CEF_CALLBACK *get_opener_window_handle)( + struct _cef_browser_host_t* self); + + /// + // Returns the client for this browser. + /// + struct _cef_client_t* (CEF_CALLBACK *get_client)( + struct _cef_browser_host_t* self); + + /// + // Returns the DevTools URL for this browser. If |http_scheme| is true (1) the + // returned URL will use the http scheme instead of the chrome-devtools + // scheme. Remote debugging can be enabled by specifying the "remote- + // debugging-port" command-line flag or by setting the + // CefSettings.remote_debugging_port value. If remote debugging is not enabled + // this function will return an NULL string. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_dev_tools_url)( + struct _cef_browser_host_t* self, int http_scheme); + + /// + // Get the current zoom level. The default zoom level is 0.0. This function + // can only be called on the UI thread. + /// + double (CEF_CALLBACK *get_zoom_level)(struct _cef_browser_host_t* self); + + /// + // Change the zoom level to the specified value. Specify 0.0 to reset the zoom + // level. If called on the UI thread the change will be applied immediately. + // Otherwise, the change will be applied asynchronously on the UI thread. + /// + void (CEF_CALLBACK *set_zoom_level)(struct _cef_browser_host_t* self, + double zoomLevel); + + /// + // Call to run a file chooser dialog. Only a single file chooser dialog may be + // pending at any given time. |mode| represents the type of dialog to display. + // |title| to the title to be used for the dialog and may be NULL to show the + // default title ("Open" or "Save" depending on the mode). |default_file_name| + // is the default file name to select in the dialog. |accept_types| is a list + // of valid lower-cased MIME types or file extensions specified in an input + // element and is used to restrict selectable files to such types. |callback| + // will be executed after the dialog is dismissed or immediately if another + // dialog is already pending. The dialog will be initiated asynchronously on + // the UI thread. + /// + void (CEF_CALLBACK *run_file_dialog)(struct _cef_browser_host_t* self, + enum cef_file_dialog_mode_t mode, const cef_string_t* title, + const cef_string_t* default_file_name, cef_string_list_t accept_types, + struct _cef_run_file_dialog_callback_t* callback); + + /// + // Download the file at |url| using cef_download_handler_t. + /// + void (CEF_CALLBACK *start_download)(struct _cef_browser_host_t* self, + const cef_string_t* url); + + /// + // Set whether mouse cursor change is disabled. + /// + void (CEF_CALLBACK *set_mouse_cursor_change_disabled)( + struct _cef_browser_host_t* self, int disabled); + + /// + // Returns true (1) if mouse cursor change is disabled. + /// + int (CEF_CALLBACK *is_mouse_cursor_change_disabled)( + struct _cef_browser_host_t* self); + + /// + // Returns true (1) if window rendering is disabled. + /// + int (CEF_CALLBACK *is_window_rendering_disabled)( + struct _cef_browser_host_t* self); + + /// + // Notify the browser that the widget has been resized. The browser will first + // call cef_render_handler_t::GetViewRect to get the new size and then call + // cef_render_handler_t::OnPaint asynchronously with the updated regions. This + // function is only used when window rendering is disabled. + /// + void (CEF_CALLBACK *was_resized)(struct _cef_browser_host_t* self); + + /// + // Notify the browser that it has been hidden or shown. Layouting and + // cef_render_handler_t::OnPaint notification will stop when the browser is + // hidden. This function is only used when window rendering is disabled. + /// + void (CEF_CALLBACK *was_hidden)(struct _cef_browser_host_t* self, int hidden); + + /// + // Invalidate the |dirtyRect| region of the view. The browser will call + // cef_render_handler_t::OnPaint asynchronously with the updated regions. This + // function is only used when window rendering is disabled. + /// + void (CEF_CALLBACK *invalidate)(struct _cef_browser_host_t* self, + const cef_rect_t* dirtyRect, enum cef_paint_element_type_t type); + + /// + // Send a key event to the browser. + /// + void (CEF_CALLBACK *send_key_event)(struct _cef_browser_host_t* self, + const struct _cef_key_event_t* event); + + /// + // Send a mouse click event to the browser. The |x| and |y| coordinates are + // relative to the upper-left corner of the view. + /// + void (CEF_CALLBACK *send_mouse_click_event)(struct _cef_browser_host_t* self, + const struct _cef_mouse_event_t* event, + enum cef_mouse_button_type_t type, int mouseUp, int clickCount); + + /// + // Send a mouse move event to the browser. The |x| and |y| coordinates are + // relative to the upper-left corner of the view. + /// + void (CEF_CALLBACK *send_mouse_move_event)(struct _cef_browser_host_t* self, + const struct _cef_mouse_event_t* event, int mouseLeave); + + /// + // Send a mouse wheel event to the browser. The |x| and |y| coordinates are + // relative to the upper-left corner of the view. The |deltaX| and |deltaY| + // values represent the movement delta in the X and Y directions respectively. + // In order to scroll inside select popups with window rendering disabled + // cef_render_handler_t::GetScreenPoint should be implemented properly. + /// + void (CEF_CALLBACK *send_mouse_wheel_event)(struct _cef_browser_host_t* self, + const struct _cef_mouse_event_t* event, int deltaX, int deltaY); + + /// + // Send a focus event to the browser. + /// + void (CEF_CALLBACK *send_focus_event)(struct _cef_browser_host_t* self, + int setFocus); + + /// + // Send a capture lost event to the browser. + /// + void (CEF_CALLBACK *send_capture_lost_event)( + struct _cef_browser_host_t* self); +} cef_browser_host_t; + + +/// +// Create a new browser window using the window parameters specified by +// |windowInfo|. All values will be copied internally and the actual window will +// be created on the UI thread. This function can be called on any browser +// process thread and will not block. +/// +CEF_EXPORT int cef_browser_host_create_browser( + const cef_window_info_t* windowInfo, struct _cef_client_t* client, + const cef_string_t* url, const struct _cef_browser_settings_t* settings); + +/// +// Create a new browser window using the window parameters specified by +// |windowInfo|. This function can only be called on the browser process UI +// thread. +/// +CEF_EXPORT cef_browser_t* cef_browser_host_create_browser_sync( + const cef_window_info_t* windowInfo, struct _cef_client_t* client, + const cef_string_t* url, const struct _cef_browser_settings_t* settings); + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_ diff --git a/cef3/include/capi/cef_browser_process_handler_capi.h b/cef3/include/capi/cef_browser_process_handler_capi.h new file mode 100644 index 000000000..fe56ff168 --- /dev/null +++ b/cef3/include/capi/cef_browser_process_handler_capi.h @@ -0,0 +1,94 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Structure used to implement browser process callbacks. The functions of this +// structure will be called on the browser process main thread unless otherwise +// indicated. +/// +typedef struct _cef_browser_process_handler_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Called on the browser process UI thread immediately after the CEF context + // has been initialized. + /// + void (CEF_CALLBACK *on_context_initialized)( + struct _cef_browser_process_handler_t* self); + + /// + // Called before a child process is launched. Will be called on the browser + // process UI thread when launching a render process and on the browser + // process IO thread when launching a GPU or plugin process. Provides an + // opportunity to modify the child process command line. Do not keep a + // reference to |command_line| outside of this function. + /// + void (CEF_CALLBACK *on_before_child_process_launch)( + struct _cef_browser_process_handler_t* self, + struct _cef_command_line_t* command_line); + + /// + // Called on the browser process IO thread after the main thread has been + // created for a new render process. Provides an opportunity to specify extra + // information that will be passed to + // cef_render_process_handler_t::on_render_thread_created() in the render + // process. Do not keep a reference to |extra_info| outside of this function. + /// + void (CEF_CALLBACK *on_render_process_thread_created)( + struct _cef_browser_process_handler_t* self, + struct _cef_list_value_t* extra_info); +} cef_browser_process_handler_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_ diff --git a/cef3/include/capi/cef_callback_capi.h b/cef3/include/capi/cef_callback_capi.h new file mode 100644 index 000000000..4220fc8b7 --- /dev/null +++ b/cef3/include/capi/cef_callback_capi.h @@ -0,0 +1,89 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_CALLBACK_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_CALLBACK_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Generic callback structure used for asynchronous continuation. +/// +typedef struct _cef_callback_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Continue processing. + /// + void (CEF_CALLBACK *cont)(struct _cef_callback_t* self); + + /// + // Cancel processing. + /// + void (CEF_CALLBACK *cancel)(struct _cef_callback_t* self); +} cef_callback_t; + + +/// +// Generic callback structure used for asynchronous completion. +/// +typedef struct _cef_completion_handler_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Method that will be called once the task is complete. + /// + void (CEF_CALLBACK *on_complete)(struct _cef_completion_handler_t* self); +} cef_completion_handler_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_CALLBACK_CAPI_H_ diff --git a/cef3/include/capi/cef_client_capi.h b/cef3/include/capi/cef_client_capi.h new file mode 100644 index 000000000..cdb513d30 --- /dev/null +++ b/cef3/include/capi/cef_client_capi.h @@ -0,0 +1,149 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Implement this structure to provide handler implementations. +/// +typedef struct _cef_client_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Return the handler for context menus. If no handler is provided the default + // implementation will be used. + /// + struct _cef_context_menu_handler_t* (CEF_CALLBACK *get_context_menu_handler)( + struct _cef_client_t* self); + + /// + // Return the handler for dialogs. If no handler is provided the default + // implementation will be used. + /// + struct _cef_dialog_handler_t* (CEF_CALLBACK *get_dialog_handler)( + struct _cef_client_t* self); + + /// + // Return the handler for browser display state events. + /// + struct _cef_display_handler_t* (CEF_CALLBACK *get_display_handler)( + struct _cef_client_t* self); + + /// + // Return the handler for download events. If no handler is returned downloads + // will not be allowed. + /// + struct _cef_download_handler_t* (CEF_CALLBACK *get_download_handler)( + struct _cef_client_t* self); + + /// + // Return the handler for focus events. + /// + struct _cef_focus_handler_t* (CEF_CALLBACK *get_focus_handler)( + struct _cef_client_t* self); + + /// + // Return the handler for geolocation permissions requests. If no handler is + // provided geolocation access will be denied by default. + /// + struct _cef_geolocation_handler_t* (CEF_CALLBACK *get_geolocation_handler)( + struct _cef_client_t* self); + + /// + // Return the handler for JavaScript dialogs. If no handler is provided the + // default implementation will be used. + /// + struct _cef_jsdialog_handler_t* (CEF_CALLBACK *get_jsdialog_handler)( + struct _cef_client_t* self); + + /// + // Return the handler for keyboard events. + /// + struct _cef_keyboard_handler_t* (CEF_CALLBACK *get_keyboard_handler)( + struct _cef_client_t* self); + + /// + // Return the handler for browser life span events. + /// + struct _cef_life_span_handler_t* (CEF_CALLBACK *get_life_span_handler)( + struct _cef_client_t* self); + + /// + // Return the handler for browser load status events. + /// + struct _cef_load_handler_t* (CEF_CALLBACK *get_load_handler)( + struct _cef_client_t* self); + + /// + // Return the handler for off-screen rendering events. + /// + struct _cef_render_handler_t* (CEF_CALLBACK *get_render_handler)( + struct _cef_client_t* self); + + /// + // Return the handler for browser request events. + /// + struct _cef_request_handler_t* (CEF_CALLBACK *get_request_handler)( + struct _cef_client_t* self); + + /// + // Called when a new message is received from a different process. Return true + // (1) if the message was handled or false (0) otherwise. Do not keep a + // reference to or attempt to access the message outside of this callback. + /// + int (CEF_CALLBACK *on_process_message_received)(struct _cef_client_t* self, + struct _cef_browser_t* browser, enum cef_process_id_t source_process, + struct _cef_process_message_t* message); +} cef_client_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_ diff --git a/cef3/include/capi/cef_command_line_capi.h b/cef3/include/capi/cef_command_line_capi.h new file mode 100644 index 000000000..0168c16c3 --- /dev/null +++ b/cef3/include/capi/cef_command_line_capi.h @@ -0,0 +1,213 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_COMMAND_LINE_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_COMMAND_LINE_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Structure used to create and/or parse command line arguments. Arguments with +// '--', '-' and, on Windows, '/' prefixes are considered switches. Switches +// will always precede any arguments without switch prefixes. Switches can +// optionally have a value specified using the '=' delimiter (e.g. +// "-switch=value"). An argument of "--" will terminate switch parsing with all +// subsequent tokens, regardless of prefix, being interpreted as non-switch +// arguments. Switch names are considered case-insensitive. This structure can +// be used before cef_initialize() is called. +/// +typedef struct _cef_command_line_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns true (1) if this object is valid. Do not call any other functions + // if this function returns false (0). + /// + int (CEF_CALLBACK *is_valid)(struct _cef_command_line_t* self); + + /// + // Returns true (1) if the values of this object are read-only. Some APIs may + // expose read-only objects. + /// + int (CEF_CALLBACK *is_read_only)(struct _cef_command_line_t* self); + + /// + // Returns a writable copy of this object. + /// + struct _cef_command_line_t* (CEF_CALLBACK *copy)( + struct _cef_command_line_t* self); + + /// + // Initialize the command line with the specified |argc| and |argv| values. + // The first argument must be the name of the program. This function is only + // supported on non-Windows platforms. + /// + void (CEF_CALLBACK *init_from_argv)(struct _cef_command_line_t* self, + int argc, const char* const* argv); + + /// + // Initialize the command line with the string returned by calling + // GetCommandLineW(). This function is only supported on Windows. + /// + void (CEF_CALLBACK *init_from_string)(struct _cef_command_line_t* self, + const cef_string_t* command_line); + + /// + // Reset the command-line switches and arguments but leave the program + // component unchanged. + /// + void (CEF_CALLBACK *reset)(struct _cef_command_line_t* self); + + /// + // Retrieve the original command line string as a vector of strings. The argv + // array: { program, [(--|-|/)switch[=value]]*, [--], [argument]* } + /// + void (CEF_CALLBACK *get_argv)(struct _cef_command_line_t* self, + cef_string_list_t argv); + + /// + // Constructs and returns the represented command line string. Use this + // function cautiously because quoting behavior is unclear. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_command_line_string)( + struct _cef_command_line_t* self); + + /// + // Get the program part of the command line string (the first item). + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_program)( + struct _cef_command_line_t* self); + + /// + // Set the program part of the command line string (the first item). + /// + void (CEF_CALLBACK *set_program)(struct _cef_command_line_t* self, + const cef_string_t* program); + + /// + // Returns true (1) if the command line has switches. + /// + int (CEF_CALLBACK *has_switches)(struct _cef_command_line_t* self); + + /// + // Returns true (1) if the command line contains the given switch. + /// + int (CEF_CALLBACK *has_switch)(struct _cef_command_line_t* self, + const cef_string_t* name); + + /// + // Returns the value associated with the given switch. If the switch has no + // value or isn't present this function returns the NULL string. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_switch_value)( + struct _cef_command_line_t* self, const cef_string_t* name); + + /// + // Returns the map of switch names and values. If a switch has no value an + // NULL string is returned. + /// + void (CEF_CALLBACK *get_switches)(struct _cef_command_line_t* self, + cef_string_map_t switches); + + /// + // Add a switch to the end of the command line. If the switch has no value + // pass an NULL value string. + /// + void (CEF_CALLBACK *append_switch)(struct _cef_command_line_t* self, + const cef_string_t* name); + + /// + // Add a switch with the specified value to the end of the command line. + /// + void (CEF_CALLBACK *append_switch_with_value)( + struct _cef_command_line_t* self, const cef_string_t* name, + const cef_string_t* value); + + /// + // True if there are remaining command line arguments. + /// + int (CEF_CALLBACK *has_arguments)(struct _cef_command_line_t* self); + + /// + // Get the remaining command line arguments. + /// + void (CEF_CALLBACK *get_arguments)(struct _cef_command_line_t* self, + cef_string_list_t arguments); + + /// + // Add an argument to the end of the command line. + /// + void (CEF_CALLBACK *append_argument)(struct _cef_command_line_t* self, + const cef_string_t* argument); + + /// + // Insert a command before the current command. Common for debuggers, like + // "valgrind" or "gdb --args". + /// + void (CEF_CALLBACK *prepend_wrapper)(struct _cef_command_line_t* self, + const cef_string_t* wrapper); +} cef_command_line_t; + + +/// +// Create a new cef_command_line_t instance. +/// +CEF_EXPORT cef_command_line_t* cef_command_line_create(); + +/// +// Returns the singleton global cef_command_line_t object. The returned object +// will be read-only. +/// +CEF_EXPORT cef_command_line_t* cef_command_line_get_global(); + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_COMMAND_LINE_CAPI_H_ diff --git a/cef3/include/capi/cef_context_menu_handler_capi.h b/cef3/include/capi/cef_context_menu_handler_capi.h new file mode 100644 index 000000000..c9282393e --- /dev/null +++ b/cef3/include/capi/cef_context_menu_handler_capi.h @@ -0,0 +1,221 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Implement this structure to handle context menu events. The functions of this +// structure will be called on the UI thread. +/// +typedef struct _cef_context_menu_handler_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Called before a context menu is displayed. |params| provides information + // about the context menu state. |model| initially contains the default + // context menu. The |model| can be cleared to show no context menu or + // modified to show a custom menu. Do not keep references to |params| or + // |model| outside of this callback. + /// + void (CEF_CALLBACK *on_before_context_menu)( + struct _cef_context_menu_handler_t* self, struct _cef_browser_t* browser, + struct _cef_frame_t* frame, struct _cef_context_menu_params_t* params, + struct _cef_menu_model_t* model); + + /// + // Called to execute a command selected from the context menu. Return true (1) + // if the command was handled or false (0) for the default implementation. See + // cef_menu_id_t for the command ids that have default implementations. All + // user-defined command ids should be between MENU_ID_USER_FIRST and + // MENU_ID_USER_LAST. |params| will have the same values as what was passed to + // on_before_context_menu(). Do not keep a reference to |params| outside of + // this callback. + /// + int (CEF_CALLBACK *on_context_menu_command)( + struct _cef_context_menu_handler_t* self, struct _cef_browser_t* browser, + struct _cef_frame_t* frame, struct _cef_context_menu_params_t* params, + int command_id, enum cef_event_flags_t event_flags); + + /// + // Called when the context menu is dismissed irregardless of whether the menu + // was NULL or a command was selected. + /// + void (CEF_CALLBACK *on_context_menu_dismissed)( + struct _cef_context_menu_handler_t* self, struct _cef_browser_t* browser, + struct _cef_frame_t* frame); +} cef_context_menu_handler_t; + + +/// +// Provides information about the context menu state. The ethods of this +// structure can only be accessed on browser process the UI thread. +/// +typedef struct _cef_context_menu_params_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns the X coordinate of the mouse where the context menu was invoked. + // Coords are relative to the associated RenderView's origin. + /// + int (CEF_CALLBACK *get_xcoord)(struct _cef_context_menu_params_t* self); + + /// + // Returns the Y coordinate of the mouse where the context menu was invoked. + // Coords are relative to the associated RenderView's origin. + /// + int (CEF_CALLBACK *get_ycoord)(struct _cef_context_menu_params_t* self); + + /// + // Returns flags representing the type of node that the context menu was + // invoked on. + /// + enum cef_context_menu_type_flags_t (CEF_CALLBACK *get_type_flags)( + struct _cef_context_menu_params_t* self); + + /// + // Returns the URL of the link, if any, that encloses the node that the + // context menu was invoked on. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_link_url)( + struct _cef_context_menu_params_t* self); + + /// + // Returns the link URL, if any, to be used ONLY for "copy link address". We + // don't validate this field in the frontend process. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_unfiltered_link_url)( + struct _cef_context_menu_params_t* self); + + /// + // Returns the source URL, if any, for the element that the context menu was + // invoked on. Example of elements with source URLs are img, audio, and video. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_source_url)( + struct _cef_context_menu_params_t* self); + + /// + // Returns true (1) if the context menu was invoked on a blocked image. + /// + int (CEF_CALLBACK *is_image_blocked)(struct _cef_context_menu_params_t* self); + + /// + // Returns the URL of the top level page that the context menu was invoked on. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_page_url)( + struct _cef_context_menu_params_t* self); + + /// + // Returns the URL of the subframe that the context menu was invoked on. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_frame_url)( + struct _cef_context_menu_params_t* self); + + /// + // Returns the character encoding of the subframe that the context menu was + // invoked on. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_frame_charset)( + struct _cef_context_menu_params_t* self); + + /// + // Returns the type of context node that the context menu was invoked on. + /// + enum cef_context_menu_media_type_t (CEF_CALLBACK *get_media_type)( + struct _cef_context_menu_params_t* self); + + /// + // Returns flags representing the actions supported by the media element, if + // any, that the context menu was invoked on. + /// + enum cef_context_menu_media_state_flags_t ( + CEF_CALLBACK *get_media_state_flags)( + struct _cef_context_menu_params_t* self); + + /// + // Returns the text of the selection, if any, that the context menu was + // invoked on. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_selection_text)( + struct _cef_context_menu_params_t* self); + + /// + // Returns true (1) if the context menu was invoked on an editable node. + /// + int (CEF_CALLBACK *is_editable)(struct _cef_context_menu_params_t* self); + + /// + // Returns true (1) if the context menu was invoked on an editable node where + // speech-input is enabled. + /// + int (CEF_CALLBACK *is_speech_input_enabled)( + struct _cef_context_menu_params_t* self); + + /// + // Returns flags representing the actions supported by the editable node, if + // any, that the context menu was invoked on. + /// + enum cef_context_menu_edit_state_flags_t (CEF_CALLBACK *get_edit_state_flags)( + struct _cef_context_menu_params_t* self); +} cef_context_menu_params_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_ diff --git a/cef3/include/capi/cef_cookie_capi.h b/cef3/include/capi/cef_cookie_capi.h new file mode 100644 index 000000000..14470be0e --- /dev/null +++ b/cef3/include/capi/cef_cookie_capi.h @@ -0,0 +1,174 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Structure used for managing cookies. The functions of this structure may be +// called on any thread unless otherwise indicated. +/// +typedef struct _cef_cookie_manager_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Set the schemes supported by this manager. By default only "http" and + // "https" schemes are supported. Must be called before any cookies are + // accessed. + /// + void (CEF_CALLBACK *set_supported_schemes)(struct _cef_cookie_manager_t* self, + cef_string_list_t schemes); + + /// + // Visit all cookies. The returned cookies are ordered by longest path, then + // by earliest creation date. Returns false (0) if cookies cannot be accessed. + /// + int (CEF_CALLBACK *visit_all_cookies)(struct _cef_cookie_manager_t* self, + struct _cef_cookie_visitor_t* visitor); + + /// + // Visit a subset of cookies. The results are filtered by the given url + // scheme, host, domain and path. If |includeHttpOnly| is true (1) HTTP-only + // cookies will also be included in the results. The returned cookies are + // ordered by longest path, then by earliest creation date. Returns false (0) + // if cookies cannot be accessed. + /// + int (CEF_CALLBACK *visit_url_cookies)(struct _cef_cookie_manager_t* self, + const cef_string_t* url, int includeHttpOnly, + struct _cef_cookie_visitor_t* visitor); + + /// + // Sets a cookie given a valid URL and explicit user-provided cookie + // attributes. This function expects each attribute to be well-formed. It will + // check for disallowed characters (e.g. the ';' character is disallowed + // within the cookie value attribute) and will return false (0) without + // setting the cookie if such characters are found. This function must be + // called on the IO thread. + /// + int (CEF_CALLBACK *set_cookie)(struct _cef_cookie_manager_t* self, + const cef_string_t* url, const struct _cef_cookie_t* cookie); + + /// + // Delete all cookies that match the specified parameters. If both |url| and + // values |cookie_name| are specified all host and domain cookies matching + // both will be deleted. If only |url| is specified all host cookies (but not + // domain cookies) irrespective of path will be deleted. If |url| is NULL all + // cookies for all hosts and domains will be deleted. Returns false (0) if a + // non- NULL invalid URL is specified or if cookies cannot be accessed. This + // function must be called on the IO thread. + /// + int (CEF_CALLBACK *delete_cookies)(struct _cef_cookie_manager_t* self, + const cef_string_t* url, const cef_string_t* cookie_name); + + /// + // Sets the directory path that will be used for storing cookie data. If + // |path| is NULL data will be stored in memory only. Otherwise, data will be + // stored at the specified |path|. To persist session cookies (cookies without + // an expiry date or validity interval) set |persist_session_cookies| to true + // (1). Session cookies are generally intended to be transient and most Web + // browsers do not persist them. Returns false (0) if cookies cannot be + // accessed. + /// + int (CEF_CALLBACK *set_storage_path)(struct _cef_cookie_manager_t* self, + const cef_string_t* path, int persist_session_cookies); + + /// + // Flush the backing store (if any) to disk and execute the specified + // |handler| on the IO thread when done. Returns false (0) if cookies cannot + // be accessed. + /// + int (CEF_CALLBACK *flush_store)(struct _cef_cookie_manager_t* self, + struct _cef_completion_handler_t* handler); +} cef_cookie_manager_t; + + +/// +// Returns the global cookie manager. By default data will be stored at +// CefSettings.cache_path if specified or in memory otherwise. +/// +CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_global_manager(); + +/// +// Creates a new cookie manager. If |path| is NULL data will be stored in memory +// only. Otherwise, data will be stored at the specified |path|. To persist +// session cookies (cookies without an expiry date or validity interval) set +// |persist_session_cookies| to true (1). Session cookies are generally intended +// to be transient and most Web browsers do not persist them. Returns NULL if +// creation fails. +/// +CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_create_manager( + const cef_string_t* path, int persist_session_cookies); + + +/// +// Structure to implement for visiting cookie values. The functions of this +// structure will always be called on the IO thread. +/// +typedef struct _cef_cookie_visitor_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Method that will be called once for each cookie. |count| is the 0-based + // index for the current cookie. |total| is the total number of cookies. Set + // |deleteCookie| to true (1) to delete the cookie currently being visited. + // Return false (0) to stop visiting cookies. This function may never be + // called if no cookies are found. + /// + int (CEF_CALLBACK *visit)(struct _cef_cookie_visitor_t* self, + const struct _cef_cookie_t* cookie, int count, int total, + int* deleteCookie); +} cef_cookie_visitor_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_ diff --git a/cef3/include/capi/cef_dialog_handler_capi.h b/cef3/include/capi/cef_dialog_handler_capi.h new file mode 100644 index 000000000..bd7a2656c --- /dev/null +++ b/cef3/include/capi/cef_dialog_handler_capi.h @@ -0,0 +1,105 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_DIALOG_HANDLER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_DIALOG_HANDLER_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Callback structure for asynchronous continuation of file dialog requests. +/// +typedef struct _cef_file_dialog_callback_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Continue the file selection with the specified |file_paths|. This may be a + // single value or a list of values depending on the dialog mode. An NULL + // value is treated the same as calling cancel(). + /// + void (CEF_CALLBACK *cont)(struct _cef_file_dialog_callback_t* self, + cef_string_list_t file_paths); + + /// + // Cancel the file selection. + /// + void (CEF_CALLBACK *cancel)(struct _cef_file_dialog_callback_t* self); +} cef_file_dialog_callback_t; + + +/// +// Implement this structure to handle dialog events. The functions of this +// structure will be called on the browser process UI thread. +/// +typedef struct _cef_dialog_handler_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Called to run a file chooser dialog. |mode| represents the type of dialog + // to display. |title| to the title to be used for the dialog and may be NULL + // to show the default title ("Open" or "Save" depending on the mode). + // |default_file_name| is the default file name to select in the dialog. + // |accept_types| is a list of valid lower-cased MIME types or file extensions + // specified in an input element and is used to restrict selectable files to + // such types. To display a custom dialog return true (1) and execute + // |callback| either inline or at a later time. To display the default dialog + // return false (0). + /// + int (CEF_CALLBACK *on_file_dialog)(struct _cef_dialog_handler_t* self, + struct _cef_browser_t* browser, enum cef_file_dialog_mode_t mode, + const cef_string_t* title, const cef_string_t* default_file_name, + cef_string_list_t accept_types, + struct _cef_file_dialog_callback_t* callback); +} cef_dialog_handler_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_DIALOG_HANDLER_CAPI_H_ diff --git a/cef3/include/capi/cef_display_handler_capi.h b/cef3/include/capi/cef_display_handler_capi.h new file mode 100644 index 000000000..9a329a8aa --- /dev/null +++ b/cef3/include/capi/cef_display_handler_capi.h @@ -0,0 +1,111 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Implement this structure to handle events related to browser display state. +// The functions of this structure will be called on the UI thread. +/// +typedef struct _cef_display_handler_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Called when the loading state has changed. + /// + void (CEF_CALLBACK *on_loading_state_change)( + struct _cef_display_handler_t* self, struct _cef_browser_t* browser, + int isLoading, int canGoBack, int canGoForward); + + /// + // Called when a frame's address has changed. + /// + void (CEF_CALLBACK *on_address_change)(struct _cef_display_handler_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame, + const cef_string_t* url); + + /// + // Called when the page title changes. + /// + void (CEF_CALLBACK *on_title_change)(struct _cef_display_handler_t* self, + struct _cef_browser_t* browser, const cef_string_t* title); + + /// + // Called when the browser is about to display a tooltip. |text| contains the + // text that will be displayed in the tooltip. To handle the display of the + // tooltip yourself return true (1). Otherwise, you can optionally modify + // |text| and then return false (0) to allow the browser to display the + // tooltip. When window rendering is disabled the application is responsible + // for drawing tooltips and the return value is ignored. + /// + int (CEF_CALLBACK *on_tooltip)(struct _cef_display_handler_t* self, + struct _cef_browser_t* browser, cef_string_t* text); + + /// + // Called when the browser receives a status message. |text| contains the text + // that will be displayed in the status message and |type| indicates the + // status message type. + /// + void (CEF_CALLBACK *on_status_message)(struct _cef_display_handler_t* self, + struct _cef_browser_t* browser, const cef_string_t* value); + + /// + // Called to display a console message. Return true (1) to stop the message + // from being output to the console. + /// + int (CEF_CALLBACK *on_console_message)(struct _cef_display_handler_t* self, + struct _cef_browser_t* browser, const cef_string_t* message, + const cef_string_t* source, int line); +} cef_display_handler_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_ diff --git a/cef3/include/capi/cef_dom_capi.h b/cef3/include/capi/cef_dom_capi.h new file mode 100644 index 000000000..99f0055c1 --- /dev/null +++ b/cef3/include/capi/cef_dom_capi.h @@ -0,0 +1,446 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_DOM_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_DOM_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Structure to implement for visiting the DOM. The functions of this structure +// will be called on the render process main thread. +/// +typedef struct _cef_domvisitor_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Method executed for visiting the DOM. The document object passed to this + // function represents a snapshot of the DOM at the time this function is + // executed. DOM objects are only valid for the scope of this function. Do not + // keep references to or attempt to access any DOM objects outside the scope + // of this function. + /// + void (CEF_CALLBACK *visit)(struct _cef_domvisitor_t* self, + struct _cef_domdocument_t* document); +} cef_domvisitor_t; + + +/// +// Structure used to represent a DOM document. The functions of this structure +// should only be called on the render process main thread thread. +/// +typedef struct _cef_domdocument_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns the document type. + /// + enum cef_dom_document_type_t (CEF_CALLBACK *get_type)( + struct _cef_domdocument_t* self); + + /// + // Returns the root document node. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_document)( + struct _cef_domdocument_t* self); + + /// + // Returns the BODY node of an HTML document. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_body)( + struct _cef_domdocument_t* self); + + /// + // Returns the HEAD node of an HTML document. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_head)( + struct _cef_domdocument_t* self); + + /// + // Returns the title of an HTML document. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_title)( + struct _cef_domdocument_t* self); + + /// + // Returns the document element with the specified ID value. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_element_by_id)( + struct _cef_domdocument_t* self, const cef_string_t* id); + + /// + // Returns the node that currently has keyboard focus. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_focused_node)( + struct _cef_domdocument_t* self); + + /// + // Returns true (1) if a portion of the document is selected. + /// + int (CEF_CALLBACK *has_selection)(struct _cef_domdocument_t* self); + + /// + // Returns the selection start node. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_selection_start_node)( + struct _cef_domdocument_t* self); + + /// + // Returns the selection offset within the start node. + /// + int (CEF_CALLBACK *get_selection_start_offset)( + struct _cef_domdocument_t* self); + + /// + // Returns the selection end node. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_selection_end_node)( + struct _cef_domdocument_t* self); + + /// + // Returns the selection offset within the end node. + /// + int (CEF_CALLBACK *get_selection_end_offset)(struct _cef_domdocument_t* self); + + /// + // Returns the contents of this selection as markup. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_selection_as_markup)( + struct _cef_domdocument_t* self); + + /// + // Returns the contents of this selection as text. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_selection_as_text)( + struct _cef_domdocument_t* self); + + /// + // Returns the base URL for the document. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_base_url)( + struct _cef_domdocument_t* self); + + /// + // Returns a complete URL based on the document base URL and the specified + // partial URL. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_complete_url)( + struct _cef_domdocument_t* self, const cef_string_t* partialURL); +} cef_domdocument_t; + + +/// +// Structure used to represent a DOM node. The functions of this structure +// should only be called on the render process main thread. +/// +typedef struct _cef_domnode_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns the type for this node. + /// + enum cef_dom_node_type_t (CEF_CALLBACK *get_type)( + struct _cef_domnode_t* self); + + /// + // Returns true (1) if this is a text node. + /// + int (CEF_CALLBACK *is_text)(struct _cef_domnode_t* self); + + /// + // Returns true (1) if this is an element node. + /// + int (CEF_CALLBACK *is_element)(struct _cef_domnode_t* self); + + /// + // Returns true (1) if this is an editable node. + /// + int (CEF_CALLBACK *is_editable)(struct _cef_domnode_t* self); + + /// + // Returns true (1) if this is a form control element node. + /// + int (CEF_CALLBACK *is_form_control_element)(struct _cef_domnode_t* self); + + /// + // Returns the type of this form control element node. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_form_control_element_type)( + struct _cef_domnode_t* self); + + /// + // Returns true (1) if this object is pointing to the same handle as |that| + // object. + /// + int (CEF_CALLBACK *is_same)(struct _cef_domnode_t* self, + struct _cef_domnode_t* that); + + /// + // Returns the name of this node. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_name)(struct _cef_domnode_t* self); + + /// + // Returns the value of this node. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_value)(struct _cef_domnode_t* self); + + /// + // Set the value of this node. Returns true (1) on success. + /// + int (CEF_CALLBACK *set_value)(struct _cef_domnode_t* self, + const cef_string_t* value); + + /// + // Returns the contents of this node as markup. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_as_markup)( + struct _cef_domnode_t* self); + + /// + // Returns the document associated with this node. + /// + struct _cef_domdocument_t* (CEF_CALLBACK *get_document)( + struct _cef_domnode_t* self); + + /// + // Returns the parent node. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_parent)( + struct _cef_domnode_t* self); + + /// + // Returns the previous sibling node. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_previous_sibling)( + struct _cef_domnode_t* self); + + /// + // Returns the next sibling node. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_next_sibling)( + struct _cef_domnode_t* self); + + /// + // Returns true (1) if this node has child nodes. + /// + int (CEF_CALLBACK *has_children)(struct _cef_domnode_t* self); + + /// + // Return the first child node. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_first_child)( + struct _cef_domnode_t* self); + + /// + // Returns the last child node. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_last_child)( + struct _cef_domnode_t* self); + + /// + // Add an event listener to this node for the specified event type. If + // |useCapture| is true (1) then this listener will be considered a capturing + // listener. Capturing listeners will recieve all events of the specified type + // before the events are dispatched to any other event targets beneath the + // current node in the tree. Events which are bubbling upwards through the + // tree will not trigger a capturing listener. Separate calls to this function + // can be used to register the same listener with and without capture. See + // WebCore/dom/EventNames.h for the list of supported event types. + /// + void (CEF_CALLBACK *add_event_listener)(struct _cef_domnode_t* self, + const cef_string_t* eventType, struct _cef_domevent_listener_t* listener, + int useCapture); + + + // The following functions are valid only for element nodes. + + /// + // Returns the tag name of this element. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_element_tag_name)( + struct _cef_domnode_t* self); + + /// + // Returns true (1) if this element has attributes. + /// + int (CEF_CALLBACK *has_element_attributes)(struct _cef_domnode_t* self); + + /// + // Returns true (1) if this element has an attribute named |attrName|. + /// + int (CEF_CALLBACK *has_element_attribute)(struct _cef_domnode_t* self, + const cef_string_t* attrName); + + /// + // Returns the element attribute named |attrName|. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_element_attribute)( + struct _cef_domnode_t* self, const cef_string_t* attrName); + + /// + // Returns a map of all element attributes. + /// + void (CEF_CALLBACK *get_element_attributes)(struct _cef_domnode_t* self, + cef_string_map_t attrMap); + + /// + // Set the value for the element attribute named |attrName|. Returns true (1) + // on success. + /// + int (CEF_CALLBACK *set_element_attribute)(struct _cef_domnode_t* self, + const cef_string_t* attrName, const cef_string_t* value); + + /// + // Returns the inner text of the element. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_element_inner_text)( + struct _cef_domnode_t* self); +} cef_domnode_t; + + +/// +// Structure used to represent a DOM event. The functions of this structure +// should only be called on the render process main thread. +/// +typedef struct _cef_domevent_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns the event type. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_type)(struct _cef_domevent_t* self); + + /// + // Returns the event category. + /// + enum cef_dom_event_category_t (CEF_CALLBACK *get_category)( + struct _cef_domevent_t* self); + + /// + // Returns the event processing phase. + /// + enum cef_dom_event_phase_t (CEF_CALLBACK *get_phase)( + struct _cef_domevent_t* self); + + /// + // Returns true (1) if the event can bubble up the tree. + /// + int (CEF_CALLBACK *can_bubble)(struct _cef_domevent_t* self); + + /// + // Returns true (1) if the event can be canceled. + /// + int (CEF_CALLBACK *can_cancel)(struct _cef_domevent_t* self); + + /// + // Returns the document associated with this event. + /// + struct _cef_domdocument_t* (CEF_CALLBACK *get_document)( + struct _cef_domevent_t* self); + + /// + // Returns the target of the event. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_target)( + struct _cef_domevent_t* self); + + /// + // Returns the current target of the event. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_current_target)( + struct _cef_domevent_t* self); +} cef_domevent_t; + + +/// +// Structure to implement for handling DOM events. The functions of this +// structure will be called on the render process main thread. +/// +typedef struct _cef_domevent_listener_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Called when an event is received. The event object passed to this function + // contains a snapshot of the DOM at the time this function is executed. DOM + // objects are only valid for the scope of this function. Do not keep + // references to or attempt to access any DOM objects outside the scope of + // this function. + /// + void (CEF_CALLBACK *handle_event)(struct _cef_domevent_listener_t* self, + struct _cef_domevent_t* event); +} cef_domevent_listener_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_DOM_CAPI_H_ diff --git a/cef3/include/capi/cef_download_handler_capi.h b/cef3/include/capi/cef_download_handler_capi.h new file mode 100644 index 000000000..e75ab07d3 --- /dev/null +++ b/cef3/include/capi/cef_download_handler_capi.h @@ -0,0 +1,125 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_DOWNLOAD_HANDLER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_DOWNLOAD_HANDLER_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Callback structure used to asynchronously continue a download. +/// +typedef struct _cef_before_download_callback_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Call to continue the download. Set |download_path| to the full file path + // for the download including the file name or leave blank to use the + // suggested name and the default temp directory. Set |show_dialog| to true + // (1) if you do wish to show the default "Save As" dialog. + /// + void (CEF_CALLBACK *cont)(struct _cef_before_download_callback_t* self, + const cef_string_t* download_path, int show_dialog); +} cef_before_download_callback_t; + + +/// +// Callback structure used to asynchronously cancel a download. +/// +typedef struct _cef_download_item_callback_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Call to cancel the download. + /// + void (CEF_CALLBACK *cancel)(struct _cef_download_item_callback_t* self); +} cef_download_item_callback_t; + + +/// +// Structure used to handle file downloads. The functions of this structure will +// called on the browser process UI thread. +/// +typedef struct _cef_download_handler_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Called before a download begins. |suggested_name| is the suggested name for + // the download file. By default the download will be canceled. Execute + // |callback| either asynchronously or in this function to continue the + // download if desired. Do not keep a reference to |download_item| outside of + // this function. + /// + void (CEF_CALLBACK *on_before_download)(struct _cef_download_handler_t* self, + struct _cef_browser_t* browser, + struct _cef_download_item_t* download_item, + const cef_string_t* suggested_name, + struct _cef_before_download_callback_t* callback); + + /// + // Called when a download's status or progress information has been updated. + // This may be called multiple times before and after on_before_download(). + // Execute |callback| either asynchronously or in this function to cancel the + // download if desired. Do not keep a reference to |download_item| outside of + // this function. + /// + void (CEF_CALLBACK *on_download_updated)(struct _cef_download_handler_t* self, + struct _cef_browser_t* browser, + struct _cef_download_item_t* download_item, + struct _cef_download_item_callback_t* callback); +} cef_download_handler_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_DOWNLOAD_HANDLER_CAPI_H_ diff --git a/cef3/include/capi/cef_download_item_capi.h b/cef3/include/capi/cef_download_item_capi.h new file mode 100644 index 000000000..5639eb53f --- /dev/null +++ b/cef3/include/capi/cef_download_item_capi.h @@ -0,0 +1,155 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_DOWNLOAD_ITEM_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_DOWNLOAD_ITEM_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Structure used to represent a download item. +/// +typedef struct _cef_download_item_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns true (1) if this object is valid. Do not call any other functions + // if this function returns false (0). + /// + int (CEF_CALLBACK *is_valid)(struct _cef_download_item_t* self); + + /// + // Returns true (1) if the download is in progress. + /// + int (CEF_CALLBACK *is_in_progress)(struct _cef_download_item_t* self); + + /// + // Returns true (1) if the download is complete. + /// + int (CEF_CALLBACK *is_complete)(struct _cef_download_item_t* self); + + /// + // Returns true (1) if the download has been canceled or interrupted. + /// + int (CEF_CALLBACK *is_canceled)(struct _cef_download_item_t* self); + + /// + // Returns a simple speed estimate in bytes/s. + /// + int64 (CEF_CALLBACK *get_current_speed)(struct _cef_download_item_t* self); + + /// + // Returns the rough percent complete or -1 if the receive total size is + // unknown. + /// + int (CEF_CALLBACK *get_percent_complete)(struct _cef_download_item_t* self); + + /// + // Returns the total number of bytes. + /// + int64 (CEF_CALLBACK *get_total_bytes)(struct _cef_download_item_t* self); + + /// + // Returns the number of received bytes. + /// + int64 (CEF_CALLBACK *get_received_bytes)(struct _cef_download_item_t* self); + + /// + // Returns the time that the download started. + /// + cef_time_t (CEF_CALLBACK *get_start_time)(struct _cef_download_item_t* self); + + /// + // Returns the time that the download ended. + /// + cef_time_t (CEF_CALLBACK *get_end_time)(struct _cef_download_item_t* self); + + /// + // Returns the full path to the downloaded or downloading file. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_full_path)( + struct _cef_download_item_t* self); + + /// + // Returns the unique identifier for this download. + /// + int32 (CEF_CALLBACK *get_id)(struct _cef_download_item_t* self); + + /// + // Returns the URL. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_url)( + struct _cef_download_item_t* self); + + /// + // Returns the suggested file name. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_suggested_file_name)( + struct _cef_download_item_t* self); + + /// + // Returns the content disposition. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_content_disposition)( + struct _cef_download_item_t* self); + + /// + // Returns the mime type. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_mime_type)( + struct _cef_download_item_t* self); +} cef_download_item_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_DOWNLOAD_ITEM_CAPI_H_ diff --git a/cef3/include/capi/cef_focus_handler_capi.h b/cef3/include/capi/cef_focus_handler_capi.h new file mode 100644 index 000000000..b0b2a34b6 --- /dev/null +++ b/cef3/include/capi/cef_focus_handler_capi.h @@ -0,0 +1,87 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_FOCUS_HANDLER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_FOCUS_HANDLER_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Implement this structure to handle events related to focus. The functions of +// this structure will be called on the UI thread. +/// +typedef struct _cef_focus_handler_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Called when the browser component is about to loose focus. For instance, if + // focus was on the last HTML element and the user pressed the TAB key. |next| + // will be true (1) if the browser is giving focus to the next component and + // false (0) if the browser is giving focus to the previous component. + /// + void (CEF_CALLBACK *on_take_focus)(struct _cef_focus_handler_t* self, + struct _cef_browser_t* browser, int next); + + /// + // Called when the browser component is requesting focus. |source| indicates + // where the focus request is originating from. Return false (0) to allow the + // focus to be set or true (1) to cancel setting the focus. + /// + int (CEF_CALLBACK *on_set_focus)(struct _cef_focus_handler_t* self, + struct _cef_browser_t* browser, enum cef_focus_source_t source); + + /// + // Called when the browser component has received focus. + /// + void (CEF_CALLBACK *on_got_focus)(struct _cef_focus_handler_t* self, + struct _cef_browser_t* browser); +} cef_focus_handler_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_FOCUS_HANDLER_CAPI_H_ diff --git a/cef3/include/capi/cef_frame_capi.h b/cef3/include/capi/cef_frame_capi.h new file mode 100644 index 000000000..692464ef8 --- /dev/null +++ b/cef3/include/capi/cef_frame_capi.h @@ -0,0 +1,214 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_FRAME_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_FRAME_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Structure used to represent a frame in the browser window. When used in the +// browser process the functions of this structure may be called on any thread +// unless otherwise indicated in the comments. When used in the render process +// the functions of this structure may only be called on the main thread. +/// +typedef struct _cef_frame_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // True if this object is currently attached to a valid frame. + /// + int (CEF_CALLBACK *is_valid)(struct _cef_frame_t* self); + + /// + // Execute undo in this frame. + /// + void (CEF_CALLBACK *undo)(struct _cef_frame_t* self); + + /// + // Execute redo in this frame. + /// + void (CEF_CALLBACK *redo)(struct _cef_frame_t* self); + + /// + // Execute cut in this frame. + /// + void (CEF_CALLBACK *cut)(struct _cef_frame_t* self); + + /// + // Execute copy in this frame. + /// + void (CEF_CALLBACK *copy)(struct _cef_frame_t* self); + + /// + // Execute paste in this frame. + /// + void (CEF_CALLBACK *paste)(struct _cef_frame_t* self); + + /// + // Execute delete in this frame. + /// + void (CEF_CALLBACK *del)(struct _cef_frame_t* self); + + /// + // Execute select all in this frame. + /// + void (CEF_CALLBACK *select_all)(struct _cef_frame_t* self); + + /// + // Save this frame's HTML source to a temporary file and open it in the + // default text viewing application. This function can only be called from the + // browser process. + /// + void (CEF_CALLBACK *view_source)(struct _cef_frame_t* self); + + /// + // Retrieve this frame's HTML source as a string sent to the specified + // visitor. + /// + void (CEF_CALLBACK *get_source)(struct _cef_frame_t* self, + struct _cef_string_visitor_t* visitor); + + /// + // Retrieve this frame's display text as a string sent to the specified + // visitor. + /// + void (CEF_CALLBACK *get_text)(struct _cef_frame_t* self, + struct _cef_string_visitor_t* visitor); + + /// + // Load the request represented by the |request| object. + /// + void (CEF_CALLBACK *load_request)(struct _cef_frame_t* self, + struct _cef_request_t* request); + + /// + // Load the specified |url|. + /// + void (CEF_CALLBACK *load_url)(struct _cef_frame_t* self, + const cef_string_t* url); + + /// + // Load the contents of |string_val| with the specified dummy |url|. |url| + // should have a standard scheme (for example, http scheme) or behaviors like + // link clicks and web security restrictions may not behave as expected. + /// + void (CEF_CALLBACK *load_string)(struct _cef_frame_t* self, + const cef_string_t* string_val, const cef_string_t* url); + + /// + // Execute a string of JavaScript code in this frame. The |script_url| + // parameter is the URL where the script in question can be found, if any. The + // renderer may request this URL to show the developer the source of the + // error. The |start_line| parameter is the base line number to use for error + // reporting. + /// + void (CEF_CALLBACK *execute_java_script)(struct _cef_frame_t* self, + const cef_string_t* code, const cef_string_t* script_url, + int start_line); + + /// + // Returns true (1) if this is the main (top-level) frame. + /// + int (CEF_CALLBACK *is_main)(struct _cef_frame_t* self); + + /// + // Returns true (1) if this is the focused frame. + /// + int (CEF_CALLBACK *is_focused)(struct _cef_frame_t* self); + + /// + // Returns the name for this frame. If the frame has an assigned name (for + // example, set via the iframe "name" attribute) then that value will be + // returned. Otherwise a unique name will be constructed based on the frame + // parent hierarchy. The main (top-level) frame will always have an NULL name + // value. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_name)(struct _cef_frame_t* self); + + /// + // Returns the globally unique identifier for this frame. + /// + int64 (CEF_CALLBACK *get_identifier)(struct _cef_frame_t* self); + + /// + // Returns the parent of this frame or NULL if this is the main (top-level) + // frame. + /// + struct _cef_frame_t* (CEF_CALLBACK *get_parent)(struct _cef_frame_t* self); + + /// + // Returns the URL currently loaded in this frame. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_url)(struct _cef_frame_t* self); + + /// + // Returns the browser that this frame belongs to. + /// + struct _cef_browser_t* (CEF_CALLBACK *get_browser)(struct _cef_frame_t* self); + + /// + // Get the V8 context associated with the frame. This function can only be + // called from the render process. + /// + struct _cef_v8context_t* (CEF_CALLBACK *get_v8context)( + struct _cef_frame_t* self); + + /// + // Visit the DOM document. This function can only be called from the render + // process. + /// + void (CEF_CALLBACK *visit_dom)(struct _cef_frame_t* self, + struct _cef_domvisitor_t* visitor); +} cef_frame_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_FRAME_CAPI_H_ diff --git a/cef3/include/capi/cef_geolocation_capi.h b/cef3/include/capi/cef_geolocation_capi.h new file mode 100644 index 000000000..c4ec6aa6a --- /dev/null +++ b/cef3/include/capi/cef_geolocation_capi.h @@ -0,0 +1,80 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_GEOLOCATION_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_GEOLOCATION_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Request a one-time geolocation update. This function bypasses any user +// permission checks so should only be used by code that is allowed to access +// location information. +/// +CEF_EXPORT int cef_get_geolocation( + struct _cef_get_geolocation_callback_t* callback); + +/// +// Implement this structure to receive geolocation updates. The functions of +// this structure will be called on the browser process UI thread. +/// +typedef struct _cef_get_geolocation_callback_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Called with the 'best available' location information or, if the location + // update failed, with error information. + /// + void (CEF_CALLBACK *on_location_update)( + struct _cef_get_geolocation_callback_t* self, + const struct _cef_geoposition_t* position); +} cef_get_geolocation_callback_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_GEOLOCATION_CAPI_H_ diff --git a/cef3/include/capi/cef_geolocation_handler_capi.h b/cef3/include/capi/cef_geolocation_handler_capi.h new file mode 100644 index 000000000..8a646b5ac --- /dev/null +++ b/cef3/include/capi/cef_geolocation_handler_capi.h @@ -0,0 +1,104 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_GEOLOCATION_HANDLER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_GEOLOCATION_HANDLER_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Callback structure used for asynchronous continuation of geolocation +// permission requests. +/// +typedef struct _cef_geolocation_callback_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Call to allow or deny geolocation access. + /// + void (CEF_CALLBACK *cont)(struct _cef_geolocation_callback_t* self, + int allow); +} cef_geolocation_callback_t; + + +/// +// Implement this structure to handle events related to geolocation permission +// requests. The functions of this structure will be called on the browser +// process IO thread. +/// +typedef struct _cef_geolocation_handler_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Called when a page requests permission to access geolocation information. + // |requesting_url| is the URL requesting permission and |request_id| is the + // unique ID for the permission request. Call + // cef_geolocation_callback_t::Continue to allow or deny the permission + // request. + /// + void (CEF_CALLBACK *on_request_geolocation_permission)( + struct _cef_geolocation_handler_t* self, struct _cef_browser_t* browser, + const cef_string_t* requesting_url, int request_id, + struct _cef_geolocation_callback_t* callback); + + /// + // Called when a geolocation access request is canceled. |requesting_url| is + // the URL that originally requested permission and |request_id| is the unique + // ID for the permission request. + /// + void (CEF_CALLBACK *on_cancel_geolocation_permission)( + struct _cef_geolocation_handler_t* self, struct _cef_browser_t* browser, + const cef_string_t* requesting_url, int request_id); +} cef_geolocation_handler_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_GEOLOCATION_HANDLER_CAPI_H_ diff --git a/cef3/include/capi/cef_jsdialog_handler_capi.h b/cef3/include/capi/cef_jsdialog_handler_capi.h new file mode 100644 index 000000000..4869f54ea --- /dev/null +++ b/cef3/include/capi/cef_jsdialog_handler_capi.h @@ -0,0 +1,126 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_JSDIALOG_HANDLER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_JSDIALOG_HANDLER_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Callback structure used for asynchronous continuation of JavaScript dialog +// requests. +/// +typedef struct _cef_jsdialog_callback_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Continue the JS dialog request. Set |success| to true (1) if the OK button + // was pressed. The |user_input| value should be specified for prompt dialogs. + /// + void (CEF_CALLBACK *cont)(struct _cef_jsdialog_callback_t* self, int success, + const cef_string_t* user_input); +} cef_jsdialog_callback_t; + + +/// +// Implement this structure to handle events related to JavaScript dialogs. The +// functions of this structure will be called on the UI thread. +/// +typedef struct _cef_jsdialog_handler_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Called to run a JavaScript dialog. The |default_prompt_text| value will be + // specified for prompt dialogs only. Set |suppress_message| to true (1) and + // return false (0) to suppress the message (suppressing messages is + // preferable to immediately executing the callback as this is used to detect + // presumably malicious behavior like spamming alert messages in + // onbeforeunload). Set |suppress_message| to false (0) and return false (0) + // to use the default implementation (the default implementation will show one + // modal dialog at a time and suppress any additional dialog requests until + // the displayed dialog is dismissed). Return true (1) if the application will + // use a custom dialog or if the callback has been executed immediately. + // Custom dialogs may be either modal or modeless. If a custom dialog is used + // the application must execute |callback| once the custom dialog is + // dismissed. + /// + int (CEF_CALLBACK *on_jsdialog)(struct _cef_jsdialog_handler_t* self, + struct _cef_browser_t* browser, const cef_string_t* origin_url, + const cef_string_t* accept_lang, enum cef_jsdialog_type_t dialog_type, + const cef_string_t* message_text, + const cef_string_t* default_prompt_text, + struct _cef_jsdialog_callback_t* callback, int* suppress_message); + + /// + // Called to run a dialog asking the user if they want to leave a page. Return + // false (0) to use the default dialog implementation. Return true (1) if the + // application will use a custom dialog or if the callback has been executed + // immediately. Custom dialogs may be either modal or modeless. If a custom + // dialog is used the application must execute |callback| once the custom + // dialog is dismissed. + /// + int (CEF_CALLBACK *on_before_unload_dialog)( + struct _cef_jsdialog_handler_t* self, struct _cef_browser_t* browser, + const cef_string_t* message_text, int is_reload, + struct _cef_jsdialog_callback_t* callback); + + /// + // Called to cancel any pending dialogs and reset any saved dialog state. Will + // be called due to events like page navigation irregardless of whether any + // dialogs are currently pending. + /// + void (CEF_CALLBACK *on_reset_dialog_state)( + struct _cef_jsdialog_handler_t* self, struct _cef_browser_t* browser); +} cef_jsdialog_handler_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_JSDIALOG_HANDLER_CAPI_H_ diff --git a/cef3/include/capi/cef_keyboard_handler_capi.h b/cef3/include/capi/cef_keyboard_handler_capi.h new file mode 100644 index 000000000..e01c150bf --- /dev/null +++ b/cef3/include/capi/cef_keyboard_handler_capi.h @@ -0,0 +1,83 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_KEYBOARD_HANDLER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_KEYBOARD_HANDLER_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Implement this structure to handle events related to keyboard input. The +// functions of this structure will be called on the UI thread. +/// +typedef struct _cef_keyboard_handler_t { + /// + // Base structure. + /// + cef_base_t base; + + // Called before a keyboard event is sent to the renderer. |event| contains + // information about the keyboard event. |os_event| is the operating system + // event message, if any. Return true (1) if the event was handled or false + // (0) otherwise. If the event will be handled in on_key_event() as a keyboard + // shortcut set |is_keyboard_shortcut| to true (1) and return false (0). + int (CEF_CALLBACK *on_pre_key_event)(struct _cef_keyboard_handler_t* self, + struct _cef_browser_t* browser, const struct _cef_key_event_t* event, + cef_event_handle_t os_event, int* is_keyboard_shortcut); + + /// + // Called after the renderer and JavaScript in the page has had a chance to + // handle the event. |event| contains information about the keyboard event. + // |os_event| is the operating system event message, if any. Return true (1) + // if the keyboard event was handled or false (0) otherwise. + /// + int (CEF_CALLBACK *on_key_event)(struct _cef_keyboard_handler_t* self, + struct _cef_browser_t* browser, const struct _cef_key_event_t* event, + cef_event_handle_t os_event); +} cef_keyboard_handler_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_KEYBOARD_HANDLER_CAPI_H_ diff --git a/cef3/include/capi/cef_life_span_handler_capi.h b/cef3/include/capi/cef_life_span_handler_capi.h new file mode 100644 index 000000000..0732c6e55 --- /dev/null +++ b/cef3/include/capi/cef_life_span_handler_capi.h @@ -0,0 +1,170 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_LIFE_SPAN_HANDLER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_LIFE_SPAN_HANDLER_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Implement this structure to handle events related to browser life span. The +// functions of this structure will be called on the UI thread unless otherwise +// indicated. +/// +typedef struct _cef_life_span_handler_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Called on the IO thread before a new popup window is created. The |browser| + // and |frame| parameters represent the source of the popup request. The + // |target_url| and |target_frame_name| values may be NULL if none were + // specified with the request. The |popupFeatures| structure contains + // information about the requested popup window. To allow creation of the + // popup window optionally modify |windowInfo|, |client|, |settings| and + // |no_javascript_access| and return false (0). To cancel creation of the + // popup window return true (1). The |client| and |settings| values will + // default to the source browser's values. The |no_javascript_access| value + // indicates whether the new browser window should be scriptable and in the + // same process as the source browser. + int (CEF_CALLBACK *on_before_popup)(struct _cef_life_span_handler_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame, + const cef_string_t* target_url, const cef_string_t* target_frame_name, + const struct _cef_popup_features_t* popupFeatures, + struct _cef_window_info_t* windowInfo, struct _cef_client_t** client, + struct _cef_browser_settings_t* settings, int* no_javascript_access); + + /// + // Called after a new browser is created. + /// + void (CEF_CALLBACK *on_after_created)(struct _cef_life_span_handler_t* self, + struct _cef_browser_t* browser); + + /// + // Called when a modal window is about to display and the modal loop should + // begin running. Return false (0) to use the default modal loop + // implementation or true (1) to use a custom implementation. + /// + int (CEF_CALLBACK *run_modal)(struct _cef_life_span_handler_t* self, + struct _cef_browser_t* browser); + + /// + // Called when a browser has recieved a request to close. This may result + // directly from a call to cef_browser_host_t::close_browser() or indirectly + // if the browser is a top-level OS window created by CEF and the user + // attempts to close the window. This function will be called after the + // JavaScript 'onunload' event has been fired. It will not be called for + // browsers after the associated OS window has been destroyed (for those + // browsers it is no longer possible to cancel the close). + // + // If CEF created an OS window for the browser returning false (0) will send + // an OS close notification to the browser window's top-level owner (e.g. + // WM_CLOSE on Windows, performClose: on OS-X and "delete_event" on Linux). If + // no OS window exists (window rendering disabled) returning false (0) will + // cause the browser object to be destroyed immediately. Return true (1) if + // the browser is parented to another window and that other window needs to + // receive close notification via some non-standard technique. + // + // If an application provides its own top-level window it should handle OS + // close notifications by calling cef_browser_host_t::CloseBrowser(false (0)) + // instead of immediately closing (see the example below). This gives CEF an + // opportunity to process the 'onbeforeunload' event and optionally cancel the + // close before do_close() is called. + // + // The cef_life_span_handler_t::OnBeforeclose() function will be called + // immediately before the browser object is destroyed. The application should + // only exit after OnBeforeclose() has been called for all existing browsers. + // + // If the browser represents a modal window and a custom modal loop + // implementation was provided in cef_life_span_handler_t::run_modal() this + // callback should be used to restore the opener window to a usable state. + // + // By way of example consider what should happen during window close when the + // browser is parented to an application-provided top-level OS window. 1. + // User clicks the window close button which sends an OS close + // notification (e.g. WM_CLOSE on Windows, performClose: on OS-X and + // "delete_event" on Linux). + // 2. Application's top-level window receives the close notification and: + // A. Calls CefBrowserHost::CloseBrowser(false). + // B. Cancels the window close. + // 3. JavaScript 'onbeforeunload' handler executes and shows the close + // confirmation dialog (which can be overridden via + // CefJSDialogHandler::OnBeforeUnloadDialog()). + // 4. User approves the close. 5. JavaScript 'onunload' handler executes. 6. + // Application's do_close() handler is called. Application will: + // A. Call CefBrowserHost::ParentWindowWillClose() to notify CEF that the + // parent window will be closing. + // B. Set a flag to indicate that the next close attempt will be allowed. + // C. Return false. + // 7. CEF sends an OS close notification. 8. Application's top-level window + // receives the OS close notification and + // allows the window to close based on the flag from #6B. + // 9. Browser OS window is destroyed. 10. Application's + // cef_life_span_handler_t::OnBeforeclose() handler is called and + // the browser object is destroyed. + // 11. Application exits by calling cef_quit_message_loop() if no other + // browsers + // exist. + /// + int (CEF_CALLBACK *do_close)(struct _cef_life_span_handler_t* self, + struct _cef_browser_t* browser); + + /// + // Called just before a browser is destroyed. Release all references to the + // browser object and do not attempt to execute any functions on the browser + // object after this callback returns. If this is a modal window and a custom + // modal loop implementation was provided in run_modal() this callback should + // be used to exit the custom modal loop. See do_close() documentation for + // additional usage information. + /// + void (CEF_CALLBACK *on_before_close)(struct _cef_life_span_handler_t* self, + struct _cef_browser_t* browser); +} cef_life_span_handler_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_LIFE_SPAN_HANDLER_CAPI_H_ diff --git a/cef3/include/capi/cef_load_handler_capi.h b/cef3/include/capi/cef_load_handler_capi.h new file mode 100644 index 000000000..5ec9060ba --- /dev/null +++ b/cef3/include/capi/cef_load_handler_capi.h @@ -0,0 +1,113 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_LOAD_HANDLER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_LOAD_HANDLER_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Implement this structure to handle events related to browser load status. The +// functions of this structure will be called on the UI thread. +/// +typedef struct _cef_load_handler_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Called when the browser begins loading a frame. The |frame| value will + // never be NULL -- call the is_main() function to check if this frame is the + // main frame. Multiple frames may be loading at the same time. Sub-frames may + // start or continue loading after the main frame load has ended. This + // function may not be called for a particular frame if the load request for + // that frame fails. + /// + void (CEF_CALLBACK *on_load_start)(struct _cef_load_handler_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame); + + /// + // Called when the browser is done loading a frame. The |frame| value will + // never be NULL -- call the is_main() function to check if this frame is the + // main frame. Multiple frames may be loading at the same time. Sub-frames may + // start or continue loading after the main frame load has ended. This + // function will always be called for all frames irrespective of whether the + // request completes successfully. + /// + void (CEF_CALLBACK *on_load_end)(struct _cef_load_handler_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame, + int httpStatusCode); + + /// + // Called when the browser fails to load a resource. |errorCode| is the error + // code number, |errorText| is the error text and and |failedUrl| is the URL + // that failed to load. See net\base\net_error_list.h for complete + // descriptions of the error codes. + /// + void (CEF_CALLBACK *on_load_error)(struct _cef_load_handler_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame, + enum cef_errorcode_t errorCode, const cef_string_t* errorText, + const cef_string_t* failedUrl); + + /// + // Called when the render process terminates unexpectedly. |status| indicates + // how the process terminated. + /// + void (CEF_CALLBACK *on_render_process_terminated)( + struct _cef_load_handler_t* self, struct _cef_browser_t* browser, + enum cef_termination_status_t status); + + /// + // Called when a plugin has crashed. |plugin_path| is the path of the plugin + // that crashed. + /// + void (CEF_CALLBACK *on_plugin_crashed)(struct _cef_load_handler_t* self, + struct _cef_browser_t* browser, const cef_string_t* plugin_path); +} cef_load_handler_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_LOAD_HANDLER_CAPI_H_ diff --git a/cef3/include/capi/cef_menu_model_capi.h b/cef3/include/capi/cef_menu_model_capi.h new file mode 100644 index 000000000..d0c7af323 --- /dev/null +++ b/cef3/include/capi/cef_menu_model_capi.h @@ -0,0 +1,388 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_MENU_MODEL_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_MENU_MODEL_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Supports creation and modification of menus. See cef_menu_id_t for the +// command ids that have default implementations. All user-defined command ids +// should be between MENU_ID_USER_FIRST and MENU_ID_USER_LAST. The functions of +// this structure can only be accessed on the browser process the UI thread. +/// +typedef struct _cef_menu_model_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Clears the menu. Returns true (1) on success. + /// + int (CEF_CALLBACK *clear)(struct _cef_menu_model_t* self); + + /// + // Returns the number of items in this menu. + /// + int (CEF_CALLBACK *get_count)(struct _cef_menu_model_t* self); + + // + // Add a separator to the menu. Returns true (1) on success. + /// + int (CEF_CALLBACK *add_separator)(struct _cef_menu_model_t* self); + + // + // Add an item to the menu. Returns true (1) on success. + /// + int (CEF_CALLBACK *add_item)(struct _cef_menu_model_t* self, int command_id, + const cef_string_t* label); + + // + // Add a check item to the menu. Returns true (1) on success. + /// + int (CEF_CALLBACK *add_check_item)(struct _cef_menu_model_t* self, + int command_id, const cef_string_t* label); + + // + // Add a radio item to the menu. Only a single item with the specified + // |group_id| can be checked at a time. Returns true (1) on success. + /// + int (CEF_CALLBACK *add_radio_item)(struct _cef_menu_model_t* self, + int command_id, const cef_string_t* label, int group_id); + + // + // Add a sub-menu to the menu. The new sub-menu is returned. + /// + struct _cef_menu_model_t* (CEF_CALLBACK *add_sub_menu)( + struct _cef_menu_model_t* self, int command_id, + const cef_string_t* label); + + // + // Insert a separator in the menu at the specified |index|. Returns true (1) + // on success. + /// + int (CEF_CALLBACK *insert_separator_at)(struct _cef_menu_model_t* self, + int index); + + // + // Insert an item in the menu at the specified |index|. Returns true (1) on + // success. + /// + int (CEF_CALLBACK *insert_item_at)(struct _cef_menu_model_t* self, int index, + int command_id, const cef_string_t* label); + + // + // Insert a check item in the menu at the specified |index|. Returns true (1) + // on success. + /// + int (CEF_CALLBACK *insert_check_item_at)(struct _cef_menu_model_t* self, + int index, int command_id, const cef_string_t* label); + + // + // Insert a radio item in the menu at the specified |index|. Only a single + // item with the specified |group_id| can be checked at a time. Returns true + // (1) on success. + /// + int (CEF_CALLBACK *insert_radio_item_at)(struct _cef_menu_model_t* self, + int index, int command_id, const cef_string_t* label, int group_id); + + // + // Insert a sub-menu in the menu at the specified |index|. The new sub-menu is + // returned. + /// + struct _cef_menu_model_t* (CEF_CALLBACK *insert_sub_menu_at)( + struct _cef_menu_model_t* self, int index, int command_id, + const cef_string_t* label); + + /// + // Removes the item with the specified |command_id|. Returns true (1) on + // success. + /// + int (CEF_CALLBACK *remove)(struct _cef_menu_model_t* self, int command_id); + + /// + // Removes the item at the specified |index|. Returns true (1) on success. + /// + int (CEF_CALLBACK *remove_at)(struct _cef_menu_model_t* self, int index); + + /// + // Returns the index associated with the specified |command_id| or -1 if not + // found due to the command id not existing in the menu. + /// + int (CEF_CALLBACK *get_index_of)(struct _cef_menu_model_t* self, + int command_id); + + /// + // Returns the command id at the specified |index| or -1 if not found due to + // invalid range or the index being a separator. + /// + int (CEF_CALLBACK *get_command_id_at)(struct _cef_menu_model_t* self, + int index); + + /// + // Sets the command id at the specified |index|. Returns true (1) on success. + /// + int (CEF_CALLBACK *set_command_id_at)(struct _cef_menu_model_t* self, + int index, int command_id); + + /// + // Returns the label for the specified |command_id| or NULL if not found. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_label)( + struct _cef_menu_model_t* self, int command_id); + + /// + // Returns the label at the specified |index| or NULL if not found due to + // invalid range or the index being a separator. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_label_at)( + struct _cef_menu_model_t* self, int index); + + /// + // Sets the label for the specified |command_id|. Returns true (1) on success. + /// + int (CEF_CALLBACK *set_label)(struct _cef_menu_model_t* self, int command_id, + const cef_string_t* label); + + /// + // Set the label at the specified |index|. Returns true (1) on success. + /// + int (CEF_CALLBACK *set_label_at)(struct _cef_menu_model_t* self, int index, + const cef_string_t* label); + + /// + // Returns the item type for the specified |command_id|. + /// + enum cef_menu_item_type_t (CEF_CALLBACK *get_type)( + struct _cef_menu_model_t* self, int command_id); + + /// + // Returns the item type at the specified |index|. + /// + enum cef_menu_item_type_t (CEF_CALLBACK *get_type_at)( + struct _cef_menu_model_t* self, int index); + + /// + // Returns the group id for the specified |command_id| or -1 if invalid. + /// + int (CEF_CALLBACK *get_group_id)(struct _cef_menu_model_t* self, + int command_id); + + /// + // Returns the group id at the specified |index| or -1 if invalid. + /// + int (CEF_CALLBACK *get_group_id_at)(struct _cef_menu_model_t* self, + int index); + + /// + // Sets the group id for the specified |command_id|. Returns true (1) on + // success. + /// + int (CEF_CALLBACK *set_group_id)(struct _cef_menu_model_t* self, + int command_id, int group_id); + + /// + // Sets the group id at the specified |index|. Returns true (1) on success. + /// + int (CEF_CALLBACK *set_group_id_at)(struct _cef_menu_model_t* self, int index, + int group_id); + + /// + // Returns the submenu for the specified |command_id| or NULL if invalid. + /// + struct _cef_menu_model_t* (CEF_CALLBACK *get_sub_menu)( + struct _cef_menu_model_t* self, int command_id); + + /// + // Returns the submenu at the specified |index| or NULL if invalid. + /// + struct _cef_menu_model_t* (CEF_CALLBACK *get_sub_menu_at)( + struct _cef_menu_model_t* self, int index); + + // + // Returns true (1) if the specified |command_id| is visible. + /// + int (CEF_CALLBACK *is_visible)(struct _cef_menu_model_t* self, + int command_id); + + // + // Returns true (1) if the specified |index| is visible. + /// + int (CEF_CALLBACK *is_visible_at)(struct _cef_menu_model_t* self, int index); + + // + // Change the visibility of the specified |command_id|. Returns true (1) on + // success. + /// + int (CEF_CALLBACK *set_visible)(struct _cef_menu_model_t* self, + int command_id, int visible); + + // + // Change the visibility at the specified |index|. Returns true (1) on + // success. + /// + int (CEF_CALLBACK *set_visible_at)(struct _cef_menu_model_t* self, int index, + int visible); + + // + // Returns true (1) if the specified |command_id| is enabled. + /// + int (CEF_CALLBACK *is_enabled)(struct _cef_menu_model_t* self, + int command_id); + + // + // Returns true (1) if the specified |index| is enabled. + /// + int (CEF_CALLBACK *is_enabled_at)(struct _cef_menu_model_t* self, int index); + + // + // Change the enabled status of the specified |command_id|. Returns true (1) + // on success. + /// + int (CEF_CALLBACK *set_enabled)(struct _cef_menu_model_t* self, + int command_id, int enabled); + + // + // Change the enabled status at the specified |index|. Returns true (1) on + // success. + /// + int (CEF_CALLBACK *set_enabled_at)(struct _cef_menu_model_t* self, int index, + int enabled); + + // + // Returns true (1) if the specified |command_id| is checked. Only applies to + // check and radio items. + /// + int (CEF_CALLBACK *is_checked)(struct _cef_menu_model_t* self, + int command_id); + + // + // Returns true (1) if the specified |index| is checked. Only applies to check + // and radio items. + /// + int (CEF_CALLBACK *is_checked_at)(struct _cef_menu_model_t* self, int index); + + // + // Check the specified |command_id|. Only applies to check and radio items. + // Returns true (1) on success. + /// + int (CEF_CALLBACK *set_checked)(struct _cef_menu_model_t* self, + int command_id, int checked); + + // + // Check the specified |index|. Only applies to check and radio items. Returns + // true (1) on success. + /// + int (CEF_CALLBACK *set_checked_at)(struct _cef_menu_model_t* self, int index, + int checked); + + // + // Returns true (1) if the specified |command_id| has a keyboard accelerator + // assigned. + /// + int (CEF_CALLBACK *has_accelerator)(struct _cef_menu_model_t* self, + int command_id); + + // + // Returns true (1) if the specified |index| has a keyboard accelerator + // assigned. + /// + int (CEF_CALLBACK *has_accelerator_at)(struct _cef_menu_model_t* self, + int index); + + // + // Set the keyboard accelerator for the specified |command_id|. |key_code| can + // be any virtual key or character value. Returns true (1) on success. + /// + int (CEF_CALLBACK *set_accelerator)(struct _cef_menu_model_t* self, + int command_id, int key_code, int shift_pressed, int ctrl_pressed, + int alt_pressed); + + // + // Set the keyboard accelerator at the specified |index|. |key_code| can be + // any virtual key or character value. Returns true (1) on success. + /// + int (CEF_CALLBACK *set_accelerator_at)(struct _cef_menu_model_t* self, + int index, int key_code, int shift_pressed, int ctrl_pressed, + int alt_pressed); + + // + // Remove the keyboard accelerator for the specified |command_id|. Returns + // true (1) on success. + /// + int (CEF_CALLBACK *remove_accelerator)(struct _cef_menu_model_t* self, + int command_id); + + // + // Remove the keyboard accelerator at the specified |index|. Returns true (1) + // on success. + /// + int (CEF_CALLBACK *remove_accelerator_at)(struct _cef_menu_model_t* self, + int index); + + // + // Retrieves the keyboard accelerator for the specified |command_id|. Returns + // true (1) on success. + /// + int (CEF_CALLBACK *get_accelerator)(struct _cef_menu_model_t* self, + int command_id, int* key_code, int* shift_pressed, int* ctrl_pressed, + int* alt_pressed); + + // + // Retrieves the keyboard accelerator for the specified |index|. Returns true + // (1) on success. + /// + int (CEF_CALLBACK *get_accelerator_at)(struct _cef_menu_model_t* self, + int index, int* key_code, int* shift_pressed, int* ctrl_pressed, + int* alt_pressed); +} cef_menu_model_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_MENU_MODEL_CAPI_H_ diff --git a/cef3/include/capi/cef_origin_whitelist_capi.h b/cef3/include/capi/cef_origin_whitelist_capi.h new file mode 100644 index 000000000..8dde4c1c5 --- /dev/null +++ b/cef3/include/capi/cef_origin_whitelist_capi.h @@ -0,0 +1,105 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_ORIGIN_WHITELIST_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_ORIGIN_WHITELIST_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Add an entry to the cross-origin access whitelist. +// +// The same-origin policy restricts how scripts hosted from different origins +// (scheme + domain + port) can communicate. By default, scripts can only access +// resources with the same origin. Scripts hosted on the HTTP and HTTPS schemes +// (but no other schemes) can use the "Access-Control-Allow-Origin" header to +// allow cross-origin requests. For example, https://source.example.com can make +// XMLHttpRequest requests on http://target.example.com if the +// http://target.example.com request returns an "Access-Control-Allow-Origin: +// https://source.example.com" response header. +// +// Scripts in separate frames or iframes and hosted from the same protocol and +// domain suffix can execute cross-origin JavaScript if both pages set the +// document.domain value to the same domain suffix. For example, +// scheme://foo.example.com and scheme://bar.example.com can communicate using +// JavaScript if both domains set document.domain="example.com". +// +// This function is used to allow access to origins that would otherwise violate +// the same-origin policy. Scripts hosted underneath the fully qualified +// |source_origin| URL (like http://www.example.com) will be allowed access to +// all resources hosted on the specified |target_protocol| and |target_domain|. +// If |target_domain| is non-NULL and |allow_target_subdomains| if false (0) +// only exact domain matches will be allowed. If |target_domain| is non-NULL and +// |allow_target_subdomains| is true (1) sub-domain matches will be allowed. If +// |target_domain| is NULL and |allow_target_subdomains| if true (1) all domains +// and IP addresses will be allowed. +// +// This function cannot be used to bypass the restrictions on local or display +// isolated schemes. See the comments on CefRegisterCustomScheme for more +// information. +// +// This function may be called on any thread. Returns false (0) if +// |source_origin| is invalid or the whitelist cannot be accessed. +/// +CEF_EXPORT int cef_add_cross_origin_whitelist_entry( + const cef_string_t* source_origin, const cef_string_t* target_protocol, + const cef_string_t* target_domain, int allow_target_subdomains); + +/// +// Remove an entry from the cross-origin access whitelist. Returns false (0) if +// |source_origin| is invalid or the whitelist cannot be accessed. +/// +CEF_EXPORT int cef_remove_cross_origin_whitelist_entry( + const cef_string_t* source_origin, const cef_string_t* target_protocol, + const cef_string_t* target_domain, int allow_target_subdomains); + +/// +// Remove all entries from the cross-origin access whitelist. Returns false (0) +// if the whitelist cannot be accessed. +/// +CEF_EXPORT int cef_clear_cross_origin_whitelist(); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_ORIGIN_WHITELIST_CAPI_H_ diff --git a/cef3/include/capi/cef_path_util_capi.h b/cef3/include/capi/cef_path_util_capi.h new file mode 100644 index 000000000..847a283ae --- /dev/null +++ b/cef3/include/capi/cef_path_util_capi.h @@ -0,0 +1,58 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_PATH_UTIL_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_PATH_UTIL_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Retrieve the path associated with the specified |key|. Returns true (1) on +// success. Can be called on any thread in the browser process. +/// +CEF_EXPORT int cef_get_path(enum cef_path_key_t key, cef_string_t* path); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_PATH_UTIL_CAPI_H_ diff --git a/cef3/include/capi/cef_process_message_capi.h b/cef3/include/capi/cef_process_message_capi.h new file mode 100644 index 000000000..cc00a3c77 --- /dev/null +++ b/cef3/include/capi/cef_process_message_capi.h @@ -0,0 +1,101 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_PROCESS_MESSAGE_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_PROCESS_MESSAGE_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Structure representing a message. Can be used on any process and thread. +/// +typedef struct _cef_process_message_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns true (1) if this object is valid. Do not call any other functions + // if this function returns false (0). + /// + int (CEF_CALLBACK *is_valid)(struct _cef_process_message_t* self); + + /// + // Returns true (1) if the values of this object are read-only. Some APIs may + // expose read-only objects. + /// + int (CEF_CALLBACK *is_read_only)(struct _cef_process_message_t* self); + + /// + // Returns a writable copy of this object. + /// + struct _cef_process_message_t* (CEF_CALLBACK *copy)( + struct _cef_process_message_t* self); + + /// + // Returns the message name. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_name)( + struct _cef_process_message_t* self); + + /// + // Returns the list of arguments. + /// + struct _cef_list_value_t* (CEF_CALLBACK *get_argument_list)( + struct _cef_process_message_t* self); +} cef_process_message_t; + + +/// +// Create a new cef_process_message_t object with the specified name. +/// +CEF_EXPORT cef_process_message_t* cef_process_message_create( + const cef_string_t* name); + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_PROCESS_MESSAGE_CAPI_H_ diff --git a/cef3/include/capi/cef_process_util_capi.h b/cef3/include/capi/cef_process_util_capi.h new file mode 100644 index 000000000..066a461e6 --- /dev/null +++ b/cef3/include/capi/cef_process_util_capi.h @@ -0,0 +1,64 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_PROCESS_UTIL_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_PROCESS_UTIL_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Launches the process specified via |command_line|. Returns true (1) upon +// success. Must be called on the browser process TID_PROCESS_LAUNCHER thread. +// +// Unix-specific notes: - All file descriptors open in the parent process will +// be closed in the +// child process except for stdin, stdout, and stderr. +// - If the first argument on the command line does not contain a slash, +// PATH will be searched. (See man execvp.) +/// +CEF_EXPORT int cef_launch_process(struct _cef_command_line_t* command_line); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_PROCESS_UTIL_CAPI_H_ diff --git a/cef3/include/capi/cef_render_handler_capi.h b/cef3/include/capi/cef_render_handler_capi.h new file mode 100644 index 000000000..da57b65ec --- /dev/null +++ b/cef3/include/capi/cef_render_handler_capi.h @@ -0,0 +1,118 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_RENDER_HANDLER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_RENDER_HANDLER_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Implement this structure to handle events when window rendering is disabled. +// The functions of this structure will be called on the UI thread. +/// +typedef struct _cef_render_handler_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Called to retrieve the root window rectangle in screen coordinates. Return + // true (1) if the rectangle was provided. + /// + int (CEF_CALLBACK *get_root_screen_rect)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, cef_rect_t* rect); + + /// + // Called to retrieve the view rectangle which is relative to screen + // coordinates. Return true (1) if the rectangle was provided. + /// + int (CEF_CALLBACK *get_view_rect)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, cef_rect_t* rect); + + /// + // Called to retrieve the translation from view coordinates to actual screen + // coordinates. Return true (1) if the screen coordinates were provided. + /// + int (CEF_CALLBACK *get_screen_point)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, int viewX, int viewY, int* screenX, + int* screenY); + + /// + // Called when the browser wants to show or hide the popup widget. The popup + // should be shown if |show| is true (1) and hidden if |show| is false (0). + /// + void (CEF_CALLBACK *on_popup_show)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, int show); + + /// + // Called when the browser wants to move or resize the popup widget. |rect| + // contains the new location and size. + /// + void (CEF_CALLBACK *on_popup_size)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, const cef_rect_t* rect); + + /// + // Called when an element should be painted. |type| indicates whether the + // element is the view or the popup widget. |buffer| contains the pixel data + // for the whole image. |dirtyRects| contains the set of rectangles that need + // to be repainted. On Windows |buffer| will be |width|*|height|*4 bytes in + // size and represents a BGRA image with an upper-left origin. + /// + void (CEF_CALLBACK *on_paint)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, enum cef_paint_element_type_t type, + size_t dirtyRectsCount, cef_rect_t const* dirtyRects, const void* buffer, + int width, int height); + + /// + // Called when the browser window's cursor has changed. + /// + void (CEF_CALLBACK *on_cursor_change)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, cef_cursor_handle_t cursor); +} cef_render_handler_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_RENDER_HANDLER_CAPI_H_ diff --git a/cef3/include/capi/cef_render_process_handler_capi.h b/cef3/include/capi/cef_render_process_handler_capi.h new file mode 100644 index 000000000..13949fe8a --- /dev/null +++ b/cef3/include/capi/cef_render_process_handler_capi.h @@ -0,0 +1,197 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_RENDER_PROCESS_HANDLER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_RENDER_PROCESS_HANDLER_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Structure used to implement render process callbacks. The functions of this +// structure will be called on the render process main thread (TID_RENDERER) +// unless otherwise indicated. +/// +typedef struct _cef_render_process_handler_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Called after the render process main thread has been created. |extra_info| + // is a read-only value originating from + // cef_browser_process_handler_t::on_render_process_thread_created(). Do not + // keep a reference to |extra_info| outside of this function. + /// + void (CEF_CALLBACK *on_render_thread_created)( + struct _cef_render_process_handler_t* self, + struct _cef_list_value_t* extra_info); + + /// + // Called after WebKit has been initialized. + /// + void (CEF_CALLBACK *on_web_kit_initialized)( + struct _cef_render_process_handler_t* self); + + /// + // Called after a browser has been created. When browsing cross-origin a new + // browser will be created before the old browser with the same identifier is + // destroyed. + /// + void (CEF_CALLBACK *on_browser_created)( + struct _cef_render_process_handler_t* self, + struct _cef_browser_t* browser); + + /// + // Called before a browser is destroyed. + /// + void (CEF_CALLBACK *on_browser_destroyed)( + struct _cef_render_process_handler_t* self, + struct _cef_browser_t* browser); + + /// + // Called before browser navigation. Return true (1) to cancel the navigation + // or false (0) to allow the navigation to proceed. The |request| object + // cannot be modified in this callback. + /// + int (CEF_CALLBACK *on_before_navigation)( + struct _cef_render_process_handler_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame, + struct _cef_request_t* request, + enum cef_navigation_type_t navigation_type, int is_redirect); + + /// + // Called immediately after the V8 context for a frame has been created. To + // retrieve the JavaScript 'window' object use the + // cef_v8context_t::get_global() function. V8 handles can only be accessed + // from the thread on which they are created. A task runner for posting tasks + // on the associated thread can be retrieved via the + // cef_v8context_t::get_task_runner() function. + /// + void (CEF_CALLBACK *on_context_created)( + struct _cef_render_process_handler_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame, + struct _cef_v8context_t* context); + + /// + // Called immediately before the V8 context for a frame is released. No + // references to the context should be kept after this function is called. + /// + void (CEF_CALLBACK *on_context_released)( + struct _cef_render_process_handler_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame, + struct _cef_v8context_t* context); + + /// + // Called for global uncaught exceptions in a frame. Execution of this + // callback is disabled by default. To enable set + // CefSettings.uncaught_exception_stack_size > 0. + /// + void (CEF_CALLBACK *on_uncaught_exception)( + struct _cef_render_process_handler_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame, + struct _cef_v8context_t* context, struct _cef_v8exception_t* exception, + struct _cef_v8stack_trace_t* stackTrace); + + /// + // Called on the WebWorker thread immediately after the V8 context for a new + // WebWorker has been created. To retrieve the JavaScript 'self' object use + // the cef_v8context_t::get_global() function. V8 handles can only be accessed + // from the thread on which they are created. A task runner for posting tasks + // on the associated thread can be retrieved via the + // cef_v8context_t::get_task_runner() function. + /// + void (CEF_CALLBACK *on_worker_context_created)( + struct _cef_render_process_handler_t* self, int worker_id, + const cef_string_t* url, struct _cef_v8context_t* context); + + /// + // Called on the WebWorker thread immediately before the V8 context for a + // WebWorker is released. No references to the context should be kept after + // this function is called. Any tasks posted or pending on the WebWorker + // thread after this function is called may not be executed. + /// + void (CEF_CALLBACK *on_worker_context_released)( + struct _cef_render_process_handler_t* self, int worker_id, + const cef_string_t* url, struct _cef_v8context_t* context); + + /// + // Called on the WebWorker thread for global uncaught exceptions in a + // WebWorker. Execution of this callback is disabled by default. To enable set + // CefSettings.uncaught_exception_stack_size > 0. + /// + void (CEF_CALLBACK *on_worker_uncaught_exception)( + struct _cef_render_process_handler_t* self, int worker_id, + const cef_string_t* url, struct _cef_v8context_t* context, + struct _cef_v8exception_t* exception, + struct _cef_v8stack_trace_t* stackTrace); + + /// + // Called when a new node in the the browser gets focus. The |node| value may + // be NULL if no specific node has gained focus. The node object passed to + // this function represents a snapshot of the DOM at the time this function is + // executed. DOM objects are only valid for the scope of this function. Do not + // keep references to or attempt to access any DOM objects outside the scope + // of this function. + /// + void (CEF_CALLBACK *on_focused_node_changed)( + struct _cef_render_process_handler_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame, + struct _cef_domnode_t* node); + + /// + // Called when a new message is received from a different process. Return true + // (1) if the message was handled or false (0) otherwise. Do not keep a + // reference to or attempt to access the message outside of this callback. + /// + int (CEF_CALLBACK *on_process_message_received)( + struct _cef_render_process_handler_t* self, + struct _cef_browser_t* browser, enum cef_process_id_t source_process, + struct _cef_process_message_t* message); +} cef_render_process_handler_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_RENDER_PROCESS_HANDLER_CAPI_H_ diff --git a/cef3/include/capi/cef_request_capi.h b/cef3/include/capi/cef_request_capi.h new file mode 100644 index 000000000..da895f362 --- /dev/null +++ b/cef3/include/capi/cef_request_capi.h @@ -0,0 +1,276 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_REQUEST_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Structure used to represent a web request. The functions of this structure +// may be called on any thread. +/// +typedef struct _cef_request_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns true (1) if this object is read-only. + /// + int (CEF_CALLBACK *is_read_only)(struct _cef_request_t* self); + + /// + // Get the fully qualified URL. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_url)(struct _cef_request_t* self); + + /// + // Set the fully qualified URL. + /// + void (CEF_CALLBACK *set_url)(struct _cef_request_t* self, + const cef_string_t* url); + + /// + // Get the request function type. The value will default to POST if post data + // is provided and GET otherwise. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_method)(struct _cef_request_t* self); + + /// + // Set the request function type. + /// + void (CEF_CALLBACK *set_method)(struct _cef_request_t* self, + const cef_string_t* method); + + /// + // Get the post data. + /// + struct _cef_post_data_t* (CEF_CALLBACK *get_post_data)( + struct _cef_request_t* self); + + /// + // Set the post data. + /// + void (CEF_CALLBACK *set_post_data)(struct _cef_request_t* self, + struct _cef_post_data_t* postData); + + /// + // Get the header values. + /// + void (CEF_CALLBACK *get_header_map)(struct _cef_request_t* self, + cef_string_multimap_t headerMap); + + /// + // Set the header values. + /// + void (CEF_CALLBACK *set_header_map)(struct _cef_request_t* self, + cef_string_multimap_t headerMap); + + /// + // Set all values at one time. + /// + void (CEF_CALLBACK *set)(struct _cef_request_t* self, const cef_string_t* url, + const cef_string_t* method, struct _cef_post_data_t* postData, + cef_string_multimap_t headerMap); + + /// + // Get the flags used in combination with cef_urlrequest_t. See + // cef_urlrequest_flags_t for supported values. + /// + int (CEF_CALLBACK *get_flags)(struct _cef_request_t* self); + + /// + // Set the flags used in combination with cef_urlrequest_t. See + // cef_urlrequest_flags_t for supported values. + /// + void (CEF_CALLBACK *set_flags)(struct _cef_request_t* self, int flags); + + /// + // Set the URL to the first party for cookies used in combination with + // cef_urlrequest_t. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_first_party_for_cookies)( + struct _cef_request_t* self); + + /// + // Get the URL to the first party for cookies used in combination with + // cef_urlrequest_t. + /// + void (CEF_CALLBACK *set_first_party_for_cookies)(struct _cef_request_t* self, + const cef_string_t* url); +} cef_request_t; + + +/// +// Create a new cef_request_t object. +/// +CEF_EXPORT cef_request_t* cef_request_create(); + + +/// +// Structure used to represent post data for a web request. The functions of +// this structure may be called on any thread. +/// +typedef struct _cef_post_data_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns true (1) if this object is read-only. + /// + int (CEF_CALLBACK *is_read_only)(struct _cef_post_data_t* self); + + /// + // Returns the number of existing post data elements. + /// + size_t (CEF_CALLBACK *get_element_count)(struct _cef_post_data_t* self); + + /// + // Retrieve the post data elements. + /// + void (CEF_CALLBACK *get_elements)(struct _cef_post_data_t* self, + size_t* elementsCount, struct _cef_post_data_element_t** elements); + + /// + // Remove the specified post data element. Returns true (1) if the removal + // succeeds. + /// + int (CEF_CALLBACK *remove_element)(struct _cef_post_data_t* self, + struct _cef_post_data_element_t* element); + + /// + // Add the specified post data element. Returns true (1) if the add succeeds. + /// + int (CEF_CALLBACK *add_element)(struct _cef_post_data_t* self, + struct _cef_post_data_element_t* element); + + /// + // Remove all existing post data elements. + /// + void (CEF_CALLBACK *remove_elements)(struct _cef_post_data_t* self); +} cef_post_data_t; + + +/// +// Create a new cef_post_data_t object. +/// +CEF_EXPORT cef_post_data_t* cef_post_data_create(); + + +/// +// Structure used to represent a single element in the request post data. The +// functions of this structure may be called on any thread. +/// +typedef struct _cef_post_data_element_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns true (1) if this object is read-only. + /// + int (CEF_CALLBACK *is_read_only)(struct _cef_post_data_element_t* self); + + /// + // Remove all contents from the post data element. + /// + void (CEF_CALLBACK *set_to_empty)(struct _cef_post_data_element_t* self); + + /// + // The post data element will represent a file. + /// + void (CEF_CALLBACK *set_to_file)(struct _cef_post_data_element_t* self, + const cef_string_t* fileName); + + /// + // The post data element will represent bytes. The bytes passed in will be + // copied. + /// + void (CEF_CALLBACK *set_to_bytes)(struct _cef_post_data_element_t* self, + size_t size, const void* bytes); + + /// + // Return the type of this post data element. + /// + enum cef_postdataelement_type_t (CEF_CALLBACK *get_type)( + struct _cef_post_data_element_t* self); + + /// + // Return the file name. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_file)( + struct _cef_post_data_element_t* self); + + /// + // Return the number of bytes. + /// + size_t (CEF_CALLBACK *get_bytes_count)(struct _cef_post_data_element_t* self); + + /// + // Read up to |size| bytes into |bytes| and return the number of bytes + // actually read. + /// + size_t (CEF_CALLBACK *get_bytes)(struct _cef_post_data_element_t* self, + size_t size, void* bytes); +} cef_post_data_element_t; + + +/// +// Create a new cef_post_data_element_t object. +/// +CEF_EXPORT cef_post_data_element_t* cef_post_data_element_create(); + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_REQUEST_CAPI_H_ diff --git a/cef3/include/capi/cef_request_handler_capi.h b/cef3/include/capi/cef_request_handler_capi.h new file mode 100644 index 000000000..a9b4199b5 --- /dev/null +++ b/cef3/include/capi/cef_request_handler_capi.h @@ -0,0 +1,223 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_HANDLER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_REQUEST_HANDLER_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Callback structure used for asynchronous continuation of authentication +// requests. +/// +typedef struct _cef_auth_callback_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Continue the authentication request. + /// + void (CEF_CALLBACK *cont)(struct _cef_auth_callback_t* self, + const cef_string_t* username, const cef_string_t* password); + + /// + // Cancel the authentication request. + /// + void (CEF_CALLBACK *cancel)(struct _cef_auth_callback_t* self); +} cef_auth_callback_t; + + +/// +// Callback structure used for asynchronous continuation of quota requests. +/// +typedef struct _cef_quota_callback_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Continue the quota request. If |allow| is true (1) the request will be + // allowed. Otherwise, the request will be denied. + /// + void (CEF_CALLBACK *cont)(struct _cef_quota_callback_t* self, int allow); + + /// + // Cancel the quota request. + /// + void (CEF_CALLBACK *cancel)(struct _cef_quota_callback_t* self); +} cef_quota_callback_t; + + +/// +// Callback structure used for asynchronous continuation of url requests when +// invalid SSL certificates are encountered. +/// +typedef struct _cef_allow_certificate_error_callback_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Continue the url request. If |allow| is true (1) the request will be + // continued. Otherwise, the request will be canceled. + /// + void (CEF_CALLBACK *cont)( + struct _cef_allow_certificate_error_callback_t* self, int allow); +} cef_allow_certificate_error_callback_t; + + +/// +// Implement this structure to handle events related to browser requests. The +// functions of this structure will be called on the thread indicated. +/// +typedef struct _cef_request_handler_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Called on the IO thread before a resource request is loaded. The |request| + // object may be modified. To cancel the request return true (1) otherwise + // return false (0). + /// + int (CEF_CALLBACK *on_before_resource_load)( + struct _cef_request_handler_t* self, struct _cef_browser_t* browser, + struct _cef_frame_t* frame, struct _cef_request_t* request); + + /// + // Called on the IO thread before a resource is loaded. To allow the resource + // to load normally return NULL. To specify a handler for the resource return + // a cef_resource_handler_t object. The |request| object should not be + // modified in this callback. + /// + struct _cef_resource_handler_t* (CEF_CALLBACK *get_resource_handler)( + struct _cef_request_handler_t* self, struct _cef_browser_t* browser, + struct _cef_frame_t* frame, struct _cef_request_t* request); + + /// + // Called on the IO thread when a resource load is redirected. The |old_url| + // parameter will contain the old URL. The |new_url| parameter will contain + // the new URL and can be changed if desired. + /// + void (CEF_CALLBACK *on_resource_redirect)(struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame, + const cef_string_t* old_url, cef_string_t* new_url); + + /// + // Called on the IO thread when the browser needs credentials from the user. + // |isProxy| indicates whether the host is a proxy server. |host| contains the + // hostname and |port| contains the port number. Return true (1) to continue + // the request and call cef_auth_callback_t::cont() when the authentication + // information is available. Return false (0) to cancel the request. + /// + int (CEF_CALLBACK *get_auth_credentials)(struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame, int isProxy, + const cef_string_t* host, int port, const cef_string_t* realm, + const cef_string_t* scheme, struct _cef_auth_callback_t* callback); + + /// + // Called on the IO thread when JavaScript requests a specific storage quota + // size via the webkitStorageInfo.requestQuota function. |origin_url| is the + // origin of the page making the request. |new_size| is the requested quota + // size in bytes. Return true (1) and call cef_quota_callback_t::cont() either + // in this function or at a later time to grant or deny the request. Return + // false (0) to cancel the request. + /// + int (CEF_CALLBACK *on_quota_request)(struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, const cef_string_t* origin_url, + int64 new_size, struct _cef_quota_callback_t* callback); + + /// + // Called on the IO thread to retrieve the cookie manager. |main_url| is the + // URL of the top-level frame. Cookies managers can be unique per browser or + // shared across multiple browsers. The global cookie manager will be used if + // this function returns NULL. + /// + struct _cef_cookie_manager_t* (CEF_CALLBACK *get_cookie_manager)( + struct _cef_request_handler_t* self, struct _cef_browser_t* browser, + const cef_string_t* main_url); + + /// + // Called on the UI thread to handle requests for URLs with an unknown + // protocol component. Set |allow_os_execution| to true (1) to attempt + // execution via the registered OS protocol handler, if any. SECURITY WARNING: + // YOU SHOULD USE THIS METHOD TO ENFORCE RESTRICTIONS BASED ON SCHEME, HOST OR + // OTHER URL ANALYSIS BEFORE ALLOWING OS EXECUTION. + /// + void (CEF_CALLBACK *on_protocol_execution)( + struct _cef_request_handler_t* self, struct _cef_browser_t* browser, + const cef_string_t* url, int* allow_os_execution); + + /// + // Called on the browser process IO thread before a plugin is loaded. Return + // true (1) to block loading of the plugin. + /// + int (CEF_CALLBACK *on_before_plugin_load)(struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, const cef_string_t* url, + const cef_string_t* policy_url, struct _cef_web_plugin_info_t* info); + + /// + // Called on the UI thread to handle requests for URLs with an invalid SSL + // certificate. Return true (1) and call + // cef_allow_certificate_error_callback_t:: cont() either in this function or + // at a later time to continue or cancel the request. Return false (0) to + // cancel the request immediately. If |callback| is NULL the error cannot be + // recovered from and the request will be canceled automatically. If + // CefSettings.ignore_certificate_errors is set all invalid certificates will + // be accepted without calling this function. + /// + int (CEF_CALLBACK *on_certificate_error)(struct _cef_request_handler_t* self, + enum cef_errorcode_t cert_error, const cef_string_t* request_url, + struct _cef_allow_certificate_error_callback_t* callback); +} cef_request_handler_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_REQUEST_HANDLER_CAPI_H_ diff --git a/cef3/include/capi/cef_resource_bundle_handler_capi.h b/cef3/include/capi/cef_resource_bundle_handler_capi.h new file mode 100644 index 000000000..62a90c04e --- /dev/null +++ b/cef3/include/capi/cef_resource_bundle_handler_capi.h @@ -0,0 +1,86 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_RESOURCE_BUNDLE_HANDLER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_RESOURCE_BUNDLE_HANDLER_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Structure used to implement a custom resource bundle structure. The functions +// of this structure may be called on multiple threads. +/// +typedef struct _cef_resource_bundle_handler_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Called to retrieve a localized translation for the string specified by + // |message_id|. To provide the translation set |string| to the translation + // string and return true (1). To use the default translation return false + // (0). Supported message IDs are listed in cef_pack_strings.h. + /// + int (CEF_CALLBACK *get_localized_string)( + struct _cef_resource_bundle_handler_t* self, int message_id, + cef_string_t* string); + + /// + // Called to retrieve data for the resource specified by |resource_id|. To + // provide the resource data set |data| and |data_size| to the data pointer + // and size respectively and return true (1). To use the default resource data + // return false (0). The resource data will not be copied and must remain + // resident in memory. Supported resource IDs are listed in + // cef_pack_resources.h. + /// + int (CEF_CALLBACK *get_data_resource)( + struct _cef_resource_bundle_handler_t* self, int resource_id, void** data, + size_t* data_size); +} cef_resource_bundle_handler_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_RESOURCE_BUNDLE_HANDLER_CAPI_H_ diff --git a/cef3/include/capi/cef_resource_handler_capi.h b/cef3/include/capi/cef_resource_handler_capi.h new file mode 100644 index 000000000..5f2d8384b --- /dev/null +++ b/cef3/include/capi/cef_resource_handler_capi.h @@ -0,0 +1,119 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_RESOURCE_HANDLER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_RESOURCE_HANDLER_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Structure used to implement a custom request handler structure. The functions +// of this structure will always be called on the IO thread. +/// +typedef struct _cef_resource_handler_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Begin processing the request. To handle the request return true (1) and + // call cef_callback_t::cont() once the response header information is + // available (cef_callback_t::cont() can also be called from inside this + // function if header information is available immediately). To cancel the + // request return false (0). + /// + int (CEF_CALLBACK *process_request)(struct _cef_resource_handler_t* self, + struct _cef_request_t* request, struct _cef_callback_t* callback); + + /// + // Retrieve response header information. If the response length is not known + // set |response_length| to -1 and read_response() will be called until it + // returns false (0). If the response length is known set |response_length| to + // a positive value and read_response() will be called until it returns false + // (0) or the specified number of bytes have been read. Use the |response| + // object to set the mime type, http status code and other optional header + // values. To redirect the request to a new URL set |redirectUrl| to the new + // URL. + /// + void (CEF_CALLBACK *get_response_headers)( + struct _cef_resource_handler_t* self, struct _cef_response_t* response, + int64* response_length, cef_string_t* redirectUrl); + + /// + // Read response data. If data is available immediately copy up to + // |bytes_to_read| bytes into |data_out|, set |bytes_read| to the number of + // bytes copied, and return true (1). To read the data at a later time set + // |bytes_read| to 0, return true (1) and call cef_callback_t::cont() when the + // data is available. To indicate response completion return false (0). + /// + int (CEF_CALLBACK *read_response)(struct _cef_resource_handler_t* self, + void* data_out, int bytes_to_read, int* bytes_read, + struct _cef_callback_t* callback); + + /// + // Return true (1) if the specified cookie can be sent with the request or + // false (0) otherwise. If false (0) is returned for any cookie then no + // cookies will be sent with the request. + /// + int (CEF_CALLBACK *can_get_cookie)(struct _cef_resource_handler_t* self, + const struct _cef_cookie_t* cookie); + + /// + // Return true (1) if the specified cookie returned with the response can be + // set or false (0) otherwise. + /// + int (CEF_CALLBACK *can_set_cookie)(struct _cef_resource_handler_t* self, + const struct _cef_cookie_t* cookie); + + /// + // Request processing has been canceled. + /// + void (CEF_CALLBACK *cancel)(struct _cef_resource_handler_t* self); +} cef_resource_handler_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_RESOURCE_HANDLER_CAPI_H_ diff --git a/cef3/include/capi/cef_response_capi.h b/cef3/include/capi/cef_response_capi.h new file mode 100644 index 000000000..f583b1343 --- /dev/null +++ b/cef3/include/capi/cef_response_capi.h @@ -0,0 +1,130 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_RESPONSE_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_RESPONSE_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Structure used to represent a web response. The functions of this structure +// may be called on any thread. +/// +typedef struct _cef_response_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns true (1) if this object is read-only. + /// + int (CEF_CALLBACK *is_read_only)(struct _cef_response_t* self); + + /// + // Get the response status code. + /// + int (CEF_CALLBACK *get_status)(struct _cef_response_t* self); + + /// + // Set the response status code. + /// + void (CEF_CALLBACK *set_status)(struct _cef_response_t* self, int status); + + /// + // Get the response status text. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_status_text)( + struct _cef_response_t* self); + + /// + // Set the response status text. + /// + void (CEF_CALLBACK *set_status_text)(struct _cef_response_t* self, + const cef_string_t* statusText); + + /// + // Get the response mime type. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_mime_type)( + struct _cef_response_t* self); + + /// + // Set the response mime type. + /// + void (CEF_CALLBACK *set_mime_type)(struct _cef_response_t* self, + const cef_string_t* mimeType); + + /// + // Get the value for the specified response header field. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_header)(struct _cef_response_t* self, + const cef_string_t* name); + + /// + // Get all response header fields. + /// + void (CEF_CALLBACK *get_header_map)(struct _cef_response_t* self, + cef_string_multimap_t headerMap); + + /// + // Set all response header fields. + /// + void (CEF_CALLBACK *set_header_map)(struct _cef_response_t* self, + cef_string_multimap_t headerMap); +} cef_response_t; + + +/// +// Create a new cef_response_t object. +/// +CEF_EXPORT cef_response_t* cef_response_create(); + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_RESPONSE_CAPI_H_ diff --git a/cef3/include/capi/cef_scheme_capi.h b/cef3/include/capi/cef_scheme_capi.h new file mode 100644 index 000000000..f124d745c --- /dev/null +++ b/cef3/include/capi/cef_scheme_capi.h @@ -0,0 +1,161 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_SCHEME_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_SCHEME_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Register a scheme handler factory for the specified |scheme_name| and +// optional |domain_name|. An NULL |domain_name| value for a standard scheme +// will cause the factory to match all domain names. The |domain_name| value +// will be ignored for non-standard schemes. If |scheme_name| is a built-in +// scheme and no handler is returned by |factory| then the built-in scheme +// handler factory will be called. If |scheme_name| is a custom scheme the +// CefRegisterCustomScheme() function should be called for that scheme. This +// function may be called multiple times to change or remove the factory that +// matches the specified |scheme_name| and optional |domain_name|. Returns false +// (0) if an error occurs. This function may be called on any thread. +/// +CEF_EXPORT int cef_register_scheme_handler_factory( + const cef_string_t* scheme_name, const cef_string_t* domain_name, + struct _cef_scheme_handler_factory_t* factory); + +/// +// Clear all registered scheme handler factories. Returns false (0) on error. +// This function may be called on any thread. +/// +CEF_EXPORT int cef_clear_scheme_handler_factories(); + +/// +// Structure that manages custom scheme registrations. +/// +typedef struct _cef_scheme_registrar_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Register a custom scheme. This function should not be called for the built- + // in HTTP, HTTPS, FILE, FTP, ABOUT and DATA schemes. + // + // If |is_standard| is true (1) the scheme will be treated as a standard + // scheme. Standard schemes are subject to URL canonicalization and parsing + // rules as defined in the Common Internet Scheme Syntax RFC 1738 Section 3.1 + // available at http://www.ietf.org/rfc/rfc1738.txt + // + // In particular, the syntax for standard scheme URLs must be of the form: + //
+  //  [scheme]://[username]:[password]@[host]:[port]/[url-path]
+  // 
Standard scheme URLs must have a host component that is a fully + // qualified domain name as defined in Section 3.5 of RFC 1034 [13] and + // Section 2.1 of RFC 1123. These URLs will be canonicalized to + // "scheme://host/path" in the simplest case and + // "scheme://username:password@host:port/path" in the most explicit case. For + // example, "scheme:host/path" and "scheme:///host/path" will both be + // canonicalized to "scheme://host/path". The origin of a standard scheme URL + // is the combination of scheme, host and port (i.e., "scheme://host:port" in + // the most explicit case). + // + // For non-standard scheme URLs only the "scheme:" component is parsed and + // canonicalized. The remainder of the URL will be passed to the handler as- + // is. For example, "scheme:///some%20text" will remain the same. Non-standard + // scheme URLs cannot be used as a target for form submission. + // + // If |is_local| is true (1) the scheme will be treated as local (i.e., with + // the same security rules as those applied to "file" URLs). Normal pages + // cannot link to or access local URLs. Also, by default, local URLs can only + // perform XMLHttpRequest calls to the same URL (origin + path) that + // originated the request. To allow XMLHttpRequest calls from a local URL to + // other URLs with the same origin set the + // CefSettings.file_access_from_file_urls_allowed value to true (1). To allow + // XMLHttpRequest calls from a local URL to all origins set the + // CefSettings.universal_access_from_file_urls_allowed value to true (1). + // + // If |is_display_isolated| is true (1) the scheme will be treated as display- + // isolated. This means that pages cannot display these URLs unless they are + // from the same scheme. For example, pages in another origin cannot create + // iframes or hyperlinks to URLs with this scheme. + // + // This function may be called on any thread. It should only be called once + // per unique |scheme_name| value. If |scheme_name| is already registered or + // if an error occurs this function will return false (0). + /// + int (CEF_CALLBACK *add_custom_scheme)(struct _cef_scheme_registrar_t* self, + const cef_string_t* scheme_name, int is_standard, int is_local, + int is_display_isolated); +} cef_scheme_registrar_t; + + +/// +// Structure that creates cef_resource_handler_t instances for handling scheme +// requests. The functions of this structure will always be called on the IO +// thread. +/// +typedef struct _cef_scheme_handler_factory_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Return a new resource handler instance to handle the request or an NULL + // reference to allow default handling of the request. |browser| and |frame| + // will be the browser window and frame respectively that originated the + // request or NULL if the request did not originate from a browser window (for + // example, if the request came from cef_urlrequest_t). The |request| object + // passed to this function will not contain cookie data. + /// + struct _cef_resource_handler_t* (CEF_CALLBACK *create)( + struct _cef_scheme_handler_factory_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame, + const cef_string_t* scheme_name, struct _cef_request_t* request); +} cef_scheme_handler_factory_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_SCHEME_CAPI_H_ diff --git a/cef3/include/capi/cef_stream_capi.h b/cef3/include/capi/cef_stream_capi.h new file mode 100644 index 000000000..e4b32b597 --- /dev/null +++ b/cef3/include/capi/cef_stream_capi.h @@ -0,0 +1,224 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_STREAM_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_STREAM_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Structure the client can implement to provide a custom stream reader. The +// functions of this structure may be called on any thread. +/// +typedef struct _cef_read_handler_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Read raw binary data. + /// + size_t (CEF_CALLBACK *read)(struct _cef_read_handler_t* self, void* ptr, + size_t size, size_t n); + + /// + // Seek to the specified offset position. |whence| may be any one of SEEK_CUR, + // SEEK_END or SEEK_SET. Return zero on success and non-zero on failure. + /// + int (CEF_CALLBACK *seek)(struct _cef_read_handler_t* self, int64 offset, + int whence); + + /// + // Return the current offset position. + /// + int64 (CEF_CALLBACK *tell)(struct _cef_read_handler_t* self); + + /// + // Return non-zero if at end of file. + /// + int (CEF_CALLBACK *eof)(struct _cef_read_handler_t* self); +} cef_read_handler_t; + + +/// +// Structure used to read data from a stream. The functions of this structure +// may be called on any thread. +/// +typedef struct _cef_stream_reader_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Read raw binary data. + /// + size_t (CEF_CALLBACK *read)(struct _cef_stream_reader_t* self, void* ptr, + size_t size, size_t n); + + /// + // Seek to the specified offset position. |whence| may be any one of SEEK_CUR, + // SEEK_END or SEEK_SET. Returns zero on success and non-zero on failure. + /// + int (CEF_CALLBACK *seek)(struct _cef_stream_reader_t* self, int64 offset, + int whence); + + /// + // Return the current offset position. + /// + int64 (CEF_CALLBACK *tell)(struct _cef_stream_reader_t* self); + + /// + // Return non-zero if at end of file. + /// + int (CEF_CALLBACK *eof)(struct _cef_stream_reader_t* self); +} cef_stream_reader_t; + + +/// +// Create a new cef_stream_reader_t object from a file. +/// +CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_file( + const cef_string_t* fileName); + +/// +// Create a new cef_stream_reader_t object from data. +/// +CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_data(void* data, + size_t size); + +/// +// Create a new cef_stream_reader_t object from a custom handler. +/// +CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_handler( + cef_read_handler_t* handler); + + +/// +// Structure the client can implement to provide a custom stream writer. The +// functions of this structure may be called on any thread. +/// +typedef struct _cef_write_handler_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Write raw binary data. + /// + size_t (CEF_CALLBACK *write)(struct _cef_write_handler_t* self, + const void* ptr, size_t size, size_t n); + + /// + // Seek to the specified offset position. |whence| may be any one of SEEK_CUR, + // SEEK_END or SEEK_SET. Return zero on success and non-zero on failure. + /// + int (CEF_CALLBACK *seek)(struct _cef_write_handler_t* self, int64 offset, + int whence); + + /// + // Return the current offset position. + /// + int64 (CEF_CALLBACK *tell)(struct _cef_write_handler_t* self); + + /// + // Flush the stream. + /// + int (CEF_CALLBACK *flush)(struct _cef_write_handler_t* self); +} cef_write_handler_t; + + +/// +// Structure used to write data to a stream. The functions of this structure may +// be called on any thread. +/// +typedef struct _cef_stream_writer_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Write raw binary data. + /// + size_t (CEF_CALLBACK *write)(struct _cef_stream_writer_t* self, + const void* ptr, size_t size, size_t n); + + /// + // Seek to the specified offset position. |whence| may be any one of SEEK_CUR, + // SEEK_END or SEEK_SET. Returns zero on success and non-zero on failure. + /// + int (CEF_CALLBACK *seek)(struct _cef_stream_writer_t* self, int64 offset, + int whence); + + /// + // Return the current offset position. + /// + int64 (CEF_CALLBACK *tell)(struct _cef_stream_writer_t* self); + + /// + // Flush the stream. + /// + int (CEF_CALLBACK *flush)(struct _cef_stream_writer_t* self); +} cef_stream_writer_t; + + +/// +// Create a new cef_stream_writer_t object for a file. +/// +CEF_EXPORT cef_stream_writer_t* cef_stream_writer_create_for_file( + const cef_string_t* fileName); + +/// +// Create a new cef_stream_writer_t object for a custom handler. +/// +CEF_EXPORT cef_stream_writer_t* cef_stream_writer_create_for_handler( + cef_write_handler_t* handler); + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_STREAM_CAPI_H_ diff --git a/cef3/include/capi/cef_string_visitor_capi.h b/cef3/include/capi/cef_string_visitor_capi.h new file mode 100644 index 000000000..13407ccd8 --- /dev/null +++ b/cef3/include/capi/cef_string_visitor_capi.h @@ -0,0 +1,69 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_STRING_VISITOR_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_STRING_VISITOR_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Implement this structure to receive string values asynchronously. +/// +typedef struct _cef_string_visitor_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Method that will be executed. + /// + void (CEF_CALLBACK *visit)(struct _cef_string_visitor_t* self, + const cef_string_t* string); +} cef_string_visitor_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_STRING_VISITOR_CAPI_H_ diff --git a/cef3/include/capi/cef_task_capi.h b/cef3/include/capi/cef_task_capi.h new file mode 100644 index 000000000..e4deec516 --- /dev/null +++ b/cef3/include/capi/cef_task_capi.h @@ -0,0 +1,160 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_TASK_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_TASK_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Returns true (1) if called on the specified thread. Equivalent to using +// cef_task_runner_t::GetForThread(threadId)->belongs_to_current_thread(). +/// +CEF_EXPORT int cef_currently_on(cef_thread_id_t threadId); + +/// +// Post a task for execution on the specified thread. Equivalent to using +// cef_task_runner_t::GetForThread(threadId)->PostTask(task). +/// +CEF_EXPORT int cef_post_task(cef_thread_id_t threadId, + struct _cef_task_t* task); + +/// +// Post a task for delayed execution on the specified thread. Equivalent to +// using cef_task_runner_t::GetForThread(threadId)->PostDelayedTask(task, +// delay_ms). +/// +CEF_EXPORT int cef_post_delayed_task(cef_thread_id_t threadId, + struct _cef_task_t* task, int64 delay_ms); + +/// +// Implement this structure for asynchronous task execution. If the task is +// posted successfully and if the associated message loop is still running then +// the execute() function will be called on the target thread. If the task fails +// to post then the task object may be destroyed on the source thread instead of +// the target thread. For this reason be cautious when performing work in the +// task object destructor. +/// +typedef struct _cef_task_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Method that will be executed on the target thread. + /// + void (CEF_CALLBACK *execute)(struct _cef_task_t* self); +} cef_task_t; + + +/// +// Structure that asynchronously executes tasks on the associated thread. It is +// safe to call the functions of this structure on any thread. +// +// CEF maintains multiple internal threads that are used for handling different +// types of tasks in different processes. The cef_thread_id_t definitions in +// cef_types.h list the common CEF threads. Task runners are also available for +// other CEF threads as appropriate (for example, V8 WebWorker threads). +/// +typedef struct _cef_task_runner_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns true (1) if this object is pointing to the same task runner as + // |that| object. + /// + int (CEF_CALLBACK *is_same)(struct _cef_task_runner_t* self, + struct _cef_task_runner_t* that); + + /// + // Returns true (1) if this task runner belongs to the current thread. + /// + int (CEF_CALLBACK *belongs_to_current_thread)( + struct _cef_task_runner_t* self); + + /// + // Returns true (1) if this task runner is for the specified CEF thread. + /// + int (CEF_CALLBACK *belongs_to_thread)(struct _cef_task_runner_t* self, + cef_thread_id_t threadId); + + /// + // Post a task for execution on the thread associated with this task runner. + // Execution will occur asynchronously. + /// + int (CEF_CALLBACK *post_task)(struct _cef_task_runner_t* self, + struct _cef_task_t* task); + + /// + // Post a task for delayed execution on the thread associated with this task + // runner. Execution will occur asynchronously. Delayed tasks are not + // supported on V8 WebWorker threads and will be executed without the + // specified delay. + /// + int (CEF_CALLBACK *post_delayed_task)(struct _cef_task_runner_t* self, + struct _cef_task_t* task, int64 delay_ms); +} cef_task_runner_t; + + +/// +// Returns the task runner for the current thread. Only CEF threads will have +// task runners. An NULL reference will be returned if this function is called +// on an invalid thread. +/// +CEF_EXPORT cef_task_runner_t* cef_task_runner_get_for_current_thread(); + +/// +// Returns the task runner for the specified CEF thread. +/// +CEF_EXPORT cef_task_runner_t* cef_task_runner_get_for_thread( + cef_thread_id_t threadId); + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_TASK_CAPI_H_ diff --git a/cef3/include/capi/cef_trace_capi.h b/cef3/include/capi/cef_trace_capi.h new file mode 100644 index 000000000..01f8970dc --- /dev/null +++ b/cef3/include/capi/cef_trace_capi.h @@ -0,0 +1,136 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_TRACE_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_TRACE_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Start tracing events on all processes. Tracing begins immediately locally, +// and asynchronously on child processes as soon as they receive the +// BeginTracing request. +// +// If CefBeginTracing was called previously, or if a CefEndTracingAsync call is +// pending, CefBeginTracing will fail and return false (0). +// +// |categories| is a comma-delimited list of category wildcards. A category can +// have an optional '-' prefix to make it an excluded category. Having both +// included and excluded categories in the same list is not supported. +// +// Example: "test_MyTest*" Example: "test_MyTest*,test_OtherStuff" Example: +// "-excluded_category1,-excluded_category2" +// +// This function must be called on the browser process UI thread. +/// +CEF_EXPORT int cef_begin_tracing(struct _cef_trace_client_t* client, + const cef_string_t* categories); + +/// +// Get the maximum trace buffer percent full state across all processes. +// +// cef_trace_client_t::OnTraceBufferPercentFullReply will be called +// asynchronously after the value is determined. When any child process reaches +// 100% full tracing will end automatically and +// cef_trace_client_t::OnEndTracingComplete will be called. This function fails +// and returns false (0) if trace is ending or disabled, no cef_trace_client_t +// was passed to CefBeginTracing, or if a previous call to +// CefGetTraceBufferPercentFullAsync is pending. +// +// This function must be called on the browser process UI thread. +/// +CEF_EXPORT int cef_get_trace_buffer_percent_full_async(); + +/// +// Stop tracing events on all processes. +// +// This function will fail and return false (0) if a previous call to +// CefEndTracingAsync is already pending or if CefBeginTracing was not called. +// +// This function must be called on the browser process UI thread. +/// +CEF_EXPORT int cef_end_tracing_async(); + +/// +// Returns the current system trace time or, if none is defined, the current +// high-res time. Can be used by clients to synchronize with the time +// information in trace events. +/// +CEF_EXPORT int64 cef_now_from_system_trace_time(); + +/// +// Implement this structure to receive trace notifications. The functions of +// this structure will be called on the browser process UI thread. +/// +typedef struct _cef_trace_client_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Called 0 or more times between CefBeginTracing and OnEndTracingComplete + // with a UTF8 JSON |fragment| of the specified |fragment_size|. Do not keep a + // reference to |fragment|. + /// + void (CEF_CALLBACK *on_trace_data_collected)(struct _cef_trace_client_t* self, + const char* fragment, size_t fragment_size); + + /// + // Called in response to CefGetTraceBufferPercentFullAsync. + /// + void (CEF_CALLBACK *on_trace_buffer_percent_full_reply)( + struct _cef_trace_client_t* self, float percent_full); + + /// + // Called after all processes have sent their trace data. + /// + void (CEF_CALLBACK *on_end_tracing_complete)( + struct _cef_trace_client_t* self); +} cef_trace_client_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_TRACE_CAPI_H_ diff --git a/cef3/include/capi/cef_url_capi.h b/cef3/include/capi/cef_url_capi.h new file mode 100644 index 000000000..b0fdcd22b --- /dev/null +++ b/cef3/include/capi/cef_url_capi.h @@ -0,0 +1,67 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_URL_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_URL_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Parse the specified |url| into its component parts. Returns false (0) if the +// URL is NULL or invalid. +/// +CEF_EXPORT int cef_parse_url(const cef_string_t* url, + struct _cef_urlparts_t* parts); + +/// +// Creates a URL from the specified |parts|, which must contain a non-NULL spec +// or a non-NULL host and path (at a minimum), but not both. Returns false (0) +// if |parts| isn't initialized as described. +/// +CEF_EXPORT int cef_create_url(const struct _cef_urlparts_t* parts, + cef_string_t* url); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_URL_CAPI_H_ diff --git a/cef3/include/capi/cef_urlrequest_capi.h b/cef3/include/capi/cef_urlrequest_capi.h new file mode 100644 index 000000000..23100feeb --- /dev/null +++ b/cef3/include/capi/cef_urlrequest_capi.h @@ -0,0 +1,164 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_URLREQUEST_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_URLREQUEST_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Structure used to make a URL request. URL requests are not associated with a +// browser instance so no cef_client_t callbacks will be executed. URL requests +// can be created on any valid CEF thread in either the browser or render +// process. Once created the functions of the URL request object must be +// accessed on the same thread that created it. +/// +typedef struct _cef_urlrequest_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns the request object used to create this URL request. The returned + // object is read-only and should not be modified. + /// + struct _cef_request_t* (CEF_CALLBACK *get_request)( + struct _cef_urlrequest_t* self); + + /// + // Returns the client. + /// + struct _cef_urlrequest_client_t* (CEF_CALLBACK *get_client)( + struct _cef_urlrequest_t* self); + + /// + // Returns the request status. + /// + enum cef_urlrequest_status_t (CEF_CALLBACK *get_request_status)( + struct _cef_urlrequest_t* self); + + /// + // Returns the request error if status is UR_CANCELED or UR_FAILED, or 0 + // otherwise. + /// + enum cef_errorcode_t (CEF_CALLBACK *get_request_error)( + struct _cef_urlrequest_t* self); + + /// + // Returns the response, or NULL if no response information is available. + // Response information will only be available after the upload has completed. + // The returned object is read-only and should not be modified. + /// + struct _cef_response_t* (CEF_CALLBACK *get_response)( + struct _cef_urlrequest_t* self); + + /// + // Cancel the request. + /// + void (CEF_CALLBACK *cancel)(struct _cef_urlrequest_t* self); +} cef_urlrequest_t; + + +/// +// Create a new URL request. Only GET, POST, HEAD, DELETE and PUT request +// functions are supported. The |request| object will be marked as read-only +// after calling this function. +/// +CEF_EXPORT cef_urlrequest_t* cef_urlrequest_create( + struct _cef_request_t* request, struct _cef_urlrequest_client_t* client); + + +/// +// Structure that should be implemented by the cef_urlrequest_t client. The +// functions of this structure will be called on the same thread that created +// the request. +/// +typedef struct _cef_urlrequest_client_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Notifies the client that the request has completed. Use the + // cef_urlrequest_t::GetRequestStatus function to determine if the request was + // successful or not. + /// + void (CEF_CALLBACK *on_request_complete)( + struct _cef_urlrequest_client_t* self, + struct _cef_urlrequest_t* request); + + /// + // Notifies the client of upload progress. |current| denotes the number of + // bytes sent so far and |total| is the total size of uploading data (or -1 if + // chunked upload is enabled). This function will only be called if the + // UR_FLAG_REPORT_UPLOAD_PROGRESS flag is set on the request. + /// + void (CEF_CALLBACK *on_upload_progress)(struct _cef_urlrequest_client_t* self, + struct _cef_urlrequest_t* request, uint64 current, uint64 total); + + /// + // Notifies the client of download progress. |current| denotes the number of + // bytes received up to the call and |total| is the expected total size of the + // response (or -1 if not determined). + /// + void (CEF_CALLBACK *on_download_progress)( + struct _cef_urlrequest_client_t* self, struct _cef_urlrequest_t* request, + uint64 current, uint64 total); + + /// + // Called when some part of the response is read. |data| contains the current + // bytes received since the last call. This function will not be called if the + // UR_FLAG_NO_DOWNLOAD_DATA flag is set on the request. + /// + void (CEF_CALLBACK *on_download_data)(struct _cef_urlrequest_client_t* self, + struct _cef_urlrequest_t* request, const void* data, + size_t data_length); +} cef_urlrequest_client_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_URLREQUEST_CAPI_H_ diff --git a/cef3/include/capi/cef_v8_capi.h b/cef3/include/capi/cef_v8_capi.h new file mode 100644 index 000000000..7ec761d6f --- /dev/null +++ b/cef3/include/capi/cef_v8_capi.h @@ -0,0 +1,844 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_V8_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_V8_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Register a new V8 extension with the specified JavaScript extension code and +// handler. Functions implemented by the handler are prototyped using the +// keyword 'native'. The calling of a native function is restricted to the scope +// in which the prototype of the native function is defined. This function may +// only be called on the render process main thread. +// +// Example JavaScript extension code:
+//   // create the 'example' global object if it doesn't already exist.
+//   if (!example)
+//     example = {};
+//   // create the 'example.test' global object if it doesn't already exist.
+//   if (!example.test)
+//     example.test = {};
+//   (function() {
+//     // Define the function 'example.test.myfunction'.
+//     example.test.myfunction = function() {
+//       // Call CefV8Handler::Execute() with the function name 'MyFunction'
+//       // and no arguments.
+//       native function MyFunction();
+//       return MyFunction();
+//     };
+//     // Define the getter function for parameter 'example.test.myparam'.
+//     example.test.__defineGetter__('myparam', function() {
+//       // Call CefV8Handler::Execute() with the function name 'GetMyParam'
+//       // and no arguments.
+//       native function GetMyParam();
+//       return GetMyParam();
+//     });
+//     // Define the setter function for parameter 'example.test.myparam'.
+//     example.test.__defineSetter__('myparam', function(b) {
+//       // Call CefV8Handler::Execute() with the function name 'SetMyParam'
+//       // and a single argument.
+//       native function SetMyParam();
+//       if(b) SetMyParam(b);
+//     });
+//
+//     // Extension definitions can also contain normal JavaScript variables
+//     // and functions.
+//     var myint = 0;
+//     example.test.increment = function() {
+//       myint += 1;
+//       return myint;
+//     };
+//   })();
+// 
Example usage in the page:
+//   // Call the function.
+//   example.test.myfunction();
+//   // Set the parameter.
+//   example.test.myparam = value;
+//   // Get the parameter.
+//   value = example.test.myparam;
+//   // Call another function.
+//   example.test.increment();
+// 
+/// +CEF_EXPORT int cef_register_extension(const cef_string_t* extension_name, + const cef_string_t* javascript_code, struct _cef_v8handler_t* handler); + +/// +// Structure representing a V8 context handle. V8 handles can only be accessed +// from the thread on which they are created. Valid threads for creating a V8 +// handle include the render process main thread (TID_RENDERER) and WebWorker +// threads. A task runner for posting tasks on the associated thread can be +// retrieved via the cef_v8context_t::get_task_runner() function. +/// +typedef struct _cef_v8context_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns the task runner associated with this context. V8 handles can only + // be accessed from the thread on which they are created. This function can be + // called on any render process thread. + /// + struct _cef_task_runner_t* (CEF_CALLBACK *get_task_runner)( + struct _cef_v8context_t* self); + + /// + // Returns true (1) if the underlying handle is valid and it can be accessed + // on the current thread. Do not call any other functions if this function + // returns false (0). + /// + int (CEF_CALLBACK *is_valid)(struct _cef_v8context_t* self); + + /// + // Returns the browser for this context. This function will return an NULL + // reference for WebWorker contexts. + /// + struct _cef_browser_t* (CEF_CALLBACK *get_browser)( + struct _cef_v8context_t* self); + + /// + // Returns the frame for this context. This function will return an NULL + // reference for WebWorker contexts. + /// + struct _cef_frame_t* (CEF_CALLBACK *get_frame)(struct _cef_v8context_t* self); + + /// + // Returns the global object for this context. The context must be entered + // before calling this function. + /// + struct _cef_v8value_t* (CEF_CALLBACK *get_global)( + struct _cef_v8context_t* self); + + /// + // Enter this context. A context must be explicitly entered before creating a + // V8 Object, Array, Function or Date asynchronously. exit() must be called + // the same number of times as enter() before releasing this context. V8 + // objects belong to the context in which they are created. Returns true (1) + // if the scope was entered successfully. + /// + int (CEF_CALLBACK *enter)(struct _cef_v8context_t* self); + + /// + // Exit this context. Call this function only after calling enter(). Returns + // true (1) if the scope was exited successfully. + /// + int (CEF_CALLBACK *exit)(struct _cef_v8context_t* self); + + /// + // Returns true (1) if this object is pointing to the same handle as |that| + // object. + /// + int (CEF_CALLBACK *is_same)(struct _cef_v8context_t* self, + struct _cef_v8context_t* that); + + /// + // Evaluates the specified JavaScript code using this context's global object. + // On success |retval| will be set to the return value, if any, and the + // function will return true (1). On failure |exception| will be set to the + // exception, if any, and the function will return false (0). + /// + int (CEF_CALLBACK *eval)(struct _cef_v8context_t* self, + const cef_string_t* code, struct _cef_v8value_t** retval, + struct _cef_v8exception_t** exception); +} cef_v8context_t; + + +/// +// Returns the current (top) context object in the V8 context stack. +/// +CEF_EXPORT cef_v8context_t* cef_v8context_get_current_context(); + +/// +// Returns the entered (bottom) context object in the V8 context stack. +/// +CEF_EXPORT cef_v8context_t* cef_v8context_get_entered_context(); + +/// +// Returns true (1) if V8 is currently inside a context. +/// +CEF_EXPORT int cef_v8context_in_context(); + + +/// +// Structure that should be implemented to handle V8 function calls. The +// functions of this structure will be called on the thread associated with the +// V8 function. +/// +typedef struct _cef_v8handler_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Handle execution of the function identified by |name|. |object| is the + // receiver ('this' object) of the function. |arguments| is the list of + // arguments passed to the function. If execution succeeds set |retval| to the + // function return value. If execution fails set |exception| to the exception + // that will be thrown. Return true (1) if execution was handled. + /// + int (CEF_CALLBACK *execute)(struct _cef_v8handler_t* self, + const cef_string_t* name, struct _cef_v8value_t* object, + size_t argumentsCount, struct _cef_v8value_t* const* arguments, + struct _cef_v8value_t** retval, cef_string_t* exception); +} cef_v8handler_t; + + +/// +// Structure that should be implemented to handle V8 accessor calls. Accessor +// identifiers are registered by calling cef_v8value_t::set_value_byaccessor(). +// The functions of this structure will be called on the thread associated with +// the V8 accessor. +/// +typedef struct _cef_v8accessor_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Handle retrieval the accessor value identified by |name|. |object| is the + // receiver ('this' object) of the accessor. If retrieval succeeds set + // |retval| to the return value. If retrieval fails set |exception| to the + // exception that will be thrown. Return true (1) if accessor retrieval was + // handled. + /// + int (CEF_CALLBACK *get)(struct _cef_v8accessor_t* self, + const cef_string_t* name, struct _cef_v8value_t* object, + struct _cef_v8value_t** retval, cef_string_t* exception); + + /// + // Handle assignment of the accessor value identified by |name|. |object| is + // the receiver ('this' object) of the accessor. |value| is the new value + // being assigned to the accessor. If assignment fails set |exception| to the + // exception that will be thrown. Return true (1) if accessor assignment was + // handled. + /// + int (CEF_CALLBACK *set)(struct _cef_v8accessor_t* self, + const cef_string_t* name, struct _cef_v8value_t* object, + struct _cef_v8value_t* value, cef_string_t* exception); +} cef_v8accessor_t; + + +/// +// Structure representing a V8 exception. The functions of this structure may be +// called on any render process thread. +/// +typedef struct _cef_v8exception_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns the exception message. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_message)( + struct _cef_v8exception_t* self); + + /// + // Returns the line of source code that the exception occurred within. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_source_line)( + struct _cef_v8exception_t* self); + + /// + // Returns the resource name for the script from where the function causing + // the error originates. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_script_resource_name)( + struct _cef_v8exception_t* self); + + /// + // Returns the 1-based number of the line where the error occurred or 0 if the + // line number is unknown. + /// + int (CEF_CALLBACK *get_line_number)(struct _cef_v8exception_t* self); + + /// + // Returns the index within the script of the first character where the error + // occurred. + /// + int (CEF_CALLBACK *get_start_position)(struct _cef_v8exception_t* self); + + /// + // Returns the index within the script of the last character where the error + // occurred. + /// + int (CEF_CALLBACK *get_end_position)(struct _cef_v8exception_t* self); + + /// + // Returns the index within the line of the first character where the error + // occurred. + /// + int (CEF_CALLBACK *get_start_column)(struct _cef_v8exception_t* self); + + /// + // Returns the index within the line of the last character where the error + // occurred. + /// + int (CEF_CALLBACK *get_end_column)(struct _cef_v8exception_t* self); +} cef_v8exception_t; + + +/// +// Structure representing a V8 value handle. V8 handles can only be accessed +// from the thread on which they are created. Valid threads for creating a V8 +// handle include the render process main thread (TID_RENDERER) and WebWorker +// threads. A task runner for posting tasks on the associated thread can be +// retrieved via the cef_v8context_t::get_task_runner() function. +/// +typedef struct _cef_v8value_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns true (1) if the underlying handle is valid and it can be accessed + // on the current thread. Do not call any other functions if this function + // returns false (0). + /// + int (CEF_CALLBACK *is_valid)(struct _cef_v8value_t* self); + + /// + // True if the value type is undefined. + /// + int (CEF_CALLBACK *is_undefined)(struct _cef_v8value_t* self); + + /// + // True if the value type is null. + /// + int (CEF_CALLBACK *is_null)(struct _cef_v8value_t* self); + + /// + // True if the value type is bool. + /// + int (CEF_CALLBACK *is_bool)(struct _cef_v8value_t* self); + + /// + // True if the value type is int. + /// + int (CEF_CALLBACK *is_int)(struct _cef_v8value_t* self); + + /// + // True if the value type is unsigned int. + /// + int (CEF_CALLBACK *is_uint)(struct _cef_v8value_t* self); + + /// + // True if the value type is double. + /// + int (CEF_CALLBACK *is_double)(struct _cef_v8value_t* self); + + /// + // True if the value type is Date. + /// + int (CEF_CALLBACK *is_date)(struct _cef_v8value_t* self); + + /// + // True if the value type is string. + /// + int (CEF_CALLBACK *is_string)(struct _cef_v8value_t* self); + + /// + // True if the value type is object. + /// + int (CEF_CALLBACK *is_object)(struct _cef_v8value_t* self); + + /// + // True if the value type is array. + /// + int (CEF_CALLBACK *is_array)(struct _cef_v8value_t* self); + + /// + // True if the value type is function. + /// + int (CEF_CALLBACK *is_function)(struct _cef_v8value_t* self); + + /// + // Returns true (1) if this object is pointing to the same handle as |that| + // object. + /// + int (CEF_CALLBACK *is_same)(struct _cef_v8value_t* self, + struct _cef_v8value_t* that); + + /// + // Return a bool value. The underlying data will be converted to if + // necessary. + /// + int (CEF_CALLBACK *get_bool_value)(struct _cef_v8value_t* self); + + /// + // Return an int value. The underlying data will be converted to if + // necessary. + /// + int32 (CEF_CALLBACK *get_int_value)(struct _cef_v8value_t* self); + + /// + // Return an unisgned int value. The underlying data will be converted to if + // necessary. + /// + uint32 (CEF_CALLBACK *get_uint_value)(struct _cef_v8value_t* self); + + /// + // Return a double value. The underlying data will be converted to if + // necessary. + /// + double (CEF_CALLBACK *get_double_value)(struct _cef_v8value_t* self); + + /// + // Return a Date value. The underlying data will be converted to if + // necessary. + /// + cef_time_t (CEF_CALLBACK *get_date_value)(struct _cef_v8value_t* self); + + /// + // Return a string value. The underlying data will be converted to if + // necessary. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_string_value)( + struct _cef_v8value_t* self); + + + // OBJECT METHODS - These functions are only available on objects. Arrays and + // functions are also objects. String- and integer-based keys can be used + // interchangably with the framework converting between them as necessary. + + /// + // Returns true (1) if this is a user created object. + /// + int (CEF_CALLBACK *is_user_created)(struct _cef_v8value_t* self); + + /// + // Returns true (1) if the last function call resulted in an exception. This + // attribute exists only in the scope of the current CEF value object. + /// + int (CEF_CALLBACK *has_exception)(struct _cef_v8value_t* self); + + /// + // Returns the exception resulting from the last function call. This attribute + // exists only in the scope of the current CEF value object. + /// + struct _cef_v8exception_t* (CEF_CALLBACK *get_exception)( + struct _cef_v8value_t* self); + + /// + // Clears the last exception and returns true (1) on success. + /// + int (CEF_CALLBACK *clear_exception)(struct _cef_v8value_t* self); + + /// + // Returns true (1) if this object will re-throw future exceptions. This + // attribute exists only in the scope of the current CEF value object. + /// + int (CEF_CALLBACK *will_rethrow_exceptions)(struct _cef_v8value_t* self); + + /// + // Set whether this object will re-throw future exceptions. By default + // exceptions are not re-thrown. If a exception is re-thrown the current + // context should not be accessed again until after the exception has been + // caught and not re-thrown. Returns true (1) on success. This attribute + // exists only in the scope of the current CEF value object. + /// + int (CEF_CALLBACK *set_rethrow_exceptions)(struct _cef_v8value_t* self, + int rethrow); + + /// + // Returns true (1) if the object has a value with the specified identifier. + /// + int (CEF_CALLBACK *has_value_bykey)(struct _cef_v8value_t* self, + const cef_string_t* key); + + /// + // Returns true (1) if the object has a value with the specified identifier. + /// + int (CEF_CALLBACK *has_value_byindex)(struct _cef_v8value_t* self, int index); + + /// + // Deletes the value with the specified identifier and returns true (1) on + // success. Returns false (0) if this function is called incorrectly or an + // exception is thrown. For read-only and don't-delete values this function + // will return true (1) even though deletion failed. + /// + int (CEF_CALLBACK *delete_value_bykey)(struct _cef_v8value_t* self, + const cef_string_t* key); + + /// + // Deletes the value with the specified identifier and returns true (1) on + // success. Returns false (0) if this function is called incorrectly, deletion + // fails or an exception is thrown. For read-only and don't-delete values this + // function will return true (1) even though deletion failed. + /// + int (CEF_CALLBACK *delete_value_byindex)(struct _cef_v8value_t* self, + int index); + + /// + // Returns the value with the specified identifier on success. Returns NULL if + // this function is called incorrectly or an exception is thrown. + /// + struct _cef_v8value_t* (CEF_CALLBACK *get_value_bykey)( + struct _cef_v8value_t* self, const cef_string_t* key); + + /// + // Returns the value with the specified identifier on success. Returns NULL if + // this function is called incorrectly or an exception is thrown. + /// + struct _cef_v8value_t* (CEF_CALLBACK *get_value_byindex)( + struct _cef_v8value_t* self, int index); + + /// + // Associates a value with the specified identifier and returns true (1) on + // success. Returns false (0) if this function is called incorrectly or an + // exception is thrown. For read-only values this function will return true + // (1) even though assignment failed. + /// + int (CEF_CALLBACK *set_value_bykey)(struct _cef_v8value_t* self, + const cef_string_t* key, struct _cef_v8value_t* value, + enum cef_v8_propertyattribute_t attribute); + + /// + // Associates a value with the specified identifier and returns true (1) on + // success. Returns false (0) if this function is called incorrectly or an + // exception is thrown. For read-only values this function will return true + // (1) even though assignment failed. + /// + int (CEF_CALLBACK *set_value_byindex)(struct _cef_v8value_t* self, int index, + struct _cef_v8value_t* value); + + /// + // Registers an identifier and returns true (1) on success. Access to the + // identifier will be forwarded to the cef_v8accessor_t instance passed to + // cef_v8value_t::cef_v8value_create_object(). Returns false (0) if this + // function is called incorrectly or an exception is thrown. For read-only + // values this function will return true (1) even though assignment failed. + /// + int (CEF_CALLBACK *set_value_byaccessor)(struct _cef_v8value_t* self, + const cef_string_t* key, enum cef_v8_accesscontrol_t settings, + enum cef_v8_propertyattribute_t attribute); + + /// + // Read the keys for the object's values into the specified vector. Integer- + // based keys will also be returned as strings. + /// + int (CEF_CALLBACK *get_keys)(struct _cef_v8value_t* self, + cef_string_list_t keys); + + /// + // Sets the user data for this object and returns true (1) on success. Returns + // false (0) if this function is called incorrectly. This function can only be + // called on user created objects. + /// + int (CEF_CALLBACK *set_user_data)(struct _cef_v8value_t* self, + struct _cef_base_t* user_data); + + /// + // Returns the user data, if any, assigned to this object. + /// + struct _cef_base_t* (CEF_CALLBACK *get_user_data)( + struct _cef_v8value_t* self); + + /// + // Returns the amount of externally allocated memory registered for the + // object. + /// + int (CEF_CALLBACK *get_externally_allocated_memory)( + struct _cef_v8value_t* self); + + /// + // Adjusts the amount of registered external memory for the object. Used to + // give V8 an indication of the amount of externally allocated memory that is + // kept alive by JavaScript objects. V8 uses this information to decide when + // to perform global garbage collection. Each cef_v8value_t tracks the amount + // of external memory associated with it and automatically decreases the + // global total by the appropriate amount on its destruction. + // |change_in_bytes| specifies the number of bytes to adjust by. This function + // returns the number of bytes associated with the object after the + // adjustment. This function can only be called on user created objects. + /// + int (CEF_CALLBACK *adjust_externally_allocated_memory)( + struct _cef_v8value_t* self, int change_in_bytes); + + + // ARRAY METHODS - These functions are only available on arrays. + + /// + // Returns the number of elements in the array. + /// + int (CEF_CALLBACK *get_array_length)(struct _cef_v8value_t* self); + + + // FUNCTION METHODS - These functions are only available on functions. + + /// + // Returns the function name. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_function_name)( + struct _cef_v8value_t* self); + + /// + // Returns the function handler or NULL if not a CEF-created function. + /// + struct _cef_v8handler_t* (CEF_CALLBACK *get_function_handler)( + struct _cef_v8value_t* self); + + /// + // Execute the function using the current V8 context. This function should + // only be called from within the scope of a cef_v8handler_t or + // cef_v8accessor_t callback, or in combination with calling enter() and + // exit() on a stored cef_v8context_t reference. |object| is the receiver + // ('this' object) of the function. If |object| is NULL the current context's + // global object will be used. |arguments| is the list of arguments that will + // be passed to the function. Returns the function return value on success. + // Returns NULL if this function is called incorrectly or an exception is + // thrown. + /// + struct _cef_v8value_t* (CEF_CALLBACK *execute_function)( + struct _cef_v8value_t* self, struct _cef_v8value_t* object, + size_t argumentsCount, struct _cef_v8value_t* const* arguments); + + /// + // Execute the function using the specified V8 context. |object| is the + // receiver ('this' object) of the function. If |object| is NULL the specified + // context's global object will be used. |arguments| is the list of arguments + // that will be passed to the function. Returns the function return value on + // success. Returns NULL if this function is called incorrectly or an + // exception is thrown. + /// + struct _cef_v8value_t* (CEF_CALLBACK *execute_function_with_context)( + struct _cef_v8value_t* self, struct _cef_v8context_t* context, + struct _cef_v8value_t* object, size_t argumentsCount, + struct _cef_v8value_t* const* arguments); +} cef_v8value_t; + + +/// +// Create a new cef_v8value_t object of type undefined. +/// +CEF_EXPORT cef_v8value_t* cef_v8value_create_undefined(); + +/// +// Create a new cef_v8value_t object of type null. +/// +CEF_EXPORT cef_v8value_t* cef_v8value_create_null(); + +/// +// Create a new cef_v8value_t object of type bool. +/// +CEF_EXPORT cef_v8value_t* cef_v8value_create_bool(int value); + +/// +// Create a new cef_v8value_t object of type int. +/// +CEF_EXPORT cef_v8value_t* cef_v8value_create_int(int32 value); + +/// +// Create a new cef_v8value_t object of type unsigned int. +/// +CEF_EXPORT cef_v8value_t* cef_v8value_create_uint(uint32 value); + +/// +// Create a new cef_v8value_t object of type double. +/// +CEF_EXPORT cef_v8value_t* cef_v8value_create_double(double value); + +/// +// Create a new cef_v8value_t object of type Date. This function should only be +// called from within the scope of a cef_v8context_tHandler, cef_v8handler_t or +// cef_v8accessor_t callback, or in combination with calling enter() and exit() +// on a stored cef_v8context_t reference. +/// +CEF_EXPORT cef_v8value_t* cef_v8value_create_date(const cef_time_t* date); + +/// +// Create a new cef_v8value_t object of type string. +/// +CEF_EXPORT cef_v8value_t* cef_v8value_create_string(const cef_string_t* value); + +/// +// Create a new cef_v8value_t object of type object with optional accessor. This +// function should only be called from within the scope of a +// cef_v8context_tHandler, cef_v8handler_t or cef_v8accessor_t callback, or in +// combination with calling enter() and exit() on a stored cef_v8context_t +// reference. +/// +CEF_EXPORT cef_v8value_t* cef_v8value_create_object(cef_v8accessor_t* accessor); + +/// +// Create a new cef_v8value_t object of type array with the specified |length|. +// If |length| is negative the returned array will have length 0. This function +// should only be called from within the scope of a cef_v8context_tHandler, +// cef_v8handler_t or cef_v8accessor_t callback, or in combination with calling +// enter() and exit() on a stored cef_v8context_t reference. +/// +CEF_EXPORT cef_v8value_t* cef_v8value_create_array(int length); + +/// +// Create a new cef_v8value_t object of type function. This function should only +// be called from within the scope of a cef_v8context_tHandler, cef_v8handler_t +// or cef_v8accessor_t callback, or in combination with calling enter() and +// exit() on a stored cef_v8context_t reference. +/// +CEF_EXPORT cef_v8value_t* cef_v8value_create_function(const cef_string_t* name, + cef_v8handler_t* handler); + + +/// +// Structure representing a V8 stack trace handle. V8 handles can only be +// accessed from the thread on which they are created. Valid threads for +// creating a V8 handle include the render process main thread (TID_RENDERER) +// and WebWorker threads. A task runner for posting tasks on the associated +// thread can be retrieved via the cef_v8context_t::get_task_runner() function. +/// +typedef struct _cef_v8stack_trace_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns true (1) if the underlying handle is valid and it can be accessed + // on the current thread. Do not call any other functions if this function + // returns false (0). + /// + int (CEF_CALLBACK *is_valid)(struct _cef_v8stack_trace_t* self); + + /// + // Returns the number of stack frames. + /// + int (CEF_CALLBACK *get_frame_count)(struct _cef_v8stack_trace_t* self); + + /// + // Returns the stack frame at the specified 0-based index. + /// + struct _cef_v8stack_frame_t* (CEF_CALLBACK *get_frame)( + struct _cef_v8stack_trace_t* self, int index); +} cef_v8stack_trace_t; + + +/// +// Returns the stack trace for the currently active context. |frame_limit| is +// the maximum number of frames that will be captured. +/// +CEF_EXPORT cef_v8stack_trace_t* cef_v8stack_trace_get_current(int frame_limit); + + +/// +// Structure representing a V8 stack frame handle. V8 handles can only be +// accessed from the thread on which they are created. Valid threads for +// creating a V8 handle include the render process main thread (TID_RENDERER) +// and WebWorker threads. A task runner for posting tasks on the associated +// thread can be retrieved via the cef_v8context_t::get_task_runner() function. +/// +typedef struct _cef_v8stack_frame_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns true (1) if the underlying handle is valid and it can be accessed + // on the current thread. Do not call any other functions if this function + // returns false (0). + /// + int (CEF_CALLBACK *is_valid)(struct _cef_v8stack_frame_t* self); + + /// + // Returns the name of the resource script that contains the function. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_script_name)( + struct _cef_v8stack_frame_t* self); + + /// + // Returns the name of the resource script that contains the function or the + // sourceURL value if the script name is undefined and its source ends with a + // "//@ sourceURL=..." string. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_script_name_or_source_url)( + struct _cef_v8stack_frame_t* self); + + /// + // Returns the name of the function. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_function_name)( + struct _cef_v8stack_frame_t* self); + + /// + // Returns the 1-based line number for the function call or 0 if unknown. + /// + int (CEF_CALLBACK *get_line_number)(struct _cef_v8stack_frame_t* self); + + /// + // Returns the 1-based column offset on the line for the function call or 0 if + // unknown. + /// + int (CEF_CALLBACK *get_column)(struct _cef_v8stack_frame_t* self); + + /// + // Returns true (1) if the function was compiled using eval(). + /// + int (CEF_CALLBACK *is_eval)(struct _cef_v8stack_frame_t* self); + + /// + // Returns true (1) if the function was called as a constructor via "new". + /// + int (CEF_CALLBACK *is_constructor)(struct _cef_v8stack_frame_t* self); +} cef_v8stack_frame_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_V8_CAPI_H_ diff --git a/cef3/include/capi/cef_values_capi.h b/cef3/include/capi/cef_values_capi.h new file mode 100644 index 000000000..ed59fa4fc --- /dev/null +++ b/cef3/include/capi/cef_values_capi.h @@ -0,0 +1,461 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_VALUES_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_VALUES_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Structure representing a binary value. Can be used on any process and thread. +/// +typedef struct _cef_binary_value_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns true (1) if this object is valid. Do not call any other functions + // if this function returns false (0). + /// + int (CEF_CALLBACK *is_valid)(struct _cef_binary_value_t* self); + + /// + // Returns true (1) if this object is currently owned by another object. + /// + int (CEF_CALLBACK *is_owned)(struct _cef_binary_value_t* self); + + /// + // Returns a copy of this object. The data in this object will also be copied. + /// + struct _cef_binary_value_t* (CEF_CALLBACK *copy)( + struct _cef_binary_value_t* self); + + /// + // Returns the data size. + /// + size_t (CEF_CALLBACK *get_size)(struct _cef_binary_value_t* self); + + /// + // Read up to |buffer_size| number of bytes into |buffer|. Reading begins at + // the specified byte |data_offset|. Returns the number of bytes read. + /// + size_t (CEF_CALLBACK *get_data)(struct _cef_binary_value_t* self, + void* buffer, size_t buffer_size, size_t data_offset); +} cef_binary_value_t; + + +/// +// Creates a new object that is not owned by any other object. The specified +// |data| will be copied. +/// +CEF_EXPORT cef_binary_value_t* cef_binary_value_create(const void* data, + size_t data_size); + + +/// +// Structure representing a dictionary value. Can be used on any process and +// thread. +/// +typedef struct _cef_dictionary_value_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns true (1) if this object is valid. Do not call any other functions + // if this function returns false (0). + /// + int (CEF_CALLBACK *is_valid)(struct _cef_dictionary_value_t* self); + + /// + // Returns true (1) if this object is currently owned by another object. + /// + int (CEF_CALLBACK *is_owned)(struct _cef_dictionary_value_t* self); + + /// + // Returns true (1) if the values of this object are read-only. Some APIs may + // expose read-only objects. + /// + int (CEF_CALLBACK *is_read_only)(struct _cef_dictionary_value_t* self); + + /// + // Returns a writable copy of this object. If |exclude_NULL_children| is true + // (1) any NULL dictionaries or lists will be excluded from the copy. + /// + struct _cef_dictionary_value_t* (CEF_CALLBACK *copy)( + struct _cef_dictionary_value_t* self, int exclude_empty_children); + + /// + // Returns the number of values. + /// + size_t (CEF_CALLBACK *get_size)(struct _cef_dictionary_value_t* self); + + /// + // Removes all values. Returns true (1) on success. + /// + int (CEF_CALLBACK *clear)(struct _cef_dictionary_value_t* self); + + /// + // Returns true (1) if the current dictionary has a value for the given key. + /// + int (CEF_CALLBACK *has_key)(struct _cef_dictionary_value_t* self, + const cef_string_t* key); + + /// + // Reads all keys for this dictionary into the specified vector. + /// + int (CEF_CALLBACK *get_keys)(struct _cef_dictionary_value_t* self, + cef_string_list_t keys); + + /// + // Removes the value at the specified key. Returns true (1) is the value was + // removed successfully. + /// + int (CEF_CALLBACK *remove)(struct _cef_dictionary_value_t* self, + const cef_string_t* key); + + /// + // Returns the value type for the specified key. + /// + enum cef_value_type_t (CEF_CALLBACK *get_type)( + struct _cef_dictionary_value_t* self, const cef_string_t* key); + + /// + // Returns the value at the specified key as type bool. + /// + int (CEF_CALLBACK *get_bool)(struct _cef_dictionary_value_t* self, + const cef_string_t* key); + + /// + // Returns the value at the specified key as type int. + /// + int (CEF_CALLBACK *get_int)(struct _cef_dictionary_value_t* self, + const cef_string_t* key); + + /// + // Returns the value at the specified key as type double. + /// + double (CEF_CALLBACK *get_double)(struct _cef_dictionary_value_t* self, + const cef_string_t* key); + + /// + // Returns the value at the specified key as type string. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_string)( + struct _cef_dictionary_value_t* self, const cef_string_t* key); + + /// + // Returns the value at the specified key as type binary. + /// + struct _cef_binary_value_t* (CEF_CALLBACK *get_binary)( + struct _cef_dictionary_value_t* self, const cef_string_t* key); + + /// + // Returns the value at the specified key as type dictionary. + /// + struct _cef_dictionary_value_t* (CEF_CALLBACK *get_dictionary)( + struct _cef_dictionary_value_t* self, const cef_string_t* key); + + /// + // Returns the value at the specified key as type list. + /// + struct _cef_list_value_t* (CEF_CALLBACK *get_list)( + struct _cef_dictionary_value_t* self, const cef_string_t* key); + + /// + // Sets the value at the specified key as type null. Returns true (1) if the + // value was set successfully. + /// + int (CEF_CALLBACK *set_null)(struct _cef_dictionary_value_t* self, + const cef_string_t* key); + + /// + // Sets the value at the specified key as type bool. Returns true (1) if the + // value was set successfully. + /// + int (CEF_CALLBACK *set_bool)(struct _cef_dictionary_value_t* self, + const cef_string_t* key, int value); + + /// + // Sets the value at the specified key as type int. Returns true (1) if the + // value was set successfully. + /// + int (CEF_CALLBACK *set_int)(struct _cef_dictionary_value_t* self, + const cef_string_t* key, int value); + + /// + // Sets the value at the specified key as type double. Returns true (1) if the + // value was set successfully. + /// + int (CEF_CALLBACK *set_double)(struct _cef_dictionary_value_t* self, + const cef_string_t* key, double value); + + /// + // Sets the value at the specified key as type string. Returns true (1) if the + // value was set successfully. + /// + int (CEF_CALLBACK *set_string)(struct _cef_dictionary_value_t* self, + const cef_string_t* key, const cef_string_t* value); + + /// + // Sets the value at the specified key as type binary. Returns true (1) if the + // value was set successfully. If |value| is currently owned by another object + // then the value will be copied and the |value| reference will not change. + // Otherwise, ownership will be transferred to this object and the |value| + // reference will be invalidated. + /// + int (CEF_CALLBACK *set_binary)(struct _cef_dictionary_value_t* self, + const cef_string_t* key, struct _cef_binary_value_t* value); + + /// + // Sets the value at the specified key as type dict. Returns true (1) if the + // value was set successfully. After calling this function the |value| object + // will no longer be valid. If |value| is currently owned by another object + // then the value will be copied and the |value| reference will not change. + // Otherwise, ownership will be transferred to this object and the |value| + // reference will be invalidated. + /// + int (CEF_CALLBACK *set_dictionary)(struct _cef_dictionary_value_t* self, + const cef_string_t* key, struct _cef_dictionary_value_t* value); + + /// + // Sets the value at the specified key as type list. Returns true (1) if the + // value was set successfully. After calling this function the |value| object + // will no longer be valid. If |value| is currently owned by another object + // then the value will be copied and the |value| reference will not change. + // Otherwise, ownership will be transferred to this object and the |value| + // reference will be invalidated. + /// + int (CEF_CALLBACK *set_list)(struct _cef_dictionary_value_t* self, + const cef_string_t* key, struct _cef_list_value_t* value); +} cef_dictionary_value_t; + + +/// +// Creates a new object that is not owned by any other object. +/// +CEF_EXPORT cef_dictionary_value_t* cef_dictionary_value_create(); + + +/// +// Structure representing a list value. Can be used on any process and thread. +/// +typedef struct _cef_list_value_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns true (1) if this object is valid. Do not call any other functions + // if this function returns false (0). + /// + int (CEF_CALLBACK *is_valid)(struct _cef_list_value_t* self); + + /// + // Returns true (1) if this object is currently owned by another object. + /// + int (CEF_CALLBACK *is_owned)(struct _cef_list_value_t* self); + + /// + // Returns true (1) if the values of this object are read-only. Some APIs may + // expose read-only objects. + /// + int (CEF_CALLBACK *is_read_only)(struct _cef_list_value_t* self); + + /// + // Returns a writable copy of this object. + /// + struct _cef_list_value_t* (CEF_CALLBACK *copy)( + struct _cef_list_value_t* self); + + /// + // Sets the number of values. If the number of values is expanded all new + // value slots will default to type null. Returns true (1) on success. + /// + int (CEF_CALLBACK *set_size)(struct _cef_list_value_t* self, size_t size); + + /// + // Returns the number of values. + /// + size_t (CEF_CALLBACK *get_size)(struct _cef_list_value_t* self); + + /// + // Removes all values. Returns true (1) on success. + /// + int (CEF_CALLBACK *clear)(struct _cef_list_value_t* self); + + /// + // Removes the value at the specified index. + /// + int (CEF_CALLBACK *remove)(struct _cef_list_value_t* self, int index); + + /// + // Returns the value type at the specified index. + /// + enum cef_value_type_t (CEF_CALLBACK *get_type)(struct _cef_list_value_t* self, + int index); + + /// + // Returns the value at the specified index as type bool. + /// + int (CEF_CALLBACK *get_bool)(struct _cef_list_value_t* self, int index); + + /// + // Returns the value at the specified index as type int. + /// + int (CEF_CALLBACK *get_int)(struct _cef_list_value_t* self, int index); + + /// + // Returns the value at the specified index as type double. + /// + double (CEF_CALLBACK *get_double)(struct _cef_list_value_t* self, int index); + + /// + // Returns the value at the specified index as type string. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_string)( + struct _cef_list_value_t* self, int index); + + /// + // Returns the value at the specified index as type binary. + /// + struct _cef_binary_value_t* (CEF_CALLBACK *get_binary)( + struct _cef_list_value_t* self, int index); + + /// + // Returns the value at the specified index as type dictionary. + /// + struct _cef_dictionary_value_t* (CEF_CALLBACK *get_dictionary)( + struct _cef_list_value_t* self, int index); + + /// + // Returns the value at the specified index as type list. + /// + struct _cef_list_value_t* (CEF_CALLBACK *get_list)( + struct _cef_list_value_t* self, int index); + + /// + // Sets the value at the specified index as type null. Returns true (1) if the + // value was set successfully. + /// + int (CEF_CALLBACK *set_null)(struct _cef_list_value_t* self, int index); + + /// + // Sets the value at the specified index as type bool. Returns true (1) if the + // value was set successfully. + /// + int (CEF_CALLBACK *set_bool)(struct _cef_list_value_t* self, int index, + int value); + + /// + // Sets the value at the specified index as type int. Returns true (1) if the + // value was set successfully. + /// + int (CEF_CALLBACK *set_int)(struct _cef_list_value_t* self, int index, + int value); + + /// + // Sets the value at the specified index as type double. Returns true (1) if + // the value was set successfully. + /// + int (CEF_CALLBACK *set_double)(struct _cef_list_value_t* self, int index, + double value); + + /// + // Sets the value at the specified index as type string. Returns true (1) if + // the value was set successfully. + /// + int (CEF_CALLBACK *set_string)(struct _cef_list_value_t* self, int index, + const cef_string_t* value); + + /// + // Sets the value at the specified index as type binary. Returns true (1) if + // the value was set successfully. After calling this function the |value| + // object will no longer be valid. If |value| is currently owned by another + // object then the value will be copied and the |value| reference will not + // change. Otherwise, ownership will be transferred to this object and the + // |value| reference will be invalidated. + /// + int (CEF_CALLBACK *set_binary)(struct _cef_list_value_t* self, int index, + struct _cef_binary_value_t* value); + + /// + // Sets the value at the specified index as type dict. Returns true (1) if the + // value was set successfully. After calling this function the |value| object + // will no longer be valid. If |value| is currently owned by another object + // then the value will be copied and the |value| reference will not change. + // Otherwise, ownership will be transferred to this object and the |value| + // reference will be invalidated. + /// + int (CEF_CALLBACK *set_dictionary)(struct _cef_list_value_t* self, int index, + struct _cef_dictionary_value_t* value); + + /// + // Sets the value at the specified index as type list. Returns true (1) if the + // value was set successfully. After calling this function the |value| object + // will no longer be valid. If |value| is currently owned by another object + // then the value will be copied and the |value| reference will not change. + // Otherwise, ownership will be transferred to this object and the |value| + // reference will be invalidated. + /// + int (CEF_CALLBACK *set_list)(struct _cef_list_value_t* self, int index, + struct _cef_list_value_t* value); +} cef_list_value_t; + + +/// +// Creates a new object that is not owned by any other object. +/// +CEF_EXPORT cef_list_value_t* cef_list_value_create(); + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_VALUES_CAPI_H_ diff --git a/cef3/include/capi/cef_web_plugin_capi.h b/cef3/include/capi/cef_web_plugin_capi.h new file mode 100644 index 000000000..13ac38b39 --- /dev/null +++ b/cef3/include/capi/cef_web_plugin_capi.h @@ -0,0 +1,194 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_WEB_PLUGIN_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_WEB_PLUGIN_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Visit web plugin information. Can be called on any thread in the browser +// process. +/// +CEF_EXPORT void cef_visit_web_plugin_info( + struct _cef_web_plugin_info_visitor_t* visitor); + +/// +// Cause the plugin list to refresh the next time it is accessed regardless of +// whether it has already been loaded. Can be called on any thread in the +// browser process. +/// +CEF_EXPORT void cef_refresh_web_plugins(); + +/// +// Add a plugin path (directory + file). This change may not take affect until +// after cef_refresh_web_plugins() is called. Can be called on any thread in the +// browser process. +/// +CEF_EXPORT void cef_add_web_plugin_path(const cef_string_t* path); + +/// +// Add a plugin directory. This change may not take affect until after +// cef_refresh_web_plugins() is called. Can be called on any thread in the +// browser process. +/// +CEF_EXPORT void cef_add_web_plugin_directory(const cef_string_t* dir); + +/// +// Remove a plugin path (directory + file). This change may not take affect +// until after cef_refresh_web_plugins() is called. Can be called on any thread +// in the browser process. +/// +CEF_EXPORT void cef_remove_web_plugin_path(const cef_string_t* path); + +/// +// Unregister an internal plugin. This may be undone the next time +// cef_refresh_web_plugins() is called. Can be called on any thread in the +// browser process. +/// +CEF_EXPORT void cef_unregister_internal_web_plugin(const cef_string_t* path); + +/// +// Force a plugin to shutdown. Can be called on any thread in the browser +// process but will be executed on the IO thread. +/// +CEF_EXPORT void cef_force_web_plugin_shutdown(const cef_string_t* path); + +/// +// Register a plugin crash. Can be called on any thread in the browser process +// but will be executed on the IO thread. +/// +CEF_EXPORT void cef_register_web_plugin_crash(const cef_string_t* path); + +/// +// Query if a plugin is unstable. Can be called on any thread in the browser +// process. +/// +CEF_EXPORT void cef_is_web_plugin_unstable(const cef_string_t* path, + struct _cef_web_plugin_unstable_callback_t* callback); + +/// +// Information about a specific web plugin. +/// +typedef struct _cef_web_plugin_info_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns the plugin name (i.e. Flash). + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_name)( + struct _cef_web_plugin_info_t* self); + + /// + // Returns the plugin file path (DLL/bundle/library). + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_path)( + struct _cef_web_plugin_info_t* self); + + /// + // Returns the version of the plugin (may be OS-specific). + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_version)( + struct _cef_web_plugin_info_t* self); + + /// + // Returns a description of the plugin from the version information. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_description)( + struct _cef_web_plugin_info_t* self); +} cef_web_plugin_info_t; + + +/// +// Structure to implement for visiting web plugin information. The functions of +// this structure will be called on the browser process UI thread. +/// +typedef struct _cef_web_plugin_info_visitor_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Method that will be called once for each plugin. |count| is the 0-based + // index for the current plugin. |total| is the total number of plugins. + // Return false (0) to stop visiting plugins. This function may never be + // called if no plugins are found. + /// + int (CEF_CALLBACK *visit)(struct _cef_web_plugin_info_visitor_t* self, + struct _cef_web_plugin_info_t* info, int count, int total); +} cef_web_plugin_info_visitor_t; + + +/// +// Structure to implement for receiving unstable plugin information. The +// functions of this structure will be called on the browser process IO thread. +/// +typedef struct _cef_web_plugin_unstable_callback_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Method that will be called for the requested plugin. |unstable| will be + // true (1) if the plugin has reached the crash count threshold of 3 times in + // 120 seconds. + /// + void (CEF_CALLBACK *is_unstable)( + struct _cef_web_plugin_unstable_callback_t* self, + const cef_string_t* path, int unstable); +} cef_web_plugin_unstable_callback_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_WEB_PLUGIN_CAPI_H_ diff --git a/cef3/include/capi/cef_xml_reader_capi.h b/cef3/include/capi/cef_xml_reader_capi.h new file mode 100644 index 000000000..952aa26e3 --- /dev/null +++ b/cef3/include/capi/cef_xml_reader_capi.h @@ -0,0 +1,278 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_XML_READER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_XML_READER_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Structure that supports the reading of XML data via the libxml streaming API. +// The functions of this structure should only be called on the thread that +// creates the object. +/// +typedef struct _cef_xml_reader_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Moves the cursor to the next node in the document. This function must be + // called at least once to set the current cursor position. Returns true (1) + // if the cursor position was set successfully. + /// + int (CEF_CALLBACK *move_to_next_node)(struct _cef_xml_reader_t* self); + + /// + // Close the document. This should be called directly to ensure that cleanup + // occurs on the correct thread. + /// + int (CEF_CALLBACK *close)(struct _cef_xml_reader_t* self); + + /// + // Returns true (1) if an error has been reported by the XML parser. + /// + int (CEF_CALLBACK *has_error)(struct _cef_xml_reader_t* self); + + /// + // Returns the error string. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_error)( + struct _cef_xml_reader_t* self); + + + // The below functions retrieve data for the node at the current cursor + // position. + + /// + // Returns the node type. + /// + enum cef_xml_node_type_t (CEF_CALLBACK *get_type)( + struct _cef_xml_reader_t* self); + + /// + // Returns the node depth. Depth starts at 0 for the root node. + /// + int (CEF_CALLBACK *get_depth)(struct _cef_xml_reader_t* self); + + /// + // Returns the local name. See http://www.w3.org/TR/REC-xml-names/#NT- + // LocalPart for additional details. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_local_name)( + struct _cef_xml_reader_t* self); + + /// + // Returns the namespace prefix. See http://www.w3.org/TR/REC-xml-names/ for + // additional details. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_prefix)( + struct _cef_xml_reader_t* self); + + /// + // Returns the qualified name, equal to (Prefix:)LocalName. See + // http://www.w3.org/TR/REC-xml-names/#ns-qualnames for additional details. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_qualified_name)( + struct _cef_xml_reader_t* self); + + /// + // Returns the URI defining the namespace associated with the node. See + // http://www.w3.org/TR/REC-xml-names/ for additional details. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_namespace_uri)( + struct _cef_xml_reader_t* self); + + /// + // Returns the base URI of the node. See http://www.w3.org/TR/xmlbase/ for + // additional details. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_base_uri)( + struct _cef_xml_reader_t* self); + + /// + // Returns the xml:lang scope within which the node resides. See + // http://www.w3.org/TR/REC-xml/#sec-lang-tag for additional details. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_xml_lang)( + struct _cef_xml_reader_t* self); + + /// + // Returns true (1) if the node represents an NULL element. is considered + // NULL but is not. + /// + int (CEF_CALLBACK *is_empty_element)(struct _cef_xml_reader_t* self); + + /// + // Returns true (1) if the node has a text value. + /// + int (CEF_CALLBACK *has_value)(struct _cef_xml_reader_t* self); + + /// + // Returns the text value. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_value)( + struct _cef_xml_reader_t* self); + + /// + // Returns true (1) if the node has attributes. + /// + int (CEF_CALLBACK *has_attributes)(struct _cef_xml_reader_t* self); + + /// + // Returns the number of attributes. + /// + size_t (CEF_CALLBACK *get_attribute_count)(struct _cef_xml_reader_t* self); + + /// + // Returns the value of the attribute at the specified 0-based index. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_attribute_byindex)( + struct _cef_xml_reader_t* self, int index); + + /// + // Returns the value of the attribute with the specified qualified name. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_attribute_byqname)( + struct _cef_xml_reader_t* self, const cef_string_t* qualifiedName); + + /// + // Returns the value of the attribute with the specified local name and + // namespace URI. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_attribute_bylname)( + struct _cef_xml_reader_t* self, const cef_string_t* localName, + const cef_string_t* namespaceURI); + + /// + // Returns an XML representation of the current node's children. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_inner_xml)( + struct _cef_xml_reader_t* self); + + /// + // Returns an XML representation of the current node including its children. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_outer_xml)( + struct _cef_xml_reader_t* self); + + /// + // Returns the line number for the current node. + /// + int (CEF_CALLBACK *get_line_number)(struct _cef_xml_reader_t* self); + + + // Attribute nodes are not traversed by default. The below functions can be + // used to move the cursor to an attribute node. move_to_carrying_element() + // can be called afterwards to return the cursor to the carrying element. The + // depth of an attribute node will be 1 + the depth of the carrying element. + + /// + // Moves the cursor to the attribute at the specified 0-based index. Returns + // true (1) if the cursor position was set successfully. + /// + int (CEF_CALLBACK *move_to_attribute_byindex)(struct _cef_xml_reader_t* self, + int index); + + /// + // Moves the cursor to the attribute with the specified qualified name. + // Returns true (1) if the cursor position was set successfully. + /// + int (CEF_CALLBACK *move_to_attribute_byqname)(struct _cef_xml_reader_t* self, + const cef_string_t* qualifiedName); + + /// + // Moves the cursor to the attribute with the specified local name and + // namespace URI. Returns true (1) if the cursor position was set + // successfully. + /// + int (CEF_CALLBACK *move_to_attribute_bylname)(struct _cef_xml_reader_t* self, + const cef_string_t* localName, const cef_string_t* namespaceURI); + + /// + // Moves the cursor to the first attribute in the current element. Returns + // true (1) if the cursor position was set successfully. + /// + int (CEF_CALLBACK *move_to_first_attribute)(struct _cef_xml_reader_t* self); + + /// + // Moves the cursor to the next attribute in the current element. Returns true + // (1) if the cursor position was set successfully. + /// + int (CEF_CALLBACK *move_to_next_attribute)(struct _cef_xml_reader_t* self); + + /// + // Moves the cursor back to the carrying element. Returns true (1) if the + // cursor position was set successfully. + /// + int (CEF_CALLBACK *move_to_carrying_element)(struct _cef_xml_reader_t* self); +} cef_xml_reader_t; + + +/// +// Create a new cef_xml_reader_t object. The returned object's functions can +// only be called from the thread that created the object. +/// +CEF_EXPORT cef_xml_reader_t* cef_xml_reader_create( + struct _cef_stream_reader_t* stream, + enum cef_xml_encoding_type_t encodingType, const cef_string_t* URI); + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_XML_READER_CAPI_H_ diff --git a/cef3/include/capi/cef_zip_reader_capi.h b/cef3/include/capi/cef_zip_reader_capi.h new file mode 100644 index 000000000..36c5be0de --- /dev/null +++ b/cef3/include/capi/cef_zip_reader_capi.h @@ -0,0 +1,148 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_ZIP_READER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_ZIP_READER_CAPI_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + + +/// +// Structure that supports the reading of zip archives via the zlib unzip API. +// The functions of this structure should only be called on the thread that +// creates the object. +/// +typedef struct _cef_zip_reader_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Moves the cursor to the first file in the archive. Returns true (1) if the + // cursor position was set successfully. + /// + int (CEF_CALLBACK *move_to_first_file)(struct _cef_zip_reader_t* self); + + /// + // Moves the cursor to the next file in the archive. Returns true (1) if the + // cursor position was set successfully. + /// + int (CEF_CALLBACK *move_to_next_file)(struct _cef_zip_reader_t* self); + + /// + // Moves the cursor to the specified file in the archive. If |caseSensitive| + // is true (1) then the search will be case sensitive. Returns true (1) if the + // cursor position was set successfully. + /// + int (CEF_CALLBACK *move_to_file)(struct _cef_zip_reader_t* self, + const cef_string_t* fileName, int caseSensitive); + + /// + // Closes the archive. This should be called directly to ensure that cleanup + // occurs on the correct thread. + /// + int (CEF_CALLBACK *close)(struct _cef_zip_reader_t* self); + + + // The below functions act on the file at the current cursor position. + + /// + // Returns the name of the file. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_file_name)( + struct _cef_zip_reader_t* self); + + /// + // Returns the uncompressed size of the file. + /// + int64 (CEF_CALLBACK *get_file_size)(struct _cef_zip_reader_t* self); + + /// + // Returns the last modified timestamp for the file. + /// + time_t (CEF_CALLBACK *get_file_last_modified)(struct _cef_zip_reader_t* self); + + /// + // Opens the file for reading of uncompressed data. A read password may + // optionally be specified. + /// + int (CEF_CALLBACK *open_file)(struct _cef_zip_reader_t* self, + const cef_string_t* password); + + /// + // Closes the file. + /// + int (CEF_CALLBACK *close_file)(struct _cef_zip_reader_t* self); + + /// + // Read uncompressed file contents into the specified buffer. Returns < 0 if + // an error occurred, 0 if at the end of file, or the number of bytes read. + /// + int (CEF_CALLBACK *read_file)(struct _cef_zip_reader_t* self, void* buffer, + size_t bufferSize); + + /// + // Returns the current offset in the uncompressed file contents. + /// + int64 (CEF_CALLBACK *tell)(struct _cef_zip_reader_t* self); + + /// + // Returns true (1) if at end of the file contents. + /// + int (CEF_CALLBACK *eof)(struct _cef_zip_reader_t* self); +} cef_zip_reader_t; + + +/// +// Create a new cef_zip_reader_t object. The returned object's functions can +// only be called from the thread that created the object. +/// +CEF_EXPORT cef_zip_reader_t* cef_zip_reader_create( + struct _cef_stream_reader_t* stream); + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_ZIP_READER_CAPI_H_ diff --git a/cef3/include/cef_app.h b/cef3/include/cef_app.h new file mode 100644 index 000000000..8cdae4f3f --- /dev/null +++ b/cef3/include/cef_app.h @@ -0,0 +1,175 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + + +#ifndef CEF_INCLUDE_CEF_APP_H_ +#define CEF_INCLUDE_CEF_APP_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser_process_handler.h" +#include "include/cef_command_line.h" +#include "include/cef_render_process_handler.h" +#include "include/cef_resource_bundle_handler.h" +#include "include/cef_scheme.h" + +class CefApp; + +/// +// This function should be called from the application entry point function to +// execute a secondary process. It can be used to run secondary processes from +// the browser client executable (default behavior) or from a separate +// executable specified by the CefSettings.browser_subprocess_path value. If +// called for the browser process (identified by no "type" command-line value) +// it will return immediately with a value of -1. If called for a recognized +// secondary process it will block until the process should exit and then return +// the process exit code. The |application| parameter may be empty. +/// +/*--cef(api_hash_check,optional_param=application)--*/ +int CefExecuteProcess(const CefMainArgs& args, CefRefPtr application); + +/// +// This function should be called on the main application thread to initialize +// the CEF browser process. The |application| parameter may be empty. A return +// value of true indicates that it succeeded and false indicates that it failed. +/// +/*--cef(api_hash_check,optional_param=application)--*/ +bool CefInitialize(const CefMainArgs& args, const CefSettings& settings, + CefRefPtr application); + +/// +// This function should be called on the main application thread to shut down +// the CEF browser process before the application exits. +/// +/*--cef()--*/ +void CefShutdown(); + +/// +// Perform a single iteration of CEF message loop processing. This function is +// used to integrate the CEF message loop into an existing application message +// loop. Care must be taken to balance performance against excessive CPU usage. +// This function should only be called on the main application thread and only +// if CefInitialize() is called with a CefSettings.multi_threaded_message_loop +// value of false. This function will not block. +/// +/*--cef()--*/ +void CefDoMessageLoopWork(); + +/// +// Run the CEF message loop. Use this function instead of an application- +// provided message loop to get the best balance between performance and CPU +// usage. This function should only be called on the main application thread and +// only if CefInitialize() is called with a +// CefSettings.multi_threaded_message_loop value of false. This function will +// block until a quit message is received by the system. +/// +/*--cef()--*/ +void CefRunMessageLoop(); + +/// +// Quit the CEF message loop that was started by calling CefRunMessageLoop(). +// This function should only be called on the main application thread and only +// if CefRunMessageLoop() was used. +/// +/*--cef()--*/ +void CefQuitMessageLoop(); + +/// +// Implement this interface to provide handler implementations. Methods will be +// called by the process and/or thread indicated. +/// +/*--cef(source=client,no_debugct_check)--*/ +class CefApp : public virtual CefBase { + public: + /// + // Provides an opportunity to view and/or modify command-line arguments before + // processing by CEF and Chromium. The |process_type| value will be empty for + // the browser process. Do not keep a reference to the CefCommandLine object + // passed to this method. The CefSettings.command_line_args_disabled value + // can be used to start with an empty command-line object. Any values + // specified in CefSettings that equate to command-line arguments will be set + // before this method is called. Be cautious when using this method to modify + // command-line arguments for non-browser processes as this may result in + // undefined behavior including crashes. + /// + /*--cef(optional_param=process_type)--*/ + virtual void OnBeforeCommandLineProcessing( + const CefString& process_type, + CefRefPtr command_line) { + } + + /// + // Provides an opportunity to register custom schemes. Do not keep a reference + // to the |registrar| object. This method is called on the main thread for + // each process and the registered schemes should be the same across all + // processes. + /// + /*--cef()--*/ + virtual void OnRegisterCustomSchemes( + CefRefPtr registrar) { + } + + /// + // Return the handler for resource bundle events. If + // CefSettings.pack_loading_disabled is true a handler must be returned. If no + // handler is returned resources will be loaded from pack files. This method + // is called by the browser and render processes on multiple threads. + /// + /*--cef()--*/ + virtual CefRefPtr GetResourceBundleHandler() { + return NULL; + } + + /// + // Return the handler for functionality specific to the browser process. This + // method is called on multiple threads in the browser process. + /// + /*--cef()--*/ + virtual CefRefPtr GetBrowserProcessHandler() { + return NULL; + } + + /// + // Return the handler for functionality specific to the render process. This + // method is called on the render process main thread. + /// + /*--cef()--*/ + virtual CefRefPtr GetRenderProcessHandler() { + return NULL; + } +}; + +#endif // CEF_INCLUDE_CEF_APP_H_ diff --git a/cef3/include/cef_application_mac.h b/cef3/include/cef_application_mac.h new file mode 100644 index 000000000..3a5126ef7 --- /dev/null +++ b/cef3/include/cef_application_mac.h @@ -0,0 +1,137 @@ +// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef CEF_INCLUDE_CEF_APPLICATION_MAC_H_ +#define CEF_INCLUDE_CEF_APPLICATION_MAC_H_ +#pragma once + +#include "include/cef_base.h" + +#if defined(OS_MACOSX) && defined(__OBJC__) + +#ifdef BUILDING_CEF_SHARED + +// Use the existing CrAppProtocol definition. +#import "base/message_pump_mac.h" + +// Use the existing CrAppControlProtocol definition. +#import "base/mac/scoped_sending_event.h" + +// Use the existing UnderlayableSurface definition. +#import "ui/base/cocoa/underlay_opengl_hosting_window.h" + +// Use the existing empty protocol definitions. +#import "base/mac/cocoa_protocols.h" + +#else // BUILDING_CEF_SHARED + +#import +#import + +// Copy of definition from base/message_pump_mac.h. +@protocol CrAppProtocol +// Must return true if -[NSApplication sendEvent:] is currently on the stack. +- (BOOL)isHandlingSendEvent; +@end + +// Copy of definition from base/mac/scoped_sending_event.h. +@protocol CrAppControlProtocol +- (void)setHandlingSendEvent:(BOOL)handlingSendEvent; +@end + +// Copy of definition from ui/base/cocoa/underlay_opengl_hosting_window.h. +// Common base class for windows that host a OpenGL surface that renders under +// the window. Contains methods relating to hole punching so that the OpenGL +// surface is visible through the window. +@interface UnderlayOpenGLHostingWindow : NSWindow +@end + +// The Mac OS X 10.6 SDK introduced new protocols used for delegates. These +// protocol defintions were not present in earlier releases of the Mac OS X +// SDK. In order to support building against the new SDK, which requires +// delegates to conform to these protocols, and earlier SDKs, which do not +// define these protocols at all, this file will provide empty protocol +// definitions when used with earlier SDK versions. + +#if !defined(MAC_OS_X_VERSION_10_6) || \ +MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 + +#define DEFINE_EMPTY_PROTOCOL(p) \ +@protocol p \ +@end + +DEFINE_EMPTY_PROTOCOL(NSAlertDelegate) +DEFINE_EMPTY_PROTOCOL(NSApplicationDelegate) +DEFINE_EMPTY_PROTOCOL(NSControlTextEditingDelegate) +DEFINE_EMPTY_PROTOCOL(NSMatrixDelegate) +DEFINE_EMPTY_PROTOCOL(NSMenuDelegate) +DEFINE_EMPTY_PROTOCOL(NSOpenSavePanelDelegate) +DEFINE_EMPTY_PROTOCOL(NSOutlineViewDataSource) +DEFINE_EMPTY_PROTOCOL(NSOutlineViewDelegate) +DEFINE_EMPTY_PROTOCOL(NSSpeechSynthesizerDelegate) +DEFINE_EMPTY_PROTOCOL(NSSplitViewDelegate) +DEFINE_EMPTY_PROTOCOL(NSTableViewDataSource) +DEFINE_EMPTY_PROTOCOL(NSTableViewDelegate) +DEFINE_EMPTY_PROTOCOL(NSTextFieldDelegate) +DEFINE_EMPTY_PROTOCOL(NSTextViewDelegate) +DEFINE_EMPTY_PROTOCOL(NSWindowDelegate) + +#undef DEFINE_EMPTY_PROTOCOL + +#endif + +#endif // BUILDING_CEF_SHARED + +// All CEF client applications must subclass NSApplication and implement this +// protocol. +@protocol CefAppProtocol +@end + +// Controls the state of |isHandlingSendEvent| in the event loop so that it is +// reset properly. +class CefScopedSendingEvent { + public: + CefScopedSendingEvent() + : app_(static_cast*>( + [NSApplication sharedApplication])), + handling_([app_ isHandlingSendEvent]) { + [app_ setHandlingSendEvent:YES]; + } + ~CefScopedSendingEvent() { + [app_ setHandlingSendEvent:handling_]; + } + + private: + NSApplication* app_; + BOOL handling_; +}; + +#endif // defined(OS_MACOSX) && defined(__OBJC__) + +#endif // CEF_INCLUDE_CEF_APPLICATION_MAC_H_ diff --git a/cef3/include/cef_base.h b/cef3/include/cef_base.h new file mode 100644 index 000000000..bc284f72e --- /dev/null +++ b/cef3/include/cef_base.h @@ -0,0 +1,154 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + + +#ifndef CEF_INCLUDE_CEF_BASE_H_ +#define CEF_INCLUDE_CEF_BASE_H_ +#pragma once + +#include "include/internal/cef_build.h" +#include "include/internal/cef_ptr.h" +#include "include/internal/cef_types_wrappers.h" + +// Bring in platform-specific definitions. +#if defined(OS_WIN) +#include "include/internal/cef_win.h" +#elif defined(OS_MACOSX) +#include "include/internal/cef_mac.h" +#elif defined(OS_LINUX) +#include "include/internal/cef_linux.h" +#endif + +/// +// Interface defining the reference count implementation methods. All framework +// classes must extend the CefBase class. +/// +class CefBase { + public: + /// + // The AddRef method increments the reference count for the object. It should + // be called for every new copy of a pointer to a given object. The resulting + // reference count value is returned and should be used for diagnostic/testing + // purposes only. + /// + virtual int AddRef() =0; + + /// + // The Release method decrements the reference count for the object. If the + // reference count on the object falls to 0, then the object should free + // itself from memory. The resulting reference count value is returned and + // should be used for diagnostic/testing purposes only. + /// + virtual int Release() =0; + + /// + // Return the current number of references. + /// + virtual int GetRefCt() =0; + + protected: + virtual ~CefBase() {} +}; + + +/// +// Class that implements atomic reference counting. +/// +class CefRefCount { + public: + CefRefCount() : refct_(0) {} + + /// + // Atomic reference increment. + /// + int AddRef() { + return CefAtomicIncrement(&refct_); + } + + /// + // Atomic reference decrement. Delete the object when no references remain. + /// + int Release() { + return CefAtomicDecrement(&refct_); + } + + /// + // Return the current number of references. + /// + int GetRefCt() { return refct_; } + + private: + long refct_; // NOLINT(runtime/int) +}; + +/// +// Macro that provides a reference counting implementation for classes extending +// CefBase. +/// +#define IMPLEMENT_REFCOUNTING(ClassName) \ + public: \ + int AddRef() { return refct_.AddRef(); } \ + int Release() { \ + int retval = refct_.Release(); \ + if (retval == 0) \ + delete this; \ + return retval; \ + } \ + int GetRefCt() { return refct_.GetRefCt(); } \ + private: \ + CefRefCount refct_; + +/// +// Macro that provides a locking implementation. Use the Lock() and Unlock() +// methods to protect a section of code from simultaneous access by multiple +// threads. The AutoLock class is a helper that will hold the lock while in +// scope. +/// +#define IMPLEMENT_LOCKING(ClassName) \ + public: \ + class AutoLock { \ + public: \ + explicit AutoLock(ClassName* base) : base_(base) { base_->Lock(); } \ + ~AutoLock() { base_->Unlock(); } \ + private: \ + ClassName* base_; \ + }; \ + void Lock() { critsec_.Lock(); } \ + void Unlock() { critsec_.Unlock(); } \ + private: \ + CefCriticalSection critsec_; + +#endif // CEF_INCLUDE_CEF_BASE_H_ diff --git a/cef3/include/cef_browser.h b/cef3/include/cef_browser.h new file mode 100644 index 000000000..51d37bdba --- /dev/null +++ b/cef3/include/cef_browser.h @@ -0,0 +1,446 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_BROWSER_H_ +#define CEF_INCLUDE_CEF_BROWSER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_frame.h" +#include "include/cef_process_message.h" +#include + +class CefBrowserHost; +class CefClient; + + +/// +// Class used to represent a browser window. When used in the browser process +// the methods of this class may be called on any thread unless otherwise +// indicated in the comments. When used in the render process the methods of +// this class may only be called on the main thread. +/// +/*--cef(source=library)--*/ +class CefBrowser : public virtual CefBase { + public: + /// + // Returns the browser host object. This method can only be called in the + // browser process. + /// + /*--cef()--*/ + virtual CefRefPtr GetHost() =0; + + /// + // Returns true if the browser can navigate backwards. + /// + /*--cef()--*/ + virtual bool CanGoBack() =0; + + /// + // Navigate backwards. + /// + /*--cef()--*/ + virtual void GoBack() =0; + + /// + // Returns true if the browser can navigate forwards. + /// + /*--cef()--*/ + virtual bool CanGoForward() =0; + + /// + // Navigate forwards. + /// + /*--cef()--*/ + virtual void GoForward() =0; + + /// + // Returns true if the browser is currently loading. + /// + /*--cef()--*/ + virtual bool IsLoading() =0; + + /// + // Reload the current page. + /// + /*--cef()--*/ + virtual void Reload() =0; + + /// + // Reload the current page ignoring any cached data. + /// + /*--cef()--*/ + virtual void ReloadIgnoreCache() =0; + + /// + // Stop loading the page. + /// + /*--cef()--*/ + virtual void StopLoad() =0; + + /// + // Returns the globally unique identifier for this browser. + /// + /*--cef()--*/ + virtual int GetIdentifier() =0; + + /// + // Returns true if this object is pointing to the same handle as |that| + // object. + /// + /*--cef()--*/ + virtual bool IsSame(CefRefPtr that) =0; + + /// + // Returns true if the window is a popup window. + /// + /*--cef()--*/ + virtual bool IsPopup() =0; + + /// + // Returns true if a document has been loaded in the browser. + /// + /*--cef()--*/ + virtual bool HasDocument() =0; + + /// + // Returns the main (top-level) frame for the browser window. + /// + /*--cef()--*/ + virtual CefRefPtr GetMainFrame() =0; + + /// + // Returns the focused frame for the browser window. + /// + /*--cef()--*/ + virtual CefRefPtr GetFocusedFrame() =0; + + /// + // Returns the frame with the specified identifier, or NULL if not found. + /// + /*--cef(capi_name=get_frame_byident)--*/ + virtual CefRefPtr GetFrame(int64 identifier) =0; + + /// + // Returns the frame with the specified name, or NULL if not found. + /// + /*--cef()--*/ + virtual CefRefPtr GetFrame(const CefString& name) =0; + + /// + // Returns the number of frames that currently exist. + /// + /*--cef()--*/ + virtual size_t GetFrameCount() =0; + + /// + // Returns the identifiers of all existing frames. + /// + /*--cef(count_func=identifiers:GetFrameCount)--*/ + virtual void GetFrameIdentifiers(std::vector& identifiers) =0; + + /// + // Returns the names of all existing frames. + /// + /*--cef()--*/ + virtual void GetFrameNames(std::vector& names) =0; + + // + // Send a message to the specified |target_process|. Returns true if the + // message was sent successfully. + /// + /*--cef()--*/ + virtual bool SendProcessMessage(CefProcessId target_process, + CefRefPtr message) =0; +}; + + +/// +// Callback interface for CefBrowserHost::RunFileDialog. The methods of this +// class will be called on the browser process UI thread. +/// +/*--cef(source=client)--*/ +class CefRunFileDialogCallback : public virtual CefBase { + public: + /// + // Called asynchronously after the file dialog is dismissed. If the selection + // was successful |file_paths| will be a single value or a list of values + // depending on the dialog mode. If the selection was cancelled |file_paths| + // will be empty. + /// + /*--cef(capi_name=cont)--*/ + virtual void OnFileDialogDismissed( + CefRefPtr browser_host, + const std::vector& file_paths) =0; +}; + + +/// +// Class used to represent the browser process aspects of a browser window. The +// methods of this class can only be called in the browser process. They may be +// called on any thread in that process unless otherwise indicated in the +// comments. +/// +/*--cef(source=library)--*/ +class CefBrowserHost : public virtual CefBase { + public: + typedef cef_file_dialog_mode_t FileDialogMode; + typedef cef_mouse_button_type_t MouseButtonType; + typedef cef_paint_element_type_t PaintElementType; + + /// + // Create a new browser window using the window parameters specified by + // |windowInfo|. All values will be copied internally and the actual window + // will be created on the UI thread. This method can be called on any browser + // process thread and will not block. + /// + /*--cef(optional_param=client,optional_param=url)--*/ + static bool CreateBrowser(const CefWindowInfo& windowInfo, + CefRefPtr client, + const CefString& url, + const CefBrowserSettings& settings); + + /// + // Create a new browser window using the window parameters specified by + // |windowInfo|. This method can only be called on the browser process UI + // thread. + /// + /*--cef(optional_param=client,optional_param=url)--*/ + static CefRefPtr CreateBrowserSync( + const CefWindowInfo& windowInfo, + CefRefPtr client, + const CefString& url, + const CefBrowserSettings& settings); + + /// + // Returns the hosted browser object. + /// + /*--cef()--*/ + virtual CefRefPtr GetBrowser() =0; + + /// + // Call this method before destroying a contained browser window. This method + // performs any internal cleanup that may be needed before the browser window + // is destroyed. See CefLifeSpanHandler::DoClose() documentation for + // additional usage information. + /// + /*--cef()--*/ + virtual void ParentWindowWillClose() =0; + + /// + // Request that the browser close. The JavaScript 'onbeforeunload' event will + // be fired. If |force_close| is false the event handler, if any, will be + // allowed to prompt the user and the user can optionally cancel the close. + // If |force_close| is true the prompt will not be displayed and the close + // will proceed. Results in a call to CefLifeSpanHandler::DoClose() if the + // event handler allows the close or if |force_close| is true. See + // CefLifeSpanHandler::DoClose() documentation for additional usage + // information. + /// + /*--cef()--*/ + virtual void CloseBrowser(bool force_close) =0; + + /// + // Set focus for the browser window. If |enable| is true focus will be set to + // the window. Otherwise, focus will be removed. + /// + /*--cef()--*/ + virtual void SetFocus(bool enable) =0; + + /// + // Retrieve the window handle for this browser. + /// + /*--cef()--*/ + virtual CefWindowHandle GetWindowHandle() =0; + + /// + // Retrieve the window handle of the browser that opened this browser. Will + // return NULL for non-popup windows. This method can be used in combination + // with custom handling of modal windows. + /// + /*--cef()--*/ + virtual CefWindowHandle GetOpenerWindowHandle() =0; + + /// + // Returns the client for this browser. + /// + /*--cef()--*/ + virtual CefRefPtr GetClient() =0; + + /// + // Returns the DevTools URL for this browser. If |http_scheme| is true the + // returned URL will use the http scheme instead of the chrome-devtools + // scheme. Remote debugging can be enabled by specifying the + // "remote-debugging-port" command-line flag or by setting the + // CefSettings.remote_debugging_port value. If remote debugging is not enabled + // this method will return an empty string. + /// + /*--cef()--*/ + virtual CefString GetDevToolsURL(bool http_scheme) =0; + + /// + // Get the current zoom level. The default zoom level is 0.0. This method can + // only be called on the UI thread. + /// + /*--cef()--*/ + virtual double GetZoomLevel() =0; + + /// + // Change the zoom level to the specified value. Specify 0.0 to reset the + // zoom level. If called on the UI thread the change will be applied + // immediately. Otherwise, the change will be applied asynchronously on the + // UI thread. + /// + /*--cef()--*/ + virtual void SetZoomLevel(double zoomLevel) =0; + + /// + // Call to run a file chooser dialog. Only a single file chooser dialog may be + // pending at any given time. |mode| represents the type of dialog to display. + // |title| to the title to be used for the dialog and may be empty to show the + // default title ("Open" or "Save" depending on the mode). |default_file_name| + // is the default file name to select in the dialog. |accept_types| is a list + // of valid lower-cased MIME types or file extensions specified in an input + // element and is used to restrict selectable files to such types. |callback| + // will be executed after the dialog is dismissed or immediately if another + // dialog is already pending. The dialog will be initiated asynchronously on + // the UI thread. + /// + /*--cef(optional_param=title,optional_param=default_file_name, + optional_param=accept_types)--*/ + virtual void RunFileDialog(FileDialogMode mode, + const CefString& title, + const CefString& default_file_name, + const std::vector& accept_types, + CefRefPtr callback) =0; + + /// + // Download the file at |url| using CefDownloadHandler. + /// + /*--cef()--*/ + virtual void StartDownload(const CefString& url) =0; + + /// + // Set whether mouse cursor change is disabled. + /// + /*--cef()--*/ + virtual void SetMouseCursorChangeDisabled(bool disabled) =0; + + /// + // Returns true if mouse cursor change is disabled. + /// + /*--cef()--*/ + virtual bool IsMouseCursorChangeDisabled() =0; + + /// + // Returns true if window rendering is disabled. + /// + /*--cef()--*/ + virtual bool IsWindowRenderingDisabled() =0; + + /// + // Notify the browser that the widget has been resized. The browser will first + // call CefRenderHandler::GetViewRect to get the new size and then call + // CefRenderHandler::OnPaint asynchronously with the updated regions. This + // method is only used when window rendering is disabled. + /// + /*--cef()--*/ + virtual void WasResized() =0; + + /// + // Notify the browser that it has been hidden or shown. Layouting and + // CefRenderHandler::OnPaint notification will stop when the browser is + // hidden. This method is only used when window rendering is disabled. + /// + /*--cef()--*/ + virtual void WasHidden(bool hidden) =0; + + /// + // Invalidate the |dirtyRect| region of the view. The browser will call + // CefRenderHandler::OnPaint asynchronously with the updated regions. This + // method is only used when window rendering is disabled. + /// + /*--cef()--*/ + virtual void Invalidate(const CefRect& dirtyRect, PaintElementType type) =0; + + /// + // Send a key event to the browser. + /// + /*--cef()--*/ + virtual void SendKeyEvent(const CefKeyEvent& event) =0; + + /// + // Send a mouse click event to the browser. The |x| and |y| coordinates are + // relative to the upper-left corner of the view. + /// + /*--cef()--*/ + virtual void SendMouseClickEvent(const CefMouseEvent& event, + MouseButtonType type, + bool mouseUp, int clickCount) =0; + + /// + // Send a mouse move event to the browser. The |x| and |y| coordinates are + // relative to the upper-left corner of the view. + /// + /*--cef()--*/ + virtual void SendMouseMoveEvent(const CefMouseEvent& event, + bool mouseLeave) =0; + + /// + // Send a mouse wheel event to the browser. The |x| and |y| coordinates are + // relative to the upper-left corner of the view. The |deltaX| and |deltaY| + // values represent the movement delta in the X and Y directions respectively. + // In order to scroll inside select popups with window rendering disabled + // CefRenderHandler::GetScreenPoint should be implemented properly. + /// + /*--cef()--*/ + virtual void SendMouseWheelEvent(const CefMouseEvent& event, + int deltaX, int deltaY) =0; + + /// + // Send a focus event to the browser. + /// + /*--cef()--*/ + virtual void SendFocusEvent(bool setFocus) =0; + + /// + // Send a capture lost event to the browser. + /// + /*--cef()--*/ + virtual void SendCaptureLostEvent() =0; +}; + +#endif // CEF_INCLUDE_CEF_BROWSER_H_ diff --git a/cef3/include/cef_browser_process_handler.h b/cef3/include/cef_browser_process_handler.h new file mode 100644 index 000000000..66cc28621 --- /dev/null +++ b/cef3/include/cef_browser_process_handler.h @@ -0,0 +1,82 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_BROWSER_PROCESS_HANDLER_H_ +#define CEF_INCLUDE_CEF_BROWSER_PROCESS_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_command_line.h" +#include "include/cef_values.h" + +/// +// Class used to implement browser process callbacks. The methods of this class +// will be called on the browser process main thread unless otherwise indicated. +/// +/*--cef(source=client)--*/ +class CefBrowserProcessHandler : public virtual CefBase { + public: + /// + // Called on the browser process UI thread immediately after the CEF context + // has been initialized. + /// + /*--cef()--*/ + virtual void OnContextInitialized() {} + + /// + // Called before a child process is launched. Will be called on the browser + // process UI thread when launching a render process and on the browser + // process IO thread when launching a GPU or plugin process. Provides an + // opportunity to modify the child process command line. Do not keep a + // reference to |command_line| outside of this method. + /// + /*--cef()--*/ + virtual void OnBeforeChildProcessLaunch( + CefRefPtr command_line) {} + + /// + // Called on the browser process IO thread after the main thread has been + // created for a new render process. Provides an opportunity to specify extra + // information that will be passed to + // CefRenderProcessHandler::OnRenderThreadCreated() in the render process. Do + // not keep a reference to |extra_info| outside of this method. + /// + /*--cef()--*/ + virtual void OnRenderProcessThreadCreated( + CefRefPtr extra_info) {} +}; + +#endif // CEF_INCLUDE_CEF_BROWSER_PROCESS_HANDLER_H_ diff --git a/cef3/include/cef_callback.h b/cef3/include/cef_callback.h new file mode 100644 index 000000000..9b4e5321e --- /dev/null +++ b/cef3/include/cef_callback.h @@ -0,0 +1,75 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_CALLBACK_H_ +#define CEF_INCLUDE_CEF_CALLBACK_H_ +#pragma once + +#include "include/cef_base.h" + +/// +// Generic callback interface used for asynchronous continuation. +/// +/*--cef(source=library)--*/ +class CefCallback : public virtual CefBase { + public: + /// + // Continue processing. + /// + /*--cef(capi_name=cont)--*/ + virtual void Continue() =0; + + /// + // Cancel processing. + /// + /*--cef()--*/ + virtual void Cancel() =0; +}; + +/// +// Generic callback interface used for asynchronous completion. +/// +/*--cef(source=client)--*/ +class CefCompletionHandler : public virtual CefBase { + public: + /// + // Method that will be called once the task is complete. + /// + /*--cef()--*/ + virtual void OnComplete() =0; +}; + +#endif // CEF_INCLUDE_CEF_CALLBACK_H_ diff --git a/cef3/include/cef_client.h b/cef3/include/cef_client.h new file mode 100644 index 000000000..dbba43927 --- /dev/null +++ b/cef3/include/cef_client.h @@ -0,0 +1,176 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_CLIENT_H_ +#define CEF_INCLUDE_CEF_CLIENT_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_context_menu_handler.h" +#include "include/cef_dialog_handler.h" +#include "include/cef_display_handler.h" +#include "include/cef_download_handler.h" +#include "include/cef_focus_handler.h" +#include "include/cef_geolocation_handler.h" +#include "include/cef_jsdialog_handler.h" +#include "include/cef_keyboard_handler.h" +#include "include/cef_life_span_handler.h" +#include "include/cef_load_handler.h" +#include "include/cef_process_message.h" +#include "include/cef_render_handler.h" +#include "include/cef_request_handler.h" + +/// +// Implement this interface to provide handler implementations. +/// +/*--cef(source=client,no_debugct_check)--*/ +class CefClient : public virtual CefBase { + public: + /// + // Return the handler for context menus. If no handler is provided the default + // implementation will be used. + /// + /*--cef()--*/ + virtual CefRefPtr GetContextMenuHandler() { + return NULL; + } + + /// + // Return the handler for dialogs. If no handler is provided the default + // implementation will be used. + /// + /*--cef()--*/ + virtual CefRefPtr GetDialogHandler() { + return NULL; + } + + /// + // Return the handler for browser display state events. + /// + /*--cef()--*/ + virtual CefRefPtr GetDisplayHandler() { + return NULL; + } + + /// + // Return the handler for download events. If no handler is returned downloads + // will not be allowed. + /// + /*--cef()--*/ + virtual CefRefPtr GetDownloadHandler() { + return NULL; + } + + /// + // Return the handler for focus events. + /// + /*--cef()--*/ + virtual CefRefPtr GetFocusHandler() { + return NULL; + } + + /// + // Return the handler for geolocation permissions requests. If no handler is + // provided geolocation access will be denied by default. + /// + /*--cef()--*/ + virtual CefRefPtr GetGeolocationHandler() { + return NULL; + } + + /// + // Return the handler for JavaScript dialogs. If no handler is provided the + // default implementation will be used. + /// + /*--cef()--*/ + virtual CefRefPtr GetJSDialogHandler() { + return NULL; + } + + /// + // Return the handler for keyboard events. + /// + /*--cef()--*/ + virtual CefRefPtr GetKeyboardHandler() { + return NULL; + } + + /// + // Return the handler for browser life span events. + /// + /*--cef()--*/ + virtual CefRefPtr GetLifeSpanHandler() { + return NULL; + } + + /// + // Return the handler for browser load status events. + /// + /*--cef()--*/ + virtual CefRefPtr GetLoadHandler() { + return NULL; + } + + /// + // Return the handler for off-screen rendering events. + /// + /*--cef()--*/ + virtual CefRefPtr GetRenderHandler() { + return NULL; + } + + /// + // Return the handler for browser request events. + /// + /*--cef()--*/ + virtual CefRefPtr GetRequestHandler() { + return NULL; + } + + /// + // Called when a new message is received from a different process. Return true + // if the message was handled or false otherwise. Do not keep a reference to + // or attempt to access the message outside of this callback. + /// + /*--cef()--*/ + virtual bool OnProcessMessageReceived(CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) { + return false; + } +}; + +#endif // CEF_INCLUDE_CEF_CLIENT_H_ diff --git a/cef3/include/cef_command_line.h b/cef3/include/cef_command_line.h new file mode 100644 index 000000000..96241cf43 --- /dev/null +++ b/cef3/include/cef_command_line.h @@ -0,0 +1,208 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_COMMAND_LINE_H_ +#define CEF_INCLUDE_CEF_COMMAND_LINE_H_ +#pragma once + +#include "include/cef_base.h" +#include +#include + +/// +// Class used to create and/or parse command line arguments. Arguments with +// '--', '-' and, on Windows, '/' prefixes are considered switches. Switches +// will always precede any arguments without switch prefixes. Switches can +// optionally have a value specified using the '=' delimiter (e.g. +// "-switch=value"). An argument of "--" will terminate switch parsing with all +// subsequent tokens, regardless of prefix, being interpreted as non-switch +// arguments. Switch names are considered case-insensitive. This class can be +// used before CefInitialize() is called. +/// +/*--cef(source=library,no_debugct_check)--*/ +class CefCommandLine : public virtual CefBase { + public: + typedef std::vector ArgumentList; + typedef std::map SwitchMap; + + /// + // Create a new CefCommandLine instance. + /// + /*--cef(api_hash_check)--*/ + static CefRefPtr CreateCommandLine(); + + /// + // Returns the singleton global CefCommandLine object. The returned object + // will be read-only. + /// + /*--cef(api_hash_check)--*/ + static CefRefPtr GetGlobalCommandLine(); + + /// + // Returns true if this object is valid. Do not call any other methods if this + // function returns false. + /// + /*--cef()--*/ + virtual bool IsValid() =0; + + /// + // Returns true if the values of this object are read-only. Some APIs may + // expose read-only objects. + /// + /*--cef()--*/ + virtual bool IsReadOnly() =0; + + /// + // Returns a writable copy of this object. + /// + /*--cef()--*/ + virtual CefRefPtr Copy() =0; + + /// + // Initialize the command line with the specified |argc| and |argv| values. + // The first argument must be the name of the program. This method is only + // supported on non-Windows platforms. + /// + /*--cef()--*/ + virtual void InitFromArgv(int argc, const char* const* argv) =0; + + /// + // Initialize the command line with the string returned by calling + // GetCommandLineW(). This method is only supported on Windows. + /// + /*--cef()--*/ + virtual void InitFromString(const CefString& command_line) =0; + + /// + // Reset the command-line switches and arguments but leave the program + // component unchanged. + /// + /*--cef()--*/ + virtual void Reset() =0; + + /// + // Retrieve the original command line string as a vector of strings. + // The argv array: { program, [(--|-|/)switch[=value]]*, [--], [argument]* } + /// + /*--cef()--*/ + virtual void GetArgv(std::vector& argv) =0; + + /// + // Constructs and returns the represented command line string. Use this method + // cautiously because quoting behavior is unclear. + /// + /*--cef()--*/ + virtual CefString GetCommandLineString() =0; + + /// + // Get the program part of the command line string (the first item). + /// + /*--cef()--*/ + virtual CefString GetProgram() =0; + + /// + // Set the program part of the command line string (the first item). + /// + /*--cef()--*/ + virtual void SetProgram(const CefString& program) =0; + + /// + // Returns true if the command line has switches. + /// + /*--cef()--*/ + virtual bool HasSwitches() =0; + + /// + // Returns true if the command line contains the given switch. + /// + /*--cef()--*/ + virtual bool HasSwitch(const CefString& name) =0; + + /// + // Returns the value associated with the given switch. If the switch has no + // value or isn't present this method returns the empty string. + /// + /*--cef()--*/ + virtual CefString GetSwitchValue(const CefString& name) =0; + + /// + // Returns the map of switch names and values. If a switch has no value an + // empty string is returned. + /// + /*--cef()--*/ + virtual void GetSwitches(SwitchMap& switches) =0; + + /// + // Add a switch to the end of the command line. If the switch has no value + // pass an empty value string. + /// + /*--cef()--*/ + virtual void AppendSwitch(const CefString& name) =0; + + /// + // Add a switch with the specified value to the end of the command line. + /// + /*--cef()--*/ + virtual void AppendSwitchWithValue(const CefString& name, + const CefString& value) =0; + + /// + // True if there are remaining command line arguments. + /// + /*--cef()--*/ + virtual bool HasArguments() =0; + + /// + // Get the remaining command line arguments. + /// + /*--cef()--*/ + virtual void GetArguments(ArgumentList& arguments) =0; + + /// + // Add an argument to the end of the command line. + /// + /*--cef()--*/ + virtual void AppendArgument(const CefString& argument) =0; + + /// + // Insert a command before the current command. + // Common for debuggers, like "valgrind" or "gdb --args". + /// + /*--cef()--*/ + virtual void PrependWrapper(const CefString& wrapper) =0; +}; + +#endif // CEF_INCLUDE_CEF_COMMAND_LINE_H_ diff --git a/cef3/include/cef_context_menu_handler.h b/cef3/include/cef_context_menu_handler.h new file mode 100644 index 000000000..e3e983ad5 --- /dev/null +++ b/cef3/include/cef_context_menu_handler.h @@ -0,0 +1,216 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_CONTEXT_MENU_HANDLER_H_ +#define CEF_INCLUDE_CEF_CONTEXT_MENU_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser.h" +#include "include/cef_frame.h" +#include "include/cef_menu_model.h" + +class CefContextMenuParams; + +/// +// Implement this interface to handle context menu events. The methods of this +// class will be called on the UI thread. +/// +/*--cef(source=client)--*/ +class CefContextMenuHandler : public virtual CefBase { + public: + typedef cef_event_flags_t EventFlags; + + /// + // Called before a context menu is displayed. |params| provides information + // about the context menu state. |model| initially contains the default + // context menu. The |model| can be cleared to show no context menu or + // modified to show a custom menu. Do not keep references to |params| or + // |model| outside of this callback. + /// + /*--cef()--*/ + virtual void OnBeforeContextMenu(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr params, + CefRefPtr model) {} + + /// + // Called to execute a command selected from the context menu. Return true if + // the command was handled or false for the default implementation. See + // cef_menu_id_t for the command ids that have default implementations. All + // user-defined command ids should be between MENU_ID_USER_FIRST and + // MENU_ID_USER_LAST. |params| will have the same values as what was passed to + // OnBeforeContextMenu(). Do not keep a reference to |params| outside of this + // callback. + /// + /*--cef()--*/ + virtual bool OnContextMenuCommand(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr params, + int command_id, + EventFlags event_flags) { return false; } + + /// + // Called when the context menu is dismissed irregardless of whether the menu + // was empty or a command was selected. + /// + /*--cef()--*/ + virtual void OnContextMenuDismissed(CefRefPtr browser, + CefRefPtr frame) {} +}; + + +/// +// Provides information about the context menu state. The ethods of this class +// can only be accessed on browser process the UI thread. +/// +/*--cef(source=library)--*/ +class CefContextMenuParams : public virtual CefBase { + public: + typedef cef_context_menu_type_flags_t TypeFlags; + typedef cef_context_menu_media_type_t MediaType; + typedef cef_context_menu_media_state_flags_t MediaStateFlags; + typedef cef_context_menu_edit_state_flags_t EditStateFlags; + + /// + // Returns the X coordinate of the mouse where the context menu was invoked. + // Coords are relative to the associated RenderView's origin. + /// + /*--cef()--*/ + virtual int GetXCoord() =0; + + /// + // Returns the Y coordinate of the mouse where the context menu was invoked. + // Coords are relative to the associated RenderView's origin. + /// + /*--cef()--*/ + virtual int GetYCoord() =0; + + /// + // Returns flags representing the type of node that the context menu was + // invoked on. + /// + /*--cef(default_retval=CM_TYPEFLAG_NONE)--*/ + virtual TypeFlags GetTypeFlags() =0; + + /// + // Returns the URL of the link, if any, that encloses the node that the + // context menu was invoked on. + /// + /*--cef()--*/ + virtual CefString GetLinkUrl() =0; + + /// + // Returns the link URL, if any, to be used ONLY for "copy link address". We + // don't validate this field in the frontend process. + /// + /*--cef()--*/ + virtual CefString GetUnfilteredLinkUrl() =0; + + /// + // Returns the source URL, if any, for the element that the context menu was + // invoked on. Example of elements with source URLs are img, audio, and video. + /// + /*--cef()--*/ + virtual CefString GetSourceUrl() =0; + + /// + // Returns true if the context menu was invoked on a blocked image. + /// + /*--cef()--*/ + virtual bool IsImageBlocked() =0; + + /// + // Returns the URL of the top level page that the context menu was invoked on. + /// + /*--cef()--*/ + virtual CefString GetPageUrl() =0; + + /// + // Returns the URL of the subframe that the context menu was invoked on. + /// + /*--cef()--*/ + virtual CefString GetFrameUrl() =0; + + /// + // Returns the character encoding of the subframe that the context menu was + // invoked on. + /// + /*--cef()--*/ + virtual CefString GetFrameCharset() =0; + + /// + // Returns the type of context node that the context menu was invoked on. + /// + /*--cef(default_retval=CM_MEDIATYPE_NONE)--*/ + virtual MediaType GetMediaType() =0; + + /// + // Returns flags representing the actions supported by the media element, if + // any, that the context menu was invoked on. + /// + /*--cef(default_retval=CM_MEDIAFLAG_NONE)--*/ + virtual MediaStateFlags GetMediaStateFlags() =0; + + /// + // Returns the text of the selection, if any, that the context menu was + // invoked on. + /// + /*--cef()--*/ + virtual CefString GetSelectionText() =0; + + /// + // Returns true if the context menu was invoked on an editable node. + /// + /*--cef()--*/ + virtual bool IsEditable() =0; + + /// + // Returns true if the context menu was invoked on an editable node where + // speech-input is enabled. + /// + /*--cef()--*/ + virtual bool IsSpeechInputEnabled() =0; + + /// + // Returns flags representing the actions supported by the editable node, if + // any, that the context menu was invoked on. + /// + /*--cef(default_retval=CM_EDITFLAG_NONE)--*/ + virtual EditStateFlags GetEditStateFlags() =0; +}; + +#endif // CEF_INCLUDE_CEF_CONTEXT_MENU_HANDLER_H_ diff --git a/cef3/include/cef_cookie.h b/cef3/include/cef_cookie.h new file mode 100644 index 000000000..8a7267d56 --- /dev/null +++ b/cef3/include/cef_cookie.h @@ -0,0 +1,166 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_COOKIE_H_ +#define CEF_INCLUDE_CEF_COOKIE_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_callback.h" +#include + +class CefCookieVisitor; + + +/// +// Class used for managing cookies. The methods of this class may be called on +// any thread unless otherwise indicated. +/// +/*--cef(source=library)--*/ +class CefCookieManager : public virtual CefBase { + public: + /// + // Returns the global cookie manager. By default data will be stored at + // CefSettings.cache_path if specified or in memory otherwise. + /// + /*--cef()--*/ + static CefRefPtr GetGlobalManager(); + + /// + // Creates a new cookie manager. If |path| is empty data will be stored in + // memory only. Otherwise, data will be stored at the specified |path|. To + // persist session cookies (cookies without an expiry date or validity + // interval) set |persist_session_cookies| to true. Session cookies are + // generally intended to be transient and most Web browsers do not persist + // them. Returns NULL if creation fails. + /// + /*--cef(optional_param=path)--*/ + static CefRefPtr CreateManager( + const CefString& path, + bool persist_session_cookies); + + /// + // Set the schemes supported by this manager. By default only "http" and + // "https" schemes are supported. Must be called before any cookies are + // accessed. + /// + /*--cef()--*/ + virtual void SetSupportedSchemes(const std::vector& schemes) =0; + + /// + // Visit all cookies. The returned cookies are ordered by longest path, then + // by earliest creation date. Returns false if cookies cannot be accessed. + /// + /*--cef()--*/ + virtual bool VisitAllCookies(CefRefPtr visitor) =0; + + /// + // Visit a subset of cookies. The results are filtered by the given url + // scheme, host, domain and path. If |includeHttpOnly| is true HTTP-only + // cookies will also be included in the results. The returned cookies are + // ordered by longest path, then by earliest creation date. Returns false if + // cookies cannot be accessed. + /// + /*--cef()--*/ + virtual bool VisitUrlCookies(const CefString& url, bool includeHttpOnly, + CefRefPtr visitor) =0; + + /// + // Sets a cookie given a valid URL and explicit user-provided cookie + // attributes. This function expects each attribute to be well-formed. It will + // check for disallowed characters (e.g. the ';' character is disallowed + // within the cookie value attribute) and will return false without setting + // the cookie if such characters are found. This method must be called on the + // IO thread. + /// + /*--cef()--*/ + virtual bool SetCookie(const CefString& url, const CefCookie& cookie) =0; + + /// + // Delete all cookies that match the specified parameters. If both |url| and + // values |cookie_name| are specified all host and domain cookies matching + // both will be deleted. If only |url| is specified all host cookies (but not + // domain cookies) irrespective of path will be deleted. If |url| is empty all + // cookies for all hosts and domains will be deleted. Returns false if a non- + // empty invalid URL is specified or if cookies cannot be accessed. This + // method must be called on the IO thread. + /// + /*--cef(optional_param=url,optional_param=cookie_name)--*/ + virtual bool DeleteCookies(const CefString& url, + const CefString& cookie_name) =0; + + /// + // Sets the directory path that will be used for storing cookie data. If + // |path| is empty data will be stored in memory only. Otherwise, data will be + // stored at the specified |path|. To persist session cookies (cookies without + // an expiry date or validity interval) set |persist_session_cookies| to true. + // Session cookies are generally intended to be transient and most Web browsers + // do not persist them. Returns false if cookies cannot be accessed. + /// + /*--cef(optional_param=path)--*/ + virtual bool SetStoragePath(const CefString& path, + bool persist_session_cookies) =0; + + /// + // Flush the backing store (if any) to disk and execute the specified + // |handler| on the IO thread when done. Returns false if cookies cannot be + // accessed. + /// + /*--cef(optional_param=handler)--*/ + virtual bool FlushStore(CefRefPtr handler) =0; +}; + + +/// +// Interface to implement for visiting cookie values. The methods of this class +// will always be called on the IO thread. +/// +/*--cef(source=client)--*/ +class CefCookieVisitor : public virtual CefBase { + public: + /// + // Method that will be called once for each cookie. |count| is the 0-based + // index for the current cookie. |total| is the total number of cookies. + // Set |deleteCookie| to true to delete the cookie currently being visited. + // Return false to stop visiting cookies. This method may never be called if + // no cookies are found. + /// + /*--cef()--*/ + virtual bool Visit(const CefCookie& cookie, int count, int total, + bool& deleteCookie) =0; +}; + +#endif // CEF_INCLUDE_CEF_COOKIE_H_ diff --git a/cef3/include/cef_dialog_handler.h b/cef3/include/cef_dialog_handler.h new file mode 100644 index 000000000..83e1048a4 --- /dev/null +++ b/cef3/include/cef_dialog_handler.h @@ -0,0 +1,98 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_DIALOG_HANDLER_H_ +#define CEF_INCLUDE_CEF_DIALOG_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser.h" + +/// +// Callback interface for asynchronous continuation of file dialog requests. +/// +/*--cef(source=library)--*/ +class CefFileDialogCallback : public virtual CefBase { + public: + /// + // Continue the file selection with the specified |file_paths|. This may be + // a single value or a list of values depending on the dialog mode. An empty + // value is treated the same as calling Cancel(). + /// + /*--cef(capi_name=cont)--*/ + virtual void Continue(const std::vector& file_paths) =0; + + /// + // Cancel the file selection. + /// + /*--cef()--*/ + virtual void Cancel() =0; +}; + + +/// +// Implement this interface to handle dialog events. The methods of this class +// will be called on the browser process UI thread. +/// +/*--cef(source=client)--*/ +class CefDialogHandler : public virtual CefBase { + public: + typedef cef_file_dialog_mode_t FileDialogMode; + + /// + // Called to run a file chooser dialog. |mode| represents the type of dialog + // to display. |title| to the title to be used for the dialog and may be empty + // to show the default title ("Open" or "Save" depending on the mode). + // |default_file_name| is the default file name to select in the dialog. + // |accept_types| is a list of valid lower-cased MIME types or file extensions + // specified in an input element and is used to restrict selectable files to + // such types. To display a custom dialog return true and execute |callback| + // either inline or at a later time. To display the default dialog return + // false. + /// + /*--cef(optional_param=title,optional_param=default_file_name, + optional_param=accept_types)--*/ + virtual bool OnFileDialog(CefRefPtr browser, + FileDialogMode mode, + const CefString& title, + const CefString& default_file_name, + const std::vector& accept_types, + CefRefPtr callback) { + return false; + } +}; + +#endif // CEF_INCLUDE_CEF_DIALOG_HANDLER_H_ diff --git a/cef3/include/cef_display_handler.h b/cef3/include/cef_display_handler.h new file mode 100644 index 000000000..7c19081c2 --- /dev/null +++ b/cef3/include/cef_display_handler.h @@ -0,0 +1,108 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_DISPLAY_HANDLER_H_ +#define CEF_INCLUDE_CEF_DISPLAY_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser.h" +#include "include/cef_frame.h" + +/// +// Implement this interface to handle events related to browser display state. +// The methods of this class will be called on the UI thread. +/// +/*--cef(source=client)--*/ +class CefDisplayHandler : public virtual CefBase { + public: + /// + // Called when the loading state has changed. + /// + /*--cef()--*/ + virtual void OnLoadingStateChange(CefRefPtr browser, + bool isLoading, + bool canGoBack, + bool canGoForward) {} + + /// + // Called when a frame's address has changed. + /// + /*--cef()--*/ + virtual void OnAddressChange(CefRefPtr browser, + CefRefPtr frame, + const CefString& url) {} + + /// + // Called when the page title changes. + /// + /*--cef(optional_param=title)--*/ + virtual void OnTitleChange(CefRefPtr browser, + const CefString& title) {} + + /// + // Called when the browser is about to display a tooltip. |text| contains the + // text that will be displayed in the tooltip. To handle the display of the + // tooltip yourself return true. Otherwise, you can optionally modify |text| + // and then return false to allow the browser to display the tooltip. + // When window rendering is disabled the application is responsible for + // drawing tooltips and the return value is ignored. + /// + /*--cef(optional_param=text)--*/ + virtual bool OnTooltip(CefRefPtr browser, + CefString& text) { return false; } + + /// + // Called when the browser receives a status message. |text| contains the text + // that will be displayed in the status message and |type| indicates the + // status message type. + /// + /*--cef(optional_param=value)--*/ + virtual void OnStatusMessage(CefRefPtr browser, + const CefString& value) {} + + /// + // Called to display a console message. Return true to stop the message from + // being output to the console. + /// + /*--cef(optional_param=message,optional_param=source)--*/ + virtual bool OnConsoleMessage(CefRefPtr browser, + const CefString& message, + const CefString& source, + int line) { return false; } +}; + +#endif // CEF_INCLUDE_CEF_DISPLAY_HANDLER_H_ diff --git a/cef3/include/cef_dom.h b/cef3/include/cef_dom.h new file mode 100644 index 000000000..f155e2f31 --- /dev/null +++ b/cef3/include/cef_dom.h @@ -0,0 +1,435 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_DOM_H_ +#define CEF_INCLUDE_CEF_DOM_H_ +#pragma once + +#include "include/cef_base.h" +#include + +class CefDOMDocument; +class CefDOMEventListener; +class CefDOMNode; + +/// +// Interface to implement for visiting the DOM. The methods of this class will +// be called on the render process main thread. +/// +/*--cef(source=client)--*/ +class CefDOMVisitor : public virtual CefBase { + public: + /// + // Method executed for visiting the DOM. The document object passed to this + // method represents a snapshot of the DOM at the time this method is + // executed. DOM objects are only valid for the scope of this method. Do not + // keep references to or attempt to access any DOM objects outside the scope + // of this method. + /// + /*--cef()--*/ + virtual void Visit(CefRefPtr document) =0; +}; + + +/// +// Class used to represent a DOM document. The methods of this class should only +// be called on the render process main thread thread. +/// +/*--cef(source=library)--*/ +class CefDOMDocument : public virtual CefBase { + public: + typedef cef_dom_document_type_t Type; + + /// + // Returns the document type. + /// + /*--cef(default_retval=DOM_DOCUMENT_TYPE_UNKNOWN)--*/ + virtual Type GetType() =0; + + /// + // Returns the root document node. + /// + /*--cef()--*/ + virtual CefRefPtr GetDocument() =0; + + /// + // Returns the BODY node of an HTML document. + /// + /*--cef()--*/ + virtual CefRefPtr GetBody() =0; + + /// + // Returns the HEAD node of an HTML document. + /// + /*--cef()--*/ + virtual CefRefPtr GetHead() =0; + + /// + // Returns the title of an HTML document. + /// + /*--cef()--*/ + virtual CefString GetTitle() =0; + + /// + // Returns the document element with the specified ID value. + /// + /*--cef()--*/ + virtual CefRefPtr GetElementById(const CefString& id) =0; + + /// + // Returns the node that currently has keyboard focus. + /// + /*--cef()--*/ + virtual CefRefPtr GetFocusedNode() =0; + + /// + // Returns true if a portion of the document is selected. + /// + /*--cef()--*/ + virtual bool HasSelection() =0; + + /// + // Returns the selection start node. + /// + /*--cef()--*/ + virtual CefRefPtr GetSelectionStartNode() =0; + + /// + // Returns the selection offset within the start node. + /// + /*--cef()--*/ + virtual int GetSelectionStartOffset() =0; + + /// + // Returns the selection end node. + /// + /*--cef()--*/ + virtual CefRefPtr GetSelectionEndNode() =0; + + /// + // Returns the selection offset within the end node. + /// + /*--cef()--*/ + virtual int GetSelectionEndOffset() =0; + + /// + // Returns the contents of this selection as markup. + /// + /*--cef()--*/ + virtual CefString GetSelectionAsMarkup() =0; + + /// + // Returns the contents of this selection as text. + /// + /*--cef()--*/ + virtual CefString GetSelectionAsText() =0; + + /// + // Returns the base URL for the document. + /// + /*--cef()--*/ + virtual CefString GetBaseURL() =0; + + /// + // Returns a complete URL based on the document base URL and the specified + // partial URL. + /// + /*--cef()--*/ + virtual CefString GetCompleteURL(const CefString& partialURL) =0; +}; + + +/// +// Class used to represent a DOM node. The methods of this class should only be +// called on the render process main thread. +/// +/*--cef(source=library)--*/ +class CefDOMNode : public virtual CefBase { + public: + typedef std::map AttributeMap; + typedef cef_dom_node_type_t Type; + + /// + // Returns the type for this node. + /// + /*--cef(default_retval=DOM_NODE_TYPE_UNSUPPORTED)--*/ + virtual Type GetType() =0; + + /// + // Returns true if this is a text node. + /// + /*--cef()--*/ + virtual bool IsText() =0; + + /// + // Returns true if this is an element node. + /// + /*--cef()--*/ + virtual bool IsElement() =0; + + /// + // Returns true if this is an editable node. + /// + /*--cef()--*/ + virtual bool IsEditable() =0; + + /// + // Returns true if this is a form control element node. + /// + /*--cef()--*/ + virtual bool IsFormControlElement() =0; + + /// + // Returns the type of this form control element node. + /// + /*--cef()--*/ + virtual CefString GetFormControlElementType() =0; + + /// + // Returns true if this object is pointing to the same handle as |that| + // object. + /// + /*--cef()--*/ + virtual bool IsSame(CefRefPtr that) =0; + + /// + // Returns the name of this node. + /// + /*--cef()--*/ + virtual CefString GetName() =0; + + /// + // Returns the value of this node. + /// + /*--cef()--*/ + virtual CefString GetValue() =0; + + /// + // Set the value of this node. Returns true on success. + /// + /*--cef()--*/ + virtual bool SetValue(const CefString& value) =0; + + /// + // Returns the contents of this node as markup. + /// + /*--cef()--*/ + virtual CefString GetAsMarkup() =0; + + /// + // Returns the document associated with this node. + /// + /*--cef()--*/ + virtual CefRefPtr GetDocument() =0; + + /// + // Returns the parent node. + /// + /*--cef()--*/ + virtual CefRefPtr GetParent() =0; + + /// + // Returns the previous sibling node. + /// + /*--cef()--*/ + virtual CefRefPtr GetPreviousSibling() =0; + + /// + // Returns the next sibling node. + /// + /*--cef()--*/ + virtual CefRefPtr GetNextSibling() =0; + + /// + // Returns true if this node has child nodes. + /// + /*--cef()--*/ + virtual bool HasChildren() =0; + + /// + // Return the first child node. + /// + /*--cef()--*/ + virtual CefRefPtr GetFirstChild() =0; + + /// + // Returns the last child node. + /// + /*--cef()--*/ + virtual CefRefPtr GetLastChild() =0; + + /// + // Add an event listener to this node for the specified event type. If + // |useCapture| is true then this listener will be considered a capturing + // listener. Capturing listeners will recieve all events of the specified + // type before the events are dispatched to any other event targets beneath + // the current node in the tree. Events which are bubbling upwards through + // the tree will not trigger a capturing listener. Separate calls to this + // method can be used to register the same listener with and without capture. + // See WebCore/dom/EventNames.h for the list of supported event types. + /// + /*--cef()--*/ + virtual void AddEventListener(const CefString& eventType, + CefRefPtr listener, + bool useCapture) =0; + + + // The following methods are valid only for element nodes. + + /// + // Returns the tag name of this element. + /// + /*--cef()--*/ + virtual CefString GetElementTagName() =0; + + /// + // Returns true if this element has attributes. + /// + /*--cef()--*/ + virtual bool HasElementAttributes() =0; + + /// + // Returns true if this element has an attribute named |attrName|. + /// + /*--cef()--*/ + virtual bool HasElementAttribute(const CefString& attrName) =0; + + /// + // Returns the element attribute named |attrName|. + /// + /*--cef()--*/ + virtual CefString GetElementAttribute(const CefString& attrName) =0; + + /// + // Returns a map of all element attributes. + /// + /*--cef()--*/ + virtual void GetElementAttributes(AttributeMap& attrMap) =0; + + /// + // Set the value for the element attribute named |attrName|. Returns true on + // success. + /// + /*--cef()--*/ + virtual bool SetElementAttribute(const CefString& attrName, + const CefString& value) =0; + + /// + // Returns the inner text of the element. + /// + /*--cef()--*/ + virtual CefString GetElementInnerText() =0; +}; + + +/// +// Class used to represent a DOM event. The methods of this class should only +// be called on the render process main thread. +/// +/*--cef(source=library)--*/ +class CefDOMEvent : public virtual CefBase { + public: + typedef cef_dom_event_category_t Category; + typedef cef_dom_event_phase_t Phase; + + /// + // Returns the event type. + /// + /*--cef()--*/ + virtual CefString GetType() =0; + + /// + // Returns the event category. + /// + /*--cef(default_retval=DOM_EVENT_CATEGORY_UNKNOWN)--*/ + virtual Category GetCategory() =0; + + /// + // Returns the event processing phase. + /// + /*--cef(default_retval=DOM_EVENT_PHASE_UNKNOWN)--*/ + virtual Phase GetPhase() =0; + + /// + // Returns true if the event can bubble up the tree. + /// + /*--cef()--*/ + virtual bool CanBubble() =0; + + /// + // Returns true if the event can be canceled. + /// + /*--cef()--*/ + virtual bool CanCancel() =0; + + /// + // Returns the document associated with this event. + /// + /*--cef()--*/ + virtual CefRefPtr GetDocument() =0; + + /// + // Returns the target of the event. + /// + /*--cef()--*/ + virtual CefRefPtr GetTarget() =0; + + /// + // Returns the current target of the event. + /// + /*--cef()--*/ + virtual CefRefPtr GetCurrentTarget() =0; +}; + + +/// +// Interface to implement for handling DOM events. The methods of this class +// will be called on the render process main thread. +/// +/*--cef(source=client)--*/ +class CefDOMEventListener : public virtual CefBase { + public: + /// + // Called when an event is received. The event object passed to this method + // contains a snapshot of the DOM at the time this method is executed. DOM + // objects are only valid for the scope of this method. Do not keep references + // to or attempt to access any DOM objects outside the scope of this method. + /// + /*--cef()--*/ + virtual void HandleEvent(CefRefPtr event) =0; +}; + +#endif // CEF_INCLUDE_CEF_DOM_H_ diff --git a/cef3/include/cef_download_handler.h b/cef3/include/cef_download_handler.h new file mode 100644 index 000000000..f7c26b3cd --- /dev/null +++ b/cef3/include/cef_download_handler.h @@ -0,0 +1,112 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_DOWNLOAD_HANDLER_H_ +#define CEF_INCLUDE_CEF_DOWNLOAD_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser.h" +#include "include/cef_download_item.h" + + +/// +// Callback interface used to asynchronously continue a download. +/// +/*--cef(source=library)--*/ +class CefBeforeDownloadCallback : public virtual CefBase { + public: + /// + // Call to continue the download. Set |download_path| to the full file path + // for the download including the file name or leave blank to use the + // suggested name and the default temp directory. Set |show_dialog| to true + // if you do wish to show the default "Save As" dialog. + /// + /*--cef(capi_name=cont,optional_param=download_path)--*/ + virtual void Continue(const CefString& download_path, bool show_dialog) =0; +}; + + +/// +// Callback interface used to asynchronously cancel a download. +/// +/*--cef(source=library)--*/ +class CefDownloadItemCallback : public virtual CefBase { + public: + /// + // Call to cancel the download. + /// + /*--cef()--*/ + virtual void Cancel() =0; +}; + + +/// +// Class used to handle file downloads. The methods of this class will called +// on the browser process UI thread. +/// +/*--cef(source=client)--*/ +class CefDownloadHandler : public virtual CefBase { + public: + /// + // Called before a download begins. |suggested_name| is the suggested name for + // the download file. By default the download will be canceled. Execute + // |callback| either asynchronously or in this method to continue the download + // if desired. Do not keep a reference to |download_item| outside of this + // method. + /// + /*--cef()--*/ + virtual void OnBeforeDownload( + CefRefPtr browser, + CefRefPtr download_item, + const CefString& suggested_name, + CefRefPtr callback) =0; + + /// + // Called when a download's status or progress information has been updated. + // This may be called multiple times before and after OnBeforeDownload(). + // Execute |callback| either asynchronously or in this method to cancel the + // download if desired. Do not keep a reference to |download_item| outside of + // this method. + /// + /*--cef()--*/ + virtual void OnDownloadUpdated( + CefRefPtr browser, + CefRefPtr download_item, + CefRefPtr callback) {} +}; + +#endif // CEF_INCLUDE_CEF_DOWNLOAD_HANDLER_H_ diff --git a/cef3/include/cef_download_item.h b/cef3/include/cef_download_item.h new file mode 100644 index 000000000..55f7fce06 --- /dev/null +++ b/cef3/include/cef_download_item.h @@ -0,0 +1,148 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_DOWNLOAD_ITEM_H_ +#define CEF_INCLUDE_CEF_DOWNLOAD_ITEM_H_ +#pragma once + +#include "include/cef_base.h" + +/// +// Class used to represent a download item. +/// +/*--cef(source=library)--*/ +class CefDownloadItem : public virtual CefBase { + public: + /// + // Returns true if this object is valid. Do not call any other methods if this + // function returns false. + /// + /*--cef()--*/ + virtual bool IsValid() =0; + + /// + // Returns true if the download is in progress. + /// + /*--cef()--*/ + virtual bool IsInProgress() =0; + + /// + // Returns true if the download is complete. + /// + /*--cef()--*/ + virtual bool IsComplete() =0; + + /// + // Returns true if the download has been canceled or interrupted. + /// + /*--cef()--*/ + virtual bool IsCanceled() =0; + + /// + // Returns a simple speed estimate in bytes/s. + /// + /*--cef()--*/ + virtual int64 GetCurrentSpeed() =0; + + /// + // Returns the rough percent complete or -1 if the receive total size is + // unknown. + /// + /*--cef()--*/ + virtual int GetPercentComplete() =0; + + /// + // Returns the total number of bytes. + /// + /*--cef()--*/ + virtual int64 GetTotalBytes() =0; + + /// + // Returns the number of received bytes. + /// + /*--cef()--*/ + virtual int64 GetReceivedBytes() =0; + + /// + // Returns the time that the download started. + /// + /*--cef()--*/ + virtual CefTime GetStartTime() =0; + + /// + // Returns the time that the download ended. + /// + /*--cef()--*/ + virtual CefTime GetEndTime() =0; + + /// + // Returns the full path to the downloaded or downloading file. + /// + /*--cef()--*/ + virtual CefString GetFullPath() =0; + + /// + // Returns the unique identifier for this download. + /// + /*--cef()--*/ + virtual int32 GetId() =0; + + /// + // Returns the URL. + /// + /*--cef()--*/ + virtual CefString GetURL() =0; + + /// + // Returns the suggested file name. + /// + /*--cef()--*/ + virtual CefString GetSuggestedFileName() =0; + + /// + // Returns the content disposition. + /// + /*--cef()--*/ + virtual CefString GetContentDisposition() =0; + + /// + // Returns the mime type. + /// + /*--cef()--*/ + virtual CefString GetMimeType() =0; +}; + +#endif // CEF_INCLUDE_CEF_DOWNLOAD_ITEM_H_ diff --git a/cef3/include/cef_focus_handler.h b/cef3/include/cef_focus_handler.h new file mode 100644 index 000000000..1d91c42ab --- /dev/null +++ b/cef3/include/cef_focus_handler.h @@ -0,0 +1,81 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_FOCUS_HANDLER_H_ +#define CEF_INCLUDE_CEF_FOCUS_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser.h" +#include "include/cef_dom.h" +#include "include/cef_frame.h" + +/// +// Implement this interface to handle events related to focus. The methods of +// this class will be called on the UI thread. +/// +/*--cef(source=client)--*/ +class CefFocusHandler : public virtual CefBase { + public: + typedef cef_focus_source_t FocusSource; + + /// + // Called when the browser component is about to loose focus. For instance, if + // focus was on the last HTML element and the user pressed the TAB key. |next| + // will be true if the browser is giving focus to the next component and false + // if the browser is giving focus to the previous component. + /// + /*--cef()--*/ + virtual void OnTakeFocus(CefRefPtr browser, + bool next) {} + + /// + // Called when the browser component is requesting focus. |source| indicates + // where the focus request is originating from. Return false to allow the + // focus to be set or true to cancel setting the focus. + /// + /*--cef()--*/ + virtual bool OnSetFocus(CefRefPtr browser, + FocusSource source) { return false; } + + /// + // Called when the browser component has received focus. + /// + /*--cef()--*/ + virtual void OnGotFocus(CefRefPtr browser) {} +}; + +#endif // CEF_INCLUDE_CEF_FOCUS_HANDLER_H_ diff --git a/cef3/include/cef_frame.h b/cef3/include/cef_frame.h new file mode 100644 index 000000000..adba66f1e --- /dev/null +++ b/cef3/include/cef_frame.h @@ -0,0 +1,224 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_FRAME_H_ +#define CEF_INCLUDE_CEF_FRAME_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_dom.h" +#include "include/cef_request.h" +#include "include/cef_stream.h" +#include "include/cef_string_visitor.h" + +class CefBrowser; +class CefV8Context; + +/// +// Class used to represent a frame in the browser window. When used in the +// browser process the methods of this class may be called on any thread unless +// otherwise indicated in the comments. When used in the render process the +// methods of this class may only be called on the main thread. +/// +/*--cef(source=library)--*/ +class CefFrame : public virtual CefBase { + public: + /// + // True if this object is currently attached to a valid frame. + /// + /*--cef()--*/ + virtual bool IsValid() =0; + + /// + // Execute undo in this frame. + /// + /*--cef()--*/ + virtual void Undo() =0; + + /// + // Execute redo in this frame. + /// + /*--cef()--*/ + virtual void Redo() =0; + + /// + // Execute cut in this frame. + /// + /*--cef()--*/ + virtual void Cut() =0; + + /// + // Execute copy in this frame. + /// + /*--cef()--*/ + virtual void Copy() =0; + + /// + // Execute paste in this frame. + /// + /*--cef()--*/ + virtual void Paste() =0; + + /// + // Execute delete in this frame. + /// + /*--cef(capi_name=del)--*/ + virtual void Delete() =0; + + /// + // Execute select all in this frame. + /// + /*--cef()--*/ + virtual void SelectAll() =0; + + /// + // Save this frame's HTML source to a temporary file and open it in the + // default text viewing application. This method can only be called from the + // browser process. + /// + /*--cef()--*/ + virtual void ViewSource() =0; + + /// + // Retrieve this frame's HTML source as a string sent to the specified + // visitor. + /// + /*--cef()--*/ + virtual void GetSource(CefRefPtr visitor) =0; + + /// + // Retrieve this frame's display text as a string sent to the specified + // visitor. + /// + /*--cef()--*/ + virtual void GetText(CefRefPtr visitor) =0; + + /// + // Load the request represented by the |request| object. + /// + /*--cef()--*/ + virtual void LoadRequest(CefRefPtr request) =0; + + /// + // Load the specified |url|. + /// + /*--cef()--*/ + virtual void LoadURL(const CefString& url) =0; + + /// + // Load the contents of |string_val| with the specified dummy |url|. |url| + // should have a standard scheme (for example, http scheme) or behaviors like + // link clicks and web security restrictions may not behave as expected. + /// + /*--cef()--*/ + virtual void LoadString(const CefString& string_val, + const CefString& url) =0; + + /// + // Execute a string of JavaScript code in this frame. The |script_url| + // parameter is the URL where the script in question can be found, if any. + // The renderer may request this URL to show the developer the source of the + // error. The |start_line| parameter is the base line number to use for error + // reporting. + /// + /*--cef(optional_param=script_url)--*/ + virtual void ExecuteJavaScript(const CefString& code, + const CefString& script_url, + int start_line) =0; + + /// + // Returns true if this is the main (top-level) frame. + /// + /*--cef()--*/ + virtual bool IsMain() =0; + + /// + // Returns true if this is the focused frame. + /// + /*--cef()--*/ + virtual bool IsFocused() =0; + + /// + // Returns the name for this frame. If the frame has an assigned name (for + // example, set via the iframe "name" attribute) then that value will be + // returned. Otherwise a unique name will be constructed based on the frame + // parent hierarchy. The main (top-level) frame will always have an empty name + // value. + /// + /*--cef()--*/ + virtual CefString GetName() =0; + + /// + // Returns the globally unique identifier for this frame. + /// + /*--cef()--*/ + virtual int64 GetIdentifier() =0; + + /// + // Returns the parent of this frame or NULL if this is the main (top-level) + // frame. + /// + /*--cef()--*/ + virtual CefRefPtr GetParent() =0; + + /// + // Returns the URL currently loaded in this frame. + /// + /*--cef()--*/ + virtual CefString GetURL() =0; + + /// + // Returns the browser that this frame belongs to. + /// + /*--cef()--*/ + virtual CefRefPtr GetBrowser() =0; + + /// + // Get the V8 context associated with the frame. This method can only be + // called from the render process. + /// + /*--cef()--*/ + virtual CefRefPtr GetV8Context() =0; + + /// + // Visit the DOM document. This method can only be called from the render + // process. + /// + /*--cef()--*/ + virtual void VisitDOM(CefRefPtr visitor) =0; +}; + +#endif // CEF_INCLUDE_CEF_FRAME_H_ diff --git a/cef3/include/cef_geolocation.h b/cef3/include/cef_geolocation.h new file mode 100644 index 000000000..69c08779c --- /dev/null +++ b/cef3/include/cef_geolocation.h @@ -0,0 +1,66 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_GEOLOCATION_H_ +#define CEF_INCLUDE_CEF_GEOLOCATION_H_ +#pragma once + +#include "include/cef_base.h" + +/// +// Implement this interface to receive geolocation updates. The methods of this +// class will be called on the browser process UI thread. +/// +/*--cef(source=client)--*/ +class CefGetGeolocationCallback : public virtual CefBase { + public: + /// + // Called with the 'best available' location information or, if the location + // update failed, with error information. + /// + /*--cef()--*/ + virtual void OnLocationUpdate(const CefGeoposition& position) =0; +}; + +/// +// Request a one-time geolocation update. This function bypasses any user +// permission checks so should only be used by code that is allowed to access +// location information. +/// +/*--cef()--*/ +bool CefGetGeolocation(CefRefPtr callback); + +#endif // CEF_INCLUDE_CEF_GEOLOCATION_H_ diff --git a/cef3/include/cef_geolocation_handler.h b/cef3/include/cef_geolocation_handler.h new file mode 100644 index 000000000..ea92cdd20 --- /dev/null +++ b/cef3/include/cef_geolocation_handler.h @@ -0,0 +1,94 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_GEOLOCATION_HANDLER_H_ +#define CEF_INCLUDE_CEF_GEOLOCATION_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser.h" + +/// +// Callback interface used for asynchronous continuation of geolocation +// permission requests. +/// +/*--cef(source=library)--*/ +class CefGeolocationCallback : public virtual CefBase { + public: + /// + // Call to allow or deny geolocation access. + /// + /*--cef(capi_name=cont)--*/ + virtual void Continue(bool allow) =0; +}; + + +/// +// Implement this interface to handle events related to geolocation permission +// requests. The methods of this class will be called on the browser process IO +// thread. +/// +/*--cef(source=client)--*/ +class CefGeolocationHandler : public virtual CefBase { + public: + /// + // Called when a page requests permission to access geolocation information. + // |requesting_url| is the URL requesting permission and |request_id| is the + // unique ID for the permission request. Call CefGeolocationCallback::Continue + // to allow or deny the permission request. + /// + /*--cef()--*/ + virtual void OnRequestGeolocationPermission( + CefRefPtr browser, + const CefString& requesting_url, + int request_id, + CefRefPtr callback) { + } + + /// + // Called when a geolocation access request is canceled. |requesting_url| is + // the URL that originally requested permission and |request_id| is the unique + // ID for the permission request. + /// + /*--cef()--*/ + virtual void OnCancelGeolocationPermission( + CefRefPtr browser, + const CefString& requesting_url, + int request_id) { + } +}; + +#endif // CEF_INCLUDE_CEF_GEOLOCATION_HANDLER_H_ diff --git a/cef3/include/cef_jsdialog_handler.h b/cef3/include/cef_jsdialog_handler.h new file mode 100644 index 000000000..f2a4cf849 --- /dev/null +++ b/cef3/include/cef_jsdialog_handler.h @@ -0,0 +1,122 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_JSDIALOG_HANDLER_H_ +#define CEF_INCLUDE_CEF_JSDIALOG_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser.h" + +/// +// Callback interface used for asynchronous continuation of JavaScript dialog +// requests. +/// +/*--cef(source=library)--*/ +class CefJSDialogCallback : public virtual CefBase { + public: + /// + // Continue the JS dialog request. Set |success| to true if the OK button was + // pressed. The |user_input| value should be specified for prompt dialogs. + /// + /*--cef(capi_name=cont,optional_param=user_input)--*/ + virtual void Continue(bool success, + const CefString& user_input) =0; +}; + + +/// +// Implement this interface to handle events related to JavaScript dialogs. The +// methods of this class will be called on the UI thread. +/// +/*--cef(source=client)--*/ +class CefJSDialogHandler : public virtual CefBase { + public: + typedef cef_jsdialog_type_t JSDialogType; + + /// + // Called to run a JavaScript dialog. The |default_prompt_text| value will be + // specified for prompt dialogs only. Set |suppress_message| to true and + // return false to suppress the message (suppressing messages is preferable + // to immediately executing the callback as this is used to detect presumably + // malicious behavior like spamming alert messages in onbeforeunload). Set + // |suppress_message| to false and return false to use the default + // implementation (the default implementation will show one modal dialog at a + // time and suppress any additional dialog requests until the displayed dialog + // is dismissed). Return true if the application will use a custom dialog or + // if the callback has been executed immediately. Custom dialogs may be either + // modal or modeless. If a custom dialog is used the application must execute + // |callback| once the custom dialog is dismissed. + /// + /*--cef(optional_param=accept_lang,optional_param=message_text, + optional_param=default_prompt_text)--*/ + virtual bool OnJSDialog(CefRefPtr browser, + const CefString& origin_url, + const CefString& accept_lang, + JSDialogType dialog_type, + const CefString& message_text, + const CefString& default_prompt_text, + CefRefPtr callback, + bool& suppress_message) { + return false; + } + + /// + // Called to run a dialog asking the user if they want to leave a page. Return + // false to use the default dialog implementation. Return true if the + // application will use a custom dialog or if the callback has been executed + // immediately. Custom dialogs may be either modal or modeless. If a custom + // dialog is used the application must execute |callback| once the custom + // dialog is dismissed. + /// + /*--cef(optional_param=message_text)--*/ + virtual bool OnBeforeUnloadDialog(CefRefPtr browser, + const CefString& message_text, + bool is_reload, + CefRefPtr callback) { + return false; + } + + /// + // Called to cancel any pending dialogs and reset any saved dialog state. Will + // be called due to events like page navigation irregardless of whether any + // dialogs are currently pending. + /// + /*--cef()--*/ + virtual void OnResetDialogState(CefRefPtr browser) {} +}; + +#endif // CEF_INCLUDE_CEF_JSDIALOG_HANDLER_H_ diff --git a/cef3/include/cef_keyboard_handler.h b/cef3/include/cef_keyboard_handler.h new file mode 100644 index 000000000..55cb57ef8 --- /dev/null +++ b/cef3/include/cef_keyboard_handler.h @@ -0,0 +1,74 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_KEYBOARD_HANDLER_H_ +#define CEF_INCLUDE_CEF_KEYBOARD_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser.h" + +/// +// Implement this interface to handle events related to keyboard input. The +// methods of this class will be called on the UI thread. +/// +/*--cef(source=client)--*/ +class CefKeyboardHandler : public virtual CefBase { + public: + // Called before a keyboard event is sent to the renderer. |event| contains + // information about the keyboard event. |os_event| is the operating system + // event message, if any. Return true if the event was handled or false + // otherwise. If the event will be handled in OnKeyEvent() as a keyboard + // shortcut set |is_keyboard_shortcut| to true and return false. + /*--cef()--*/ + virtual bool OnPreKeyEvent(CefRefPtr browser, + const CefKeyEvent& event, + CefEventHandle os_event, + bool* is_keyboard_shortcut) { return false; } + + /// + // Called after the renderer and JavaScript in the page has had a chance to + // handle the event. |event| contains information about the keyboard event. + // |os_event| is the operating system event message, if any. Return true if + // the keyboard event was handled or false otherwise. + /// + /*--cef()--*/ + virtual bool OnKeyEvent(CefRefPtr browser, + const CefKeyEvent& event, + CefEventHandle os_event) { return false; } +}; + +#endif // CEF_INCLUDE_CEF_KEYBOARD_HANDLER_H_ diff --git a/cef3/include/cef_life_span_handler.h b/cef3/include/cef_life_span_handler.h new file mode 100644 index 000000000..5e652716c --- /dev/null +++ b/cef3/include/cef_life_span_handler.h @@ -0,0 +1,166 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_LIFE_SPAN_HANDLER_H_ +#define CEF_INCLUDE_CEF_LIFE_SPAN_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser.h" + +class CefClient; + +/// +// Implement this interface to handle events related to browser life span. The +// methods of this class will be called on the UI thread unless otherwise +// indicated. +/// +/*--cef(source=client)--*/ +class CefLifeSpanHandler : public virtual CefBase { + public: + /// + // Called on the IO thread before a new popup window is created. The |browser| + // and |frame| parameters represent the source of the popup request. The + // |target_url| and |target_frame_name| values may be empty if none were + // specified with the request. The |popupFeatures| structure contains + // information about the requested popup window. To allow creation of the + // popup window optionally modify |windowInfo|, |client|, |settings| and + // |no_javascript_access| and return false. To cancel creation of the popup + // window return true. The |client| and |settings| values will default to the + // source browser's values. The |no_javascript_access| value indicates whether + // the new browser window should be scriptable and in the same process as the + // source browser. + /*--cef(optional_param=target_url,optional_param=target_frame_name)--*/ + virtual bool OnBeforePopup(CefRefPtr browser, + CefRefPtr frame, + const CefString& target_url, + const CefString& target_frame_name, + const CefPopupFeatures& popupFeatures, + CefWindowInfo& windowInfo, + CefRefPtr& client, + CefBrowserSettings& settings, + bool* no_javascript_access) { + return false; + } + + /// + // Called after a new browser is created. + /// + /*--cef()--*/ + virtual void OnAfterCreated(CefRefPtr browser) {} + + /// + // Called when a modal window is about to display and the modal loop should + // begin running. Return false to use the default modal loop implementation or + // true to use a custom implementation. + /// + /*--cef()--*/ + virtual bool RunModal(CefRefPtr browser) { return false; } + + /// + // Called when a browser has recieved a request to close. This may result + // directly from a call to CefBrowserHost::CloseBrowser() or indirectly if the + // browser is a top-level OS window created by CEF and the user attempts to + // close the window. This method will be called after the JavaScript + // 'onunload' event has been fired. It will not be called for browsers after + // the associated OS window has been destroyed (for those browsers it is no + // longer possible to cancel the close). + // + // If CEF created an OS window for the browser returning false will send an OS + // close notification to the browser window's top-level owner (e.g. WM_CLOSE + // on Windows, performClose: on OS-X and "delete_event" on Linux). If no OS + // window exists (window rendering disabled) returning false will cause the + // browser object to be destroyed immediately. Return true if the browser is + // parented to another window and that other window needs to receive close + // notification via some non-standard technique. + // + // If an application provides its own top-level window it should handle OS + // close notifications by calling CefBrowserHost::CloseBrowser(false) instead + // of immediately closing (see the example below). This gives CEF an + // opportunity to process the 'onbeforeunload' event and optionally cancel the + // close before DoClose() is called. + // + // The CefLifeSpanHandler::OnBeforeClose() method will be called immediately + // before the browser object is destroyed. The application should only exit + // after OnBeforeClose() has been called for all existing browsers. + // + // If the browser represents a modal window and a custom modal loop + // implementation was provided in CefLifeSpanHandler::RunModal() this callback + // should be used to restore the opener window to a usable state. + // + // By way of example consider what should happen during window close when the + // browser is parented to an application-provided top-level OS window. + // 1. User clicks the window close button which sends an OS close + // notification (e.g. WM_CLOSE on Windows, performClose: on OS-X and + // "delete_event" on Linux). + // 2. Application's top-level window receives the close notification and: + // A. Calls CefBrowserHost::CloseBrowser(false). + // B. Cancels the window close. + // 3. JavaScript 'onbeforeunload' handler executes and shows the close + // confirmation dialog (which can be overridden via + // CefJSDialogHandler::OnBeforeUnloadDialog()). + // 4. User approves the close. + // 5. JavaScript 'onunload' handler executes. + // 6. Application's DoClose() handler is called. Application will: + // A. Call CefBrowserHost::ParentWindowWillClose() to notify CEF that the + // parent window will be closing. + // B. Set a flag to indicate that the next close attempt will be allowed. + // C. Return false. + // 7. CEF sends an OS close notification. + // 8. Application's top-level window receives the OS close notification and + // allows the window to close based on the flag from #6B. + // 9. Browser OS window is destroyed. + // 10. Application's CefLifeSpanHandler::OnBeforeClose() handler is called and + // the browser object is destroyed. + // 11. Application exits by calling CefQuitMessageLoop() if no other browsers + // exist. + /// + /*--cef()--*/ + virtual bool DoClose(CefRefPtr browser) { return false; } + + /// + // Called just before a browser is destroyed. Release all references to the + // browser object and do not attempt to execute any methods on the browser + // object after this callback returns. If this is a modal window and a custom + // modal loop implementation was provided in RunModal() this callback should + // be used to exit the custom modal loop. See DoClose() documentation for + // additional usage information. + /// + /*--cef()--*/ + virtual void OnBeforeClose(CefRefPtr browser) {} +}; + +#endif // CEF_INCLUDE_CEF_LIFE_SPAN_HANDLER_H_ diff --git a/cef3/include/cef_load_handler.h b/cef3/include/cef_load_handler.h new file mode 100644 index 000000000..cc5cbf376 --- /dev/null +++ b/cef3/include/cef_load_handler.h @@ -0,0 +1,110 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_LOAD_HANDLER_H_ +#define CEF_INCLUDE_CEF_LOAD_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser.h" +#include "include/cef_frame.h" + +/// +// Implement this interface to handle events related to browser load status. The +// methods of this class will be called on the UI thread. +/// +/*--cef(source=client)--*/ +class CefLoadHandler : public virtual CefBase { + public: + typedef cef_errorcode_t ErrorCode; + typedef cef_termination_status_t TerminationStatus; + + /// + // Called when the browser begins loading a frame. The |frame| value will + // never be empty -- call the IsMain() method to check if this frame is the + // main frame. Multiple frames may be loading at the same time. Sub-frames may + // start or continue loading after the main frame load has ended. This method + // may not be called for a particular frame if the load request for that frame + // fails. + /// + /*--cef()--*/ + virtual void OnLoadStart(CefRefPtr browser, + CefRefPtr frame) {} + + /// + // Called when the browser is done loading a frame. The |frame| value will + // never be empty -- call the IsMain() method to check if this frame is the + // main frame. Multiple frames may be loading at the same time. Sub-frames may + // start or continue loading after the main frame load has ended. This method + // will always be called for all frames irrespective of whether the request + // completes successfully. + /// + /*--cef()--*/ + virtual void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) {} + + /// + // Called when the browser fails to load a resource. |errorCode| is the error + // code number, |errorText| is the error text and and |failedUrl| is the URL + // that failed to load. See net\base\net_error_list.h for complete + // descriptions of the error codes. + /// + /*--cef(optional_param=errorText)--*/ + virtual void OnLoadError(CefRefPtr browser, + CefRefPtr frame, + ErrorCode errorCode, + const CefString& errorText, + const CefString& failedUrl) {} + + /// + // Called when the render process terminates unexpectedly. |status| indicates + // how the process terminated. + /// + /*--cef()--*/ + virtual void OnRenderProcessTerminated(CefRefPtr browser, + TerminationStatus status) {} + + /// + // Called when a plugin has crashed. |plugin_path| is the path of the plugin + // that crashed. + /// + /*--cef()--*/ + virtual void OnPluginCrashed(CefRefPtr browser, + const CefString& plugin_path) {} +}; + +#endif // CEF_INCLUDE_CEF_LOAD_HANDLER_H_ diff --git a/cef3/include/cef_menu_model.h b/cef3/include/cef_menu_model.h new file mode 100644 index 000000000..84728c58b --- /dev/null +++ b/cef3/include/cef_menu_model.h @@ -0,0 +1,402 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_MENU_MODEL_H_ +#define CEF_INCLUDE_CEF_MENU_MODEL_H_ +#pragma once + +#include "include/cef_base.h" + +/// +// Supports creation and modification of menus. See cef_menu_id_t for the +// command ids that have default implementations. All user-defined command ids +// should be between MENU_ID_USER_FIRST and MENU_ID_USER_LAST. The methods of +// this class can only be accessed on the browser process the UI thread. +/// +/*--cef(source=library)--*/ +class CefMenuModel : public virtual CefBase { + public: + typedef cef_menu_item_type_t MenuItemType; + + /// + // Clears the menu. Returns true on success. + /// + /*--cef()--*/ + virtual bool Clear() =0; + + /// + // Returns the number of items in this menu. + /// + /*--cef()--*/ + virtual int GetCount() =0; + + // + // Add a separator to the menu. Returns true on success. + /// + /*--cef()--*/ + virtual bool AddSeparator() =0; + + // + // Add an item to the menu. Returns true on success. + /// + /*--cef()--*/ + virtual bool AddItem(int command_id, + const CefString& label) =0; + + // + // Add a check item to the menu. Returns true on success. + /// + /*--cef()--*/ + virtual bool AddCheckItem(int command_id, + const CefString& label) =0; + // + // Add a radio item to the menu. Only a single item with the specified + // |group_id| can be checked at a time. Returns true on success. + /// + /*--cef()--*/ + virtual bool AddRadioItem(int command_id, + const CefString& label, + int group_id) =0; + + // + // Add a sub-menu to the menu. The new sub-menu is returned. + /// + /*--cef()--*/ + virtual CefRefPtr AddSubMenu(int command_id, + const CefString& label) =0; + + // + // Insert a separator in the menu at the specified |index|. Returns true on + // success. + /// + /*--cef()--*/ + virtual bool InsertSeparatorAt(int index) =0; + + // + // Insert an item in the menu at the specified |index|. Returns true on + // success. + /// + /*--cef()--*/ + virtual bool InsertItemAt(int index, + int command_id, + const CefString& label) =0; + + // + // Insert a check item in the menu at the specified |index|. Returns true on + // success. + /// + /*--cef()--*/ + virtual bool InsertCheckItemAt(int index, + int command_id, + const CefString& label) =0; + + // + // Insert a radio item in the menu at the specified |index|. Only a single + // item with the specified |group_id| can be checked at a time. Returns true + // on success. + /// + /*--cef()--*/ + virtual bool InsertRadioItemAt(int index, + int command_id, + const CefString& label, + int group_id) =0; + + // + // Insert a sub-menu in the menu at the specified |index|. The new sub-menu + // is returned. + /// + /*--cef()--*/ + virtual CefRefPtr InsertSubMenuAt(int index, + int command_id, + const CefString& label) =0; + + /// + // Removes the item with the specified |command_id|. Returns true on success. + /// + /*--cef()--*/ + virtual bool Remove(int command_id) =0; + + /// + // Removes the item at the specified |index|. Returns true on success. + /// + /*--cef()--*/ + virtual bool RemoveAt(int index) =0; + + /// + // Returns the index associated with the specified |command_id| or -1 if not + // found due to the command id not existing in the menu. + /// + /*--cef()--*/ + virtual int GetIndexOf(int command_id) =0; + + /// + // Returns the command id at the specified |index| or -1 if not found due to + // invalid range or the index being a separator. + /// + /*--cef()--*/ + virtual int GetCommandIdAt(int index) =0; + + /// + // Sets the command id at the specified |index|. Returns true on success. + /// + /*--cef()--*/ + virtual bool SetCommandIdAt(int index, int command_id) =0; + + /// + // Returns the label for the specified |command_id| or empty if not found. + /// + /*--cef()--*/ + virtual CefString GetLabel(int command_id) =0; + + /// + // Returns the label at the specified |index| or empty if not found due to + // invalid range or the index being a separator. + /// + /*--cef()--*/ + virtual CefString GetLabelAt(int index) =0; + + /// + // Sets the label for the specified |command_id|. Returns true on success. + /// + /*--cef()--*/ + virtual bool SetLabel(int command_id, const CefString& label) =0; + + /// + // Set the label at the specified |index|. Returns true on success. + /// + /*--cef()--*/ + virtual bool SetLabelAt(int index, const CefString& label) =0; + + /// + // Returns the item type for the specified |command_id|. + /// + /*--cef(default_retval=MENUITEMTYPE_NONE)--*/ + virtual MenuItemType GetType(int command_id) =0; + + /// + // Returns the item type at the specified |index|. + /// + /*--cef(default_retval=MENUITEMTYPE_NONE)--*/ + virtual MenuItemType GetTypeAt(int index) =0; + + /// + // Returns the group id for the specified |command_id| or -1 if invalid. + /// + /*--cef()--*/ + virtual int GetGroupId(int command_id) =0; + + /// + // Returns the group id at the specified |index| or -1 if invalid. + /// + /*--cef()--*/ + virtual int GetGroupIdAt(int index) =0; + + /// + // Sets the group id for the specified |command_id|. Returns true on success. + /// + /*--cef()--*/ + virtual bool SetGroupId(int command_id, int group_id) =0; + + /// + // Sets the group id at the specified |index|. Returns true on success. + /// + /*--cef()--*/ + virtual bool SetGroupIdAt(int index, int group_id) =0; + + /// + // Returns the submenu for the specified |command_id| or empty if invalid. + /// + /*--cef()--*/ + virtual CefRefPtr GetSubMenu(int command_id) =0; + + /// + // Returns the submenu at the specified |index| or empty if invalid. + /// + /*--cef()--*/ + virtual CefRefPtr GetSubMenuAt(int index) =0; + + // + // Returns true if the specified |command_id| is visible. + /// + /*--cef()--*/ + virtual bool IsVisible(int command_id) =0; + + // + // Returns true if the specified |index| is visible. + /// + /*--cef()--*/ + virtual bool IsVisibleAt(int index) =0; + + // + // Change the visibility of the specified |command_id|. Returns true on + // success. + /// + /*--cef()--*/ + virtual bool SetVisible(int command_id, bool visible) =0; + + // + // Change the visibility at the specified |index|. Returns true on success. + /// + /*--cef()--*/ + virtual bool SetVisibleAt(int index, bool visible) =0; + + // + // Returns true if the specified |command_id| is enabled. + /// + /*--cef()--*/ + virtual bool IsEnabled(int command_id) =0; + + // + // Returns true if the specified |index| is enabled. + /// + /*--cef()--*/ + virtual bool IsEnabledAt(int index) =0; + + // + // Change the enabled status of the specified |command_id|. Returns true on + // success. + /// + /*--cef()--*/ + virtual bool SetEnabled(int command_id, bool enabled) =0; + + // + // Change the enabled status at the specified |index|. Returns true on + // success. + /// + /*--cef()--*/ + virtual bool SetEnabledAt(int index, bool enabled) =0; + + // + // Returns true if the specified |command_id| is checked. Only applies to + // check and radio items. + /// + /*--cef()--*/ + virtual bool IsChecked(int command_id) =0; + + // + // Returns true if the specified |index| is checked. Only applies to check + // and radio items. + /// + /*--cef()--*/ + virtual bool IsCheckedAt(int index) =0; + + // + // Check the specified |command_id|. Only applies to check and radio items. + // Returns true on success. + /// + /*--cef()--*/ + virtual bool SetChecked(int command_id, bool checked) =0; + + // + // Check the specified |index|. Only applies to check and radio items. Returns + // true on success. + /// + /*--cef()--*/ + virtual bool SetCheckedAt(int index, bool checked) =0; + + // + // Returns true if the specified |command_id| has a keyboard accelerator + // assigned. + /// + /*--cef()--*/ + virtual bool HasAccelerator(int command_id) =0; + + // + // Returns true if the specified |index| has a keyboard accelerator assigned. + /// + /*--cef()--*/ + virtual bool HasAcceleratorAt(int index) =0; + + // + // Set the keyboard accelerator for the specified |command_id|. |key_code| can + // be any virtual key or character value. Returns true on success. + /// + /*--cef()--*/ + virtual bool SetAccelerator(int command_id, + int key_code, + bool shift_pressed, + bool ctrl_pressed, + bool alt_pressed) =0; + + // + // Set the keyboard accelerator at the specified |index|. |key_code| can be + // any virtual key or character value. Returns true on success. + /// + /*--cef()--*/ + virtual bool SetAcceleratorAt(int index, + int key_code, + bool shift_pressed, + bool ctrl_pressed, + bool alt_pressed) =0; + + // + // Remove the keyboard accelerator for the specified |command_id|. Returns + // true on success. + /// + /*--cef()--*/ + virtual bool RemoveAccelerator(int command_id) =0; + + // + // Remove the keyboard accelerator at the specified |index|. Returns true on + // success. + /// + /*--cef()--*/ + virtual bool RemoveAcceleratorAt(int index) =0; + + // + // Retrieves the keyboard accelerator for the specified |command_id|. Returns + // true on success. + /// + /*--cef()--*/ + virtual bool GetAccelerator(int command_id, + int& key_code, + bool& shift_pressed, + bool& ctrl_pressed, + bool& alt_pressed) =0; + + // + // Retrieves the keyboard accelerator for the specified |index|. Returns true + // on success. + /// + /*--cef()--*/ + virtual bool GetAcceleratorAt(int index, + int& key_code, + bool& shift_pressed, + bool& ctrl_pressed, + bool& alt_pressed) =0; +}; + +#endif // CEF_INCLUDE_CEF_MENU_MODEL_H_ diff --git a/cef3/include/cef_origin_whitelist.h b/cef3/include/cef_origin_whitelist.h new file mode 100644 index 000000000..163a93b91 --- /dev/null +++ b/cef3/include/cef_origin_whitelist.h @@ -0,0 +1,102 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_ORIGIN_WHITELIST_H_ +#define CEF_INCLUDE_CEF_ORIGIN_WHITELIST_H_ +#pragma once + +#include "include/cef_base.h" + + +/// +// Add an entry to the cross-origin access whitelist. +// +// The same-origin policy restricts how scripts hosted from different origins +// (scheme + domain + port) can communicate. By default, scripts can only access +// resources with the same origin. Scripts hosted on the HTTP and HTTPS schemes +// (but no other schemes) can use the "Access-Control-Allow-Origin" header to +// allow cross-origin requests. For example, https://source.example.com can make +// XMLHttpRequest requests on http://target.example.com if the +// http://target.example.com request returns an "Access-Control-Allow-Origin: +// https://source.example.com" response header. +// +// Scripts in separate frames or iframes and hosted from the same protocol and +// domain suffix can execute cross-origin JavaScript if both pages set the +// document.domain value to the same domain suffix. For example, +// scheme://foo.example.com and scheme://bar.example.com can communicate using +// JavaScript if both domains set document.domain="example.com". +// +// This method is used to allow access to origins that would otherwise violate +// the same-origin policy. Scripts hosted underneath the fully qualified +// |source_origin| URL (like http://www.example.com) will be allowed access to +// all resources hosted on the specified |target_protocol| and |target_domain|. +// If |target_domain| is non-empty and |allow_target_subdomains| if false only +// exact domain matches will be allowed. If |target_domain| is non-empty and +// |allow_target_subdomains| is true sub-domain matches will be allowed. If +// |target_domain| is empty and |allow_target_subdomains| if true all domains +// and IP addresses will be allowed. +// +// This method cannot be used to bypass the restrictions on local or display +// isolated schemes. See the comments on CefRegisterCustomScheme for more +// information. +// +// This function may be called on any thread. Returns false if |source_origin| +// is invalid or the whitelist cannot be accessed. +/// +/*--cef(optional_param=target_domain)--*/ +bool CefAddCrossOriginWhitelistEntry(const CefString& source_origin, + const CefString& target_protocol, + const CefString& target_domain, + bool allow_target_subdomains); + +/// +// Remove an entry from the cross-origin access whitelist. Returns false if +// |source_origin| is invalid or the whitelist cannot be accessed. +/// +/*--cef(optional_param=target_domain)--*/ +bool CefRemoveCrossOriginWhitelistEntry(const CefString& source_origin, + const CefString& target_protocol, + const CefString& target_domain, + bool allow_target_subdomains); + +/// +// Remove all entries from the cross-origin access whitelist. Returns false if +// the whitelist cannot be accessed. +/// +/*--cef()--*/ +bool CefClearCrossOriginWhitelist(); + +#endif // CEF_INCLUDE_CEF_ORIGIN_WHITELIST_H_ diff --git a/cef3/include/cef_path_util.h b/cef3/include/cef_path_util.h new file mode 100644 index 000000000..552f4ba59 --- /dev/null +++ b/cef3/include/cef_path_util.h @@ -0,0 +1,52 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_PATH_UTIL_H_ +#define CEF_INCLUDE_CEF_PATH_UTIL_H_ +#pragma once + +#include "include/cef_base.h" + +typedef cef_path_key_t PathKey; + +/// +// Retrieve the path associated with the specified |key|. Returns true on +// success. Can be called on any thread in the browser process. +/// +/*--cef()--*/ +bool CefGetPath(PathKey key, CefString& path); + +#endif // CEF_INCLUDE_CEF_PATH_UTIL_H_ diff --git a/cef3/include/cef_process_message.h b/cef3/include/cef_process_message.h new file mode 100644 index 000000000..1e27bd681 --- /dev/null +++ b/cef3/include/cef_process_message.h @@ -0,0 +1,91 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_MESSAGE_H_ +#define CEF_INCLUDE_CEF_MESSAGE_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_values.h" + +typedef cef_process_id_t CefProcessId; + +/// +// Class representing a message. Can be used on any process and thread. +/// +/*--cef(source=library)--*/ +class CefProcessMessage : public virtual CefBase { + public: + /// + // Create a new CefProcessMessage object with the specified name. + /// + /*--cef()--*/ + static CefRefPtr Create(const CefString& name); + + /// + // Returns true if this object is valid. Do not call any other methods if this + // function returns false. + /// + /*--cef()--*/ + virtual bool IsValid() =0; + + /// + // Returns true if the values of this object are read-only. Some APIs may + // expose read-only objects. + /// + /*--cef()--*/ + virtual bool IsReadOnly() =0; + + /// + // Returns a writable copy of this object. + /// + /*--cef()--*/ + virtual CefRefPtr Copy() =0; + + /// + // Returns the message name. + /// + /*--cef()--*/ + virtual CefString GetName() =0; + + /// + // Returns the list of arguments. + /// + /*--cef()--*/ + virtual CefRefPtr GetArgumentList() =0; +}; + +#endif // CEF_INCLUDE_CEF_MESSAGE_H_ diff --git a/cef3/include/cef_process_util.h b/cef3/include/cef_process_util.h new file mode 100644 index 000000000..4fce778e7 --- /dev/null +++ b/cef3/include/cef_process_util.h @@ -0,0 +1,57 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_PROCESS_UTIL_H_ +#define CEF_INCLUDE_CEF_PROCESS_UTIL_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_command_line.h" + +/// +// Launches the process specified via |command_line|. Returns true upon +// success. Must be called on the browser process TID_PROCESS_LAUNCHER thread. +// +// Unix-specific notes: +// - All file descriptors open in the parent process will be closed in the +// child process except for stdin, stdout, and stderr. +// - If the first argument on the command line does not contain a slash, +// PATH will be searched. (See man execvp.) +/// +/*--cef()--*/ +bool CefLaunchProcess(CefRefPtr command_line); + +#endif // CEF_INCLUDE_CEF_PROCESS_UTIL_H_ diff --git a/cef3/include/cef_render_handler.h b/cef3/include/cef_render_handler.h new file mode 100644 index 000000000..5064950cd --- /dev/null +++ b/cef3/include/cef_render_handler.h @@ -0,0 +1,119 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_RENDER_HANDLER_H_ +#define CEF_INCLUDE_CEF_RENDER_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser.h" +#include + +/// +// Implement this interface to handle events when window rendering is disabled. +// The methods of this class will be called on the UI thread. +/// +/*--cef(source=client)--*/ +class CefRenderHandler : public virtual CefBase { + public: + typedef cef_paint_element_type_t PaintElementType; + typedef std::vector RectList; + + /// + // Called to retrieve the root window rectangle in screen coordinates. Return + // true if the rectangle was provided. + /// + /*--cef()--*/ + virtual bool GetRootScreenRect(CefRefPtr browser, + CefRect& rect) { return false; } + + /// + // Called to retrieve the view rectangle which is relative to screen + // coordinates. Return true if the rectangle was provided. + /// + /*--cef()--*/ + virtual bool GetViewRect(CefRefPtr browser, CefRect& rect) =0; + + /// + // Called to retrieve the translation from view coordinates to actual screen + // coordinates. Return true if the screen coordinates were provided. + /// + /*--cef()--*/ + virtual bool GetScreenPoint(CefRefPtr browser, + int viewX, + int viewY, + int& screenX, + int& screenY) { return false; } + + /// + // Called when the browser wants to show or hide the popup widget. The popup + // should be shown if |show| is true and hidden if |show| is false. + /// + /*--cef()--*/ + virtual void OnPopupShow(CefRefPtr browser, + bool show) {} + + /// + // Called when the browser wants to move or resize the popup widget. |rect| + // contains the new location and size. + /// + /*--cef()--*/ + virtual void OnPopupSize(CefRefPtr browser, + const CefRect& rect) {} + + /// + // Called when an element should be painted. |type| indicates whether the + // element is the view or the popup widget. |buffer| contains the pixel data + // for the whole image. |dirtyRects| contains the set of rectangles that need + // to be repainted. On Windows |buffer| will be |width|*|height|*4 bytes + // in size and represents a BGRA image with an upper-left origin. + /// + /*--cef()--*/ + virtual void OnPaint(CefRefPtr browser, + PaintElementType type, + const RectList& dirtyRects, + const void* buffer, + int width, int height) =0; + + /// + // Called when the browser window's cursor has changed. + /// + /*--cef()--*/ + virtual void OnCursorChange(CefRefPtr browser, + CefCursorHandle cursor) {} +}; + +#endif // CEF_INCLUDE_CEF_RENDER_HANDLER_H_ diff --git a/cef3/include/cef_render_process_handler.h b/cef3/include/cef_render_process_handler.h new file mode 100644 index 000000000..0f21b1d2c --- /dev/null +++ b/cef3/include/cef_render_process_handler.h @@ -0,0 +1,196 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_RENDER_PROCESS_HANDLER_H_ +#define CEF_INCLUDE_CEF_RENDER_PROCESS_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser.h" +#include "include/cef_dom.h" +#include "include/cef_frame.h" +#include "include/cef_process_message.h" +#include "include/cef_v8.h" +#include "include/cef_values.h" + +/// +// Class used to implement render process callbacks. The methods of this class +// will be called on the render process main thread (TID_RENDERER) unless +// otherwise indicated. +/// +/*--cef(source=client)--*/ +class CefRenderProcessHandler : public virtual CefBase { + public: + typedef cef_navigation_type_t NavigationType; + + /// + // Called after the render process main thread has been created. |extra_info| + // is a read-only value originating from + // CefBrowserProcessHandler::OnRenderProcessThreadCreated(). Do not keep a + // reference to |extra_info| outside of this method. + /// + /*--cef()--*/ + virtual void OnRenderThreadCreated(CefRefPtr extra_info) {} + + /// + // Called after WebKit has been initialized. + /// + /*--cef()--*/ + virtual void OnWebKitInitialized() {} + + /// + // Called after a browser has been created. When browsing cross-origin a new + // browser will be created before the old browser with the same identifier is + // destroyed. + /// + /*--cef()--*/ + virtual void OnBrowserCreated(CefRefPtr browser) {} + + /// + // Called before a browser is destroyed. + /// + /*--cef()--*/ + virtual void OnBrowserDestroyed(CefRefPtr browser) {} + + /// + // Called before browser navigation. Return true to cancel the navigation or + // false to allow the navigation to proceed. The |request| object cannot be + // modified in this callback. + /// + /*--cef()--*/ + virtual bool OnBeforeNavigation(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr request, + NavigationType navigation_type, + bool is_redirect) { return false; } + + /// + // Called immediately after the V8 context for a frame has been created. To + // retrieve the JavaScript 'window' object use the CefV8Context::GetGlobal() + // method. V8 handles can only be accessed from the thread on which they are + // created. A task runner for posting tasks on the associated thread can be + // retrieved via the CefV8Context::GetTaskRunner() method. + /// + /*--cef()--*/ + virtual void OnContextCreated(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context) {} + + /// + // Called immediately before the V8 context for a frame is released. No + // references to the context should be kept after this method is called. + /// + /*--cef()--*/ + virtual void OnContextReleased(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context) {} + + /// + // Called for global uncaught exceptions in a frame. Execution of this + // callback is disabled by default. To enable set + // CefSettings.uncaught_exception_stack_size > 0. + /// + /*--cef()--*/ + virtual void OnUncaughtException(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context, + CefRefPtr exception, + CefRefPtr stackTrace) {} + + /// + // Called on the WebWorker thread immediately after the V8 context for a new + // WebWorker has been created. To retrieve the JavaScript 'self' object use + // the CefV8Context::GetGlobal() method. V8 handles can only be accessed from + // the thread on which they are created. A task runner for posting tasks on + // the associated thread can be retrieved via the + // CefV8Context::GetTaskRunner() method. + /// + /*--cef()--*/ + virtual void OnWorkerContextCreated(int worker_id, + const CefString& url, + CefRefPtr context) {} + + /// + // Called on the WebWorker thread immediately before the V8 context for a + // WebWorker is released. No references to the context should be kept after + // this method is called. Any tasks posted or pending on the WebWorker + // thread after this method is called may not be executed. + /// + /*--cef()--*/ + virtual void OnWorkerContextReleased(int worker_id, + const CefString& url, + CefRefPtr context) {} + + /// + // Called on the WebWorker thread for global uncaught exceptions in a + // WebWorker. Execution of this callback is disabled by default. To enable set + // CefSettings.uncaught_exception_stack_size > 0. + /// + /*--cef()--*/ + virtual void OnWorkerUncaughtException( + int worker_id, + const CefString& url, + CefRefPtr context, + CefRefPtr exception, + CefRefPtr stackTrace) {} + + /// + // Called when a new node in the the browser gets focus. The |node| value may + // be empty if no specific node has gained focus. The node object passed to + // this method represents a snapshot of the DOM at the time this method is + // executed. DOM objects are only valid for the scope of this method. Do not + // keep references to or attempt to access any DOM objects outside the scope + // of this method. + /// + /*--cef(optional_param=frame,optional_param=node)--*/ + virtual void OnFocusedNodeChanged(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr node) {} + + /// + // Called when a new message is received from a different process. Return true + // if the message was handled or false otherwise. Do not keep a reference to + // or attempt to access the message outside of this callback. + /// + /*--cef()--*/ + virtual bool OnProcessMessageReceived(CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) { + return false; + } +}; + +#endif // CEF_INCLUDE_CEF_RENDER_PROCESS_HANDLER_H_ diff --git a/cef3/include/cef_request.h b/cef3/include/cef_request.h new file mode 100644 index 000000000..7ac4cb027 --- /dev/null +++ b/cef3/include/cef_request.h @@ -0,0 +1,280 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_REQUEST_H_ +#define CEF_INCLUDE_CEF_REQUEST_H_ +#pragma once + +#include "include/cef_base.h" +#include +#include + +class CefPostData; +class CefPostDataElement; + +/// +// Class used to represent a web request. The methods of this class may be +// called on any thread. +/// +/*--cef(source=library,no_debugct_check)--*/ +class CefRequest : public virtual CefBase { + public: + typedef std::multimap HeaderMap; + + /// + // Create a new CefRequest object. + /// + /*--cef()--*/ + static CefRefPtr Create(); + + /// + // Returns true if this object is read-only. + /// + /*--cef()--*/ + virtual bool IsReadOnly() =0; + + /// + // Get the fully qualified URL. + /// + /*--cef()--*/ + virtual CefString GetURL() =0; + + /// + // Set the fully qualified URL. + /// + /*--cef()--*/ + virtual void SetURL(const CefString& url) =0; + + /// + // Get the request method type. The value will default to POST if post data + // is provided and GET otherwise. + /// + /*--cef()--*/ + virtual CefString GetMethod() =0; + + /// + // Set the request method type. + /// + /*--cef()--*/ + virtual void SetMethod(const CefString& method) =0; + + /// + // Get the post data. + /// + /*--cef()--*/ + virtual CefRefPtr GetPostData() =0; + + /// + // Set the post data. + /// + /*--cef()--*/ + virtual void SetPostData(CefRefPtr postData) =0; + + /// + // Get the header values. + /// + /*--cef()--*/ + virtual void GetHeaderMap(HeaderMap& headerMap) =0; + + /// + // Set the header values. + /// + /*--cef()--*/ + virtual void SetHeaderMap(const HeaderMap& headerMap) =0; + + /// + // Set all values at one time. + /// + /*--cef(optional_param=postData)--*/ + virtual void Set(const CefString& url, + const CefString& method, + CefRefPtr postData, + const HeaderMap& headerMap) =0; + + /// + // Get the flags used in combination with CefURLRequest. See + // cef_urlrequest_flags_t for supported values. + /// + /*--cef(default_retval=UR_FLAG_NONE)--*/ + virtual int GetFlags() =0; + + /// + // Set the flags used in combination with CefURLRequest. See + // cef_urlrequest_flags_t for supported values. + /// + /*--cef()--*/ + virtual void SetFlags(int flags) =0; + + /// + // Set the URL to the first party for cookies used in combination with + // CefURLRequest. + /// + /*--cef()--*/ + virtual CefString GetFirstPartyForCookies() =0; + + /// + // Get the URL to the first party for cookies used in combination with + // CefURLRequest. + /// + /*--cef()--*/ + virtual void SetFirstPartyForCookies(const CefString& url) =0; +}; + + +/// +// Class used to represent post data for a web request. The methods of this +// class may be called on any thread. +/// +/*--cef(source=library,no_debugct_check)--*/ +class CefPostData : public virtual CefBase { + public: + typedef std::vector > ElementVector; + + /// + // Create a new CefPostData object. + /// + /*--cef()--*/ + static CefRefPtr Create(); + + /// + // Returns true if this object is read-only. + /// + /*--cef()--*/ + virtual bool IsReadOnly() =0; + + /// + // Returns the number of existing post data elements. + /// + /*--cef()--*/ + virtual size_t GetElementCount() =0; + + /// + // Retrieve the post data elements. + /// + /*--cef(count_func=elements:GetElementCount)--*/ + virtual void GetElements(ElementVector& elements) =0; + + /// + // Remove the specified post data element. Returns true if the removal + // succeeds. + /// + /*--cef()--*/ + virtual bool RemoveElement(CefRefPtr element) =0; + + /// + // Add the specified post data element. Returns true if the add succeeds. + /// + /*--cef()--*/ + virtual bool AddElement(CefRefPtr element) =0; + + /// + // Remove all existing post data elements. + /// + /*--cef()--*/ + virtual void RemoveElements() =0; +}; + + +/// +// Class used to represent a single element in the request post data. The +// methods of this class may be called on any thread. +/// +/*--cef(source=library,no_debugct_check)--*/ +class CefPostDataElement : public virtual CefBase { + public: + /// + // Post data elements may represent either bytes or files. + /// + typedef cef_postdataelement_type_t Type; + + /// + // Create a new CefPostDataElement object. + /// + /*--cef()--*/ + static CefRefPtr Create(); + + /// + // Returns true if this object is read-only. + /// + /*--cef()--*/ + virtual bool IsReadOnly() =0; + + /// + // Remove all contents from the post data element. + /// + /*--cef()--*/ + virtual void SetToEmpty() =0; + + /// + // The post data element will represent a file. + /// + /*--cef()--*/ + virtual void SetToFile(const CefString& fileName) =0; + + /// + // The post data element will represent bytes. The bytes passed + // in will be copied. + /// + /*--cef()--*/ + virtual void SetToBytes(size_t size, const void* bytes) =0; + + /// + // Return the type of this post data element. + /// + /*--cef(default_retval=PDE_TYPE_EMPTY)--*/ + virtual Type GetType() =0; + + /// + // Return the file name. + /// + /*--cef()--*/ + virtual CefString GetFile() =0; + + /// + // Return the number of bytes. + /// + /*--cef()--*/ + virtual size_t GetBytesCount() =0; + + /// + // Read up to |size| bytes into |bytes| and return the number of bytes + // actually read. + /// + /*--cef()--*/ + virtual size_t GetBytes(size_t size, void* bytes) =0; +}; + +#endif // CEF_INCLUDE_CEF_REQUEST_H_ diff --git a/cef3/include/cef_request_handler.h b/cef3/include/cef_request_handler.h new file mode 100644 index 000000000..641e16b74 --- /dev/null +++ b/cef3/include/cef_request_handler.h @@ -0,0 +1,241 @@ +// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_REQUEST_HANDLER_H_ +#define CEF_INCLUDE_CEF_REQUEST_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser.h" +#include "include/cef_cookie.h" +#include "include/cef_frame.h" +#include "include/cef_resource_handler.h" +#include "include/cef_response.h" +#include "include/cef_request.h" +#include "include/cef_web_plugin.h" + +/// +// Callback interface used for asynchronous continuation of authentication +// requests. +/// +/*--cef(source=library)--*/ +class CefAuthCallback : public virtual CefBase { + public: + /// + // Continue the authentication request. + /// + /*--cef(capi_name=cont)--*/ + virtual void Continue(const CefString& username, + const CefString& password) =0; + + /// + // Cancel the authentication request. + /// + /*--cef()--*/ + virtual void Cancel() =0; +}; + + +/// +// Callback interface used for asynchronous continuation of quota requests. +/// +/*--cef(source=library)--*/ +class CefQuotaCallback : public virtual CefBase { + public: + /// + // Continue the quota request. If |allow| is true the request will be + // allowed. Otherwise, the request will be denied. + /// + /*--cef(capi_name=cont)--*/ + virtual void Continue(bool allow) =0; + + /// + // Cancel the quota request. + /// + /*--cef()--*/ + virtual void Cancel() =0; +}; + + +/// +// Callback interface used for asynchronous continuation of url requests when +// invalid SSL certificates are encountered. +/// +/*--cef(source=library)--*/ +class CefAllowCertificateErrorCallback : public virtual CefBase { + public: + /// + // Continue the url request. If |allow| is true the request will be + // continued. Otherwise, the request will be canceled. + /// + /*--cef(capi_name=cont)--*/ + virtual void Continue(bool allow) =0; +}; + + +/// +// Implement this interface to handle events related to browser requests. The +// methods of this class will be called on the thread indicated. +/// +/*--cef(source=client)--*/ +class CefRequestHandler : public virtual CefBase { + public: + /// + // Called on the IO thread before a resource request is loaded. The |request| + // object may be modified. To cancel the request return true otherwise return + // false. + /// + /*--cef()--*/ + virtual bool OnBeforeResourceLoad(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr request) { + return false; + } + + /// + // Called on the IO thread before a resource is loaded. To allow the resource + // to load normally return NULL. To specify a handler for the resource return + // a CefResourceHandler object. The |request| object should not be modified in + // this callback. + /// + /*--cef()--*/ + virtual CefRefPtr GetResourceHandler( + CefRefPtr browser, + CefRefPtr frame, + CefRefPtr request) { + return NULL; + } + + /// + // Called on the IO thread when a resource load is redirected. The |old_url| + // parameter will contain the old URL. The |new_url| parameter will contain + // the new URL and can be changed if desired. + /// + /*--cef()--*/ + virtual void OnResourceRedirect(CefRefPtr browser, + CefRefPtr frame, + const CefString& old_url, + CefString& new_url) {} + + /// + // Called on the IO thread when the browser needs credentials from the user. + // |isProxy| indicates whether the host is a proxy server. |host| contains the + // hostname and |port| contains the port number. Return true to continue the + // request and call CefAuthCallback::Continue() when the authentication + // information is available. Return false to cancel the request. + /// + /*--cef(optional_param=realm)--*/ + virtual bool GetAuthCredentials(CefRefPtr browser, + CefRefPtr frame, + bool isProxy, + const CefString& host, + int port, + const CefString& realm, + const CefString& scheme, + CefRefPtr callback) { + return false; + } + + /// + // Called on the IO thread when JavaScript requests a specific storage quota + // size via the webkitStorageInfo.requestQuota function. |origin_url| is the + // origin of the page making the request. |new_size| is the requested quota + // size in bytes. Return true and call CefQuotaCallback::Continue() either in + // this method or at a later time to grant or deny the request. Return false + // to cancel the request. + /// + /*--cef(optional_param=realm)--*/ + virtual bool OnQuotaRequest(CefRefPtr browser, + const CefString& origin_url, + int64 new_size, + CefRefPtr callback) { + return false; + } + + /// + // Called on the IO thread to retrieve the cookie manager. |main_url| is the + // URL of the top-level frame. Cookies managers can be unique per browser or + // shared across multiple browsers. The global cookie manager will be used if + // this method returns NULL. + /// + /*--cef()--*/ + virtual CefRefPtr GetCookieManager( + CefRefPtr browser, + const CefString& main_url) { return NULL; } + + /// + // Called on the UI thread to handle requests for URLs with an unknown + // protocol component. Set |allow_os_execution| to true to attempt execution + // via the registered OS protocol handler, if any. + // SECURITY WARNING: YOU SHOULD USE THIS METHOD TO ENFORCE RESTRICTIONS BASED + // ON SCHEME, HOST OR OTHER URL ANALYSIS BEFORE ALLOWING OS EXECUTION. + /// + /*--cef()--*/ + virtual void OnProtocolExecution(CefRefPtr browser, + const CefString& url, + bool& allow_os_execution) {} + + /// + // Called on the browser process IO thread before a plugin is loaded. Return + // true to block loading of the plugin. + /// + /*--cef(optional_param=url,optional_param=policy_url)--*/ + virtual bool OnBeforePluginLoad(CefRefPtr browser, + const CefString& url, + const CefString& policy_url, + CefRefPtr info) { + return false; + } + + /// + // Called on the UI thread to handle requests for URLs with an invalid + // SSL certificate. Return true and call CefAllowCertificateErrorCallback:: + // Continue() either in this method or at a later time to continue or cancel + // the request. Return false to cancel the request immediately. If |callback| + // is empty the error cannot be recovered from and the request will be + // canceled automatically. If CefSettings.ignore_certificate_errors is set + // all invalid certificates will be accepted without calling this method. + /// + /*--cef()--*/ + virtual bool OnCertificateError( + cef_errorcode_t cert_error, + const CefString& request_url, + CefRefPtr callback) { + return false; + } +}; + +#endif // CEF_INCLUDE_CEF_REQUEST_HANDLER_H_ diff --git a/cef3/include/cef_resource_bundle_handler.h b/cef3/include/cef_resource_bundle_handler.h new file mode 100644 index 000000000..2cd39a5eb --- /dev/null +++ b/cef3/include/cef_resource_bundle_handler.h @@ -0,0 +1,73 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_RESOURCE_BUNDLE_HANDLER_H_ +#define CEF_INCLUDE_CEF_RESOURCE_BUNDLE_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" + +/// +// Class used to implement a custom resource bundle interface. The methods of +// this class may be called on multiple threads. +/// +/*--cef(source=client)--*/ +class CefResourceBundleHandler : public virtual CefBase { + public: + /// + // Called to retrieve a localized translation for the string specified by + // |message_id|. To provide the translation set |string| to the translation + // string and return true. To use the default translation return false. + // Supported message IDs are listed in cef_pack_strings.h. + /// + /*--cef()--*/ + virtual bool GetLocalizedString(int message_id, + CefString& string) =0; + + /// + // Called to retrieve data for the resource specified by |resource_id|. To + // provide the resource data set |data| and |data_size| to the data pointer + // and size respectively and return true. To use the default resource data + // return false. The resource data will not be copied and must remain resident + // in memory. Supported resource IDs are listed in cef_pack_resources.h. + /// + /*--cef()--*/ + virtual bool GetDataResource(int resource_id, + void*& data, + size_t& data_size) =0; +}; + +#endif // CEF_INCLUDE_CEF_RESOURCE_BUNDLE_HANDLER_H_ diff --git a/cef3/include/cef_resource_handler.h b/cef3/include/cef_resource_handler.h new file mode 100644 index 000000000..57c8b7fc0 --- /dev/null +++ b/cef3/include/cef_resource_handler.h @@ -0,0 +1,116 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_RESOURCE_HANDLER_H_ +#define CEF_INCLUDE_CEF_RESOURCE_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser.h" +#include "include/cef_callback.h" +#include "include/cef_cookie.h" +#include "include/cef_request.h" +#include "include/cef_response.h" + +/// +// Class used to implement a custom request handler interface. The methods of +// this class will always be called on the IO thread. +/// +/*--cef(source=client)--*/ +class CefResourceHandler : public virtual CefBase { + public: + /// + // Begin processing the request. To handle the request return true and call + // CefCallback::Continue() once the response header information is available + // (CefCallback::Continue() can also be called from inside this method if + // header information is available immediately). To cancel the request return + // false. + /// + /*--cef()--*/ + virtual bool ProcessRequest(CefRefPtr request, + CefRefPtr callback) =0; + + /// + // Retrieve response header information. If the response length is not known + // set |response_length| to -1 and ReadResponse() will be called until it + // returns false. If the response length is known set |response_length| + // to a positive value and ReadResponse() will be called until it returns + // false or the specified number of bytes have been read. Use the |response| + // object to set the mime type, http status code and other optional header + // values. To redirect the request to a new URL set |redirectUrl| to the new + // URL. + /// + /*--cef()--*/ + virtual void GetResponseHeaders(CefRefPtr response, + int64& response_length, + CefString& redirectUrl) =0; + + /// + // Read response data. If data is available immediately copy up to + // |bytes_to_read| bytes into |data_out|, set |bytes_read| to the number of + // bytes copied, and return true. To read the data at a later time set + // |bytes_read| to 0, return true and call CefCallback::Continue() when the + // data is available. To indicate response completion return false. + /// + /*--cef()--*/ + virtual bool ReadResponse(void* data_out, + int bytes_to_read, + int& bytes_read, + CefRefPtr callback) =0; + + /// + // Return true if the specified cookie can be sent with the request or false + // otherwise. If false is returned for any cookie then no cookies will be sent + // with the request. + /// + /*--cef()--*/ + virtual bool CanGetCookie(const CefCookie& cookie) { return true; } + + /// + // Return true if the specified cookie returned with the response can be set + // or false otherwise. + /// + /*--cef()--*/ + virtual bool CanSetCookie(const CefCookie& cookie) { return true; } + + /// + // Request processing has been canceled. + /// + /*--cef()--*/ + virtual void Cancel() =0; +}; + +#endif // CEF_INCLUDE_CEF_RESOURCE_HANDLER_H_ diff --git a/cef3/include/cef_response.h b/cef3/include/cef_response.h new file mode 100644 index 000000000..32fbef1b0 --- /dev/null +++ b/cef3/include/cef_response.h @@ -0,0 +1,120 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_RESPONSE_H_ +#define CEF_INCLUDE_CEF_RESPONSE_H_ +#pragma once + +#include "include/cef_base.h" +#include + +/// +// Class used to represent a web response. The methods of this class may be +// called on any thread. +/// +/*--cef(source=library,no_debugct_check)--*/ +class CefResponse : public virtual CefBase { + public: + typedef std::multimap HeaderMap; + + /// + // Create a new CefResponse object. + /// + /*--cef()--*/ + static CefRefPtr Create(); + + /// + // Returns true if this object is read-only. + /// + /*--cef()--*/ + virtual bool IsReadOnly() =0; + + /// + // Get the response status code. + /// + /*--cef()--*/ + virtual int GetStatus() =0; + + /// + // Set the response status code. + /// + /*--cef()--*/ + virtual void SetStatus(int status) = 0; + + /// + // Get the response status text. + /// + /*--cef()--*/ + virtual CefString GetStatusText() =0; + + /// + // Set the response status text. + /// + /*--cef()--*/ + virtual void SetStatusText(const CefString& statusText) = 0; + + /// + // Get the response mime type. + /// + /*--cef()--*/ + virtual CefString GetMimeType() = 0; + + /// + // Set the response mime type. + /// + /*--cef()--*/ + virtual void SetMimeType(const CefString& mimeType) = 0; + + /// + // Get the value for the specified response header field. + /// + /*--cef()--*/ + virtual CefString GetHeader(const CefString& name) =0; + + /// + // Get all response header fields. + /// + /*--cef()--*/ + virtual void GetHeaderMap(HeaderMap& headerMap) =0; + + /// + // Set all response header fields. + /// + /*--cef()--*/ + virtual void SetHeaderMap(const HeaderMap& headerMap) =0; +}; + +#endif // CEF_INCLUDE_CEF_RESPONSE_H_ diff --git a/cef3/include/cef_runnable.h b/cef3/include/cef_runnable.h new file mode 100644 index 000000000..37ad0efe2 --- /dev/null +++ b/cef3/include/cef_runnable.h @@ -0,0 +1,346 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. Portions Copyright (c) +// 2006-2011 Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The contents of this file are a modified extract of base/task.h + +#ifndef CEF_INCLUDE_CEF_RUNNABLE_H_ +#define CEF_INCLUDE_CEF_RUNNABLE_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_task.h" +#ifdef BUILDING_CEF_SHARED +#include "base/tuple.h" +#else +#include "internal/cef_tuple.h" +#endif + +// CefRunnableMethodTraits ----------------------------------------------------- +// +// This traits-class is used by CefRunnableMethod to manage the lifetime of the +// callee object. By default, it is assumed that the callee supports AddRef +// and Release methods. A particular class can specialize this template to +// define other lifetime management. For example, if the callee is known to +// live longer than the CefRunnableMethod object, then a CefRunnableMethodTraits +// struct could be defined with empty RetainCallee and ReleaseCallee methods. +// +// The DISABLE_RUNNABLE_METHOD_REFCOUNT macro is provided as a convenient way +// for declaring a CefRunnableMethodTraits that disables refcounting. + +template +struct CefRunnableMethodTraits { + CefRunnableMethodTraits() { + } + + ~CefRunnableMethodTraits() { + } + + void RetainCallee(T* obj) { +#ifndef NDEBUG + // Catch NewCefRunnableMethod being called in an object's constructor. + // This isn't safe since the method can be invoked before the constructor + // completes, causing the object to be deleted. + obj->AddRef(); + obj->Release(); +#endif + obj->AddRef(); + } + + void ReleaseCallee(T* obj) { + obj->Release(); + } +}; + +// Convenience macro for declaring a CefRunnableMethodTraits that disables +// refcounting of a class. This is useful if you know that the callee +// will outlive the CefRunnableMethod object and thus do not need the ref +// counts. +// +// The invocation of DISABLE_RUNNABLE_METHOD_REFCOUNT should be done at the +// global namespace scope. Example: +// +// namespace foo { +// class Bar { +// ... +// }; +// } // namespace foo +// +// DISABLE_RUNNABLE_METHOD_REFCOUNT(foo::Bar); +// +// This is different from DISALLOW_COPY_AND_ASSIGN which is declared inside the +// class. +#define DISABLE_RUNNABLE_METHOD_REFCOUNT(TypeName) \ + template <> \ + struct CefRunnableMethodTraits { \ + void RetainCallee(TypeName* manager) {} \ + void ReleaseCallee(TypeName* manager) {} \ + } + +// CefRunnableMethod and CefRunnableFunction ---------------------------------- +// +// CefRunnable methods are a type of task that call a function on an object +// when they are run. We implement both an object and a set of +// NewCefRunnableMethod and NewCefRunnableFunction functions for convenience. +// These functions are overloaded and will infer the template types, +// simplifying calling code. +// +// The template definitions all use the following names: +// T - the class type of the object you're supplying +// this is not needed for the Static version of the call +// Method/Function - the signature of a pointer to the method or function you +// want to call +// Param - the parameter(s) to the method, possibly packed as a Tuple +// A - the first parameter (if any) to the method +// B - the second parameter (if any) to the method +// +// Put these all together and you get an object that can call a method whose +// signature is: +// R T::MyFunction([A[, B]]) +// +// Usage: +// CefPostTask(TID_UI, NewCefRunnableMethod(object, &Object::method[, a[, b]]) +// CefPostTask(TID_UI, NewCefRunnableFunction(&function[, a[, b]]) + +// CefRunnableMethod and NewCefRunnableMethod implementation ------------------ + +template +class CefRunnableMethod : public CefTask { + public: + CefRunnableMethod(T* obj, Method meth, const Params& params) + : obj_(obj), meth_(meth), params_(params) { + traits_.RetainCallee(obj_); + } + + ~CefRunnableMethod() { + T* obj = obj_; + obj_ = NULL; + if (obj) + traits_.ReleaseCallee(obj); + } + + virtual void Execute() { + if (obj_) + DispatchToMethod(obj_, meth_, params_); + } + + private: + T* obj_; + Method meth_; + Params params_; + CefRunnableMethodTraits traits_; + + IMPLEMENT_REFCOUNTING(CefRunnableMethod); +}; + +template +inline CefRefPtr NewCefRunnableMethod(T* object, Method method) { + return new CefRunnableMethod(object, method, MakeTuple()); +} + +template +inline CefRefPtr NewCefRunnableMethod(T* object, Method method, + const A& a) { + return new CefRunnableMethod >(object, + method, + MakeTuple(a)); +} + +template +inline CefRefPtr NewCefRunnableMethod(T* object, Method method, + const A& a, const B& b) { + return new CefRunnableMethod >(object, method, + MakeTuple(a, b)); +} + +template +inline CefRefPtr NewCefRunnableMethod(T* object, Method method, + const A& a, const B& b, + const C& c) { + return new CefRunnableMethod >(object, method, + MakeTuple(a, b, + c)); +} + +template +inline CefRefPtr NewCefRunnableMethod(T* object, Method method, + const A& a, const B& b, + const C& c, const D& d) { + return new CefRunnableMethod >(object, method, + MakeTuple(a, b, + c, + d)); +} + +template +inline CefRefPtr NewCefRunnableMethod(T* object, Method method, + const A& a, const B& b, + const C& c, const D& d, + const E& e) { + return new CefRunnableMethod >(object, + method, + MakeTuple(a, b, c, d, + e)); +} + +template +inline CefRefPtr NewCefRunnableMethod(T* object, Method method, + const A& a, const B& b, + const C& c, const D& d, + const E& e, const F& f) { + return new CefRunnableMethod >(object, + method, + MakeTuple(a, b, c, d, + e, f)); +} + +template +inline CefRefPtr NewCefRunnableMethod(T* object, Method method, + const A& a, const B& b, + const C& c, const D& d, + const E& e, const F& f, + const G& g) { + return new CefRunnableMethod >(object, + method, + MakeTuple(a, b, c, + d, e, f, + g)); +} + +// CefRunnableFunction and NewCefRunnableFunction implementation -------------- + +template +class CefRunnableFunction : public CefTask { + public: + CefRunnableFunction(Function function, const Params& params) + : function_(function), params_(params) { + } + + ~CefRunnableFunction() { + } + + virtual void Execute() { + if (function_) + DispatchToFunction(function_, params_); + } + + private: + Function function_; + Params params_; + + IMPLEMENT_REFCOUNTING(CefRunnableFunction); +}; + +template +inline CefRefPtr NewCefRunnableFunction(Function function) { + return new CefRunnableFunction(function, MakeTuple()); +} + +template +inline CefRefPtr NewCefRunnableFunction(Function function, + const A& a) { + return new CefRunnableFunction >(function, MakeTuple(a)); +} + +template +inline CefRefPtr NewCefRunnableFunction(Function function, + const A& a, const B& b) { + return new CefRunnableFunction >(function, + MakeTuple(a, b)); +} + +template +inline CefRefPtr NewCefRunnableFunction(Function function, + const A& a, const B& b, + const C& c) { + return new CefRunnableFunction >(function, + MakeTuple(a, b, + c)); +} + +template +inline CefRefPtr NewCefRunnableFunction(Function function, + const A& a, const B& b, + const C& c, const D& d) { + return new CefRunnableFunction >(function, + MakeTuple(a, b, + c, + d)); +} + +template +inline CefRefPtr NewCefRunnableFunction(Function function, + const A& a, const B& b, + const C& c, const D& d, + const E& e) { + return new CefRunnableFunction >(function, + MakeTuple(a, b, c, d, e)); +} + +template +inline CefRefPtr NewCefRunnableFunction(Function function, + const A& a, const B& b, + const C& c, const D& d, + const E& e, const F& f) { + return new CefRunnableFunction >(function, + MakeTuple(a, b, c, d, e, f)); +} + +template +inline CefRefPtr NewCefRunnableFunction(Function function, + const A& a, const B& b, + const C& c, const D& d, + const E& e, const F& f, + const G& g) { + return new CefRunnableFunction >( + function, MakeTuple(a, b, c, d, e, f, g)); +} + +template +inline CefRefPtr NewCefRunnableFunction(Function function, + const A& a, const B& b, + const C& c, const D& d, + const E& e, const F& f, + const G& g, const H& h) { + return new CefRunnableFunction >( + function, MakeTuple(a, b, c, d, e, f, g, h)); +} + +#endif // CEF_INCLUDE_CEF_RUNNABLE_H_ diff --git a/cef3/include/cef_scheme.h b/cef3/include/cef_scheme.h new file mode 100644 index 000000000..a32a3b690 --- /dev/null +++ b/cef3/include/cef_scheme.h @@ -0,0 +1,160 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_SCHEME_H_ +#define CEF_INCLUDE_CEF_SCHEME_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser.h" +#include "include/cef_frame.h" +#include "include/cef_request.h" +#include "include/cef_response.h" +#include "include/cef_resource_handler.h" + +class CefSchemeHandlerFactory; + + +/// +// Register a scheme handler factory for the specified |scheme_name| and +// optional |domain_name|. An empty |domain_name| value for a standard scheme +// will cause the factory to match all domain names. The |domain_name| value +// will be ignored for non-standard schemes. If |scheme_name| is a built-in +// scheme and no handler is returned by |factory| then the built-in scheme +// handler factory will be called. If |scheme_name| is a custom scheme the +// CefRegisterCustomScheme() function should be called for that scheme. +// This function may be called multiple times to change or remove the factory +// that matches the specified |scheme_name| and optional |domain_name|. +// Returns false if an error occurs. This function may be called on any thread. +/// +/*--cef(optional_param=domain_name,optional_param=factory)--*/ +bool CefRegisterSchemeHandlerFactory( + const CefString& scheme_name, + const CefString& domain_name, + CefRefPtr factory); + +/// +// Clear all registered scheme handler factories. Returns false on error. This +// function may be called on any thread. +/// +/*--cef()--*/ +bool CefClearSchemeHandlerFactories(); + + +/// +// Class that manages custom scheme registrations. +/// +/*--cef(source=library)--*/ +class CefSchemeRegistrar : public virtual CefBase { + public: + /// + // Register a custom scheme. This method should not be called for the built-in + // HTTP, HTTPS, FILE, FTP, ABOUT and DATA schemes. + // + // If |is_standard| is true the scheme will be treated as a standard scheme. + // Standard schemes are subject to URL canonicalization and parsing rules as + // defined in the Common Internet Scheme Syntax RFC 1738 Section 3.1 available + // at http://www.ietf.org/rfc/rfc1738.txt + // + // In particular, the syntax for standard scheme URLs must be of the form: + //
+  //  [scheme]://[username]:[password]@[host]:[port]/[url-path]
+  // 
+ // Standard scheme URLs must have a host component that is a fully qualified + // domain name as defined in Section 3.5 of RFC 1034 [13] and Section 2.1 of + // RFC 1123. These URLs will be canonicalized to "scheme://host/path" in the + // simplest case and "scheme://username:password@host:port/path" in the most + // explicit case. For example, "scheme:host/path" and "scheme:///host/path" + // will both be canonicalized to "scheme://host/path". The origin of a + // standard scheme URL is the combination of scheme, host and port (i.e., + // "scheme://host:port" in the most explicit case). + // + // For non-standard scheme URLs only the "scheme:" component is parsed and + // canonicalized. The remainder of the URL will be passed to the handler + // as-is. For example, "scheme:///some%20text" will remain the same. + // Non-standard scheme URLs cannot be used as a target for form submission. + // + // If |is_local| is true the scheme will be treated as local (i.e., with the + // same security rules as those applied to "file" URLs). Normal pages cannot + // link to or access local URLs. Also, by default, local URLs can only perform + // XMLHttpRequest calls to the same URL (origin + path) that originated the + // request. To allow XMLHttpRequest calls from a local URL to other URLs with + // the same origin set the CefSettings.file_access_from_file_urls_allowed + // value to true. To allow XMLHttpRequest calls from a local URL to all + // origins set the CefSettings.universal_access_from_file_urls_allowed value + // to true. + // + // If |is_display_isolated| is true the scheme will be treated as display- + // isolated. This means that pages cannot display these URLs unless they are + // from the same scheme. For example, pages in another origin cannot create + // iframes or hyperlinks to URLs with this scheme. + // + // This function may be called on any thread. It should only be called once + // per unique |scheme_name| value. If |scheme_name| is already registered or + // if an error occurs this method will return false. + /// + /*--cef()--*/ + virtual bool AddCustomScheme(const CefString& scheme_name, + bool is_standard, + bool is_local, + bool is_display_isolated) =0; +}; + + +/// +// Class that creates CefResourceHandler instances for handling scheme requests. +// The methods of this class will always be called on the IO thread. +/// +/*--cef(source=client)--*/ +class CefSchemeHandlerFactory : public virtual CefBase { + public: + /// + // Return a new resource handler instance to handle the request or an empty + // reference to allow default handling of the request. |browser| and |frame| + // will be the browser window and frame respectively that originated the + // request or NULL if the request did not originate from a browser window + // (for example, if the request came from CefURLRequest). The |request| object + // passed to this method will not contain cookie data. + /// + /*--cef(optional_param=browser,optional_param=frame)--*/ + virtual CefRefPtr Create( + CefRefPtr browser, + CefRefPtr frame, + const CefString& scheme_name, + CefRefPtr request) =0; +}; + +#endif // CEF_INCLUDE_CEF_SCHEME_H_ diff --git a/cef3/include/cef_stream.h b/cef3/include/cef_stream.h new file mode 100644 index 000000000..6ccec8dec --- /dev/null +++ b/cef3/include/cef_stream.h @@ -0,0 +1,210 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_STREAM_H_ +#define CEF_INCLUDE_CEF_STREAM_H_ + +#include "include/cef_base.h" + +/// +// Interface the client can implement to provide a custom stream reader. The +// methods of this class may be called on any thread. +/// +/*--cef(source=client)--*/ +class CefReadHandler : public virtual CefBase { + public: + /// + // Read raw binary data. + /// + /*--cef()--*/ + virtual size_t Read(void* ptr, size_t size, size_t n) =0; + + /// + // Seek to the specified offset position. |whence| may be any one of + // SEEK_CUR, SEEK_END or SEEK_SET. Return zero on success and non-zero on + // failure. + /// + /*--cef()--*/ + virtual int Seek(int64 offset, int whence) =0; + + /// + // Return the current offset position. + /// + /*--cef()--*/ + virtual int64 Tell() =0; + + /// + // Return non-zero if at end of file. + /// + /*--cef()--*/ + virtual int Eof() =0; +}; + + +/// +// Class used to read data from a stream. The methods of this class may be +// called on any thread. +/// +/*--cef(source=library)--*/ +class CefStreamReader : public virtual CefBase { + public: + /// + // Create a new CefStreamReader object from a file. + /// + /*--cef()--*/ + static CefRefPtr CreateForFile(const CefString& fileName); + /// + // Create a new CefStreamReader object from data. + /// + /*--cef()--*/ + static CefRefPtr CreateForData(void* data, size_t size); + /// + // Create a new CefStreamReader object from a custom handler. + /// + /*--cef()--*/ + static CefRefPtr CreateForHandler( + CefRefPtr handler); + + /// + // Read raw binary data. + /// + /*--cef()--*/ + virtual size_t Read(void* ptr, size_t size, size_t n) =0; + + /// + // Seek to the specified offset position. |whence| may be any one of + // SEEK_CUR, SEEK_END or SEEK_SET. Returns zero on success and non-zero on + // failure. + /// + /*--cef()--*/ + virtual int Seek(int64 offset, int whence) =0; + + /// + // Return the current offset position. + /// + /*--cef()--*/ + virtual int64 Tell() =0; + + /// + // Return non-zero if at end of file. + /// + /*--cef()--*/ + virtual int Eof() =0; +}; + + +/// +// Interface the client can implement to provide a custom stream writer. The +// methods of this class may be called on any thread. +/// +/*--cef(source=client)--*/ +class CefWriteHandler : public virtual CefBase { + public: + /// + // Write raw binary data. + /// + /*--cef()--*/ + virtual size_t Write(const void* ptr, size_t size, size_t n) =0; + + /// + // Seek to the specified offset position. |whence| may be any one of + // SEEK_CUR, SEEK_END or SEEK_SET. Return zero on success and non-zero on + // failure. + /// + /*--cef()--*/ + virtual int Seek(int64 offset, int whence) =0; + + /// + // Return the current offset position. + /// + /*--cef()--*/ + virtual int64 Tell() =0; + + /// + // Flush the stream. + /// + /*--cef()--*/ + virtual int Flush() =0; +}; + + +/// +// Class used to write data to a stream. The methods of this class may be called +// on any thread. +/// +/*--cef(source=library)--*/ +class CefStreamWriter : public virtual CefBase { + public: + /// + // Create a new CefStreamWriter object for a file. + /// + /*--cef()--*/ + static CefRefPtr CreateForFile(const CefString& fileName); + /// + // Create a new CefStreamWriter object for a custom handler. + /// + /*--cef()--*/ + static CefRefPtr CreateForHandler( + CefRefPtr handler); + + /// + // Write raw binary data. + /// + /*--cef()--*/ + virtual size_t Write(const void* ptr, size_t size, size_t n) =0; + + /// + // Seek to the specified offset position. |whence| may be any one of + // SEEK_CUR, SEEK_END or SEEK_SET. Returns zero on success and non-zero on + // failure. + /// + /*--cef()--*/ + virtual int Seek(int64 offset, int whence) =0; + + /// + // Return the current offset position. + /// + /*--cef()--*/ + virtual int64 Tell() =0; + + /// + // Flush the stream. + /// + /*--cef()--*/ + virtual int Flush() =0; +}; + +#endif // CEF_INCLUDE_CEF_STREAM_H_ diff --git a/cef3/include/cef_string_visitor.h b/cef3/include/cef_string_visitor.h new file mode 100644 index 000000000..79c9b1cbc --- /dev/null +++ b/cef3/include/cef_string_visitor.h @@ -0,0 +1,55 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_STRING_VISITOR_H_ +#define CEF_INCLUDE_CEF_STRING_VISITOR_H_ + +#include "include/cef_base.h" + +/// +// Implement this interface to receive string values asynchronously. +/// +/*--cef(source=client)--*/ +class CefStringVisitor : public virtual CefBase { + public: + /// + // Method that will be executed. + /// + /*--cef()--*/ + virtual void Visit(const CefString& string) =0; +}; + +#endif // CEF_INCLUDE_CEF_STRING_VISITOR_H_ diff --git a/cef3/include/cef_task.h b/cef3/include/cef_task.h new file mode 100644 index 000000000..0ecaa7526 --- /dev/null +++ b/cef3/include/cef_task.h @@ -0,0 +1,148 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_TASK_H_ +#define CEF_INCLUDE_CEF_TASK_H_ + +#include "include/cef_base.h" + +typedef cef_thread_id_t CefThreadId; + +/// +// Implement this interface for asynchronous task execution. If the task is +// posted successfully and if the associated message loop is still running then +// the Execute() method will be called on the target thread. If the task fails +// to post then the task object may be destroyed on the source thread instead of +// the target thread. For this reason be cautious when performing work in the +// task object destructor. +/// +/*--cef(source=client)--*/ +class CefTask : public virtual CefBase { + public: + /// + // Method that will be executed on the target thread. + /// + /*--cef()--*/ + virtual void Execute() =0; +}; + +/// +// Class that asynchronously executes tasks on the associated thread. It is safe +// to call the methods of this class on any thread. +// +// CEF maintains multiple internal threads that are used for handling different +// types of tasks in different processes. The cef_thread_id_t definitions in +// cef_types.h list the common CEF threads. Task runners are also available for +// other CEF threads as appropriate (for example, V8 WebWorker threads). +/// +/*--cef(source=library)--*/ +class CefTaskRunner : public virtual CefBase { + public: + /// + // Returns the task runner for the current thread. Only CEF threads will have + // task runners. An empty reference will be returned if this method is called + // on an invalid thread. + /// + /*--cef()--*/ + static CefRefPtr GetForCurrentThread(); + + /// + // Returns the task runner for the specified CEF thread. + /// + /*--cef()--*/ + static CefRefPtr GetForThread(CefThreadId threadId); + + /// + // Returns true if this object is pointing to the same task runner as |that| + // object. + /// + /*--cef()--*/ + virtual bool IsSame(CefRefPtr that) =0; + + /// + // Returns true if this task runner belongs to the current thread. + /// + /*--cef()--*/ + virtual bool BelongsToCurrentThread() =0; + + /// + // Returns true if this task runner is for the specified CEF thread. + /// + /*--cef()--*/ + virtual bool BelongsToThread(CefThreadId threadId) =0; + + /// + // Post a task for execution on the thread associated with this task runner. + // Execution will occur asynchronously. + /// + /*--cef()--*/ + virtual bool PostTask(CefRefPtr task) =0; + + /// + // Post a task for delayed execution on the thread associated with this task + // runner. Execution will occur asynchronously. Delayed tasks are not + // supported on V8 WebWorker threads and will be executed without the + // specified delay. + /// + /*--cef()--*/ + virtual bool PostDelayedTask(CefRefPtr task, int64 delay_ms) =0; +}; + + +/// +// Returns true if called on the specified thread. Equivalent to using +// CefTaskRunner::GetForThread(threadId)->BelongsToCurrentThread(). +/// +/*--cef()--*/ +bool CefCurrentlyOn(CefThreadId threadId); + +/// +// Post a task for execution on the specified thread. Equivalent to +// using CefTaskRunner::GetForThread(threadId)->PostTask(task). +/// +/*--cef()--*/ +bool CefPostTask(CefThreadId threadId, CefRefPtr task); + +/// +// Post a task for delayed execution on the specified thread. Equivalent to +// using CefTaskRunner::GetForThread(threadId)->PostDelayedTask(task, delay_ms). +/// +/*--cef()--*/ +bool CefPostDelayedTask(CefThreadId threadId, CefRefPtr task, + int64 delay_ms); + + +#endif // CEF_INCLUDE_CEF_TASK_H_ diff --git a/cef3/include/cef_trace.h b/cef3/include/cef_trace.h new file mode 100644 index 000000000..a2cf2966c --- /dev/null +++ b/cef3/include/cef_trace.h @@ -0,0 +1,132 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. Portons copyright (c) 2012 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +// See cef_trace_event.h for trace macros and additonal documentation. + +#ifndef CEF_INCLUDE_CEF_TRACE_H_ +#define CEF_INCLUDE_CEF_TRACE_H_ +#pragma once + +#include "include/cef_base.h" + +/// +// Implement this interface to receive trace notifications. The methods of this +// class will be called on the browser process UI thread. +/// +/*--cef(source=client)--*/ +class CefTraceClient : public virtual CefBase { + public: + /// + // Called 0 or more times between CefBeginTracing and OnEndTracingComplete + // with a UTF8 JSON |fragment| of the specified |fragment_size|. Do not keep + // a reference to |fragment|. + /// + /*--cef()--*/ + virtual void OnTraceDataCollected(const char* fragment, + size_t fragment_size) {} + + /// + // Called in response to CefGetTraceBufferPercentFullAsync. + /// + /*--cef()--*/ + virtual void OnTraceBufferPercentFullReply(float percent_full) {} + + /// + // Called after all processes have sent their trace data. + /// + /*--cef()--*/ + virtual void OnEndTracingComplete() {} +}; + + +/// +// Start tracing events on all processes. Tracing begins immediately locally, +// and asynchronously on child processes as soon as they receive the +// BeginTracing request. +// +// If CefBeginTracing was called previously, or if a CefEndTracingAsync call is +// pending, CefBeginTracing will fail and return false. +// +// |categories| is a comma-delimited list of category wildcards. A category can +// have an optional '-' prefix to make it an excluded category. Having both +// included and excluded categories in the same list is not supported. +// +// Example: "test_MyTest*" +// Example: "test_MyTest*,test_OtherStuff" +// Example: "-excluded_category1,-excluded_category2" +// +// This function must be called on the browser process UI thread. +/// +/*--cef(optional_param=client,optional_param=categories)--*/ +bool CefBeginTracing(CefRefPtr client, + const CefString& categories); + +/// +// Get the maximum trace buffer percent full state across all processes. +// +// CefTraceClient::OnTraceBufferPercentFullReply will be called asynchronously +// after the value is determined. When any child process reaches 100% full +// tracing will end automatically and CefTraceClient::OnEndTracingComplete +// will be called. This function fails and returns false if trace is ending or +// disabled, no CefTraceClient was passed to CefBeginTracing, or if a previous +// call to CefGetTraceBufferPercentFullAsync is pending. +// +// This function must be called on the browser process UI thread. +/// +/*--cef()--*/ +bool CefGetTraceBufferPercentFullAsync(); + +/// +// Stop tracing events on all processes. +// +// This function will fail and return false if a previous call to +// CefEndTracingAsync is already pending or if CefBeginTracing was not called. +// +// This function must be called on the browser process UI thread. +/// +/*--cef()--*/ +bool CefEndTracingAsync(); + +/// +// Returns the current system trace time or, if none is defined, the current +// high-res time. Can be used by clients to synchronize with the time +// information in trace events. +/// +/*--cef()--*/ +int64 CefNowFromSystemTraceTime(); + +#endif // CEF_INCLUDE_CEF_TRACE_H_ diff --git a/cef3/include/cef_trace_event.h b/cef3/include/cef_trace_event.h new file mode 100644 index 000000000..7fee2183f --- /dev/null +++ b/cef3/include/cef_trace_event.h @@ -0,0 +1,439 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +/// +// Trace events are for tracking application performance and resource usage. +// Macros are provided to track: +// Begin and end of function calls +// Counters +// +// Events are issued against categories. Whereas LOG's categories are statically +// defined, TRACE categories are created implicitly with a string. For example: +// CEF_TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent") +// +// Events can be INSTANT, or can be pairs of BEGIN and END in the same scope: +// CEF_TRACE_EVENT_BEGIN0("MY_SUBSYSTEM", "SomethingCostly") +// doSomethingCostly() +// CEF_TRACE_EVENT_END0("MY_SUBSYSTEM", "SomethingCostly") +// Note: Our tools can't always determine the correct BEGIN/END pairs unless +// these are used in the same scope. Use ASYNC_BEGIN/ASYNC_END macros if you +// need them to be in separate scopes. +// +// A common use case is to trace entire function scopes. This issues a trace +// BEGIN and END automatically: +// void doSomethingCostly() { +// CEF_TRACE_EVENT0("MY_SUBSYSTEM", "doSomethingCostly"); +// ... +// } +// +// Additional parameters can be associated with an event: +// void doSomethingCostly2(int howMuch) { +// CEF_TRACE_EVENT1("MY_SUBSYSTEM", "doSomethingCostly", +// "howMuch", howMuch); +// ... +// } +// +// The trace system will automatically add to this information the current +// process id, thread id, and a timestamp in microseconds. +// +// To trace an asynchronous procedure such as an IPC send/receive, use +// ASYNC_BEGIN and ASYNC_END: +// [single threaded sender code] +// static int send_count = 0; +// ++send_count; +// CEF_TRACE_EVENT_ASYNC_BEGIN0("ipc", "message", send_count); +// Send(new MyMessage(send_count)); +// [receive code] +// void OnMyMessage(send_count) { +// CEF_TRACE_EVENT_ASYNC_END0("ipc", "message", send_count); +// } +// The third parameter is a unique ID to match ASYNC_BEGIN/ASYNC_END pairs. +// ASYNC_BEGIN and ASYNC_END can occur on any thread of any traced process. +// Pointers can be used for the ID parameter, and they will be mangled +// internally so that the same pointer on two different processes will not +// match. For example: +// class MyTracedClass { +// public: +// MyTracedClass() { +// CEF_TRACE_EVENT_ASYNC_BEGIN0("category", "MyTracedClass", this); +// } +// ~MyTracedClass() { +// CEF_TRACE_EVENT_ASYNC_END0("category", "MyTracedClass", this); +// } +// } +// +// The trace event also supports counters, which is a way to track a quantity +// as it varies over time. Counters are created with the following macro: +// CEF_TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter", g_myCounterValue); +// +// Counters are process-specific. The macro itself can be issued from any +// thread, however. +// +// Sometimes, you want to track two counters at once. You can do this with two +// counter macros: +// CEF_TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter0", g_myCounterValue[0]); +// CEF_TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter1", g_myCounterValue[1]); +// Or you can do it with a combined macro: +// CEF_TRACE_COUNTER2("MY_SUBSYSTEM", "myCounter", +// "bytesPinned", g_myCounterValue[0], +// "bytesAllocated", g_myCounterValue[1]); +// This indicates to the tracing UI that these counters should be displayed +// in a single graph, as a summed area chart. +// +// Since counters are in a global namespace, you may want to disembiguate with a +// unique ID, by using the CEF_TRACE_COUNTER_ID* variations. +// +// By default, trace collection is compiled in, but turned off at runtime. +// Collecting trace data is the responsibility of the embedding application. In +// CEF's case, calling BeginTracing will turn on tracing on all active +// processes. +// +// +// Memory scoping note: +// Tracing copies the pointers, not the string content, of the strings passed +// in for category, name, and arg_names. Thus, the following code will cause +// problems: +// char* str = strdup("impprtantName"); +// CEF_TRACE_EVENT_INSTANT0("SUBSYSTEM", str); // BAD! +// free(str); // Trace system now has dangling pointer +// +// To avoid this issue with the |name| and |arg_name| parameters, use the +// CEF_TRACE_EVENT_COPY_XXX overloads of the macros at additional runtime +// overhead. +// Notes: The category must always be in a long-lived char* (i.e. static const). +// The |arg_values|, when used, are always deep copied with the _COPY +// macros. +// +// +// Thread Safety: +// All macros are thread safe and can be used from any process. +/// + +#ifndef CEF_INCLUDE_CEF_TRACE_EVENT_H_ +#define CEF_INCLUDE_CEF_TRACE_EVENT_H_ +#pragma once + +#include "include/internal/cef_export.h" +#include "include/internal/cef_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Functions for tracing counters and functions; called from macros. +// - |category| string must have application lifetime (static or literal). They +// may not include "(quotes) chars. +// - |argX_name|, |argX_val|, |valueX_name|, |valeX_val| are optional parameters +// and represent pairs of name and values of arguments +// - |copy| is used to avoid memory scoping issues with the |name| and +// |arg_name| parameters by copying them +// - |id| is used to disambiguate counters with the same name, or match async +// trace events + +CEF_EXPORT void cef_trace_event(const char* category, + const char* name, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val); +CEF_EXPORT void cef_trace_event_instant(const char* category, + const char* name, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy); +CEF_EXPORT void cef_trace_event_begin(const char* category, + const char* name, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy); +CEF_EXPORT void cef_trace_event_end(const char* category, + const char* name, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy); +CEF_EXPORT void cef_trace_counter(const char* category, + const char* name, + const char* value1_name, + uint64 value1_val, + const char* value2_name, + uint64 value2_val, + int copy); +CEF_EXPORT void cef_trace_counter_id(const char* category, + const char* name, + uint64 id, + const char* value1_name, + uint64 value1_val, + const char* value2_name, + uint64 value2_val, + int copy); +CEF_EXPORT void cef_trace_event_async_begin(const char* category, + const char* name, + uint64 id, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy); +CEF_EXPORT void cef_trace_event_async_step(const char* category, + const char* name, + uint64 id, + uint64 step, + const char* arg1_name, + uint64 arg1_val, + int copy); +CEF_EXPORT void cef_trace_event_async_end(const char* category, + const char* name, + uint64 id, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy); + +#ifdef __cplusplus +} +#endif + +// Records a pair of begin and end events called "name" for the current +// scope, with 0, 1 or 2 associated arguments. If the category is not +// enabled, then this does nothing. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +#define CEF_TRACE_EVENT0(category, name) \ + cef_trace_event(category, name, NULL, 0, NULL, 0) +#define CEF_TRACE_EVENT1(category, name, arg1_name, arg1_val) \ + cef_trace_event(category, name, arg1_name, arg1_val, NULL, 0) +#define CEF_TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val) \ + cef_trace_event(category, name, arg1_name, arg1_val, arg2_name, arg2_val) + +// Records a single event called "name" immediately, with 0, 1 or 2 +// associated arguments. If the category is not enabled, then this +// does nothing. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +#define CEF_TRACE_EVENT_INSTANT0(category, name) \ + cef_trace_event_instant(category, name, NULL, 0, NULL, 0, false) +#define CEF_TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val) \ + cef_trace_event_instant(category, name, arg1_name, arg1_val, NULL, 0, false) +#define CEF_TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, \ + arg2_name, arg2_val) \ + cef_trace_event_instant(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, false) +#define CEF_TRACE_EVENT_COPY_INSTANT0(category, name) \ + cef_trace_event_instant(category, name, NULL, 0, NULL, 0, true) +#define CEF_TRACE_EVENT_COPY_INSTANT1(category, name, arg1_name, arg1_val) \ + cef_trace_event_instant(category, name, arg1_name, arg1_val, NULL, 0, true) +#define CEF_TRACE_EVENT_COPY_INSTANT2(category, name, arg1_name, arg1_val, \ + arg2_name, arg2_val) \ + cef_trace_event_instant(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, true) + +// Records a single BEGIN event called "name" immediately, with 0, 1 or 2 +// associated arguments. If the category is not enabled, then this +// does nothing. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +#define CEF_TRACE_EVENT_BEGIN0(category, name) \ + cef_trace_event_begin(category, name, NULL, 0, NULL, 0, false) +#define CEF_TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) \ + cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, false) +#define CEF_TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, \ + arg2_name, arg2_val) \ + cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, false) +#define CEF_TRACE_EVENT_COPY_BEGIN0(category, name) \ + cef_trace_event_begin(category, name, NULL, 0, NULL, 0, true) +#define CEF_TRACE_EVENT_COPY_BEGIN1(category, name, arg1_name, arg1_val) \ + cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, true) +#define CEF_TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, \ + arg2_name, arg2_val) \ + cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, true) + +// Records a single END event for "name" immediately. If the category +// is not enabled, then this does nothing. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +#define CEF_TRACE_EVENT_END0(category, name) \ + cef_trace_event_end(category, name, NULL, 0, NULL, 0, false) +#define CEF_TRACE_EVENT_END1(category, name, arg1_name, arg1_val) \ + cef_trace_event_end(category, name, arg1_name, arg1_val, NULL, 0, false) +#define CEF_TRACE_EVENT_END2(category, name, arg1_name, arg1_val, \ + arg2_name, arg2_val) \ + cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, false) +#define CEF_TRACE_EVENT_COPY_END0(category, name) \ + cef_trace_event_end(category, name, NULL, 0, NULL, 0, true) +#define CEF_TRACE_EVENT_COPY_END1(category, name, arg1_name, arg1_val) \ + cef_trace_event_end(category, name, arg1_name, arg1_val, NULL, 0, true) +#define CEF_TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, \ + arg2_name, arg2_val) \ + cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, true) + +// Records the value of a counter called "name" immediately. Value +// must be representable as a 32 bit integer. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +#define CEF_TRACE_COUNTER1(category, name, value) \ + cef_trace_counter(category, name, NULL, value, NULL, 0, false) +#define CEF_TRACE_COPY_COUNTER1(category, name, value) \ + cef_trace_counter(category, name, NULL, value, NULL, 0, true) + +// Records the values of a multi-parted counter called "name" immediately. +// The UI will treat value1 and value2 as parts of a whole, displaying their +// values as a stacked-bar chart. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +#define CEF_TRACE_COUNTER2(category, name, value1_name, value1_val, \ + value2_name, value2_val) \ + cef_trace_counter(category, name, value1_name, value1_val, value2_name, \ + value2_val, false) +#define CEF_TRACE_COPY_COUNTER2(category, name, value1_name, value1_val, \ + value2_name, value2_val) \ + cef_trace_counter(category, name, value1_name, value1_val, value2_name, \ + value2_val, true) + +// Records the value of a counter called "name" immediately. Value +// must be representable as a 32 bit integer. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +// - |id| is used to disambiguate counters with the same name. It must either +// be a pointer or an integer value up to 64 bits. If it's a pointer, the +// bits will be xored with a hash of the process ID so that the same pointer +// on two different processes will not collide. +#define CEF_TRACE_COUNTER_ID1(category, name, id, value) \ + cef_trace_counter_id(category, name, id, NULL, value, NULL, 0, false) +#define CEF_TRACE_COPY_COUNTER_ID1(category, name, id, value) \ + cef_trace_counter_id(category, name, id, NULL, value, NULL, 0, true) + +// Records the values of a multi-parted counter called "name" immediately. +// The UI will treat value1 and value2 as parts of a whole, displaying their +// values as a stacked-bar chart. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +// - |id| is used to disambiguate counters with the same name. It must either +// be a pointer or an integer value up to 64 bits. If it's a pointer, the +// bits will be xored with a hash of the process ID so that the same pointer +// on two different processes will not collide. +#define CEF_TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, \ + value2_name, value2_val) \ + cef_trace_counter_id(category, name, id, value1_name, value1_val, \ + value2_name, value2_val, false) +#define CEF_TRACE_COPY_COUNTER_ID2(category, name, id, value1_name, \ + value1_val, value2_name, value2_val) \ + cef_trace_counter_id(category, name, id, value1_name, value1_val, \ + value2_name, value2_val, true) + + +// Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2 +// associated arguments. If the category is not enabled, then this +// does nothing. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +// - |id| is used to match the ASYNC_BEGIN event with the ASYNC_END event. +// ASYNC events are considered to match if their category, name and id values +// all match. |id| must either be a pointer or an integer value up to 64 +// bits. If it's a pointer, the bits will be xored with a hash of the process +// ID sothat the same pointer on two different processes will not collide. +// An asynchronous operation can consist of multiple phases. The first phase is +// defined by the ASYNC_BEGIN calls. Additional phases can be defined using the +// ASYNC_STEP_BEGIN macros. When the operation completes, call ASYNC_END. +// An async operation can span threads and processes, but all events in that +// operation must use the same |name| and |id|. Each event can have its own +// args. +#define CEF_TRACE_EVENT_ASYNC_BEGIN0(category, name, id) \ + cef_trace_event_async_begin(category, name, id, NULL, 0, NULL, 0, false) +#define CEF_TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \ + cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, NULL, \ + 0, false) +#define CEF_TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val) \ + cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val, false) +#define CEF_TRACE_EVENT_COPY_ASYNC_BEGIN0(category, name, id) \ + cef_trace_event_async_begin(category, name, id, NULL, 0, NULL, 0, true) +#define CEF_TRACE_EVENT_COPY_ASYNC_BEGIN1(category, name, id, arg1_name, \ + arg1_val) \ + cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, NULL, \ + 0, true) +#define CEF_TRACE_EVENT_COPY_ASYNC_BEGIN2(category, name, id, arg1_name, \ + arg1_val, arg2_name, arg2_val) \ + cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val, true) + +// Records a single ASYNC_STEP event for |step| immediately. If the category +// is not enabled, then this does nothing. The |name| and |id| must match the +// ASYNC_BEGIN event above. The |step| param identifies this step within the +// async event. This should be called at the beginning of the next phase of an +// asynchronous operation. +#define CEF_TRACE_EVENT_ASYNC_STEP0(category, name, id, step) \ + cef_trace_event_async_step(category, name, id, step, NULL, 0, false) +#define CEF_TRACE_EVENT_ASYNC_STEP1(category, name, id, step, \ + arg1_name, arg1_val) \ + cef_trace_event_async_step(category, name, id, step, arg1_name, arg1_val, \ + false) +#define CEF_TRACE_EVENT_COPY_ASYNC_STEP0(category, name, id, step) \ + cef_trace_event_async_step(category, name, id, step, NULL, 0, true) +#define CEF_TRACE_EVENT_COPY_ASYNC_STEP1(category, name, id, step, \ + arg1_name, arg1_val) \ + cef_trace_event_async_step(category, name, id, step, arg1_name, arg1_val, \ + true) + +// Records a single ASYNC_END event for "name" immediately. If the category +// is not enabled, then this does nothing. +#define CEF_TRACE_EVENT_ASYNC_END0(category, name, id) \ + cef_trace_event_async_end(category, name, id, NULL, 0, NULL, 0, false) +#define CEF_TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val) \ + cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, NULL, 0, \ + false) +#define CEF_TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val) \ + cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val, false) +#define CEF_TRACE_EVENT_COPY_ASYNC_END0(category, name, id) \ + cef_trace_event_async_end(category, name, id, NULL, 0, NULL, 0, true) +#define CEF_TRACE_EVENT_COPY_ASYNC_END1(category, name, id, arg1_name, \ + arg1_val) \ + cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, NULL, 0, \ + true) +#define CEF_TRACE_EVENT_COPY_ASYNC_END2(category, name, id, arg1_name, \ + arg1_val, arg2_name, arg2_val) \ + cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val, true) + +#endif // CEF_INCLUDE_CEF_TRACE_EVENT_H_ diff --git a/cef3/include/cef_url.h b/cef3/include/cef_url.h new file mode 100644 index 000000000..c5cb21aaf --- /dev/null +++ b/cef3/include/cef_url.h @@ -0,0 +1,60 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_URL_H_ +#define CEF_INCLUDE_CEF_URL_H_ +#pragma once + +#include "include/cef_base.h" + +/// +// Parse the specified |url| into its component parts. +// Returns false if the URL is empty or invalid. +/// +/*--cef()--*/ +bool CefParseURL(const CefString& url, + CefURLParts& parts); + +/// +// Creates a URL from the specified |parts|, which must contain a non-empty +// spec or a non-empty host and path (at a minimum), but not both. +// Returns false if |parts| isn't initialized as described. +/// +/*--cef()--*/ +bool CefCreateURL(const CefURLParts& parts, + CefString& url); + +#endif // CEF_INCLUDE_CEF_URL_H_ diff --git a/cef3/include/cef_urlrequest.h b/cef3/include/cef_urlrequest.h new file mode 100644 index 000000000..069d2668c --- /dev/null +++ b/cef3/include/cef_urlrequest.h @@ -0,0 +1,159 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_URLREQUEST_H_ +#define CEF_INCLUDE_CEF_URLREQUEST_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_request.h" +#include "include/cef_response.h" + +class CefURLRequestClient; + +/// +// Class used to make a URL request. URL requests are not associated with a +// browser instance so no CefClient callbacks will be executed. URL requests +// can be created on any valid CEF thread in either the browser or render +// process. Once created the methods of the URL request object must be accessed +// on the same thread that created it. +/// +/*--cef(source=library)--*/ +class CefURLRequest : public virtual CefBase { + public: + typedef cef_urlrequest_status_t Status; + typedef cef_errorcode_t ErrorCode; + + /// + // Create a new URL request. Only GET, POST, HEAD, DELETE and PUT request + // methods are supported. The |request| object will be marked as read-only + // after calling this method. + /// + /*--cef()--*/ + static CefRefPtr Create( + CefRefPtr request, + CefRefPtr client); + + /// + // Returns the request object used to create this URL request. The returned + // object is read-only and should not be modified. + /// + /*--cef()--*/ + virtual CefRefPtr GetRequest() =0; + + /// + // Returns the client. + /// + /*--cef()--*/ + virtual CefRefPtr GetClient() =0; + + /// + // Returns the request status. + /// + /*--cef(default_retval=UR_UNKNOWN)--*/ + virtual Status GetRequestStatus() =0; + + /// + // Returns the request error if status is UR_CANCELED or UR_FAILED, or 0 + // otherwise. + /// + /*--cef(default_retval=ERR_NONE)--*/ + virtual ErrorCode GetRequestError() =0; + + /// + // Returns the response, or NULL if no response information is available. + // Response information will only be available after the upload has completed. + // The returned object is read-only and should not be modified. + /// + /*--cef()--*/ + virtual CefRefPtr GetResponse() =0; + + /// + // Cancel the request. + /// + /*--cef()--*/ + virtual void Cancel() =0; +}; + +/// +// Interface that should be implemented by the CefURLRequest client. The +// methods of this class will be called on the same thread that created the +// request. +/// +/*--cef(source=client)--*/ +class CefURLRequestClient : public virtual CefBase { + public: + /// + // Notifies the client that the request has completed. Use the + // CefURLRequest::GetRequestStatus method to determine if the request was + // successful or not. + /// + /*--cef()--*/ + virtual void OnRequestComplete(CefRefPtr request) =0; + + /// + // Notifies the client of upload progress. |current| denotes the number of + // bytes sent so far and |total| is the total size of uploading data (or -1 if + // chunked upload is enabled). This method will only be called if the + // UR_FLAG_REPORT_UPLOAD_PROGRESS flag is set on the request. + /// + /*--cef()--*/ + virtual void OnUploadProgress(CefRefPtr request, + uint64 current, + uint64 total) =0; + + /// + // Notifies the client of download progress. |current| denotes the number of + // bytes received up to the call and |total| is the expected total size of the + // response (or -1 if not determined). + /// + /*--cef()--*/ + virtual void OnDownloadProgress(CefRefPtr request, + uint64 current, + uint64 total) =0; + + /// + // Called when some part of the response is read. |data| contains the current + // bytes received since the last call. This method will not be called if the + // UR_FLAG_NO_DOWNLOAD_DATA flag is set on the request. + /// + /*--cef()--*/ + virtual void OnDownloadData(CefRefPtr request, + const void* data, + size_t data_length) =0; +}; + +#endif // CEF_INCLUDE_CEF_URLREQUEST_H_ diff --git a/cef3/include/cef_v8.h b/cef3/include/cef_v8.h new file mode 100644 index 000000000..3f05b802e --- /dev/null +++ b/cef3/include/cef_v8.h @@ -0,0 +1,879 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + + +#ifndef CEF_INCLUDE_CEF_V8_H_ +#define CEF_INCLUDE_CEF_V8_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser.h" +#include "include/cef_frame.h" +#include "include/cef_task.h" +#include + +class CefV8Exception; +class CefV8Handler; +class CefV8StackFrame; +class CefV8Value; + + +/// +// Register a new V8 extension with the specified JavaScript extension code and +// handler. Functions implemented by the handler are prototyped using the +// keyword 'native'. The calling of a native function is restricted to the scope +// in which the prototype of the native function is defined. This function may +// only be called on the render process main thread. +// +// Example JavaScript extension code: +//
+//   // create the 'example' global object if it doesn't already exist.
+//   if (!example)
+//     example = {};
+//   // create the 'example.test' global object if it doesn't already exist.
+//   if (!example.test)
+//     example.test = {};
+//   (function() {
+//     // Define the function 'example.test.myfunction'.
+//     example.test.myfunction = function() {
+//       // Call CefV8Handler::Execute() with the function name 'MyFunction'
+//       // and no arguments.
+//       native function MyFunction();
+//       return MyFunction();
+//     };
+//     // Define the getter function for parameter 'example.test.myparam'.
+//     example.test.__defineGetter__('myparam', function() {
+//       // Call CefV8Handler::Execute() with the function name 'GetMyParam'
+//       // and no arguments.
+//       native function GetMyParam();
+//       return GetMyParam();
+//     });
+//     // Define the setter function for parameter 'example.test.myparam'.
+//     example.test.__defineSetter__('myparam', function(b) {
+//       // Call CefV8Handler::Execute() with the function name 'SetMyParam'
+//       // and a single argument.
+//       native function SetMyParam();
+//       if(b) SetMyParam(b);
+//     });
+//
+//     // Extension definitions can also contain normal JavaScript variables
+//     // and functions.
+//     var myint = 0;
+//     example.test.increment = function() {
+//       myint += 1;
+//       return myint;
+//     };
+//   })();
+// 
+// Example usage in the page: +//
+//   // Call the function.
+//   example.test.myfunction();
+//   // Set the parameter.
+//   example.test.myparam = value;
+//   // Get the parameter.
+//   value = example.test.myparam;
+//   // Call another function.
+//   example.test.increment();
+// 
+/// +/*--cef(optional_param=handler)--*/ +bool CefRegisterExtension(const CefString& extension_name, + const CefString& javascript_code, + CefRefPtr handler); + + +/// +// Class representing a V8 context handle. V8 handles can only be accessed from +// the thread on which they are created. Valid threads for creating a V8 handle +// include the render process main thread (TID_RENDERER) and WebWorker threads. +// A task runner for posting tasks on the associated thread can be retrieved via +// the CefV8Context::GetTaskRunner() method. +/// +/*--cef(source=library)--*/ +class CefV8Context : public virtual CefBase { + public: + /// + // Returns the current (top) context object in the V8 context stack. + /// + /*--cef()--*/ + static CefRefPtr GetCurrentContext(); + + /// + // Returns the entered (bottom) context object in the V8 context stack. + /// + /*--cef()--*/ + static CefRefPtr GetEnteredContext(); + + /// + // Returns true if V8 is currently inside a context. + /// + /*--cef()--*/ + static bool InContext(); + + /// + // Returns the task runner associated with this context. V8 handles can only + // be accessed from the thread on which they are created. This method can be + // called on any render process thread. + /// + /*--cef()--*/ + virtual CefRefPtr GetTaskRunner() =0; + + /// + // Returns true if the underlying handle is valid and it can be accessed on + // the current thread. Do not call any other methods if this method returns + // false. + /// + /*--cef()--*/ + virtual bool IsValid() =0; + + /// + // Returns the browser for this context. This method will return an empty + // reference for WebWorker contexts. + /// + /*--cef()--*/ + virtual CefRefPtr GetBrowser() =0; + + /// + // Returns the frame for this context. This method will return an empty + // reference for WebWorker contexts. + /// + /*--cef()--*/ + virtual CefRefPtr GetFrame() =0; + + /// + // Returns the global object for this context. The context must be entered + // before calling this method. + /// + /*--cef()--*/ + virtual CefRefPtr GetGlobal() =0; + + /// + // Enter this context. A context must be explicitly entered before creating a + // V8 Object, Array, Function or Date asynchronously. Exit() must be called + // the same number of times as Enter() before releasing this context. V8 + // objects belong to the context in which they are created. Returns true if + // the scope was entered successfully. + /// + /*--cef()--*/ + virtual bool Enter() =0; + + /// + // Exit this context. Call this method only after calling Enter(). Returns + // true if the scope was exited successfully. + /// + /*--cef()--*/ + virtual bool Exit() =0; + + /// + // Returns true if this object is pointing to the same handle as |that| + // object. + /// + /*--cef()--*/ + virtual bool IsSame(CefRefPtr that) =0; + + /// + // Evaluates the specified JavaScript code using this context's global object. + // On success |retval| will be set to the return value, if any, and the + // function will return true. On failure |exception| will be set to the + // exception, if any, and the function will return false. + /// + /*--cef()--*/ + virtual bool Eval(const CefString& code, + CefRefPtr& retval, + CefRefPtr& exception) =0; +}; + + +typedef std::vector > CefV8ValueList; + +/// +// Interface that should be implemented to handle V8 function calls. The methods +// of this class will be called on the thread associated with the V8 function. +/// +/*--cef(source=client)--*/ +class CefV8Handler : public virtual CefBase { + public: + /// + // Handle execution of the function identified by |name|. |object| is the + // receiver ('this' object) of the function. |arguments| is the list of + // arguments passed to the function. If execution succeeds set |retval| to the + // function return value. If execution fails set |exception| to the exception + // that will be thrown. Return true if execution was handled. + /// + /*--cef()--*/ + virtual bool Execute(const CefString& name, + CefRefPtr object, + const CefV8ValueList& arguments, + CefRefPtr& retval, + CefString& exception) =0; +}; + +/// +// Interface that should be implemented to handle V8 accessor calls. Accessor +// identifiers are registered by calling CefV8Value::SetValue(). The methods +// of this class will be called on the thread associated with the V8 accessor. +/// +/*--cef(source=client)--*/ +class CefV8Accessor : public virtual CefBase { + public: + /// + // Handle retrieval the accessor value identified by |name|. |object| is the + // receiver ('this' object) of the accessor. If retrieval succeeds set + // |retval| to the return value. If retrieval fails set |exception| to the + // exception that will be thrown. Return true if accessor retrieval was + // handled. + /// + /*--cef()--*/ + virtual bool Get(const CefString& name, + const CefRefPtr object, + CefRefPtr& retval, + CefString& exception) =0; + + /// + // Handle assignment of the accessor value identified by |name|. |object| is + // the receiver ('this' object) of the accessor. |value| is the new value + // being assigned to the accessor. If assignment fails set |exception| to the + // exception that will be thrown. Return true if accessor assignment was + // handled. + /// + /*--cef()--*/ + virtual bool Set(const CefString& name, + const CefRefPtr object, + const CefRefPtr value, + CefString& exception) =0; +}; + +/// +// Class representing a V8 exception. The methods of this class may be called on +// any render process thread. +/// +/*--cef(source=library)--*/ +class CefV8Exception : public virtual CefBase { + public: + /// + // Returns the exception message. + /// + /*--cef()--*/ + virtual CefString GetMessage() =0; + + /// + // Returns the line of source code that the exception occurred within. + /// + /*--cef()--*/ + virtual CefString GetSourceLine() =0; + + /// + // Returns the resource name for the script from where the function causing + // the error originates. + /// + /*--cef()--*/ + virtual CefString GetScriptResourceName() =0; + + /// + // Returns the 1-based number of the line where the error occurred or 0 if the + // line number is unknown. + /// + /*--cef()--*/ + virtual int GetLineNumber() =0; + + /// + // Returns the index within the script of the first character where the error + // occurred. + /// + /*--cef()--*/ + virtual int GetStartPosition() =0; + + /// + // Returns the index within the script of the last character where the error + // occurred. + /// + /*--cef()--*/ + virtual int GetEndPosition() =0; + + /// + // Returns the index within the line of the first character where the error + // occurred. + /// + /*--cef()--*/ + virtual int GetStartColumn() =0; + + /// + // Returns the index within the line of the last character where the error + // occurred. + /// + /*--cef()--*/ + virtual int GetEndColumn() =0; +}; + +/// +// Class representing a V8 value handle. V8 handles can only be accessed from +// the thread on which they are created. Valid threads for creating a V8 handle +// include the render process main thread (TID_RENDERER) and WebWorker threads. +// A task runner for posting tasks on the associated thread can be retrieved via +// the CefV8Context::GetTaskRunner() method. +/// +/*--cef(source=library)--*/ +class CefV8Value : public virtual CefBase { + public: + typedef cef_v8_accesscontrol_t AccessControl; + typedef cef_v8_propertyattribute_t PropertyAttribute; + + /// + // Create a new CefV8Value object of type undefined. + /// + /*--cef()--*/ + static CefRefPtr CreateUndefined(); + + /// + // Create a new CefV8Value object of type null. + /// + /*--cef()--*/ + static CefRefPtr CreateNull(); + + /// + // Create a new CefV8Value object of type bool. + /// + /*--cef()--*/ + static CefRefPtr CreateBool(bool value); + + /// + // Create a new CefV8Value object of type int. + /// + /*--cef()--*/ + static CefRefPtr CreateInt(int32 value); + + /// + // Create a new CefV8Value object of type unsigned int. + /// + /*--cef()--*/ + static CefRefPtr CreateUInt(uint32 value); + + /// + // Create a new CefV8Value object of type double. + /// + /*--cef()--*/ + static CefRefPtr CreateDouble(double value); + + /// + // Create a new CefV8Value object of type Date. This method should only be + // called from within the scope of a CefV8ContextHandler, CefV8Handler or + // CefV8Accessor callback, or in combination with calling Enter() and Exit() + // on a stored CefV8Context reference. + /// + /*--cef()--*/ + static CefRefPtr CreateDate(const CefTime& date); + + /// + // Create a new CefV8Value object of type string. + /// + /*--cef(optional_param=value)--*/ + static CefRefPtr CreateString(const CefString& value); + + /// + // Create a new CefV8Value object of type object with optional accessor. This + // method should only be called from within the scope of a + // CefV8ContextHandler, CefV8Handler or CefV8Accessor callback, or in + // combination with calling Enter() and Exit() on a stored CefV8Context + // reference. + /// + /*--cef(optional_param=accessor)--*/ + static CefRefPtr CreateObject(CefRefPtr accessor); + + /// + // Create a new CefV8Value object of type array with the specified |length|. + // If |length| is negative the returned array will have length 0. This method + // should only be called from within the scope of a CefV8ContextHandler, + // CefV8Handler or CefV8Accessor callback, or in combination with calling + // Enter() and Exit() on a stored CefV8Context reference. + /// + /*--cef()--*/ + static CefRefPtr CreateArray(int length); + + /// + // Create a new CefV8Value object of type function. This method should only be + // called from within the scope of a CefV8ContextHandler, CefV8Handler or + // CefV8Accessor callback, or in combination with calling Enter() and Exit() + // on a stored CefV8Context reference. + /// + /*--cef()--*/ + static CefRefPtr CreateFunction(const CefString& name, + CefRefPtr handler); + + /// + // Returns true if the underlying handle is valid and it can be accessed on + // the current thread. Do not call any other methods if this method returns + // false. + /// + /*--cef()--*/ + virtual bool IsValid() =0; + + /// + // True if the value type is undefined. + /// + /*--cef()--*/ + virtual bool IsUndefined() =0; + + /// + // True if the value type is null. + /// + /*--cef()--*/ + virtual bool IsNull() =0; + + /// + // True if the value type is bool. + /// + /*--cef()--*/ + virtual bool IsBool() =0; + + /// + // True if the value type is int. + /// + /*--cef()--*/ + virtual bool IsInt() =0; + + /// + // True if the value type is unsigned int. + /// + /*--cef()--*/ + virtual bool IsUInt() =0; + + /// + // True if the value type is double. + /// + /*--cef()--*/ + virtual bool IsDouble() =0; + + /// + // True if the value type is Date. + /// + /*--cef()--*/ + virtual bool IsDate() =0; + + /// + // True if the value type is string. + /// + /*--cef()--*/ + virtual bool IsString() =0; + + /// + // True if the value type is object. + /// + /*--cef()--*/ + virtual bool IsObject() =0; + + /// + // True if the value type is array. + /// + /*--cef()--*/ + virtual bool IsArray() =0; + + /// + // True if the value type is function. + /// + /*--cef()--*/ + virtual bool IsFunction() =0; + + /// + // Returns true if this object is pointing to the same handle as |that| + // object. + /// + /*--cef()--*/ + virtual bool IsSame(CefRefPtr that) =0; + + /// + // Return a bool value. The underlying data will be converted to if + // necessary. + /// + /*--cef()--*/ + virtual bool GetBoolValue() =0; + + /// + // Return an int value. The underlying data will be converted to if + // necessary. + /// + /*--cef()--*/ + virtual int32 GetIntValue() =0; + + /// + // Return an unisgned int value. The underlying data will be converted to if + // necessary. + /// + /*--cef()--*/ + virtual uint32 GetUIntValue() =0; + + /// + // Return a double value. The underlying data will be converted to if + // necessary. + /// + /*--cef()--*/ + virtual double GetDoubleValue() =0; + + /// + // Return a Date value. The underlying data will be converted to if + // necessary. + /// + /*--cef()--*/ + virtual CefTime GetDateValue() =0; + + /// + // Return a string value. The underlying data will be converted to if + // necessary. + /// + /*--cef()--*/ + virtual CefString GetStringValue() =0; + + + // OBJECT METHODS - These methods are only available on objects. Arrays and + // functions are also objects. String- and integer-based keys can be used + // interchangably with the framework converting between them as necessary. + + /// + // Returns true if this is a user created object. + /// + /*--cef()--*/ + virtual bool IsUserCreated() =0; + + /// + // Returns true if the last method call resulted in an exception. This + // attribute exists only in the scope of the current CEF value object. + /// + /*--cef()--*/ + virtual bool HasException() =0; + + /// + // Returns the exception resulting from the last method call. This attribute + // exists only in the scope of the current CEF value object. + /// + /*--cef()--*/ + virtual CefRefPtr GetException() =0; + + /// + // Clears the last exception and returns true on success. + /// + /*--cef()--*/ + virtual bool ClearException() =0; + + /// + // Returns true if this object will re-throw future exceptions. This attribute + // exists only in the scope of the current CEF value object. + /// + /*--cef()--*/ + virtual bool WillRethrowExceptions() =0; + + /// + // Set whether this object will re-throw future exceptions. By default + // exceptions are not re-thrown. If a exception is re-thrown the current + // context should not be accessed again until after the exception has been + // caught and not re-thrown. Returns true on success. This attribute exists + // only in the scope of the current CEF value object. + /// + /*--cef()--*/ + virtual bool SetRethrowExceptions(bool rethrow) =0; + + /// + // Returns true if the object has a value with the specified identifier. + /// + /*--cef(capi_name=has_value_bykey,optional_param=key)--*/ + virtual bool HasValue(const CefString& key) =0; + + /// + // Returns true if the object has a value with the specified identifier. + /// + /*--cef(capi_name=has_value_byindex,index_param=index)--*/ + virtual bool HasValue(int index) =0; + + /// + // Deletes the value with the specified identifier and returns true on + // success. Returns false if this method is called incorrectly or an exception + // is thrown. For read-only and don't-delete values this method will return + // true even though deletion failed. + /// + /*--cef(capi_name=delete_value_bykey,optional_param=key)--*/ + virtual bool DeleteValue(const CefString& key) =0; + + /// + // Deletes the value with the specified identifier and returns true on + // success. Returns false if this method is called incorrectly, deletion fails + // or an exception is thrown. For read-only and don't-delete values this + // method will return true even though deletion failed. + /// + /*--cef(capi_name=delete_value_byindex,index_param=index)--*/ + virtual bool DeleteValue(int index) =0; + + /// + // Returns the value with the specified identifier on success. Returns NULL + // if this method is called incorrectly or an exception is thrown. + /// + /*--cef(capi_name=get_value_bykey,optional_param=key)--*/ + virtual CefRefPtr GetValue(const CefString& key) =0; + + /// + // Returns the value with the specified identifier on success. Returns NULL + // if this method is called incorrectly or an exception is thrown. + /// + /*--cef(capi_name=get_value_byindex,index_param=index)--*/ + virtual CefRefPtr GetValue(int index) =0; + + /// + // Associates a value with the specified identifier and returns true on + // success. Returns false if this method is called incorrectly or an exception + // is thrown. For read-only values this method will return true even though + // assignment failed. + /// + /*--cef(capi_name=set_value_bykey,optional_param=key)--*/ + virtual bool SetValue(const CefString& key, CefRefPtr value, + PropertyAttribute attribute) =0; + + /// + // Associates a value with the specified identifier and returns true on + // success. Returns false if this method is called incorrectly or an exception + // is thrown. For read-only values this method will return true even though + // assignment failed. + /// + /*--cef(capi_name=set_value_byindex,index_param=index)--*/ + virtual bool SetValue(int index, CefRefPtr value) =0; + + /// + // Registers an identifier and returns true on success. Access to the + // identifier will be forwarded to the CefV8Accessor instance passed to + // CefV8Value::CreateObject(). Returns false if this method is called + // incorrectly or an exception is thrown. For read-only values this method + // will return true even though assignment failed. + /// + /*--cef(capi_name=set_value_byaccessor,optional_param=key)--*/ + virtual bool SetValue(const CefString& key, AccessControl settings, + PropertyAttribute attribute) =0; + + /// + // Read the keys for the object's values into the specified vector. Integer- + // based keys will also be returned as strings. + /// + /*--cef()--*/ + virtual bool GetKeys(std::vector& keys) =0; + + /// + // Sets the user data for this object and returns true on success. Returns + // false if this method is called incorrectly. This method can only be called + // on user created objects. + /// + /*--cef(optional_param=user_data)--*/ + virtual bool SetUserData(CefRefPtr user_data) =0; + + /// + // Returns the user data, if any, assigned to this object. + /// + /*--cef()--*/ + virtual CefRefPtr GetUserData() =0; + + /// + // Returns the amount of externally allocated memory registered for the + // object. + /// + /*--cef()--*/ + virtual int GetExternallyAllocatedMemory() =0; + + /// + // Adjusts the amount of registered external memory for the object. Used to + // give V8 an indication of the amount of externally allocated memory that is + // kept alive by JavaScript objects. V8 uses this information to decide when + // to perform global garbage collection. Each CefV8Value tracks the amount of + // external memory associated with it and automatically decreases the global + // total by the appropriate amount on its destruction. |change_in_bytes| + // specifies the number of bytes to adjust by. This method returns the number + // of bytes associated with the object after the adjustment. This method can + // only be called on user created objects. + /// + /*--cef()--*/ + virtual int AdjustExternallyAllocatedMemory(int change_in_bytes) =0; + + + // ARRAY METHODS - These methods are only available on arrays. + + /// + // Returns the number of elements in the array. + /// + /*--cef()--*/ + virtual int GetArrayLength() =0; + + + // FUNCTION METHODS - These methods are only available on functions. + + /// + // Returns the function name. + /// + /*--cef()--*/ + virtual CefString GetFunctionName() =0; + + /// + // Returns the function handler or NULL if not a CEF-created function. + /// + /*--cef()--*/ + virtual CefRefPtr GetFunctionHandler() =0; + + /// + // Execute the function using the current V8 context. This method should only + // be called from within the scope of a CefV8Handler or CefV8Accessor + // callback, or in combination with calling Enter() and Exit() on a stored + // CefV8Context reference. |object| is the receiver ('this' object) of the + // function. If |object| is empty the current context's global object will be + // used. |arguments| is the list of arguments that will be passed to the + // function. Returns the function return value on success. Returns NULL if + // this method is called incorrectly or an exception is thrown. + /// + /*--cef(optional_param=object)--*/ + virtual CefRefPtr ExecuteFunction( + CefRefPtr object, + const CefV8ValueList& arguments) =0; + + /// + // Execute the function using the specified V8 context. |object| is the + // receiver ('this' object) of the function. If |object| is empty the + // specified context's global object will be used. |arguments| is the list of + // arguments that will be passed to the function. Returns the function return + // value on success. Returns NULL if this method is called incorrectly or an + // exception is thrown. + /// + /*--cef(optional_param=object)--*/ + virtual CefRefPtr ExecuteFunctionWithContext( + CefRefPtr context, + CefRefPtr object, + const CefV8ValueList& arguments) =0; +}; + +/// +// Class representing a V8 stack trace handle. V8 handles can only be accessed +// from the thread on which they are created. Valid threads for creating a V8 +// handle include the render process main thread (TID_RENDERER) and WebWorker +// threads. A task runner for posting tasks on the associated thread can be +// retrieved via the CefV8Context::GetTaskRunner() method. +/// +/*--cef(source=library)--*/ +class CefV8StackTrace : public virtual CefBase { + public: + /// + // Returns the stack trace for the currently active context. |frame_limit| is + // the maximum number of frames that will be captured. + /// + /*--cef()--*/ + static CefRefPtr GetCurrent(int frame_limit); + + /// + // Returns true if the underlying handle is valid and it can be accessed on + // the current thread. Do not call any other methods if this method returns + // false. + /// + /*--cef()--*/ + virtual bool IsValid() =0; + + /// + // Returns the number of stack frames. + /// + /*--cef()--*/ + virtual int GetFrameCount() =0; + + /// + // Returns the stack frame at the specified 0-based index. + /// + /*--cef()--*/ + virtual CefRefPtr GetFrame(int index) =0; +}; + +/// +// Class representing a V8 stack frame handle. V8 handles can only be accessed +// from the thread on which they are created. Valid threads for creating a V8 +// handle include the render process main thread (TID_RENDERER) and WebWorker +// threads. A task runner for posting tasks on the associated thread can be +// retrieved via the CefV8Context::GetTaskRunner() method. +/// +/*--cef(source=library)--*/ +class CefV8StackFrame : public virtual CefBase { + public: + /// + // Returns true if the underlying handle is valid and it can be accessed on + // the current thread. Do not call any other methods if this method returns + // false. + /// + /*--cef()--*/ + virtual bool IsValid() =0; + + /// + // Returns the name of the resource script that contains the function. + /// + /*--cef()--*/ + virtual CefString GetScriptName() =0; + + /// + // Returns the name of the resource script that contains the function or the + // sourceURL value if the script name is undefined and its source ends with + // a "//@ sourceURL=..." string. + /// + /*--cef()--*/ + virtual CefString GetScriptNameOrSourceURL() =0; + + /// + // Returns the name of the function. + /// + /*--cef()--*/ + virtual CefString GetFunctionName() =0; + + /// + // Returns the 1-based line number for the function call or 0 if unknown. + /// + /*--cef()--*/ + virtual int GetLineNumber() =0; + + /// + // Returns the 1-based column offset on the line for the function call or 0 if + // unknown. + /// + /*--cef()--*/ + virtual int GetColumn() =0; + + /// + // Returns true if the function was compiled using eval(). + /// + /*--cef()--*/ + virtual bool IsEval() =0; + + /// + // Returns true if the function was called as a constructor via "new". + /// + /*--cef()--*/ + virtual bool IsConstructor() =0; +}; + +#endif // CEF_INCLUDE_CEF_V8_H_ diff --git a/cef3/include/cef_values.h b/cef3/include/cef_values.h new file mode 100644 index 000000000..9a640ab77 --- /dev/null +++ b/cef3/include/cef_values.h @@ -0,0 +1,471 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_VALUES_H_ +#define CEF_INCLUDE_CEF_VALUES_H_ +#pragma once + +#include +#include "include/cef_base.h" + +class CefDictionaryValue; +class CefListValue; + +typedef cef_value_type_t CefValueType; + +/// +// Class representing a binary value. Can be used on any process and thread. +/// +/*--cef(source=library)--*/ +class CefBinaryValue : public virtual CefBase { + public: + /// + // Creates a new object that is not owned by any other object. The specified + // |data| will be copied. + /// + /*--cef()--*/ + static CefRefPtr Create(const void* data, + size_t data_size); + + /// + // Returns true if this object is valid. Do not call any other methods if this + // method returns false. + /// + /*--cef()--*/ + virtual bool IsValid() =0; + + /// + // Returns true if this object is currently owned by another object. + /// + /*--cef()--*/ + virtual bool IsOwned() =0; + + /// + // Returns a copy of this object. The data in this object will also be copied. + /// + /*--cef()--*/ + virtual CefRefPtr Copy() =0; + + /// + // Returns the data size. + /// + /*--cef()--*/ + virtual size_t GetSize() =0; + + /// + // Read up to |buffer_size| number of bytes into |buffer|. Reading begins at + // the specified byte |data_offset|. Returns the number of bytes read. + /// + /*--cef()--*/ + virtual size_t GetData(void* buffer, + size_t buffer_size, + size_t data_offset) =0; +}; + + +/// +// Class representing a dictionary value. Can be used on any process and thread. +/// +/*--cef(source=library)--*/ +class CefDictionaryValue : public virtual CefBase { + public: + typedef std::vector KeyList; + + /// + // Creates a new object that is not owned by any other object. + /// + /*--cef()--*/ + static CefRefPtr Create(); + + /// + // Returns true if this object is valid. Do not call any other methods if this + // method returns false. + /// + /*--cef()--*/ + virtual bool IsValid() =0; + + /// + // Returns true if this object is currently owned by another object. + /// + /*--cef()--*/ + virtual bool IsOwned() =0; + + /// + // Returns true if the values of this object are read-only. Some APIs may + // expose read-only objects. + /// + /*--cef()--*/ + virtual bool IsReadOnly() =0; + + /// + // Returns a writable copy of this object. If |exclude_empty_children| is true + // any empty dictionaries or lists will be excluded from the copy. + /// + /*--cef()--*/ + virtual CefRefPtr Copy(bool exclude_empty_children) =0; + + /// + // Returns the number of values. + /// + /*--cef()--*/ + virtual size_t GetSize() =0; + + /// + // Removes all values. Returns true on success. + /// + /*--cef()--*/ + virtual bool Clear() =0; + + /// + // Returns true if the current dictionary has a value for the given key. + /// + /*--cef()--*/ + virtual bool HasKey(const CefString& key) =0; + + /// + // Reads all keys for this dictionary into the specified vector. + /// + /*--cef()--*/ + virtual bool GetKeys(KeyList& keys) =0; + + /// + // Removes the value at the specified key. Returns true is the value was + // removed successfully. + /// + /*--cef()--*/ + virtual bool Remove(const CefString& key) =0; + + /// + // Returns the value type for the specified key. + /// + /*--cef(default_retval=VTYPE_INVALID)--*/ + virtual CefValueType GetType(const CefString& key) =0; + + /// + // Returns the value at the specified key as type bool. + /// + /*--cef()--*/ + virtual bool GetBool(const CefString& key) =0; + + /// + // Returns the value at the specified key as type int. + /// + /*--cef()--*/ + virtual int GetInt(const CefString& key) =0; + + /// + // Returns the value at the specified key as type double. + /// + /*--cef()--*/ + virtual double GetDouble(const CefString& key) =0; + + /// + // Returns the value at the specified key as type string. + /// + /*--cef()--*/ + virtual CefString GetString(const CefString& key) =0; + + /// + // Returns the value at the specified key as type binary. + /// + /*--cef()--*/ + virtual CefRefPtr GetBinary(const CefString& key) =0; + + /// + // Returns the value at the specified key as type dictionary. + /// + /*--cef()--*/ + virtual CefRefPtr GetDictionary(const CefString& key) =0; + + /// + // Returns the value at the specified key as type list. + /// + /*--cef()--*/ + virtual CefRefPtr GetList(const CefString& key) =0; + + /// + // Sets the value at the specified key as type null. Returns true if the + // value was set successfully. + /// + /*--cef()--*/ + virtual bool SetNull(const CefString& key) =0; + + /// + // Sets the value at the specified key as type bool. Returns true if the + // value was set successfully. + /// + /*--cef()--*/ + virtual bool SetBool(const CefString& key, bool value) =0; + + /// + // Sets the value at the specified key as type int. Returns true if the + // value was set successfully. + /// + /*--cef()--*/ + virtual bool SetInt(const CefString& key, int value) =0; + + /// + // Sets the value at the specified key as type double. Returns true if the + // value was set successfully. + /// + /*--cef()--*/ + virtual bool SetDouble(const CefString& key, double value) =0; + + /// + // Sets the value at the specified key as type string. Returns true if the + // value was set successfully. + /// + /*--cef(optional_param=value)--*/ + virtual bool SetString(const CefString& key, const CefString& value) =0; + + /// + // Sets the value at the specified key as type binary. Returns true if the + // value was set successfully. If |value| is currently owned by another object + // then the value will be copied and the |value| reference will not change. + // Otherwise, ownership will be transferred to this object and the |value| + // reference will be invalidated. + /// + /*--cef()--*/ + virtual bool SetBinary(const CefString& key, + CefRefPtr value) =0; + + /// + // Sets the value at the specified key as type dict. Returns true if the + // value was set successfully. After calling this method the |value| object + // will no longer be valid. If |value| is currently owned by another object + // then the value will be copied and the |value| reference will not change. + // Otherwise, ownership will be transferred to this object and the |value| + // reference will be invalidated. + /// + /*--cef()--*/ + virtual bool SetDictionary(const CefString& key, + CefRefPtr value) =0; + + /// + // Sets the value at the specified key as type list. Returns true if the + // value was set successfully. After calling this method the |value| object + // will no longer be valid. If |value| is currently owned by another object + // then the value will be copied and the |value| reference will not change. + // Otherwise, ownership will be transferred to this object and the |value| + // reference will be invalidated. + /// + /*--cef()--*/ + virtual bool SetList(const CefString& key, + CefRefPtr value) =0; +}; + + +/// +// Class representing a list value. Can be used on any process and thread. +/// +/*--cef(source=library)--*/ +class CefListValue : public virtual CefBase { + public: + /// + // Creates a new object that is not owned by any other object. + /// + /*--cef()--*/ + static CefRefPtr Create(); + + /// + // Returns true if this object is valid. Do not call any other methods if this + // method returns false. + /// + /*--cef()--*/ + virtual bool IsValid() =0; + + /// + // Returns true if this object is currently owned by another object. + /// + /*--cef()--*/ + virtual bool IsOwned() =0; + + /// + // Returns true if the values of this object are read-only. Some APIs may + // expose read-only objects. + /// + /*--cef()--*/ + virtual bool IsReadOnly() =0; + + /// + // Returns a writable copy of this object. + /// + /*--cef()--*/ + virtual CefRefPtr Copy() =0; + + /// + // Sets the number of values. If the number of values is expanded all + // new value slots will default to type null. Returns true on success. + /// + /*--cef()--*/ + virtual bool SetSize(size_t size) =0; + + /// + // Returns the number of values. + /// + /*--cef()--*/ + virtual size_t GetSize() =0; + + /// + // Removes all values. Returns true on success. + /// + /*--cef()--*/ + virtual bool Clear() =0; + + /// + // Removes the value at the specified index. + /// + /*--cef(index_param=index)--*/ + virtual bool Remove(int index) =0; + + /// + // Returns the value type at the specified index. + /// + /*--cef(default_retval=VTYPE_INVALID,index_param=index)--*/ + virtual CefValueType GetType(int index) =0; + + /// + // Returns the value at the specified index as type bool. + /// + /*--cef(index_param=index)--*/ + virtual bool GetBool(int index) =0; + + /// + // Returns the value at the specified index as type int. + /// + /*--cef(index_param=index)--*/ + virtual int GetInt(int index) =0; + + /// + // Returns the value at the specified index as type double. + /// + /*--cef(index_param=index)--*/ + virtual double GetDouble(int index) =0; + + /// + // Returns the value at the specified index as type string. + /// + /*--cef(index_param=index)--*/ + virtual CefString GetString(int index) =0; + + /// + // Returns the value at the specified index as type binary. + /// + /*--cef(index_param=index)--*/ + virtual CefRefPtr GetBinary(int index) =0; + + /// + // Returns the value at the specified index as type dictionary. + /// + /*--cef(index_param=index)--*/ + virtual CefRefPtr GetDictionary(int index) =0; + + /// + // Returns the value at the specified index as type list. + /// + /*--cef(index_param=index)--*/ + virtual CefRefPtr GetList(int index) =0; + + /// + // Sets the value at the specified index as type null. Returns true if the + // value was set successfully. + /// + /*--cef(index_param=index)--*/ + virtual bool SetNull(int index) =0; + + /// + // Sets the value at the specified index as type bool. Returns true if the + // value was set successfully. + /// + /*--cef(index_param=index)--*/ + virtual bool SetBool(int index, bool value) =0; + + /// + // Sets the value at the specified index as type int. Returns true if the + // value was set successfully. + /// + /*--cef(index_param=index)--*/ + virtual bool SetInt(int index, int value) =0; + + /// + // Sets the value at the specified index as type double. Returns true if the + // value was set successfully. + /// + /*--cef(index_param=index)--*/ + virtual bool SetDouble(int index, double value) =0; + + /// + // Sets the value at the specified index as type string. Returns true if the + // value was set successfully. + /// + /*--cef(optional_param=value,index_param=index)--*/ + virtual bool SetString(int index, const CefString& value) =0; + + /// + // Sets the value at the specified index as type binary. Returns true if the + // value was set successfully. After calling this method the |value| object + // will no longer be valid. If |value| is currently owned by another object + // then the value will be copied and the |value| reference will not change. + // Otherwise, ownership will be transferred to this object and the |value| + // reference will be invalidated. + /// + /*--cef(index_param=index)--*/ + virtual bool SetBinary(int index, CefRefPtr value) =0; + + /// + // Sets the value at the specified index as type dict. Returns true if the + // value was set successfully. After calling this method the |value| object + // will no longer be valid. If |value| is currently owned by another object + // then the value will be copied and the |value| reference will not change. + // Otherwise, ownership will be transferred to this object and the |value| + // reference will be invalidated. + /// + /*--cef(index_param=index)--*/ + virtual bool SetDictionary(int index, CefRefPtr value) =0; + + /// + // Sets the value at the specified index as type list. Returns true if the + // value was set successfully. After calling this method the |value| object + // will no longer be valid. If |value| is currently owned by another object + // then the value will be copied and the |value| reference will not change. + // Otherwise, ownership will be transferred to this object and the |value| + // reference will be invalidated. + /// + /*--cef(index_param=index)--*/ + virtual bool SetList(int index, CefRefPtr value) =0; +}; + +#endif // CEF_INCLUDE_CEF_VALUES_H_ diff --git a/cef3/include/cef_web_plugin.h b/cef3/include/cef_web_plugin.h new file mode 100644 index 000000000..0ff2b8ea1 --- /dev/null +++ b/cef3/include/cef_web_plugin.h @@ -0,0 +1,178 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_WEB_PLUGIN_H_ +#define CEF_INCLUDE_CEF_WEB_PLUGIN_H_ + +#include "include/cef_base.h" +#include "include/cef_browser.h" + +/// +// Information about a specific web plugin. +/// +/*--cef(source=library)--*/ +class CefWebPluginInfo : public virtual CefBase { + public: + /// + // Returns the plugin name (i.e. Flash). + /// + /*--cef()--*/ + virtual CefString GetName() =0; + + /// + // Returns the plugin file path (DLL/bundle/library). + /// + /*--cef()--*/ + virtual CefString GetPath() =0; + + /// + // Returns the version of the plugin (may be OS-specific). + /// + /*--cef()--*/ + virtual CefString GetVersion() =0; + + /// + // Returns a description of the plugin from the version information. + /// + /*--cef()--*/ + virtual CefString GetDescription() =0; +}; + +/// +// Interface to implement for visiting web plugin information. The methods of +// this class will be called on the browser process UI thread. +/// +/*--cef(source=client)--*/ +class CefWebPluginInfoVisitor : public virtual CefBase { + public: + /// + // Method that will be called once for each plugin. |count| is the 0-based + // index for the current plugin. |total| is the total number of plugins. + // Return false to stop visiting plugins. This method may never be called if + // no plugins are found. + /// + /*--cef()--*/ + virtual bool Visit(CefRefPtr info, int count, int total) =0; +}; + +/// +// Visit web plugin information. Can be called on any thread in the browser +// process. +/// +/*--cef()--*/ +void CefVisitWebPluginInfo(CefRefPtr visitor); + +/// +// Cause the plugin list to refresh the next time it is accessed regardless +// of whether it has already been loaded. Can be called on any thread in the +// browser process. +/// +/*--cef()--*/ +void CefRefreshWebPlugins(); + +/// +// Add a plugin path (directory + file). This change may not take affect until +// after CefRefreshWebPlugins() is called. Can be called on any thread in the +// browser process. +/// +/*--cef()--*/ +void CefAddWebPluginPath(const CefString& path); + +/// +// Add a plugin directory. This change may not take affect until after +// CefRefreshWebPlugins() is called. Can be called on any thread in the browser +// process. +/// +/*--cef()--*/ +void CefAddWebPluginDirectory(const CefString& dir); + +/// +// Remove a plugin path (directory + file). This change may not take affect +// until after CefRefreshWebPlugins() is called. Can be called on any thread in +// the browser process. +/// +/*--cef()--*/ +void CefRemoveWebPluginPath(const CefString& path); + +/// +// Unregister an internal plugin. This may be undone the next time +// CefRefreshWebPlugins() is called. Can be called on any thread in the browser +// process. +/// +/*--cef()--*/ +void CefUnregisterInternalWebPlugin(const CefString& path); + +/// +// Force a plugin to shutdown. Can be called on any thread in the browser +// process but will be executed on the IO thread. +/// +/*--cef()--*/ +void CefForceWebPluginShutdown(const CefString& path); + +/// +// Register a plugin crash. Can be called on any thread in the browser process +// but will be executed on the IO thread. +/// +/*--cef()--*/ +void CefRegisterWebPluginCrash(const CefString& path); + +/// +// Interface to implement for receiving unstable plugin information. The methods +// of this class will be called on the browser process IO thread. +/// +/*--cef(source=client)--*/ +class CefWebPluginUnstableCallback : public virtual CefBase { + public: + /// + // Method that will be called for the requested plugin. |unstable| will be + // true if the plugin has reached the crash count threshold of 3 times in 120 + // seconds. + /// + /*--cef()--*/ + virtual void IsUnstable(const CefString& path, + bool unstable) =0; +}; + +/// +// Query if a plugin is unstable. Can be called on any thread in the browser +// process. +/// +/*--cef()--*/ +void CefIsWebPluginUnstable(const CefString& path, + CefRefPtr callback); + + +#endif // CEF_INCLUDE_CEF_WEB_PLUGIN_H_ diff --git a/cef3/include/cef_xml_reader.h b/cef3/include/cef_xml_reader.h new file mode 100644 index 000000000..86be8bac7 --- /dev/null +++ b/cef3/include/cef_xml_reader.h @@ -0,0 +1,268 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_XML_READER_H_ +#define CEF_INCLUDE_CEF_XML_READER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_stream.h" + +/// +// Class that supports the reading of XML data via the libxml streaming API. +// The methods of this class should only be called on the thread that creates +// the object. +/// +/*--cef(source=library)--*/ +class CefXmlReader : public virtual CefBase { + public: + typedef cef_xml_encoding_type_t EncodingType; + typedef cef_xml_node_type_t NodeType; + + /// + // Create a new CefXmlReader object. The returned object's methods can only + // be called from the thread that created the object. + /// + /*--cef()--*/ + static CefRefPtr Create(CefRefPtr stream, + EncodingType encodingType, + const CefString& URI); + + /// + // Moves the cursor to the next node in the document. This method must be + // called at least once to set the current cursor position. Returns true if + // the cursor position was set successfully. + /// + /*--cef()--*/ + virtual bool MoveToNextNode() =0; + + /// + // Close the document. This should be called directly to ensure that cleanup + // occurs on the correct thread. + /// + /*--cef()--*/ + virtual bool Close() =0; + + /// + // Returns true if an error has been reported by the XML parser. + /// + /*--cef()--*/ + virtual bool HasError() =0; + + /// + // Returns the error string. + /// + /*--cef()--*/ + virtual CefString GetError() =0; + + + // The below methods retrieve data for the node at the current cursor + // position. + + /// + // Returns the node type. + /// + /*--cef(default_retval=XML_NODE_UNSUPPORTED)--*/ + virtual NodeType GetType() =0; + + /// + // Returns the node depth. Depth starts at 0 for the root node. + /// + /*--cef()--*/ + virtual int GetDepth() =0; + + /// + // Returns the local name. See + // http://www.w3.org/TR/REC-xml-names/#NT-LocalPart for additional details. + /// + /*--cef()--*/ + virtual CefString GetLocalName() =0; + + /// + // Returns the namespace prefix. See http://www.w3.org/TR/REC-xml-names/ for + // additional details. + /// + /*--cef()--*/ + virtual CefString GetPrefix() =0; + + /// + // Returns the qualified name, equal to (Prefix:)LocalName. See + // http://www.w3.org/TR/REC-xml-names/#ns-qualnames for additional details. + /// + /*--cef()--*/ + virtual CefString GetQualifiedName() =0; + + /// + // Returns the URI defining the namespace associated with the node. See + // http://www.w3.org/TR/REC-xml-names/ for additional details. + /// + /*--cef()--*/ + virtual CefString GetNamespaceURI() =0; + + /// + // Returns the base URI of the node. See http://www.w3.org/TR/xmlbase/ for + // additional details. + /// + /*--cef()--*/ + virtual CefString GetBaseURI() =0; + + /// + // Returns the xml:lang scope within which the node resides. See + // http://www.w3.org/TR/REC-xml/#sec-lang-tag for additional details. + /// + /*--cef()--*/ + virtual CefString GetXmlLang() =0; + + /// + // Returns true if the node represents an empty element. is considered + // empty but is not. + /// + /*--cef()--*/ + virtual bool IsEmptyElement() =0; + + /// + // Returns true if the node has a text value. + /// + /*--cef()--*/ + virtual bool HasValue() =0; + + /// + // Returns the text value. + /// + /*--cef()--*/ + virtual CefString GetValue() =0; + + /// + // Returns true if the node has attributes. + /// + /*--cef()--*/ + virtual bool HasAttributes() =0; + + /// + // Returns the number of attributes. + /// + /*--cef()--*/ + virtual size_t GetAttributeCount() =0; + + /// + // Returns the value of the attribute at the specified 0-based index. + /// + /*--cef(capi_name=get_attribute_byindex,index_param=index)--*/ + virtual CefString GetAttribute(int index) =0; + + /// + // Returns the value of the attribute with the specified qualified name. + /// + /*--cef(capi_name=get_attribute_byqname)--*/ + virtual CefString GetAttribute(const CefString& qualifiedName) =0; + + /// + // Returns the value of the attribute with the specified local name and + // namespace URI. + /// + /*--cef(capi_name=get_attribute_bylname)--*/ + virtual CefString GetAttribute(const CefString& localName, + const CefString& namespaceURI) =0; + + /// + // Returns an XML representation of the current node's children. + /// + /*--cef()--*/ + virtual CefString GetInnerXml() =0; + + /// + // Returns an XML representation of the current node including its children. + /// + /*--cef()--*/ + virtual CefString GetOuterXml() =0; + + /// + // Returns the line number for the current node. + /// + /*--cef()--*/ + virtual int GetLineNumber() =0; + + + // Attribute nodes are not traversed by default. The below methods can be + // used to move the cursor to an attribute node. MoveToCarryingElement() can + // be called afterwards to return the cursor to the carrying element. The + // depth of an attribute node will be 1 + the depth of the carrying element. + + /// + // Moves the cursor to the attribute at the specified 0-based index. Returns + // true if the cursor position was set successfully. + /// + /*--cef(capi_name=move_to_attribute_byindex,index_param=index)--*/ + virtual bool MoveToAttribute(int index) =0; + + /// + // Moves the cursor to the attribute with the specified qualified name. + // Returns true if the cursor position was set successfully. + /// + /*--cef(capi_name=move_to_attribute_byqname)--*/ + virtual bool MoveToAttribute(const CefString& qualifiedName) =0; + + /// + // Moves the cursor to the attribute with the specified local name and + // namespace URI. Returns true if the cursor position was set successfully. + /// + /*--cef(capi_name=move_to_attribute_bylname)--*/ + virtual bool MoveToAttribute(const CefString& localName, + const CefString& namespaceURI) =0; + + /// + // Moves the cursor to the first attribute in the current element. Returns + // true if the cursor position was set successfully. + /// + /*--cef()--*/ + virtual bool MoveToFirstAttribute() =0; + + /// + // Moves the cursor to the next attribute in the current element. Returns + // true if the cursor position was set successfully. + /// + /*--cef()--*/ + virtual bool MoveToNextAttribute() =0; + + /// + // Moves the cursor back to the carrying element. Returns true if the cursor + // position was set successfully. + /// + /*--cef()--*/ + virtual bool MoveToCarryingElement() =0; +}; + +#endif // CEF_INCLUDE_CEF_XML_READER_H_ diff --git a/cef3/include/cef_zip_reader.h b/cef3/include/cef_zip_reader.h new file mode 100644 index 000000000..1fe02b916 --- /dev/null +++ b/cef3/include/cef_zip_reader.h @@ -0,0 +1,141 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_ZIP_READER_H_ +#define CEF_INCLUDE_CEF_ZIP_READER_H_ + +#include "include/cef_base.h" +#include "include/cef_stream.h" + +/// +// Class that supports the reading of zip archives via the zlib unzip API. +// The methods of this class should only be called on the thread that creates +// the object. +/// +/*--cef(source=library)--*/ +class CefZipReader : public virtual CefBase { + public: + /// + // Create a new CefZipReader object. The returned object's methods can only + // be called from the thread that created the object. + /// + /*--cef()--*/ + static CefRefPtr Create(CefRefPtr stream); + + /// + // Moves the cursor to the first file in the archive. Returns true if the + // cursor position was set successfully. + /// + /*--cef()--*/ + virtual bool MoveToFirstFile() =0; + + /// + // Moves the cursor to the next file in the archive. Returns true if the + // cursor position was set successfully. + /// + /*--cef()--*/ + virtual bool MoveToNextFile() =0; + + /// + // Moves the cursor to the specified file in the archive. If |caseSensitive| + // is true then the search will be case sensitive. Returns true if the cursor + // position was set successfully. + /// + /*--cef()--*/ + virtual bool MoveToFile(const CefString& fileName, bool caseSensitive) =0; + + /// + // Closes the archive. This should be called directly to ensure that cleanup + // occurs on the correct thread. + /// + /*--cef()--*/ + virtual bool Close() =0; + + + // The below methods act on the file at the current cursor position. + + /// + // Returns the name of the file. + /// + /*--cef()--*/ + virtual CefString GetFileName() =0; + + /// + // Returns the uncompressed size of the file. + /// + /*--cef()--*/ + virtual int64 GetFileSize() =0; + + /// + // Returns the last modified timestamp for the file. + /// + /*--cef()--*/ + virtual time_t GetFileLastModified() =0; + + /// + // Opens the file for reading of uncompressed data. A read password may + // optionally be specified. + /// + /*--cef(optional_param=password)--*/ + virtual bool OpenFile(const CefString& password) =0; + + /// + // Closes the file. + /// + /*--cef()--*/ + virtual bool CloseFile() =0; + + /// + // Read uncompressed file contents into the specified buffer. Returns < 0 if + // an error occurred, 0 if at the end of file, or the number of bytes read. + /// + /*--cef()--*/ + virtual int ReadFile(void* buffer, size_t bufferSize) =0; + + /// + // Returns the current offset in the uncompressed file contents. + /// + /*--cef()--*/ + virtual int64 Tell() =0; + + /// + // Returns true if at end of the file contents. + /// + /*--cef()--*/ + virtual bool Eof() =0; +}; + +#endif // CEF_INCLUDE_CEF_ZIP_READER_H_ diff --git a/cef3/include/internal/cef_build.h b/cef3/include/internal/cef_build.h new file mode 100644 index 000000000..4b8c54546 --- /dev/null +++ b/cef3/include/internal/cef_build.h @@ -0,0 +1,129 @@ +// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +#ifndef CEF_INCLUDE_INTERNAL_CEF_BUILD_H_ +#define CEF_INCLUDE_INTERNAL_CEF_BUILD_H_ +#pragma once + +#if defined(BUILDING_CEF_SHARED) + +#include "base/compiler_specific.h" + +#else // !BUILDING_CEF_SHARED + +#if defined(_WIN32) +#ifndef OS_WIN +#define OS_WIN 1 +#endif +#elif defined(__APPLE__) +#ifndef OS_MACOSX +#define OS_MACOSX 1 +#endif +#elif defined(__linux__) +#ifndef OS_LINUX +#define OS_LINUX 1 +#endif +#else +#error Please add support for your platform in cef_build.h +#endif + +// For access to standard POSIXish features, use OS_POSIX instead of a +// more specific macro. +#if defined(OS_MACOSX) || defined(OS_LINUX) +#ifndef OS_POSIX +#define OS_POSIX 1 +#endif +#endif + +// Compiler detection. +#if defined(__GNUC__) +#ifndef COMPILER_GCC +#define COMPILER_GCC 1 +#endif +#elif defined(_MSC_VER) +#ifndef COMPILER_MSVC +#define COMPILER_MSVC 1 +#endif +#else +#error Please add support for your compiler in cef_build.h +#endif + +// Annotate a virtual method indicating it must be overriding a virtual +// method in the parent class. +// Use like: +// virtual void foo() OVERRIDE; +#ifndef OVERRIDE +#if defined(COMPILER_MSVC) +#define OVERRIDE override +#elif defined(__clang__) +#define OVERRIDE override +#else +#define OVERRIDE +#endif +#endif + +#ifndef ALLOW_THIS_IN_INITIALIZER_LIST +#if defined(COMPILER_MSVC) + +// MSVC_PUSH_DISABLE_WARNING pushes |n| onto a stack of warnings to be disabled. +// The warning remains disabled until popped by MSVC_POP_WARNING. +#define MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \ + __pragma(warning(disable:n)) + +// MSVC_PUSH_WARNING_LEVEL pushes |n| as the global warning level. The level +// remains in effect until popped by MSVC_POP_WARNING(). Use 0 to disable all +// warnings. +#define MSVC_PUSH_WARNING_LEVEL(n) __pragma(warning(push, n)) + +// Pop effects of innermost MSVC_PUSH_* macro. +#define MSVC_POP_WARNING() __pragma(warning(pop)) + +// Allows |this| to be passed as an argument in constructor initializer lists. +// This uses push/pop instead of the seemingly simpler suppress feature to avoid +// having the warning be disabled for more than just |code|. +// +// Example usage: +// Foo::Foo() : x(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(y(this)), z(3) {} +// +// Compiler warning C4355: 'this': used in base member initializer list: +// http://msdn.microsoft.com/en-us/library/3c594ae3(VS.80).aspx +#define ALLOW_THIS_IN_INITIALIZER_LIST(code) MSVC_PUSH_DISABLE_WARNING(4355) \ + code \ + MSVC_POP_WARNING() +#else // !COMPILER_MSVC + +#define ALLOW_THIS_IN_INITIALIZER_LIST(code) code + +#endif // !COMPILER_MSVC +#endif + +#endif // !BUILDING_CEF_SHARED + +#endif // CEF_INCLUDE_INTERNAL_CEF_BUILD_H_ diff --git a/cef3/include/internal/cef_export.h b/cef3/include/internal/cef_export.h new file mode 100644 index 000000000..d333a5db8 --- /dev/null +++ b/cef3/include/internal/cef_export.h @@ -0,0 +1,55 @@ +// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights +// reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_EXPORT_H_ +#define CEF_INCLUDE_INTERNAL_CEF_EXPORT_H_ +#pragma once + +#include "include/internal/cef_build.h" + +#if defined(COMPILER_MSVC) + +#ifdef BUILDING_CEF_SHARED +#define CEF_EXPORT __declspec(dllexport) +#elif USING_CEF_SHARED +#define CEF_EXPORT __declspec(dllimport) +#else +#define CEF_EXPORT +#endif +#define CEF_CALLBACK __stdcall + +#elif defined(COMPILER_GCC) + +#define CEF_EXPORT __attribute__ ((visibility("default"))) +#define CEF_CALLBACK + +#endif // COMPILER_GCC + +#endif // CEF_INCLUDE_INTERNAL_CEF_EXPORT_H_ diff --git a/cef3/include/internal/cef_linux.h b/cef3/include/internal/cef_linux.h new file mode 100644 index 000000000..c7974bec2 --- /dev/null +++ b/cef3/include/internal/cef_linux.h @@ -0,0 +1,132 @@ +// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +#ifndef CEF_INCLUDE_INTERNAL_CEF_LINUX_H_ +#define CEF_INCLUDE_INTERNAL_CEF_LINUX_H_ +#pragma once + +#if defined(OS_LINUX) +#include +#include "include/internal/cef_types_linux.h" +#include "include/internal/cef_types_wrappers.h" + +// Atomic increment and decrement. +inline long CefAtomicIncrement(long volatile *pDest) { // NOLINT(runtime/int) + return __sync_add_and_fetch(pDest, 1); +} +inline long CefAtomicDecrement(long volatile *pDest) { // NOLINT(runtime/int) + return __sync_sub_and_fetch(pDest, 1); +} + +// Critical section wrapper. +class CefCriticalSection { + public: + CefCriticalSection() { + pthread_mutexattr_init(&attr_); + pthread_mutexattr_settype(&attr_, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(&lock_, &attr_); + } + virtual ~CefCriticalSection() { + pthread_mutex_destroy(&lock_); + pthread_mutexattr_destroy(&attr_); + } + void Lock() { + pthread_mutex_lock(&lock_); + } + void Unlock() { + pthread_mutex_unlock(&lock_); + } + + pthread_mutex_t lock_; + pthread_mutexattr_t attr_; +}; + +// Handle types. +#define CefCursorHandle cef_cursor_handle_t +#define CefEventHandle cef_event_handle_t +#define CefWindowHandle cef_window_handle_t + +struct CefMainArgsTraits { + typedef cef_main_args_t struct_type; + + static inline void init(struct_type* s) {} + static inline void clear(struct_type* s) {} + + static inline void set(const struct_type* src, struct_type* target, + bool copy) { + target->argc = src->argc; + target->argv = src->argv; + } +}; + +// Class representing CefExecuteProcess arguments. +class CefMainArgs : public CefStructBase { + public: + typedef CefStructBase parent; + + CefMainArgs() : parent() {} + explicit CefMainArgs(const cef_main_args_t& r) : parent(r) {} + explicit CefMainArgs(const CefMainArgs& r) : parent(r) {} + CefMainArgs(int argc_arg, char** argv_arg) : parent() { + argc = argc_arg; + argv = argv_arg; + } +}; + +struct CefWindowInfoTraits { + typedef cef_window_info_t struct_type; + + static inline void init(struct_type* s) {} + static inline void clear(struct_type* s) {} + + static inline void set(const struct_type* src, struct_type* target, + bool copy) { + target->widget = src->widget; + target->parent_widget = src->parent_widget; + } +}; + +// Class representing window information. +class CefWindowInfo : public CefStructBase { + public: + typedef CefStructBase parent; + + CefWindowInfo() : parent() {} + explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {} + explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {} + + void SetAsChild(CefWindowHandle ParentWidget) { + parent_widget = ParentWidget; + } +}; + +#endif // OS_LINUX + +#endif // CEF_INCLUDE_INTERNAL_CEF_LINUX_H_ diff --git a/cef3/include/internal/cef_mac.h b/cef3/include/internal/cef_mac.h new file mode 100644 index 000000000..ddedbce50 --- /dev/null +++ b/cef3/include/internal/cef_mac.h @@ -0,0 +1,148 @@ +// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +#ifndef CEF_INCLUDE_INTERNAL_CEF_MAC_H_ +#define CEF_INCLUDE_INTERNAL_CEF_MAC_H_ +#pragma once + +#if defined(OS_MACOSX) +#include +#include "include/internal/cef_types_mac.h" +#include "include/internal/cef_types_wrappers.h" + +// Atomic increment and decrement. +inline long CefAtomicIncrement(long volatile *pDest) { // NOLINT(runtime/int) + return __sync_add_and_fetch(pDest, 1); +} +inline long CefAtomicDecrement(long volatile *pDest) { // NOLINT(runtime/int) + return __sync_sub_and_fetch(pDest, 1); +} + +// Critical section wrapper. +class CefCriticalSection { + public: + CefCriticalSection() { + pthread_mutexattr_init(&attr_); + pthread_mutexattr_settype(&attr_, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(&lock_, &attr_); + } + virtual ~CefCriticalSection() { + pthread_mutex_destroy(&lock_); + pthread_mutexattr_destroy(&attr_); + } + void Lock() { + pthread_mutex_lock(&lock_); + } + void Unlock() { + pthread_mutex_unlock(&lock_); + } + + pthread_mutex_t lock_; + pthread_mutexattr_t attr_; +}; + +// Handle types. +#define CefCursorHandle cef_cursor_handle_t +#define CefEventHandle cef_event_handle_t +#define CefWindowHandle cef_window_handle_t + +struct CefMainArgsTraits { + typedef cef_main_args_t struct_type; + + static inline void init(struct_type* s) {} + static inline void clear(struct_type* s) {} + + static inline void set(const struct_type* src, struct_type* target, + bool copy) { + target->argc = src->argc; + target->argv = src->argv; + } +}; + +// Class representing CefExecuteProcess arguments. +class CefMainArgs : public CefStructBase { + public: + typedef CefStructBase parent; + + CefMainArgs() : parent() {} + explicit CefMainArgs(const cef_main_args_t& r) : parent(r) {} + explicit CefMainArgs(const CefMainArgs& r) : parent(r) {} + CefMainArgs(int argc, char** argv) : parent() { + this->argc = argc; + this->argv = argv; + } +}; + +struct CefWindowInfoTraits { + typedef cef_window_info_t struct_type; + + static inline void init(struct_type* s) {} + + static inline void clear(struct_type* s) { + cef_string_clear(&s->window_name); + } + + static inline void set(const struct_type* src, struct_type* target, + bool copy) { + target->view = src->view; + target->parent_view = src->parent_view; + cef_string_set(src->window_name.str, src->window_name.length, + &target->window_name, copy); + target->x = src->x; + target->y = src->y; + target->width = src->width; + target->height = src->height; + target->hidden = src->hidden; + } +}; + +// Class representing window information. +class CefWindowInfo : public CefStructBase { + public: + typedef CefStructBase parent; + + CefWindowInfo() : parent() {} + explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {} + explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {} + + void SetAsChild(CefWindowHandle ParentView, int x, int y, int width, + int height) { + parent_view = ParentView; + this->x = x; + this->y = y; + this->width = width; + this->height = height; + hidden = false; + } +}; + +#endif // OS_MACOSX + +#endif // CEF_INCLUDE_INTERNAL_CEF_MAC_H_ diff --git a/cef3/include/internal/cef_ptr.h b/cef3/include/internal/cef_ptr.h new file mode 100644 index 000000000..fcbe69e5c --- /dev/null +++ b/cef3/include/internal/cef_ptr.h @@ -0,0 +1,199 @@ +// Copyright (c) 2008 Marshall A. Greenblatt. Portions Copyright (c) +// 2006-2008 Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +#ifndef CEF_INCLUDE_INTERNAL_CEF_PTR_H_ +#define CEF_INCLUDE_INTERNAL_CEF_PTR_H_ +#pragma once + +#include + +/// +// Smart pointer implementation borrowed from base/ref_counted.h +//

+// A smart pointer class for reference counted objects. Use this class instead +// of calling AddRef and Release manually on a reference counted object to +// avoid common memory leaks caused by forgetting to Release an object +// reference. Sample usage: +//

+//   class MyFoo : public CefBase {
+//    ...
+//   };
+//
+//   void some_function() {
+//     // The MyFoo object that |foo| represents starts with a single
+//     // reference.
+//     CefRefPtr<MyFoo> foo = new MyFoo();
+//     foo->Method(param);
+//     // |foo| is released when this function returns
+//   }
+//
+//   void some_other_function() {
+//     CefRefPtr<MyFoo> foo = new MyFoo();
+//     ...
+//     foo = NULL;  // explicitly releases |foo|
+//     ...
+//     if (foo)
+//       foo->Method(param);
+//   }
+// 
+// The above examples show how CefRefPtr<T> acts like a pointer to T. +// Given two CefRefPtr<T> classes, it is also possible to exchange +// references between the two objects, like so: +//
+//   {
+//     CefRefPtr<MyFoo> a = new MyFoo();
+//     CefRefPtr<MyFoo> b;
+//
+//     b.swap(a);
+//     // now, |b| references the MyFoo object, and |a| references NULL.
+//   }
+// 
+// To make both |a| and |b| in the above example reference the same MyFoo +// object, simply use the assignment operator: +//
+//   {
+//     CefRefPtr<MyFoo> a = new MyFoo();
+//     CefRefPtr<MyFoo> b;
+//
+//     b = a;
+//     // now, |a| and |b| each own a reference to the same MyFoo object.
+//     // the reference count of the underlying MyFoo object will be 2.
+//   }
+// 
+// Reference counted objects can also be passed as function parameters and +// used as function return values: +//
+//   void some_func_with_param(CefRefPtr<MyFoo> param) {
+//     // A reference is added to the MyFoo object that |param| represents
+//     // during the scope of some_func_with_param() and released when
+//     // some_func_with_param() goes out of scope.
+//   }
+//
+//   CefRefPtr<MyFoo> some_func_with_retval() {
+//     // The MyFoo object that |foox| represents starts with a single
+//     // reference.
+//     CefRefPtr<MyFoo> foox = new MyFoo();
+//
+//     // Creating the return value adds an additional reference.
+//     return foox;
+//
+//     // When some_func_with_retval() goes out of scope the original |foox|
+//     // reference is released.
+//   }
+//
+//   void and_another_function() {
+//     CefRefPtr<MyFoo> foo = new MyFoo();
+//
+//     // pass |foo| as a parameter.
+//     some_function(foo);
+//
+//     CefRefPtr<MyFoo> foo2 = some_func_with_retval();
+//     // Now, since we kept a reference to the some_func_with_retval() return
+//     // value, |foo2| is the only class pointing to the MyFoo object created
+//     in some_func_with_retval(), and it has a reference count of 1.
+//
+//     some_func_with_retval();
+//     // Now, since we didn't keep a reference to the some_func_with_retval()
+//     // return value, the MyFoo object created in some_func_with_retval()
+//     // will automatically be released.
+//   }
+// 
+// And in standard containers: +//
+//   {
+//      // Create a vector that holds MyFoo objects.
+//      std::vector<CefRefPtr<MyFoo> > MyFooVec;
+//
+//     // The MyFoo object that |foo| represents starts with a single
+//     // reference.
+//     CefRefPtr<MyFoo> foo = new MyFoo();
+//
+//     // When the MyFoo object is added to |MyFooVec| the reference count
+//     // is increased to 2.
+//     MyFooVec.push_back(foo);
+//   }
+// 
+//

+/// +template +class CefRefPtr { + public: + CefRefPtr() : ptr_(NULL) { + } + + CefRefPtr(T* p) : ptr_(p) { // NOLINT(runtime/explicit) + if (ptr_) + ptr_->AddRef(); + } + + CefRefPtr(const CefRefPtr& r) : ptr_(r.ptr_) { + if (ptr_) + ptr_->AddRef(); + } + + ~CefRefPtr() { + if (ptr_) + ptr_->Release(); + } + + T* get() const { return ptr_; } + operator T*() const { return ptr_; } + T* operator->() const { return ptr_; } + + CefRefPtr& operator=(T* p) { + // AddRef first so that self assignment should work + if (p) + p->AddRef(); + if (ptr_ ) + ptr_ ->Release(); + ptr_ = p; + return *this; + } + + CefRefPtr& operator=(const CefRefPtr& r) { + return *this = r.ptr_; + } + + void swap(T** pp) { + T* p = ptr_; + ptr_ = *pp; + *pp = p; + } + + void swap(CefRefPtr& r) { + swap(&r.ptr_); // NOLINT(build/include_what_you_use) + } + + private: + T* ptr_; +}; + +#endif // CEF_INCLUDE_INTERNAL_CEF_PTR_H_ diff --git a/cef3/include/internal/cef_string.h b/cef3/include/internal/cef_string.h new file mode 100644 index 000000000..a7876fe56 --- /dev/null +++ b/cef3/include/internal/cef_string.h @@ -0,0 +1,113 @@ +// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_H_ +#define CEF_INCLUDE_INTERNAL_CEF_STRING_H_ +#pragma once + +// The CEF interface is built with one string type as the default. Comment out +// all but one of the CEF_STRING_TYPE_* defines below to specify the default. +// If you change the default you MUST recompile all of CEF. + +// Build with the UTF8 string type as default. +// #define CEF_STRING_TYPE_UTF8 1 + +// Build with the UTF16 string type as default. +#define CEF_STRING_TYPE_UTF16 1 + +// Build with the wide string type as default. +// #define CEF_STRING_TYPE_WIDE 1 + + +#include "include/internal/cef_string_types.h" + +#ifdef __cplusplus +#include "include/internal/cef_string_wrappers.h" +#if defined(CEF_STRING_TYPE_UTF16) +typedef CefStringUTF16 CefString; +#elif defined(CEF_STRING_TYPE_UTF8) +typedef CefStringUTF8 CefString; +#elif defined(CEF_STRING_TYPE_WIDE) +typedef CefStringWide CefString; +#endif +#endif // __cplusplus + +#if defined(CEF_STRING_TYPE_UTF8) +typedef char cef_char_t; +typedef cef_string_utf8_t cef_string_t; +typedef cef_string_userfree_utf8_t cef_string_userfree_t; +#define cef_string_set cef_string_utf8_set +#define cef_string_copy cef_string_utf8_copy +#define cef_string_clear cef_string_utf8_clear +#define cef_string_userfree_alloc cef_string_userfree_utf8_alloc +#define cef_string_userfree_free cef_string_userfree_utf8_free +#define cef_string_from_ascii cef_string_utf8_copy +#define cef_string_to_utf8 cef_string_utf8_copy +#define cef_string_from_utf8 cef_string_utf8_copy +#define cef_string_to_utf16 cef_string_utf8_to_utf16 +#define cef_string_from_utf16 cef_string_utf16_to_utf8 +#define cef_string_to_wide cef_string_utf8_to_wide +#define cef_string_from_wide cef_string_wide_to_utf8 +#elif defined(CEF_STRING_TYPE_UTF16) +typedef char16 cef_char_t; +typedef cef_string_userfree_utf16_t cef_string_userfree_t; +typedef cef_string_utf16_t cef_string_t; +#define cef_string_set cef_string_utf16_set +#define cef_string_copy cef_string_utf16_copy +#define cef_string_clear cef_string_utf16_clear +#define cef_string_userfree_alloc cef_string_userfree_utf16_alloc +#define cef_string_userfree_free cef_string_userfree_utf16_free +#define cef_string_from_ascii cef_string_ascii_to_utf16 +#define cef_string_to_utf8 cef_string_utf16_to_utf8 +#define cef_string_from_utf8 cef_string_utf8_to_utf16 +#define cef_string_to_utf16 cef_string_utf16_copy +#define cef_string_from_utf16 cef_string_utf16_copy +#define cef_string_to_wide cef_string_utf16_to_wide +#define cef_string_from_wide cef_string_wide_to_utf16 +#elif defined(CEF_STRING_TYPE_WIDE) +typedef wchar_t cef_char_t; +typedef cef_string_wide_t cef_string_t; +typedef cef_string_userfree_wide_t cef_string_userfree_t; +#define cef_string_set cef_string_wide_set +#define cef_string_copy cef_string_wide_copy +#define cef_string_clear cef_string_wide_clear +#define cef_string_userfree_alloc cef_string_userfree_wide_alloc +#define cef_string_userfree_free cef_string_userfree_wide_free +#define cef_string_from_ascii cef_string_ascii_to_wide +#define cef_string_to_utf8 cef_string_wide_to_utf8 +#define cef_string_from_utf8 cef_string_utf8_to_wide +#define cef_string_to_utf16 cef_string_wide_to_utf16 +#define cef_string_from_utf16 cef_string_utf16_to_wide +#define cef_string_to_wide cef_string_wide_copy +#define cef_string_from_wide cef_string_wide_copy +#else +#error Please choose a string type. +#endif + +#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_H_ diff --git a/cef3/include/internal/cef_string_list.h b/cef3/include/internal/cef_string_list.h new file mode 100644 index 000000000..52a0abf2f --- /dev/null +++ b/cef3/include/internal/cef_string_list.h @@ -0,0 +1,88 @@ +// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_LIST_H_ +#define CEF_INCLUDE_INTERNAL_CEF_STRING_LIST_H_ +#pragma once + +#include "include/internal/cef_export.h" +#include "include/internal/cef_string.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// CEF string maps are a set of key/value string pairs. +/// +typedef void* cef_string_list_t; + +/// +// Allocate a new string map. +/// +CEF_EXPORT cef_string_list_t cef_string_list_alloc(); + +/// +// Return the number of elements in the string list. +/// +CEF_EXPORT int cef_string_list_size(cef_string_list_t list); + +/// +// Retrieve the value at the specified zero-based string list index. Returns +// true (1) if the value was successfully retrieved. +/// +CEF_EXPORT int cef_string_list_value(cef_string_list_t list, + int index, cef_string_t* value); + +/// +// Append a new value at the end of the string list. +/// +CEF_EXPORT void cef_string_list_append(cef_string_list_t list, + const cef_string_t* value); + +/// +// Clear the string list. +/// +CEF_EXPORT void cef_string_list_clear(cef_string_list_t list); + +/// +// Free the string list. +/// +CEF_EXPORT void cef_string_list_free(cef_string_list_t list); + +/// +// Creates a copy of an existing string list. +/// +CEF_EXPORT cef_string_list_t cef_string_list_copy(cef_string_list_t list); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_LIST_H_ diff --git a/cef3/include/internal/cef_string_map.h b/cef3/include/internal/cef_string_map.h new file mode 100644 index 000000000..93eea2a55 --- /dev/null +++ b/cef3/include/internal/cef_string_map.h @@ -0,0 +1,97 @@ +// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_MAP_H_ +#define CEF_INCLUDE_INTERNAL_CEF_STRING_MAP_H_ +#pragma once + +#include "include/internal/cef_export.h" +#include "include/internal/cef_string.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// CEF string maps are a set of key/value string pairs. +/// +typedef void* cef_string_map_t; + +/// +// Allocate a new string map. +/// +CEF_EXPORT cef_string_map_t cef_string_map_alloc(); + +/// +// Return the number of elements in the string map. +/// +CEF_EXPORT int cef_string_map_size(cef_string_map_t map); + +/// +// Return the value assigned to the specified key. +/// +CEF_EXPORT int cef_string_map_find(cef_string_map_t map, + const cef_string_t* key, + cef_string_t* value); + +/// +// Return the key at the specified zero-based string map index. +/// +CEF_EXPORT int cef_string_map_key(cef_string_map_t map, int index, + cef_string_t* key); + +/// +// Return the value at the specified zero-based string map index. +/// +CEF_EXPORT int cef_string_map_value(cef_string_map_t map, int index, + cef_string_t* value); + +/// +// Append a new key/value pair at the end of the string map. +/// +CEF_EXPORT int cef_string_map_append(cef_string_map_t map, + const cef_string_t* key, + const cef_string_t* value); + +/// +// Clear the string map. +/// +CEF_EXPORT void cef_string_map_clear(cef_string_map_t map); + +/// +// Free the string map. +/// +CEF_EXPORT void cef_string_map_free(cef_string_map_t map); + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_MAP_H_ diff --git a/cef3/include/internal/cef_string_multimap.h b/cef3/include/internal/cef_string_multimap.h new file mode 100644 index 000000000..cd3904244 --- /dev/null +++ b/cef3/include/internal/cef_string_multimap.h @@ -0,0 +1,105 @@ +// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_MULTIMAP_H_ +#define CEF_INCLUDE_INTERNAL_CEF_STRING_MULTIMAP_H_ +#pragma once + +#include "include/internal/cef_export.h" +#include "include/internal/cef_string.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// CEF string multimaps are a set of key/value string pairs. +// More than one value can be assigned to a single key. +/// +typedef void* cef_string_multimap_t; + +/// +// Allocate a new string multimap. +/// +CEF_EXPORT cef_string_multimap_t cef_string_multimap_alloc(); + +/// +// Return the number of elements in the string multimap. +/// +CEF_EXPORT int cef_string_multimap_size(cef_string_multimap_t map); + +/// +// Return the number of values with the specified key. +/// +CEF_EXPORT int cef_string_multimap_find_count(cef_string_multimap_t map, + const cef_string_t* key); + +/// +// Return the value_index-th value with the specified key. +/// +CEF_EXPORT int cef_string_multimap_enumerate(cef_string_multimap_t map, + const cef_string_t* key, + int value_index, + cef_string_t* value); + +/// +// Return the key at the specified zero-based string multimap index. +/// +CEF_EXPORT int cef_string_multimap_key(cef_string_multimap_t map, int index, + cef_string_t* key); + +/// +// Return the value at the specified zero-based string multimap index. +/// +CEF_EXPORT int cef_string_multimap_value(cef_string_multimap_t map, int index, + cef_string_t* value); + +/// +// Append a new key/value pair at the end of the string multimap. +/// +CEF_EXPORT int cef_string_multimap_append(cef_string_multimap_t map, + const cef_string_t* key, + const cef_string_t* value); + +/// +// Clear the string multimap. +/// +CEF_EXPORT void cef_string_multimap_clear(cef_string_multimap_t map); + +/// +// Free the string multimap. +/// +CEF_EXPORT void cef_string_multimap_free(cef_string_multimap_t map); + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_MULTIMAP_H_ diff --git a/cef3/include/internal/cef_string_types.h b/cef3/include/internal/cef_string_types.h new file mode 100644 index 000000000..7ab6671cb --- /dev/null +++ b/cef3/include/internal/cef_string_types.h @@ -0,0 +1,204 @@ +// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_TYPES_H_ +#define CEF_INCLUDE_INTERNAL_CEF_STRING_TYPES_H_ +#pragma once + +// CEF provides functions for converting between UTF-8, -16 and -32 strings. +// CEF string types are safe for reading from multiple threads but not for +// modification. It is the user's responsibility to provide synchronization if +// modifying CEF strings from multiple threads. + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/internal/cef_build.h" +#include "include/internal/cef_export.h" +#include + +// CEF character type definitions. wchar_t is 2 bytes on Windows and 4 bytes on +// most other platforms. + +#if defined(OS_WIN) +typedef wchar_t char16; +#else // !OS_WIN +typedef unsigned short char16; // NOLINT (runtime/int) +#ifndef WCHAR_T_IS_UTF32 +#define WCHAR_T_IS_UTF32 +#endif // WCHAR_T_IS_UTF32 +#endif // !OS_WIN + + +// CEF string type definitions. Whomever allocates |str| is responsible for +// providing an appropriate |dtor| implementation that will free the string in +// the same memory space. When reusing an existing string structure make sure +// to call |dtor| for the old value before assigning new |str| and |dtor| +// values. Static strings will have a NULL |dtor| value. Using the below +// functions if you want this managed for you. + +typedef struct _cef_string_wide_t { + wchar_t* str; + size_t length; + void (*dtor)(wchar_t* str); +} cef_string_wide_t; + +typedef struct _cef_string_utf8_t { + char* str; + size_t length; + void (*dtor)(char* str); +} cef_string_utf8_t; + +typedef struct _cef_string_utf16_t { + char16* str; + size_t length; + void (*dtor)(char16* str); +} cef_string_utf16_t; + + +/// +// These functions set string values. If |copy| is true (1) the value will be +// copied instead of referenced. It is up to the user to properly manage +// the lifespan of references. +/// + +CEF_EXPORT int cef_string_wide_set(const wchar_t* src, size_t src_len, + cef_string_wide_t* output, int copy); +CEF_EXPORT int cef_string_utf8_set(const char* src, size_t src_len, + cef_string_utf8_t* output, int copy); +CEF_EXPORT int cef_string_utf16_set(const char16* src, size_t src_len, + cef_string_utf16_t* output, int copy); + + +/// +// Convenience macros for copying values. +/// + +#define cef_string_wide_copy(src, src_len, output) \ + cef_string_wide_set(src, src_len, output, true) +#define cef_string_utf8_copy(src, src_len, output) \ + cef_string_utf8_set(src, src_len, output, true) +#define cef_string_utf16_copy(src, src_len, output) \ + cef_string_utf16_set(src, src_len, output, true) + + +/// +// These functions clear string values. The structure itself is not freed. +/// + +CEF_EXPORT void cef_string_wide_clear(cef_string_wide_t* str); +CEF_EXPORT void cef_string_utf8_clear(cef_string_utf8_t* str); +CEF_EXPORT void cef_string_utf16_clear(cef_string_utf16_t* str); + + +/// +// These functions compare two string values with the same results as strcmp(). +/// + +CEF_EXPORT int cef_string_wide_cmp(const cef_string_wide_t* str1, + const cef_string_wide_t* str2); +CEF_EXPORT int cef_string_utf8_cmp(const cef_string_utf8_t* str1, + const cef_string_utf8_t* str2); +CEF_EXPORT int cef_string_utf16_cmp(const cef_string_utf16_t* str1, + const cef_string_utf16_t* str2); + + +/// +// These functions convert between UTF-8, -16, and -32 strings. They are +// potentially slow so unnecessary conversions should be avoided. The best +// possible result will always be written to |output| with the boolean return +// value indicating whether the conversion is 100% valid. +/// + +CEF_EXPORT int cef_string_wide_to_utf8(const wchar_t* src, size_t src_len, + cef_string_utf8_t* output); +CEF_EXPORT int cef_string_utf8_to_wide(const char* src, size_t src_len, + cef_string_wide_t* output); + +CEF_EXPORT int cef_string_wide_to_utf16(const wchar_t* src, size_t src_len, + cef_string_utf16_t* output); +CEF_EXPORT int cef_string_utf16_to_wide(const char16* src, size_t src_len, + cef_string_wide_t* output); + +CEF_EXPORT int cef_string_utf8_to_utf16(const char* src, size_t src_len, + cef_string_utf16_t* output); +CEF_EXPORT int cef_string_utf16_to_utf8(const char16* src, size_t src_len, + cef_string_utf8_t* output); + + +/// +// These functions convert an ASCII string, typically a hardcoded constant, to a +// Wide/UTF16 string. Use instead of the UTF8 conversion routines if you know +// the string is ASCII. +/// + +CEF_EXPORT int cef_string_ascii_to_wide(const char* src, size_t src_len, + cef_string_wide_t* output); +CEF_EXPORT int cef_string_ascii_to_utf16(const char* src, size_t src_len, + cef_string_utf16_t* output); + + + +/// +// It is sometimes necessary for the system to allocate string structures with +// the expectation that the user will free them. The userfree types act as a +// hint that the user is responsible for freeing the structure. +/// + +typedef cef_string_wide_t* cef_string_userfree_wide_t; +typedef cef_string_utf8_t* cef_string_userfree_utf8_t; +typedef cef_string_utf16_t* cef_string_userfree_utf16_t; + + +/// +// These functions allocate a new string structure. They must be freed by +// calling the associated free function. +/// + +CEF_EXPORT cef_string_userfree_wide_t cef_string_userfree_wide_alloc(); +CEF_EXPORT cef_string_userfree_utf8_t cef_string_userfree_utf8_alloc(); +CEF_EXPORT cef_string_userfree_utf16_t cef_string_userfree_utf16_alloc(); + + +/// +// These functions free the string structure allocated by the associated +// alloc function. Any string contents will first be cleared. +/// + +CEF_EXPORT void cef_string_userfree_wide_free(cef_string_userfree_wide_t str); +CEF_EXPORT void cef_string_userfree_utf8_free(cef_string_userfree_utf8_t str); +CEF_EXPORT void cef_string_userfree_utf16_free(cef_string_userfree_utf16_t str); + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_TYPES_H_ diff --git a/cef3/include/internal/cef_string_wrappers.h b/cef3/include/internal/cef_string_wrappers.h new file mode 100644 index 000000000..135fed6b1 --- /dev/null +++ b/cef3/include/internal/cef_string_wrappers.h @@ -0,0 +1,724 @@ +// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_WRAPPERS_H_ +#define CEF_INCLUDE_INTERNAL_CEF_STRING_WRAPPERS_H_ +#pragma once + +#include +#include +#include "include/internal/cef_string_types.h" + +#ifdef BUILDING_CEF_SHARED +#include "base/string16.h" +#endif + + +/// +// Traits implementation for wide character strings. +/// +struct CefStringTraitsWide { + typedef wchar_t char_type; + typedef cef_string_wide_t struct_type; + typedef cef_string_userfree_wide_t userfree_struct_type; + + static inline void clear(struct_type *s) { cef_string_wide_clear(s); } + static inline int set(const char_type* src, size_t src_size, + struct_type* output, int copy) { + return cef_string_wide_set(src, src_size, output, copy); + } + static inline int compare(const struct_type* s1, const struct_type* s2) { + return cef_string_wide_cmp(s1, s2); + } + static inline userfree_struct_type userfree_alloc() { + return cef_string_userfree_wide_alloc(); + } + static inline void userfree_free(userfree_struct_type ufs) { + return cef_string_userfree_wide_free(ufs); + } + + // Conversion methods. + static inline bool from_ascii(const char* str, size_t len, struct_type *s) { + return cef_string_ascii_to_wide(str, len, s) ? true : false; + } + static inline std::string to_string(const struct_type *s) { + cef_string_utf8_t cstr; + memset(&cstr, 0, sizeof(cstr)); + cef_string_wide_to_utf8(s->str, s->length, &cstr); + std::string str; + if (cstr.length > 0) + str = std::string(cstr.str, cstr.length); + cef_string_utf8_clear(&cstr); + return str; + } + static inline bool from_string(const std::string& str, struct_type *s) { + return cef_string_utf8_to_wide(str.c_str(), str.length(), s) ? true : false; + } + static inline std::wstring to_wstring(const struct_type *s) { + return std::wstring(s->str, s->length); + } + static inline bool from_wstring(const std::wstring& str, struct_type *s) { + return cef_string_wide_set(str.c_str(), str.length(), s, true) ? + true : false; + } +#if defined(BUILDING_CEF_SHARED) +#if defined(WCHAR_T_IS_UTF32) + static inline string16 to_string16(const struct_type *s) { + cef_string_utf16_t cstr; + memset(&cstr, 0, sizeof(cstr)); + cef_string_wide_to_utf16(s->str, s->length, &cstr); + string16 str; + if (cstr.length > 0) + str = string16(cstr.str, cstr.length); + cef_string_utf16_clear(&cstr); + return str; + } + static inline bool from_string16(const string16& str, struct_type *s) { + return cef_string_utf16_to_wide(str.c_str(), str.length(), s) ? + true : false; + } +#else // WCHAR_T_IS_UTF32 + static inline string16 to_string16(const struct_type *s) { + return string16(s->str, s->length); + } + static inline bool from_string16(const string16& str, struct_type *s) { + return cef_string_wide_set(str.c_str(), str.length(), s, true) ? + true : false; + } +#endif // WCHAR_T_IS_UTF32 +#endif // BUILDING_CEF_SHARED +}; + +/// +// Traits implementation for utf8 character strings. +/// +struct CefStringTraitsUTF8 { + typedef char char_type; + typedef cef_string_utf8_t struct_type; + typedef cef_string_userfree_utf8_t userfree_struct_type; + + static inline void clear(struct_type *s) { cef_string_utf8_clear(s); } + static inline int set(const char_type* src, size_t src_size, + struct_type* output, int copy) { + return cef_string_utf8_set(src, src_size, output, copy); + } + static inline int compare(const struct_type* s1, const struct_type* s2) { + return cef_string_utf8_cmp(s1, s2); + } + static inline userfree_struct_type userfree_alloc() { + return cef_string_userfree_utf8_alloc(); + } + static inline void userfree_free(userfree_struct_type ufs) { + return cef_string_userfree_utf8_free(ufs); + } + + // Conversion methods. + static inline bool from_ascii(const char* str, size_t len, struct_type* s) { + return cef_string_utf8_copy(str, len, s) ? true : false; + } + static inline std::string to_string(const struct_type* s) { + return std::string(s->str, s->length); + } + static inline bool from_string(const std::string& str, struct_type* s) { + return cef_string_utf8_copy(str.c_str(), str.length(), s) ? true : false; + } + static inline std::wstring to_wstring(const struct_type* s) { + cef_string_wide_t cstr; + memset(&cstr, 0, sizeof(cstr)); + cef_string_utf8_to_wide(s->str, s->length, &cstr); + std::wstring str; + if (cstr.length > 0) + str = std::wstring(cstr.str, cstr.length); + cef_string_wide_clear(&cstr); + return str; + } + static inline bool from_wstring(const std::wstring& str, struct_type* s) { + return cef_string_wide_to_utf8(str.c_str(), str.length(), s) ? true : false; + } +#if defined(BUILDING_CEF_SHARED) + static inline string16 to_string16(const struct_type* s) { + cef_string_utf16_t cstr; + memset(&cstr, 0, sizeof(cstr)); + cef_string_utf8_to_utf16(s->str, s->length, &cstr); + string16 str; + if (cstr.length > 0) + str = string16(cstr.str, cstr.length); + cef_string_utf16_clear(&cstr); + return str; + } + static inline bool from_string16(const string16& str, struct_type* s) { + return cef_string_utf16_to_utf8(str.c_str(), str.length(), s) ? + true : false; + } +#endif // BUILDING_CEF_SHARED +}; + +/// +// Traits implementation for utf16 character strings. +/// +struct CefStringTraitsUTF16 { + typedef char16 char_type; + typedef cef_string_utf16_t struct_type; + typedef cef_string_userfree_utf16_t userfree_struct_type; + + static inline void clear(struct_type *s) { cef_string_utf16_clear(s); } + static inline int set(const char_type* src, size_t src_size, + struct_type* output, int copy) { + return cef_string_utf16_set(src, src_size, output, copy); + } + static inline int compare(const struct_type* s1, const struct_type* s2) { + return cef_string_utf16_cmp(s1, s2); + } + static inline userfree_struct_type userfree_alloc() { + return cef_string_userfree_utf16_alloc(); + } + static inline void userfree_free(userfree_struct_type ufs) { + return cef_string_userfree_utf16_free(ufs); + } + + // Conversion methods. + static inline bool from_ascii(const char* str, size_t len, struct_type* s) { + return cef_string_ascii_to_utf16(str, len, s) ? true : false; + } + static inline std::string to_string(const struct_type* s) { + cef_string_utf8_t cstr; + memset(&cstr, 0, sizeof(cstr)); + cef_string_utf16_to_utf8(s->str, s->length, &cstr); + std::string str; + if (cstr.length > 0) + str = std::string(cstr.str, cstr.length); + cef_string_utf8_clear(&cstr); + return str; + } + static inline bool from_string(const std::string& str, struct_type* s) { + return cef_string_utf8_to_utf16(str.c_str(), str.length(), s) ? + true : false; + } +#if defined(WCHAR_T_IS_UTF32) + static inline std::wstring to_wstring(const struct_type* s) { + cef_string_wide_t cstr; + memset(&cstr, 0, sizeof(cstr)); + cef_string_utf16_to_wide(s->str, s->length, &cstr); + std::wstring str; + if (cstr.length > 0) + str = std::wstring(cstr.str, cstr.length); + cef_string_wide_clear(&cstr); + return str; + } + static inline bool from_wstring(const std::wstring& str, struct_type* s) { + return cef_string_wide_to_utf16(str.c_str(), str.length(), s) ? + true : false; + } +#else // WCHAR_T_IS_UTF32 + static inline std::wstring to_wstring(const struct_type* s) { + return std::wstring(s->str, s->length); + } + static inline bool from_wstring(const std::wstring& str, struct_type* s) { + return cef_string_utf16_set(str.c_str(), str.length(), s, true) ? + true : false; + } +#endif // WCHAR_T_IS_UTF32 +#if defined(BUILDING_CEF_SHARED) + static inline string16 to_string16(const struct_type* s) { + return string16(s->str, s->length); + } + static inline bool from_string16(const string16& str, struct_type* s) { + return cef_string_utf16_set(str.c_str(), str.length(), s, true) ? + true : false; + } +#endif // BUILDING_CEF_SHARED +}; + +/// +// CEF string classes can convert between all supported string types. For +// example, the CefStringWide class uses wchar_t as the underlying character +// type and provides two approaches for converting data to/from a UTF8 string +// (std::string). +//

+// 1. Implicit conversion using the assignment operator overload. +//

+//   CefStringWide aCefString;
+//   std::string aUTF8String;
+//   aCefString = aUTF8String; // Assign std::string to CefStringWide
+//   aUTF8String = aCefString; // Assign CefStringWide to std::string
+// 
+// 2. Explicit conversion using the FromString/ToString methods. +//
+//   CefStringWide aCefString;
+//   std::string aUTF8String;
+//   aCefString.FromString(aUTF8String); // Assign std::string to CefStringWide
+//   aUTF8String = aCefString.ToString(); // Assign CefStringWide to std::string
+// 
+// Conversion will only occur if the assigned value is a different string type. +// Assigning a std::string to a CefStringUTF8, for example, will copy the data +// without performing a conversion. +//

+// CEF string classes are safe for reading from multiple threads but not for +// modification. It is the user's responsibility to provide synchronization if +// modifying CEF strings from multiple threads. +/// +template +class CefStringBase { + public: + typedef typename traits::char_type char_type; + typedef typename traits::struct_type struct_type; + typedef typename traits::userfree_struct_type userfree_struct_type; + + /// + // Default constructor. + /// + CefStringBase() : string_(NULL), owner_(false) {} + + /// + // Create a new string from an existing string. Data will always be copied. + /// + CefStringBase(const CefStringBase& str) + : string_(NULL), owner_(false) { + FromString(str.c_str(), str.length(), true); + } + + /// + // Create a new string from an existing std::string. Data will be always + // copied. Translation will occur if necessary based on the underlying string + // type. + /// + CefStringBase(const std::string& src) // NOLINT(runtime/explicit) + : string_(NULL), owner_(false) { + FromString(src); + } + CefStringBase(const char* src) // NOLINT(runtime/explicit) + : string_(NULL), owner_(false) { + if (src) + FromString(std::string(src)); + } + + /// + // Create a new string from an existing std::wstring. Data will be always + // copied. Translation will occur if necessary based on the underlying string + // type. + /// + CefStringBase(const std::wstring& src) // NOLINT(runtime/explicit) + : string_(NULL), owner_(false) { + FromWString(src); + } + CefStringBase(const wchar_t* src) // NOLINT(runtime/explicit) + : string_(NULL), owner_(false) { + if (src) + FromWString(std::wstring(src)); + } + +#if (defined(BUILDING_CEF_SHARED) && defined(WCHAR_T_IS_UTF32)) + /// + // Create a new string from an existing string16. Data will be always + // copied. Translation will occur if necessary based on the underlying string + // type. + /// + CefStringBase(const string16& src) // NOLINT(runtime/explicit) + : string_(NULL), owner_(false) { + FromString16(src); + } + CefStringBase(const char16* src) // NOLINT(runtime/explicit) + : string_(NULL), owner_(false) { + if (src) + FromString16(string16(src)); + } +#endif // BUILDING_CEF_SHARED && WCHAR_T_IS_UTF32 + + /// + // Create a new string from an existing character array. If |copy| is true + // this class will copy the data. Otherwise, this class will reference the + // existing data. Referenced data must exist for the lifetime of this class + // and will not be freed by this class. + /// + CefStringBase(const char_type* src, size_t src_len, bool copy) + : string_(NULL), owner_(false) { + if (src && src_len > 0) + FromString(src, src_len, copy); + } + + /// + // Create a new string referencing an existing string structure without taking + // ownership. Referenced structures must exist for the lifetime of this class + // and will not be freed by this class. + /// + CefStringBase(const struct_type* src) // NOLINT(runtime/explicit) + : string_(NULL), owner_(false) { + if (!src) + return; + // Reference the existing structure without taking ownership. + Attach(const_cast(src), false); + } + + virtual ~CefStringBase() { ClearAndFree(); } + + + // The following methods are named for compatibility with the standard library + // string template types. + + /// + // Return a read-only pointer to the string data. + /// + const char_type* c_str() const { return (string_ ? string_->str : NULL); } + + /// + // Return the length of the string data. + /// + size_t length() const { return (string_ ? string_->length : 0); } + + /// + // Return the length of the string data. + /// + inline size_t size() const { return length(); } + + /// + // Returns true if the string is empty. + /// + bool empty() const { return (string_ == NULL || string_->length == 0); } + + /// + // Compare this string to the specified string. + /// + int compare(const CefStringBase& str) const { + if (empty() && str.empty()) + return 0; + if (empty()) + return -1; + if (str.empty()) + return 1; + return traits::compare(string_, str.GetStruct()); + } + + /// + // Clear the string data. + /// + void clear() { + if (string_) + traits::clear(string_); + } + + /// + // Swap this string's contents with the specified string. + /// + void swap(CefStringBase& str) { + struct_type* tmp_string = string_; + bool tmp_owner = owner_; + string_ = str.string_; + owner_ = str.owner_; + str.string_ = tmp_string; + str.owner_ = tmp_owner; + } + + + // The following methods are unique to CEF string template types. + + /// + // Returns true if this class owns the underlying string structure. + /// + bool IsOwner() const { return owner_; } + + /// + // Returns a read-only pointer to the underlying string structure. May return + // NULL if no structure is currently allocated. + /// + const struct_type* GetStruct() const { return string_; } + + /// + // Returns a writable pointer to the underlying string structure. Will never + // return NULL. + /// + struct_type* GetWritableStruct() { + AllocIfNeeded(); + return string_; + } + + /// + // Clear the state of this class. The underlying string structure and data + // will be freed if this class owns the structure. + /// + void ClearAndFree() { + if (!string_) + return; + if (owner_) { + clear(); + delete string_; + } + string_ = NULL; + owner_ = false; + } + + /// + // Attach to the specified string structure. If |owner| is true this class + // will take ownership of the structure. + /// + void Attach(struct_type* str, bool owner) { + // Free the previous structure and data, if any. + ClearAndFree(); + + string_ = str; + owner_ = owner; + } + + /// + // Take ownership of the specified userfree structure's string data. The + // userfree structure itself will be freed. Only use this method with userfree + // structures. + /// + void AttachToUserFree(userfree_struct_type str) { + // Free the previous structure and data, if any. + ClearAndFree(); + + if (!str) + return; + + AllocIfNeeded(); + owner_ = true; + memcpy(string_, str, sizeof(struct_type)); + + // Free the |str| structure but not the data. + memset(str, 0, sizeof(struct_type)); + traits::userfree_free(str); + } + + /// + // Detach from the underlying string structure. To avoid memory leaks only use + // this method if you already hold a pointer to the underlying string + // structure. + /// + void Detach() { + string_ = NULL; + owner_ = false; + } + + /// + // Create a userfree structure and give it ownership of this class' string + // data. This class will be disassociated from the data. May return NULL if + // this string class currently contains no data. + /// + userfree_struct_type DetachToUserFree() { + if (empty()) + return NULL; + + userfree_struct_type str = traits::userfree_alloc(); + memcpy(str, string_, sizeof(struct_type)); + + // Free this class' structure but not the data. + memset(string_, 0, sizeof(struct_type)); + ClearAndFree(); + + return str; + } + + /// + // Set this string's data to the specified character array. If |copy| is true + // this class will copy the data. Otherwise, this class will reference the + // existing data. Referenced data must exist for the lifetime of this class + // and will not be freed by this class. + /// + bool FromString(const char_type* src, size_t src_len, bool copy) { + if (src == NULL || src_len == 0) { + clear(); + return true; + } + AllocIfNeeded(); + return traits::set(src, src_len, string_, copy) ? true : false; + } + + /// + // Set this string's data from an existing ASCII string. Data will be always + // copied. Translation will occur if necessary based on the underlying string + // type. + /// + bool FromASCII(const char* str) { + size_t len = str ? strlen(str) : 0; + if (len == 0) { + clear(); + return true; + } + AllocIfNeeded(); + return traits::from_ascii(str, len, string_); + } + + /// + // Return this string's data as a std::string. Translation will occur if + // necessary based on the underlying string type. + /// + std::string ToString() const { + if (empty()) + return std::string(); + return traits::to_string(string_); + } + + /// + // Set this string's data from an existing std::string. Data will be always + // copied. Translation will occur if necessary based on the underlying string + // type. + /// + bool FromString(const std::string& str) { + if (str.empty()) { + clear(); + return true; + } + AllocIfNeeded(); + return traits::from_string(str, string_); + } + + /// + // Return this string's data as a std::wstring. Translation will occur if + // necessary based on the underlying string type. + /// + std::wstring ToWString() const { + if (empty()) + return std::wstring(); + return traits::to_wstring(string_); + } + + /// + // Set this string's data from an existing std::wstring. Data will be always + // copied. Translation will occur if necessary based on the underlying string + // type. + /// + bool FromWString(const std::wstring& str) { + if (str.empty()) { + clear(); + return true; + } + AllocIfNeeded(); + return traits::from_wstring(str, string_); + } +#if defined(BUILDING_CEF_SHARED) + /// + // Return this string's data as a string16. Translation will occur if + // necessary based on the underlying string type. + /// + string16 ToString16() const { + if (empty()) + return string16(); + return traits::to_string16(string_); + } + + /// + // Set this string's data from an existing string16. Data will be always + // copied. Translation will occur if necessary based on the underlying string + // type. + /// + bool FromString16(const string16& str) { + if (str.empty()) { + clear(); + return true; + } + AllocIfNeeded(); + return traits::from_string16(str, string_); + } +#endif // BUILDING_CEF_SHARED + + /// + // Comparison operator overloads. + /// + bool operator<(const CefStringBase& str) const { + return (compare(str) < 0); + } + bool operator<=(const CefStringBase& str) const { + return (compare(str) <= 0); + } + bool operator>(const CefStringBase& str) const { + return (compare(str) > 0); + } + bool operator>=(const CefStringBase& str) const { + return (compare(str) >= 0); + } + bool operator==(const CefStringBase& str) const { + return (compare(str) == 0); + } + bool operator!=(const CefStringBase& str) const { + return (compare(str) != 0); + } + + /// + // Assignment operator overloads. + /// + CefStringBase& operator=(const CefStringBase& str) { + FromString(str.c_str(), str.length(), true); + return *this; + } + operator std::string() const { + return ToString(); + } + CefStringBase& operator=(const std::string& str) { + FromString(str); + return *this; + } + CefStringBase& operator=(const char* str) { + FromString(std::string(str)); + return *this; + } + operator std::wstring() const { + return ToWString(); + } + CefStringBase& operator=(const std::wstring& str) { + FromWString(str); + return *this; + } + CefStringBase& operator=(const wchar_t* str) { + FromWString(std::wstring(str)); + return *this; + } +#if (defined(BUILDING_CEF_SHARED) && defined(WCHAR_T_IS_UTF32)) + operator string16() const { + return ToString16(); + } + CefStringBase& operator=(const string16& str) { + FromString16(str); + return *this; + } + CefStringBase& operator=(const char16* str) { + FromString16(string16(str)); + return *this; + } +#endif // BUILDING_CEF_SHARED && WCHAR_T_IS_UTF32 + + private: + // Allocate the string structure if it doesn't already exist. + void AllocIfNeeded() { + if (string_ == NULL) { + string_ = new struct_type; + memset(string_, 0, sizeof(struct_type)); + owner_ = true; + } + } + + struct_type* string_; + bool owner_; +}; + + +typedef CefStringBase CefStringWide; +typedef CefStringBase CefStringUTF8; +typedef CefStringBase CefStringUTF16; + +#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_WRAPPERS_H_ diff --git a/cef3/include/internal/cef_time.h b/cef3/include/internal/cef_time.h new file mode 100644 index 000000000..64e601fe0 --- /dev/null +++ b/cef3/include/internal/cef_time.h @@ -0,0 +1,88 @@ +// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_TIME_H_ +#define CEF_INCLUDE_INTERNAL_CEF_TIME_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/internal/cef_export.h" +#include + +/// +// Time information. Values should always be in UTC. +/// +typedef struct _cef_time_t { + int year; // Four digit year "2007" + int month; // 1-based month (values 1 = January, etc.) + int day_of_week; // 0-based day of week (0 = Sunday, etc.) + int day_of_month; // 1-based day of month (1-31) + int hour; // Hour within the current day (0-23) + int minute; // Minute within the current hour (0-59) + int second; // Second within the current minute (0-59 plus leap + // seconds which may take it up to 60). + int millisecond; // Milliseconds within the current second (0-999) +} cef_time_t; + +/// +// Converts cef_time_t to/from time_t. Returns true (1) on success and false (0) +// on failure. +/// +CEF_EXPORT int cef_time_to_timet(const cef_time_t* cef_time, time_t* time); +CEF_EXPORT int cef_time_from_timet(time_t time, cef_time_t* cef_time); + +/// +// Converts cef_time_t to/from a double which is the number of seconds since +// epoch (Jan 1, 1970). Webkit uses this format to represent time. A value of 0 +// means "not initialized". Returns true (1) on success and false (0) on +// failure. +/// +CEF_EXPORT int cef_time_to_doublet(const cef_time_t* cef_time, double* time); +CEF_EXPORT int cef_time_from_doublet(double time, cef_time_t* cef_time); + +/// +// Retrieve the current system time. +// +CEF_EXPORT int cef_time_now(cef_time_t* cef_time); + +/// +// Retrieve the delta in milliseconds between two time values. +// +CEF_EXPORT int cef_time_delta(const cef_time_t* cef_time1, + const cef_time_t* cef_time2, + long long* delta); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_INTERNAL_CEF_TIME_H_ diff --git a/cef3/include/internal/cef_tuple.h b/cef3/include/internal/cef_tuple.h new file mode 100644 index 000000000..c2cdf7058 --- /dev/null +++ b/cef3/include/internal/cef_tuple.h @@ -0,0 +1,1088 @@ +// Copyright (c) 2006-2011 Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The contents of this file are identical to base/tuple.h + +// A Tuple is a generic templatized container, similar in concept to std::pair. +// There are classes Tuple0 to Tuple6, cooresponding to the number of elements +// it contains. The convenient MakeTuple() function takes 0 to 6 arguments, +// and will construct and return the appropriate Tuple object. The functions +// DispatchToMethod and DispatchToFunction take a function pointer or instance +// and method pointer, and unpack a tuple into arguments to the call. +// +// Tuple elements are copied by value, and stored in the tuple. See the unit +// tests for more details of how/when the values are copied. +// +// Example usage: +// // These two methods of creating a Tuple are identical. +// Tuple2 tuple_a(1, "wee"); +// Tuple2 tuple_b = MakeTuple(1, "wee"); +// +// void SomeFunc(int a, const char* b) { } +// DispatchToFunction(&SomeFunc, tuple_a); // SomeFunc(1, "wee") +// DispatchToFunction( +// &SomeFunc, MakeTuple(10, "foo")); // SomeFunc(10, "foo") +// +// struct { void SomeMeth(int a, int b, int c) { } } foo; +// DispatchToMethod(&foo, &Foo::SomeMeth, MakeTuple(1, 2, 3)); +// // foo->SomeMeth(1, 2, 3); + +#ifndef CEF_INCLUDE_INTERNAL_CEF_TUPLE_H_ +#define CEF_INCLUDE_INTERNAL_CEF_TUPLE_H_ +#pragma once + +// If base/tuple.h is included first then exclude this file. This is to +// facilitate the use of both base/bind.h and cef_runnable.h in unit tests. +#ifndef BASE_TUPLE_H__ + +#if defined(OS_CHROMEOS) +// To troubleshoot crosbug.com/7327. +#include "base/logging.h" +#endif +// Traits ---------------------------------------------------------------------- +// +// A simple traits class for tuple arguments. +// +// ValueType: the bare, nonref version of a type (same as the type for nonrefs). +// RefType: the ref version of a type (same as the type for refs). +// ParamType: what type to pass to functions (refs should not be constified). + +template +struct TupleTraits { + typedef P ValueType; + typedef P& RefType; + typedef const P& ParamType; +}; + +template +struct TupleTraits { + typedef P ValueType; + typedef P& RefType; + typedef P& ParamType; +}; + +template +struct TupleTypes { }; + +// Tuple ----------------------------------------------------------------------- +// +// This set of classes is useful for bundling 0 or more heterogeneous data types +// into a single variable. The advantage of this is that it greatly simplifies +// function objects that need to take an arbitrary number of parameters; see +// RunnableMethod and IPC::MessageWithTuple. +// +// Tuple0 is supplied to act as a 'void' type. It can be used, for example, +// when dispatching to a function that accepts no arguments (see the +// Dispatchers below). +// Tuple1 is rarely useful. One such use is when A is non-const ref that you +// want filled by the dispatchee, and the tuple is merely a container for that +// output (a "tier"). See MakeRefTuple and its usages. + +struct Tuple0 { + typedef Tuple0 ValueTuple; + typedef Tuple0 RefTuple; + typedef Tuple0 ParamTuple; +}; + +template +struct Tuple1 { + public: + typedef A TypeA; + + Tuple1() {} + explicit Tuple1(typename TupleTraits::ParamType a) : a(a) {} + + A a; +}; + +template +struct Tuple2 { + public: + typedef A TypeA; + typedef B TypeB; + + Tuple2() {} + Tuple2(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b) + : a(a), b(b) { + } + + A a; + B b; +}; + +template +struct Tuple3 { + public: + typedef A TypeA; + typedef B TypeB; + typedef C TypeC; + + Tuple3() {} + Tuple3(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c) + : a(a), b(b), c(c) { + } + + A a; + B b; + C c; +}; + +template +struct Tuple4 { + public: + typedef A TypeA; + typedef B TypeB; + typedef C TypeC; + typedef D TypeD; + + Tuple4() {} + Tuple4(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c, + typename TupleTraits::ParamType d) + : a(a), b(b), c(c), d(d) { + } + + A a; + B b; + C c; + D d; +}; + +template +struct Tuple5 { + public: + typedef A TypeA; + typedef B TypeB; + typedef C TypeC; + typedef D TypeD; + typedef E TypeE; + + Tuple5() {} + Tuple5(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c, + typename TupleTraits::ParamType d, + typename TupleTraits::ParamType e) + : a(a), b(b), c(c), d(d), e(e) { + } + + A a; + B b; + C c; + D d; + E e; +}; + +template +struct Tuple6 { + public: + typedef A TypeA; + typedef B TypeB; + typedef C TypeC; + typedef D TypeD; + typedef E TypeE; + typedef F TypeF; + + Tuple6() {} + Tuple6(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c, + typename TupleTraits::ParamType d, + typename TupleTraits::ParamType e, + typename TupleTraits::ParamType f) + : a(a), b(b), c(c), d(d), e(e), f(f) { + } + + A a; + B b; + C c; + D d; + E e; + F f; +}; + +template +struct Tuple7 { + public: + typedef A TypeA; + typedef B TypeB; + typedef C TypeC; + typedef D TypeD; + typedef E TypeE; + typedef F TypeF; + typedef G TypeG; + + Tuple7() {} + Tuple7(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c, + typename TupleTraits::ParamType d, + typename TupleTraits::ParamType e, + typename TupleTraits::ParamType f, + typename TupleTraits::ParamType g) + : a(a), b(b), c(c), d(d), e(e), f(f), g(g) { + } + + A a; + B b; + C c; + D d; + E e; + F f; + G g; +}; + +template +struct Tuple8 { + public: + typedef A TypeA; + typedef B TypeB; + typedef C TypeC; + typedef D TypeD; + typedef E TypeE; + typedef F TypeF; + typedef G TypeG; + typedef H TypeH; + + Tuple8() {} + Tuple8(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c, + typename TupleTraits::ParamType d, + typename TupleTraits::ParamType e, + typename TupleTraits::ParamType f, + typename TupleTraits::ParamType g, + typename TupleTraits::ParamType h) + : a(a), b(b), c(c), d(d), e(e), f(f), g(g), h(h) { + } + + A a; + B b; + C c; + D d; + E e; + F f; + G g; + H h; +}; + +// Tuple types ---------------------------------------------------------------- +// +// Allows for selection of ValueTuple/RefTuple/ParamTuple without needing the +// definitions of class types the tuple takes as parameters. + +template <> +struct TupleTypes< Tuple0 > { + typedef Tuple0 ValueTuple; + typedef Tuple0 RefTuple; + typedef Tuple0 ParamTuple; +}; + +template +struct TupleTypes< Tuple1 > { + typedef Tuple1::ValueType> ValueTuple; + typedef Tuple1::RefType> RefTuple; + typedef Tuple1::ParamType> ParamTuple; +}; + +template +struct TupleTypes< Tuple2 > { + typedef Tuple2::ValueType, + typename TupleTraits::ValueType> ValueTuple; +typedef Tuple2::RefType, + typename TupleTraits::RefType> RefTuple; + typedef Tuple2::ParamType, + typename TupleTraits::ParamType> ParamTuple; +}; + +template +struct TupleTypes< Tuple3 > { + typedef Tuple3::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType> ValueTuple; +typedef Tuple3::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> RefTuple; + typedef Tuple3::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType> ParamTuple; +}; + +template +struct TupleTypes< Tuple4 > { + typedef Tuple4::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType> ValueTuple; +typedef Tuple4::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> RefTuple; + typedef Tuple4::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType> ParamTuple; +}; + +template +struct TupleTypes< Tuple5 > { + typedef Tuple5::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType> ValueTuple; +typedef Tuple5::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> RefTuple; + typedef Tuple5::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType> ParamTuple; +}; + +template +struct TupleTypes< Tuple6 > { + typedef Tuple6::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType> ValueTuple; +typedef Tuple6::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> RefTuple; + typedef Tuple6::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType> ParamTuple; +}; + +template +struct TupleTypes< Tuple7 > { + typedef Tuple7::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType> ValueTuple; +typedef Tuple7::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> RefTuple; + typedef Tuple7::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType> ParamTuple; +}; + +template +struct TupleTypes< Tuple8 > { + typedef Tuple8::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType> ValueTuple; +typedef Tuple8::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> RefTuple; + typedef Tuple8::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType> ParamTuple; +}; + +// Tuple creators ------------------------------------------------------------- +// +// Helper functions for constructing tuples while inferring the template +// argument types. + +inline Tuple0 MakeTuple() { + return Tuple0(); +} + +template +inline Tuple1 MakeTuple(const A& a) { + return Tuple1(a); +} + +template +inline Tuple2 MakeTuple(const A& a, const B& b) { + return Tuple2(a, b); +} + +template +inline Tuple3 MakeTuple(const A& a, const B& b, const C& c) { + return Tuple3(a, b, c); +} + +template +inline Tuple4 MakeTuple(const A& a, const B& b, const C& c, + const D& d) { + return Tuple4(a, b, c, d); +} + +template +inline Tuple5 MakeTuple(const A& a, const B& b, const C& c, + const D& d, const E& e) { + return Tuple5(a, b, c, d, e); +} + +template +inline Tuple6 MakeTuple(const A& a, const B& b, const C& c, + const D& d, const E& e, const F& f) { + return Tuple6(a, b, c, d, e, f); +} + +template +inline Tuple7 MakeTuple(const A& a, const B& b, const C& c, + const D& d, const E& e, const F& f, + const G& g) { + return Tuple7(a, b, c, d, e, f, g); +} + +template +inline Tuple8 MakeTuple(const A& a, const B& b, + const C& c, const D& d, + const E& e, const F& f, + const G& g, const H& h) { + return Tuple8(a, b, c, d, e, f, g, h); +} + +// The following set of helpers make what Boost refers to as "Tiers" - a tuple +// of references. + +template +inline Tuple1 MakeRefTuple(A& a) { + return Tuple1(a); +} + +template +inline Tuple2 MakeRefTuple(A& a, B& b) { + return Tuple2(a, b); +} + +template +inline Tuple3 MakeRefTuple(A& a, B& b, C& c) { + return Tuple3(a, b, c); +} + +template +inline Tuple4 MakeRefTuple(A& a, B& b, C& c, D& d) { + return Tuple4(a, b, c, d); +} + +template +inline Tuple5 MakeRefTuple(A& a, B& b, C& c, D& d, E& e) { + return Tuple5(a, b, c, d, e); +} + +template +inline Tuple6 MakeRefTuple(A& a, B& b, C& c, D& d, E& e, + F& f) { + return Tuple6(a, b, c, d, e, f); +} + +template +inline Tuple7 MakeRefTuple(A& a, B& b, C& c, D& d, + E& e, F& f, G& g) { + return Tuple7(a, b, c, d, e, f, g); +} + +template +inline Tuple8 MakeRefTuple(A& a, B& b, C& c, + D& d, E& e, F& f, + G& g, H& h) { + return Tuple8(a, b, c, d, e, f, g, h); +} + +// Dispatchers ---------------------------------------------------------------- +// +// Helper functions that call the given method on an object, with the unpacked +// tuple arguments. Notice that they all have the same number of arguments, +// so you need only write: +// DispatchToMethod(object, &Object::method, args); +// This is very useful for templated dispatchers, since they don't need to know +// what type |args| is. + +// Non-Static Dispatchers with no out params. + +template +inline void DispatchToMethod(ObjT* obj, Method method, const Tuple0& arg) { + (obj->*method)(); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, const A& arg) { + (obj->*method)(arg); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, const Tuple1& arg) { +#if defined(OS_CHROMEOS) + // To troubleshoot crosbug.com/7327. + CHECK(obj); + CHECK(&arg); + CHECK(method); +#endif + (obj->*method)(arg.a); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple2& arg) { + (obj->*method)(arg.a, arg.b); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple3& arg) { + (obj->*method)(arg.a, arg.b, arg.c); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple4& arg) { + (obj->*method)(arg.a, arg.b, arg.c, arg.d); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple5& arg) { + (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple6& arg) { + (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple7& arg) { + (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g); +} + +// Static Dispatchers with no out params. + +template +inline void DispatchToFunction(Function function, const Tuple0& arg) { + (*function)(); +} + +template +inline void DispatchToFunction(Function function, const A& arg) { + (*function)(arg); +} + +template +inline void DispatchToFunction(Function function, const Tuple1& arg) { + (*function)(arg.a); +} + +template +inline void DispatchToFunction(Function function, const Tuple2& arg) { + (*function)(arg.a, arg.b); +} + +template +inline void DispatchToFunction(Function function, const Tuple3& arg) { + (*function)(arg.a, arg.b, arg.c); +} + +template +inline void DispatchToFunction(Function function, + const Tuple4& arg) { + (*function)(arg.a, arg.b, arg.c, arg.d); +} + +template +inline void DispatchToFunction(Function function, + const Tuple5& arg) { + (*function)(arg.a, arg.b, arg.c, arg.d, arg.e); +} + +template +inline void DispatchToFunction(Function function, + const Tuple6& arg) { + (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f); +} + +template +inline void DispatchToFunction(Function function, + const Tuple7& arg) { + (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g); +} + +template +inline void DispatchToFunction(Function function, + const Tuple8& arg) { + (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g, arg.h); +} + +// Dispatchers with 0 out param (as a Tuple0). + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple0& arg, Tuple0*) { + (obj->*method)(); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, const A& arg, Tuple0*) { + (obj->*method)(arg); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple1& arg, Tuple0*) { + (obj->*method)(arg.a); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple2& arg, Tuple0*) { + (obj->*method)(arg.a, arg.b); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple3& arg, Tuple0*) { + (obj->*method)(arg.a, arg.b, arg.c); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple4& arg, Tuple0*) { + (obj->*method)(arg.a, arg.b, arg.c, arg.d); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple5& arg, Tuple0*) { + (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple6& arg, Tuple0*) { + (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f); +} + +// Dispatchers with 1 out param. + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple0& in, + Tuple1* out) { + (obj->*method)(&out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const InA& in, + Tuple1* out) { + (obj->*method)(in, &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple1& in, + Tuple1* out) { + (obj->*method)(in.a, &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple2& in, + Tuple1* out) { + (obj->*method)(in.a, in.b, &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple3& in, + Tuple1* out) { + (obj->*method)(in.a, in.b, in.c, &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple4& in, + Tuple1* out) { + (obj->*method)(in.a, in.b, in.c, in.d, &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple5& in, + Tuple1* out) { + (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple6& in, + Tuple1* out) { + (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a); +} + +// Dispatchers with 2 out params. + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple0& in, + Tuple2* out) { + (obj->*method)(&out->a, &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const InA& in, + Tuple2* out) { + (obj->*method)(in, &out->a, &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple1& in, + Tuple2* out) { + (obj->*method)(in.a, &out->a, &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple2& in, + Tuple2* out) { + (obj->*method)(in.a, in.b, &out->a, &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple3& in, + Tuple2* out) { + (obj->*method)(in.a, in.b, in.c, &out->a, &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple4& in, + Tuple2* out) { + (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple5& in, + Tuple2* out) { + (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple6& in, + Tuple2* out) { + (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a, &out->b); +} + +// Dispatchers with 3 out params. + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple0& in, + Tuple3* out) { + (obj->*method)(&out->a, &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const InA& in, + Tuple3* out) { + (obj->*method)(in, &out->a, &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple1& in, + Tuple3* out) { + (obj->*method)(in.a, &out->a, &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple2& in, + Tuple3* out) { + (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple3& in, + Tuple3* out) { + (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple4& in, + Tuple3* out) { + (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple5& in, + Tuple3* out) { + (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple6& in, + Tuple3* out) { + (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a, &out->b, &out->c); +} + +// Dispatchers with 4 out params. + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple0& in, + Tuple4* out) { + (obj->*method)(&out->a, &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const InA& in, + Tuple4* out) { + (obj->*method)(in, &out->a, &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple1& in, + Tuple4* out) { + (obj->*method)(in.a, &out->a, &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple2& in, + Tuple4* out) { + (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple3& in, + Tuple4* out) { + (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple4& in, + Tuple4* out) { + (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple5& in, + Tuple4* out) { + (obj->*method)(in.a, in.b, in.c, in.d, in.e, + &out->a, &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple6& in, + Tuple4* out) { + (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, + &out->a, &out->b, &out->c, &out->d); +} + +// Dispatchers with 5 out params. + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple0& in, + Tuple5* out) { + (obj->*method)(&out->a, &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const InA& in, + Tuple5* out) { + (obj->*method)(in, &out->a, &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple1& in, + Tuple5* out) { + (obj->*method)(in.a, &out->a, &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple2& in, + Tuple5* out) { + (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple3& in, + Tuple5* out) { + (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple4& in, + Tuple5* out) { + (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c, &out->d, + &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple5& in, + Tuple5* out) { + (obj->*method)(in.a, in.b, in.c, in.d, in.e, + &out->a, &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple6& in, + Tuple5* out) { + (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, + &out->a, &out->b, &out->c, &out->d, &out->e); +} + +#endif // BASE_TUPLE_H__ + +#endif // CEF_INCLUDE_INTERNAL_CEF_TUPLE_H_ diff --git a/cef3/include/internal/cef_types.h b/cef3/include/internal/cef_types.h new file mode 100644 index 000000000..988e5a0ba --- /dev/null +++ b/cef3/include/internal/cef_types.h @@ -0,0 +1,1478 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_H_ +#define CEF_INCLUDE_INTERNAL_CEF_TYPES_H_ +#pragma once + +#include "include/internal/cef_build.h" +#include "include/internal/cef_string.h" +#include "include/internal/cef_string_list.h" +#include "include/internal/cef_time.h" + +// Bring in platform-specific definitions. +#if defined(OS_WIN) +#include "include/internal/cef_types_win.h" +#elif defined(OS_MACOSX) +#include "include/internal/cef_types_mac.h" +#elif defined(OS_LINUX) +#include "include/internal/cef_types_linux.h" +#endif + +#include // For size_t + +// The NSPR system headers define 64-bit as |long| when possible, except on +// Mac OS X. In order to not have typedef mismatches, we do the same on LP64. +// +// On Mac OS X, |long long| is used for 64-bit types for compatibility with +// format macros even in the LP64 model. +#if defined(__LP64__) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) +typedef long int64; // NOLINT(runtime/int) +typedef unsigned long uint64; // NOLINT(runtime/int) +#else +typedef long long int64; // NOLINT(runtime/int) +typedef unsigned long long uint64; // NOLINT(runtime/int) +#endif + +// TODO: Remove these type guards. These are to avoid conflicts with +// obsolete/protypes.h in the Gecko SDK. +#ifndef _INT32 +#define _INT32 +typedef int int32; +#endif + +// TODO: Remove these type guards. These are to avoid conflicts with +// obsolete/protypes.h in the Gecko SDK. +#ifndef _UINT32 +#define _UINT32 +typedef unsigned int uint32; +#endif + +// UTF-16 character type +#ifndef char16 +#if defined(WIN32) +typedef wchar_t char16; +#else +typedef unsigned short char16; +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// Log severity levels. +/// +enum cef_log_severity_t { + /// + // Default logging (currently INFO logging). + /// + LOGSEVERITY_DEFAULT, + + /// + // Verbose logging. + /// + LOGSEVERITY_VERBOSE, + + /// + // INFO logging. + /// + LOGSEVERITY_INFO, + + /// + // WARNING logging. + /// + LOGSEVERITY_WARNING, + + /// + // ERROR logging. + /// + LOGSEVERITY_ERROR, + + /// + // ERROR_REPORT logging. + /// + LOGSEVERITY_ERROR_REPORT, + + /// + // Completely disable logging. + /// + LOGSEVERITY_DISABLE = 99 +}; + +/// +// Represents the state of a setting. +/// +enum cef_state_t { + /// + // Use the default state for the setting. + /// + STATE_DEFAULT = 0, + + /// + // Enable or allow the setting. + /// + STATE_ENABLED, + + /// + // Disable or disallow the setting. + /// + STATE_DISABLED, +}; + +/// +// Initialization settings. Specify NULL or 0 to get the recommended default +// values. Many of these and other settings can also configured using command- +// line switches. +/// +typedef struct _cef_settings_t { + /// + // Size of this structure. + /// + size_t size; + + /// + // Set to true (1) to use a single process for the browser and renderer. This + // run mode is not officially supported by Chromium and is less stable than + // the multi-process default. Also configurable using the "single-process" + // command-line switch. + /// + bool single_process; + + /// + // The path to a separate executable that will be launched for sub-processes. + // By default the browser process executable is used. See the comments on + // CefExecuteProcess() for details. Also configurable using the + // "browser-subprocess-path" command-line switch. + /// + cef_string_t browser_subprocess_path; + + /// + // Set to true (1) to have the browser process message loop run in a separate + // thread. If false (0) than the CefDoMessageLoopWork() function must be + // called from your application message loop. + /// + bool multi_threaded_message_loop; + + /// + // Set to true (1) to disable configuration of browser process features using + // standard CEF and Chromium command-line arguments. Configuration can still + // be specified using CEF data structures or via the + // CefApp::OnBeforeCommandLineProcessing() method. + /// + bool command_line_args_disabled; + + /// + // The location where cache data will be stored on disk. If empty an in-memory + // cache will be used. HTML5 databases such as localStorage will only persist + // across sessions if a cache path is specified. + /// + cef_string_t cache_path; + + /// + // To persist session cookies (cookies without an expiry date or validity + // interval) by default when using the global cookie manager set this value to + // true. Session cookies are generally intended to be transient and most Web + // browsers do not persist them. A |cache_path| value must also be specified to + // enable this feature. Also configurable using the "persist-session-cookies" + // command-line switch. + /// + bool persist_session_cookies; + + /// + // Value that will be returned as the User-Agent HTTP header. If empty the + // default User-Agent string will be used. Also configurable using the + // "user-agent" command-line switch. + /// + cef_string_t user_agent; + + /// + // Value that will be inserted as the product portion of the default + // User-Agent string. If empty the Chromium product version will be used. If + // |userAgent| is specified this value will be ignored. Also configurable + // using the "product-version" command-line switch. + /// + cef_string_t product_version; + + /// + // The locale string that will be passed to WebKit. If empty the default + // locale of "en-US" will be used. This value is ignored on Linux where locale + // is determined using environment variable parsing with the precedence order: + // LANGUAGE, LC_ALL, LC_MESSAGES and LANG. Also configurable using the "lang" + // command-line switch. + /// + cef_string_t locale; + + /// + // The directory and file name to use for the debug log. If empty, the + // default name of "debug.log" will be used and the file will be written + // to the application directory. Also configurable using the "log-file" + // command-line switch. + /// + cef_string_t log_file; + + /// + // The log severity. Only messages of this severity level or higher will be + // logged. Also configurable using the "log-severity" command-line switch with + // a value of "verbose", "info", "warning", "error", "error-report" or + // "disable". + /// + cef_log_severity_t log_severity; + + /// + // Enable DCHECK in release mode to ease debugging. Also configurable using the + // "enable-release-dcheck" command-line switch. + /// + bool release_dcheck_enabled; + + /// + // Custom flags that will be used when initializing the V8 JavaScript engine. + // The consequences of using custom flags may not be well tested. Also + // configurable using the "js-flags" command-line switch. + /// + cef_string_t javascript_flags; + + /// + // The fully qualified path for the resources directory. If this value is + // empty the cef.pak and/or devtools_resources.pak files must be located in + // the module directory on Windows/Linux or the app bundle Resources directory + // on Mac OS X. Also configurable using the "resources-dir-path" command-line + // switch. + /// + cef_string_t resources_dir_path; + + /// + // The fully qualified path for the locales directory. If this value is empty + // the locales directory must be located in the module directory. This value + // is ignored on Mac OS X where pack files are always loaded from the app + // bundle Resources directory. Also configurable using the "locales-dir-path" + // command-line switch. + /// + cef_string_t locales_dir_path; + + /// + // Set to true (1) to disable loading of pack files for resources and locales. + // A resource bundle handler must be provided for the browser and render + // processes via CefApp::GetResourceBundleHandler() if loading of pack files + // is disabled. Also configurable using the "disable-pack-loading" command- + // line switch. + /// + bool pack_loading_disabled; + + /// + // Set to a value between 1024 and 65535 to enable remote debugging on the + // specified port. For example, if 8080 is specified the remote debugging URL + // will be http://localhost:8080. CEF can be remotely debugged from any CEF or + // Chrome browser window. Also configurable using the "remote-debugging-port" + // command-line switch. + /// + int remote_debugging_port; + + /// + // The number of stack trace frames to capture for uncaught exceptions. + // Specify a positive value to enable the CefV8ContextHandler:: + // OnUncaughtException() callback. Specify 0 (default value) and + // OnUncaughtException() will not be called. Also configurable using the + // "uncaught-exception-stack-size" command-line switch. + /// + int uncaught_exception_stack_size; + + /// + // By default CEF V8 references will be invalidated (the IsValid() method will + // return false) after the owning context has been released. This reduces the + // need for external record keeping and avoids crashes due to the use of V8 + // references after the associated context has been released. + // + // CEF currently offers two context safety implementations with different + // performance characteristics. The default implementation (value of 0) uses a + // map of hash values and should provide better performance in situations with + // a small number contexts. The alternate implementation (value of 1) uses a + // hidden value attached to each context and should provide better performance + // in situations with a large number of contexts. + // + // If you need better performance in the creation of V8 references and you + // plan to manually track context lifespan you can disable context safety by + // specifying a value of -1. + // + // Also configurable using the "context-safety-implementation" command-line + // switch. + /// + int context_safety_implementation; + + /// + // Set to true (1) to ignore errors related to invalid SSL certificates. + // Enabling this setting can lead to potential security vulnerabilities like + // "man in the middle" attacks. Applications that load content from the + // internet should not enable this setting. Also configurable using the + // "ignore-certificate-errors" command-line switch. + /// + bool ignore_certificate_errors; +} cef_settings_t; + +/// +// Browser initialization settings. Specify NULL or 0 to get the recommended +// default values. The consequences of using custom values may not be well +// tested. Many of these and other settings can also configured using command- +// line switches. +/// +typedef struct _cef_browser_settings_t { + /// + // Size of this structure. + /// + size_t size; + + // The below values map to WebPreferences settings. + + /// + // Font settings. + /// + cef_string_t standard_font_family; + cef_string_t fixed_font_family; + cef_string_t serif_font_family; + cef_string_t sans_serif_font_family; + cef_string_t cursive_font_family; + cef_string_t fantasy_font_family; + int default_font_size; + int default_fixed_font_size; + int minimum_font_size; + int minimum_logical_font_size; + + /// + // Default encoding for Web content. If empty "ISO-8859-1" will be used. Also + // configurable using the "default-encoding" command-line switch. + /// + cef_string_t default_encoding; + + /// + // Location of the user style sheet that will be used for all pages. This must + // be a data URL of the form "data:text/css;charset=utf-8;base64,csscontent" + // where "csscontent" is the base64 encoded contents of the CSS file. Also + // configurable using the "user-style-sheet-location" command-line switch. + /// + cef_string_t user_style_sheet_location; + + /// + // Controls the loading of fonts from remote sources. Also configurable using + // the "disable-remote-fonts" command-line switch. + /// + cef_state_t remote_fonts; + + /// + // Controls whether JavaScript can be executed. Also configurable using the + // "disable-javascript" command-line switch. + /// + cef_state_t javascript; + + /// + // Controls whether JavaScript can be used for opening windows. Also + // configurable using the "disable-javascript-open-windows" command-line + // switch. + /// + cef_state_t javascript_open_windows; + + /// + // Controls whether JavaScript can be used to close windows that were not + // opened via JavaScript. JavaScript can still be used to close windows that + // were opened via JavaScript. Also configurable using the + // "disable-javascript-close-windows" command-line switch. + /// + cef_state_t javascript_close_windows; + + /// + // Controls whether JavaScript can access the clipboard. Also configurable + // using the "disable-javascript-access-clipboard" command-line switch. + /// + cef_state_t javascript_access_clipboard; + + /// + // Controls whether DOM pasting is supported in the editor via + // execCommand("paste"). The |javascript_access_clipboard| setting must also + // be enabled. Also configurable using the "disable-javascript-dom-paste" + // command-line switch. + /// + cef_state_t javascript_dom_paste; + + /// + // Controls whether the caret position will be drawn. Also configurable using + // the "enable-caret-browsing" command-line switch. + /// + cef_state_t caret_browsing; + + /// + // Controls whether the Java plugin will be loaded. Also configurable using + // the "disable-java" command-line switch. + /// + cef_state_t java; + + /// + // Controls whether any plugins will be loaded. Also configurable using the + // "disable-plugins" command-line switch. + /// + cef_state_t plugins; + + /// + // Controls whether file URLs will have access to all URLs. Also configurable + // using the "allow-universal-access-from-files" command-line switch. + /// + cef_state_t universal_access_from_file_urls; + + /// + // Controls whether file URLs will have access to other file URLs. Also + // configurable using the "allow-access-from-files" command-line switch. + /// + cef_state_t file_access_from_file_urls; + + /// + // Controls whether web security restrictions (same-origin policy) will be + // enforced. Disabling this setting is not recommend as it will allow risky + // security behavior such as cross-site scripting (XSS). Also configurable + // using the "disable-web-security" command-line switch. + /// + cef_state_t web_security; + + /// + // Controls whether image URLs will be loaded from the network. A cached image + // will still be rendered if requested. Also configurable using the + // "disable-image-loading" command-line switch. + /// + cef_state_t image_loading; + + /// + // Controls whether standalone images will be shrunk to fit the page. Also + // configurable using the "image-shrink-standalone-to-fit" command-line + // switch. + /// + cef_state_t image_shrink_standalone_to_fit; + + /// + // Controls whether text areas can be resized. Also configurable using the + // "disable-text-area-resize" command-line switch. + /// + cef_state_t text_area_resize; + + /// + // Controls whether the fastback (back/forward) page cache will be used. Also + // configurable using the "enable-fastback" command-line switch. + /// + cef_state_t page_cache; + + /// + // Controls whether the tab key can advance focus to links. Also configurable + // using the "disable-tab-to-links" command-line switch. + /// + cef_state_t tab_to_links; + + /// + // Controls whether style sheets can be used. Also configurable using the + // "disable-author-and-user-styles" command-line switch. + /// + cef_state_t author_and_user_styles; + + /// + // Controls whether local storage can be used. Also configurable using the + // "disable-local-storage" command-line switch. + /// + cef_state_t local_storage; + + /// + // Controls whether databases can be used. Also configurable using the + // "disable-databases" command-line switch. + /// + cef_state_t databases; + + /// + // Controls whether the application cache can be used. Also configurable using + // the "disable-application-cache" command-line switch. + /// + cef_state_t application_cache; + + /// + // Controls whether WebGL can be used. Note that WebGL requires hardware + // support and may not work on all systems even when enabled. Also + // configurable using the "disable-webgl" command-line switch. + /// + cef_state_t webgl; + + /// + // Controls whether content that depends on accelerated compositing can be + // used. Note that accelerated compositing requires hardware support and may + // not work on all systems even when enabled. Also configurable using the + // "disable-accelerated-compositing" command-line switch. + /// + cef_state_t accelerated_compositing; + + /// + // Controls whether developer tools (WebKit inspector) can be used. Also + // configurable using the "disable-developer-tools" command-line switch. + /// + cef_state_t developer_tools; +} cef_browser_settings_t; + +/// +// URL component parts. +/// +typedef struct _cef_urlparts_t { + /// + // The complete URL specification. + /// + cef_string_t spec; + + /// + // Scheme component not including the colon (e.g., "http"). + /// + cef_string_t scheme; + + /// + // User name component. + /// + cef_string_t username; + + /// + // Password component. + /// + cef_string_t password; + + /// + // Host component. This may be a hostname, an IPv4 address or an IPv6 literal + // surrounded by square brackets (e.g., "[2001:db8::1]"). + /// + cef_string_t host; + + /// + // Port number component. + /// + cef_string_t port; + + /// + // Path component including the first slash following the host. + /// + cef_string_t path; + + /// + // Query string component (i.e., everything following the '?'). + /// + cef_string_t query; +} cef_urlparts_t; + +/// +// Cookie information. +/// +typedef struct _cef_cookie_t { + /// + // The cookie name. + /// + cef_string_t name; + + /// + // The cookie value. + /// + cef_string_t value; + + /// + // If |domain| is empty a host cookie will be created instead of a domain + // cookie. Domain cookies are stored with a leading "." and are visible to + // sub-domains whereas host cookies are not. + /// + cef_string_t domain; + + /// + // If |path| is non-empty only URLs at or below the path will get the cookie + // value. + /// + cef_string_t path; + + /// + // If |secure| is true the cookie will only be sent for HTTPS requests. + /// + bool secure; + + /// + // If |httponly| is true the cookie will only be sent for HTTP requests. + /// + bool httponly; + + /// + // The cookie creation date. This is automatically populated by the system on + // cookie creation. + /// + cef_time_t creation; + + /// + // The cookie last access date. This is automatically populated by the system + // on access. + /// + cef_time_t last_access; + + /// + // The cookie expiration date is only valid if |has_expires| is true. + /// + bool has_expires; + cef_time_t expires; +} cef_cookie_t; + +/// +// Process termination status values. +/// +enum cef_termination_status_t { + /// + // Non-zero exit status. + /// + TS_ABNORMAL_TERMINATION, + + /// + // SIGKILL or task manager kill. + /// + TS_PROCESS_WAS_KILLED, + + /// + // Segmentation fault. + /// + TS_PROCESS_CRASHED, +}; + +/// +// Path key values. +/// +enum cef_path_key_t { + /// + // Current directory. + /// + PK_DIR_CURRENT, + + /// + // Directory containing PK_FILE_EXE. + /// + PK_DIR_EXE, + + /// + // Directory containing PK_FILE_MODULE. + /// + PK_DIR_MODULE, + + /// + // Temporary directory. + /// + PK_DIR_TEMP, + + /// + // Path and filename of the current executable. + /// + PK_FILE_EXE, + + /// + // Path and filename of the module containing the CEF code (usually the libcef + // module). + /// + PK_FILE_MODULE, +}; + +/// +// Storage types. +/// +enum cef_storage_type_t { + ST_LOCALSTORAGE = 0, + ST_SESSIONSTORAGE, +}; + +/// +// Supported error code values. See net\base\net_error_list.h for complete +// descriptions of the error codes. +/// +enum cef_errorcode_t { + ERR_NONE = 0, + ERR_FAILED = -2, + ERR_ABORTED = -3, + ERR_INVALID_ARGUMENT = -4, + ERR_INVALID_HANDLE = -5, + ERR_FILE_NOT_FOUND = -6, + ERR_TIMED_OUT = -7, + ERR_FILE_TOO_BIG = -8, + ERR_UNEXPECTED = -9, + ERR_ACCESS_DENIED = -10, + ERR_NOT_IMPLEMENTED = -11, + ERR_CONNECTION_CLOSED = -100, + ERR_CONNECTION_RESET = -101, + ERR_CONNECTION_REFUSED = -102, + ERR_CONNECTION_ABORTED = -103, + ERR_CONNECTION_FAILED = -104, + ERR_NAME_NOT_RESOLVED = -105, + ERR_INTERNET_DISCONNECTED = -106, + ERR_SSL_PROTOCOL_ERROR = -107, + ERR_ADDRESS_INVALID = -108, + ERR_ADDRESS_UNREACHABLE = -109, + ERR_SSL_CLIENT_AUTH_CERT_NEEDED = -110, + ERR_TUNNEL_CONNECTION_FAILED = -111, + ERR_NO_SSL_VERSIONS_ENABLED = -112, + ERR_SSL_VERSION_OR_CIPHER_MISMATCH = -113, + ERR_SSL_RENEGOTIATION_REQUESTED = -114, + ERR_CERT_COMMON_NAME_INVALID = -200, + ERR_CERT_DATE_INVALID = -201, + ERR_CERT_AUTHORITY_INVALID = -202, + ERR_CERT_CONTAINS_ERRORS = -203, + ERR_CERT_NO_REVOCATION_MECHANISM = -204, + ERR_CERT_UNABLE_TO_CHECK_REVOCATION = -205, + ERR_CERT_REVOKED = -206, + ERR_CERT_INVALID = -207, + ERR_CERT_END = -208, + ERR_INVALID_URL = -300, + ERR_DISALLOWED_URL_SCHEME = -301, + ERR_UNKNOWN_URL_SCHEME = -302, + ERR_TOO_MANY_REDIRECTS = -310, + ERR_UNSAFE_REDIRECT = -311, + ERR_UNSAFE_PORT = -312, + ERR_INVALID_RESPONSE = -320, + ERR_INVALID_CHUNKED_ENCODING = -321, + ERR_METHOD_NOT_SUPPORTED = -322, + ERR_UNEXPECTED_PROXY_AUTH = -323, + ERR_EMPTY_RESPONSE = -324, + ERR_RESPONSE_HEADERS_TOO_BIG = -325, + ERR_CACHE_MISS = -400, + ERR_INSECURE_RESPONSE = -501, +}; + +/// +// V8 access control values. +/// +enum cef_v8_accesscontrol_t { + V8_ACCESS_CONTROL_DEFAULT = 0, + V8_ACCESS_CONTROL_ALL_CAN_READ = 1, + V8_ACCESS_CONTROL_ALL_CAN_WRITE = 1 << 1, + V8_ACCESS_CONTROL_PROHIBITS_OVERWRITING = 1 << 2 +}; + +/// +// V8 property attribute values. +/// +enum cef_v8_propertyattribute_t { + V8_PROPERTY_ATTRIBUTE_NONE = 0, // Writeable, Enumerable, + // Configurable + V8_PROPERTY_ATTRIBUTE_READONLY = 1 << 0, // Not writeable + V8_PROPERTY_ATTRIBUTE_DONTENUM = 1 << 1, // Not enumerable + V8_PROPERTY_ATTRIBUTE_DONTDELETE = 1 << 2 // Not configurable +}; + +/// +// Post data elements may represent either bytes or files. +/// +enum cef_postdataelement_type_t { + PDE_TYPE_EMPTY = 0, + PDE_TYPE_BYTES, + PDE_TYPE_FILE, +}; + +/// +// Flags used to customize the behavior of CefURLRequest. +/// +enum cef_urlrequest_flags_t { + /// + // Default behavior. + /// + UR_FLAG_NONE = 0, + + /// + // If set the cache will be skipped when handling the request. + /// + UR_FLAG_SKIP_CACHE = 1 << 0, + + /// + // If set user name, password, and cookies may be sent with the request. + /// + UR_FLAG_ALLOW_CACHED_CREDENTIALS = 1 << 1, + + /// + // If set cookies may be sent with the request and saved from the response. + // UR_FLAG_ALLOW_CACHED_CREDENTIALS must also be set. + /// + UR_FLAG_ALLOW_COOKIES = 1 << 2, + + /// + // If set upload progress events will be generated when a request has a body. + /// + UR_FLAG_REPORT_UPLOAD_PROGRESS = 1 << 3, + + /// + // If set load timing info will be collected for the request. + /// + UR_FLAG_REPORT_LOAD_TIMING = 1 << 4, + + /// + // If set the headers sent and received for the request will be recorded. + /// + UR_FLAG_REPORT_RAW_HEADERS = 1 << 5, + + /// + // If set the CefURLRequestClient::OnDownloadData method will not be called. + /// + UR_FLAG_NO_DOWNLOAD_DATA = 1 << 6, + + /// + // If set 5XX redirect errors will be propagated to the observer instead of + // automatically re-tried. This currently only applies for requests + // originated in the browser process. + /// + UR_FLAG_NO_RETRY_ON_5XX = 1 << 7, +}; + +/// +// Flags that represent CefURLRequest status. +/// +enum cef_urlrequest_status_t { + /// + // Unknown status. + /// + UR_UNKNOWN = 0, + + /// + // Request succeeded. + /// + UR_SUCCESS, + + /// + // An IO request is pending, and the caller will be informed when it is + // completed. + /// + UR_IO_PENDING, + + /// + // Request was canceled programatically. + /// + UR_CANCELED, + + /// + // Request failed for some reason. + /// + UR_FAILED, +}; + +/// +// Structure representing a rectangle. +/// +typedef struct _cef_rect_t { + int x; + int y; + int width; + int height; +} cef_rect_t; + +/// +// Existing process IDs. +/// +enum cef_process_id_t { + /// + // Browser process. + /// + PID_BROWSER, + /// + // Renderer process. + /// + PID_RENDERER, +}; + +/// +// Existing thread IDs. +/// +enum cef_thread_id_t { +// BROWSER PROCESS THREADS -- Only available in the browser process. + + /// + // The main thread in the browser. This will be the same as the main + // application thread if CefInitialize() is called with a + // CefSettings.multi_threaded_message_loop value of false. + /// + TID_UI, + + /// + // Used to interact with the database. + /// + TID_DB, + + /// + // Used to interact with the file system. + /// + TID_FILE, + + /// + // Used for file system operations that block user interactions. + // Responsiveness of this thread affects users. + /// + TID_FILE_USER_BLOCKING, + + /// + // Used to launch and terminate browser processes. + /// + TID_PROCESS_LAUNCHER, + + /// + // Used to handle slow HTTP cache operations. + /// + TID_CACHE, + + /// + // Used to process IPC and network messages. + /// + TID_IO, + +// RENDER PROCESS THREADS -- Only available in the render process. + + /// + // The main thread in the renderer. Used for all WebKit and V8 interaction. + /// + TID_RENDERER, +}; + +/// +// Supported value types. +/// +enum cef_value_type_t { + VTYPE_INVALID = 0, + VTYPE_NULL, + VTYPE_BOOL, + VTYPE_INT, + VTYPE_DOUBLE, + VTYPE_STRING, + VTYPE_BINARY, + VTYPE_DICTIONARY, + VTYPE_LIST, +}; + +/// +// Supported JavaScript dialog types. +/// +enum cef_jsdialog_type_t { + JSDIALOGTYPE_ALERT = 0, + JSDIALOGTYPE_CONFIRM, + JSDIALOGTYPE_PROMPT, +}; + +/// +// Supported menu IDs. Non-English translations can be provided for the +// IDS_MENU_* strings in CefResourceBundleHandler::GetLocalizedString(). +/// +enum cef_menu_id_t { + // Navigation. + MENU_ID_BACK = 100, + MENU_ID_FORWARD = 101, + MENU_ID_RELOAD = 102, + MENU_ID_RELOAD_NOCACHE = 103, + MENU_ID_STOPLOAD = 104, + + // Editing. + MENU_ID_UNDO = 110, + MENU_ID_REDO = 111, + MENU_ID_CUT = 112, + MENU_ID_COPY = 113, + MENU_ID_PASTE = 114, + MENU_ID_DELETE = 115, + MENU_ID_SELECT_ALL = 116, + + // Miscellaneous. + MENU_ID_FIND = 130, + MENU_ID_PRINT = 131, + MENU_ID_VIEW_SOURCE = 132, + + // All user-defined menu IDs should come between MENU_ID_USER_FIRST and + // MENU_ID_USER_LAST to avoid overlapping the Chromium and CEF ID ranges + // defined in the tools/gritsettings/resource_ids file. + MENU_ID_USER_FIRST = 26500, + MENU_ID_USER_LAST = 28500, +}; + +/// +// Mouse button types. +/// +enum cef_mouse_button_type_t { + MBT_LEFT = 0, + MBT_MIDDLE, + MBT_RIGHT, +}; + +/// +// Structure representing mouse event information. +/// +typedef struct _cef_mouse_event_t { + /// + // X coordinate relative to the left side of the view. + /// + int x; + + /// + // Y coordinate relative to the top side of the view. + /// + int y; + + /// + // Bit flags describing any pressed modifier keys. See + // cef_event_flags_t for values. + /// + uint32 modifiers; +} cef_mouse_event_t; + +/// +// Paint element types. +/// +enum cef_paint_element_type_t { + PET_VIEW = 0, + PET_POPUP, +}; + +/// +// Supported event bit flags. +/// +enum cef_event_flags_t { + EVENTFLAG_NONE = 0, + EVENTFLAG_CAPS_LOCK_ON = 1 << 0, + EVENTFLAG_SHIFT_DOWN = 1 << 1, + EVENTFLAG_CONTROL_DOWN = 1 << 2, + EVENTFLAG_ALT_DOWN = 1 << 3, + EVENTFLAG_LEFT_MOUSE_BUTTON = 1 << 4, + EVENTFLAG_MIDDLE_MOUSE_BUTTON = 1 << 5, + EVENTFLAG_RIGHT_MOUSE_BUTTON = 1 << 6, + // Mac OS-X command key. + EVENTFLAG_COMMAND_DOWN = 1 << 7, + EVENTFLAG_NUM_LOCK_ON = 1 << 8, + EVENTFLAG_IS_KEY_PAD = 1 << 9, + EVENTFLAG_IS_LEFT = 1 << 10, + EVENTFLAG_IS_RIGHT = 1 << 11, +}; + +/// +// Supported menu item types. +/// +enum cef_menu_item_type_t { + MENUITEMTYPE_NONE, + MENUITEMTYPE_COMMAND, + MENUITEMTYPE_CHECK, + MENUITEMTYPE_RADIO, + MENUITEMTYPE_SEPARATOR, + MENUITEMTYPE_SUBMENU, +}; + +/// +// Supported context menu type flags. +/// +enum cef_context_menu_type_flags_t { + /// + // No node is selected. + /// + CM_TYPEFLAG_NONE = 0, + /// + // The top page is selected. + /// + CM_TYPEFLAG_PAGE = 1 << 0, + /// + // A subframe page is selected. + /// + CM_TYPEFLAG_FRAME = 1 << 1, + /// + // A link is selected. + /// + CM_TYPEFLAG_LINK = 1 << 2, + /// + // A media node is selected. + /// + CM_TYPEFLAG_MEDIA = 1 << 3, + /// + // There is a textual or mixed selection that is selected. + /// + CM_TYPEFLAG_SELECTION = 1 << 4, + /// + // An editable element is selected. + /// + CM_TYPEFLAG_EDITABLE = 1 << 5, +}; + +/// +// Supported context menu media types. +/// +enum cef_context_menu_media_type_t { + /// + // No special node is in context. + /// + CM_MEDIATYPE_NONE, + /// + // An image node is selected. + /// + CM_MEDIATYPE_IMAGE, + /// + // A video node is selected. + /// + CM_MEDIATYPE_VIDEO, + /// + // An audio node is selected. + /// + CM_MEDIATYPE_AUDIO, + /// + // A file node is selected. + /// + CM_MEDIATYPE_FILE, + /// + // A plugin node is selected. + /// + CM_MEDIATYPE_PLUGIN, +}; + +/// +// Supported context menu media state bit flags. +/// +enum cef_context_menu_media_state_flags_t { + CM_MEDIAFLAG_NONE = 0, + CM_MEDIAFLAG_ERROR = 1 << 0, + CM_MEDIAFLAG_PAUSED = 1 << 1, + CM_MEDIAFLAG_MUTED = 1 << 2, + CM_MEDIAFLAG_LOOP = 1 << 3, + CM_MEDIAFLAG_CAN_SAVE = 1 << 4, + CM_MEDIAFLAG_HAS_AUDIO = 1 << 5, + CM_MEDIAFLAG_HAS_VIDEO = 1 << 6, + CM_MEDIAFLAG_CONTROL_ROOT_ELEMENT = 1 << 7, + CM_MEDIAFLAG_CAN_PRINT = 1 << 8, + CM_MEDIAFLAG_CAN_ROTATE = 1 << 9, +}; + +/// +// Supported context menu edit state bit flags. +/// +enum cef_context_menu_edit_state_flags_t { + CM_EDITFLAG_NONE = 0, + CM_EDITFLAG_CAN_UNDO = 1 << 0, + CM_EDITFLAG_CAN_REDO = 1 << 1, + CM_EDITFLAG_CAN_CUT = 1 << 2, + CM_EDITFLAG_CAN_COPY = 1 << 3, + CM_EDITFLAG_CAN_PASTE = 1 << 4, + CM_EDITFLAG_CAN_DELETE = 1 << 5, + CM_EDITFLAG_CAN_SELECT_ALL = 1 << 6, + CM_EDITFLAG_CAN_TRANSLATE = 1 << 7, +}; + +/// +// Key event types. +/// +enum cef_key_event_type_t { + KEYEVENT_RAWKEYDOWN = 0, + KEYEVENT_KEYDOWN, + KEYEVENT_KEYUP, + KEYEVENT_CHAR +}; + +/// +// Structure representing keyboard event information. +/// +typedef struct _cef_key_event_t { + /// + // The type of keyboard event. + /// + cef_key_event_type_t type; + + /// + // Bit flags describing any pressed modifier keys. See + // cef_event_flags_t for values. + /// + uint32 modifiers; + + /// + // The Windows key code for the key event. This value is used by the DOM + // specification. Sometimes it comes directly from the event (i.e. on + // Windows) and sometimes it's determined using a mapping function. See + // WebCore/platform/chromium/KeyboardCodes.h for the list of values. + /// + int windows_key_code; + + /// + // The actual key code genenerated by the platform. + /// + int native_key_code; + + /// + // Indicates whether the event is considered a "system key" event (see + // http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx for details). + // This value will always be false on non-Windows platforms. + /// + bool is_system_key; + + /// + // The character generated by the keystroke. + /// + char16 character; + + /// + // Same as |character| but unmodified by any concurrently-held modifiers + // (except shift). This is useful for working out shortcut keys. + /// + char16 unmodified_character; + + /// + // True if the focus is currently on an editable field on the page. This is + // useful for determining if standard key events should be intercepted. + /// + bool focus_on_editable_field; +} cef_key_event_t; + +/// +// Focus sources. +/// +enum cef_focus_source_t { + /// + // The source is explicit navigation via the API (LoadURL(), etc). + /// + FOCUS_SOURCE_NAVIGATION = 0, + /// + // The source is a system-generated focus event. + /// + FOCUS_SOURCE_SYSTEM, +}; + +/// +// Navigation types. +/// +enum cef_navigation_type_t { + NAVIGATION_LINK_CLICKED = 0, + NAVIGATION_FORM_SUBMITTED, + NAVIGATION_BACK_FORWARD, + NAVIGATION_RELOAD, + NAVIGATION_FORM_RESUBMITTED, + NAVIGATION_OTHER, +}; + +/// +// Supported XML encoding types. The parser supports ASCII, ISO-8859-1, and +// UTF16 (LE and BE) by default. All other types must be translated to UTF8 +// before being passed to the parser. If a BOM is detected and the correct +// decoder is available then that decoder will be used automatically. +/// +enum cef_xml_encoding_type_t { + XML_ENCODING_NONE = 0, + XML_ENCODING_UTF8, + XML_ENCODING_UTF16LE, + XML_ENCODING_UTF16BE, + XML_ENCODING_ASCII, +}; + +/// +// XML node types. +/// +enum cef_xml_node_type_t { + XML_NODE_UNSUPPORTED = 0, + XML_NODE_PROCESSING_INSTRUCTION, + XML_NODE_DOCUMENT_TYPE, + XML_NODE_ELEMENT_START, + XML_NODE_ELEMENT_END, + XML_NODE_ATTRIBUTE, + XML_NODE_TEXT, + XML_NODE_CDATA, + XML_NODE_ENTITY_REFERENCE, + XML_NODE_WHITESPACE, + XML_NODE_COMMENT, +}; + +/// +// Popup window features. +/// +typedef struct _cef_popup_features_t { + int x; + bool xSet; + int y; + bool ySet; + int width; + bool widthSet; + int height; + bool heightSet; + + bool menuBarVisible; + bool statusBarVisible; + bool toolBarVisible; + bool locationBarVisible; + bool scrollbarsVisible; + bool resizable; + + bool fullscreen; + bool dialog; + cef_string_list_t additionalFeatures; +} cef_popup_features_t; + +/// +// DOM document types. +/// +enum cef_dom_document_type_t { + DOM_DOCUMENT_TYPE_UNKNOWN = 0, + DOM_DOCUMENT_TYPE_HTML, + DOM_DOCUMENT_TYPE_XHTML, + DOM_DOCUMENT_TYPE_PLUGIN, +}; + +/// +// DOM event category flags. +/// +enum cef_dom_event_category_t { + DOM_EVENT_CATEGORY_UNKNOWN = 0x0, + DOM_EVENT_CATEGORY_UI = 0x1, + DOM_EVENT_CATEGORY_MOUSE = 0x2, + DOM_EVENT_CATEGORY_MUTATION = 0x4, + DOM_EVENT_CATEGORY_KEYBOARD = 0x8, + DOM_EVENT_CATEGORY_TEXT = 0x10, + DOM_EVENT_CATEGORY_COMPOSITION = 0x20, + DOM_EVENT_CATEGORY_DRAG = 0x40, + DOM_EVENT_CATEGORY_CLIPBOARD = 0x80, + DOM_EVENT_CATEGORY_MESSAGE = 0x100, + DOM_EVENT_CATEGORY_WHEEL = 0x200, + DOM_EVENT_CATEGORY_BEFORE_TEXT_INSERTED = 0x400, + DOM_EVENT_CATEGORY_OVERFLOW = 0x800, + DOM_EVENT_CATEGORY_PAGE_TRANSITION = 0x1000, + DOM_EVENT_CATEGORY_POPSTATE = 0x2000, + DOM_EVENT_CATEGORY_PROGRESS = 0x4000, + DOM_EVENT_CATEGORY_XMLHTTPREQUEST_PROGRESS = 0x8000, + DOM_EVENT_CATEGORY_WEBKIT_ANIMATION = 0x10000, + DOM_EVENT_CATEGORY_WEBKIT_TRANSITION = 0x20000, + DOM_EVENT_CATEGORY_BEFORE_LOAD = 0x40000, +}; + +/// +// DOM event processing phases. +/// +enum cef_dom_event_phase_t { + DOM_EVENT_PHASE_UNKNOWN = 0, + DOM_EVENT_PHASE_CAPTURING, + DOM_EVENT_PHASE_AT_TARGET, + DOM_EVENT_PHASE_BUBBLING, +}; + +/// +// DOM node types. +/// +enum cef_dom_node_type_t { + DOM_NODE_TYPE_UNSUPPORTED = 0, + DOM_NODE_TYPE_ELEMENT, + DOM_NODE_TYPE_ATTRIBUTE, + DOM_NODE_TYPE_TEXT, + DOM_NODE_TYPE_CDATA_SECTION, + DOM_NODE_TYPE_ENTITY_REFERENCE, + DOM_NODE_TYPE_ENTITY, + DOM_NODE_TYPE_PROCESSING_INSTRUCTIONS, + DOM_NODE_TYPE_COMMENT, + DOM_NODE_TYPE_DOCUMENT, + DOM_NODE_TYPE_DOCUMENT_TYPE, + DOM_NODE_TYPE_DOCUMENT_FRAGMENT, + DOM_NODE_TYPE_NOTATION, + DOM_NODE_TYPE_XPATH_NAMESPACE, +}; + +/// +// Supported file dialog modes. +/// +enum cef_file_dialog_mode_t { + /// + // Requires that the file exists before allowing the user to pick it. + /// + FILE_DIALOG_OPEN = 0, + + /// + // Like Open, but allows picking multiple files to open. + /// + FILE_DIALOG_OPEN_MULTIPLE, + + /// + // Allows picking a nonexistent file, and prompts to overwrite if the file + // already exists. + /// + FILE_DIALOG_SAVE, +}; + +/// +// Geoposition error codes. +/// +enum cef_geoposition_error_code_t { + GEOPOSITON_ERROR_NONE = 0, + GEOPOSITON_ERROR_PERMISSION_DENIED, + GEOPOSITON_ERROR_POSITION_UNAVAILABLE, + GEOPOSITON_ERROR_TIMEOUT, +}; + +/// +// Structure representing geoposition information. The properties of this +// structure correspond to those of the JavaScript Position object although +// their types may differ. +/// +typedef struct _cef_geoposition_t { + /// + // Latitude in decimal degrees north (WGS84 coordinate frame). + /// + double latitude; + + /// + // Longitude in decimal degrees west (WGS84 coordinate frame). + /// + double longitude; + + /// + // Altitude in meters (above WGS84 datum). + /// + double altitude; + + /// + // Accuracy of horizontal position in meters. + /// + double accuracy; + + /// + // Accuracy of altitude in meters. + /// + double altitude_accuracy; + + /// + // Heading in decimal degrees clockwise from true north. + /// + double heading; + + /// + // Horizontal component of device velocity in meters per second. + /// + double speed; + + /// + // Time of position measurement in miliseconds since Epoch in UTC time. This + // is taken from the host computer's system clock. + /// + cef_time_t timestamp; + + /// + // Error code, see enum above. + /// + cef_geoposition_error_code_t error_code; + + /// + // Human-readable error message. + /// + cef_string_t error_message; +} cef_geoposition_t; + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_H_ diff --git a/cef3/include/internal/cef_types_linux.h b/cef3/include/internal/cef_types_linux.h new file mode 100644 index 000000000..ebb57becd --- /dev/null +++ b/cef3/include/internal/cef_types_linux.h @@ -0,0 +1,75 @@ +// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_LINUX_H_ +#define CEF_INCLUDE_INTERNAL_CEF_TYPES_LINUX_H_ +#pragma once + +#include "include/internal/cef_build.h" + +#if defined(OS_LINUX) +#include +#include "include/internal/cef_string.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Handle types. +#define cef_cursor_handle_t void* +#define cef_event_handle_t GdkEvent* +#define cef_window_handle_t GtkWidget* + +/// +// Structure representing CefExecuteProcess arguments. +/// +typedef struct _cef_main_args_t { + int argc; + char** argv; +} cef_main_args_t; + +/// +// Class representing window information. +/// +typedef struct _cef_window_info_t { + // Pointer for the parent GtkBox widget. + cef_window_handle_t parent_widget; + + // Pointer for the new browser widget. + cef_window_handle_t widget; +} cef_window_info_t; + +#ifdef __cplusplus +} +#endif + +#endif // OS_LINUX + +#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_LINUX_H_ diff --git a/cef3/include/internal/cef_types_mac.h b/cef3/include/internal/cef_types_mac.h new file mode 100644 index 000000000..44863bd4b --- /dev/null +++ b/cef3/include/internal/cef_types_mac.h @@ -0,0 +1,96 @@ +// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_MAC_H_ +#define CEF_INCLUDE_INTERNAL_CEF_TYPES_MAC_H_ +#pragma once + +#include "include/internal/cef_build.h" + +#if defined(OS_MACOSX) +#include "include/internal/cef_string.h" + +// Handle types. +#ifdef __cplusplus +#ifdef __OBJC__ +@class NSCursor; +@class NSEvent; +@class NSView; +#else +class NSCursor; +class NSEvent; +struct NSView; +#endif +#define cef_cursor_handle_t NSCursor* +#define cef_event_handle_t NSEvent* +#define cef_window_handle_t NSView* +#else +#define cef_cursor_handle_t void* +#define cef_event_handle_t void* +#define cef_window_handle_t void* +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// Structure representing CefExecuteProcess arguments. +/// +typedef struct _cef_main_args_t { + int argc; + char** argv; +} cef_main_args_t; + +/// +// Class representing window information. +/// +typedef struct _cef_window_info_t { + cef_string_t window_name; + int x; + int y; + int width; + int height; + int hidden; + + // NSView pointer for the parent view. + cef_window_handle_t parent_view; + + // NSView pointer for the new browser view. + cef_window_handle_t view; +} cef_window_info_t; + +#ifdef __cplusplus +} +#endif + +#endif // OS_MACOSX + +#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_MAC_H_ diff --git a/cef3/include/internal/cef_types_win.h b/cef3/include/internal/cef_types_win.h new file mode 100644 index 000000000..fbaaaaf59 --- /dev/null +++ b/cef3/include/internal/cef_types_win.h @@ -0,0 +1,94 @@ +// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_WIN_H_ +#define CEF_INCLUDE_INTERNAL_CEF_TYPES_WIN_H_ +#pragma once + +#include "include/internal/cef_build.h" + +#if defined(OS_WIN) +#include +#include "include/internal/cef_string.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Handle types. +#define cef_cursor_handle_t HCURSOR +#define cef_event_handle_t MSG* +#define cef_window_handle_t HWND + +/// +// Structure representing CefExecuteProcess arguments. +/// +typedef struct _cef_main_args_t { + HINSTANCE instance; +} cef_main_args_t; + +/// +// Structure representing window information. +/// +typedef struct _cef_window_info_t { + // Standard parameters required by CreateWindowEx() + DWORD ex_style; + cef_string_t window_name; + DWORD style; + int x; + int y; + int width; + int height; + cef_window_handle_t parent_window; + HMENU menu; + + // If window rendering is disabled no browser window will be created. Set + // |parent_window| to be used for identifying monitor info + // (MonitorFromWindow). If |parent_window| is not provided the main screen + // monitor will be used. + BOOL window_rendering_disabled; + + // Set to true to enable transparent painting. + // If window rendering is disabled and |transparent_painting| is set to true + // WebKit rendering will draw on a transparent background (RGBA=0x00000000). + // When this value is false the background will be white and opaque. + BOOL transparent_painting; + + // Handle for the new browser window. + cef_window_handle_t window; +} cef_window_info_t; + +#ifdef __cplusplus +} +#endif + +#endif // OS_WIN + +#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WIN_H_ diff --git a/cef3/include/internal/cef_types_wrappers.h b/cef3/include/internal/cef_types_wrappers.h new file mode 100644 index 000000000..410979c67 --- /dev/null +++ b/cef3/include/internal/cef_types_wrappers.h @@ -0,0 +1,577 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_ +#define CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_ +#pragma once + +#include "include/internal/cef_string.h" +#include "include/internal/cef_string_list.h" +#include "include/internal/cef_types.h" + +/// +// Template class that provides common functionality for CEF structure wrapping. +/// +template +class CefStructBase : public traits::struct_type { + public: + typedef typename traits::struct_type struct_type; + + CefStructBase() : attached_to_(NULL) { + Init(); + } + virtual ~CefStructBase() { + // Only clear this object's data if it isn't currently attached to a + // structure. + if (!attached_to_) + Clear(this); + } + + CefStructBase(const CefStructBase& r) { + Init(); + *this = r; + } + CefStructBase(const struct_type& r) { // NOLINT(runtime/explicit) + Init(); + *this = r; + } + + /// + // Clear this object's values. + /// + void Reset() { + Clear(this); + Init(); + } + + /// + // Attach to the source structure's existing values. DetachTo() can be called + // to insert the values back into the existing structure. + /// + void AttachTo(struct_type& source) { + // Only clear this object's data if it isn't currently attached to a + // structure. + if (!attached_to_) + Clear(this); + + // This object is now attached to the new structure. + attached_to_ = &source; + + // Transfer ownership of the values from the source structure. + memcpy(static_cast(this), &source, sizeof(struct_type)); + } + + /// + // Relinquish ownership of values to the target structure. + /// + void DetachTo(struct_type& target) { + if (attached_to_ != &target) { + // Clear the target structure's values only if we are not currently + // attached to that structure. + Clear(&target); + } + + // Transfer ownership of the values to the target structure. + memcpy(&target, static_cast(this), sizeof(struct_type)); + + // Remove the references from this object. + Init(); + } + + /// + // Set this object's values. If |copy| is true the source structure's values + // will be copied instead of referenced. + /// + void Set(const struct_type& source, bool copy) { + traits::set(&source, this, copy); + } + + CefStructBase& operator=(const CefStructBase& s) { + return operator=(static_cast(s)); + } + + CefStructBase& operator=(const struct_type& s) { + Set(s, true); + return *this; + } + + protected: + void Init() { + memset(static_cast(this), 0, sizeof(struct_type)); + attached_to_ = NULL; + traits::init(this); + } + + static void Clear(struct_type* s) { traits::clear(s); } + + struct_type* attached_to_; +}; + + +struct CefRectTraits { + typedef cef_rect_t struct_type; + + static inline void init(struct_type* s) {} + static inline void clear(struct_type* s) {} + + static inline void set(const struct_type* src, struct_type* target, + bool copy) { + *target = *src; + } +}; + +/// +// Class representing a rectangle. +/// +class CefRect : public CefStructBase { + public: + typedef CefStructBase parent; + + CefRect() : parent() {} + CefRect(const cef_rect_t& r) : parent(r) {} // NOLINT(runtime/explicit) + CefRect(const CefRect& r) : parent(r) {} // NOLINT(runtime/explicit) + CefRect(int x, int y, int width, int height) : parent() { + Set(x, y, width, height); + } + + bool IsEmpty() const { return width <= 0 || height <= 0; } + void Set(int x, int y, int width, int height) { + this->x = x, this->y = y, this->width = width, this->height = height; + } +}; + +inline bool operator==(const CefRect& a, const CefRect& b) { + return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height; +} + +inline bool operator!=(const CefRect& a, const CefRect& b) { + return !(a == b); +} + +struct CefKeyEventTraits { + typedef cef_key_event_t struct_type; + + static inline void init(struct_type* s) {} + + static inline void clear(struct_type* s) {} + + static inline void set(const struct_type* src, struct_type* target, + bool copy) { + target->type = src->type; + target->modifiers = src->modifiers; + target->windows_key_code = src->windows_key_code; + target->native_key_code = src->native_key_code; + target->is_system_key = src->is_system_key; + target->character = src->character; + target->unmodified_character = src->unmodified_character; + target->focus_on_editable_field = src->focus_on_editable_field; + } +}; + +/// +// Class representing a a keyboard event. +/// +typedef CefStructBase CefKeyEvent; + +struct CefMouseEventTraits { + typedef cef_mouse_event_t struct_type; + + static inline void init(struct_type* s) {} + + static inline void clear(struct_type* s) {} + + static inline void set(const struct_type* src, struct_type* target, + bool copy) { + target->x = src->x; + target->y = src->y; + target->modifiers = src->modifiers; + } +}; + +/// +// Class representing a mouse event. +/// +typedef CefStructBase CefMouseEvent; + +struct CefPopupFeaturesTraits { + typedef cef_popup_features_t struct_type; + + static inline void init(struct_type* s) { + s->menuBarVisible = true; + s->statusBarVisible = true; + s->toolBarVisible = true; + s->locationBarVisible = true; + s->scrollbarsVisible = true; + s->resizable = true; + } + + static inline void clear(struct_type* s) { + if (s->additionalFeatures) + cef_string_list_free(s->additionalFeatures); + } + + static inline void set(const struct_type* src, struct_type* target, + bool copy) { + if (target->additionalFeatures) + cef_string_list_free(target->additionalFeatures); + target->additionalFeatures = src->additionalFeatures ? + cef_string_list_copy(src->additionalFeatures) : NULL; + + target->x = src->x; + target->xSet = src->xSet; + target->y = src->y; + target->ySet = src->ySet; + target->width = src->width; + target->widthSet = src->widthSet; + target->height = src->height; + target->heightSet = src->heightSet; + target->menuBarVisible = src->menuBarVisible; + target->statusBarVisible = src->statusBarVisible; + target->toolBarVisible = src->toolBarVisible; + target->locationBarVisible = src->locationBarVisible; + target->scrollbarsVisible = src->scrollbarsVisible; + target->resizable = src->resizable; + target->fullscreen = src->fullscreen; + target->dialog = src->dialog; + } +}; + +/// +// Class representing popup window features. +/// +typedef CefStructBase CefPopupFeatures; + + +struct CefSettingsTraits { + typedef cef_settings_t struct_type; + + static inline void init(struct_type* s) { + s->size = sizeof(struct_type); + } + + static inline void clear(struct_type* s) { + cef_string_clear(&s->browser_subprocess_path); + cef_string_clear(&s->cache_path); + cef_string_clear(&s->user_agent); + cef_string_clear(&s->product_version); + cef_string_clear(&s->locale); + cef_string_clear(&s->log_file); + cef_string_clear(&s->javascript_flags); + cef_string_clear(&s->resources_dir_path); + cef_string_clear(&s->locales_dir_path); + } + + static inline void set(const struct_type* src, struct_type* target, + bool copy) { + target->single_process = src->single_process; + cef_string_set(src->browser_subprocess_path.str, + src->browser_subprocess_path.length, + &target->browser_subprocess_path, copy); + target->multi_threaded_message_loop = src->multi_threaded_message_loop; + target->command_line_args_disabled = src->command_line_args_disabled; + + cef_string_set(src->cache_path.str, src->cache_path.length, + &target->cache_path, copy); + target->persist_session_cookies = src->persist_session_cookies; + + cef_string_set(src->user_agent.str, src->user_agent.length, + &target->user_agent, copy); + cef_string_set(src->product_version.str, src->product_version.length, + &target->product_version, copy); + cef_string_set(src->locale.str, src->locale.length, &target->locale, copy); + + cef_string_set(src->log_file.str, src->log_file.length, &target->log_file, + copy); + target->log_severity = src->log_severity; + target->release_dcheck_enabled = src->release_dcheck_enabled; + cef_string_set(src->javascript_flags.str, src->javascript_flags.length, + &target->javascript_flags, copy); + + cef_string_set(src->resources_dir_path.str, src->resources_dir_path.length, + &target->resources_dir_path, copy); + cef_string_set(src->locales_dir_path.str, src->locales_dir_path.length, + &target->locales_dir_path, copy); + target->pack_loading_disabled = src->pack_loading_disabled; + target->remote_debugging_port = src->remote_debugging_port; + target->uncaught_exception_stack_size = src->uncaught_exception_stack_size; + target->context_safety_implementation = src->context_safety_implementation; + target->ignore_certificate_errors = src->ignore_certificate_errors; + } +}; + +/// +// Class representing initialization settings. +/// +typedef CefStructBase CefSettings; + + +struct CefBrowserSettingsTraits { + typedef cef_browser_settings_t struct_type; + + static inline void init(struct_type* s) { + s->size = sizeof(struct_type); + } + + static inline void clear(struct_type* s) { + cef_string_clear(&s->standard_font_family); + cef_string_clear(&s->fixed_font_family); + cef_string_clear(&s->serif_font_family); + cef_string_clear(&s->sans_serif_font_family); + cef_string_clear(&s->cursive_font_family); + cef_string_clear(&s->fantasy_font_family); + cef_string_clear(&s->default_encoding); + cef_string_clear(&s->user_style_sheet_location); + } + + static inline void set(const struct_type* src, struct_type* target, + bool copy) { + cef_string_set(src->standard_font_family.str, + src->standard_font_family.length, &target->standard_font_family, copy); + cef_string_set(src->fixed_font_family.str, src->fixed_font_family.length, + &target->fixed_font_family, copy); + cef_string_set(src->serif_font_family.str, src->serif_font_family.length, + &target->serif_font_family, copy); + cef_string_set(src->sans_serif_font_family.str, + src->sans_serif_font_family.length, &target->sans_serif_font_family, + copy); + cef_string_set(src->cursive_font_family.str, + src->cursive_font_family.length, &target->cursive_font_family, copy); + cef_string_set(src->fantasy_font_family.str, + src->fantasy_font_family.length, &target->fantasy_font_family, copy); + + target->default_font_size = src->default_font_size; + target->default_fixed_font_size = src->default_fixed_font_size; + target->minimum_font_size = src->minimum_font_size; + target->minimum_logical_font_size = src->minimum_logical_font_size; + + cef_string_set(src->default_encoding.str, src->default_encoding.length, + &target->default_encoding, copy); + + cef_string_set(src->user_style_sheet_location.str, + src->user_style_sheet_location.length, + &target->user_style_sheet_location, copy); + + target->remote_fonts = src->remote_fonts; + target->javascript = src->javascript; + target->javascript_open_windows = src->javascript_open_windows; + target->javascript_close_windows = src->javascript_close_windows; + target->javascript_access_clipboard = src->javascript_access_clipboard; + target->javascript_dom_paste = src->javascript_dom_paste; + target->caret_browsing = src->caret_browsing; + target->java = src->java; + target->plugins = src->plugins; + target->universal_access_from_file_urls = + src->universal_access_from_file_urls; + target->file_access_from_file_urls = src->file_access_from_file_urls; + target->web_security = src->web_security; + target->image_loading = src->image_loading; + target->image_shrink_standalone_to_fit = + src->image_shrink_standalone_to_fit; + target->text_area_resize = src->text_area_resize; + target->page_cache = src->page_cache; + target->tab_to_links = src->tab_to_links; + target->author_and_user_styles = src->author_and_user_styles; + target->local_storage = src->local_storage; + target->databases= src->databases; + target->application_cache = src->application_cache; + target->webgl = src->webgl; + target->accelerated_compositing = src->accelerated_compositing; + target->developer_tools = src->developer_tools; + } +}; + +/// +// Class representing browser initialization settings. +/// +typedef CefStructBase CefBrowserSettings; + + +struct CefURLPartsTraits { + typedef cef_urlparts_t struct_type; + + static inline void init(struct_type* s) {} + + static inline void clear(struct_type* s) { + cef_string_clear(&s->spec); + cef_string_clear(&s->scheme); + cef_string_clear(&s->username); + cef_string_clear(&s->password); + cef_string_clear(&s->host); + cef_string_clear(&s->port); + cef_string_clear(&s->path); + cef_string_clear(&s->query); + } + + static inline void set(const struct_type* src, struct_type* target, + bool copy) { + cef_string_set(src->spec.str, src->spec.length, &target->spec, copy); + cef_string_set(src->scheme.str, src->scheme.length, &target->scheme, copy); + cef_string_set(src->username.str, src->username.length, &target->username, + copy); + cef_string_set(src->password.str, src->password.length, &target->password, + copy); + cef_string_set(src->host.str, src->host.length, &target->host, copy); + cef_string_set(src->port.str, src->port.length, &target->port, copy); + cef_string_set(src->path.str, src->path.length, &target->path, copy); + cef_string_set(src->query.str, src->query.length, &target->query, copy); + } +}; + +/// +// Class representing a URL's component parts. +/// +typedef CefStructBase CefURLParts; + + +struct CefTimeTraits { + typedef cef_time_t struct_type; + + static inline void init(struct_type* s) {} + + static inline void clear(struct_type* s) {} + + static inline void set(const struct_type* src, struct_type* target, + bool copy) { + *target = *src; + } +}; + +/// +// Class representing a time. +/// +class CefTime : public CefStructBase { + public: + typedef CefStructBase parent; + + CefTime() : parent() {} + CefTime(const cef_time_t& r) : parent(r) {} // NOLINT(runtime/explicit) + CefTime(const CefTime& r) : parent(r) {} // NOLINT(runtime/explicit) + explicit CefTime(time_t r) : parent() { SetTimeT(r); } + explicit CefTime(double r) : parent() { SetDoubleT(r); } + + // Converts to/from time_t. + void SetTimeT(time_t r) { + cef_time_from_timet(r, this); + } + time_t GetTimeT() const { + time_t time = 0; + cef_time_to_timet(this, &time); + return time; + } + + // Converts to/from a double which is the number of seconds since epoch + // (Jan 1, 1970). Webkit uses this format to represent time. A value of 0 + // means "not initialized". + void SetDoubleT(double r) { + cef_time_from_doublet(r, this); + } + double GetDoubleT() const { + double time = 0; + cef_time_to_doublet(this, &time); + return time; + } + + // Set this object to now. + void Now() { + cef_time_now(this); + } + + // Return the delta between this object and |other| in milliseconds. + long long Delta(const CefTime& other) { + long long delta = 0; + cef_time_delta(this, &other, &delta); + return delta; + } +}; + + +struct CefCookieTraits { + typedef cef_cookie_t struct_type; + + static inline void init(struct_type* s) {} + + static inline void clear(struct_type* s) { + cef_string_clear(&s->name); + cef_string_clear(&s->value); + cef_string_clear(&s->domain); + cef_string_clear(&s->path); + } + + static inline void set(const struct_type* src, struct_type* target, + bool copy) { + cef_string_set(src->name.str, src->name.length, &target->name, copy); + cef_string_set(src->value.str, src->value.length, &target->value, copy); + cef_string_set(src->domain.str, src->domain.length, &target->domain, copy); + cef_string_set(src->path.str, src->path.length, &target->path, copy); + target->secure = src->secure; + target->httponly = src->httponly; + target->creation = src->creation; + target->last_access = src->last_access; + target->has_expires = src->has_expires; + target->expires = src->expires; + } +}; + +/// +// Class representing a cookie. +/// +typedef CefStructBase CefCookie; + + +struct CefGeopositionTraits { + typedef cef_geoposition_t struct_type; + + static inline void init(struct_type* s) {} + + static inline void clear(struct_type* s) { + cef_string_clear(&s->error_message); + } + + static inline void set(const struct_type* src, struct_type* target, + bool copy) { + target->latitude = src->latitude; + target->longitude = src->longitude; + target->altitude = src->altitude; + target->accuracy = src->accuracy; + target->altitude_accuracy = src->altitude_accuracy; + target->heading = src->heading; + target->speed = src->speed; + target->timestamp = src->timestamp; + target->error_code = src->error_code; + cef_string_set(src->error_message.str, src->error_message.length, + &target->error_message, copy); + } +}; + +/// +// Class representing a geoposition. +/// +typedef CefStructBase CefGeoposition; + +#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_ diff --git a/cef3/include/internal/cef_win.h b/cef3/include/internal/cef_win.h new file mode 100644 index 000000000..d9caad443 --- /dev/null +++ b/cef3/include/internal/cef_win.h @@ -0,0 +1,172 @@ +// Copyright (c) 2008 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +#ifndef CEF_INCLUDE_INTERNAL_CEF_WIN_H_ +#define CEF_INCLUDE_INTERNAL_CEF_WIN_H_ +#pragma once + +#if defined(OS_WIN) +#include +#include "include/internal/cef_types_win.h" +#include "include/internal/cef_types_wrappers.h" + +/// +// Atomic increment and decrement. +/// +#define CefAtomicIncrement(p) InterlockedIncrement(p) +#define CefAtomicDecrement(p) InterlockedDecrement(p) + +/// +// Critical section wrapper. +/// +class CefCriticalSection { + public: + CefCriticalSection() { + memset(&m_sec, 0, sizeof(CRITICAL_SECTION)); + InitializeCriticalSection(&m_sec); + } + virtual ~CefCriticalSection() { + DeleteCriticalSection(&m_sec); + } + void Lock() { + EnterCriticalSection(&m_sec); + } + void Unlock() { + LeaveCriticalSection(&m_sec); + } + + CRITICAL_SECTION m_sec; +}; + +/// +// Handle types. +/// +#define CefCursorHandle cef_cursor_handle_t +#define CefEventHandle cef_event_handle_t +#define CefWindowHandle cef_window_handle_t + +struct CefMainArgsTraits { + typedef cef_main_args_t struct_type; + + static inline void init(struct_type* s) {} + static inline void clear(struct_type* s) {} + + static inline void set(const struct_type* src, struct_type* target, + bool copy) { + target->instance = src->instance; + } +}; + +// Class representing CefExecuteProcess arguments. +class CefMainArgs : public CefStructBase { + public: + typedef CefStructBase parent; + + CefMainArgs() : parent() {} + explicit CefMainArgs(const cef_main_args_t& r) : parent(r) {} + explicit CefMainArgs(const CefMainArgs& r) : parent(r) {} + explicit CefMainArgs(HINSTANCE hInstance) : parent() { + instance = hInstance; + } +}; + +struct CefWindowInfoTraits { + typedef cef_window_info_t struct_type; + + static inline void init(struct_type* s) {} + + static inline void clear(struct_type* s) { + cef_string_clear(&s->window_name); + } + + static inline void set(const struct_type* src, struct_type* target, + bool copy) { + target->ex_style = src->ex_style; + cef_string_set(src->window_name.str, src->window_name.length, + &target->window_name, copy); + target->style = src->style; + target->x = src->x; + target->y = src->y; + target->width = src->width; + target->height = src->height; + target->parent_window = src->parent_window; + target->menu = src->menu; + target->window = src->window; + target->transparent_painting = src->transparent_painting; + target->window_rendering_disabled = src->window_rendering_disabled; + } +}; + +/// +// Class representing window information. +/// +class CefWindowInfo : public CefStructBase { + public: + typedef CefStructBase parent; + + CefWindowInfo() : parent() {} + explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {} + explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {} + + void SetAsChild(HWND hWndParent, RECT windowRect) { + style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_TABSTOP | + WS_VISIBLE; + parent_window = hWndParent; + x = windowRect.left; + y = windowRect.top; + width = windowRect.right - windowRect.left; + height = windowRect.bottom - windowRect.top; + } + + void SetAsPopup(HWND hWndParent, const CefString& windowName) { + style = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | + WS_VISIBLE; + parent_window = hWndParent; + x = CW_USEDEFAULT; + y = CW_USEDEFAULT; + width = CW_USEDEFAULT; + height = CW_USEDEFAULT; + + cef_string_copy(windowName.c_str(), windowName.length(), &window_name); + } + + void SetTransparentPainting(BOOL transparentPainting) { + transparent_painting = transparentPainting; + } + + void SetAsOffScreen(HWND hWndParent) { + window_rendering_disabled = TRUE; + parent_window = hWndParent; + } +}; + +#endif // OS_WIN + +#endif // CEF_INCLUDE_INTERNAL_CEF_WIN_H_ diff --git a/cef3/include/wrapper/cef_byte_read_handler.h b/cef3/include/wrapper/cef_byte_read_handler.h new file mode 100644 index 000000000..1752588de --- /dev/null +++ b/cef3/include/wrapper/cef_byte_read_handler.h @@ -0,0 +1,74 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file are only available to applications that link +// against the libcef_dll_wrapper target. +// + +#ifndef CEF_INCLUDE_WRAPPER_CEF_BYTE_READ_HANDLER_H_ +#define CEF_INCLUDE_WRAPPER_CEF_BYTE_READ_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_stream.h" + +/// +// Thread safe implementation of the CefReadHandler class for reading an +// in-memory array of bytes. +/// +class CefByteReadHandler : public CefReadHandler { + public: + /// + // Create a new object for reading an array of bytes. An optional |source| + // reference can be kept to keep the underlying data source from being + // released while the reader exists. + /// + CefByteReadHandler(const unsigned char* bytes, + size_t size, + CefRefPtr source); + + // CefReadHandler methods. + virtual size_t Read(void* ptr, size_t size, size_t n) OVERRIDE; + virtual int Seek(int64 offset, int whence) OVERRIDE; + virtual int64 Tell() OVERRIDE; + virtual int Eof() OVERRIDE; + + private: + const unsigned char* bytes_; + int64 size_; + int64 offset_; + CefRefPtr source_; + + IMPLEMENT_REFCOUNTING(CefByteReadHandler); + IMPLEMENT_LOCKING(CefByteReadHandler); +}; + +#endif // CEF_INCLUDE_WRAPPER_CEF_BYTE_READ_HANDLER_H_ diff --git a/cef3/include/wrapper/cef_stream_resource_handler.h b/cef3/include/wrapper/cef_stream_resource_handler.h new file mode 100644 index 000000000..181bbbfe8 --- /dev/null +++ b/cef3/include/wrapper/cef_stream_resource_handler.h @@ -0,0 +1,85 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file are only available to applications that link +// against the libcef_dll_wrapper target. +// + +#ifndef CEF_INCLUDE_WRAPPER_CEF_STREAM_RESOURCE_HANDLER_H_ +#define CEF_INCLUDE_WRAPPER_CEF_STREAM_RESOURCE_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_resource_handler.h" +#include "include/cef_response.h" + +class CefStreamReader; + +/// +// Implementation of the CefResourceHandler class for reading from a CefStream. +/// +class CefStreamResourceHandler : public CefResourceHandler { + public: + /// + // Create a new object with default response values. + /// + CefStreamResourceHandler(const CefString& mime_type, + CefRefPtr stream); + /// + // Create a new object with explicit response values. + /// + CefStreamResourceHandler(int status_code, + const CefString& mime_type, + CefResponse::HeaderMap header_map, + CefRefPtr stream); + + // CefStreamResourceHandler methods. + virtual bool ProcessRequest(CefRefPtr request, + CefRefPtr callback) OVERRIDE; + virtual void GetResponseHeaders(CefRefPtr response, + int64& response_length, + CefString& redirectUrl) OVERRIDE; + virtual bool ReadResponse(void* data_out, + int bytes_to_read, + int& bytes_read, + CefRefPtr callback) OVERRIDE; + virtual void Cancel() OVERRIDE; + + private: + int status_code_; + CefString mime_type_; + CefResponse::HeaderMap header_map_; + CefRefPtr stream_; + + IMPLEMENT_REFCOUNTING(CefStreamResourceHandler); +}; + +#endif // CEF_INCLUDE_WRAPPER_CEF_STREAM_RESOURCE_HANDLER_H_ diff --git a/cef3/include/wrapper/cef_xml_object.h b/cef3/include/wrapper/cef_xml_object.h new file mode 100644 index 000000000..d9f706fde --- /dev/null +++ b/cef3/include/wrapper/cef_xml_object.h @@ -0,0 +1,188 @@ +// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file are only available to applications that link +// against the libcef_dll_wrapper target. +// + +#ifndef CEF_INCLUDE_WRAPPER_CEF_XML_OBJECT_H_ +#define CEF_INCLUDE_WRAPPER_CEF_XML_OBJECT_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_xml_reader.h" +#include +#include + +class CefStreamReader; + +/// +// Thread safe class for representing XML data as a structured object. This +// class should not be used with large XML documents because all data will be +// resident in memory at the same time. This implementation supports a +// restricted set of XML features: +//
+// (1) Processing instructions, whitespace and comments are ignored.
+// (2) Elements and attributes must always be referenced using the fully
+//     qualified name (ie, namespace:localname).
+// (3) Empty elements () and elements with zero-length values ()
+//     are considered the same.
+// (4) Element nodes are considered part of a value if:
+//     (a) The element node follows a non-element node at the same depth
+//         (see 5), or
+//     (b) The element node does not have a namespace and the parent node does.
+// (5) Mixed node types at the same depth are combined into a single element
+//     value as follows:
+//     (a) All node values are concatenated to form a single string value.
+//     (b) Entity reference nodes are resolved to the corresponding entity
+//         value.
+//     (c) Element nodes are represented by their outer XML string.
+// 
+/// +class CefXmlObject : public CefBase { + public: + typedef std::vector > ObjectVector; + typedef std::map AttributeMap; + + /// + // Create a new object with the specified name. An object name must always be + // at least one character long. + /// + explicit CefXmlObject(const CefString& name); + virtual ~CefXmlObject(); + + /// + // Load the contents of the specified XML stream into this object. The + // existing children and attributes, if any, will first be cleared. + /// + bool Load(CefRefPtr stream, + CefXmlReader::EncodingType encodingType, + const CefString& URI, CefString* loadError); + + /// + // Set the name, children and attributes of this object to a duplicate of the + // specified object's contents. The existing children and attributes, if any, + // will first be cleared. + /// + void Set(CefRefPtr object); + + /// + // Append a duplicate of the children and attributes of the specified object + // to this object. If |overwriteAttributes| is true then any attributes in + // this object that also exist in the specified object will be overwritten + // with the new values. The name of this object is not changed. + /// + void Append(CefRefPtr object, bool overwriteAttributes); + + /// + // Return a new object with the same name, children and attributes as this + // object. The parent of the new object will be NULL. + /// + CefRefPtr Duplicate(); + + /// + // Clears this object's children and attributes. The name and parenting of + // this object are not changed. + /// + void Clear(); + + /// + // Access the object's name. An object name must always be at least one + // character long. + /// + CefString GetName(); + bool SetName(const CefString& name); + + /// + // Access the object's parent. The parent can be NULL if this object has not + // been added as the child on another object. + /// + bool HasParent(); + CefRefPtr GetParent(); + + /// + // Access the object's value. An object cannot have a value if it also has + // children. Attempting to set the value while children exist will fail. + /// + bool HasValue(); + CefString GetValue(); + bool SetValue(const CefString& value); + + /// + // Access the object's attributes. Attributes must have unique names. + /// + bool HasAttributes(); + size_t GetAttributeCount(); + bool HasAttribute(const CefString& name); + CefString GetAttributeValue(const CefString& name); + bool SetAttributeValue(const CefString& name, const CefString& value); + size_t GetAttributes(AttributeMap& attributes); + void ClearAttributes(); + + /// + // Access the object's children. Each object can only have one parent so + // attempting to add an object that already has a parent will fail. Removing a + // child will set the child's parent to NULL. Adding a child will set the + // child's parent to this object. This object's value, if any, will be cleared + // if a child is added. + /// + bool HasChildren(); + size_t GetChildCount(); + bool HasChild(CefRefPtr child); + bool AddChild(CefRefPtr child); + bool RemoveChild(CefRefPtr child); + size_t GetChildren(ObjectVector& children); + void ClearChildren(); + + /// + // Find the first child with the specified name. + /// + CefRefPtr FindChild(const CefString& name); + + /// + // Find all children with the specified name. + /// + size_t FindChildren(const CefString& name, ObjectVector& children); + + private: + void SetParent(CefXmlObject* parent); + + CefString name_; + CefXmlObject* parent_; + CefString value_; + AttributeMap attributes_; + ObjectVector children_; + + IMPLEMENT_REFCOUNTING(CefXmlObject); + IMPLEMENT_LOCKING(CefXmlObject); +}; + +#endif // CEF_INCLUDE_WRAPPER_CEF_XML_OBJECT_H_ diff --git a/cef3/include/wrapper/cef_zip_archive.h b/cef3/include/wrapper/cef_zip_archive.h new file mode 100644 index 000000000..b58dbca01 --- /dev/null +++ b/cef3/include/wrapper/cef_zip_archive.h @@ -0,0 +1,132 @@ +// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file are only available to applications that link +// against the libcef_dll_wrapper target. +// + +#ifndef CEF_INCLUDE_WRAPPER_CEF_ZIP_ARCHIVE_H_ +#define CEF_INCLUDE_WRAPPER_CEF_ZIP_ARCHIVE_H_ +#pragma once + +#include "include/cef_base.h" +#include + +class CefStreamReader; + +/// +// Thread-safe class for accessing zip archive file contents. This class should +// not be used with large archive files because all data will be resident in +// memory at the same time. This implementation supports a restricted set of zip +// archive features: +// (1) Password-protected files are not supported. +// (2) All file names are stored and compared in lower case. +// (3) File ordering from the original zip archive is not maintained. This +// means that files from the same folder may not be located together in the +// file content map. +/// +class CefZipArchive : public CefBase { + public: + /// + // Class representing a file in the archive. Accessing the file data from + // multiple threads is safe provided a reference to the File object is kept. + /// + class File : public CefBase { + public: + /// + // Returns the read-only data contained in the file. + /// + virtual const unsigned char* GetData() =0; + + /// + // Returns the size of the data in the file. + /// + virtual size_t GetDataSize() =0; + + /// + // Returns a CefStreamReader object for streaming the contents of the file. + /// + virtual CefRefPtr GetStreamReader() =0; + }; + typedef std::map > FileMap; + + /// + // Create a new object. + /// + CefZipArchive(); + virtual ~CefZipArchive(); + + /// + // Load the contents of the specified zip archive stream into this object. + // If |overwriteExisting| is true then any files in this object that also + // exist in the specified archive will be replaced with the new files. + // Returns the number of files successfully loaded. + /// + size_t Load(CefRefPtr stream, bool overwriteExisting); + + /// + // Clears the contents of this object. + /// + void Clear(); + + /// + // Returns the number of files in the archive. + /// + size_t GetFileCount(); + + /// + // Returns true if the specified file exists and has contents. + /// + bool HasFile(const CefString& fileName); + + /// + // Returns the specified file. + /// + CefRefPtr GetFile(const CefString& fileName); + + /// + // Removes the specified file. + /// + bool RemoveFile(const CefString& fileName); + + /// + // Returns the map of all files. + /// + size_t GetFiles(FileMap& map); + + private: + FileMap contents_; + + IMPLEMENT_REFCOUNTING(CefZipArchive); + IMPLEMENT_LOCKING(CefZipArchive); +}; + +#endif // CEF_INCLUDE_WRAPPER_CEF_ZIP_ARCHIVE_H_ diff --git a/cef3/libcef/browser/application_mac.h b/cef3/libcef/browser/application_mac.h new file mode 100644 index 000000000..440cbf180 --- /dev/null +++ b/cef3/libcef/browser/application_mac.h @@ -0,0 +1,11 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_APPLICATION_MAC_H_ +#define CEF_LIBCEF_BROWSER_APPLICATION_MAC_H_ + +// Create the CefCrApplication instance used by secondary processes. +void CefCrApplicationCreate(); + +#endif // CEF_LIBCEF_BROWSER_APPLICATION_MAC_H_ diff --git a/cef3/libcef/browser/application_mac.mm b/cef3/libcef/browser/application_mac.mm new file mode 100644 index 000000000..ad85cf8fa --- /dev/null +++ b/cef3/libcef/browser/application_mac.mm @@ -0,0 +1,46 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2012 The Chromium 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 "libcef/browser/application_mac.h" + +#include "base/message_pump_mac.h" +#include "base/mac/scoped_sending_event.h" + +@interface CefCrApplication : NSApplication { + @private + BOOL handlingSendEvent_; +} + +// CrAppProtocol: +- (BOOL)isHandlingSendEvent; + +// CrAppControlProtocol: +- (void)setHandlingSendEvent:(BOOL)handlingSendEvent; + +@end + +@implementation CefCrApplication + +- (BOOL)isHandlingSendEvent { + return handlingSendEvent_; +} + +- (void)sendEvent:(NSEvent*)event { + BOOL wasHandlingSendEvent = handlingSendEvent_; + handlingSendEvent_ = YES; + [super sendEvent:event]; + handlingSendEvent_ = wasHandlingSendEvent; +} + +- (void)setHandlingSendEvent:(BOOL)handlingSendEvent { + handlingSendEvent_ = handlingSendEvent; +} + +@end + +void CefCrApplicationCreate() { + [CefCrApplication sharedApplication]; +} diff --git a/cef3/libcef/browser/backing_store_osr.cc b/cef3/libcef/browser/backing_store_osr.cc new file mode 100644 index 000000000..5ff6b0ab4 --- /dev/null +++ b/cef3/libcef/browser/backing_store_osr.cc @@ -0,0 +1,82 @@ +// Copyright (c) 2012 The Chromium 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 "libcef/browser/backing_store_osr.h" + +#include "content/public/browser/render_process_host.h" +#include "ui/gfx/rect.h" +#include "ui/surface/transport_dib.h" + +BackingStoreOSR::BackingStoreOSR(content::RenderWidgetHost* widget, + const gfx::Size& size) + : content::BackingStore(widget, size), + device_(SkBitmap::kARGB_8888_Config, size.width(), size.height(), true), + canvas_(&device_) { + canvas_.drawColor(SK_ColorWHITE); +} + +void BackingStoreOSR::PaintToBackingStore( + content::RenderProcessHost* process, + TransportDIB::Id bitmap, + const gfx::Rect& bitmap_rect, + const std::vector& copy_rects, + float scale_factor, + const base::Closure& completion_callback, + bool* scheduled_completion_callback) { + *scheduled_completion_callback = false; + TransportDIB* dib = process->GetTransportDIB(bitmap); + if (!dib) + return; + + SkBitmap src_bitmap; + src_bitmap.setConfig(SkBitmap::kARGB_8888_Config, + bitmap_rect.width(), + bitmap_rect.height()); + src_bitmap.setPixels(dib->memory()); + + SkPaint copy_paint; + copy_paint.setXfermodeMode(SkXfermode::kSrc_Mode); + + for (size_t i = 0; i < copy_rects.size(); i++) { + SkIRect src_rect = SkIRect::MakeXYWH(copy_rects[i].x() - bitmap_rect.x(), + copy_rects[i].y() - bitmap_rect.y(), + copy_rects[i].width(), + copy_rects[i].height()); + SkRect paint_rect = SkRect::MakeXYWH(copy_rects[i].x(), + copy_rects[i].y(), + copy_rects[i].width(), + copy_rects[i].height()); + canvas_.drawBitmapRect(src_bitmap, &src_rect, paint_rect, ©_paint); + } + src_bitmap.setPixels(0); +} + +bool BackingStoreOSR::CopyFromBackingStore(const gfx::Rect& rect, + skia::PlatformBitmap* output) { + if (!output->Allocate(rect.width(), rect.height(), true)) + return false; + + SkPaint copy_paint; + copy_paint.setXfermodeMode(SkXfermode::kSrc_Mode); + + SkCanvas canvas(output->GetBitmap()); + canvas.drawColor(SK_ColorWHITE); + canvas.drawBitmap(device_.accessBitmap(false), 0, 0, ©_paint); + return true; +} + +void BackingStoreOSR::ScrollBackingStore(const gfx::Vector2d& delta, + const gfx::Rect& clip_rect, + const gfx::Size& view_size) { + SkIRect subset_rect = SkIRect::MakeXYWH(clip_rect.x(), + clip_rect.y(), + clip_rect.width(), + clip_rect.height()); + device_.accessBitmap(true).scrollRect(&subset_rect, delta.x(), delta.y()); +} + +const void* BackingStoreOSR::getPixels() const { + return const_cast(this)->device_. + accessBitmap(false).getPixels(); +} diff --git a/cef3/libcef/browser/backing_store_osr.h b/cef3/libcef/browser/backing_store_osr.h new file mode 100644 index 000000000..91446c27b --- /dev/null +++ b/cef3/libcef/browser/backing_store_osr.h @@ -0,0 +1,52 @@ +// Copyright (c) 2012 The Chromium 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_LIBCEF_BROWSER_BACKING_STORE_OSR_H_ +#define CEF_LIBCEF_BROWSER_BACKING_STORE_OSR_H_ + +#include + +#include "content/browser/renderer_host/backing_store.h" +#include "ui/gfx/canvas.h" + +class CefRenderWidgetHostViewOSR; + +class BackingStoreOSR : public content::BackingStore { + public: + static BackingStoreOSR* From(content::BackingStore* backing_store) { + return static_cast(backing_store); + } + + // BackingStore implementation. + virtual void PaintToBackingStore( + content::RenderProcessHost* process, + TransportDIB::Id bitmap, + const gfx::Rect& bitmap_rect, + const std::vector& copy_rects, + float scale_factor, + const base::Closure& completion_callback, + bool* scheduled_completion_callback) OVERRIDE; + virtual bool CopyFromBackingStore(const gfx::Rect& rect, + skia::PlatformBitmap* output) OVERRIDE; + virtual void ScrollBackingStore(const gfx::Vector2d& delta, + const gfx::Rect& clip_rect, + const gfx::Size& view_size) OVERRIDE; + + const void* getPixels() const; + + private: + // Can be instantiated only within CefRenderWidgetHostViewOSR. + friend class CefRenderWidgetHostViewOSR; + explicit BackingStoreOSR(content::RenderWidgetHost* widget, + const gfx::Size& size); + virtual ~BackingStoreOSR() {} + + SkDevice device_; + SkCanvas canvas_; + + DISALLOW_COPY_AND_ASSIGN(BackingStoreOSR); +}; + +#endif // CEF_LIBCEF_BROWSER_BACKING_STORE_OSR_H_ + diff --git a/cef3/libcef/browser/browser_context.cc b/cef3/libcef/browser/browser_context.cc new file mode 100644 index 000000000..911f3185d --- /dev/null +++ b/cef3/libcef/browser/browser_context.cc @@ -0,0 +1,324 @@ +// Copyright (c) 2012 The Chromium 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 "libcef/browser/browser_context.h" + +#include + +#include "libcef/browser/browser_host_impl.h" +#include "libcef/browser/context.h" +#include "libcef/browser/download_manager_delegate.h" +#include "libcef/browser/thread_util.h" +#include "libcef/browser/url_request_context_getter.h" +#include "libcef/common/cef_switches.h" + +#include "base/bind.h" +#include "base/command_line.h" +#include "base/logging.h" +#include "base/threading/thread.h" +#include "content/public/browser/download_manager.h" +#include "content/public/browser/browser_thread.h" +#include "content/public/browser/geolocation_permission_context.h" +#include "content/public/browser/resource_context.h" +#include "content/public/browser/speech_recognition_preferences.h" +#include "content/public/browser/storage_partition.h" + +using content::BrowserThread; + +namespace { + +class CefGeolocationPermissionContext + : public content::GeolocationPermissionContext { + public: + // CefGeolocationCallback implementation. + class CallbackImpl : public CefGeolocationCallback { + public: + typedef base::Callback // NOLINT(readability/function) + CallbackType; + + explicit CallbackImpl( + CefGeolocationPermissionContext* context, + int bridge_id, + const CallbackType& callback) + : context_(context), + bridge_id_(bridge_id), + callback_(callback) {} + + virtual void Continue(bool allow) OVERRIDE { + if (CEF_CURRENTLY_ON_IOT()) { + if (!callback_.is_null()) { + // Callback must be executed on the UI thread. + CEF_POST_TASK(CEF_UIT, + base::Bind(&CallbackImpl::Run, callback_, allow)); + context_->RemoveCallback(bridge_id_); + } + } else { + CEF_POST_TASK(CEF_IOT, + base::Bind(&CallbackImpl::Continue, this, allow)); + } + } + + void Disconnect() { + callback_.Reset(); + context_ = NULL; + } + + private: + static void Run(const CallbackType& callback, bool allow) { + CEF_REQUIRE_UIT(); + callback.Run(allow); + } + + CefGeolocationPermissionContext* context_; + int bridge_id_; + CallbackType callback_; + + IMPLEMENT_REFCOUNTING(CallbackImpl); + }; + + CefGeolocationPermissionContext() {} + + virtual void RequestGeolocationPermission( + int render_process_id, + int render_view_id, + int bridge_id, + const GURL& requesting_frame, + base::Callback callback) // NOLINT(readability/function) + OVERRIDE { + CEF_REQUIRE_IOT(); + + CefRefPtr browser = + CefBrowserHostImpl::GetBrowserByRoutingID(render_process_id, + render_view_id); + if (browser.get()) { + CefRefPtr client = browser->GetClient(); + if (client.get()) { + CefRefPtr handler = + client->GetGeolocationHandler(); + if (handler.get()) { + CefRefPtr callbackPtr( + new CallbackImpl(this, bridge_id, callback)); + + // Add the callback reference to the map. + callback_map_.insert(std::make_pair(bridge_id, callbackPtr)); + + // Notify the handler. + handler->OnRequestGeolocationPermission(browser.get(), + requesting_frame.spec(), bridge_id, callbackPtr.get()); + return; + } + } + } + + // Disallow geolocation access by default. + CEF_POST_TASK(CEF_UIT, base::Bind(callback, false)); + } + + virtual void CancelGeolocationPermissionRequest( + int render_process_id, + int render_view_id, + int bridge_id, + const GURL& requesting_frame) OVERRIDE { + RemoveCallback(bridge_id); + + CefRefPtr browser = + CefBrowserHostImpl::GetBrowserByRoutingID(render_process_id, + render_view_id); + if (browser.get()) { + CefRefPtr client = browser->GetClient(); + if (client.get()) { + CefRefPtr handler = + client->GetGeolocationHandler(); + if (handler.get()) { + // Notify the handler. + handler->OnCancelGeolocationPermission(browser.get(), + requesting_frame.spec(), bridge_id); + } + } + } + } + + void RemoveCallback(int bridge_id) { + CEF_REQUIRE_IOT(); + + // Disconnect the callback and remove the reference from the map. + CallbackMap::iterator it = callback_map_.find(bridge_id); + if (it != callback_map_.end()) { + it->second->Disconnect(); + callback_map_.erase(it); + } + } + + private: + // Map of bridge ids to callback references. + typedef std::map > CallbackMap; + CallbackMap callback_map_; + + DISALLOW_COPY_AND_ASSIGN(CefGeolocationPermissionContext); +}; + +class CefSpeechRecognitionPreferences + : public content::SpeechRecognitionPreferences { + public: + CefSpeechRecognitionPreferences() { + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + filter_profanities_ = + command_line.HasSwitch(switches::kEnableProfanityFilter); + } + + // Overridden from SpeechRecognitionPreferences: + virtual bool FilterProfanities() const OVERRIDE { + return filter_profanities_; + } + + private: + bool filter_profanities_; + + DISALLOW_COPY_AND_ASSIGN(CefSpeechRecognitionPreferences); +}; + +} // namespace + +class CefBrowserContext::CefResourceContext : public content::ResourceContext { + public: + CefResourceContext() : getter_(NULL) {} + virtual ~CefResourceContext() {} + + // ResourceContext implementation: + virtual net::HostResolver* GetHostResolver() OVERRIDE { + CHECK(getter_); + return getter_->host_resolver(); + } + virtual net::URLRequestContext* GetRequestContext() OVERRIDE { + CHECK(getter_); + return getter_->GetURLRequestContext(); + } + + void set_url_request_context_getter(CefURLRequestContextGetter* getter) { + getter_ = getter; + } + + private: + CefURLRequestContextGetter* getter_; + + DISALLOW_COPY_AND_ASSIGN(CefResourceContext); +}; + +CefBrowserContext::CefBrowserContext() + : resource_context_(new CefResourceContext), + use_osr_next_contents_view_(false) { +} + +CefBrowserContext::~CefBrowserContext() { + // Delete the download manager delegate here because otherwise we'll crash + // when it's accessed from the content::BrowserContext destructor. + if (download_manager_delegate_.get()) + download_manager_delegate_.reset(NULL); + + if (resource_context_.get()) { + BrowserThread::DeleteSoon( + BrowserThread::IO, FROM_HERE, resource_context_.release()); + } +} + +base::FilePath CefBrowserContext::GetPath() { + return _Context->cache_path(); +} + +bool CefBrowserContext::IsOffTheRecord() const { + return false; +} + +content::DownloadManagerDelegate* + CefBrowserContext::GetDownloadManagerDelegate() { + DCHECK(!download_manager_delegate_.get()); + + content::DownloadManager* manager = BrowserContext::GetDownloadManager(this); + download_manager_delegate_.reset(new CefDownloadManagerDelegate(manager)); + return download_manager_delegate_.get(); +} + +net::URLRequestContextGetter* CefBrowserContext::GetRequestContext() { + CEF_REQUIRE_UIT(); + return GetDefaultStoragePartition(this)->GetURLRequestContext(); +} + +net::URLRequestContextGetter* + CefBrowserContext::GetRequestContextForRenderProcess( + int renderer_child_id) { + CefRefPtr browser = + CefBrowserHostImpl::GetBrowserByChildID(renderer_child_id); + if (browser.get()) + return browser->GetRequestContext(); + return GetRequestContext(); +} + +net::URLRequestContextGetter* + CefBrowserContext::GetMediaRequestContext() { + return GetRequestContext(); +} + +net::URLRequestContextGetter* + CefBrowserContext::GetMediaRequestContextForRenderProcess( + int renderer_child_id) { + return GetRequestContext(); +} + +net::URLRequestContextGetter* + CefBrowserContext::GetMediaRequestContextForStoragePartition( + const base::FilePath& partition_path, + bool in_memory) { + return GetRequestContext(); +} + +content::ResourceContext* CefBrowserContext::GetResourceContext() { + return resource_context_.get(); +} + +content::GeolocationPermissionContext* + CefBrowserContext::GetGeolocationPermissionContext() { + if (!geolocation_permission_context_) { + geolocation_permission_context_ = + new CefGeolocationPermissionContext(); + } + return geolocation_permission_context_; +} + +content::SpeechRecognitionPreferences* + CefBrowserContext::GetSpeechRecognitionPreferences() { + if (!speech_recognition_preferences_.get()) + speech_recognition_preferences_ = new CefSpeechRecognitionPreferences(); + return speech_recognition_preferences_.get(); +} + +quota::SpecialStoragePolicy* CefBrowserContext::GetSpecialStoragePolicy() { + return NULL; +} + +net::URLRequestContextGetter* CefBrowserContext::CreateRequestContext( + content::ProtocolHandlerMap* protocol_handlers) { + DCHECK(!url_request_getter_); + url_request_getter_ = new CefURLRequestContextGetter( + BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO), + BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE), + protocol_handlers); + resource_context_->set_url_request_context_getter(url_request_getter_.get()); + return url_request_getter_.get(); +} + +net::URLRequestContextGetter* + CefBrowserContext::CreateRequestContextForStoragePartition( + const base::FilePath& partition_path, + bool in_memory, + content::ProtocolHandlerMap* protocol_handlers) { + return NULL; +} + +bool CefBrowserContext::use_osr_next_contents_view() const { + return use_osr_next_contents_view_; +} + +void CefBrowserContext::set_use_osr_next_contents_view(bool override) { + use_osr_next_contents_view_ = override; +} diff --git a/cef3/libcef/browser/browser_context.h b/cef3/libcef/browser/browser_context.h new file mode 100644 index 000000000..e9799922f --- /dev/null +++ b/cef3/libcef/browser/browser_context.h @@ -0,0 +1,81 @@ +// Copyright (c) 2011 The Chromium 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_LIBCEF_BROWSER_BROWSER_CONTEXT_H_ +#define CEF_LIBCEF_BROWSER_BROWSER_CONTEXT_H_ +#pragma once + +#include "base/compiler_specific.h" +#include "base/files/file_path.h" +#include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" +#include "content/public/browser/browser_context.h" +#include "content/public/browser/content_browser_client.h" +#include "net/url_request/url_request_job_factory.h" + +namespace content { +class DownloadManagerDelegate; +class SpeechRecognitionPreferences; +} + +class CefDownloadManagerDelegate; +class CefURLRequestContextGetter; + +class CefBrowserContext : public content::BrowserContext { + public: + CefBrowserContext(); + virtual ~CefBrowserContext(); + + // BrowserContext methods. + virtual base::FilePath GetPath() OVERRIDE; + virtual bool IsOffTheRecord() const OVERRIDE; + virtual content::DownloadManagerDelegate* GetDownloadManagerDelegate() OVERRIDE; + virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; + virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess( + int renderer_child_id) OVERRIDE; + virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE; + virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess( + int renderer_child_id) OVERRIDE; + virtual net::URLRequestContextGetter* + GetMediaRequestContextForStoragePartition( + const base::FilePath& partition_path, + bool in_memory) OVERRIDE; + virtual content::ResourceContext* GetResourceContext() OVERRIDE; + virtual content::GeolocationPermissionContext* + GetGeolocationPermissionContext() OVERRIDE; + virtual content::SpeechRecognitionPreferences* + GetSpeechRecognitionPreferences() OVERRIDE; + virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; + + net::URLRequestContextGetter* CreateRequestContext( + content::ProtocolHandlerMap* protocol_handlers); + net::URLRequestContextGetter* CreateRequestContextForStoragePartition( + const base::FilePath& partition_path, + bool in_memory, + content::ProtocolHandlerMap* protocol_handlers); + + // To disable window rendering call this function with |override|=true + // just before calling WebContents::Create. This will cause + // CefContentBrowserClient::OverrideCreateWebContentsView to create + // a windowless WebContentsView object. + void set_use_osr_next_contents_view(bool override); + bool use_osr_next_contents_view() const; + + private: + class CefResourceContext; + + scoped_ptr resource_context_; + scoped_ptr download_manager_delegate_; + scoped_refptr url_request_getter_; + scoped_refptr + geolocation_permission_context_; + scoped_refptr + speech_recognition_preferences_; + + bool use_osr_next_contents_view_; + + DISALLOW_COPY_AND_ASSIGN(CefBrowserContext); +}; + +#endif // CEF_LIBCEF_BROWSER_BROWSER_CONTEXT_H_ diff --git a/cef3/libcef/browser/browser_host_impl.cc b/cef3/libcef/browser/browser_host_impl.cc new file mode 100644 index 000000000..6a54de219 --- /dev/null +++ b/cef3/libcef/browser/browser_host_impl.cc @@ -0,0 +1,2338 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 The Chromium 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 "libcef/browser/browser_host_impl.h" + +#include +#include + +#include "libcef/browser/browser_context.h" +#include "libcef/browser/browser_info.h" +#include "libcef/browser/browser_pref_store.h" +#include "libcef/browser/chrome_scheme_handler.h" +#include "libcef/browser/content_browser_client.h" +#include "libcef/browser/context.h" +#include "libcef/browser/devtools_delegate.h" +#include "libcef/browser/media_capture_devices_dispatcher.h" +#include "libcef/browser/navigate_params.h" +#include "libcef/browser/scheme_registration.h" +#include "libcef/browser/thread_util.h" +#include "libcef/browser/url_request_context_getter.h" +#include "libcef/browser/url_request_context_getter_proxy.h" +#include "libcef/common/cef_messages.h" +#include "libcef/common/cef_switches.h" +#include "libcef/common/http_header_utils.h" +#include "libcef/common/main_delegate.h" +#include "libcef/common/process_message_impl.h" +#include "libcef/common/request_impl.h" + +#include "base/bind.h" +#include "base/bind_helpers.h" +#include "base/command_line.h" +#include "content/browser/renderer_host/render_view_host_impl.h" +#include "content/browser/web_contents/web_contents_impl.h" +#include "content/common/view_messages.h" +#include "content/public/browser/download_manager.h" +#include "content/public/browser/download_url_parameters.h" +#include "content/public/browser/native_web_keyboard_event.h" +#include "content/public/browser/navigation_controller.h" +#include "content/public/browser/navigation_entry.h" +#include "content/public/browser/notification_details.h" +#include "content/public/browser/notification_source.h" +#include "content/public/browser/notification_types.h" +#include "content/public/browser/resource_request_info.h" +#include "content/public/browser/web_contents_view.h" +#include "content/public/common/file_chooser_params.h" +#include "ui/shell_dialogs/selected_file_info.h" + +#if defined(OS_WIN) +#include "libcef/browser/render_widget_host_view_osr.h" +#include "libcef/browser/web_contents_view_osr.h" +#endif + +namespace { + +class CreateBrowserHelper { + public: + CreateBrowserHelper(const CefWindowInfo& windowInfo, + CefRefPtr client, + const CefString& url, + const CefBrowserSettings& settings) + : window_info_(windowInfo), + client_(client), + url_(url), + settings_(settings) {} + + CefWindowInfo window_info_; + CefRefPtr client_; + CefString url_; + CefBrowserSettings settings_; +}; + +void CreateBrowserWithHelper(CreateBrowserHelper* helper) { + CefBrowserHost::CreateBrowserSync(helper->window_info_, helper->client_, + helper->url_, helper->settings_); + delete helper; +} + +// Convert a NativeWebKeyboardEvent to a CefKeyEvent. +bool GetCefKeyEvent(const content::NativeWebKeyboardEvent& event, + CefKeyEvent& cef_event) { + switch (event.type) { + case WebKit::WebKeyboardEvent::RawKeyDown: + cef_event.type = KEYEVENT_RAWKEYDOWN; + break; + case WebKit::WebKeyboardEvent::KeyDown: + cef_event.type = KEYEVENT_KEYDOWN; + break; + case WebKit::WebKeyboardEvent::KeyUp: + cef_event.type = KEYEVENT_KEYUP; + break; + case WebKit::WebKeyboardEvent::Char: + cef_event.type = KEYEVENT_CHAR; + break; + default: + return false; + } + + cef_event.modifiers = 0; + if (event.modifiers & WebKit::WebKeyboardEvent::ShiftKey) + cef_event.modifiers |= EVENTFLAG_SHIFT_DOWN; + if (event.modifiers & WebKit::WebKeyboardEvent::ControlKey) + cef_event.modifiers |= EVENTFLAG_CONTROL_DOWN; + if (event.modifiers & WebKit::WebKeyboardEvent::AltKey) + cef_event.modifiers |= EVENTFLAG_ALT_DOWN; + if (event.modifiers & WebKit::WebKeyboardEvent::MetaKey) + cef_event.modifiers |= EVENTFLAG_COMMAND_DOWN; + if (event.modifiers & WebKit::WebKeyboardEvent::IsKeyPad) + cef_event.modifiers |= EVENTFLAG_IS_KEY_PAD; + + cef_event.windows_key_code = event.windowsKeyCode; + cef_event.native_key_code = event.nativeKeyCode; + cef_event.is_system_key = event.isSystemKey; + cef_event.character = event.text[0]; + cef_event.unmodified_character = event.unmodifiedText[0]; + + return true; +} + +class CefFileDialogCallbackImpl : public CefFileDialogCallback { + public: + explicit CefFileDialogCallbackImpl( + const CefBrowserHostImpl::RunFileChooserCallback& callback) + : callback_(callback) { + } + ~CefFileDialogCallbackImpl() { + if (!callback_.is_null()) { + // The callback is still pending. Cancel it now. + if (CEF_CURRENTLY_ON_UIT()) { + CancelNow(callback_); + } else { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefFileDialogCallbackImpl::CancelNow, callback_)); + } + } + } + + virtual void Continue(const std::vector& file_paths) OVERRIDE { + if (CEF_CURRENTLY_ON_UIT()) { + if (!callback_.is_null()) { + std::vector vec; + if (!file_paths.empty()) { + std::vector::const_iterator it = file_paths.begin(); + for (; it != file_paths.end(); ++it) + vec.push_back(base::FilePath(*it)); + } + callback_.Run(vec); + callback_.Reset(); + } + } else { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefFileDialogCallbackImpl::Continue, this, file_paths)); + } + } + + virtual void Cancel() OVERRIDE { + if (CEF_CURRENTLY_ON_UIT()) { + if (!callback_.is_null()) { + CancelNow(callback_); + callback_.Reset(); + } + } else { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefFileDialogCallbackImpl::Cancel, this)); + } + } + + bool IsConnected() { + return !callback_.is_null(); + } + + void Disconnect() { + callback_.Reset(); + } + + private: + static void CancelNow( + const CefBrowserHostImpl::RunFileChooserCallback& callback) { + CEF_REQUIRE_UIT(); + std::vector file_paths; + callback.Run(file_paths); + } + + CefBrowserHostImpl::RunFileChooserCallback callback_; + + IMPLEMENT_REFCOUNTING(CefFileDialogCallbackImpl); +}; + +class CefRunFileDialogCallbackWrapper + : public base::RefCountedThreadSafe { + public: + CefRunFileDialogCallbackWrapper(CefRefPtr host, + CefRefPtr callback) + : host_(host), + callback_(callback) { + } + + void Callback(const std::vector& file_paths) { + std::vector paths; + if (file_paths.size() > 0) { + for (size_t i = 0; i < file_paths.size(); ++i) + paths.push_back(file_paths[i].value()); + } + callback_->OnFileDialogDismissed(host_, paths); + } + + private: + CefRefPtr host_; + CefRefPtr callback_; +}; + +} // namespace + + +// CefBrowserHost static methods. +// ----------------------------------------------------------------------------- + +// static +bool CefBrowserHost::CreateBrowser(const CefWindowInfo& windowInfo, + CefRefPtr client, + const CefString& url, + const CefBrowserSettings& settings) { + // Verify that the context is in a valid state. + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return false; + } + + // Verify that the settings structure is a valid size. + if (settings.size != sizeof(cef_browser_settings_t)) { + NOTREACHED() << "invalid CefBrowserSettings structure size"; + return false; + } + + CefBrowserSettings new_settings = settings; + + // Verify that render handler is in place for a windowless browser. + if (CefBrowserHostImpl::IsWindowRenderingDisabled(windowInfo)) { + if (!client->GetRenderHandler().get()) { + NOTREACHED() << "CefRenderHandler implementation is required"; + return false; + } + if (new_settings.accelerated_compositing != STATE_DISABLED) { + // Accelerated compositing is not supported when window rendering is + // disabled. + new_settings.accelerated_compositing = STATE_DISABLED; + } + } + + // Create the browser on the UI thread. + CreateBrowserHelper* helper = + new CreateBrowserHelper(windowInfo, client, url, new_settings); + CEF_POST_TASK(CEF_UIT, base::Bind(CreateBrowserWithHelper, helper)); + + return true; +} + +// static +CefRefPtr CefBrowserHost::CreateBrowserSync( + const CefWindowInfo& windowInfo, + CefRefPtr client, + const CefString& url, + const CefBrowserSettings& settings) { + // Verify that the context is in a valid state. + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return NULL; + } + + // Verify that the settings structure is a valid size. + if (settings.size != sizeof(cef_browser_settings_t)) { + NOTREACHED() << "invalid CefBrowserSettings structure size"; + return NULL; + } + + // Verify that this method is being called on the UI thread. + if (!CEF_CURRENTLY_ON_UIT()) { + NOTREACHED() << "called on invalid thread"; + return NULL; + } + + CefBrowserSettings new_settings = settings; + + // Verify that render handler is in place for a windowless browser. + if (CefBrowserHostImpl::IsWindowRenderingDisabled(windowInfo)) { + if (!client->GetRenderHandler().get()) { + NOTREACHED() << "CefRenderHandler implementation is required"; + return NULL; + } + if (new_settings.accelerated_compositing != STATE_DISABLED) { + // Accelerated compositing is not supported when window rendering is + // disabled. + new_settings.accelerated_compositing = STATE_DISABLED; + } + } + + _Context->browser_context()->set_use_osr_next_contents_view( + CefBrowserHostImpl::IsWindowRenderingDisabled(windowInfo)); + + scoped_refptr info = + CefContentBrowserClient::Get()->CreateBrowserInfo(); + DCHECK(!info->is_popup()); + CefRefPtr browser = + CefBrowserHostImpl::Create(windowInfo, new_settings, client, NULL, info, + NULL); + if (!url.empty()) + browser->LoadURL(CefFrameHostImpl::kMainFrameId, url); + return browser.get(); +} + + +// CefBrowserHostImpl static methods. +// ----------------------------------------------------------------------------- + +CefBrowserHostImpl::~CefBrowserHostImpl() { +} + +// static +CefRefPtr CefBrowserHostImpl::Create( + const CefWindowInfo& window_info, + const CefBrowserSettings& settings, + CefRefPtr client, + content::WebContents* web_contents, + scoped_refptr browser_info, + CefWindowHandle opener) { + CEF_REQUIRE_UIT(); + DCHECK(browser_info.get()); + + // If |opener| is non-NULL it must be a popup window. + DCHECK(opener == NULL || browser_info->is_popup()); + + if (web_contents == NULL) { + content::WebContents::CreateParams create_params( + _Context->browser_context()); + web_contents = content::WebContents::Create(create_params); + } + + CefRefPtr browser = + new CefBrowserHostImpl(window_info, settings, client, web_contents, + browser_info, opener); + if (!browser->IsWindowRenderingDisabled() && + !browser->PlatformCreateWindow()) { + return NULL; + } + + // TODO(port): Implement this method to work on other platforms as part of + // off-screen rendering support. +#if defined(OS_WIN) + if (browser->IsWindowRenderingDisabled()) { + CefRenderWidgetHostViewOSR* view = + static_cast( + web_contents->GetRenderViewHost()->GetView()); + if (view) + view->set_browser_impl(browser); + } +#endif // OS_WIN + + if (client.get()) { + CefRefPtr handler = client->GetLifeSpanHandler(); + if (handler.get()) + handler->OnAfterCreated(browser.get()); + } + + return browser; +} + +// static +CefRefPtr CefBrowserHostImpl::GetBrowserForHost( + const content::RenderViewHost* host) { + DCHECK(host); + CEF_REQUIRE_UIT(); + content::WebContentsImpl* web_contents = + static_cast(host->GetDelegate()); + if (web_contents) + return static_cast(web_contents->GetDelegate()); + return NULL; +} + +// static +CefRefPtr CefBrowserHostImpl::GetBrowserForContents( + content::WebContents* contents) { + DCHECK(contents); + CEF_REQUIRE_UIT(); + return static_cast(contents->GetDelegate()); +} + +// static +CefRefPtr CefBrowserHostImpl::GetBrowserForRequest( + net::URLRequest* request) { + DCHECK(request); + CEF_REQUIRE_IOT(); + int render_process_id = -1; + int render_view_id = -1; + + if (!content::ResourceRequestInfo::GetRenderViewForRequest(request, + &render_process_id, + &render_view_id)) { + return NULL; + } + + return GetBrowserByRoutingID(render_process_id, render_view_id); +} + +// static +CefRefPtr CefBrowserHostImpl::GetBrowserByRoutingID( + int render_process_id, int render_view_id) { + if (CEF_CURRENTLY_ON_UIT()) { + // Use the non-thread-safe but potentially faster approach. + content::RenderViewHost* render_view_host = + content::RenderViewHost::FromID(render_process_id, render_view_id); + if (!render_view_host) + return NULL; + return GetBrowserForHost(render_view_host); + } else { + // Use the thread-safe approach. + return _Context->GetBrowserByRoutingID(render_process_id, render_view_id); + } +} + +// static +CefRefPtr CefBrowserHostImpl::GetBrowserByChildID( + int render_process_id) { + if (CEF_CURRENTLY_ON_UIT()) { + // Use the non-thread-safe but potentially faster approach. + content::RenderProcessHost* render_process_host = + content::RenderProcessHost::FromID(render_process_id); + if (!render_process_host) + return NULL; + + content::RenderProcessHost::RenderWidgetHostsIterator iter( + render_process_host->GetRenderWidgetHostsIterator()); + if (!iter.IsAtEnd()) { + const content::RenderWidgetHost* widget = iter.GetCurrentValue(); + + // This implementation is based on an assumption that each process hosts a + // single renderer. Revisit this implementation if the assumption proves + // false. + iter.Advance(); + DCHECK(iter.IsAtEnd()); + + if (widget && widget->IsRenderView()) { + return GetBrowserForHost(content::RenderViewHost::From( + const_cast(widget))); + } + } + + return NULL; + } else { + // Use the thread-safe approach. + return _Context->GetBrowserByRoutingID(render_process_id, 0); + } +} + + +// CefBrowserHost methods. +// ----------------------------------------------------------------------------- + +CefRefPtr CefBrowserHostImpl::GetBrowser() { + return this; +} + +void CefBrowserHostImpl::CloseBrowser(bool force_close) { + if (CEF_CURRENTLY_ON_UIT()) { + // Exit early if a close attempt is already pending and this method is + // called again from somewhere other than WindowDestroyed(). + if (destruction_state_ >= DESTRUCTION_STATE_PENDING && + (IsWindowRenderingDisabled() || !window_destroyed_)) { + if (force_close && destruction_state_ == DESTRUCTION_STATE_PENDING) { + // Upgrade the destruction state. + destruction_state_ = DESTRUCTION_STATE_ACCEPTED; + } + return; + } + + if (destruction_state_ < DESTRUCTION_STATE_ACCEPTED) { + destruction_state_ = (force_close ? DESTRUCTION_STATE_ACCEPTED : + DESTRUCTION_STATE_PENDING); + } + + content::WebContents* contents = web_contents(); + if (contents && contents->NeedToFireBeforeUnload()) { + // Will result in a call to BeforeUnloadFired() and, if the close isn't + // canceled, CloseContents(). + contents->GetRenderViewHost()->FirePageBeforeUnload(false); + } else { + CloseContents(contents); + } + } else { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefBrowserHostImpl::CloseBrowser, this, force_close)); + } +} + +void CefBrowserHostImpl::ParentWindowWillClose() { +} + +void CefBrowserHostImpl::SetFocus(bool enable) { + if (!enable) + return; + + OnSetFocus(FOCUS_SOURCE_SYSTEM); +} + +CefWindowHandle CefBrowserHostImpl::GetWindowHandle() { + return PlatformGetWindowHandle(); +} + +CefWindowHandle CefBrowserHostImpl::GetOpenerWindowHandle() { + return opener_; +} + +CefRefPtr CefBrowserHostImpl::GetClient() { + return client_; +} + +CefString CefBrowserHostImpl::GetDevToolsURL(bool http_scheme) { + base::AutoLock lock_scope(state_lock_); + return (http_scheme ? devtools_url_http_ : devtools_url_chrome_); +} + +double CefBrowserHostImpl::GetZoomLevel() { + // Verify that this method is being called on the UI thread. + if (!CEF_CURRENTLY_ON_UIT()) { + NOTREACHED() << "called on invalid thread"; + return 0; + } + + if (web_contents_.get()) + return web_contents_->GetZoomLevel(); + + return 0; +} + +void CefBrowserHostImpl::SetZoomLevel(double zoomLevel) { + if (CEF_CURRENTLY_ON_UIT()) { + if (web_contents_.get() && web_contents_->GetRenderViewHost()) + web_contents_->GetRenderViewHost()->SetZoomLevel(zoomLevel); + } else { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefBrowserHostImpl::SetZoomLevel, this, zoomLevel)); + } +} + +void CefBrowserHostImpl::RunFileDialog( + FileDialogMode mode, + const CefString& title, + const CefString& default_file_name, + const std::vector& accept_types, + CefRefPtr callback) { + DCHECK(callback.get()); + if (!callback.get()) + return; + + content::FileChooserParams params; + switch (mode) { + case FILE_DIALOG_OPEN: + params.mode = content::FileChooserParams::Open; + break; + case FILE_DIALOG_OPEN_MULTIPLE: + params.mode = content::FileChooserParams::OpenMultiple; + break; + case FILE_DIALOG_SAVE: + params.mode = content::FileChooserParams::Save; + break; + } + params.title = title; + if (!default_file_name.empty()) + params.default_file_name = base::FilePath(default_file_name); + if (!accept_types.empty()) { + std::vector::const_iterator it = accept_types.begin(); + for (; it != accept_types.end(); ++it) + params.accept_types.push_back(*it); + } + + scoped_refptr wrapper = + new CefRunFileDialogCallbackWrapper(this, callback); + RunFileChooser(params, + base::Bind(&CefRunFileDialogCallbackWrapper::Callback, wrapper)); +} + +void CefBrowserHostImpl::StartDownload(const CefString& url) { + if (!CEF_CURRENTLY_ON_UIT()) { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefBrowserHostImpl::StartDownload, this, url)); + return; + } + + GURL gurl = GURL(url.ToString()); + if (gurl.is_empty() || !gurl.is_valid()) + return; + + if (!web_contents()) + return; + + CefBrowserContext* context = _Context->browser_context(); + if (!context) + return; + + scoped_refptr manager = + content::BrowserContext::GetDownloadManager(context); + if (!manager) + return; + + scoped_ptr params; + params.reset( + content::DownloadUrlParameters::FromWebContents(web_contents(), gurl)); + manager->DownloadUrl(params.Pass()); +} + +void CefBrowserHostImpl::SetMouseCursorChangeDisabled(bool disabled) { + base::AutoLock lock_scope(state_lock_); + mouse_cursor_change_disabled_ = disabled; +} + +bool CefBrowserHostImpl::IsMouseCursorChangeDisabled() { + base::AutoLock lock_scope(state_lock_); + return mouse_cursor_change_disabled_; +} + +bool CefBrowserHostImpl::IsWindowRenderingDisabled() { + return IsWindowRenderingDisabled(window_info_); +} + +void CefBrowserHostImpl::WasResized() { + if (!IsWindowRenderingDisabled()) { + NOTREACHED() << "Window rendering is not disabled"; + return; + } + + if (!CEF_CURRENTLY_ON_UIT()) { + CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::WasResized, this)); + return; + } + + if (!web_contents()) + return; + + content::RenderWidgetHost* widget = web_contents()->GetRenderViewHost(); + if (widget) + widget->WasResized(); +} + +void CefBrowserHostImpl::WasHidden(bool hidden) { + if (!IsWindowRenderingDisabled()) { + NOTREACHED() << "Window rendering is not disabled"; + return; + } + + if (!CEF_CURRENTLY_ON_UIT()) { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefBrowserHostImpl::WasHidden, this, hidden)); + return; + } + + if (!web_contents()) + return; + + content::RenderWidgetHostImpl* widget = + content::RenderWidgetHostImpl::From(web_contents()->GetRenderViewHost()); + if (!widget) + return; + + if (hidden) + widget->WasHidden(); + else + widget->WasShown(); +} + +void CefBrowserHostImpl::Invalidate(const CefRect& dirtyRect, + PaintElementType type) { + if (!IsWindowRenderingDisabled()) { + NOTREACHED() << "Window rendering is not disabled"; + return; + } + + if (!CEF_CURRENTLY_ON_UIT()) { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefBrowserHostImpl::Invalidate, this, dirtyRect, type)); + return; + } + + if (!web_contents()) + return; + +#if defined(OS_WIN) + content::RenderWidgetHostView* view = + web_contents()->GetRenderViewHost()->GetView(); + CefRenderWidgetHostViewOSR* orview = + static_cast(view); + + if (orview) { + gfx::Rect rect(dirtyRect.x, dirtyRect.y, + dirtyRect.width, dirtyRect.height); + orview->Invalidate(rect, type); + } +#else + // TODO(port): Implement this method to work on other platforms as part of + // off-screen rendering support. + NOTREACHED(); +#endif +} + +void CefBrowserHostImpl::SendKeyEvent(const CefKeyEvent& event) { + if (!CEF_CURRENTLY_ON_UIT()) { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefBrowserHostImpl::SendKeyEvent, this, event)); + return; + } + + content::NativeWebKeyboardEvent web_event; + PlatformTranslateKeyEvent(web_event, event); + + if (!IsWindowRenderingDisabled()) { + content::RenderWidgetHost* widget = web_contents()->GetRenderViewHost(); + if (widget) + widget->ForwardKeyboardEvent(web_event); + } else { +#if defined(OS_WIN) + if (!web_contents()) + return; + content::RenderWidgetHostView* view = + web_contents()->GetRenderViewHost()->GetView(); + CefRenderWidgetHostViewOSR* orview = + static_cast(view); + if (orview) + orview->SendKeyEvent(web_event); +#else + // TODO(port): Implement this method to work on other platforms as part of + // off-screen rendering support. + NOTREACHED(); +#endif + } +} + +void CefBrowserHostImpl::SendMouseClickEvent(const CefMouseEvent& event, + MouseButtonType type, bool mouseUp, int clickCount) { + if (!CEF_CURRENTLY_ON_UIT()) { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefBrowserHostImpl::SendMouseClickEvent, this, event, type, + mouseUp, clickCount)); + return; + } + + WebKit::WebMouseEvent web_event; + PlatformTranslateClickEvent(web_event, event, type, mouseUp, clickCount); + + SendMouseEvent(web_event); +} + +void CefBrowserHostImpl::SendMouseMoveEvent(const CefMouseEvent& event, + bool mouseLeave) { + if (!CEF_CURRENTLY_ON_UIT()) { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefBrowserHostImpl::SendMouseMoveEvent, this, event, + mouseLeave)); + return; + } + + WebKit::WebMouseEvent web_event; + PlatformTranslateMoveEvent(web_event, event, mouseLeave); + + SendMouseEvent(web_event); +} + +void CefBrowserHostImpl::SendMouseWheelEvent(const CefMouseEvent& event, + int deltaX, int deltaY) { + if (!CEF_CURRENTLY_ON_UIT()) { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefBrowserHostImpl::SendMouseWheelEvent, this, event, + deltaX, deltaY)); + return; + } + + WebKit::WebMouseWheelEvent web_event; + PlatformTranslateWheelEvent(web_event, event, deltaX, deltaY); + + if (!IsWindowRenderingDisabled()) { + content::RenderWidgetHost* widget = web_contents()->GetRenderViewHost(); + if (widget) + widget->ForwardWheelEvent(web_event); + } else { +#if defined(OS_WIN) + if (!web_contents()) + return; + content::RenderWidgetHostView* view = + web_contents()->GetRenderViewHost()->GetView(); + CefRenderWidgetHostViewOSR* orview = + static_cast(view); + + if (orview) + orview->SendMouseWheelEvent(web_event); +#else + // TODO(port): Implement this method to work on other platforms as part of + // off-screen rendering support. + NOTREACHED(); +#endif + } +} + +int CefBrowserHostImpl::TranslateModifiers(uint32 cef_modifiers) { + int webkit_modifiers = 0; + // Set modifiers based on key state. + if (cef_modifiers & EVENTFLAG_SHIFT_DOWN) + webkit_modifiers |= WebKit::WebInputEvent::ShiftKey; + if (cef_modifiers & EVENTFLAG_CONTROL_DOWN) + webkit_modifiers |= WebKit::WebInputEvent::ControlKey; + if (cef_modifiers & EVENTFLAG_ALT_DOWN) + webkit_modifiers |= WebKit::WebInputEvent::AltKey; + if (cef_modifiers & EVENTFLAG_COMMAND_DOWN) + webkit_modifiers |= WebKit::WebInputEvent::MetaKey; + if (cef_modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON) + webkit_modifiers |= WebKit::WebInputEvent::LeftButtonDown; + if (cef_modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON) + webkit_modifiers |= WebKit::WebInputEvent::MiddleButtonDown; + if (cef_modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON) + webkit_modifiers |= WebKit::WebInputEvent::RightButtonDown; + if (cef_modifiers & EVENTFLAG_CAPS_LOCK_ON) + webkit_modifiers |= WebKit::WebInputEvent::CapsLockOn; + if (cef_modifiers & EVENTFLAG_NUM_LOCK_ON) + webkit_modifiers |= WebKit::WebInputEvent::NumLockOn; + if (cef_modifiers & EVENTFLAG_IS_LEFT) + webkit_modifiers |= WebKit::WebInputEvent::IsLeft; + if (cef_modifiers & EVENTFLAG_IS_RIGHT) + webkit_modifiers |= WebKit::WebInputEvent::IsRight; + if (cef_modifiers & EVENTFLAG_IS_KEY_PAD) + webkit_modifiers |= WebKit::WebInputEvent::IsKeyPad; + return webkit_modifiers; +} + +void CefBrowserHostImpl::SendMouseEvent(const WebKit::WebMouseEvent& event) { + if (!IsWindowRenderingDisabled()) { + content::RenderWidgetHost* widget = web_contents()->GetRenderViewHost(); + if (widget) + widget->ForwardMouseEvent(event); + } else { +#if defined(OS_WIN) + if (!web_contents()) + return; + content::RenderWidgetHostView* view = + web_contents()->GetRenderViewHost()->GetView(); + CefRenderWidgetHostViewOSR* orview = + static_cast(view); + + if (orview) + orview->SendMouseEvent(event); +#else + // TODO(port): Implement this method to work on other platforms as part of + // off-screen rendering support. + NOTREACHED(); +#endif + } +} + +void CefBrowserHostImpl::SendFocusEvent(bool setFocus) { + if (!CEF_CURRENTLY_ON_UIT()) { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefBrowserHostImpl::SendFocusEvent, this, setFocus)); + return; + } + + if (!web_contents()) + return; + + content::RenderWidgetHostImpl* widget = + content::RenderWidgetHostImpl::From(web_contents()->GetRenderViewHost()); + if (!widget) + return; + if (setFocus) { + widget->GotFocus(); + widget->SetActive(true); + } else { + widget->SetActive(false); + widget->Blur(); + } +} + +void CefBrowserHostImpl::SendCaptureLostEvent() { + if (!CEF_CURRENTLY_ON_UIT()) { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefBrowserHostImpl::SendCaptureLostEvent, this)); + return; + } + + if (!web_contents()) + return; + + content::RenderWidgetHostImpl* widget = + content::RenderWidgetHostImpl::From(web_contents()->GetRenderViewHost()); + if (!widget) + return; + widget->LostCapture(); +} + +// CefBrowser methods. +// ----------------------------------------------------------------------------- + +CefRefPtr CefBrowserHostImpl::GetHost() { + return this; +} + +bool CefBrowserHostImpl::CanGoBack() { + base::AutoLock lock_scope(state_lock_); + return can_go_back_; +} + +void CefBrowserHostImpl::GoBack() { + if (CEF_CURRENTLY_ON_UIT()) { + if (web_contents_.get() && web_contents_->GetController().CanGoBack()) + web_contents_->GetController().GoBack(); + } else { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefBrowserHostImpl::GoBack, this)); + } +} + +bool CefBrowserHostImpl::CanGoForward() { + base::AutoLock lock_scope(state_lock_); + return can_go_forward_; +} + +void CefBrowserHostImpl::GoForward() { + if (CEF_CURRENTLY_ON_UIT()) { + if (web_contents_.get() && web_contents_->GetController().CanGoForward()) + web_contents_->GetController().GoForward(); + } else { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefBrowserHostImpl::GoForward, this)); + } +} + +bool CefBrowserHostImpl::IsLoading() { + base::AutoLock lock_scope(state_lock_); + return is_loading_; +} + +void CefBrowserHostImpl::Reload() { + if (CEF_CURRENTLY_ON_UIT()) { + if (web_contents_.get()) + web_contents_->GetController().Reload(true); + } else { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefBrowserHostImpl::Reload, this)); + } +} + +void CefBrowserHostImpl::ReloadIgnoreCache() { + if (CEF_CURRENTLY_ON_UIT()) { + if (web_contents_.get()) + web_contents_->GetController().ReloadIgnoringCache(true); + } else { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefBrowserHostImpl::ReloadIgnoreCache, this)); + } +} + +void CefBrowserHostImpl::StopLoad() { + if (CEF_CURRENTLY_ON_UIT()) { + if (web_contents_.get()) + web_contents_->Stop(); + } else { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefBrowserHostImpl::StopLoad, this)); + } +} + +int CefBrowserHostImpl::GetIdentifier() { + return browser_id(); +} + +bool CefBrowserHostImpl::IsSame(CefRefPtr that) { + CefBrowserHostImpl* impl = static_cast(that.get()); + return (impl == this); +} + +bool CefBrowserHostImpl::IsPopup() { + return browser_info_->is_popup(); +} + +bool CefBrowserHostImpl::HasDocument() { + base::AutoLock lock_scope(state_lock_); + return has_document_; +} + +CefRefPtr CefBrowserHostImpl::GetMainFrame() { + return GetFrame(CefFrameHostImpl::kMainFrameId); +} + +CefRefPtr CefBrowserHostImpl::GetFocusedFrame() { + return GetFrame(CefFrameHostImpl::kFocusedFrameId); +} + +CefRefPtr CefBrowserHostImpl::GetFrame(int64 identifier) { + base::AutoLock lock_scope(state_lock_); + + if (main_frame_id_ == CefFrameHostImpl::kInvalidFrameId) { + // A main frame does not exist yet. Return the placeholder frame that + // provides limited functionality. + return placeholder_frame_.get(); + } + + if (identifier == CefFrameHostImpl::kMainFrameId) { + identifier = main_frame_id_; + } else if (identifier == CefFrameHostImpl::kFocusedFrameId) { + // Return the main frame if no focused frame is currently identified. + if (focused_frame_id_ == CefFrameHostImpl::kInvalidFrameId) + identifier = main_frame_id_; + else + identifier = focused_frame_id_; + } + + if (identifier == CefFrameHostImpl::kInvalidFrameId) + return NULL; + + FrameMap::const_iterator it = frames_.find(identifier); + if (it != frames_.end()) + return it->second.get(); + + return NULL; +} + +CefRefPtr CefBrowserHostImpl::GetFrame(const CefString& name) { + base::AutoLock lock_scope(state_lock_); + + FrameMap::const_iterator it = frames_.begin(); + for (; it != frames_.end(); ++it) { + if (it->second->GetName() == name) + return it->second.get(); + } + + return NULL; +} + +size_t CefBrowserHostImpl::GetFrameCount() { + base::AutoLock lock_scope(state_lock_); + return frames_.size(); +} + +void CefBrowserHostImpl::GetFrameIdentifiers(std::vector& identifiers) { + base::AutoLock lock_scope(state_lock_); + + if (identifiers.size() > 0) + identifiers.clear(); + + FrameMap::const_iterator it = frames_.begin(); + for (; it != frames_.end(); ++it) + identifiers.push_back(it->first); +} + +void CefBrowserHostImpl::GetFrameNames(std::vector& names) { + base::AutoLock lock_scope(state_lock_); + + if (names.size() > 0) + names.clear(); + + FrameMap::const_iterator it = frames_.begin(); + for (; it != frames_.end(); ++it) + names.push_back(it->second->GetName()); +} + +bool CefBrowserHostImpl::SendProcessMessage( + CefProcessId target_process, + CefRefPtr message) { + DCHECK(message.get()); + + Cef_Request_Params params; + CefProcessMessageImpl* impl = + static_cast(message.get()); + if (impl->CopyTo(params)) { + return SendProcessMessage(target_process, params.name, ¶ms.arguments, + true); + } + + return false; +} + + +// CefBrowserHostImpl public methods. +// ----------------------------------------------------------------------------- + +void CefBrowserHostImpl::WindowDestroyed() { + CEF_REQUIRE_UIT(); + DCHECK(!window_destroyed_); + window_destroyed_ = true; + CloseBrowser(true); +} + +void CefBrowserHostImpl::DestroyBrowser() { + CEF_REQUIRE_UIT(); + + destruction_state_ = DESTRUCTION_STATE_COMPLETED; + + if (client_.get()) { + CefRefPtr handler = client_->GetLifeSpanHandler(); + if (handler.get()) { + // Notify the handler that the window is about to be closed. + handler->OnBeforeClose(this); + } + } + + while (!queued_messages_.empty()) { + delete queued_messages_.front(); + queued_messages_.pop(); + } + + registrar_.reset(NULL); + response_manager_.reset(NULL); + content::WebContentsObserver::Observe(NULL); + web_contents_.reset(NULL); + + DetachAllFrames(); + + request_context_proxy_ = NULL; + + CefContentBrowserClient::Get()->RemoveBrowserInfo(browser_info_); + browser_info_->set_browser(NULL); +} + +gfx::NativeView CefBrowserHostImpl::GetContentView() const { + CEF_REQUIRE_UIT(); + if (!web_contents_.get()) + return NULL; + return web_contents_->GetView()->GetNativeView(); +} + +content::WebContents* CefBrowserHostImpl::GetWebContents() const { + CEF_REQUIRE_UIT(); + return web_contents_.get(); +} + +net::URLRequestContextGetter* CefBrowserHostImpl::GetRequestContext() { + CEF_REQUIRE_UIT(); + if (!request_context_proxy_) { + request_context_proxy_ = + new CefURLRequestContextGetterProxy(this, + static_cast( + _Context->request_context().get())); + } + return request_context_proxy_.get(); +} + +CefRefPtr CefBrowserHostImpl::GetFrameForRequest( + net::URLRequest* request) { + CEF_REQUIRE_IOT(); + const content::ResourceRequestInfo* info = + content::ResourceRequestInfo::ForRequest(request); + if (!info) + return NULL; + return GetOrCreateFrame(info->GetFrameID(), info->GetParentFrameID(), + info->IsMainFrame(), string16(), GURL()); +} + +void CefBrowserHostImpl::Navigate(const CefNavigateParams& params) { + // Only known frame ids and kMainFrameId are supported. + DCHECK(params.frame_id >= CefFrameHostImpl::kMainFrameId); + + CefMsg_LoadRequest_Params request; + request.url = params.url; + if (!request.url.is_valid()) { + LOG(ERROR) << "Invalid URL passed to CefBrowserHostImpl::Navigate: " << + params.url; + return; + } + + request.method = params.method; + request.referrer = params.referrer.url; + request.referrer_policy = params.referrer.policy; + request.frame_id = params.frame_id; + request.first_party_for_cookies = params.first_party_for_cookies; + request.headers = params.headers; + request.load_flags = params.load_flags; + request.upload_data = params.upload_data; + + Send(new CefMsg_LoadRequest(routing_id(), request)); + + OnSetFocus(FOCUS_SOURCE_NAVIGATION); +} + +void CefBrowserHostImpl::LoadRequest(int64 frame_id, + CefRefPtr request) { + CefNavigateParams params(GURL(std::string(request->GetURL())), + content::PAGE_TRANSITION_TYPED); + params.method = request->GetMethod(); + params.frame_id = frame_id; + params.first_party_for_cookies = + GURL(std::string(request->GetFirstPartyForCookies())); + + CefRequest::HeaderMap headerMap; + request->GetHeaderMap(headerMap); + if (!headerMap.empty()) + params.headers = HttpHeaderUtils::GenerateHeaders(headerMap); + + CefRefPtr postData = request->GetPostData(); + if (postData.get()) { + CefPostDataImpl* impl = static_cast(postData.get()); + params.upload_data = new net::UploadData(); + impl->Get(*params.upload_data.get()); + } + + params.load_flags = request->GetFlags(); + + Navigate(params); +} + +void CefBrowserHostImpl::LoadURL(int64 frame_id, const std::string& url) { + if (frame_id == CefFrameHostImpl::kMainFrameId) { + // Go through the navigation controller. + if (CEF_CURRENTLY_ON_UIT()) { + if (web_contents_.get()) { + GURL gurl = GURL(url); + + if (!gurl.is_valid() && !gurl.has_scheme()) { + // Try to add "http://" at the beginning + std::string new_url = std::string("http://") + url; + gurl = GURL(new_url); + } + + if (!gurl.is_valid()) { + LOG(ERROR) << + "Invalid URL passed to CefBrowserHostImpl::LoadURL: " << url; + return; + } + + // Update the loading URL. + OnLoadingURLChange(gurl); + + web_contents_->GetController().LoadURL( + gurl, + content::Referrer(), + content::PAGE_TRANSITION_TYPED, + std::string()); + OnSetFocus(FOCUS_SOURCE_NAVIGATION); + } + } else { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefBrowserHostImpl::LoadURL, this, frame_id, url)); + } + } else { + CefNavigateParams params(GURL(url), content::PAGE_TRANSITION_TYPED); + params.frame_id = frame_id; + Navigate(params); + } +} + +void CefBrowserHostImpl::LoadString(int64 frame_id, const std::string& string, + const std::string& url) { + // Only known frame ids or kMainFrameId are supported. + DCHECK(frame_id >= CefFrameHostImpl::kMainFrameId); + + Cef_Request_Params params; + params.name = "load-string"; + params.frame_id = frame_id; + params.user_initiated = false; + params.request_id = -1; + params.expect_response = false; + + params.arguments.Append(base::Value::CreateStringValue(string)); + params.arguments.Append(base::Value::CreateStringValue(url)); + + Send(new CefMsg_Request(routing_id(), params)); +} + +void CefBrowserHostImpl::SendCommand( + int64 frame_id, + const std::string& command, + CefRefPtr responseHandler) { + // Only known frame ids are supported. + DCHECK(frame_id > CefFrameHostImpl::kMainFrameId); + DCHECK(!command.empty()); + + // Execute on the UI thread because CefResponseManager is not thread safe. + if (CEF_CURRENTLY_ON_UIT()) { + Cef_Request_Params params; + params.name = "execute-command"; + params.frame_id = frame_id; + params.user_initiated = false; + + if (responseHandler.get()) { + params.request_id = response_manager_->RegisterHandler(responseHandler); + params.expect_response = true; + } else { + params.request_id = -1; + params.expect_response = false; + } + + params.arguments.Append(base::Value::CreateStringValue(command)); + + Send(new CefMsg_Request(routing_id(), params)); + } else { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefBrowserHostImpl::SendCommand, this, frame_id, command, + responseHandler)); + } +} + +void CefBrowserHostImpl::SendCode( + int64 frame_id, + bool is_javascript, + const std::string& code, + const std::string& script_url, + int script_start_line, + CefRefPtr responseHandler) { + // Only known frame ids are supported. + DCHECK(frame_id >= CefFrameHostImpl::kMainFrameId); + DCHECK(!code.empty()); + DCHECK_GE(script_start_line, 0); + + // Execute on the UI thread because CefResponseManager is not thread safe. + if (CEF_CURRENTLY_ON_UIT()) { + Cef_Request_Params params; + params.name = "execute-code"; + params.frame_id = frame_id; + params.user_initiated = false; + + if (responseHandler.get()) { + params.request_id = response_manager_->RegisterHandler(responseHandler); + params.expect_response = true; + } else { + params.request_id = -1; + params.expect_response = false; + } + + params.arguments.Append(base::Value::CreateBooleanValue(is_javascript)); + params.arguments.Append(base::Value::CreateStringValue(code)); + params.arguments.Append(base::Value::CreateStringValue(script_url)); + params.arguments.Append(base::Value::CreateIntegerValue(script_start_line)); + + Send(new CefMsg_Request(routing_id(), params)); + } else { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefBrowserHostImpl::SendCode, this, frame_id, is_javascript, + code, script_url, script_start_line, responseHandler)); + } +} + +bool CefBrowserHostImpl::SendProcessMessage(CefProcessId target_process, + const std::string& name, + base::ListValue* arguments, + bool user_initiated) { + DCHECK_EQ(PID_RENDERER, target_process); + DCHECK(!name.empty()); + + Cef_Request_Params params; + params.name = name; + if (arguments) + params.arguments.Swap(arguments); + params.frame_id = -1; + params.user_initiated = user_initiated; + params.request_id = -1; + params.expect_response = false; + + return Send(new CefMsg_Request(routing_id(), params)); +} + +bool CefBrowserHostImpl::ViewText(const std::string& text) { + return PlatformViewText(text); +} + +void CefBrowserHostImpl::HandleExternalProtocol(const GURL& url) { + if (CEF_CURRENTLY_ON_UIT()) { + bool allow_os_execution = false; + + if (client_.get()) { + CefRefPtr handler = client_->GetRequestHandler(); + if (handler.get()) + handler->OnProtocolExecution(this, url.spec(), allow_os_execution); + } + + if (allow_os_execution) + PlatformHandleExternalProtocol(url); + } else { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefBrowserHostImpl::HandleExternalProtocol, this, url)); + } +} + +int CefBrowserHostImpl::browser_id() const { + return browser_info_->browser_id(); +} + +GURL CefBrowserHostImpl::GetLoadingURL() { + base::AutoLock lock_scope(state_lock_); + return loading_url_; +} + +void CefBrowserHostImpl::OnSetFocus(cef_focus_source_t source) { + if (CEF_CURRENTLY_ON_UIT()) { + // SetFocus() might be called while inside the OnSetFocus() callback. If so, + // don't re-enter the callback. + if (!is_in_onsetfocus_) { + if (client_.get()) { + CefRefPtr handler = client_->GetFocusHandler(); + if (handler.get()) { + is_in_onsetfocus_ = true; + bool handled = handler->OnSetFocus(this, source); + is_in_onsetfocus_ = false; + + if (handled) + return; + } + } + } + + if (web_contents_.get()) + web_contents_->GetView()->Focus(); + } else { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefBrowserHostImpl::OnSetFocus, this, source)); + } +} + +void CefBrowserHostImpl::RunFileChooser( + const content::FileChooserParams& params, + const RunFileChooserCallback& callback) { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefBrowserHostImpl::RunFileChooserOnUIThread, this, params, + callback)); +} + + +// content::WebContentsDelegate methods. +// ----------------------------------------------------------------------------- + +content::WebContents* CefBrowserHostImpl::OpenURLFromTab( + content::WebContents* source, + const content::OpenURLParams& params) { + // Start the new navigation. + CefNavigateParams nav_params(params.url, params.transition); + nav_params.referrer = params.referrer; + nav_params.frame_id = params.source_frame_id; + nav_params.disposition = params.disposition; + nav_params.user_gesture = true; + nav_params.override_encoding = params.override_encoding; + nav_params.is_renderer_initiated = params.is_renderer_initiated; + nav_params.transferred_global_request_id = + params.transferred_global_request_id; + Navigate(nav_params); + + return source; +} + +void CefBrowserHostImpl::LoadingStateChanged(content::WebContents* source) { + int current_index = web_contents_->GetController().GetCurrentEntryIndex(); + int max_index = web_contents_->GetController().GetEntryCount() - 1; + + bool is_loading, can_go_back, can_go_forward; + + { + base::AutoLock lock_scope(state_lock_); + is_loading = is_loading_ = web_contents_->IsLoading(); + can_go_back = can_go_back_ = (current_index > 0); + can_go_forward = can_go_forward_ = (current_index < max_index); + } + + if (client_.get()) { + CefRefPtr handler = client_->GetDisplayHandler(); + if (handler.get()) { + handler->OnLoadingStateChange(this, is_loading, can_go_back, + can_go_forward); + } + } +} + +void CefBrowserHostImpl::CloseContents(content::WebContents* source) { + if (destruction_state_ == DESTRUCTION_STATE_COMPLETED) + return; + + bool close_browser = true; + + // If this method is called in response to something other than + // WindowDestroyed() ask the user if the browser should close. + if (IsWindowRenderingDisabled() || !window_destroyed_) { + CefRefPtr handler = + client_->GetLifeSpanHandler(); + if (handler.get()) { + close_browser = !handler->DoClose(this); + } + } + + if (close_browser) { + if (destruction_state_ != DESTRUCTION_STATE_ACCEPTED) + destruction_state_ = DESTRUCTION_STATE_ACCEPTED; + + if (!IsWindowRenderingDisabled() && !window_destroyed_) { + // A window exists so try to close it using the platform method. Will + // result in a call to WindowDestroyed() if/when the window is destroyed + // via the platform window destruction mechanism. + PlatformCloseWindow(); + } else { + // No window exists. Destroy the browser immediately. + DestroyBrowser(); + if (!IsWindowRenderingDisabled()) { + // Release the reference added in PlatformCreateWindow(). + Release(); + } + } + } else if (destruction_state_ != DESTRUCTION_STATE_NONE) { + destruction_state_ = DESTRUCTION_STATE_NONE; + } +} + +void CefBrowserHostImpl::UpdateTargetURL(content::WebContents* source, + int32 page_id, + const GURL& url) { + if (client_.get()) { + CefRefPtr handler = client_->GetDisplayHandler(); + if (handler.get()) + handler->OnStatusMessage(this, url.spec()); + } +} + +bool CefBrowserHostImpl::AddMessageToConsole(content::WebContents* source, + int32 level, + const string16& message, + int32 line_no, + const string16& source_id) { + if (client_.get()) { + CefRefPtr handler = client_->GetDisplayHandler(); + if (handler.get()) + return handler->OnConsoleMessage(this, message, source_id, line_no); + } + + return false; +} + +void CefBrowserHostImpl::BeforeUnloadFired(content::WebContents* source, + bool proceed, + bool* proceed_to_fire_unload) { + if (destruction_state_ == DESTRUCTION_STATE_ACCEPTED || proceed) { + *proceed_to_fire_unload = true; + } else if (!proceed) { + *proceed_to_fire_unload = false; + destruction_state_ = DESTRUCTION_STATE_NONE; + } +} + +bool CefBrowserHostImpl::TakeFocus(content::WebContents* source, + bool reverse) { + if (client_.get()) { + CefRefPtr handler = client_->GetFocusHandler(); + if (handler.get()) + handler->OnTakeFocus(this, !reverse); + } + + return false; +} + +void CefBrowserHostImpl::WebContentsFocused(content::WebContents* contents) { + if (client_.get()) { + CefRefPtr handler = client_->GetFocusHandler(); + if (handler.get()) + handler->OnGotFocus(this); + } +} + +bool CefBrowserHostImpl::HandleContextMenu( + const content::ContextMenuParams& params) { + if (!menu_creator_.get()) + menu_creator_.reset(new CefMenuCreator(this)); + return menu_creator_->CreateContextMenu(params); +} + +bool CefBrowserHostImpl::PreHandleKeyboardEvent( + content::WebContents* source, + const content::NativeWebKeyboardEvent& event, + bool* is_keyboard_shortcut) { + if (client_.get()) { + CefRefPtr handler = client_->GetKeyboardHandler(); + if (handler.get()) { + CefKeyEvent cef_event; + if (!GetCefKeyEvent(event, cef_event)) + return false; + +#if defined(OS_WIN) + CefEventHandle os_event = const_cast(&event.os_event); +#else + CefEventHandle os_event = event.os_event; +#endif + + cef_event.focus_on_editable_field = focus_on_editable_field_; + + return handler->OnPreKeyEvent(this, cef_event, os_event, + is_keyboard_shortcut); + } + } + + return false; +} + +void CefBrowserHostImpl::HandleKeyboardEvent( + content::WebContents* source, + const content::NativeWebKeyboardEvent& event) { + // Check to see if event should be ignored. + if (event.skip_in_browser) + return; + + if (client_.get()) { + CefRefPtr handler = client_->GetKeyboardHandler(); + if (handler.get()) { + CefKeyEvent cef_event; + if (GetCefKeyEvent(event, cef_event)) { +#if defined(OS_WIN) + CefEventHandle os_event = const_cast(&event.os_event); +#else + CefEventHandle os_event = event.os_event; +#endif + + cef_event.focus_on_editable_field = focus_on_editable_field_; + + if (handler->OnKeyEvent(this, cef_event, os_event)) + return; + } + } + } + + PlatformHandleKeyboardEvent(event); +} + +bool CefBrowserHostImpl::ShouldCreateWebContents( + content::WebContents* web_contents, + int route_id, + WindowContainerType window_container_type, + const string16& frame_name, + const GURL& target_url) { + CefContentBrowserClient::Get()->GetOrCreateBrowserInfo( + web_contents->GetRenderProcessHost()->GetID(), route_id); + + base::AutoLock lock_scope(pending_popup_info_lock_); + DCHECK(pending_popup_info_.get()); + _Context->browser_context()->set_use_osr_next_contents_view( + IsWindowRenderingDisabled(pending_popup_info_->window_info)); + + return true; +} + +void CefBrowserHostImpl::WebContentsCreated( + content::WebContents* source_contents, + int64 source_frame_id, + const string16& frame_name, + const GURL& target_url, + content::WebContents* new_contents) { + scoped_ptr pending_popup_info; + { + base::AutoLock lock_scope(pending_popup_info_lock_); + pending_popup_info.reset(pending_popup_info_.release()); + } + DCHECK(pending_popup_info.get()); + + CefWindowHandle opener = NULL; + scoped_refptr info = + CefContentBrowserClient::Get()->GetBrowserInfo( + new_contents->GetRenderProcessHost()->GetID(), + new_contents->GetRoutingID()); + + if (source_contents) { + DCHECK(info->is_popup()); + opener = GetBrowserForContents(source_contents)->GetWindowHandle(); + } else { + DCHECK(!info->is_popup()); + } + + CefRefPtr browser = CefBrowserHostImpl::Create( + pending_popup_info->window_info, pending_popup_info->settings, + pending_popup_info->client, new_contents, info, opener); +} + +void CefBrowserHostImpl::DidNavigateMainFramePostCommit( + content::WebContents* tab) { + base::AutoLock lock_scope(state_lock_); + has_document_ = false; +} + +content::JavaScriptDialogManager* + CefBrowserHostImpl::GetJavaScriptDialogManager() { + if (!dialog_manager_.get()) + dialog_manager_.reset(new CefJavaScriptDialogManager(this)); + return dialog_manager_.get(); +} + +void CefBrowserHostImpl::RunFileChooser( + content::WebContents* tab, + const content::FileChooserParams& params) { + content::RenderViewHost* render_view_host = tab->GetRenderViewHost(); + if (!render_view_host) + return; + + RunFileChooserOnUIThread(params, + base::Bind(&CefBrowserHostImpl::OnRunFileChooserDelegateCallback, this, + tab)); +} + +bool CefBrowserHostImpl::SetPendingPopupInfo( + scoped_ptr info) { + base::AutoLock lock_scope(pending_popup_info_lock_); + if (pending_popup_info_.get()) + return false; + pending_popup_info_.reset(info.release()); + return true; +} + +void CefBrowserHostImpl::UpdatePreferredSize(content::WebContents* source, + const gfx::Size& pref_size) { + PlatformSizeTo(pref_size.width(), pref_size.height()); +} + +void CefBrowserHostImpl::RequestMediaAccessPermission( + content::WebContents* web_contents, + const content::MediaStreamRequest& request, + const content::MediaResponseCallback& callback) { + CEF_CURRENTLY_ON_UIT(); + + content::MediaStreamDevices devices; + + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + if (!command_line.HasSwitch(switches::kEnableMediaStream)) { + // Cancel the request. + callback.Run(devices); + return; + } + + // Based on chrome/browser/media/media_stream_devices_controller.cc + bool microphone_requested = + (request.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE); + bool webcam_requested = + (request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE); + if (microphone_requested || webcam_requested) { + switch (request.request_type) { + case content::MEDIA_OPEN_DEVICE: + // For open device request pick the desired device or fall back to the + // first available of the given type. + CefMediaCaptureDevicesDispatcher::GetInstance()->GetRequestedDevice( + request.requested_device_id, + microphone_requested, + webcam_requested, + &devices); + break; + case content::MEDIA_DEVICE_ACCESS: + case content::MEDIA_GENERATE_STREAM: + case content::MEDIA_ENUMERATE_DEVICES: + // Get the default devices for the request. + CefMediaCaptureDevicesDispatcher::GetInstance()-> + GetDefaultDevices(_Context->pref_service(), + microphone_requested, + webcam_requested, + &devices); + break; + } + } + + callback.Run(devices); +} + + +// content::WebContentsObserver methods. +// ----------------------------------------------------------------------------- + +void CefBrowserHostImpl::RenderViewCreated( + content::RenderViewHost* render_view_host) { + // When navigating cross-origin the new (pending) RenderViewHost will be + // created before the old (current) RenderViewHost is destroyed. It may be + // necessary in the future to track both current and pending render IDs. + browser_info_->set_render_ids(render_view_host->GetProcess()->GetID(), + render_view_host->GetRoutingID()); + + // Update the DevTools URLs, if any. + CefDevToolsDelegate* devtools_delegate = _Context->devtools_delegate(); + if (devtools_delegate) { + base::AutoLock lock_scope(state_lock_); + devtools_url_http_ = + devtools_delegate->GetDevToolsURL(render_view_host, true); + devtools_url_chrome_ = + devtools_delegate->GetDevToolsURL(render_view_host, false); + } + + // May be already registered if the renderer crashed previously. + if (!registrar_->IsRegistered( + this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, + content::Source(render_view_host))) { + registrar_->Add(this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, + content::Source(render_view_host)); + } +} + +void CefBrowserHostImpl::RenderViewDeleted( + content::RenderViewHost* render_view_host) { + if (registrar_->IsRegistered( + this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, + content::Source(render_view_host))) { + registrar_->Remove(this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, + content::Source(render_view_host)); + } +} + +void CefBrowserHostImpl::RenderViewReady() { + // Send the queued messages. + queue_messages_ = false; + while (!queued_messages_.empty()) { + Send(queued_messages_.front()); + queued_messages_.pop(); + } +} + +void CefBrowserHostImpl::RenderViewGone(base::TerminationStatus status) { + queue_messages_ = true; + + cef_termination_status_t ts = TS_ABNORMAL_TERMINATION; + if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) + ts = TS_PROCESS_WAS_KILLED; + else if (status == base::TERMINATION_STATUS_PROCESS_CRASHED) + ts = TS_PROCESS_CRASHED; + else if (status != base::TERMINATION_STATUS_ABNORMAL_TERMINATION) + return; + + if (client_.get()) { + CefRefPtr handler = client_->GetLoadHandler(); + if (handler.get()) + handler->OnRenderProcessTerminated(this, ts); + } +} + +void CefBrowserHostImpl::DidCommitProvisionalLoadForFrame( + int64 frame_id, + bool is_main_frame, + const GURL& url, + content::PageTransition transition_type, + content::RenderViewHost* render_view_host) { + CefRefPtr frame = GetOrCreateFrame(frame_id, + CefFrameHostImpl::kUnspecifiedFrameId, is_main_frame, string16(), url); + OnLoadStart(frame, url, transition_type); + if (is_main_frame) + OnAddressChange(frame, url); +} + +void CefBrowserHostImpl::DidFailProvisionalLoad( + int64 frame_id, + bool is_main_frame, + const GURL& validated_url, + int error_code, + const string16& error_description, + content::RenderViewHost* render_view_host) { + CefRefPtr frame = GetOrCreateFrame(frame_id, + CefFrameHostImpl::kUnspecifiedFrameId, is_main_frame, string16(), + validated_url); + OnLoadError(frame, validated_url, error_code, error_description); +} + +void CefBrowserHostImpl::DocumentAvailableInMainFrame() { + base::AutoLock lock_scope(state_lock_); + has_document_ = true; +} + +void CefBrowserHostImpl::DidFailLoad( + int64 frame_id, + const GURL& validated_url, + bool is_main_frame, + int error_code, + const string16& error_description, + content::RenderViewHost* render_view_host) { + CefRefPtr frame = GetOrCreateFrame(frame_id, + CefFrameHostImpl::kUnspecifiedFrameId, is_main_frame, string16(), + validated_url); + OnLoadError(frame, validated_url, error_code, error_description); + OnLoadEnd(frame, validated_url, error_code); +} + +void CefBrowserHostImpl::PluginCrashed(const base::FilePath& plugin_path, + base::ProcessId plugin_pid) { + if (client_.get()) { + CefRefPtr handler = client_->GetLoadHandler(); + if (handler.get()) + handler->OnPluginCrashed(this, plugin_path.value()); + } +} + +bool CefBrowserHostImpl::OnMessageReceived(const IPC::Message& message) { + // Handle the cursor message here if mouse cursor change is disabled instead + // of propegating the message to the normal handler. + if (message.type() == ViewHostMsg_SetCursor::ID) + return IsMouseCursorChangeDisabled(); + + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(CefBrowserHostImpl, message) + IPC_MESSAGE_HANDLER(CefHostMsg_FrameIdentified, OnFrameIdentified) + IPC_MESSAGE_HANDLER(CefHostMsg_FrameDetached, DetachFrame) + IPC_MESSAGE_HANDLER(CefHostMsg_FrameFocusChange, SetFocusedFrame) + IPC_MESSAGE_HANDLER(CefHostMsg_DidFinishLoad, OnDidFinishLoad) + IPC_MESSAGE_HANDLER(CefHostMsg_LoadingURLChange, OnLoadingURLChange) + IPC_MESSAGE_HANDLER(CefHostMsg_Request, OnRequest) + IPC_MESSAGE_HANDLER(CefHostMsg_Response, OnResponse) + IPC_MESSAGE_HANDLER(CefHostMsg_ResponseAck, OnResponseAck) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + +bool CefBrowserHostImpl::Send(IPC::Message* message) { + if (CEF_CURRENTLY_ON_UIT()) { + if (queue_messages_) { + queued_messages_.push(message); + return true; + } else { + return content::WebContentsObserver::Send(message); + } + } else { + CEF_POST_TASK(CEF_UIT, + base::Bind(base::IgnoreResult(&CefBrowserHostImpl::Send), this, + message)); + return true; + } +} + + +// content::WebContentsObserver::OnMessageReceived() message handlers. +// ----------------------------------------------------------------------------- + +void CefBrowserHostImpl::OnFrameIdentified(int64 frame_id, + int64 parent_frame_id, + string16 name) { + bool is_main_frame = (parent_frame_id == CefFrameHostImpl::kMainFrameId); + GetOrCreateFrame(frame_id, parent_frame_id, is_main_frame, name, GURL()); +} + +void CefBrowserHostImpl::OnDidFinishLoad(int64 frame_id, + const GURL& validated_url, + bool is_main_frame, + int http_status_code) { + CefRefPtr frame = GetOrCreateFrame(frame_id, + CefFrameHostImpl::kUnspecifiedFrameId, is_main_frame, string16(), + validated_url); + + // Give internal scheme handlers an opportunity to update content. + scheme::DidFinishLoad(frame, validated_url); + + OnLoadEnd(frame, validated_url, http_status_code); +} + +void CefBrowserHostImpl::OnLoadingURLChange(const GURL& loading_url) { + base::AutoLock lock_scope(state_lock_); + loading_url_ = loading_url; +} + +void CefBrowserHostImpl::OnRequest(const Cef_Request_Params& params) { + bool success = false; + std::string response; + bool expect_response_ack = false; + + if (params.user_initiated) { + // Give the user a chance to handle the request. + if (client_.get()) { + CefRefPtr message( + new CefProcessMessageImpl(const_cast(¶ms), + false, true)); + success = client_->OnProcessMessageReceived(this, PID_RENDERER, + message.get()); + message->Detach(NULL); + } + } else if (params.name == scheme::kChromeProcessMessage) { + scheme::OnChromeProcessMessage(this, params.arguments); + } else { + // Invalid request. + NOTREACHED(); + } + + if (params.expect_response) { + DCHECK_GE(params.request_id, 0); + + // Send a response to the renderer. + Cef_Response_Params response_params; + response_params.request_id = params.request_id; + response_params.success = success; + response_params.response = response; + response_params.expect_response_ack = expect_response_ack; + Send(new CefMsg_Response(routing_id(), response_params)); + } +} + +void CefBrowserHostImpl::OnResponse(const Cef_Response_Params& params) { + response_manager_->RunHandler(params); + if (params.expect_response_ack) + Send(new CefMsg_ResponseAck(routing_id(), params.request_id)); +} + +void CefBrowserHostImpl::OnResponseAck(int request_id) { + response_manager_->RunAckHandler(request_id); +} + + +// content::NotificationObserver methods. +// ----------------------------------------------------------------------------- + +void CefBrowserHostImpl::Observe(int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) { + DCHECK(type == content::NOTIFICATION_LOAD_STOP || + type == content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE || + type == content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED); + + if (type == content::NOTIFICATION_LOAD_STOP || + type == content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED) { + string16 title; + + if (type == content::NOTIFICATION_LOAD_STOP) { + content::NavigationController* controller = + content::Source(source).ptr(); + title = controller->GetWebContents()->GetTitle(); + } else { + content::WebContents* web_contents = + content::Source(source).ptr(); + title = web_contents->GetTitle(); + } + + // Don't notify if the title hasn't changed. + if (title == title_) + return; + + title_ = title; + + if (client_.get()) { + CefRefPtr handler = client_->GetDisplayHandler(); + if (handler.get()) + handler->OnTitleChange(this, title); + } + } else if (type == content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE) { + focus_on_editable_field_ = *content::Details(details).ptr(); + } +} + + +// CefBrowserHostImpl private methods. +// ----------------------------------------------------------------------------- + +CefBrowserHostImpl::CefBrowserHostImpl( + const CefWindowInfo& window_info, + const CefBrowserSettings& settings, + CefRefPtr client, + content::WebContents* web_contents, + scoped_refptr browser_info, + CefWindowHandle opener) + : content::WebContentsObserver(web_contents), + window_info_(window_info), + settings_(settings), + client_(client), + browser_info_(browser_info), + opener_(opener), + is_loading_(false), + can_go_back_(false), + can_go_forward_(false), + has_document_(false), + queue_messages_(true), + main_frame_id_(CefFrameHostImpl::kInvalidFrameId), + focused_frame_id_(CefFrameHostImpl::kInvalidFrameId), + destruction_state_(DESTRUCTION_STATE_NONE), + window_destroyed_(false), + is_in_onsetfocus_(false), + focus_on_editable_field_(false), + mouse_cursor_change_disabled_(false), + file_chooser_pending_(false) { + DCHECK(!browser_info_->browser().get()); + browser_info_->set_browser(this); + + web_contents_.reset(web_contents); + web_contents->SetDelegate(this); + + registrar_.reset(new content::NotificationRegistrar); + registrar_->Add(this, content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, + content::Source(web_contents)); + + // When navigating through the history, the restored NavigationEntry's title + // will be used. If the entry ends up having the same title after we return + // to it, as will usually be the case, the + // NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED will then be suppressed, since the + // NavigationEntry's title hasn't changed. + registrar_->Add(this, content::NOTIFICATION_LOAD_STOP, + content::Source( + &web_contents->GetController())); + + response_manager_.reset(new CefResponseManager); + + placeholder_frame_ = + new CefFrameHostImpl(this, CefFrameHostImpl::kInvalidFrameId, true); + + // Make sure RenderViewCreated is called at least one time. + RenderViewCreated(web_contents->GetRenderViewHost()); +} + +CefRefPtr CefBrowserHostImpl::GetOrCreateFrame( + int64 frame_id, int64 parent_frame_id, bool is_main_frame, + string16 frame_name, const GURL& frame_url) { + DCHECK(frame_id > CefFrameHostImpl::kInvalidFrameId); + if (frame_id <= CefFrameHostImpl::kInvalidFrameId) + return NULL; + + CefString url; + if (frame_url.is_valid()) + url = frame_url.spec(); + + CefString name; + if (!frame_name.empty()) + name = frame_name; + + base::AutoLock lock_scope(state_lock_); + + if (is_main_frame) + main_frame_id_ = frame_id; + + CefRefPtr frame; + + // Check if a frame object already exists. + FrameMap::const_iterator it = frames_.find(frame_id); + if (it != frames_.end()) + frame = it->second.get(); + + if (!frame.get()) { + // Create a new frame object. + frame = new CefFrameHostImpl(this, frame_id, is_main_frame); + frames_.insert(std::make_pair(frame_id, frame)); + } + + if (!url.empty()) + frame->SetURL(url); + if (!name.empty()) + frame->SetName(name); + if (parent_frame_id != CefFrameHostImpl::kUnspecifiedFrameId) + frame->SetParentId(parent_frame_id); + + return frame.get(); +} + +void CefBrowserHostImpl::DetachFrame(int64 frame_id) { + base::AutoLock lock_scope(state_lock_); + + FrameMap::iterator it = frames_.find(frame_id); + if (it != frames_.end()) { + it->second->Detach(); + frames_.erase(it); + } + + if (main_frame_id_ == frame_id) + main_frame_id_ = CefFrameHostImpl::kInvalidFrameId; + if (focused_frame_id_ == frame_id) + focused_frame_id_ = CefFrameHostImpl::kInvalidFrameId; +} + +void CefBrowserHostImpl::DetachAllFrames() { + base::AutoLock lock_scope(state_lock_); + + FrameMap::const_iterator it = frames_.begin(); + for (; it != frames_.end(); ++it) + it->second->Detach(); + + frames_.clear(); + + if (main_frame_id_ != CefFrameHostImpl::kInvalidFrameId) + main_frame_id_ = CefFrameHostImpl::kInvalidFrameId; + if (focused_frame_id_ != CefFrameHostImpl::kInvalidFrameId) + focused_frame_id_ = CefFrameHostImpl::kInvalidFrameId; +} + +void CefBrowserHostImpl::SetFocusedFrame(int64 frame_id) { + base::AutoLock lock_scope(state_lock_); + + if (focused_frame_id_ != CefFrameHostImpl::kInvalidFrameId) { + // Unfocus the previously focused frame. + FrameMap::const_iterator it = frames_.find(frame_id); + if (it != frames_.end()) + it->second->SetFocused(false); + } + + if (frame_id != CefFrameHostImpl::kInvalidFrameId) { + // Focus the newly focused frame. + FrameMap::iterator it = frames_.find(frame_id); + if (it != frames_.end()) { + it->second->SetFocused(true); + focused_frame_id_ = frame_id; + return; + } + } + + // No valid frame found. + focused_frame_id_ = CefFrameHostImpl::kInvalidFrameId; +} + +void CefBrowserHostImpl::OnAddressChange(CefRefPtr frame, + const GURL& url) { + if (client_.get()) { + CefRefPtr handler = client_->GetDisplayHandler(); + if (handler.get()) { + // Notify the handler of an address change. + handler->OnAddressChange(this, GetMainFrame(), url.spec()); + } + } +} + +void CefBrowserHostImpl::OnLoadStart(CefRefPtr frame, + const GURL& url, + content::PageTransition transition_type) { + if (client_.get()) { + CefRefPtr handler = client_->GetLoadHandler(); + if (handler.get()) { + // Notify the handler that loading has started. + handler->OnLoadStart(this, frame); + } + } +} + +void CefBrowserHostImpl::OnLoadError(CefRefPtr frame, + const GURL& url, + int error_code, + const string16& error_description) { + if (client_.get()) { + CefRefPtr handler = client_->GetLoadHandler(); + if (handler.get()) { + // Notify the handler that loading has failed. + handler->OnLoadError(this, frame, + static_cast(error_code), + CefString(error_description), + url.spec()); + } + } +} + +void CefBrowserHostImpl::OnLoadEnd(CefRefPtr frame, + const GURL& url, + int http_status_code) { + if (client_.get()) { + CefRefPtr handler = client_->GetLoadHandler(); + if (handler.get()) + handler->OnLoadEnd(this, frame, http_status_code); + } +} + +void CefBrowserHostImpl::RunFileChooserOnUIThread( + const content::FileChooserParams& params, + const RunFileChooserCallback& callback) { + CEF_REQUIRE_UIT(); + + if (file_chooser_pending_) { + // Dismiss the new dialog immediately. + callback.Run(std::vector()); + return; + } + + if (params.mode == content::FileChooserParams::OpenFolder) { + NOTIMPLEMENTED(); + callback.Run(std::vector()); + return; + } + + file_chooser_pending_ = true; + + // Ensure that the |file_chooser_pending_| flag is cleared. + const RunFileChooserCallback& host_callback = + base::Bind(&CefBrowserHostImpl::OnRunFileChooserCallback, this, callback); + + bool handled = false; + + if (client_.get()) { + CefRefPtr handler = client_->GetDialogHandler(); + if (handler.get()) { + cef_file_dialog_mode_t mode = FILE_DIALOG_OPEN; + switch (params.mode) { + case content::FileChooserParams::Open: + mode = FILE_DIALOG_OPEN; + break; + case content::FileChooserParams::OpenMultiple: + mode = FILE_DIALOG_OPEN_MULTIPLE; + break; + case content::FileChooserParams::Save: + mode = FILE_DIALOG_SAVE; + break; + default: + NOTREACHED(); + break; + } + + std::vector accept_types; + std::vector::const_iterator it = params.accept_types.begin(); + for (; it != params.accept_types.end(); ++it) + accept_types.push_back(*it); + + CefRefPtr callbackImpl( + new CefFileDialogCallbackImpl(host_callback)); + handled = handler->OnFileDialog(this, mode, params.title, + params.default_file_name.value(), + accept_types, callbackImpl.get()); + if (!handled) { + if (callbackImpl->IsConnected()) { + callbackImpl->Disconnect(); + } else { + // User executed the callback even though they returned false. + NOTREACHED(); + handled = true; + } + } + } + } + + if (!handled) + PlatformRunFileChooser(params, host_callback); +} + +void CefBrowserHostImpl::OnRunFileChooserCallback( + const RunFileChooserCallback& callback, + const std::vector& file_paths) { + CEF_REQUIRE_UIT(); + + file_chooser_pending_ = false; + + // Execute the callback asynchronously. + CEF_POST_TASK(CEF_UIT, base::Bind(callback, file_paths)); +} + +void CefBrowserHostImpl::OnRunFileChooserDelegateCallback( + content::WebContents* tab, + const std::vector& file_paths) { + CEF_REQUIRE_UIT(); + + content::RenderViewHost* render_view_host = tab->GetRenderViewHost(); + if (!render_view_host) + return; + + const int kReadFilePermissions = + base::PLATFORM_FILE_OPEN | + base::PLATFORM_FILE_READ | + base::PLATFORM_FILE_EXCLUSIVE_READ | + base::PLATFORM_FILE_ASYNC; + + // Convert FilePath list to SelectedFileInfo list. + std::vector selected_files; + for (size_t i = 0; i < file_paths.size(); ++i) { + selected_files.push_back( + ui::SelectedFileInfo(file_paths[i], base::FilePath())); + } + + // Notify our RenderViewHost in all cases. + render_view_host->FilesSelectedInChooser(selected_files, + kReadFilePermissions); +} diff --git a/cef3/libcef/browser/browser_host_impl.h b/cef3/libcef/browser/browser_host_impl.h new file mode 100644 index 000000000..6b6b01813 --- /dev/null +++ b/cef3/libcef/browser/browser_host_impl.h @@ -0,0 +1,544 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 The Chromium 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_LIBCEF_BROWSER_BROWSER_HOST_IMPL_H_ +#define CEF_LIBCEF_BROWSER_BROWSER_HOST_IMPL_H_ +#pragma once + +#include +#include +#include +#include + +#include "include/cef_browser.h" +#include "include/cef_client.h" +#include "include/cef_frame.h" +#include "libcef/browser/frame_host_impl.h" +#include "libcef/browser/javascript_dialog_manager.h" +#include "libcef/browser/menu_creator.h" +#include "libcef/common/response_manager.h" + +#include "base/memory/scoped_ptr.h" +#include "base/string16.h" +#include "base/synchronization/lock.h" +#include "content/public/browser/notification_observer.h" +#include "content/public/browser/notification_registrar.h" +#include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_delegate.h" +#include "content/public/browser/web_contents_observer.h" +#include "net/url_request/url_request_context_getter.h" + +namespace content { +struct NativeWebKeyboardEvent; +} + +namespace WebKit { +class WebMouseEvent; +class WebMouseWheelEvent; +class WebInputEvent; +} + +namespace net { +class URLRequest; +} + +struct Cef_Request_Params; +struct Cef_Response_Params; +class CefBrowserInfo; +struct CefNavigateParams; +class SiteInstance; + +// Implementation of CefBrowser. +// +// WebContentsDelegate: Interface for handling WebContents delegations. There is +// a one-to-one relationship between CefBrowserHostImpl and WebContents +// instances. +// +// WebContentsObserver: Interface for observing WebContents notifications and +// IPC messages. There is a one-to-one relationship between WebContents and +// RenderViewHost instances. IPC messages received by the RenderViewHost will be +// forwarded to this WebContentsObserver implementation via WebContents. IPC +// messages sent using CefBrowserHostImpl::Send() will be forwarded to the +// RenderViewHost (after posting to the UI thread if necessary). Use +// WebContentsObserver::routing_id() when sending IPC messages. +// +// NotificationObserver: Interface for observing post-processed notifications. +class CefBrowserHostImpl : public CefBrowserHost, + public CefBrowser, + public content::WebContentsDelegate, + public content::WebContentsObserver, + public content::NotificationObserver { + public: + // Used for handling the response to command messages. + class CommandResponseHandler : public virtual CefBase { + public: + virtual void OnResponse(const std::string& response) =0; + }; + + virtual ~CefBrowserHostImpl(); + + // Create a new CefBrowserHostImpl instance. + static CefRefPtr Create( + const CefWindowInfo& window_info, + const CefBrowserSettings& settings, + CefRefPtr client, + content::WebContents* web_contents, + scoped_refptr browser_info, + CefWindowHandle opener); + + // Returns the browser associated with the specified RenderViewHost. + static CefRefPtr GetBrowserForHost( + const content::RenderViewHost* host); + // Returns the browser associated with the specified WebContents. + static CefRefPtr GetBrowserForContents( + content::WebContents* contents); + // Returns the browser associated with the specified URLRequest. + static CefRefPtr GetBrowserForRequest( + net::URLRequest* request); + // Returns the browser associated with the specified routing IDs. + static CefRefPtr GetBrowserByRoutingID( + int render_process_id, int render_view_id); + // Returns the browser associated with the specified child process ID. + static CefRefPtr GetBrowserByChildID( + int render_process_id); + + // Returns true if window rendering is disabled in CefWindowInfo. + static bool IsWindowRenderingDisabled(const CefWindowInfo& info); + + // CefBrowserHost methods. + virtual CefRefPtr GetBrowser() OVERRIDE; + virtual void CloseBrowser(bool force_close) OVERRIDE; + virtual void ParentWindowWillClose() OVERRIDE; + virtual void SetFocus(bool enable) OVERRIDE; + virtual CefWindowHandle GetWindowHandle() OVERRIDE; + virtual CefWindowHandle GetOpenerWindowHandle() OVERRIDE; + virtual CefRefPtr GetClient() OVERRIDE; + virtual CefString GetDevToolsURL(bool http_scheme) OVERRIDE; + virtual double GetZoomLevel() OVERRIDE; + virtual void SetZoomLevel(double zoomLevel) OVERRIDE; + virtual void RunFileDialog( + FileDialogMode mode, + const CefString& title, + const CefString& default_file_name, + const std::vector& accept_types, + CefRefPtr callback) OVERRIDE; + virtual void StartDownload(const CefString& url) OVERRIDE; + virtual void SetMouseCursorChangeDisabled(bool disabled) OVERRIDE; + virtual bool IsMouseCursorChangeDisabled() OVERRIDE; + virtual bool IsWindowRenderingDisabled() OVERRIDE; + virtual void WasResized() OVERRIDE; + virtual void WasHidden(bool hidden) OVERRIDE; + virtual void Invalidate(const CefRect& dirtyRect, + PaintElementType type) OVERRIDE; + virtual void SendKeyEvent(const CefKeyEvent& event) OVERRIDE; + virtual void SendMouseClickEvent(const CefMouseEvent& event, + MouseButtonType type, + bool mouseUp, int clickCount) OVERRIDE; + virtual void SendMouseMoveEvent(const CefMouseEvent& event, + bool mouseLeave) OVERRIDE; + virtual void SendMouseWheelEvent(const CefMouseEvent& event, + int deltaX, int deltaY) OVERRIDE; + virtual void SendFocusEvent(bool setFocus) OVERRIDE; + virtual void SendCaptureLostEvent() OVERRIDE; + + // CefBrowser methods. + virtual CefRefPtr GetHost() OVERRIDE; + virtual bool CanGoBack() OVERRIDE; + virtual void GoBack() OVERRIDE; + virtual bool CanGoForward() OVERRIDE; + virtual void GoForward() OVERRIDE; + virtual bool IsLoading() OVERRIDE; + virtual void Reload() OVERRIDE; + virtual void ReloadIgnoreCache() OVERRIDE; + virtual void StopLoad() OVERRIDE; + virtual int GetIdentifier() OVERRIDE; + virtual bool IsSame(CefRefPtr that) OVERRIDE; + virtual bool IsPopup() OVERRIDE; + virtual bool HasDocument() OVERRIDE; + virtual CefRefPtr GetMainFrame() OVERRIDE; + virtual CefRefPtr GetFocusedFrame() OVERRIDE; + virtual CefRefPtr GetFrame(int64 identifier) OVERRIDE; + virtual CefRefPtr GetFrame(const CefString& name) OVERRIDE; + virtual size_t GetFrameCount() OVERRIDE; + virtual void GetFrameIdentifiers(std::vector& identifiers) OVERRIDE; + virtual void GetFrameNames(std::vector& names) OVERRIDE; + virtual bool SendProcessMessage( + CefProcessId target_process, + CefRefPtr message) OVERRIDE; + + // Called when the OS window hosting the browser is destroyed. + void WindowDestroyed(); + + // Destroy the browser members. This method should only be called after the + // native browser window is not longer processing messages. + void DestroyBrowser(); + + // Returns the native view for the WebContents. + gfx::NativeView GetContentView() const; + + // Returns a pointer to the WebContents. + content::WebContents* GetWebContents() const; + + // Returns the browser-specific request context. + net::URLRequestContextGetter* GetRequestContext(); + + // Returns the frame associated with the specified URLRequest. + CefRefPtr GetFrameForRequest(net::URLRequest* request); + + // Navigate as specified by the |params| argument. + void Navigate(const CefNavigateParams& params); + + // Load the specified request. + void LoadRequest(int64 frame_id, CefRefPtr request); + + // Load the specified URL. + void LoadURL(int64 frame_id, const std::string& url); + + // Load the specified string. + void LoadString(int64 frame_id, const std::string& string, + const std::string& url); + + // Send a command to the renderer for execution. + void SendCommand(int64 frame_id, const std::string& command, + CefRefPtr responseHandler); + + // Send code to the renderer for execution. + void SendCode(int64 frame_id, bool is_javascript, const std::string& code, + const std::string& script_url, int script_start_line, + CefRefPtr responseHandler); + + bool SendProcessMessage(CefProcessId target_process, + const std::string& name, + base::ListValue* arguments, + bool user_initiated); + + // Open the specified text in the default text editor. + bool ViewText(const std::string& text); + + // Handler for URLs involving external protocols. + void HandleExternalProtocol(const GURL& url); + + // Thread safe accessors. + const CefBrowserSettings& settings() const { return settings_; } + CefRefPtr client() const { return client_; } + int browser_id() const; + + // Returns the URL that is currently loading (or loaded) in the main frame. + GURL GetLoadingURL(); + + bool IsTransparent(); + +#if defined(OS_WIN) + static void RegisterWindowClass(); +#endif + + void OnSetFocus(cef_focus_source_t source); + + // The argument vector will be empty if the dialog was cancelled. + typedef base::Callback&)> + RunFileChooserCallback; + + // Run the file chooser dialog specified by |params|. Only a single dialog may + // be pending at any given time. |callback| will be executed asynchronously + // after the dialog is dismissed or if another dialog is already pending. + void RunFileChooser(const content::FileChooserParams& params, + const RunFileChooserCallback& callback); + + // Used when creating a new popup window. + struct PendingPopupInfo { + CefWindowInfo window_info; + CefBrowserSettings settings; + CefRefPtr client; + }; + // Returns false if a popup is already pending. + bool SetPendingPopupInfo(scoped_ptr info); + + enum DestructionState { + DESTRUCTION_STATE_NONE = 0, + DESTRUCTION_STATE_PENDING, + DESTRUCTION_STATE_ACCEPTED, + DESTRUCTION_STATE_COMPLETED + }; + DestructionState destruction_state() const { return destruction_state_; } + + private: + // content::WebContentsDelegate methods. + virtual content::WebContents* OpenURLFromTab( + content::WebContents* source, + const content::OpenURLParams& params) OVERRIDE; + virtual void LoadingStateChanged(content::WebContents* source) OVERRIDE; + virtual void CloseContents(content::WebContents* source) OVERRIDE; + virtual void UpdateTargetURL(content::WebContents* source, + int32 page_id, + const GURL& url) OVERRIDE; + virtual bool AddMessageToConsole(content::WebContents* source, + int32 level, + const string16& message, + int32 line_no, + const string16& source_id) OVERRIDE; + virtual void BeforeUnloadFired(content::WebContents* source, + bool proceed, + bool* proceed_to_fire_unload) OVERRIDE; + virtual bool TakeFocus(content::WebContents* source, + bool reverse) OVERRIDE; + virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE; + virtual bool HandleContextMenu(const content::ContextMenuParams& params) + OVERRIDE; + virtual bool PreHandleKeyboardEvent( + content::WebContents* source, + const content::NativeWebKeyboardEvent& event, + bool* is_keyboard_shortcut) OVERRIDE; + virtual void HandleKeyboardEvent( + content::WebContents* source, + const content::NativeWebKeyboardEvent& event) OVERRIDE; + virtual bool ShouldCreateWebContents( + content::WebContents* web_contents, + int route_id, + WindowContainerType window_container_type, + const string16& frame_name, + const GURL& target_url) OVERRIDE; + virtual void WebContentsCreated(content::WebContents* source_contents, + int64 source_frame_id, + const string16& frame_name, + const GURL& target_url, + content::WebContents* new_contents) OVERRIDE; + virtual void DidNavigateMainFramePostCommit( + content::WebContents* tab) OVERRIDE; + virtual content::JavaScriptDialogManager* GetJavaScriptDialogManager() + OVERRIDE; + virtual void RunFileChooser( + content::WebContents* tab, + const content::FileChooserParams& params) OVERRIDE; + virtual void UpdatePreferredSize(content::WebContents* source, + const gfx::Size& pref_size) OVERRIDE; + virtual void RequestMediaAccessPermission( + content::WebContents* web_contents, + const content::MediaStreamRequest& request, + const content::MediaResponseCallback& callback) OVERRIDE; + + // content::WebContentsObserver methods. + virtual void RenderViewCreated( + content::RenderViewHost* render_view_host) OVERRIDE; + virtual void RenderViewDeleted( + content::RenderViewHost* render_view_host) OVERRIDE; + virtual void RenderViewReady() OVERRIDE; + virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; + virtual void DidCommitProvisionalLoadForFrame( + int64 frame_id, + bool is_main_frame, + const GURL& url, + content::PageTransition transition_type, + content::RenderViewHost* render_view_host) OVERRIDE; + virtual void DidFailProvisionalLoad( + int64 frame_id, + bool is_main_frame, + const GURL& validated_url, + int error_code, + const string16& error_description, + content::RenderViewHost* render_view_host) OVERRIDE; + virtual void DocumentAvailableInMainFrame() OVERRIDE; + virtual void DidFailLoad(int64 frame_id, + const GURL& validated_url, + bool is_main_frame, + int error_code, + const string16& error_description, + content::RenderViewHost* render_view_host) OVERRIDE; + virtual void PluginCrashed(const base::FilePath& plugin_path, + base::ProcessId plugin_pid) OVERRIDE; + virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; + // Override to provide a thread safe implementation. + virtual bool Send(IPC::Message* message) OVERRIDE; + + // content::WebContentsObserver::OnMessageReceived() message handlers. + void OnFrameIdentified(int64 frame_id, int64 parent_frame_id, string16 name); + void OnDidFinishLoad( + int64 frame_id, + const GURL& validated_url, + bool is_main_frame, + int http_status_code); + void OnLoadingURLChange(const GURL& pending_url); + void OnRequest(const Cef_Request_Params& params); + void OnResponse(const Cef_Response_Params& params); + void OnResponseAck(int request_id); + + // content::NotificationObserver methods. + virtual void Observe(int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) OVERRIDE; + + CefBrowserHostImpl(const CefWindowInfo& window_info, + const CefBrowserSettings& settings, + CefRefPtr client, + content::WebContents* web_contents, + scoped_refptr browser_info, + CefWindowHandle opener); + + // Updates and returns an existing frame or creates a new frame. Pass + // CefFrameHostImpl::kUnspecifiedFrameId for |parent_frame_id| if unknown. + CefRefPtr GetOrCreateFrame(int64 frame_id, + int64 parent_frame_id, + bool is_main_frame, + string16 frame_name, + const GURL& frame_url); + // Remove the reference to the frame and mark it as detached. + void DetachFrame(int64 frame_id); + // Remove the references to all frames and mark them as detached. + void DetachAllFrames(); + // Set the frame that currently has focus. + void SetFocusedFrame(int64 frame_id); + +#if defined(OS_WIN) + static LPCTSTR GetWndClass(); + static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, + WPARAM wParam, LPARAM lParam); +#endif + + // Create the window. + bool PlatformCreateWindow(); + // Sends a message via the OS to close the native browser window. + // DestroyBrowser will be called after the native window has closed. + void PlatformCloseWindow(); + // Resize the window to the given dimensions. + void PlatformSizeTo(int width, int height); + // Return the handle for this window. + CefWindowHandle PlatformGetWindowHandle(); + // Open the specified text in the default text editor. + bool PlatformViewText(const std::string& text); + // Forward the keyboard event to the application or frame window to allow + // processing of shortcut keys. + void PlatformHandleKeyboardEvent( + const content::NativeWebKeyboardEvent& event); + // Invoke platform specific handling for the external protocol. + void PlatformHandleExternalProtocol(const GURL& url); + // Invoke platform specific file chooser dialog. + void PlatformRunFileChooser(const content::FileChooserParams& params, + RunFileChooserCallback callback); + + void PlatformTranslateKeyEvent(content::NativeWebKeyboardEvent& native_event, + const CefKeyEvent& key_event); + void PlatformTranslateClickEvent(WebKit::WebMouseEvent& web_event, + const CefMouseEvent& mouse_event, + CefBrowserHost::MouseButtonType type, + bool mouseUp, int clickCount); + void PlatformTranslateMoveEvent(WebKit::WebMouseEvent& web_event, + const CefMouseEvent& mouse_event, + bool mouseLeave); + void PlatformTranslateWheelEvent(WebKit::WebMouseWheelEvent& web_event, + const CefMouseEvent& mouse_event, + int deltaX, int deltaY); + void PlatformTranslateMouseEvent(WebKit::WebMouseEvent& web_event, + const CefMouseEvent& mouse_event); + int TranslateModifiers(uint32 cefKeyStates); + void SendMouseEvent(const WebKit::WebMouseEvent& web_event); + + void OnAddressChange(CefRefPtr frame, + const GURL& url); + void OnLoadStart(CefRefPtr frame, + const GURL& url, + content::PageTransition transition_type); + void OnLoadError(CefRefPtr frame, + const GURL& url, + int error_code, + const string16& error_description); + void OnLoadEnd(CefRefPtr frame, + const GURL& url, + int http_status_code); + + // Continuation from RunFileChooser. + void RunFileChooserOnUIThread(const content::FileChooserParams& params, + const RunFileChooserCallback& callback); + + // Used with RunFileChooser to clear the |file_chooser_pending_| flag. + void OnRunFileChooserCallback(const RunFileChooserCallback& callback, + const std::vector& file_paths); + + // Used with WebContentsDelegate::RunFileChooser to notify the WebContents. + void OnRunFileChooserDelegateCallback( + content::WebContents* tab, + const std::vector& file_paths); + + CefWindowInfo window_info_; + CefBrowserSettings settings_; + CefRefPtr client_; + scoped_ptr web_contents_; + scoped_refptr browser_info_; + CefWindowHandle opener_; + + // Pending popup information. Access must be protected by + // |pending_popup_info_lock_|. + base::Lock pending_popup_info_lock_; + scoped_ptr pending_popup_info_; + + // Volatile state information. All access must be protected by the state lock. + base::Lock state_lock_; + bool is_loading_; + bool can_go_back_; + bool can_go_forward_; + bool has_document_; + GURL loading_url_; + CefString devtools_url_http_; + CefString devtools_url_chrome_; + + // Messages we queue while waiting for the RenderView to be ready. We queue + // them here instead of in the RenderProcessHost to ensure that they're sent + // after the CefRenderViewObserver has been created on the renderer side. + std::queue queued_messages_; + bool queue_messages_; + + // Map of unique frame ids to CefFrameHostImpl references. + typedef std::map > FrameMap; + FrameMap frames_; + // The unique frame id currently identified as the main frame. + int64 main_frame_id_; + // The unique frame id currently identified as the focused frame. + int64 focused_frame_id_; + // Used when no other frame exists. Provides limited functionality. + CefRefPtr placeholder_frame_; + + // Represents the current browser destruction state. Only accessed on the UI + // thread. + DestructionState destruction_state_; + + // True if the OS window hosting the browser has been destroyed. Only accessed + // on the UI thread. + bool window_destroyed_; + + // True if currently in the OnSetFocus callback. Only accessed on the UI + // thread. + bool is_in_onsetfocus_; + + // True if the focus is currently on an editable field on the page. Only + // accessed on the UI thread. + bool focus_on_editable_field_; + + // True if mouse cursor change is disabled. + bool mouse_cursor_change_disabled_; + + // Used for managing notification subscriptions. + scoped_ptr registrar_; + + // Used for proxying cookie requests. + scoped_refptr request_context_proxy_; + + // Manages response registrations. + scoped_ptr response_manager_; + + // Used for creating and managing JavaScript dialogs. + scoped_ptr dialog_manager_; + + // Used for creating and managing context menus. + scoped_ptr menu_creator_; + + // True if a file chooser is currently pending. + bool file_chooser_pending_; + + // Current title for the main frame. Only accessed on the UI thread. + string16 title_; + + IMPLEMENT_REFCOUNTING(CefBrowserHostImpl); + DISALLOW_EVIL_CONSTRUCTORS(CefBrowserHostImpl); +}; + +#endif // CEF_LIBCEF_BROWSER_BROWSER_HOST_IMPL_H_ diff --git a/cef3/libcef/browser/browser_host_impl_gtk.cc b/cef3/libcef/browser/browser_host_impl_gtk.cc new file mode 100644 index 000000000..2a7bf96b1 --- /dev/null +++ b/cef3/libcef/browser/browser_host_impl_gtk.cc @@ -0,0 +1,419 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 The Chromium 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 "libcef/browser/browser_host_impl.h" + +#include + +#include "libcef/browser/thread_util.h" + +#include "base/bind.h" +#include "base/utf_string_conversions.h" +#include "content/public/browser/web_contents_view.h" +#include "content/public/common/file_chooser_params.h" +#include "content/public/common/renderer_preferences.h" +#include "grit/cef_strings.h" +#include "grit/ui_strings.h" +#include "net/base/mime_util.h" +#include "ui/base/l10n/l10n_util.h" + +namespace { + +void DestroyBrowser(CefRefPtr browser) { + // Force the browser to be destroyed and release the reference added in + // PlatformCreateWindow(). + browser->WindowDestroyed(); +} + +void browser_destroy(GtkWidget* widget, CefBrowserHostImpl* browser) { + // Destroy the browser host after window destruction is complete. + CEF_POST_TASK(CEF_UIT, base::Bind(DestroyBrowser, browser)); +} + +void window_destroy(GtkWidget* widget, gpointer data) { +} + +gboolean window_delete_event(GtkWidget* widget, GdkEvent* event, + CefBrowserHostImpl* browser) { + // Protect against multiple requests to close while the close is pending. + if (browser && browser->destruction_state() <= + CefBrowserHostImpl::DESTRUCTION_STATE_PENDING) { + if (browser->destruction_state() == + CefBrowserHostImpl::DESTRUCTION_STATE_NONE) { + // Request that the browser close. + browser->CloseBrowser(false); + } + + // Cancel the close. + return TRUE; + } + + // Allow the close. + return FALSE; +} + +std::string GetDescriptionFromMimeType(const std::string& mime_type) { + // Check for wild card mime types and return an appropriate description. + static const struct { + const char* mime_type; + int string_id; + } kWildCardMimeTypes[] = { + { "audio", IDS_APP_AUDIO_FILES }, + { "image", IDS_APP_IMAGE_FILES }, + { "text", IDS_APP_TEXT_FILES }, + { "video", IDS_APP_VIDEO_FILES }, + }; + + for (size_t i = 0; + i < sizeof(kWildCardMimeTypes) / sizeof(kWildCardMimeTypes[0]); ++i) { + if (mime_type == std::string(kWildCardMimeTypes[i].mime_type) + "/*") + return l10n_util::GetStringUTF8(kWildCardMimeTypes[i].string_id); + } + + return std::string(); +} + +void AddFiltersForAcceptTypes(GtkFileChooser* chooser, + const std::vector& accept_types, + bool include_all_files) { + bool has_filter = false; + + for (size_t i = 0; i < accept_types.size(); ++i) { + std::string ascii_type = UTF16ToASCII(accept_types[i]); + if (ascii_type.length()) { + // Just treat as extension if contains '.' as the first character. + if (ascii_type[0] == '.') { + GtkFileFilter* filter = gtk_file_filter_new(); + std::string pattern = "*" + ascii_type; + gtk_file_filter_add_pattern(filter, pattern.c_str()); + gtk_file_filter_set_name(filter, pattern.c_str()); + gtk_file_chooser_add_filter(chooser, filter); + if (!has_filter) + has_filter = true; + } else { + // Otherwise convert mime type to one or more extensions. + GtkFileFilter* filter = NULL; + std::string description = GetDescriptionFromMimeType(ascii_type); + bool description_from_ext = description.empty(); + + std::vector ext; + net::GetExtensionsForMimeType(ascii_type, &ext); + for (size_t x = 0; x < ext.size(); ++x) { + if (!filter) + filter = gtk_file_filter_new(); + std::string pattern = "*." + ext[x]; + gtk_file_filter_add_pattern(filter, pattern.c_str()); + + if (description_from_ext) { + if (x != 0) + description += ";"; + description += pattern; + } + } + + if (filter) { + gtk_file_filter_set_name(filter, description.c_str()); + gtk_file_chooser_add_filter(chooser, filter); + if (!has_filter) + has_filter = true; + } + } + } + } + + // Add the *.* filter, but only if we have added other filters (otherwise it + // is implied). + if (include_all_files && has_filter) { + GtkFileFilter* filter = gtk_file_filter_new(); + gtk_file_filter_add_pattern(filter, "*"); + gtk_file_filter_set_name(filter, + l10n_util::GetStringUTF8(IDS_SAVEAS_ALL_FILES).c_str()); + gtk_file_chooser_add_filter(chooser, filter); + } +} + +bool RunFileDialog(const content::FileChooserParams& params, + CefWindowHandle widget, + std::vector* files) { + GtkFileChooserAction action; + const gchar* accept_button; + if (params.mode == content::FileChooserParams::Open || + params.mode == content::FileChooserParams::OpenMultiple) { + action = GTK_FILE_CHOOSER_ACTION_OPEN; + accept_button = GTK_STOCK_OPEN; + } else if (params.mode == content::FileChooserParams::Save) { + action = GTK_FILE_CHOOSER_ACTION_SAVE; + accept_button = GTK_STOCK_SAVE; + } else { + NOTREACHED(); + return false; + } + + // Consider default file name if any. + base::FilePath default_file_name(params.default_file_name); + + std::string base_name; + if (!default_file_name.empty()) + base_name = default_file_name.BaseName().value(); + + std::string title; + if (!params.title.empty()) { + title = UTF16ToUTF8(params.title); + } else { + int string_id = 0; + switch (params.mode) { + case content::FileChooserParams::Open: + string_id = IDS_OPEN_FILE_DIALOG_TITLE; + break; + case content::FileChooserParams::OpenMultiple: + string_id = IDS_OPEN_FILES_DIALOG_TITLE; + break; + case content::FileChooserParams::Save: + string_id = IDS_SAVE_AS_DIALOG_TITLE; + break; + default: + break; + } + title = l10n_util::GetStringUTF8(string_id); + } + + GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(widget)); + GtkWidget* dialog = gtk_file_chooser_dialog_new( + title.c_str(), + GTK_WINDOW(window), + action, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + accept_button, GTK_RESPONSE_ACCEPT, + NULL); + + if (params.mode == content::FileChooserParams::OpenMultiple) { + gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE); + } else if (params.mode == content::FileChooserParams::Save) { + gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), + TRUE); + } + + if (params.mode == content::FileChooserParams::Save && !base_name.empty()) { + gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), + base_name.c_str()); + } + + AddFiltersForAcceptTypes(GTK_FILE_CHOOSER(dialog), params.accept_types, true); + + bool success = false; + + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { + if (params.mode == content::FileChooserParams::Open || + params.mode == content::FileChooserParams::Save) { + char* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); + files->push_back(base::FilePath(filename)); + success = true; + } else if (params.mode == content::FileChooserParams::OpenMultiple) { + GSList* filenames = + gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog)); + if (filenames) { + for (GSList* iter = filenames; iter != NULL; + iter = g_slist_next(iter)) { + base::FilePath path(static_cast(iter->data)); + g_free(iter->data); + files->push_back(path); + } + g_slist_free(filenames); + success = true; + } + } + } + + gtk_widget_destroy(dialog); + + return success; +} + +} // namespace + +bool CefBrowserHostImpl::PlatformCreateWindow() { + GtkWidget* window; + GtkWidget* parentView = window_info_.parent_widget; + + if (parentView == NULL) { + // Create a new window. + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_default_size(GTK_WINDOW(window), 800, 600); + + parentView = gtk_vbox_new(FALSE, 0); + + gtk_container_add(GTK_CONTAINER(window), parentView); + gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); + gtk_widget_show_all(GTK_WIDGET(window)); + + g_signal_connect(G_OBJECT(window), "destroy", + G_CALLBACK(window_destroy), NULL); + g_signal_connect(G_OBJECT(window), "delete_event", + G_CALLBACK(window_delete_event), this); + + window_info_.parent_widget = parentView; + } + + // Add a reference that will be released in the destroy handler. + AddRef(); + + // Parent the TabContents to the browser window. + window_info_.widget = web_contents_->GetView()->GetNativeView(); + gtk_container_add(GTK_CONTAINER(window_info_.parent_widget), + window_info_.widget); + + g_signal_connect(G_OBJECT(window_info_.widget), "destroy", + G_CALLBACK(browser_destroy), this); + + // As an additional requirement on Linux, we must set the colors for the + // render widgets in webkit. + content::RendererPreferences* prefs = + web_contents_->GetMutableRendererPrefs(); + prefs->focus_ring_color = SkColorSetARGB(255, 229, 151, 0); + prefs->thumb_active_color = SkColorSetRGB(244, 244, 244); + prefs->thumb_inactive_color = SkColorSetRGB(234, 234, 234); + prefs->track_color = SkColorSetRGB(211, 211, 211); + + prefs->active_selection_bg_color = SkColorSetRGB(30, 144, 255); + prefs->active_selection_fg_color = SK_ColorWHITE; + prefs->inactive_selection_bg_color = SkColorSetRGB(200, 200, 200); + prefs->inactive_selection_fg_color = SkColorSetRGB(50, 50, 50); + + return true; +} + +void CefBrowserHostImpl::PlatformCloseWindow() { + if (window_info_.widget != NULL) { + GtkWidget* window = + gtk_widget_get_toplevel(GTK_WIDGET(window_info_.widget)); + + // Send the "delete_event" signal. + GdkEvent event; + memset(&event, 0, sizeof(GdkEvent)); + event.any.type = GDK_DELETE; + event.any.send_event = TRUE; + event.any.window = window->window; + gtk_main_do_event(&event); + } +} + +void CefBrowserHostImpl::PlatformSizeTo(int width, int height) { + if (window_info_.widget != NULL) { + GtkWidget* window = + gtk_widget_get_toplevel(GTK_WIDGET(window_info_.widget)); + gtk_widget_set_size_request(window, width, height); + } +} + +CefWindowHandle CefBrowserHostImpl::PlatformGetWindowHandle() { + return window_info_.widget; +} + +bool CefBrowserHostImpl::PlatformViewText(const std::string& text) { + CEF_REQUIRE_UIT(); + + char buff[] = "/tmp/CEFSourceXXXXXX"; + int fd = mkstemp(buff); + + if (fd == -1) + return false; + + FILE* srcOutput = fdopen(fd, "w+"); + if (!srcOutput) + return false; + + if (fputs(text.c_str(), srcOutput) < 0) { + fclose(srcOutput); + return false; + } + + fclose(srcOutput); + + std::string newName(buff); + newName.append(".txt"); + if (rename(buff, newName.c_str()) != 0) + return false; + + std::string openCommand("xdg-open "); + openCommand += newName; + + if (system(openCommand.c_str()) != 0) + return false; + + return true; +} + +void CefBrowserHostImpl::PlatformHandleKeyboardEvent( + const content::NativeWebKeyboardEvent& event) { + // TODO(cef): Is something required here to handle shortcut keys? +} + +void CefBrowserHostImpl::PlatformRunFileChooser( + const content::FileChooserParams& params, + RunFileChooserCallback callback) { + std::vector files; + + if (params.mode == content::FileChooserParams::Open || + params.mode == content::FileChooserParams::OpenMultiple || + params.mode == content::FileChooserParams::Save) { + ::RunFileDialog(params, PlatformGetWindowHandle(), &files); + } else { + NOTIMPLEMENTED(); + } + + callback.Run(files); +} + +void CefBrowserHostImpl::PlatformHandleExternalProtocol(const GURL& url) { +} + +// static +bool CefBrowserHostImpl::IsWindowRenderingDisabled(const CefWindowInfo& info) { + // TODO(port): Implement this method as part of off-screen rendering support. + return false; +} + +bool CefBrowserHostImpl::IsTransparent() { + return false; +} + +void CefBrowserHostImpl::PlatformTranslateKeyEvent( + content::NativeWebKeyboardEvent& native_event, + const CefKeyEvent& event) { + // TODO(port): Implement this method as part of off-screen rendering support. + NOTIMPLEMENTED(); +} + +void CefBrowserHostImpl::PlatformTranslateClickEvent( + WebKit::WebMouseEvent& ev, + const CefMouseEvent& mouse_event, + MouseButtonType type, + bool mouseUp, int clickCount) { + // TODO(port): Implement this method as part of off-screen rendering support. + NOTIMPLEMENTED(); +} + +void CefBrowserHostImpl::PlatformTranslateMoveEvent( + WebKit::WebMouseEvent& ev, + const CefMouseEvent& mouse_event, + bool mouseLeave) { + // TODO(port): Implement this method as part of off-screen rendering support. + NOTIMPLEMENTED(); +} + +void CefBrowserHostImpl::PlatformTranslateWheelEvent( + WebKit::WebMouseWheelEvent& ev, + const CefMouseEvent& mouse_event, + int deltaX, int deltaY) { + // TODO(port): Implement this method as part of off-screen rendering support. + NOTIMPLEMENTED(); +} + +void CefBrowserHostImpl::PlatformTranslateMouseEvent( + WebKit::WebMouseEvent& ev, + const CefMouseEvent& mouse_event) { + // TODO(port): Implement this method as part of off-screen rendering support. + NOTIMPLEMENTED(); +} diff --git a/cef3/libcef/browser/browser_host_impl_mac.mm b/cef3/libcef/browser/browser_host_impl_mac.mm new file mode 100644 index 000000000..e59512630 --- /dev/null +++ b/cef3/libcef/browser/browser_host_impl_mac.mm @@ -0,0 +1,420 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 The Chromium 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 "libcef/browser/browser_host_impl.h" + +#import +#import + +#include "base/file_util.h" +#include "base/mac/mac_util.h" +#include "base/string_util.h" +#include "base/sys_string_conversions.h" +#include "base/threading/thread_restrictions.h" +#include "content/public/browser/native_web_keyboard_event.h" +#include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" +#include "content/public/common/file_chooser_params.h" +#include "grit/ui_strings.h" +#include "net/base/mime_util.h" +#import "ui/base/cocoa/underlay_opengl_hosting_window.h" +#include "ui/base/l10n/l10n_util.h" +#include "ui/gfx/rect.h" + + +// Wrapper NSView for the native view. Necessary to destroy the browser when +// the view is deleted. +@interface CefBrowserHostView : NSView { + @private + CefBrowserHostImpl* browser_; // weak + bool is_in_onsetfocus_; +} + +@property (nonatomic, assign) CefBrowserHostImpl* browser; + +@end + +@implementation CefBrowserHostView + +@synthesize browser = browser_; + +- (void) dealloc { + if (browser_) { + // Force the browser to be destroyed and release the reference added in + // PlatformCreateWindow(). + browser_->WindowDestroyed(); + } + + [super dealloc]; +} + +- (BOOL)acceptsFirstResponder { + return browser_ && browser_->GetWebContents(); +} + +- (BOOL)becomeFirstResponder { + if (browser_ && browser_->GetWebContents()) { + // Avoid re-entering OnSetFocus. + if (!is_in_onsetfocus_) { + is_in_onsetfocus_ = true; + browser_->OnSetFocus(FOCUS_SOURCE_SYSTEM); + is_in_onsetfocus_ = false; + } + } + + return YES; +} + +@end + +// Receives notifications from the browser window. Will delete itself when done. +@interface CefWindowDelegate : NSObject { + @private + CefBrowserHostImpl* browser_; // weak +} + +@property (nonatomic, assign) CefBrowserHostImpl* browser; + +@end + +@implementation CefWindowDelegate + +@synthesize browser = browser_; + +- (BOOL)windowShouldClose:(id)window { + // Protect against multiple requests to close while the close is pending. + if (browser_ && browser_->destruction_state() <= + CefBrowserHostImpl::DESTRUCTION_STATE_PENDING) { + if (browser_->destruction_state() == + CefBrowserHostImpl::DESTRUCTION_STATE_NONE) { + // Request that the browser close. + browser_->CloseBrowser(false); + } + + // Cancel the close. + return NO; + } + + // Clean ourselves up after clearing the stack of anything that might have the + // window on it. + [self performSelectorOnMainThread:@selector(cleanup:) + withObject:window + waitUntilDone:NO]; + + // Allow the close. + return YES; +} + +- (void)cleanup:(id)window { + [self release]; +} + +@end + + +namespace { + +// Accept-types to file-types helper. +NSMutableArray* GetFileTypesFromAcceptTypes( + const std::vector& accept_types) { + NSMutableArray* acceptArray = [[NSMutableArray alloc] init]; + for (size_t i=0; i ext; + net::GetExtensionsForMimeType(ascii_type, &ext); + for (size_t x = 0; x < ext.size(); ++x) + [acceptArray addObject:base::SysUTF8ToNSString(ext[x])]; + } + } + } + return acceptArray; +} + +void RunOpenFileDialog(const content::FileChooserParams& params, + NSView* view, + std::vector* files) { + NSOpenPanel* openPanel = [NSOpenPanel openPanel]; + + string16 title; + if (!params.title.empty()) { + title = params.title; + } else { + title = l10n_util::GetStringUTF16( + params.mode == content::FileChooserParams::Open ? + IDS_OPEN_FILE_DIALOG_TITLE : IDS_OPEN_FILES_DIALOG_TITLE); + } + [openPanel setTitle:base::SysUTF16ToNSString(title)]; + + // Consider default file name if any. + base::FilePath default_file_name(params.default_file_name); + + if (!default_file_name.empty()) { + if (!default_file_name.BaseName().empty()) { + NSString* defaultName = base::SysUTF8ToNSString( + default_file_name.BaseName().value()); + [openPanel setNameFieldStringValue:defaultName]; + } + + if (!default_file_name.DirName().empty()) { + NSString* defaultDir = base::SysUTF8ToNSString( + default_file_name.DirName().value()); + [openPanel setDirectoryURL:[NSURL fileURLWithPath:defaultDir]]; + } + } + + // Consider supported file types + if (!params.accept_types.empty()) { + [openPanel setAllowedFileTypes:GetFileTypesFromAcceptTypes( + params.accept_types)]; + } + + // Further panel configuration. + [openPanel setAllowsOtherFileTypes:YES]; + [openPanel setAllowsMultipleSelection: + (params.mode == content::FileChooserParams::OpenMultiple)]; + [openPanel setCanChooseFiles:YES]; + [openPanel setCanChooseDirectories:NO]; + + // Show panel. + [openPanel beginSheetModalForWindow:[view window] completionHandler:nil]; + if ([openPanel runModal] == NSFileHandlingPanelOKButton) { + NSArray *urls = [openPanel URLs]; + int i, count = [urls count]; + for (i=0; ipush_back(base::FilePath(base::SysNSStringToUTF8([url path]))); + } + } + [NSApp endSheet:openPanel]; +} + +bool RunSaveFileDialog(const content::FileChooserParams& params, + NSView* view, + base::FilePath* file) { + NSSavePanel* savePanel = [NSSavePanel savePanel]; + + string16 title; + if (!params.title.empty()) + title = params.title; + else + title = l10n_util::GetStringUTF16(IDS_SAVE_AS_DIALOG_TITLE); + [savePanel setTitle:base::SysUTF16ToNSString(title)]; + + // Consider default file name if any. + base::FilePath default_file_name(params.default_file_name); + + if (!default_file_name.empty()) { + if (!default_file_name.BaseName().empty()) { + NSString* defaultName = base::SysUTF8ToNSString( + default_file_name.BaseName().value()); + [savePanel setNameFieldStringValue:defaultName]; + } + + if (!default_file_name.DirName().empty()) { + NSString* defaultDir = base::SysUTF8ToNSString( + default_file_name.DirName().value()); + [savePanel setDirectoryURL:[NSURL fileURLWithPath:defaultDir]]; + } + } + + // Consider supported file types + if (!params.accept_types.empty()) { + [savePanel setAllowedFileTypes:GetFileTypesFromAcceptTypes( + params.accept_types)]; + } + + [savePanel setAllowsOtherFileTypes:YES]; + + bool success = false; + + [savePanel beginSheetModalForWindow:[view window] completionHandler:nil]; + if ([savePanel runModal] == NSFileHandlingPanelOKButton) { + NSURL * url = [savePanel URL]; + NSString* path = [url path]; + *file = base::FilePath([path UTF8String]); + success = true; + } + [NSApp endSheet:savePanel]; + + return success; +} + +} // namespace + +bool CefBrowserHostImpl::PlatformViewText(const std::string& text) { + NOTIMPLEMENTED(); + return false; +} + +bool CefBrowserHostImpl::PlatformCreateWindow() { + NSWindow* newWnd = nil; + + NSView* parentView = window_info_.parent_view; + NSRect contentRect = {{window_info_.x, window_info_.y}, + {window_info_.width, window_info_.height}}; + if (parentView == nil) { + // Create a new window. + NSRect screen_rect = [[NSScreen mainScreen] visibleFrame]; + NSRect window_rect = {{window_info_.x, + screen_rect.size.height - window_info_.y}, + {window_info_.width, window_info_.height}}; + if (window_rect.size.width == 0) + window_rect.size.width = 750; + if (window_rect.size.height == 0) + window_rect.size.height = 750; + + contentRect.origin.x = 0; + contentRect.origin.y = 0; + contentRect.size.width = window_rect.size.width; + contentRect.size.height = window_rect.size.height; + + // Create the delegate for control and browser window events. + CefWindowDelegate* delegate = [[CefWindowDelegate alloc] init]; + delegate.browser = this; + + newWnd = [[UnderlayOpenGLHostingWindow alloc] + initWithContentRect:window_rect + styleMask:(NSTitledWindowMask | + NSClosableWindowMask | + NSMiniaturizableWindowMask | + NSResizableWindowMask | + NSUnifiedTitleAndToolbarWindowMask ) + backing:NSBackingStoreBuffered + defer:NO]; + [newWnd setDelegate:delegate]; + parentView = [newWnd contentView]; + window_info_.parent_view = parentView; + } + + // Add a reference that will be released in the dealloc handler. + AddRef(); + + // Create the browser view. + CefBrowserHostView* browser_view = + [[CefBrowserHostView alloc] initWithFrame:contentRect]; + browser_view.browser = this; + [parentView addSubview:browser_view]; + [browser_view setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; + [browser_view setNeedsDisplay:YES]; + [browser_view release]; + + // Parent the TabContents to the browser view. + const NSRect bounds = [browser_view bounds]; + NSView* native_view = web_contents_->GetView()->GetNativeView(); + [browser_view addSubview:native_view]; + [native_view setFrame:bounds]; + [native_view setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; + [native_view setNeedsDisplay:YES]; + + window_info_.view = browser_view; + + if (newWnd != nil && !window_info_.hidden) { + // Show the window. + [newWnd makeKeyAndOrderFront: nil]; + } + + return true; +} + +void CefBrowserHostImpl::PlatformCloseWindow() { + if (window_info_.view != nil) { + [[window_info_.view window] performSelector:@selector(performClose:) + withObject:nil + afterDelay:0]; + } +} + +void CefBrowserHostImpl::PlatformSizeTo(int width, int height) { + // Not needed; subviews are bound. +} + +CefWindowHandle CefBrowserHostImpl::PlatformGetWindowHandle() { + return window_info_.view; +} + +void CefBrowserHostImpl::PlatformHandleKeyboardEvent( + const content::NativeWebKeyboardEvent& event) { + // Give the top level menu equivalents a chance to handle the event. + if ([event.os_event type] == NSKeyDown) + [[NSApp mainMenu] performKeyEquivalent:event.os_event]; +} + +void CefBrowserHostImpl::PlatformRunFileChooser( + const content::FileChooserParams& params, + RunFileChooserCallback callback) { + std::vector files; + + if (params.mode == content::FileChooserParams::Open || + params.mode == content::FileChooserParams::OpenMultiple) { + RunOpenFileDialog(params, PlatformGetWindowHandle(), &files); + } else if (params.mode == content::FileChooserParams::Save) { + base::FilePath file; + if (RunSaveFileDialog(params, PlatformGetWindowHandle(), &file)) + files.push_back(file); + } else { + NOTIMPLEMENTED(); + } + + callback.Run(files); +} + +void CefBrowserHostImpl::PlatformHandleExternalProtocol(const GURL& url) { +} + +// static +bool CefBrowserHostImpl::IsWindowRenderingDisabled(const CefWindowInfo& info) { + // TODO(port): Implement this method as part of off-screen rendering support. + return false; +} + +bool CefBrowserHostImpl::IsTransparent() { + return false; +} + +void CefBrowserHostImpl::PlatformTranslateKeyEvent( + content::NativeWebKeyboardEvent& native_event, + const CefKeyEvent& event) { + // TODO(port): Implement this method as part of off-screen rendering support. + NOTIMPLEMENTED(); +} + +void CefBrowserHostImpl::PlatformTranslateClickEvent( + WebKit::WebMouseEvent& ev, + const CefMouseEvent& mouse_event, + MouseButtonType type, + bool mouseUp, int clickCount) { + // TODO(port): Implement this method as part of off-screen rendering support. + NOTIMPLEMENTED(); +} + +void CefBrowserHostImpl::PlatformTranslateMoveEvent( + WebKit::WebMouseEvent& ev, + const CefMouseEvent& mouse_event, + bool mouseLeave) { + // TODO(port): Implement this method as part of off-screen rendering support. + NOTIMPLEMENTED(); +} + +void CefBrowserHostImpl::PlatformTranslateWheelEvent( + WebKit::WebMouseWheelEvent& ev, + const CefMouseEvent& mouse_event, + int deltaX, int deltaY) { + // TODO(port): Implement this method as part of off-screen rendering support. + NOTIMPLEMENTED(); +} + +void CefBrowserHostImpl::PlatformTranslateMouseEvent( + WebKit::WebMouseEvent& ev, + const CefMouseEvent& mouse_event) { + // TODO(port): Implement this method as part of off-screen rendering support. + NOTIMPLEMENTED(); +} diff --git a/cef3/libcef/browser/browser_host_impl_win.cc b/cef3/libcef/browser/browser_host_impl_win.cc new file mode 100644 index 000000000..be9ed839a --- /dev/null +++ b/cef3/libcef/browser/browser_host_impl_win.cc @@ -0,0 +1,848 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 The Chromium 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 "libcef/browser/browser_host_impl.h" + +#include +#include +#include +#include +#include + +#include "libcef/browser/thread_util.h" + +#include "base/i18n/case_conversion.h" +#include "base/string_util.h" +#include "base/utf_string_conversions.h" +#include "base/win/registry.h" +#include "base/win/windows_version.h" +#include "content/public/browser/native_web_keyboard_event.h" +#include "content/public/browser/web_contents_view.h" +#include "content/public/common/file_chooser_params.h" +#include "grit/cef_strings.h" +#include "grit/ui_strings.h" +#include "net/base/mime_util.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/win/WebInputEventFactory.h" +#include "ui/base/l10n/l10n_util.h" +#include "ui/base/win/hwnd_util.h" + +#pragma comment(lib, "dwmapi.lib") + +namespace { + +bool IsAeroGlassEnabled() { + if (base::win::GetVersion() < base::win::VERSION_VISTA) + return false; + + BOOL enabled = FALSE; + return SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled; +} + +void SetAeroGlass(HWND hWnd) { + if (!IsAeroGlassEnabled()) + return; + + // Make the whole window transparent. + MARGINS mgMarInset = { -1, -1, -1, -1 }; + DwmExtendFrameIntoClientArea(hWnd, &mgMarInset); +} + +void WriteTextToFile(const std::string& data, const std::wstring& file_path) { + FILE* fp; + errno_t err = _wfopen_s(&fp, file_path.c_str(), L"wt"); + if (err) + return; + fwrite(data.c_str(), 1, data.size(), fp); + fclose(fp); +} + +// From ui/base/dialogs/select_file_dialog_win.cc. + +// Get the file type description from the registry. This will be "Text Document" +// for .txt files, "JPEG Image" for .jpg files, etc. If the registry doesn't +// have an entry for the file type, we return false, true if the description was +// found. 'file_ext' must be in form ".txt". +static bool GetRegistryDescriptionFromExtension(const std::wstring& file_ext, + std::wstring* reg_description) { + DCHECK(reg_description); + base::win::RegKey reg_ext(HKEY_CLASSES_ROOT, file_ext.c_str(), KEY_READ); + std::wstring reg_app; + if (reg_ext.ReadValue(NULL, ®_app) == ERROR_SUCCESS && !reg_app.empty()) { + base::win::RegKey reg_link(HKEY_CLASSES_ROOT, reg_app.c_str(), KEY_READ); + if (reg_link.ReadValue(NULL, reg_description) == ERROR_SUCCESS) + return true; + } + return false; +} + +// Set up a filter for a Save/Open dialog, which will consist of |file_ext| file +// extensions (internally separated by semicolons), |ext_desc| as the text +// descriptions of the |file_ext| types (optional), and (optionally) the default +// 'All Files' view. The purpose of the filter is to show only files of a +// particular type in a Windows Save/Open dialog box. The resulting filter is +// returned. The filters created here are: +// 1. only files that have 'file_ext' as their extension +// 2. all files (only added if 'include_all_files' is true) +// Example: +// file_ext: { "*.txt", "*.htm;*.html" } +// ext_desc: { "Text Document" } +// returned: "Text Document\0*.txt\0HTML Document\0*.htm;*.html\0" +// "All Files\0*.*\0\0" (in one big string) +// If a description is not provided for a file extension, it will be retrieved +// from the registry. If the file extension does not exist in the registry, it +// will be omitted from the filter, as it is likely a bogus extension. +std::wstring FormatFilterForExtensions( + const std::vector& file_ext, + const std::vector& ext_desc, + bool include_all_files) { + const std::wstring all_ext = L"*.*"; + const std::wstring all_desc = + l10n_util::GetStringUTF16(IDS_APP_SAVEAS_ALL_FILES) + + L" (" + all_ext + L")"; + + DCHECK(file_ext.size() >= ext_desc.size()); + + if (file_ext.empty()) + include_all_files = true; + + std::wstring result; + + for (size_t i = 0; i < file_ext.size(); ++i) { + std::wstring ext = file_ext[i]; + std::wstring desc; + if (i < ext_desc.size()) + desc = ext_desc[i]; + + if (ext.empty()) { + // Force something reasonable to appear in the dialog box if there is no + // extension provided. + include_all_files = true; + continue; + } + + if (desc.empty()) { + DCHECK(ext.find(L'.') != std::wstring::npos); + std::wstring first_extension = ext.substr(ext.find(L'.')); + size_t first_separator_index = first_extension.find(L';'); + if (first_separator_index != std::wstring::npos) + first_extension = first_extension.substr(0, first_separator_index); + + // Find the extension name without the preceeding '.' character. + std::wstring ext_name = first_extension; + size_t ext_index = ext_name.find_first_not_of(L'.'); + if (ext_index != std::wstring::npos) + ext_name = ext_name.substr(ext_index); + + if (!GetRegistryDescriptionFromExtension(first_extension, &desc)) { + // The extension doesn't exist in the registry. Create a description + // based on the unknown extension type (i.e. if the extension is .qqq, + // the we create a description "QQQ File (.qqq)"). + include_all_files = true; + desc = l10n_util::GetStringFUTF16( + IDS_APP_SAVEAS_EXTENSION_FORMAT, + base::i18n::ToUpper(WideToUTF16(ext_name)), + ext_name); + } + } + + if (!desc.empty()) + desc += L" (" + ext + L")"; + else + desc = ext; + + result.append(desc.c_str(), desc.size() + 1); // Append NULL too. + result.append(ext.c_str(), ext.size() + 1); + } + + if (include_all_files) { + result.append(all_desc.c_str(), all_desc.size() + 1); + result.append(all_ext.c_str(), all_ext.size() + 1); + } + + result.append(1, '\0'); // Double NULL required. + return result; +} + +std::wstring GetDescriptionFromMimeType(const std::string& mime_type) { + // Check for wild card mime types and return an appropriate description. + static const struct { + const char* mime_type; + int string_id; + } kWildCardMimeTypes[] = { + { "audio", IDS_APP_AUDIO_FILES }, + { "image", IDS_APP_IMAGE_FILES }, + { "text", IDS_APP_TEXT_FILES }, + { "video", IDS_APP_VIDEO_FILES }, + }; + + for (size_t i = 0; i < arraysize(kWildCardMimeTypes); ++i) { + if (mime_type == std::string(kWildCardMimeTypes[i].mime_type) + "/*") + return l10n_util::GetStringUTF16(kWildCardMimeTypes[i].string_id); + } + + return std::wstring(); +} + +std::wstring GetFilterStringFromAcceptTypes( + const std::vector& accept_types) { + std::vector extensions; + std::vector descriptions; + + for (size_t i = 0; i < accept_types.size(); ++i) { + std::string ascii_type = UTF16ToASCII(accept_types[i]); + if (ascii_type.length()) { + // Just treat as extension if contains '.' as the first character. + if (ascii_type[0] == '.') { + extensions.push_back(L"*" + ASCIIToWide(ascii_type)); + descriptions.push_back(std::wstring()); + } else { + // Otherwise convert mime type to one or more extensions. + std::vector ext; + std::wstring ext_str; + net::GetExtensionsForMimeType(ascii_type, &ext); + if (ext.size() > 0) { + for (size_t x = 0; x < ext.size(); ++x) { + if (x != 0) + ext_str += L";"; + ext_str += L"*." + ext[x]; + } + extensions.push_back(ext_str); + descriptions.push_back(GetDescriptionFromMimeType(ascii_type)); + } + } + } + } + + return FormatFilterForExtensions(extensions, descriptions, true); +} + +// from chrome/browser/views/shell_dialogs_win.cc + +bool RunOpenFileDialog(const content::FileChooserParams& params, + HWND owner, + base::FilePath* path) { + OPENFILENAME ofn; + + // We must do this otherwise the ofn's FlagsEx may be initialized to random + // junk in release builds which can cause the Places Bar not to show up! + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = owner; + + // Consider default file name if any. + base::FilePath default_file_name(params.default_file_name); + + wchar_t filename[MAX_PATH] = {0}; + + ofn.lpstrFile = filename; + ofn.nMaxFile = MAX_PATH; + + std::wstring directory; + if (!default_file_name.empty()) { + base::wcslcpy(filename, default_file_name.value().c_str(), + arraysize(filename)); + + directory = default_file_name.DirName().value(); + ofn.lpstrInitialDir = directory.c_str(); + } + + std::wstring title; + if (!params.title.empty()) + title = params.title; + else + title = l10n_util::GetStringUTF16(IDS_OPEN_FILE_DIALOG_TITLE); + if (!title.empty()) + ofn.lpstrTitle = title.c_str(); + + // We use OFN_NOCHANGEDIR so that the user can rename or delete the directory + // without having to close Chrome first. + ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_EXPLORER | + OFN_ENABLESIZING; + + std::wstring filter = GetFilterStringFromAcceptTypes(params.accept_types); + if (!filter.empty()) + ofn.lpstrFilter = filter.c_str(); + + bool success = !!GetOpenFileName(&ofn); + if (success) + *path = base::FilePath(filename); + return success; +} + +bool RunOpenMultiFileDialog(const content::FileChooserParams& params, + HWND owner, + std::vector* paths) { + OPENFILENAME ofn; + + // We must do this otherwise the ofn's FlagsEx may be initialized to random + // junk in release builds which can cause the Places Bar not to show up! + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = owner; + + scoped_array filename(new wchar_t[UNICODE_STRING_MAX_CHARS]); + filename[0] = 0; + + ofn.lpstrFile = filename.get(); + ofn.nMaxFile = UNICODE_STRING_MAX_CHARS; + + std::wstring title; + if (!params.title.empty()) + title = params.title; + else + title = l10n_util::GetStringUTF16(IDS_OPEN_FILES_DIALOG_TITLE); + if (!title.empty()) + ofn.lpstrTitle = title.c_str(); + + // We use OFN_NOCHANGEDIR so that the user can rename or delete the directory + // without having to close Chrome first. + ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_EXPLORER | + OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT | OFN_ENABLESIZING; + + std::wstring filter = GetFilterStringFromAcceptTypes(params.accept_types); + if (!filter.empty()) + ofn.lpstrFilter = filter.c_str(); + + bool success = !!GetOpenFileName(&ofn); + + if (success) { + std::vector files; + const wchar_t* selection = ofn.lpstrFile; + while (*selection) { // Empty string indicates end of list. + files.push_back(base::FilePath(selection)); + // Skip over filename and null-terminator. + selection += files.back().value().length() + 1; + } + if (files.empty()) { + success = false; + } else if (files.size() == 1) { + // When there is one file, it contains the path and filename. + paths->swap(files); + } else { + // Otherwise, the first string is the path, and the remainder are + // filenames. + std::vector::iterator path = files.begin(); + for (std::vector::iterator file = path + 1; + file != files.end(); ++file) { + paths->push_back(path->Append(*file)); + } + } + } + return success; +} + +bool RunSaveFileDialog(const content::FileChooserParams& params, + HWND owner, + base::FilePath* path) { + OPENFILENAME ofn; + + // We must do this otherwise the ofn's FlagsEx may be initialized to random + // junk in release builds which can cause the Places Bar not to show up! + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = owner; + + // Consider default file name if any. + base::FilePath default_file_name(params.default_file_name); + + wchar_t filename[MAX_PATH] = {0}; + + ofn.lpstrFile = filename; + ofn.nMaxFile = MAX_PATH; + + std::wstring directory; + if (!default_file_name.empty()) { + base::wcslcpy(filename, default_file_name.value().c_str(), + arraysize(filename)); + + directory = default_file_name.DirName().value(); + ofn.lpstrInitialDir = directory.c_str(); + } + + std::wstring title; + if (!params.title.empty()) + title = params.title; + else + title = l10n_util::GetStringUTF16(IDS_SAVE_AS_DIALOG_TITLE); + if (!title.empty()) + ofn.lpstrTitle = title.c_str(); + + // We use OFN_NOCHANGEDIR so that the user can rename or delete the directory + // without having to close Chrome first. + ofn.Flags = OFN_OVERWRITEPROMPT | OFN_EXPLORER | OFN_ENABLESIZING | + OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST; + + std::wstring filter = GetFilterStringFromAcceptTypes(params.accept_types); + if (!filter.empty()) + ofn.lpstrFilter = filter.c_str(); + + bool success = !!GetSaveFileName(&ofn); + if (success) + *path = base::FilePath(filename); + return success; +} + + +// According to Mozilla in uriloader/exthandler/win/nsOSHelperAppService.cpp: +// "Some versions of windows (Win2k before SP3, Win XP before SP1) crash in +// ShellExecute on long URLs (bug 161357 on bugzilla.mozilla.org). IE 5 and 6 +// support URLS of 2083 chars in length, 2K is safe." +const int kMaxAddressLengthChars = 2048; + +bool HasExternalHandler(const std::string& scheme) { + base::win::RegKey key; + const std::wstring registry_path = + ASCIIToWide(scheme + "\\shell\\open\\command"); + key.Open(HKEY_CLASSES_ROOT, registry_path.c_str(), KEY_READ); + if (key.Valid()) { + DWORD size = 0; + key.ReadValue(NULL, NULL, &size, NULL); + if (size > 2) { + // ShellExecute crashes the process when the command is empty. + // We check for "2" because it always returns the trailing NULL. + return true; + } + } + + return false; +} + +WORD KeyStatesToWord() { + static const USHORT kHighBitMaskShort = 0x8000; + WORD result = 0; + + if (GetKeyState(VK_CONTROL) & kHighBitMaskShort) + result |= MK_CONTROL; + if (GetKeyState(VK_SHIFT) & kHighBitMaskShort) + result |= MK_SHIFT; + if (GetKeyState(VK_LBUTTON) & kHighBitMaskShort) + result |= MK_LBUTTON; + if (GetKeyState(VK_MBUTTON) & kHighBitMaskShort) + result |= MK_MBUTTON; + if (GetKeyState(VK_RBUTTON) & kHighBitMaskShort) + result |= MK_RBUTTON; + return result; +} + +} // namespace + +// static +void CefBrowserHostImpl::RegisterWindowClass() { + // Register the window class + WNDCLASSEX wcex = { + /* cbSize = */ sizeof(WNDCLASSEX), + /* style = */ CS_HREDRAW | CS_VREDRAW, + /* lpfnWndProc = */ CefBrowserHostImpl::WndProc, + /* cbClsExtra = */ 0, + /* cbWndExtra = */ 0, + /* hInstance = */ ::GetModuleHandle(NULL), + /* hIcon = */ NULL, + /* hCursor = */ LoadCursor(NULL, IDC_ARROW), + /* hbrBackground = */ 0, + /* lpszMenuName = */ NULL, + /* lpszClassName = */ CefBrowserHostImpl::GetWndClass(), + /* hIconSm = */ NULL, + }; + RegisterClassEx(&wcex); +} + +// static +LPCTSTR CefBrowserHostImpl::GetWndClass() { + return L"CefBrowserWindow"; +} + +// static +LRESULT CALLBACK CefBrowserHostImpl::WndProc(HWND hwnd, UINT message, + WPARAM wParam, LPARAM lParam) { + CefBrowserHostImpl* browser = + static_cast(ui::GetWindowUserData(hwnd)); + + switch (message) { + case WM_CLOSE: + // Protect against multiple requests to close while the close is pending. + if (browser && browser->destruction_state() <= DESTRUCTION_STATE_PENDING) { + if (browser->destruction_state() == DESTRUCTION_STATE_NONE) { + // Request that the browser close. + browser->CloseBrowser(false); + } + + // Cancel the close. + return 0; + } + + // Allow the close. + break; + + case WM_DESTROY: + if (browser) { + // Clear the user data pointer. + ui::SetWindowUserData(hwnd, NULL); + + // Force the browser to be destroyed and release the reference added in + // PlatformCreateWindow(). + browser->WindowDestroyed(); + } + return 0; + + case WM_SIZE: + // Minimizing resizes the window to 0x0 which causes our layout to go all + // screwy, so we just ignore it. + if (wParam != SIZE_MINIMIZED && browser) { + // resize the web view window to the full size of the browser window + RECT rc; + GetClientRect(hwnd, &rc); + MoveWindow(browser->GetContentView(), 0, 0, rc.right, rc.bottom, + TRUE); + } + return 0; + + case WM_SETFOCUS: + if (browser) + browser->OnSetFocus(FOCUS_SOURCE_SYSTEM); + return 0; + + case WM_ERASEBKGND: + return 0; + + case WM_DWMCOMPOSITIONCHANGED: + // Message sent to top-level windows when composition has been enabled or + // disabled. + if (browser && browser->window_info_.transparent_painting) + SetAeroGlass(hwnd); + break; + } + + return DefWindowProc(hwnd, message, wParam, lParam); +} + +bool CefBrowserHostImpl::PlatformCreateWindow() { + std::wstring windowName(CefString(&window_info_.window_name)); + + // Create the new browser window. + window_info_.window = CreateWindowEx(window_info_.ex_style, + GetWndClass(), windowName.c_str(), window_info_.style, + window_info_.x, window_info_.y, window_info_.width, + window_info_.height, window_info_.parent_window, window_info_.menu, + ::GetModuleHandle(NULL), NULL); + + // It's possible for CreateWindowEx to fail if the parent window was + // destroyed between the call to CreateBrowser and the above one. + DCHECK(window_info_.window != NULL); + if (!window_info_.window) + return false; + + if (window_info_.transparent_painting && + !(window_info_.style & WS_CHILD)) { + // Transparent top-level windows will be given "sheet of glass" effect. + SetAeroGlass(window_info_.window); + } + + // Set window user data to this object for future reference from the window + // procedure. + ui::SetWindowUserData(window_info_.window, this); + + // Add a reference that will be released in the WM_DESTROY handler. + AddRef(); + + // Parent the TabContents to the browser window. + SetParent(web_contents_->GetView()->GetNativeView(), window_info_.window); + + // Size the web view window to the browser window. + RECT cr; + GetClientRect(window_info_.window, &cr); + + // Respect the WS_VISIBLE window style when setting the window's position. + UINT flags = SWP_NOZORDER | SWP_SHOWWINDOW; + if (!(window_info_.style & WS_VISIBLE)) + flags |= SWP_NOACTIVATE; + + SetWindowPos(GetContentView(), NULL, cr.left, cr.top, cr.right, + cr.bottom, flags); + + return true; +} + +void CefBrowserHostImpl::PlatformCloseWindow() { + if (window_info_.window != NULL) { + HWND frameWnd = GetAncestor(window_info_.window, GA_ROOT); + PostMessage(frameWnd, WM_CLOSE, 0, 0); + } +} + +void CefBrowserHostImpl::PlatformSizeTo(int width, int height) { + RECT rect = {0, 0, width, height}; + DWORD style = GetWindowLong(window_info_.window, GWL_STYLE); + DWORD ex_style = GetWindowLong(window_info_.window, GWL_EXSTYLE); + bool has_menu = !(style & WS_CHILD) && (GetMenu(window_info_.window) != NULL); + + // The size value is for the client area. Calculate the whole window size + // based on the current style. + AdjustWindowRectEx(&rect, style, has_menu, ex_style); + + // Size the window. + SetWindowPos(window_info_.window, NULL, 0, 0, rect.right, + rect.bottom, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); +} + +CefWindowHandle CefBrowserHostImpl::PlatformGetWindowHandle() { + return IsWindowRenderingDisabled() ? + window_info_.parent_window : + window_info_.window; +} + +bool CefBrowserHostImpl::PlatformViewText(const std::string& text) { + CEF_REQUIRE_UIT(); + + DWORD dwRetVal; + DWORD dwBufSize = 512; + TCHAR lpPathBuffer[512]; + UINT uRetVal; + TCHAR szTempName[512]; + + dwRetVal = GetTempPath(dwBufSize, // length of the buffer + lpPathBuffer); // buffer for path + if (dwRetVal > dwBufSize || (dwRetVal == 0)) + return false; + + // Create a temporary file. + uRetVal = GetTempFileName(lpPathBuffer, // directory for tmp files + TEXT("src"), // temp file name prefix + 0, // create unique name + szTempName); // buffer for name + if (uRetVal == 0) + return false; + + size_t len = wcslen(szTempName); + wcscpy(szTempName + len - 3, L"txt"); + WriteTextToFile(text, szTempName); + + HWND frameWnd = GetAncestor(PlatformGetWindowHandle(), GA_ROOT); + int errorCode = reinterpret_cast(ShellExecute(frameWnd, L"open", + szTempName, NULL, NULL, SW_SHOWNORMAL)); + if (errorCode <= 32) + return false; + + return true; +} + +void CefBrowserHostImpl::PlatformHandleKeyboardEvent( + const content::NativeWebKeyboardEvent& event) { + // Any unhandled keyboard/character messages are sent to DefWindowProc so that + // shortcut keys work correctly. + DefWindowProc(event.os_event.hwnd, event.os_event.message, + event.os_event.wParam, event.os_event.lParam); +} + +void CefBrowserHostImpl::PlatformRunFileChooser( + const content::FileChooserParams& params, + RunFileChooserCallback callback) { + std::vector files; + + if (params.mode == content::FileChooserParams::Open) { + base::FilePath file; + if (RunOpenFileDialog(params, PlatformGetWindowHandle(), &file)) + files.push_back(file); + } else if (params.mode == content::FileChooserParams::OpenMultiple) { + RunOpenMultiFileDialog(params, PlatformGetWindowHandle(), &files); + } else if (params.mode == content::FileChooserParams::Save) { + base::FilePath file; + if (RunSaveFileDialog(params, PlatformGetWindowHandle(), &file)) + files.push_back(file); + } else { + NOTIMPLEMENTED(); + } + + callback.Run(files); +} + +void CefBrowserHostImpl::PlatformHandleExternalProtocol(const GURL& url) { + if (CEF_CURRENTLY_ON_FILET()) { + if (!HasExternalHandler(url.scheme())) + return; + + const std::string& address = url.spec(); + if (address.length() > kMaxAddressLengthChars) + return; + + ShellExecuteA(NULL, "open", address.c_str(), NULL, NULL, SW_SHOWNORMAL); + } else { + // Execute on the FILE thread. + CEF_POST_TASK(CEF_FILET, + base::Bind(&CefBrowserHostImpl::PlatformHandleExternalProtocol, this, + url)); + } +} + +// static +bool CefBrowserHostImpl::IsWindowRenderingDisabled(const CefWindowInfo& info) { + return info.window_rendering_disabled ? true : false; +} + +bool CefBrowserHostImpl::IsTransparent() { + return window_info_.transparent_painting != 0; +} + +void CefBrowserHostImpl::PlatformTranslateKeyEvent( + content::NativeWebKeyboardEvent& result, const CefKeyEvent& key_event) { + result.timeStampSeconds = GetMessageTime() / 1000.0; + + result.windowsKeyCode = key_event.windows_key_code; + result.nativeKeyCode = key_event.native_key_code; + result.isSystemKey = key_event.is_system_key; + switch (key_event.type) { + case KEYEVENT_RAWKEYDOWN: + case KEYEVENT_KEYDOWN: + result.type = WebKit::WebInputEvent::RawKeyDown; + break; + case KEYEVENT_KEYUP: + result.type = WebKit::WebInputEvent::KeyUp; + break; + case KEYEVENT_CHAR: + result.type = WebKit::WebInputEvent::Char; + break; + default: + NOTREACHED(); + } + + if (result.type == WebKit::WebInputEvent::Char || + result.type == WebKit::WebInputEvent::RawKeyDown) { + result.text[0] = result.windowsKeyCode; + result.unmodifiedText[0] = result.windowsKeyCode; + } + if (result.type != WebKit::WebInputEvent::Char) + result.setKeyIdentifierFromWindowsKeyCode(); + + result.modifiers |= TranslateModifiers(key_event.modifiers); +} + +void CefBrowserHostImpl::PlatformTranslateClickEvent( + WebKit::WebMouseEvent& result, + const CefMouseEvent& mouse_event, + CefBrowserHost::MouseButtonType type, + bool mouseUp, int clickCount) { + PlatformTranslateMouseEvent(result, mouse_event); + + switch (type) { + case MBT_LEFT: + result.type = mouseUp ? WebKit::WebInputEvent::MouseUp : + WebKit::WebInputEvent::MouseDown; + result.button = WebKit::WebMouseEvent::ButtonLeft; + break; + case MBT_MIDDLE: + result.type = mouseUp ? WebKit::WebInputEvent::MouseUp : + WebKit::WebInputEvent::MouseDown; + result.button = WebKit::WebMouseEvent::ButtonMiddle; + break; + case MBT_RIGHT: + result.type = mouseUp ? WebKit::WebInputEvent::MouseUp : + WebKit::WebInputEvent::MouseDown; + result.button = WebKit::WebMouseEvent::ButtonRight; + break; + default: + NOTREACHED(); + } + + result.clickCount = clickCount; +} + +void CefBrowserHostImpl::PlatformTranslateMoveEvent( + WebKit::WebMouseEvent& result, + const CefMouseEvent& mouse_event, + bool mouseLeave) { + PlatformTranslateMouseEvent(result, mouse_event); + + if (!mouseLeave) { + result.type = WebKit::WebInputEvent::MouseMove; + if (mouse_event.modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON) + result.button = WebKit::WebMouseEvent::ButtonLeft; + else if (mouse_event.modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON) + result.button = WebKit::WebMouseEvent::ButtonMiddle; + else if (mouse_event.modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON) + result.button = WebKit::WebMouseEvent::ButtonRight; + else + result.button = WebKit::WebMouseEvent::ButtonNone; + } else { + result.type = WebKit::WebInputEvent::MouseLeave; + result.button = WebKit::WebMouseEvent::ButtonNone; + } + + result.clickCount = 0; +} + +void CefBrowserHostImpl::PlatformTranslateWheelEvent( + WebKit::WebMouseWheelEvent& result, + const CefMouseEvent& mouse_event, + int deltaX, int deltaY) { + PlatformTranslateMouseEvent(result, mouse_event); + + result.type = WebKit::WebInputEvent::MouseWheel; + result.button = WebKit::WebMouseEvent::ButtonNone; + + float wheelDelta; + bool horizontalScroll = false; + + wheelDelta = static_cast(deltaY ? deltaY : deltaX); + + horizontalScroll = (deltaY == 0); + + static const ULONG defaultScrollCharsPerWheelDelta = 1; + static const FLOAT scrollbarPixelsPerLine = 100.0f / 3.0f; + static const ULONG defaultScrollLinesPerWheelDelta = 3; + wheelDelta /= WHEEL_DELTA; + float scrollDelta = wheelDelta; + if (horizontalScroll) { + ULONG scrollChars = defaultScrollCharsPerWheelDelta; + SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &scrollChars, 0); + scrollDelta *= static_cast(scrollChars) * scrollbarPixelsPerLine; + } else { + ULONG scrollLines = defaultScrollLinesPerWheelDelta; + SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scrollLines, 0); + if (scrollLines == WHEEL_PAGESCROLL) + result.scrollByPage = true; + if (!result.scrollByPage) + scrollDelta *= static_cast(scrollLines) * scrollbarPixelsPerLine; + } + + // Set scroll amount based on above calculations. WebKit expects positive + // deltaY to mean "scroll up" and positive deltaX to mean "scroll left". + if (horizontalScroll) { + result.deltaX = scrollDelta; + result.wheelTicksX = wheelDelta; + } else { + result.deltaY = scrollDelta; + result.wheelTicksY = wheelDelta; + } +} + +void CefBrowserHostImpl::PlatformTranslateMouseEvent( + WebKit::WebMouseEvent& result, + const CefMouseEvent& mouse_event) { + // position + result.x = mouse_event.x; + result.y = mouse_event.y; + result.windowX = result.x; + result.windowY = result.y; + result.globalX = result.x; + result.globalY = result.y; + + // global position + if (IsWindowRenderingDisabled()) { + GetClient()->GetRenderHandler()->GetScreenPoint(GetBrowser(), + result.x, result.y, + result.globalX, result.globalY); + } else { + POINT globalPoint = { result.x, result.y }; + ClientToScreen(GetWindowHandle(), &globalPoint); + result.globalX = globalPoint.x; + result.globalY = globalPoint.y; + } + + // modifiers + result.modifiers |= TranslateModifiers(mouse_event.modifiers); + + // timestamp + result.timeStampSeconds = GetMessageTime() / 1000.0; +} diff --git a/cef3/libcef/browser/browser_info.cc b/cef3/libcef/browser/browser_info.cc new file mode 100644 index 000000000..458a10264 --- /dev/null +++ b/cef3/libcef/browser/browser_info.cc @@ -0,0 +1,42 @@ +// 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 "libcef/browser/browser_info.h" +#include "ipc/ipc_message.h" + +CefBrowserInfo::CefBrowserInfo(int browser_id, bool is_popup) + : browser_id_(browser_id), + is_popup_(is_popup), + render_process_id_(MSG_ROUTING_NONE), + render_view_id_(MSG_ROUTING_NONE) { + DCHECK_GT(browser_id, 0); +} + +CefBrowserInfo::~CefBrowserInfo() { +} + +void CefBrowserInfo::set_render_ids( + int render_process_id, int render_view_id) { + base::AutoLock lock_scope(lock_); + render_process_id_ = render_process_id; + render_view_id_ = render_view_id; +} + +bool CefBrowserInfo::is_render_id_match( + int render_process_id, int render_view_id) { + base::AutoLock lock_scope(lock_); + if (render_process_id != render_process_id_) + return false; + return (render_view_id == 0 || render_view_id == render_view_id_); +} + +CefRefPtr CefBrowserInfo::browser() { + base::AutoLock lock_scope(lock_); + return browser_; +} + +void CefBrowserInfo::set_browser(CefRefPtr browser) { + base::AutoLock lock_scope(lock_); + browser_ = browser; +} diff --git a/cef3/libcef/browser/browser_info.h b/cef3/libcef/browser/browser_info.h new file mode 100644 index 000000000..81f58f5e0 --- /dev/null +++ b/cef3/libcef/browser/browser_info.h @@ -0,0 +1,53 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_BROWSER_INFO_H_ +#define CEF_LIBCEF_BROWSER_BROWSER_INFO_H_ +#pragma once + +#include "libcef/browser/browser_host_impl.h" +#include "base/memory/ref_counted.h" + +// CefBrowserInfo is used to associate a browser ID and render view/process +// IDs with a particular CefBrowserHostImpl. Render view/process IDs may change +// during the lifetime of a single CefBrowserHostImpl. +// +// CefBrowserInfo objects are managed by CefContentBrowserClient and should not +// be created directly. +class CefBrowserInfo : public base::RefCountedThreadSafe { + public: + CefBrowserInfo(int browser_id, bool is_popup); + virtual ~CefBrowserInfo(); + + int browser_id() const { return browser_id_; }; + bool is_popup() const { return is_popup_; } + + void set_render_ids(int render_process_id, int render_view_id); + + // Returns true if this browser matches the specified ID values. If + // |render_view_id| is 0 any browser with the specified |render_process_id| + // will match. + bool is_render_id_match(int render_process_id, int render_view_id); + + CefRefPtr browser(); + void set_browser(CefRefPtr browser); + + private: + int browser_id_; + bool is_popup_; + + base::Lock lock_; + + // The below members must be protected by |lock_|. + int render_process_id_; + int render_view_id_; + + // May be NULL if the browser has not yet been created or if the browser has + // been destroyed. + CefRefPtr browser_; + + DISALLOW_COPY_AND_ASSIGN(CefBrowserInfo); +}; + +#endif // CEF_LIBCEF_BROWSER_BROWSER_INFO_H_ diff --git a/cef3/libcef/browser/browser_main.cc b/cef3/libcef/browser/browser_main.cc new file mode 100644 index 000000000..78202c1b6 --- /dev/null +++ b/cef3/libcef/browser/browser_main.cc @@ -0,0 +1,136 @@ +// Copyright (c) 2012 The Chromium 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 "libcef/browser/browser_main.h" + +#include + +#include "libcef/browser/browser_context.h" +#include "libcef/browser/browser_message_loop.h" +#include "libcef/browser/context.h" +#include "libcef/browser/devtools_delegate.h" + +#include "base/bind.h" +#include "base/command_line.h" +#include "base/message_loop.h" +#include "base/string_number_conversions.h" +#include "chrome/browser/net/proxy_service_factory.h" +#include "content/browser/webui/content_web_ui_controller_factory.h" +#include "content/public/browser/gpu_data_manager.h" +#include "content/public/browser/web_ui_controller_factory.h" +#include "content/public/common/content_client.h" +#include "content/public/common/content_switches.h" +#include "net/base/net_module.h" +#include "net/proxy/proxy_resolver_v8.h" +#include "ui/base/resource/resource_bundle.h" +#include "v8/include/v8.h" + +namespace { + +base::StringPiece ResourceProvider(int resource_id) { + return content::GetContentClient()->GetDataResource(resource_id, + ui::SCALE_FACTOR_NONE); +} + +} // namespace + +CefBrowserMainParts::CefBrowserMainParts( + const content::MainFunctionParams& parameters) + : BrowserMainParts(), + devtools_delegate_(NULL), + proxy_v8_isolate_(NULL) { +} + +CefBrowserMainParts::~CefBrowserMainParts() { +} + +void CefBrowserMainParts::PreMainMessageLoopStart() { + if (!MessageLoop::current()) { + // Create the browser message loop. + message_loop_.reset(new CefBrowserMessageLoop()); + message_loop_->set_thread_name("CrBrowserMain"); + } +} + +void CefBrowserMainParts::PostMainMessageLoopStart() { + // Don't use the default WebUI controller factory because is conflicts with + // CEF's internal handling of "chrome://tracing". + content::WebUIControllerFactory::UnregisterFactoryForTesting( + content::ContentWebUIControllerFactory::GetInstance()); +} + +int CefBrowserMainParts::PreCreateThreads() { + PlatformInitialize(); + net::NetModule::SetResourceProvider(&ResourceProvider); + + // Initialize the GpuDataManager before IO access restrictions are applied and + // before the IO thread is started. + content::GpuDataManager::GetInstance(); + + // Initialize user preferences. + pref_store_ = new CefBrowserPrefStore(); + pref_store_->SetInitializationCompleted(); + pref_service_.reset(pref_store_->CreateService()); + + // Create a v8::Isolate for the current thread if it doesn't already exist. + if (!v8::Isolate::GetCurrent()) { + proxy_v8_isolate_ = v8::Isolate::New(); + proxy_v8_isolate_->Enter(); + } + + // Initialize the V8 proxy integration. + net::ProxyResolverV8::RememberDefaultIsolate(); + + // Initialize proxy configuration tracker. + pref_proxy_config_tracker_.reset( + ProxyServiceFactory::CreatePrefProxyConfigTracker( + pref_service_.get())); + + return 0; +} + +void CefBrowserMainParts::PreMainMessageLoopRun() { + browser_context_.reset(new CefBrowserContext()); + + // Initialize the request context getter. + _Context->set_request_context(browser_context_->GetRequestContext()); + + // Initialize proxy configuration service. + ChromeProxyConfigService* chrome_proxy_config_service = + ProxyServiceFactory::CreateProxyConfigService(); + proxy_config_service_.reset(chrome_proxy_config_service); + pref_proxy_config_tracker_->SetChromeProxyConfigService( + chrome_proxy_config_service); + + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) { + std::string port_str = + command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort); + int port; + if (base::StringToInt(port_str, &port) && port > 0 && port < 65535) { + devtools_delegate_ = new CefDevToolsDelegate(port); + } else { + LOG(WARNING) << "Invalid http debugger port number " << port; + } + } +} + +void CefBrowserMainParts::PostMainMessageLoopRun() { + if (devtools_delegate_) + devtools_delegate_->Stop(); + pref_proxy_config_tracker_->DetachFromPrefService(); + _Context->set_request_context(NULL); + browser_context_.reset(); +} + +void CefBrowserMainParts::PostDestroyThreads() { + pref_proxy_config_tracker_.reset(NULL); + + if (proxy_v8_isolate_) { + proxy_v8_isolate_->Exit(); + proxy_v8_isolate_->Dispose(); + } + + PlatformCleanup(); +} diff --git a/cef3/libcef/browser/browser_main.h b/cef3/libcef/browser/browser_main.h new file mode 100644 index 000000000..33929eafd --- /dev/null +++ b/cef3/libcef/browser/browser_main.h @@ -0,0 +1,70 @@ +// Copyright (c) 2011 The Chromium 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_LIBCEF_BROWSER_BROWSER_MAIN_H_ +#define CEF_LIBCEF_BROWSER_BROWSER_MAIN_H_ +#pragma once + +#include "libcef/browser/browser_pref_store.h" + +#include "base/basictypes.h" +#include "base/memory/scoped_ptr.h" +#include "base/prefs/pref_service.h" +#include "base/string_piece.h" +#include "chrome/browser/net/pref_proxy_config_tracker.h" +#include "content/public/browser/browser_main_parts.h" +#include "net/proxy/proxy_config_service.h" + +namespace base { +class Thread; +} + +namespace content { +struct MainFunctionParams; +} + +namespace v8 { +class Isolate; +} + +class CefBrowserContext; +class CefDevToolsDelegate; +class MessageLoop; + +class CefBrowserMainParts : public content::BrowserMainParts { + public: + explicit CefBrowserMainParts(const content::MainFunctionParams& parameters); + virtual ~CefBrowserMainParts(); + + virtual void PreMainMessageLoopStart() OVERRIDE; + virtual void PostMainMessageLoopStart() OVERRIDE; + virtual int PreCreateThreads() OVERRIDE; + virtual void PreMainMessageLoopRun() OVERRIDE; + virtual void PostMainMessageLoopRun() OVERRIDE; + virtual void PostDestroyThreads() OVERRIDE; + + CefBrowserContext* browser_context() const { return browser_context_.get(); } + CefDevToolsDelegate* devtools_delegate() const { return devtools_delegate_; } + PrefService* pref_service() const { return pref_service_.get(); } + scoped_ptr proxy_config_service() { + return proxy_config_service_.Pass(); + } + + private: + void PlatformInitialize(); + void PlatformCleanup(); + + scoped_ptr browser_context_; + CefDevToolsDelegate* devtools_delegate_; + scoped_ptr message_loop_; + scoped_ptr pref_proxy_config_tracker_; + scoped_ptr proxy_config_service_; + scoped_refptr pref_store_; + scoped_ptr pref_service_; + v8::Isolate* proxy_v8_isolate_; + + DISALLOW_COPY_AND_ASSIGN(CefBrowserMainParts); +}; + +#endif // CEF_LIBCEF_BROWSER_BROWSER_MAIN_H_ diff --git a/cef3/libcef/browser/browser_main_gtk.cc b/cef3/libcef/browser/browser_main_gtk.cc new file mode 100644 index 000000000..0f547f331 --- /dev/null +++ b/cef3/libcef/browser/browser_main_gtk.cc @@ -0,0 +1,15 @@ +// Copyright (c) 2011 The Chromium 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 + +#include "libcef/browser/browser_main.h" + +#include "base/string_piece.h" + +void CefBrowserMainParts::PlatformInitialize() { +} + +void CefBrowserMainParts::PlatformCleanup() { +} diff --git a/cef3/libcef/browser/browser_main_mac.mm b/cef3/libcef/browser/browser_main_mac.mm new file mode 100644 index 000000000..19170320f --- /dev/null +++ b/cef3/libcef/browser/browser_main_mac.mm @@ -0,0 +1,13 @@ +// Copyright (c) 2011 The Chromium 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 "libcef/browser/browser_main.h" + +#include "base/string_piece.h" + +void CefBrowserMainParts::PlatformInitialize() { +} + +void CefBrowserMainParts::PlatformCleanup() { +} diff --git a/cef3/libcef/browser/browser_main_win.cc b/cef3/libcef/browser/browser_main_win.cc new file mode 100644 index 000000000..45109e3a4 --- /dev/null +++ b/cef3/libcef/browser/browser_main_win.cc @@ -0,0 +1,35 @@ +// Copyright (c) 2012 The Chromium 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 +#include +#include + +#include "libcef/browser/browser_host_impl.h" +#include "libcef/browser/browser_main.h" + +#include "base/string_piece.h" +#include "base/win/resource_util.h" + +void CefBrowserMainParts::PlatformInitialize() { + HRESULT res; + + // Initialize common controls. + res = CoInitialize(NULL); + DCHECK(SUCCEEDED(res)); + INITCOMMONCONTROLSEX InitCtrlEx; + InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX); + InitCtrlEx.dwICC = ICC_STANDARD_CLASSES; + InitCommonControlsEx(&InitCtrlEx); + + // Start COM stuff. + res = OleInitialize(NULL); + DCHECK(SUCCEEDED(res)); + + // Register the browser window class. + CefBrowserHostImpl::RegisterWindowClass(); +} + +void CefBrowserMainParts::PlatformCleanup() { +} diff --git a/cef3/libcef/browser/browser_message_filter.cc b/cef3/libcef/browser/browser_message_filter.cc new file mode 100644 index 000000000..057bee82e --- /dev/null +++ b/cef3/libcef/browser/browser_message_filter.cc @@ -0,0 +1,100 @@ +/// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions (c) 2011 The Chromium 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 "libcef/browser/browser_message_filter.h" + +#include "libcef/browser/browser_host_impl.h" +#include "libcef/browser/browser_info.h" +#include "libcef/browser/content_browser_client.h" +#include "libcef/browser/context.h" +#include "libcef/browser/origin_whitelist_impl.h" +#include "libcef/browser/thread_util.h" +#include "libcef/common/cef_messages.h" +#include "libcef/common/values_impl.h" + +#include "base/compiler_specific.h" +#include "base/bind.h" +#include "content/common/view_messages.h" +#include "content/public/browser/render_process_host.h" + +CefBrowserMessageFilter::CefBrowserMessageFilter( + content::RenderProcessHost* host) + : host_(host), + channel_(NULL) { +} + +CefBrowserMessageFilter::~CefBrowserMessageFilter() { +} + +void CefBrowserMessageFilter::OnFilterAdded(IPC::Channel* channel) { + channel_ = channel; +} + +void CefBrowserMessageFilter::OnFilterRemoved() { +} + +bool CefBrowserMessageFilter::OnMessageReceived(const IPC::Message& message) { + bool handled = true; + if (message.type() == ViewHostMsg_CreateWindow::ID) { + // Observe but don't handle this message. + handled = false; + } + + IPC_BEGIN_MESSAGE_MAP(CefBrowserMessageFilter, message) + IPC_MESSAGE_HANDLER(CefProcessHostMsg_GetNewRenderThreadInfo, + OnGetNewRenderThreadInfo) + IPC_MESSAGE_HANDLER(CefProcessHostMsg_GetNewBrowserInfo, + OnGetNewBrowserInfo) + IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_CreateWindow, OnCreateWindow) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + +bool CefBrowserMessageFilter::Send(IPC::Message* message) { + return host_->Send(message); +} + +void CefBrowserMessageFilter::OnGetNewRenderThreadInfo( + CefProcessHostMsg_GetNewRenderThreadInfo_Params* params) { + GetCrossOriginWhitelistEntries(¶ms->cross_origin_whitelist_entries); + + CefRefPtr app = _Context->application(); + if (app.get()) { + CefRefPtr handler = + app->GetBrowserProcessHandler(); + if (handler.get()) { + CefRefPtr listValuePtr( + new CefListValueImpl(¶ms->extra_info, false, false)); + handler->OnRenderProcessThreadCreated(listValuePtr.get()); + listValuePtr->Detach(NULL); + } + } +} + +void CefBrowserMessageFilter::OnGetNewBrowserInfo( + int routing_id, CefProcessHostMsg_GetNewBrowserInfo_Params* params) { + // Popup windows may not have info yet. + scoped_refptr info = + CefContentBrowserClient::Get()->GetOrCreateBrowserInfo(host_->GetID(), + routing_id); + params->browser_id = info->browser_id(); + params->is_popup = info->is_popup(); +} + +void CefBrowserMessageFilter::OnCreateWindow( + const ViewHostMsg_CreateWindow_Params& params, + IPC::Message* reply_msg) { + CefContentBrowserClient::LastCreateWindowParams lcwp; + lcwp.opener_process_id = host_->GetID(); + lcwp.opener_view_id = params.opener_id; + lcwp.opener_frame_id = params.opener_frame_id; + lcwp.target_url = params.target_url; + lcwp.target_frame_name = params.frame_name; + CefContentBrowserClient::Get()->set_last_create_window_params(lcwp); + + // Reply message is not used. + delete reply_msg; +} diff --git a/cef3/libcef/browser/browser_message_filter.h b/cef3/libcef/browser/browser_message_filter.h new file mode 100644 index 000000000..490723165 --- /dev/null +++ b/cef3/libcef/browser/browser_message_filter.h @@ -0,0 +1,49 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 The Chromium 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_LIBCEF_BROWSER_BROWSER_MESSAGE_FILTER_H_ +#define CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_FILTER_H_ + +#include +#include "ipc/ipc_channel_proxy.h" + +namespace content { +class RenderProcessHost; +} + +struct CefProcessHostMsg_GetNewBrowserInfo_Params; +struct CefProcessHostMsg_GetNewRenderThreadInfo_Params; +struct ViewHostMsg_CreateWindow_Params; + +// This class sends and receives control messages on the browser process. +class CefBrowserMessageFilter : public IPC::ChannelProxy::MessageFilter { + public: + explicit CefBrowserMessageFilter(content::RenderProcessHost* host); + virtual ~CefBrowserMessageFilter(); + + // IPC::ChannelProxy::MessageFilter implementation. + virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; + virtual void OnFilterRemoved() OVERRIDE; + virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; + + bool Send(IPC::Message* message); + + private: + // Message handlers. + void OnGetNewRenderThreadInfo( + CefProcessHostMsg_GetNewRenderThreadInfo_Params* params); + void OnGetNewBrowserInfo(int routing_id, + CefProcessHostMsg_GetNewBrowserInfo_Params* params); + void OnCreateWindow(const ViewHostMsg_CreateWindow_Params& params, + IPC::Message* reply_msg); + + content::RenderProcessHost* host_; + IPC::Channel* channel_; + + DISALLOW_COPY_AND_ASSIGN(CefBrowserMessageFilter); +}; + + +#endif // CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_FILTER_H_ diff --git a/cef3/libcef/browser/browser_message_loop.cc b/cef3/libcef/browser/browser_message_loop.cc new file mode 100644 index 000000000..57846fb47 --- /dev/null +++ b/cef3/libcef/browser/browser_message_loop.cc @@ -0,0 +1,28 @@ +// 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 "libcef/browser/browser_message_loop.h" +#include "base/run_loop.h" + +CefBrowserMessageLoop::CefBrowserMessageLoop() { +} + +CefBrowserMessageLoop::~CefBrowserMessageLoop() { +} + +// static +CefBrowserMessageLoop* CefBrowserMessageLoop::current() { + MessageLoop* loop = MessageLoop::current(); + DCHECK_EQ(MessageLoop::TYPE_UI, loop->type()); + return static_cast(loop); +} + +void CefBrowserMessageLoop::DoMessageLoopIteration() { + base::RunLoop run_loop; + run_loop.RunUntilIdle(); +} + +void CefBrowserMessageLoop::RunMessageLoop() { + Run(); +} diff --git a/cef3/libcef/browser/browser_message_loop.h b/cef3/libcef/browser/browser_message_loop.h new file mode 100644 index 000000000..a5200a896 --- /dev/null +++ b/cef3/libcef/browser/browser_message_loop.h @@ -0,0 +1,33 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_LOOP_H_ +#define CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_LOOP_H_ +#pragma once + +#include "base/basictypes.h" +#include "base/message_loop.h" + +// Class used to process events on the current message loop. +class CefBrowserMessageLoop : public MessageLoopForUI { + typedef MessageLoopForUI inherited; + + public: + CefBrowserMessageLoop(); + virtual ~CefBrowserMessageLoop(); + + // Returns the MessageLoopForUI of the current thread. + static CefBrowserMessageLoop* current(); + + // Do a single interation of the UI message loop. + void DoMessageLoopIteration(); + + // Run the UI message loop. + void RunMessageLoop(); + + private: + DISALLOW_COPY_AND_ASSIGN(CefBrowserMessageLoop); +}; + +#endif // CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_LOOP_H_ diff --git a/cef3/libcef/browser/browser_pref_store.cc b/cef3/libcef/browser/browser_pref_store.cc new file mode 100644 index 000000000..69303b95c --- /dev/null +++ b/cef3/libcef/browser/browser_pref_store.cc @@ -0,0 +1,36 @@ +// Copyright (c) 2013 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 "libcef/browser/browser_pref_store.h" +#include "libcef/browser/media_capture_devices_dispatcher.h" + +#include "base/command_line.h" +#include "base/prefs/pref_service_builder.h" +#include "base/prefs/pref_registry_simple.h" +#include "base/values.h" +#include "chrome/browser/net/pref_proxy_config_tracker_impl.h" +#include "chrome/browser/prefs/command_line_pref_store.h" +#include "chrome/browser/prefs/proxy_config_dictionary.h" +#include "chrome/common/pref_names.h" + +CefBrowserPrefStore::CefBrowserPrefStore() { +} + +PrefService* CefBrowserPrefStore::CreateService() { + PrefServiceBuilder builder; + builder.WithCommandLinePrefs( + new CommandLinePrefStore(CommandLine::ForCurrentProcess())); + builder.WithUserPrefs(this); + + scoped_refptr registry(new PrefRegistrySimple()); + + // Default settings. + CefMediaCaptureDevicesDispatcher::RegisterPrefs(registry); + PrefProxyConfigTrackerImpl::RegisterPrefs(registry); + + return builder.Create(registry); +} + +CefBrowserPrefStore::~CefBrowserPrefStore() { +} diff --git a/cef3/libcef/browser/browser_pref_store.h b/cef3/libcef/browser/browser_pref_store.h new file mode 100644 index 000000000..e4ed69cb3 --- /dev/null +++ b/cef3/libcef/browser/browser_pref_store.h @@ -0,0 +1,24 @@ +// Copyright (c) 2013 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_LIBCEF_BROWSER_BROWSER_PREF_STORE_H_ +#define CEF_LIBCEF_BROWSER_BROWSER_PREF_STORE_H_ + +#include "base/prefs/testing_pref_store.h" + +class PrefService; + +class CefBrowserPrefStore : public TestingPrefStore { + public: + CefBrowserPrefStore(); + + PrefService* CreateService(); + + protected: + virtual ~CefBrowserPrefStore(); + + DISALLOW_COPY_AND_ASSIGN(CefBrowserPrefStore); +}; + +#endif // CEF_LIBCEF_BROWSER_BROWSER_PREF_STORE_H_ diff --git a/cef3/libcef/browser/browser_settings.cc b/cef3/libcef/browser/browser_settings.cc new file mode 100644 index 000000000..eba262783 --- /dev/null +++ b/cef3/libcef/browser/browser_settings.cc @@ -0,0 +1,152 @@ +// Copyright (c) 2010 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 "libcef/browser/browser_settings.h" + +#include + +#include "libcef/common/cef_switches.h" + +#include "base/command_line.h" +#include "include/internal/cef_types_wrappers.h" +#include "webkit/glue/webpreferences.h" + +using webkit_glue::WebPreferences; + +// Set default preferences based on CEF command-line flags. Chromium command- +// line flags should not exist for these preferences. +void SetDefaults(WebPreferences& web) { + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + + if (command_line.HasSwitch(switches::kDefaultEncoding)) { + web.default_encoding = + command_line.GetSwitchValueASCII(switches::kDefaultEncoding); + } + + if (command_line.HasSwitch(switches::kUserStyleSheetLocation)) { + web.user_style_sheet_location = GURL( + command_line.GetSwitchValueASCII(switches::kUserStyleSheetLocation)); + if (!web.user_style_sheet_location.is_empty()) + web.user_style_sheet_enabled = true; + } + + web.javascript_can_open_windows_automatically = + !command_line.HasSwitch(switches::kDisableJavascriptOpenWindows); + web.allow_scripts_to_close_windows = + !command_line.HasSwitch(switches::kDisableJavascriptCloseWindows); + web.javascript_can_access_clipboard = + !command_line.HasSwitch(switches::kDisableJavascriptAccessClipboard); + web.dom_paste_enabled = + !command_line.HasSwitch(switches::kDisableJavascriptDomPaste); + web.caret_browsing_enabled = + command_line.HasSwitch(switches::kEnableCaretBrowsing); + web.allow_universal_access_from_file_urls = + command_line.HasSwitch(switches::kAllowUniversalAccessFromFileUrls); + web.loads_images_automatically = + !command_line.HasSwitch(switches::kDisableImageLoading); + web.shrinks_standalone_images_to_fit = + command_line.HasSwitch(switches::kImageShrinkStandaloneToFit); + web.text_areas_are_resizable = + !command_line.HasSwitch(switches::kDisableTextAreaResize); + web.tabs_to_links = + !command_line.HasSwitch(switches::kDisableTabToLinks); + web.author_and_user_styles_enabled = + !command_line.HasSwitch(switches::kDisableAuthorAndUserStyles); + web.developer_extras_enabled = + !command_line.HasSwitch(switches::kDisableDeveloperTools); +} + +// Helper macro for setting a WebPreferences variable based on the value of a +// CefBrowserSettings variable. +#define SET_STATE(cef_var, web_var) \ + if (cef_var == STATE_ENABLED) \ + web_var = true; \ + else if (cef_var == STATE_DISABLED) \ + web_var = false; + +// Use the preferences from WebContentsImpl::GetWebkitPrefs and the +// WebPreferences constructor by default. Only override features that are +// explicitly enabled or disabled. +void BrowserToWebSettings(const CefBrowserSettings& cef, WebPreferences& web) { + SetDefaults(web); + + if (cef.standard_font_family.length > 0) { + web.standard_font_family_map[WebPreferences::kCommonScript] = + CefString(&cef.standard_font_family); + } + if (cef.fixed_font_family.length > 0) { + web.fixed_font_family_map[WebPreferences::kCommonScript] = + CefString(&cef.fixed_font_family); + } + if (cef.serif_font_family.length > 0) { + web.serif_font_family_map[WebPreferences::kCommonScript] = + CefString(&cef.serif_font_family); + } + if (cef.sans_serif_font_family.length > 0) { + web.sans_serif_font_family_map[WebPreferences::kCommonScript] = + CefString(&cef.sans_serif_font_family); + } + if (cef.cursive_font_family.length > 0) { + web.cursive_font_family_map[WebPreferences::kCommonScript] = + CefString(&cef.cursive_font_family); + } + if (cef.fantasy_font_family.length > 0) { + web.fantasy_font_family_map[WebPreferences::kCommonScript] = + CefString(&cef.fantasy_font_family); + } + + if (cef.default_font_size > 0) + web.default_font_size = cef.default_font_size; + if (cef.default_fixed_font_size > 0) + web.default_fixed_font_size = cef.default_fixed_font_size; + if (cef.minimum_font_size > 0) + web.minimum_font_size = cef.minimum_font_size; + if (cef.minimum_logical_font_size > 0) + web.minimum_logical_font_size = cef.minimum_logical_font_size; + + if (cef.default_encoding.length > 0) + web.default_encoding = CefString(&cef.default_encoding); + + if (cef.user_style_sheet_location.length > 0) { + web.user_style_sheet_enabled = true; + web.user_style_sheet_location = + GURL(CefString(&cef.user_style_sheet_location).ToString()); + } + + SET_STATE(cef.remote_fonts, web.remote_fonts_enabled); + SET_STATE(cef.javascript, web.javascript_enabled); + SET_STATE(cef.javascript_open_windows, + web.javascript_can_open_windows_automatically); + SET_STATE(cef.javascript_close_windows, web.allow_scripts_to_close_windows); + SET_STATE(cef.javascript_access_clipboard, + web.javascript_can_access_clipboard); + SET_STATE(cef.javascript_dom_paste, web.dom_paste_enabled); + SET_STATE(cef.caret_browsing, web.caret_browsing_enabled); + SET_STATE(cef.java, web.java_enabled); + SET_STATE(cef.plugins, web.plugins_enabled); + SET_STATE(cef.universal_access_from_file_urls, + web.allow_universal_access_from_file_urls); + SET_STATE(cef.file_access_from_file_urls, + web.allow_file_access_from_file_urls); + SET_STATE(cef.web_security, web.web_security_enabled); + SET_STATE(cef.image_loading, web.loads_images_automatically); + SET_STATE(cef.image_shrink_standalone_to_fit, + web.shrinks_standalone_images_to_fit); + SET_STATE(cef.text_area_resize, web.text_areas_are_resizable); + SET_STATE(cef.page_cache, web.uses_page_cache); + SET_STATE(cef.tab_to_links, web.tabs_to_links); + SET_STATE(cef.author_and_user_styles, web.author_and_user_styles_enabled); + SET_STATE(cef.local_storage, web.local_storage_enabled); + SET_STATE(cef.databases, web.databases_enabled); + SET_STATE(cef.application_cache, web.application_cache_enabled); + + // Never explicitly enable GPU-related functions in this method because the + // GPU blacklist is not being checked here. + if (cef.webgl == STATE_DISABLED) + web.experimental_webgl_enabled = false; + if (cef.accelerated_compositing == STATE_DISABLED) + web.accelerated_compositing_enabled = false; + + SET_STATE(cef.developer_tools, web.developer_extras_enabled); +} diff --git a/cef3/libcef/browser/browser_settings.h b/cef3/libcef/browser/browser_settings.h new file mode 100644 index 000000000..8e182259e --- /dev/null +++ b/cef3/libcef/browser/browser_settings.h @@ -0,0 +1,18 @@ +// Copyright (c) 2010 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_LIBCEF_BROWSER_BROWSER_SETTINGS_H_ +#define CEF_LIBCEF_BROWSER_BROWSER_SETTINGS_H_ +#pragma once + +#include "include/internal/cef_types_wrappers.h" + +namespace webkit_glue { +struct WebPreferences; +} + +void BrowserToWebSettings(const CefBrowserSettings& cef, + webkit_glue::WebPreferences& web); + +#endif // CEF_LIBCEF_BROWSER_BROWSER_SETTINGS_H_ diff --git a/cef3/libcef/browser/browser_urlrequest_impl.cc b/cef3/libcef/browser/browser_urlrequest_impl.cc new file mode 100644 index 000000000..01cb62836 --- /dev/null +++ b/cef3/libcef/browser/browser_urlrequest_impl.cc @@ -0,0 +1,440 @@ +// 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 "libcef/browser/browser_urlrequest_impl.h" + +#include + +#include "libcef/browser/browser_context.h" +#include "libcef/browser/context.h" +#include "libcef/browser/thread_util.h" +#include "libcef/common/http_header_utils.h" +#include "libcef/common/request_impl.h" +#include "libcef/common/response_impl.h" + +#include "base/logging.h" +#include "base/message_loop.h" +#include "base/string_util.h" +#include "content/public/common/url_fetcher.h" +#include "net/base/load_flags.h" +#include "net/http/http_request_headers.h" +#include "net/http/http_response_headers.h" +#include "net/url_request/url_fetcher.h" +#include "net/url_request/url_fetcher_delegate.h" +#include "net/url_request/url_request_status.h" + + +namespace { + +class CefURLFetcherDelegate : public net::URLFetcherDelegate { + public: + CefURLFetcherDelegate(CefBrowserURLRequest::Context* context, + int request_flags); + virtual ~CefURLFetcherDelegate(); + + // net::URLFetcherDelegate methods. + virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; + virtual void OnURLFetchDownloadProgress(const net::URLFetcher* source, + int64 current, int64 total) OVERRIDE; + virtual void OnURLFetchDownloadData(const net::URLFetcher* source, + scoped_ptr download_data) + OVERRIDE; + virtual bool ShouldSendDownloadData() OVERRIDE; + virtual void OnURLFetchUploadProgress(const net::URLFetcher* source, + int64 current, int64 total) OVERRIDE; + + private: + // The context_ pointer will outlive this object. + CefBrowserURLRequest::Context* context_; + int request_flags_; +}; + +} // namespace + + +// CefBrowserURLRequest::Context ---------------------------------------------- + +class CefBrowserURLRequest::Context + : public base::RefCountedThreadSafe { + public: + Context(CefRefPtr url_request, + CefRefPtr request, + CefRefPtr client) + : url_request_(url_request), + request_(request), + client_(client), + message_loop_proxy_(MessageLoop::current()->message_loop_proxy()), + status_(UR_IO_PENDING), + error_code_(ERR_NONE), + upload_data_size_(0), + got_upload_progress_complete_(false) { + // Mark the request as read-only. + static_cast(request_.get())->SetReadOnly(true); + } + + virtual ~Context() { + if (fetcher_.get()) { + // Delete the fetcher object on the thread that created it. + message_loop_proxy_->DeleteSoon(FROM_HERE, fetcher_.release()); + } + } + + inline bool CalledOnValidThread() { + return message_loop_proxy_->BelongsToCurrentThread(); + } + + bool Start() { + DCHECK(CalledOnValidThread()); + + GURL url = GURL(request_->GetURL().ToString()); + if (!url.is_valid()) + return false; + + std::string method = request_->GetMethod(); + StringToLowerASCII(&method); + net::URLFetcher::RequestType request_type = net::URLFetcher::GET; + if (LowerCaseEqualsASCII(method, "get")) { + } else if (LowerCaseEqualsASCII(method, "post")) { + request_type = net::URLFetcher::POST; + } else if (LowerCaseEqualsASCII(method, "head")) { + request_type = net::URLFetcher::HEAD; + } else if (LowerCaseEqualsASCII(method, "delete")) { + request_type = net::URLFetcher::DELETE_REQUEST; + } else if (LowerCaseEqualsASCII(method, "put")) { + request_type = net::URLFetcher::PUT; + } else { + NOTREACHED() << "invalid request type"; + return false; + } + + fetcher_delegate_.reset( + new CefURLFetcherDelegate(this, request_->GetFlags())); + + fetcher_.reset(net::URLFetcher::Create(url, request_type, + fetcher_delegate_.get())); + fetcher_->SetRequestContext(_Context->request_context()); + + CefRequest::HeaderMap headerMap; + request_->GetHeaderMap(headerMap); + + // Extract the Referer header value. + { + CefString referrerStr; + referrerStr.FromASCII(net::HttpRequestHeaders::kReferer); + CefRequest::HeaderMap::iterator it = headerMap.find(referrerStr); + if (it == headerMap.end()) { + fetcher_->SetReferrer(""); + } else { + fetcher_->SetReferrer(it->second); + headerMap.erase(it); + } + } + + std::string content_type; + + // Extract the Content-Type header value. + { + CefString contentTypeStr; + contentTypeStr.FromASCII(net::HttpRequestHeaders::kContentType); + CefRequest::HeaderMap::iterator it = headerMap.find(contentTypeStr); + if (it != headerMap.end()) { + content_type = it->second; + headerMap.erase(it); + } + } + + int64 upload_data_size = 0; + + CefRefPtr post_data = request_->GetPostData(); + if (post_data.get()) { + CefPostData::ElementVector elements; + post_data->GetElements(elements); + if (elements.size() == 1 && elements[0]->GetType() == PDE_TYPE_BYTES) { + CefPostDataElementImpl* impl = + static_cast(elements[0].get()); + + // Default to URL encoding if not specified. + if (content_type.empty()) + content_type = "application/x-www-form-urlencoded"; + + upload_data_size = impl->GetBytesCount(); + fetcher_->SetUploadData(content_type, + std::string(static_cast(impl->GetBytes()), + upload_data_size)); + } else { + NOTIMPLEMENTED() << "multi-part form data is not supported"; + } + } + + std::string first_party_for_cookies = request_->GetFirstPartyForCookies(); + if (!first_party_for_cookies.empty()) + fetcher_->SetFirstPartyForCookies(GURL(first_party_for_cookies)); + + int cef_flags = request_->GetFlags(); + + if (cef_flags & UR_FLAG_NO_RETRY_ON_5XX) + fetcher_->SetAutomaticallyRetryOn5xx(false); + + int load_flags = 0; + + if (cef_flags & UR_FLAG_SKIP_CACHE) + load_flags |= net::LOAD_BYPASS_CACHE; + + if (cef_flags & UR_FLAG_ALLOW_CACHED_CREDENTIALS) { + if (!(cef_flags & UR_FLAG_ALLOW_COOKIES)) { + load_flags |= net::LOAD_DO_NOT_SEND_COOKIES; + load_flags |= net::LOAD_DO_NOT_SAVE_COOKIES; + } + } else { + load_flags |= net::LOAD_DO_NOT_SEND_AUTH_DATA; + load_flags |= net::LOAD_DO_NOT_SEND_COOKIES; + load_flags |= net::LOAD_DO_NOT_SAVE_COOKIES; + } + + if (cef_flags & UR_FLAG_REPORT_UPLOAD_PROGRESS) { + load_flags |= net::LOAD_ENABLE_UPLOAD_PROGRESS; + upload_data_size_ = upload_data_size; + } + + if (cef_flags & UR_FLAG_REPORT_LOAD_TIMING) + load_flags |= net::LOAD_ENABLE_LOAD_TIMING; + + if (cef_flags & UR_FLAG_REPORT_RAW_HEADERS) + load_flags |= net::LOAD_REPORT_RAW_HEADERS; + + fetcher_->SetLoadFlags(load_flags); + + fetcher_->SetExtraRequestHeaders( + HttpHeaderUtils::GenerateHeaders(headerMap)); + + fetcher_->Start(); + + return true; + } + + void Cancel() { + DCHECK(CalledOnValidThread()); + + // The request may already be complete. + if (!fetcher_.get()) + return; + + // Cancel the fetch by deleting the fetcher. + fetcher_.reset(NULL); + + status_ = UR_CANCELED; + error_code_ = ERR_ABORTED; + OnComplete(); + } + + void OnComplete() { + DCHECK(CalledOnValidThread()); + + if (fetcher_.get()) { + const net::URLRequestStatus& status = fetcher_->GetStatus(); + + if (status.is_success()) + NotifyUploadProgressIfNecessary(); + + switch (status.status()) { + case net::URLRequestStatus::SUCCESS: + status_ = UR_SUCCESS; + break; + case net::URLRequestStatus::IO_PENDING: + status_ = UR_IO_PENDING; + break; + case net::URLRequestStatus::CANCELED: + status_ = UR_CANCELED; + break; + case net::URLRequestStatus::FAILED: + status_ = UR_FAILED; + break; + } + + error_code_ = static_cast(status.error()); + + response_ = new CefResponseImpl(); + CefResponseImpl* responseImpl = + static_cast(response_.get()); + + net::HttpResponseHeaders* headers = fetcher_->GetResponseHeaders(); + if (headers) + responseImpl->SetResponseHeaders(*headers); + + responseImpl->SetReadOnly(true); + } + + DCHECK(url_request_.get()); + client_->OnRequestComplete(url_request_.get()); + + if (fetcher_.get()) + fetcher_.reset(NULL); + + // This may result in the Context object being deleted. + url_request_ = NULL; + } + + void OnDownloadProgress(int64 current, int64 total) { + DCHECK(CalledOnValidThread()); + DCHECK(url_request_.get()); + + NotifyUploadProgressIfNecessary(); + + client_->OnDownloadProgress(url_request_.get(), current, total); + } + + void OnDownloadData(scoped_ptr download_data) { + DCHECK(CalledOnValidThread()); + DCHECK(url_request_.get()); + client_->OnDownloadData(url_request_.get(), download_data->c_str(), + download_data->length()); + } + + void OnUploadProgress(int64 current, int64 total) { + DCHECK(CalledOnValidThread()); + DCHECK(url_request_.get()); + if (current == total) + got_upload_progress_complete_ = true; + client_->OnUploadProgress(url_request_.get(), current, total); + } + + CefRefPtr request() { return request_; } + CefRefPtr client() { return client_; } + CefURLRequest::Status status() { return status_; } + CefURLRequest::ErrorCode error_code() { return error_code_; } + CefRefPtr response() { return response_; } + + private: + void NotifyUploadProgressIfNecessary() { + if (!got_upload_progress_complete_ && upload_data_size_ > 0) { + // URLFetcher sends upload notifications using a timer and will not send + // a notification if the request completes too quickly. We therefore + // send the notification here if necessary. + client_->OnUploadProgress(url_request_.get(), upload_data_size_, + upload_data_size_); + got_upload_progress_complete_ = true; + } + } + + // Members only accessed on the initialization thread. + CefRefPtr url_request_; + CefRefPtr request_; + CefRefPtr client_; + scoped_refptr message_loop_proxy_; + scoped_ptr fetcher_; + scoped_ptr fetcher_delegate_; + CefURLRequest::Status status_; + CefURLRequest::ErrorCode error_code_; + CefRefPtr response_; + int64 upload_data_size_; + bool got_upload_progress_complete_; +}; + + +// CefURLFetcherDelegate ------------------------------------------------------ + +namespace { + +CefURLFetcherDelegate::CefURLFetcherDelegate( + CefBrowserURLRequest::Context* context, int request_flags) + : context_(context), + request_flags_(request_flags) { +} + +CefURLFetcherDelegate::~CefURLFetcherDelegate() { +} + +void CefURLFetcherDelegate::OnURLFetchComplete( + const net::URLFetcher* source) { + context_->OnComplete(); +} + +void CefURLFetcherDelegate::OnURLFetchDownloadProgress( + const net::URLFetcher* source, + int64 current, int64 total) { + context_->OnDownloadProgress(current, total); +} + +void CefURLFetcherDelegate::OnURLFetchDownloadData( + const net::URLFetcher* source, + scoped_ptr download_data) { + context_->OnDownloadData(download_data.Pass()); +} + +bool CefURLFetcherDelegate::ShouldSendDownloadData() { + return !(request_flags_ & UR_FLAG_NO_DOWNLOAD_DATA); +} + +void CefURLFetcherDelegate::OnURLFetchUploadProgress( + const net::URLFetcher* source, + int64 current, int64 total) { + if (request_flags_ & UR_FLAG_REPORT_UPLOAD_PROGRESS) + context_->OnUploadProgress(current, total); +} + +} // namespace + + +// CefBrowserURLRequest ------------------------------------------------------- + +CefBrowserURLRequest::CefBrowserURLRequest( + CefRefPtr request, + CefRefPtr client) { + context_ = new Context(this, request, client); +} + +CefBrowserURLRequest::~CefBrowserURLRequest() { +} + +bool CefBrowserURLRequest::Start() { + if (!VerifyContext()) + return false; + return context_->Start(); +} + +CefRefPtr CefBrowserURLRequest::GetRequest() { + if (!VerifyContext()) + return NULL; + return context_->request(); +} + +CefRefPtr CefBrowserURLRequest::GetClient() { + if (!VerifyContext()) + return NULL; + return context_->client(); +} + +CefURLRequest::Status CefBrowserURLRequest::GetRequestStatus() { + if (!VerifyContext()) + return UR_UNKNOWN; + return context_->status(); +} + +CefURLRequest::ErrorCode CefBrowserURLRequest::GetRequestError() { + if (!VerifyContext()) + return ERR_NONE; + return context_->error_code(); +} + +CefRefPtr CefBrowserURLRequest::GetResponse() { + if (!VerifyContext()) + return NULL; + return context_->response(); +} + +void CefBrowserURLRequest::Cancel() { + if (!VerifyContext()) + return; + return context_->Cancel(); +} + +bool CefBrowserURLRequest::VerifyContext() { + DCHECK(context_.get()); + if (!context_->CalledOnValidThread()) { + NOTREACHED() << "called on invalid thread"; + return false; + } + + return true; +} diff --git a/cef3/libcef/browser/browser_urlrequest_impl.h b/cef3/libcef/browser/browser_urlrequest_impl.h new file mode 100644 index 000000000..e1e186940 --- /dev/null +++ b/cef3/libcef/browser/browser_urlrequest_impl.h @@ -0,0 +1,37 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_BROWSER_URLREQUEST_IMPL_H_ +#define CEF_LIBCEF_BROWSER_BROWSER_URLREQUEST_IMPL_H_ + +#include "include/cef_urlrequest.h" +#include "base/memory/ref_counted.h" + +class CefBrowserURLRequest : public CefURLRequest { + public: + class Context; + + CefBrowserURLRequest(CefRefPtr request, + CefRefPtr client); + virtual ~CefBrowserURLRequest(); + + bool Start(); + + // CefURLRequest methods. + virtual CefRefPtr GetRequest() OVERRIDE; + virtual CefRefPtr GetClient() OVERRIDE; + virtual Status GetRequestStatus() OVERRIDE; + virtual ErrorCode GetRequestError() OVERRIDE; + virtual CefRefPtr GetResponse() OVERRIDE; + virtual void Cancel() OVERRIDE; + + private: + bool VerifyContext(); + + scoped_refptr context_; + + IMPLEMENT_REFCOUNTING(CefBrowserURLRequest); +}; + +#endif // CEF_LIBCEF_BROWSER_BROWSER_URLREQUEST_IMPL_H_ diff --git a/cef3/libcef/browser/chrome_scheme_handler.cc b/cef3/libcef/browser/chrome_scheme_handler.cc new file mode 100644 index 000000000..cfec7f9e2 --- /dev/null +++ b/cef3/libcef/browser/chrome_scheme_handler.cc @@ -0,0 +1,701 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2012 The Chromium 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 "libcef/browser/chrome_scheme_handler.h" + +#include +#include + +#include "include/cef_trace.h" +#include "include/cef_version.h" +#include "include/cef_web_plugin.h" +#include "libcef/browser/context.h" +#include "libcef/browser/frame_host_impl.h" +#include "libcef/browser/internal_scheme_handler.h" +#include "libcef/browser/scheme_impl.h" +#include "libcef/browser/thread_util.h" + +#include "base/command_line.h" +#include "base/file_util.h" +#include "base/logging.h" +#include "base/path_service.h" +#include "base/string_util.h" +#include "base/stringprintf.h" +#include "base/utf_string_conversions.h" +#include "base/values.h" +#include "content/browser/net/view_http_cache_job_factory.h" +#include "content/browser/net/view_blob_internals_job_factory.h" +#include "content/public/common/content_client.h" +#include "content/public/common/url_constants.h" +#include "grit/cef_resources.h" +#include "ipc/ipc_channel.h" +#include "net/url_request/url_request.h" +#include "v8/include/v8.h" +#include "webkit/user_agent/user_agent_util.h" + +namespace scheme { + +const char kChromeURL[] = "chrome://"; +const char kChromeProcessMessage[] = "chrome.send"; + +namespace { + +const char kChromeCreditsDomain[] = "credits"; +const char kChromeLicenseDomain[] = "license"; +const char kChromeTracingDomain[] = "tracing"; +const char kChromeVersionDomain[] = "version"; + +enum ChromeDomain { + CHROME_UNKNOWN = 0, + CHROME_CREDITS, + CHROME_LICENSE, + CHROME_TRACING, + CHROME_VERSION, +}; + +ChromeDomain GetChromeDomain(const std::string& domain_name) { + static struct { + const char* name; + ChromeDomain domain; + } domains[] = { + { kChromeCreditsDomain, CHROME_CREDITS }, + { kChromeLicenseDomain, CHROME_LICENSE }, + { kChromeTracingDomain, CHROME_TRACING }, + { kChromeVersionDomain, CHROME_VERSION }, + }; + + for (size_t i = 0; i < sizeof(domains) / sizeof(domains[0]); ++i) { + if (base::strcasecmp(domains[i].name, domain_name.c_str()) == 0) + return domains[i].domain; + } + + return CHROME_UNKNOWN; +} + +std::string GetOSType() { +#if defined(OS_WIN) + return "Windows"; +#elif defined(OS_MACOSX) + return "Mac OS X"; +#elif defined(OS_CHROMEOS) + return "Chromium OS"; +#elif defined(OS_ANDROID) + return "Android"; +#elif defined(OS_LINUX) + return "Linux"; +#elif defined(OS_FREEBSD) + return "FreeBSD"; +#elif defined(OS_OPENBSD) + return "OpenBSD"; +#elif defined(OS_SOLARIS) + return "Solaris"; +#else + return "Unknown"; +#endif +} + +std::string GetCommandLine() { +#if defined(OS_WIN) + return WideToUTF8(CommandLine::ForCurrentProcess()->GetCommandLineString()); +#elif defined(OS_POSIX) + std::string command_line = ""; + typedef std::vector ArgvList; + const ArgvList& argv = CommandLine::ForCurrentProcess()->argv(); + for (ArgvList::const_iterator iter = argv.begin(); iter != argv.end(); iter++) + command_line += " " + *iter; + // TODO(viettrungluu): |command_line| could really have any encoding, whereas + // below we assumes it's UTF-8. + return command_line; +#endif +} + +std::string GetModulePath() { + base::FilePath path; + if (PathService::Get(base::FILE_MODULE, &path)) + return CefString(path.value()); + return std::string(); +} + +class TemplateParser { + public: + TemplateParser() + : ident_start_("$$"), + ident_end_("$$") { + } + + TemplateParser(const std::string& ident_start, + const std::string& ident_end) + : ident_start_(ident_start), + ident_end_(ident_end) { + } + + void Add(const std::string& key, const std::string& value) { + values_.insert(std::make_pair(key, value)); + } + + void Parse(std::string* tmpl) { + int start_pos, end_pos = 0; + int ident_start_len = ident_start_.length(); + int ident_end_len = ident_end_.length(); + + while(true) { + start_pos = tmpl->find(ident_start_, end_pos); + if (start_pos >= 0) { + end_pos = tmpl->find(ident_end_, start_pos + ident_start_len); + if (end_pos >= 0) { + // Found an identifier. Check if a substitution exists. + std::string key = tmpl->substr(start_pos + ident_start_len, + end_pos - start_pos - ident_start_len); + KeyMap::const_iterator it = values_.find(key); + if (it != values_.end()) { + // Peform the substitution. + tmpl->replace(start_pos, end_pos + ident_end_len - start_pos, + it->second); + end_pos = start_pos + it->second.length(); + } else { + // Leave the unknown identifier in place. + end_pos += ident_end_len; + } + + if (end_pos >= static_cast(tmpl->length()) - ident_start_len - + ident_end_len) { + // Not enough room remaining for more identifiers. + break; + } + } else { + // No end identifier found. + break; + } + } else { + // No start identifier found. + break; + } + } + } + + private: + typedef std::map KeyMap; + KeyMap values_; + std::string ident_start_; + std::string ident_end_; +}; + +class Delegate : public InternalHandlerDelegate { + public: + Delegate() {} + + virtual bool OnRequest(CefRefPtr request, + Action* action) OVERRIDE { + GURL url = GURL(request->GetURL().ToString()); + std::string path = url.path(); + if (path.length() > 0) + path = path.substr(1); + + bool handled = false; + + ChromeDomain domain = GetChromeDomain(url.host()); + switch (domain) { + case CHROME_CREDITS: + handled = OnCredits(path, action); + break; + case CHROME_LICENSE: + handled = OnLicense(action); + break; + case CHROME_TRACING: + handled = OnTracing(path, action); + break; + case CHROME_VERSION: + handled = OnVersion(action); + break; + default: + break; + } + + if (!handled && domain != CHROME_VERSION) { + LOG(INFO) << "Reguest for unknown chrome resource: " << + url.spec().c_str(); + action->redirect_url = + GURL(std::string(kChromeURL) + kChromeVersionDomain); + } + + return true; + } + + bool OnCredits(const std::string& path, Action* action) { + if (path == "credits.js") { + action->resource_id = IDR_CEF_CREDITS_JS; + } else if (path == "swiftshader.jpg") { + action->resource_id = IDR_CEF_CREDITS_SWIFTSHADER_JPG; + } else { + action->mime_type = "text/html"; + action->resource_id = IDR_CEF_CREDITS_HTML; + } + return true; + } + + bool OnLicense(Action* action) { + base::StringPiece piece = content::GetContentClient()->GetDataResource( + IDR_CEF_LICENSE_TXT, ui::SCALE_FACTOR_NONE); + if (piece.empty()) { + NOTREACHED() << "Failed to load license txt resource."; + return false; + } + + std::string html = "License
" +
+                       piece.as_string() + "
"; + + action->mime_type = "text/html"; + action->stream = CefStreamReader::CreateForData( + const_cast(html.c_str()), html.length()); + action->stream_size = html.length(); + + return true; + } + + bool OnTracing(const std::string& path, Action* action) { + if (path == "tracing.js") { + action->resource_id = IDR_CEF_TRACING_JS; + } else { + action->mime_type = "text/html"; + action->resource_id = IDR_CEF_TRACING_HTML; + } + return true; + } + + bool OnVersion(Action* action) { + base::StringPiece piece = content::GetContentClient()->GetDataResource( + IDR_CEF_VERSION_HTML, ui::SCALE_FACTOR_NONE); + if (piece.empty()) { + NOTREACHED() << "Failed to load version html resource."; + return false; + } + + TemplateParser parser; + parser.Add("YEAR", MAKE_STRING(COPYRIGHT_YEAR)); + parser.Add("CEF", + base::StringPrintf("%d.%d.%d", + CEF_VERSION_MAJOR, + CHROME_VERSION_BUILD, + CEF_REVISION)); + parser.Add("CHROMIUM", + base::StringPrintf("%d.%d.%d.%d", + CHROME_VERSION_MAJOR, + CHROME_VERSION_MINOR, + CHROME_VERSION_BUILD, + CHROME_VERSION_PATCH)); + parser.Add("OS", GetOSType()); + parser.Add("WEBKIT", + base::StringPrintf("%d.%d", + webkit_glue::GetWebKitMajorVersion(), + webkit_glue::GetWebKitMinorVersion())); + parser.Add("JAVASCRIPT", v8::V8::GetVersion()); + parser.Add("FLASH", std::string()); // Value populated asynchronously. + parser.Add("USERAGENT", content::GetUserAgent(GURL())); + parser.Add("COMMANDLINE", GetCommandLine()); + parser.Add("MODULEPATH", GetModulePath()); + parser.Add("CACHEPATH", CefString(_Context->cache_path().value())); + + std::string tmpl = piece.as_string(); + parser.Parse(&tmpl); + + action->mime_type = "text/html"; + action->stream = CefStreamReader::CreateForData( + const_cast(tmpl.c_str()), tmpl.length()); + action->stream_size = tmpl.length(); + + return true; + } +}; + +void DidFinishChromeVersionLoad(CefRefPtr frame) { + // Retieve Flash version information and update asynchronously. + class Visitor : public CefWebPluginInfoVisitor { + public: + Visitor(CefRefPtr frame) + : frame_(frame) { + } + + virtual bool Visit(CefRefPtr info, + int count, int total) OVERRIDE { + std::string name = info->GetName(); + if (name == "Shockwave Flash") { + if (frame_->IsValid()) { + std::string version = info->GetVersion(); + frame_->ExecuteJavaScript( + "document.getElementById('flash').innerText = '" + version + "';", + std::string(), 0); + } + return false; + } + + return true; + } + + private: + CefRefPtr frame_; + + IMPLEMENT_REFCOUNTING(Visitor); + }; + + CefVisitWebPluginInfo(new Visitor(frame)); +} + +// Test that the tracing browser window hasn't closed or navigated elsewhere. +bool IsTraceFrameValid(CefRefPtr frame) { + if (!frame->IsValid()) + return false; + + std::string tracing_url(kChromeURL); + tracing_url += kChromeTracingDomain; + + std::string url = frame->GetURL(); + if (url.find(tracing_url.c_str()) != 0) + return false; + + return true; +} + +void LoadTraceFile(CefRefPtr frame, + const base::FilePath& path) { + CEF_REQUIRE_FILET(); + + if (!IsTraceFrameValid(frame)) + return; + + std::string file_contents; + if (!file_util::ReadFileToString(path, &file_contents)) { + frame->SendJavaScript( + "tracingController.onLoadTraceFileCanceled();", std::string(), 0); + return; + } + + // We need to escape the file contents, because it will go into a javascript + // quoted string in LoadTraceFileSuccess. We need to escape control characters + // (to have well-formed javascript statements), as well as \ and ' (the only + // special characters in a ''-quoted string). Do the escaping on this thread, + // it may take a little while for big files and we don't want to block the UI + // during that time. Also do the UTF-16 conversion here. + // Note: we're using UTF-16 because we'll need to cut the string into slices + // to give to Javascript, and it's easier to cut than UTF-8 (since JS strings + // are arrays of 16-bit values, UCS-2 really, whereas we can't cut inside of a + // multibyte UTF-8 codepoint). + size_t size = file_contents.size(); + std::string escaped_contents; + escaped_contents.reserve(size); + for (size_t i = 0; i < size; ++i) { + char c = file_contents[i]; + if (c < ' ') { + escaped_contents += base::StringPrintf("\\u%04x", c); + continue; + } + if (c == '\\' || c == '\'') + escaped_contents.push_back('\\'); + escaped_contents.push_back(c); + } + file_contents.clear(); + + const string16& contents16 = UTF8ToUTF16(escaped_contents); + + // We need to pass contents to tracingController.onLoadTraceFileComplete, but + // that may be arbitrarily big, and IPC messages are limited in size. So we + // need to cut it into pieces and rebuild the string in Javascript. + // IPC::Channel::kMaximumMessageSize is in bytes, and we need to account for + // overhead. + static const size_t kMaxSize = IPC::Channel::kMaximumMessageSize / 2 - 128; + const string16& first_prefix = ASCIIToUTF16("window.traceData = '"); + const string16& prefix = ASCIIToUTF16("window.traceData += '"); + const string16& suffix = ASCIIToUTF16("';"); + + for (size_t i = 0; i < contents16.size(); i += kMaxSize) { + string16 javascript = i == 0 ? first_prefix : prefix; + javascript += contents16.substr(i, kMaxSize) + suffix; + frame->SendJavaScript(UTF16ToUTF8(javascript), std::string(), 0); + } + + frame->SendJavaScript( + "tracingController.onLoadTraceFileComplete(JSON.parse(window.traceData));" + "delete window.traceData;", + std::string(), 0); +} + +void SaveTraceFile(CefRefPtr frame, + const base::FilePath& path, + scoped_ptr contents) { + CEF_REQUIRE_FILET(); + + if (!IsTraceFrameValid(frame)) + return; + + if (file_util::WriteFile(path, contents->c_str(), contents->size())) { + frame->SendJavaScript( + "tracingController.onSaveTraceFileComplete();", + std::string(), 0); + } else { + frame->SendJavaScript( + "tracingController.onSaveTraceFileCanceled();", + std::string(), 0); + } +} + +void OnChromeTracingProcessMessage(CefRefPtr browser, + const std::string& action, + const base::ListValue* arguments) { + CefRefPtr frame = + static_cast(browser->GetMainFrame().get()); + + if (action == "tracingControllerInitialized") { + // Send the client info to the tracingController. + } else if (action == "beginTracing") { + if (!arguments || arguments->GetSize() != 3) { + NOTREACHED() << "Invalid arguments to " << action.c_str(); + return; + } + + class Client : public CefTraceClient { + public: + explicit Client(CefRefPtr frame) + : frame_(frame), + ended_(false) { + } + + virtual void OnTraceDataCollected(const char* fragment, + size_t fragment_size) OVERRIDE { + const std::string& prefix = "tracingController.onTraceDataCollected(["; + const std::string& suffix = "]);"; + + std::string str; + str.reserve(prefix.size() + fragment_size + suffix.size() + 1); + str.append(prefix); + str.append(fragment, fragment_size); + str.append(suffix); + Execute(str); + } + + virtual void OnTraceBufferPercentFullReply(float percent_full) OVERRIDE { + Execute(base::StringPrintf( + "tracingController.onRequestBufferPercentFullComplete(%f);", + percent_full)); + } + + virtual void OnEndTracingComplete() OVERRIDE { + ended_ = true; + Execute("tracingController.onEndTracingComplete();"); + } + + private: + void Execute(const std::string& code) { + if (!IsTraceFrameValid(frame_) && !ended_) { + ended_ = true; + CefEndTracingAsync(); + return; + } + frame_->SendJavaScript(code, std::string(), 0); + } + + CefRefPtr frame_; + bool ended_; + IMPLEMENT_REFCOUNTING(Callback); + }; + + std::string categories; + arguments->GetString(1, &categories); + + CefRefPtr client = new Client(frame); + + // Tracing may already be running, in which case the previous client will + // continue handling it. + CefBeginTracing(client, categories); + } else if (action == "endTracingAsync") { + if (!CefEndTracingAsync()) { + // We weren't really tracing to begin with. + frame->SendJavaScript( + "tracingController.onEndTracingComplete();", + std::string(), 0); + } + } else if (action == "beginRequestBufferPercentFull") { + CefGetTraceBufferPercentFullAsync(); + } else if (action == "loadTraceFile") { + class Callback : public CefRunFileDialogCallback { + public: + explicit Callback(CefRefPtr frame) + : frame_(frame) { + } + + virtual void OnFileDialogDismissed( + CefRefPtr browser_host, + const std::vector& file_paths) OVERRIDE { + if (!IsTraceFrameValid(frame_)) + return; + + if (!file_paths.empty()) { + CEF_POST_TASK(CEF_FILET, + base::Bind(LoadTraceFile, frame_, + base::FilePath(file_paths.front()))); + } else { + frame_->SendJavaScript( + "tracingController.onLoadTraceFileCanceled();", + std::string(), 0); + } + } + + private: + CefRefPtr frame_; + IMPLEMENT_REFCOUNTING(Callback); + }; + + browser->GetHost()->RunFileDialog(FILE_DIALOG_OPEN, CefString(), + CefString(), std::vector(), new Callback(frame)); + } else if (action == "saveTraceFile") { + if (!arguments || arguments->GetSize() != 1) { + NOTREACHED() << "Invalid arguments to " << action.c_str(); + return; + } + + class Callback : public CefRunFileDialogCallback { + public: + Callback(CefRefPtr frame, + scoped_ptr contents) + : frame_(frame), + contents_(contents.Pass()) { + } + + virtual void OnFileDialogDismissed( + CefRefPtr browser_host, + const std::vector& file_paths) OVERRIDE { + if (!IsTraceFrameValid(frame_)) + return; + + if (!file_paths.empty()) { + CEF_POST_TASK(CEF_FILET, + base::Bind(SaveTraceFile, frame_, + base::FilePath(file_paths.front()), + base::Passed(contents_.Pass()))); + } else { + frame_->SendJavaScript( + "tracingController.onSaveTraceFileCanceled();", + std::string(), 0); + } + } + + private: + CefRefPtr frame_; + scoped_ptr contents_; + IMPLEMENT_REFCOUNTING(Callback); + }; + + std::string contents_str; + arguments->GetString(0, &contents_str); + + scoped_ptr contents(new std::string()); + contents_str.swap(*contents); + + browser->GetHost()->RunFileDialog(FILE_DIALOG_SAVE, CefString(), + CefString(), std::vector(), + new Callback(frame, contents.Pass())); + } else { + NOTREACHED() << "Unknown trace action: " << action.c_str(); + } +} + +// Wrapper for a ChromeProtocolHandler instance from +// content/browser/webui/url_data_manager_backend.cc. +class ChromeProtocolHandlerWrapper : + public net::URLRequestJobFactory::ProtocolHandler { + public: + explicit ChromeProtocolHandlerWrapper( + scoped_ptr chrome_protocol_handler) + : chrome_protocol_handler_(chrome_protocol_handler.Pass()) { + } + + virtual net::URLRequestJob* MaybeCreateJob( + net::URLRequest* request, + net::NetworkDelegate* network_delegate) const OVERRIDE { + // Keep synchronized with the checks in ChromeProtocolHandler::MaybeCreateJob. + if (content::ViewHttpCacheJobFactory::IsSupportedURL(request->url()) || + (request->url().SchemeIs(chrome::kChromeUIScheme) && + request->url().host() == chrome::kChromeUIAppCacheInternalsHost) || + content::ViewBlobInternalsJobFactory::IsSupportedURL(request->url()) || +#if defined(USE_TCMALLOC) + (request->url().SchemeIs(chrome::kChromeUIScheme) && + request->url().host() == chrome::kChromeUITcmallocHost) || +#endif + (request->url().SchemeIs(chrome::kChromeUIScheme) && + request->url().host() == chrome::kChromeUIHistogramHost)) { + return chrome_protocol_handler_->MaybeCreateJob(request, network_delegate); + } + + // Use the protocol handler registered with CEF. + return scheme::GetRequestJob(request, network_delegate); + } + + private: + scoped_ptr chrome_protocol_handler_; +}; + +} // namespace + +void RegisterChromeHandler() { + CefRegisterSchemeHandlerFactory( + chrome::kChromeUIScheme, + std::string(), + CreateInternalHandlerFactory( + make_scoped_ptr(new Delegate()))); +} + +bool WillHandleBrowserAboutURL(GURL* url, + content::BrowserContext* browser_context) { + std::string text = url->possibly_invalid_spec(); + if (text.find("about:") == 0 && text != "about:blank" && text.length() > 6) { + // Redirect about: URLs to chrome:// + *url = GURL(kChromeURL + text.substr(6)); + } + + // Allow the redirection to proceed. + return false; +} + +void DidFinishChromeLoad(CefRefPtr frame, + const GURL& validated_url) { + ChromeDomain domain = GetChromeDomain(validated_url.host()); + switch (domain) { + case CHROME_VERSION: + DidFinishChromeVersionLoad(frame); + default: + break; + } +} + +void OnChromeProcessMessage(CefRefPtr browser, + const base::ListValue& arguments) { + std::string action; + const base::ListValue* args = NULL; + + size_t size = arguments.GetSize(); + if (size > 0) { + arguments.GetString(0, &action); + if (size > 1) + arguments.GetList(1, &args); + } + + GURL url = GURL(browser->GetMainFrame()->GetURL().ToString()); + ChromeDomain domain = GetChromeDomain(url.host()); + switch (domain) { + case CHROME_TRACING: + OnChromeTracingProcessMessage(browser, action, args); + default: + break; + } +} + +scoped_ptr +WrapChromeProtocolHandler( + scoped_ptr + chrome_protocol_handler) { + scoped_ptr ret( + new ChromeProtocolHandlerWrapper(chrome_protocol_handler.Pass())); + return ret.Pass(); +} + +} // namespace scheme diff --git a/cef3/libcef/browser/chrome_scheme_handler.h b/cef3/libcef/browser/chrome_scheme_handler.h new file mode 100644 index 000000000..cd339f335 --- /dev/null +++ b/cef3/libcef/browser/chrome_scheme_handler.h @@ -0,0 +1,56 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_CHROME_SCHEME_HANDLER_H_ +#define CEF_LIBCEF_BROWSER_CHROME_SCHEME_HANDLER_H_ +#pragma once + +#include + +#include "include/cef_browser.h" +#include "include/cef_frame.h" +#include "include/cef_process_message.h" + +#include "base/memory/scoped_ptr.h" +#include "googleurl/src/gurl.h" +#include "net/url_request/url_request_job_factory.h" + +namespace base { +class ListValue; +} + +namespace content { +class BrowserContext; +} + +namespace scheme { + +extern const char kChromeURL[]; +extern const char kChromeProcessMessage[]; + +// Register the chrome scheme handler. +void RegisterChromeHandler(); + +// Used to redirect about: URLs to chrome: URLs. +bool WillHandleBrowserAboutURL(GURL* url, + content::BrowserContext* browser_context); + +// Used to fire any asynchronous content updates. +void DidFinishChromeLoad(CefRefPtr frame, + const GURL& validated_url); + +// Used to execute messages from render process bindings. +void OnChromeProcessMessage(CefRefPtr browser, + const base::ListValue& arguments); + +// Create a new ProtocolHandler that will filter the URLs passed to the default +// "chrome" protocol handler and forward the rest to CEF's handler. +scoped_ptr +WrapChromeProtocolHandler( + scoped_ptr + chrome_protocol_handler); + +} // namespace scheme + +#endif // CEF_LIBCEF_BROWSER_CHROME_SCHEME_HANDLER_H_ diff --git a/cef3/libcef/browser/content_browser_client.cc b/cef3/libcef/browser/content_browser_client.cc new file mode 100644 index 000000000..124390a72 --- /dev/null +++ b/cef3/libcef/browser/content_browser_client.cc @@ -0,0 +1,694 @@ +// Copyright (c) 2012 The Chromium 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 "libcef/browser/content_browser_client.h" + +#include + +#include "libcef/browser/browser_context.h" +#include "libcef/browser/browser_info.h" +#include "libcef/browser/browser_host_impl.h" +#include "libcef/browser/browser_main.h" +#include "libcef/browser/browser_message_filter.h" +#include "libcef/browser/browser_settings.h" +#include "libcef/browser/chrome_scheme_handler.h" +#include "libcef/browser/context.h" +#include "libcef/browser/media_capture_devices_dispatcher.h" +#include "libcef/browser/resource_dispatcher_host_delegate.h" +#include "libcef/browser/speech_recognition_manager_delegate.h" +#include "libcef/browser/thread_util.h" +#include "libcef/browser/web_plugin_impl.h" +#include "libcef/common/cef_switches.h" +#include "libcef/common/command_line_impl.h" + +#include "base/command_line.h" +#include "base/files/file_path.h" +#include "base/path_service.h" +#include "chrome/common/chrome_switches.h" +#include "content/browser/plugin_service_impl.h" +#include "content/public/browser/access_token_store.h" +#include "content/public/browser/browser_url_handler.h" +#include "content/public/browser/plugin_service_filter.h" +#include "content/public/browser/quota_permission_context.h" +#include "content/public/browser/render_process_host.h" +#include "content/public/browser/resource_dispatcher_host.h" +#include "content/public/common/content_switches.h" +#include "googleurl/src/gurl.h" +#include "ui/base/ui_base_switches.h" + +#if defined(OS_WIN) +#include "libcef/browser/web_contents_view_osr.h" +#endif + +namespace { + +// In-memory store for access tokens used by geolocation. +class CefAccessTokenStore : public content::AccessTokenStore { + public: + CefAccessTokenStore() {} + + virtual void LoadAccessTokens( + const LoadAccessTokensCallbackType& callback) OVERRIDE { + callback.Run(access_token_set_, _Context->request_context()); + } + + virtual void SaveAccessToken( + const GURL& server_url, const string16& access_token) OVERRIDE { + access_token_set_[server_url] = access_token; + } + + private: + AccessTokenSet access_token_set_; +}; + +class CefQuotaCallbackImpl : public CefQuotaCallback { + public: + explicit CefQuotaCallbackImpl( + const content::QuotaPermissionContext::PermissionCallback& callback) + : callback_(callback) { + } + ~CefQuotaCallbackImpl() { + if (!callback_.is_null()) { + // The callback is still pending. Cancel it now. + if (CEF_CURRENTLY_ON_IOT()) { + CancelNow(callback_); + } else { + CEF_POST_TASK(CEF_IOT, + base::Bind(&CefQuotaCallbackImpl::CancelNow, callback_)); + } + } + } + + virtual void Continue(bool allow) OVERRIDE { + if (CEF_CURRENTLY_ON_IOT()) { + if (!callback_.is_null()) { + callback_.Run(allow ? + content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_ALLOW : + content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_DISALLOW); + callback_.Reset(); + } + } else { + CEF_POST_TASK(CEF_IOT, + base::Bind(&CefQuotaCallbackImpl::Continue, this, allow)); + } + } + + virtual void Cancel() OVERRIDE { + if (CEF_CURRENTLY_ON_IOT()) { + if (!callback_.is_null()) { + CancelNow(callback_); + callback_.Reset(); + } + } else { + CEF_POST_TASK(CEF_IOT, base::Bind(&CefQuotaCallbackImpl::Cancel, this)); + } + } + + void Disconnect() { + callback_.Reset(); + } + + private: + static void CancelNow( + const content::QuotaPermissionContext::PermissionCallback& callback) { + CEF_REQUIRE_IOT(); + callback.Run( + content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_CANCELLED); + } + + content::QuotaPermissionContext::PermissionCallback callback_; + + IMPLEMENT_REFCOUNTING(CefQuotaCallbackImpl); +}; + +class CefAllowCertificateErrorCallbackImpl + : public CefAllowCertificateErrorCallback { + public: + explicit CefAllowCertificateErrorCallbackImpl( + const base::Callback& callback) : callback_(callback) { + } + + virtual void Continue(bool allow) OVERRIDE { + if (CEF_CURRENTLY_ON_UIT()) { + if (!callback_.is_null()) { + callback_.Run(allow); + callback_.Reset(); + } + } else { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefAllowCertificateErrorCallbackImpl::Continue, + this, allow)); + } + } + + void Disconnect() { + callback_.Reset(); + } + + private: + base::Callback callback_; + + IMPLEMENT_REFCOUNTING(CefAllowCertificateErrorCallbackImpl); +}; + +class CefQuotaPermissionContext : public content::QuotaPermissionContext { + public: + CefQuotaPermissionContext() { + } + + // The callback will be dispatched on the IO thread. + virtual void RequestQuotaPermission( + const GURL& origin_url, + quota::StorageType type, + int64 new_quota, + int render_process_id, + int render_view_id, + const PermissionCallback& callback) OVERRIDE { + if (type != quota::kStorageTypePersistent) { + // To match Chrome behavior we only support requesting quota with this + // interface for Persistent storage type. + callback.Run(QUOTA_PERMISSION_RESPONSE_DISALLOW); + return; + } + + bool handled = false; + + CefRefPtr browser = + CefBrowserHostImpl::GetBrowserByRoutingID(render_process_id, + render_view_id); + if (browser.get()) { + CefRefPtr client = browser->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetRequestHandler(); + if (handler.get()) { + CefRefPtr callbackImpl( + new CefQuotaCallbackImpl(callback)); + handled = handler->OnQuotaRequest(browser.get(), origin_url.spec(), + new_quota, callbackImpl.get()); + if (!handled) + callbackImpl->Disconnect(); + } + } + } + + if (!handled) { + // Disallow the request by default. + callback.Run(QUOTA_PERMISSION_RESPONSE_DISALLOW); + } + } + + private: + virtual ~CefQuotaPermissionContext() { + } +}; + +class CefPluginServiceFilter : public content::PluginServiceFilter { + public: + CefPluginServiceFilter() {} + virtual ~CefPluginServiceFilter() {} + + virtual bool IsPluginAvailable(int render_process_id, + int render_view_id, + const void* context, + const GURL& url, + const GURL& policy_url, + webkit::WebPluginInfo* plugin) OVERRIDE { + bool allowed = true; + + CefRefPtr browser = + CefBrowserHostImpl::GetBrowserByRoutingID(render_process_id, + render_view_id); + if (browser.get()) { + CefRefPtr client = browser->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetRequestHandler(); + if (handler.get()) { + CefRefPtr pluginInfo( + new CefWebPluginInfoImpl(*plugin)); + allowed = + !handler->OnBeforePluginLoad(browser.get(), + url.possibly_invalid_spec(), + policy_url.possibly_invalid_spec(), + pluginInfo.get()); + } + } + } + + return allowed; + } + + virtual bool CanLoadPlugin(int render_process_id, + const base::FilePath& path) OVERRIDE { + return true; + } +}; + +} // namespace + + +CefContentBrowserClient::CefContentBrowserClient() + : browser_main_parts_(NULL), + next_browser_id_(0) { + plugin_service_filter_.reset(new CefPluginServiceFilter); + content::PluginServiceImpl::GetInstance()->SetFilter( + plugin_service_filter_.get()); + + last_create_window_params_.opener_process_id = MSG_ROUTING_NONE; +} + +CefContentBrowserClient::~CefContentBrowserClient() { +} + +// static +CefContentBrowserClient* CefContentBrowserClient::Get() { + return static_cast( + content::GetContentClient()->browser()); +} + +scoped_refptr CefContentBrowserClient::CreateBrowserInfo() { + base::AutoLock lock_scope(browser_info_lock_); + + scoped_refptr browser_info = + new CefBrowserInfo(++next_browser_id_, false); + browser_info_list_.push_back(browser_info); + return browser_info; +} + +scoped_refptr + CefContentBrowserClient::GetOrCreateBrowserInfo(int render_process_id, + int render_view_id) { + base::AutoLock lock_scope(browser_info_lock_); + + BrowserInfoList::const_iterator it = browser_info_list_.begin(); + for (; it != browser_info_list_.end(); ++it) { + const scoped_refptr& browser_info = *it; + if (browser_info->is_render_id_match(render_process_id, render_view_id)) + return browser_info; + } + + // Must be a popup if it hasn't already been created. + scoped_refptr browser_info = + new CefBrowserInfo(++next_browser_id_, true); + browser_info->set_render_ids(render_process_id, render_view_id); + browser_info_list_.push_back(browser_info); + return browser_info; +} + +void CefContentBrowserClient::RemoveBrowserInfo( + scoped_refptr browser_info) { + base::AutoLock lock_scope(browser_info_lock_); + + BrowserInfoList::iterator it = browser_info_list_.begin(); + for (; it != browser_info_list_.end(); ++it) { + if (*it == browser_info) { + browser_info_list_.erase(it); + return; + } + } + + NOTREACHED(); +} + +void CefContentBrowserClient::DestroyAllBrowsers() { + BrowserInfoList list; + + { + base::AutoLock lock_scope(browser_info_lock_); + list = browser_info_list_; + } + + // Destroy any remaining browser windows. + if (!list.empty()) { + BrowserInfoList::iterator it = list.begin(); + for (; it != list.end(); ++it) { + CefRefPtr browser = (*it)->browser(); + if (browser.get()) { + // DestroyBrowser will call RemoveBrowserInfo. + browser->DestroyBrowser(); + } else { + // Canceled popup windows may have browser info but no browser because + // CefBrowserMessageFilter::OnGetNewBrowserInfo is still called. + DCHECK((*it)->is_popup()); + RemoveBrowserInfo(*it); + } + } + } + +#ifndef NDEBUG + { + // Verify that all browser windows have been destroyed. + base::AutoLock lock_scope(browser_info_lock_); + DCHECK(browser_info_list_.empty()); + } +#endif +} + +scoped_refptr CefContentBrowserClient::GetBrowserInfo( + int render_process_id, int render_view_id) { + base::AutoLock lock_scope(browser_info_lock_); + + BrowserInfoList::const_iterator it = browser_info_list_.begin(); + for (; it != browser_info_list_.end(); ++it) { + const scoped_refptr& browser_info = *it; + if (browser_info->is_render_id_match(render_process_id, render_view_id)) + return browser_info; + } + + LOG(WARNING) << "No browser info matching process id " << + render_process_id << " and view id " << render_view_id; + + return scoped_refptr(); +} + +content::BrowserMainParts* CefContentBrowserClient::CreateBrowserMainParts( + const content::MainFunctionParams& parameters) { + browser_main_parts_ = new CefBrowserMainParts(parameters); + return browser_main_parts_; +} + +content::WebContentsViewPort* +CefContentBrowserClient::OverrideCreateWebContentsView( + content::WebContents* web_contents, + content::RenderViewHostDelegateView** render_view_host_delegate_view) { + content::WebContentsViewPort* view = NULL; + *render_view_host_delegate_view = NULL; + // TODO(port): Implement this method to work on other platforms as part of + // off-screen rendering support. +#if defined(OS_WIN) + CefBrowserContext* browserContext = + static_cast(web_contents->GetBrowserContext()); + + if (browserContext && browserContext->use_osr_next_contents_view()) { + CefWebContentsViewOSR* view_or = new CefWebContentsViewOSR(web_contents, + GetWebContentsViewDelegate(web_contents)); + *render_view_host_delegate_view = view_or; + view = view_or; + } +#endif // OS_WIN + + return view; +} + +void CefContentBrowserClient::RenderProcessHostCreated( + content::RenderProcessHost* host) { + host->GetChannel()->AddFilter(new CefBrowserMessageFilter(host)); +} + +net::URLRequestContextGetter* CefContentBrowserClient::CreateRequestContext( + content::BrowserContext* content_browser_context, + content::ProtocolHandlerMap* protocol_handlers) { + CefBrowserContext* cef_browser_context = + CefBrowserContextForBrowserContext(content_browser_context); + return cef_browser_context->CreateRequestContext(protocol_handlers); +} + +net::URLRequestContextGetter* +CefContentBrowserClient::CreateRequestContextForStoragePartition( + content::BrowserContext* content_browser_context, + const base::FilePath& partition_path, + bool in_memory, + content::ProtocolHandlerMap* protocol_handlers) { + CefBrowserContext* cef_browser_context = + CefBrowserContextForBrowserContext(content_browser_context); + return cef_browser_context->CreateRequestContextForStoragePartition( + partition_path, in_memory, protocol_handlers); +} + +void CefContentBrowserClient::AppendExtraCommandLineSwitches( + CommandLine* command_line, int child_process_id) { + const CommandLine& browser_cmd = *CommandLine::ForCurrentProcess(); + + { + // Propagate the following switches to all command lines (along with any + // associated values) if present in the browser command line. + static const char* const kSwitchNames[] = { + switches::kLang, + switches::kLocalesDirPath, + switches::kLogFile, + switches::kLogSeverity, + switches::kEnableReleaseDcheck, + switches::kDisablePackLoading, + switches::kResourcesDirPath, + }; + command_line->CopySwitchesFrom(browser_cmd, kSwitchNames, + arraysize(kSwitchNames)); + } + + std::string process_type = + command_line->GetSwitchValueASCII(switches::kProcessType); + if (process_type == switches::kRendererProcess) { + // Propagate the following switches to the renderer command line (along with + // any associated values) if present in the browser command line. + static const char* const kSwitchNames[] = { + switches::kContextSafetyImplementation, + switches::kEnableMediaStream, + switches::kEnableSpeechInput, + switches::kProductVersion, + switches::kUncaughtExceptionStackSize, + }; + command_line->CopySwitchesFrom(browser_cmd, kSwitchNames, + arraysize(kSwitchNames)); + } + + CefRefPtr app = _Context->application(); + if (app.get()) { + CefRefPtr handler = + app->GetBrowserProcessHandler(); + if (handler.get()) { + CefRefPtr commandLinePtr( + new CefCommandLineImpl(command_line, false, false)); + handler->OnBeforeChildProcessLaunch(commandLinePtr.get()); + commandLinePtr->Detach(NULL); + } + } +} + +content::QuotaPermissionContext* + CefContentBrowserClient::CreateQuotaPermissionContext() { + return new CefQuotaPermissionContext(); +} + +content::MediaObserver* CefContentBrowserClient::GetMediaObserver() { + return CefMediaCaptureDevicesDispatcher::GetInstance(); +} + +content::SpeechRecognitionManagerDelegate* + CefContentBrowserClient::GetSpeechRecognitionManagerDelegate() { +#if defined(ENABLE_INPUT_SPEECH) + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + if (command_line.HasSwitch(switches::kEnableSpeechInput)) + return new CefSpeechRecognitionManagerDelegate(); +#endif + + return NULL; +} + +void CefContentBrowserClient::AllowCertificateError( + int render_process_id, + int render_view_id, + int cert_error, + const net::SSLInfo& ssl_info, + const GURL& request_url, + ResourceType::Type resource_type, + bool overridable, + bool strict_enforcement, + const base::Callback& callback, + bool* cancel_request) { + CEF_REQUIRE_UIT(); + + if (resource_type != ResourceType::MAIN_FRAME) { + // A sub-resource has a certificate error. The user doesn't really + // have a context for making the right decision, so block the request + // hard. + *cancel_request = true; + return; + } + + CefRefPtr browser = + CefBrowserHostImpl::GetBrowserByRoutingID(render_process_id, + render_view_id); + if (!browser.get()) + return; + CefRefPtr client = browser->GetClient(); + if (!client.get()) + return; + CefRefPtr handler = client->GetRequestHandler(); + if (!handler.get()) + return; + + CefRefPtr callbackImpl; + if (overridable && !strict_enforcement) + callbackImpl = new CefAllowCertificateErrorCallbackImpl(callback); + + *cancel_request = !handler->OnCertificateError( + static_cast(cert_error), request_url.spec(), + callbackImpl.get()); + if (*cancel_request && callbackImpl.get()) + callbackImpl->Disconnect(); +} + +content::AccessTokenStore* CefContentBrowserClient::CreateAccessTokenStore() { + return new CefAccessTokenStore; +} + +bool CefContentBrowserClient::CanCreateWindow( + const GURL& opener_url, + const GURL& origin, + WindowContainerType container_type, + content::ResourceContext* context, + int render_process_id, + bool* no_javascript_access) { + CEF_REQUIRE_IOT(); + *no_javascript_access = false; + + DCHECK_NE(last_create_window_params_.opener_process_id, MSG_ROUTING_NONE); + if (last_create_window_params_.opener_process_id == MSG_ROUTING_NONE) + return false; + + CefRefPtr browser = + CefBrowserHostImpl::GetBrowserByRoutingID( + last_create_window_params_.opener_process_id, + last_create_window_params_.opener_view_id); + DCHECK(browser.get()); + if (!browser.get()) { + LOG(WARNING) << "CanCreateWindow called before browser was created"; + return false; + } + + CefRefPtr client = browser->GetClient(); + bool allow = true; + + scoped_ptr pending_info; + pending_info.reset(new CefBrowserHostImpl::PendingPopupInfo); + +#if defined(OS_WIN) + pending_info->window_info.SetAsPopup(NULL, CefString()); +#endif + + // Start with the current browser's settings. + pending_info->client = client; + pending_info->settings = browser->settings(); + + if (client.get()) { + CefRefPtr handler = client->GetLifeSpanHandler(); + if (handler.get()) { + CefRefPtr frame = + browser->GetFrame(last_create_window_params_.opener_frame_id); + + // TODO(cef): Figure out how to populate CefPopupFeatures. + // See: http://crbug.com/110510 + CefPopupFeatures features; + +#if (defined(OS_WIN) || defined(OS_MACOSX)) + // Default to the size from the popup features. + if (features.xSet) + pending_info->window_info.x = features.x; + if (features.ySet) + pending_info->window_info.y = features.y; + if (features.widthSet) + pending_info->window_info.width = features.width; + if (features.heightSet) + pending_info->window_info.height = features.height; +#endif + + allow = !handler->OnBeforePopup(browser.get(), + frame, + last_create_window_params_.target_url.spec(), + last_create_window_params_.target_frame_name, + features, + pending_info->window_info, + pending_info->client, + pending_info->settings, + no_javascript_access); + if (allow) { + if (CefBrowserHostImpl::IsWindowRenderingDisabled( + pending_info->window_info)) { + if (!pending_info->client->GetRenderHandler().get()) { + NOTREACHED() << "CefRenderHandler implementation is required"; + allow = false; + } + if (pending_info->settings.accelerated_compositing != STATE_DISABLED) { + // Accelerated compositing is not supported when window rendering is + // disabled. + pending_info->settings.accelerated_compositing = STATE_DISABLED; + } + } + } + } + } + + if (allow) { + CefRefPtr pending_client = pending_info->client; + allow = browser->SetPendingPopupInfo(pending_info.Pass()); + if (!allow) { + LOG(WARNING) << "Creation of popup window denied because one is already " + "pending."; + } + } + + last_create_window_params_.opener_process_id = MSG_ROUTING_NONE; + + return allow; +} + +void CefContentBrowserClient::ResourceDispatcherHostCreated() { + resource_dispatcher_host_delegate_.reset( + new CefResourceDispatcherHostDelegate()); + content::ResourceDispatcherHost::Get()->SetDelegate( + resource_dispatcher_host_delegate_.get()); +} + +void CefContentBrowserClient::OverrideWebkitPrefs( + content::RenderViewHost* rvh, + const GURL& url, + webkit_glue::WebPreferences* prefs) { + CefRefPtr browser = + CefBrowserHostImpl::GetBrowserForHost(rvh); + DCHECK(browser.get()); + + // Populate WebPreferences based on CefBrowserSettings. + BrowserToWebSettings(browser->settings(), *prefs); +} + +void CefContentBrowserClient::BrowserURLHandlerCreated( + content::BrowserURLHandler* handler) { + // Used to redirect about: URLs to chrome: URLs. + handler->AddHandlerPair(&scheme::WillHandleBrowserAboutURL, + content::BrowserURLHandler::null_handler()); +} + +std::string CefContentBrowserClient::GetDefaultDownloadName() { + return "download"; +} + +#if defined(OS_WIN) +const wchar_t* CefContentBrowserClient::GetResourceDllName() { + static wchar_t file_path[MAX_PATH+1] = {0}; + + if (file_path[0] == 0) { + // Retrieve the module path (usually libcef.dll). + base::FilePath module; + PathService::Get(base::FILE_MODULE, &module); + const std::wstring wstr = module.value(); + size_t count = std::min(static_cast(MAX_PATH), wstr.size()); + wcsncpy(file_path, wstr.c_str(), count); + file_path[count] = 0; + } + + return file_path; +} +#endif // defined(OS_WIN) + +void CefContentBrowserClient::set_last_create_window_params( + const LastCreateWindowParams& params) { + CEF_REQUIRE_IOT(); + last_create_window_params_ = params; +} + +CefBrowserContext* +CefContentBrowserClient::CefBrowserContextForBrowserContext( + content::BrowserContext* content_browser_context) { + DCHECK_EQ(content_browser_context, browser_main_parts_->browser_context()); + return browser_main_parts_->browser_context(); +} diff --git a/cef3/libcef/browser/content_browser_client.h b/cef3/libcef/browser/content_browser_client.h new file mode 100644 index 000000000..5be144bd4 --- /dev/null +++ b/cef3/libcef/browser/content_browser_client.h @@ -0,0 +1,146 @@ +// Copyright (c) 2011 The Chromium 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_LIBCEF_BROWSER_CONTENT_BROWSER_CLIENT_H_ +#define CEF_LIBCEF_BROWSER_CONTENT_BROWSER_CLIENT_H_ +#pragma once + +#include +#include +#include +#include + +#include "base/compiler_specific.h" +#include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" +#include "base/synchronization/lock.h" +#include "content/public/browser/content_browser_client.h" +#include "googleurl/src/gurl.h" + +class CefBrowserContext; +class CefBrowserInfo; +class CefBrowserMainParts; +class CefResourceDispatcherHostDelegate; + +namespace content { +class PluginServiceFilter; +class SiteInstance; +} + +class CefContentBrowserClient : public content::ContentBrowserClient { + public: + CefContentBrowserClient(); + virtual ~CefContentBrowserClient(); + + // Returns the singleton CefContentBrowserClient instance. + static CefContentBrowserClient* Get(); + + CefBrowserMainParts* browser_main_parts() const { + return browser_main_parts_; + } + + // Methods for managing CefBrowserInfo life span. Do not add new callers of + // these methods. + // During popup window creation there is a race between the call to + // CefBrowserMessageFilter::OnGetNewBrowserInfo on the IO thread and the call + // to CefBrowserHostImpl::ShouldCreateWebContents on the UI thread. To resolve + // this race CefBrowserInfo may be created when requested for the first time + // and before the associated CefBrowserHostImpl is created. + scoped_refptr CreateBrowserInfo(); + scoped_refptr GetOrCreateBrowserInfo(int render_process_id, + int render_view_id); + void RemoveBrowserInfo(scoped_refptr browser_info); + void DestroyAllBrowsers(); + + // Retrieves the CefBrowserInfo matching the specified IDs or an empty + // pointer if no match is found. It is allowed to add new callers of this + // method but consider using CefContext::GetBrowserByRoutingID() instead. + scoped_refptr GetBrowserInfo(int render_process_id, + int render_view_id); + + virtual content::BrowserMainParts* CreateBrowserMainParts( + const content::MainFunctionParams& parameters) OVERRIDE; + virtual content::WebContentsViewPort* OverrideCreateWebContentsView( + content::WebContents* web_contents, + content::RenderViewHostDelegateView** rvhdv) OVERRIDE; + virtual void RenderProcessHostCreated( + content::RenderProcessHost* host) OVERRIDE; + virtual net::URLRequestContextGetter* CreateRequestContext( + content::BrowserContext* browser_context, + content::ProtocolHandlerMap* protocol_handlers) OVERRIDE; + virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition( + content::BrowserContext* browser_context, + const base::FilePath& partition_path, + bool in_memory, + content::ProtocolHandlerMap* protocol_handlers) OVERRIDE; + virtual void AppendExtraCommandLineSwitches(CommandLine* command_line, + int child_process_id) OVERRIDE; + virtual content::QuotaPermissionContext* + CreateQuotaPermissionContext() OVERRIDE; + virtual content::MediaObserver* GetMediaObserver() OVERRIDE; + virtual content::SpeechRecognitionManagerDelegate* + GetSpeechRecognitionManagerDelegate() OVERRIDE; + virtual void AllowCertificateError( + int render_process_id, + int render_view_id, + int cert_error, + const net::SSLInfo& ssl_info, + const GURL& request_url, + ResourceType::Type resource_type, + bool overridable, + bool strict_enforcement, + const base::Callback& callback, + bool* cancel_request) OVERRIDE; + virtual content::AccessTokenStore* CreateAccessTokenStore() OVERRIDE; + virtual bool CanCreateWindow(const GURL& opener_url, + const GURL& origin, + WindowContainerType container_type, + content::ResourceContext* context, + int render_process_id, + bool* no_javascript_access) OVERRIDE; + virtual void ResourceDispatcherHostCreated() OVERRIDE; + virtual void OverrideWebkitPrefs(content::RenderViewHost* rvh, + const GURL& url, + webkit_glue::WebPreferences* prefs) OVERRIDE; + virtual void BrowserURLHandlerCreated( + content::BrowserURLHandler* handler) OVERRIDE; + virtual std::string GetDefaultDownloadName() OVERRIDE; + +#if defined(OS_WIN) + const wchar_t* GetResourceDllName() OVERRIDE; +#endif + + // Store additional state from the ViewHostMsg_CreateWindow message that will + // be used when CanCreateWindow() is called. + struct LastCreateWindowParams { + int opener_process_id; + int opener_view_id; + int64 opener_frame_id; + GURL target_url; + string16 target_frame_name; + }; + void set_last_create_window_params(const LastCreateWindowParams& params); + + private: + CefBrowserContext* CefBrowserContextForBrowserContext( + content::BrowserContext* content_browser_context); + + CefBrowserMainParts* browser_main_parts_; + + scoped_ptr plugin_service_filter_; + scoped_ptr + resource_dispatcher_host_delegate_; + + base::Lock browser_info_lock_; + + // Access must be protected by |browser_info_lock_|. + typedef std::list > BrowserInfoList; + BrowserInfoList browser_info_list_; + int next_browser_id_; + + // Only accessed on the IO thread. + LastCreateWindowParams last_create_window_params_; +}; + +#endif // CEF_LIBCEF_BROWSER_CONTENT_BROWSER_CLIENT_H_ diff --git a/cef3/libcef/browser/context.cc b/cef3/libcef/browser/context.cc new file mode 100644 index 000000000..018f95bd1 --- /dev/null +++ b/cef3/libcef/browser/context.cc @@ -0,0 +1,364 @@ +// 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 "libcef/browser/context.h" +#include "libcef/browser/browser_context.h" +#include "libcef/browser/browser_host_impl.h" +#include "libcef/browser/browser_info.h" +#include "libcef/browser/browser_main.h" +#include "libcef/browser/browser_message_loop.h" +#include "libcef/browser/content_browser_client.h" +#include "libcef/browser/scheme_registration.h" +#include "libcef/browser/thread_util.h" +#include "libcef/browser/trace_subscriber.h" +#include "libcef/common/main_delegate.h" +#include "libcef/renderer/content_renderer_client.h" + +#include "base/bind.h" +#include "base/command_line.h" +#include "base/file_util.h" +#include "base/synchronization/waitable_event.h" +#include "content/public/app/content_main.h" +#include "content/public/app/content_main_runner.h" +#include "content/public/browser/render_process_host.h" +#include "content/public/common/content_switches.h" +#include "ui/base/ui_base_switches.h" + +#if defined(OS_MACOSX) +#include "libcef/browser/application_mac.h" +#endif + +#if defined(OS_WIN) +#include "content/public/app/startup_helper_win.h" +#include "sandbox/win/src/sandbox_types.h" +#endif + +// Global CefContext pointer +CefRefPtr _Context; + + +int CefExecuteProcess(const CefMainArgs& args, + CefRefPtr application) { + CommandLine command_line(CommandLine::NO_PROGRAM); +#if defined(OS_WIN) + command_line.ParseFromString(::GetCommandLineW()); +#else + command_line.InitFromArgv(args.argc, args.argv); +#endif + + // If no process type is specified then it represents the browser process and + // we do nothing. + std::string process_type = + command_line.GetSwitchValueASCII(switches::kProcessType); + if (process_type.empty()) + return -1; + +#if defined(OS_MACOSX) + // Create the CefCrApplication instance. + CefCrApplicationCreate(); +#endif + + CefMainDelegate main_delegate(application); + + // Execute the secondary process. +#if defined(OS_WIN) + sandbox::SandboxInterfaceInfo sandbox_info = {0}; + content::InitializeSandboxInfo(&sandbox_info); + + return content::ContentMain(args.instance, &sandbox_info, &main_delegate); +#else + return content::ContentMain(args.argc, const_cast(args.argv), + &main_delegate); +#endif +} + +bool CefInitialize(const CefMainArgs& args, + const CefSettings& settings, + CefRefPtr application) { + // Return true if the global context already exists. + if (_Context.get()) + return true; + + if (settings.size != sizeof(cef_settings_t)) { + NOTREACHED() << "invalid CefSettings structure size"; + return false; + } + + // Create the new global context object. + _Context = new CefContext(); + + // Initialize the global context. + return _Context->Initialize(args, settings, application); +} + +void CefShutdown() { + // Verify that the context is in a valid state. + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return; + } + + // Must always be called on the same thread as Initialize. + if (!_Context->OnInitThread()) { + NOTREACHED() << "called on invalid thread"; + return; + } + + // Shut down the global context. This will block until shutdown is complete. + _Context->Shutdown(); + + // Delete the global context object. + _Context = NULL; +} + +void CefDoMessageLoopWork() { + // Verify that the context is in a valid state. + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return; + } + + // Must always be called on the same thread as Initialize. + if (!_Context->OnInitThread()) { + NOTREACHED() << "called on invalid thread"; + return; + } + + CefBrowserMessageLoop::current()->DoMessageLoopIteration(); +} + +void CefRunMessageLoop() { + // Verify that the context is in a valid state. + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return; + } + + // Must always be called on the same thread as Initialize. + if (!_Context->OnInitThread()) { + NOTREACHED() << "called on invalid thread"; + return; + } + + CefBrowserMessageLoop::current()->RunMessageLoop(); +} + +void CefQuitMessageLoop() { + // Verify that the context is in a valid state. + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return; + } + + // Must always be called on the same thread as Initialize. + if (!_Context->OnInitThread()) { + NOTREACHED() << "called on invalid thread"; + return; + } + + CefBrowserMessageLoop::current()->Quit(); +} + + +// CefContext + +CefContext::CefContext() + : initialized_(false), + shutting_down_(false), + init_thread_id_(0) { +} + +CefContext::~CefContext() { + if (!shutting_down_) + Shutdown(); +} + +bool CefContext::Initialize(const CefMainArgs& args, + const CefSettings& settings, + CefRefPtr application) { + init_thread_id_ = base::PlatformThread::CurrentId(); + settings_ = settings; + + cache_path_ = base::FilePath(CefString(&settings.cache_path)); + if (!cache_path_.empty() && + !file_util::DirectoryExists(cache_path_) && + !file_util::CreateDirectory(cache_path_)) { + NOTREACHED() << "The cache_path directory could not be created"; + cache_path_ = base::FilePath(); + } + if (cache_path_.empty()) { + // Create and use a temporary directory. + if (cache_temp_dir_.CreateUniqueTempDir()) { + cache_path_ = cache_temp_dir_.path(); + } else { + NOTREACHED() << "Failed to create temporary cache_path directory"; + } + } + +#if !defined(OS_WIN) + if (settings.multi_threaded_message_loop) { + NOTIMPLEMENTED() << "multi_threaded_message_loop is not supported."; + return false; + } +#endif + + main_delegate_.reset(new CefMainDelegate(application)); + main_runner_.reset(content::ContentMainRunner::Create()); + + int exit_code; + + // Initialize the content runner. +#if defined(OS_WIN) + sandbox::SandboxInterfaceInfo sandbox_info = {0}; + content::InitializeSandboxInfo(&sandbox_info); + + exit_code = main_runner_->Initialize(args.instance, &sandbox_info, + main_delegate_.get()); +#else + exit_code = main_runner_->Initialize(args.argc, + const_cast(args.argv), + main_delegate_.get()); +#endif + + DCHECK_LT(exit_code, 0); + if (exit_code >= 0) + return false; + + // Run the process. Results in a call to CefMainDelegate::RunProcess() which + // will create the browser runner and message loop without blocking. + exit_code = main_runner_->Run(); + + initialized_ = true; + + // Continue initialization on the UI thread. + CEF_POST_TASK(CEF_UIT, base::Bind(&CefContext::OnContextInitialized, this)); + + return true; +} + +void CefContext::Shutdown() { + // Must always be called on the same thread as Initialize. + DCHECK(OnInitThread()); + + shutting_down_ = true; + + if (settings_.multi_threaded_message_loop) { + // Events that will be used to signal when shutdown is complete. Start in + // non-signaled mode so that the event will block. + base::WaitableEvent uithread_shutdown_event(false, false); + + // Finish shutdown on the UI thread. + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefContext::FinishShutdownOnUIThread, this, + &uithread_shutdown_event)); + + /// Block until UI thread shutdown is complete. + uithread_shutdown_event.Wait(); + + FinalizeShutdown(); + } else { + // Finish shutdown on the current thread, which should be the UI thread. + FinishShutdownOnUIThread(NULL); + + FinalizeShutdown(); + } +} + +bool CefContext::OnInitThread() { + return (base::PlatformThread::CurrentId() == init_thread_id_); +} + +CefRefPtr CefContext::GetBrowserByRoutingID( + int render_process_id, int render_view_id) { + scoped_refptr info = + CefContentBrowserClient::Get()->GetBrowserInfo(render_process_id, + render_view_id); + if (info.get()) { + CefRefPtr browser = info->browser(); + if (!browser.get()) { + LOG(WARNING) << "Found browser id " << info->browser_id() << + " but no browser object matching process id " << + render_process_id << " and view id " << render_view_id; + } + return browser; + } + return NULL; +} + +CefRefPtr CefContext::application() const { + return main_delegate_->content_client()->application(); +} + +CefBrowserContext* CefContext::browser_context() const { + return main_delegate_->browser_client()->browser_main_parts()-> + browser_context(); +} + +CefDevToolsDelegate* CefContext::devtools_delegate() const { + return main_delegate_->browser_client()->browser_main_parts()-> + devtools_delegate(); +} + +scoped_ptr CefContext::proxy_config_service() const { + return main_delegate_->browser_client()->browser_main_parts()-> + proxy_config_service(); +} + +PrefService* CefContext::pref_service() const { + return main_delegate_->browser_client()->browser_main_parts()->pref_service(); +} + +CefTraceSubscriber* CefContext::GetTraceSubscriber() { + CEF_REQUIRE_UIT(); + if (shutting_down_) + return NULL; + if (!trace_subscriber_.get()) + trace_subscriber_.reset(new CefTraceSubscriber()); + return trace_subscriber_.get(); +} + +void CefContext::OnContextInitialized() { + CEF_REQUIRE_UIT(); + + // Register internal scheme handlers. + scheme::RegisterInternalHandlers(); + + // Notify the handler. + CefRefPtr app = application(); + if (app.get()) { + CefRefPtr handler = + app->GetBrowserProcessHandler(); + if (handler.get()) + handler->OnContextInitialized(); + } +} + +void CefContext::FinishShutdownOnUIThread( + base::WaitableEvent* uithread_shutdown_event) { + CEF_REQUIRE_UIT(); + + CefContentBrowserClient::Get()->DestroyAllBrowsers(); + + if (trace_subscriber_.get()) + trace_subscriber_.reset(NULL); + + if (uithread_shutdown_event) + uithread_shutdown_event->Signal(); +} + +void CefContext::FinalizeShutdown() { + if (content::RenderProcessHost::run_renderer_in_process()) { + // Blocks until RenderProcess cleanup is complete. + CefContentRendererClient::Get()->RunSingleProcessCleanup(); + } + + // Shut down the browser runner or UI thread. + main_delegate_->ShutdownBrowser(); + + // Shut down the content runner. + main_runner_->Shutdown(); + + main_runner_.reset(NULL); + main_delegate_.reset(NULL); +} diff --git a/cef3/libcef/browser/context.h b/cef3/libcef/browser/context.h new file mode 100644 index 000000000..1d76d0a0b --- /dev/null +++ b/cef3/libcef/browser/context.h @@ -0,0 +1,123 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_CONTEXT_H_ +#define CEF_LIBCEF_BROWSER_CONTEXT_H_ +#pragma once + +#include +#include +#include + +#include "include/cef_app.h" +#include "include/cef_base.h" + +#include "base/files/file_path.h" +#include "base/files/scoped_temp_dir.h" +#include "base/memory/scoped_ptr.h" +#include "base/threading/platform_thread.h" +#include "net/proxy/proxy_config_service.h" +#include "net/url_request/url_request_context_getter.h" + +namespace base { +class WaitableEvent; +} + +namespace content { +class ContentMainRunner; +} + +class CefBrowserContext; +class CefBrowserHostImpl; +class CefDevToolsDelegate; +class CefMainDelegate; +class CefTraceSubscriber; +class PrefService; + +class CefContext : public CefBase { + public: + typedef std::list > BrowserList; + + CefContext(); + ~CefContext(); + + // These methods will be called on the main application thread. + bool Initialize(const CefMainArgs& args, + const CefSettings& settings, + CefRefPtr application); + void Shutdown(); + + // Returns true if the current thread is the initialization thread. + bool OnInitThread(); + + // Returns true if the context is initialized. + bool initialized() { return initialized_; } + + // Returns true if the context is shutting down. + bool shutting_down() { return shutting_down_; } + + CefRefPtr GetBrowserByRoutingID(int render_process_id, + int render_view_id); + + // Retrieve the path at which cache data will be stored on disk. If empty, + // cache data will be stored in-memory. + const base::FilePath& cache_path() const { return cache_path_; } + + const CefSettings& settings() const { return settings_; } + CefRefPtr application() const; + CefBrowserContext* browser_context() const; + CefDevToolsDelegate* devtools_delegate() const; + PrefService* pref_service() const; + + scoped_refptr request_context() const { + return request_context_; + } + void set_request_context(scoped_refptr context) { + request_context_ = context; + } + + // Passes ownership. + scoped_ptr proxy_config_service() const; + + CefTraceSubscriber* GetTraceSubscriber(); + + private: + void OnContextInitialized(); + + // Performs shutdown actions that need to occur on the UI thread before any + // threads are destroyed. + void FinishShutdownOnUIThread(base::WaitableEvent* uithread_shutdown_event); + + // Destroys the main runner and related objects. + void FinalizeShutdown(); + + // Track context state. + bool initialized_; + bool shutting_down_; + + // The thread on which the context was initialized. + base::PlatformThreadId init_thread_id_; + + CefSettings settings_; + base::FilePath cache_path_; + base::ScopedTempDir cache_temp_dir_; + + scoped_ptr main_delegate_; + scoped_ptr main_runner_; + scoped_ptr trace_subscriber_; + + scoped_refptr request_context_; + + IMPLEMENT_REFCOUNTING(CefContext); + IMPLEMENT_LOCKING(CefContext); +}; + +// Global context object pointer. +extern CefRefPtr _Context; + +// Helper macro that returns true if the global context is in a valid state. +#define CONTEXT_STATE_VALID() \ + (_Context.get() && _Context->initialized() && !_Context->shutting_down()) + +#endif // CEF_LIBCEF_BROWSER_CONTEXT_H_ diff --git a/cef3/libcef/browser/context_menu_params_impl.cc b/cef3/libcef/browser/context_menu_params_impl.cc new file mode 100644 index 000000000..eaed08b0c --- /dev/null +++ b/cef3/libcef/browser/context_menu_params_impl.cc @@ -0,0 +1,112 @@ +// 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 "libcef/browser/context_menu_params_impl.h" + +#include "base/logging.h" + +CefContextMenuParamsImpl::CefContextMenuParamsImpl( + content::ContextMenuParams* value) + : CefValueBase( + value, NULL, kOwnerNoDelete, true, + new CefValueControllerNonThreadSafe()) { + // Indicate that this object owns the controller. + SetOwnsController(); +} + +int CefContextMenuParamsImpl::GetXCoord() { + CEF_VALUE_VERIFY_RETURN(false, 0); + return const_value().x; +} + +int CefContextMenuParamsImpl::GetYCoord() { + CEF_VALUE_VERIFY_RETURN(false, 0); + return const_value().y; +} + +CefContextMenuParamsImpl::TypeFlags CefContextMenuParamsImpl::GetTypeFlags() { + CEF_VALUE_VERIFY_RETURN(false, CM_TYPEFLAG_NONE); + const content::ContextMenuParams& params = const_value(); + int type_flags = CM_TYPEFLAG_NONE; + if (!params.page_url.is_empty()) + type_flags |= CM_TYPEFLAG_PAGE; + if (!params.frame_url.is_empty()) + type_flags |= CM_TYPEFLAG_FRAME; + if (!params.link_url.is_empty()) + type_flags |= CM_TYPEFLAG_LINK; + if (params.media_type != WebKit::WebContextMenuData::MediaTypeNone) + type_flags |= CM_TYPEFLAG_MEDIA; + if (!params.selection_text.empty()) + type_flags |= CM_TYPEFLAG_SELECTION; + if (params.is_editable) + type_flags |= CM_TYPEFLAG_EDITABLE; + return static_cast(type_flags); +} + +CefString CefContextMenuParamsImpl::GetLinkUrl() { + CEF_VALUE_VERIFY_RETURN(false, CefString()); + return const_value().link_url.spec(); +} + +CefString CefContextMenuParamsImpl::GetUnfilteredLinkUrl() { + CEF_VALUE_VERIFY_RETURN(false, CefString()); + return const_value().unfiltered_link_url.spec(); +} + +CefString CefContextMenuParamsImpl::GetSourceUrl() { + CEF_VALUE_VERIFY_RETURN(false, CefString()); + return const_value().src_url.spec(); +} + +bool CefContextMenuParamsImpl::IsImageBlocked() { + CEF_VALUE_VERIFY_RETURN(false, false); + return const_value().is_image_blocked; +} + +CefString CefContextMenuParamsImpl::GetPageUrl() { + CEF_VALUE_VERIFY_RETURN(false, CefString()); + return const_value().page_url.spec(); +} + +CefString CefContextMenuParamsImpl::GetFrameUrl() { + CEF_VALUE_VERIFY_RETURN(false, CefString()); + return const_value().frame_url.spec(); +} + +CefString CefContextMenuParamsImpl::GetFrameCharset() { + CEF_VALUE_VERIFY_RETURN(false, CefString()); + return const_value().frame_charset; +} + +CefContextMenuParamsImpl::MediaType CefContextMenuParamsImpl::GetMediaType() { + CEF_VALUE_VERIFY_RETURN(false, CM_MEDIATYPE_NONE); + return static_cast(const_value().media_type); +} + +CefContextMenuParamsImpl::MediaStateFlags + CefContextMenuParamsImpl::GetMediaStateFlags() { + CEF_VALUE_VERIFY_RETURN(false, CM_MEDIAFLAG_NONE); + return static_cast(const_value().media_flags); +} + +CefString CefContextMenuParamsImpl::GetSelectionText() { + CEF_VALUE_VERIFY_RETURN(false, CefString()); + return const_value().selection_text; +} + +bool CefContextMenuParamsImpl::IsEditable() { + CEF_VALUE_VERIFY_RETURN(false, false); + return const_value().is_editable; +} + +bool CefContextMenuParamsImpl::IsSpeechInputEnabled() { + CEF_VALUE_VERIFY_RETURN(false, false); + return const_value().speech_input_enabled; +} + +CefContextMenuParamsImpl::EditStateFlags + CefContextMenuParamsImpl::GetEditStateFlags() { + CEF_VALUE_VERIFY_RETURN(false, CM_EDITFLAG_NONE); + return static_cast(const_value().edit_flags); +} diff --git a/cef3/libcef/browser/context_menu_params_impl.h b/cef3/libcef/browser/context_menu_params_impl.h new file mode 100644 index 000000000..2846febc0 --- /dev/null +++ b/cef3/libcef/browser/context_menu_params_impl.h @@ -0,0 +1,41 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_CONTEXT_MENU_PARAMS_IMPL_H_ +#define CEF_LIBCEF_BROWSER_CONTEXT_MENU_PARAMS_IMPL_H_ +#pragma once + +#include "include/cef_context_menu_handler.h" +#include "libcef/common/value_base.h" + +#include "content/public/common/context_menu_params.h" + +// CefContextMenuParams implementation. This class is not thread safe. +class CefContextMenuParamsImpl + : public CefValueBase { + public: + explicit CefContextMenuParamsImpl(content::ContextMenuParams* value); + + // CefContextMenuParams methods. + virtual int GetXCoord() OVERRIDE; + virtual int GetYCoord() OVERRIDE; + virtual TypeFlags GetTypeFlags() OVERRIDE; + virtual CefString GetLinkUrl() OVERRIDE; + virtual CefString GetUnfilteredLinkUrl() OVERRIDE; + virtual CefString GetSourceUrl() OVERRIDE; + virtual bool IsImageBlocked() OVERRIDE; + virtual CefString GetPageUrl() OVERRIDE; + virtual CefString GetFrameUrl() OVERRIDE; + virtual CefString GetFrameCharset() OVERRIDE; + virtual MediaType GetMediaType() OVERRIDE; + virtual MediaStateFlags GetMediaStateFlags() OVERRIDE; + virtual CefString GetSelectionText() OVERRIDE; + virtual bool IsEditable() OVERRIDE; + virtual bool IsSpeechInputEnabled() OVERRIDE; + virtual EditStateFlags GetEditStateFlags() OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(CefContextMenuParamsImpl); +}; + +#endif // CEF_LIBCEF_BROWSER_CONTEXT_MENU_PARAMS_IMPL_H_ diff --git a/cef3/libcef/browser/cookie_manager_impl.cc b/cef3/libcef/browser/cookie_manager_impl.cc new file mode 100644 index 000000000..1536e3df8 --- /dev/null +++ b/cef3/libcef/browser/cookie_manager_impl.cc @@ -0,0 +1,441 @@ +// 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 "libcef/browser/cookie_manager_impl.h" + +#include +#include +#include + +#include "libcef/browser/browser_context.h" +#include "libcef/browser/context.h" +#include "libcef/browser/thread_util.h" +#include "libcef/browser/url_request_context_getter.h" +#include "libcef/common/time_util.h" + +#include "base/bind.h" +#include "base/file_util.h" +#include "base/format_macros.h" +#include "base/logging.h" +#include "base/threading/thread_restrictions.h" +#include "chrome/browser/net/sqlite_persistent_cookie_store.h" +#include "googleurl/src/gurl.h" +#include "net/cookies/cookie_util.h" +#include "net/cookies/parsed_cookie.h" +#include "net/url_request/url_request_context.h" + +using content::BrowserThread; + +namespace { + +// Callback class for visiting cookies. +class VisitCookiesCallback : public base::RefCounted { + public: + explicit VisitCookiesCallback(net::CookieMonster* cookie_monster, + CefRefPtr visitor) + : cookie_monster_(cookie_monster), + visitor_(visitor) { + } + + void Run(const net::CookieList& list) { + CEF_REQUIRE_IOT(); + + int total = list.size(), count = 0; + + net::CookieList::const_iterator it = list.begin(); + for (; it != list.end(); ++it, ++count) { + CefCookie cookie; + const net::CanonicalCookie& cc = *(it); + CefCookieManagerImpl::GetCefCookie(cc, cookie); + + bool deleteCookie = false; + bool keepLooping = visitor_->Visit(cookie, count, total, deleteCookie); + if (deleteCookie) { + cookie_monster_->DeleteCanonicalCookieAsync(cc, + net::CookieMonster::DeleteCookieCallback()); + } + if (!keepLooping) + break; + } + } + + private: + scoped_refptr cookie_monster_; + CefRefPtr visitor_; +}; + + +// Methods extracted from net/cookies/cookie_monster.cc + +// Determine the cookie domain to use for setting the specified cookie. +bool GetCookieDomain(const GURL& url, + const net::ParsedCookie& pc, + std::string* result) { + std::string domain_string; + if (pc.HasDomain()) + domain_string = pc.Domain(); + return net::cookie_util::GetCookieDomainWithString(url, domain_string, + result); +} + +void RunCompletionOnIOThread(CefRefPtr handler) { + CEF_POST_TASK(CEF_IOT, + base::Bind(&CefCompletionHandler::OnComplete, handler.get())); +} + +} // namespace + + +CefCookieManagerImpl::CefCookieManagerImpl(bool is_global) + : is_global_(is_global) { +} + +CefCookieManagerImpl::~CefCookieManagerImpl() { +} + +void CefCookieManagerImpl::Initialize( + const CefString& path, + bool persist_session_cookies) { + if (is_global_) + SetGlobal(); + else + SetStoragePath(path, persist_session_cookies); +} + +void CefCookieManagerImpl::SetSupportedSchemes( + const std::vector& schemes) { + if (CEF_CURRENTLY_ON_IOT()) { + if (!cookie_monster_) + return; + + if (is_global_) { + // Global changes are handled by the request context. + scoped_refptr getter = + static_cast( + _Context->request_context().get()); + + std::vector scheme_vec; + std::vector::const_iterator it = schemes.begin(); + for (; it != schemes.end(); ++it) + scheme_vec.push_back(it->ToString()); + + getter->SetCookieSupportedSchemes(scheme_vec); + return; + } + + supported_schemes_ = schemes; + + if (supported_schemes_.empty()) { + supported_schemes_.push_back("http"); + supported_schemes_.push_back("https"); + } + + std::set scheme_set; + std::vector::const_iterator it = supported_schemes_.begin(); + for (; it != supported_schemes_.end(); ++it) + scheme_set.insert(*it); + + const char** arr = new const char*[scheme_set.size()]; + std::set::const_iterator it2 = scheme_set.begin(); + for (int i = 0; it2 != scheme_set.end(); ++it2, ++i) + arr[i] = it2->c_str(); + + cookie_monster_->SetCookieableSchemes(arr, scheme_set.size()); + + delete [] arr; + } else { + // Execute on the IO thread. + CEF_POST_TASK(CEF_IOT, + base::Bind(&CefCookieManagerImpl::SetSupportedSchemes, + this, schemes)); + } +} + +bool CefCookieManagerImpl::VisitAllCookies( + CefRefPtr visitor) { + if (CEF_CURRENTLY_ON_IOT()) { + if (!cookie_monster_) + return false; + + scoped_refptr callback( + new VisitCookiesCallback(cookie_monster_, visitor)); + + cookie_monster_->GetAllCookiesAsync( + base::Bind(&VisitCookiesCallback::Run, callback.get())); + } else { + // Execute on the IO thread. + CEF_POST_TASK(CEF_IOT, + base::Bind(base::IgnoreResult(&CefCookieManagerImpl::VisitAllCookies), + this, visitor)); + } + + return true; +} + +bool CefCookieManagerImpl::VisitUrlCookies( + const CefString& url, bool includeHttpOnly, + CefRefPtr visitor) { + if (CEF_CURRENTLY_ON_IOT()) { + if (!cookie_monster_) + return false; + + net::CookieOptions options; + if (includeHttpOnly) + options.set_include_httponly(); + + scoped_refptr callback( + new VisitCookiesCallback(cookie_monster_, visitor)); + + GURL gurl = GURL(url.ToString()); + cookie_monster_->GetAllCookiesForURLWithOptionsAsync(gurl, options, + base::Bind(&VisitCookiesCallback::Run, callback.get())); + } else { + // Execute on the IO thread. + CEF_POST_TASK(CEF_IOT, + base::Bind(base::IgnoreResult(&CefCookieManagerImpl::VisitUrlCookies), + this, url, includeHttpOnly, visitor)); + } + + return true; +} + +bool CefCookieManagerImpl::SetCookie(const CefString& url, + const CefCookie& cookie) { + CEF_REQUIRE_IOT_RETURN(false); + + if (!cookie_monster_) + return false; + + GURL gurl = GURL(url.ToString()); + if (!gurl.is_valid()) + return false; + + std::string name = CefString(&cookie.name).ToString(); + std::string value = CefString(&cookie.value).ToString(); + std::string domain = CefString(&cookie.domain).ToString(); + std::string path = CefString(&cookie.path).ToString(); + + base::Time expiration_time; + if (cookie.has_expires) + cef_time_to_basetime(cookie.expires, expiration_time); + + cookie_monster_->SetCookieWithDetailsAsync(gurl, name, value, domain, path, + expiration_time, cookie.secure, cookie.httponly, + net::CookieStore::SetCookiesCallback()); + return true; +} + +bool CefCookieManagerImpl::DeleteCookies(const CefString& url, + const CefString& cookie_name) { + CEF_REQUIRE_IOT_RETURN(false); + + if (!cookie_monster_) + return false; + + if (url.empty()) { + // Delete all cookies. + cookie_monster_->DeleteAllAsync(net::CookieMonster::DeleteCallback()); + return true; + } + + GURL gurl = GURL(url.ToString()); + if (!gurl.is_valid()) + return false; + + if (cookie_name.empty()) { + // Delete all matching host cookies. + cookie_monster_->DeleteAllForHostAsync(gurl, + net::CookieMonster::DeleteCallback()); + } else { + // Delete all matching host and domain cookies. + cookie_monster_->DeleteCookieAsync(gurl, cookie_name, base::Closure()); + } + return true; +} + +bool CefCookieManagerImpl::SetStoragePath( + const CefString& path, + bool persist_session_cookies) { + if (CEF_CURRENTLY_ON_IOT()) { + base::FilePath new_path; + if (!path.empty()) + new_path = base::FilePath(path); + + if (is_global_) { + // Global path changes are handled by the request context. + scoped_refptr getter = + static_cast( + _Context->request_context().get()); + getter->SetCookieStoragePath(new_path, persist_session_cookies); + cookie_monster_ = getter->GetURLRequestContext()->cookie_store()-> + GetCookieMonster(); + return true; + } + + if (cookie_monster_ && ((storage_path_.empty() && path.empty()) || + storage_path_ == new_path)) { + // The path has not changed so don't do anything. + return true; + } + + scoped_refptr persistent_store; + if (!new_path.empty()) { + // TODO(cef): Move directory creation to the blocking pool instead of + // allowing file IO on this thread. + base::ThreadRestrictions::ScopedAllowIO allow_io; + if (file_util::DirectoryExists(new_path) || + file_util::CreateDirectory(new_path)) { + const base::FilePath& cookie_path = new_path.AppendASCII("Cookies"); + persistent_store = + new SQLitePersistentCookieStore( + cookie_path, + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), + persist_session_cookies, + NULL); + } else { + NOTREACHED() << "The cookie storage directory could not be created"; + storage_path_.clear(); + } + } + + // Set the new cookie store that will be used for all new requests. The old + // cookie store, if any, will be automatically flushed and closed when no + // longer referenced. + cookie_monster_ = new net::CookieMonster(persistent_store.get(), NULL); + if (persistent_store.get() && persist_session_cookies) + cookie_monster_->SetPersistSessionCookies(true); + storage_path_ = new_path; + + // Restore the previously supported schemes. + SetSupportedSchemes(supported_schemes_); + } else { + // Execute on the IO thread. + CEF_POST_TASK(CEF_IOT, + base::Bind(base::IgnoreResult(&CefCookieManagerImpl::SetStoragePath), + this, path, persist_session_cookies)); + } + + return true; +} + +bool CefCookieManagerImpl::FlushStore(CefRefPtr handler) { + if (CEF_CURRENTLY_ON_IOT()) { + if (!cookie_monster_) { + if (handler.get()) + RunCompletionOnIOThread(handler); + return true; + } + + base::Closure callback; + if (handler.get()) + callback = base::Bind(RunCompletionOnIOThread, handler); + else + callback = base::Bind(&base::DoNothing); + + cookie_monster_->FlushStore(callback); + } else { + // Execute on the IO thread. + CEF_POST_TASK(CEF_IOT, + base::Bind(base::IgnoreResult(&CefCookieManagerImpl::FlushStore), + this, handler)); + } + + return true; +} + +void CefCookieManagerImpl::SetGlobal() { + if (CEF_CURRENTLY_ON_IOT()) { + if (_Context->browser_context()) { + cookie_monster_ = _Context->request_context()->GetURLRequestContext()-> + cookie_store()->GetCookieMonster(); + DCHECK(cookie_monster_); + } + } else { + // Execute on the IO thread. + CEF_POST_TASK(CEF_IOT, base::Bind(&CefCookieManagerImpl::SetGlobal, this)); + } +} + +// static +bool CefCookieManagerImpl::GetCefCookie(const net::CanonicalCookie& cc, + CefCookie& cookie) { + CefString(&cookie.name).FromString(cc.Name()); + CefString(&cookie.value).FromString(cc.Value()); + CefString(&cookie.domain).FromString(cc.Domain()); + CefString(&cookie.path).FromString(cc.Path()); + cookie.secure = cc.IsSecure(); + cookie.httponly = cc.IsHttpOnly(); + cef_time_from_basetime(cc.CreationDate(), cookie.creation); + cef_time_from_basetime(cc.LastAccessDate(), cookie.last_access); + cookie.has_expires = cc.IsPersistent(); + if (cookie.has_expires) + cef_time_from_basetime(cc.ExpiryDate(), cookie.expires); + + return true; +} + +// static +bool CefCookieManagerImpl::GetCefCookie(const GURL& url, + const std::string& cookie_line, + CefCookie& cookie) { + // Parse the cookie. + net::ParsedCookie pc(cookie_line); + if (!pc.IsValid()) + return false; + + std::string cookie_domain; + if (!GetCookieDomain(url, pc, &cookie_domain)) + return false; + + std::string cookie_path = net::CanonicalCookie::CanonPath(url, pc); + base::Time creation_time = base::Time::Now(); + base::Time cookie_expires = + net::CanonicalCookie::CanonExpiration(pc, creation_time, creation_time); + + CefString(&cookie.name).FromString(pc.Name()); + CefString(&cookie.value).FromString(pc.Value()); + CefString(&cookie.domain).FromString(cookie_domain); + CefString(&cookie.path).FromString(cookie_path); + cookie.secure = pc.IsSecure(); + cookie.httponly = pc.IsHttpOnly(); + cef_time_from_basetime(creation_time, cookie.creation); + cef_time_from_basetime(creation_time, cookie.last_access); + cookie.has_expires = !cookie_expires.is_null(); + if (cookie.has_expires) + cef_time_from_basetime(cookie_expires, cookie.expires); + + return true; +} + + +// CefCookieManager methods ---------------------------------------------------- + +// static +CefRefPtr CefCookieManager::GetGlobalManager() { + // Verify that the context is in a valid state. + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return NULL; + } + + CefRefPtr manager(new CefCookieManagerImpl(true)); + manager->Initialize(CefString(), false); + return manager.get(); +} + +// static +CefRefPtr CefCookieManager::CreateManager( + const CefString& path, + bool persist_session_cookies) { + // Verify that the context is in a valid state. + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return NULL; + } + + CefRefPtr manager(new CefCookieManagerImpl(false)); + manager->Initialize(path, persist_session_cookies); + return manager.get(); +} diff --git a/cef3/libcef/browser/cookie_manager_impl.h b/cef3/libcef/browser/cookie_manager_impl.h new file mode 100644 index 000000000..8fc353b1b --- /dev/null +++ b/cef3/libcef/browser/cookie_manager_impl.h @@ -0,0 +1,53 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_COOKIE_MANAGER_IMPL_H_ +#define CEF_LIBCEF_BROWSER_COOKIE_MANAGER_IMPL_H_ + +#include "include/cef_cookie.h" +#include "base/files/file_path.h" +#include "net/cookies/cookie_monster.h" + +// Implementation of the CefCookieManager interface. +class CefCookieManagerImpl : public CefCookieManager { + public: + CefCookieManagerImpl(bool is_global); + ~CefCookieManagerImpl(); + + // Initialize the cookie manager. + void Initialize(const CefString& path, + bool persist_session_cookies); + + // CefCookieManager methods. + virtual void SetSupportedSchemes(const std::vector& schemes) + OVERRIDE; + virtual bool VisitAllCookies(CefRefPtr visitor) OVERRIDE; + virtual bool VisitUrlCookies(const CefString& url, bool includeHttpOnly, + CefRefPtr visitor) OVERRIDE; + virtual bool SetCookie(const CefString& url, + const CefCookie& cookie) OVERRIDE; + virtual bool DeleteCookies(const CefString& url, + const CefString& cookie_name) OVERRIDE; + virtual bool SetStoragePath(const CefString& path, + bool persist_session_cookies) OVERRIDE; + virtual bool FlushStore(CefRefPtr handler) OVERRIDE; + + net::CookieMonster* cookie_monster() { return cookie_monster_; } + + static bool GetCefCookie(const net::CanonicalCookie& cc, CefCookie& cookie); + static bool GetCefCookie(const GURL& url, const std::string& cookie_line, + CefCookie& cookie); + + private: + void SetGlobal(); + + scoped_refptr cookie_monster_; + bool is_global_; + base::FilePath storage_path_; + std::vector supported_schemes_; + + IMPLEMENT_REFCOUNTING(CefCookieManagerImpl); +}; + +#endif // CEF_LIBCEF_BROWSER_COOKIE_MANAGER_IMPL_H_ diff --git a/cef3/libcef/browser/devtools_delegate.cc b/cef3/libcef/browser/devtools_delegate.cc new file mode 100644 index 000000000..6d20d5984 --- /dev/null +++ b/cef3/libcef/browser/devtools_delegate.cc @@ -0,0 +1,191 @@ +// Copyright (c) 2012 The Chromium 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 "libcef/browser/devtools_delegate.h" +#include "libcef/browser/devtools_scheme_handler.h" + +#include +#include + +#include "base/command_line.h" +#include "base/md5.h" +#include "base/rand_util.h" +#include "base/stringprintf.h" +#include "base/string_number_conversions.h" +#include "base/time.h" +#include "content/public/browser/devtools_http_handler.h" +#include "content/public/browser/render_process_host.h" +#include "content/public/browser/render_view_host.h" +#include "content/public/common/content_client.h" +#include "content/public/common/content_switches.h" +#include "content/public/common/url_constants.h" +#include "grit/cef_resources.h" +#include "net/base/tcp_listen_socket.h" +#include "ui/base/layout.h" +#include "ui/base/resource/resource_bundle.h" + +// CefDevToolsBindingHandler + +CefDevToolsBindingHandler::CefDevToolsBindingHandler() { +} + +std::string CefDevToolsBindingHandler::GetIdentifier( + content::DevToolsAgentHost* agent_host) { + GarbageCollect(); + + const std::string& identifier = + GetIdentifier(agent_host->GetRenderViewHost()); + agents_map_[identifier] = agent_host; + return identifier; +} + +content::DevToolsAgentHost* CefDevToolsBindingHandler::ForIdentifier( + const std::string& identifier) { + GarbageCollect(); + + // Return the existing agent host, if any. + AgentsMap::const_iterator it = agents_map_.find(identifier); + if (it != agents_map_.end()) + return it->second; + + // Iterate through the existing RVH instances to find a match. + for (content::RenderProcessHost::iterator it( + content::RenderProcessHost::AllHostsIterator()); + !it.IsAtEnd(); it.Advance()) { + content::RenderProcessHost* render_process_host = it.GetCurrentValue(); + DCHECK(render_process_host); + + // Ignore processes that don't have a connection, such as crashed contents. + if (!render_process_host->HasConnection()) + continue; + + content::RenderProcessHost::RenderWidgetHostsIterator rwit( + render_process_host->GetRenderWidgetHostsIterator()); + for (; !rwit.IsAtEnd(); rwit.Advance()) { + const content::RenderWidgetHost* widget = rwit.GetCurrentValue(); + DCHECK(widget); + if (!widget || !widget->IsRenderView()) + continue; + + content::RenderViewHost* host = + content::RenderViewHost::From( + const_cast(widget)); + if (GetIdentifier(host) == identifier) { + // May create a new agent host. + scoped_refptr agent_host( + content::DevToolsAgentHost::GetOrCreateFor(host)); + agents_map_[identifier] = agent_host; + return agent_host; + } + } + } + + return NULL; +} + +std::string CefDevToolsBindingHandler::GetIdentifier( + content::RenderViewHost* rvh) { + int process_id = rvh->GetProcess()->GetID(); + int routing_id = rvh->GetRoutingID(); + + if (random_seed_.empty()) { + // Generate a random seed that is used to make identifier guessing more + // difficult. + random_seed_ = base::StringPrintf("%lf|%u", + base::Time::Now().ToDoubleT(), base::RandInt(0, INT_MAX)); + } + + // Create a key that combines RVH IDs and the random seed. + std::string key = base::StringPrintf("%d|%d|%s", + process_id, + routing_id, + random_seed_.c_str()); + + // Return an MD5 hash of the key. + return base::MD5String(key); +} + +void CefDevToolsBindingHandler::GarbageCollect() { + AgentsMap::iterator it = agents_map_.begin(); + while (it != agents_map_.end()) { + if (!it->second->GetRenderViewHost()) + agents_map_.erase(it++); + else + ++it; + } +} + + +// CefDevToolsDelegate + +CefDevToolsDelegate::CefDevToolsDelegate(int port) { + devtools_http_handler_ = content::DevToolsHttpHandler::Start( + new net::TCPListenSocketFactory("127.0.0.1", port), + "", + this); + + binding_.reset(new CefDevToolsBindingHandler()); + devtools_http_handler_->SetDevToolsAgentHostBinding(binding_.get()); +} + +CefDevToolsDelegate::~CefDevToolsDelegate() { +} + +void CefDevToolsDelegate::Stop() { + // The call below destroys this. + devtools_http_handler_->Stop(); +} + +std::string CefDevToolsDelegate::GetDiscoveryPageHTML() { + return content::GetContentClient()->GetDataResource( + IDR_CEF_DEVTOOLS_DISCOVERY_PAGE, ui::SCALE_FACTOR_NONE).as_string(); +} + +bool CefDevToolsDelegate::BundlesFrontendResources() { + return true; +} + +base::FilePath CefDevToolsDelegate::GetDebugFrontendDir() { + return base::FilePath(); +} + +std::string CefDevToolsDelegate::GetPageThumbnailData(const GURL& url) { + return std::string(); +} + +content::RenderViewHost* CefDevToolsDelegate::CreateNewTarget() { + return NULL; +} + +content::DevToolsHttpHandlerDelegate::TargetType + CefDevToolsDelegate::GetTargetType(content::RenderViewHost*) { + return kTargetTypeTab; +} + +std::string CefDevToolsDelegate::GetViewDescription(content::RenderViewHost*) { + return std::string(); +} + +std::string CefDevToolsDelegate::GetDevToolsURL(content::RenderViewHost* rvh, + bool http_scheme) { + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + std::string port_str = + command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort); + DCHECK(!port_str.empty()); + int port; + if (!base::StringToInt(port_str, &port)) + return std::string(); + + std::string page_id = binding_->GetIdentifier(rvh); + std::string host = http_scheme ? + base::StringPrintf("http://localhost:%d/devtools/", port) : + base::StringPrintf("%s://%s/devtools/", chrome::kChromeDevToolsScheme, + scheme::kChromeDevToolsHost); + + return base::StringPrintf( + "%sdevtools.html?ws=localhost:%d/devtools/page/%s", + host.c_str(), + port, + page_id.c_str()); +} diff --git a/cef3/libcef/browser/devtools_delegate.h b/cef3/libcef/browser/devtools_delegate.h new file mode 100644 index 000000000..082aadaf1 --- /dev/null +++ b/cef3/libcef/browser/devtools_delegate.h @@ -0,0 +1,77 @@ +// Copyright (c) 2012 The Chromium 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_LIBCEF_BROWSER_DEVTOOLS_DELEGATE_H_ +#define CEF_LIBCEF_BROWSER_DEVTOOLS_DELEGATE_H_ +#pragma once + +#include +#include + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "base/memory/scoped_ptr.h" +#include "content/public/browser/devtools_agent_host.h" +#include "content/public/browser/devtools_http_handler.h" +#include "content/public/browser/devtools_http_handler_delegate.h" + +namespace content { +class RenderViewHost; +} + +class CefDevToolsBindingHandler + : public content::DevToolsHttpHandler::DevToolsAgentHostBinding { + public: + CefDevToolsBindingHandler(); + + // DevToolsAgentHostBinding overrides. + virtual std::string GetIdentifier( + content::DevToolsAgentHost* agent_host) OVERRIDE; + virtual content::DevToolsAgentHost* ForIdentifier( + const std::string& identifier) OVERRIDE; + + std::string GetIdentifier(content::RenderViewHost* rvh); + + private: + void GarbageCollect(); + + std::string random_seed_; + + // Map of identifier to DevToolsAgentHost. Keeps the DevToolsAgentHost objects + // alive until the associated RVH is disconnected. + typedef std::map > + AgentsMap; + AgentsMap agents_map_; + + DISALLOW_COPY_AND_ASSIGN(CefDevToolsBindingHandler); +}; + +class CefDevToolsDelegate : public content::DevToolsHttpHandlerDelegate { + public: + explicit CefDevToolsDelegate(int port); + virtual ~CefDevToolsDelegate(); + + // Stops http server. + void Stop(); + + // DevToolsHttpProtocolHandler::Delegate overrides. + virtual std::string GetDiscoveryPageHTML() OVERRIDE; + virtual bool BundlesFrontendResources() OVERRIDE; + virtual base::FilePath GetDebugFrontendDir() OVERRIDE; + virtual std::string GetPageThumbnailData(const GURL& url) OVERRIDE; + virtual content::RenderViewHost* CreateNewTarget() OVERRIDE; + virtual TargetType GetTargetType(content::RenderViewHost*) OVERRIDE; + virtual std::string GetViewDescription(content::RenderViewHost*) OVERRIDE; + + // Returns the DevTools URL for the specified RenderViewHost. + std::string GetDevToolsURL(content::RenderViewHost* rvh, bool http_scheme); + + private: + content::DevToolsHttpHandler* devtools_http_handler_; + scoped_ptr binding_; + + DISALLOW_COPY_AND_ASSIGN(CefDevToolsDelegate); +}; + +#endif // CEF_LIBCEF_BROWSER_DEVTOOLS_DELEGATE_H_ diff --git a/cef3/libcef/browser/devtools_scheme_handler.cc b/cef3/libcef/browser/devtools_scheme_handler.cc new file mode 100644 index 000000000..a5095d69d --- /dev/null +++ b/cef3/libcef/browser/devtools_scheme_handler.cc @@ -0,0 +1,54 @@ +// 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 "libcef/browser/devtools_scheme_handler.h" + +#include + +#include "libcef/browser/internal_scheme_handler.h" + +#include "base/string_util.h" +#include "content/public/common/url_constants.h" +#include "grit/devtools_resources_map.h" + +namespace scheme { + +const char kChromeDevToolsHost[] = "devtools"; + +namespace { + +class Delegate : public InternalHandlerDelegate { + public: + Delegate() {} + + virtual bool OnRequest(CefRefPtr request, + Action* action) OVERRIDE { + GURL url = GURL(request->GetURL().ToString()); + std::string path = url.path(); + if (path.length() > 0) + path = path.substr(1); + + for (size_t i = 0; i < kDevtoolsResourcesSize; ++i) { + if (base::strcasecmp(kDevtoolsResources[i].name, + path.c_str()) == 0) { + action->resource_id = kDevtoolsResources[i].value; + return true; + } + } + + return false; + } +}; + +} // namespace + +void RegisterChromeDevToolsHandler() { + CefRegisterSchemeHandlerFactory( + chrome::kChromeDevToolsScheme, + kChromeDevToolsHost, + CreateInternalHandlerFactory( + make_scoped_ptr(new Delegate()))); +} + +} // namespace scheme diff --git a/cef3/libcef/browser/devtools_scheme_handler.h b/cef3/libcef/browser/devtools_scheme_handler.h new file mode 100644 index 000000000..57168b17b --- /dev/null +++ b/cef3/libcef/browser/devtools_scheme_handler.h @@ -0,0 +1,18 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_DEVTOOLS_SCHEME_HANDLER_H_ +#define CEF_LIBCEF_BROWSER_DEVTOOLS_SCHEME_HANDLER_H_ +#pragma once + +namespace scheme { + +extern const char kChromeDevToolsHost[]; + +// Register the chrome-devtools scheme handler. +void RegisterChromeDevToolsHandler(); + +} // namespace scheme + +#endif // CEF_LIBCEF_BROWSER_DEVTOOLS_SCHEME_HANDLER_H_ diff --git a/cef3/libcef/browser/download_item_impl.cc b/cef3/libcef/browser/download_item_impl.cc new file mode 100644 index 000000000..7b6372737 --- /dev/null +++ b/cef3/libcef/browser/download_item_impl.cc @@ -0,0 +1,102 @@ +// 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 "libcef/browser/download_item_impl.h" + +#include "libcef/common/time_util.h" + +#include "content/public/browser/download_item.h" +#include "googleurl/src/gurl.h" + + +CefDownloadItemImpl::CefDownloadItemImpl(content::DownloadItem* value) + : CefValueBase( + value, NULL, kOwnerNoDelete, true, + new CefValueControllerNonThreadSafe()) { + // Indicate that this object owns the controller. + SetOwnsController(); +} + +bool CefDownloadItemImpl::IsValid() { + return !detached(); +} + +bool CefDownloadItemImpl::IsInProgress() { + CEF_VALUE_VERIFY_RETURN(false, false); + return const_value().IsInProgress(); +} + +bool CefDownloadItemImpl::IsComplete() { + CEF_VALUE_VERIFY_RETURN(false, false); + return const_value().IsComplete(); +} + +bool CefDownloadItemImpl::IsCanceled() { + CEF_VALUE_VERIFY_RETURN(false, false); + return const_value().IsCancelled(); +} + +int64 CefDownloadItemImpl::GetCurrentSpeed() { + CEF_VALUE_VERIFY_RETURN(false, 0); + return const_value().CurrentSpeed(); +} + +int CefDownloadItemImpl::GetPercentComplete() { + CEF_VALUE_VERIFY_RETURN(false, -1); + return const_value().PercentComplete(); +} + +int64 CefDownloadItemImpl::GetTotalBytes() { + CEF_VALUE_VERIFY_RETURN(false, 0); + return const_value().GetTotalBytes(); +} + +int64 CefDownloadItemImpl::GetReceivedBytes() { + CEF_VALUE_VERIFY_RETURN(false, 0); + return const_value().GetReceivedBytes(); +} + +CefTime CefDownloadItemImpl::GetStartTime() { + CefTime time; + CEF_VALUE_VERIFY_RETURN(false, time); + cef_time_from_basetime(const_value().GetStartTime(), time); + return time; +} + +CefTime CefDownloadItemImpl::GetEndTime() { + CefTime time; + CEF_VALUE_VERIFY_RETURN(false, time); + cef_time_from_basetime(const_value().GetEndTime(), time); + return time; +} + +CefString CefDownloadItemImpl::GetFullPath() { + CEF_VALUE_VERIFY_RETURN(false, CefString()); + return const_value().GetFullPath().value(); +} + +int32 CefDownloadItemImpl::GetId() { + CEF_VALUE_VERIFY_RETURN(false, 0); + return const_value().GetId(); +} + +CefString CefDownloadItemImpl::GetURL() { + CEF_VALUE_VERIFY_RETURN(false, CefString()); + return const_value().GetURL().spec(); +} + +CefString CefDownloadItemImpl::GetSuggestedFileName() { + CEF_VALUE_VERIFY_RETURN(false, CefString()); + return const_value().GetSuggestedFilename(); +} + +CefString CefDownloadItemImpl::GetContentDisposition() { + CEF_VALUE_VERIFY_RETURN(false, CefString()); + return const_value().GetContentDisposition(); +} + +CefString CefDownloadItemImpl::GetMimeType() { + CEF_VALUE_VERIFY_RETURN(false, CefString()); + return const_value().GetMimeType(); +} diff --git a/cef3/libcef/browser/download_item_impl.h b/cef3/libcef/browser/download_item_impl.h new file mode 100644 index 000000000..64a598310 --- /dev/null +++ b/cef3/libcef/browser/download_item_impl.h @@ -0,0 +1,44 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_DOWNLOAD_ITEM_IMPL_H_ +#define CEF_LIBCEF_BROWSER_DOWNLOAD_ITEM_IMPL_H_ +#pragma once + +#include "include/cef_download_item.h" +#include "libcef/common/value_base.h" + +namespace content { +class DownloadItem; +} + +// CefDownloadItem implementation +class CefDownloadItemImpl + : public CefValueBase { + public: + explicit CefDownloadItemImpl(content::DownloadItem* value); + + // CefDownloadItem methods. + virtual bool IsValid() OVERRIDE; + virtual bool IsInProgress() OVERRIDE; + virtual bool IsComplete() OVERRIDE; + virtual bool IsCanceled() OVERRIDE; + virtual int64 GetCurrentSpeed() OVERRIDE; + virtual int GetPercentComplete() OVERRIDE; + virtual int64 GetTotalBytes() OVERRIDE; + virtual int64 GetReceivedBytes() OVERRIDE; + virtual CefTime GetStartTime() OVERRIDE; + virtual CefTime GetEndTime() OVERRIDE; + virtual CefString GetFullPath() OVERRIDE; + virtual int32 GetId() OVERRIDE; + virtual CefString GetURL() OVERRIDE; + virtual CefString GetSuggestedFileName() OVERRIDE; + virtual CefString GetContentDisposition() OVERRIDE; + virtual CefString GetMimeType() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(CefDownloadItemImpl); +}; + +#endif // CEF_LIBCEF_BROWSER_DOWNLOAD_ITEM_IMPL_H_ diff --git a/cef3/libcef/browser/download_manager_delegate.cc b/cef3/libcef/browser/download_manager_delegate.cc new file mode 100644 index 000000000..eb42923d0 --- /dev/null +++ b/cef3/libcef/browser/download_manager_delegate.cc @@ -0,0 +1,343 @@ +// Copyright (c) 2012 The Chromium 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 "libcef/browser/download_manager_delegate.h" + +#include "include/cef_download_handler.h" +#include "libcef/browser/browser_context.h" +#include "libcef/browser/browser_host_impl.h" +#include "libcef/browser/context.h" +#include "libcef/browser/download_item_impl.h" +#include "libcef/browser/thread_util.h" + +#include "base/bind.h" +#include "base/file_util.h" +#include "base/logging.h" +#include "base/path_service.h" +#include "base/string_util.h" +#include "base/utf_string_conversions.h" +#include "content/public/browser/browser_context.h" +#include "content/public/browser/web_contents.h" +#include "content/public/common/file_chooser_params.h" +#include "net/base/net_util.h" + +using content::DownloadItem; +using content::DownloadManager; +using content::WebContents; + + +namespace { + +// Helper function to retrieve the CefBrowserHostImpl. +CefRefPtr GetBrowser(DownloadItem* item) { + content::WebContents* contents = item->GetWebContents(); + if (!contents) + return NULL; + + return CefBrowserHostImpl::GetBrowserForContents(contents).get(); +} + +// Helper function to retrieve the CefDownloadHandler. +CefRefPtr GetDownloadHandler( + CefRefPtr browser) { + CefRefPtr client = browser->GetClient(); + if (client.get()) + return client->GetDownloadHandler(); + return NULL; +} + + +// CefBeforeDownloadCallback implementation. +class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback { + public: + CefBeforeDownloadCallbackImpl( + const base::WeakPtr& manager, + int32 download_id, + const base::FilePath& suggested_name, + const content::DownloadTargetCallback& callback) + : manager_(manager), + download_id_(download_id), + suggested_name_(suggested_name), + callback_(callback) { + } + + virtual void Continue(const CefString& download_path, + bool show_dialog) OVERRIDE { + if (CEF_CURRENTLY_ON_UIT()) { + if (download_id_ <= 0) + return; + + if (manager_) { + base::FilePath path = base::FilePath(download_path); + CEF_POST_TASK(CEF_FILET, + base::Bind(&CefBeforeDownloadCallbackImpl::GenerateFilename, + manager_, download_id_, suggested_name_, path, + show_dialog, callback_)); + } + + download_id_ = 0; + callback_.Reset(); + } else { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefBeforeDownloadCallbackImpl::Continue, this, + download_path, show_dialog)); + } + } + + private: + static void GenerateFilename( + base::WeakPtr manager, + int32 download_id, + const base::FilePath& suggested_name, + const base::FilePath& download_path, + bool show_dialog, + const content::DownloadTargetCallback& callback) { + base::FilePath suggested_path = download_path; + if (!suggested_path.empty()) { + // Create the directory if necessary. + base::FilePath dir_path = suggested_path.DirName(); + if (!file_util::DirectoryExists(dir_path) && + !file_util::CreateDirectory(dir_path)) { + NOTREACHED() << "failed to create the download directory"; + suggested_path.clear(); + } + } + + if (suggested_path.empty()) { + if (PathService::Get(base::DIR_TEMP, &suggested_path)) { + // Use the temp directory. + suggested_path = suggested_path.Append(suggested_name); + } else { + // Use the current working directory. + suggested_path = suggested_name; + } + } + + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefBeforeDownloadCallbackImpl::ChooseDownloadPath, + manager, download_id, suggested_path, show_dialog, + callback)); + } + + static void ChooseDownloadPath( + base::WeakPtr manager, + int32 download_id, + const base::FilePath& suggested_path, + bool show_dialog, + const content::DownloadTargetCallback& callback) { + if (!manager) + return; + + DownloadItem* item = manager->GetDownload(download_id); + if (!item || !item->IsInProgress()) + return; + + bool handled = false; + + if (show_dialog) { + WebContents* web_contents = item->GetWebContents(); + CefRefPtr browser = + CefBrowserHostImpl::GetBrowserForContents(web_contents); + if (browser.get()) { + handled = true; + + content::FileChooserParams params; + params.mode = content::FileChooserParams::Save; + if (!suggested_path.empty()) { + params.default_file_name = suggested_path; + if (!suggested_path.Extension().empty()) { + params.accept_types.push_back( + CefString(suggested_path.Extension())); + } + } + + browser->RunFileChooser(params, + base::Bind( + &CefBeforeDownloadCallbackImpl::ChooseDownloadPathCallback, + callback)); + } + } + + if (!handled) { + callback.Run(suggested_path, + DownloadItem::TARGET_DISPOSITION_OVERWRITE, + content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, + suggested_path); + } + } + + static void ChooseDownloadPathCallback( + const content::DownloadTargetCallback& callback, + const std::vector& file_paths) { + DCHECK_LE(file_paths.size(), (size_t) 1); + + base::FilePath path; + if (file_paths.size() > 0) + path = file_paths.front(); + + // The download will be cancelled if |path| is empty. + callback.Run(path, + DownloadItem::TARGET_DISPOSITION_OVERWRITE, + content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, + path); + } + + base::WeakPtr manager_; + int32 download_id_; + base::FilePath suggested_name_; + content::DownloadTargetCallback callback_; + + IMPLEMENT_REFCOUNTING(CefBeforeDownloadCallbackImpl); + DISALLOW_COPY_AND_ASSIGN(CefBeforeDownloadCallbackImpl); +}; + + +// CefDownloadItemCallback implementation. +class CefDownloadItemCallbackImpl : public CefDownloadItemCallback { + public: + explicit CefDownloadItemCallbackImpl( + const base::WeakPtr& manager, + int32 download_id) + : manager_(manager), + download_id_(download_id) { + } + + virtual void Cancel() OVERRIDE { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefDownloadItemCallbackImpl::DoCancel, this)); + } + + private: + void DoCancel() { + if (download_id_ <= 0) + return; + + if (manager_) { + DownloadItem* item = manager_->GetDownload(download_id_); + if (item && item->IsInProgress()) + item->Cancel(true); + } + + download_id_ = 0; + } + + base::WeakPtr manager_; + int32 download_id_; + + IMPLEMENT_REFCOUNTING(CefDownloadItemCallbackImpl); + DISALLOW_COPY_AND_ASSIGN(CefDownloadItemCallbackImpl); +}; + +} // namespace + + +CefDownloadManagerDelegate::CefDownloadManagerDelegate( + DownloadManager* manager) + : manager_(manager), + manager_ptr_factory_(manager) { + DCHECK(manager); + manager->AddObserver(this); + + DownloadManager::DownloadVector items; + manager->GetAllDownloads(&items); + DownloadManager::DownloadVector::const_iterator it = items.begin(); + for (; it != items.end(); ++it) { + (*it)->AddObserver(this); + observing_.insert(*it); + } +} + +CefDownloadManagerDelegate::~CefDownloadManagerDelegate() { + if (manager_) { + manager_->SetDelegate(NULL); + manager_->RemoveObserver(this); + } + + std::set::const_iterator it = observing_.begin(); + for (; it != observing_.end(); ++it) + (*it)->RemoveObserver(this); + observing_.clear(); +} + +void CefDownloadManagerDelegate::OnDownloadUpdated( + DownloadItem* download) { + CefRefPtr browser = GetBrowser(download); + CefRefPtr handler; + if (browser.get()) + handler = GetDownloadHandler(browser); + + if (handler.get()) { + CefRefPtr download_item( + new CefDownloadItemImpl(download)); + CefRefPtr callback( + new CefDownloadItemCallbackImpl(manager_ptr_factory_.GetWeakPtr(), + download->GetId())); + + handler->OnDownloadUpdated(browser.get(), download_item.get(), callback); + + download_item->Detach(NULL); + } +} + +void CefDownloadManagerDelegate::OnDownloadDestroyed( + DownloadItem* download) { + download->RemoveObserver(this); + observing_.erase(download); +} + +void CefDownloadManagerDelegate::OnDownloadCreated( + DownloadManager* manager, + DownloadItem* item) { + item->AddObserver(this); + observing_.insert(item); +} + +void CefDownloadManagerDelegate::ManagerGoingDown( + DownloadManager* manager) { + DCHECK_EQ(manager, manager_); + manager->SetDelegate(NULL); + manager->RemoveObserver(this); + manager_ptr_factory_.InvalidateWeakPtrs(); + manager_ = NULL; +} + +bool CefDownloadManagerDelegate::DetermineDownloadTarget( + DownloadItem* item, + const content::DownloadTargetCallback& callback) { + if (!item->GetForcedFilePath().empty()) { + callback.Run(item->GetForcedFilePath(), + DownloadItem::TARGET_DISPOSITION_OVERWRITE, + content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, + item->GetForcedFilePath()); + return true; + } + + CefRefPtr browser = GetBrowser(item); + CefRefPtr handler; + if (browser.get()) + handler = GetDownloadHandler(browser); + + if (handler.get()) { + base::FilePath suggested_name = net::GenerateFileName( + item->GetURL(), + item->GetContentDisposition(), + EmptyString(), + item->GetSuggestedFilename(), + item->GetMimeType(), + "download"); + + CefRefPtr download_item(new CefDownloadItemImpl(item)); + CefRefPtr callbackObj( + new CefBeforeDownloadCallbackImpl(manager_ptr_factory_.GetWeakPtr(), + item->GetId(), suggested_name, + callback)); + + handler->OnBeforeDownload(browser.get(), download_item.get(), + suggested_name.value(), callbackObj); + + download_item->Detach(NULL); + } + + return true; +} diff --git a/cef3/libcef/browser/download_manager_delegate.h b/cef3/libcef/browser/download_manager_delegate.h new file mode 100644 index 000000000..272dc4f64 --- /dev/null +++ b/cef3/libcef/browser/download_manager_delegate.h @@ -0,0 +1,47 @@ +// Copyright (c) 2012 The Chromium 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_LIBCEF_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_ +#define CEF_LIBCEF_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_ +#pragma once + +#include + +#include "base/compiler_specific.h" +#include "base/memory/weak_ptr.h" +#include "content/public/browser/download_item.h" +#include "content/public/browser/download_manager.h" +#include "content/public/browser/download_manager_delegate.h" + +class CefDownloadManagerDelegate + : public content::DownloadItem::Observer, + public content::DownloadManager::Observer, + public content::DownloadManagerDelegate { + public: + explicit CefDownloadManagerDelegate(content::DownloadManager* manager); + ~CefDownloadManagerDelegate(); + + private: + // DownloadItem::Observer methods. + virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE; + virtual void OnDownloadDestroyed(content::DownloadItem* download) OVERRIDE; + + // DownloadManager::Observer methods. + virtual void OnDownloadCreated(content::DownloadManager* manager, + content::DownloadItem* item) OVERRIDE; + virtual void ManagerGoingDown(content::DownloadManager* manager) OVERRIDE; + + // DownloadManagerDelegate methods. + virtual bool DetermineDownloadTarget( + content::DownloadItem* item, + const content::DownloadTargetCallback& callback) OVERRIDE; + + content::DownloadManager* manager_; + base::WeakPtrFactory manager_ptr_factory_; + std::set observing_; + + DISALLOW_COPY_AND_ASSIGN(CefDownloadManagerDelegate); +}; + +#endif // CEF_LIBCEF_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_ diff --git a/cef3/libcef/browser/frame_host_impl.cc b/cef3/libcef/browser/frame_host_impl.cc new file mode 100644 index 000000000..a587da8e2 --- /dev/null +++ b/cef3/libcef/browser/frame_host_impl.cc @@ -0,0 +1,247 @@ +// 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 "libcef/browser/frame_host_impl.h" +#include "include/cef_request.h" +#include "include/cef_stream.h" +#include "include/cef_v8.h" +#include "libcef/common/cef_messages.h" +#include "libcef/browser/browser_host_impl.h" + +namespace { + +// Implementation of CommandResponseHandler for calling a CefStringVisitor. +class StringVisitHandler : public CefResponseManager::Handler { + public: + explicit StringVisitHandler(CefRefPtr visitor) + : visitor_(visitor) { + } + virtual void OnResponse(const Cef_Response_Params& params) OVERRIDE { + visitor_->Visit(params.response); + } + private: + CefRefPtr visitor_; + + IMPLEMENT_REFCOUNTING(StringVisitHandler); +}; + +// Implementation of CommandResponseHandler for calling ViewText(). +class ViewTextHandler : public CefResponseManager::Handler { + public: + explicit ViewTextHandler(CefRefPtr frame) + : frame_(frame) { + } + virtual void OnResponse(const Cef_Response_Params& params) OVERRIDE { + CefRefPtr browser = frame_->GetBrowser(); + if (browser.get()) { + static_cast(browser.get())->ViewText( + params.response); + } + } + private: + CefRefPtr frame_; + + IMPLEMENT_REFCOUNTING(ViewTextHandler); +}; + +} // namespace + +CefFrameHostImpl::CefFrameHostImpl(CefBrowserHostImpl* browser, + int64 frame_id, + bool is_main_frame) + : frame_id_(frame_id), + is_main_frame_(is_main_frame), + browser_(browser), + is_focused_(false), + parent_frame_id_(kInvalidFrameId) { +} + +CefFrameHostImpl::~CefFrameHostImpl() { +} + +bool CefFrameHostImpl::IsValid() { + base::AutoLock lock_scope(state_lock_); + return (browser_ != NULL); +} + +void CefFrameHostImpl::Undo() { + base::AutoLock lock_scope(state_lock_); + if (browser_ && frame_id_ != kInvalidFrameId) + browser_->SendCommand(frame_id_, "Undo", NULL); +} + +void CefFrameHostImpl::Redo() { + base::AutoLock lock_scope(state_lock_); + if (browser_ && frame_id_ != kInvalidFrameId) + browser_->SendCommand(frame_id_, "Redo", NULL); +} + +void CefFrameHostImpl::Cut() { + base::AutoLock lock_scope(state_lock_); + if (browser_ && frame_id_ != kInvalidFrameId) + browser_->SendCommand(frame_id_, "Cut", NULL); +} + +void CefFrameHostImpl::Copy() { + base::AutoLock lock_scope(state_lock_); + if (browser_ && frame_id_ != kInvalidFrameId) + browser_->SendCommand(frame_id_, "Copy", NULL); +} + +void CefFrameHostImpl::Paste() { + base::AutoLock lock_scope(state_lock_); + if (browser_ && frame_id_ != kInvalidFrameId) + browser_->SendCommand(frame_id_, "Paste", NULL); +} + +void CefFrameHostImpl::Delete() { + base::AutoLock lock_scope(state_lock_); + if (browser_ && frame_id_ != kInvalidFrameId) + browser_->SendCommand(frame_id_, "Delete", NULL); +} + +void CefFrameHostImpl::SelectAll() { + base::AutoLock lock_scope(state_lock_); + if (browser_ && frame_id_ != kInvalidFrameId) + browser_->SendCommand(frame_id_, "SelectAll", NULL); +} + +void CefFrameHostImpl::ViewSource() { + base::AutoLock lock_scope(state_lock_); + if (browser_ && frame_id_ != kInvalidFrameId) + browser_->SendCommand(frame_id_, "GetSource", new ViewTextHandler(this)); +} + +void CefFrameHostImpl::GetSource(CefRefPtr visitor) { + base::AutoLock lock_scope(state_lock_); + if (browser_ && frame_id_ != kInvalidFrameId) { + browser_->SendCommand(frame_id_, "GetSource", + new StringVisitHandler(visitor)); + } +} + +void CefFrameHostImpl::GetText(CefRefPtr visitor) { + base::AutoLock lock_scope(state_lock_); + if (browser_ && frame_id_ != kInvalidFrameId) { + browser_->SendCommand(frame_id_, "GetText", + new StringVisitHandler(visitor)); + } +} + +void CefFrameHostImpl::LoadRequest(CefRefPtr request) { + base::AutoLock lock_scope(state_lock_); + if (browser_) + browser_->LoadRequest((is_main_frame_ ? kMainFrameId : frame_id_), request); +} + +void CefFrameHostImpl::LoadURL(const CefString& url) { + base::AutoLock lock_scope(state_lock_); + if (browser_) + browser_->LoadURL((is_main_frame_ ? kMainFrameId : frame_id_), url); +} + +void CefFrameHostImpl::LoadString(const CefString& string, + const CefString& url) { + base::AutoLock lock_scope(state_lock_); + if (browser_) { + browser_->LoadString((is_main_frame_ ? kMainFrameId : frame_id_), string, + url); + } +} + +void CefFrameHostImpl::ExecuteJavaScript(const CefString& jsCode, + const CefString& scriptUrl, + int startLine) { + SendJavaScript(jsCode, scriptUrl, startLine); +} + +bool CefFrameHostImpl::IsMain() { + return is_main_frame_; +} + +bool CefFrameHostImpl::IsFocused() { + base::AutoLock lock_scope(state_lock_); + return is_focused_; +} + +CefString CefFrameHostImpl::GetName() { + base::AutoLock lock_scope(state_lock_); + return name_; +} + +int64 CefFrameHostImpl::GetIdentifier() { + return frame_id_; +} + +CefRefPtr CefFrameHostImpl::GetParent() { + base::AutoLock lock_scope(state_lock_); + + if (is_main_frame_ || parent_frame_id_ == kInvalidFrameId) + return NULL; + + if (browser_) + return browser_->GetFrame(parent_frame_id_); + + return NULL; +} + +CefString CefFrameHostImpl::GetURL() { + base::AutoLock lock_scope(state_lock_); + return url_; +} + +CefRefPtr CefFrameHostImpl::GetBrowser() { + base::AutoLock lock_scope(state_lock_); + return browser_; +} + +void CefFrameHostImpl::SetFocused(bool focused) { + base::AutoLock lock_scope(state_lock_); + is_focused_ = focused; +} + +void CefFrameHostImpl::SetURL(const CefString& url) { + base::AutoLock lock_scope(state_lock_); + url_ = url; +} + +void CefFrameHostImpl::SetName(const CefString& name) { + base::AutoLock lock_scope(state_lock_); + name_ = name; +} + +void CefFrameHostImpl::SetParentId(int64 frame_id) { + base::AutoLock lock_scope(state_lock_); + parent_frame_id_ = frame_id; +} + +CefRefPtr CefFrameHostImpl::GetV8Context() { + NOTREACHED() << "GetV8Context cannot be called from the browser process"; + return NULL; +} + +void CefFrameHostImpl::VisitDOM(CefRefPtr visitor) { + NOTREACHED() << "VisitDOM cannot be called from the browser process"; +} + +void CefFrameHostImpl::SendJavaScript( + const std::string& jsCode, + const std::string& scriptUrl, + int startLine) { + if (jsCode.empty()) + return; + if (startLine < 0) + startLine = 0; + + base::AutoLock lock_scope(state_lock_); + if (browser_) { + browser_->SendCode((is_main_frame_ ? kMainFrameId : frame_id_), true, + jsCode, scriptUrl, startLine, NULL); + } +} + +void CefFrameHostImpl::Detach() { + base::AutoLock lock_scope(state_lock_); + browser_ = NULL; +} diff --git a/cef3/libcef/browser/frame_host_impl.h b/cef3/libcef/browser/frame_host_impl.h new file mode 100644 index 000000000..0b96d2dbb --- /dev/null +++ b/cef3/libcef/browser/frame_host_impl.h @@ -0,0 +1,89 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_FRAME_HOST_IMPL_H_ +#define CEF_LIBCEF_BROWSER_FRAME_HOST_IMPL_H_ +#pragma once + +#include +#include "include/cef_frame.h" +#include "base/synchronization/lock.h" + +class CefBrowserHostImpl; + +// Implementation of CefFrame. CefFrameHostImpl objects are owned by the +// CefBrowerHostImpl and will be detached when the browser is notified that the +// associated renderer WebFrame will close. +class CefFrameHostImpl : public CefFrame { + public: + CefFrameHostImpl(CefBrowserHostImpl* browser, + int64 frame_id, + bool is_main_frame); + virtual ~CefFrameHostImpl(); + + // CefFrame methods + virtual bool IsValid() OVERRIDE; + virtual void Undo() OVERRIDE; + virtual void Redo() OVERRIDE; + virtual void Cut() OVERRIDE; + virtual void Copy() OVERRIDE; + virtual void Paste() OVERRIDE; + virtual void Delete() OVERRIDE; + virtual void SelectAll() OVERRIDE; + virtual void ViewSource() OVERRIDE; + virtual void GetSource(CefRefPtr visitor) OVERRIDE; + virtual void GetText(CefRefPtr visitor) OVERRIDE; + virtual void LoadRequest(CefRefPtr request) OVERRIDE; + virtual void LoadURL(const CefString& url) OVERRIDE; + virtual void LoadString(const CefString& string, + const CefString& url) OVERRIDE; + virtual void ExecuteJavaScript(const CefString& jsCode, + const CefString& scriptUrl, + int startLine) OVERRIDE; + virtual bool IsMain() OVERRIDE; + virtual bool IsFocused() OVERRIDE; + virtual CefString GetName() OVERRIDE; + virtual int64 GetIdentifier() OVERRIDE; + virtual CefRefPtr GetParent() OVERRIDE; + virtual CefString GetURL() OVERRIDE; + virtual CefRefPtr GetBrowser() OVERRIDE; + virtual CefRefPtr GetV8Context() OVERRIDE; + virtual void VisitDOM(CefRefPtr visitor) OVERRIDE; + + void SetFocused(bool focused); + void SetURL(const CefString& url); + void SetName(const CefString& name); + void SetParentId(int64 frame_id); + + // Avoids unnecessary string type conversions. + void SendJavaScript(const std::string& jsCode, + const std::string& scriptUrl, + int startLine); + + // Detach the frame from the browser. + void Detach(); + + // kMainFrameId must be -1 to align with renderer expectations. + static const int64 kMainFrameId = -1; + static const int64 kFocusedFrameId = -2; + static const int64 kUnspecifiedFrameId = -3; + static const int64 kInvalidFrameId = -4; + + protected: + int64 frame_id_; + bool is_main_frame_; + + // Volatile state information. All access must be protected by the state lock. + base::Lock state_lock_; + CefBrowserHostImpl* browser_; + bool is_focused_; + CefString url_; + CefString name_; + int64 parent_frame_id_; + + IMPLEMENT_REFCOUNTING(CefFrameHostImpl); + DISALLOW_EVIL_CONSTRUCTORS(CefFrameHostImpl); +}; + +#endif // CEF_LIBCEF_BROWSER_FRAME_HOST_IMPL_H_ diff --git a/cef3/libcef/browser/geolocation_impl.cc b/cef3/libcef/browser/geolocation_impl.cc new file mode 100644 index 000000000..21cc1a0dc --- /dev/null +++ b/cef3/libcef/browser/geolocation_impl.cc @@ -0,0 +1,80 @@ +// 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 "include/cef_geolocation.h" +#include "libcef/browser/context.h" +#include "libcef/browser/thread_util.h" +#include "libcef/common/time_util.h" +#include "base/logging.h" +#include "content/browser/geolocation/geolocation_provider.h" +#include "content/public/common/geoposition.h" + +namespace { + +void SetPosition(const content::Geoposition& source, CefGeoposition& target) { + target.latitude = source.latitude; + target.longitude = source.longitude; + target.altitude = source.altitude; + target.accuracy = source.accuracy; + target.altitude_accuracy = source.altitude_accuracy; + target.heading = source.heading; + target.speed = source.speed; + cef_time_from_basetime(source.timestamp, target.timestamp); + + switch (source.error_code) { + case content::Geoposition::ERROR_CODE_NONE: + target.error_code = GEOPOSITON_ERROR_NONE; + break; + case content::Geoposition::ERROR_CODE_PERMISSION_DENIED: + target.error_code = GEOPOSITON_ERROR_PERMISSION_DENIED; + break; + case content::Geoposition::ERROR_CODE_POSITION_UNAVAILABLE: + target.error_code = GEOPOSITON_ERROR_POSITION_UNAVAILABLE; + break; + case content::Geoposition::ERROR_CODE_TIMEOUT: + target.error_code = GEOPOSITON_ERROR_TIMEOUT; + break; + } + + CefString(&target.error_message) = source.error_message; +} + +void LocationCallback(CefRefPtr callback, + const content::Geoposition& position) { + if (CEF_CURRENTLY_ON_UIT()) { + CefGeoposition cef_position; + SetPosition(position, cef_position); + callback->OnLocationUpdate(cef_position); + } else { + CEF_POST_TASK(CEF_UIT, base::Bind(LocationCallback, callback, position)); + } +} + +} // namespace + +bool CefGetGeolocation(CefRefPtr callback) { + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return false; + } + + if (!callback.get()) { + NOTREACHED() << "invalid parameter"; + return false; + } + + if (CEF_CURRENTLY_ON_IOT()) { + content::GeolocationProvider* provider = + content::GeolocationProvider::GetInstance(); + if (provider) { + provider->RequestCallback(base::Bind(LocationCallback, callback)); + return true; + } + return false; + } else { + CEF_POST_TASK(CEF_IOT, + base::Bind(base::IgnoreResult(CefGetGeolocation), callback)); + return true; + } +} diff --git a/cef3/libcef/browser/gtk_util_stub.cc b/cef3/libcef/browser/gtk_util_stub.cc new file mode 100644 index 000000000..809d0eeb4 --- /dev/null +++ b/cef3/libcef/browser/gtk_util_stub.cc @@ -0,0 +1,36 @@ +// Copyright (c) 2012 The Chromium 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 + +#include "ui/base/events/event.h" + +// This file includes a selection of methods copied from +// chrome/browser/ui/gtk/gtk_util.cc. + +namespace gtk_util { + +void SetAlwaysShowImage(GtkWidget* image_menu_item) { + gtk_image_menu_item_set_always_show_image( + GTK_IMAGE_MENU_ITEM(image_menu_item), TRUE); +} + +} // namespace gtk_util + + +namespace event_utils { + +int EventFlagsFromGdkState(guint state) { + int flags = 0; + flags |= (state & GDK_LOCK_MASK) ? ui::EF_CAPS_LOCK_DOWN : 0; + flags |= (state & GDK_CONTROL_MASK) ? ui::EF_CONTROL_DOWN : 0; + flags |= (state & GDK_SHIFT_MASK) ? ui::EF_SHIFT_DOWN : 0; + flags |= (state & GDK_MOD1_MASK) ? ui::EF_ALT_DOWN : 0; + flags |= (state & GDK_BUTTON1_MASK) ? ui::EF_LEFT_MOUSE_BUTTON : 0; + flags |= (state & GDK_BUTTON2_MASK) ? ui::EF_MIDDLE_MOUSE_BUTTON : 0; + flags |= (state & GDK_BUTTON3_MASK) ? ui::EF_RIGHT_MOUSE_BUTTON : 0; + return flags; +} + +} // namespace event_utils diff --git a/cef3/libcef/browser/internal_scheme_handler.cc b/cef3/libcef/browser/internal_scheme_handler.cc new file mode 100644 index 000000000..a5019d4bf --- /dev/null +++ b/cef3/libcef/browser/internal_scheme_handler.cc @@ -0,0 +1,178 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2012 The Chromium 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 "libcef/browser/internal_scheme_handler.h" +#include +#include "base/string_util.h" +#include "content/public/common/content_client.h" +#include "ui/base/resource/resource_bundle.h" + +namespace scheme { + +namespace { + +static std::string GetMimeType(const std::string& filename) { + if (EndsWith(filename, ".html", false)) { + return "text/html"; + } else if (EndsWith(filename, ".css", false)) { + return "text/css"; + } else if (EndsWith(filename, ".jpg", false)) { + return "image/jpeg"; + } else if (EndsWith(filename, ".js", false)) { + return "application/javascript"; + } else if (EndsWith(filename, ".png", false)) { + return "image/png"; + } else if (EndsWith(filename, ".gif", false)) { + return "image/gif"; + } + NOTREACHED() << "No known mime type for file: " << filename.c_str(); + return "text/plain"; +} + +class RedirectHandler : public CefResourceHandler { + public: + explicit RedirectHandler(const GURL& url) + : url_(url) { + } + + virtual bool ProcessRequest(CefRefPtr request, + CefRefPtr callback) OVERRIDE { + callback->Continue(); + return true; + } + + virtual void GetResponseHeaders(CefRefPtr response, + int64& response_length, + CefString& redirectUrl) OVERRIDE { + response_length = 0; + redirectUrl = url_.spec(); + } + + virtual bool ReadResponse(void* data_out, + int bytes_to_read, + int& bytes_read, + CefRefPtr callback) OVERRIDE { + return false; + } + + virtual void Cancel() OVERRIDE { + } + + private: + GURL url_; + + IMPLEMENT_REFCOUNTING(RedirectHandler); +}; + +class InternalHandler : public CefResourceHandler { + public: + InternalHandler(const std::string& mime_type, + CefRefPtr reader, + int size) + : mime_type_(mime_type), + reader_(reader), + size_(size) { + } + + virtual bool ProcessRequest(CefRefPtr request, + CefRefPtr callback) OVERRIDE { + callback->Continue(); + return true; + } + + virtual void GetResponseHeaders(CefRefPtr response, + int64& response_length, + CefString& redirectUrl) OVERRIDE { + response_length = size_; + + response->SetMimeType(mime_type_); + response->SetStatus(200); + } + + virtual bool ReadResponse(void* data_out, + int bytes_to_read, + int& bytes_read, + CefRefPtr callback) OVERRIDE { + bytes_read = reader_->Read(data_out, 1, bytes_to_read); + return (bytes_read > 0); + } + + virtual void Cancel() OVERRIDE { + } + + private: + std::string mime_type_; + CefRefPtr reader_; + int size_; + + IMPLEMENT_REFCOUNTING(InternalHandler); +}; + +class InternalHandlerFactory : public CefSchemeHandlerFactory { + public: + explicit InternalHandlerFactory( + scoped_ptr delegate) + : delegate_(delegate.Pass()) { + } + + virtual CefRefPtr Create( + CefRefPtr browser, + CefRefPtr frame, + const CefString& scheme_name, + CefRefPtr request) OVERRIDE { + GURL url = GURL(request->GetURL().ToString()); + + InternalHandlerDelegate::Action action; + if (delegate_->OnRequest(request, &action)) { + if (!action.redirect_url.is_empty() && action.redirect_url.is_valid()) + return new RedirectHandler(action.redirect_url); + + if (action.mime_type.empty()) + action.mime_type = GetMimeType(url.path()); + + if (action.resource_id >= 0) { + base::StringPiece piece = content::GetContentClient()->GetDataResource( + action.resource_id, ui::SCALE_FACTOR_NONE); + if (!piece.empty()) { + action.stream = + CefStreamReader::CreateForData(const_cast(piece.data()), + piece.size()); + action.stream_size = piece.size(); + } else { + NOTREACHED() << "Failed to load internal resource for id: " << + action.resource_id << " URL: " << url.spec().c_str(); + return NULL; + } + } + + if (action.stream.get()) { + return new InternalHandler(action.mime_type, action.stream, + action.stream_size); + } + } + + return NULL; + } + + private: + scoped_ptr delegate_; + + IMPLEMENT_REFCOUNTING(InternalHandlerFactory); +}; + +} // namespace + +InternalHandlerDelegate::Action::Action() + : stream_size(-1), + resource_id(-1) { +} + +CefRefPtr CreateInternalHandlerFactory( + scoped_ptr delegate) { + DCHECK(delegate.get()); + return new InternalHandlerFactory(delegate.Pass()); +} + +} // namespace scheme diff --git a/cef3/libcef/browser/internal_scheme_handler.h b/cef3/libcef/browser/internal_scheme_handler.h new file mode 100644 index 000000000..e6c39052c --- /dev/null +++ b/cef3/libcef/browser/internal_scheme_handler.h @@ -0,0 +1,53 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_INTERNAL_SCHEME_HANDLER_H_ +#define CEF_LIBCEF_BROWSER_INTERNAL_SCHEME_HANDLER_H_ +#pragma once + +#include +#include "include/cef_scheme.h" +#include "base/memory/scoped_ptr.h" +#include "googleurl/src/gurl.h" + +namespace scheme { + +// All methods will be called on the browser process IO thread. +class InternalHandlerDelegate { + public: + class Action { + public: + Action(); + + // Set to the appropriate value or leave empty to have it determined based + // on the file extension. + std::string mime_type; + + // Option 1: Provide a stream for the resource contents. Set |stream_size| + // to the stream size or to -1 if unknown. + CefRefPtr stream; + int stream_size; + + // Option 2: Specify a resource id to load static content. + int resource_id; + + // Option 3: Redirect to the specified URL. + GURL redirect_url; + }; + + virtual ~InternalHandlerDelegate() {} + + // Populate |action| and return true if the request was handled. + virtual bool OnRequest(CefRefPtr request, + Action* action) = 0; +}; + +// Create an internal scheme handler factory. The factory will take ownership of +// |delegate|. +CefRefPtr CreateInternalHandlerFactory( + scoped_ptr delegate); + +} // namespace scheme + +#endif // CEF_LIBCEF_BROWSER_INTERNAL_SCHEME_HANDLER_H_ diff --git a/cef3/libcef/browser/javascript_dialog.h b/cef3/libcef/browser/javascript_dialog.h new file mode 100644 index 000000000..a2edc964f --- /dev/null +++ b/cef3/libcef/browser/javascript_dialog.h @@ -0,0 +1,74 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2012 The Chromium 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_LIBCEF_BROWSER_JAVASCRIPT_DIALOG_H_ +#define CEF_LIBCEF_BROWSER_JAVASCRIPT_DIALOG_H_ +#pragma once + +#include "content/public/browser/javascript_dialog_manager.h" + +#if defined(TOOLKIT_GTK) +#include "ui/base/gtk/gtk_signal.h" +#endif + +#if defined(OS_MACOSX) +#if __OBJC__ +@class CefJavaScriptDialogHelper; +#else +class CefJavaScriptDialogHelper; +#endif // __OBJC__ +#endif // defined(OS_MACOSX) + +class CefJavaScriptDialogManager; + +class CefJavaScriptDialog { + public: + CefJavaScriptDialog( + CefJavaScriptDialogManager* creator, + content::JavaScriptMessageType message_type, + const string16& display_url, + const string16& message_text, + const string16& default_prompt_text, + const content::JavaScriptDialogManager::DialogClosedCallback& callback); + ~CefJavaScriptDialog(); + + // Called to cancel a dialog mid-flight. + void Cancel(); + + // Activate the dialog. + void Activate(); + + private: + CefJavaScriptDialogManager* creator_; + content::JavaScriptDialogManager::DialogClosedCallback callback_; + +#if defined(OS_MACOSX) + CefJavaScriptDialogHelper* helper_; // owned +#elif defined(OS_WIN) + content::JavaScriptMessageType message_type_; + HWND dialog_win_; + HWND parent_win_; + string16 message_text_; + string16 default_prompt_text_; + static INT_PTR CALLBACK DialogProc(HWND dialog, UINT message, WPARAM wparam, + LPARAM lparam); + + // Since the message loop we expect to run in isn't going to be nicely + // calling IsDialogMessage(), we need to hook the wnd proc and call it + // ourselves. See http://support.microsoft.com/kb/q187988/ + static bool InstallMessageHook(); + static bool UninstallMessageHook(); + static LRESULT CALLBACK GetMsgProc(int code, WPARAM wparam, LPARAM lparam); + static HHOOK msg_hook_; + static int msg_hook_user_count_; +#elif defined(TOOLKIT_GTK) + GtkWidget* gtk_dialog_; + CHROMEGTK_CALLBACK_1(CefJavaScriptDialog, void, OnResponse, int); +#endif + + DISALLOW_COPY_AND_ASSIGN(CefJavaScriptDialog); +}; + +#endif // CEF_LIBCEF_BROWSER_JAVASCRIPT_DIALOG_H_ diff --git a/cef3/libcef/browser/javascript_dialog_gtk.cc b/cef3/libcef/browser/javascript_dialog_gtk.cc new file mode 100644 index 000000000..f00a5d83b --- /dev/null +++ b/cef3/libcef/browser/javascript_dialog_gtk.cc @@ -0,0 +1,135 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2012 The Chromium 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 "libcef/browser/javascript_dialog.h" +#include "libcef/browser/browser_host_impl.h" +#include "libcef/browser/javascript_dialog_manager.h" + +#include + +#include "base/logging.h" +#include "base/string_util.h" +#include "base/utf_string_conversions.h" + +namespace { + +const char kPromptTextId[] = "cef_prompt_text"; + +// If there's a text entry in the dialog, get the text from the first one and +// return it. +string16 GetPromptText(GtkDialog* dialog) { + GtkWidget* widget = static_cast( + g_object_get_data(G_OBJECT(dialog), kPromptTextId)); + if (widget) + return UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(widget))); + return string16(); +} + +} // namespace + +CefJavaScriptDialog::CefJavaScriptDialog( + CefJavaScriptDialogManager* creator, + content::JavaScriptMessageType message_type, + const string16& display_url, + const string16& message_text, + const string16& default_prompt_text, + const content::JavaScriptDialogManager::DialogClosedCallback& callback) + : creator_(creator), + callback_(callback) { + GtkButtonsType buttons = GTK_BUTTONS_NONE; + GtkMessageType gtk_message_type = GTK_MESSAGE_OTHER; + std::string title; + + switch (message_type) { + case content::JAVASCRIPT_MESSAGE_TYPE_ALERT: + buttons = GTK_BUTTONS_NONE; + gtk_message_type = GTK_MESSAGE_WARNING; + title = "JavaScript Alert"; + break; + + case content::JAVASCRIPT_MESSAGE_TYPE_CONFIRM: + buttons = GTK_BUTTONS_CANCEL; + gtk_message_type = GTK_MESSAGE_QUESTION; + title = "JavaScript Confirm"; + break; + + case content::JAVASCRIPT_MESSAGE_TYPE_PROMPT: + buttons = GTK_BUTTONS_CANCEL; + gtk_message_type = GTK_MESSAGE_QUESTION; + title = "JavaScript Prompt"; + break; + + default: + NOTREACHED(); + } + + if (!display_url.empty()) { + title += " - "; + title += UTF16ToUTF8(display_url).c_str(); + } + + GtkWidget* window = + gtk_widget_get_ancestor( + GTK_WIDGET(creator->browser()->GetWindowHandle()), + GTK_TYPE_WINDOW); + gtk_dialog_ = gtk_message_dialog_new(GTK_WINDOW(window), + GTK_DIALOG_MODAL, + gtk_message_type, + buttons, + "%s", + UTF16ToUTF8(message_text).c_str()); + g_signal_connect(gtk_dialog_, + "delete-event", + G_CALLBACK(gtk_widget_hide_on_delete), + NULL); + + gtk_window_set_title(GTK_WINDOW(gtk_dialog_), title.c_str()); + + GtkWidget* ok_button = gtk_dialog_add_button(GTK_DIALOG(gtk_dialog_), + GTK_STOCK_OK, + GTK_RESPONSE_OK); + + if (message_type != content::JAVASCRIPT_MESSAGE_TYPE_PROMPT) + gtk_widget_grab_focus(ok_button); + + if (message_type == content::JAVASCRIPT_MESSAGE_TYPE_PROMPT) { + GtkWidget* content_area = + gtk_dialog_get_content_area(GTK_DIALOG(gtk_dialog_)); + GtkWidget* text_box = gtk_entry_new(); + gtk_entry_set_text(GTK_ENTRY(text_box), + UTF16ToUTF8(default_prompt_text).c_str()); + gtk_box_pack_start(GTK_BOX(content_area), text_box, TRUE, TRUE, 0); + g_object_set_data(G_OBJECT(gtk_dialog_), kPromptTextId, text_box); + gtk_entry_set_activates_default(GTK_ENTRY(text_box), TRUE); + } + + gtk_dialog_set_default_response(GTK_DIALOG(gtk_dialog_), GTK_RESPONSE_OK); + g_signal_connect(gtk_dialog_, "response", G_CALLBACK(OnResponseThunk), this); + gtk_widget_show_all(GTK_WIDGET(gtk_dialog_)); +} + +CefJavaScriptDialog::~CefJavaScriptDialog() { +} + +void CefJavaScriptDialog::Cancel() { +} + +void CefJavaScriptDialog::OnResponse(GtkWidget* dialog, int response_id) { + switch (response_id) { + case GTK_RESPONSE_OK: + callback_.Run(true, GetPromptText(GTK_DIALOG(dialog))); + break; + case GTK_RESPONSE_CANCEL: + case GTK_RESPONSE_DELETE_EVENT: + callback_.Run(false, string16()); + break; + default: + NOTREACHED(); + } + + gtk_widget_destroy(dialog); + + creator_->DialogClosed(this); +} \ No newline at end of file diff --git a/cef3/libcef/browser/javascript_dialog_mac.mm b/cef3/libcef/browser/javascript_dialog_mac.mm new file mode 100644 index 000000000..874fac5eb --- /dev/null +++ b/cef3/libcef/browser/javascript_dialog_mac.mm @@ -0,0 +1,155 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2012 The Chromium 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 "libcef/browser/javascript_dialog.h" +#include "libcef/browser/javascript_dialog_manager.h" + +#import + +#import "base/memory/scoped_nsobject.h" +#include "base/sys_string_conversions.h" +#include "base/utf_string_conversions.h" + +// Helper object that receives the notification that the dialog/sheet is +// going away. Is responsible for cleaning itself up. +@interface CefJavaScriptDialogHelper : NSObject { + @private + scoped_nsobject alert_; + NSTextField* textField_; // WEAK; owned by alert_ + + // Copies of the fields in CefJavaScriptDialog because they're private. + CefJavaScriptDialogManager* creator_; + content::JavaScriptDialogManager::DialogClosedCallback callback_; +} + +- (id)initHelperWithCreator:(CefJavaScriptDialogManager*)creator + andCallback:(content::JavaScriptDialogManager::DialogClosedCallback)callback; +- (NSAlert*)alert; +- (NSTextField*)textField; +- (void)alertDidEnd:(NSAlert*)alert + returnCode:(int)returnCode + contextInfo:(void*)contextInfo; +- (void)cancel; + +@end + +@implementation CefJavaScriptDialogHelper + +- (id)initHelperWithCreator:(CefJavaScriptDialogManager*)creator + andCallback:(content::JavaScriptDialogManager::DialogClosedCallback)callback { + if (self = [super init]) { + creator_ = creator; + callback_ = callback; + } + + return self; +} + +- (NSAlert*)alert { + alert_.reset([[NSAlert alloc] init]); + return alert_; +} + +- (NSTextField*)textField { + textField_ = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 300, 22)]; + [[textField_ cell] setLineBreakMode:NSLineBreakByTruncatingTail]; + [alert_ setAccessoryView:textField_]; + [textField_ release]; + + return textField_; +} + +- (void)alertDidEnd:(NSAlert*)alert + returnCode:(int)returnCode + contextInfo:(void*)contextInfo { + if (returnCode == NSRunStoppedResponse) + return; + + bool success = returnCode == NSAlertFirstButtonReturn; + string16 input; + if (textField_) + input = base::SysNSStringToUTF16([textField_ stringValue]); + + CefJavaScriptDialog* native_dialog = + reinterpret_cast(contextInfo); + callback_.Run(success, input); + creator_->DialogClosed(native_dialog); +} + +- (void)cancel { + [NSApp endSheet:[alert_ window]]; + alert_.reset(); +} + +@end + +CefJavaScriptDialog::CefJavaScriptDialog( + CefJavaScriptDialogManager* creator, + content::JavaScriptMessageType message_type, + const string16& display_url, + const string16& message_text, + const string16& default_prompt_text, + const content::JavaScriptDialogManager::DialogClosedCallback& callback) + : creator_(creator), + callback_(callback) { + bool text_field = + message_type == content::JAVASCRIPT_MESSAGE_TYPE_PROMPT; + bool one_button = + message_type == content::JAVASCRIPT_MESSAGE_TYPE_ALERT; + + helper_ = + [[CefJavaScriptDialogHelper alloc] initHelperWithCreator:creator + andCallback:callback]; + + // Show the modal dialog. + NSAlert* alert = [helper_ alert]; + NSTextField* field = nil; + if (text_field) { + field = [helper_ textField]; + [field setStringValue:base::SysUTF16ToNSString(default_prompt_text)]; + } + [alert setDelegate:helper_]; + [alert setInformativeText:base::SysUTF16ToNSString(message_text)]; + + string16 label; + switch (message_type) { + case content::JAVASCRIPT_MESSAGE_TYPE_ALERT: + label = ASCIIToUTF16("JavaScript Alert"); + break; + case content::JAVASCRIPT_MESSAGE_TYPE_PROMPT: + label = ASCIIToUTF16("JavaScript Prompt"); + break; + case content::JAVASCRIPT_MESSAGE_TYPE_CONFIRM: + label = ASCIIToUTF16("JavaScript Confirm"); + break; + } + if (!display_url.empty()) + label += ASCIIToUTF16(" - ") + display_url; + + [alert setMessageText:base::SysUTF16ToNSString(label)]; + + [alert addButtonWithTitle:@"OK"]; + if (!one_button) { + NSButton* other = [alert addButtonWithTitle:@"Cancel"]; + [other setKeyEquivalent:@"\e"]; + } + + [alert + beginSheetModalForWindow:nil // nil here makes it app-modal + modalDelegate:helper_ + didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) + contextInfo:this]; + + if ([alert accessoryView]) + [[alert window] makeFirstResponder:[alert accessoryView]]; +} + +CefJavaScriptDialog::~CefJavaScriptDialog() { + [helper_ release]; +} + +void CefJavaScriptDialog::Cancel() { + [helper_ cancel]; +} diff --git a/cef3/libcef/browser/javascript_dialog_manager.cc b/cef3/libcef/browser/javascript_dialog_manager.cc new file mode 100644 index 000000000..af9ce26d8 --- /dev/null +++ b/cef3/libcef/browser/javascript_dialog_manager.cc @@ -0,0 +1,213 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2012 The Chromium 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 "libcef/browser/javascript_dialog_manager.h" +#include "libcef/browser/browser_host_impl.h" +#include "libcef/browser/javascript_dialog.h" +#include "libcef/browser/thread_util.h" + +#include "base/bind.h" +#include "base/logging.h" +#include "base/utf_string_conversions.h" +#include "net/base/net_util.h" + +namespace { + +class CefJSDialogCallbackImpl : public CefJSDialogCallback { + public: + CefJSDialogCallbackImpl( + const content::JavaScriptDialogManager::DialogClosedCallback& callback) + : callback_(callback) { + } + ~CefJSDialogCallbackImpl() { + if (!callback_.is_null()) { + // The callback is still pending. Cancel it now. + if (CEF_CURRENTLY_ON_UIT()) { + CancelNow(callback_); + } else { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefJSDialogCallbackImpl::CancelNow, callback_)); + } + } + } + + virtual void Continue(bool success, + const CefString& user_input) OVERRIDE { + if (CEF_CURRENTLY_ON_UIT()) { + if (!callback_.is_null()) { + callback_.Run(success, user_input); + callback_.Reset(); + } + } else { + CEF_POST_TASK(CEF_UIT, + base::Bind(&CefJSDialogCallbackImpl::Continue, this, success, + user_input)); + } + } + + void Disconnect() { + callback_.Reset(); + } + + private: + static void CancelNow( + const content::JavaScriptDialogManager::DialogClosedCallback& callback) { + CEF_REQUIRE_UIT(); + callback.Run(false, string16()); + } + + content::JavaScriptDialogManager::DialogClosedCallback callback_; + + IMPLEMENT_REFCOUNTING(CefJSDialogCallbackImpl); +}; + +} // namespace + + +CefJavaScriptDialogManager::CefJavaScriptDialogManager( + CefBrowserHostImpl* browser) + : browser_(browser) { +} + +CefJavaScriptDialogManager::~CefJavaScriptDialogManager() { +} + +void CefJavaScriptDialogManager::RunJavaScriptDialog( + content::WebContents* web_contents, + const GURL& origin_url, + const std::string& accept_lang, + content::JavaScriptMessageType message_type, + const string16& message_text, + const string16& default_prompt_text, + const DialogClosedCallback& callback, + bool* did_suppress_message) { + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetJSDialogHandler(); + if (handler.get()) { + *did_suppress_message = false; + + CefRefPtr callbackPtr( + new CefJSDialogCallbackImpl(callback)); + + // Execute the user callback. + bool handled = handler->OnJSDialog(browser_, origin_url.spec(), + accept_lang, + static_cast(message_type), + message_text, default_prompt_text, callbackPtr.get(), + *did_suppress_message); + if (handled) + return; + + callbackPtr->Disconnect(); + if (*did_suppress_message) + return; + } + } + +#if defined(OS_MACOSX) || defined(OS_WIN) || defined(TOOLKIT_GTK) + *did_suppress_message = false; + + if (dialog_.get()) { + // One dialog at a time, please. + *did_suppress_message = true; + return; + } + + string16 display_url = net::FormatUrl(origin_url, accept_lang); + + dialog_.reset(new CefJavaScriptDialog(this, + message_type, + display_url, + message_text, + default_prompt_text, + callback)); +#else + // TODO(port): implement CefJavaScriptDialog for other platforms. + *did_suppress_message = true; + return; +#endif +} + +void CefJavaScriptDialogManager::RunBeforeUnloadDialog( + content::WebContents* web_contents, + const string16& message_text, + bool is_reload, + const DialogClosedCallback& callback) { + if (browser_->destruction_state() >= + CefBrowserHostImpl::DESTRUCTION_STATE_ACCEPTED) { + // Currently destroying the browser. Accept the unload without showing + // the prompt. + callback.Run(true, string16()); + return; + } + + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetJSDialogHandler(); + if (handler.get()) { + CefRefPtr callbackPtr( + new CefJSDialogCallbackImpl(callback)); + + // Execute the user callback. + bool handled = handler->OnBeforeUnloadDialog(browser_, message_text, + is_reload, callbackPtr.get()); + if (handled) + return; + + callbackPtr->Disconnect(); + } + } + +#if defined(OS_MACOSX) || defined(OS_WIN) || defined(TOOLKIT_GTK) + if (dialog_.get()) { + // Seriously!? + callback.Run(true, string16()); + return; + } + + string16 new_message_text = + message_text + + ASCIIToUTF16("\n\nIs it OK to leave/reload this page?"); + + dialog_.reset( + new CefJavaScriptDialog(this, + content::JAVASCRIPT_MESSAGE_TYPE_CONFIRM, + string16(), // display_url + new_message_text, + string16(), // default_prompt_text + callback)); +#else + // TODO(port): implement CefJavaScriptDialog for other platforms. + callback.Run(true, string16()); + return; +#endif +} + +void CefJavaScriptDialogManager::ResetJavaScriptState( + content::WebContents* web_contents) { + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetJSDialogHandler(); + if (handler.get()) { + // Execute the user callback. + handler->OnResetDialogState(browser_); + } + } + +#if defined(OS_MACOSX) || defined(OS_WIN) || defined(TOOLKIT_GTK) + if (dialog_.get()) { + dialog_->Cancel(); + dialog_.reset(); + } +#endif +} + +void CefJavaScriptDialogManager::DialogClosed(CefJavaScriptDialog* dialog) { +#if defined(OS_MACOSX) || defined(OS_WIN) || defined(TOOLKIT_GTK) + DCHECK_EQ(dialog, dialog_.get()); + dialog_.reset(); +#endif +} diff --git a/cef3/libcef/browser/javascript_dialog_manager.h b/cef3/libcef/browser/javascript_dialog_manager.h new file mode 100644 index 000000000..4e6037d6c --- /dev/null +++ b/cef3/libcef/browser/javascript_dialog_manager.h @@ -0,0 +1,61 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2012 The Chromium 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_LIBCEF_BROWSER_JAVASCRIPT_DIALOG_MANAGER_H_ +#define CEF_LIBCEF_BROWSER_JAVASCRIPT_DIALOG_MANAGER_H_ +#pragma once + +#include + +#include "base/compiler_specific.h" +#include "base/memory/scoped_ptr.h" +#include "content/public/browser/javascript_dialog_manager.h" + +class CefBrowserHostImpl; +class CefJavaScriptDialog; + +class CefJavaScriptDialogManager : public content::JavaScriptDialogManager { + public: + explicit CefJavaScriptDialogManager(CefBrowserHostImpl* browser); + virtual ~CefJavaScriptDialogManager(); + + // JavaScriptDialogManager methods. + virtual void RunJavaScriptDialog( + content::WebContents* web_contents, + const GURL& origin_url, + const std::string& accept_lang, + content::JavaScriptMessageType message_type, + const string16& message_text, + const string16& default_prompt_text, + const DialogClosedCallback& callback, + bool* did_suppress_message) OVERRIDE; + + virtual void RunBeforeUnloadDialog( + content::WebContents* web_contents, + const string16& message_text, + bool is_reload, + const DialogClosedCallback& callback) OVERRIDE; + + virtual void ResetJavaScriptState( + content::WebContents* web_contents) OVERRIDE; + + // Called by the CefJavaScriptDialog when it closes. + void DialogClosed(CefJavaScriptDialog* dialog); + + CefBrowserHostImpl* browser() const { return browser_; } + + private: + // This pointer is guaranteed to outlive the CefJavaScriptDialogManager. + CefBrowserHostImpl* browser_; + +#if defined(OS_MACOSX) || defined(OS_WIN) || defined(TOOLKIT_GTK) + // The dialog being shown. No queueing. + scoped_ptr dialog_; +#endif + + DISALLOW_COPY_AND_ASSIGN(CefJavaScriptDialogManager); +}; + +#endif // CEF_LIBCEF_BROWSER_JAVASCRIPT_DIALOG_MANAGER_H_ diff --git a/cef3/libcef/browser/javascript_dialog_win.cc b/cef3/libcef/browser/javascript_dialog_win.cc new file mode 100644 index 000000000..3c2bb1f97 --- /dev/null +++ b/cef3/libcef/browser/javascript_dialog_win.cc @@ -0,0 +1,227 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2012 The Chromium 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 "libcef/browser/javascript_dialog.h" +#include "libcef/browser/javascript_dialog_manager.h" +#include "libcef/browser/browser_host_impl.h" +#include "libcef_dll/resource.h" + +#include "base/files/file_path.h" +#include "base/path_service.h" +#include "base/string_util.h" +#include "base/utf_string_conversions.h" + +class CefJavaScriptDialog; + +HHOOK CefJavaScriptDialog::msg_hook_ = NULL; +int CefJavaScriptDialog::msg_hook_user_count_ = 0; + +INT_PTR CALLBACK CefJavaScriptDialog::DialogProc(HWND dialog, + UINT message, + WPARAM wparam, + LPARAM lparam) { + switch (message) { + case WM_INITDIALOG: { + SetWindowLongPtr(dialog, DWLP_USER, static_cast(lparam)); + CefJavaScriptDialog* owner = + reinterpret_cast(lparam); + owner->dialog_win_ = dialog; + SetDlgItemText(dialog, IDC_DIALOGTEXT, owner->message_text_.c_str()); + if (owner->message_type_ == content::JAVASCRIPT_MESSAGE_TYPE_PROMPT) + SetDlgItemText(dialog, IDC_PROMPTEDIT, + owner->default_prompt_text_.c_str()); + break; + } + case WM_CLOSE: { + CefJavaScriptDialog* owner = reinterpret_cast( + GetWindowLongPtr(dialog, DWLP_USER)); + if (owner) { + owner->Cancel(); + owner->callback_.Run(false, string16()); + owner->creator_->DialogClosed(owner); + + // No need for the system to call DestroyWindow() because it will be + // called by the Cancel() method. + return 0; + } + break; + } + case WM_COMMAND: { + CefJavaScriptDialog* owner = reinterpret_cast( + GetWindowLongPtr(dialog, DWLP_USER)); + string16 user_input; + bool finish = false; + bool result; + switch (LOWORD(wparam)) { + case IDOK: + finish = true; + result = true; + if (owner->message_type_ == content::JAVASCRIPT_MESSAGE_TYPE_PROMPT) { + size_t length = + GetWindowTextLength(GetDlgItem(dialog, IDC_PROMPTEDIT)) + 1; + if (length > 1) { + GetDlgItemText(dialog, IDC_PROMPTEDIT, + WriteInto(&user_input, length), length); + } + } + break; + case IDCANCEL: + finish = true; + result = false; + break; + } + if (finish) { + owner->Cancel(); + owner->callback_.Run(result, user_input); + owner->creator_->DialogClosed(owner); + } + break; + } + default: + return DefWindowProc(dialog, message, wparam, lparam); + } + return 0; +} + +CefJavaScriptDialog::CefJavaScriptDialog( + CefJavaScriptDialogManager* creator, + content::JavaScriptMessageType message_type, + const string16& display_url, + const string16& message_text, + const string16& default_prompt_text, + const content::JavaScriptDialogManager::DialogClosedCallback& callback) + : creator_(creator), + callback_(callback), + message_text_(message_text), + default_prompt_text_(default_prompt_text), + message_type_(message_type) { + InstallMessageHook(); + + int dialog_type; + if (message_type == content::JAVASCRIPT_MESSAGE_TYPE_ALERT) + dialog_type = IDD_ALERT; + else if (message_type == content::JAVASCRIPT_MESSAGE_TYPE_CONFIRM) + dialog_type = IDD_CONFIRM; + else // JAVASCRIPT_MESSAGE_TYPE_PROMPT + dialog_type = IDD_PROMPT; + + base::FilePath file_path; + HMODULE hModule = NULL; + + // Try to load the dialog from the DLL. + if (PathService::Get(base::FILE_MODULE, &file_path)) + hModule = ::GetModuleHandle(file_path.value().c_str()); + if (!hModule) + hModule = ::GetModuleHandle(NULL); + DCHECK(hModule); + + parent_win_ = GetAncestor(creator->browser()->GetWindowHandle(), GA_ROOT); + dialog_win_ = CreateDialogParam(hModule, + MAKEINTRESOURCE(dialog_type), + parent_win_, + DialogProc, + reinterpret_cast(this)); + DCHECK(dialog_win_); + + if (!display_url.empty()) { + // Add the display URL to the window title. + TCHAR text[64]; + GetWindowText(dialog_win_, text, sizeof(text)/sizeof(TCHAR)); + + string16 new_window_text = text + ASCIIToUTF16(" - ") + display_url; + SetWindowText(dialog_win_, new_window_text.c_str()); + } + + // Disable the parent window so the user can't interact with it. + if (IsWindowEnabled(parent_win_)) + EnableWindow(parent_win_, FALSE); + + ShowWindow(dialog_win_, SW_SHOWNORMAL); +} + +CefJavaScriptDialog::~CefJavaScriptDialog() { + Cancel(); + UninstallMessageHook(); +} + +void CefJavaScriptDialog::Cancel() { + HWND parent = NULL; + + // Re-enable the parent before closing the popup to avoid focus/activation/ + // z-order issues. + if (parent_win_ && IsWindow(parent_win_) && !IsWindowEnabled(parent_win_)) { + parent = parent_win_; + EnableWindow(parent_win_, TRUE); + parent_win_ = NULL; + } + + if (dialog_win_ && IsWindow(dialog_win_)) { + SetWindowLongPtr(dialog_win_, DWLP_USER, NULL); + DestroyWindow(dialog_win_); + dialog_win_ = NULL; + } + + // Return focus to the parent window. + if (parent) + SetFocus(parent); +} + +// static +LRESULT CALLBACK CefJavaScriptDialog::GetMsgProc(int code, WPARAM wparam, + LPARAM lparam) { + // Mostly borrowed from http://support.microsoft.com/kb/q187988/ + // and http://www.codeproject.com/KB/atl/cdialogmessagehook.aspx. + LPMSG msg = reinterpret_cast(lparam); + if (code >= 0 && wparam == PM_REMOVE && + msg->message >= WM_KEYFIRST && msg->message <= WM_KEYLAST) { + HWND hwnd = GetActiveWindow(); + if (::IsWindow(hwnd) && ::IsDialogMessage(hwnd, msg)) { + // The value returned from this hookproc is ignored, and it cannot + // be used to tell Windows the message has been handled. To avoid + // further processing, convert the message to WM_NULL before + // returning. + msg->hwnd = NULL; + msg->message = WM_NULL; + msg->lParam = 0L; + msg->wParam = 0; + } + } + + // Passes the hook information to the next hook procedure in + // the current hook chain. + return ::CallNextHookEx(msg_hook_, code, wparam, lparam); +} + +// static +bool CefJavaScriptDialog::InstallMessageHook() { + msg_hook_user_count_++; + + // Make sure we only call this once. + if (msg_hook_ != NULL) + return true; + + msg_hook_ = ::SetWindowsHookEx(WH_GETMESSAGE, + &CefJavaScriptDialog::GetMsgProc, + NULL, + GetCurrentThreadId()); + DCHECK(msg_hook_ != NULL); + return msg_hook_ != NULL; +} + +// static +bool CefJavaScriptDialog::UninstallMessageHook() { + msg_hook_user_count_--; + DCHECK_GE(msg_hook_user_count_, 0); + + if (msg_hook_user_count_ > 0) + return true; + + DCHECK(msg_hook_ != NULL); + BOOL result = ::UnhookWindowsHookEx(msg_hook_); + DCHECK(result); + msg_hook_ = NULL; + + return result != FALSE; +} diff --git a/cef3/libcef/browser/media_capture_devices_dispatcher.cc b/cef3/libcef/browser/media_capture_devices_dispatcher.cc new file mode 100644 index 000000000..cac8ae9bd --- /dev/null +++ b/cef3/libcef/browser/media_capture_devices_dispatcher.cc @@ -0,0 +1,217 @@ +// Copyright (c) 2012 The Chromium 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 "libcef/browser/media_capture_devices_dispatcher.h" + +#include "base/prefs/pref_registry_simple.h" +#include "base/prefs/pref_service.h" +#include "chrome/common/pref_names.h" +#include "content/public/browser/browser_thread.h" +#include "content/public/browser/media_devices_monitor.h" +#include "content/public/common/media_stream_request.h" + +using content::BrowserThread; +using content::MediaStreamDevices; + +namespace { + +const content::MediaStreamDevice* FindDefaultDeviceWithId( + const content::MediaStreamDevices& devices, + const std::string& device_id) { + if (devices.empty()) + return NULL; + + content::MediaStreamDevices::const_iterator iter = devices.begin(); + for (; iter != devices.end(); ++iter) { + if (iter->id == device_id) { + return &(*iter); + } + } + + return &(*devices.begin()); +}; + +} // namespace + + +CefMediaCaptureDevicesDispatcher* + CefMediaCaptureDevicesDispatcher::GetInstance() { + return Singleton::get(); +} + +CefMediaCaptureDevicesDispatcher::CefMediaCaptureDevicesDispatcher() + : devices_enumerated_(false) {} + +CefMediaCaptureDevicesDispatcher::~CefMediaCaptureDevicesDispatcher() {} + +void CefMediaCaptureDevicesDispatcher::RegisterPrefs( + PrefRegistrySimple* registry) { + registry->RegisterStringPref(prefs::kDefaultAudioCaptureDevice, + std::string()); + registry->RegisterStringPref(prefs::kDefaultVideoCaptureDevice, + std::string()); +} + +void CefMediaCaptureDevicesDispatcher::AddObserver(Observer* observer) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + if (!observers_.HasObserver(observer)) + observers_.AddObserver(observer); +} + +void CefMediaCaptureDevicesDispatcher::RemoveObserver(Observer* observer) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + observers_.RemoveObserver(observer); +} + +const MediaStreamDevices& +CefMediaCaptureDevicesDispatcher::GetAudioCaptureDevices() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + if (!devices_enumerated_) { + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, + base::Bind(&content::EnsureMonitorCaptureDevices)); + devices_enumerated_ = true; + } + return audio_devices_; +} + +const MediaStreamDevices& +CefMediaCaptureDevicesDispatcher::GetVideoCaptureDevices() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + if (!devices_enumerated_) { + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, + base::Bind(&content::EnsureMonitorCaptureDevices)); + devices_enumerated_ = true; + } + return video_devices_; +} + +void CefMediaCaptureDevicesDispatcher::GetDefaultDevices( + PrefService* prefs, + bool audio, + bool video, + content::MediaStreamDevices* devices) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK(audio || video); + + std::string default_device; + if (audio) { + default_device = prefs->GetString(prefs::kDefaultAudioCaptureDevice); + GetRequestedDevice(default_device, true, false, devices); + } + + if (video) { + default_device = prefs->GetString(prefs::kDefaultVideoCaptureDevice); + GetRequestedDevice(default_device, false, true, devices); + } +} + +void CefMediaCaptureDevicesDispatcher::GetRequestedDevice( + const std::string& requested_device_id, + bool audio, + bool video, + content::MediaStreamDevices* devices) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK(audio || video); + + if (audio) { + const content::MediaStreamDevices& audio_devices = GetAudioCaptureDevices(); + const content::MediaStreamDevice* const device = + FindDefaultDeviceWithId(audio_devices, requested_device_id); + if (device) + devices->push_back(*device); + } + if (video) { + const content::MediaStreamDevices& video_devices = GetVideoCaptureDevices(); + const content::MediaStreamDevice* const device = + FindDefaultDeviceWithId(video_devices, requested_device_id); + if (device) + devices->push_back(*device); + } +} + +void CefMediaCaptureDevicesDispatcher::OnCaptureDevicesOpened( + int render_process_id, + int render_view_id, + const content::MediaStreamDevices& devices, + const base::Closure& close_callback) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); +} + +void CefMediaCaptureDevicesDispatcher::OnCaptureDevicesClosed( + int render_process_id, + int render_view_id, + const content::MediaStreamDevices& devices) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); +} + +void CefMediaCaptureDevicesDispatcher::OnAudioCaptureDevicesChanged( + const content::MediaStreamDevices& devices) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::Bind( + &CefMediaCaptureDevicesDispatcher::UpdateAudioDevicesOnUIThread, + base::Unretained(this), devices)); +} + +void CefMediaCaptureDevicesDispatcher::OnVideoCaptureDevicesChanged( + const content::MediaStreamDevices& devices) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::Bind( + &CefMediaCaptureDevicesDispatcher::UpdateVideoDevicesOnUIThread, + base::Unretained(this), devices)); +} + +void CefMediaCaptureDevicesDispatcher::OnMediaRequestStateChanged( + int render_process_id, + int render_view_id, + const content::MediaStreamDevice& device, + content::MediaRequestState state) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::Bind( + &CefMediaCaptureDevicesDispatcher::UpdateMediaRequestStateOnUIThread, + base::Unretained(this), render_process_id, render_view_id, device, + state)); + +} + +void CefMediaCaptureDevicesDispatcher::OnAudioStreamPlayingChanged( + int render_process_id, int render_view_id, int stream_id, bool playing) { +} + +void CefMediaCaptureDevicesDispatcher::UpdateAudioDevicesOnUIThread( + const content::MediaStreamDevices& devices) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + devices_enumerated_ = true; + audio_devices_ = devices; + FOR_EACH_OBSERVER(Observer, observers_, + OnUpdateAudioDevices(audio_devices_)); +} + +void CefMediaCaptureDevicesDispatcher::UpdateVideoDevicesOnUIThread( + const content::MediaStreamDevices& devices){ + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + devices_enumerated_ = true; + video_devices_ = devices; + FOR_EACH_OBSERVER(Observer, observers_, + OnUpdateVideoDevices(video_devices_)); +} + +void CefMediaCaptureDevicesDispatcher::UpdateMediaRequestStateOnUIThread( + int render_process_id, + int render_view_id, + const content::MediaStreamDevice& device, + content::MediaRequestState state) { + FOR_EACH_OBSERVER(Observer, observers_, + OnRequestUpdate(render_process_id, + render_view_id, + device, + state)); +} diff --git a/cef3/libcef/browser/media_capture_devices_dispatcher.h b/cef3/libcef/browser/media_capture_devices_dispatcher.h new file mode 100644 index 000000000..7a900f9b6 --- /dev/null +++ b/cef3/libcef/browser/media_capture_devices_dispatcher.h @@ -0,0 +1,129 @@ +// Copyright (c) 2012 The Chromium 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_LIBCEF_BROWSER_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ +#define CEF_LIBCEF_BROWSER_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ + +#include "base/callback.h" +#include "base/memory/scoped_ptr.h" +#include "base/memory/singleton.h" +#include "base/observer_list.h" +#include "content/public/browser/media_observer.h" +#include "content/public/common/media_stream_request.h" + +class PrefRegistrySimple; +class PrefService; + +// This singleton is used to receive updates about media events from the content +// layer. Based on chrome/browser/media/media_capture_devices_dispatcher.[h|cc]. +class CefMediaCaptureDevicesDispatcher : public content::MediaObserver { + public: + class Observer { + public: + // Handle an information update consisting of a up-to-date audio capture + // device lists. This happens when a microphone is plugged in or unplugged. + virtual void OnUpdateAudioDevices( + const content::MediaStreamDevices& devices) {} + + // Handle an information update consisting of a up-to-date video capture + // device lists. This happens when a camera is plugged in or unplugged. + virtual void OnUpdateVideoDevices( + const content::MediaStreamDevices& devices) {} + + // Handle an information update related to a media stream request. + virtual void OnRequestUpdate( + int render_process_id, + int render_view_id, + const content::MediaStreamDevice& device, + const content::MediaRequestState state) {} + + virtual ~Observer() {} + }; + + static CefMediaCaptureDevicesDispatcher* GetInstance(); + + // Registers the preferences related to Media Stream default devices. + static void RegisterPrefs(PrefRegistrySimple* registry); + + // Methods for observers. Called on UI thread. + // Observers should add themselves on construction and remove themselves + // on destruction. + void AddObserver(Observer* observer); + void RemoveObserver(Observer* observer); + const content::MediaStreamDevices& GetAudioCaptureDevices(); + const content::MediaStreamDevices& GetVideoCaptureDevices(); + + // Helper to get the default devices which can be used by the media request, + // if the return list is empty, it means there is no available device on the + // OS. + // Called on the UI thread. + void GetDefaultDevices(PrefService* prefs, + bool audio, + bool video, + content::MediaStreamDevices* devices); + + // Helper for picking the device that was requested for an OpenDevice request. + // If the device requested is not available it will revert to using the first + // available one instead or will return an empty list if no devices of the + // requested kind are present. + void GetRequestedDevice(const std::string& requested_device_id, + bool audio, + bool video, + content::MediaStreamDevices* devices); + + // Overridden from content::MediaObserver: + virtual void OnCaptureDevicesOpened( + int render_process_id, + int render_view_id, + const content::MediaStreamDevices& devices, + const base::Closure& close_callback) OVERRIDE; + virtual void OnCaptureDevicesClosed( + int render_process_id, + int render_view_id, + const content::MediaStreamDevices& devices) OVERRIDE; + virtual void OnAudioCaptureDevicesChanged( + const content::MediaStreamDevices& devices) OVERRIDE; + virtual void OnVideoCaptureDevicesChanged( + const content::MediaStreamDevices& devices) OVERRIDE; + virtual void OnMediaRequestStateChanged( + int render_process_id, + int render_view_id, + const content::MediaStreamDevice& device, + content::MediaRequestState state) OVERRIDE; + virtual void OnAudioStreamPlayingChanged( + int render_process_id, + int render_view_id, + int stream_id, + bool playing) OVERRIDE; + + private: + friend struct DefaultSingletonTraits; + + CefMediaCaptureDevicesDispatcher(); + virtual ~CefMediaCaptureDevicesDispatcher(); + + // Called by the MediaObserver() functions, executed on UI thread. + void UpdateAudioDevicesOnUIThread(const content::MediaStreamDevices& devices); + void UpdateVideoDevicesOnUIThread(const content::MediaStreamDevices& devices); + void UpdateMediaRequestStateOnUIThread( + int render_process_id, + int render_view_id, + const content::MediaStreamDevice& device, + content::MediaRequestState state); + + // A list of cached audio capture devices. + content::MediaStreamDevices audio_devices_; + + // A list of cached video capture devices. + content::MediaStreamDevices video_devices_; + + // A list of observers for the device update notifications. + ObserverList observers_; + + // Flag to indicate if device enumeration has been done/doing. + // Only accessed on UI thread. + bool devices_enumerated_; +}; + +#endif // CEF_LIBCEF_BROWSER_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ diff --git a/cef3/libcef/browser/menu_creator.cc b/cef3/libcef/browser/menu_creator.cc new file mode 100644 index 000000000..faa25c1bd --- /dev/null +++ b/cef3/libcef/browser/menu_creator.cc @@ -0,0 +1,317 @@ +// 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 "libcef/browser/menu_creator.h" +#include "libcef/browser/browser_host_impl.h" +#include "libcef/browser/context_menu_params_impl.h" + +#include "base/compiler_specific.h" +#include "base/logging.h" +#include "content/public/browser/render_view_host.h" +#include "content/public/browser/render_widget_host_view.h" +#include "content/public/common/content_client.h" +#include "grit/cef_strings.h" + +#if defined(OS_WIN) +#include "libcef/browser/menu_creator_runner_win.h" +#elif defined(OS_MACOSX) +#include "libcef/browser/menu_creator_runner_mac.h" +#elif defined(TOOLKIT_GTK) +#include "libcef/browser/menu_creator_runner_gtk.h" +#endif + +namespace { + +CefString GetLabel(int message_id) { + string16 label = content::GetContentClient()->GetLocalizedString(message_id); + DCHECK(!label.empty()); + return label; +} + +} // namespace + +CefMenuCreator::CefMenuCreator(CefBrowserHostImpl* browser) + : browser_(browser) { + model_ = new CefMenuModelImpl(this); +} + +CefMenuCreator::~CefMenuCreator() { + // The model may outlive the delegate if the context menu is visible when the + // application is closed. + model_->set_delegate(NULL); +} + +bool CefMenuCreator::IsShowingContextMenu() { + content::WebContents* web_contents = browser_->GetWebContents(); + if (!web_contents) + return false; + content::RenderWidgetHostView* view = web_contents->GetRenderWidgetHostView(); + return (view && view->IsShowingContextMenu()); +} + +bool CefMenuCreator::CreateContextMenu( + const content::ContextMenuParams& params) { + if (!CreateRunner()) + return true; + + // The renderer may send the "show context menu" message multiple times, one + // for each right click mouse event it receives. Normally, this doesn't happen + // because mouse events are not forwarded once the context menu is showing. + // However, there's a race - the context menu may not yet be showing when + // the second mouse event arrives. In this case, |HandleContextMenu()| will + // get called multiple times - if so, don't create another context menu. + // TODO(asvitkine): Fix the renderer so that it doesn't do this. + if (IsShowingContextMenu()) + return true; + + params_ = params; + model_->Clear(); + + // Create the default menu model. + CreateDefaultModel(); + + // Give the client a chance to modify the model. + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = + client->GetContextMenuHandler(); + if (handler.get()) { + CefRefPtr frame; + if (params_.frame_id > 0) + frame = browser_->GetFrame(params_.frame_id); + if (!frame.get()) + frame = browser_->GetMainFrame(); + + CefRefPtr paramsPtr( + new CefContextMenuParamsImpl(¶ms_)); + + handler->OnBeforeContextMenu(browser_, frame, paramsPtr.get(), + model_.get()); + + // Do not keep references to the parameters in the callback. + paramsPtr->Detach(NULL); + DCHECK_EQ(paramsPtr->GetRefCt(), 1); + DCHECK(model_->VerifyRefCount()); + + // Menu is empty so notify the client and return. + if (model_->GetCount() == 0) { + MenuClosed(model_); + return true; + } + } + } + + return runner_->RunContextMenu(this); +} + +bool CefMenuCreator::CreateRunner() { + if (!runner_.get()) { + // Create the menu runner. +#if defined(OS_WIN) + runner_.reset(new CefMenuCreatorRunnerWin); +#elif defined(OS_MACOSX) + runner_.reset(new CefMenuCreatorRunnerMac); +#elif defined(TOOLKIT_GTK) + runner_.reset(new CefMenuCreatorRunnerGtk); +#else + // Need an implementation. + NOTREACHED(); +#endif + } + return (runner_.get() != NULL); +} + +void CefMenuCreator::ExecuteCommand(CefRefPtr source, + int command_id, + cef_event_flags_t event_flags) { + // Give the client a chance to handle the command. + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = + client->GetContextMenuHandler(); + if (handler.get()) { + CefRefPtr frame; + if (params_.frame_id > 0) + frame = browser_->GetFrame(params_.frame_id); + if (!frame.get()) + frame = browser_->GetMainFrame(); + + CefRefPtr paramsPtr( + new CefContextMenuParamsImpl(¶ms_)); + + bool handled = handler->OnContextMenuCommand(browser_, frame, + paramsPtr.get(), command_id, event_flags); + + // Do not keep references to the parameters in the callback. + paramsPtr->Detach(NULL); + DCHECK_EQ(paramsPtr->GetRefCt(), 1); + + if (handled) + return; + } + } + + // Execute the default command handling. + ExecuteDefaultCommand(command_id); +} + +void CefMenuCreator::MenuWillShow(CefRefPtr source) { + // May be called for sub-menus as well. + if (source.get() != model_.get()) + return; + + content::WebContents* web_contents = browser_->GetWebContents(); + if (!web_contents) + return; + + // Notify the host before showing the context menu. + content::RenderWidgetHostView* view = web_contents->GetRenderWidgetHostView(); + if (view) + view->SetShowingContextMenu(true); +} + +void CefMenuCreator::MenuClosed(CefRefPtr source) { + // May be called for sub-menus as well. + if (source.get() != model_.get()) + return; + + // Notify the client. + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = + client->GetContextMenuHandler(); + if (handler.get()) { + CefRefPtr frame; + if (params_.frame_id > 0) + frame = browser_->GetFrame(params_.frame_id); + if (!frame.get()) + frame = browser_->GetMainFrame(); + + handler->OnContextMenuDismissed(browser_, frame); + } + } + + if (IsShowingContextMenu()) { + // Notify the host after closing the context menu. + content::RenderWidgetHostView* view = + browser_->GetWebContents()->GetRenderWidgetHostView(); + if (view) + view->SetShowingContextMenu(false); + content::RenderViewHost* rvh = + browser_->GetWebContents()->GetRenderViewHost(); + if (rvh) + rvh->NotifyContextMenuClosed(params_.custom_context); + } +} + +void CefMenuCreator::CreateDefaultModel() { + if (params_.is_editable) { + // Editable node. + model_->AddItem(MENU_ID_UNDO, GetLabel(IDS_MENU_UNDO)); + model_->AddItem(MENU_ID_REDO, GetLabel(IDS_MENU_REDO)); + + model_->AddSeparator(); + model_->AddItem(MENU_ID_CUT, GetLabel(IDS_MENU_CUT)); + model_->AddItem(MENU_ID_COPY, GetLabel(IDS_MENU_COPY)); + model_->AddItem(MENU_ID_PASTE, GetLabel(IDS_MENU_PASTE)); + model_->AddItem(MENU_ID_DELETE, GetLabel(IDS_MENU_DELETE)); + + model_->AddSeparator(); + model_->AddItem(MENU_ID_SELECT_ALL, GetLabel(IDS_MENU_SELECT_ALL)); + + if (!(params_.edit_flags & CM_EDITFLAG_CAN_UNDO)) + model_->SetEnabled(MENU_ID_UNDO, false); + if (!(params_.edit_flags & CM_EDITFLAG_CAN_REDO)) + model_->SetEnabled(MENU_ID_REDO, false); + if (!(params_.edit_flags & CM_EDITFLAG_CAN_CUT)) + model_->SetEnabled(MENU_ID_CUT, false); + if (!(params_.edit_flags & CM_EDITFLAG_CAN_COPY)) + model_->SetEnabled(MENU_ID_COPY, false); + if (!(params_.edit_flags & CM_EDITFLAG_CAN_PASTE)) + model_->SetEnabled(MENU_ID_PASTE, false); + if (!(params_.edit_flags & CM_EDITFLAG_CAN_DELETE)) + model_->SetEnabled(MENU_ID_DELETE, false); + if (!(params_.edit_flags & CM_EDITFLAG_CAN_SELECT_ALL)) + model_->SetEnabled(MENU_ID_SELECT_ALL, false); + } else if (!params_.selection_text.empty()) { + // Something is selected. + model_->AddItem(MENU_ID_COPY, GetLabel(IDS_MENU_COPY)); + } else if (!params_.page_url.is_empty() || !params_.frame_url.is_empty()) { + // Page or frame. + model_->AddItem(MENU_ID_BACK, GetLabel(IDS_MENU_BACK)); + model_->AddItem(MENU_ID_FORWARD, GetLabel(IDS_MENU_FORWARD)); + + model_->AddSeparator(); + model_->AddItem(MENU_ID_PRINT, GetLabel(IDS_MENU_PRINT)); + model_->AddItem(MENU_ID_VIEW_SOURCE, GetLabel(IDS_MENU_VIEW_SOURCE)); + + if (!browser_->CanGoBack()) + model_->SetEnabled(MENU_ID_BACK, false); + if (!browser_->CanGoForward()) + model_->SetEnabled(MENU_ID_FORWARD, false); + + // TODO(cef): Enable once printing is supported. + model_->SetEnabled(MENU_ID_PRINT, false); + } +} + +void CefMenuCreator::ExecuteDefaultCommand(int command_id) { + switch (command_id) { + // Navigation. + case MENU_ID_BACK: + browser_->GoBack(); + break; + case MENU_ID_FORWARD: + browser_->GoForward(); + break; + case MENU_ID_RELOAD: + browser_->Reload(); + break; + case MENU_ID_RELOAD_NOCACHE: + browser_->ReloadIgnoreCache(); + break; + case MENU_ID_STOPLOAD: + browser_->StopLoad(); + break; + + // Editing. + case MENU_ID_UNDO: + browser_->GetFocusedFrame()->Undo(); + break; + case MENU_ID_REDO: + browser_->GetFocusedFrame()->Redo(); + break; + case MENU_ID_CUT: + browser_->GetFocusedFrame()->Cut(); + break; + case MENU_ID_COPY: + browser_->GetFocusedFrame()->Copy(); + break; + case MENU_ID_PASTE: + browser_->GetFocusedFrame()->Paste(); + break; + case MENU_ID_DELETE: + browser_->GetFocusedFrame()->Delete(); + break; + case MENU_ID_SELECT_ALL: + browser_->GetFocusedFrame()->SelectAll(); + break; + + // Miscellaneous. + case MENU_ID_FIND: + // TODO(cef): Implement. + NOTIMPLEMENTED(); + break; + case MENU_ID_PRINT: + // TODO(cef): Implement. + NOTIMPLEMENTED(); + break; + case MENU_ID_VIEW_SOURCE: + browser_->GetFocusedFrame()->ViewSource(); + break; + + default: + break; + } +} diff --git a/cef3/libcef/browser/menu_creator.h b/cef3/libcef/browser/menu_creator.h new file mode 100644 index 000000000..60c3f2ced --- /dev/null +++ b/cef3/libcef/browser/menu_creator.h @@ -0,0 +1,63 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_MENU_MANAGER_H_ +#define CEF_LIBCEF_BROWSER_MENU_MANAGER_H_ +#pragma once + +#include "libcef/browser/menu_model_impl.h" + +#include "base/memory/scoped_ptr.h" +#include "content/public/common/context_menu_params.h" + +class CefBrowserHostImpl; + +class CefMenuCreator : public CefMenuModelImpl::Delegate { + public: + // Used for OS-specific menu implementations. + class Runner { + public: + virtual ~Runner() {} + virtual bool RunContextMenu(CefMenuCreator* manager) =0; + }; + + explicit CefMenuCreator(CefBrowserHostImpl* browser); + virtual ~CefMenuCreator(); + + // Returns true if the context menu is currently showing. + bool IsShowingContextMenu(); + + // Create the context menu. + bool CreateContextMenu(const content::ContextMenuParams& params); + + CefBrowserHostImpl* browser() { return browser_; } + ui::MenuModel* model() { return model_->model(); } + const content::ContextMenuParams& params() const { return params_; } + + private: + // Create the menu runner if it doesn't already exist. + bool CreateRunner(); + + // CefMenuModelImpl::Delegate methods. + virtual void ExecuteCommand(CefRefPtr source, + int command_id, + cef_event_flags_t event_flags) OVERRIDE; + virtual void MenuWillShow(CefRefPtr source) OVERRIDE; + virtual void MenuClosed(CefRefPtr source) OVERRIDE; + + // Create the default menu model. + void CreateDefaultModel(); + // Execute the default command handling. + void ExecuteDefaultCommand(int command_id); + + // CefBrowserHostImpl pointer is guaranteed to outlive this object. + CefBrowserHostImpl* browser_; + CefRefPtr model_; + content::ContextMenuParams params_; + scoped_ptr runner_; + + DISALLOW_COPY_AND_ASSIGN(CefMenuCreator); +}; + +#endif // CEF_LIBCEF_BROWSER_MENU_MANAGER_H_ diff --git a/cef3/libcef/browser/menu_creator_runner_gtk.cc b/cef3/libcef/browser/menu_creator_runner_gtk.cc new file mode 100644 index 000000000..c2f5fe1ca --- /dev/null +++ b/cef3/libcef/browser/menu_creator_runner_gtk.cc @@ -0,0 +1,46 @@ +// 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 "libcef/browser/menu_creator_runner_gtk.h" +#include "libcef/browser/browser_host_impl.h" + +#include "content/public/browser/render_widget_host_view.h" +#include "content/public/browser/web_contents_view.h" +#include "ui/gfx/point.h" + +namespace { + +class CefMenuDelegate : public MenuGtk::Delegate { + public: + CefMenuDelegate() {} +}; + +} // namespace + + +CefMenuCreatorRunnerGtk::CefMenuCreatorRunnerGtk() { +} + +bool CefMenuCreatorRunnerGtk::RunContextMenu(CefMenuCreator* manager) { + if (!menu_delegate_.get()) + menu_delegate_.reset(new CefMenuDelegate); + + // Create a menu based on the model. + menu_.reset(new MenuGtk(menu_delegate_.get(), manager->model())); + + gfx::Rect bounds; + manager->browser()->GetWebContents()->GetView()->GetContainerBounds(&bounds); + gfx::Point point = bounds.origin(); + point.Offset(manager->params().x, manager->params().y); + + content::RenderWidgetHostView* view = + manager->browser()->GetWebContents()->GetRenderWidgetHostView(); + GdkEventButton* event = view->GetLastMouseDown(); + uint32_t triggering_event_time = event ? event->time : GDK_CURRENT_TIME; + + // Show the menu. Execution will continue asynchronously. + menu_->PopupAsContext(point, triggering_event_time); + + return true; +} diff --git a/cef3/libcef/browser/menu_creator_runner_gtk.h b/cef3/libcef/browser/menu_creator_runner_gtk.h new file mode 100644 index 000000000..d113ef717 --- /dev/null +++ b/cef3/libcef/browser/menu_creator_runner_gtk.h @@ -0,0 +1,26 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_MENU_MANAGER_RUNNER_GTK_H_ +#define CEF_LIBCEF_BROWSER_MENU_MANAGER_RUNNER_GTK_H_ +#pragma once + +#include "libcef/browser/menu_creator.h" + +#include "base/memory/scoped_ptr.h" +#include "chrome/browser/ui/gtk/menu_gtk.h" + +class CefMenuCreatorRunnerGtk: public CefMenuCreator::Runner { + public: + CefMenuCreatorRunnerGtk(); + + // CefMemoryManager::Runner methods. + virtual bool RunContextMenu(CefMenuCreator* manager) OVERRIDE; + + private: + scoped_ptr menu_; + scoped_ptr menu_delegate_; +}; + +#endif // CEF_LIBCEF_BROWSER_MENU_MANAGER_RUNNER_GTK_H_ diff --git a/cef3/libcef/browser/menu_creator_runner_mac.h b/cef3/libcef/browser/menu_creator_runner_mac.h new file mode 100644 index 000000000..d4ccc6d79 --- /dev/null +++ b/cef3/libcef/browser/menu_creator_runner_mac.h @@ -0,0 +1,29 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_MENU_MANAGER_RUNNER_MAC_H_ +#define CEF_LIBCEF_BROWSER_MENU_MANAGER_RUNNER_MAC_H_ +#pragma once + +#include "libcef/browser/menu_creator.h" + +#if __OBJC__ +@class MenuController; +#else +class MenuController; +#endif + +class CefMenuCreatorRunnerMac : public CefMenuCreator::Runner { + public: + CefMenuCreatorRunnerMac(); + virtual ~CefMenuCreatorRunnerMac(); + + // CefMemoryManager::Runner methods. + virtual bool RunContextMenu(CefMenuCreator* manager) OVERRIDE; + + private: + MenuController* menu_controller_; +}; + +#endif // CEF_LIBCEF_BROWSER_MENU_MANAGER_RUNNER_MAC_H_ diff --git a/cef3/libcef/browser/menu_creator_runner_mac.mm b/cef3/libcef/browser/menu_creator_runner_mac.mm new file mode 100644 index 000000000..7f21ee115 --- /dev/null +++ b/cef3/libcef/browser/menu_creator_runner_mac.mm @@ -0,0 +1,68 @@ +// 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 "libcef/browser/menu_creator_runner_mac.h" +#include "libcef/browser/browser_host_impl.h" + +#include "base/message_loop.h" +#include "base/compiler_specific.h" +#import "base/mac/scoped_sending_event.h" +#import "chrome/browser/ui/cocoa/menu_controller.h" +#include "content/public/browser/web_contents_view.h" + +CefMenuCreatorRunnerMac::CefMenuCreatorRunnerMac() + : menu_controller_(nil) { +} + +CefMenuCreatorRunnerMac::~CefMenuCreatorRunnerMac() { + if (menu_controller_ != nil) + [menu_controller_ release]; +} + +bool CefMenuCreatorRunnerMac::RunContextMenu(CefMenuCreator* manager) { + // Create a menu controller based on the model. + if (menu_controller_ != nil) + [menu_controller_ release]; + menu_controller_ = + [[MenuController alloc] initWithModel:manager->model() + useWithPopUpButtonCell:NO]; + + NSView* parent_view = + manager->browser()->GetWebContents()->GetView()->GetContentNativeView(); + + // Synthesize an event for the click, as there is no certainty that + // [NSApp currentEvent] will return a valid event. + NSEvent* currentEvent = [NSApp currentEvent]; + NSWindow* window = [parent_view window]; + NSPoint position = [window mouseLocationOutsideOfEventStream]; + NSTimeInterval eventTime = [currentEvent timestamp]; + NSEvent* clickEvent = [NSEvent mouseEventWithType:NSRightMouseDown + location:position + modifierFlags:NSRightMouseDownMask + timestamp:eventTime + windowNumber:[window windowNumber] + context:nil + eventNumber:0 + clickCount:1 + pressure:1.0]; + + { + // Make sure events can be pumped while the menu is up. + MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); + + // One of the events that could be pumped is |window.close()|. + // User-initiated event-tracking loops protect against this by + // setting flags in -[CrApplication sendEvent:], but since + // web-content menus are initiated by IPC message the setup has to + // be done manually. + base::mac::ScopedSendingEvent sendingEventScoper; + + // Show the menu. Blocks until the menu is dismissed. + [NSMenu popUpContextMenu:[menu_controller_ menu] + withEvent:clickEvent + forView:parent_view]; + } + + return true; +} diff --git a/cef3/libcef/browser/menu_creator_runner_win.cc b/cef3/libcef/browser/menu_creator_runner_win.cc new file mode 100644 index 000000000..c911ff1d9 --- /dev/null +++ b/cef3/libcef/browser/menu_creator_runner_win.cc @@ -0,0 +1,55 @@ +// 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 "libcef/browser/menu_creator_runner_win.h" +#include "libcef/browser/browser_host_impl.h" + +#include "base/message_loop.h" +#include "content/public/browser/web_contents_view.h" +#include "ui/gfx/point.h" +#include "ui/views/controls/menu/menu_2.h" + +CefMenuCreatorRunnerWin::CefMenuCreatorRunnerWin() { +} + +bool CefMenuCreatorRunnerWin::RunContextMenu(CefMenuCreator* manager) { + // Create a menu based on the model. + menu_.reset(new views::NativeMenuWin(manager->model(), NULL)); + menu_->Rebuild(NULL); + + // Make sure events can be pumped while the menu is up. + MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); + + gfx::Point screen_point; + + if (manager->browser()->IsWindowRenderingDisabled()) { + CefRefPtr client = manager->browser()->GetClient(); + if (!client.get()) + return false; + + CefRefPtr handler = client->GetRenderHandler(); + if (!handler.get()) + return false; + + int screenX = 0, screenY = 0; + if (!handler->GetScreenPoint(manager->browser(), + manager->params().x, manager->params().y, + screenX, screenY)) { + return false; + } + + screen_point = gfx::Point(screenX, screenY); + } else { + POINT temp = {manager->params().x, manager->params().y}; + HWND hwnd = + manager->browser()->GetWebContents()->GetView()->GetNativeView(); + ClientToScreen(hwnd, &temp); + screen_point = temp; + } + + // Show the menu. Blocks until the menu is dismissed. + menu_->RunMenuAt(screen_point, views::Menu2::ALIGN_TOPLEFT); + + return true; +} diff --git a/cef3/libcef/browser/menu_creator_runner_win.h b/cef3/libcef/browser/menu_creator_runner_win.h new file mode 100644 index 000000000..c78e953b6 --- /dev/null +++ b/cef3/libcef/browser/menu_creator_runner_win.h @@ -0,0 +1,25 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_MENU_MANAGER_RUNNER_WIN_H_ +#define CEF_LIBCEF_BROWSER_MENU_MANAGER_RUNNER_WIN_H_ +#pragma once + +#include "libcef/browser/menu_creator.h" + +#include "base/memory/scoped_ptr.h" +#include "ui/views/controls/menu/native_menu_win.h" + +class CefMenuCreatorRunnerWin : public CefMenuCreator::Runner { + public: + CefMenuCreatorRunnerWin(); + + // CefMemoryManager::Runner methods. + virtual bool RunContextMenu(CefMenuCreator* manager) OVERRIDE; + + private: + scoped_ptr menu_; +}; + +#endif // CEF_LIBCEF_BROWSER_MENU_MANAGER_RUNNER_WIN_H_ diff --git a/cef3/libcef/browser/menu_model_impl.cc b/cef3/libcef/browser/menu_model_impl.cc new file mode 100644 index 000000000..6bc889795 --- /dev/null +++ b/cef3/libcef/browser/menu_model_impl.cc @@ -0,0 +1,700 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2012 The Chromium 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 "libcef/browser/menu_model_impl.h" + +#include + +#include "base/bind.h" +#include "base/logging.h" +#include "base/message_loop.h" +#include "ui/base/accelerators/accelerator.h" + +namespace { + +const int kSeparatorId = -1; + +// A simple MenuModel implementation that delegates to CefMenuModelImpl. +class CefSimpleMenuModel : public ui::MenuModel { + public: + // The Delegate can be NULL, though if it is items can't be checked or + // disabled. + explicit CefSimpleMenuModel(CefMenuModelImpl* impl) + : impl_(impl), + menu_model_delegate_(NULL) { + } + + virtual ~CefSimpleMenuModel() { + } + + // MenuModel methods. + virtual bool HasIcons() const OVERRIDE { + return false; + } + + virtual int GetItemCount() const OVERRIDE { + return impl_->GetCount(); + } + + virtual ItemType GetTypeAt(int index) const OVERRIDE { + switch (impl_->GetTypeAt(index)) { + case MENUITEMTYPE_COMMAND: + return TYPE_COMMAND; + case MENUITEMTYPE_CHECK: + return TYPE_CHECK; + case MENUITEMTYPE_RADIO: + return TYPE_RADIO; + case MENUITEMTYPE_SEPARATOR: + return TYPE_SEPARATOR; + case MENUITEMTYPE_SUBMENU: + return TYPE_SUBMENU; + default: + NOTREACHED(); + return TYPE_COMMAND; + } + } + + virtual ui::MenuSeparatorType GetSeparatorTypeAt(int index) const OVERRIDE { + return ui::NORMAL_SEPARATOR; + } + + virtual int GetCommandIdAt(int index) const OVERRIDE { + return impl_->GetCommandIdAt(index); + } + + virtual string16 GetLabelAt(int index) const OVERRIDE { + return impl_->GetLabelAt(index).ToString16(); + } + + virtual bool IsItemDynamicAt(int index) const OVERRIDE { + return false; + } + + virtual bool GetAcceleratorAt(int index, + ui::Accelerator* accelerator) const OVERRIDE { + int key_code = 0; + bool shift_pressed = false; + bool ctrl_pressed = false; + bool alt_pressed = false; + if (impl_->GetAcceleratorAt(index, key_code, shift_pressed, ctrl_pressed, + alt_pressed)) { + int modifiers = 0; + if (shift_pressed) + modifiers |= ui::EF_SHIFT_DOWN; + if (ctrl_pressed) + modifiers |= ui::EF_CONTROL_DOWN; + if (alt_pressed) + modifiers |= ui::EF_ALT_DOWN; + + *accelerator = ui::Accelerator(static_cast(key_code), + modifiers); + return true; + } + return false; + } + + virtual bool IsItemCheckedAt(int index) const OVERRIDE { + return impl_->IsCheckedAt(index); + } + + virtual int GetGroupIdAt(int index) const OVERRIDE { + return impl_->GetGroupIdAt(index); + } + + virtual bool GetIconAt(int index, gfx::Image* icon) OVERRIDE { + return false; + } + + virtual ui::ButtonMenuItemModel* GetButtonMenuItemAt( + int index) const OVERRIDE { + return NULL; + } + + virtual bool IsEnabledAt(int index) const OVERRIDE { + return impl_->IsEnabledAt(index); + } + + virtual bool IsVisibleAt(int index) const OVERRIDE { + return impl_->IsVisibleAt(index); + } + + virtual void HighlightChangedTo(int index) OVERRIDE { + } + + virtual void ActivatedAt(int index) OVERRIDE { + ActivatedAt(index, 0); + } + + virtual void ActivatedAt(int index, int event_flags) OVERRIDE { + impl_->ActivatedAt(index, static_cast(event_flags)); + } + + virtual MenuModel* GetSubmenuModelAt(int index) const OVERRIDE { + CefRefPtr submenu = impl_->GetSubMenuAt(index); + if (submenu.get()) + return static_cast(submenu.get())->model(); + return NULL; + } + + virtual void MenuWillShow() OVERRIDE { + impl_->MenuWillShow(); + } + + virtual void MenuClosed() OVERRIDE { + impl_->MenuClosed(); + } + + virtual void SetMenuModelDelegate( + ui::MenuModelDelegate* menu_model_delegate) OVERRIDE { + menu_model_delegate_ = menu_model_delegate; + } + + virtual ui::MenuModelDelegate* GetMenuModelDelegate() const OVERRIDE { + return menu_model_delegate_; + } + + private: + CefMenuModelImpl* impl_; + ui::MenuModelDelegate* menu_model_delegate_; + + DISALLOW_COPY_AND_ASSIGN(CefSimpleMenuModel); +}; + +} // namespace + + +struct CefMenuModelImpl::Item { + Item(cef_menu_item_type_t type, + int command_id, + const CefString& label, + int group_id) + : type_(type), + command_id_(command_id), + label_(label), + group_id_(group_id), + enabled_(true), + visible_(true), + checked_(false), + has_accelerator_(false), + key_code_(0), + shift_pressed_(false), + ctrl_pressed_(false), + alt_pressed_(false) { + } + + // Basic information. + cef_menu_item_type_t type_; + int command_id_; + CefString label_; + int group_id_; + CefRefPtr submenu_; + + // State information. + bool enabled_; + bool visible_; + bool checked_; + + // Accelerator information. + bool has_accelerator_; + int key_code_; + bool shift_pressed_; + bool ctrl_pressed_; + bool alt_pressed_; +}; + + +CefMenuModelImpl::CefMenuModelImpl(Delegate* delegate) + : supported_thread_id_(base::PlatformThread::CurrentId()), + delegate_(delegate) { + model_.reset(new CefSimpleMenuModel(this)); +} + +CefMenuModelImpl::~CefMenuModelImpl() { +} + +bool CefMenuModelImpl::Clear() { + if (!VerifyContext()) + return false; + + items_.clear(); + return true; +} + +int CefMenuModelImpl::GetCount() { + if (!VerifyContext()) + return 0; + + return static_cast(items_.size()); +} + +bool CefMenuModelImpl::AddSeparator() { + if (!VerifyContext()) + return false; + + AppendItem(Item(MENUITEMTYPE_SEPARATOR, kSeparatorId, CefString(), -1)); + return true; +} + +bool CefMenuModelImpl::AddItem(int command_id, const CefString& label) { + if (!VerifyContext()) + return false; + + AppendItem(Item(MENUITEMTYPE_COMMAND, command_id, label, -1)); + return true; +} + +bool CefMenuModelImpl::AddCheckItem(int command_id, const CefString& label) { + if (!VerifyContext()) + return false; + + AppendItem(Item(MENUITEMTYPE_CHECK, command_id, label, -1)); + return true; +} + +bool CefMenuModelImpl::AddRadioItem(int command_id, const CefString& label, + int group_id) { + if (!VerifyContext()) + return false; + + AppendItem(Item(MENUITEMTYPE_RADIO, command_id, label, group_id)); + return true; +} + +CefRefPtr CefMenuModelImpl::AddSubMenu(int command_id, + const CefString& label) { + if (!VerifyContext()) + return NULL; + + Item item(MENUITEMTYPE_SUBMENU, command_id, label, -1); + item.submenu_ = new CefMenuModelImpl(delegate_); + AppendItem(item); + return item.submenu_.get(); +} + +bool CefMenuModelImpl::InsertSeparatorAt(int index) { + if (!VerifyContext()) + return false; + + InsertItemAt(Item(MENUITEMTYPE_SEPARATOR, kSeparatorId, CefString(), -1), + index); + return true; +} + +bool CefMenuModelImpl::InsertItemAt(int index, int command_id, + const CefString& label) { + if (!VerifyContext()) + return false; + + InsertItemAt(Item(MENUITEMTYPE_COMMAND, command_id, label, -1), index); + return true; +} + +bool CefMenuModelImpl::InsertCheckItemAt(int index, int command_id, + const CefString& label) { + if (!VerifyContext()) + return false; + + InsertItemAt(Item(MENUITEMTYPE_CHECK, command_id, label, -1), index); + return true; +} + +bool CefMenuModelImpl::InsertRadioItemAt(int index, int command_id, + const CefString& label, int group_id) { + if (!VerifyContext()) + return false; + + InsertItemAt(Item(MENUITEMTYPE_RADIO, command_id, label, -1), index); + return true; +} + +CefRefPtr CefMenuModelImpl::InsertSubMenuAt( + int index, int command_id, const CefString& label) { + if (!VerifyContext()) + return NULL; + + Item item(MENUITEMTYPE_SUBMENU, command_id, label, -1); + item.submenu_ = new CefMenuModelImpl(delegate_); + InsertItemAt(item, index); + return item.submenu_.get(); +} + +bool CefMenuModelImpl::Remove(int command_id) { + return RemoveAt(GetIndexOf(command_id)); +} + +bool CefMenuModelImpl::RemoveAt(int index) { + if (!VerifyContext()) + return false; + + if (index >= 0 && index < static_cast(items_.size())) { + items_.erase(items_.begin()+index); + return true; + } + return false; +} + +int CefMenuModelImpl::GetIndexOf(int command_id) { + if (!VerifyContext()) + return -1; + + for (ItemVector::iterator i = items_.begin(); i != items_.end(); ++i) { + if ((*i).command_id_ == command_id) { + return static_cast(std::distance(items_.begin(), i)); + } + } + return -1; +} + +int CefMenuModelImpl::GetCommandIdAt(int index) { + if (!VerifyContext()) + return -1; + + if (index >= 0 && index < static_cast(items_.size())) + return items_[index].command_id_; + return -1; +} + +bool CefMenuModelImpl::SetCommandIdAt(int index, int command_id) { + if (!VerifyContext()) + return false; + + if (index >= 0 && index < static_cast(items_.size())) { + items_[index].command_id_ = command_id; + return true; + } + return false; +} + +CefString CefMenuModelImpl::GetLabel(int command_id) { + return GetLabelAt(GetIndexOf(command_id)); +} + +CefString CefMenuModelImpl::GetLabelAt(int index) { + if (!VerifyContext()) + return CefString(); + + if (index >= 0 && index < static_cast(items_.size())) + return items_[index].label_; + return CefString(); +} + +bool CefMenuModelImpl::SetLabel(int command_id, const CefString& label) { + return SetLabelAt(GetIndexOf(command_id), label); +} + +bool CefMenuModelImpl::SetLabelAt(int index, const CefString& label) { + if (!VerifyContext()) + return false; + + if (index >= 0 && index < static_cast(items_.size())) { + items_[index].label_ = label; + return true; + } + return false; +} + +CefMenuModelImpl::MenuItemType CefMenuModelImpl::GetType(int command_id) { + return GetTypeAt(GetIndexOf(command_id)); +} + +CefMenuModelImpl::MenuItemType CefMenuModelImpl::GetTypeAt(int index) { + if (!VerifyContext()) + return MENUITEMTYPE_NONE; + + if (index >= 0 && index < static_cast(items_.size())) + return items_[index].type_; + return MENUITEMTYPE_NONE; +} + +int CefMenuModelImpl::GetGroupId(int command_id) { + return GetGroupIdAt(GetIndexOf(command_id)); +} + +int CefMenuModelImpl::GetGroupIdAt(int index) { + if (!VerifyContext()) + return -1; + + if (index >= 0 && index < static_cast(items_.size())) + return items_[index].group_id_; + return -1; +} + +bool CefMenuModelImpl::SetGroupId(int command_id, int group_id) { + return SetGroupIdAt(GetIndexOf(command_id), group_id); +} + +bool CefMenuModelImpl::SetGroupIdAt(int index, int group_id) { + if (!VerifyContext()) + return false; + + if (index >= 0 && index < static_cast(items_.size())) { + items_[index].group_id_ = group_id; + return true; + } + return false; +} + +CefRefPtr CefMenuModelImpl::GetSubMenu(int command_id) { + return GetSubMenuAt(GetIndexOf(command_id)); +} + +CefRefPtr CefMenuModelImpl::GetSubMenuAt(int index) { + if (!VerifyContext()) + return NULL; + + if (index >= 0 && index < static_cast(items_.size())) + return items_[index].submenu_.get(); + return NULL; +} + +bool CefMenuModelImpl::IsVisible(int command_id) { + return IsVisibleAt(GetIndexOf(command_id)); +} + +bool CefMenuModelImpl::IsVisibleAt(int index) { + if (!VerifyContext()) + return false; + + if (index >= 0 && index < static_cast(items_.size())) + return items_[index].visible_; + return false; +} + +bool CefMenuModelImpl::SetVisible(int command_id, bool visible) { + return SetVisibleAt(GetIndexOf(command_id), visible); +} + +bool CefMenuModelImpl::SetVisibleAt(int index, bool visible) { + if (!VerifyContext()) + return false; + + if (index >= 0 && index < static_cast(items_.size())) { + items_[index].visible_ = visible; + return true; + } + return false; +} + +bool CefMenuModelImpl::IsEnabled(int command_id) { + return IsEnabledAt(GetIndexOf(command_id)); +} + +bool CefMenuModelImpl::IsEnabledAt(int index) { + if (!VerifyContext()) + return false; + + if (index >= 0 && index < static_cast(items_.size())) + return items_[index].enabled_; + return false; +} + +bool CefMenuModelImpl::SetEnabled(int command_id, bool enabled) { + return SetEnabledAt(GetIndexOf(command_id), enabled); +} + +bool CefMenuModelImpl::SetEnabledAt(int index, bool enabled) { + if (!VerifyContext()) + return false; + + if (index >= 0 && index < static_cast(items_.size())) { + items_[index].enabled_ = enabled; + return true; + } + return false; +} + +bool CefMenuModelImpl::IsChecked(int command_id) { + return IsCheckedAt(GetIndexOf(command_id)); +} + +bool CefMenuModelImpl::IsCheckedAt(int index) { + if (!VerifyContext()) + return false; + + if (index >= 0 && index < static_cast(items_.size())) + return items_[index].checked_; + return false; +} + +bool CefMenuModelImpl::SetChecked(int command_id, bool checked) { + return SetCheckedAt(GetIndexOf(command_id), checked); +} + +bool CefMenuModelImpl::SetCheckedAt(int index, bool checked) { + if (!VerifyContext()) + return false; + + if (index >= 0 && index < static_cast(items_.size())) { + items_[index].checked_ = checked; + return true; + } + return false; +} + +bool CefMenuModelImpl::HasAccelerator(int command_id) { + return HasAcceleratorAt(GetIndexOf(command_id)); +} + +bool CefMenuModelImpl::HasAcceleratorAt(int index) { + if (!VerifyContext()) + return false; + + if (index >= 0 && index < static_cast(items_.size())) + return items_[index].has_accelerator_; + return false; +} + +bool CefMenuModelImpl::SetAccelerator(int command_id, int key_code, + bool shift_pressed, bool ctrl_pressed, + bool alt_pressed) { + return SetAcceleratorAt(GetIndexOf(command_id), key_code, shift_pressed, + ctrl_pressed, alt_pressed); +} + +bool CefMenuModelImpl::SetAcceleratorAt(int index, int key_code, + bool shift_pressed, bool ctrl_pressed, + bool alt_pressed) { + if (!VerifyContext()) + return false; + + if (index >= 0 && index < static_cast(items_.size())) { + Item& item = items_[index]; + item.has_accelerator_ = true; + item.key_code_ = key_code; + item.shift_pressed_ = shift_pressed; + item.ctrl_pressed_ = ctrl_pressed; + item.alt_pressed_ = alt_pressed; + return true; + } + return false; +} + +bool CefMenuModelImpl::RemoveAccelerator(int command_id) { + return RemoveAcceleratorAt(GetIndexOf(command_id)); +} + +bool CefMenuModelImpl::RemoveAcceleratorAt(int index) { + if (!VerifyContext()) + return false; + + if (index >= 0 && index < static_cast(items_.size())) { + Item& item = items_[index]; + if (item.has_accelerator_) { + item.has_accelerator_ = false; + item.key_code_ = 0; + item.shift_pressed_ = false; + item.ctrl_pressed_ = false; + item.alt_pressed_ = false; + } + return true; + } + return false; +} + +bool CefMenuModelImpl::GetAccelerator(int command_id, int& key_code, + bool& shift_pressed, bool& ctrl_pressed, + bool& alt_pressed) { + return GetAcceleratorAt(GetIndexOf(command_id), key_code, shift_pressed, + ctrl_pressed, alt_pressed); +} + +bool CefMenuModelImpl::GetAcceleratorAt(int index, int& key_code, + bool& shift_pressed, bool& ctrl_pressed, + bool& alt_pressed) { + if (!VerifyContext()) + return false; + + if (index >= 0 && index < static_cast(items_.size())) { + const Item& item = items_[index]; + if (item.has_accelerator_) { + key_code = item.key_code_; + shift_pressed = item.shift_pressed_; + ctrl_pressed = item.ctrl_pressed_; + alt_pressed = item.alt_pressed_; + return true; + } + } + return false; +} + +void CefMenuModelImpl::ActivatedAt(int index, cef_event_flags_t event_flags) { + if (VerifyContext() && delegate_) + delegate_->ExecuteCommand(this, GetCommandIdAt(index), event_flags); +} + +void CefMenuModelImpl::MenuWillShow() { + if (VerifyContext() && delegate_) + delegate_->MenuWillShow(this); +} + +void CefMenuModelImpl::MenuClosed() { + if (!VerifyContext()) + return; + + // Due to how menus work on the different platforms, ActivatedAt will be + // called after this. It's more convenient for the delegate to be called + // afterwards, though, so post a task. + MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&CefMenuModelImpl::OnMenuClosed, this)); +} + +bool CefMenuModelImpl::VerifyRefCount() { + if (!VerifyContext()) + return false; + + if (GetRefCt() != 1) + return false; + + for (ItemVector::iterator i = items_.begin(); i != items_.end(); ++i) { + if ((*i).submenu_.get()) { + if (!(*i).submenu_->VerifyRefCount()) + return false; + } + } + + return true; +} + +void CefMenuModelImpl::AppendItem(const Item& item) { + ValidateItem(item); + items_.push_back(item); +} + +void CefMenuModelImpl::InsertItemAt(const Item& item, int index) { + // Sanitize the index. + if (index < 0) + index = 0; + else if (index > static_cast(items_.size())) + index = items_.size(); + + ValidateItem(item); + items_.insert(items_.begin() + index, item); +} + +void CefMenuModelImpl::ValidateItem(const Item& item) { +#ifndef NDEBUG + if (item.type_ == MENUITEMTYPE_SEPARATOR) { + DCHECK_EQ(item.command_id_, kSeparatorId); + } else { + DCHECK_GE(item.command_id_, 0); + } +#endif // NDEBUG +} + +void CefMenuModelImpl::OnMenuClosed() { + if (delegate_) + delegate_->MenuClosed(this); +} + +bool CefMenuModelImpl::VerifyContext() { + if (base::PlatformThread::CurrentId() != supported_thread_id_) { + // This object should only be accessed from the thread that created it. + NOTREACHED(); + return false; + } + + return true; +} diff --git a/cef3/libcef/browser/menu_model_impl.h b/cef3/libcef/browser/menu_model_impl.h new file mode 100644 index 000000000..102b68d97 --- /dev/null +++ b/cef3/libcef/browser/menu_model_impl.h @@ -0,0 +1,140 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2012 The Chromium 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_LIBCEF_BROWSER_MENU_MODEL_IMPL_H_ +#define CEF_LIBCEF_BROWSER_MENU_MODEL_IMPL_H_ +#pragma once + +#include + +#include "include/cef_menu_model.h" + +#include "base/memory/scoped_ptr.h" +#include "base/threading/platform_thread.h" +#include "ui/base/models/menu_model.h" + +class CefMenuModelImpl : public CefMenuModel { + public: + class Delegate { + public: + // Perform the action associated with the specified |command_id| and + // optional |event_flags|. + virtual void ExecuteCommand(CefRefPtr source, + int command_id, + cef_event_flags_t event_flags) =0; + + // Notifies the delegate that the menu is about to show. + virtual void MenuWillShow(CefRefPtr source) =0; + + // Notifies the delegate that the menu has closed. + virtual void MenuClosed(CefRefPtr source) =0; + + protected: + virtual ~Delegate() {} + }; + + // The delegate must outlive this class. + explicit CefMenuModelImpl(Delegate* delegate); + virtual ~CefMenuModelImpl(); + + // CefMenuModel methods. + virtual bool Clear() OVERRIDE; + virtual int GetCount() OVERRIDE; + virtual bool AddSeparator() OVERRIDE; + virtual bool AddItem(int command_id, const CefString& label) OVERRIDE; + virtual bool AddCheckItem(int command_id, const CefString& label) OVERRIDE; + virtual bool AddRadioItem(int command_id, const CefString& label, + int group_id) OVERRIDE; + virtual CefRefPtr AddSubMenu(int command_id, + const CefString& label) OVERRIDE; + virtual bool InsertSeparatorAt(int index) OVERRIDE; + virtual bool InsertItemAt(int index, int command_id, + const CefString& label) OVERRIDE; + virtual bool InsertCheckItemAt(int index, int command_id, + const CefString& label) OVERRIDE; + virtual bool InsertRadioItemAt(int index, int command_id, + const CefString& label, int group_id) OVERRIDE; + virtual CefRefPtr InsertSubMenuAt(int index, int command_id, + const CefString& label) OVERRIDE; + virtual bool Remove(int command_id) OVERRIDE; + virtual bool RemoveAt(int index) OVERRIDE; + virtual int GetIndexOf(int command_id) OVERRIDE; + virtual int GetCommandIdAt(int index) OVERRIDE; + virtual bool SetCommandIdAt(int index, int command_id) OVERRIDE; + virtual CefString GetLabel(int command_id) OVERRIDE; + virtual CefString GetLabelAt(int index) OVERRIDE; + virtual bool SetLabel(int command_id, const CefString& label) OVERRIDE; + virtual bool SetLabelAt(int index, const CefString& label) OVERRIDE; + virtual MenuItemType GetType(int command_id) OVERRIDE; + virtual MenuItemType GetTypeAt(int index) OVERRIDE; + virtual int GetGroupId(int command_id) OVERRIDE; + virtual int GetGroupIdAt(int index) OVERRIDE; + virtual bool SetGroupId(int command_id, int group_id) OVERRIDE; + virtual bool SetGroupIdAt(int index, int group_id) OVERRIDE; + virtual CefRefPtr GetSubMenu(int command_id) OVERRIDE; + virtual CefRefPtr GetSubMenuAt(int index) OVERRIDE; + virtual bool IsVisible(int command_id) OVERRIDE; + virtual bool IsVisibleAt(int index) OVERRIDE; + virtual bool SetVisible(int command_id, bool visible) OVERRIDE; + virtual bool SetVisibleAt(int index, bool visible) OVERRIDE; + virtual bool IsEnabled(int command_id) OVERRIDE; + virtual bool IsEnabledAt(int index) OVERRIDE; + virtual bool SetEnabled(int command_id, bool enabled) OVERRIDE; + virtual bool SetEnabledAt(int index, bool enabled) OVERRIDE; + virtual bool IsChecked(int command_id) OVERRIDE; + virtual bool IsCheckedAt(int index) OVERRIDE; + virtual bool SetChecked(int command_id, bool checked) OVERRIDE; + virtual bool SetCheckedAt(int index, bool checked) OVERRIDE; + virtual bool HasAccelerator(int command_id) OVERRIDE; + virtual bool HasAcceleratorAt(int index) OVERRIDE; + virtual bool SetAccelerator(int command_id, int key_code, bool shift_pressed, + bool ctrl_pressed, bool alt_pressed) OVERRIDE; + virtual bool SetAcceleratorAt(int index, int key_code, bool shift_pressed, + bool ctrl_pressed, bool alt_pressed) OVERRIDE; + virtual bool RemoveAccelerator(int command_id) OVERRIDE; + virtual bool RemoveAcceleratorAt(int index) OVERRIDE; + virtual bool GetAccelerator(int command_id, int& key_code, + bool& shift_pressed, bool& ctrl_pressed, bool& alt_pressed) OVERRIDE; + virtual bool GetAcceleratorAt(int index, int& key_code, bool& shift_pressed, + bool& ctrl_pressed, bool& alt_pressed) OVERRIDE; + + // Callbacks from the ui::MenuModel implementation. + void ActivatedAt(int index, cef_event_flags_t event_flags); + void MenuWillShow(); + void MenuClosed(); + + // Verify that only a single reference exists to all CefMenuModelImpl objects. + bool VerifyRefCount(); + + ui::MenuModel* model() { return model_.get(); } + Delegate* delegate() { return delegate_; } + void set_delegate(Delegate* delegate) { delegate_ = NULL; } + + private: + struct Item; + + typedef std::vector ItemVector; + + // Functions for inserting items into |items_|. + void AppendItem(const Item& item); + void InsertItemAt(const Item& item, int index); + void ValidateItem(const Item& item); + + // Notify the delegate that the menu is closed. + void OnMenuClosed(); + + // Verify that the object is being accessed from the correct thread. + bool VerifyContext(); + + base::PlatformThreadId supported_thread_id_; + Delegate* delegate_; + ItemVector items_; + scoped_ptr model_; + + IMPLEMENT_REFCOUNTING(CefMenuModelImpl); + DISALLOW_COPY_AND_ASSIGN(CefMenuModelImpl); +}; + +#endif // CEF_LIBCEF_BROWSER_MENU_MODEL_IMPL_H_ diff --git a/cef3/libcef/browser/navigate_params.cc b/cef3/libcef/browser/navigate_params.cc new file mode 100644 index 000000000..85222a4d1 --- /dev/null +++ b/cef3/libcef/browser/navigate_params.cc @@ -0,0 +1,20 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2012 The Chromium 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 "libcef/browser/navigate_params.h" + +CefNavigateParams::CefNavigateParams( + const GURL& a_url, + content::PageTransition a_transition) + : url(a_url), + frame_id(-1), + disposition(CURRENT_TAB), + transition(a_transition), + is_renderer_initiated(false), + user_gesture(true) { +} + +CefNavigateParams::~CefNavigateParams() { +} diff --git a/cef3/libcef/browser/navigate_params.h b/cef3/libcef/browser/navigate_params.h new file mode 100644 index 000000000..e78907413 --- /dev/null +++ b/cef3/libcef/browser/navigate_params.h @@ -0,0 +1,84 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 The Chromium 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_LIBCEF_BROWSER_NAVIGATE_PARAMS_H_ +#define CEF_LIBCEF_BROWSER_NAVIGATE_PARAMS_H_ +#pragma once + +#include + +#include "content/public/browser/global_request_id.h" +#include "content/public/common/page_transition_types.h" +#include "content/public/common/referrer.h" +#include "googleurl/src/gurl.h" +#include "net/base/upload_data.h" +#include "ui/base/window_open_disposition.h" + +// Parameters that tell CefBrowserHostImpl::Navigate() what to do. +struct CefNavigateParams { + CefNavigateParams(const GURL& a_url, + content::PageTransition a_transition); + ~CefNavigateParams(); + + // The following parameters are sent to the renderer via CefMsg_LoadRequest. + // --------------------------------------------------------------------------- + + // Request method. + std::string method; + + // The URL/referrer to be loaded. + GURL url; + content::Referrer referrer; + + // The frame that the request should be loaded in or -1 to use the main frame. + int64 frame_id; + + // Usually the URL of the document in the top-level window, which may be + // checked by the third-party cookie blocking policy. Leaving it empty may + // lead to undesired cookie blocking. Third-party cookie blocking can be + // bypassed by setting first_party_for_cookies = url, but this should ideally + // only be done if there really is no way to determine the correct value. + GURL first_party_for_cookies; + + // Additional HTTP request headers. + std::string headers; + + // net::URLRequest load flags (0 by default). + int load_flags; + + // Upload data (may be NULL). + scoped_refptr upload_data; + + + // The following parameters are used to define browser behavior when servicing + // the navigation request. + // --------------------------------------------------------------------------- + + // The disposition requested by the navigation source. Default is CURRENT_TAB. + WindowOpenDisposition disposition; + + // The transition type of the navigation. + content::PageTransition transition; + + // Whether this navigation was initiated by the renderer process. + bool is_renderer_initiated; + + // If non-empty, the new tab contents encoding is overriden by this value. + std::string override_encoding; + + // If false then the navigation was not initiated by a user gesture. Default + // is true. + bool user_gesture; + + // Refers to a navigation that was parked in the browser in order to be + // transferred to another RVH. Only used in case of a redirection of a request + // to a different site that created a new RVH. + content::GlobalRequestID transferred_global_request_id; + + private: + CefNavigateParams(); +}; + +#endif // CEF_LIBCEF_BROWSER_NAVIGATE_PARAMS_H_ diff --git a/cef3/libcef/browser/origin_whitelist_impl.cc b/cef3/libcef/browser/origin_whitelist_impl.cc new file mode 100644 index 000000000..83b0f790e --- /dev/null +++ b/cef3/libcef/browser/origin_whitelist_impl.cc @@ -0,0 +1,243 @@ +// 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 "libcef/browser/origin_whitelist_impl.h" + +#include +#include + +#include "include/cef_origin_whitelist.h" +#include "libcef/browser/context.h" +#include "libcef/browser/thread_util.h" +#include "libcef/common/cef_messages.h" + +#include "base/bind.h" +#include "base/lazy_instance.h" +#include "base/synchronization/lock.h" +#include "content/public/browser/render_process_host.h" +#include "googleurl/src/gurl.h" + +namespace { + +// Class that manages cross-origin whitelist registrations. +class CefOriginWhitelistManager { + public: + CefOriginWhitelistManager() {} + + // Retrieve the singleton instance. + static CefOriginWhitelistManager* GetInstance(); + + bool AddOriginEntry(const std::string& source_origin, + const std::string& target_protocol, + const std::string& target_domain, + bool allow_target_subdomains) { + Cef_CrossOriginWhiteListEntry_Params info; + info.source_origin = source_origin; + info.target_protocol = target_protocol; + info.target_domain = target_domain; + info.allow_target_subdomains = allow_target_subdomains; + + { + base::AutoLock lock_scope(lock_); + + // Verify that the origin entry doesn't already exist. + OriginList::const_iterator it = origin_list_.begin(); + for (; it != origin_list_.end(); ++it) { + if (IsEqual(*it, info)) + return false; + } + + origin_list_.push_back(info); + } + + SendModifyCrossOriginWhitelistEntry(true, info); + return true; + } + + bool RemoveOriginEntry(const std::string& source_origin, + const std::string& target_protocol, + const std::string& target_domain, + bool allow_target_subdomains) { + Cef_CrossOriginWhiteListEntry_Params info; + info.source_origin = source_origin; + info.target_protocol = target_protocol; + info.target_domain = target_domain; + info.allow_target_subdomains = allow_target_subdomains; + + bool found = false; + + { + base::AutoLock lock_scope(lock_); + + OriginList::iterator it = origin_list_.begin(); + for (; it != origin_list_.end(); ++it) { + if (IsEqual(*it, info)) { + origin_list_.erase(it); + found = true; + break; + } + } + } + + if (!found) + return false; + + SendModifyCrossOriginWhitelistEntry(false, info); + return true; + } + + void ClearOrigins() { + { + base::AutoLock lock_scope(lock_); + origin_list_.clear(); + } + + SendClearCrossOriginWhitelist(); + } + + void GetCrossOriginWhitelistEntries( + std::vector* entries) { + base::AutoLock lock_scope(lock_); + + if (origin_list_.empty()) + return; + entries->insert(entries->end(), origin_list_.begin(), origin_list_.end()); + } + + private: + // Send the modify cross-origin whitelist entry message to all currently + // existing hosts. + static void SendModifyCrossOriginWhitelistEntry( + bool add, + Cef_CrossOriginWhiteListEntry_Params& params) { + CEF_REQUIRE_UIT(); + + content::RenderProcessHost::iterator i( + content::RenderProcessHost::AllHostsIterator()); + for (; !i.IsAtEnd(); i.Advance()) { + i.GetCurrentValue()->Send( + new CefProcessMsg_ModifyCrossOriginWhitelistEntry(add, params)); + } + } + + // Send the clear cross-origin whitelists message to all currently existing + // hosts. + static void SendClearCrossOriginWhitelist() { + CEF_REQUIRE_UIT(); + + content::RenderProcessHost::iterator i( + content::RenderProcessHost::AllHostsIterator()); + for (; !i.IsAtEnd(); i.Advance()) { + i.GetCurrentValue()->Send(new CefProcessMsg_ClearCrossOriginWhitelist); + } + } + + static bool IsEqual(const Cef_CrossOriginWhiteListEntry_Params& param1, + const Cef_CrossOriginWhiteListEntry_Params& param2) { + return (param1.source_origin == param2.source_origin && + param1.target_protocol == param2.target_protocol && + param1.target_domain == param2.target_domain && + param1.allow_target_subdomains == param2.allow_target_subdomains); + } + + base::Lock lock_; + + // List of registered origins. Access must be protected by |lock_|. + typedef std::vector OriginList; + OriginList origin_list_; + + DISALLOW_EVIL_CONSTRUCTORS(CefOriginWhitelistManager); +}; + +base::LazyInstance g_manager = + LAZY_INSTANCE_INITIALIZER; + +CefOriginWhitelistManager* CefOriginWhitelistManager::GetInstance() { + return g_manager.Pointer(); +} + +} // namespace + +bool CefAddCrossOriginWhitelistEntry(const CefString& source_origin, + const CefString& target_protocol, + const CefString& target_domain, + bool allow_target_subdomains) { + // Verify that the context is in a valid state. + if (!CONTEXT_STATE_VALID()) { + NOTREACHED(); + return false; + } + + std::string source_url = source_origin; + GURL gurl = GURL(source_url); + if (gurl.is_empty() || !gurl.is_valid()) { + NOTREACHED() << "Invalid source_origin URL: " << source_url; + return false; + } + + if (CEF_CURRENTLY_ON_UIT()) { + return CefOriginWhitelistManager::GetInstance()->AddOriginEntry( + source_origin, target_protocol, target_domain, allow_target_subdomains); + } else { + CEF_POST_TASK(CEF_UIT, + base::Bind(base::IgnoreResult(&CefAddCrossOriginWhitelistEntry), + source_origin, target_protocol, target_domain, + allow_target_subdomains)); + } + + return true; +} + +bool CefRemoveCrossOriginWhitelistEntry(const CefString& source_origin, + const CefString& target_protocol, + const CefString& target_domain, + bool allow_target_subdomains) { + // Verify that the context is in a valid state. + if (!CONTEXT_STATE_VALID()) { + NOTREACHED(); + return false; + } + + std::string source_url = source_origin; + GURL gurl = GURL(source_url); + if (gurl.is_empty() || !gurl.is_valid()) { + NOTREACHED() << "Invalid source_origin URL: " << source_url; + return false; + } + + if (CEF_CURRENTLY_ON_UIT()) { + return CefOriginWhitelistManager::GetInstance()->RemoveOriginEntry( + source_origin, target_protocol, target_domain, allow_target_subdomains); + } else { + CEF_POST_TASK(CEF_UIT, + base::Bind(base::IgnoreResult(&CefRemoveCrossOriginWhitelistEntry), + source_origin, target_protocol, target_domain, + allow_target_subdomains)); + } + + return true; +} + +bool CefClearCrossOriginWhitelist() { + // Verify that the context is in a valid state. + if (!CONTEXT_STATE_VALID()) { + NOTREACHED(); + return false; + } + + if (CEF_CURRENTLY_ON_UIT()) { + CefOriginWhitelistManager::GetInstance()->ClearOrigins(); + } else { + CEF_POST_TASK(CEF_UIT, + base::Bind(base::IgnoreResult(&CefClearCrossOriginWhitelist))); + } + + return true; +} + +void GetCrossOriginWhitelistEntries( + std::vector* entries) { + CefOriginWhitelistManager::GetInstance()->GetCrossOriginWhitelistEntries( + entries); +} diff --git a/cef3/libcef/browser/origin_whitelist_impl.h b/cef3/libcef/browser/origin_whitelist_impl.h new file mode 100644 index 000000000..37fd19eed --- /dev/null +++ b/cef3/libcef/browser/origin_whitelist_impl.h @@ -0,0 +1,21 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_ORIGIN_WHITELIST_IMPL_H_ +#define CEF_LIBCEF_BROWSER_ORIGIN_WHITELIST_IMPL_H_ + +#include + +namespace content { +class RenderProcessHost; +} + +struct Cef_CrossOriginWhiteListEntry_Params; + +// Called to retrieve the current list of cross-origin white list entries. This +// method is thread safe. +void GetCrossOriginWhitelistEntries( + std::vector* entries); + +#endif // CEF_LIBCEF_BROWSER_ORIGIN_WHITELIST_IMPL_H_ diff --git a/cef3/libcef/browser/path_util_impl.cc b/cef3/libcef/browser/path_util_impl.cc new file mode 100644 index 000000000..9a73d800c --- /dev/null +++ b/cef3/libcef/browser/path_util_impl.cc @@ -0,0 +1,44 @@ +// 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 "include/cef_path_util.h" + +#include "base/files/file_path.h" +#include "base/logging.h" +#include "base/path_service.h" + +bool CefGetPath(PathKey key, CefString& path) { + int pref_key = base::PATH_START; + switch(key) { + case PK_DIR_CURRENT: + pref_key = base::DIR_CURRENT; + break; + case PK_DIR_EXE: + pref_key = base::DIR_EXE; + break; + case PK_DIR_MODULE: + pref_key = base::DIR_MODULE; + break; + case PK_DIR_TEMP: + pref_key = base::DIR_TEMP; + break; + case PK_FILE_EXE: + pref_key = base::FILE_EXE; + break; + case PK_FILE_MODULE: + pref_key = base::FILE_MODULE; + break; + default: + NOTREACHED() << "invalid argument"; + return false; + } + + base::FilePath file_path; + if (PathService::Get(pref_key, &file_path)) { + path = file_path.value(); + return true; + } + + return false; +} diff --git a/cef3/libcef/browser/process_util_impl.cc b/cef3/libcef/browser/process_util_impl.cc new file mode 100644 index 000000000..3ddb407c0 --- /dev/null +++ b/cef3/libcef/browser/process_util_impl.cc @@ -0,0 +1,31 @@ +// 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 "include/cef_process_util.h" +#include "libcef/common/command_line_impl.h" + +#include "base/logging.h" +#include "base/process_util.h" +#include "content/public/browser/browser_thread.h" + +bool CefLaunchProcess(CefRefPtr command_line) { + if (!command_line.get()) { + NOTREACHED() << "invalid parameter"; + return false; + } + + if (!content::BrowserThread::CurrentlyOn( + content::BrowserThread::PROCESS_LAUNCHER)) { + NOTREACHED() << "called on invalid thread"; + return false; + } + + CefCommandLineImpl* impl = + static_cast(command_line.get()); + + CefValueController::AutoLock lock_scope(impl->controller()); + + base::LaunchOptions options; + return base::LaunchProcess(impl->command_line(), options, NULL); +} diff --git a/cef3/libcef/browser/proxy_stubs.cc b/cef3/libcef/browser/proxy_stubs.cc new file mode 100644 index 000000000..42c55f0f2 --- /dev/null +++ b/cef3/libcef/browser/proxy_stubs.cc @@ -0,0 +1,14 @@ +// Copyright (c) 2012 The Chromium 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 "base/logging.h" +#include "components/user_prefs/pref_registry_syncable.h" + +// Required by PrefProxyConfigTrackerImpl::RegisterUserPrefs. +void PrefRegistrySyncable::RegisterDictionaryPref( + const char* path, + base::DictionaryValue* default_value, + PrefSyncStatus sync_status) { + NOTREACHED(); +} diff --git a/cef3/libcef/browser/render_widget_host_view_osr.cc b/cef3/libcef/browser/render_widget_host_view_osr.cc new file mode 100644 index 000000000..a4fab5cea --- /dev/null +++ b/cef3/libcef/browser/render_widget_host_view_osr.cc @@ -0,0 +1,552 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 The Chromium 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 "libcef/browser/backing_store_osr.h" +#include "libcef/browser/browser_host_impl.h" +#include "libcef/browser/render_widget_host_view_osr.h" + +#include "base/message_loop.h" +#include "content/browser/renderer_host/render_widget_host_impl.h" +#include "content/public/browser/content_browser_client.h" +#include "content/public/browser/render_view_host.h" +#include "content/public/common/content_client.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" + +#if defined(OS_WIN) +#include "third_party/WebKit/Source/WebKit/chromium/public/win/WebScreenInfoFactory.h" +#endif + +#include "webkit/glue/webcursor.h" + +/////////////////////////////////////////////////////////////////////////////// +// CefRenderWidgetHostViewOSR, public: + +CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR( + content::RenderWidgetHost* widget) + : render_widget_host_(content::RenderWidgetHostImpl::From(widget)), + about_to_validate_and_paint_(false), + parent_host_view_(NULL), + popup_host_view_(NULL), + weak_factory_(this) { + DCHECK(render_widget_host_); + render_widget_host_->SetView(this); + + // CefBrowserHostImpl might not be created at this time for popups. + if (render_widget_host_->IsRenderView()) { + browser_impl_ = CefBrowserHostImpl::GetBrowserForHost( + content::RenderViewHost::From(render_widget_host_)); + } +} + +CefRenderWidgetHostViewOSR::~CefRenderWidgetHostViewOSR() { +} + + +// RenderWidgetHostView implementation. +void CefRenderWidgetHostViewOSR::InitAsChild(gfx::NativeView parent_view) { +} + +content::RenderWidgetHost* + CefRenderWidgetHostViewOSR::GetRenderWidgetHost() const { + return render_widget_host_; +} + +void CefRenderWidgetHostViewOSR::SetSize(const gfx::Size& size) { +} + +void CefRenderWidgetHostViewOSR::SetBounds(const gfx::Rect& rect) { +} + +gfx::NativeView CefRenderWidgetHostViewOSR::GetNativeView() const { + return browser_impl_.get() ? browser_impl_->GetWindowHandle() : NULL; +} + +gfx::NativeViewId CefRenderWidgetHostViewOSR::GetNativeViewId() const { + if (!browser_impl_.get()) + return gfx::NativeViewId(); + // This Id is used on Windows as HWND to retrieve monitor info + // If this Id is not a valid window, the main screen monitor info is used + return reinterpret_cast(browser_impl_->GetWindowHandle()); +} + +gfx::NativeViewAccessible + CefRenderWidgetHostViewOSR::GetNativeViewAccessible() { + return gfx::NativeViewAccessible(); +} + +bool CefRenderWidgetHostViewOSR::HasFocus() const { + return false; +} + +bool CefRenderWidgetHostViewOSR::IsSurfaceAvailableForCopy() const { + return false; +} + +void CefRenderWidgetHostViewOSR::Show() { + WasShown(); +} + +void CefRenderWidgetHostViewOSR::Hide() { + WasHidden(); +} + +bool CefRenderWidgetHostViewOSR::IsShowing() { + return true; +} + +gfx::Rect CefRenderWidgetHostViewOSR::GetViewBounds() const { + if (IsPopupWidget()) + return popup_position_; + + if (!browser_impl_.get()) + return gfx::Rect(); + CefRect rc; + browser_impl_->GetClient()->GetRenderHandler()->GetViewRect( + browser_impl_->GetBrowser(), rc); + return gfx::Rect(rc.x, rc.y, rc.width, rc.height); +} + +// Implementation of RenderWidgetHostViewPort. +void CefRenderWidgetHostViewOSR::InitAsPopup( + RenderWidgetHostView* parent_host_view, + const gfx::Rect& pos) { + parent_host_view_ = static_cast( + parent_host_view); + browser_impl_ = parent_host_view_->get_browser_impl(); + if (!browser_impl_.get()) + return; + + parent_host_view_->CancelWidget(); + + parent_host_view_->set_popup_host_view(this); + NotifyShowWidget(); + + popup_position_ = pos; + NotifySizeWidget(); +} + +void CefRenderWidgetHostViewOSR::InitAsFullscreen( + RenderWidgetHostView* reference_host_view) { + NOTREACHED() << "Fullscreen widgets are not supported in OSR"; +} + +void CefRenderWidgetHostViewOSR::WasShown() { + if (render_widget_host_) + render_widget_host_->WasShown(); +} + +void CefRenderWidgetHostViewOSR::WasHidden() { + if (render_widget_host_) + render_widget_host_->WasHidden(); +} + +void CefRenderWidgetHostViewOSR::MovePluginWindows( + const gfx::Vector2d& scroll_offset, + const std::vector& moves) { +} + +void CefRenderWidgetHostViewOSR::Focus() { +} + +void CefRenderWidgetHostViewOSR::Blur() { +} + +void CefRenderWidgetHostViewOSR::UpdateCursor(const WebCursor& cursor) { + if (!browser_impl_.get()) + return; +#if defined(OS_WIN) + HMODULE hModule = ::GetModuleHandle( + content::GetContentClient()->browser()->GetResourceDllName()); + if (!hModule) + hModule = ::GetModuleHandle(NULL); + WebCursor web_cursor = cursor; + HCURSOR hCursor = web_cursor.GetCursor((HINSTANCE)hModule); + browser_impl_->GetClient()->GetRenderHandler()->OnCursorChange( + browser_impl_->GetBrowser(), hCursor); +#else + // TODO(port): Implement this method to work on other platforms as part of + // off-screen rendering support. + NOTREACHED(); +#endif +} + +void CefRenderWidgetHostViewOSR::SetIsLoading(bool is_loading) { +} + +void CefRenderWidgetHostViewOSR::TextInputStateChanged( + const ViewHostMsg_TextInputState_Params& params) { +} + +void CefRenderWidgetHostViewOSR::ImeCancelComposition() { +} + +void CefRenderWidgetHostViewOSR::ImeCompositionRangeChanged( + const ui::Range& range, + const std::vector& character_bounds) { +} + +void CefRenderWidgetHostViewOSR::DidUpdateBackingStore( + const gfx::Rect& scroll_rect, + const gfx::Vector2d& scroll_delta, + const std::vector& copy_rects) { + if (!scroll_rect.IsEmpty()) { + std::vector dirty_rects(copy_rects); + dirty_rects.push_back(scroll_rect); + Paint(dirty_rects); + } else { + Paint(copy_rects); + } +} + +void CefRenderWidgetHostViewOSR::RenderViewGone( + base::TerminationStatus status, + int error_code) { + render_widget_host_ = NULL; + parent_host_view_ = NULL; + popup_host_view_ = NULL; +} + +#if defined(OS_WIN) && !defined(USE_AURA) +void CefRenderWidgetHostViewOSR::WillWmDestroy() { + // Will not be called if GetNativeView returns NULL. + NOTREACHED(); +} +#endif + +void CefRenderWidgetHostViewOSR::GetScreenInfo( + WebKit::WebScreenInfo* results) { +#if defined(OS_WIN) + *results = WebKit::WebScreenInfoFactory::screenInfo(GetNativeView()); +#endif +} + +gfx::Rect CefRenderWidgetHostViewOSR::GetBoundsInRootWindow() { + if (!browser_impl_.get()) + return gfx::Rect(); + CefRect rc; + if (browser_impl_->GetClient()->GetRenderHandler()->GetRootScreenRect( + browser_impl_->GetBrowser(), rc)) { + return gfx::Rect(rc.x, rc.y, rc.width, rc.height); + } + return gfx::Rect(); +} + +void CefRenderWidgetHostViewOSR::OnAccessibilityNotifications( + const std::vector& params) { +} + +void CefRenderWidgetHostViewOSR::Destroy() { + if (IsPopupWidget()) { + if (parent_host_view_) + parent_host_view_->CancelWidget(); + } else { + CancelWidget(); + } + + delete this; +} + +void CefRenderWidgetHostViewOSR::SetTooltipText(const string16& tooltip_text) { + if (!browser_impl_.get()) + return; + + CefString tooltip(tooltip_text); + CefRefPtr handler = + browser_impl_->GetClient()->GetDisplayHandler(); + if (handler.get()) { + handler->OnTooltip(browser_impl_->GetBrowser(), tooltip); + } +} + +void CefRenderWidgetHostViewOSR::SelectionBoundsChanged( + const ViewHostMsg_SelectionBounds_Params& params) { +} + +void CefRenderWidgetHostViewOSR::ScrollOffsetChanged() { +} + +content::BackingStore* CefRenderWidgetHostViewOSR::AllocBackingStore( + const gfx::Size& size) { + return render_widget_host_ ? + new BackingStoreOSR(render_widget_host_, size) : + NULL; +} + +void CefRenderWidgetHostViewOSR::CopyFromCompositingSurface( + const gfx::Rect& src_subrect, + const gfx::Size& dst_size, + const base::Callback& callback) { +} + +void CefRenderWidgetHostViewOSR::CopyFromCompositingSurfaceToVideoFrame( + const gfx::Rect& src_subrect, + const scoped_refptr& target, + const base::Callback& callback) { +} + +bool CefRenderWidgetHostViewOSR::CanCopyToVideoFrame() const { + return false; +} + +void CefRenderWidgetHostViewOSR::OnAcceleratedCompositingStateChange() { +} + +void CefRenderWidgetHostViewOSR::SetHasHorizontalScrollbar( + bool has_horizontal_scrollbar) { +} + +void CefRenderWidgetHostViewOSR::SetScrollOffsetPinning( + bool is_pinned_to_left, bool is_pinned_to_right) { +} + +gfx::GLSurfaceHandle CefRenderWidgetHostViewOSR::GetCompositingSurface() { + return gfx::GLSurfaceHandle(); +} + +void CefRenderWidgetHostViewOSR::AcceleratedSurfaceBuffersSwapped( + const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, + int gpu_host_id) { +} + +void CefRenderWidgetHostViewOSR::AcceleratedSurfacePostSubBuffer( + const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, + int gpu_host_id) { +} + +void CefRenderWidgetHostViewOSR::AcceleratedSurfaceSuspend() { +} + +void CefRenderWidgetHostViewOSR::AcceleratedSurfaceRelease() { +} + +bool CefRenderWidgetHostViewOSR::HasAcceleratedSurface( + const gfx::Size& desired_size) { + return false; +} + +bool CefRenderWidgetHostViewOSR::LockMouse() { + return false; +} + +void CefRenderWidgetHostViewOSR::UnlockMouse() { +} + +#if defined(OS_WIN) && !defined(USE_AURA) +void CefRenderWidgetHostViewOSR::SetClickthroughRegion(SkRegion* region) { +} +#endif + +void CefRenderWidgetHostViewOSR::SetBackground(const SkBitmap& background) { + if (!render_widget_host_) + return; + RenderWidgetHostViewBase::SetBackground(background); + render_widget_host_->SetBackground(background); +} + +void CefRenderWidgetHostViewOSR::Invalidate(const gfx::Rect& rect, + CefBrowserHost::PaintElementType type) { + if (!IsPopupWidget() && type == PET_POPUP) { + if (popup_host_view_) + popup_host_view_->Invalidate(rect, type); + return; + } + std::vector dirtyRects; + dirtyRects.push_back(rect); + Paint(dirtyRects); +} + +void CefRenderWidgetHostViewOSR::Paint( + const std::vector& copy_rects) { + if (about_to_validate_and_paint_ || + !browser_impl_.get() || + !render_widget_host_) { + pending_update_rects_.insert(pending_update_rects_.end(), + copy_rects.begin(), copy_rects.end()); + return; + } + + about_to_validate_and_paint_ = true; + BackingStoreOSR* backing_store = + BackingStoreOSR::From(render_widget_host_->GetBackingStore(true)); + about_to_validate_and_paint_ = false; + + if (backing_store) { + const gfx::Rect client_rect(backing_store->size()); + SkRegion damaged_rgn; + + for (size_t i = 0; i < copy_rects.size(); ++i) { + SkIRect skRect = SkIRect::MakeLTRB( + copy_rects[i].x(), copy_rects[i].y(), + copy_rects[i].right(), copy_rects[i].bottom()); + damaged_rgn.op(skRect, SkRegion::kUnion_Op); + } + + for (size_t i = 0; i < pending_update_rects_.size(); ++i) { + SkIRect skRect = SkIRect::MakeLTRB( + pending_update_rects_[i].x(), pending_update_rects_[i].y(), + pending_update_rects_[i].right(), pending_update_rects_[i].bottom()); + damaged_rgn.op(skRect, SkRegion::kUnion_Op); + } + pending_update_rects_.clear(); + + CefRenderHandler::RectList rcList; + SkRegion::Cliperator iterator(damaged_rgn, + SkIRect::MakeWH(client_rect.width(), client_rect.height())); + for (; !iterator.done(); iterator.next()) { + const SkIRect& r = iterator.rect(); + rcList.push_back( + CefRect(r.left(), r.top(), r.width(), r.height())); + } + + if (rcList.size() == 0) + return; + + browser_impl_->GetClient()->GetRenderHandler()->OnPaint( + browser_impl_->GetBrowser(), + IsPopupWidget() ? PET_POPUP : PET_VIEW, + rcList, + backing_store->getPixels(), + client_rect.width(), + client_rect.height()); + } +} + +bool CefRenderWidgetHostViewOSR::InstallTransparency() { + if (browser_impl_.get() && browser_impl_->IsTransparent()) { + SkBitmap bg; + bg.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); // 1x1 alpha bitmap. + bg.allocPixels(); + bg.eraseARGB(0x00, 0x00, 0x00, 0x00); + SetBackground(bg); + return true; + } + return false; +} + +void CefRenderWidgetHostViewOSR::CancelWidget() { + if (IsPopupWidget()) { + if (render_widget_host_) + render_widget_host_->LostCapture(); + + if (browser_impl_.get()) { + NotifyHideWidget(); + browser_impl_ = NULL; + } + + if (parent_host_view_) { + parent_host_view_->set_popup_host_view(NULL); + parent_host_view_ = NULL; + } + + if (!weak_factory_.HasWeakPtrs()) { + MessageLoop::current()->PostTask(FROM_HERE, + base::Bind(&CefRenderWidgetHostViewOSR::ShutdownHost, + weak_factory_.GetWeakPtr())); + } + } else if (popup_host_view_) { + popup_host_view_->CancelWidget(); + } +} + +void CefRenderWidgetHostViewOSR::NotifyShowWidget() { + if (browser_impl_.get()) { + browser_impl_->GetClient()->GetRenderHandler()->OnPopupShow( + browser_impl_->GetBrowser(), true); + } +} + +void CefRenderWidgetHostViewOSR::NotifyHideWidget() { + if (browser_impl_.get()) { + browser_impl_->GetClient()->GetRenderHandler()->OnPopupShow( + browser_impl_->GetBrowser(), false); + } +} + +void CefRenderWidgetHostViewOSR::NotifySizeWidget() { + if (browser_impl_.get()) { + CefRect widget_pos(popup_position_.x(), popup_position_.y(), + popup_position_.width(), popup_position_.height()); + browser_impl_->GetClient()->GetRenderHandler()->OnPopupSize( + browser_impl_->GetBrowser(), widget_pos); + } +} + +CefRefPtr + CefRenderWidgetHostViewOSR::get_browser_impl() const { + return browser_impl_; +} + +void CefRenderWidgetHostViewOSR::set_browser_impl( + CefRefPtr browser) { + browser_impl_ = browser; +} + +void CefRenderWidgetHostViewOSR::set_popup_host_view( + CefRenderWidgetHostViewOSR* popup_view) { + popup_host_view_ = popup_view; +} + +void CefRenderWidgetHostViewOSR::ShutdownHost() { + weak_factory_.InvalidateWeakPtrs(); + if (render_widget_host_) + render_widget_host_->Shutdown(); + // Do not touch any members at this point, |this| has been deleted. +} + +void CefRenderWidgetHostViewOSR::set_parent_host_view( + CefRenderWidgetHostViewOSR* parent_view) { + parent_host_view_ = parent_view; +} + +void CefRenderWidgetHostViewOSR::SendKeyEvent( + const content::NativeWebKeyboardEvent& event) { + if (!IsPopupWidget() && popup_host_view_) { + popup_host_view_->SendKeyEvent(event); + return; + } + if (!render_widget_host_) + return; + render_widget_host_->ForwardKeyboardEvent(event); +} + +void CefRenderWidgetHostViewOSR::SendMouseEvent( + const WebKit::WebMouseEvent& event) { + if (!IsPopupWidget() && popup_host_view_) { + if (popup_host_view_->popup_position_.Contains(event.x, event.y)) { + WebKit::WebMouseEvent popup_event(event); + popup_event.x -= popup_host_view_->popup_position_.x(); + popup_event.y -= popup_host_view_->popup_position_.y(); + popup_event.windowX = popup_event.x; + popup_event.windowY = popup_event.y; + + popup_host_view_->SendMouseEvent(popup_event); + return; + } + } + if (!render_widget_host_) + return; + render_widget_host_->ForwardMouseEvent(event); +} + +void CefRenderWidgetHostViewOSR::SendMouseWheelEvent( + const WebKit::WebMouseWheelEvent& event) { + if (!IsPopupWidget() && popup_host_view_) { + if (popup_host_view_->popup_position_.Contains(event.x, event.y)) { + WebKit::WebMouseWheelEvent popup_event(event); + popup_event.x -= popup_host_view_->popup_position_.x(); + popup_event.y -= popup_host_view_->popup_position_.y(); + popup_event.windowX = popup_event.x; + popup_event.windowY = popup_event.y; + popup_host_view_->SendMouseWheelEvent(popup_event); + return; + } else { + // scrolling outside the popup widget, will destroy widget + CancelWidget(); + } + } + if (!render_widget_host_) + return; + render_widget_host_->ForwardWheelEvent(event); +} diff --git a/cef3/libcef/browser/render_widget_host_view_osr.h b/cef3/libcef/browser/render_widget_host_view_osr.h new file mode 100644 index 000000000..5b369872c --- /dev/null +++ b/cef3/libcef/browser/render_widget_host_view_osr.h @@ -0,0 +1,188 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 The Chromium 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_LIBCEF_BROWSER_RENDER_WIDGET_HOST_VIEW_OSR_H_ +#define CEF_LIBCEF_BROWSER_RENDER_WIDGET_HOST_VIEW_OSR_H_ +#pragma once + +#include + +#include "include/cef_base.h" +#include "include/cef_browser.h" + +#include "base/memory/weak_ptr.h" +#include "content/browser/renderer_host/render_widget_host_view_base.h" + +namespace content { + class RenderWidgetHost; + class BackingStore; +} + +class CefBrowserHostImpl; +class CefWebContentsViewOSR; + +/////////////////////////////////////////////////////////////////////////////// +// CefRenderWidgetHostViewOSR +// +// An object representing the "View" of a rendered web page. This object is +// responsible for sending paint events to the the CefRenderHandler +// when window rendering is disabled. It is the implementation of the +// RenderWidgetHostView that the cross-platform RenderWidgetHost object uses +// to display the data. +// +// Comment excerpted from render_widget_host.h: +// +// "The lifetime of the RenderWidgetHostHWND is tied to the render process. +// If the render process dies, the RenderWidgetHostHWND goes away and all +// references to it must become NULL." +// +// RenderWidgetHostView class hierarchy described in render_widget_host_view.h. +/////////////////////////////////////////////////////////////////////////////// + +class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase { + public: + // RenderWidgetHostView methods. + virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE; + virtual content::RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE; + virtual void SetSize(const gfx::Size& size) OVERRIDE; + virtual void SetBounds(const gfx::Rect& rect) OVERRIDE; + virtual gfx::NativeView GetNativeView() const OVERRIDE; + virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE; + virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; + virtual bool HasFocus() const OVERRIDE; + virtual bool IsSurfaceAvailableForCopy() const OVERRIDE; + virtual void Show() OVERRIDE; + virtual void Hide() OVERRIDE; + virtual bool IsShowing() OVERRIDE; + virtual gfx::Rect GetViewBounds() const OVERRIDE; + + // RenderWidgetHostViewPort methods. + virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, + const gfx::Rect& pos) OVERRIDE; + virtual void InitAsFullscreen( + RenderWidgetHostView* reference_host_view) OVERRIDE; + virtual void WasShown() OVERRIDE; + virtual void WasHidden() OVERRIDE; + virtual void MovePluginWindows( + const gfx::Vector2d& scroll_offset, + const std::vector& moves) OVERRIDE; + virtual void Focus() OVERRIDE; + virtual void Blur() OVERRIDE; + virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE; + virtual void SetIsLoading(bool is_loading) OVERRIDE; + virtual void TextInputStateChanged( + const ViewHostMsg_TextInputState_Params& params) OVERRIDE; + virtual void ImeCancelComposition() OVERRIDE; + virtual void ImeCompositionRangeChanged( + const ui::Range& range, + const std::vector& character_bounds) OVERRIDE; + virtual void DidUpdateBackingStore( + const gfx::Rect& scroll_rect, + const gfx::Vector2d& scroll_delta, + const std::vector& copy_rects) OVERRIDE; + virtual void RenderViewGone(base::TerminationStatus status, + int error_code) OVERRIDE; +#if defined(OS_WIN) && !defined(USE_AURA) + virtual void WillWmDestroy() OVERRIDE; +#endif + virtual void GetScreenInfo(WebKit::WebScreenInfo* results) OVERRIDE; + virtual gfx::Rect GetBoundsInRootWindow() OVERRIDE; + void OnAccessibilityNotifications( + const std::vector& params) + OVERRIDE; + virtual void Destroy() OVERRIDE; + virtual void SetTooltipText(const string16& tooltip_text) OVERRIDE; + virtual void SelectionBoundsChanged( + const ViewHostMsg_SelectionBounds_Params& params) OVERRIDE; + virtual void ScrollOffsetChanged() OVERRIDE; + virtual content::BackingStore* + AllocBackingStore(const gfx::Size& size) OVERRIDE; + virtual void CopyFromCompositingSurface( + const gfx::Rect& src_subrect, + const gfx::Size& dst_size, + const base::Callback& callback) OVERRIDE; + virtual void CopyFromCompositingSurfaceToVideoFrame( + const gfx::Rect& src_subrect, + const scoped_refptr& target, + const base::Callback& callback) OVERRIDE; + virtual bool CanCopyToVideoFrame() const OVERRIDE; + virtual void OnAcceleratedCompositingStateChange() OVERRIDE; + virtual void SetHasHorizontalScrollbar( + bool has_horizontal_scrollbar) OVERRIDE; + virtual void SetScrollOffsetPinning( + bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE; + virtual gfx::GLSurfaceHandle GetCompositingSurface() OVERRIDE; + virtual void AcceleratedSurfaceBuffersSwapped( + const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, + int gpu_host_id) OVERRIDE; + virtual void AcceleratedSurfacePostSubBuffer( + const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, + int gpu_host_id) OVERRIDE; + virtual void AcceleratedSurfaceSuspend() OVERRIDE; + virtual void AcceleratedSurfaceRelease() OVERRIDE; + virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) OVERRIDE; + virtual bool LockMouse() OVERRIDE; + virtual void UnlockMouse() OVERRIDE; + +#if defined(OS_WIN) && !defined(USE_AURA) + virtual void SetClickthroughRegion(SkRegion* region) OVERRIDE; +#endif + + // RenderWidgetHostViewBase methods. + virtual void SetBackground(const SkBitmap& background) OVERRIDE; + + void SendKeyEvent(const content::NativeWebKeyboardEvent& event); + void SendMouseEvent(const WebKit::WebMouseEvent& event); + void SendMouseWheelEvent(const WebKit::WebMouseWheelEvent& event); + + void Invalidate(const gfx::Rect& rect, + CefBrowserHost::PaintElementType type); + void Paint(const std::vector& copy_rects); + bool InstallTransparency(); + + void CancelWidget(); + void NotifyShowWidget(); + void NotifyHideWidget(); + void NotifySizeWidget(); + + CefRefPtr get_browser_impl() const; + void set_browser_impl(CefRefPtr browser); + void set_popup_host_view(CefRenderWidgetHostViewOSR* popup_view); + void set_parent_host_view(CefRenderWidgetHostViewOSR* parent_view); + + bool IsPopupWidget() const { + return popup_type_ != WebKit::WebPopupTypeNone; + } + + private: + friend class CefWebContentsViewOSR; + + explicit CefRenderWidgetHostViewOSR(content::RenderWidgetHost* widget); + virtual ~CefRenderWidgetHostViewOSR(); + + // After calling this function, object gets deleted + void ShutdownHost(); + + // Factory used to safely scope delayed calls to ShutdownHost(). + base::WeakPtrFactory weak_factory_; + + // The associated Model. While |this| is being Destroyed, + // |render_widget_host_| is NULL and the Windows message loop is run one last + // time. Message handlers must check for a NULL |render_widget_host_|. + content::RenderWidgetHostImpl* render_widget_host_; + CefRenderWidgetHostViewOSR* parent_host_view_; + CefRenderWidgetHostViewOSR* popup_host_view_; + + CefRefPtr browser_impl_; + + bool about_to_validate_and_paint_; + std::vector pending_update_rects_; + + gfx::Rect popup_position_; + + DISALLOW_COPY_AND_ASSIGN(CefRenderWidgetHostViewOSR); +}; + +#endif // CEF_LIBCEF_BROWSER_RENDER_WIDGET_HOST_VIEW_OSR_H_ diff --git a/cef3/libcef/browser/resource_dispatcher_host_delegate.cc b/cef3/libcef/browser/resource_dispatcher_host_delegate.cc new file mode 100644 index 000000000..7e3d5fb40 --- /dev/null +++ b/cef3/libcef/browser/resource_dispatcher_host_delegate.cc @@ -0,0 +1,22 @@ +// 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 "libcef/browser/resource_dispatcher_host_delegate.h" +#include "libcef/browser/browser_host_impl.h" + +CefResourceDispatcherHostDelegate::CefResourceDispatcherHostDelegate() { +} + +CefResourceDispatcherHostDelegate::~CefResourceDispatcherHostDelegate() { +} + +bool CefResourceDispatcherHostDelegate::HandleExternalProtocol(const GURL& url, + int child_id, + int route_id) { + CefRefPtr browser = + CefBrowserHostImpl::GetBrowserByRoutingID(child_id, route_id); + if (browser.get()) + browser->HandleExternalProtocol(url); + return false; +} diff --git a/cef3/libcef/browser/resource_dispatcher_host_delegate.h b/cef3/libcef/browser/resource_dispatcher_host_delegate.h new file mode 100644 index 000000000..4e0e64270 --- /dev/null +++ b/cef3/libcef/browser/resource_dispatcher_host_delegate.h @@ -0,0 +1,28 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ +#define CEF_LIBCEF_BROWSER_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ +#pragma once + +#include "base/compiler_specific.h" +#include "content/public/browser/resource_dispatcher_host_delegate.h" + +// Implements ResourceDispatcherHostDelegate. +class CefResourceDispatcherHostDelegate + : public content::ResourceDispatcherHostDelegate { + public: + CefResourceDispatcherHostDelegate(); + virtual ~CefResourceDispatcherHostDelegate(); + + // ResourceDispatcherHostDelegate methods. + virtual bool HandleExternalProtocol(const GURL& url, + int child_id, + int route_id) OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(CefResourceDispatcherHostDelegate); +}; + +#endif // CEF_LIBCEF_BROWSER_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ diff --git a/cef3/libcef/browser/resource_request_job.cc b/cef3/libcef/browser/resource_request_job.cc new file mode 100644 index 000000000..9e5fe706c --- /dev/null +++ b/cef3/libcef/browser/resource_request_job.cc @@ -0,0 +1,526 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2006-2009 The Chromium 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 "libcef/browser/resource_request_job.h" + +#include +#include + +#include "include/cef_callback.h" +#include "libcef/browser/cookie_manager_impl.h" +#include "libcef/browser/thread_util.h" +#include "libcef/common/request_impl.h" +#include "libcef/common/response_impl.h" + +#include "base/logging.h" +#include "net/base/io_buffer.h" +#include "net/base/load_flags.h" +#include "net/http/http_response_headers.h" +#include "net/url_request/http_user_agent_settings.h" +#include "net/url_request/url_request.h" +#include "net/url_request/url_request_context.h" + +using net::URLRequestStatus; + +namespace { + +bool SetHeaderIfMissing(CefRequest::HeaderMap& headerMap, + const std::string& name, + const std::string& value) { + if (value.empty()) + return false; + + CefRequest::HeaderMap::const_iterator it = headerMap.find(name); + if (it == headerMap.end()) { + headerMap.insert(std::make_pair(name, value)); + return true; + } + + return false; +} + +} // namespace + +// Client callback for asynchronous response continuation. +class CefResourceRequestJobCallback : public CefCallback { + public: + enum Type { + HEADERS_AVAILABLE, + BYTES_AVAILABLE, + }; + + explicit CefResourceRequestJobCallback(CefResourceRequestJob* job, Type type) + : job_(job), + type_(type), + dest_(NULL), + dest_size_(0) {} + + virtual void Continue() OVERRIDE { + if (CEF_CURRENTLY_ON_IOT()) { + // Currently on IO thread. + // Return early if the callback has already been detached. + if (!job_) + return; + + if (type_ == HEADERS_AVAILABLE) { + // Callback for headers available. + if (!job_->has_response_started()) { + // Send header information. + job_->SendHeaders(); + } + + // This type of callback only ever needs to be called once. + Detach(); + } else if (type_ == BYTES_AVAILABLE) { + // Callback for bytes available. + if (job_->has_response_started() && + job_->GetStatus().is_io_pending()) { + // Read the bytes. They should be available but, if not, wait again. + int bytes_read = 0; + if (job_->ReadRawData(dest_, dest_size_, &bytes_read)) { + if (bytes_read > 0) { + // Clear the IO_PENDING status. + job_->SetStatus(URLRequestStatus()); + + // Notify about the available bytes. + job_->NotifyReadComplete(bytes_read); + + dest_ = NULL; + dest_size_ = 0; + } else { + // All done. + job_->NotifyDone(URLRequestStatus()); + Detach(); + } + } else if (!job_->GetStatus().is_io_pending()) { + // Failed due to an error. + NOTREACHED() << + "ReadRawData returned false without setting IO as pending"; + job_->NotifyDone(URLRequestStatus()); + Detach(); + } + } + } + } else { + // Execute this method on the IO thread. + CEF_POST_TASK(CEF_IOT, + base::Bind(&CefResourceRequestJobCallback::Continue, this)); + } + } + + virtual void Cancel() OVERRIDE { + if (CEF_CURRENTLY_ON_IOT()) { + // Currently on IO thread. + if (job_) + job_->Kill(); + } else { + // Execute this method on the IO thread. + CEF_POST_TASK(CEF_IOT, + base::Bind(&CefResourceRequestJobCallback::Cancel, this)); + } + } + + void Detach() { + CEF_REQUIRE_IOT(); + job_ = NULL; + } + + void SetDestination(net::IOBuffer* dest, int dest_size) { + CEF_REQUIRE_IOT(); + dest_ = dest; + dest_size_ = dest_size; + } + + private: + CefResourceRequestJob* job_; + Type type_; + + net::IOBuffer* dest_; + int dest_size_; + + IMPLEMENT_REFCOUNTING(Callback); +}; + +CefResourceRequestJob::CefResourceRequestJob( + net::URLRequest* request, + net::NetworkDelegate* network_delegate, + CefRefPtr handler) + : net::URLRequestJob(request, network_delegate), + handler_(handler), + remaining_bytes_(0), + response_cookies_save_index_(0), + ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { +} + +CefResourceRequestJob::~CefResourceRequestJob() { +} + +void CefResourceRequestJob::Start() { + CEF_REQUIRE_IOT(); + + cef_request_ = CefRequest::Create(); + + // Populate the request data. + static_cast(cef_request_.get())->Set(request_); + + // Add default headers if not already specified. + const net::URLRequestContext* context = request_->context(); + if (context) { + CefRequest::HeaderMap headerMap; + cef_request_->GetHeaderMap(headerMap); + bool changed = false; + + const net::HttpUserAgentSettings* ua_settings = + context->http_user_agent_settings(); + if (ua_settings) { + if (SetHeaderIfMissing(headerMap, + net::HttpRequestHeaders::kAcceptLanguage, + ua_settings->GetAcceptLanguage())) { + changed = true; + } + + if (SetHeaderIfMissing(headerMap, + net::HttpRequestHeaders::kUserAgent, + ua_settings->GetUserAgent(request_->url()))) { + changed = true; + } + } + + if (changed) + cef_request_->SetHeaderMap(headerMap); + } + + AddCookieHeaderAndStart(); +} + +void CefResourceRequestJob::Kill() { + CEF_REQUIRE_IOT(); + + // Notify the handler that the request has been canceled. + handler_->Cancel(); + + if (callback_) { + callback_->Detach(); + callback_ = NULL; + } + + net::URLRequestJob::Kill(); +} + +bool CefResourceRequestJob::ReadRawData(net::IOBuffer* dest, int dest_size, + int* bytes_read) { + CEF_REQUIRE_IOT(); + + DCHECK_NE(dest_size, 0); + DCHECK(bytes_read); + + if (remaining_bytes_ == 0) { + // No more data to read. + *bytes_read = 0; + return true; + } else if (remaining_bytes_ > 0 && remaining_bytes_ < dest_size) { + // The handler knows the content size beforehand. + dest_size = static_cast(remaining_bytes_); + } + + if (!callback_.get()) { + // Create the bytes available callback that will be used until the request + // is completed. + callback_ = new CefResourceRequestJobCallback(this, + CefResourceRequestJobCallback::BYTES_AVAILABLE); + } + + // Read response data from the handler. + bool rv = handler_->ReadResponse(dest->data(), dest_size, *bytes_read, + callback_.get()); + if (!rv) { + // The handler has indicated completion of the request. + *bytes_read = 0; + return true; + } else if (*bytes_read == 0) { + if (!GetStatus().is_io_pending()) { + // Report our status as IO pending. + SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); + callback_->SetDestination(dest, dest_size); + } + return false; + } else if (*bytes_read > dest_size) { + // Normalize the return value. + *bytes_read = dest_size; + } + + if (remaining_bytes_ > 0) + remaining_bytes_ -= *bytes_read; + + // Continue calling this method. + return true; +} + +void CefResourceRequestJob::GetResponseInfo(net::HttpResponseInfo* info) { + CEF_REQUIRE_IOT(); + + info->headers = GetResponseHeaders(); +} + +bool CefResourceRequestJob::GetResponseCookies( + std::vector* cookies) { + CEF_REQUIRE_IOT(); + + cookies->clear(); + FetchResponseCookies(cookies); + return true; +} + +bool CefResourceRequestJob::IsRedirectResponse(GURL* location, + int* http_status_code) { + CEF_REQUIRE_IOT(); + + if (redirect_url_.is_valid()) { + // Redirect to the new URL. + *http_status_code = 303; + location->Swap(&redirect_url_); + return true; + } + + if (response_.get()) { + // Check for HTTP 302 or HTTP 303 redirect. + int status = response_->GetStatus(); + if (status == 302 || status == 303) { + CefResponse::HeaderMap headerMap; + response_->GetHeaderMap(headerMap); + CefRequest::HeaderMap::iterator iter = headerMap.find("Location"); + if (iter != headerMap.end()) { + GURL new_url = GURL(std::string(iter->second)); + *http_status_code = status; + location->Swap(&new_url); + return true; + } + } + } + + return false; +} + +bool CefResourceRequestJob::GetMimeType(std::string* mime_type) const { + CEF_REQUIRE_IOT(); + + if (response_.get()) + *mime_type = response_->GetMimeType(); + return true; +} + +void CefResourceRequestJob::SendHeaders() { + CEF_REQUIRE_IOT(); + + // Clear the headers available callback. + callback_ = NULL; + + // We may have been orphaned... + if (!request()) + return; + + response_ = new CefResponseImpl(); + remaining_bytes_ = 0; + + CefString redirectUrl; + + // Get header information from the handler. + handler_->GetResponseHeaders(response_, remaining_bytes_, redirectUrl); + if (!redirectUrl.empty()) { + std::string redirectUrlStr = redirectUrl; + redirect_url_ = GURL(redirectUrlStr); + } + + if (remaining_bytes_ > 0) + set_expected_content_size(remaining_bytes_); + + // Continue processing the request. + SaveCookiesAndNotifyHeadersComplete(); +} + +void CefResourceRequestJob::AddCookieHeaderAndStart() { + // No matter what, we want to report our status as IO pending since we will + // be notifying our consumer asynchronously via OnStartCompleted. + SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); + + // If the request was destroyed, then there is no more work to do. + if (!request_) + return; + + net::CookieStore* cookie_store = + request_->context()->cookie_store(); + if (cookie_store && + !(request_->load_flags() & net::LOAD_DO_NOT_SEND_COOKIES)) { + net::CookieMonster* cookie_monster = cookie_store->GetCookieMonster(); + if (cookie_monster) { + cookie_monster->GetAllCookiesForURLAsync( + request_->url(), + base::Bind(&CefResourceRequestJob::CheckCookiePolicyAndLoad, + weak_factory_.GetWeakPtr())); + } else { + DoLoadCookies(); + } + } else { + DoStartTransaction(); + } +} + +void CefResourceRequestJob::DoLoadCookies() { + net::CookieOptions options; + options.set_include_httponly(); + request_->context()->cookie_store()->GetCookiesWithOptionsAsync( + request_->url(), options, + base::Bind(&CefResourceRequestJob::OnCookiesLoaded, + weak_factory_.GetWeakPtr())); +} + +void CefResourceRequestJob::CheckCookiePolicyAndLoad( + const net::CookieList& cookie_list) { + bool can_get_cookies = CanGetCookies(cookie_list); + if (can_get_cookies) { + net::CookieList::const_iterator it = cookie_list.begin(); + for (; it != cookie_list.end(); ++it) { + CefCookie cookie; + if (!CefCookieManagerImpl::GetCefCookie(*it, cookie) || + !handler_->CanGetCookie(cookie)) { + can_get_cookies = false; + break; + } + } + } + + if (can_get_cookies) + DoLoadCookies(); + else + DoStartTransaction(); +} + +void CefResourceRequestJob::OnCookiesLoaded(const std::string& cookie_line) { + if (!cookie_line.empty()) { + CefRequest::HeaderMap headerMap; + cef_request_->GetHeaderMap(headerMap); + headerMap.insert( + std::make_pair(net::HttpRequestHeaders::kCookie, cookie_line)); + cef_request_->SetHeaderMap(headerMap); + } + DoStartTransaction(); +} + +void CefResourceRequestJob::DoStartTransaction() { + // We may have been canceled while retrieving cookies. + if (GetStatus().is_success()) { + StartTransaction(); + } else { + NotifyCanceled(); + } +} + +void CefResourceRequestJob::StartTransaction() { + // Create the callback that will be used to notify when header information is + // available. + callback_ = new CefResourceRequestJobCallback(this, + CefResourceRequestJobCallback::HEADERS_AVAILABLE); + + // Protect against deletion of this object. + base::WeakPtr weak_ptr(weak_factory_.GetWeakPtr()); + + // Handler can decide whether to process the request. + bool rv = handler_->ProcessRequest(cef_request_, callback_.get()); + if (weak_ptr.get() && !rv) { + // Cancel the request. + NotifyCanceled(); + } +} + +net::HttpResponseHeaders* CefResourceRequestJob::GetResponseHeaders() { + DCHECK(response_); + if (!response_headers_.get()) { + CefResponseImpl* responseImpl = + static_cast(response_.get()); + response_headers_ = responseImpl->GetResponseHeaders(); + } + return response_headers_; +} + +void CefResourceRequestJob::SaveCookiesAndNotifyHeadersComplete() { + if (request_->load_flags() & net::LOAD_DO_NOT_SAVE_COOKIES) { + SetStatus(URLRequestStatus()); // Clear the IO_PENDING status + NotifyHeadersComplete(); + return; + } + + response_cookies_.clear(); + response_cookies_save_index_ = 0; + + FetchResponseCookies(&response_cookies_); + + // Now, loop over the response cookies, and attempt to persist each. + SaveNextCookie(); +} + +void CefResourceRequestJob::SaveNextCookie() { + if (response_cookies_save_index_ == response_cookies_.size()) { + response_cookies_.clear(); + response_cookies_save_index_ = 0; + SetStatus(URLRequestStatus()); // Clear the IO_PENDING status + NotifyHeadersComplete(); + return; + } + + // No matter what, we want to report our status as IO pending since we will + // be notifying our consumer asynchronously via OnStartCompleted. + SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); + + net::CookieOptions options; + options.set_include_httponly(); + bool can_set_cookie = CanSetCookie( + response_cookies_[response_cookies_save_index_], &options); + if (can_set_cookie) { + CefCookie cookie; + if (CefCookieManagerImpl::GetCefCookie(request_->url(), + response_cookies_[response_cookies_save_index_], cookie)) { + can_set_cookie = handler_->CanSetCookie(cookie); + } else { + can_set_cookie = false; + } + } + + if (can_set_cookie) { + request_->context()->cookie_store()->SetCookieWithOptionsAsync( + request_->url(), response_cookies_[response_cookies_save_index_], + options, base::Bind(&CefResourceRequestJob::OnCookieSaved, + weak_factory_.GetWeakPtr())); + return; + } + + CookieHandled(); +} + +void CefResourceRequestJob::OnCookieSaved(bool cookie_status) { + CookieHandled(); +} + +void CefResourceRequestJob::CookieHandled() { + response_cookies_save_index_++; + // We may have been canceled within OnSetCookie. + if (GetStatus().is_success()) { + SaveNextCookie(); + } else { + NotifyCanceled(); + } +} + +void CefResourceRequestJob::FetchResponseCookies( + std::vector* cookies) { + const std::string name = "Set-Cookie"; + std::string value; + + void* iter = NULL; + net::HttpResponseHeaders* headers = GetResponseHeaders(); + while (headers->EnumerateHeader(&iter, name, &value)) { + if (!value.empty()) + cookies->push_back(value); + } +} diff --git a/cef3/libcef/browser/resource_request_job.h b/cef3/libcef/browser/resource_request_job.h new file mode 100644 index 000000000..c2b8e086c --- /dev/null +++ b/cef3/libcef/browser/resource_request_job.h @@ -0,0 +1,78 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2006-2009 The Chromium 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_LIBCEF_BROWSER_RESOURCE_REQUEST_JOB_H_ +#define CEF_LIBCEF_BROWSER_RESOURCE_REQUEST_JOB_H_ + +#include + +#include "include/cef_browser.h" +#include "include/cef_frame.h" +#include "include/cef_request_handler.h" + +#include "net/cookies/cookie_monster.h" +#include "net/url_request/url_request_job.h" + +namespace net { +class HttpResponseHeaders; +class URLRequest; +} + +class CefResourceRequestJobCallback; + +class CefResourceRequestJob : public net::URLRequestJob { + public: + CefResourceRequestJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate, + CefRefPtr handler); + virtual ~CefResourceRequestJob(); + + private: + // net::URLRequestJob methods. + virtual void Start() OVERRIDE; + virtual void Kill() OVERRIDE; + virtual bool ReadRawData(net::IOBuffer* dest, int dest_size, int* bytes_read) + OVERRIDE; + virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE; + virtual bool GetResponseCookies(std::vector* cookies) OVERRIDE; + virtual bool IsRedirectResponse(GURL* location, int* http_status_code) + OVERRIDE; + virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; + + void SendHeaders(); + + // Used for sending cookies with the request. + void AddCookieHeaderAndStart(); + void DoLoadCookies(); + void CheckCookiePolicyAndLoad(const net::CookieList& cookie_list); + void OnCookiesLoaded(const std::string& cookie_line); + void DoStartTransaction(); + void StartTransaction(); + + // Used for saving cookies returned as part of the response. + net::HttpResponseHeaders* GetResponseHeaders(); + void SaveCookiesAndNotifyHeadersComplete(); + void SaveNextCookie(); + void OnCookieSaved(bool cookie_status); + void CookieHandled(); + void FetchResponseCookies(std::vector* cookies); + + CefRefPtr handler_; + CefRefPtr response_; + GURL redirect_url_; + int64 remaining_bytes_; + CefRefPtr cef_request_; + CefRefPtr callback_; + scoped_refptr response_headers_; + std::vector response_cookies_; + size_t response_cookies_save_index_; + base::WeakPtrFactory weak_factory_; + + friend class CefResourceRequestJobCallback; + + DISALLOW_COPY_AND_ASSIGN(CefResourceRequestJob); +}; + +#endif // CEF_LIBCEF_BROWSER_RESOURCE_REQUEST_JOB_H_ diff --git a/cef3/libcef/browser/scheme_impl.cc b/cef3/libcef/browser/scheme_impl.cc new file mode 100644 index 000000000..cc7e25084 --- /dev/null +++ b/cef3/libcef/browser/scheme_impl.cc @@ -0,0 +1,368 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2006-2009 The Chromium 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 + +#include "include/cef_browser.h" +#include "include/cef_scheme.h" +#include "libcef/browser/browser_context.h" +#include "libcef/browser/browser_host_impl.h" +#include "libcef/browser/context.h" +#include "libcef/browser/resource_request_job.h" +#include "libcef/browser/scheme_registration.h" +#include "libcef/browser/thread_util.h" +#include "libcef/browser/url_request_context_getter.h" +#include "libcef/common/request_impl.h" +#include "libcef/common/response_impl.h" + +#include "base/bind.h" +#include "base/lazy_instance.h" +#include "base/logging.h" +#include "base/message_loop.h" +#include "base/string_util.h" +#include "base/synchronization/lock.h" +#include "googleurl/src/url_util.h" +#include "net/base/completion_callback.h" +#include "net/base/io_buffer.h" +#include "net/base/upload_data.h" +#include "net/http/http_response_headers.h" +#include "net/http/http_util.h" +#include "net/url_request/url_request.h" +#include "net/url_request/url_request_about_job.h" +#include "net/url_request/url_request_context.h" +#include "net/url_request/url_request_data_job.h" +#include "net/url_request/url_request_error_job.h" +#include "net/url_request/url_request_file_job.h" +#include "net/url_request/url_request_filter.h" +#include "net/url_request/url_request_ftp_job.h" +#include "net/url_request/url_request_http_job.h" +#include "net/url_request/url_request_job.h" +#include "net/url_request/url_request_job_factory_impl.h" + +using net::URLRequestStatus; + +namespace { + +bool IsStandardScheme(const std::string& scheme) { + url_parse::Component scheme_comp(0, scheme.length()); + return url_util::IsStandard(scheme.c_str(), scheme_comp); +} + +// Copied from net/url_request/url_request_job_manager.cc. +struct SchemeToFactory { + const char* scheme; + net::URLRequest::ProtocolFactory* factory; +}; +static const SchemeToFactory kBuiltinFactories[] = { + { "http", net::URLRequestHttpJob::Factory }, + { "https", net::URLRequestHttpJob::Factory }, + { "file", net::URLRequestFileJob::Factory }, + { "ftp", net::URLRequestFtpJob::Factory }, + { "about", net::URLRequestAboutJob::Factory }, + { "data", net::URLRequestDataJob::Factory }, +}; + +bool IsBuiltinScheme(const std::string& scheme) { + for (size_t i = 0; i < arraysize(kBuiltinFactories); ++i) + if (LowerCaseEqualsASCII(scheme, kBuiltinFactories[i].scheme)) + return true; + return false; +} + +net::URLRequestJob* GetBuiltinSchemeRequestJob( + net::URLRequest* request, + net::NetworkDelegate* network_delegate, + const std::string& scheme) { + // See if the request should be handled by a built-in protocol factory. + for (size_t i = 0; i < arraysize(kBuiltinFactories); ++i) { + if (scheme == kBuiltinFactories[i].scheme) { + net::URLRequestJob* job = + (kBuiltinFactories[i].factory)(request, network_delegate, scheme); + DCHECK(job); // The built-in factories are not expected to fail! + return job; + } + } + + return NULL; +} + +std::string ToLower(const std::string& str) { + std::string str_lower = str; + std::transform(str_lower.begin(), str_lower.end(), str_lower.begin(), + towlower); + return str; +} + +// Class that manages the CefSchemeHandlerFactory instances. +class CefUrlRequestManager { + protected: + // Class used for creating URLRequestJob instances. The lifespan of this + // object is managed by URLRequestJobFactory. + class ProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler { + public: + explicit ProtocolHandler(const std::string& scheme) + : scheme_(scheme) {} + + // From net::URLRequestJobFactory::ProtocolHandler + virtual net::URLRequestJob* MaybeCreateJob( + net::URLRequest* request, + net::NetworkDelegate* network_delegate) const OVERRIDE { + CEF_REQUIRE_IOT(); + return CefUrlRequestManager::GetInstance()->GetRequestJob( + request, network_delegate, scheme_); + } + + private: + std::string scheme_; + }; + + public: + CefUrlRequestManager() {} + + // Retrieve the singleton instance. + static CefUrlRequestManager* GetInstance(); + + bool AddFactory(const std::string& scheme, + const std::string& domain, + CefRefPtr factory) { + if (!factory.get()) { + RemoveFactory(scheme, domain); + return true; + } + + CEF_REQUIRE_IOT(); + + std::string scheme_lower = ToLower(scheme); + std::string domain_lower = ToLower(domain); + + // Hostname is only supported for standard schemes. + if (!IsStandardScheme(scheme_lower)) + domain_lower.clear(); + + SetProtocolHandlerIfNecessary(scheme_lower, true); + + handler_map_[make_pair(scheme_lower, domain_lower)] = factory; + + return true; + } + + void RemoveFactory(const std::string& scheme, + const std::string& domain) { + CEF_REQUIRE_IOT(); + + std::string scheme_lower = ToLower(scheme); + std::string domain_lower = ToLower(domain); + + // Hostname is only supported for standard schemes. + if (!IsStandardScheme(scheme_lower)) + domain_lower.clear(); + + HandlerMap::iterator iter = + handler_map_.find(make_pair(scheme_lower, domain_lower)); + if (iter != handler_map_.end()) { + handler_map_.erase(iter); + + SetProtocolHandlerIfNecessary(scheme_lower, false); + } + } + + // Clear all the existing URL handlers and unregister the ProtocolFactory. + void ClearFactories() { + CEF_REQUIRE_IOT(); + + net::URLRequestJobFactoryImpl* job_factory = GetJobFactoryImpl(); + + // Create a unique set of scheme names. + std::set schemes; + for (HandlerMap::const_iterator i = handler_map_.begin(); + i != handler_map_.end(); ++i) { + schemes.insert(i->first.first); + } + + for (std::set::const_iterator scheme = schemes.begin(); + scheme != schemes.end(); ++scheme) { + const std::string& scheme_name = *scheme; + if (!scheme::IsInternalProtectedScheme(scheme_name)) { + bool set_protocol = job_factory->SetProtocolHandler(scheme_name, NULL); + DCHECK(set_protocol); + } + } + + handler_map_.clear(); + } + + // Helper for chaining ProtocolHandler implementations. + net::URLRequestJob* GetRequestJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate) { + CEF_REQUIRE_IOT(); + return GetRequestJob(request, network_delegate, request->url().scheme()); + } + + private: + net::URLRequestJobFactoryImpl* GetJobFactoryImpl() { + return static_cast( + _Context->request_context().get())->job_factory_impl(); + } + + // Add or remove the protocol handler if necessary. |scheme| will already be + // in lower case. + void SetProtocolHandlerIfNecessary(const std::string& scheme, bool add) { + // Don't modify a protocol handler for internal protected schemes or if the + // protocol handler is still needed by other registered factories. + if (scheme::IsInternalProtectedScheme(scheme) || HasFactory(scheme)) + return; + + net::URLRequestJobFactoryImpl* job_factory = GetJobFactoryImpl(); + bool set_protocol = job_factory->SetProtocolHandler( + scheme, + (add ? new ProtocolHandler(scheme) : NULL)); + DCHECK(set_protocol); + } + + // Returns true if any factory currently exists for |scheme|. |scheme| will + // already be in lower case. + bool HasFactory(const std::string& scheme) { + if (handler_map_.empty()) + return false; + + for (HandlerMap::const_iterator i = handler_map_.begin(); + i != handler_map_.end(); ++i) { + if (scheme == i->first.first) + return true; + } + + return false; + } + + // Retrieve the matching handler factory, if any. |scheme| will already be in + // lower case. + CefRefPtr GetHandlerFactory( + net::URLRequest* request, const std::string& scheme) { + CefRefPtr factory; + + if (request->url().is_valid() && IsStandardScheme(scheme)) { + // Check for a match with a domain first. + const std::string& domain = request->url().host(); + + HandlerMap::iterator i = handler_map_.find(make_pair(scheme, domain)); + if (i != handler_map_.end()) + factory = i->second; + } + + if (!factory.get()) { + // Check for a match with no specified domain. + HandlerMap::iterator i = + handler_map_.find(make_pair(scheme, std::string())); + if (i != handler_map_.end()) + factory = i->second; + } + + return factory; + } + + // Create the job that will handle the request. |scheme| will already be in + // lower case. + net::URLRequestJob* GetRequestJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate, + const std::string& scheme) { + net::URLRequestJob* job = NULL; + CefRefPtr factory = + GetHandlerFactory(request, scheme); + if (factory) { + CefRefPtr browser = + CefBrowserHostImpl::GetBrowserForRequest(request); + CefRefPtr frame; + if (browser.get()) + frame = browser->GetFrameForRequest(request); + + // Populate the request data. + CefRefPtr requestPtr(new CefRequestImpl()); + requestPtr->Set(request); + + // Call the handler factory to create the handler for the request. + CefRefPtr handler = + factory->Create(browser.get(), frame, scheme, requestPtr.get()); + if (handler.get()) + job = new CefResourceRequestJob(request, network_delegate, handler); + } + + if (!job && IsBuiltinScheme(scheme)) { + // Give the built-in scheme handler a chance to handle the request. + job = GetBuiltinSchemeRequestJob(request, network_delegate, scheme); + } + +#ifndef NDEBUG + if (job) + DLOG(INFO) << "CefUrlRequestManager hit for " << request->url().spec(); +#endif + + return job; + } + + // Map (scheme, domain) to factories. This map will only be accessed on the IO + // thread. + typedef std::map, + CefRefPtr > HandlerMap; + HandlerMap handler_map_; + + DISALLOW_EVIL_CONSTRUCTORS(CefUrlRequestManager); +}; + +base::LazyInstance g_manager = LAZY_INSTANCE_INITIALIZER; + +CefUrlRequestManager* CefUrlRequestManager::GetInstance() { + return g_manager.Pointer(); +} + +} // namespace + + +bool CefRegisterSchemeHandlerFactory( + const CefString& scheme_name, + const CefString& domain_name, + CefRefPtr factory) { + // Verify that the context is in a valid state. + if (!CONTEXT_STATE_VALID()) + return false; + + if (CEF_CURRENTLY_ON(CEF_IOT)) { + return CefUrlRequestManager::GetInstance()->AddFactory(scheme_name, + domain_name, + factory); + } else { + CEF_POST_TASK(CEF_IOT, + base::Bind(base::IgnoreResult(&CefRegisterSchemeHandlerFactory), + scheme_name, domain_name, factory)); + return true; + } +} + +bool CefClearSchemeHandlerFactories() { + // Verify that the context is in a valid state. + if (!CONTEXT_STATE_VALID()) + return false; + + if (CEF_CURRENTLY_ON(CEF_IOT)) { + CefUrlRequestManager::GetInstance()->ClearFactories(); + + // Register internal scheme handlers. + scheme::RegisterInternalHandlers(); + } else { + CEF_POST_TASK(CEF_IOT, + base::Bind(base::IgnoreResult(&CefClearSchemeHandlerFactories))); + } + + return true; +} + +namespace scheme { + +net::URLRequestJob* GetRequestJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate) { + return CefUrlRequestManager::GetInstance()->GetRequestJob( + request, network_delegate); +} + +} // namespace scheme diff --git a/cef3/libcef/browser/scheme_impl.h b/cef3/libcef/browser/scheme_impl.h new file mode 100644 index 000000000..5b66ef9a1 --- /dev/null +++ b/cef3/libcef/browser/scheme_impl.h @@ -0,0 +1,24 @@ +// Copyright (c) 2013 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_LIBCEF_BROWSER_SCHEME_IMPL_H_ +#define CEF_LIBCEF_BROWSER_SCHEME_IMPL_H_ +#pragma once + +namespace net { +class NetworkDelegate; +class URLRequest; +class URLRequestJob; +} + +namespace scheme { + +// Helper for chaining net::URLRequestJobFactory::ProtocolHandler +// implementations. +net::URLRequestJob* GetRequestJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate); + +} // namespace scheme + +#endif // CEF_LIBCEF_BROWSER_SCHEME_IMPL_H_ diff --git a/cef3/libcef/browser/scheme_registration.cc b/cef3/libcef/browser/scheme_registration.cc new file mode 100644 index 000000000..f66b29b27 --- /dev/null +++ b/cef3/libcef/browser/scheme_registration.cc @@ -0,0 +1,98 @@ +// 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 "libcef/browser/scheme_registration.h" +#include "libcef/browser/chrome_scheme_handler.h" +#include "libcef/browser/devtools_scheme_handler.h" +#include "libcef/renderer/content_renderer_client.h" + +#include "content/public/common/url_constants.h" +#include "net/url_request/url_request_job_factory_impl.h" + +namespace scheme { + +void AddInternalStandardSchemes(std::vector* standard_schemes) { + static struct { + const char* name; + bool is_local; + bool is_display_isolated; + } schemes[] = { + { chrome::kChromeUIScheme, true, true }, + { chrome::kChromeDevToolsScheme, true, false } + }; + + for (size_t i = 0; i < sizeof(schemes) / sizeof(schemes[0]); ++i) + standard_schemes->push_back(schemes[i].name); + + if (CefContentRendererClient::Get()) { + // Running in single-process mode. Register the schemes with WebKit. + for (size_t i = 0; i < sizeof(schemes) / sizeof(schemes[0]); ++i) { + CefContentRendererClient::Get()->AddCustomScheme( + schemes[i].name, schemes[i].is_local, schemes[i].is_display_isolated); + } + } +} + +bool IsInternalProtectedScheme(const std::string& scheme) { + // These values originate from StoragePartitionImplMap::Get() in + // content/browser/storage_partition_impl_map.cc and are modified by + // InstallInternalHandlers(). + static const char* schemes[] = { + chrome::kBlobScheme, + chrome::kChromeUIScheme, + chrome::kFileSystemScheme, + }; + + for (size_t i = 0; i < sizeof(schemes) / sizeof(schemes[0]); ++i) { + if (scheme == schemes[i]) + return true; + } + + return false; +} + +void InstallInternalProtectedHandlers( + net::URLRequestJobFactoryImpl* job_factory, + content::ProtocolHandlerMap* protocol_handlers) { + for (content::ProtocolHandlerMap::iterator it = + protocol_handlers->begin(); + it != protocol_handlers->end(); + ++it) { + const std::string& scheme = it->first; + scoped_ptr protocol_handler; + + if (scheme == chrome::kChromeDevToolsScheme) { + // Don't use the default "chrome-devtools" handler. + continue; + } else if (scheme == chrome::kChromeUIScheme) { + // Filter the URLs that are passed to the default "chrome" handler so as + // not to interfere with CEF's "chrome" handler. + protocol_handler.reset( + scheme::WrapChromeProtocolHandler( + make_scoped_ptr(it->second.release())).release()); + } else { + protocol_handler.reset(it->second.release()); + } + + // Make sure IsInternalScheme() stays synchronized with what Chromium is + // actually giving us. + DCHECK(IsInternalProtectedScheme(scheme)); + + bool set_protocol = job_factory->SetProtocolHandler( + scheme, protocol_handler.release()); + DCHECK(set_protocol); + } +} + +void RegisterInternalHandlers() { + scheme::RegisterChromeHandler(); + scheme::RegisterChromeDevToolsHandler(); +} + +void DidFinishLoad(CefRefPtr frame, const GURL& validated_url) { + if (validated_url.scheme() == chrome::kChromeUIScheme) + scheme::DidFinishChromeLoad(frame, validated_url); +} + +} // namespace scheme diff --git a/cef3/libcef/browser/scheme_registration.h b/cef3/libcef/browser/scheme_registration.h new file mode 100644 index 000000000..43f47508d --- /dev/null +++ b/cef3/libcef/browser/scheme_registration.h @@ -0,0 +1,47 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_SCHEME_REGISTRATION_H_ +#define CEF_LIBCEF_BROWSER_SCHEME_REGISTRATION_H_ +#pragma once + +#include +#include + +#include "include/cef_frame.h" + +#include "content/public/browser/content_browser_client.h" +#include "googleurl/src/gurl.h" + +namespace net { +class URLRequestJobFactoryImpl; +} + +namespace scheme { + +// Add internal standard schemes. +void AddInternalStandardSchemes(std::vector* standard_schemes); + +// Returns true if the specified |scheme| is handled internally and should not +// be explicitly registered or unregistered with the URLRequestJobFactory. A +// registered handler for one of these schemes (like "chrome") may still be +// triggered via chaining from an existing ProtocolHandler. |scheme| should +// always be a lower-case string. +bool IsInternalProtectedScheme(const std::string& scheme); + +// Install the internal scheme handlers provided by Chromium that cannot be +// overridden. +void InstallInternalProtectedHandlers( + net::URLRequestJobFactoryImpl* job_factory, + content::ProtocolHandlerMap* protocol_handlers); + +// Register the internal scheme handlers that can be overridden. +void RegisterInternalHandlers(); + +// Used to fire any asynchronous content updates. +void DidFinishLoad(CefRefPtr frame, const GURL& validated_url); + +} // namespace scheme + +#endif // CEF_LIBCEF_BROWSER_SCHEME_REGISTRATION_H_ diff --git a/cef3/libcef/browser/speech_recognition_manager_delegate.cc b/cef3/libcef/browser/speech_recognition_manager_delegate.cc new file mode 100644 index 000000000..2baef9259 --- /dev/null +++ b/cef3/libcef/browser/speech_recognition_manager_delegate.cc @@ -0,0 +1,217 @@ +// Copyright (c) 2012 The Chromium 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 "libcef/browser/speech_recognition_manager_delegate.h" + +#include +#include + +#include "base/bind.h" +#include "content/public/browser/browser_thread.h" +#include "content/public/browser/notification_observer.h" +#include "content/public/browser/notification_registrar.h" +#include "content/public/browser/notification_source.h" +#include "content/public/browser/notification_types.h" +#include "content/public/browser/render_process_host.h" +#include "content/public/browser/render_view_host.h" +#include "content/public/browser/speech_recognition_manager.h" +#include "content/public/browser/speech_recognition_session_context.h" +#include "content/public/browser/web_contents.h" +#include "content/public/common/speech_recognition_error.h" +#include "content/public/common/speech_recognition_result.h" + +using content::BrowserThread; +using content::SpeechRecognitionManager; +using content::WebContents; + +// Simple utility to get notified when a WebContents is closed or crashes. +// Both the callback site and the callback thread are passed by the caller in +// the constructor. There is no restriction on the constructor, however this +// class must be destroyed on the UI thread, due to the NotificationRegistrar +// dependency. +class CefSpeechRecognitionManagerDelegate::WebContentsWatcher + : public base::RefCountedThreadSafe, + public content::NotificationObserver { + public: + typedef base::Callback + WebContentsClosedCallback; + + WebContentsWatcher(WebContentsClosedCallback web_contents_closed_callback, + BrowserThread::ID callback_thread) + : web_contents_closed_callback_(web_contents_closed_callback), + callback_thread_(callback_thread) { + } + + // Starts monitoring the WebContents corresponding to the given + // |render_process_id|, |render_view_id| pair, invoking + // |web_contents_closed_callback_| if closed/unloaded. + void Watch(int render_process_id, int render_view_id) { + if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( + &WebContentsWatcher::Watch, this, render_process_id, render_view_id)); + return; + } + + WebContents* web_contents = NULL; + content::RenderViewHost* render_view_host = + content::RenderViewHost::FromID(render_process_id, render_view_id); + if (render_view_host) + web_contents = WebContents::FromRenderViewHost(render_view_host); + DCHECK(web_contents); + + // Avoid multiple registrations on |registrar_| for the same |web_contents|. + if (registered_web_contents_.find(web_contents) != + registered_web_contents_.end()) { + return; + } + registered_web_contents_.insert(web_contents); + + // Lazy initialize the registrar. + if (!registrar_.get()) + registrar_.reset(new content::NotificationRegistrar()); + + registrar_->Add(this, + content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, + content::Source(web_contents)); + } + + // content::NotificationObserver implementation. + virtual void Observe(int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) OVERRIDE { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_EQ(content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, type); + + WebContents* web_contents = content::Source(source).ptr(); + int render_process_id = web_contents->GetRenderProcessHost()->GetID(); + int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); + + registrar_->Remove(this, + content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, + content::Source(web_contents)); + registered_web_contents_.erase(web_contents); + + BrowserThread::PostTask(callback_thread_, FROM_HERE, base::Bind( + web_contents_closed_callback_, render_process_id, render_view_id)); + } + + private: + friend class base::RefCountedThreadSafe; + + virtual ~WebContentsWatcher() { + // Must be destroyed on the UI thread due to |registrar_| non thread-safety. + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + } + + // Lazy-initialized and used on the UI thread to handle web contents + // notifications (tab closing). + scoped_ptr registrar_; + + // Keeps track of which WebContent(s) have been registered, in order to avoid + // double registrations on |registrar_| + std::set registered_web_contents_; + + // Callback used to notify, on the thread specified by |callback_thread_| the + // closure of a registered tab. + WebContentsClosedCallback web_contents_closed_callback_; + content::BrowserThread::ID callback_thread_; + + DISALLOW_COPY_AND_ASSIGN(WebContentsWatcher); +}; + +CefSpeechRecognitionManagerDelegate +::CefSpeechRecognitionManagerDelegate() { +} + +CefSpeechRecognitionManagerDelegate +::~CefSpeechRecognitionManagerDelegate() { +} + +void CefSpeechRecognitionManagerDelegate::WebContentsClosedCallback( + int render_process_id, int render_view_id) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + + SpeechRecognitionManager* manager = SpeechRecognitionManager::GetInstance(); + // |manager| becomes NULL if a browser shutdown happens between the post of + // this task (from the UI thread) and this call (on the IO thread). In this + // case we just return. + if (!manager) + return; + + manager->AbortAllSessionsForRenderView(render_process_id, render_view_id); +} + +void CefSpeechRecognitionManagerDelegate::OnRecognitionStart( + int session_id) { + const content::SpeechRecognitionSessionContext& context = + SpeechRecognitionManager::GetInstance()->GetSessionContext(session_id); + + // Register callback to auto abort session on tab closure. + // |web_contents_watcher_| is lazyly istantiated on the first call. + if (!web_contents_watcher_.get()) { + web_contents_watcher_ = new WebContentsWatcher( + base::Bind( + &CefSpeechRecognitionManagerDelegate::WebContentsClosedCallback, + base::Unretained(this)), + BrowserThread::IO); + } + web_contents_watcher_->Watch(context.render_process_id, + context.render_view_id); +} + +void CefSpeechRecognitionManagerDelegate::OnAudioStart(int session_id) { +} + +void CefSpeechRecognitionManagerDelegate::OnEnvironmentEstimationComplete( + int session_id) { +} + +void CefSpeechRecognitionManagerDelegate::OnSoundStart(int session_id) { +} + +void CefSpeechRecognitionManagerDelegate::OnSoundEnd(int session_id) { +} + +void CefSpeechRecognitionManagerDelegate::OnAudioEnd(int session_id) { +} + +void CefSpeechRecognitionManagerDelegate::OnRecognitionResults( + int session_id, const content::SpeechRecognitionResults& result) { +} + +void CefSpeechRecognitionManagerDelegate::OnRecognitionError( + int session_id, const content::SpeechRecognitionError& error) { +} + +void CefSpeechRecognitionManagerDelegate::OnAudioLevelsChange( + int session_id, float volume, float noise_volume) { +} + +void CefSpeechRecognitionManagerDelegate::OnRecognitionEnd(int session_id) { +} + +void CefSpeechRecognitionManagerDelegate::GetDiagnosticInformation( + bool* can_report_metrics, + std::string* hardware_info) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); +} + +void CefSpeechRecognitionManagerDelegate::CheckRecognitionIsAllowed( + int session_id, + base::Callback callback) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + + const content::SpeechRecognitionSessionContext& context = + SpeechRecognitionManager::GetInstance()->GetSessionContext(session_id); + + // Make sure that initiators properly set the |render_process_id| field. + DCHECK_NE(context.render_process_id, 0); + + callback.Run(false, true); +} + +content::SpeechRecognitionEventListener* +CefSpeechRecognitionManagerDelegate::GetEventListener() { + return this; +} diff --git a/cef3/libcef/browser/speech_recognition_manager_delegate.h b/cef3/libcef/browser/speech_recognition_manager_delegate.h new file mode 100644 index 000000000..34cccc02f --- /dev/null +++ b/cef3/libcef/browser/speech_recognition_manager_delegate.h @@ -0,0 +1,61 @@ +// Copyright (c) 2012 The Chromium 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_LIBCEF_BROWSER_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_ +#define CEF_LIBCEF_BROWSER_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_ + +#include "base/compiler_specific.h" +#include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" +#include "content/public/browser/speech_recognition_event_listener.h" +#include "content/public/browser/speech_recognition_manager_delegate.h" + + +// This is CEF's implementation of the SpeechRecognitionManagerDelegate +// interface. Based on chrome/browser/speech/ +// chrome_speech_recognition_manager_delegate.[cc|h] +class CefSpeechRecognitionManagerDelegate + : NON_EXPORTED_BASE(public content::SpeechRecognitionManagerDelegate), + public content::SpeechRecognitionEventListener { + public: + CefSpeechRecognitionManagerDelegate(); + virtual ~CefSpeechRecognitionManagerDelegate(); + + protected: + // SpeechRecognitionEventListener methods. + virtual void OnRecognitionStart(int session_id) OVERRIDE; + virtual void OnAudioStart(int session_id) OVERRIDE; + virtual void OnEnvironmentEstimationComplete(int session_id) OVERRIDE; + virtual void OnSoundStart(int session_id) OVERRIDE; + virtual void OnSoundEnd(int session_id) OVERRIDE; + virtual void OnAudioEnd(int session_id) OVERRIDE; + virtual void OnRecognitionEnd(int session_id) OVERRIDE; + virtual void OnRecognitionResults( + int session_id, const content::SpeechRecognitionResults& result) OVERRIDE; + virtual void OnRecognitionError( + int session_id, const content::SpeechRecognitionError& error) OVERRIDE; + virtual void OnAudioLevelsChange(int session_id, float volume, + float noise_volume) OVERRIDE; + + // SpeechRecognitionManagerDelegate methods. + virtual void GetDiagnosticInformation(bool* can_report_metrics, + std::string* hardware_info) OVERRIDE; + virtual void CheckRecognitionIsAllowed( + int session_id, + base::Callback callback) OVERRIDE; + virtual content::SpeechRecognitionEventListener* GetEventListener() OVERRIDE; + + private: + class WebContentsWatcher; + + // Callback called by |web_contents_watcher_| on the IO thread to signal + // web contents closure. + void WebContentsClosedCallback(int render_process_id, int render_view_id); + + scoped_refptr web_contents_watcher_; + + DISALLOW_COPY_AND_ASSIGN(CefSpeechRecognitionManagerDelegate); +}; + +#endif // CEF_LIBCEF_BROWSER_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_ diff --git a/cef3/libcef/browser/stream_impl.cc b/cef3/libcef/browser/stream_impl.cc new file mode 100644 index 000000000..d095d36d1 --- /dev/null +++ b/cef3/libcef/browser/stream_impl.cc @@ -0,0 +1,309 @@ +// Copyright (c) 2008 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 "libcef/browser/stream_impl.h" +#include +#include "base/logging.h" + +// Static functions + +CefRefPtr CefStreamReader::CreateForFile( + const CefString& fileName) { + CefRefPtr reader; + std::string fileNameStr = fileName; + FILE* file = fopen(fileNameStr.c_str(), "rb"); + if (file) + reader = new CefFileReader(file, true); + return reader; +} + +CefRefPtr CefStreamReader::CreateForData(void* data, + size_t size) { + DCHECK(data != NULL); + DCHECK(size > 0); // NOLINT(readability/check) + CefRefPtr reader; + if (data && size > 0) + reader = new CefBytesReader(data, size, true); + return reader; +} + +CefRefPtr CefStreamReader::CreateForHandler( + CefRefPtr handler) { + DCHECK(handler.get()); + CefRefPtr reader; + if (handler.get()) + reader = new CefHandlerReader(handler); + return reader; +} + +CefRefPtr CefStreamWriter::CreateForFile( + const CefString& fileName) { + DCHECK(!fileName.empty()); + CefRefPtr writer; + std::string fileNameStr = fileName; + FILE* file = fopen(fileNameStr.c_str(), "wb"); + if (file) + writer = new CefFileWriter(file, true); + return writer; +} + +CefRefPtr CefStreamWriter::CreateForHandler( + CefRefPtr handler) { + DCHECK(handler.get()); + CefRefPtr writer; + if (handler.get()) + writer = new CefHandlerWriter(handler); + return writer; +} + + +// CefFileReader + +CefFileReader::CefFileReader(FILE* file, bool close) + : close_(close), file_(file) { +} + +CefFileReader::~CefFileReader() { + AutoLock lock_scope(this); + if (close_) + fclose(file_); +} + +size_t CefFileReader::Read(void* ptr, size_t size, size_t n) { + AutoLock lock_scope(this); + return fread(ptr, size, n, file_); +} + +int CefFileReader::Seek(int64 offset, int whence) { + AutoLock lock_scope(this); +#if defined(OS_WIN) + return _fseeki64(file_, offset, whence); +#else + return fseek(file_, offset, whence); +#endif +} + +int64 CefFileReader::Tell() { + AutoLock lock_scope(this); +#if defined(OS_WIN) + return _ftelli64(file_); +#else + return ftell(file_); +#endif +} + +int CefFileReader::Eof() { + AutoLock lock_scope(this); + return feof(file_); +} + + +// CefFileWriter + +CefFileWriter::CefFileWriter(FILE* file, bool close) + : file_(file), + close_(close) { +} + +CefFileWriter::~CefFileWriter() { + AutoLock lock_scope(this); + if (close_) + fclose(file_); +} + +size_t CefFileWriter::Write(const void* ptr, size_t size, size_t n) { + AutoLock lock_scope(this); + return (size_t)fwrite(ptr, size, n, file_); +} + +int CefFileWriter::Seek(int64 offset, int whence) { + AutoLock lock_scope(this); + return fseek(file_, offset, whence); +} + +int64 CefFileWriter::Tell() { + AutoLock lock_scope(this); + return ftell(file_); +} + +int CefFileWriter::Flush() { + AutoLock lock_scope(this); + return fflush(file_); +} + + +// CefBytesReader + +CefBytesReader::CefBytesReader(void* data, int64 datasize, bool copy) + : data_(NULL), + datasize_(0), + copy_(false), + offset_(0) { + SetData(data, datasize, copy); +} + +CefBytesReader::~CefBytesReader() { + SetData(NULL, 0, false); +} + +size_t CefBytesReader::Read(void* ptr, size_t size, size_t n) { + AutoLock lock_scope(this); + size_t s = (datasize_ - offset_) / size; + size_t ret = (n < s ? n : s); + memcpy(ptr, (reinterpret_cast(data_)) + offset_, ret * size); + offset_ += ret * size; + return ret; +} + +int CefBytesReader::Seek(int64 offset, int whence) { + int rv = -1L; + AutoLock lock_scope(this); + switch (whence) { + case SEEK_CUR: + if (offset_ + offset > datasize_ || offset_ + offset < 0) + break; + offset_ += offset; + rv = 0; + break; + case SEEK_END: { + int64 offset_abs = abs(offset); + if (offset_abs > datasize_) + break; + offset_ = datasize_ - offset_abs; + rv = 0; + break; + } + case SEEK_SET: + if (offset > datasize_ || offset < 0) + break; + offset_ = offset; + rv = 0; + break; + } + + return rv; +} + +int64 CefBytesReader::Tell() { + AutoLock lock_scope(this); + return offset_; +} + +int CefBytesReader::Eof() { + AutoLock lock_scope(this); + return (offset_ >= datasize_); +} + +void CefBytesReader::SetData(void* data, int64 datasize, bool copy) { + AutoLock lock_scope(this); + if (copy_) + free(data_); + + copy_ = copy; + offset_ = 0; + datasize_ = datasize; + + if (copy) { + data_ = malloc(datasize); + DCHECK(data_ != NULL); + if (data_) + memcpy(data_, data, datasize); + } else { + data_ = data; + } +} + + +// CefBytesWriter + +CefBytesWriter::CefBytesWriter(size_t grow) + : grow_(grow), + datasize_(grow), + offset_(0) { + DCHECK(grow > 0); // NOLINT(readability/check) + data_ = malloc(grow); + DCHECK(data_ != NULL); +} + +CefBytesWriter::~CefBytesWriter() { + AutoLock lock_scope(this); + if (data_) + free(data_); +} + +size_t CefBytesWriter::Write(const void* ptr, size_t size, size_t n) { + AutoLock lock_scope(this); + size_t rv; + if (offset_ + static_cast(size * n) >= datasize_ && + Grow(size * n) == 0) { + rv = 0; + } else { + memcpy(reinterpret_cast(data_) + offset_, ptr, size * n); + offset_ += size * n; + rv = n; + } + + return rv; +} + +int CefBytesWriter::Seek(int64 offset, int whence) { + int rv = -1L; + AutoLock lock_scope(this); + switch (whence) { + case SEEK_CUR: + if (offset_ + offset > datasize_ || offset_ + offset < 0) + break; + offset_ += offset; + rv = 0; + break; + case SEEK_END: { + int64 offset_abs = abs(offset); + if (offset_abs > datasize_) + break; + offset_ = datasize_ - offset_abs; + rv = 0; + break; + } + case SEEK_SET: + if (offset > datasize_ || offset < 0) + break; + offset_ = offset; + rv = 0; + break; + } + + return rv; +} + +int64 CefBytesWriter::Tell() { + AutoLock lock_scope(this); + return offset_; +} + +int CefBytesWriter::Flush() { + return 0; +} + +std::string CefBytesWriter::GetDataString() { + AutoLock lock_scope(this); + std::string str(reinterpret_cast(data_), offset_); + return str; +} + +size_t CefBytesWriter::Grow(size_t size) { + AutoLock lock_scope(this); + size_t rv; + size_t s = (size > grow_ ? size : grow_); + void* tmp = realloc(data_, datasize_ + s); + DCHECK(tmp != NULL); + if (tmp) { + data_ = tmp; + datasize_ += s; + rv = datasize_; + } else { + rv = 0; + } + + return rv; +} diff --git a/cef3/libcef/browser/stream_impl.h b/cef3/libcef/browser/stream_impl.h new file mode 100644 index 000000000..0039b9b2f --- /dev/null +++ b/cef3/libcef/browser/stream_impl.h @@ -0,0 +1,154 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_STREAM_IMPL_H_ +#define CEF_LIBCEF_BROWSER_STREAM_IMPL_H_ +#pragma once + +#include +#include +#include "include/cef_stream.h" + +// Implementation of CefStreamReader for files. +class CefFileReader : public CefStreamReader { + public: + CefFileReader(FILE* file, bool close); + virtual ~CefFileReader(); + + virtual size_t Read(void* ptr, size_t size, size_t n) OVERRIDE; + virtual int Seek(int64 offset, int whence) OVERRIDE; + virtual int64 Tell() OVERRIDE; + virtual int Eof() OVERRIDE; + + protected: + bool close_; + FILE* file_; + + IMPLEMENT_REFCOUNTING(CefFileReader); + IMPLEMENT_LOCKING(CefFileReader); +}; + +// Implementation of CefStreamWriter for files. +class CefFileWriter : public CefStreamWriter { + public: + CefFileWriter(FILE* file, bool close); + virtual ~CefFileWriter(); + + virtual size_t Write(const void* ptr, size_t size, size_t n) OVERRIDE; + virtual int Seek(int64 offset, int whence) OVERRIDE; + virtual int64 Tell() OVERRIDE; + virtual int Flush() OVERRIDE; + + protected: + FILE* file_; + bool close_; + + IMPLEMENT_REFCOUNTING(CefFileWriter); + IMPLEMENT_LOCKING(CefFileWriter); +}; + +// Implementation of CefStreamReader for byte buffers. +class CefBytesReader : public CefStreamReader { + public: + CefBytesReader(void* data, int64 datasize, bool copy); + virtual ~CefBytesReader(); + + virtual size_t Read(void* ptr, size_t size, size_t n) OVERRIDE; + virtual int Seek(int64 offset, int whence) OVERRIDE; + virtual int64 Tell() OVERRIDE; + virtual int Eof() OVERRIDE; + + void SetData(void* data, int64 datasize, bool copy); + + void* GetData() { return data_; } + size_t GetDataSize() { return offset_; } + + protected: + void* data_; + int64 datasize_; + bool copy_; + int64 offset_; + + IMPLEMENT_REFCOUNTING(CefBytesReader); + IMPLEMENT_LOCKING(CefBytesReader); +}; + +// Implementation of CefStreamWriter for byte buffers. +class CefBytesWriter : public CefStreamWriter { + public: + explicit CefBytesWriter(size_t grow); + virtual ~CefBytesWriter(); + + virtual size_t Write(const void* ptr, size_t size, size_t n) OVERRIDE; + virtual int Seek(int64 offset, int whence) OVERRIDE; + virtual int64 Tell() OVERRIDE; + virtual int Flush() OVERRIDE; + + void* GetData() { return data_; } + int64 GetDataSize() { return offset_; } + std::string GetDataString(); + + protected: + size_t Grow(size_t size); + + size_t grow_; + void* data_; + int64 datasize_; + int64 offset_; + + IMPLEMENT_REFCOUNTING(CefBytesWriter); + IMPLEMENT_LOCKING(CefBytesWriter); +}; + +// Implementation of CefStreamReader for handlers. +class CefHandlerReader : public CefStreamReader { + public: + explicit CefHandlerReader(CefRefPtr handler) + : handler_(handler) {} + + virtual size_t Read(void* ptr, size_t size, size_t n) OVERRIDE { + return handler_->Read(ptr, size, n); + } + virtual int Seek(int64 offset, int whence) OVERRIDE { + return handler_->Seek(offset, whence); + } + virtual int64 Tell() OVERRIDE { + return handler_->Tell(); + } + virtual int Eof() OVERRIDE { + return handler_->Eof(); + } + + protected: + CefRefPtr handler_; + + IMPLEMENT_REFCOUNTING(CefHandlerReader); +}; + +// Implementation of CefStreamWriter for handlers. +class CefHandlerWriter : public CefStreamWriter { + public: + explicit CefHandlerWriter(CefRefPtr handler) + : handler_(handler) {} + + virtual size_t Write(const void* ptr, size_t size, size_t n) OVERRIDE { + return handler_->Write(ptr, size, n); + } + virtual int Seek(int64 offset, int whence) OVERRIDE { + return handler_->Seek(offset, whence); + } + virtual int64 Tell() OVERRIDE { + return handler_->Tell(); + } + virtual int Flush() OVERRIDE { + return handler_->Flush(); + } + + protected: + CefRefPtr handler_; + + IMPLEMENT_REFCOUNTING(CefHandlerWriter); +}; + +#endif // CEF_LIBCEF_BROWSER_STREAM_IMPL_H_ diff --git a/cef3/libcef/browser/thread_util.h b/cef3/libcef/browser/thread_util.h new file mode 100644 index 000000000..b9286e9e5 --- /dev/null +++ b/cef3/libcef/browser/thread_util.h @@ -0,0 +1,48 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_THREAD_UTIL_H_ +#define CEF_LIBCEF_BROWSER_THREAD_UTIL_H_ +#pragma once + +#include "base/location.h" +#include "base/logging.h" +#include "content/public/browser/browser_thread.h" + +#define CEF_UIT content::BrowserThread::UI +#define CEF_IOT content::BrowserThread::IO +#define CEF_FILET content::BrowserThread::FILE + +#define CEF_CURRENTLY_ON(id) content::BrowserThread::CurrentlyOn(id) +#define CEF_CURRENTLY_ON_UIT() CEF_CURRENTLY_ON(CEF_UIT) +#define CEF_CURRENTLY_ON_IOT() CEF_CURRENTLY_ON(CEF_IOT) +#define CEF_CURRENTLY_ON_FILET() CEF_CURRENTLY_ON(CEF_FILET) + +#define CEF_REQUIRE(id) DCHECK(CEF_CURRENTLY_ON(id)) +#define CEF_REQUIRE_UIT() CEF_REQUIRE(CEF_UIT) +#define CEF_REQUIRE_IOT() CEF_REQUIRE(CEF_IOT) +#define CEF_REQUIRE_FILET() CEF_REQUIRE(CEF_FILET) + +#define CEF_REQUIRE_RETURN(id, var) \ + if (!CEF_CURRENTLY_ON(id)) { \ + NOTREACHED() << "called on invalid thread"; \ + return var; \ + } +#define CEF_REQUIRE_UIT_RETURN(var) CEF_REQUIRE_RETURN(CEF_UIT, var) +#define CEF_REQUIRE_IOT_RETURN(var) CEF_REQUIRE_RETURN(CEF_IOT, var) + +#define CEF_REQUIRE_RETURN_VOID(id) \ + if (!CEF_CURRENTLY_ON(id)) { \ + NOTREACHED() << "called on invalid thread"; \ + return; \ + } +#define CEF_REQUIRE_UIT_RETURN_VOID() CEF_REQUIRE_RETURN_VOID(CEF_UIT) +#define CEF_REQUIRE_IOT_RETURN_VOID() CEF_REQUIRE_RETURN_VOID(CEF_IOT) + +#define CEF_POST_TASK(id, task) \ + content::BrowserThread::PostTask(id, FROM_HERE, task) +#define CEF_POST_DELAYED_TASK(id, task, delay_ms) \ + content::BrowserThread::PostDelayedTask(id, FROM_HERE, task, delay_ms) + +#endif // CEF_LIBCEF_BROWSER_THREAD_UTIL_H_ diff --git a/cef3/libcef/browser/trace_impl.cc b/cef3/libcef/browser/trace_impl.cc new file mode 100644 index 000000000..37f2af425 --- /dev/null +++ b/cef3/libcef/browser/trace_impl.cc @@ -0,0 +1,351 @@ +// 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 "include/cef_trace.h" +#include "include/cef_trace_event.h" +#include "libcef/browser/trace_subscriber.h" +#include "libcef/browser/context.h" +#include "libcef/browser/thread_util.h" + +#include "base/debug/trace_event.h" +#include "base/time.h" + +bool CefBeginTracing(CefRefPtr client, + const CefString& categories) { + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return false; + } + + if (!CEF_CURRENTLY_ON_UIT()) { + NOTREACHED() << "called on invalid thread"; + return false; + } + + CefTraceSubscriber* subscriber = _Context->GetTraceSubscriber(); + if (!subscriber) + return false; + + return subscriber->BeginTracing(client, categories); +} + +bool CefGetTraceBufferPercentFullAsync() { + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return false; + } + + if (!CEF_CURRENTLY_ON_UIT()) { + NOTREACHED() << "called on invalid thread"; + return false; + } + + CefTraceSubscriber* subscriber = _Context->GetTraceSubscriber(); + if (!subscriber) + return false; + + return subscriber->GetTraceBufferPercentFullAsync(); +} + +bool CefEndTracingAsync() { + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return false; + } + + if (!CEF_CURRENTLY_ON_UIT()) { + NOTREACHED() << "called on invalid thread"; + return false; + } + + CefTraceSubscriber* subscriber = _Context->GetTraceSubscriber(); + if (!subscriber) + return false; + + return subscriber->EndTracingAsync(); +} + +int64 CefNowFromSystemTraceTime() { + return base::TimeTicks::NowFromSystemTraceTime().ToInternalValue(); +} + +// The below functions can be called from any process. + +CEF_EXPORT void cef_trace_event(const char* category, + const char* name, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val) { + DCHECK(category); + DCHECK(name); + if (!category || !name) + return; + + if (arg1_name == NULL && arg2_name == NULL) { + TRACE_EVENT0(category, name); + } else if (arg2_name == NULL) { + TRACE_EVENT1(category, name, arg1_name, arg1_val); + } else { + TRACE_EVENT2(category, name, arg1_name, arg1_val, + arg2_name, arg2_val); + } +} + +CEF_EXPORT void cef_trace_event_instant(const char* category, + const char* name, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy) { + DCHECK(category); + DCHECK(name); + if (!category || !name) + return; + + if (copy) { + if (arg1_name == NULL && arg2_name == NULL) { + TRACE_EVENT_COPY_INSTANT0(category, name); + } else if (arg2_name == NULL) { + TRACE_EVENT_COPY_INSTANT1(category, name, arg1_name, arg1_val); + } else { + TRACE_EVENT_COPY_INSTANT2(category, name, arg1_name, arg1_val, + arg2_name, arg2_val); + } + } else { + if (arg1_name == NULL && arg2_name == NULL) { + TRACE_EVENT_INSTANT0(category, name); + } else if (arg2_name == NULL) { + TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val); + } else { + TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, + arg2_name, arg2_val); + } + } +} + +CEF_EXPORT void cef_trace_event_begin(const char* category, + const char* name, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy) { + DCHECK(category); + DCHECK(name); + if (!category || !name) + return; + + if (copy) { + if (arg1_name == NULL && arg2_name == NULL) { + TRACE_EVENT_COPY_BEGIN0(category, name); + } else if (arg2_name == NULL) { + TRACE_EVENT_COPY_BEGIN1(category, name, arg1_name, arg1_val); + } else { + TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, + arg2_name, arg2_val); + } + } else { + if (arg1_name == NULL && arg2_name == NULL) { + TRACE_EVENT_BEGIN0(category, name); + } else if (arg2_name == NULL) { + TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val); + } else { + TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, + arg2_name, arg2_val); + } + } +} + +CEF_EXPORT void cef_trace_event_end(const char* category, + const char* name, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy) { + DCHECK(category); + DCHECK(name); + if (!category || !name) + return; + + if (copy) { + if (arg1_name == NULL && arg2_name == NULL) { + TRACE_EVENT_COPY_END0(category, name); + } else if (arg2_name == NULL) { + TRACE_EVENT_COPY_END1(category, name, arg1_name, arg1_val); + } else { + TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, + arg2_name, arg2_val); + } + } else { + if (arg1_name == NULL && arg2_name == NULL) { + TRACE_EVENT_END0(category, name); + } else if (arg2_name == NULL) { + TRACE_EVENT_END1(category, name, arg1_name, arg1_val); + } else { + TRACE_EVENT_END2(category, name, arg1_name, arg1_val, + arg2_name, arg2_val); + } + } +} + +CEF_EXPORT void cef_trace_counter(const char* category, + const char* name, + const char* value1_name, + uint64 value1_val, + const char* value2_name, + uint64 value2_val, + int copy) { + DCHECK(category); + DCHECK(name); + if (!category || !name) + return; + + if (copy) { + if (value1_name == NULL && value2_name == NULL) { + TRACE_COPY_COUNTER1(category, name, value1_val); + } else { + TRACE_COPY_COUNTER2(category, name, value1_name, value1_val, + value2_name, value2_val); + } + } else { + if (value1_name == NULL && value2_name == NULL) { + TRACE_COUNTER1(category, name, value1_val); + } else { + TRACE_COUNTER2(category, name, value1_name, value1_val, + value2_name, value2_val); + } + } +} + +CEF_EXPORT void cef_trace_counter_id(const char* category, + const char* name, + uint64 id, + const char* value1_name, + uint64 value1_val, + const char* value2_name, + uint64 value2_val, + int copy) { + DCHECK(category); + DCHECK(name); + if (!category || !name) + return; + + if (copy) { + if (value1_name == NULL && value2_name == NULL) { + TRACE_COPY_COUNTER_ID1(category, name, id, value1_val); + } else { + TRACE_COPY_COUNTER_ID2(category, name, id, value1_name, + value1_val, value2_name, value2_val); + } + } else { + if (value1_name == NULL && value2_name == NULL) { + TRACE_COUNTER_ID1(category, name, id, value1_val); + } else { + TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, + value2_name, value2_val); + } + } +} + +CEF_EXPORT void cef_trace_event_async_begin(const char* category, + const char* name, + uint64 id, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy) { + DCHECK(category); + DCHECK(name); + if (!category || !name) + return; + + if (copy) { + if (arg1_name == NULL && arg2_name == NULL) { + TRACE_EVENT_COPY_ASYNC_BEGIN0(category, name, id); + } else if (arg2_name == NULL) { + TRACE_EVENT_COPY_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val); + } else { + TRACE_EVENT_COPY_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, + arg2_name, arg2_val); + } + } else { + if (arg1_name == NULL && arg2_name == NULL) { + TRACE_EVENT_ASYNC_BEGIN0(category, name, id); + } else if (arg2_name == NULL) { + TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val); + } else { + TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, + arg2_name, arg2_val); + } + } +} + +CEF_EXPORT void cef_trace_event_async_step(const char* category, + const char* name, + uint64 id, + uint64 step, + const char* arg1_name, + uint64 arg1_val, + int copy) { + DCHECK(category); + DCHECK(name); + if (!category || !name) + return; + + if (copy) { + if (arg1_name == NULL) { + TRACE_EVENT_COPY_ASYNC_STEP0(category, name, id, step); + } else { + TRACE_EVENT_COPY_ASYNC_STEP1(category, name, id, step, + arg1_name, arg1_val); + } + } else { + if (arg1_name == NULL) { + TRACE_EVENT_ASYNC_STEP0(category, name, id, step); + } else { + TRACE_EVENT_ASYNC_STEP1(category, name, id, step, + arg1_name, arg1_val); + } + } +} + +CEF_EXPORT void cef_trace_event_async_end(const char* category, + const char* name, + uint64 id, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy) { + DCHECK(category); + DCHECK(name); + if (!category || !name) + return; + + if (copy) { + if (arg1_name == NULL && arg2_name == NULL) { + TRACE_EVENT_COPY_ASYNC_END0(category, name, id); + } else if (arg2_name == NULL) { + TRACE_EVENT_COPY_ASYNC_END1(category, name, id, arg1_name, + arg1_val); + } else { + TRACE_EVENT_COPY_ASYNC_END2(category, name, id, arg1_name, + arg1_val, arg2_name, arg2_val); + } + } else { + if (arg1_name == NULL && arg2_name == NULL) { + TRACE_EVENT_ASYNC_END0(category, name, id); + } else if (arg2_name == NULL) { + TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, + arg1_val); + } else { + TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, + arg1_val, arg2_name, arg2_val); + } + } +} diff --git a/cef3/libcef/browser/trace_subscriber.cc b/cef3/libcef/browser/trace_subscriber.cc new file mode 100644 index 000000000..8bcadb735 --- /dev/null +++ b/cef3/libcef/browser/trace_subscriber.cc @@ -0,0 +1,78 @@ +// 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 "libcef/browser/trace_subscriber.h" +#include "include/cef_trace.h" +#include "libcef/browser/thread_util.h" + +#include "content/public/browser/trace_controller.h" + +CefTraceSubscriber::CefTraceSubscriber() + : collecting_trace_data_(false) { + CEF_REQUIRE_UIT(); +} + +CefTraceSubscriber::~CefTraceSubscriber() { + CEF_REQUIRE_UIT(); + if (collecting_trace_data_) + content::TraceController::GetInstance()->CancelSubscriber(this); +} + +bool CefTraceSubscriber::BeginTracing(CefRefPtr client, + const std::string& categories) { + CEF_REQUIRE_UIT(); + + if (collecting_trace_data_) + return false; + + collecting_trace_data_ = true; + client_ = client; + + return content::TraceController::GetInstance()->BeginTracing( + this, categories, base::debug::TraceLog::GetInstance()->trace_options()); +} + +bool CefTraceSubscriber::EndTracingAsync() { + CEF_REQUIRE_UIT(); + + if (!collecting_trace_data_) + return false; + + return content::TraceController::GetInstance()->EndTracingAsync(this); +} + +bool CefTraceSubscriber::GetTraceBufferPercentFullAsync() { + CEF_REQUIRE_UIT(); + + if (!collecting_trace_data_ || !client_.get()) + return false; + + return content::TraceController::GetInstance()-> + GetTraceBufferPercentFullAsync(this); +} + +void CefTraceSubscriber::OnTraceDataCollected( + const scoped_refptr& trace_fragment) { + CEF_REQUIRE_UIT(); + DCHECK(collecting_trace_data_); + if (client_.get()) { + client_->OnTraceDataCollected(trace_fragment->data().c_str(), + trace_fragment->data().size()); + } +} + +void CefTraceSubscriber::OnTraceBufferPercentFullReply(float percent_full) { + CEF_REQUIRE_UIT(); + DCHECK(collecting_trace_data_); + DCHECK(client_.get()); + client_->OnTraceBufferPercentFullReply(percent_full); +} + +void CefTraceSubscriber::OnEndTracingComplete() { + CEF_REQUIRE_UIT(); + DCHECK(collecting_trace_data_); + collecting_trace_data_ = false; + if (client_.get()) + client_->OnEndTracingComplete(); +} diff --git a/cef3/libcef/browser/trace_subscriber.h b/cef3/libcef/browser/trace_subscriber.h new file mode 100644 index 000000000..f76b4a4ec --- /dev/null +++ b/cef3/libcef/browser/trace_subscriber.h @@ -0,0 +1,38 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_TRACE_SUBSCRIBER_H_ +#define CEF_LIBCEF_BROWSER_TRACE_SUBSCRIBER_H_ +#pragma once + +#include "include/cef_trace.h" + +#include "base/debug/trace_event.h" +#include "base/files/file_path.h" +#include "base/memory/scoped_ptr.h" +#include "content/public/browser/trace_subscriber.h" + +// May only be accessed on the browser process UI thread. +class CefTraceSubscriber : public content::TraceSubscriber { + public: + CefTraceSubscriber(); + virtual ~CefTraceSubscriber(); + + bool BeginTracing(CefRefPtr client, + const std::string& categories); + bool GetTraceBufferPercentFullAsync(); + bool EndTracingAsync(); + + private: + // content::TraceSubscriber methods: + virtual void OnTraceDataCollected( + const scoped_refptr& trace_fragment) OVERRIDE; + virtual void OnTraceBufferPercentFullReply(float percent_full) OVERRIDE; + virtual void OnEndTracingComplete() OVERRIDE; + + bool collecting_trace_data_; + CefRefPtr client_; +}; + +#endif // CEF_LIBCEF_BROWSER_TRACE_SUBSCRIBER_H_ diff --git a/cef3/libcef/browser/url_network_delegate.cc b/cef3/libcef/browser/url_network_delegate.cc new file mode 100644 index 000000000..cb52bad80 --- /dev/null +++ b/cef3/libcef/browser/url_network_delegate.cc @@ -0,0 +1,228 @@ +// 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 "libcef/browser/url_network_delegate.h" + +#include + +#include "libcef/browser/browser_host_impl.h" +#include "libcef/browser/thread_util.h" +#include "libcef/common/request_impl.h" + +#include "net/base/net_errors.h" +#include "net/url_request/url_request.h" + +namespace { + +class CefAuthCallbackImpl : public CefAuthCallback { + public: + CefAuthCallbackImpl(const net::NetworkDelegate::AuthCallback& callback, + net::AuthCredentials* credentials) + : callback_(callback), + credentials_(credentials) { + } + ~CefAuthCallbackImpl() { + if (!callback_.is_null()) { + // The auth callback is still pending. Cancel it now. + if (CEF_CURRENTLY_ON_IOT()) { + CancelNow(callback_); + } else { + CEF_POST_TASK(CEF_IOT, + base::Bind(&CefAuthCallbackImpl::CancelNow, callback_)); + } + } + } + + virtual void Continue(const CefString& username, + const CefString& password) OVERRIDE { + if (CEF_CURRENTLY_ON_IOT()) { + if (!callback_.is_null()) { + credentials_->Set(username, password); + callback_.Run(net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_SET_AUTH); + callback_.Reset(); + } + } else { + CEF_POST_TASK(CEF_IOT, + base::Bind(&CefAuthCallbackImpl::Continue, this, username, password)); + } + } + + virtual void Cancel() OVERRIDE { + if (CEF_CURRENTLY_ON_IOT()) { + if (!callback_.is_null()) { + CancelNow(callback_); + callback_.Reset(); + } + } else { + CEF_POST_TASK(CEF_IOT, base::Bind(&CefAuthCallbackImpl::Cancel, this)); + } + } + + void Disconnect() { + callback_.Reset(); + } + + private: + static void CancelNow(const net::NetworkDelegate::AuthCallback& callback) { + CEF_REQUIRE_IOT(); + callback.Run(net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION); + } + + net::NetworkDelegate::AuthCallback callback_; + net::AuthCredentials* credentials_; + + IMPLEMENT_REFCOUNTING(CefAuthCallbackImpl); +}; + +} // namespace + +CefNetworkDelegate::CefNetworkDelegate() { +} + +CefNetworkDelegate::~CefNetworkDelegate() { +} + +int CefNetworkDelegate::OnBeforeURLRequest( + net::URLRequest* request, + const net::CompletionCallback& callback, + GURL* new_url) { + CefRefPtr browser = + CefBrowserHostImpl::GetBrowserForRequest(request); + if (browser.get()) { + CefRefPtr client = browser->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetRequestHandler(); + if (handler.get()) { + CefRefPtr frame = browser->GetFrameForRequest(request); + + GURL old_url = request->url(); + + // Populate the request data. + CefRefPtr requestPtr(new CefRequestImpl()); + requestPtr->Set(request); + + // Give the client an opportunity to cancel the request. + if (handler->OnBeforeResourceLoad(browser.get(), frame, + requestPtr.get())) { + return net::ERR_ABORTED; + } + + GURL url = GURL(std::string(requestPtr->GetURL())); + if (old_url != url) + new_url ->Swap(&url); + + requestPtr->Get(request); + } + } + } + + return net::OK; +} + +int CefNetworkDelegate::OnBeforeSendHeaders( + net::URLRequest* request, + const net::CompletionCallback& callback, + net::HttpRequestHeaders* headers) { + return net::OK; +} + +void CefNetworkDelegate::OnSendHeaders( + net::URLRequest* request, + const net::HttpRequestHeaders& headers) { +} + +int CefNetworkDelegate::OnHeadersReceived( + net::URLRequest* request, + const net::CompletionCallback& callback, + const net::HttpResponseHeaders* original_response_headers, + scoped_refptr* override_response_headers) { + return net::OK; +} + +void CefNetworkDelegate::OnBeforeRedirect(net::URLRequest* request, + const GURL& new_location) { +} + +void CefNetworkDelegate::OnResponseStarted(net::URLRequest* request) { +} + +void CefNetworkDelegate::OnRawBytesRead(const net::URLRequest& request, + int bytes_read) { +} + +void CefNetworkDelegate::OnCompleted(net::URLRequest* request, bool started) { +} + +void CefNetworkDelegate::OnURLRequestDestroyed(net::URLRequest* request) { +} + +void CefNetworkDelegate::OnPACScriptError(int line_number, + const string16& error) { +} + +net::NetworkDelegate::AuthRequiredResponse CefNetworkDelegate::OnAuthRequired( + net::URLRequest* request, + const net::AuthChallengeInfo& auth_info, + const AuthCallback& callback, + net::AuthCredentials* credentials) { + CefRefPtr browser = + CefBrowserHostImpl::GetBrowserForRequest(request); + if (browser.get()) { + CefRefPtr client = browser->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetRequestHandler(); + if (handler.get()) { + CefRefPtr frame = browser->GetFrameForRequest(request); + + CefRefPtr callbackPtr( + new CefAuthCallbackImpl(callback, credentials)); + if (handler->GetAuthCredentials(browser.get(), + frame, + auth_info.is_proxy, + auth_info.challenger.host(), + auth_info.challenger.port(), + auth_info.realm, + auth_info.scheme, + callbackPtr.get())) { + return AUTH_REQUIRED_RESPONSE_IO_PENDING; + } else { + callbackPtr->Disconnect(); + } + } + } + } + + return AUTH_REQUIRED_RESPONSE_NO_ACTION; +} + +bool CefNetworkDelegate::OnCanGetCookies(const net::URLRequest& request, + const net::CookieList& cookie_list) { + return true; +} + +bool CefNetworkDelegate::OnCanSetCookie(const net::URLRequest& request, + const std::string& cookie_line, + net::CookieOptions* options) { + return true; +} + +bool CefNetworkDelegate::OnCanAccessFile(const net::URLRequest& request, + const base::FilePath& path) const { + return true; +} + +bool CefNetworkDelegate::OnCanThrottleRequest( + const net::URLRequest& request) const { + return false; +} + +int CefNetworkDelegate::OnBeforeSocketStreamConnect( + net::SocketStream* socket, + const net::CompletionCallback& callback) { + return net::OK; +} + +void CefNetworkDelegate::OnRequestWaitStateChange(const net::URLRequest& request, + RequestWaitState state) { +} diff --git a/cef3/libcef/browser/url_network_delegate.h b/cef3/libcef/browser/url_network_delegate.h new file mode 100644 index 000000000..587a45d8b --- /dev/null +++ b/cef3/libcef/browser/url_network_delegate.h @@ -0,0 +1,66 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_URL_NETWORK_DELEGATE_H_ +#define CEF_LIBCEF_BROWSER_URL_NETWORK_DELEGATE_H_ +#pragma once + +#include "net/base/network_delegate.h" + +// Used for intercepting resource requests, redirects and responses. The single +// instance of this class is managed by CefURLRequestContextGetter. +class CefNetworkDelegate : public net::NetworkDelegate { + public: + CefNetworkDelegate(); + ~CefNetworkDelegate(); + + private: + // net::NetworkDelegate methods. + virtual int OnBeforeURLRequest(net::URLRequest* request, + const net::CompletionCallback& callback, + GURL* new_url) OVERRIDE; + virtual int OnBeforeSendHeaders(net::URLRequest* request, + const net::CompletionCallback& callback, + net::HttpRequestHeaders* headers) OVERRIDE; + virtual void OnSendHeaders(net::URLRequest* request, + const net::HttpRequestHeaders& headers) OVERRIDE; + virtual int OnHeadersReceived( + net::URLRequest* request, + const net::CompletionCallback& callback, + const net::HttpResponseHeaders* original_response_headers, + scoped_refptr* override_response_headers) + OVERRIDE; + virtual void OnBeforeRedirect(net::URLRequest* request, + const GURL& new_location) OVERRIDE; + virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE; + virtual void OnRawBytesRead(const net::URLRequest& request, int bytes_read) + OVERRIDE; + virtual void OnCompleted(net::URLRequest* request, bool started) OVERRIDE; + virtual void OnURLRequestDestroyed(net::URLRequest* request) OVERRIDE; + virtual void OnPACScriptError(int line_number, const string16& error) + OVERRIDE; + virtual AuthRequiredResponse OnAuthRequired( + net::URLRequest* request, + const net::AuthChallengeInfo& auth_info, + const AuthCallback& callback, + net::AuthCredentials* credentials) OVERRIDE; + virtual bool OnCanGetCookies(const net::URLRequest& request, + const net::CookieList& cookie_list) OVERRIDE; + virtual bool OnCanSetCookie(const net::URLRequest& request, + const std::string& cookie_line, + net::CookieOptions* options) OVERRIDE; + virtual bool OnCanAccessFile(const net::URLRequest& request, + const base::FilePath& path) const OVERRIDE; + virtual bool OnCanThrottleRequest( + const net::URLRequest& request) const OVERRIDE; + virtual int OnBeforeSocketStreamConnect( + net::SocketStream* stream, + const net::CompletionCallback& callback) OVERRIDE; + virtual void OnRequestWaitStateChange(const net::URLRequest& request, + RequestWaitState state) OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(CefNetworkDelegate); +}; + +#endif // CEF_LIBCEF_BROWSER_URL_NETWORK_DELEGATE_H_ diff --git a/cef3/libcef/browser/url_request_context_getter.cc b/cef3/libcef/browser/url_request_context_getter.cc new file mode 100644 index 000000000..3061ae762 --- /dev/null +++ b/cef3/libcef/browser/url_request_context_getter.cc @@ -0,0 +1,320 @@ +// Copyright (c) 2012 The Chromium 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 "libcef/browser/url_request_context_getter.h" + +#if defined(OS_WIN) +#include +#endif +#include +#include + +#include "libcef/browser/context.h" +#include "libcef/browser/scheme_registration.h" +#include "libcef/browser/thread_util.h" +#include "libcef/browser/url_network_delegate.h" +#include "libcef/browser/url_request_context_proxy.h" +#include "libcef/browser/url_request_interceptor.h" +#include "libcef/common/cef_switches.h" + +#include "base/command_line.h" +#include "base/file_util.h" +#include "base/logging.h" +#include "base/stl_util.h" +#include "base/string_util.h" +#include "base/threading/thread_restrictions.h" +#include "base/threading/worker_pool.h" +#include "chrome/browser/net/proxy_service_factory.h" +#include "chrome/browser/net/sqlite_persistent_cookie_store.h" +#include "content/public/browser/browser_thread.h" +#include "content/public/common/content_switches.h" +#include "content/public/common/url_constants.h" +#include "net/base/cert_verifier.h" +#include "net/cookies/cookie_monster.h" +#include "net/dns/host_resolver.h" +#include "net/ftp/ftp_network_layer.h" +#include "net/http/http_auth_handler_factory.h" +#include "net/http/http_cache.h" +#include "net/http/http_server_properties_impl.h" +#include "net/proxy/proxy_service.h" +#include "net/ssl/default_server_bound_cert_store.h" +#include "net/ssl/server_bound_cert_service.h" +#include "net/ssl/ssl_config_service_defaults.h" +#include "net/url_request/static_http_user_agent_settings.h" +#include "net/url_request/url_request.h" +#include "net/url_request/url_request_context.h" +#include "net/url_request/url_request_context_storage.h" +#include "net/url_request/url_request_job_factory_impl.h" +#include "net/url_request/url_request_job_manager.h" + +using content::BrowserThread; + +#if defined(OS_WIN) +#pragma comment(lib, "winhttp.lib") +#endif + +CefURLRequestContextGetter::CefURLRequestContextGetter( + MessageLoop* io_loop, + MessageLoop* file_loop, + content::ProtocolHandlerMap* protocol_handlers) + : io_loop_(io_loop), + file_loop_(file_loop) { + // Must first be created on the UI thread. + CEF_REQUIRE_UIT(); + + std::swap(protocol_handlers_, *protocol_handlers); +} + +CefURLRequestContextGetter::~CefURLRequestContextGetter() { + CEF_REQUIRE_IOT(); + STLDeleteElements(&url_request_context_proxies_); +} + +net::URLRequestContext* CefURLRequestContextGetter::GetURLRequestContext() { + CEF_REQUIRE_IOT(); + + if (!url_request_context_.get()) { + const base::FilePath& cache_path = _Context->cache_path(); + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + const CefSettings& settings = _Context->settings(); + + url_request_context_.reset(new net::URLRequestContext()); + storage_.reset( + new net::URLRequestContextStorage(url_request_context_.get())); + + bool persist_session_cookies = + (settings.persist_session_cookies || + command_line.HasSwitch(switches::kPersistSessionCookies)); + SetCookieStoragePath(cache_path, persist_session_cookies); + + storage_->set_network_delegate(new CefNetworkDelegate); + + storage_->set_server_bound_cert_service(new net::ServerBoundCertService( + new net::DefaultServerBoundCertStore(NULL), + base::WorkerPool::GetTaskRunner(true))); + storage_->set_http_user_agent_settings( + new net::StaticHttpUserAgentSettings("en-us,en", EmptyString())); + + storage_->set_host_resolver(net::HostResolver::CreateDefaultResolver(NULL)); + storage_->set_cert_verifier(net::CertVerifier::CreateDefault()); + + scoped_ptr system_proxy_service; + system_proxy_service.reset( + ProxyServiceFactory::CreateProxyService( + NULL, + url_request_context_.get(), + url_request_context_->network_delegate(), + _Context->proxy_config_service().release(), + command_line)); + storage_->set_proxy_service(system_proxy_service.release()); + + storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults); + + // Add support for single sign-on. + url_security_manager_.reset(net::URLSecurityManager::Create(NULL, NULL)); + + std::vector supported_schemes; + supported_schemes.push_back("basic"); + supported_schemes.push_back("digest"); + supported_schemes.push_back("ntlm"); + supported_schemes.push_back("negotiate"); + + storage_->set_http_auth_handler_factory( + net::HttpAuthHandlerRegistryFactory::Create( + supported_schemes, + url_security_manager_.get(), + url_request_context_->host_resolver(), + std::string(), + false, + false)); + storage_->set_http_server_properties(new net::HttpServerPropertiesImpl); + + net::HttpCache::DefaultBackend* main_backend = + new net::HttpCache::DefaultBackend( + cache_path.empty() ? net::MEMORY_CACHE : net::DISK_CACHE, + cache_path, + 0, + BrowserThread::GetMessageLoopProxyForThread( + BrowserThread::CACHE)); + + net::HttpNetworkSession::Params network_session_params; + network_session_params.host_resolver = + url_request_context_->host_resolver(); + network_session_params.cert_verifier = + url_request_context_->cert_verifier(); + network_session_params.server_bound_cert_service = + url_request_context_->server_bound_cert_service(); + network_session_params.proxy_service = + url_request_context_->proxy_service(); + network_session_params.ssl_config_service = + url_request_context_->ssl_config_service(); + network_session_params.http_auth_handler_factory = + url_request_context_->http_auth_handler_factory(); + network_session_params.network_delegate = + url_request_context_->network_delegate(); + network_session_params.http_server_properties = + url_request_context_->http_server_properties(); + network_session_params.ignore_certificate_errors = + (settings.ignore_certificate_errors || + command_line.HasSwitch(switches::kIgnoreCertificateErrors)); + + net::HttpCache* main_cache = new net::HttpCache(network_session_params, + main_backend); + storage_->set_http_transaction_factory(main_cache); + + storage_->set_ftp_transaction_factory( + new net::FtpNetworkLayer(url_request_context_->host_resolver())); + + scoped_ptr job_factory( + new net::URLRequestJobFactoryImpl()); + job_factory_impl_ = job_factory.get(); + + scheme::InstallInternalProtectedHandlers(job_factory.get(), + &protocol_handlers_); + protocol_handlers_.clear(); + + storage_->set_job_factory(job_factory.release()); + + request_interceptor_.reset(new CefRequestInterceptor); + } + + return url_request_context_.get(); +} + +scoped_refptr + CefURLRequestContextGetter::GetNetworkTaskRunner() const { + return BrowserThread::GetMessageLoopProxyForThread(CEF_IOT); +} + +net::HostResolver* CefURLRequestContextGetter::host_resolver() { + return url_request_context_->host_resolver(); +} + +void CefURLRequestContextGetter::SetCookieStoragePath( + const base::FilePath& path, + bool persist_session_cookies) { + CEF_REQUIRE_IOT(); + + if (url_request_context_->cookie_store() && + ((cookie_store_path_.empty() && path.empty()) || + cookie_store_path_ == path)) { + // The path has not changed so don't do anything. + return; + } + + scoped_refptr persistent_store; + if (!path.empty()) { + // TODO(cef): Move directory creation to the blocking pool instead of + // allowing file IO on this thread. + base::ThreadRestrictions::ScopedAllowIO allow_io; + if (file_util::DirectoryExists(path) || + file_util::CreateDirectory(path)) { + const base::FilePath& cookie_path = path.AppendASCII("Cookies"); + persistent_store = + new SQLitePersistentCookieStore( + cookie_path, + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), + persist_session_cookies, + NULL); + } else { + NOTREACHED() << "The cookie storage directory could not be created"; + } + } + + // Set the new cookie store that will be used for all new requests. The old + // cookie store, if any, will be automatically flushed and closed when no + // longer referenced. + scoped_refptr cookie_monster = + new net::CookieMonster(persistent_store.get(), NULL); + storage_->set_cookie_store(cookie_monster); + if (persistent_store.get() && persist_session_cookies) + cookie_monster->SetPersistSessionCookies(true); + cookie_store_path_ = path; + + // Restore the previously supported schemes. + SetCookieSupportedSchemes(cookie_supported_schemes_); +} + +void CefURLRequestContextGetter::SetCookieSupportedSchemes( + const std::vector& schemes) { + CEF_REQUIRE_IOT(); + + cookie_supported_schemes_ = schemes; + + if (cookie_supported_schemes_.empty()) { + cookie_supported_schemes_.push_back("http"); + cookie_supported_schemes_.push_back("https"); + } + + std::set scheme_set; + std::vector::const_iterator it = + cookie_supported_schemes_.begin(); + for (; it != cookie_supported_schemes_.end(); ++it) + scheme_set.insert(*it); + + const char** arr = new const char*[scheme_set.size()]; + std::set::const_iterator it2 = scheme_set.begin(); + for (int i = 0; it2 != scheme_set.end(); ++it2, ++i) + arr[i] = it2->c_str(); + + url_request_context_->cookie_store()->GetCookieMonster()-> + SetCookieableSchemes(arr, scheme_set.size()); + + delete [] arr; +} + +CefURLRequestContextProxy* + CefURLRequestContextGetter::CreateURLRequestContextProxy() { + CEF_REQUIRE_IOT(); + CefURLRequestContextProxy* proxy = new CefURLRequestContextProxy(this); + url_request_context_proxies_.insert(proxy); + return proxy; +} + +void CefURLRequestContextGetter::ReleaseURLRequestContextProxy( + CefURLRequestContextProxy* proxy) { + CEF_REQUIRE_IOT(); + + // Don't do anything if we're currently shutting down. The proxy objects will + // be deleted when this object is destroyed. + if (_Context->shutting_down()) + return; + + if (proxy->url_requests()->size() == 0) { + // Safe to delete the proxy. + RequestContextProxySet::iterator it = + url_request_context_proxies_.find(proxy); + DCHECK(it != url_request_context_proxies_.end()); + url_request_context_proxies_.erase(it); + delete proxy; + } else { + proxy->increment_delete_try_count(); + if (proxy->delete_try_count() <= 1) { + // Cancel the pending requests. This may result in additional tasks being + // posted on the IO thread. + std::set::iterator it = + proxy->url_requests()->begin(); + for (; it != proxy->url_requests()->end(); ++it) + const_cast(*it)->Cancel(); + + // Try to delete the proxy again later. + CEF_POST_TASK(CEF_IOT, + base::Bind(&CefURLRequestContextGetter::ReleaseURLRequestContextProxy, + this, proxy)); + } else { + NOTREACHED() << + "too many retries to delete URLRequestContext proxy object"; + } + } +} + +void CefURLRequestContextGetter::CreateProxyConfigService() { + if (proxy_config_service_.get()) + return; + + proxy_config_service_.reset( + net::ProxyService::CreateSystemProxyConfigService( + io_loop_->message_loop_proxy(), file_loop_)); +} diff --git a/cef3/libcef/browser/url_request_context_getter.h b/cef3/libcef/browser/url_request_context_getter.h new file mode 100644 index 000000000..53ab23232 --- /dev/null +++ b/cef3/libcef/browser/url_request_context_getter.h @@ -0,0 +1,126 @@ +// Copyright (c) 2011 The Chromium 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_LIBCEF_BROWSER_URL_REQUEST_CONTEXT_GETTER_H_ +#define CEF_LIBCEF_BROWSER_URL_REQUEST_CONTEXT_GETTER_H_ +#pragma once + +#include +#include +#include + +#include "base/compiler_specific.h" +#include "base/files/file_path.h" +#include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" +#include "content/public/browser/content_browser_client.h" +#include "net/url_request/url_request_context_getter.h" +#include "net/url_request/url_request_job_factory.h" + +class CefRequestInterceptor; +class CefURLRequestContextProxy; +class MessageLoop; + +namespace net { +class HostResolver; +class ProxyConfigService; +class URLRequestContextStorage; +class URLRequestJobFactory; +class URLRequestJobFactoryImpl; +class URLSecurityManager; +} + +/* +// Classes used in network request processing: +// +// RC = net::URLRequestContext +// Owns various network-related objects including the global cookie manager. +// +// RCP = CefURLRequestContextProxy +// Creates the CSP and forwards requests to the objects owned by RC. +// +// CSP = CefCookieStoreProxy +// Gives the CefCookieManager associated with CefBrowserHostImpl an +// opportunity to handle cookie requests. Otherwise forwards requests via RC +// to the global cookie manager. +// +// RCG = CefURLRequestContextGetter +// Creates the RC and manages RCP lifespan. +// +// RCGP = CefURLRequestContextGetterProxy +// Causes the RCG to create and destroy browser-specific RCPs. +// +// Relationship diagram: +// ref = reference (scoped_refptr) +// own = ownership (scoped_ptr) +// ptr = raw pointer +// +// global cookie manager, etc... +// ^ +// | +// /-own-> RC <-ptr-\ +// / \ +// / /<-ptr-\ \ +// / / \ \ +// CefBrowserContext -ref-> RCG --own-> RCP --ref-> CSP +// ^ ^ / +// ref ptr / +// | / / +// CefBrowserHostImpl -ref-> RCGP----/ / +// ^ / +// \-ref--------------------------/ +*/ + +class CefURLRequestContextGetter : public net::URLRequestContextGetter { + public: + CefURLRequestContextGetter( + MessageLoop* io_loop, + MessageLoop* file_loop, + content::ProtocolHandlerMap* protocol_handlers); + virtual ~CefURLRequestContextGetter(); + + // net::URLRequestContextGetter implementation. + virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; + virtual scoped_refptr + GetNetworkTaskRunner() const OVERRIDE; + + net::HostResolver* host_resolver(); + net::URLRequestJobFactoryImpl* job_factory_impl() const { + return job_factory_impl_; + } + + void SetCookieStoragePath(const base::FilePath& path, + bool persist_session_cookies); + void SetCookieSupportedSchemes(const std::vector& schemes); + + // Manage URLRequestContext proxy objects. It's important that proxy objects + // not be destroyed while any in-flight URLRequests exist. These methods + // manage that requirement. + CefURLRequestContextProxy* CreateURLRequestContextProxy(); + void ReleaseURLRequestContextProxy(CefURLRequestContextProxy* proxy); + + private: + void CreateProxyConfigService(); + + MessageLoop* io_loop_; + MessageLoop* file_loop_; + + scoped_ptr proxy_config_service_; + scoped_ptr request_interceptor_; + scoped_ptr storage_; + scoped_ptr url_request_context_; + scoped_ptr url_security_manager_; + content::ProtocolHandlerMap protocol_handlers_; + net::URLRequestJobFactoryImpl* job_factory_impl_; + + typedef std::set RequestContextProxySet; + RequestContextProxySet url_request_context_proxies_; + + base::FilePath cookie_store_path_; + std::vector cookie_supported_schemes_; + + DISALLOW_COPY_AND_ASSIGN(CefURLRequestContextGetter); +}; + +#endif // CEF_LIBCEF_BROWSER_URL_REQUEST_CONTEXT_GETTER_H_ diff --git a/cef3/libcef/browser/url_request_context_getter_proxy.cc b/cef3/libcef/browser/url_request_context_getter_proxy.cc new file mode 100644 index 000000000..866f05010 --- /dev/null +++ b/cef3/libcef/browser/url_request_context_getter_proxy.cc @@ -0,0 +1,39 @@ +// 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 "libcef/browser/url_request_context_getter_proxy.h" +#include "libcef/browser/thread_util.h" +#include "libcef/browser/url_request_context_getter.h" +#include "libcef/browser/url_request_context_proxy.h" + +CefURLRequestContextGetterProxy::CefURLRequestContextGetterProxy( + CefBrowserHostImpl* browser, + CefURLRequestContextGetter* parent) + : browser_(browser), + parent_(parent), + context_proxy_(NULL) { + DCHECK(browser); + DCHECK(parent); +} + +CefURLRequestContextGetterProxy::~CefURLRequestContextGetterProxy() { + CEF_REQUIRE_IOT(); + if (context_proxy_) + parent_->ReleaseURLRequestContextProxy(context_proxy_); +} + +net::URLRequestContext* + CefURLRequestContextGetterProxy::GetURLRequestContext() { + CEF_REQUIRE_IOT(); + if (!context_proxy_) { + context_proxy_ = parent_->CreateURLRequestContextProxy(); + context_proxy_->Initialize(browser_); + } + return context_proxy_; +} + +scoped_refptr + CefURLRequestContextGetterProxy::GetNetworkTaskRunner() const { + return parent_->GetNetworkTaskRunner(); +} diff --git a/cef3/libcef/browser/url_request_context_getter_proxy.h b/cef3/libcef/browser/url_request_context_getter_proxy.h new file mode 100644 index 000000000..ec6555145 --- /dev/null +++ b/cef3/libcef/browser/url_request_context_getter_proxy.h @@ -0,0 +1,37 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_URL_REQUEST_CONTEXT_GETTER_PROXY_H_ +#define CEF_LIBCEF_BROWSER_URL_REQUEST_CONTEXT_GETTER_PROXY_H_ +#pragma once + +#include "base/memory/scoped_ptr.h" +#include "net/url_request/url_request_context_getter.h" + +class CefBrowserHostImpl; +class CefURLRequestContextGetter; +class CefURLRequestContextProxy; + +class CefURLRequestContextGetterProxy : public net::URLRequestContextGetter { + public: + CefURLRequestContextGetterProxy(CefBrowserHostImpl* browser, + CefURLRequestContextGetter* parent); + virtual ~CefURLRequestContextGetterProxy(); + + // net::URLRequestContextGetter implementation. + virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; + virtual scoped_refptr + GetNetworkTaskRunner() const OVERRIDE; + + private: + CefBrowserHostImpl* browser_; + scoped_refptr parent_; + + // The |context_proxy_| object is owned by |parent_|. + CefURLRequestContextProxy* context_proxy_; + + DISALLOW_COPY_AND_ASSIGN(CefURLRequestContextGetterProxy); +}; + +#endif // CEF_LIBCEF_BROWSER_URL_REQUEST_CONTEXT_GETTER_PROXY_H_ diff --git a/cef3/libcef/browser/url_request_context_proxy.cc b/cef3/libcef/browser/url_request_context_proxy.cc new file mode 100644 index 000000000..1a2c89cd2 --- /dev/null +++ b/cef3/libcef/browser/url_request_context_proxy.cc @@ -0,0 +1,155 @@ +// 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 "libcef/browser/url_request_context_proxy.h" + +#include + +#include "libcef/browser/browser_host_impl.h" +#include "libcef/browser/cookie_manager_impl.h" +#include "libcef/browser/thread_util.h" + +#include "base/logging.h" +#include "base/message_loop_proxy.h" +#include "net/cookies/cookie_store.h" +#include "net/url_request/url_request_context_getter.h" + +namespace { + +class CefCookieStoreProxy : public net::CookieStore { + public: + explicit CefCookieStoreProxy(CefBrowserHostImpl* browser, + net::URLRequestContext* parent) + : parent_(parent), + browser_(browser) { + } + virtual ~CefCookieStoreProxy() { + CEF_REQUIRE_IOT(); + } + + // net::CookieStore methods. + virtual void SetCookieWithOptionsAsync( + const GURL& url, + const std::string& cookie_line, + const net::CookieOptions& options, + const SetCookiesCallback& callback) OVERRIDE { + scoped_refptr cookie_store = GetCookieStore(); + cookie_store->SetCookieWithOptionsAsync(url, cookie_line, options, + callback); + } + + virtual void GetCookiesWithOptionsAsync( + const GURL& url, const net::CookieOptions& options, + const GetCookiesCallback& callback) OVERRIDE { + scoped_refptr cookie_store = GetCookieStore(); + cookie_store->GetCookiesWithOptionsAsync(url, options, callback); + } + + virtual void DeleteCookieAsync(const GURL& url, + const std::string& cookie_name, + const base::Closure& callback) OVERRIDE { + scoped_refptr cookie_store = GetCookieStore(); + cookie_store->DeleteCookieAsync(url, cookie_name, callback); + } + + virtual void DeleteAllCreatedBetweenAsync(const base::Time& delete_begin, + const base::Time& delete_end, + const DeleteCallback& callback) + OVERRIDE { + scoped_refptr cookie_store = GetCookieStore(); + cookie_store->DeleteAllCreatedBetweenAsync(delete_begin, delete_end, + callback); + } + + virtual void DeleteSessionCookiesAsync(const DeleteCallback& callback) + OVERRIDE { + scoped_refptr cookie_store = GetCookieStore(); + cookie_store->DeleteSessionCookiesAsync(callback); + } + + virtual net::CookieMonster* GetCookieMonster() OVERRIDE { + scoped_refptr cookie_store = GetCookieStore(); + return cookie_store->GetCookieMonster(); + } + + private: + net::CookieStore* GetCookieStore() { + CEF_REQUIRE_IOT(); + + scoped_refptr cookie_store; + + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetRequestHandler(); + if (handler.get()) { + // Get the manager from the handler. + CefRefPtr manager = + handler->GetCookieManager(browser_.get(), + browser_->GetLoadingURL().spec()); + if (manager.get()) { + cookie_store = + reinterpret_cast( + manager.get())->cookie_monster(); + DCHECK(cookie_store); + } + } + } + + if (!cookie_store) { + // Use the global cookie store. + cookie_store = parent_->cookie_store(); + } + + DCHECK(cookie_store); + return cookie_store; + } + + // This pointer is guaranteed by the CefRequestContextProxy object. + net::URLRequestContext* parent_; + CefRefPtr browser_; + + DISALLOW_COPY_AND_ASSIGN(CefCookieStoreProxy); +}; + +} // namespace + + +CefURLRequestContextProxy::CefURLRequestContextProxy( + net::URLRequestContextGetter* parent) + : parent_(parent), + delete_try_count_(0) { +} + +CefURLRequestContextProxy::~CefURLRequestContextProxy() { + CEF_REQUIRE_IOT(); +} + +void CefURLRequestContextProxy::Initialize(CefBrowserHostImpl* browser) { + CEF_REQUIRE_IOT(); + + net::URLRequestContext* context = parent_->GetURLRequestContext(); + + // Cookie store that proxies to the browser implementation. + cookie_store_proxy_ = new CefCookieStoreProxy(browser, context); + set_cookie_store(cookie_store_proxy_); + + // All other values refer to the parent request context. + set_net_log(context->net_log()); + set_host_resolver(context->host_resolver()); + set_cert_verifier(context->cert_verifier()); + set_server_bound_cert_service(context->server_bound_cert_service()); + set_fraudulent_certificate_reporter( + context->fraudulent_certificate_reporter()); + set_proxy_service(context->proxy_service()); + set_ssl_config_service(context->ssl_config_service()); + set_http_auth_handler_factory(context->http_auth_handler_factory()); + set_http_transaction_factory(context->http_transaction_factory()); + set_ftp_transaction_factory(context->ftp_transaction_factory()); + set_network_delegate(context->network_delegate()); + set_http_server_properties(context->http_server_properties()); + set_transport_security_state(context->transport_security_state()); + set_http_user_agent_settings(const_cast( + context->http_user_agent_settings())); + set_job_factory(context->job_factory()); +} diff --git a/cef3/libcef/browser/url_request_context_proxy.h b/cef3/libcef/browser/url_request_context_proxy.h new file mode 100644 index 000000000..b4b188829 --- /dev/null +++ b/cef3/libcef/browser/url_request_context_proxy.h @@ -0,0 +1,41 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_URL_REQUEST_CONTEXT_PROXY_H_ +#define CEF_LIBCEF_BROWSER_URL_REQUEST_CONTEXT_PROXY_H_ +#pragma once + +#include "base/memory/scoped_ptr.h" +#include "net/url_request/url_request_context.h" + +class CefBrowserHostImpl; + +namespace net { +class CookieStore; +class URLRequestContextGetter; +} + +class CefURLRequestContextProxy : public net::URLRequestContext { + public: + explicit CefURLRequestContextProxy(net::URLRequestContextGetter* parent); + virtual ~CefURLRequestContextProxy(); + + void Initialize(CefBrowserHostImpl* browser); + + // We may try to delete this proxy multiple times if URLRequests are still + // pending. Keep track of the number of tries so that they don't become + // excessive. + int delete_try_count() const { return delete_try_count_; } + void increment_delete_try_count() { delete_try_count_++; } + + private: + net::URLRequestContextGetter* parent_; + scoped_refptr cookie_store_proxy_; + + int delete_try_count_; + + DISALLOW_COPY_AND_ASSIGN(CefURLRequestContextProxy); +}; + +#endif // CEF_LIBCEF_BROWSER_URL_REQUEST_CONTEXT_PROXY_H_ diff --git a/cef3/libcef/browser/url_request_interceptor.cc b/cef3/libcef/browser/url_request_interceptor.cc new file mode 100644 index 000000000..becb553bf --- /dev/null +++ b/cef3/libcef/browser/url_request_interceptor.cc @@ -0,0 +1,93 @@ +// 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 "libcef/browser/url_request_interceptor.h" + +#include + +#include "libcef/browser/browser_host_impl.h" +#include "libcef/browser/resource_request_job.h" +#include "libcef/browser/thread_util.h" +#include "libcef/common/request_impl.h" + +#include "net/url_request/url_request_job_manager.h" +#include "net/url_request/url_request_redirect_job.h" + +CefRequestInterceptor::CefRequestInterceptor() { + CEF_REQUIRE_IOT(); + net::URLRequestJobManager::GetInstance()->RegisterRequestInterceptor(this); +} + +CefRequestInterceptor::~CefRequestInterceptor() { + CEF_REQUIRE_IOT(); + net::URLRequestJobManager::GetInstance()-> + UnregisterRequestInterceptor(this); +} + +net::URLRequestJob* CefRequestInterceptor::MaybeIntercept( + net::URLRequest* request, + net::NetworkDelegate* network_delegate) { + CefRefPtr browser = + CefBrowserHostImpl::GetBrowserForRequest(request); + if (browser.get()) { + CefRefPtr client = browser->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetRequestHandler(); + if (handler.get()) { + CefRefPtr frame = browser->GetFrameForRequest(request); + + // Populate the request data. + CefRefPtr req(CefRequest::Create()); + static_cast(req.get())->Set(request); + + // Give the client an opportunity to replace the request. + CefRefPtr resourceHandler = + handler->GetResourceHandler(browser.get(), frame, req); + if (resourceHandler.get()) + return new CefResourceRequestJob(request, network_delegate, + resourceHandler); + } + } + } + + return NULL; +} + +net::URLRequestJob* CefRequestInterceptor::MaybeInterceptRedirect( + net::URLRequest* request, + net::NetworkDelegate* network_delegate, + const GURL& location) { + CefRefPtr browser = + CefBrowserHostImpl::GetBrowserForRequest(request); + if (browser.get()) { + CefRefPtr client = browser->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetRequestHandler(); + if (handler.get()) { + CefRefPtr frame = browser->GetFrameForRequest(request); + + // Give the client an opportunity to redirect the request. + CefString newUrlStr = location.spec(); + handler->OnResourceRedirect(browser.get(), frame, request->url().spec(), + newUrlStr); + if (newUrlStr != location.spec()) { + GURL new_url = GURL(std::string(newUrlStr)); + if (!new_url.is_empty() && new_url.is_valid()) { + return new net::URLRequestRedirectJob( + request, network_delegate, new_url, + net::URLRequestRedirectJob::REDIRECT_302_FOUND); + } + } + } + } + } + + return NULL; +} + +net::URLRequestJob* CefRequestInterceptor::MaybeInterceptResponse( + net::URLRequest* request, + net::NetworkDelegate* network_delegate) { + return NULL; +} diff --git a/cef3/libcef/browser/url_request_interceptor.h b/cef3/libcef/browser/url_request_interceptor.h new file mode 100644 index 000000000..6dacc7e15 --- /dev/null +++ b/cef3/libcef/browser/url_request_interceptor.h @@ -0,0 +1,33 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_URL_REQUEST_INTERCEPTOR_H_ +#define CEF_LIBCEF_BROWSER_URL_REQUEST_INTERCEPTOR_H_ +#pragma once + +#include "net/url_request/url_request.h" + +// Used for intercepting resource requests, redirects and responses. The single +// instance of this class is managed by CefURLRequestContextGetter. +class CefRequestInterceptor : public net::URLRequest::Interceptor { + public: + CefRequestInterceptor(); + ~CefRequestInterceptor(); + + // net::URLRequest::Interceptor methods. + virtual net::URLRequestJob* MaybeIntercept( + net::URLRequest* request, + net::NetworkDelegate* network_delegate) OVERRIDE; + virtual net::URLRequestJob* MaybeInterceptRedirect( + net::URLRequest* request, + net::NetworkDelegate* network_delegate, + const GURL& location) OVERRIDE; + virtual net::URLRequestJob* MaybeInterceptResponse( + net::URLRequest* request, + net::NetworkDelegate* network_delegate) OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(CefRequestInterceptor); +}; + +#endif // CEF_LIBCEF_BROWSER_URL_REQUEST_INTERCEPTOR_H_ diff --git a/cef3/libcef/browser/web_contents_view_osr.cc b/cef3/libcef/browser/web_contents_view_osr.cc new file mode 100644 index 000000000..91af0eb1b --- /dev/null +++ b/cef3/libcef/browser/web_contents_view_osr.cc @@ -0,0 +1,136 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 The Chromium 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 "libcef/browser/render_widget_host_view_osr.h" +#include "libcef/browser/web_contents_view_osr.h" + +#include "content/public/browser/render_widget_host.h" +#include "content/public/browser/web_contents.h" + +CefWebContentsViewOSR::CefWebContentsViewOSR( + content::WebContents* web_contents, + content::WebContentsViewDelegate* delegate) + : web_contents_(web_contents), + view_(NULL) { +} + +CefWebContentsViewOSR::~CefWebContentsViewOSR() { +} + +// Overridden from WebContentsView: + +void CefWebContentsViewOSR::CreateView(const gfx::Size& initial_size, + gfx::NativeView context) { +} + +content::RenderWidgetHostView* CefWebContentsViewOSR::CreateViewForWidget( + content::RenderWidgetHost* render_widget_host) { + if (render_widget_host->GetView()) + return render_widget_host->GetView(); + + view_ = new CefRenderWidgetHostViewOSR(render_widget_host); + return view_; +} + +content::RenderWidgetHostView* CefWebContentsViewOSR::CreateViewForPopupWidget( + content::RenderWidgetHost* render_widget_host) { + CefRenderWidgetHostViewOSR* popup_widget = + new CefRenderWidgetHostViewOSR(render_widget_host); + return popup_widget; +} + +gfx::NativeView CefWebContentsViewOSR::GetNativeView() const { + return gfx::NativeView(); +} + +gfx::NativeView CefWebContentsViewOSR::GetContentNativeView() const { + return gfx::NativeView(); +} + +gfx::NativeWindow CefWebContentsViewOSR::GetTopLevelNativeWindow() const { + return gfx::NativeWindow(); +} + + +void CefWebContentsViewOSR::GetContainerBounds(gfx::Rect *out) const { + *out = GetViewBounds(); +} + +void CefWebContentsViewOSR::SetPageTitle(const string16& title) { +} + +void CefWebContentsViewOSR::OnTabCrashed(base::TerminationStatus status, + int error_code) { + view_ = NULL; +} + +void CefWebContentsViewOSR::SizeContents(const gfx::Size& size) { +} + +void CefWebContentsViewOSR::RenderViewCreated(content::RenderViewHost* host) { + if (view_) { + CefRenderWidgetHostViewOSR* osr_view = + static_cast(view_); + osr_view->InstallTransparency(); + } +} + +void CefWebContentsViewOSR::RenderViewSwappedIn(content::RenderViewHost* host) { +} + +void CefWebContentsViewOSR::SetOverscrollControllerEnabled(bool enabled) { +} + +void CefWebContentsViewOSR::Focus() { +} + +void CefWebContentsViewOSR::SetInitialFocus() { +} + +void CefWebContentsViewOSR::StoreFocus() { +} + +void CefWebContentsViewOSR::RestoreFocus() { +} + +WebDropData* CefWebContentsViewOSR::GetDropData() const { + return NULL; +} + +gfx::Rect CefWebContentsViewOSR::GetViewBounds() const { + return view_ ? view_->GetViewBounds() : gfx::Rect(); +} + +#if defined(OS_MACOSX) +bool CefWebContentsViewOSR::IsEventTracking() const { + return false; +} + +void CefWebContentsViewOSR::CloseTabAfterEventTracking() { +} + +void CefWebContentsViewOSR::SetAllowOverlappingViews(bool overlapping) { +} +#endif // defined(OS_MACOSX) + +// RenderViewHostDelegateView methods. + +void CefWebContentsViewOSR::StartDragging(const WebDropData& drop_data, + WebKit::WebDragOperationsMask allowed_ops, + const gfx::ImageSkia& image, + const gfx::Vector2d& image_offset, + const content::DragEventSourceInfo& event_info) { + // Dragging is not supported when window rendering is disabled. + web_contents_->SystemDragEnded(); +} + +void CefWebContentsViewOSR::ShowPopupMenu(const gfx::Rect& bounds, + int item_height, + double item_font_size, + int selected_item, + const std::vector& items, + bool right_aligned, + bool allow_multiple_selection) { +} diff --git a/cef3/libcef/browser/web_contents_view_osr.h b/cef3/libcef/browser/web_contents_view_osr.h new file mode 100644 index 000000000..48898345c --- /dev/null +++ b/cef3/libcef/browser/web_contents_view_osr.h @@ -0,0 +1,80 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 The Chromium 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_LIBCEF_BROWSER_WEB_CONTENTS_VIEW_OSR_H_ +#define CEF_LIBCEF_BROWSER_WEB_CONTENTS_VIEW_OSR_H_ + +#include + +#include "content/port/browser/render_view_host_delegate_view.h" +#include "content/port/browser/web_contents_view_port.h" + +namespace content { +class WebContents; +class WebContentsViewDelegate; +} + +class CefBrowserHostImpl; + +// An implementation of WebContentsView for off-screen rendering. +class CefWebContentsViewOSR : public content::WebContentsViewPort, + public content::RenderViewHostDelegateView { + public: + CefWebContentsViewOSR(content::WebContents* web_contents, + content::WebContentsViewDelegate* delegate); + virtual ~CefWebContentsViewOSR(); + + // WebContentsView methods. + virtual void CreateView(const gfx::Size& initial_size, + gfx::NativeView context) OVERRIDE; + virtual content::RenderWidgetHostView* CreateViewForWidget( + content::RenderWidgetHost* render_widget_host) OVERRIDE; + virtual content::RenderWidgetHostView* CreateViewForPopupWidget( + content::RenderWidgetHost* render_widget_host); + virtual gfx::NativeView GetNativeView() const OVERRIDE; + virtual gfx::NativeView GetContentNativeView() const OVERRIDE; + virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; + virtual void GetContainerBounds(gfx::Rect *out) const OVERRIDE; + virtual void SetPageTitle(const string16& title) OVERRIDE; + virtual void OnTabCrashed(base::TerminationStatus status, + int error_code) OVERRIDE; + virtual void SizeContents(const gfx::Size& size) OVERRIDE; + virtual void RenderViewCreated(content::RenderViewHost* host) OVERRIDE; + virtual void RenderViewSwappedIn(content::RenderViewHost* host) OVERRIDE; + virtual void SetOverscrollControllerEnabled(bool enabled) OVERRIDE; + virtual void Focus() OVERRIDE; + virtual void SetInitialFocus() OVERRIDE; + virtual void StoreFocus() OVERRIDE; + virtual void RestoreFocus() OVERRIDE; + virtual WebDropData* GetDropData() const OVERRIDE; + virtual gfx::Rect GetViewBounds() const OVERRIDE; +#if defined(OS_MACOSX) + virtual bool IsEventTracking() const OVERRIDE; + virtual void CloseTabAfterEventTracking() OVERRIDE; + virtual void SetAllowOverlappingViews(bool overlapping) OVERRIDE; +#endif + + // RenderViewHostDelegateView methods. + virtual void StartDragging(const WebDropData& drop_data, + WebKit::WebDragOperationsMask allowed_ops, + const gfx::ImageSkia& image, + const gfx::Vector2d& image_offset, + const content::DragEventSourceInfo& event_info) OVERRIDE; + virtual void ShowPopupMenu(const gfx::Rect& bounds, + int item_height, + double item_font_size, + int selected_item, + const std::vector& items, + bool right_aligned, + bool allow_multiple_selection) OVERRIDE; + + private: + content::WebContents* web_contents_; + content::RenderWidgetHostView* view_; + + DISALLOW_COPY_AND_ASSIGN(CefWebContentsViewOSR); +}; + +#endif // CEF_LIBCEF_BROWSER_WEB_CONTENTS_VIEW_OSR_H_ diff --git a/cef3/libcef/browser/web_plugin_impl.cc b/cef3/libcef/browser/web_plugin_impl.cc new file mode 100644 index 000000000..367d4675a --- /dev/null +++ b/cef3/libcef/browser/web_plugin_impl.cc @@ -0,0 +1,224 @@ +// 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 "libcef/browser/web_plugin_impl.h" +#include "libcef/browser/context.h" +#include "libcef/browser/thread_util.h" + +#include "base/bind.h" +#include "base/files/file_path.h" +#include "content/browser/plugin_service_impl.h" + +namespace { + +void PluginsCallbackImpl( + CefRefPtr visitor, + const std::vector& all_plugins) { + CEF_REQUIRE_UIT(); + + int count = 0; + int total = static_cast(all_plugins.size()); + + std::vector::const_iterator it = all_plugins.begin(); + for (; it != all_plugins.end(); ++it, ++count) { + CefRefPtr info(new CefWebPluginInfoImpl(*it)); + if (!visitor->Visit(info.get(), count, total)) + break; + } +} + +} // namespace + + +// CefWebPluginInfoImpl + +CefWebPluginInfoImpl::CefWebPluginInfoImpl( + const webkit::WebPluginInfo& plugin_info) + : plugin_info_(plugin_info) { +} + +CefString CefWebPluginInfoImpl::GetName() { + return plugin_info_.name; +} + +CefString CefWebPluginInfoImpl::GetPath() { + return plugin_info_.path.value(); +} + +CefString CefWebPluginInfoImpl::GetVersion() { + return plugin_info_.version; +} + +CefString CefWebPluginInfoImpl::GetDescription() { + return plugin_info_.desc; +} + + +// Global functions. + +void CefVisitWebPluginInfo(CefRefPtr visitor) { + // Verify that the context is in a valid state. + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return; + } + + if (!visitor.get()) { + NOTREACHED() << "invalid parameter"; + return; + } + + if (CEF_CURRENTLY_ON_UIT()) { + content::PluginServiceImpl::GetInstance()->GetPlugins( + base::Bind(PluginsCallbackImpl, visitor)); + } else { + // Execute on the UI thread. + CEF_POST_TASK(CEF_UIT, base::Bind(CefVisitWebPluginInfo, visitor)); + } +} + +void CefRefreshWebPlugins() { + // Verify that the context is in a valid state. + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return; + } + + // No thread affinity. + content::PluginServiceImpl::GetInstance()->RefreshPlugins(); +} + +void CefAddWebPluginPath(const CefString& path) { + // Verify that the context is in a valid state. + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return; + } + + if (path.empty()) { + NOTREACHED() << "invalid parameter"; + return; + } + + // No thread affinity. + content::PluginServiceImpl::GetInstance()->AddExtraPluginPath( + base::FilePath(path)); +} + +void CefAddWebPluginDirectory(const CefString& dir) { + // Verify that the context is in a valid state. + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return; + } + + if (dir.empty()) { + NOTREACHED() << "invalid parameter"; + return; + } + + // No thread affinity. + content::PluginServiceImpl::GetInstance()->AddExtraPluginDir( + base::FilePath(dir)); +} + +void CefRemoveWebPluginPath(const CefString& path) { + // Verify that the context is in a valid state. + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return; + } + + if (path.empty()) { + NOTREACHED() << "invalid parameter"; + return; + } + + // No thread affinity. + content::PluginServiceImpl::GetInstance()->RemoveExtraPluginPath( + base::FilePath(path)); +} + +void CefUnregisterInternalWebPlugin(const CefString& path) { + // Verify that the context is in a valid state. + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return; + } + + if (path.empty()) { + NOTREACHED() << "invalid parameter"; + return; + } + + // No thread affinity. + content::PluginServiceImpl::GetInstance()->UnregisterInternalPlugin( + base::FilePath(path)); +} + +void CefForceWebPluginShutdown(const CefString& path) { + // Verify that the context is in a valid state. + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return; + } + + if (path.empty()) { + NOTREACHED() << "invalid parameter"; + return; + } + + if (CEF_CURRENTLY_ON_IOT()) { + content::PluginServiceImpl::GetInstance()->ForcePluginShutdown( + base::FilePath(path)); + } else { + // Execute on the IO thread. + CEF_POST_TASK(CEF_IOT, base::Bind(CefForceWebPluginShutdown, path)); + } +} + +void CefRegisterWebPluginCrash(const CefString& path) { + // Verify that the context is in a valid state. + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return; + } + + if (path.empty()) { + NOTREACHED() << "invalid parameter"; + return; + } + + if (CEF_CURRENTLY_ON_IOT()) { + content::PluginServiceImpl::GetInstance()->RegisterPluginCrash( + base::FilePath(path)); + } else { + // Execute on the IO thread. + CEF_POST_TASK(CEF_IOT, base::Bind(CefRegisterWebPluginCrash, path)); + } +} + +void CefIsWebPluginUnstable( + const CefString& path, + CefRefPtr callback) { + // Verify that the context is in a valid state. + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return; + } + + if (path.empty() || !callback.get()) { + NOTREACHED() << "invalid parameter"; + return; + } + + if (CEF_CURRENTLY_ON_IOT()) { + callback->IsUnstable(path, + content::PluginServiceImpl::GetInstance()->IsPluginUnstable( + base::FilePath(path))); + } else { + // Execute on the IO thread. + CEF_POST_TASK(CEF_IOT, base::Bind(CefIsWebPluginUnstable, path, callback)); + } +} diff --git a/cef3/libcef/browser/web_plugin_impl.h b/cef3/libcef/browser/web_plugin_impl.h new file mode 100644 index 000000000..4ec9c87be --- /dev/null +++ b/cef3/libcef/browser/web_plugin_impl.h @@ -0,0 +1,27 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_WEB_PLUGIN_IMPL_H_ +#define CEF_LIBCEF_BROWSER_WEB_PLUGIN_IMPL_H_ +#pragma once + +#include "include/cef_web_plugin.h" +#include "webkit/plugins/webplugininfo.h" + +class CefWebPluginInfoImpl : public CefWebPluginInfo { + public: + explicit CefWebPluginInfoImpl(const webkit::WebPluginInfo& plugin_info); + + virtual CefString GetName() OVERRIDE; + virtual CefString GetPath() OVERRIDE; + virtual CefString GetVersion() OVERRIDE; + virtual CefString GetDescription() OVERRIDE; + + private: + webkit::WebPluginInfo plugin_info_; + + IMPLEMENT_REFCOUNTING(CefWebPluginInfoImpl); +}; + +#endif // CEF_LIBCEF_BROWSER_WEB_PLUGIN_IMPL_H_ diff --git a/cef3/libcef/browser/xml_reader_impl.cc b/cef3/libcef/browser/xml_reader_impl.cc new file mode 100644 index 000000000..b66ea6326 --- /dev/null +++ b/cef3/libcef/browser/xml_reader_impl.cc @@ -0,0 +1,446 @@ +// 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 "libcef/browser/xml_reader_impl.h" +#include "include/cef_stream.h" +#include "base/logging.h" + +// Static functions + +// static +CefRefPtr CefXmlReader::Create(CefRefPtr stream, + EncodingType encodingType, + const CefString& URI) { + CefRefPtr impl(new CefXmlReaderImpl()); + if (!impl->Initialize(stream, encodingType, URI)) + return NULL; + return impl.get(); +} + + +// CefXmlReaderImpl + +namespace { + +/** + * xmlInputReadCallback: + * @context: an Input context + * @buffer: the buffer to store data read + * @len: the length of the buffer in bytes + * + * Callback used in the I/O Input API to read the resource + * + * Returns the number of bytes read or -1 in case of error + */ +int XMLCALL xml_read_callback(void * context, char * buffer, int len) { + CefRefPtr reader(static_cast(context)); + return reader->Read(buffer, 1, len); +} + +/** + * xmlTextReaderErrorFunc: + * @arg: the user argument + * @msg: the message + * @severity: the severity of the error + * @locator: a locator indicating where the error occured + * + * Signature of an error callback from a reader parser + */ +void XMLCALL xml_error_callback(void *arg, const char *msg, + xmlParserSeverities severity, + xmlTextReaderLocatorPtr locator) { + if (!msg) + return; + + std::string error_str(msg); + if (!error_str.empty() && error_str[error_str.length()-1] == '\n') + error_str.resize(error_str.length()-1); + + std::stringstream ss; + ss << error_str << ", line " << xmlTextReaderLocatorLineNumber(locator); + + LOG(INFO) << ss.str(); + + CefRefPtr impl(static_cast(arg)); + impl->AppendError(ss.str()); +} + +/** + * xmlStructuredErrorFunc: + * @userData: user provided data for the error callback + * @error: the error being raised. + * + * Signature of the function to use when there is an error and + * the module handles the new error reporting mechanism. + */ +void XMLCALL xml_structured_error_callback(void *userData, xmlErrorPtr error) { + if (!error->message) + return; + + std::string error_str(error->message); + if (!error_str.empty() && error_str[error_str.length()-1] == '\n') + error_str.resize(error_str.length()-1); + + std::stringstream ss; + ss << error_str << ", line " << error->line; + + LOG(INFO) << ss.str(); + + CefRefPtr impl(static_cast(userData)); + impl->AppendError(ss.str()); +} + +CefString xmlCharToString(const xmlChar* xmlStr, bool free) { + if (!xmlStr) + return CefString(); + + const char* str = reinterpret_cast(xmlStr); + CefString wstr = std::string(str); + + if (free) + xmlFree(const_cast(xmlStr)); + + return wstr; +} + +} // namespace + +CefXmlReaderImpl::CefXmlReaderImpl() + : supported_thread_id_(base::PlatformThread::CurrentId()), reader_(NULL) { +} + +CefXmlReaderImpl::~CefXmlReaderImpl() { + if (reader_ != NULL) { + if (!VerifyContext()) { + // Close() is supposed to be called directly. We'll try to free the reader + // now on the wrong thread but there's no guarantee this call won't crash. + xmlFreeTextReader(reader_); + } else { + Close(); + } + } +} + +bool CefXmlReaderImpl::Initialize(CefRefPtr stream, + EncodingType encodingType, + const CefString& URI) { + xmlCharEncoding enc = XML_CHAR_ENCODING_NONE; + switch (encodingType) { + case XML_ENCODING_UTF8: + enc = XML_CHAR_ENCODING_UTF8; + break; + case XML_ENCODING_UTF16LE: + enc = XML_CHAR_ENCODING_UTF16LE; + break; + case XML_ENCODING_UTF16BE: + enc = XML_CHAR_ENCODING_UTF16BE; + break; + case XML_ENCODING_ASCII: + enc = XML_CHAR_ENCODING_ASCII; + break; + default: + break; + } + + // Create the input buffer. + xmlParserInputBufferPtr input_buffer = xmlAllocParserInputBuffer(enc); + if (!input_buffer) + return false; + + input_buffer->context = stream.get(); + input_buffer->readcallback = xml_read_callback; + + // Create the text reader. + std::string uriStr = URI; + reader_ = xmlNewTextReader(input_buffer, uriStr.c_str()); + if (!reader_) { + // Free the input buffer. + xmlFreeParserInputBuffer(input_buffer); + return false; + } + + // Keep a reference to the stream. + stream_ = stream; + + // Register the error callbacks. + xmlTextReaderSetErrorHandler(reader_, xml_error_callback, this); + xmlTextReaderSetStructuredErrorHandler(reader_, + xml_structured_error_callback, this); + + return true; +} + +bool CefXmlReaderImpl::MoveToNextNode() { + if (!VerifyContext()) + return false; + + return xmlTextReaderRead(reader_) == 1 ? true : false; +} + +bool CefXmlReaderImpl::Close() { + if (!VerifyContext()) + return false; + + // The input buffer will be freed automatically. + xmlFreeTextReader(reader_); + reader_ = NULL; + return true; +} + +bool CefXmlReaderImpl::HasError() { + if (!VerifyContext()) + return false; + + return !error_buf_.str().empty(); +} + +CefString CefXmlReaderImpl::GetError() { + if (!VerifyContext()) + return CefString(); + + return error_buf_.str(); +} + +CefXmlReader::NodeType CefXmlReaderImpl::GetType() { + if (!VerifyContext()) + return XML_NODE_UNSUPPORTED; + + switch (xmlTextReaderNodeType(reader_)) { + case XML_READER_TYPE_ELEMENT: + return XML_NODE_ELEMENT_START; + case XML_READER_TYPE_END_ELEMENT: + return XML_NODE_ELEMENT_END; + case XML_READER_TYPE_ATTRIBUTE: + return XML_NODE_ATTRIBUTE; + case XML_READER_TYPE_TEXT: + return XML_NODE_TEXT; + case XML_READER_TYPE_SIGNIFICANT_WHITESPACE: + case XML_READER_TYPE_WHITESPACE: + return XML_NODE_WHITESPACE; + case XML_READER_TYPE_CDATA: + return XML_NODE_CDATA; + case XML_READER_TYPE_ENTITY_REFERENCE: + return XML_NODE_ENTITY_REFERENCE; + case XML_READER_TYPE_PROCESSING_INSTRUCTION: + return XML_NODE_PROCESSING_INSTRUCTION; + case XML_READER_TYPE_COMMENT: + return XML_NODE_COMMENT; + case XML_READER_TYPE_DOCUMENT_TYPE: + return XML_NODE_DOCUMENT_TYPE; + default: + break; + } + + return XML_NODE_UNSUPPORTED; +} + +int CefXmlReaderImpl::GetDepth() { + if (!VerifyContext()) + return -1; + + return xmlTextReaderDepth(reader_); +} + +CefString CefXmlReaderImpl::GetLocalName() { + if (!VerifyContext()) + return CefString(); + + return xmlCharToString(xmlTextReaderConstLocalName(reader_), false); +} + +CefString CefXmlReaderImpl::GetPrefix() { + if (!VerifyContext()) + return CefString(); + + return xmlCharToString(xmlTextReaderConstPrefix(reader_), false); +} + +CefString CefXmlReaderImpl::GetQualifiedName() { + if (!VerifyContext()) + return CefString(); + + return xmlCharToString(xmlTextReaderConstName(reader_), false); +} + +CefString CefXmlReaderImpl::GetNamespaceURI() { + if (!VerifyContext()) + return CefString(); + + return xmlCharToString(xmlTextReaderConstNamespaceUri(reader_), false); +} + +CefString CefXmlReaderImpl::GetBaseURI() { + if (!VerifyContext()) + return CefString(); + + return xmlCharToString(xmlTextReaderConstBaseUri(reader_), false); +} + +CefString CefXmlReaderImpl::GetXmlLang() { + if (!VerifyContext()) + return CefString(); + + return xmlCharToString(xmlTextReaderConstXmlLang(reader_), false); +} + +bool CefXmlReaderImpl::IsEmptyElement() { + if (!VerifyContext()) + return false; + + return xmlTextReaderIsEmptyElement(reader_) == 1 ? true : false; +} + +bool CefXmlReaderImpl::HasValue() { + if (!VerifyContext()) + return false; + + if (xmlTextReaderNodeType(reader_) == XML_READER_TYPE_ENTITY_REFERENCE) { + // Provide special handling to return entity reference values. + return true; + } else { + return xmlTextReaderHasValue(reader_) == 1 ? true : false; + } +} + +CefString CefXmlReaderImpl::GetValue() { + if (!VerifyContext()) + return CefString(); + + if (xmlTextReaderNodeType(reader_) == XML_READER_TYPE_ENTITY_REFERENCE) { + // Provide special handling to return entity reference values. + xmlNodePtr node = xmlTextReaderCurrentNode(reader_); + if (node->content != NULL) + return xmlCharToString(node->content, false); + return CefString(); + } else { + return xmlCharToString(xmlTextReaderConstValue(reader_), false); + } +} + +bool CefXmlReaderImpl::HasAttributes() { + if (!VerifyContext()) + return false; + + return xmlTextReaderHasAttributes(reader_) == 1 ? true : false; +} + +size_t CefXmlReaderImpl::GetAttributeCount() { + if (!VerifyContext()) + return 0; + + return xmlTextReaderAttributeCount(reader_); +} + +CefString CefXmlReaderImpl::GetAttribute(int index) { + if (!VerifyContext()) + return CefString(); + + return xmlCharToString(xmlTextReaderGetAttributeNo(reader_, index), true); +} + +CefString CefXmlReaderImpl::GetAttribute(const CefString& qualifiedName) { + if (!VerifyContext()) + return CefString(); + + std::string qualifiedNameStr = qualifiedName; + return xmlCharToString(xmlTextReaderGetAttribute(reader_, + BAD_CAST qualifiedNameStr.c_str()), true); +} + +CefString CefXmlReaderImpl::GetAttribute(const CefString& localName, + const CefString& namespaceURI) { + if (!VerifyContext()) + return CefString(); + + std::string localNameStr = localName; + std::string namespaceURIStr = namespaceURI; + return xmlCharToString(xmlTextReaderGetAttributeNs(reader_, + BAD_CAST localNameStr.c_str(), BAD_CAST namespaceURIStr.c_str()), true); +} + +CefString CefXmlReaderImpl::GetInnerXml() { + if (!VerifyContext()) + return CefString(); + + return xmlCharToString(xmlTextReaderReadInnerXml(reader_), true); +} + +CefString CefXmlReaderImpl::GetOuterXml() { + if (!VerifyContext()) + return CefString(); + + return xmlCharToString(xmlTextReaderReadOuterXml(reader_), true); +} + +int CefXmlReaderImpl::GetLineNumber() { + if (!VerifyContext()) + return -1; + + return xmlTextReaderGetParserLineNumber(reader_); +} + +bool CefXmlReaderImpl::MoveToAttribute(int index) { + if (!VerifyContext()) + return false; + + return xmlTextReaderMoveToAttributeNo(reader_, index) == 1 ? true : false; +} + +bool CefXmlReaderImpl::MoveToAttribute(const CefString& qualifiedName) { + if (!VerifyContext()) + return false; + + std::string qualifiedNameStr = qualifiedName; + return xmlTextReaderMoveToAttribute(reader_, + BAD_CAST qualifiedNameStr.c_str()) == 1 ? true : false; +} + +bool CefXmlReaderImpl::MoveToAttribute(const CefString& localName, + const CefString& namespaceURI) { + if (!VerifyContext()) + return false; + + std::string localNameStr = localName; + std::string namespaceURIStr = namespaceURI; + return xmlTextReaderMoveToAttributeNs(reader_, + BAD_CAST localNameStr.c_str(), BAD_CAST namespaceURIStr.c_str()) == 1 ? + true : false; +} + +bool CefXmlReaderImpl::MoveToFirstAttribute() { + if (!VerifyContext()) + return false; + + return xmlTextReaderMoveToFirstAttribute(reader_) == 1 ? true : false; +} + +bool CefXmlReaderImpl::MoveToNextAttribute() { + if (!VerifyContext()) + return false; + + return xmlTextReaderMoveToNextAttribute(reader_) == 1 ? true : false; +} + +bool CefXmlReaderImpl::MoveToCarryingElement() { + if (!VerifyContext()) + return false; + + return xmlTextReaderMoveToElement(reader_) == 1 ? true : false; +} + +void CefXmlReaderImpl::AppendError(const CefString& error_str) { + if (!error_buf_.str().empty()) + error_buf_ << L"\n"; + error_buf_ << error_str; +} + +bool CefXmlReaderImpl::VerifyContext() { + if (base::PlatformThread::CurrentId() != supported_thread_id_) { + // This object should only be accessed from the thread that created it. + NOTREACHED(); + return false; + } + + return (reader_ != NULL); +} diff --git a/cef3/libcef/browser/xml_reader_impl.h b/cef3/libcef/browser/xml_reader_impl.h new file mode 100644 index 000000000..b81733ca3 --- /dev/null +++ b/cef3/libcef/browser/xml_reader_impl.h @@ -0,0 +1,73 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_XML_READER_IMPL_H_ +#define CEF_LIBCEF_BROWSER_XML_READER_IMPL_H_ +#pragma once + +#include +#include + +#include "include/cef_xml_reader.h" +#include "base/threading/platform_thread.h" + +// Implementation of CefXmlReader +class CefXmlReaderImpl : public CefXmlReader { + public: + CefXmlReaderImpl(); + ~CefXmlReaderImpl(); + + // Initialize the reader context. + bool Initialize(CefRefPtr stream, + EncodingType encodingType, const CefString& URI); + + virtual bool MoveToNextNode() OVERRIDE; + virtual bool Close() OVERRIDE; + virtual bool HasError() OVERRIDE; + virtual CefString GetError() OVERRIDE; + virtual NodeType GetType() OVERRIDE; + virtual int GetDepth() OVERRIDE; + virtual CefString GetLocalName() OVERRIDE; + virtual CefString GetPrefix() OVERRIDE; + virtual CefString GetQualifiedName() OVERRIDE; + virtual CefString GetNamespaceURI() OVERRIDE; + virtual CefString GetBaseURI() OVERRIDE; + virtual CefString GetXmlLang() OVERRIDE; + virtual bool IsEmptyElement() OVERRIDE; + virtual bool HasValue() OVERRIDE; + virtual CefString GetValue() OVERRIDE; + virtual bool HasAttributes() OVERRIDE; + virtual size_t GetAttributeCount() OVERRIDE; + virtual CefString GetAttribute(int index) OVERRIDE; + virtual CefString GetAttribute(const CefString& qualifiedName) OVERRIDE; + virtual CefString GetAttribute(const CefString& localName, + const CefString& namespaceURI) OVERRIDE; + virtual CefString GetInnerXml() OVERRIDE; + virtual CefString GetOuterXml() OVERRIDE; + virtual int GetLineNumber() OVERRIDE; + virtual bool MoveToAttribute(int index) OVERRIDE; + virtual bool MoveToAttribute(const CefString& qualifiedName) OVERRIDE; + virtual bool MoveToAttribute(const CefString& localName, + const CefString& namespaceURI) OVERRIDE; + virtual bool MoveToFirstAttribute() OVERRIDE; + virtual bool MoveToNextAttribute() OVERRIDE; + virtual bool MoveToCarryingElement() OVERRIDE; + + // Add another line to the error string. + void AppendError(const CefString& error_str); + + // Verify that the reader exists and is being accessed from the correct + // thread. + bool VerifyContext(); + + protected: + base::PlatformThreadId supported_thread_id_; + CefRefPtr stream_; + xmlTextReaderPtr reader_; + std::stringstream error_buf_; + + IMPLEMENT_REFCOUNTING(CefXMLReaderImpl); +}; + +#endif // CEF_LIBCEF_BROWSER_XML_READER_IMPL_H_ diff --git a/cef3/libcef/browser/zip_reader_impl.cc b/cef3/libcef/browser/zip_reader_impl.cc new file mode 100644 index 000000000..dca92ae36 --- /dev/null +++ b/cef3/libcef/browser/zip_reader_impl.cc @@ -0,0 +1,280 @@ +// 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 "libcef/browser/zip_reader_impl.h" +#include +#include "include/cef_stream.h" +#include "base/logging.h" + +// Static functions + +// static +CefRefPtr CefZipReader::Create( + CefRefPtr stream) { + CefRefPtr impl(new CefZipReaderImpl()); + if (!impl->Initialize(stream)) + return NULL; + return impl.get(); +} + + +// CefZipReaderImpl + +namespace { + +voidpf ZCALLBACK zlib_open_callback OF((voidpf opaque, const void* filename, + int mode)) { + // The stream is already implicitly open so just return the pointer. + return opaque; +} + +uLong ZCALLBACK zlib_read_callback OF((voidpf opaque, voidpf stream, void* buf, + uLong size)) { + CefRefPtr reader(static_cast(opaque)); + return reader->Read(buf, 1, size); +} + +ZPOS64_T ZCALLBACK zlib_tell_callback OF((voidpf opaque, voidpf stream)) { + CefRefPtr reader(static_cast(opaque)); + return reader->Tell(); +} + +long ZCALLBACK zlib_seek_callback OF((voidpf opaque, // NOLINT(runtime/int) + voidpf stream, ZPOS64_T offset, + int origin)) { + CefRefPtr reader(static_cast(opaque)); + int whence; + switch (origin) { + case ZLIB_FILEFUNC_SEEK_CUR: + whence = SEEK_CUR; + break; + case ZLIB_FILEFUNC_SEEK_END: + whence = SEEK_END; + break; + case ZLIB_FILEFUNC_SEEK_SET: + whence = SEEK_SET; + break; + default: + NOTREACHED(); + return -1; + } + return reader->Seek(offset, whence); +} + +int ZCALLBACK zlib_close_callback OF((voidpf opaque, voidpf stream)) { + CefRefPtr reader(static_cast(opaque)); + // Release the reference added by CefZipReaderImpl::Initialize(). + reader->Release(); + return 0; +} + +int ZCALLBACK zlib_error_callback OF((voidpf opaque, voidpf stream)) { + return 0; +} + +} // namespace + +CefZipReaderImpl::CefZipReaderImpl() + : supported_thread_id_(base::PlatformThread::CurrentId()), reader_(NULL), + has_fileopen_(false), + has_fileinfo_(false), + filesize_(0), + filemodified_(0) { +} + +CefZipReaderImpl::~CefZipReaderImpl() { + if (reader_ != NULL) { + if (!VerifyContext()) { + // Close() is supposed to be called directly. We'll try to free the reader + // now on the wrong thread but there's no guarantee this call won't crash. + if (has_fileopen_) + unzCloseCurrentFile(reader_); + unzClose(reader_); + } else { + Close(); + } + } +} + +bool CefZipReaderImpl::Initialize(CefRefPtr stream) { + zlib_filefunc64_def filefunc_def; + filefunc_def.zopen64_file = zlib_open_callback; + filefunc_def.zread_file = zlib_read_callback; + filefunc_def.zwrite_file = NULL; + filefunc_def.ztell64_file = zlib_tell_callback; + filefunc_def.zseek64_file = zlib_seek_callback; + filefunc_def.zclose_file = zlib_close_callback; + filefunc_def.zerror_file = zlib_error_callback; + filefunc_def.opaque = stream.get(); + + // Add a reference that will be released by zlib_close_callback(). + stream->AddRef(); + + reader_ = unzOpen2_64("", &filefunc_def); + return (reader_ != NULL); +} + +bool CefZipReaderImpl::MoveToFirstFile() { + if (!VerifyContext()) + return false; + + if (has_fileopen_) + CloseFile(); + + has_fileinfo_ = false; + + return (unzGoToFirstFile(reader_) == UNZ_OK); +} + +bool CefZipReaderImpl::MoveToNextFile() { + if (!VerifyContext()) + return false; + + if (has_fileopen_) + CloseFile(); + + has_fileinfo_ = false; + + return (unzGoToNextFile(reader_) == UNZ_OK); +} + +bool CefZipReaderImpl::MoveToFile(const CefString& fileName, + bool caseSensitive) { + if (!VerifyContext()) + return false; + + if (has_fileopen_) + CloseFile(); + + has_fileinfo_ = false; + + std::string fileNameStr = fileName; + return (unzLocateFile(reader_, fileNameStr.c_str(), + (caseSensitive ? 1 : 2)) == UNZ_OK); +} + +bool CefZipReaderImpl::Close() { + if (!VerifyContext()) + return false; + + if (has_fileopen_) + CloseFile(); + + int result = unzClose(reader_); + reader_ = NULL; + return (result == UNZ_OK); +} + +CefString CefZipReaderImpl::GetFileName() { + if (!VerifyContext() || !GetFileInfo()) + return CefString(); + + return filename_; +} + +int64 CefZipReaderImpl::GetFileSize() { + if (!VerifyContext() || !GetFileInfo()) + return -1; + + return filesize_; +} + +time_t CefZipReaderImpl::GetFileLastModified() { + if (!VerifyContext() || !GetFileInfo()) + return 0; + + return filemodified_; +} + +bool CefZipReaderImpl::OpenFile(const CefString& password) { + if (!VerifyContext()) + return false; + + if (has_fileopen_) + CloseFile(); + + bool ret; + + if (password.empty()) { + ret = (unzOpenCurrentFile(reader_) == UNZ_OK); + } else { + std::string passwordStr = password; + ret = (unzOpenCurrentFilePassword(reader_, passwordStr.c_str()) == UNZ_OK); + } + + if (ret) + has_fileopen_ = true; + return ret; +} + +bool CefZipReaderImpl::CloseFile() { + if (!VerifyContext() || !has_fileopen_) + return false; + + has_fileopen_ = false; + has_fileinfo_ = false; + + return (unzCloseCurrentFile(reader_) == UNZ_OK); +} + +int CefZipReaderImpl::ReadFile(void* buffer, size_t bufferSize) { + if (!VerifyContext() || !has_fileopen_) + return -1; + + return unzReadCurrentFile(reader_, buffer, bufferSize); +} + +int64 CefZipReaderImpl::Tell() { + if (!VerifyContext() || !has_fileopen_) + return -1; + + return unztell64(reader_); +} + +bool CefZipReaderImpl::Eof() { + if (!VerifyContext() || !has_fileopen_) + return true; + + return (unzeof(reader_) == 1 ? true : false); +} + +bool CefZipReaderImpl::GetFileInfo() { + if (has_fileinfo_) + return true; + + char file_name[512] = {0}; + unz_file_info file_info; + memset(&file_info, 0, sizeof(file_info)); + + if (unzGetCurrentFileInfo(reader_, &file_info, file_name, sizeof(file_name), + NULL, 0, NULL, 0) != UNZ_OK) { + return false; + } + + has_fileinfo_ = true; + filename_ = std::string(file_name); + filesize_ = file_info.uncompressed_size; + + struct tm time; + memset(&time, 0, sizeof(time)); + time.tm_sec = file_info.tmu_date.tm_sec; + time.tm_min = file_info.tmu_date.tm_min; + time.tm_hour = file_info.tmu_date.tm_hour; + time.tm_mday = file_info.tmu_date.tm_mday; + time.tm_mon = file_info.tmu_date.tm_mon; + time.tm_year = file_info.tmu_date.tm_year; + filemodified_ = mktime(&time); + + return true; +} + +bool CefZipReaderImpl::VerifyContext() { + if (base::PlatformThread::CurrentId() != supported_thread_id_) { + // This object should only be accessed from the thread that created it. + NOTREACHED(); + return false; + } + + return (reader_ != NULL); +} diff --git a/cef3/libcef/browser/zip_reader_impl.h b/cef3/libcef/browser/zip_reader_impl.h new file mode 100644 index 000000000..d53d157a0 --- /dev/null +++ b/cef3/libcef/browser/zip_reader_impl.h @@ -0,0 +1,55 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_ZIP_READER_IMPL_H_ +#define CEF_LIBCEF_BROWSER_ZIP_READER_IMPL_H_ +#pragma once + +#include + +#include "include/cef_zip_reader.h" +#include "base/threading/platform_thread.h" +#include "third_party/zlib/contrib/minizip/unzip.h" + +// Implementation of CefZipReader +class CefZipReaderImpl : public CefZipReader { + public: + CefZipReaderImpl(); + ~CefZipReaderImpl(); + + // Initialize the reader context. + bool Initialize(CefRefPtr stream); + + virtual bool MoveToFirstFile(); + virtual bool MoveToNextFile(); + virtual bool MoveToFile(const CefString& fileName, bool caseSensitive); + virtual bool Close(); + virtual CefString GetFileName(); + virtual int64 GetFileSize(); + virtual time_t GetFileLastModified(); + virtual bool OpenFile(const CefString& password); + virtual bool CloseFile(); + virtual int ReadFile(void* buffer, size_t bufferSize); + virtual int64 Tell(); + virtual bool Eof(); + + bool GetFileInfo(); + + // Verify that the reader exists and is being accessed from the correct + // thread. + bool VerifyContext(); + + protected: + base::PlatformThreadId supported_thread_id_; + unzFile reader_; + bool has_fileopen_; + bool has_fileinfo_; + CefString filename_; + int64 filesize_; + time_t filemodified_; + + IMPLEMENT_REFCOUNTING(CefZipReaderImpl); +}; + +#endif // CEF_LIBCEF_BROWSER_ZIP_READER_IMPL_H_ diff --git a/cef3/libcef/common/cef_message_generator.cc b/cef3/libcef/common/cef_message_generator.cc new file mode 100644 index 000000000..6e16dc1d4 --- /dev/null +++ b/cef3/libcef/common/cef_message_generator.cc @@ -0,0 +1,33 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Get basic type definitions. +#define IPC_MESSAGE_IMPL +#include "libcef/common/cef_message_generator.h" + +// Generate constructors. +#include "ipc/struct_constructor_macros.h" +#include "libcef/common/cef_message_generator.h" + +// Generate destructors. +#include "ipc/struct_destructor_macros.h" +#include "libcef/common/cef_message_generator.h" + +// Generate param traits write methods. +#include "ipc/param_traits_write_macros.h" +namespace IPC { +#include "libcef/common/cef_message_generator.h" +} // namespace IPC + +// Generate param traits read methods. +#include "ipc/param_traits_read_macros.h" +namespace IPC { +#include "libcef/common/cef_message_generator.h" +} // namespace IPC + +// Generate param traits log methods. +#include "ipc/param_traits_log_macros.h" +namespace IPC { +#include "libcef/common/cef_message_generator.h" +} // namespace IPC diff --git a/cef3/libcef/common/cef_message_generator.h b/cef3/libcef/common/cef_message_generator.h new file mode 100644 index 000000000..124361160 --- /dev/null +++ b/cef3/libcef/common/cef_message_generator.h @@ -0,0 +1,7 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Multiply-included file, hence no include guard. + +#include "libcef/common/cef_messages.h" diff --git a/cef3/libcef/common/cef_messages.cc b/cef3/libcef/common/cef_messages.cc new file mode 100644 index 000000000..9727d843e --- /dev/null +++ b/cef3/libcef/common/cef_messages.cc @@ -0,0 +1,116 @@ +// Copyright (c) 2012 The Chromium 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 "libcef/common/cef_messages.h" + +namespace IPC { + +// Extracted from chrome/common/automation_messages.cc. + +// Only the net::UploadData ParamTraits<> definition needs this definition, so +// keep this in the implementation file so we can forward declare UploadData in +// the header. +template <> +struct ParamTraits { + typedef net::UploadElement param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, static_cast(p.type())); + switch (p.type()) { + case net::UploadElement::TYPE_BYTES: { + m->WriteData(p.bytes(), static_cast(p.bytes_length())); + break; + } + default: { + DCHECK(p.type() == net::UploadElement::TYPE_FILE); + WriteParam(m, p.file_path()); + WriteParam(m, p.file_range_offset()); + WriteParam(m, p.file_range_length()); + WriteParam(m, p.expected_file_modification_time()); + break; + } + } + } + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { + int type; + if (!ReadParam(m, iter, &type)) + return false; + switch (type) { + case net::UploadElement::TYPE_BYTES: { + const char* data; + int len; + if (!m->ReadData(iter, &data, &len)) + return false; + r->SetToBytes(data, len); + break; + } + default: { + DCHECK(type == net::UploadElement::TYPE_FILE); + base::FilePath file_path; + uint64 offset, length; + base::Time expected_modification_time; + if (!ReadParam(m, iter, &file_path)) + return false; + if (!ReadParam(m, iter, &offset)) + return false; + if (!ReadParam(m, iter, &length)) + return false; + if (!ReadParam(m, iter, &expected_modification_time)) + return false; + r->SetToFilePathRange(file_path, offset, length, + expected_modification_time); + break; + } + } + return true; + } + static void Log(const param_type& p, std::string* l) { + l->append(""); + } +}; + +void ParamTraits >::Write(Message* m, + const param_type& p) { + WriteParam(m, p.get() != NULL); + if (p) { + WriteParam(m, p->elements()); + WriteParam(m, p->identifier()); + WriteParam(m, p->is_chunked()); + WriteParam(m, p->last_chunk_appended()); + } +} + +bool ParamTraits >::Read(const Message* m, + PickleIterator* iter, + param_type* r) { + bool has_object; + if (!ReadParam(m, iter, &has_object)) + return false; + if (!has_object) + return true; + ScopedVector elements; + if (!ReadParam(m, iter, &elements)) + return false; + int64 identifier; + if (!ReadParam(m, iter, &identifier)) + return false; + bool is_chunked = false; + if (!ReadParam(m, iter, &is_chunked)) + return false; + bool last_chunk_appended = false; + if (!ReadParam(m, iter, &last_chunk_appended)) + return false; + *r = new net::UploadData; + (*r)->swap_elements(&elements); + (*r)->set_identifier(identifier); + (*r)->set_is_chunked(is_chunked); + (*r)->set_last_chunk_appended(last_chunk_appended); + return true; +} + +void ParamTraits >::Log(const param_type& p, + std::string* l) { + l->append(""); +} + +} // namespace IPC diff --git a/cef3/libcef/common/cef_messages.h b/cef3/libcef/common/cef_messages.h new file mode 100644 index 000000000..040064658 --- /dev/null +++ b/cef3/libcef/common/cef_messages.h @@ -0,0 +1,219 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// IPC messages for CEF. +// Multiply-included message file, hence no include guard. + +#include "base/shared_memory.h" +#include "base/values.h" +#include "content/public/common/common_param_traits.h" +#include "content/public/common/referrer.h" +#include "ipc/ipc_message_macros.h" +#include "net/base/upload_data.h" + +// TODO(cef): Re-using the message start for extensions may be problematic in +// the future. It would be better if ipc_message_utils.h contained a value +// reserved for consumers of the content API. +// See: http://crbug.com/110911 +#define IPC_MESSAGE_START ExtensionMsgStart + + +// Common types. + +// Parameters structure for a request. +IPC_STRUCT_BEGIN(Cef_Request_Params) + // Unique request id to match requests and responses. + IPC_STRUCT_MEMBER(int, request_id) + + // Unique id of the target frame. -1 if unknown / invalid. + IPC_STRUCT_MEMBER(int64, frame_id) + + // True if the request is user-initiated instead of internal. + IPC_STRUCT_MEMBER(bool, user_initiated) + + // True if a response is expected. + IPC_STRUCT_MEMBER(bool, expect_response) + + // Message name. + IPC_STRUCT_MEMBER(std::string, name) + + // List of message arguments. + IPC_STRUCT_MEMBER(ListValue, arguments) +IPC_STRUCT_END() + +// Parameters structure for a response. +IPC_STRUCT_BEGIN(Cef_Response_Params) + // Unique request id to match requests and responses. + IPC_STRUCT_MEMBER(int, request_id) + + // True if a response ack is expected. + IPC_STRUCT_MEMBER(bool, expect_response_ack) + + // True on success. + IPC_STRUCT_MEMBER(bool, success) + + // Response or error string depending on the value of |success|. + IPC_STRUCT_MEMBER(std::string, response) +IPC_STRUCT_END() + +// Parameters structure for a cross-origin white list entry. +IPC_STRUCT_BEGIN(Cef_CrossOriginWhiteListEntry_Params) + IPC_STRUCT_MEMBER(std::string, source_origin) + IPC_STRUCT_MEMBER(std::string, target_protocol) + IPC_STRUCT_MEMBER(std::string, target_domain) + IPC_STRUCT_MEMBER(bool, allow_target_subdomains) +IPC_STRUCT_END() + + +// Messages sent from the browser to the renderer. + +// Parameters for a resource request. +IPC_STRUCT_BEGIN(CefMsg_LoadRequest_Params) + // The request method: GET, POST, etc. + IPC_STRUCT_MEMBER(std::string, method) + + // The requested URL. + IPC_STRUCT_MEMBER(GURL, url) + + // The URL to send in the "Referer" header field. Can be empty if there is + // no referrer. + IPC_STRUCT_MEMBER(GURL, referrer) + // One of the WebKit::WebReferrerPolicy values. + IPC_STRUCT_MEMBER(int, referrer_policy) + + // Identifies the frame within the RenderView that sent the request. + // -1 if unknown / invalid. + IPC_STRUCT_MEMBER(int64, frame_id) + + // Usually the URL of the document in the top-level window, which may be + // checked by the third-party cookie blocking policy. Leaving it empty may + // lead to undesired cookie blocking. Third-party cookie blocking can be + // bypassed by setting first_party_for_cookies = url, but this should ideally + // only be done if there really is no way to determine the correct value. + IPC_STRUCT_MEMBER(GURL, first_party_for_cookies) + + // Additional HTTP request headers. + IPC_STRUCT_MEMBER(std::string, headers) + + // net::URLRequest load flags (0 by default). + IPC_STRUCT_MEMBER(int, load_flags) + + // Optional upload data (may be null). + IPC_STRUCT_MEMBER(scoped_refptr, upload_data) +IPC_STRUCT_END() + +// Tell the renderer to load a request. +IPC_MESSAGE_ROUTED1(CefMsg_LoadRequest, + CefMsg_LoadRequest_Params) + +// Sent when the browser has a request for the renderer. The renderer may +// respond with a CefHostMsg_Response. +IPC_MESSAGE_ROUTED1(CefMsg_Request, + Cef_Request_Params) + +// Optional message sent in response to a CefHostMsg_Request. +IPC_MESSAGE_ROUTED1(CefMsg_Response, + Cef_Response_Params) + +// Optional Ack message sent to the browser to notify that a CefHostMsg_Response +// has been processed. +IPC_MESSAGE_ROUTED1(CefMsg_ResponseAck, + int /* request_id */) + +// Sent to child processes to add or remove a cross-origin whitelist entry. +IPC_MESSAGE_CONTROL2(CefProcessMsg_ModifyCrossOriginWhitelistEntry, + bool /* add */, + Cef_CrossOriginWhiteListEntry_Params /* params */) + +// Sent to child processes to clear the cross-origin whitelist. +IPC_MESSAGE_CONTROL0(CefProcessMsg_ClearCrossOriginWhitelist) + + +// Messages sent from the renderer to the browser. + +// Parameters for a newly created render thread. +IPC_STRUCT_BEGIN(CefProcessHostMsg_GetNewRenderThreadInfo_Params) + IPC_STRUCT_MEMBER(std::vector, + cross_origin_whitelist_entries) + + IPC_STRUCT_MEMBER(ListValue, extra_info) +IPC_STRUCT_END() + +// Retrieve information about a newly created render thread. +IPC_SYNC_MESSAGE_CONTROL0_1( + CefProcessHostMsg_GetNewRenderThreadInfo, + CefProcessHostMsg_GetNewRenderThreadInfo_Params /* params*/) + +// Parameters for a newly created browser window. +IPC_STRUCT_BEGIN(CefProcessHostMsg_GetNewBrowserInfo_Params) + IPC_STRUCT_MEMBER(int, browser_id) + IPC_STRUCT_MEMBER(bool, is_popup) +IPC_STRUCT_END() + +// Retrieve information about a newly created browser window. +IPC_SYNC_MESSAGE_CONTROL1_1( + CefProcessHostMsg_GetNewBrowserInfo, + int /* routing_id */, + CefProcessHostMsg_GetNewBrowserInfo_Params /* params*/) + +// Sent when a frame is identified for the first time. +IPC_MESSAGE_ROUTED3(CefHostMsg_FrameIdentified, + int64 /* frame_id */, + int64 /* parent_frame_id */, + string16 /* frame_name */) + +// Sent when a frame has been detached. +IPC_MESSAGE_ROUTED1(CefHostMsg_FrameDetached, + int64 /* frame_id */) + +// Sent when a new frame has been given focus. +IPC_MESSAGE_ROUTED1(CefHostMsg_FrameFocusChange, + int64 /* frame_id */) + +// Sent when a frame has finished loading. Based on ViewHostMsg_DidFinishLoad. +IPC_MESSAGE_ROUTED4(CefHostMsg_DidFinishLoad, + int64 /* frame_id */, + GURL /* validated_url */, + bool /* is_main_frame */, + int /* http_status_code */) + +// Sent when a new URL is about to be loaded in the main frame. Used for the +// cookie manager. +IPC_MESSAGE_ROUTED1(CefHostMsg_LoadingURLChange, + GURL /* loading_url */) + +// Sent when the renderer has a request for the browser. The browser may respond +// with a CefMsg_Response. +IPC_MESSAGE_ROUTED1(CefHostMsg_Request, + Cef_Request_Params) + +// Optional message sent in response to a CefMsg_Request. +IPC_MESSAGE_ROUTED1(CefHostMsg_Response, + Cef_Response_Params) + +// Optional Ack message sent to the browser to notify that a CefMsg_Response +// has been processed. +IPC_MESSAGE_ROUTED1(CefHostMsg_ResponseAck, + int /* request_id */) + + +// Singly-included section for struct and custom IPC traits. +#ifndef CEF_LIBCEF_COMMON_CEF_MESSAGES_H_ +#define CEF_LIBCEF_COMMON_CEF_MESSAGES_H_ + +namespace IPC { + +// Extracted from chrome/common/automation_messages.h. +template <> +struct ParamTraits > { + typedef scoped_refptr param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); + static void Log(const param_type& p, std::string* l); +}; + +} // namespace IPC + +#endif // CEF_LIBCEF_COMMON_CEF_MESSAGES_H_ diff --git a/cef3/libcef/common/cef_switches.cc b/cef3/libcef/common/cef_switches.cc new file mode 100644 index 000000000..c696ce4df --- /dev/null +++ b/cef3/libcef/common/cef_switches.cc @@ -0,0 +1,98 @@ +// 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 "libcef/common/cef_switches.h" + +namespace switches { + +// Log file path. +const char kLogFile[] = "log-file"; + +// Severity of messages to log. +const char kLogSeverity[] = "log-severity"; +const char kLogSeverity_Verbose[] = "verbose"; +const char kLogSeverity_Info[] = "info"; +const char kLogSeverity_Warning[] = "warning"; +const char kLogSeverity_Error[] = "error"; +const char kLogSeverity_ErrorReport[] = "error-report"; +const char kLogSeverity_Disable[] = "disable"; + +// Enable DCHECK for release mode. +const char kEnableReleaseDcheck[] = "enable-release-dcheck"; + +// Path to resources directory. +const char kResourcesDirPath[] = "resources-dir-path"; + +// Path to locales directory. +const char kLocalesDirPath[] = "locales-dir-path"; + +// Path to locales directory. +const char kDisablePackLoading[] = "disable-pack-loading"; + +// Stack size for uncaught exceptions. +const char kUncaughtExceptionStackSize[] = "uncaught-exception-stack-size"; + +// Context safety implementation type. +const char kContextSafetyImplementation[] = "context-safety-implementation"; + +// Default encoding. +const char kDefaultEncoding[] = "default-encoding"; + +// User style sheet location. +const char kUserStyleSheetLocation[] = "user-style-sheet-location"; + +// Disable opening of windows via JavaScript. +const char kDisableJavascriptOpenWindows[] = + "disable-javascript-open-windows"; + +// Disable closing of windows via JavaScript. +const char kDisableJavascriptCloseWindows[] = + "disable-javascript-close-windows"; + +// Disable clipboard access via JavaScript. +const char kDisableJavascriptAccessClipboard[] = + "disable-javascript-access-clipboard"; + +// Disable DOM paste via JavaScript execCommand("paste"). +const char kDisableJavascriptDomPaste[] = "disable-javascript-dom-paste"; + +// Enable caret browsing. +const char kEnableCaretBrowsing[] = "enable-caret-browsing"; + +// Allow universal access from file URLs. +const char kAllowUniversalAccessFromFileUrls[] = + "allow-universal-access-from-files"; + +// Disable loading of images from the network. A cached image will still be +// rendered if requested. +const char kDisableImageLoading[] = "disable-image-loading"; + +// Shrink stand-alone images to fit. +const char kImageShrinkStandaloneToFit[] = "image-shrink-standalone-to-fit"; + +// Disable resizing of text areas. +const char kDisableTextAreaResize[] = "disable-text-area-resize"; + +// Disable using the tab key to advance focus to links. +const char kDisableTabToLinks[] = "disable-tab-to-links"; + +// Disable user style sheets. +const char kDisableAuthorAndUserStyles[] = "disable-author-and-user-styles"; + +// Disable developer tools (WebKit Inspector). +const char kDisableDeveloperTools[] = "disable-developer-tools"; + +// Persist session cookies. +const char kPersistSessionCookies[] = "persist-session-cookies"; + +// Enable media (WebRTC audio/video) streaming. +const char kEnableMediaStream[] = "enable-media-stream"; + +// Enable speech input (x-webkit-speech). +const char kEnableSpeechInput[] = "enable-speech-input"; + +// Enable the speech input profanity filter. +const char kEnableProfanityFilter[] = "enable-profanity-filter"; + +} // namespace switches diff --git a/cef3/libcef/common/cef_switches.h b/cef3/libcef/common/cef_switches.h new file mode 100644 index 000000000..d76583efc --- /dev/null +++ b/cef3/libcef/common/cef_switches.h @@ -0,0 +1,48 @@ +// 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. + +// Defines all the "cef" command-line switches. + +#ifndef CEF_LIBCEF_COMMON_CEF_SWITCHES_H_ +#define CEF_LIBCEF_COMMON_CEF_SWITCHES_H_ +#pragma once + +namespace switches { + +extern const char kLogFile[]; +extern const char kLogSeverity[]; +extern const char kLogSeverity_Verbose[]; +extern const char kLogSeverity_Info[]; +extern const char kLogSeverity_Warning[]; +extern const char kLogSeverity_Error[]; +extern const char kLogSeverity_ErrorReport[]; +extern const char kLogSeverity_Disable[]; +extern const char kEnableReleaseDcheck[]; +extern const char kResourcesDirPath[]; +extern const char kLocalesDirPath[]; +extern const char kDisablePackLoading[]; +extern const char kUncaughtExceptionStackSize[]; +extern const char kContextSafetyImplementation[]; +extern const char kDefaultEncoding[]; +extern const char kUserStyleSheetLocation[]; +extern const char kDisableJavascriptOpenWindows[]; +extern const char kDisableJavascriptCloseWindows[]; +extern const char kDisableJavascriptAccessClipboard[]; +extern const char kDisableJavascriptDomPaste[]; +extern const char kEnableCaretBrowsing[]; +extern const char kAllowUniversalAccessFromFileUrls[]; +extern const char kDisableImageLoading[]; +extern const char kImageShrinkStandaloneToFit[]; +extern const char kDisableTextAreaResize[]; +extern const char kDisableTabToLinks[]; +extern const char kDisableAuthorAndUserStyles[]; +extern const char kDisableDeveloperTools[]; +extern const char kPersistSessionCookies[]; +extern const char kEnableMediaStream[]; +extern const char kEnableSpeechInput[]; +extern const char kEnableProfanityFilter[]; + +} // namespace switches + +#endif // CEF_LIBCEF_COMMON_CEF_SWITCHES_H_ diff --git a/cef3/libcef/common/command_line_impl.cc b/cef3/libcef/common/command_line_impl.cc new file mode 100644 index 000000000..8075b0ccc --- /dev/null +++ b/cef3/libcef/common/command_line_impl.cc @@ -0,0 +1,159 @@ +// 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 "libcef/common/command_line_impl.h" + +#include "base/files/file_path.h" +#include "base/logging.h" + +CefCommandLineImpl::CefCommandLineImpl(CommandLine* value, + bool will_delete, + bool read_only) + : CefValueBase( + value, NULL, will_delete ? kOwnerWillDelete : kOwnerNoDelete, + read_only, NULL) { +} + +bool CefCommandLineImpl::IsValid() { + return !detached(); +} + +bool CefCommandLineImpl::IsReadOnly() { + return read_only(); +} + +CefRefPtr CefCommandLineImpl::Copy() { + CEF_VALUE_VERIFY_RETURN(false, NULL); + return new CefCommandLineImpl( + new CommandLine(const_value().argv()), true, false); +} + +void CefCommandLineImpl::InitFromArgv(int argc, const char* const* argv) { +#if !defined(OS_WIN) + CEF_VALUE_VERIFY_RETURN_VOID(true); + mutable_value()->InitFromArgv(argc, argv); +#else + NOTREACHED() << "method not supported on this platform"; +#endif +} + +void CefCommandLineImpl::InitFromString(const CefString& command_line) { +#if defined(OS_WIN) + CEF_VALUE_VERIFY_RETURN_VOID(true); + mutable_value()->ParseFromString(command_line); +#else + NOTREACHED() << "method not supported on this platform"; +#endif +} + +void CefCommandLineImpl::Reset() { + CEF_VALUE_VERIFY_RETURN_VOID(true); + CommandLine::StringVector argv; + argv.push_back(mutable_value()->GetProgram().value()); + mutable_value()->InitFromArgv(argv); + + const CommandLine::SwitchMap& map = mutable_value()->GetSwitches(); + const_cast(&map)->clear(); +} + +void CefCommandLineImpl::GetArgv(std::vector& argv) { + CEF_VALUE_VERIFY_RETURN_VOID(false); + const CommandLine::StringVector& cmd_argv = const_value().argv(); + CommandLine::StringVector::const_iterator it = cmd_argv.begin(); + for (; it != cmd_argv.end(); ++it) + argv.push_back(*it); +} + +CefString CefCommandLineImpl::GetCommandLineString() { + CEF_VALUE_VERIFY_RETURN(false, CefString()); + return const_value().GetCommandLineString(); +} + +CefString CefCommandLineImpl::GetProgram() { + CEF_VALUE_VERIFY_RETURN(false, CefString()); + return const_value().GetProgram().value(); +} + +void CefCommandLineImpl::SetProgram(const CefString& program) { + CEF_VALUE_VERIFY_RETURN_VOID(true); + mutable_value()->SetProgram(base::FilePath(program)); +} + +bool CefCommandLineImpl::HasSwitches() { + CEF_VALUE_VERIFY_RETURN(false, false); + return (const_value().GetSwitches().size() > 0); +} + +bool CefCommandLineImpl::HasSwitch(const CefString& name) { + CEF_VALUE_VERIFY_RETURN(false, false); + return const_value().HasSwitch(name); +} + +CefString CefCommandLineImpl::GetSwitchValue(const CefString& name) { + CEF_VALUE_VERIFY_RETURN(false, CefString()); + return const_value().GetSwitchValueNative(name); +} + +void CefCommandLineImpl::GetSwitches(SwitchMap& switches) { + CEF_VALUE_VERIFY_RETURN_VOID(false); + const CommandLine::SwitchMap& map = const_value().GetSwitches(); + CommandLine::SwitchMap::const_iterator it = map.begin(); + for (; it != map.end(); ++it) + switches.insert(std::make_pair(it->first, it->second)); +} + +void CefCommandLineImpl::AppendSwitch(const CefString& name) { + CEF_VALUE_VERIFY_RETURN_VOID(true); + mutable_value()->AppendSwitch(name); +} + +void CefCommandLineImpl::AppendSwitchWithValue(const CefString& name, + const CefString& value) { + CEF_VALUE_VERIFY_RETURN_VOID(true); + mutable_value()->AppendSwitchNative(name, value); +} + +bool CefCommandLineImpl::HasArguments() { + CEF_VALUE_VERIFY_RETURN(false, false); + return (const_value().GetArgs().size() > 0); +} + +void CefCommandLineImpl::GetArguments(ArgumentList& arguments) { + CEF_VALUE_VERIFY_RETURN_VOID(false); + const CommandLine::StringVector& vec = const_value().GetArgs(); + CommandLine::StringVector::const_iterator it = vec.begin(); + for (; it != vec.end(); ++it) + arguments.push_back(*it); +} + +void CefCommandLineImpl::AppendArgument(const CefString& argument) { + CEF_VALUE_VERIFY_RETURN_VOID(true); + mutable_value()->AppendArgNative(argument); +} + +void CefCommandLineImpl::PrependWrapper(const CefString& wrapper) { + CEF_VALUE_VERIFY_RETURN_VOID(true); + mutable_value()->PrependWrapper(wrapper); +} + + +// CefCommandLine implementation. + +// static +CefRefPtr CefCommandLine::CreateCommandLine() { + return new CefCommandLineImpl( + new CommandLine(CommandLine::NO_PROGRAM), true, false); +} + +// static +CefRefPtr CefCommandLine::GetGlobalCommandLine() { + // Uses a singleton reference object. + static CefRefPtr commandLinePtr; + if (!commandLinePtr.get()) { + CommandLine* command_line = CommandLine::ForCurrentProcess(); + if (command_line) + commandLinePtr = new CefCommandLineImpl(command_line, false, true); + } + return commandLinePtr.get(); +} diff --git a/cef3/libcef/common/command_line_impl.h b/cef3/libcef/common/command_line_impl.h new file mode 100644 index 000000000..85f472657 --- /dev/null +++ b/cef3/libcef/common/command_line_impl.h @@ -0,0 +1,50 @@ +// 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. + +#ifndef CEF_LIBCEF_COMMON_COMMAND_LINE_IMPL_H_ +#define CEF_LIBCEF_COMMON_COMMAND_LINE_IMPL_H_ +#pragma once + +#include "include/cef_command_line.h" +#include "libcef/common/value_base.h" + +#include "base/command_line.h" + +// CefCommandLine implementation +class CefCommandLineImpl : public CefValueBase { + public: + CefCommandLineImpl(CommandLine* value, + bool will_delete, + bool read_only); + + // CefCommandLine methods. + virtual bool IsValid() OVERRIDE; + virtual bool IsReadOnly() OVERRIDE; + virtual CefRefPtr Copy() OVERRIDE; + virtual void InitFromArgv(int argc, const char* const* argv) OVERRIDE; + virtual void InitFromString(const CefString& command_line) OVERRIDE; + virtual void Reset() OVERRIDE; + virtual void GetArgv(std::vector& argv) OVERRIDE; + virtual CefString GetCommandLineString() OVERRIDE; + virtual CefString GetProgram() OVERRIDE; + virtual void SetProgram(const CefString& program) OVERRIDE; + virtual bool HasSwitches() OVERRIDE; + virtual bool HasSwitch(const CefString& name) OVERRIDE; + virtual CefString GetSwitchValue(const CefString& name) OVERRIDE; + virtual void GetSwitches(SwitchMap& switches) OVERRIDE; + virtual void AppendSwitch(const CefString& name) OVERRIDE; + virtual void AppendSwitchWithValue(const CefString& name, + const CefString& value) OVERRIDE; + virtual bool HasArguments() OVERRIDE; + virtual void GetArguments(ArgumentList& arguments) OVERRIDE; + virtual void AppendArgument(const CefString& argument) OVERRIDE; + virtual void PrependWrapper(const CefString& wrapper) OVERRIDE; + + // Must hold the controller lock while using this value. + const CommandLine& command_line() { return const_value(); } + + DISALLOW_COPY_AND_ASSIGN(CefCommandLineImpl); +}; + +#endif // CEF_LIBCEF_COMMON_COMMAND_LINE_IMPL_H_ diff --git a/cef3/libcef/common/content_client.cc b/cef3/libcef/common/content_client.cc new file mode 100644 index 000000000..c021c85d3 --- /dev/null +++ b/cef3/libcef/common/content_client.cc @@ -0,0 +1,178 @@ +// Copyright (c) 2012 The Chromium 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 "libcef/common/content_client.h" +#include "include/cef_stream.h" +#include "include/cef_version.h" +#include "libcef/browser/scheme_registration.h" +#include "libcef/common/scheme_registrar_impl.h" + +#include "base/command_line.h" +#include "base/logging.h" +#include "base/string_piece.h" +#include "base/stringprintf.h" +#include "chrome/common/chrome_switches.h" +#include "content/public/common/content_switches.h" +#include "ui/base/resource/resource_bundle.h" +#include "webkit/user_agent/user_agent_util.h" + +namespace { + +const char kInterposeLibraryPath[] = + "@executable_path/../../../libplugin_carbon_interpose.dylib"; + +} // namespace + + +CefContentClient::CefContentClient(CefRefPtr application) + : application_(application), + pack_loading_disabled_(false), + allow_pack_file_load_(false) { +} + +CefContentClient::~CefContentClient() { +} + +// static +CefContentClient* CefContentClient::Get() { + return static_cast(content::GetContentClient()); +} + +void CefContentClient::AddAdditionalSchemes( + std::vector* standard_schemes, + std::vector* savable_schemes) { + if (application_.get()) { + CefRefPtr schemeRegistrar( + new CefSchemeRegistrarImpl()); + application_->OnRegisterCustomSchemes(schemeRegistrar.get()); + schemeRegistrar->GetStandardSchemes(standard_schemes); + + // No references to the registar should be kept. + schemeRegistrar->Detach(); + DCHECK(schemeRegistrar->VerifyRefCount()); + } + + scheme::AddInternalStandardSchemes(standard_schemes); +} + +std::string CefContentClient::GetUserAgent() const { + std::string product_version; + + static CommandLine& command_line = *CommandLine::ForCurrentProcess(); + if (command_line.HasSwitch(switches::kProductVersion)) { + product_version = + command_line.GetSwitchValueASCII(switches::kProductVersion); + } else { + product_version = base::StringPrintf("Chrome/%d.%d.%d.%d", + CHROME_VERSION_MAJOR, CHROME_VERSION_MINOR, CHROME_VERSION_BUILD, + CHROME_VERSION_PATCH); + } + + return webkit_glue::BuildUserAgentFromProduct(product_version); +} + +string16 CefContentClient::GetLocalizedString(int message_id) const { + string16 value = + ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); + if (value.empty()) + LOG(ERROR) << "No localized string available for id " << message_id; + + return value; +} + +base::StringPiece CefContentClient::GetDataResource( + int resource_id, + ui::ScaleFactor scale_factor) const { + base::StringPiece value = + ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( + resource_id, scale_factor); + if (value.empty()) + LOG(ERROR) << "No data resource available for id " << resource_id; + + return value; +} + +gfx::Image& CefContentClient::GetNativeImageNamed(int resource_id) const { + gfx::Image& value = + ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); + if (value.IsEmpty()) + LOG(ERROR) << "No native image available for id " << resource_id; + + return value; +} + +#if defined(OS_MACOSX) && !defined(OS_IOS) +std::string CefContentClient::GetCarbonInterposePath() const { + return std::string(kInterposeLibraryPath); +} +#endif + +base::FilePath CefContentClient::GetPathForResourcePack( + const base::FilePath& pack_path, + ui::ScaleFactor scale_factor) { + // Only allow the cef pack file to load. + if (!pack_loading_disabled_ && allow_pack_file_load_) + return pack_path; + return base::FilePath(); +} + +base::FilePath CefContentClient::GetPathForLocalePack( + const base::FilePath& pack_path, + const std::string& locale) { + if (!pack_loading_disabled_) + return pack_path; + return base::FilePath(); +} + +gfx::Image CefContentClient::GetImageNamed(int resource_id) { + return gfx::Image(); +} + +gfx::Image CefContentClient::GetNativeImageNamed( + int resource_id, + ui::ResourceBundle::ImageRTL rtl) { + return gfx::Image(); +} + +base::RefCountedStaticMemory* CefContentClient::LoadDataResourceBytes( + int resource_id, + ui::ScaleFactor scale_factor) { + return NULL; +} + +bool CefContentClient::GetRawDataResource(int resource_id, + ui::ScaleFactor scale_factor, + base::StringPiece* value) { + if (application_.get()) { + CefRefPtr handler = + application_->GetResourceBundleHandler(); + if (handler.get()) { + void* data = NULL; + size_t data_size = 0; + if (handler->GetDataResource(resource_id, data, data_size)) + *value = base::StringPiece(static_cast(data), data_size); + } + } + + return (pack_loading_disabled_ || !value->empty()); +} + +bool CefContentClient::GetLocalizedString(int message_id, string16* value) { + if (application_.get()) { + CefRefPtr handler = + application_->GetResourceBundleHandler(); + if (handler.get()) { + CefString cef_str; + if (handler->GetLocalizedString(message_id, cef_str)) + *value = cef_str; + } + } + + return (pack_loading_disabled_ || !value->empty()); +} + +scoped_ptr CefContentClient::GetFont( + ui::ResourceBundle::FontStyle style) { + return scoped_ptr(); +} diff --git a/cef3/libcef/common/content_client.h b/cef3/libcef/common/content_client.h new file mode 100644 index 000000000..41c50657b --- /dev/null +++ b/cef3/libcef/common/content_client.h @@ -0,0 +1,75 @@ +// Copyright (c) 2012 The Chromium 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_LIBCEF_COMMON_CONTENT_CLIENT_H_ +#define CEF_LIBCEF_COMMON_CONTENT_CLIENT_H_ +#pragma once + +#include +#include + +#include "include/cef_app.h" + +#include "base/compiler_specific.h" +#include "content/public/common/content_client.h" +#include "ui/base/resource/resource_bundle.h" + +class CefContentClient : public content::ContentClient, + public ui::ResourceBundle::Delegate { + public: + explicit CefContentClient(CefRefPtr application); + virtual ~CefContentClient(); + + // Returns the singleton CefContentClient instance. + static CefContentClient* Get(); + + // content::ContentClient methods. + virtual void AddAdditionalSchemes( + std::vector* standard_schemes, + std::vector* savable_schemes) OVERRIDE; + virtual std::string GetUserAgent() const OVERRIDE; + virtual string16 GetLocalizedString(int message_id) const OVERRIDE; + virtual base::StringPiece GetDataResource( + int resource_id, + ui::ScaleFactor scale_factor) const OVERRIDE; + virtual gfx::Image& GetNativeImageNamed(int resource_id) const OVERRIDE; + +#if defined(OS_MACOSX) && !defined(OS_IOS) + virtual std::string GetCarbonInterposePath() const OVERRIDE; +#endif + + CefRefPtr application() const { return application_; } + + void set_pack_loading_disabled(bool val) { pack_loading_disabled_ = val; } + bool pack_loading_disabled() const { return pack_loading_disabled_; } + void set_allow_pack_file_load(bool val) { allow_pack_file_load_ = val; } + + private: + // ui::ResourceBundle::Delegate methods. + virtual base::FilePath GetPathForResourcePack( + const base::FilePath& pack_path, + ui::ScaleFactor scale_factor) OVERRIDE; + virtual base::FilePath GetPathForLocalePack( + const base::FilePath& pack_path, + const std::string& locale) OVERRIDE; + virtual gfx::Image GetImageNamed(int resource_id) OVERRIDE; + virtual gfx::Image GetNativeImageNamed( + int resource_id, + ui::ResourceBundle::ImageRTL rtl) OVERRIDE; + virtual base::RefCountedStaticMemory* LoadDataResourceBytes( + int resource_id, + ui::ScaleFactor scale_factor) OVERRIDE; + virtual bool GetRawDataResource(int resource_id, + ui::ScaleFactor scale_factor, + base::StringPiece* value) OVERRIDE; + virtual bool GetLocalizedString(int message_id, string16* value) OVERRIDE; + virtual scoped_ptr GetFont( + ui::ResourceBundle::FontStyle style) OVERRIDE; + + CefRefPtr application_; + bool pack_loading_disabled_; + bool allow_pack_file_load_; +}; + +#endif // CEF_LIBCEF_COMMON_CONTENT_CLIENT_H_ diff --git a/cef3/libcef/common/http_header_utils.cc b/cef3/libcef/common/http_header_utils.cc new file mode 100644 index 000000000..249833bc5 --- /dev/null +++ b/cef3/libcef/common/http_header_utils.cc @@ -0,0 +1,43 @@ +// 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 "libcef/common/http_header_utils.h" +#include "net/http/http_response_headers.h" +#include "net/http/http_util.h" + +using net::HttpResponseHeaders; + +namespace HttpHeaderUtils { + +std::string GenerateHeaders(const HeaderMap& map) { + std::string headers; + + for (HeaderMap::const_iterator header = map.begin(); + header != map.end(); + ++header) { + const CefString& key = header->first; + const CefString& value = header->second; + + if (!key.empty()) { + // Delimit with "\r\n". + if (!headers.empty()) + headers += "\r\n"; + + headers += std::string(key) + ": " + std::string(value); + } + } + + return headers; +} + +void ParseHeaders(const std::string& header_str, HeaderMap& map) { + // Parse the request header values + for (net::HttpUtil::HeadersIterator i(header_str.begin(), + header_str.end(), "\n"); + i.GetNext(); ) { + map.insert(std::make_pair(i.name(), i.values())); + } +} + +} // namespace HttpHeaderUtils diff --git a/cef3/libcef/common/http_header_utils.h b/cef3/libcef/common/http_header_utils.h new file mode 100644 index 000000000..579b4a9cf --- /dev/null +++ b/cef3/libcef/common/http_header_utils.h @@ -0,0 +1,22 @@ +// 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. + +#ifndef CEF_LIBCEF_COMMON_HTTP_HEADER_UTILS_H_ +#define CEF_LIBCEF_COMMON_HTTP_HEADER_UTILS_H_ +#pragma once + +#include + +#include "include/cef_request.h" + +namespace HttpHeaderUtils { + +typedef CefRequest::HeaderMap HeaderMap; + +std::string GenerateHeaders(const HeaderMap& map); +void ParseHeaders(const std::string& header_str, HeaderMap& map); + +}; // namespace HttpHeaderUtils + +#endif // CEF_LIBCEF_COMMON_HTTP_HEADER_UTILS_H_ diff --git a/cef3/libcef/common/main_delegate.cc b/cef3/libcef/common/main_delegate.cc new file mode 100644 index 000000000..88e878828 --- /dev/null +++ b/cef3/libcef/common/main_delegate.cc @@ -0,0 +1,458 @@ +// Copyright (c) 2012 The Chromium 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 "libcef/common/main_delegate.h" +#include "libcef/browser/content_browser_client.h" +#include "libcef/browser/context.h" +#include "libcef/common/cef_switches.h" +#include "libcef/common/command_line_impl.h" +#include "libcef/renderer/content_renderer_client.h" + +#include "base/command_line.h" +#include "base/files/file_path.h" +#include "base/file_util.h" +#include "base/path_service.h" +#include "base/string_number_conversions.h" +#include "base/string_util.h" +#include "base/synchronization/waitable_event.h" +#include "base/threading/thread.h" +#include "chrome/common/chrome_switches.h" +#include "content/public/browser/browser_main_runner.h" +#include "content/public/browser/render_process_host.h" +#include "content/public/common/content_switches.h" +#include "content/public/common/main_function_params.h" +#include "ui/base/resource/resource_bundle.h" +#include "ui/base/ui_base_paths.h" +#include "ui/base/ui_base_switches.h" + +#if defined(OS_WIN) +#include // NOLINT(build/include_order) +#endif + +#if defined(OS_MACOSX) +#include "base/mac/bundle_locations.h" +#include "base/mac/foundation_util.h" +#include "content/public/common/content_paths.h" +#endif + +namespace { + +#if defined(OS_MACOSX) + +base::FilePath GetFrameworksPath() { + // Start out with the path to the running executable. + base::FilePath execPath; + PathService::Get(base::FILE_EXE, &execPath); + + // Get the main bundle path. + base::FilePath bundlePath = base::mac::GetAppBundlePath(execPath); + + // Go into the Contents/Frameworks directory. + return bundlePath.Append(FILE_PATH_LITERAL("Contents")) + .Append(FILE_PATH_LITERAL("Frameworks")); +} + +// The framework bundle path is used for loading resources, libraries, etc. +base::FilePath GetFrameworkBundlePath() { + return GetFrameworksPath().Append( + FILE_PATH_LITERAL("Chromium Embedded Framework.framework")); +} + +base::FilePath GetResourcesFilePath() { + return GetFrameworkBundlePath().Append(FILE_PATH_LITERAL("Resources")); +} + +void OverrideFrameworkBundlePath() { + base::mac::SetOverrideFrameworkBundlePath(GetFrameworkBundlePath()); +} + +void OverrideChildProcessPath() { + // Retrieve the name of the running executable. + base::FilePath path; + PathService::Get(base::FILE_EXE, &path); + + std::string name = path.BaseName().value(); + + base::FilePath helper_path = GetFrameworksPath() + .Append(FILE_PATH_LITERAL(name+" Helper.app")) + .Append(FILE_PATH_LITERAL("Contents")) + .Append(FILE_PATH_LITERAL("MacOS")) + .Append(FILE_PATH_LITERAL(name+" Helper")); + + PathService::Override(content::CHILD_PROCESS_EXE, helper_path); +} + +#else // !defined(OS_MACOSX) + +base::FilePath GetResourcesFilePath() { + base::FilePath pak_dir; + PathService::Get(base::DIR_MODULE, &pak_dir); + return pak_dir; +} + +#endif // !defined(OS_MACOSX) + +// Used to run the UI on a separate thread. +class CefUIThread : public base::Thread { + public: + explicit CefUIThread(const content::MainFunctionParams& main_function_params) + : base::Thread("CefUIThread"), + main_function_params_(main_function_params) { + } + + virtual void Init() OVERRIDE { +#if defined(OS_WIN) + // Initializes the COM library on the current thread. + CoInitialize(NULL); +#endif + + // Use our own browser process runner. + browser_runner_.reset(content::BrowserMainRunner::Create()); + + // Initialize browser process state. Uses the current thread's mesage loop. + int exit_code = browser_runner_->Initialize(main_function_params_); + CHECK_EQ(exit_code, -1); + } + + virtual void CleanUp() OVERRIDE { + browser_runner_->Shutdown(); + browser_runner_.reset(NULL); + +#if defined(OS_WIN) + // Closes the COM library on the current thread. CoInitialize must + // be balanced by a corresponding call to CoUninitialize. + CoUninitialize(); +#endif + } + + protected: + content::MainFunctionParams main_function_params_; + scoped_ptr browser_runner_; +}; + +} // namespace + +CefMainDelegate::CefMainDelegate(CefRefPtr application) + : content_client_(application) { +} + +CefMainDelegate::~CefMainDelegate() { +} + +bool CefMainDelegate::BasicStartupComplete(int* exit_code) { +#if defined(OS_MACOSX) + OverrideFrameworkBundlePath(); +#endif + + CommandLine* command_line = CommandLine::ForCurrentProcess(); + std::string process_type = + command_line->GetSwitchValueASCII(switches::kProcessType); + + if (process_type.empty()) { + // In the browser process. Populate the global command-line object. + const CefSettings& settings = _Context->settings(); + + if (settings.command_line_args_disabled) { + // Remove any existing command-line arguments. + CommandLine::StringVector argv; + argv.push_back(command_line->GetProgram().value()); + command_line->InitFromArgv(argv); + + const CommandLine::SwitchMap& map = command_line->GetSwitches(); + const_cast(&map)->clear(); + } + + if (settings.single_process) + command_line->AppendSwitch(switches::kSingleProcess); + + if (settings.browser_subprocess_path.length > 0) { + base::FilePath file_path = + base::FilePath(CefString(&settings.browser_subprocess_path)); + if (!file_path.empty()) { + command_line->AppendSwitchPath(switches::kBrowserSubprocessPath, + file_path); + } + } + + if (settings.user_agent.length > 0) { + command_line->AppendSwitchASCII(switches::kUserAgent, + CefString(&settings.user_agent)); + } else if (settings.product_version.length > 0) { + command_line->AppendSwitchASCII(switches::kProductVersion, + CefString(&settings.product_version)); + } + + if (settings.locale.length > 0) { + command_line->AppendSwitchASCII(switches::kLang, + CefString(&settings.locale)); + } else if (!command_line->HasSwitch(switches::kLang)) { + command_line->AppendSwitchASCII(switches::kLang, "en-US"); + } + + if (settings.log_file.length > 0) { + base::FilePath file_path = base::FilePath(CefString(&settings.log_file)); + if (!file_path.empty()) + command_line->AppendSwitchPath(switches::kLogFile, file_path); + } + + if (settings.log_severity != LOGSEVERITY_DEFAULT) { + std::string log_severity; + switch (settings.log_severity) { + case LOGSEVERITY_VERBOSE: + log_severity = switches::kLogSeverity_Verbose; + break; + case LOGSEVERITY_INFO: + log_severity = switches::kLogSeverity_Info; + break; + case LOGSEVERITY_WARNING: + log_severity = switches::kLogSeverity_Warning; + break; + case LOGSEVERITY_ERROR: + log_severity = switches::kLogSeverity_Error; + break; + case LOGSEVERITY_ERROR_REPORT: + log_severity = switches::kLogSeverity_ErrorReport; + break; + case LOGSEVERITY_DISABLE: + log_severity = switches::kLogSeverity_Disable; + break; + default: + break; + } + if (!log_severity.empty()) + command_line->AppendSwitchASCII(switches::kLogSeverity, log_severity); + } + + if (settings.release_dcheck_enabled) + command_line->AppendSwitch(switches::kEnableReleaseDcheck); + + if (settings.javascript_flags.length > 0) { + command_line->AppendSwitchASCII(switches::kJavaScriptFlags, + CefString(&settings.javascript_flags)); + } + + if (settings.pack_loading_disabled) { + command_line->AppendSwitch(switches::kDisablePackLoading); + } else { + if (settings.resources_dir_path.length > 0) { + base::FilePath file_path = + base::FilePath(CefString(&settings.resources_dir_path)); + if (!file_path.empty()) { + command_line->AppendSwitchPath(switches::kResourcesDirPath, + file_path); + } + } + + if (settings.locales_dir_path.length > 0) { + base::FilePath file_path = + base::FilePath(CefString(&settings.locales_dir_path)); + if (!file_path.empty()) + command_line->AppendSwitchPath(switches::kLocalesDirPath, file_path); + } + } + + if (settings.remote_debugging_port >= 1024 && + settings.remote_debugging_port <= 65535) { + command_line->AppendSwitchASCII(switches::kRemoteDebuggingPort, + base::IntToString(settings.remote_debugging_port)); + } + + if (settings.uncaught_exception_stack_size > 0) { + command_line->AppendSwitchASCII(switches::kUncaughtExceptionStackSize, + base::IntToString(settings.uncaught_exception_stack_size)); + } + + if (settings.context_safety_implementation != 0) { + command_line->AppendSwitchASCII(switches::kContextSafetyImplementation, + base::IntToString(settings.context_safety_implementation)); + } + + // TODO(cef): Figure out how to support the sandbox. + if (!command_line->HasSwitch(switches::kNoSandbox)) + command_line->AppendSwitch(switches::kNoSandbox); + } + + if (content_client_.application().get()) { + // Give the application a chance to view/modify the command line. + CefRefPtr commandLinePtr( + new CefCommandLineImpl(command_line, false, false)); + content_client_.application()->OnBeforeCommandLineProcessing( + CefString(process_type), commandLinePtr.get()); + commandLinePtr->Detach(NULL); + } + + // Initialize logging. + base::FilePath log_file = + command_line->GetSwitchValuePath(switches::kLogFile); + std::string log_severity_str = + command_line->GetSwitchValueASCII(switches::kLogSeverity); + + logging::LogSeverity log_severity = logging::LOG_INFO; + if (!log_severity_str.empty()) { + if (LowerCaseEqualsASCII(log_severity_str, + switches::kLogSeverity_Verbose)) { + log_severity = logging::LOG_VERBOSE; + } else if (LowerCaseEqualsASCII(log_severity_str, + switches::kLogSeverity_Warning)) { + log_severity = logging::LOG_WARNING; + } else if (LowerCaseEqualsASCII(log_severity_str, + switches::kLogSeverity_Error)) { + log_severity = logging::LOG_ERROR; + } else if (LowerCaseEqualsASCII(log_severity_str, + switches::kLogSeverity_ErrorReport)) { + log_severity = logging::LOG_ERROR_REPORT; + } else if (LowerCaseEqualsASCII(log_severity_str, + switches::kLogSeverity_Disable)) { + log_severity = LOGSEVERITY_DISABLE; + } + } + + logging::LoggingDestination logging_dest; + if (log_severity == LOGSEVERITY_DISABLE) { + logging_dest = logging::LOG_NONE; + } else { + logging_dest = logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG; + logging::SetMinLogLevel(log_severity); + } + + logging::DcheckState dcheck_state = + logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS; + if (command_line->HasSwitch(switches::kEnableReleaseDcheck)) + dcheck_state = logging::ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS; + + logging::InitLogging(log_file.value().c_str(), logging_dest, + logging::DONT_LOCK_LOG_FILE, logging::APPEND_TO_OLD_LOG_FILE, + dcheck_state); + + content::SetContentClient(&content_client_); + + return false; +} + +void CefMainDelegate::PreSandboxStartup() { +#if defined(OS_MACOSX) + OverrideChildProcessPath(); +#endif + + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + if (command_line.HasSwitch(switches::kDisablePackLoading)) + content_client_.set_pack_loading_disabled(true); + + InitializeResourceBundle(); +} + +int CefMainDelegate::RunProcess( + const std::string& process_type, + const content::MainFunctionParams& main_function_params) { + if (process_type.empty()) { + const CefSettings& settings = _Context->settings(); + if (!settings.multi_threaded_message_loop) { + // Use our own browser process runner. + browser_runner_.reset(content::BrowserMainRunner::Create()); + + // Initialize browser process state. Results in a call to + // CefBrowserMain::PreMainMessageLoopStart() which creates the UI message + // loop. + int exit_code = browser_runner_->Initialize(main_function_params); + if (exit_code >= 0) + return exit_code; + } else { + // Run the UI on a separate thread. + scoped_ptr thread; + thread.reset(new CefUIThread(main_function_params)); + base::Thread::Options options; + options.message_loop_type = MessageLoop::TYPE_UI; + if (!thread->StartWithOptions(options)) { + NOTREACHED() << "failed to start UI thread"; + return 1; + } + ui_thread_.swap(thread); + } + + return 0; + } + + return -1; +} + +void CefMainDelegate::ProcessExiting(const std::string& process_type) { + ResourceBundle::CleanupSharedInstance(); +} + + +content::ContentBrowserClient* CefMainDelegate::CreateContentBrowserClient() { + browser_client_.reset(new CefContentBrowserClient); + return browser_client_.get(); +} + +content::ContentRendererClient* + CefMainDelegate::CreateContentRendererClient() { + renderer_client_.reset(new CefContentRendererClient); + return renderer_client_.get(); +} + +void CefMainDelegate::ShutdownBrowser() { + if (browser_runner_.get()) { + browser_runner_->Shutdown(); + browser_runner_.reset(NULL); + } + if (ui_thread_.get()) { + // Blocks until the thread has stopped. + ui_thread_->Stop(); + ui_thread_.reset(); + } +} + +void CefMainDelegate::InitializeResourceBundle() { + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + base::FilePath cef_pak_file, devtools_pak_file, locales_dir; + + if (!content_client_.pack_loading_disabled()) { + base::FilePath resources_dir; + if (command_line.HasSwitch(switches::kResourcesDirPath)) { + resources_dir = + command_line.GetSwitchValuePath(switches::kResourcesDirPath); + } + if (resources_dir.empty()) + resources_dir = GetResourcesFilePath(); + + if (!resources_dir.empty()) { + cef_pak_file = resources_dir.Append(FILE_PATH_LITERAL("cef.pak")); + devtools_pak_file = + resources_dir.Append(FILE_PATH_LITERAL("devtools_resources.pak")); + } + + if (command_line.HasSwitch(switches::kLocalesDirPath)) + locales_dir = command_line.GetSwitchValuePath(switches::kLocalesDirPath); + + if (!locales_dir.empty()) + PathService::Override(ui::DIR_LOCALES, locales_dir); + } + + std::string locale = command_line.GetSwitchValueASCII(switches::kLang); + DCHECK(!locale.empty()); + + const std::string loaded_locale = + ui::ResourceBundle::InitSharedInstanceWithLocale(locale, + &content_client_); + if (!content_client_.pack_loading_disabled()) { + CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale; + + content_client_.set_allow_pack_file_load(true); + + if (file_util::PathExists(cef_pak_file)) { + ResourceBundle::GetSharedInstance().AddDataPackFromPath( + cef_pak_file, ui::SCALE_FACTOR_NONE); + } else { + NOTREACHED() << "Could not load cef.pak"; + } + + if (file_util::PathExists(devtools_pak_file)) { + ResourceBundle::GetSharedInstance().AddDataPackFromPath( + devtools_pak_file, ui::SCALE_FACTOR_NONE); + } + + content_client_.set_allow_pack_file_load(false); + } +} diff --git a/cef3/libcef/common/main_delegate.h b/cef3/libcef/common/main_delegate.h new file mode 100644 index 000000000..d532b69b5 --- /dev/null +++ b/cef3/libcef/common/main_delegate.h @@ -0,0 +1,66 @@ +// Copyright (c) 2011 The Chromium 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_LIBCEF_COMMON_MAIN_DELEGATE_H_ +#define CEF_LIBCEF_COMMON_MAIN_DELEGATE_H_ +#pragma once + +#include + +#include "libcef/common/content_client.h" +#include "include/cef_app.h" + +#include "base/compiler_specific.h" +#include "base/memory/scoped_ptr.h" +#include "content/public/app/content_main_delegate.h" + +namespace base { +class Thread; +} + +namespace content { +class BrowserMainRunner; +} + +class CefContentBrowserClient; +class CefContentRendererClient; +class CefContentPluginClient; +class CefContentUtilityClient; +class MessageLoop; + +class CefMainDelegate : public content::ContentMainDelegate { + public: + explicit CefMainDelegate(CefRefPtr application); + virtual ~CefMainDelegate(); + + virtual bool BasicStartupComplete(int* exit_code) OVERRIDE; + virtual void PreSandboxStartup() OVERRIDE; + virtual int RunProcess( + const std::string& process_type, + const content::MainFunctionParams& main_function_params) OVERRIDE; + virtual void ProcessExiting(const std::string& process_type) OVERRIDE; + virtual content::ContentBrowserClient* CreateContentBrowserClient() OVERRIDE; + virtual content::ContentRendererClient* + CreateContentRendererClient() OVERRIDE; + + // Shut down the browser runner. + void ShutdownBrowser(); + + CefContentBrowserClient* browser_client() { return browser_client_.get(); } + CefContentClient* content_client() { return &content_client_; } + + private: + void InitializeResourceBundle(); + + scoped_ptr browser_runner_; + scoped_ptr ui_thread_; + + scoped_ptr browser_client_; + scoped_ptr renderer_client_; + CefContentClient content_client_; + + DISALLOW_COPY_AND_ASSIGN(CefMainDelegate); +}; + +#endif // CEF_LIBCEF_COMMON_MAIN_DELEGATE_H_ diff --git a/cef3/libcef/common/process_message_impl.cc b/cef3/libcef/common/process_message_impl.cc new file mode 100644 index 000000000..e6dabd87e --- /dev/null +++ b/cef3/libcef/common/process_message_impl.cc @@ -0,0 +1,76 @@ +// 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 "libcef/common/process_message_impl.h" +#include "libcef/common/cef_messages.h" +#include "libcef/common/values_impl.h" + +#include "base/logging.h" + +namespace { + +void CopyList(const base::ListValue& source, + base::ListValue& target) { + base::ListValue::const_iterator it = source.begin(); + for (; it != source.end(); ++it) + target.Append((*it)->DeepCopy()); +} + +void CopyValue(const Cef_Request_Params& source, + Cef_Request_Params& target) { + target.name = source.name; + CopyList(source.arguments, target.arguments); +} + +} // namespace + +// static +CefRefPtr CefProcessMessage::Create(const CefString& name) { + Cef_Request_Params* params = new Cef_Request_Params(); + params->name = name; + return new CefProcessMessageImpl(params, true, false); +} + +CefProcessMessageImpl::CefProcessMessageImpl(Cef_Request_Params* value, + bool will_delete, + bool read_only) + : CefValueBase( + value, NULL, will_delete ? kOwnerWillDelete : kOwnerNoDelete, + read_only, NULL) { +} + +bool CefProcessMessageImpl::CopyTo(Cef_Request_Params& target) { + CEF_VALUE_VERIFY_RETURN(false, false); + CopyValue(const_value(), target); + return true; +} + +bool CefProcessMessageImpl::IsValid() { + return !detached(); +} + +bool CefProcessMessageImpl::IsReadOnly() { + return read_only(); +} + +CefRefPtr CefProcessMessageImpl::Copy() { + CEF_VALUE_VERIFY_RETURN(false, NULL); + Cef_Request_Params* params = new Cef_Request_Params(); + CopyValue(const_value(), *params); + return new CefProcessMessageImpl(params, true, false); +} + +CefString CefProcessMessageImpl::GetName() { + CEF_VALUE_VERIFY_RETURN(false, CefString()); + return const_value().name; +} + +CefRefPtr CefProcessMessageImpl::GetArgumentList() { + CEF_VALUE_VERIFY_RETURN(false, NULL); + return CefListValueImpl::GetOrCreateRef( + const_cast(&(const_value().arguments)), + const_cast(&const_value()), + read_only(), + controller()); +} diff --git a/cef3/libcef/common/process_message_impl.h b/cef3/libcef/common/process_message_impl.h new file mode 100644 index 000000000..28e078a90 --- /dev/null +++ b/cef3/libcef/common/process_message_impl.h @@ -0,0 +1,35 @@ +// 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. + +#ifndef CEF_LIBCEF_COMMON_PROCESS_MESSAGE_IMPL_H_ +#define CEF_LIBCEF_COMMON_PROCESS_MESSAGE_IMPL_H_ +#pragma once + +#include "include/cef_process_message.h" +#include "libcef/common/value_base.h" + +struct Cef_Request_Params; + +// CefProcessMessage implementation +class CefProcessMessageImpl + : public CefValueBase { + public: + CefProcessMessageImpl(Cef_Request_Params* value, + bool will_delete, + bool read_only); + + // Copies the underlying value to the specified |target| structure. + bool CopyTo(Cef_Request_Params& target); + + // CefProcessMessage methods. + virtual bool IsValid() OVERRIDE; + virtual bool IsReadOnly() OVERRIDE; + virtual CefRefPtr Copy() OVERRIDE; + virtual CefString GetName() OVERRIDE; + virtual CefRefPtr GetArgumentList() OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(CefProcessMessageImpl); +}; + +#endif // CEF_LIBCEF_COMMON_PROCESS_MESSAGE_IMPL_H_ diff --git a/cef3/libcef/common/request_impl.cc b/cef3/libcef/common/request_impl.cc new file mode 100644 index 000000000..d2ad13548 --- /dev/null +++ b/cef3/libcef/common/request_impl.cc @@ -0,0 +1,779 @@ +// Copyright (c) 2008-2009 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 +#include + +#include "libcef/common/http_header_utils.h" +#include "libcef/common/request_impl.h" +#include "libcef/common/task_runner_impl.h" + +#include "base/logging.h" +#include "net/base/upload_data.h" +#include "net/base/upload_data_stream.h" +#include "net/base/upload_element_reader.h" +#include "net/base/upload_bytes_element_reader.h" +#include "net/base/upload_file_element_reader.h" +#include "net/http/http_request_headers.h" +#include "net/url_request/url_request.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebHTTPHeaderVisitor.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebURLError.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h" + +namespace { + +// A subclass of net::UploadBytesElementReader that keeps the associated +// UploadElement alive until the request completes. +class BytesElementReader : public net::UploadBytesElementReader { + public: + explicit BytesElementReader(scoped_ptr element) + : net::UploadBytesElementReader(element->bytes(), + element->bytes_length()), + element_(element.Pass()) { + DCHECK_EQ(net::UploadElement::TYPE_BYTES, element_->type()); + } + + virtual ~BytesElementReader() {} + + private: + scoped_ptr element_; + + DISALLOW_COPY_AND_ASSIGN(BytesElementReader); +}; + +base::TaskRunner* GetFileTaskRunner() { + scoped_refptr task_runner = + CefTaskRunnerImpl::GetTaskRunner(TID_FILE); + DCHECK(task_runner); + return task_runner; +} + +// A subclass of net::UploadFileElementReader that keeps the associated +// UploadElement alive until the request completes. +class FileElementReader : public net::UploadFileElementReader { + public: + explicit FileElementReader(scoped_ptr element) + : net::UploadFileElementReader( + GetFileTaskRunner(), + element->file_path(), + element->file_range_offset(), + element->file_range_length(), + element->expected_file_modification_time()), + element_(element.Pass()) { + DCHECK_EQ(net::UploadElement::TYPE_FILE, element_->type()); + } + + virtual ~FileElementReader() {} + + private: + scoped_ptr element_; + + DISALLOW_COPY_AND_ASSIGN(FileElementReader); +}; + +} // namespace + + +#define CHECK_READONLY_RETURN(val) \ + if (read_only_) { \ + NOTREACHED() << "object is read only"; \ + return val; \ + } + +#define CHECK_READONLY_RETURN_VOID() \ + if (read_only_) { \ + NOTREACHED() << "object is read only"; \ + return; \ + } + + +// CefRequest ----------------------------------------------------------------- + +// static +CefRefPtr CefRequest::Create() { + CefRefPtr request(new CefRequestImpl()); + return request; +} + + +// CefRequestImpl ------------------------------------------------------------- + +CefRequestImpl::CefRequestImpl() + : method_("GET"), + flags_(UR_FLAG_NONE), + read_only_(false) { +} + +bool CefRequestImpl::IsReadOnly() { + AutoLock lock_scope(this); + return read_only_; +} + +CefString CefRequestImpl::GetURL() { + AutoLock lock_scope(this); + return url_; +} + +void CefRequestImpl::SetURL(const CefString& url) { + AutoLock lock_scope(this); + CHECK_READONLY_RETURN_VOID(); + url_ = url; +} + +CefString CefRequestImpl::GetMethod() { + AutoLock lock_scope(this); + return method_; +} + +void CefRequestImpl::SetMethod(const CefString& method) { + AutoLock lock_scope(this); + CHECK_READONLY_RETURN_VOID(); + method_ = method; +} + +CefRefPtr CefRequestImpl::GetPostData() { + AutoLock lock_scope(this); + return postdata_; +} + +void CefRequestImpl::SetPostData(CefRefPtr postData) { + AutoLock lock_scope(this); + CHECK_READONLY_RETURN_VOID(); + postdata_ = postData; +} + +void CefRequestImpl::GetHeaderMap(HeaderMap& headerMap) { + AutoLock lock_scope(this); + headerMap = headermap_; +} + +void CefRequestImpl::SetHeaderMap(const HeaderMap& headerMap) { + AutoLock lock_scope(this); + CHECK_READONLY_RETURN_VOID(); + headermap_ = headerMap; +} + +void CefRequestImpl::Set(const CefString& url, + const CefString& method, + CefRefPtr postData, + const HeaderMap& headerMap) { + AutoLock lock_scope(this); + CHECK_READONLY_RETURN_VOID(); + url_ = url; + method_ = method; + postdata_ = postData; + headermap_ = headerMap; +} + +int CefRequestImpl::GetFlags() { + AutoLock lock_scope(this); + return flags_; +} +void CefRequestImpl::SetFlags(int flags) { + AutoLock lock_scope(this); + CHECK_READONLY_RETURN_VOID(); + flags_ = flags; +} + +CefString CefRequestImpl::GetFirstPartyForCookies() { + AutoLock lock_scope(this); + return first_party_for_cookies_; +} +void CefRequestImpl::SetFirstPartyForCookies(const CefString& url) { + AutoLock lock_scope(this); + CHECK_READONLY_RETURN_VOID(); + first_party_for_cookies_ = url; +} + +void CefRequestImpl::Set(net::URLRequest* request) { + AutoLock lock_scope(this); + CHECK_READONLY_RETURN_VOID(); + + url_ = request->url().spec(); + method_ = request->method(); + first_party_for_cookies_ = request->first_party_for_cookies().spec(); + + net::HttpRequestHeaders headers = request->extra_request_headers(); + + // Ensure that we do not send username and password fields in the referrer. + GURL referrer(request->GetSanitizedReferrer()); + + // Strip Referer from request_info_.extra_headers to prevent, e.g., plugins + // from overriding headers that are controlled using other means. Otherwise a + // plugin could set a referrer although sending the referrer is inhibited. + headers.RemoveHeader(net::HttpRequestHeaders::kReferer); + + // Our consumer should have made sure that this is a safe referrer. See for + // instance WebCore::FrameLoader::HideReferrer. + if (referrer.is_valid()) + headers.SetHeader(net::HttpRequestHeaders::kReferer, referrer.spec()); + + // Transfer request headers + GetHeaderMap(headers, headermap_); + + // Transfer post data, if any + const net::UploadDataStream* data = request->get_upload(); + if (data) { + postdata_ = CefPostData::Create(); + static_cast(postdata_.get())->Set(*data); + } else if (postdata_.get()) { + postdata_ = NULL; + } +} + +void CefRequestImpl::Get(net::URLRequest* request) { + AutoLock lock_scope(this); + + request->set_method(method_); + if (!first_party_for_cookies_.empty()) { + request->set_first_party_for_cookies( + GURL(std::string(first_party_for_cookies_))); + } + + CefString referrerStr; + referrerStr.FromASCII(net::HttpRequestHeaders::kReferer); + HeaderMap headerMap = headermap_; + HeaderMap::iterator it = headerMap.find(referrerStr); + if (it == headerMap.end()) { + request->set_referrer(""); + } else { + request->set_referrer(it->second); + headerMap.erase(it); + } + net::HttpRequestHeaders headers; + headers.AddHeadersFromString(HttpHeaderUtils::GenerateHeaders(headerMap)); + request->SetExtraRequestHeaders(headers); + + if (postdata_.get()) { + request->set_upload( + make_scoped_ptr(static_cast(postdata_.get())->Get())); + } else if (request->get_upload()) { + request->set_upload(scoped_ptr()); + } +} + +void CefRequestImpl::Set(const WebKit::WebURLRequest& request) { + DCHECK(!request.isNull()); + + AutoLock lock_scope(this); + CHECK_READONLY_RETURN_VOID(); + + url_ = request.url().spec().utf16(); + method_ = request.httpMethod(); + + const WebKit::WebHTTPBody& body = request.httpBody(); + if (!body.isNull()) { + postdata_ = new CefPostDataImpl(); + static_cast(postdata_.get())->Set(body); + } else if (postdata_.get()) { + postdata_ = NULL; + } + + headermap_.clear(); + GetHeaderMap(request, headermap_); + + flags_ = UR_FLAG_NONE; + if (request.cachePolicy() == WebKit::WebURLRequest::ReloadIgnoringCacheData) + flags_ |= UR_FLAG_SKIP_CACHE; + if (request.allowStoredCredentials()) + flags_ |= UR_FLAG_ALLOW_CACHED_CREDENTIALS; + if (request.allowCookies()) + flags_ |= UR_FLAG_ALLOW_COOKIES; + if (request.reportUploadProgress()) + flags_ |= UR_FLAG_REPORT_UPLOAD_PROGRESS; + if (request.reportLoadTiming()) + flags_ |= UR_FLAG_REPORT_LOAD_TIMING; + if (request.reportRawHeaders()) + flags_ |= UR_FLAG_REPORT_RAW_HEADERS; + + first_party_for_cookies_ = request.firstPartyForCookies().spec().utf16(); +} + +void CefRequestImpl::Get(WebKit::WebURLRequest& request) { + request.initialize(); + AutoLock lock_scope(this); + + GURL gurl = GURL(url_.ToString()); + request.setURL(WebKit::WebURL(gurl)); + + std::string method(method_); + request.setHTTPMethod(WebKit::WebString::fromUTF8(method.c_str())); + request.setTargetType(WebKit::WebURLRequest::TargetIsMainFrame); + + WebKit::WebHTTPBody body; + if (postdata_.get()) { + body.initialize(); + static_cast(postdata_.get())->Get(body); + request.setHTTPBody(body); + } + + SetHeaderMap(headermap_, request); + + request.setCachePolicy((flags_ & UR_FLAG_SKIP_CACHE) ? + WebKit::WebURLRequest::ReloadIgnoringCacheData : + WebKit::WebURLRequest::UseProtocolCachePolicy); + + #define SETBOOLFLAG(obj, flags, method, FLAG) \ + obj.method((flags & (FLAG)) == (FLAG)) + + SETBOOLFLAG(request, flags_, setAllowStoredCredentials, + UR_FLAG_ALLOW_CACHED_CREDENTIALS); + SETBOOLFLAG(request, flags_, setAllowCookies, + UR_FLAG_ALLOW_COOKIES); + SETBOOLFLAG(request, flags_, setReportUploadProgress, + UR_FLAG_REPORT_UPLOAD_PROGRESS); + SETBOOLFLAG(request, flags_, setReportLoadTiming, + UR_FLAG_REPORT_LOAD_TIMING); + SETBOOLFLAG(request, flags_, setReportRawHeaders, + UR_FLAG_REPORT_RAW_HEADERS); + + if (!first_party_for_cookies_.empty()) { + GURL gurl = GURL(first_party_for_cookies_.ToString()); + request.setFirstPartyForCookies(WebKit::WebURL(gurl)); + } +} + +void CefRequestImpl::SetReadOnly(bool read_only) { + AutoLock lock_scope(this); + if (read_only_ == read_only) + return; + + read_only_ = read_only; + + if (postdata_.get()) + static_cast(postdata_.get())->SetReadOnly(read_only); +} + +// static +void CefRequestImpl::GetHeaderMap(const net::HttpRequestHeaders& headers, + HeaderMap& map) { + if (headers.IsEmpty()) + return; + + net::HttpRequestHeaders::Iterator it(headers); + do { + map.insert(std::make_pair(it.name(), it.value())); + } while (it.GetNext()); +} + + +// static +void CefRequestImpl::GetHeaderMap(const WebKit::WebURLRequest& request, + HeaderMap& map) { + class HeaderVisitor : public WebKit::WebHTTPHeaderVisitor { + public: + explicit HeaderVisitor(HeaderMap* map) : map_(map) {} + + virtual void visitHeader(const WebKit::WebString& name, + const WebKit::WebString& value) { + map_->insert(std::make_pair(string16(name), string16(value))); + } + + private: + HeaderMap* map_; + }; + + HeaderVisitor visitor(&map); + request.visitHTTPHeaderFields(&visitor); +} + +// static +void CefRequestImpl::SetHeaderMap(const HeaderMap& map, + WebKit::WebURLRequest& request) { + HeaderMap::const_iterator it = map.begin(); + for (; it != map.end(); ++it) + request.setHTTPHeaderField(string16(it->first), string16(it->second)); +} + +// CefPostData ---------------------------------------------------------------- + +// static +CefRefPtr CefPostData::Create() { + CefRefPtr postdata(new CefPostDataImpl()); + return postdata; +} + + +// CefPostDataImpl ------------------------------------------------------------ + +CefPostDataImpl::CefPostDataImpl() + : read_only_(false) { +} + +bool CefPostDataImpl::IsReadOnly() { + AutoLock lock_scope(this); + return read_only_; +} + +size_t CefPostDataImpl::GetElementCount() { + AutoLock lock_scope(this); + return elements_.size(); +} + +void CefPostDataImpl::GetElements(ElementVector& elements) { + AutoLock lock_scope(this); + elements = elements_; +} + +bool CefPostDataImpl::RemoveElement(CefRefPtr element) { + AutoLock lock_scope(this); + CHECK_READONLY_RETURN(false); + + ElementVector::iterator it = elements_.begin(); + for (; it != elements_.end(); ++it) { + if (it->get() == element.get()) { + elements_.erase(it); + return true; + } + } + + return false; +} + +bool CefPostDataImpl::AddElement(CefRefPtr element) { + bool found = false; + + AutoLock lock_scope(this); + CHECK_READONLY_RETURN(false); + + // check that the element isn't already in the list before adding + ElementVector::const_iterator it = elements_.begin(); + for (; it != elements_.end(); ++it) { + if (it->get() == element.get()) { + found = true; + break; + } + } + + if (!found) + elements_.push_back(element); + + return !found; +} + +void CefPostDataImpl::RemoveElements() { + AutoLock lock_scope(this); + CHECK_READONLY_RETURN_VOID(); + elements_.clear(); +} + +void CefPostDataImpl::Set(const net::UploadData& data) { + AutoLock lock_scope(this); + CHECK_READONLY_RETURN_VOID(); + + CefRefPtr postelem; + + const ScopedVector& elements = data.elements(); + ScopedVector::const_iterator it = elements.begin(); + for (; it != elements.end(); ++it) { + postelem = CefPostDataElement::Create(); + static_cast(postelem.get())->Set(**it); + AddElement(postelem); + } +} + +void CefPostDataImpl::Set(const net::UploadDataStream& data_stream) { + AutoLock lock_scope(this); + CHECK_READONLY_RETURN_VOID(); + + CefRefPtr postelem; + + const ScopedVector& elements = + data_stream.element_readers(); + ScopedVector::const_iterator it = elements.begin(); + for (; it != elements.end(); ++it) { + postelem = CefPostDataElement::Create(); + static_cast(postelem.get())->Set(**it); + AddElement(postelem); + } +} + +void CefPostDataImpl::Get(net::UploadData& data) { + AutoLock lock_scope(this); + + ScopedVector data_elements; + ElementVector::const_iterator it = elements_.begin(); + for (; it != elements_.end(); ++it) { + net::UploadElement* element = new net::UploadElement(); + static_cast(it->get())->Get(*element); + data_elements.push_back(element); + } + data.swap_elements(&data_elements); +} + +net::UploadDataStream* CefPostDataImpl::Get() { + AutoLock lock_scope(this); + + ScopedVector element_readers; + ElementVector::const_iterator it = elements_.begin(); + for (; it != elements_.end(); ++it) { + element_readers.push_back( + static_cast(it->get())->Get()); + } + + return new net::UploadDataStream(&element_readers, 0); +} + +void CefPostDataImpl::Set(const WebKit::WebHTTPBody& data) { + AutoLock lock_scope(this); + CHECK_READONLY_RETURN_VOID(); + + CefRefPtr postelem; + WebKit::WebHTTPBody::Element element; + size_t size = data.elementCount(); + for (size_t i = 0; i < size; ++i) { + if (data.elementAt(i, element)) { + postelem = CefPostDataElement::Create(); + static_cast(postelem.get())->Set(element); + AddElement(postelem); + } + } +} + +void CefPostDataImpl::Get(WebKit::WebHTTPBody& data) { + AutoLock lock_scope(this); + + WebKit::WebHTTPBody::Element element; + ElementVector::iterator it = elements_.begin(); + for (; it != elements_.end(); ++it) { + static_cast(it->get())->Get(element); + if (element.type == WebKit::WebHTTPBody::Element::TypeData) { + data.appendData(element.data); + } else if (element.type == WebKit::WebHTTPBody::Element::TypeFile) { + data.appendFile(element.filePath); + } else { + NOTREACHED(); + } + } +} + +void CefPostDataImpl::SetReadOnly(bool read_only) { + AutoLock lock_scope(this); + if (read_only_ == read_only) + return; + + read_only_ = read_only; + + ElementVector::const_iterator it = elements_.begin(); + for (; it != elements_.end(); ++it) { + static_cast(it->get())->SetReadOnly(read_only); + } +} + +// CefPostDataElement --------------------------------------------------------- + +// static +CefRefPtr CefPostDataElement::Create() { + CefRefPtr element(new CefPostDataElementImpl()); + return element; +} + + +// CefPostDataElementImpl ----------------------------------------------------- + +CefPostDataElementImpl::CefPostDataElementImpl() + : type_(PDE_TYPE_EMPTY), + read_only_(false) { + memset(&data_, 0, sizeof(data_)); +} + +CefPostDataElementImpl::~CefPostDataElementImpl() { + Cleanup(); +} + +bool CefPostDataElementImpl::IsReadOnly() { + AutoLock lock_scope(this); + return read_only_; +} + +void CefPostDataElementImpl::SetToEmpty() { + AutoLock lock_scope(this); + CHECK_READONLY_RETURN_VOID(); + + Cleanup(); +} + +void CefPostDataElementImpl::SetToFile(const CefString& fileName) { + AutoLock lock_scope(this); + CHECK_READONLY_RETURN_VOID(); + + // Clear any data currently in the element + SetToEmpty(); + + // Assign the new data + type_ = PDE_TYPE_FILE; + cef_string_copy(fileName.c_str(), fileName.length(), &data_.filename); +} + +void CefPostDataElementImpl::SetToBytes(size_t size, const void* bytes) { + AutoLock lock_scope(this); + CHECK_READONLY_RETURN_VOID(); + + // Clear any data currently in the element + SetToEmpty(); + + // Assign the new data + void* data = malloc(size); + DCHECK(data != NULL); + if (data == NULL) + return; + + memcpy(data, bytes, size); + + type_ = PDE_TYPE_BYTES; + data_.bytes.bytes = data; + data_.bytes.size = size; +} + +CefPostDataElement::Type CefPostDataElementImpl::GetType() { + AutoLock lock_scope(this); + return type_; +} + +CefString CefPostDataElementImpl::GetFile() { + AutoLock lock_scope(this); + DCHECK(type_ == PDE_TYPE_FILE); + CefString filename; + if (type_ == PDE_TYPE_FILE) + filename.FromString(data_.filename.str, data_.filename.length, false); + return filename; +} + +size_t CefPostDataElementImpl::GetBytesCount() { + AutoLock lock_scope(this); + DCHECK(type_ == PDE_TYPE_BYTES); + size_t size = 0; + if (type_ == PDE_TYPE_BYTES) + size = data_.bytes.size; + return size; +} + +size_t CefPostDataElementImpl::GetBytes(size_t size, void* bytes) { + AutoLock lock_scope(this); + DCHECK(type_ == PDE_TYPE_BYTES); + size_t rv = 0; + if (type_ == PDE_TYPE_BYTES) { + rv = (size < data_.bytes.size ? size : data_.bytes.size); + memcpy(bytes, data_.bytes.bytes, rv); + } + return rv; +} + +void CefPostDataElementImpl::Set(const net::UploadElement& element) { + AutoLock lock_scope(this); + CHECK_READONLY_RETURN_VOID(); + + if (element.type() == net::UploadElement::TYPE_BYTES) { + SetToBytes(element.bytes_length(), element.bytes()); + } else if (element.type() == net::UploadElement::TYPE_FILE) { + SetToFile(element.file_path().value()); + } else { + NOTREACHED(); + } +} + +void CefPostDataElementImpl::Set( + const net::UploadElementReader& element_reader) { + AutoLock lock_scope(this); + CHECK_READONLY_RETURN_VOID(); + + const net::UploadBytesElementReader* bytes_reader = + element_reader.AsBytesReader(); + if (bytes_reader) { + SetToBytes(bytes_reader->length(), bytes_reader->bytes()); + return; + } + + const net::UploadFileElementReader* file_reader = + element_reader.AsFileReader(); + if (file_reader) { + SetToFile(file_reader->path().value()); + return; + } + + NOTREACHED(); +} + +void CefPostDataElementImpl::Get(net::UploadElement& element) { + AutoLock lock_scope(this); + + if (type_ == PDE_TYPE_BYTES) { + element.SetToBytes(static_cast(data_.bytes.bytes), data_.bytes.size); + } else if (type_ == PDE_TYPE_FILE) { + base::FilePath path = base::FilePath(CefString(&data_.filename)); + element.SetToFilePath(path); + } else { + NOTREACHED(); + } +} + +net::UploadElementReader* CefPostDataElementImpl::Get() { + AutoLock lock_scope(this); + + if (type_ == PDE_TYPE_BYTES) { + net::UploadElement* element = new net::UploadElement(); + element->SetToBytes(static_cast(data_.bytes.bytes), + data_.bytes.size); + return new BytesElementReader(make_scoped_ptr(element)); + } else if (type_ == PDE_TYPE_FILE) { + net::UploadElement* element = new net::UploadElement(); + base::FilePath path = base::FilePath(CefString(&data_.filename)); + element->SetToFilePath(path); + return new FileElementReader(make_scoped_ptr(element)); + } else { + NOTREACHED(); + return NULL; + } +} + +void CefPostDataElementImpl::Set(const WebKit::WebHTTPBody::Element& element) { + AutoLock lock_scope(this); + CHECK_READONLY_RETURN_VOID(); + + if (element.type == WebKit::WebHTTPBody::Element::TypeData) { + SetToBytes(element.data.size(), + static_cast(element.data.data())); + } else if (element.type == WebKit::WebHTTPBody::Element::TypeFile) { + SetToFile(string16(element.filePath)); + } else { + NOTREACHED(); + } +} + +void CefPostDataElementImpl::Get(WebKit::WebHTTPBody::Element& element) { + AutoLock lock_scope(this); + + if (type_ == PDE_TYPE_BYTES) { + element.type = WebKit::WebHTTPBody::Element::TypeData; + element.data.assign( + static_cast(data_.bytes.bytes), data_.bytes.size); + } else if (type_ == PDE_TYPE_FILE) { + element.type = WebKit::WebHTTPBody::Element::TypeFile; + element.filePath.assign(string16(CefString(&data_.filename))); + } else { + NOTREACHED(); + } +} + +void CefPostDataElementImpl::SetReadOnly(bool read_only) { + AutoLock lock_scope(this); + if (read_only_ == read_only) + return; + + read_only_ = read_only; +} + +void CefPostDataElementImpl::Cleanup() { + if (type_ == PDE_TYPE_EMPTY) + return; + + if (type_ == PDE_TYPE_BYTES) + free(data_.bytes.bytes); + else if (type_ == PDE_TYPE_FILE) + cef_string_clear(&data_.filename); + type_ = PDE_TYPE_EMPTY; + memset(&data_, 0, sizeof(data_)); +} diff --git a/cef3/libcef/common/request_impl.h b/cef3/libcef/common/request_impl.h new file mode 100644 index 000000000..ec9737cb2 --- /dev/null +++ b/cef3/libcef/common/request_impl.h @@ -0,0 +1,164 @@ +// 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. + +#ifndef CEF_LIBCEF_COMMON_REQUEST_IMPL_H_ +#define CEF_LIBCEF_COMMON_REQUEST_IMPL_H_ +#pragma once + +#include "include/cef_request.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebHTTPBody.h" + +namespace net { +class HttpRequestHeaders; +class UploadData; +class UploadDataStream; +class UploadElement; +class UploadElementReader; +class URLRequest; +}; + +namespace WebKit { +class WebURLRequest; +} + +// Implementation of CefRequest +class CefRequestImpl : public CefRequest { + public: + CefRequestImpl(); + ~CefRequestImpl() {} + + virtual bool IsReadOnly() OVERRIDE; + virtual CefString GetURL() OVERRIDE; + virtual void SetURL(const CefString& url) OVERRIDE; + virtual CefString GetMethod() OVERRIDE; + virtual void SetMethod(const CefString& method) OVERRIDE; + virtual CefRefPtr GetPostData() OVERRIDE; + virtual void SetPostData(CefRefPtr postData) OVERRIDE; + virtual void GetHeaderMap(HeaderMap& headerMap) OVERRIDE; + virtual void SetHeaderMap(const HeaderMap& headerMap) OVERRIDE; + virtual void Set(const CefString& url, + const CefString& method, + CefRefPtr postData, + const HeaderMap& headerMap) OVERRIDE; + virtual int GetFlags() OVERRIDE; + virtual void SetFlags(int flags) OVERRIDE; + virtual CefString GetFirstPartyForCookies() OVERRIDE; + virtual void SetFirstPartyForCookies(const CefString& url) OVERRIDE; + + // Populate this object from the URLRequest object. + void Set(net::URLRequest* request); + + // Populate the URLRequest object from this object. + void Get(net::URLRequest* request); + + // Populate this object from a WebURLRequest object. + void Set(const WebKit::WebURLRequest& request); + + // Populate the WebURLRequest object from this object. + void Get(WebKit::WebURLRequest& request); + + void SetReadOnly(bool read_only); + + static void GetHeaderMap(const net::HttpRequestHeaders& headers, + HeaderMap& map); + static void GetHeaderMap(const WebKit::WebURLRequest& request, + HeaderMap& map); + static void SetHeaderMap(const HeaderMap& map, + WebKit::WebURLRequest& request); + + protected: + CefString url_; + CefString method_; + CefRefPtr postdata_; + HeaderMap headermap_; + + // The below members are used by CefURLRequest. + int flags_; + CefString first_party_for_cookies_; + + // True if this object is read-only. + bool read_only_; + + IMPLEMENT_REFCOUNTING(CefRequestImpl); + IMPLEMENT_LOCKING(CefRequestImpl); +}; + +// Implementation of CefPostData +class CefPostDataImpl : public CefPostData { + public: + CefPostDataImpl(); + ~CefPostDataImpl() {} + + virtual bool IsReadOnly() OVERRIDE; + virtual size_t GetElementCount() OVERRIDE; + virtual void GetElements(ElementVector& elements) OVERRIDE; + virtual bool RemoveElement(CefRefPtr element) OVERRIDE; + virtual bool AddElement(CefRefPtr element) OVERRIDE; + virtual void RemoveElements(); + + void Set(const net::UploadData& data); + void Set(const net::UploadDataStream& data_stream); + void Get(net::UploadData& data); + net::UploadDataStream* Get(); + void Set(const WebKit::WebHTTPBody& data); + void Get(WebKit::WebHTTPBody& data); + + void SetReadOnly(bool read_only); + + protected: + ElementVector elements_; + + // True if this object is read-only. + bool read_only_; + + IMPLEMENT_REFCOUNTING(CefPostDataImpl); + IMPLEMENT_LOCKING(CefPostDataImpl); +}; + +// Implementation of CefPostDataElement +class CefPostDataElementImpl : public CefPostDataElement { + public: + CefPostDataElementImpl(); + ~CefPostDataElementImpl(); + + virtual bool IsReadOnly() OVERRIDE; + virtual void SetToEmpty() OVERRIDE; + virtual void SetToFile(const CefString& fileName) OVERRIDE; + virtual void SetToBytes(size_t size, const void* bytes) OVERRIDE; + virtual Type GetType() OVERRIDE; + virtual CefString GetFile() OVERRIDE; + virtual size_t GetBytesCount() OVERRIDE; + virtual size_t GetBytes(size_t size, void* bytes) OVERRIDE; + + void* GetBytes() { return data_.bytes.bytes; } + + void Set(const net::UploadElement& element); + void Set(const net::UploadElementReader& element_reader); + void Get(net::UploadElement& element); + net::UploadElementReader* Get(); + void Set(const WebKit::WebHTTPBody::Element& element); + void Get(WebKit::WebHTTPBody::Element& element); + + void SetReadOnly(bool read_only); + + protected: + void Cleanup(); + + Type type_; + union { + struct { + void* bytes; + size_t size; + } bytes; + cef_string_t filename; + } data_; + + // True if this object is read-only. + bool read_only_; + + IMPLEMENT_REFCOUNTING(CefPostDataElementImpl); + IMPLEMENT_LOCKING(CefPostDataElementImpl); +}; + +#endif // CEF_LIBCEF_COMMON_REQUEST_IMPL_H_ diff --git a/cef3/libcef/common/response_impl.cc b/cef3/libcef/common/response_impl.cc new file mode 100644 index 000000000..1d57dc437 --- /dev/null +++ b/cef3/libcef/common/response_impl.cc @@ -0,0 +1,204 @@ +// 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 "libcef/common/response_impl.h" + +#include + +#include "base/logging.h" +#include "base/stringprintf.h" +#include "net/http/http_request_headers.h" +#include "net/http/http_response_headers.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebHTTPHeaderVisitor.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebURLResponse.h" + + +#define CHECK_READONLY_RETURN_VOID() \ + if (read_only_) { \ + NOTREACHED() << "object is read only"; \ + return; \ + } + + +// CefResponse ---------------------------------------------------------------- + +// static +CefRefPtr CefResponse::Create() { + CefRefPtr response(new CefResponseImpl()); + return response; +} + + +// CefResponseImpl ------------------------------------------------------------ + +CefResponseImpl::CefResponseImpl() + : status_code_(0), + read_only_(false) { +} + +bool CefResponseImpl::IsReadOnly() { + AutoLock lock_scope(this); + return read_only_; +} + +int CefResponseImpl::GetStatus() { + AutoLock lock_scope(this); + return status_code_; +} + +void CefResponseImpl::SetStatus(int status) { + AutoLock lock_scope(this); + CHECK_READONLY_RETURN_VOID(); + status_code_ = status; +} + +CefString CefResponseImpl::GetStatusText() { + AutoLock lock_scope(this); + return status_text_; +} + +void CefResponseImpl::SetStatusText(const CefString& statusText) { + AutoLock lock_scope(this); + CHECK_READONLY_RETURN_VOID(); + status_text_ = statusText; +} + +CefString CefResponseImpl::GetMimeType() { + AutoLock lock_scope(this); + return mime_type_; +} + +void CefResponseImpl::SetMimeType(const CefString& mimeType) { + AutoLock lock_scope(this); + CHECK_READONLY_RETURN_VOID(); + mime_type_ = mimeType; +} + +CefString CefResponseImpl::GetHeader(const CefString& name) { + AutoLock lock_scope(this); + + CefString value; + + HeaderMap::const_iterator it = header_map_.find(name); + if (it != header_map_.end()) + value = it->second; + + return value; +} + +void CefResponseImpl::GetHeaderMap(HeaderMap& map) { + AutoLock lock_scope(this); + map = header_map_; +} + +void CefResponseImpl::SetHeaderMap(const HeaderMap& headerMap) { + AutoLock lock_scope(this); + CHECK_READONLY_RETURN_VOID(); + header_map_ = headerMap; +} + +net::HttpResponseHeaders* CefResponseImpl::GetResponseHeaders() { + AutoLock lock_scope(this); + + std::string response; + std::string status_text; + bool has_content_type_header = false; + + if (!status_text_.empty()) + status_text = status_text_; + else + status_text = (status_code_ == 200)?"OK":"ERROR"; + + base::SStringPrintf(&response, "HTTP/1.1 %d %s", status_code_, + status_text.c_str()); + if (header_map_.size() > 0) { + for (HeaderMap::const_iterator header = header_map_.begin(); + header != header_map_.end(); + ++header) { + const CefString& key = header->first; + const CefString& value = header->second; + + if (!key.empty()) { + // Delimit with "\0" as required by net::HttpResponseHeaders. + std::string key_str(key); + std::string value_str(value); + base::StringAppendF(&response, "%c%s: %s", '\0', key_str.c_str(), + value_str.c_str()); + + if (!has_content_type_header && + key_str == net::HttpRequestHeaders::kContentType) { + has_content_type_header = true; + } + } + } + } + + if (!has_content_type_header) { + std::string mime_type; + if (!mime_type_.empty()) + mime_type = mime_type_; + else + mime_type = "text/html"; + + base::StringAppendF(&response, "%c%s: %s", '\0', + net::HttpRequestHeaders::kContentType, mime_type.c_str()); + } + + return new net::HttpResponseHeaders(response); +} + +void CefResponseImpl::SetResponseHeaders( + const net::HttpResponseHeaders& headers) { + AutoLock lock_scope(this); + + header_map_.empty(); + + void* iter = NULL; + std::string name, value; + while (headers.EnumerateHeaderLines(&iter, &name, &value)) + header_map_.insert(std::make_pair(name, value)); + + status_code_ = headers.response_code(); + status_text_ = headers.GetStatusText(); + + std::string mime_type; + if (headers.GetMimeType(&mime_type)) + mime_type_ = mime_type; +} + +void CefResponseImpl::Set(const WebKit::WebURLResponse& response) { + DCHECK(!response.isNull()); + + AutoLock lock_scope(this); + CHECK_READONLY_RETURN_VOID(); + + WebKit::WebString str; + status_code_ = response.httpStatusCode(); + str = response.httpStatusText(); + status_text_ = CefString(str); + str = response.mimeType(); + mime_type_ = CefString(str); + + class HeaderVisitor : public WebKit::WebHTTPHeaderVisitor { + public: + explicit HeaderVisitor(HeaderMap* map) : map_(map) {} + + virtual void visitHeader(const WebKit::WebString& name, + const WebKit::WebString& value) { + map_->insert(std::make_pair(string16(name), string16(value))); + } + + private: + HeaderMap* map_; + }; + + HeaderVisitor visitor(&header_map_); + response.visitHTTPHeaderFields(&visitor); +} + +void CefResponseImpl::SetReadOnly(bool read_only) { + AutoLock lock_scope(this); + read_only_ = read_only; +} diff --git a/cef3/libcef/common/response_impl.h b/cef3/libcef/common/response_impl.h new file mode 100644 index 000000000..e14e0eecf --- /dev/null +++ b/cef3/libcef/common/response_impl.h @@ -0,0 +1,55 @@ +// 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. + +#ifndef CEF_LIBCEF_COMMON_RESPONSE_IMPL_H_ +#define CEF_LIBCEF_COMMON_RESPONSE_IMPL_H_ +#pragma once + +#include "include/cef_response.h" + +namespace net { +class HttpResponseHeaders; +} + +namespace WebKit { +class WebURLResponse; +} + +// Implementation of CefResponse. +class CefResponseImpl : public CefResponse { + public: + CefResponseImpl(); + ~CefResponseImpl() {} + + // CefResponse methods. + virtual bool IsReadOnly() OVERRIDE; + virtual int GetStatus() OVERRIDE; + virtual void SetStatus(int status) OVERRIDE; + virtual CefString GetStatusText() OVERRIDE; + virtual void SetStatusText(const CefString& statusText) OVERRIDE; + virtual CefString GetMimeType() OVERRIDE; + virtual void SetMimeType(const CefString& mimeType) OVERRIDE; + virtual CefString GetHeader(const CefString& name) OVERRIDE; + virtual void GetHeaderMap(HeaderMap& headerMap) OVERRIDE; + virtual void SetHeaderMap(const HeaderMap& headerMap) OVERRIDE; + + net::HttpResponseHeaders* GetResponseHeaders(); + void SetResponseHeaders(const net::HttpResponseHeaders& headers); + + void Set(const WebKit::WebURLResponse& response); + + void SetReadOnly(bool read_only); + + protected: + int status_code_; + CefString status_text_; + CefString mime_type_; + HeaderMap header_map_; + bool read_only_; + + IMPLEMENT_REFCOUNTING(CefResponseImpl); + IMPLEMENT_LOCKING(CefResponseImpl); +}; + +#endif // CEF_LIBCEF_COMMON_RESPONSE_IMPL_H_ diff --git a/cef3/libcef/common/response_manager.cc b/cef3/libcef/common/response_manager.cc new file mode 100644 index 000000000..b6c5d14c8 --- /dev/null +++ b/cef3/libcef/common/response_manager.cc @@ -0,0 +1,54 @@ +// 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 "libcef/common/response_manager.h" +#include "libcef/common/cef_messages.h" + +#include "base/logging.h" + +CefResponseManager::CefResponseManager() + : next_request_id_(0) { +} + +int CefResponseManager::GetNextRequestId() { + DCHECK(CalledOnValidThread()); + return ++next_request_id_; +} + +int CefResponseManager::RegisterHandler(CefRefPtr handler) { + DCHECK(CalledOnValidThread()); + int request_id = GetNextRequestId(); + handlers_.insert(std::make_pair(request_id, handler)); + return request_id; +} + +bool CefResponseManager::RunHandler(const Cef_Response_Params& params) { + DCHECK(CalledOnValidThread()); + DCHECK_GT(params.request_id, 0); + HandlerMap::iterator it = handlers_.find(params.request_id); + if (it != handlers_.end()) { + it->second->OnResponse(params); + handlers_.erase(it); + return true; + } + return false; +} + +void CefResponseManager::RegisterAckHandler(int request_id, + CefRefPtr handler) { + DCHECK(CalledOnValidThread()); + ack_handlers_.insert(std::make_pair(request_id, handler)); +} + +bool CefResponseManager::RunAckHandler(int request_id) { + DCHECK(CalledOnValidThread()); + DCHECK_GT(request_id, 0); + AckHandlerMap::iterator it = ack_handlers_.find(request_id); + if (it != ack_handlers_.end()) { + it->second->OnResponseAck(); + ack_handlers_.erase(it); + return true; + } + return false; +} diff --git a/cef3/libcef/common/response_manager.h b/cef3/libcef/common/response_manager.h new file mode 100644 index 000000000..ee383cc83 --- /dev/null +++ b/cef3/libcef/common/response_manager.h @@ -0,0 +1,62 @@ +// 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. + +#ifndef CEF_LIBCEF_COMMON_RESPONSE_MANAGER_H_ +#define CEF_LIBCEF_COMMON_RESPONSE_MANAGER_H_ +#pragma once + +#include +#include "include/cef_base.h" +#include "base/threading/non_thread_safe.h" + +struct Cef_Response_Params; + +// This class is not thread-safe. +class CefResponseManager : base::NonThreadSafe { + public: + // Used for handling response messages. + class Handler : public virtual CefBase { + public: + virtual void OnResponse(const Cef_Response_Params& params) =0; + }; + + // Used for handling response ack messages. + class AckHandler : public virtual CefBase { + public: + virtual void OnResponseAck() =0; + }; + + CefResponseManager(); + + // Returns the next unique request id. + int GetNextRequestId(); + + // Register a response handler and return the unique request id. + int RegisterHandler(CefRefPtr handler); + + // Run the response handler for the specified request id. Returns true if a + // handler was run. + bool RunHandler(const Cef_Response_Params& params); + + // Register a response ack handler for the specified request id. + void RegisterAckHandler(int request_id, CefRefPtr handler); + + // Run the response ack handler for the specified request id. Returns true if + // a handler was run. + bool RunAckHandler(int request_id); + + private: + // Used for generating unique request ids. + int next_request_id_; + + // Map of unique request ids to Handler references. + typedef std::map > HandlerMap; + HandlerMap handlers_; + + // Map of unique request ids to AckHandler references. + typedef std::map > AckHandlerMap; + AckHandlerMap ack_handlers_; +}; + +#endif // CEF_LIBCEF_COMMON_RESPONSE_MANAGER_H_ diff --git a/cef3/libcef/common/scheme_registrar_impl.cc b/cef3/libcef/common/scheme_registrar_impl.cc new file mode 100644 index 000000000..280ab4b48 --- /dev/null +++ b/cef3/libcef/common/scheme_registrar_impl.cc @@ -0,0 +1,67 @@ +// 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 "libcef/common/scheme_registrar_impl.h" + +#include + +#include "libcef/renderer/content_renderer_client.h" + +#include "base/bind.h" +#include "base/logging.h" + +CefSchemeRegistrarImpl::CefSchemeRegistrarImpl() + : supported_thread_id_(base::PlatformThread::CurrentId()) { +} + +bool CefSchemeRegistrarImpl::AddCustomScheme( + const CefString& scheme_name, + bool is_standard, + bool is_local, + bool is_display_isolated) { + if (!VerifyContext()) + return false; + + if (is_standard) + standard_schemes_.push_back(scheme_name); + + if (CefContentRendererClient::Get()) { + // Register the custom scheme with WebKit. + CefContentRendererClient::Get()->AddCustomScheme(scheme_name, is_local, + is_display_isolated); + } + + return true; +} + +void CefSchemeRegistrarImpl::GetStandardSchemes( + std::vector* standard_schemes) { + if (!VerifyContext()) + return; + + if (standard_schemes_.empty()) + return; + + standard_schemes->insert(standard_schemes->end(), standard_schemes_.begin(), + standard_schemes_.end()); +} + +bool CefSchemeRegistrarImpl::VerifyRefCount() { + return (GetRefCt() == 1); +} + +void CefSchemeRegistrarImpl::Detach() { + if (VerifyContext()) + supported_thread_id_ = base::kInvalidThreadId; +} + +bool CefSchemeRegistrarImpl::VerifyContext() { + if (base::PlatformThread::CurrentId() != supported_thread_id_) { + // This object should only be accessed from the thread that created it. + NOTREACHED(); + return false; + } + + return true; +} diff --git a/cef3/libcef/common/scheme_registrar_impl.h b/cef3/libcef/common/scheme_registrar_impl.h new file mode 100644 index 000000000..ad7d01186 --- /dev/null +++ b/cef3/libcef/common/scheme_registrar_impl.h @@ -0,0 +1,46 @@ +// 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. + +#ifndef CEF_LIBCEF_COMMON_SCHEME_REGISTRAR_IMPL_H_ +#define CEF_LIBCEF_COMMON_SCHEME_REGISTRAR_IMPL_H_ +#pragma once + +#include +#include + +#include "include/cef_scheme.h" + +#include "base/threading/platform_thread.h" + +class CefSchemeRegistrarImpl : public CefSchemeRegistrar { + public: + CefSchemeRegistrarImpl(); + + // CefSchemeRegistrar methods. + virtual bool AddCustomScheme(const CefString& scheme_name, + bool is_standard, + bool is_local, + bool is_display_isolated) OVERRIDE; + + void GetStandardSchemes(std::vector* standard_schemes); + + // Verify that only a single reference exists to all CefSchemeRegistrarImpl + // objects. + bool VerifyRefCount(); + + void Detach(); + + private: + // Verify that the object is being accessed from the correct thread. + bool VerifyContext(); + + base::PlatformThreadId supported_thread_id_; + + std::vector standard_schemes_; + + IMPLEMENT_REFCOUNTING(CefSchemeRegistrarImpl); + DISALLOW_COPY_AND_ASSIGN(CefSchemeRegistrarImpl); +}; + +#endif // CEF_LIBCEF_COMMON_SCHEME_REGISTRAR_IMPL_H_ diff --git a/cef3/libcef/common/string_list_impl.cc b/cef3/libcef/common/string_list_impl.cc new file mode 100644 index 000000000..8db72cbeb --- /dev/null +++ b/cef3/libcef/common/string_list_impl.cc @@ -0,0 +1,57 @@ +// Copyright (c) 2009 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 +#include "include/internal/cef_string_list.h" +#include "base/logging.h" + +typedef std::vector StringList; + +CEF_EXPORT cef_string_list_t cef_string_list_alloc() { + return new StringList; +} + +CEF_EXPORT int cef_string_list_size(cef_string_list_t list) { + DCHECK(list); + StringList* impl = reinterpret_cast(list); + return impl->size(); +} + +CEF_EXPORT int cef_string_list_value(cef_string_list_t list, int index, + cef_string_t* value) { + DCHECK(list); + DCHECK(value); + StringList* impl = reinterpret_cast(list); + DCHECK_GE(index, 0); + DCHECK_LT(index, static_cast(impl->size())); + if (index < 0 || index >= static_cast(impl->size())) + return false; + const CefString& str = (*impl)[index]; + return cef_string_copy(str.c_str(), str.length(), value); +} + +CEF_EXPORT void cef_string_list_append(cef_string_list_t list, + const cef_string_t* value) { + DCHECK(list); + StringList* impl = reinterpret_cast(list); + impl->push_back(CefString(value)); +} + +CEF_EXPORT void cef_string_list_clear(cef_string_list_t list) { + DCHECK(list); + StringList* impl = reinterpret_cast(list); + impl->clear(); +} + +CEF_EXPORT void cef_string_list_free(cef_string_list_t list) { + DCHECK(list); + StringList* impl = reinterpret_cast(list); + delete impl; +} + +CEF_EXPORT cef_string_list_t cef_string_list_copy(cef_string_list_t list) { + DCHECK(list); + StringList* impl = reinterpret_cast(list); + return new StringList(*impl); +} diff --git a/cef3/libcef/common/string_map_impl.cc b/cef3/libcef/common/string_map_impl.cc new file mode 100644 index 000000000..9538ab05e --- /dev/null +++ b/cef3/libcef/common/string_map_impl.cc @@ -0,0 +1,92 @@ +// Copyright (c) 2009 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 +#include "include/internal/cef_string_map.h" +#include "base/logging.h" + +typedef std::map StringMap; + +CEF_EXPORT cef_string_map_t cef_string_map_alloc() { + return new StringMap; +} + +CEF_EXPORT int cef_string_map_size(cef_string_map_t map) { + DCHECK(map); + StringMap* impl = reinterpret_cast(map); + return impl->size(); +} + +CEF_EXPORT int cef_string_map_find(cef_string_map_t map, + const cef_string_t* key, + cef_string_t* value) { + DCHECK(map); + DCHECK(value); + StringMap* impl = reinterpret_cast(map); + StringMap::const_iterator it = impl->find(CefString(key)); + if (it == impl->end()) + return 0; + + const CefString& val = it->second; + return cef_string_set(val.c_str(), val.length(), value, true); +} + +CEF_EXPORT int cef_string_map_key(cef_string_map_t map, int index, + cef_string_t* key) { + DCHECK(map); + DCHECK(key); + StringMap* impl = reinterpret_cast(map); + DCHECK_GE(index, 0); + DCHECK_LT(index, static_cast(impl->size())); + if (index < 0 || index >= static_cast(impl->size())) + return 0; + + StringMap::const_iterator it = impl->begin(); + for (int ct = 0; it != impl->end(); ++it, ct++) { + if (ct == index) + return cef_string_set(it->first.c_str(), it->first.length(), key, true); + } + return 0; +} + +CEF_EXPORT int cef_string_map_value(cef_string_map_t map, int index, + cef_string_t* value) { + DCHECK(map); + DCHECK(value); + StringMap* impl = reinterpret_cast(map); + DCHECK_GE(index, 0); + DCHECK_LT(index, static_cast(impl->size())); + if (index < 0 || index >= static_cast(impl->size())) + return 0; + + StringMap::const_iterator it = impl->begin(); + for (int ct = 0; it != impl->end(); ++it, ct++) { + if (ct == index) { + return cef_string_set(it->second.c_str(), it->second.length(), value, + true); + } + } + return 0; +} + +CEF_EXPORT int cef_string_map_append(cef_string_map_t map, + const cef_string_t* key, + const cef_string_t* value) { + DCHECK(map); + StringMap* impl = reinterpret_cast(map); + impl->insert(std::make_pair(CefString(key), CefString(value))); + return 1; +} + +CEF_EXPORT void cef_string_map_clear(cef_string_map_t map) { + DCHECK(map); + StringMap* impl = reinterpret_cast(map); + impl->clear(); +} + +CEF_EXPORT void cef_string_map_free(cef_string_map_t map) { + DCHECK(map); + StringMap* impl = reinterpret_cast(map); + delete impl; +} diff --git a/cef3/libcef/common/string_multimap_impl.cc b/cef3/libcef/common/string_multimap_impl.cc new file mode 100644 index 000000000..594ca90dd --- /dev/null +++ b/cef3/libcef/common/string_multimap_impl.cc @@ -0,0 +1,116 @@ +// 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 +#include "include/internal/cef_string_multimap.h" +#include "base/logging.h" + +typedef std::multimap StringMultimap; + +CEF_EXPORT cef_string_multimap_t cef_string_multimap_alloc() { + return new StringMultimap; +} + +CEF_EXPORT int cef_string_multimap_size(cef_string_multimap_t map) { + DCHECK(map); + StringMultimap* impl = reinterpret_cast(map); + return impl->size(); +} + +CEF_EXPORT int cef_string_multimap_find_count(cef_string_multimap_t map, + const cef_string_t* key) { + DCHECK(map); + DCHECK(key); + StringMultimap* impl = reinterpret_cast(map); + return impl->count(CefString(key)); +} + +CEF_EXPORT int cef_string_multimap_enumerate(cef_string_multimap_t map, + const cef_string_t* key, + int value_index, + cef_string_t* value) { + DCHECK(map); + DCHECK(key); + DCHECK(value); + + StringMultimap* impl = reinterpret_cast(map); + CefString key_str(key); + + DCHECK_GE(value_index, 0); + DCHECK_LT(value_index, static_cast(impl->count(key_str))); + if (value_index < 0 || value_index >= static_cast(impl->count(key_str))) + return 0; + + std::pair range_it = + impl->equal_range(key_str); + + int count = value_index; + while (count-- && range_it.first != range_it.second) + range_it.first++; + + if (range_it.first == range_it.second) + return 0; + + const CefString& val = range_it.first->second; + return cef_string_set(val.c_str(), val.length(), value, true); +} + +CEF_EXPORT int cef_string_multimap_key(cef_string_multimap_t map, int index, + cef_string_t* key) { + DCHECK(map); + DCHECK(key); + StringMultimap* impl = reinterpret_cast(map); + DCHECK_GE(index, 0); + DCHECK_LT(index, static_cast(impl->size())); + if (index < 0 || index >= static_cast(impl->size())) + return 0; + + StringMultimap::const_iterator it = impl->begin(); + for (int ct = 0; it != impl->end(); ++it, ct++) { + if (ct == index) + return cef_string_set(it->first.c_str(), it->first.length(), key, true); + } + return 0; +} + +CEF_EXPORT int cef_string_multimap_value(cef_string_multimap_t map, int index, + cef_string_t* value) { + DCHECK(map); + DCHECK(value); + StringMultimap* impl = reinterpret_cast(map); + DCHECK_GE(index, 0); + DCHECK_LT(index, static_cast(impl->size())); + if (index < 0 || index >= static_cast(impl->size())) + return 0; + + StringMultimap::const_iterator it = impl->begin(); + for (int ct = 0; it != impl->end(); ++it, ct++) { + if (ct == index) { + return cef_string_set(it->second.c_str(), it->second.length(), value, + true); + } + } + return 0; +} + +CEF_EXPORT int cef_string_multimap_append(cef_string_multimap_t map, + const cef_string_t* key, + const cef_string_t* value) { + DCHECK(map); + StringMultimap* impl = reinterpret_cast(map); + impl->insert(std::make_pair(CefString(key), CefString(value))); + return 1; +} + +CEF_EXPORT void cef_string_multimap_clear(cef_string_multimap_t map) { + DCHECK(map); + StringMultimap* impl = reinterpret_cast(map); + impl->clear(); +} + +CEF_EXPORT void cef_string_multimap_free(cef_string_multimap_t map) { + DCHECK(map); + StringMultimap* impl = reinterpret_cast(map); + delete impl; +} diff --git a/cef3/libcef/common/string_types_impl.cc b/cef3/libcef/common/string_types_impl.cc new file mode 100644 index 000000000..cf82d381f --- /dev/null +++ b/cef3/libcef/common/string_types_impl.cc @@ -0,0 +1,269 @@ +// Copyright (c) 2010 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 "include/internal/cef_string_types.h" +#include "base/logging.h" +#include "base/string16.h" +#include "base/utf_string_conversions.h" + +namespace { + +void string_wide_dtor(wchar_t* str) { + delete [] str; +} + +void string_utf8_dtor(char* str) { + delete [] str; +} + +void string_utf16_dtor(char16* str) { + delete [] str; +} + +} // namespace + +CEF_EXPORT int cef_string_wide_set(const wchar_t* src, size_t src_len, + cef_string_wide_t* output, int copy) { + cef_string_wide_clear(output); + + if (copy) { + if (src && src_len > 0) { + output->str = new wchar_t[src_len+1]; + if (!output->str) + return 0; + + memcpy(output->str, src, src_len * sizeof(wchar_t)); + output->str[src_len] = 0; + output->length = src_len; + output->dtor = string_wide_dtor; + } + } else { + output->str = const_cast(src); + output->length = src_len; + output->dtor = NULL; + } + return 1; +} + +CEF_EXPORT int cef_string_utf8_set(const char* src, size_t src_len, + cef_string_utf8_t* output, int copy) { + cef_string_utf8_clear(output); + if (copy) { + if (src && src_len > 0) { + output->str = new char[src_len+1]; + if (!output->str) + return 0; + + memcpy(output->str, src, src_len * sizeof(char)); + output->str[src_len] = 0; + output->length = src_len; + output->dtor = string_utf8_dtor; + } + } else { + output->str = const_cast(src); + output->length = src_len; + output->dtor = NULL; + } + return 1; +} + +CEF_EXPORT int cef_string_utf16_set(const char16* src, size_t src_len, + cef_string_utf16_t* output, int copy) { + cef_string_utf16_clear(output); + + if (copy) { + if (src && src_len > 0) { + output->str = new char16[src_len+1]; + if (!output->str) + return 0; + + memcpy(output->str, src, src_len * sizeof(char16)); + output->str[src_len] = 0; + output->length = src_len; + output->dtor = string_utf16_dtor; + } + } else { + output->str = const_cast(src); + output->length = src_len; + output->dtor = NULL; + } + return 1; +} + +CEF_EXPORT void cef_string_wide_clear(cef_string_wide_t* str) { + DCHECK(str != NULL); + if (str->dtor && str->str) + str->dtor(str->str); + + str->str = NULL; + str->length = 0; + str->dtor = NULL; +} + +CEF_EXPORT void cef_string_utf8_clear(cef_string_utf8_t* str) { + DCHECK(str != NULL); + if (str->dtor && str->str) + str->dtor(str->str); + + str->str = NULL; + str->length = 0; + str->dtor = NULL; +} + +CEF_EXPORT void cef_string_utf16_clear(cef_string_utf16_t* str) { + DCHECK(str != NULL); + if (str->dtor && str->str) + str->dtor(str->str); + + str->str = NULL; + str->length = 0; + str->dtor = NULL; +} + +CEF_EXPORT int cef_string_wide_cmp(const cef_string_wide_t* str1, + const cef_string_wide_t* str2) { + if (str1->length == 0 && str2->length == 0) + return 0; + int r = wcsncmp(str1->str, str2->str, std::min(str1->length, str2->length)); + if (r == 0) { + if (str1->length > str2->length) + return 1; + else if (str1->length < str2->length) + return -1; + } + return r; +} + +CEF_EXPORT int cef_string_utf8_cmp(const cef_string_utf8_t* str1, + const cef_string_utf8_t* str2) { + if (str1->length == 0 && str2->length == 0) + return 0; + int r = strncmp(str1->str, str2->str, std::min(str1->length, str2->length)); + if (r == 0) { + if (str1->length > str2->length) + return 1; + else if (str1->length < str2->length) + return -1; + } + return r; +} + +CEF_EXPORT int cef_string_utf16_cmp(const cef_string_utf16_t* str1, + const cef_string_utf16_t* str2) { + if (str1->length == 0 && str2->length == 0) + return 0; +#if defined(WCHAR_T_IS_UTF32) + int r = base::c16memcmp(str1->str, str2->str, std::min(str1->length, + str2->length)); +#else + int r = wcsncmp(str1->str, str2->str, std::min(str1->length, str2->length)); +#endif + if (r == 0) { + if (str1->length > str2->length) + return 1; + else if (str1->length < str2->length) + return -1; + } + return r; +} + +CEF_EXPORT int cef_string_wide_to_utf8(const wchar_t* src, size_t src_len, + cef_string_utf8_t* output) { + std::string str; + bool ret = WideToUTF8(src, src_len, &str); + if (!cef_string_utf8_set(str.c_str(), str.length(), output, true)) + return false; + return ret; +} + +CEF_EXPORT int cef_string_utf8_to_wide(const char* src, size_t src_len, + cef_string_wide_t* output) { + std::wstring str; + bool ret = UTF8ToWide(src, src_len, &str); + if (!cef_string_wide_set(str.c_str(), str.length(), output, true)) + return false; + return ret; +} + +CEF_EXPORT int cef_string_wide_to_utf16(const wchar_t* src, size_t src_len, + cef_string_utf16_t* output) { + string16 str; + bool ret = WideToUTF16(src, src_len, &str); + if (!cef_string_utf16_set(str.c_str(), str.length(), output, true)) + return false; + return ret; +} + +CEF_EXPORT int cef_string_utf16_to_wide(const char16* src, size_t src_len, + cef_string_wide_t* output) { + std::wstring str; + bool ret = UTF16ToWide(src, src_len, &str); + if (!cef_string_wide_set(str.c_str(), str.length(), output, true)) + return false; + return ret; +} + +CEF_EXPORT int cef_string_utf8_to_utf16(const char* src, size_t src_len, + cef_string_utf16_t* output) { + string16 str; + bool ret = UTF8ToUTF16(src, src_len, &str); + if (!cef_string_utf16_set(str.c_str(), str.length(), output, true)) + return false; + return ret; +} + +CEF_EXPORT int cef_string_utf16_to_utf8(const char16* src, size_t src_len, + cef_string_utf8_t* output) { + std::string str; + bool ret = UTF16ToUTF8(src, src_len, &str); + if (!cef_string_utf8_set(str.c_str(), str.length(), output, true)) + return false; + return ret; +} + +CEF_EXPORT int cef_string_ascii_to_wide(const char* src, size_t src_len, + cef_string_wide_t* output) { + std::wstring str = ASCIIToWide(std::string(src, src_len)); + return cef_string_wide_set(str.c_str(), str.length(), output, true); +} + +CEF_EXPORT int cef_string_ascii_to_utf16(const char* src, size_t src_len, + cef_string_utf16_t* output) { + string16 str = ASCIIToUTF16(std::string(src, src_len)); + return cef_string_utf16_set(str.c_str(), str.length(), output, true); +} + +CEF_EXPORT cef_string_userfree_wide_t cef_string_userfree_wide_alloc() { + cef_string_wide_t* s = new cef_string_wide_t; + memset(s, 0, sizeof(cef_string_wide_t)); + return s; +} + +CEF_EXPORT cef_string_userfree_utf8_t cef_string_userfree_utf8_alloc() { + cef_string_utf8_t* s = new cef_string_utf8_t; + memset(s, 0, sizeof(cef_string_utf8_t)); + return s; +} + +CEF_EXPORT cef_string_userfree_utf16_t cef_string_userfree_utf16_alloc() { + cef_string_utf16_t* s = new cef_string_utf16_t; + memset(s, 0, sizeof(cef_string_utf16_t)); + return s; +} + +CEF_EXPORT void cef_string_userfree_wide_free(cef_string_userfree_wide_t str) { + cef_string_wide_clear(str); + delete str; +} + +CEF_EXPORT void cef_string_userfree_utf8_free(cef_string_userfree_utf8_t str) { + cef_string_utf8_clear(str); + delete str; +} + +CEF_EXPORT void cef_string_userfree_utf16_free( + cef_string_userfree_utf16_t str) { + cef_string_utf16_clear(str); + delete str; +} diff --git a/cef3/libcef/common/task_impl.cc b/cef3/libcef/common/task_impl.cc new file mode 100644 index 000000000..300ae8a43 --- /dev/null +++ b/cef3/libcef/common/task_impl.cc @@ -0,0 +1,38 @@ +// Copyright (c) 2013 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 "include/cef_task.h" +#include "libcef/common/task_runner_impl.h" + +#include "base/bind.h" +#include "base/location.h" + +bool CefCurrentlyOn(CefThreadId threadId) { + scoped_refptr task_runner = + CefTaskRunnerImpl::GetTaskRunner(threadId); + if (task_runner.get()) + return task_runner->RunsTasksOnCurrentThread(); + return false; +} + +bool CefPostTask(CefThreadId threadId, CefRefPtr task) { + scoped_refptr task_runner = + CefTaskRunnerImpl::GetTaskRunner(threadId); + if (task_runner.get()) { + return task_runner->PostTask(FROM_HERE, + base::Bind(&CefTask::Execute, task)); + } + return false; +} + +bool CefPostDelayedTask(CefThreadId threadId, CefRefPtr task, int64 delay_ms) { + scoped_refptr task_runner = + CefTaskRunnerImpl::GetTaskRunner(threadId); + if (task_runner.get()) { + return task_runner->PostDelayedTask(FROM_HERE, + base::Bind(&CefTask::Execute, task), + base::TimeDelta::FromMilliseconds(delay_ms)); + } + return false; +} diff --git a/cef3/libcef/common/task_runner_impl.cc b/cef3/libcef/common/task_runner_impl.cc new file mode 100644 index 000000000..da3e06041 --- /dev/null +++ b/cef3/libcef/common/task_runner_impl.cc @@ -0,0 +1,146 @@ +// Copyright (c) 2013 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 "libcef/common/task_runner_impl.h" +#include "libcef/renderer/content_renderer_client.h" + +#include "base/bind.h" +#include "base/location.h" +#include "base/logging.h" +#include "base/message_loop.h" +#include "base/message_loop_proxy.h" +#include "content/public/browser/browser_thread.h" + +using content::BrowserThread; + +// CefTaskRunner + +// static +CefRefPtr CefTaskRunner::GetForCurrentThread() { + scoped_refptr task_runner = + CefTaskRunnerImpl::GetCurrentTaskRunner(); + if (task_runner.get()) + return new CefTaskRunnerImpl(task_runner); + return NULL; +} + +// static +CefRefPtr CefTaskRunner::GetForThread(CefThreadId threadId) { + scoped_refptr task_runner = + CefTaskRunnerImpl::GetTaskRunner(threadId); + if (task_runner.get()) + return new CefTaskRunnerImpl(task_runner); + + LOG(WARNING) << "Invalid thread id " << threadId; + return NULL; +} + + +// CefTaskRunnerImpl + +CefTaskRunnerImpl::CefTaskRunnerImpl( + scoped_refptr task_runner) + : task_runner_(task_runner) { + DCHECK(task_runner_.get()); +} + +// static +scoped_refptr + CefTaskRunnerImpl::GetTaskRunner(CefThreadId threadId) { + // Render process. + if (threadId == TID_RENDERER) { + CefContentRendererClient* client = CefContentRendererClient::Get(); + if (client) + return client->render_task_runner(); + return NULL; + } + + // Browser process. + int id = -1; + switch (threadId) { + case TID_UI: + id = BrowserThread::UI; + break; + case TID_DB: + id = BrowserThread::DB; + break; + case TID_FILE: + id = BrowserThread::FILE; + break; + case TID_FILE_USER_BLOCKING: + id = BrowserThread::FILE_USER_BLOCKING; + break; + case TID_PROCESS_LAUNCHER: + id = BrowserThread::PROCESS_LAUNCHER; + break; + case TID_CACHE: + id = BrowserThread::CACHE; + break; + case TID_IO: + id = BrowserThread::IO; + break; + default: + break; + }; + + if (id >= 0 && content::GetContentClient()->browser() && + BrowserThread::IsMessageLoopValid(static_cast(id))) { + // Don't use BrowserThread::GetMessageLoopProxyForThread because it returns + // a new MessageLoopProxy object for each call and makes pointer equality + // testing impossible. + MessageLoop* message_loop = + BrowserThread::UnsafeGetMessageLoopForThread( + static_cast(id)); + if (message_loop) + return message_loop->message_loop_proxy(); + } + + return NULL; +} + +// static +scoped_refptr + CefTaskRunnerImpl::GetCurrentTaskRunner() { + scoped_refptr task_runner; + + // Check for a MessageLoopProxy. This covers all of the named browser and + // render process threads, plus a few extra. + task_runner = base::MessageLoopProxy::current(); + + if (!task_runner.get()) { + // Check for a WebWorker thread. + CefContentRendererClient* client = CefContentRendererClient::Get(); + if (client) + task_runner = client->GetCurrentTaskRunner(); + } + + return task_runner; +} + +bool CefTaskRunnerImpl::IsSame(CefRefPtr that) { + CefTaskRunnerImpl* impl = static_cast(that.get()); + return (impl && task_runner_ == impl->task_runner_); +} + +bool CefTaskRunnerImpl::BelongsToCurrentThread() { + return task_runner_->RunsTasksOnCurrentThread(); +} + +bool CefTaskRunnerImpl::BelongsToThread(CefThreadId threadId) { + scoped_refptr task_runner = + GetTaskRunner(threadId); + return (task_runner_ == task_runner); +} + +bool CefTaskRunnerImpl::PostTask(CefRefPtr task) { + return task_runner_->PostTask(FROM_HERE, + base::Bind(&CefTask::Execute, task)); +} + +bool CefTaskRunnerImpl::PostDelayedTask(CefRefPtr task, + int64 delay_ms) { + return task_runner_->PostDelayedTask(FROM_HERE, + base::Bind(&CefTask::Execute, task), + base::TimeDelta::FromMilliseconds(delay_ms)); +} diff --git a/cef3/libcef/common/task_runner_impl.h b/cef3/libcef/common/task_runner_impl.h new file mode 100644 index 000000000..709476221 --- /dev/null +++ b/cef3/libcef/common/task_runner_impl.h @@ -0,0 +1,38 @@ +// Copyright (c) 2013 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_LIBCEF_COMMON_TASK_RUNNER_IMPL_H_ +#define CEF_LIBCEF_COMMON_TASK_RUNNER_IMPL_H_ +#pragma once + +#include "include/cef_task.h" +#include "base/sequenced_task_runner.h" + +class CefTaskRunnerImpl : public CefTaskRunner { + public: + explicit CefTaskRunnerImpl( + scoped_refptr task_runner); + + // Returns the task runner associated with |threadId|. + static scoped_refptr + GetTaskRunner(CefThreadId threadId); + // Returns the current task runner. + static scoped_refptr GetCurrentTaskRunner(); + + // CefTaskRunner methods: + virtual bool IsSame(CefRefPtr that) OVERRIDE; + virtual bool BelongsToCurrentThread() OVERRIDE; + virtual bool BelongsToThread(CefThreadId threadId) OVERRIDE; + virtual bool PostTask(CefRefPtr task) OVERRIDE; + virtual bool PostDelayedTask(CefRefPtr task, + int64 delay_ms) OVERRIDE; + + private: + scoped_refptr task_runner_; + + IMPLEMENT_REFCOUNTING(CefTaskRunnerImpl); + DISALLOW_COPY_AND_ASSIGN(CefTaskRunnerImpl); +}; + +#endif // CEF_LIBCEF_COMMON_TASK_RUNNER_IMPL_H_ diff --git a/cef3/libcef/common/time_impl.cc b/cef3/libcef/common/time_impl.cc new file mode 100644 index 000000000..68100b0b3 --- /dev/null +++ b/cef3/libcef/common/time_impl.cc @@ -0,0 +1,93 @@ +// 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 "libcef/common/time_util.h" + +void cef_time_to_basetime(const cef_time_t& cef_time, base::Time& time) { + base::Time::Exploded exploded; + exploded.year = cef_time.year; + exploded.month = cef_time.month; + exploded.day_of_week = cef_time.day_of_week; + exploded.day_of_month = cef_time.day_of_month; + exploded.hour = cef_time.hour; + exploded.minute = cef_time.minute; + exploded.second = cef_time.second; + exploded.millisecond = cef_time.millisecond; + time = base::Time::FromUTCExploded(exploded); +} + +void cef_time_from_basetime(const base::Time& time, cef_time_t& cef_time) { + base::Time::Exploded exploded; + time.UTCExplode(&exploded); + cef_time.year = exploded.year; + cef_time.month = exploded.month; + cef_time.day_of_week = exploded.day_of_week; + cef_time.day_of_month = exploded.day_of_month; + cef_time.hour = exploded.hour; + cef_time.minute = exploded.minute; + cef_time.second = exploded.second; + cef_time.millisecond = exploded.millisecond; +} + +CEF_EXPORT int cef_time_to_timet(const cef_time_t* cef_time, time_t* time) { + if (!cef_time || !time) + return 0; + + base::Time base_time; + cef_time_to_basetime(*cef_time, base_time); + *time = base_time.ToTimeT(); + return 1; +} + +CEF_EXPORT int cef_time_from_timet(time_t time, cef_time_t* cef_time) { + if (!cef_time) + return 0; + + base::Time base_time = base::Time::FromTimeT(time); + cef_time_from_basetime(base_time, *cef_time); + return 1; +} + +CEF_EXPORT int cef_time_to_doublet(const cef_time_t* cef_time, double* time) { + if (!cef_time || !time) + return 0; + + base::Time base_time; + cef_time_to_basetime(*cef_time, base_time); + *time = base_time.ToDoubleT(); + return 1; +} + +CEF_EXPORT int cef_time_from_doublet(double time, cef_time_t* cef_time) { + if (!cef_time) + return 0; + + base::Time base_time = base::Time::FromDoubleT(time); + cef_time_from_basetime(base_time, *cef_time); + return 1; +} + +CEF_EXPORT int cef_time_now(cef_time_t* cef_time) { + if (!cef_time) + return 0; + + base::Time base_time = base::Time::Now(); + cef_time_from_basetime(base_time, *cef_time); + return 1; +} + +CEF_EXPORT int cef_time_delta(const cef_time_t* cef_time1, + const cef_time_t* cef_time2, + long long* delta) { + if (!cef_time1 || !cef_time2 || !delta) + return 0; + + base::Time base_time1, base_time2; + cef_time_to_basetime(*cef_time1, base_time1); + cef_time_to_basetime(*cef_time2, base_time2); + + base::TimeDelta time_delta = base_time2 - base_time1; + *delta = time_delta.InMilliseconds(); + return 1; +} diff --git a/cef3/libcef/common/time_util.h b/cef3/libcef/common/time_util.h new file mode 100644 index 000000000..fb010ff6c --- /dev/null +++ b/cef3/libcef/common/time_util.h @@ -0,0 +1,16 @@ +// 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. + +#ifndef CEF_LIBCEF_COMMON_TIME_UTIL_H_ +#define CEF_LIBCEF_COMMON_TIME_UTIL_H_ +#pragma once + +#include "include/internal/cef_time.h" +#include "base/time.h" + +// Converts cef_time_t to/from a base::Time object. +void cef_time_to_basetime(const cef_time_t& cef_time, base::Time& time); +void cef_time_from_basetime(const base::Time& time, cef_time_t& cef_time); + +#endif // CEF_LIBCEF_COMMON_TIME_UTIL_H_ diff --git a/cef3/libcef/common/tracker.cc b/cef3/libcef/common/tracker.cc new file mode 100644 index 000000000..6ed19e891 --- /dev/null +++ b/cef3/libcef/common/tracker.cc @@ -0,0 +1,83 @@ +// 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 "libcef/common/tracker.h" + +// CefTrackNode implementation. + +CefTrackNode::CefTrackNode() + : track_next_(NULL), + track_prev_(NULL) { +} + +CefTrackNode::~CefTrackNode() { +} + +void CefTrackNode::InsertTrackPrev(CefTrackNode* object) { + if (track_prev_) + track_prev_->SetTrackNext(object); + object->SetTrackNext(this); + object->SetTrackPrev(track_prev_); + track_prev_ = object; +} + +void CefTrackNode::InsertTrackNext(CefTrackNode* object) { + if (track_next_) + track_next_->SetTrackPrev(object); + object->SetTrackPrev(this); + object->SetTrackNext(track_next_); + track_next_ = object; +} + +void CefTrackNode::RemoveTracking() { + if (track_next_) + track_next_->SetTrackPrev(track_prev_); + if (track_prev_) + track_prev_->SetTrackNext(track_next_); + track_next_ = NULL; + track_prev_ = NULL; +} + + +// CefTrackManager implementation. + +CefTrackManager::CefTrackManager() + : object_count_(0) { +} + +CefTrackManager::~CefTrackManager() { + DeleteAll(); +} + +void CefTrackManager::Add(CefTrackNode* object) { + AutoLock lock_scope(this); + if (!object->IsTracked()) { + tracker_.InsertTrackNext(object); + ++object_count_; + } +} + +bool CefTrackManager::Delete(CefTrackNode* object) { + AutoLock lock_scope(this); + if (object->IsTracked()) { + object->RemoveTracking(); + delete object; + --object_count_; + return true; + } + return false; +} + +void CefTrackManager::DeleteAll() { + AutoLock lock_scope(this); + CefTrackNode* next; + do { + next = tracker_.GetTrackNext(); + if (next) { + next->RemoveTracking(); + delete next; + } + } while (next != NULL); + object_count_ = 0; +} diff --git a/cef3/libcef/common/tracker.h b/cef3/libcef/common/tracker.h new file mode 100644 index 000000000..741d5c5e1 --- /dev/null +++ b/cef3/libcef/common/tracker.h @@ -0,0 +1,74 @@ +// 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. + +#ifndef CEF_LIBCEF_COMMON_TRACKER_H_ +#define CEF_LIBCEF_COMMON_TRACKER_H_ +#pragma once + +#include "include/cef_base.h" + +// Class extended by objects that must be tracked. After creating a tracked +// object you should add it to the appropriate track manager. +class CefTrackNode { + public: + CefTrackNode(); + virtual ~CefTrackNode(); + + // Returns true if the object is currently being tracked. + inline bool IsTracked() { return (track_prev_ || track_next_); } + + private: + inline CefTrackNode* GetTrackPrev() { return track_prev_; } + inline void SetTrackPrev(CefTrackNode* base) { track_prev_ = base; } + inline CefTrackNode* GetTrackNext() { return track_next_; } + inline void SetTrackNext(CefTrackNode* base) { track_next_ = base; } + + // Insert a new object into the tracking list before this object. + void InsertTrackPrev(CefTrackNode* object); + + // Insert a new object into the tracking list after this object. + void InsertTrackNext(CefTrackNode* object); + + // Remove this object from the tracking list. + void RemoveTracking(); + + private: + CefTrackNode* track_next_; + CefTrackNode* track_prev_; + + friend class CefTrackManager; +}; + +// Class used to manage tracked objects. A single instance of this class +// should be created for each intended usage. Any objects that have not been +// removed by explicit calls to the Destroy() method will be removed when the +// manager object is destroyed. A manager object can be created as either a +// member variable of another class or by using lazy initialization: +// base::LazyInstance g_singleton = LAZY_INSTANCE_INITIALIZER; +class CefTrackManager : public CefBase { + public: + CefTrackManager(); + virtual ~CefTrackManager(); + + // Add an object to be tracked by this manager. + void Add(CefTrackNode* object); + + // Delete an object tracked by this manager. + bool Delete(CefTrackNode* object); + + // Delete all objects tracked by this manager. + void DeleteAll(); + + // Returns the number of objects currently being tracked. + inline int GetCount() { return object_count_; } + + private: + CefTrackNode tracker_; + int object_count_; + + IMPLEMENT_REFCOUNTING(CefTrackManager); + IMPLEMENT_LOCKING(CefTrackManager); +}; + +#endif // CEF_LIBCEF_COMMON_TRACKER_H_ diff --git a/cef3/libcef/common/url_impl.cc b/cef3/libcef/common/url_impl.cc new file mode 100644 index 000000000..cc9d7a964 --- /dev/null +++ b/cef3/libcef/common/url_impl.cc @@ -0,0 +1,68 @@ +// 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 +#include "include/cef_url.h" +#include "googleurl/src/gurl.h" + +bool CefParseURL(const CefString& url, + CefURLParts& parts) { + GURL gurl(url.ToString()); + if (!gurl.is_valid()) + return false; + + CefString(&parts.spec).FromString(gurl.spec()); + CefString(&parts.scheme).FromString(gurl.scheme()); + CefString(&parts.username).FromString(gurl.username()); + CefString(&parts.password).FromString(gurl.password()); + CefString(&parts.host).FromString(gurl.host()); + CefString(&parts.port).FromString(gurl.port()); + CefString(&parts.path).FromString(gurl.path()); + CefString(&parts.query).FromString(gurl.query()); + + return true; +} + +bool CefCreateURL(const CefURLParts& parts, + CefString& url) { + std::string spec = CefString(parts.spec.str, parts.spec.length, false); + std::string scheme = CefString(parts.scheme.str, parts.scheme.length, false); + std::string username = + CefString(parts.username.str, parts.username.length, false); + std::string password = + CefString(parts.password.str, parts.password.length, false); + std::string host = CefString(parts.host.str, parts.host.length, false); + std::string port = CefString(parts.port.str, parts.port.length, false); + std::string path = CefString(parts.path.str, parts.path.length, false); + std::string query = CefString(parts.query.str, parts.query.length, false); + + GURL gurl; + if (!spec.empty()) { + gurl = GURL(spec); + } else if (!scheme.empty() && !host.empty()) { + std::stringstream ss; + ss << scheme << "://"; + if (!username.empty()) { + ss << username; + if (!password.empty()) + ss << ":" << password; + ss << "@"; + } + ss << host; + if (!port.empty()) + ss << ":" << port; + if (!path.empty()) + ss << path; + if (!query.empty()) + ss << "?" << query; + gurl = GURL(ss.str()); + } + + if (gurl.is_valid()) { + url = gurl.spec(); + return true; + } + + return false; +} diff --git a/cef3/libcef/common/urlrequest_impl.cc b/cef3/libcef/common/urlrequest_impl.cc new file mode 100644 index 000000000..de47161aa --- /dev/null +++ b/cef3/libcef/common/urlrequest_impl.cc @@ -0,0 +1,45 @@ +// 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 "include/cef_urlrequest.h" +#include "libcef/browser/browser_urlrequest_impl.h" +#include "libcef/renderer/render_urlrequest_impl.h" + +#include "base/logging.h" +#include "base/message_loop.h" +#include "content/public/common/content_client.h" + +// static +CefRefPtr CefURLRequest::Create( + CefRefPtr request, + CefRefPtr client) { + if (!request.get() || !client.get()) { + NOTREACHED() << "called with invalid parameters"; + return NULL; + } + + if (!MessageLoop::current()) { + NOTREACHED() << "called on invalid thread"; + return NULL; + } + + if (content::GetContentClient()->browser()) { + // In the browser process. + CefRefPtr impl = + new CefBrowserURLRequest(request, client); + if (impl->Start()) + return impl.get(); + return NULL; + } else if (content::GetContentClient()->renderer()) { + // In the render process. + CefRefPtr impl = + new CefRenderURLRequest(request, client); + if (impl->Start()) + return impl.get(); + return NULL; + } else { + NOTREACHED() << "called in unsupported process"; + return NULL; + } +} diff --git a/cef3/libcef/common/value_base.cc b/cef3/libcef/common/value_base.cc new file mode 100644 index 000000000..5ca561488 --- /dev/null +++ b/cef3/libcef/common/value_base.cc @@ -0,0 +1,201 @@ +// 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 "libcef/common/value_base.h" + + +CefValueController::CefValueController() + : owner_value_(NULL), + owner_object_(NULL) { +} + +CefValueController::~CefValueController() { + // Everything should already have been removed. + DCHECK(!owner_value_ && !owner_object_); + DCHECK(reference_map_.empty()); + DCHECK(dependency_map_.empty()); +} + +void CefValueController::SetOwner(void* value, Object* object) { + DCHECK(value && object); + + // Controller should already be locked. + DCHECK(locked()); + + // Owner should only be set once. + DCHECK(!owner_value_ && !owner_object_); + + owner_value_ = value; + owner_object_ = object; +} + +void CefValueController::AddReference(void* value, Object* object) { + DCHECK(value && object); + + // Controller should already be locked. + DCHECK(locked()); + + // Controller should currently have an owner. + DCHECK(owner_value_); + + // Values should only be added once. + DCHECK(reference_map_.find(value) == reference_map_.end()); + DCHECK(value != owner_value_); + + reference_map_.insert(std::make_pair(value, object)); +} + +void CefValueController::Remove(void* value, bool notify_object) { + DCHECK(value); + + // Controller should already be locked. + DCHECK(locked()); + + // Controller should currently have an owner. + DCHECK(owner_value_); + + if (value == owner_value_) { + // Should never notify when removing the owner object. + DCHECK(!notify_object); + + owner_value_ = NULL; + owner_object_ = NULL; + + // Remove all references. + if (reference_map_.size() > 0) { + ReferenceMap::iterator it = reference_map_.begin(); + for (; it != reference_map_.end(); ++it) + it->second->OnControlRemoved(); + reference_map_.clear(); + } + + // Remove all dependencies. + dependency_map_.clear(); + } else { + ReferenceMap::iterator it = reference_map_.find(value); + if (it != reference_map_.end()) { + // Remove the reference. + if (notify_object) + it->second->OnControlRemoved(); + reference_map_.erase(it); + } + } +} + +CefValueController::Object* CefValueController::Get(void* value) { + DCHECK(value); + + // Controller should already be locked. + DCHECK(locked()); + + if (value == owner_value_) { + return owner_object_; + } else { + ReferenceMap::iterator it = reference_map_.find(value); + if (it != reference_map_.end()) + return it->second; + return NULL; + } +} + +void CefValueController::AddDependency(void* parent, void* child) { + DCHECK(parent && child && parent != child); + + // Controller should already be locked. + DCHECK(locked()); + + DependencyMap::iterator it = dependency_map_.find(parent); + if (it == dependency_map_.end()) { + // New set. + DependencySet set; + set.insert(child); + dependency_map_.insert(std::make_pair(parent, set)); + } else if (it->second.find(child) == it->second.end()) { + // Update existing set. + it->second.insert(child); + } +} + +void CefValueController::RemoveDependencies(void* value) { + DCHECK(value); + + // Controller should already be locked. + DCHECK(locked()); + + if (dependency_map_.empty()) + return; + + DependencyMap::iterator it_dependency = dependency_map_.find(value); + if (it_dependency == dependency_map_.end()) + return; + + // Start with the set of dependencies for the current value. + DependencySet remove_set = it_dependency->second; + dependency_map_.erase(it_dependency); + + DependencySet::iterator it_value; + ReferenceMap::iterator it_reference; + + while (remove_set.size() > 0) { + it_value = remove_set.begin(); + value = *it_value; + remove_set.erase(it_value); + + // Does the current value have dependencies? + it_dependency = dependency_map_.find(value); + if (it_dependency != dependency_map_.end()) { + // Append the dependency set to the remove set. + remove_set.insert(it_dependency->second.begin(), + it_dependency->second.end()); + dependency_map_.erase(it_dependency); + } + + // Does the current value have a reference? + it_reference = reference_map_.find(value); + if (it_reference != reference_map_.end()) { + // Remove the reference. + it_reference->second->OnControlRemoved(); + reference_map_.erase(it_reference); + } + } +} + +void CefValueController::TakeFrom(CefValueController* other) { + DCHECK(other); + + // Both controllers should already be locked. + DCHECK(locked()); + DCHECK(other->locked()); + + if (!other->reference_map_.empty()) { + // Transfer references from the other to this. + ReferenceMap::iterator it = other->reference_map_.begin(); + for (; it != other->reference_map_.end(); ++it) { + // References should only be added once. + DCHECK(reference_map_.find(it->first) == reference_map_.end()); + reference_map_.insert(std::make_pair(it->first, it->second)); + } + other->reference_map_.empty(); + } + + if (!other->dependency_map_.empty()) { + // Transfer dependencies from the other to this. + DependencyMap::iterator it_other = other->dependency_map_.begin(); + for (; it_other != other->dependency_map_.end(); ++it_other) { + DependencyMap::iterator it_me = dependency_map_.find(it_other->first); + if (it_me == dependency_map_.end()) { + // All children are new. + dependency_map_.insert( + std::make_pair(it_other->first, it_other->second)); + } else { + // Evaluate each child. + DependencySet::iterator it_other_set = it_other->second.begin(); + for (; it_other_set != it_other->second.end(); ++it_other_set) { + if (it_me->second.find(*it_other_set) == it_me->second.end()) + it_me->second.insert(*it_other_set); + } + } + } + } +} diff --git a/cef3/libcef/common/value_base.h b/cef3/libcef/common/value_base.h new file mode 100644 index 000000000..f6f9f7a39 --- /dev/null +++ b/cef3/libcef/common/value_base.h @@ -0,0 +1,415 @@ +// 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. + +#ifndef CEF_LIBCEF_COMMON_VALUE_BASE_H_ +#define CEF_LIBCEF_COMMON_VALUE_BASE_H_ +#pragma once + +#include +#include +#include "include/cef_base.h" + +#include "base/logging.h" +#include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" +#include "base/synchronization/lock.h" +#include "base/threading/platform_thread.h" + + +// Controller implementation base class. +class CefValueController + : public base::RefCountedThreadSafe { + public: + // Implemented by a class controlled using the access controller. + class Object { + public: + virtual ~Object() {} + + // Called when the value has been removed. + virtual void OnControlRemoved() =0; + }; + + // Encapsulates context locking and verification logic. + class AutoLock { + public: + explicit AutoLock(CefValueController* impl) + : impl_(impl), + verified_(impl && impl->VerifyThread()) { + DCHECK(impl); + if (verified_) + impl_->lock(); + } + virtual ~AutoLock() { + if (verified_) + impl_->unlock(); + } + + inline bool verified() { return verified_; } + + private: + scoped_refptr impl_; + bool verified_; + + DISALLOW_COPY_AND_ASSIGN(AutoLock); + }; + + CefValueController(); + virtual ~CefValueController(); + + // Returns true if this controller is thread safe. + virtual bool thread_safe() =0; + + // Returns true if the current thread is allowed to access this controller. + virtual bool on_correct_thread() =0; + + // Lock the controller. + virtual void lock() =0; + + // Unlock the controller. + virtual void unlock() =0; + + // Returns true if the controller is locked on the current thread. + virtual bool locked() =0; + + // Verify that the current thread is correct for accessing the controller. + inline bool VerifyThread() { + if (!thread_safe() && !on_correct_thread()) { + // This object should only be accessed from the thread that created it. + NOTREACHED() << "object accessed from incorrect thread."; + return false; + } + return true; + } + + // The controller must already be locked before calling the below methods. + + // Set the owner for this controller. + void SetOwner(void* value, Object* object); + + // Add a reference value and associated object. + void AddReference(void* value, Object* object); + + // Remove the value. If |notify_object| is true the removed object will be + // notified. If |value| is the owner all reference objects will be removed. + // If |value| has dependencies those objects will also be removed. + void Remove(void* value, bool notify_object); + + // Returns the object for the specified value. + Object* Get(void* value); + + // Add a dependency between |parent| and |child|. + void AddDependency(void* parent, void* child); + + // Recursively removes any dependent values. + void RemoveDependencies(void* value); + + // Takes ownership of all references and dependencies currently controlled by + // |other|. The |other| controller must already be locked. + void TakeFrom(CefValueController* other); + + private: + // Owner object. + void* owner_value_; + Object* owner_object_; + + // Map of reference objects. + typedef std::map ReferenceMap; + ReferenceMap reference_map_; + + // Map of dependency objects. + typedef std::set DependencySet; + typedef std::map DependencyMap; + DependencyMap dependency_map_; + + DISALLOW_COPY_AND_ASSIGN(CefValueController); +}; + +// Thread-safe access control implementation. +class CefValueControllerThreadSafe : public CefValueController { + public: + explicit CefValueControllerThreadSafe() + : locked_thread_id_(0) {} + + // CefValueController methods. + virtual bool thread_safe() OVERRIDE { return true; } + virtual bool on_correct_thread() OVERRIDE { return true; } + virtual void lock() OVERRIDE { + lock_.Acquire(); + locked_thread_id_ = base::PlatformThread::CurrentId(); + } + virtual void unlock() OVERRIDE { + locked_thread_id_ = 0; + lock_.Release(); + } + virtual bool locked() OVERRIDE { + return (locked_thread_id_ == base::PlatformThread::CurrentId()); + } + + private: + base::Lock lock_; + base::PlatformThreadId locked_thread_id_; + + DISALLOW_COPY_AND_ASSIGN(CefValueControllerThreadSafe); +}; + +// Non-thread-safe access control implementation. +class CefValueControllerNonThreadSafe : public CefValueController { + public: + explicit CefValueControllerNonThreadSafe() + : thread_id_(base::PlatformThread::CurrentId()) {} + + // CefValueController methods. + virtual bool thread_safe() OVERRIDE { return false; } + virtual bool on_correct_thread() OVERRIDE { + return (thread_id_ == base::PlatformThread::CurrentId()); + } + virtual void lock() OVERRIDE {} + virtual void unlock() OVERRIDE {} + virtual bool locked() OVERRIDE { return on_correct_thread(); } + + private: + base::PlatformThreadId thread_id_; + + DISALLOW_COPY_AND_ASSIGN(CefValueControllerNonThreadSafe); +}; + + +// Helper macros for verifying context. + +#define CEF_VALUE_VERIFY_RETURN_VOID_EX(object, modify) \ + if (!VerifyAttached()) \ + return; \ + AutoLock auto_lock(object, modify); \ + if (!auto_lock.verified()) \ + return; + +#define CEF_VALUE_VERIFY_RETURN_VOID(modify) \ + CEF_VALUE_VERIFY_RETURN_VOID_EX(this, modify) + +#define CEF_VALUE_VERIFY_RETURN_EX(object, modify, error_val) \ + if (!VerifyAttached()) \ + return error_val; \ + AutoLock auto_lock(object, modify); \ + if (!auto_lock.verified()) \ + return error_val; + +#define CEF_VALUE_VERIFY_RETURN(modify, error_val) \ + CEF_VALUE_VERIFY_RETURN_EX(this, modify, error_val) + + +// Template class for implementing CEF wrappers of other types. +template +class CefValueBase : public CefType, public CefValueController::Object { + public: + // Specifies how the value will be used. + enum ValueMode { + // A reference to a value managed by an existing controller. These values + // can be safely detached but ownership should not be transferred (make a + // copy of the value instead). + kReference, + + // The value has its own controller and will be deleted on destruction. + // These values can only be detached to another controller otherwise any + // references will not be properly managed. + kOwnerWillDelete, + + // The value has its own controller and will not be deleted on destruction. + // This should only be used for global values or scope-limited values that + // will be explicitly detached. + kOwnerNoDelete, + }; + + // Create a new object. + // If |read_only| is true mutable access will not be allowed. + // If |parent_value| is non-NULL and the value mode is kReference a dependency + // will be added. + CefValueBase(ValueType* value, + void* parent_value, + ValueMode value_mode, + bool read_only, + CefValueController* controller) + : value_(value), + value_mode_(value_mode), + read_only_(read_only), + controller_(controller) { + DCHECK(value_); + + // Specifying a parent value for a non-reference doesn't make sense. + DCHECK(!(!reference() && parent_value)); + + if (!reference() && !controller_) { + // For owned values default to using a new multi-threaded controller. + controller_ = new CefValueControllerThreadSafe(); + SetOwnsController(); + } + + // A controller is required. + DCHECK(controller_); + + if (reference()) { + // Register the reference with the controller. + controller_->AddReference(value_, this); + + // Add a dependency on the parent value. + if (parent_value) + controller_->AddDependency(parent_value, value_); + } + } + virtual ~CefValueBase() { + if (controller_ && value_) + Delete(); + } + + // True if the underlying value is referenced instead of owned. + inline bool reference() const { return (value_mode_ == kReference); } + + // True if the underlying value will be deleted. + inline bool will_delete() const { return (value_mode_ == kOwnerWillDelete); } + + // True if access to the underlying value is read-only. + inline bool read_only() const { return read_only_; } + + // True if the underlying value has been detached. + inline bool detached() { return (controller_ == NULL); } + + // Returns the controller. + inline CefValueController* controller() { return controller_; } + + // Deletes the underlying value. + void Delete() { + CEF_VALUE_VERIFY_RETURN_VOID(false); + + // Remove the object from the controller. If this is the owner object any + // references will be detached. + controller()->Remove(value_, false); + + if (will_delete()) { + // Remove any dependencies. + controller()->RemoveDependencies(value_); + + // Delete the value. + DeleteValue(value_); + } + + controller_ = NULL; + value_ = NULL; + } + + // Detaches the underlying value and returns a pointer to it. If this is an + // owner and a |new_controller| value is specified any existing references + // will be passed to the new controller. + ValueType* Detach(CefValueController* new_controller) { + CEF_VALUE_VERIFY_RETURN(false, NULL); + + // A |new_controller| value is required for mode kOwnerWillDelete. + DCHECK(!will_delete() || new_controller); + + if (new_controller && !reference()) { + // Pass any existing references and dependencies to the new controller. + // They will be removed from this controller. + new_controller->TakeFrom(controller()); + } + + // Remove the object from the controller. If this is the owner object any + // references will be detached. + controller()->Remove(value_, false); + controller_ = NULL; + + // Return the old value. + ValueType* old_val = value_; + value_ = NULL; + return old_val; + } + + // Verify that the value is attached. + inline bool VerifyAttached() { + if (detached()) { + // This object should not be accessed after being detached. + NOTREACHED() << "object accessed after being detached."; + return false; + } + return true; + } + + protected: + // CefValueController::Object methods. + virtual void OnControlRemoved() { + DCHECK(controller()->locked()); + + // Only references should be removed in this manner. + DCHECK(reference()); + + controller_ = NULL; + value_ = NULL; + } + + // Override to customize value deletion. + virtual void DeleteValue(ValueType* value) { delete value; } + + // Returns a mutable reference to the value. + inline ValueType* mutable_value() { + DCHECK(value_); + DCHECK(!read_only_); + DCHECK(controller()->locked()); + return value_; + } + // Returns a const reference to the value. + inline const ValueType& const_value() { + DCHECK(value_); + DCHECK(controller()->locked()); + return *value_; + } + + // Verify that the value can be accessed. + inline bool VerifyAccess(bool modify) { + // The controller must already be locked. + DCHECK(controller()->locked()); + + if (read_only() && modify) { + // This object cannot be modified. + NOTREACHED() << "mutation attempted on read-only object."; + return false; + } + + return true; + } + + // Used to indicate that this object owns the controller. + inline void SetOwnsController() { + CefValueController::AutoLock lock_scope(controller_); + if (lock_scope.verified()) + controller_->SetOwner(value_, this); + } + + // Encapsulates value locking and verification logic. + class AutoLock { + public: + explicit AutoLock(CefValueBase* impl, bool modify) + : auto_lock_(impl->controller()), + verified_(auto_lock_.verified() && impl->VerifyAccess(modify)) { + } + virtual ~AutoLock() {} + + inline bool verified() { return verified_; } + + private: + CefValueController::AutoLock auto_lock_; + bool verified_; + + DISALLOW_COPY_AND_ASSIGN(AutoLock); + }; + + private: + ValueType* value_; + ValueMode value_mode_; + bool read_only_; + scoped_refptr controller_; + + IMPLEMENT_REFCOUNTING(CefValueBase); + + DISALLOW_COPY_AND_ASSIGN(CefValueBase); +}; + + +#endif // CEF_LIBCEF_COMMON_VALUE_BASE_H_ diff --git a/cef3/libcef/common/values_impl.cc b/cef3/libcef/common/values_impl.cc new file mode 100644 index 000000000..6840b7107 --- /dev/null +++ b/cef3/libcef/common/values_impl.cc @@ -0,0 +1,839 @@ +// 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 "libcef/common/values_impl.h" + +#include +#include + + +// CefBinaryValueImpl implementation. + +CefRefPtr CefBinaryValue::Create(const void* data, + size_t data_size) { + DCHECK(data); + DCHECK_GT(data_size, (size_t)0); + if (!data || data_size == 0) + return NULL; + + return new CefBinaryValueImpl(static_cast(const_cast(data)), + data_size, true); +} + +// static +CefRefPtr CefBinaryValueImpl::GetOrCreateRef( + base::BinaryValue* value, + void* parent_value, + CefValueController* controller) { + DCHECK(value); + DCHECK(parent_value); + DCHECK(controller); + + CefValueController::Object* object = controller->Get(value); + if (object) + return static_cast(object); + + return new CefBinaryValueImpl(value, parent_value, + CefBinaryValueImpl::kReference, controller); +} + +CefBinaryValueImpl::CefBinaryValueImpl(base::BinaryValue* value, + bool will_delete, + bool read_only) + : CefValueBase( + value, NULL, will_delete ? kOwnerWillDelete : kOwnerNoDelete, + read_only, NULL) { +} + +base::BinaryValue* CefBinaryValueImpl::CopyValue() { + CEF_VALUE_VERIFY_RETURN(false, NULL); + return const_value().DeepCopy(); +} + +base::BinaryValue* CefBinaryValueImpl::CopyOrDetachValue( + CefValueController* new_controller) { + base::BinaryValue* new_value; + + if (!will_delete()) { + // Copy the value. + new_value = CopyValue(); + } else { + // Take ownership of the value. + new_value = Detach(new_controller); + } + + DCHECK(new_value); + return new_value; +} + +bool CefBinaryValueImpl::IsValid() { + return !detached(); +} + +bool CefBinaryValueImpl::IsOwned() { + return !will_delete(); +} + +CefRefPtr CefBinaryValueImpl::Copy() { + CEF_VALUE_VERIFY_RETURN(false, NULL); + return new CefBinaryValueImpl(const_value().DeepCopy(), NULL, + CefBinaryValueImpl::kOwnerWillDelete, NULL); +} + +size_t CefBinaryValueImpl::GetSize() { + CEF_VALUE_VERIFY_RETURN(false, 0); + return const_value().GetSize(); +} + +size_t CefBinaryValueImpl::GetData(void* buffer, + size_t buffer_size, + size_t data_offset) { + DCHECK(buffer); + DCHECK_GT(buffer_size, (size_t)0); + if (!buffer || buffer_size == 0) + return 0; + + CEF_VALUE_VERIFY_RETURN(false, 0); + + size_t size = const_value().GetSize(); + DCHECK_LT(data_offset, size); + if (data_offset >= size) + return 0; + + size = std::min(buffer_size, size-data_offset); + const char* data = const_value().GetBuffer(); + memcpy(buffer, data+data_offset, size); + return size; +} + +CefBinaryValueImpl::CefBinaryValueImpl(base::BinaryValue* value, + void* parent_value, + ValueMode value_mode, + CefValueController* controller) + : CefValueBase( + value, parent_value, value_mode, true, controller) { +} + +CefBinaryValueImpl::CefBinaryValueImpl(char* data, + size_t data_size, + bool copy) + : CefValueBase( + copy ? base::BinaryValue::CreateWithCopiedBuffer(data, data_size) : + new base::BinaryValue(scoped_ptr(data), data_size), + NULL, kOwnerWillDelete, true, NULL) { +} + + +// CefDictionaryValueImpl implementation. + +// static +CefRefPtr CefDictionaryValue::Create() { + return new CefDictionaryValueImpl(new base::DictionaryValue(), + NULL, CefDictionaryValueImpl::kOwnerWillDelete, false, NULL); +} + +// static +CefRefPtr CefDictionaryValueImpl::GetOrCreateRef( + base::DictionaryValue* value, + void* parent_value, + bool read_only, + CefValueController* controller) { + CefValueController::Object* object = controller->Get(value); + if (object) + return static_cast(object); + + return new CefDictionaryValueImpl(value, parent_value, + CefDictionaryValueImpl::kReference, read_only, controller); +} + +CefDictionaryValueImpl::CefDictionaryValueImpl(base::DictionaryValue* value, + bool will_delete, + bool read_only) + : CefValueBase( + value, NULL, will_delete ? kOwnerWillDelete : kOwnerNoDelete, + read_only, NULL) { +} + +base::DictionaryValue* CefDictionaryValueImpl::CopyValue() { + CEF_VALUE_VERIFY_RETURN(false, NULL); + return const_value().DeepCopy(); +} + +base::DictionaryValue* CefDictionaryValueImpl::CopyOrDetachValue( + CefValueController* new_controller) { + base::DictionaryValue* new_value; + + if (!will_delete()) { + // Copy the value. + new_value = CopyValue(); + } else { + // Take ownership of the value. + new_value = Detach(new_controller); + } + + DCHECK(new_value); + return new_value; +} + +bool CefDictionaryValueImpl::IsValid() { + return !detached(); +} + +bool CefDictionaryValueImpl::IsOwned() { + return !will_delete(); +} + +bool CefDictionaryValueImpl::IsReadOnly() { + return read_only(); +} + +CefRefPtr CefDictionaryValueImpl::Copy( + bool exclude_empty_children) { + CEF_VALUE_VERIFY_RETURN(false, NULL); + + base::DictionaryValue* value; + if (exclude_empty_children) { + value = const_cast( + const_value()).DeepCopyWithoutEmptyChildren(); + } else { + value = const_value().DeepCopy(); + } + + return new CefDictionaryValueImpl(value, NULL, + CefDictionaryValueImpl::kOwnerWillDelete, false, NULL); +} + +size_t CefDictionaryValueImpl::GetSize() { + CEF_VALUE_VERIFY_RETURN(false, 0); + return const_value().size(); +} + +bool CefDictionaryValueImpl::Clear() { + CEF_VALUE_VERIFY_RETURN(true, false); + + // Detach any dependent values. + controller()->RemoveDependencies(mutable_value()); + + mutable_value()->Clear(); + return true; +} + +bool CefDictionaryValueImpl::HasKey(const CefString& key) { + CEF_VALUE_VERIFY_RETURN(false, 0); + return const_value().HasKey(key); +} + +bool CefDictionaryValueImpl::GetKeys(KeyList& keys) { + CEF_VALUE_VERIFY_RETURN(false, 0); + + for (DictionaryValue::Iterator i(const_value()); !i.IsAtEnd(); i.Advance()) + keys.push_back(i.key()); + + return true; +} + +bool CefDictionaryValueImpl::Remove(const CefString& key) { + CEF_VALUE_VERIFY_RETURN(true, false); + return RemoveInternal(key); +} + +CefValueType CefDictionaryValueImpl::GetType(const CefString& key) { + CEF_VALUE_VERIFY_RETURN(false, VTYPE_INVALID); + + const base::Value* out_value = NULL; + if (const_value().GetWithoutPathExpansion(key, &out_value)) { + switch (out_value->GetType()) { + case base::Value::TYPE_NULL: + return VTYPE_NULL; + case base::Value::TYPE_BOOLEAN: + return VTYPE_BOOL; + case base::Value::TYPE_INTEGER: + return VTYPE_INT; + case base::Value::TYPE_DOUBLE: + return VTYPE_DOUBLE; + case base::Value::TYPE_STRING: + return VTYPE_STRING; + case base::Value::TYPE_BINARY: + return VTYPE_BINARY; + case base::Value::TYPE_DICTIONARY: + return VTYPE_DICTIONARY; + case base::Value::TYPE_LIST: + return VTYPE_LIST; + } + } + + return VTYPE_INVALID; +} + +bool CefDictionaryValueImpl::GetBool(const CefString& key) { + CEF_VALUE_VERIFY_RETURN(false, false); + + const base::Value* out_value = NULL; + bool ret_value = false; + + if (const_value().GetWithoutPathExpansion(key, &out_value)) + out_value->GetAsBoolean(&ret_value); + + return ret_value; +} + +int CefDictionaryValueImpl::GetInt(const CefString& key) { + CEF_VALUE_VERIFY_RETURN(false, 0); + + const base::Value* out_value = NULL; + int ret_value = 0; + + if (const_value().GetWithoutPathExpansion(key, &out_value)) + out_value->GetAsInteger(&ret_value); + + return ret_value; +} + +double CefDictionaryValueImpl::GetDouble(const CefString& key) { + CEF_VALUE_VERIFY_RETURN(false, 0); + + const base::Value* out_value = NULL; + double ret_value = 0; + + if (const_value().GetWithoutPathExpansion(key, &out_value)) + out_value->GetAsDouble(&ret_value); + + return ret_value; +} + +CefString CefDictionaryValueImpl::GetString(const CefString& key) { + CEF_VALUE_VERIFY_RETURN(false, CefString()); + + const base::Value* out_value = NULL; + std::string ret_value; + + if (const_value().GetWithoutPathExpansion(key, &out_value)) + out_value->GetAsString(&ret_value); + + return ret_value; +} + +CefRefPtr CefDictionaryValueImpl::GetBinary( + const CefString& key) { + CEF_VALUE_VERIFY_RETURN(false, NULL); + + const base::Value* out_value = NULL; + + if (const_value().GetWithoutPathExpansion(key, &out_value) && + out_value->IsType(base::Value::TYPE_BINARY)) { + base::BinaryValue* binary_value = + static_cast(const_cast(out_value)); + return CefBinaryValueImpl::GetOrCreateRef(binary_value, + const_cast(&const_value()), controller()); + } + + return NULL; +} + +CefRefPtr CefDictionaryValueImpl::GetDictionary( + const CefString& key) { + CEF_VALUE_VERIFY_RETURN(false, NULL); + + const base::Value* out_value = NULL; + + if (const_value().GetWithoutPathExpansion(key, &out_value) && + out_value->IsType(base::Value::TYPE_DICTIONARY)) { + base::DictionaryValue* dict_value = + static_cast( + const_cast(out_value)); + return CefDictionaryValueImpl::GetOrCreateRef( + dict_value, + const_cast(&const_value()), + read_only(), + controller()); + } + + return NULL; +} + +CefRefPtr CefDictionaryValueImpl::GetList(const CefString& key) { + CEF_VALUE_VERIFY_RETURN(false, NULL); + + const base::Value* out_value = NULL; + + if (const_value().GetWithoutPathExpansion(key, &out_value) && + out_value->IsType(base::Value::TYPE_LIST)) { + base::ListValue* list_value = + static_cast(const_cast(out_value)); + return CefListValueImpl::GetOrCreateRef( + list_value, + const_cast(&const_value()), + read_only(), + controller()); + } + + return NULL; +} + +bool CefDictionaryValueImpl::SetNull(const CefString& key) { + CEF_VALUE_VERIFY_RETURN(true, false); + RemoveInternal(key); + mutable_value()->SetWithoutPathExpansion(key, base::Value::CreateNullValue()); + return true; +} + +bool CefDictionaryValueImpl::SetBool(const CefString& key, bool value) { + CEF_VALUE_VERIFY_RETURN(true, false); + RemoveInternal(key); + mutable_value()->SetWithoutPathExpansion(key, + base::Value::CreateBooleanValue(value)); + return true; +} + +bool CefDictionaryValueImpl::SetInt(const CefString& key, int value) { + CEF_VALUE_VERIFY_RETURN(true, false); + RemoveInternal(key); + mutable_value()->SetWithoutPathExpansion(key, + base::Value::CreateIntegerValue(value)); + return true; +} + +bool CefDictionaryValueImpl::SetDouble(const CefString& key, double value) { + CEF_VALUE_VERIFY_RETURN(true, false); + RemoveInternal(key); + mutable_value()->SetWithoutPathExpansion(key, + base::Value::CreateDoubleValue(value)); + return true; +} + +bool CefDictionaryValueImpl::SetString(const CefString& key, + const CefString& value) { + CEF_VALUE_VERIFY_RETURN(true, false); + RemoveInternal(key); + mutable_value()->SetWithoutPathExpansion(key, + base::Value::CreateStringValue(value.ToString())); + return true; +} + +bool CefDictionaryValueImpl::SetBinary(const CefString& key, + CefRefPtr value) { + CEF_VALUE_VERIFY_RETURN(true, false); + RemoveInternal(key); + + CefBinaryValueImpl* impl = static_cast(value.get()); + DCHECK(impl); + + mutable_value()->SetWithoutPathExpansion(key, + impl->CopyOrDetachValue(controller())); + return true; +} + +bool CefDictionaryValueImpl::SetDictionary( + const CefString& key, CefRefPtr value) { + CEF_VALUE_VERIFY_RETURN(true, false); + RemoveInternal(key); + + CefDictionaryValueImpl* impl = + static_cast(value.get()); + DCHECK(impl); + + mutable_value()->SetWithoutPathExpansion(key, + impl->CopyOrDetachValue(controller())); + return true; +} + +bool CefDictionaryValueImpl::SetList(const CefString& key, + CefRefPtr value) { + CEF_VALUE_VERIFY_RETURN(true, false); + RemoveInternal(key); + + CefListValueImpl* impl = static_cast(value.get()); + DCHECK(impl); + + mutable_value()->SetWithoutPathExpansion(key, + impl->CopyOrDetachValue(controller())); + return true; +} + +bool CefDictionaryValueImpl::RemoveInternal(const CefString& key) { + base::Value* out_value = NULL; + if (!mutable_value()->RemoveWithoutPathExpansion(key, &out_value)) + return false; + + // Remove the value. + controller()->Remove(out_value, true); + + // Only list and dictionary types may have dependencies. + if (out_value->IsType(base::Value::TYPE_LIST) || + out_value->IsType(base::Value::TYPE_DICTIONARY)) { + controller()->RemoveDependencies(out_value); + } + + delete out_value; + return true; +} + +CefDictionaryValueImpl::CefDictionaryValueImpl( + base::DictionaryValue* value, + void* parent_value, + ValueMode value_mode, + bool read_only, + CefValueController* controller) + : CefValueBase( + value, parent_value, value_mode, read_only, controller) { +} + + +// CefListValueImpl implementation. + +// static +CefRefPtr CefListValue::Create() { + return new CefListValueImpl(new base::ListValue(), + NULL, CefListValueImpl::kOwnerWillDelete, false, NULL); +} + +// static +CefRefPtr CefListValueImpl::GetOrCreateRef( + base::ListValue* value, + void* parent_value, + bool read_only, + CefValueController* controller) { + CefValueController::Object* object = controller->Get(value); + if (object) + return static_cast(object); + + return new CefListValueImpl(value, parent_value, + CefListValueImpl::kReference, read_only, controller); +} + +CefListValueImpl::CefListValueImpl(base::ListValue* value, + bool will_delete, + bool read_only) + : CefValueBase( + value, NULL, will_delete ? kOwnerWillDelete : kOwnerNoDelete, + read_only, NULL) { +} + +base::ListValue* CefListValueImpl::CopyValue() { + CEF_VALUE_VERIFY_RETURN(false, NULL); + return const_value().DeepCopy(); +} + +base::ListValue* CefListValueImpl::CopyOrDetachValue( + CefValueController* new_controller) { + base::ListValue* new_value; + + if (!will_delete()) { + // Copy the value. + new_value = CopyValue(); + } else { + // Take ownership of the value. + new_value = Detach(new_controller); + } + + DCHECK(new_value); + return new_value; +} + +bool CefListValueImpl::IsValid() { + return !detached(); +} + +bool CefListValueImpl::IsOwned() { + return !will_delete(); +} + +bool CefListValueImpl::IsReadOnly() { + return read_only(); +} + +CefRefPtr CefListValueImpl::Copy() { + CEF_VALUE_VERIFY_RETURN(false, NULL); + + return new CefListValueImpl(const_value().DeepCopy(), NULL, + CefListValueImpl::kOwnerWillDelete, false, NULL); +} + +bool CefListValueImpl::SetSize(size_t size) { + CEF_VALUE_VERIFY_RETURN(true, false); + + size_t current_size = const_value().GetSize(); + if (size < current_size) { + // Clean up any values above the requested size. + for (size_t i = current_size-1; i >= size; --i) + RemoveInternal(i); + } else if (size > 0) { + // Expand the list size. + mutable_value()->Set(size-1, base::Value::CreateNullValue()); + } + return true; +} + +size_t CefListValueImpl::GetSize() { + CEF_VALUE_VERIFY_RETURN(false, 0); + return const_value().GetSize(); +} + +bool CefListValueImpl::Clear() { + CEF_VALUE_VERIFY_RETURN(true, false); + + // Detach any dependent values. + controller()->RemoveDependencies(mutable_value()); + + mutable_value()->Clear(); + return true; +} + +bool CefListValueImpl::Remove(int index) { + CEF_VALUE_VERIFY_RETURN(true, false); + return RemoveInternal(index); +} + +CefValueType CefListValueImpl::GetType(int index) { + CEF_VALUE_VERIFY_RETURN(false, VTYPE_INVALID); + + const base::Value* out_value = NULL; + if (const_value().Get(index, &out_value)) { + switch (out_value->GetType()) { + case base::Value::TYPE_NULL: + return VTYPE_NULL; + case base::Value::TYPE_BOOLEAN: + return VTYPE_BOOL; + case base::Value::TYPE_INTEGER: + return VTYPE_INT; + case base::Value::TYPE_DOUBLE: + return VTYPE_DOUBLE; + case base::Value::TYPE_STRING: + return VTYPE_STRING; + case base::Value::TYPE_BINARY: + return VTYPE_BINARY; + case base::Value::TYPE_DICTIONARY: + return VTYPE_DICTIONARY; + case base::Value::TYPE_LIST: + return VTYPE_LIST; + } + } + + return VTYPE_INVALID; +} + +bool CefListValueImpl::GetBool(int index) { + CEF_VALUE_VERIFY_RETURN(false, false); + + const base::Value* out_value = NULL; + bool ret_value = false; + + if (const_value().Get(index, &out_value)) + out_value->GetAsBoolean(&ret_value); + + return ret_value; +} + +int CefListValueImpl::GetInt(int index) { + CEF_VALUE_VERIFY_RETURN(false, 0); + + const base::Value* out_value = NULL; + int ret_value = 0; + + if (const_value().Get(index, &out_value)) + out_value->GetAsInteger(&ret_value); + + return ret_value; +} + +double CefListValueImpl::GetDouble(int index) { + CEF_VALUE_VERIFY_RETURN(false, 0); + + const base::Value* out_value = NULL; + double ret_value = 0; + + if (const_value().Get(index, &out_value)) + out_value->GetAsDouble(&ret_value); + + return ret_value; +} + +CefString CefListValueImpl::GetString(int index) { + CEF_VALUE_VERIFY_RETURN(false, CefString()); + + const base::Value* out_value = NULL; + std::string ret_value; + + if (const_value().Get(index, &out_value)) + out_value->GetAsString(&ret_value); + + return ret_value; +} + +CefRefPtr CefListValueImpl::GetBinary(int index) { + CEF_VALUE_VERIFY_RETURN(false, NULL); + + const base::Value* out_value = NULL; + + if (const_value().Get(index, &out_value) && + out_value->IsType(base::Value::TYPE_BINARY)) { + base::BinaryValue* binary_value = + static_cast(const_cast(out_value)); + return CefBinaryValueImpl::GetOrCreateRef(binary_value, + const_cast(&const_value()), controller()); + } + + return NULL; +} + +CefRefPtr CefListValueImpl::GetDictionary(int index) { + CEF_VALUE_VERIFY_RETURN(false, NULL); + + const base::Value* out_value = NULL; + + if (const_value().Get(index, &out_value) && + out_value->IsType(base::Value::TYPE_DICTIONARY)) { + base::DictionaryValue* dict_value = + static_cast( + const_cast(out_value)); + return CefDictionaryValueImpl::GetOrCreateRef( + dict_value, + const_cast(&const_value()), + read_only(), + controller()); + } + + return NULL; +} + +CefRefPtr CefListValueImpl::GetList(int index) { + CEF_VALUE_VERIFY_RETURN(false, NULL); + + const base::Value* out_value = NULL; + + if (const_value().Get(index, &out_value) && + out_value->IsType(base::Value::TYPE_LIST)) { + base::ListValue* list_value = + static_cast(const_cast(out_value)); + return CefListValueImpl::GetOrCreateRef( + list_value, + const_cast(&const_value()), + read_only(), + controller()); + } + + return NULL; +} + +bool CefListValueImpl::SetNull(int index) { + CEF_VALUE_VERIFY_RETURN(true, false); + base::Value* new_value = base::Value::CreateNullValue(); + if (RemoveInternal(index)) + mutable_value()->Insert(index, new_value); + else + mutable_value()->Set(index, new_value); + return true; +} + +bool CefListValueImpl::SetBool(int index, bool value) { + CEF_VALUE_VERIFY_RETURN(true, false); + base::Value* new_value = base::Value::CreateBooleanValue(value); + if (RemoveInternal(index)) + mutable_value()->Insert(index, new_value); + else + mutable_value()->Set(index, new_value); + return true; +} + +bool CefListValueImpl::SetInt(int index, int value) { + CEF_VALUE_VERIFY_RETURN(true, false); + base::Value* new_value = base::Value::CreateIntegerValue(value); + if (RemoveInternal(index)) + mutable_value()->Insert(index, new_value); + else + mutable_value()->Set(index, new_value); + return true; +} + +bool CefListValueImpl::SetDouble(int index, double value) { + CEF_VALUE_VERIFY_RETURN(true, false); + base::Value* new_value = base::Value::CreateDoubleValue(value); + if (RemoveInternal(index)) + mutable_value()->Insert(index, new_value); + else + mutable_value()->Set(index, new_value); + return true; +} + +bool CefListValueImpl::SetString(int index, const CefString& value) { + CEF_VALUE_VERIFY_RETURN(true, false); + base::Value* new_value = base::Value::CreateStringValue(value.ToString()); + if (RemoveInternal(index)) + mutable_value()->Insert(index, new_value); + else + mutable_value()->Set(index, new_value); + return true; +} + +bool CefListValueImpl::SetBinary(int index, CefRefPtr value) { + CEF_VALUE_VERIFY_RETURN(true, false); + + CefBinaryValueImpl* impl = static_cast(value.get()); + DCHECK(impl); + + base::Value* new_value = impl->CopyOrDetachValue(controller()); + if (RemoveInternal(index)) + mutable_value()->Insert(index, new_value); + else + mutable_value()->Set(index, new_value); + return true; +} + +bool CefListValueImpl::SetDictionary(int index, + CefRefPtr value) { + CEF_VALUE_VERIFY_RETURN(true, false); + + CefDictionaryValueImpl* impl = + static_cast(value.get()); + DCHECK(impl); + + base::Value* new_value = impl->CopyOrDetachValue(controller()); + if (RemoveInternal(index)) + mutable_value()->Insert(index, new_value); + else + mutable_value()->Set(index, new_value); + return true; +} + +bool CefListValueImpl::SetList(int index, CefRefPtr value) { + CEF_VALUE_VERIFY_RETURN(true, false); + + CefListValueImpl* impl = static_cast(value.get()); + DCHECK(impl); + + base::Value* new_value = impl->CopyOrDetachValue(controller()); + if (RemoveInternal(index)) + mutable_value()->Insert(index, new_value); + else + mutable_value()->Set(index, new_value); + return true; +} + +bool CefListValueImpl::RemoveInternal(int index) { + base::Value* out_value = NULL; + if (!mutable_value()->Remove(index, &out_value)) + return false; + + // Remove the value. + controller()->Remove(out_value, true); + + // Only list and dictionary types may have dependencies. + if (out_value->IsType(base::Value::TYPE_LIST) || + out_value->IsType(base::Value::TYPE_DICTIONARY)) { + controller()->RemoveDependencies(out_value); + } + + delete out_value; + return true; +} + +CefListValueImpl::CefListValueImpl( + base::ListValue* value, + void* parent_value, + ValueMode value_mode, + bool read_only, + CefValueController* controller) + : CefValueBase( + value, parent_value, value_mode, read_only, controller) { +} diff --git a/cef3/libcef/common/values_impl.h b/cef3/libcef/common/values_impl.h new file mode 100644 index 000000000..2148c1b13 --- /dev/null +++ b/cef3/libcef/common/values_impl.h @@ -0,0 +1,209 @@ +// 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. + +#ifndef CEF_LIBCEF_COMMON_VALUES_IMPL_H_ +#define CEF_LIBCEF_COMMON_VALUES_IMPL_H_ +#pragma once + +#include + +#include "include/cef_values.h" +#include "libcef/common/value_base.h" + +#include "base/values.h" +#include "base/threading/platform_thread.h" + + +// CefBinaryValue implementation +class CefBinaryValueImpl + : public CefValueBase { + public: + // Get or create a reference value. + static CefRefPtr GetOrCreateRef( + base::BinaryValue* value, + void* parent_value, + CefValueController* controller); + + // Simple constructor for referencing existing value objects. + CefBinaryValueImpl(base::BinaryValue* value, + bool will_delete, + bool read_only); + + // Return a copy of the value. + base::BinaryValue* CopyValue(); + + // If a reference return a copy of the value otherwise detach the value to the + // specified |new_controller|. + base::BinaryValue* CopyOrDetachValue(CefValueController* new_controller); + + // CefBinaryValue methods. + virtual bool IsValid() OVERRIDE; + virtual bool IsOwned() OVERRIDE; + virtual CefRefPtr Copy() OVERRIDE; + virtual size_t GetSize() OVERRIDE; + virtual size_t GetData(void* buffer, + size_t buffer_size, + size_t data_offset) OVERRIDE; + + private: + // See the CefValueBase constructor for usage. Binary values are always + // read-only. + CefBinaryValueImpl(base::BinaryValue* value, + void* parent_value, + ValueMode value_mode, + CefValueController* controller); + // If |copy| is false this object will take ownership of the specified |data| + // buffer instead of copying it. + CefBinaryValueImpl(char* data, + size_t data_size, + bool copy); + + // For the Create() method. + friend class CefBinaryValue; + + DISALLOW_COPY_AND_ASSIGN(CefBinaryValueImpl); +}; + + +// CefDictionaryValue implementation +class CefDictionaryValueImpl + : public CefValueBase { + public: + // Get or create a reference value. + static CefRefPtr GetOrCreateRef( + base::DictionaryValue* value, + void* parent_value, + bool read_only, + CefValueController* controller); + + // Simple constructor for referencing existing value objects. + CefDictionaryValueImpl(base::DictionaryValue* value, + bool will_delete, + bool read_only); + + // Return a copy of the value. + base::DictionaryValue* CopyValue(); + + // If a reference return a copy of the value otherwise detach the value to the + // specified |new_controller|. + base::DictionaryValue* CopyOrDetachValue(CefValueController* new_controller); + + // CefDictionaryValue methods. + virtual bool IsValid() OVERRIDE; + virtual bool IsOwned() OVERRIDE; + virtual bool IsReadOnly() OVERRIDE; + virtual CefRefPtr Copy( + bool exclude_empty_children) OVERRIDE; + virtual size_t GetSize() OVERRIDE; + virtual bool Clear() OVERRIDE; + virtual bool HasKey(const CefString& key) OVERRIDE; + virtual bool GetKeys(KeyList& keys) OVERRIDE; + virtual bool Remove(const CefString& key) OVERRIDE; + virtual CefValueType GetType(const CefString& key) OVERRIDE; + virtual bool GetBool(const CefString& key) OVERRIDE; + virtual int GetInt(const CefString& key) OVERRIDE; + virtual double GetDouble(const CefString& key) OVERRIDE; + virtual CefString GetString(const CefString& key) OVERRIDE; + virtual CefRefPtr GetBinary(const CefString& key) OVERRIDE; + virtual CefRefPtr GetDictionary( + const CefString& key) OVERRIDE; + virtual CefRefPtr GetList(const CefString& key) OVERRIDE; + virtual bool SetNull(const CefString& key) OVERRIDE; + virtual bool SetBool(const CefString& key, bool value) OVERRIDE; + virtual bool SetInt(const CefString& key, int value) OVERRIDE; + virtual bool SetDouble(const CefString& key, double value) OVERRIDE; + virtual bool SetString(const CefString& key, + const CefString& value) OVERRIDE; + virtual bool SetBinary(const CefString& key, + CefRefPtr value) OVERRIDE; + virtual bool SetDictionary(const CefString& key, + CefRefPtr value) OVERRIDE; + virtual bool SetList(const CefString& key, + CefRefPtr value) OVERRIDE; + + private: + // See the CefValueBase constructor for usage. + CefDictionaryValueImpl(base::DictionaryValue* value, + void* parent_value, + ValueMode value_mode, + bool read_only, + CefValueController* controller); + + bool RemoveInternal(const CefString& key); + + // For the Create() method. + friend class CefDictionaryValue; + + DISALLOW_COPY_AND_ASSIGN(CefDictionaryValueImpl); +}; + + +// CefListValue implementation +class CefListValueImpl + : public CefValueBase { + public: + // Get or create a reference value. + static CefRefPtr GetOrCreateRef( + base::ListValue* value, + void* parent_value, + bool read_only, + CefValueController* controller); + + // Simple constructor for referencing existing value objects. + CefListValueImpl(base::ListValue* value, + bool will_delete, + bool read_only); + + // Return a copy of the value. + base::ListValue* CopyValue(); + + // If a reference return a copy of the value otherwise detach the value to the + // specified |new_controller|. + base::ListValue* CopyOrDetachValue(CefValueController* new_controller); + + /// CefListValue methods. + virtual bool IsValid() OVERRIDE; + virtual bool IsOwned() OVERRIDE; + virtual bool IsReadOnly() OVERRIDE; + virtual CefRefPtr Copy() OVERRIDE; + virtual bool SetSize(size_t size) OVERRIDE; + virtual size_t GetSize() OVERRIDE; + virtual bool Clear() OVERRIDE; + virtual bool Remove(int index) OVERRIDE; + virtual CefValueType GetType(int index) OVERRIDE; + virtual bool GetBool(int index) OVERRIDE; + virtual int GetInt(int index) OVERRIDE; + virtual double GetDouble(int index) OVERRIDE; + virtual CefString GetString(int index) OVERRIDE; + virtual CefRefPtr GetBinary(int index) OVERRIDE; + virtual CefRefPtr GetDictionary(int index) OVERRIDE; + virtual CefRefPtr GetList(int index) OVERRIDE; + virtual bool SetNull(int index) OVERRIDE; + virtual bool SetBool(int index, bool value) OVERRIDE; + virtual bool SetInt(int index, int value) OVERRIDE; + virtual bool SetDouble(int index, double value) OVERRIDE; + virtual bool SetString(int index, const CefString& value) OVERRIDE; + virtual bool SetBinary(int index, CefRefPtr value) OVERRIDE; + virtual bool SetDictionary(int index, + CefRefPtr value) OVERRIDE; + virtual bool SetList(int index, CefRefPtr value) OVERRIDE; + + private: + // See the CefValueBase constructor for usage. + CefListValueImpl(base::ListValue* value, + void* parent_value, + ValueMode value_mode, + bool read_only, + CefValueController* controller); + + bool RemoveInternal(int index); + + // For the Create() method. + friend class CefListValue; + + DISALLOW_COPY_AND_ASSIGN(CefListValueImpl); +}; + + +#endif // CEF_LIBCEF_COMMON_VALUES_IMPL_H_ diff --git a/cef3/libcef/renderer/browser_impl.cc b/cef3/libcef/renderer/browser_impl.cc new file mode 100644 index 000000000..caf77f816 --- /dev/null +++ b/cef3/libcef/renderer/browser_impl.cc @@ -0,0 +1,699 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 The Chromium 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 "libcef/renderer/browser_impl.h" + +#include +#include + +#include "libcef/common/cef_messages.h" +#include "libcef/common/content_client.h" +#include "libcef/common/process_message_impl.h" +#include "libcef/common/response_manager.h" +#include "libcef/renderer/content_renderer_client.h" +#include "libcef/renderer/dom_document_impl.h" +#include "libcef/renderer/thread_util.h" +#include "libcef/renderer/webkit_glue.h" + +#include "base/string16.h" +#include "base/string_util.h" +#include "base/utf_string_conversions.h" +#include "content/public/renderer/document_state.h" +#include "content/public/renderer/navigation_state.h" +#include "content/public/renderer/render_view.h" +#include "net/http/http_util.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebURLResponse.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" +#include "webkit/base/file_path_string_conversions.h" +#include "webkit/glue/webkit_glue.h" + +using WebKit::WebFrame; +using WebKit::WebScriptSource; +using WebKit::WebString; +using WebKit::WebURL; +using WebKit::WebView; + +namespace { + +const int64 kInvalidBrowserId = -1; +const int64 kInvalidFrameId = -1; + +} // namespace + + +// CefBrowserImpl static methods. +// ----------------------------------------------------------------------------- + +// static +CefRefPtr CefBrowserImpl::GetBrowserForView( + content::RenderView* view) { + return CefContentRendererClient::Get()->GetBrowserForView(view); +} + +// static +CefRefPtr CefBrowserImpl::GetBrowserForMainFrame( + WebKit::WebFrame* frame) { + return CefContentRendererClient::Get()->GetBrowserForMainFrame(frame); +} + + +// CefBrowser methods. +// ----------------------------------------------------------------------------- + +CefRefPtr CefBrowserImpl::GetHost() { + NOTREACHED() << "GetHost cannot be called from the render process"; + return NULL; +} + +bool CefBrowserImpl::CanGoBack() { + CEF_REQUIRE_RT_RETURN(false); + + return webkit_glue::CanGoBackOrForward(render_view()->GetWebView(), -1); +} + +void CefBrowserImpl::GoBack() { + CEF_REQUIRE_RT_RETURN_VOID(); + + webkit_glue::GoBackOrForward(render_view()->GetWebView(), -1); +} + +bool CefBrowserImpl::CanGoForward() { + CEF_REQUIRE_RT_RETURN(false); + + return webkit_glue::CanGoBackOrForward(render_view()->GetWebView(), 1); +} + +void CefBrowserImpl::GoForward() { + CEF_REQUIRE_RT_RETURN_VOID(); + + webkit_glue::GoBackOrForward(render_view()->GetWebView(), 1); +} + +bool CefBrowserImpl::IsLoading() { + CEF_REQUIRE_RT_RETURN(false); + + if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) + return render_view()->GetWebView()->mainFrame()->isLoading(); + return false; +} + +void CefBrowserImpl::Reload() { + CEF_REQUIRE_RT_RETURN_VOID(); + + if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) + render_view()->GetWebView()->mainFrame()->reload(false); +} + +void CefBrowserImpl::ReloadIgnoreCache() { + CEF_REQUIRE_RT_RETURN_VOID(); + + if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) + render_view()->GetWebView()->mainFrame()->reload(true); +} + +void CefBrowserImpl::StopLoad() { + CEF_REQUIRE_RT_RETURN_VOID(); + + if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) + render_view()->GetWebView()->mainFrame()->stopLoading(); +} + +int CefBrowserImpl::GetIdentifier() { + CEF_REQUIRE_RT_RETURN(0); + + return browser_id(); +} + +bool CefBrowserImpl::IsSame(CefRefPtr that) { + CEF_REQUIRE_RT_RETURN(false); + + CefBrowserImpl* impl = static_cast(that.get()); + return (impl == this); +} + +bool CefBrowserImpl::IsPopup() { + CEF_REQUIRE_RT_RETURN(false); + + return is_popup(); +} + +bool CefBrowserImpl::HasDocument() { + CEF_REQUIRE_RT_RETURN(false); + + if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) + return !render_view()->GetWebView()->mainFrame()->document().isNull(); + return false; +} + +CefRefPtr CefBrowserImpl::GetMainFrame() { + CEF_REQUIRE_RT_RETURN(NULL); + + if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) + return GetWebFrameImpl(render_view()->GetWebView()->mainFrame()).get(); + return NULL; +} + +CefRefPtr CefBrowserImpl::GetFocusedFrame() { + CEF_REQUIRE_RT_RETURN(NULL); + + if (render_view()->GetWebView() && + render_view()->GetWebView()->focusedFrame()) { + return GetWebFrameImpl(render_view()->GetWebView()->focusedFrame()).get(); + } + return NULL; +} + +CefRefPtr CefBrowserImpl::GetFrame(int64 identifier) { + CEF_REQUIRE_RT_RETURN(NULL); + + return GetWebFrameImpl(identifier).get(); +} + +CefRefPtr CefBrowserImpl::GetFrame(const CefString& name) { + CEF_REQUIRE_RT_RETURN(NULL); + + if (render_view()->GetWebView()) { + WebFrame* frame = + render_view()->GetWebView()->findFrameByName(name.ToString16()); + if (frame) + return GetWebFrameImpl(frame).get(); + } + + return NULL; +} + +size_t CefBrowserImpl::GetFrameCount() { + CEF_REQUIRE_RT_RETURN(0); + + int count = 0; + + if (render_view()->GetWebView()) { + WebFrame* main_frame = render_view()->GetWebView()->mainFrame(); + if (main_frame) { + WebFrame* cur = main_frame; + do { + count++; + cur = cur->traverseNext(true); + } while (cur != main_frame); + } + } + + return count; +} + +void CefBrowserImpl::GetFrameIdentifiers(std::vector& identifiers) { + CEF_REQUIRE_RT_RETURN_VOID(); + + if (render_view()->GetWebView()) { + WebFrame* main_frame = render_view()->GetWebView()->mainFrame(); + if (main_frame) { + WebFrame* cur = main_frame; + do { + identifiers.push_back(cur->identifier()); + cur = cur->traverseNext(true); + } while (cur != main_frame); + } + } +} + +void CefBrowserImpl::GetFrameNames(std::vector& names) { + CEF_REQUIRE_RT_RETURN_VOID(); + + if (render_view()->GetWebView()) { + WebFrame* main_frame = render_view()->GetWebView()->mainFrame(); + if (main_frame) { + WebFrame* cur = main_frame; + do { + names.push_back(CefString(cur->uniqueName().utf8())); + cur = cur->traverseNext(true); + } while (cur != main_frame); + } + } +} + +bool CefBrowserImpl::SendProcessMessage(CefProcessId target_process, + CefRefPtr message) { + Cef_Request_Params params; + CefProcessMessageImpl* impl = + static_cast(message.get()); + if (impl->CopyTo(params)) { + return SendProcessMessage(target_process, params.name, ¶ms.arguments, + true); + } + + return false; +} + + +// CefBrowserImpl public methods. +// ----------------------------------------------------------------------------- + +CefBrowserImpl::CefBrowserImpl(content::RenderView* render_view, + int browser_id, + bool is_popup) + : content::RenderViewObserver(render_view), + browser_id_(browser_id), + is_popup_(is_popup), + last_focused_frame_id_(kInvalidFrameId) { + response_manager_.reset(new CefResponseManager); +} + +CefBrowserImpl::~CefBrowserImpl() { +} + +void CefBrowserImpl::LoadRequest(const CefMsg_LoadRequest_Params& params) { + CefRefPtr framePtr = GetWebFrameImpl(params.frame_id); + if (!framePtr.get()) + return; + + WebFrame* web_frame = framePtr->web_frame(); + + WebKit::WebURLRequest request(params.url); + + // DidCreateDataSource checks for this value. + request.setRequestorID(-1); + + if (!params.method.empty()) + request.setHTTPMethod(ASCIIToUTF16(params.method)); + + if (params.referrer.is_valid()) { + WebString referrer = WebKit::WebSecurityPolicy::generateReferrerHeader( + static_cast(params.referrer_policy), + params.url, + WebString::fromUTF8(params.referrer.spec())); + if (!referrer.isEmpty()) + request.setHTTPHeaderField(WebString::fromUTF8("Referer"), referrer); + } + + if (params.first_party_for_cookies.is_valid()) + request.setFirstPartyForCookies(params.first_party_for_cookies); + + if (!params.headers.empty()) { + for (net::HttpUtil::HeadersIterator i(params.headers.begin(), + params.headers.end(), "\n"); + i.GetNext(); ) { + request.addHTTPHeaderField(WebString::fromUTF8(i.name()), + WebString::fromUTF8(i.values())); + } + } + + if (params.upload_data.get()) { + string16 method = request.httpMethod(); + if (method == ASCIIToUTF16("GET") || method == ASCIIToUTF16("HEAD")) + request.setHTTPMethod(ASCIIToUTF16("POST")); + + if (request.httpHeaderField(ASCIIToUTF16("Content-Type")).length() == 0) { + request.setHTTPHeaderField( + ASCIIToUTF16("Content-Type"), + ASCIIToUTF16("application/x-www-form-urlencoded")); + } + + WebKit::WebHTTPBody body; + body.initialize(); + + const ScopedVector& elements = + params.upload_data->elements(); + ScopedVector::const_iterator it = + elements.begin(); + for (; it != elements.end(); ++it) { + const net::UploadElement& element = **it; + if (element.type() == net::UploadElement::TYPE_BYTES) { + WebKit::WebData data; + data.assign(element.bytes(), element.bytes_length()); + body.appendData(data); + } else if (element.type() == net::UploadElement::TYPE_FILE) { + body.appendFile(webkit_base::FilePathToWebString(element.file_path())); + } else { + NOTREACHED(); + } + } + + request.setHTTPBody(body); + } + + web_frame->loadRequest(request); +} + +bool CefBrowserImpl::SendProcessMessage(CefProcessId target_process, + const std::string& name, + base::ListValue* arguments, + bool user_initiated) { + DCHECK_EQ(PID_BROWSER, target_process); + DCHECK(!name.empty()); + + Cef_Request_Params params; + params.name = name; + if (arguments) + params.arguments.Swap(arguments); + params.frame_id = -1; + params.user_initiated = user_initiated; + params.request_id = -1; + params.expect_response = false; + + return Send(new CefHostMsg_Request(routing_id(), params)); +} + +CefRefPtr CefBrowserImpl::GetWebFrameImpl( + WebKit::WebFrame* frame) { + DCHECK(frame); + int64 frame_id = frame->identifier(); + + // Frames are re-used between page loads. Only add the frame to the map once. + FrameMap::const_iterator it = frames_.find(frame_id); + if (it != frames_.end()) + return it->second; + + CefRefPtr framePtr(new CefFrameImpl(this, frame)); + frames_.insert(std::make_pair(frame_id, framePtr)); + + int64 parent_id = frame->parent() == NULL ? + kInvalidFrameId : frame->parent()->identifier(); + string16 name = frame->uniqueName(); + + // Notify the browser that the frame has been identified. + Send(new CefHostMsg_FrameIdentified(routing_id(), frame_id, parent_id, name)); + + return framePtr; +} + +CefRefPtr CefBrowserImpl::GetWebFrameImpl(int64 frame_id) { + if (frame_id == kInvalidFrameId) { + if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) + return GetWebFrameImpl(render_view()->GetWebView()->mainFrame()); + return NULL; + } + + // Check if we already know about the frame. + FrameMap::const_iterator it = frames_.find(frame_id); + if (it != frames_.end()) + return it->second; + + if (render_view()->GetWebView()) { + // Check if the frame exists but we don't know about it yet. + WebFrame* main_frame = render_view()->GetWebView()->mainFrame(); + if (main_frame) { + WebFrame* cur = main_frame; + do { + if (cur->identifier() == frame_id) + return GetWebFrameImpl(cur); + cur = cur->traverseNext(true); + } while (cur != main_frame); + } + } + + return NULL; +} + +void CefBrowserImpl::AddFrameObject(int64 frame_id, + CefTrackNode* tracked_object) { + CefRefPtr manager; + + if (!frame_objects_.empty()) { + FrameObjectMap::const_iterator it = frame_objects_.find(frame_id); + if (it != frame_objects_.end()) + manager = it->second; + } + + if (!manager.get()) { + manager = new CefTrackManager(); + frame_objects_.insert(std::make_pair(frame_id, manager)); + } + + manager->Add(tracked_object); +} + + +// RenderViewObserver methods. +// ----------------------------------------------------------------------------- + +void CefBrowserImpl::OnDestruct() { + // Notify that the browser window has been destroyed. + CefRefPtr app = CefContentClient::Get()->application(); + if (app.get()) { + CefRefPtr handler = + app->GetRenderProcessHandler(); + if (handler.get()) + handler->OnBrowserDestroyed(this); + } + + response_manager_.reset(NULL); + + CefContentRendererClient::Get()->OnBrowserDestroyed(this); +} + +void CefBrowserImpl::DidFinishLoad(WebKit::WebFrame* frame) { + WebKit::WebDataSource* ds = frame->dataSource(); + Send(new CefHostMsg_DidFinishLoad(routing_id(), + frame->identifier(), + ds->request().url(), + !frame->parent(), + ds->response().httpStatusCode())); +} + +void CefBrowserImpl::DidStartProvisionalLoad(WebKit::WebFrame* frame) { + // Send the frame creation notification if necessary. + GetWebFrameImpl(frame); +} + +void CefBrowserImpl::FrameDetached(WebFrame* frame) { + int64 frame_id = frame->identifier(); + + { + // Remove the frame from the map. + FrameMap::iterator it = frames_.find(frame_id); + DCHECK(it != frames_.end()); + it->second->Detach(); + frames_.erase(it); + } + + if (!frame_objects_.empty()) { + // Remove any tracked objects associated with the frame. + FrameObjectMap::iterator it = frame_objects_.find(frame_id); + if (it != frame_objects_.end()) + frame_objects_.erase(it); + } + + // Notify the browser that the frame has detached. + Send(new CefHostMsg_FrameDetached(routing_id(), frame_id)); +} + +void CefBrowserImpl::FocusedNodeChanged(const WebKit::WebNode& node) { + // Notify the handler. + CefRefPtr app = CefContentClient::Get()->application(); + if (app.get()) { + CefRefPtr handler = + app->GetRenderProcessHandler(); + if (handler.get()) { + if (node.isNull()) { + handler->OnFocusedNodeChanged(this, GetFocusedFrame(), NULL); + } else { + const WebKit::WebDocument& document = node.document(); + if (!document.isNull()) { + WebKit::WebFrame* frame = document.frame(); + CefRefPtr documentImpl = + new CefDOMDocumentImpl(this, frame); + handler->OnFocusedNodeChanged(this, + GetWebFrameImpl(frame).get(), + documentImpl->GetOrCreateNode(node)); + documentImpl->Detach(); + } + } + } + } + + // TODO(cef): This method is being used as a work-around for identifying frame + // focus changes. The ideal approach would be implementating delegation from + // ChromeClientImpl::focusedFrameChanged(). + + WebFrame* focused_frame = NULL; + + // Try to identify the focused frame from the node. + if (!node.isNull()) { + const WebKit::WebDocument& document = node.document(); + if (!document.isNull()) + focused_frame = document.frame(); + } + + if (focused_frame == NULL && render_view()->GetWebView()) { + // Try to identify the global focused frame. + focused_frame = render_view()->GetWebView()->focusedFrame(); + } + + int64 frame_id = kInvalidFrameId; + if (focused_frame != NULL) + frame_id = focused_frame->identifier(); + + // Don't send a message if the focused frame has not changed. + if (frame_id == last_focused_frame_id_) + return; + + last_focused_frame_id_ = frame_id; + Send(new CefHostMsg_FrameFocusChange(routing_id(), frame_id)); +} + +void CefBrowserImpl::DidCreateDataSource(WebKit::WebFrame* frame, + WebKit::WebDataSource* ds) { + const WebKit::WebURLRequest& request = ds->request(); + if (request.requestorID() == -1) { + // Mark the request as browser-initiated so + // RenderViewImpl::decidePolicyForNavigation won't attempt to fork it. + content::DocumentState* document_state = + content::DocumentState::FromDataSource(ds); + document_state->set_navigation_state( + content::NavigationState::CreateBrowserInitiated(-1, -1, + content::PAGE_TRANSITION_LINK)); + } + + if (frame->parent() == 0) { + GURL url = ds->request().url(); + if (!url.is_empty()) { + // Notify that the loading URL has changed. + Send(new CefHostMsg_LoadingURLChange(routing_id(), url)); + } + } +} + +bool CefBrowserImpl::OnMessageReceived(const IPC::Message& message) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(CefBrowserImpl, message) + IPC_MESSAGE_HANDLER(CefMsg_Request, OnRequest) + IPC_MESSAGE_HANDLER(CefMsg_Response, OnResponse) + IPC_MESSAGE_HANDLER(CefMsg_ResponseAck, OnResponseAck) + IPC_MESSAGE_HANDLER(CefMsg_LoadRequest, LoadRequest) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + + +// RenderViewObserver::OnMessageReceived message handlers. +// ----------------------------------------------------------------------------- + +void CefBrowserImpl::OnRequest(const Cef_Request_Params& params) { + bool success = false; + std::string response; + bool expect_response_ack = false; + + if (params.user_initiated) { + // Give the user a chance to handle the request. + CefRefPtr app = CefContentClient::Get()->application(); + if (app.get()) { + CefRefPtr handler = + app->GetRenderProcessHandler(); + if (handler.get()) { + CefRefPtr message( + new CefProcessMessageImpl(const_cast(¶ms), + false, true)); + success = handler->OnProcessMessageReceived(this, PID_BROWSER, + message.get()); + message->Detach(NULL); + } + } + } else if (params.name == "execute-code") { + // Execute code. + CefRefPtr framePtr = GetWebFrameImpl(params.frame_id); + if (framePtr.get()) { + WebFrame* web_frame = framePtr->web_frame(); + if (web_frame) { + DCHECK_EQ(params.arguments.GetSize(), (size_t)4); + + bool is_javascript = false; + std::string code, script_url; + int script_start_line = 0; + + params.arguments.GetBoolean(0, &is_javascript); + params.arguments.GetString(1, &code); + DCHECK(!code.empty()); + params.arguments.GetString(2, &script_url); + params.arguments.GetInteger(3, &script_start_line); + DCHECK_GE(script_start_line, 0); + + if (is_javascript) { + web_frame->executeScript( + WebScriptSource(UTF8ToUTF16(code), + GURL(script_url), + script_start_line)); + success = true; + } else { + // TODO(cef): implement support for CSS code. + NOTIMPLEMENTED(); + } + } + } + } else if (params.name == "execute-command") { + // Execute command. + CefRefPtr framePtr = GetWebFrameImpl(params.frame_id); + if (framePtr.get()) { + WebFrame* web_frame = framePtr->web_frame(); + if (web_frame) { + DCHECK_EQ(params.arguments.GetSize(), (size_t)1); + + std::string command; + + params.arguments.GetString(0, &command); + DCHECK(!command.empty()); + + if (LowerCaseEqualsASCII(command, "getsource")) { + response = web_frame->contentAsMarkup().utf8(); + success = true; + } else if (LowerCaseEqualsASCII(command, "gettext")) { + response = UTF16ToUTF8(webkit_glue::DumpDocumentText(web_frame)); + success = true; + } else if (web_frame->executeCommand(UTF8ToUTF16(command))) { + success = true; + } + } + } + } else if (params.name == "load-string") { + // Load a string. + CefRefPtr framePtr = GetWebFrameImpl(params.frame_id); + if (framePtr.get()) { + WebFrame* web_frame = framePtr->web_frame(); + if (web_frame) { + DCHECK_EQ(params.arguments.GetSize(), (size_t)2); + + std::string string, url; + + params.arguments.GetString(0, &string); + params.arguments.GetString(1, &url); + + web_frame->loadHTMLString(string, GURL(url)); + } + } + } else { + // Invalid request. + NOTREACHED(); + } + + if (params.expect_response) { + DCHECK_GE(params.request_id, 0); + + // Send a response to the browser. + Cef_Response_Params response_params; + response_params.request_id = params.request_id; + response_params.success = success; + response_params.response = response; + response_params.expect_response_ack = expect_response_ack; + Send(new CefHostMsg_Response(routing_id(), response_params)); + } +} + +void CefBrowserImpl::OnResponse(const Cef_Response_Params& params) { + response_manager_->RunHandler(params); + if (params.expect_response_ack) + Send(new CefHostMsg_ResponseAck(routing_id(), params.request_id)); +} + +void CefBrowserImpl::OnResponseAck(int request_id) { + response_manager_->RunAckHandler(request_id); +} diff --git a/cef3/libcef/renderer/browser_impl.h b/cef3/libcef/renderer/browser_impl.h new file mode 100644 index 000000000..485abc16c --- /dev/null +++ b/cef3/libcef/renderer/browser_impl.h @@ -0,0 +1,147 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 The Chromium 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_LIBCEF_RENDERER_BROWSER_IMPL_H_ +#define CEF_LIBCEF_RENDERER_BROWSER_IMPL_H_ +#pragma once + +#include +#include +#include + +#include "include/cef_browser.h" +#include "include/cef_client.h" +#include "libcef/common/tracker.h" +#include "libcef/renderer/frame_impl.h" + +#include "base/memory/scoped_ptr.h" +#include "content/public/renderer/render_view_observer.h" + +class GURL; +struct CefMsg_LoadRequest_Params; +struct Cef_Request_Params; +struct Cef_Response_Params; +class CefContentRendererClient; +class CefResponseManager; + +namespace base { +class ListValue; +} + +namespace WebKit { +class WebFrame; +} + +// Renderer plumbing for CEF features. There is a one-to-one relationship +// between RenderView on the renderer side and RenderViewHost on the browser +// side. +// +// RenderViewObserver: Interface for observing RenderView notifications and IPC +// messages. IPC messages received by the RenderView will be forwarded to this +// RenderViewObserver implementation. IPC messages sent using +// RenderViewObserver::Send() will be forwarded to the RenderView. Use +// RenderViewObserver::routing_id() when sending IPC messages. +class CefBrowserImpl : public CefBrowser, + public content::RenderViewObserver { + public: + // Returns the browser associated with the specified RenderView. + static CefRefPtr GetBrowserForView(content::RenderView* view); + // Returns the browser associated with the specified main WebFrame. + static CefRefPtr GetBrowserForMainFrame( + WebKit::WebFrame* frame); + + // CefBrowser methods. + virtual CefRefPtr GetHost() OVERRIDE; + virtual bool CanGoBack() OVERRIDE; + virtual void GoBack() OVERRIDE; + virtual bool CanGoForward() OVERRIDE; + virtual void GoForward() OVERRIDE; + virtual bool IsLoading() OVERRIDE; + virtual void Reload() OVERRIDE; + virtual void ReloadIgnoreCache() OVERRIDE; + virtual void StopLoad() OVERRIDE; + virtual int GetIdentifier() OVERRIDE; + virtual bool IsSame(CefRefPtr that) OVERRIDE; + virtual bool IsPopup() OVERRIDE; + virtual bool HasDocument() OVERRIDE; + virtual CefRefPtr GetMainFrame() OVERRIDE; + virtual CefRefPtr GetFocusedFrame() OVERRIDE; + virtual CefRefPtr GetFrame(int64 identifier) OVERRIDE; + virtual CefRefPtr GetFrame(const CefString& name) OVERRIDE; + virtual size_t GetFrameCount() OVERRIDE; + virtual void GetFrameIdentifiers(std::vector& identifiers) OVERRIDE; + virtual void GetFrameNames(std::vector& names) OVERRIDE; + virtual bool SendProcessMessage( + CefProcessId target_process, + CefRefPtr message) OVERRIDE; + + CefBrowserImpl(content::RenderView* render_view, + int browser_id, + bool is_popup); + virtual ~CefBrowserImpl(); + + void LoadRequest(const CefMsg_LoadRequest_Params& params); + + // Avoids unnecessary string type conversions. + bool SendProcessMessage(CefProcessId target_process, + const std::string& name, + base::ListValue* arguments, + bool user_initiated); + + // Returns the matching CefFrameImpl reference or creates a new one. + CefRefPtr GetWebFrameImpl(WebKit::WebFrame* frame); + CefRefPtr GetWebFrameImpl(int64 frame_id); + + // Frame objects will be deleted immediately before the frame is closed. + void AddFrameObject(int64 frame_id, CefTrackNode* tracked_object); + + int browser_id() const { return browser_id_; } + bool is_popup() const { return is_popup_; } + content::RenderView* render_view() { + return content::RenderViewObserver::render_view(); + } + + private: + // RenderViewObserver methods. + virtual void OnDestruct() OVERRIDE; + virtual void DidFinishLoad(WebKit::WebFrame* frame) OVERRIDE; + virtual void DidStartProvisionalLoad(WebKit::WebFrame* frame) OVERRIDE; + virtual void FrameDetached(WebKit::WebFrame* frame) OVERRIDE; + virtual void FocusedNodeChanged(const WebKit::WebNode& node) OVERRIDE; + virtual void DidCreateDataSource(WebKit::WebFrame* frame, + WebKit::WebDataSource* ds) OVERRIDE; + virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; + + // RenderViewObserver::OnMessageReceived message handlers. + void OnRequest(const Cef_Request_Params& params); + void OnResponse(const Cef_Response_Params& params); + void OnResponseAck(int request_id); + + // ID of the browser that this RenderView is associated with. During loading + // of cross-origin requests multiple RenderViews may be associated with the + // same browser ID. + int browser_id_; + bool is_popup_; + + // Id of the last frame that had focus. + int64 last_focused_frame_id_; + + // Map of unique frame ids to CefFrameImpl references. + typedef std::map > FrameMap; + FrameMap frames_; + + // Map of unique frame ids to CefTrackManager objects that need to be cleaned + // up when the frame is deleted. + typedef std::map > FrameObjectMap; + FrameObjectMap frame_objects_; + + // Manages response registrations. + scoped_ptr response_manager_; + + IMPLEMENT_REFCOUNTING(CefBrowserImpl); + DISALLOW_COPY_AND_ASSIGN(CefBrowserImpl); +}; + +#endif // CEF_LIBCEF_RENDERER_BROWSER_IMPL_H_ diff --git a/cef3/libcef/renderer/chrome_bindings.cc b/cef3/libcef/renderer/chrome_bindings.cc new file mode 100644 index 000000000..73e33dff5 --- /dev/null +++ b/cef3/libcef/renderer/chrome_bindings.cc @@ -0,0 +1,119 @@ +// 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 "libcef/renderer/chrome_bindings.h" +#include "libcef/renderer/browser_impl.h" + +#include + +#include "base/logging.h" +#include "base/values.h" +#include "content/public/common/url_constants.h" + +namespace scheme { + +namespace { + +void SetList(CefRefPtr source, base::ListValue* target); + +// Transfer a V8 value to a List index. +void SetListValue(base::ListValue* list, int index, + CefRefPtr value) { + if (value->IsArray()) { + base::ListValue* new_list = new base::ListValue(); + SetList(value, new_list); + list->Set(index, new_list); + } else if (value->IsString()) { + list->Set(index, + base::Value::CreateStringValue(value->GetStringValue().ToString())); + } else if (value->IsBool()) { + list->Set(index, base::Value::CreateBooleanValue(value->GetBoolValue())); + } else if (value->IsInt()) { + list->Set(index, base::Value::CreateIntegerValue(value->GetIntValue())); + } else if (value->IsDouble()) { + list->Set(index, base::Value::CreateDoubleValue(value->GetDoubleValue())); + } +} + +// Transfer a V8 array to a List. +void SetList(CefRefPtr source, base::ListValue* target) { + DCHECK(source->IsArray()); + + int arg_length = source->GetArrayLength(); + if (arg_length == 0) + return; + + for (int i = 0; i < arg_length; ++i) + SetListValue(target, i, source->GetValue(i)); +} + +class V8Handler : public CefV8Handler { +public: + V8Handler() {} + + virtual bool Execute(const CefString& name, + CefRefPtr object, + const CefV8ValueList& arguments, + CefRefPtr& retval, + CefString& exception) OVERRIDE { + std::string nameStr = name; + if (nameStr == "send") { + if (arguments.size() > 0 && arguments.size() <= 2 && + arguments[0]->IsString()) { + base::ListValue args; + SetListValue(&args, 0, arguments[0]); + if (arguments.size() > 1) + SetListValue(&args, 1, arguments[1]); + + CefRefPtr browser = static_cast( + CefV8Context::GetCurrentContext()->GetBrowser().get()); + browser->SendProcessMessage(PID_BROWSER, kChromeProcessMessage, &args, + false); + + retval = CefV8Value::CreateBool(true); + } else { + exception = "Invalid number of arguments or argument format"; + } + return true; + } else if (nameStr == "bind") { + // Return the "send" object. + DCHECK(object->GetFunctionName() == "send"); + retval = object; + return true; + } + + NOTREACHED(); + return false; + } + + IMPLEMENT_REFCOUNTING(V8Handler); +}; + +} // namespace + +void OnContextCreated(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context) { + GURL url = GURL(frame->GetURL().ToString()); + if (url.scheme() != chrome::kChromeUIScheme) + return; + + CefRefPtr global = context->GetGlobal(); + + CefRefPtr handler = new V8Handler(); + + // Add "chrome". + CefRefPtr chrome = CefV8Value::CreateObject(NULL); + global->SetValue("chrome", chrome, V8_PROPERTY_ATTRIBUTE_NONE); + + // Add "chrome.send". + CefRefPtr send = CefV8Value::CreateFunction("send", handler); + chrome->SetValue("send", send, V8_PROPERTY_ATTRIBUTE_NONE); + + // Add "chrome.send.bind". + CefRefPtr bind = CefV8Value::CreateFunction("bind", handler); + send->SetValue("bind", bind, V8_PROPERTY_ATTRIBUTE_NONE); +} + +} // namespace scheme diff --git a/cef3/libcef/renderer/chrome_bindings.h b/cef3/libcef/renderer/chrome_bindings.h new file mode 100644 index 000000000..b62d458fd --- /dev/null +++ b/cef3/libcef/renderer/chrome_bindings.h @@ -0,0 +1,23 @@ +// 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. + +#ifndef CEF_LIBCEF_RENDERER_CHROME_BINDINGS_H_ +#define CEF_LIBCEF_RENDERER_CHROME_BINDINGS_H_ +#pragma once + +#include "include/cef_v8.h" +#include "libcef/renderer/browser_impl.h" +#include "libcef/renderer/frame_impl.h" + +namespace scheme { + +extern const char kChromeProcessMessage[]; + +void OnContextCreated(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context); + +} // namespace scheme + +#endif // CEF_LIBCEF_RENDERER_CHROME_BINDINGS_H_ diff --git a/cef3/libcef/renderer/content_renderer_client.cc b/cef3/libcef/renderer/content_renderer_client.cc new file mode 100644 index 000000000..280f5d9d6 --- /dev/null +++ b/cef3/libcef/renderer/content_renderer_client.cc @@ -0,0 +1,675 @@ +// Copyright (c) 2013 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2012 The Chromium 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 "base/compiler_specific.h" + +#include "third_party/WebKit/Source/WebCore/config.h" +MSVC_PUSH_WARNING_LEVEL(0); +#include "V8RecursionScope.h" // NOLINT(build/include) +#include "V8Utilities.h" // NOLINT(build/include) +MSVC_POP_WARNING(); +#undef LOG + +#include "libcef/renderer/content_renderer_client.h" + +#include "libcef/browser/context.h" +#include "libcef/common/cef_messages.h" +#include "libcef/common/cef_switches.h" +#include "libcef/common/content_client.h" +#include "libcef/common/request_impl.h" +#include "libcef/common/values_impl.h" +#include "libcef/renderer/browser_impl.h" +#include "libcef/renderer/chrome_bindings.h" +#include "libcef/renderer/render_message_filter.h" +#include "libcef/renderer/render_process_observer.h" +#include "libcef/renderer/thread_util.h" +#include "libcef/renderer/v8_impl.h" + +#include "base/command_line.h" +#include "base/path_service.h" +#include "base/string_number_conversions.h" +#include "chrome/renderer/loadtimes_extension_bindings.h" +#include "content/common/child_thread.h" +#include "content/public/browser/browser_thread.h" +#include "content/public/browser/render_process_host.h" +#include "content/public/renderer/render_thread.h" +#include "content/public/renderer/render_view.h" +#include "ipc/ipc_sync_channel.h" +#include "media/base/media.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebPrerenderingSupport.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebWorkerRunLoop.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebPrerendererClient.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebWorkerInfo.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebWorkerScriptObserver.h" +#include "v8/include/v8.h" +#include "webkit/glue/worker_task_runner.h" + +namespace { + +// Stub implementation of WebKit::WebPrerenderingSupport. +class CefPrerenderingSupport : public WebKit::WebPrerenderingSupport { + public: + virtual ~CefPrerenderingSupport() {} + + private: + virtual void add(const WebKit::WebPrerender& prerender) OVERRIDE {} + virtual void cancel(const WebKit::WebPrerender& prerender) OVERRIDE {} + virtual void abandon(const WebKit::WebPrerender& prerender) OVERRIDE {} +}; + +// Stub implementation of WebKit::WebPrerendererClient. +class CefPrerendererClient : public content::RenderViewObserver, + public WebKit::WebPrerendererClient { + public: + explicit CefPrerendererClient(content::RenderView* render_view) + : content::RenderViewObserver(render_view) { + DCHECK(render_view); + render_view->GetWebView()->setPrerendererClient(this); + } + + private: + virtual ~CefPrerendererClient() {} + + virtual void willAddPrerender(WebKit::WebPrerender* prerender) OVERRIDE {} +}; + +// Implementation of SequencedTaskRunner for WebWorker threads. +class CefWebWorkerTaskRunner : public base::SequencedTaskRunner, + public webkit_glue::WorkerTaskRunner::Observer { + public: + CefWebWorkerTaskRunner(webkit_glue::WorkerTaskRunner* runner, + int worker_id) + : runner_(runner), + worker_id_(worker_id) { + DCHECK(runner_); + DCHECK_GT(worker_id_, 0); + DCHECK(RunsTasksOnCurrentThread()); + + // Adds an observer for the current thread. + runner_->AddStopObserver(this); + } + + // SequencedTaskRunner methods: + virtual bool PostNonNestableDelayedTask( + const tracked_objects::Location& from_here, + const base::Closure& task, + base::TimeDelta delay) OVERRIDE { + return PostDelayedTask(from_here, task, delay); + } + + // TaskRunner methods: + virtual bool PostDelayedTask(const tracked_objects::Location& from_here, + const base::Closure& task, + base::TimeDelta delay) OVERRIDE { + if (delay != base::TimeDelta()) + LOG(WARNING) << "Delayed tasks are not supported on WebWorker threads"; + runner_->PostTask(worker_id_, task); + return true; + } + + virtual bool RunsTasksOnCurrentThread() const OVERRIDE { + return (runner_->CurrentWorkerId() == worker_id_); + } + + // WorkerTaskRunner::Observer methods: + virtual void OnWorkerRunLoopStopped() OVERRIDE { + CefContentRendererClient::Get()->RemoveWorkerTaskRunner(worker_id_); + } + + private: + webkit_glue::WorkerTaskRunner* runner_; + int worker_id_; +}; + +} // namespace + + +class CefWebWorkerScriptObserver : public WebKit::WebWorkerScriptObserver { + public: + CefWebWorkerScriptObserver() { + } + + virtual void didCreateWorkerScriptContext( + const WebKit::WebWorkerRunLoop& run_loop, + const WebKit::WebURL& url, + v8::Handle context) OVERRIDE { + // Create global objects associated with the WebWorker Isolate. + CefV8IsolateCreated(); + + int stack_size = + CefContentRendererClient::Get()->uncaught_exception_stack_size(); + if (stack_size > 0) + CefV8SetUncaughtExceptionStackSize(stack_size); + + webkit_glue::WorkerTaskRunner* worker_runner = + webkit_glue::WorkerTaskRunner::Instance(); + int worker_id = worker_runner->CurrentWorkerId(); + DCHECK_GT(worker_id, 0); + GURL gurl = GURL(url); + + CefV8SetWorkerAttributes(worker_id, gurl); + + // Notify the render process handler. + CefRefPtr application = CefContentClient::Get()->application(); + if (application.get()) { + CefRefPtr handler = + application->GetRenderProcessHandler(); + if (handler.get()) { + v8::HandleScope handle_scope; + v8::Context::Scope scope(context); + + CefRefPtr contextPtr(new CefV8ContextImpl(context)); + handler->OnWorkerContextCreated(worker_id, gurl.spec(), contextPtr); + } + } + } + + virtual void willReleaseWorkerScriptContext( + const WebKit::WebWorkerRunLoop& run_loop, + const WebKit::WebURL& url, + v8::Handle context) OVERRIDE { + v8::HandleScope handle_scope; + v8::Context::Scope scope(context); + + // Notify the render process handler. + CefRefPtr application = CefContentClient::Get()->application(); + if (application.get()) { + CefRefPtr handler = + application->GetRenderProcessHandler(); + if (handler.get()) { + webkit_glue::WorkerTaskRunner* worker_runner = + webkit_glue::WorkerTaskRunner::Instance(); + int worker_id = worker_runner->CurrentWorkerId(); + DCHECK_GT(worker_id, 0); + + CefRefPtr contextPtr(new CefV8ContextImpl(context)); + GURL gurl = GURL(url); + handler->OnWorkerContextReleased(worker_id, gurl.spec(), contextPtr); + } + } + + CefV8ReleaseContext(context); + + // Destroy global objects associated with the WebWorker Isolate. + CefV8IsolateDestroyed(); + } +}; + + +struct CefContentRendererClient::SchemeInfo { + std::string scheme_name; + bool is_local; + bool is_display_isolated; +}; + +CefContentRendererClient::CefContentRendererClient() + : devtools_agent_count_(0), + uncaught_exception_stack_size_(0), + single_process_cleanup_complete_(false) { +} + +CefContentRendererClient::~CefContentRendererClient() { +} + +// static +CefContentRendererClient* CefContentRendererClient::Get() { + return static_cast( + content::GetContentClient()->renderer()); +} + +CefRefPtr CefContentRendererClient::GetBrowserForView( + content::RenderView* view) { + CEF_REQUIRE_RT_RETURN(NULL); + + BrowserMap::const_iterator it = browsers_.find(view); + if (it != browsers_.end()) + return it->second; + return NULL; +} + +CefRefPtr CefContentRendererClient::GetBrowserForMainFrame( + WebKit::WebFrame* frame) { + CEF_REQUIRE_RT_RETURN(NULL); + + BrowserMap::const_iterator it = browsers_.begin(); + for (; it != browsers_.end(); ++it) { + content::RenderView* render_view = it->second->render_view(); + if (render_view && render_view->GetWebView() && + render_view->GetWebView()->mainFrame() == frame) { + return it->second; + } + } + + return NULL; +} + +void CefContentRendererClient::OnBrowserDestroyed(CefBrowserImpl* browser) { + BrowserMap::iterator it = browsers_.begin(); + for (; it != browsers_.end(); ++it) { + if (it->second.get() == browser) { + browsers_.erase(it); + return; + } + } + + // No browser was found in the map. + NOTREACHED(); +} + +void CefContentRendererClient::AddCustomScheme( + const std::string& scheme_name, + bool is_local, + bool is_display_isolated) { + SchemeInfo info = {scheme_name, is_local, is_display_isolated}; + scheme_info_list_.push_back(info); +} + +void CefContentRendererClient::WebKitInitialized() { + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + + WebKit::WebRuntimeFeatures::enableMediaPlayer( + media::IsMediaLibraryInitialized()); + + // TODO(cef): Enable these once the implementation supports it. + WebKit::WebRuntimeFeatures::enableNotifications(false); + + WebKit::WebRuntimeFeatures::enableSpeechInput( + command_line.HasSwitch(switches::kEnableSpeechInput)); + WebKit::WebRuntimeFeatures::enableMediaStream( + command_line.HasSwitch(switches::kEnableMediaStream)); + + worker_script_observer_.reset(new CefWebWorkerScriptObserver()); + WebKit::WebWorkerInfo::addScriptObserver(worker_script_observer_.get()); + + if (!scheme_info_list_.empty()) { + // Register the custom schemes. + SchemeInfoList::const_iterator it = scheme_info_list_.begin(); + for (; it != scheme_info_list_.end(); ++it) { + const SchemeInfo& info = *it; + if (info.is_local) { + WebKit::WebSecurityPolicy::registerURLSchemeAsLocal( + WebKit::WebString::fromUTF8(info.scheme_name)); + } + if (info.is_display_isolated) { + WebKit::WebSecurityPolicy::registerURLSchemeAsDisplayIsolated( + WebKit::WebString::fromUTF8(info.scheme_name)); + } + } + } + + if (!cross_origin_whitelist_entries_.empty()) { + // Add the cross-origin white list entries. + for (size_t i = 0; i < cross_origin_whitelist_entries_.size(); ++i) { + const Cef_CrossOriginWhiteListEntry_Params& entry = + cross_origin_whitelist_entries_[i]; + GURL gurl = GURL(entry.source_origin); + WebKit::WebSecurityPolicy::addOriginAccessWhitelistEntry( + gurl, + WebKit::WebString::fromUTF8(entry.target_protocol), + WebKit::WebString::fromUTF8(entry.target_domain), + entry.allow_target_subdomains); + } + cross_origin_whitelist_entries_.clear(); + } + + // The number of stack trace frames to capture for uncaught exceptions. + if (command_line.HasSwitch(switches::kUncaughtExceptionStackSize)) { + int uncaught_exception_stack_size = 0; + base::StringToInt( + command_line.GetSwitchValueASCII(switches::kUncaughtExceptionStackSize), + &uncaught_exception_stack_size); + + if (uncaught_exception_stack_size > 0) { + uncaught_exception_stack_size_ = uncaught_exception_stack_size; + CefV8SetUncaughtExceptionStackSize(uncaught_exception_stack_size_); + } + } + + // Notify the render process handler. + CefRefPtr application = CefContentClient::Get()->application(); + if (application.get()) { + CefRefPtr handler = + application->GetRenderProcessHandler(); + if (handler.get()) + handler->OnWebKitInitialized(); + } +} + +void CefContentRendererClient::OnRenderProcessShutdown() { + // Destroy global objects associated with the default Isolate. + CefV8IsolateDestroyed(); +} + +void CefContentRendererClient::DevToolsAgentAttached() { + CEF_REQUIRE_RT(); + ++devtools_agent_count_; +} + +void CefContentRendererClient::DevToolsAgentDetached() { + CEF_REQUIRE_RT(); + --devtools_agent_count_; + if (devtools_agent_count_ == 0 && uncaught_exception_stack_size_ > 0) { + // When the last DevToolsAgent is detached the stack size is set to 0. + // Restore the user-specified stack size here. + CefV8SetUncaughtExceptionStackSize(uncaught_exception_stack_size_); + + // And do the same for any WebWorker threads. + WorkerTaskRunnerMap map_copy; + + { + base::AutoLock lock_scope(worker_task_runner_lock_); + map_copy = worker_task_runner_map_; + } + + WorkerTaskRunnerMap::const_iterator it = map_copy.begin(); + for (; it != map_copy.end(); ++it) { + it->second->PostTask(FROM_HERE, + base::Bind(CefV8SetUncaughtExceptionStackSize, + uncaught_exception_stack_size_)); + } + } +} + +scoped_refptr + CefContentRendererClient::GetCurrentTaskRunner() { + // Check if currently on the render thread. + if (CEF_CURRENTLY_ON_RT()) + return render_task_runner_; + + // Check if a WebWorker exists for the current thread. + webkit_glue::WorkerTaskRunner* worker_runner = + webkit_glue::WorkerTaskRunner::Instance(); + int worker_id = worker_runner->CurrentWorkerId(); + if (worker_id > 0) { + base::AutoLock lock_scope(worker_task_runner_lock_); + WorkerTaskRunnerMap::const_iterator it = + worker_task_runner_map_.find(worker_id); + if (it != worker_task_runner_map_.end()) + return it->second; + + scoped_refptr task_runner = + new CefWebWorkerTaskRunner(worker_runner, worker_id); + worker_task_runner_map_[worker_id] = task_runner; + return task_runner; + } + + return NULL; +} + +scoped_refptr + CefContentRendererClient::GetWorkerTaskRunner(int worker_id) { + base::AutoLock lock_scope(worker_task_runner_lock_); + WorkerTaskRunnerMap::const_iterator it = + worker_task_runner_map_.find(worker_id); + if (it != worker_task_runner_map_.end()) + return it->second; + + return NULL; +} + +void CefContentRendererClient::RemoveWorkerTaskRunner(int worker_id) { + base::AutoLock lock_scope(worker_task_runner_lock_); + WorkerTaskRunnerMap::iterator it = worker_task_runner_map_.find(worker_id); + if (it != worker_task_runner_map_.end()) + worker_task_runner_map_.erase(it); +} + +void CefContentRendererClient::RunSingleProcessCleanup() { + DCHECK(content::RenderProcessHost::run_renderer_in_process()); + + // Make sure the render thread was actually started. + if (!render_task_runner_) + return; + + if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { + RunSingleProcessCleanupOnUIThread(); + } else { + content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, + base::Bind(&CefContentRendererClient::RunSingleProcessCleanupOnUIThread, + base::Unretained(this))); + } + + // Wait for the render thread cleanup to complete. Spin instead of using + // base::WaitableEvent because calling Wait() is not allowed on the UI + // thread. + bool complete = false; + do { + { + base::AutoLock lock_scope(single_process_cleanup_lock_); + complete = single_process_cleanup_complete_; + } + if (!complete) + base::PlatformThread::YieldCurrentThread(); + } while (!complete); +} + +void CefContentRendererClient::RenderThreadStarted() { + render_task_runner_ = base::MessageLoopProxy::current(); + observer_.reset(new CefRenderProcessObserver()); + + content::RenderThread* thread = content::RenderThread::Get(); + thread->AddObserver(observer_.get()); + thread->GetChannel()->AddFilter(new CefRenderMessageFilter); + thread->RegisterExtension(extensions_v8::LoadTimesExtension::Get()); + + if (content::RenderProcessHost::run_renderer_in_process()) { + // When running in single-process mode register as a destruction observer + // on the render thread's MessageLoop. + MessageLoop::current()->AddDestructionObserver(this); + } + + // Note that under Linux, the media library will normally already have + // been initialized by the Zygote before this instance became a Renderer. + base::FilePath media_path; + PathService::Get(base::DIR_MODULE, &media_path); + if (!media_path.empty()) + media::InitializeMediaLibrary(media_path); + + WebKit::WebPrerenderingSupport::initialize(new CefPrerenderingSupport()); + + // Create global objects associated with the default Isolate. + CefV8IsolateCreated(); + + // Retrieve the new render thread information synchronously. + CefProcessHostMsg_GetNewRenderThreadInfo_Params params; + thread->Send(new CefProcessHostMsg_GetNewRenderThreadInfo(¶ms)); + + // Cross-origin entries need to be added after WebKit is initialized. + cross_origin_whitelist_entries_ = params.cross_origin_whitelist_entries; + + // Notify the render process handler. + CefRefPtr application = CefContentClient::Get()->application(); + if (application.get()) { + CefRefPtr handler = + application->GetRenderProcessHandler(); + if (handler.get()) { + CefRefPtr listValuePtr( + new CefListValueImpl(¶ms.extra_info, false, true)); + handler->OnRenderThreadCreated(listValuePtr.get()); + listValuePtr->Detach(NULL); + } + } +} + +void CefContentRendererClient::RenderViewCreated( + content::RenderView* render_view) { + // Retrieve the new browser information synchronously. + CefProcessHostMsg_GetNewBrowserInfo_Params params; + content::RenderThread::Get()->Send( + new CefProcessHostMsg_GetNewBrowserInfo(render_view->GetRoutingID(), + ¶ms)); + DCHECK_GT(params.browser_id, 0); + + CefRefPtr browser = + new CefBrowserImpl(render_view, params.browser_id, params.is_popup); + browsers_.insert(std::make_pair(render_view, browser)); + + new CefPrerendererClient(render_view); + + // Notify the render process handler. + CefRefPtr application = CefContentClient::Get()->application(); + if (application.get()) { + CefRefPtr handler = + application->GetRenderProcessHandler(); + if (handler.get()) + handler->OnBrowserCreated(browser.get()); + } +} + +bool CefContentRendererClient::HandleNavigation( + WebKit::WebFrame* frame, + const WebKit::WebURLRequest& request, + WebKit::WebNavigationType type, + WebKit::WebNavigationPolicy default_policy, + bool is_redirect) { + CefRefPtr application = CefContentClient::Get()->application(); + if (application.get()) { + CefRefPtr handler = + application->GetRenderProcessHandler(); + if (handler.get()) { + CefRefPtr browserPtr = + CefBrowserImpl::GetBrowserForMainFrame(frame->top()); + DCHECK(browserPtr.get()); + if (browserPtr.get()) { + CefRefPtr framePtr = browserPtr->GetWebFrameImpl(frame); + CefRefPtr requestPtr(CefRequest::Create()); + CefRequestImpl* requestImpl = + static_cast(requestPtr.get()); + requestImpl->Set(request); + requestImpl->SetReadOnly(true); + + cef_navigation_type_t navigation_type = NAVIGATION_OTHER; + switch (type) { + case WebKit::WebNavigationTypeLinkClicked: + navigation_type = NAVIGATION_LINK_CLICKED; + break; + case WebKit::WebNavigationTypeFormSubmitted: + navigation_type = NAVIGATION_FORM_SUBMITTED; + break; + case WebKit::WebNavigationTypeBackForward: + navigation_type = NAVIGATION_BACK_FORWARD; + break; + case WebKit::WebNavigationTypeReload: + navigation_type = NAVIGATION_RELOAD; + break; + case WebKit::WebNavigationTypeFormResubmitted: + navigation_type = NAVIGATION_FORM_RESUBMITTED; + break; + case WebKit::WebNavigationTypeOther: + navigation_type = NAVIGATION_OTHER; + break; + } + + if (handler->OnBeforeNavigation(browserPtr.get(), framePtr.get(), + requestPtr.get(), navigation_type, + is_redirect)) { + return true; + } + } + } + } + + return false; +} + +void CefContentRendererClient::DidCreateScriptContext( + WebKit::WebFrame* frame, v8::Handle context, + int extension_group, int world_id) { + CefRefPtr browserPtr = + CefBrowserImpl::GetBrowserForMainFrame(frame->top()); + DCHECK(browserPtr.get()); + if (!browserPtr.get()) + return; + + CefRefPtr framePtr = browserPtr->GetWebFrameImpl(frame); + + v8::HandleScope handle_scope; + v8::Context::Scope scope(context); + WebCore::V8RecursionScope recursion_scope( + WebCore::getScriptExecutionContext()); + + CefRefPtr contextPtr(new CefV8ContextImpl(context)); + + scheme::OnContextCreated(browserPtr, framePtr, contextPtr); + + // Notify the render process handler. + CefRefPtr application = CefContentClient::Get()->application(); + if (application.get()) { + CefRefPtr handler = + application->GetRenderProcessHandler(); + if (handler.get()) + handler->OnContextCreated(browserPtr.get(), framePtr.get(), contextPtr); + } +} + +void CefContentRendererClient::WillReleaseScriptContext( + WebKit::WebFrame* frame, v8::Handle context, int world_id) { + // Notify the render process handler. + CefRefPtr application = CefContentClient::Get()->application(); + if (application.get()) { + CefRefPtr handler = + application->GetRenderProcessHandler(); + if (handler.get()) { + CefRefPtr browserPtr = + CefBrowserImpl::GetBrowserForMainFrame(frame->top()); + DCHECK(browserPtr.get()); + if (browserPtr.get()) { + CefRefPtr framePtr = browserPtr->GetWebFrameImpl(frame); + + v8::HandleScope handle_scope; + v8::Context::Scope scope(context); + WebCore::V8RecursionScope recursion_scope( + WebCore::getScriptExecutionContext()); + + CefRefPtr contextPtr(new CefV8ContextImpl(context)); + + handler->OnContextReleased(browserPtr.get(), framePtr.get(), + contextPtr); + } + } + } + + CefV8ReleaseContext(context); +} + +void CefContentRendererClient::WillDestroyCurrentMessageLoop() { + base::AutoLock lock_scope(single_process_cleanup_lock_); + single_process_cleanup_complete_ = true; +} + +void CefContentRendererClient::RunSingleProcessCleanupOnUIThread() { + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + + // Clean up the single existing RenderProcessHost. + content::RenderProcessHost* host = NULL; + content::RenderProcessHost::iterator iterator( + content::RenderProcessHost::AllHostsIterator()); + if (!iterator.IsAtEnd()) { + host = iterator.GetCurrentValue(); + host->Cleanup(); + iterator.Advance(); + DCHECK(iterator.IsAtEnd()); + } + DCHECK(host); + + // Clear the run_renderer_in_process() flag to avoid a DCHECK in the + // RenderProcessHost destructor. + content::RenderProcessHost::SetRunRendererInProcess(false); + + // Deletion of the RenderProcessHost object will stop the render thread and + // result in a call to WillDestroyCurrentMessageLoop. + // Cleanup() will cause deletion to be posted as a task on the UI thread but + // this task will only execute when running in multi-threaded message loop + // mode (because otherwise the UI message loop has already stopped). Therefore + // we need to explicitly delete the object when not running in this mode. + if (!_Context->settings().multi_threaded_message_loop) + delete host; +} diff --git a/cef3/libcef/renderer/content_renderer_client.h b/cef3/libcef/renderer/content_renderer_client.h new file mode 100644 index 000000000..56e8ffb6c --- /dev/null +++ b/cef3/libcef/renderer/content_renderer_client.h @@ -0,0 +1,137 @@ +// Copyright (c) 2013 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 The Chromium 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_LIBCEF_RENDERER_CONTENT_RENDERER_CLIENT_H_ +#define CEF_LIBCEF_RENDERER_CONTENT_RENDERER_CLIENT_H_ +#pragma once + +#include +#include +#include +#include + +#include "libcef/renderer/browser_impl.h" + +#include "base/compiler_specific.h" +#include "base/memory/scoped_ptr.h" +#include "base/message_loop.h" +#include "base/sequenced_task_runner.h" +#include "content/public/renderer/content_renderer_client.h" + +class CefRenderProcessObserver; +class CefWebWorkerScriptObserver; +struct Cef_CrossOriginWhiteListEntry_Params; + +class CefContentRendererClient : public content::ContentRendererClient, + public MessageLoop::DestructionObserver { + public: + CefContentRendererClient(); + virtual ~CefContentRendererClient(); + + // Returns the singleton CefContentRendererClient instance. + static CefContentRendererClient* Get(); + + // Returns the browser associated with the specified RenderView. + CefRefPtr GetBrowserForView(content::RenderView* view); + + // Returns the browser associated with the specified main WebFrame. + CefRefPtr GetBrowserForMainFrame(WebKit::WebFrame* frame); + + // Called from CefBrowserImpl::OnDestruct(). + void OnBrowserDestroyed(CefBrowserImpl* browser); + + // Add a custom scheme registration. + void AddCustomScheme(const std::string& scheme_name, + bool is_local, + bool is_display_isolated); + + // Render thread task runner. + base::SequencedTaskRunner* render_task_runner() const { + return render_task_runner_.get(); + } + + int uncaught_exception_stack_size() const { + return uncaught_exception_stack_size_; + } + + void WebKitInitialized(); + void OnRenderProcessShutdown(); + + void DevToolsAgentAttached(); + void DevToolsAgentDetached(); + + // Returns the task runner for the current thread. If this is a WebWorker + // thread and the task runner does not already exist it will be created. + // Returns NULL if the current thread is not a valid render process thread. + scoped_refptr GetCurrentTaskRunner(); + + // Returns the task runner for the specified worker ID or NULL if the + // specified worker ID is not valid. + scoped_refptr GetWorkerTaskRunner(int worker_id); + + // Remove the task runner associated with the specified worker ID. + void RemoveWorkerTaskRunner(int worker_id); + + // Perform cleanup work that needs to occur before shutdown when running in + // single-process mode. Blocks until cleanup is complete. + void RunSingleProcessCleanup(); + + private: + // ContentRendererClient implementation. + virtual void RenderThreadStarted() OVERRIDE; + virtual void RenderViewCreated(content::RenderView* render_view) OVERRIDE; + virtual bool HandleNavigation(WebKit::WebFrame* frame, + const WebKit::WebURLRequest& request, + WebKit::WebNavigationType type, + WebKit::WebNavigationPolicy default_policy, + bool is_redirect) OVERRIDE; + virtual void DidCreateScriptContext(WebKit::WebFrame* frame, + v8::Handle context, + int extension_group, + int world_id) OVERRIDE; + virtual void WillReleaseScriptContext(WebKit::WebFrame* frame, + v8::Handle context, + int world_id) OVERRIDE; + + // MessageLoop::DestructionObserver implementation. + virtual void WillDestroyCurrentMessageLoop() OVERRIDE; + + // Perform cleanup work for single-process mode. + void RunSingleProcessCleanupOnUIThread(); + + scoped_refptr render_task_runner_; + scoped_ptr observer_; + scoped_ptr worker_script_observer_; + + // Map of RenderView pointers to CefBrowserImpl references. + typedef std::map > BrowserMap; + BrowserMap browsers_; + + // Custom schemes that need to be registered with WebKit. + struct SchemeInfo; + typedef std::list SchemeInfoList; + SchemeInfoList scheme_info_list_; + + // Cross-origin white list entries that need to be registered with WebKit. + typedef std::vector CrossOriginList; + CrossOriginList cross_origin_whitelist_entries_; + + int devtools_agent_count_; + int uncaught_exception_stack_size_; + + // Map of worker thread IDs to task runners. Access must be protected by + // |worker_task_runner_lock_|. + typedef std::map > + WorkerTaskRunnerMap; + WorkerTaskRunnerMap worker_task_runner_map_; + base::Lock worker_task_runner_lock_; + + // Used in single-process mode to test when cleanup is complete. + // Access must be protected by |single_process_cleanup_lock_|. + bool single_process_cleanup_complete_; + base::Lock single_process_cleanup_lock_; +}; + +#endif // CEF_LIBCEF_RENDERER_CONTENT_RENDERER_CLIENT_H_ diff --git a/cef3/libcef/renderer/dom_document_impl.cc b/cef3/libcef/renderer/dom_document_impl.cc new file mode 100644 index 000000000..01c38bc06 --- /dev/null +++ b/cef3/libcef/renderer/dom_document_impl.cc @@ -0,0 +1,262 @@ +// 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 "libcef/renderer/dom_document_impl.h" +#include "libcef/renderer/dom_node_impl.h" +#include "libcef/renderer/thread_util.h" + +#include "base/logging.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" + +using WebKit::WebDocument; +using WebKit::WebElement; +using WebKit::WebFrame; +using WebKit::WebNode; +using WebKit::WebRange; +using WebKit::WebString; +using WebKit::WebURL; + + +CefDOMDocumentImpl::CefDOMDocumentImpl(CefBrowserImpl* browser, + WebFrame* frame) + : browser_(browser), + frame_(frame) { + const WebDocument& document = frame_->document(); + DCHECK(!document.isNull()); +} + +CefDOMDocumentImpl::~CefDOMDocumentImpl() { + CEF_REQUIRE_RT(); + + // Verify that the Detach() method has been called. + DCHECK(frame_ == NULL); +} + +CefDOMDocumentImpl::Type CefDOMDocumentImpl::GetType() { + if (!VerifyContext()) + return DOM_DOCUMENT_TYPE_UNKNOWN; + + const WebDocument& document = frame_->document(); + if (document.isHTMLDocument()) + return DOM_DOCUMENT_TYPE_HTML; + if (document.isXHTMLDocument()) + return DOM_DOCUMENT_TYPE_XHTML; + if (document.isPluginDocument()) + return DOM_DOCUMENT_TYPE_PLUGIN; + return DOM_DOCUMENT_TYPE_UNKNOWN; +} + +CefRefPtr CefDOMDocumentImpl::GetDocument() { + const WebDocument& document = frame_->document(); + return GetOrCreateNode(document.document()); +} + +CefRefPtr CefDOMDocumentImpl::GetBody() { + const WebDocument& document = frame_->document(); + return GetOrCreateNode(document.body()); +} + +CefRefPtr CefDOMDocumentImpl::GetHead() { + WebDocument document = frame_->document(); + return GetOrCreateNode(document.head()); +} + +CefString CefDOMDocumentImpl::GetTitle() { + CefString str; + if (!VerifyContext()) + return str; + + const WebDocument& document = frame_->document(); + const WebString& title = document.title(); + if (!title.isNull()) + str = title; + + return str; +} + +CefRefPtr CefDOMDocumentImpl::GetElementById(const CefString& id) { + const WebDocument& document = frame_->document(); + return GetOrCreateNode(document.getElementById(string16(id))); +} + +CefRefPtr CefDOMDocumentImpl::GetFocusedNode() { + const WebDocument& document = frame_->document(); + return GetOrCreateNode(document.focusedNode()); +} + +bool CefDOMDocumentImpl::HasSelection() { + if (!VerifyContext()) + return false; + + return frame_->hasSelection(); +} + +CefRefPtr CefDOMDocumentImpl::GetSelectionStartNode() { + if (!VerifyContext() || !frame_->hasSelection()) + return NULL; + + const WebRange& range = frame_->selectionRange(); + if (range.isNull()) + return NULL; + + int exceptionCode; + return GetOrCreateNode(range.startContainer(exceptionCode)); +} + +int CefDOMDocumentImpl::GetSelectionStartOffset() { + if (!VerifyContext() || !frame_->hasSelection()) + return 0; + + const WebRange& range = frame_->selectionRange(); + if (range.isNull()) + return 0; + + return range.startOffset(); +} + +CefRefPtr CefDOMDocumentImpl::GetSelectionEndNode() { + if (!VerifyContext() || !frame_->hasSelection()) + return NULL; + + const WebRange& range = frame_->selectionRange(); + if (range.isNull()) + return NULL; + + int exceptionCode; + return GetOrCreateNode(range.endContainer(exceptionCode)); +} + +int CefDOMDocumentImpl::GetSelectionEndOffset() { + if (!VerifyContext() || !frame_->hasSelection()) + return 0; + + const WebRange& range = frame_->selectionRange(); + if (range.isNull()) + return 0; + + return range.endOffset(); +} + +CefString CefDOMDocumentImpl::GetSelectionAsMarkup() { + CefString str; + if (!VerifyContext() || !frame_->hasSelection()) + return str; + + const WebString& markup = frame_->selectionAsMarkup(); + if (!markup.isNull()) + str = markup; + + return str; +} + +CefString CefDOMDocumentImpl::GetSelectionAsText() { + CefString str; + if (!VerifyContext() || !frame_->hasSelection()) + return str; + + const WebString& text = frame_->selectionAsText(); + if (!text.isNull()) + str = text; + + return str; +} + +CefString CefDOMDocumentImpl::GetBaseURL() { + CefString str; + if (!VerifyContext()) + return str; + + const WebDocument& document = frame_->document(); + const WebURL& url = document.baseURL(); + if (!url.isNull()) { + GURL gurl = url; + str = gurl.spec(); + } + + return str; +} + +CefString CefDOMDocumentImpl::GetCompleteURL(const CefString& partialURL) { + CefString str; + if (!VerifyContext()) + return str; + + const WebDocument& document = frame_->document(); + const WebURL& url = document.completeURL(string16(partialURL)); + if (!url.isNull()) { + GURL gurl = url; + str = gurl.spec(); + } + + return str; +} + +CefRefPtr CefDOMDocumentImpl::GetOrCreateNode( + const WebKit::WebNode& node) { + if (!VerifyContext()) + return NULL; + + // Nodes may potentially be null. + if (node.isNull()) + return NULL; + + if (!node_map_.empty()) { + // Locate the existing node, if any. + NodeMap::const_iterator it = node_map_.find(node); + if (it != node_map_.end()) + return it->second; + } + + // Create the new node object. + CefRefPtr nodeImpl(new CefDOMNodeImpl(this, node)); + node_map_.insert(std::make_pair(node, nodeImpl)); + return nodeImpl; +} + +void CefDOMDocumentImpl::RemoveNode(const WebKit::WebNode& node) { + if (!VerifyContext()) + return; + + if (!node_map_.empty()) { + NodeMap::iterator it = node_map_.find(node); + if (it != node_map_.end()) + node_map_.erase(it); + } +} + +void CefDOMDocumentImpl::Detach() { + if (!VerifyContext()) + return; + + // If you hit this assert it means that you are keeping references to node + // objects beyond the valid scope. + DCHECK(node_map_.empty()); + + // If you hit this assert it means that you are keeping references to this + // document object beyond the valid scope. + DCHECK_EQ(GetRefCt(), 1); + + if (!node_map_.empty()) { + NodeMap::const_iterator it = node_map_.begin(); + for (; it != node_map_.end(); ++it) + static_cast(it->second)->Detach(); + node_map_.clear(); + } + + frame_ = NULL; +} + +bool CefDOMDocumentImpl::VerifyContext() { + if (!CEF_CURRENTLY_ON_RT() || frame_ == NULL) { + NOTREACHED(); + return false; + } + return true; +} diff --git a/cef3/libcef/renderer/dom_document_impl.h b/cef3/libcef/renderer/dom_document_impl.h new file mode 100644 index 000000000..966da1943 --- /dev/null +++ b/cef3/libcef/renderer/dom_document_impl.h @@ -0,0 +1,66 @@ +// 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. + +#ifndef CEF_LIBCEF_DOM_DOCUMENT_IMPL_H_ +#define CEF_LIBCEF_DOM_DOCUMENT_IMPL_H_ +#pragma once + +#include +#include "include/cef_dom.h" + +namespace WebKit { +class WebFrame; +class WebNode; +}; + +class CefBrowserImpl; + +class CefDOMDocumentImpl : public CefDOMDocument { + public: + CefDOMDocumentImpl(CefBrowserImpl* browser, + WebKit::WebFrame* frame); + virtual ~CefDOMDocumentImpl(); + + // CefDOMDocument methods. + virtual Type GetType() OVERRIDE; + virtual CefRefPtr GetDocument() OVERRIDE; + virtual CefRefPtr GetBody() OVERRIDE; + virtual CefRefPtr GetHead() OVERRIDE; + virtual CefString GetTitle() OVERRIDE; + virtual CefRefPtr GetElementById(const CefString& id) OVERRIDE; + virtual CefRefPtr GetFocusedNode() OVERRIDE; + virtual bool HasSelection() OVERRIDE; + virtual CefRefPtr GetSelectionStartNode() OVERRIDE; + virtual int GetSelectionStartOffset() OVERRIDE; + virtual CefRefPtr GetSelectionEndNode() OVERRIDE; + virtual int GetSelectionEndOffset() OVERRIDE; + virtual CefString GetSelectionAsMarkup() OVERRIDE; + virtual CefString GetSelectionAsText() OVERRIDE; + virtual CefString GetBaseURL() OVERRIDE; + virtual CefString GetCompleteURL(const CefString& partialURL) OVERRIDE; + + CefBrowserImpl* GetBrowser() { return browser_; } + WebKit::WebFrame* GetFrame() { return frame_; } + + // The document maintains a map of all existing node objects. + CefRefPtr GetOrCreateNode(const WebKit::WebNode& node); + void RemoveNode(const WebKit::WebNode& node); + + // Must be called before the object is destroyed. + void Detach(); + + // Verify that the object exists and is being accessed on the UI thread. + bool VerifyContext(); + + protected: + CefBrowserImpl* browser_; + WebKit::WebFrame* frame_; + + typedef std::map NodeMap; + NodeMap node_map_; + + IMPLEMENT_REFCOUNTING(CefDOMDocumentImpl); +}; + +#endif // CEF_LIBCEF_DOM_DOCUMENT_IMPL_H_ diff --git a/cef3/libcef/renderer/dom_event_impl.cc b/cef3/libcef/renderer/dom_event_impl.cc new file mode 100644 index 000000000..e6aef90a0 --- /dev/null +++ b/cef3/libcef/renderer/dom_event_impl.cc @@ -0,0 +1,160 @@ +// 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 "libcef/renderer/dom_event_impl.h" +#include "libcef/renderer/dom_document_impl.h" +#include "libcef/renderer/thread_util.h" + +#include "base/logging.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEvent.h" + +using WebKit::WebDOMEvent; +using WebKit::WebString; + + +CefDOMEventImpl::CefDOMEventImpl(CefRefPtr document, + const WebKit::WebDOMEvent& event) + : document_(document), + event_(event) { + DCHECK(!event_.isNull()); +} + +CefDOMEventImpl::~CefDOMEventImpl() { + CEF_REQUIRE_RT(); + DCHECK(event_.isNull()); +} + +CefString CefDOMEventImpl::GetType() { + CefString str; + if (!VerifyContext()) + return str; + + const WebString& type = event_.type(); + if (!type.isNull()) + str = type; + + return str; +} + +CefDOMEventImpl::Category CefDOMEventImpl::GetCategory() { + if (!VerifyContext()) + return DOM_EVENT_CATEGORY_UNKNOWN; + + int flags = 0; + if (event_.isUIEvent()) + flags |= DOM_EVENT_CATEGORY_UI; + if (event_.isMouseEvent()) + flags |= DOM_EVENT_CATEGORY_MOUSE; + if (event_.isMutationEvent()) + flags |= DOM_EVENT_CATEGORY_MUTATION; + if (event_.isKeyboardEvent()) + flags |= DOM_EVENT_CATEGORY_KEYBOARD; + if (event_.isTextEvent()) + flags |= DOM_EVENT_CATEGORY_TEXT; + if (event_.isCompositionEvent()) + flags |= DOM_EVENT_CATEGORY_COMPOSITION; + if (event_.isDragEvent()) + flags |= DOM_EVENT_CATEGORY_DRAG; + if (event_.isClipboardEvent()) + flags |= DOM_EVENT_CATEGORY_CLIPBOARD; + if (event_.isMessageEvent()) + flags |= DOM_EVENT_CATEGORY_MESSAGE; + if (event_.isWheelEvent()) + flags |= DOM_EVENT_CATEGORY_WHEEL; + if (event_.isBeforeTextInsertedEvent()) + flags |= DOM_EVENT_CATEGORY_BEFORE_TEXT_INSERTED; + if (event_.isOverflowEvent()) + flags |= DOM_EVENT_CATEGORY_OVERFLOW; + if (event_.isPageTransitionEvent()) + flags |= DOM_EVENT_CATEGORY_PAGE_TRANSITION; + if (event_.isPopStateEvent()) + flags |= DOM_EVENT_CATEGORY_POPSTATE; + if (event_.isProgressEvent()) + flags |= DOM_EVENT_CATEGORY_PROGRESS; + if (event_.isXMLHttpRequestProgressEvent()) + flags |= DOM_EVENT_CATEGORY_XMLHTTPREQUEST_PROGRESS; + if (event_.isWebKitAnimationEvent()) + flags |= DOM_EVENT_CATEGORY_WEBKIT_ANIMATION; + if (event_.isWebKitTransitionEvent()) + flags |= DOM_EVENT_CATEGORY_WEBKIT_TRANSITION; + if (event_.isBeforeLoadEvent()) + flags |= DOM_EVENT_CATEGORY_BEFORE_LOAD; + + return static_cast(flags); +} + +CefDOMEventImpl::Phase CefDOMEventImpl::GetPhase() { + if (!VerifyContext()) + return DOM_EVENT_PHASE_UNKNOWN; + + switch (event_.eventPhase()) { + case WebDOMEvent::CapturingPhase: + return DOM_EVENT_PHASE_CAPTURING; + case WebDOMEvent::AtTarget: + return DOM_EVENT_PHASE_AT_TARGET; + case WebDOMEvent::BubblingPhase: + return DOM_EVENT_PHASE_BUBBLING; + } + + return DOM_EVENT_PHASE_UNKNOWN; +} + +bool CefDOMEventImpl::CanBubble() { + if (!VerifyContext()) + return false; + + return event_.bubbles(); +} + +bool CefDOMEventImpl::CanCancel() { + if (!VerifyContext()) + return false; + + return event_.cancelable(); +} + +CefRefPtr CefDOMEventImpl::GetDocument() { + if (!VerifyContext()) + return NULL; + + return document_.get(); +} + +CefRefPtr CefDOMEventImpl::GetTarget() { + if (!VerifyContext()) + return NULL; + + return document_->GetOrCreateNode(event_.target()); +} + +CefRefPtr CefDOMEventImpl::GetCurrentTarget() { + if (!VerifyContext()) + return NULL; + + return document_->GetOrCreateNode(event_.currentTarget()); +} + +void CefDOMEventImpl::Detach() { + // If you hit this assert it means that you are keeping references to this + // event object beyond the valid scope. + DCHECK_EQ(GetRefCt(), 1); + + document_ = NULL; + event_.assign(WebDOMEvent()); +} + +bool CefDOMEventImpl::VerifyContext() { + if (!document_.get()) { + NOTREACHED(); + return false; + } + if (!document_->VerifyContext()) + return false; + if (event_.isNull()) { + NOTREACHED(); + return false; + } + return true; +} diff --git a/cef3/libcef/renderer/dom_event_impl.h b/cef3/libcef/renderer/dom_event_impl.h new file mode 100644 index 000000000..b427c4b59 --- /dev/null +++ b/cef3/libcef/renderer/dom_event_impl.h @@ -0,0 +1,43 @@ +// 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. + +#ifndef CEF_LIBCEF_DOM_EVENT_IMPL_H_ +#define CEF_LIBCEF_DOM_EVENT_IMPL_H_ +#pragma once + +#include "include/cef_dom.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEvent.h" + +class CefDOMDocumentImpl; + +class CefDOMEventImpl : public CefDOMEvent { + public: + CefDOMEventImpl(CefRefPtr document, + const WebKit::WebDOMEvent& event); + virtual ~CefDOMEventImpl(); + + // CefDOMEvent methods. + virtual CefString GetType() OVERRIDE; + virtual Category GetCategory() OVERRIDE; + virtual Phase GetPhase() OVERRIDE; + virtual bool CanBubble() OVERRIDE; + virtual bool CanCancel() OVERRIDE; + virtual CefRefPtr GetDocument() OVERRIDE; + virtual CefRefPtr GetTarget() OVERRIDE; + virtual CefRefPtr GetCurrentTarget() OVERRIDE; + + // Will be called from CefDOMEventListenerWrapper::handleEvent(). + void Detach(); + + // Verify that the object exists and is being accessed on the UI thread. + bool VerifyContext(); + + protected: + CefRefPtr document_; + WebKit::WebDOMEvent event_; + + IMPLEMENT_REFCOUNTING(CefDOMEventImpl); +}; + +#endif // CEF_LIBCEF_DOM_EVENT_IMPL_H_ diff --git a/cef3/libcef/renderer/dom_node_impl.cc b/cef3/libcef/renderer/dom_node_impl.cc new file mode 100644 index 000000000..3fccd09b6 --- /dev/null +++ b/cef3/libcef/renderer/dom_node_impl.cc @@ -0,0 +1,485 @@ +// 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 "libcef/renderer/dom_node_impl.h" +#include "libcef/common/tracker.h" +#include "libcef/renderer/browser_impl.h" +#include "libcef/renderer/dom_document_impl.h" +#include "libcef/renderer/dom_event_impl.h" +#include "libcef/renderer/thread_util.h" + +#include "base/logging.h" +#include "base/string_util.h" +#include "base/utf_string_conversions.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEvent.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEventListener.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebSelectElement.h" + +using WebKit::WebDocument; +using WebKit::WebDOMEvent; +using WebKit::WebDOMEventListener; +using WebKit::WebElement; +using WebKit::WebFrame; +using WebKit::WebFormControlElement; +using WebKit::WebInputElement; +using WebKit::WebNode; +using WebKit::WebSelectElement; +using WebKit::WebString; + +namespace { + +// Wrapper implementation for WebDOMEventListener. +class CefDOMEventListenerWrapper : public WebDOMEventListener, + public CefTrackNode { + public: + CefDOMEventListenerWrapper(CefBrowserImpl* browser, WebFrame* frame, + CefRefPtr listener) + : browser_(browser), + frame_(frame), + listener_(listener) { + // Cause this object to be deleted immediately before the frame is closed. + browser->AddFrameObject(frame->identifier(), this); + } + virtual ~CefDOMEventListenerWrapper() { + CEF_REQUIRE_RT(); + } + + virtual void handleEvent(const WebDOMEvent& event) { + CefRefPtr documentImpl; + CefRefPtr eventImpl; + + if (!event.isNull()) { + // Create CefDOMDocumentImpl and CefDOMEventImpl objects that are valid + // only for the scope of this method. + const WebDocument& document = frame_->document(); + if (!document.isNull()) { + documentImpl = new CefDOMDocumentImpl(browser_, frame_); + eventImpl = new CefDOMEventImpl(documentImpl, event); + } + } + + listener_->HandleEvent(eventImpl.get()); + + if (eventImpl.get()) + eventImpl->Detach(); + if (documentImpl.get()) + documentImpl->Detach(); + } + + protected: + CefBrowserImpl* browser_; + WebFrame* frame_; + CefRefPtr listener_; +}; + +} // namespace + + +CefDOMNodeImpl::CefDOMNodeImpl(CefRefPtr document, + const WebKit::WebNode& node) + : document_(document), + node_(node) { +} + +CefDOMNodeImpl::~CefDOMNodeImpl() { + CEF_REQUIRE_RT(); + + if (document_.get() && !node_.isNull()) { + // Remove the node from the document. + document_->RemoveNode(node_); + } +} + +CefDOMNodeImpl::Type CefDOMNodeImpl::GetType() { + if (!VerifyContext()) + return DOM_NODE_TYPE_UNSUPPORTED; + + switch (node_.nodeType()) { + case WebNode::ElementNode: + return DOM_NODE_TYPE_ELEMENT; + case WebNode::AttributeNode: + return DOM_NODE_TYPE_ATTRIBUTE; + case WebNode::TextNode: + return DOM_NODE_TYPE_TEXT; + case WebNode::CDataSectionNode: + return DOM_NODE_TYPE_CDATA_SECTION; + case WebNode::EntityReferenceNode: + return DOM_NODE_TYPE_ENTITY_REFERENCE; + case WebNode::EntityNode: + return DOM_NODE_TYPE_ENTITY; + case WebNode::ProcessingInstructionsNode: + return DOM_NODE_TYPE_PROCESSING_INSTRUCTIONS; + case WebNode::CommentNode: + return DOM_NODE_TYPE_COMMENT; + case WebNode::DocumentNode: + return DOM_NODE_TYPE_DOCUMENT; + case WebNode::DocumentTypeNode: + return DOM_NODE_TYPE_DOCUMENT_TYPE; + case WebNode::DocumentFragmentNode: + return DOM_NODE_TYPE_DOCUMENT_FRAGMENT; + case WebNode::NotationNode: + return DOM_NODE_TYPE_NOTATION; + case WebNode::XPathNamespaceNode: + return DOM_NODE_TYPE_XPATH_NAMESPACE; + default: + return DOM_NODE_TYPE_UNSUPPORTED; + } +} + +bool CefDOMNodeImpl::IsText() { + if (!VerifyContext()) + return false; + + return node_.isTextNode(); +} + +bool CefDOMNodeImpl::IsElement() { + if (!VerifyContext()) + return false; + + return node_.isElementNode(); +} + +// Logic copied from RenderViewImpl::IsEditableNode. +bool CefDOMNodeImpl::IsEditable() { + if (!VerifyContext()) + return false; + + if (node_.isContentEditable()) + return true; + + if (node_.isElementNode()) { + const WebElement& element = node_.toConst(); + if (element.isTextFormControlElement()) + return true; + + // Also return true if it has an ARIA role of 'textbox'. + for (unsigned i = 0; i < element.attributeCount(); ++i) { + if (LowerCaseEqualsASCII(element.attributeLocalName(i), "role")) { + if (LowerCaseEqualsASCII(element.attributeValue(i), "textbox")) + return true; + break; + } + } + } + + return false; +} + +bool CefDOMNodeImpl::IsFormControlElement() { + if (!VerifyContext()) + return false; + + if (node_.isElementNode()) { + const WebElement& element = node_.toConst(); + return element.isFormControlElement(); + } + + return false; +} + +CefString CefDOMNodeImpl::GetFormControlElementType() { + CefString str; + if (!VerifyContext()) + return str; + + if (node_.isElementNode()) { + const WebElement& element = node_.toConst(); + if (element.isFormControlElement()) { + // Retrieve the type from the form control element. + const WebFormControlElement& formElement = + node_.toConst(); + + const string16& form_control_type = formElement.formControlType(); + str = form_control_type; + } + } + + return str; +} + +bool CefDOMNodeImpl::IsSame(CefRefPtr that) { + if (!VerifyContext()) + return false; + + CefDOMNodeImpl* impl = static_cast(that.get()); + if (!impl || !impl->VerifyContext()) + return false; + + return node_.equals(impl->node_); +} + +CefString CefDOMNodeImpl::GetName() { + CefString str; + if (!VerifyContext()) + return str; + + const WebString& name = node_.nodeName(); + if (!name.isNull()) + str = name; + + return str; +} + +CefString CefDOMNodeImpl::GetValue() { + CefString str; + if (!VerifyContext()) + return str; + + if (node_.isElementNode()) { + const WebElement& element = node_.toConst(); + if (element.isFormControlElement()) { + // Retrieve the value from the form control element. + const WebFormControlElement& formElement = + node_.toConst(); + + string16 value; + const string16& form_control_type = formElement.formControlType(); + if (form_control_type == ASCIIToUTF16("text")) { + const WebInputElement& input_element = + formElement.toConst(); + value = input_element.value(); + } else if (form_control_type == ASCIIToUTF16("select-one")) { + const WebSelectElement& select_element = + formElement.toConst(); + value = select_element.value(); + } + + TrimWhitespace(value, TRIM_LEADING, &value); + str = value; + } + } + + if (str.empty()) { + const WebString& value = node_.nodeValue(); + if (!value.isNull()) + str = value; + } + + return str; +} + +bool CefDOMNodeImpl::SetValue(const CefString& value) { + if (!VerifyContext()) + return false; + + if (node_.isElementNode()) + return false; + + return node_.setNodeValue(string16(value)); +} + +CefString CefDOMNodeImpl::GetAsMarkup() { + CefString str; + if (!VerifyContext()) + return str; + + const WebString& markup = node_.createMarkup(); + if (!markup.isNull()) + str = markup; + + return str; +} + +CefRefPtr CefDOMNodeImpl::GetDocument() { + if (!VerifyContext()) + return NULL; + + return document_.get(); +} + +CefRefPtr CefDOMNodeImpl::GetParent() { + if (!VerifyContext()) + return NULL; + + return document_->GetOrCreateNode(node_.parentNode()); +} + +CefRefPtr CefDOMNodeImpl::GetPreviousSibling() { + if (!VerifyContext()) + return NULL; + + return document_->GetOrCreateNode(node_.previousSibling()); +} + +CefRefPtr CefDOMNodeImpl::GetNextSibling() { + if (!VerifyContext()) + return NULL; + + return document_->GetOrCreateNode(node_.nextSibling()); +} + +bool CefDOMNodeImpl::HasChildren() { + if (!VerifyContext()) + return false; + + return node_.hasChildNodes(); +} + +CefRefPtr CefDOMNodeImpl::GetFirstChild() { + if (!VerifyContext()) + return NULL; + + return document_->GetOrCreateNode(node_.firstChild()); +} + +CefRefPtr CefDOMNodeImpl::GetLastChild() { + if (!VerifyContext()) + return NULL; + + return document_->GetOrCreateNode(node_.lastChild()); +} + +void CefDOMNodeImpl::AddEventListener(const CefString& eventType, + CefRefPtr listener, + bool useCapture) { + if (!VerifyContext()) + return; + + node_.addEventListener(string16(eventType), + new CefDOMEventListenerWrapper(document_->GetBrowser(), + document_->GetFrame(), listener), + useCapture); +} + +CefString CefDOMNodeImpl::GetElementTagName() { + CefString str; + if (!VerifyContext()) + return str; + + if (!node_.isElementNode()) { + NOTREACHED(); + return str; + } + + const WebElement& element = node_.toConst(); + const WebString& tagname = element.tagName(); + if (!tagname.isNull()) + str = tagname; + + return str; +} + +bool CefDOMNodeImpl::HasElementAttributes() { + if (!VerifyContext()) + return false; + + if (!node_.isElementNode()) { + NOTREACHED(); + return false; + } + + const WebElement& element = node_.toConst(); + return (element.attributeCount() > 0); +} + +bool CefDOMNodeImpl::HasElementAttribute(const CefString& attrName) { + if (!VerifyContext()) + return false; + + if (!node_.isElementNode()) { + NOTREACHED(); + return false; + } + + const WebElement& element = node_.toConst(); + return element.hasAttribute(string16(attrName)); +} + +CefString CefDOMNodeImpl::GetElementAttribute(const CefString& attrName) { + CefString str; + if (!VerifyContext()) + return str; + + if (!node_.isElementNode()) { + NOTREACHED(); + return str; + } + + const WebElement& element = node_.toConst(); + const WebString& attr = element.getAttribute(string16(attrName)); + if (!attr.isNull()) + str = attr; + + return str; +} + +void CefDOMNodeImpl::GetElementAttributes(AttributeMap& attrMap) { + if (!VerifyContext()) + return; + + if (!node_.isElementNode()) { + NOTREACHED(); + return; + } + + const WebElement& element = node_.toConst(); + unsigned int len = element.attributeCount(); + if (len == 0) + return; + + for (unsigned int i = 0; i < len; ++i) { + string16 name = element.attributeLocalName(i); + string16 value = element.attributeValue(i); + attrMap.insert(std::make_pair(name, value)); + } +} + +bool CefDOMNodeImpl::SetElementAttribute(const CefString& attrName, + const CefString& value) { + if (!VerifyContext()) + return false; + + if (!node_.isElementNode()) { + NOTREACHED(); + return false; + } + + WebElement element = node_.to(); + return element.setAttribute(string16(attrName), string16(value)); +} + +CefString CefDOMNodeImpl::GetElementInnerText() { + CefString str; + if (!VerifyContext()) + return str; + + if (!node_.isElementNode()) { + NOTREACHED(); + return str; + } + + WebElement element = node_.to(); + const WebString& text = element.innerText(); + if (!text.isNull()) + str = text; + + return str; +} + +void CefDOMNodeImpl::Detach() { + document_ = NULL; + node_.assign(WebNode()); +} + +bool CefDOMNodeImpl::VerifyContext() { + if (!document_.get()) { + NOTREACHED(); + return false; + } + if (!document_->VerifyContext()) + return false; + if (node_.isNull()) { + NOTREACHED(); + return false; + } + return true; +} diff --git a/cef3/libcef/renderer/dom_node_impl.h b/cef3/libcef/renderer/dom_node_impl.h new file mode 100644 index 000000000..4a641a9d8 --- /dev/null +++ b/cef3/libcef/renderer/dom_node_impl.h @@ -0,0 +1,64 @@ +// 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. + +#ifndef CEF_LIBCEF_DOM_NODE_IMPL_H_ +#define CEF_LIBCEF_DOM_NODE_IMPL_H_ +#pragma once + +#include "include/cef_dom.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" + +class CefDOMDocumentImpl; + +class CefDOMNodeImpl : public CefDOMNode { + public: + CefDOMNodeImpl(CefRefPtr document, + const WebKit::WebNode& node); + virtual ~CefDOMNodeImpl(); + + // CefDOMNode methods. + virtual Type GetType() OVERRIDE; + virtual bool IsText() OVERRIDE; + virtual bool IsElement() OVERRIDE; + virtual bool IsEditable() OVERRIDE; + virtual bool IsFormControlElement() OVERRIDE; + virtual CefString GetFormControlElementType() OVERRIDE; + virtual bool IsSame(CefRefPtr that) OVERRIDE; + virtual CefString GetName() OVERRIDE; + virtual CefString GetValue() OVERRIDE; + virtual bool SetValue(const CefString& value) OVERRIDE; + virtual CefString GetAsMarkup() OVERRIDE; + virtual CefRefPtr GetDocument() OVERRIDE; + virtual CefRefPtr GetParent() OVERRIDE; + virtual CefRefPtr GetPreviousSibling() OVERRIDE; + virtual CefRefPtr GetNextSibling() OVERRIDE; + virtual bool HasChildren() OVERRIDE; + virtual CefRefPtr GetFirstChild() OVERRIDE; + virtual CefRefPtr GetLastChild() OVERRIDE; + virtual void AddEventListener(const CefString& eventType, + CefRefPtr listener, + bool useCapture) OVERRIDE; + virtual CefString GetElementTagName() OVERRIDE; + virtual bool HasElementAttributes() OVERRIDE; + virtual bool HasElementAttribute(const CefString& attrName) OVERRIDE; + virtual CefString GetElementAttribute(const CefString& attrName) OVERRIDE; + virtual void GetElementAttributes(AttributeMap& attrMap) OVERRIDE; + virtual bool SetElementAttribute(const CefString& attrName, + const CefString& value) OVERRIDE; + virtual CefString GetElementInnerText() OVERRIDE; + + // Will be called from CefDOMDocumentImpl::Detach(). + void Detach(); + + // Verify that the object exists and is being accessed on the UI thread. + bool VerifyContext(); + + protected: + CefRefPtr document_; + WebKit::WebNode node_; + + IMPLEMENT_REFCOUNTING(CefDOMNodeImpl); +}; + +#endif // CEF_LIBCEF_DOM_NODE_IMPL_H_ diff --git a/cef3/libcef/renderer/frame_impl.cc b/cef3/libcef/renderer/frame_impl.cc new file mode 100644 index 000000000..153e79837 --- /dev/null +++ b/cef3/libcef/renderer/frame_impl.cc @@ -0,0 +1,271 @@ +// 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 "libcef/renderer/frame_impl.h" + +#include "libcef/common/cef_messages.h" +#include "libcef/common/http_header_utils.h" +#include "libcef/common/request_impl.h" +#include "libcef/renderer/browser_impl.h" +#include "libcef/renderer/dom_document_impl.h" +#include "libcef/renderer/thread_util.h" +#include "libcef/renderer/v8_impl.h" +#include "libcef/renderer/webkit_glue.h" + +#include "third_party/WebKit/Source/Platform/chromium/public/WebData.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" +#include "webkit/glue/webkit_glue.h" + +using WebKit::WebString; + +CefFrameImpl::CefFrameImpl(CefBrowserImpl* browser, + WebKit::WebFrame* frame) + : browser_(browser), + frame_(frame), + frame_id_(frame->identifier()) { +} + +CefFrameImpl::~CefFrameImpl() { +} + +bool CefFrameImpl::IsValid() { + CEF_REQUIRE_RT_RETURN(false); + + return (frame_ != NULL); +} + +void CefFrameImpl::Undo() { + CEF_REQUIRE_RT_RETURN_VOID(); + if (frame_) + frame_->executeCommand(WebString::fromUTF8("Undo")); +} + +void CefFrameImpl::Redo() { + CEF_REQUIRE_RT_RETURN_VOID(); + if (frame_) + frame_->executeCommand(WebString::fromUTF8("Redo")); +} + +void CefFrameImpl::Cut() { + CEF_REQUIRE_RT_RETURN_VOID(); + if (frame_) + frame_->executeCommand(WebString::fromUTF8("Cut")); +} + +void CefFrameImpl::Copy() { + CEF_REQUIRE_RT_RETURN_VOID(); + if (frame_) + frame_->executeCommand(WebString::fromUTF8("Copy")); +} + +void CefFrameImpl::Paste() { + CEF_REQUIRE_RT_RETURN_VOID(); + if (frame_) + frame_->executeCommand(WebString::fromUTF8("Paste")); +} + +void CefFrameImpl::Delete() { + CEF_REQUIRE_RT_RETURN_VOID(); + if (frame_) + frame_->executeCommand(WebString::fromUTF8("Delete")); +} + +void CefFrameImpl::SelectAll() { + CEF_REQUIRE_RT_RETURN_VOID(); + if (frame_) + frame_->executeCommand(WebString::fromUTF8("SelectAll")); +} + +void CefFrameImpl::ViewSource() { + NOTREACHED() << "ViewSource cannot be called from the renderer process"; +} + +void CefFrameImpl::GetSource(CefRefPtr visitor) { + CEF_REQUIRE_RT_RETURN_VOID(); + + if (frame_) { + CefString content = std::string(frame_->contentAsMarkup().utf8()); + visitor->Visit(content); + } +} + +void CefFrameImpl::GetText(CefRefPtr visitor) { + CEF_REQUIRE_RT_RETURN_VOID(); + + if (frame_) { + CefString content = webkit_glue::DumpDocumentText(frame_); + visitor->Visit(content); + } +} + +void CefFrameImpl::LoadRequest(CefRefPtr request) { + CEF_REQUIRE_RT_RETURN_VOID(); + + if (!browser_) + return; + + CefMsg_LoadRequest_Params params; + params.url = GURL(std::string(request->GetURL())); + params.method = request->GetMethod(); + params.frame_id = frame_id_; + params.first_party_for_cookies = + GURL(std::string(request->GetFirstPartyForCookies())); + + CefRequest::HeaderMap headerMap; + request->GetHeaderMap(headerMap); + if (!headerMap.empty()) + params.headers = HttpHeaderUtils::GenerateHeaders(headerMap); + + CefRefPtr postData = request->GetPostData(); + if (postData.get()) { + CefPostDataImpl* impl = static_cast(postData.get()); + params.upload_data = new net::UploadData(); + impl->Get(*params.upload_data.get()); + } + + params.load_flags = request->GetFlags(); + + browser_->LoadRequest(params); +} + +void CefFrameImpl::LoadURL(const CefString& url) { + CEF_REQUIRE_RT_RETURN_VOID(); + + if (!browser_) + return; + + CefMsg_LoadRequest_Params params; + params.url = GURL(url.ToString()); + params.method = "GET"; + params.frame_id = frame_id_; + + browser_->LoadRequest(params); +} + +void CefFrameImpl::LoadString(const CefString& string, + const CefString& url) { + CEF_REQUIRE_RT_RETURN_VOID(); + + if (frame_) { + GURL gurl = GURL(url.ToString()); + frame_->loadHTMLString(string.ToString(), gurl); + } +} + +void CefFrameImpl::ExecuteJavaScript(const CefString& jsCode, + const CefString& scriptUrl, + int startLine) { + CEF_REQUIRE_RT_RETURN_VOID(); + + if (jsCode.empty()) + return; + if (startLine < 0) + startLine = 0; + + if (frame_) { + GURL gurl = GURL(scriptUrl.ToString()); + frame_->executeScript( + WebKit::WebScriptSource(jsCode.ToString16(), gurl, startLine)); + } +} + +bool CefFrameImpl::IsMain() { + CEF_REQUIRE_RT_RETURN(false); + + if (frame_) + return (frame_->parent() == NULL); + return false; +} + +bool CefFrameImpl::IsFocused() { + CEF_REQUIRE_RT_RETURN(false); + + if (frame_ && frame_->view()) + return (frame_->view()->focusedFrame() == frame_); + return false; +} + +CefString CefFrameImpl::GetName() { + CefString name; + CEF_REQUIRE_RT_RETURN(name); + + if (frame_) + name = frame_->uniqueName(); + return name; +} + +int64 CefFrameImpl::GetIdentifier() { + CEF_REQUIRE_RT_RETURN(0); + + return frame_id_; +} + +CefRefPtr CefFrameImpl::GetParent() { + CEF_REQUIRE_RT_RETURN(NULL); + + if (frame_) { + WebKit::WebFrame* parent = frame_->parent(); + if (parent) + return browser_->GetWebFrameImpl(parent).get(); + } + + return NULL; +} + +CefString CefFrameImpl::GetURL() { + CefString url; + CEF_REQUIRE_RT_RETURN(url); + + if (frame_) { + GURL gurl = frame_->document().url(); + url = gurl.spec(); + } + return url; +} + +CefRefPtr CefFrameImpl::GetBrowser() { + CEF_REQUIRE_RT_RETURN(NULL); + + return browser_; +} + +CefRefPtr CefFrameImpl::GetV8Context() { + CEF_REQUIRE_RT_RETURN(NULL); + + if (frame_) { + v8::HandleScope handle_scope; + return new CefV8ContextImpl(webkit_glue::GetV8Context(frame_)); + } else { + return NULL; + } +} + +void CefFrameImpl::VisitDOM(CefRefPtr visitor) { + CEF_REQUIRE_RT_RETURN_VOID(); + + if (!frame_) + return; + + // Create a CefDOMDocumentImpl object that is valid only for the scope of this + // method. + CefRefPtr documentImpl; + const WebKit::WebDocument& document = frame_->document(); + if (!document.isNull()) + documentImpl = new CefDOMDocumentImpl(browser_, frame_); + + visitor->Visit(documentImpl.get()); + + if (documentImpl.get()) + documentImpl->Detach(); +} + +void CefFrameImpl::Detach() { + browser_ = NULL; + frame_ = NULL; +} diff --git a/cef3/libcef/renderer/frame_impl.h b/cef3/libcef/renderer/frame_impl.h new file mode 100644 index 000000000..2d06678d2 --- /dev/null +++ b/cef3/libcef/renderer/frame_impl.h @@ -0,0 +1,70 @@ +// 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. + +#ifndef CEF_LIBCEF_RENDERER_FRAME_IMPL_H_ +#define CEF_LIBCEF_RENDERER_FRAME_IMPL_H_ +#pragma once + +#include +#include "include/cef_frame.h" +#include "include/cef_v8.h" + +class CefBrowserImpl; + +namespace WebKit { +class WebFrame; +} + +// Implementation of CefFrame. CefFrameImpl objects are owned by the +// CefBrowerImpl and will be detached when the browser is notified that the +// associated renderer WebFrame will close. +class CefFrameImpl : public CefFrame { + public: + CefFrameImpl(CefBrowserImpl* browser, + WebKit::WebFrame* frame); + virtual ~CefFrameImpl(); + + // CefFrame implementation. + virtual bool IsValid() OVERRIDE; + virtual void Undo() OVERRIDE; + virtual void Redo() OVERRIDE; + virtual void Cut() OVERRIDE; + virtual void Copy() OVERRIDE; + virtual void Paste() OVERRIDE; + virtual void Delete() OVERRIDE; + virtual void SelectAll() OVERRIDE; + virtual void ViewSource() OVERRIDE; + virtual void GetSource(CefRefPtr visitor) OVERRIDE; + virtual void GetText(CefRefPtr visitor) OVERRIDE; + virtual void LoadRequest(CefRefPtr request) OVERRIDE; + virtual void LoadURL(const CefString& url) OVERRIDE; + virtual void LoadString(const CefString& string, + const CefString& url) OVERRIDE; + virtual void ExecuteJavaScript(const CefString& jsCode, + const CefString& scriptUrl, + int startLine) OVERRIDE; + virtual bool IsMain() OVERRIDE; + virtual bool IsFocused() OVERRIDE; + virtual CefString GetName() OVERRIDE; + virtual int64 GetIdentifier() OVERRIDE; + virtual CefRefPtr GetParent() OVERRIDE; + virtual CefString GetURL() OVERRIDE; + virtual CefRefPtr GetBrowser() OVERRIDE; + virtual CefRefPtr GetV8Context() OVERRIDE; + virtual void VisitDOM(CefRefPtr visitor) OVERRIDE; + + void Detach(); + + WebKit::WebFrame* web_frame() const { return frame_; } + + protected: + CefBrowserImpl* browser_; + WebKit::WebFrame* frame_; + int64 frame_id_; + + IMPLEMENT_REFCOUNTING(CefFrameImpl); + DISALLOW_EVIL_CONSTRUCTORS(CefFrameImpl); +}; + +#endif // CEF_LIBCEF_RENDERER_FRAME_IMPL_H_ diff --git a/cef3/libcef/renderer/render_message_filter.cc b/cef3/libcef/renderer/render_message_filter.cc new file mode 100644 index 000000000..52ddf1748 --- /dev/null +++ b/cef3/libcef/renderer/render_message_filter.cc @@ -0,0 +1,74 @@ +/// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions (c) 2011 The Chromium 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 "libcef/renderer/render_message_filter.h" +#include "libcef/renderer/thread_util.h" +#include "libcef/common/cef_messages.h" + +#include "base/bind.h" +#include "base/message_loop.h" +#include "content/common/devtools_messages.h" +#include "googleurl/src/gurl.h" +#include "googleurl/src/url_util.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" + +CefRenderMessageFilter::CefRenderMessageFilter() + : channel_(NULL) { +} + +CefRenderMessageFilter::~CefRenderMessageFilter() { +} + +void CefRenderMessageFilter::OnFilterAdded(IPC::Channel* channel) { + channel_ = channel; +} + +void CefRenderMessageFilter::OnFilterRemoved() { +} + +bool CefRenderMessageFilter::OnMessageReceived(const IPC::Message& message) { + bool handled = true; + if (message.type() == DevToolsAgentMsg_Attach::ID || + message.type() == DevToolsAgentMsg_Detach::ID) { + // Observe the DevTools messages but don't handle them. + handled = false; + } + + IPC_BEGIN_MESSAGE_MAP(CefRenderMessageFilter, message) + IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Attach, OnDevToolsAgentAttach) + IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Detach, OnDevToolsAgentDetach) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + +void CefRenderMessageFilter::OnDevToolsAgentAttach() { + CEF_POST_TASK_RT( + base::Bind(&CefRenderMessageFilter::OnDevToolsAgentAttach_RT, this)); +} + +void CefRenderMessageFilter::OnDevToolsAgentDetach() { + // CefContentRendererClient::DevToolsAgentDetached() needs to be called after + // the IPC message has been handled by DevToolsAgent. A workaround for this is + // to first post to the IO thread and then post to the renderer thread. + MessageLoop::current()->PostTask(FROM_HERE, + base::Bind(&CefRenderMessageFilter::OnDevToolsAgentDetach_IOT, this)); +} + +void CefRenderMessageFilter::OnDevToolsAgentAttach_RT() { + CEF_REQUIRE_RT(); + CefContentRendererClient::Get()->DevToolsAgentAttached(); +} + +void CefRenderMessageFilter::OnDevToolsAgentDetach_IOT() { + CEF_POST_TASK_RT( + base::Bind(&CefRenderMessageFilter::OnDevToolsAgentDetach_RT, this)); +} + +void CefRenderMessageFilter::OnDevToolsAgentDetach_RT() { + CEF_REQUIRE_RT(); + CefContentRendererClient::Get()->DevToolsAgentDetached(); +} diff --git a/cef3/libcef/renderer/render_message_filter.h b/cef3/libcef/renderer/render_message_filter.h new file mode 100644 index 000000000..86b1d5b08 --- /dev/null +++ b/cef3/libcef/renderer/render_message_filter.h @@ -0,0 +1,38 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 The Chromium 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_LIBCEF_RENDERER_RENDER_MESSAGE_FILTER_H_ +#define CEF_LIBCEF_RENDERER_RENDER_MESSAGE_FILTER_H_ + +#include +#include "ipc/ipc_channel_proxy.h" + +// This class sends and receives control messages on the renderer process. +class CefRenderMessageFilter : public IPC::ChannelProxy::MessageFilter { + public: + CefRenderMessageFilter(); + virtual ~CefRenderMessageFilter(); + + // IPC::ChannelProxy::MessageFilter implementation. + virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; + virtual void OnFilterRemoved() OVERRIDE; + virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; + + private: + // Message handlers called on the IO thread. + void OnDevToolsAgentAttach(); + void OnDevToolsAgentDetach(); + + void OnDevToolsAgentAttach_RT(); + void OnDevToolsAgentDetach_IOT(); + void OnDevToolsAgentDetach_RT(); + + IPC::Channel* channel_; + + DISALLOW_COPY_AND_ASSIGN(CefRenderMessageFilter); +}; + + +#endif // CEF_LIBCEF_RENDERER_RENDER_MESSAGE_FILTER_H_ diff --git a/cef3/libcef/renderer/render_process_observer.cc b/cef3/libcef/renderer/render_process_observer.cc new file mode 100644 index 000000000..cee9221f7 --- /dev/null +++ b/cef3/libcef/renderer/render_process_observer.cc @@ -0,0 +1,62 @@ +/// Copyright (c) 2013 The Chromium Embedded Framework Authors. +// Portions (c) 2011 The Chromium 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 "libcef/renderer/render_process_observer.h" +#include "libcef/common/cef_messages.h" +#include "libcef/renderer/content_renderer_client.h" + +#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" + +CefRenderProcessObserver::CefRenderProcessObserver() { +} + +CefRenderProcessObserver::~CefRenderProcessObserver() { +} + +bool CefRenderProcessObserver::OnControlMessageReceived( + const IPC::Message& message) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(CefRenderProcessObserver, message) + IPC_MESSAGE_HANDLER(CefProcessMsg_ModifyCrossOriginWhitelistEntry, + OnModifyCrossOriginWhitelistEntry) + IPC_MESSAGE_HANDLER(CefProcessMsg_ClearCrossOriginWhitelist, + OnClearCrossOriginWhitelist) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + +void CefRenderProcessObserver::WebKitInitialized() { + CefContentRendererClient::Get()->WebKitInitialized(); +} + +void CefRenderProcessObserver::OnRenderProcessShutdown() { + CefContentRendererClient::Get()->OnRenderProcessShutdown(); +} + +void CefRenderProcessObserver::OnModifyCrossOriginWhitelistEntry( + bool add, + const Cef_CrossOriginWhiteListEntry_Params& params) { + GURL gurl = GURL(params.source_origin); + if (add) { + WebKit::WebSecurityPolicy::addOriginAccessWhitelistEntry( + gurl, + WebKit::WebString::fromUTF8(params.target_protocol), + WebKit::WebString::fromUTF8(params.target_domain), + params.allow_target_subdomains); + } else { + WebKit::WebSecurityPolicy::removeOriginAccessWhitelistEntry( + gurl, + WebKit::WebString::fromUTF8(params.target_protocol), + WebKit::WebString::fromUTF8(params.target_domain), + params.allow_target_subdomains); + } +} + +void CefRenderProcessObserver::OnClearCrossOriginWhitelist() { + WebKit::WebSecurityPolicy::resetOriginAccessWhitelists(); +} diff --git a/cef3/libcef/renderer/render_process_observer.h b/cef3/libcef/renderer/render_process_observer.h new file mode 100644 index 000000000..b29c16674 --- /dev/null +++ b/cef3/libcef/renderer/render_process_observer.h @@ -0,0 +1,35 @@ +// Copyright (c) 2013 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 The Chromium 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_LIBCEF_RENDERER_RENDER_PROCESS_OBSERVER_H_ +#define CEF_LIBCEF_RENDERER_RENDER_PROCESS_OBSERVER_H_ + +#include "base/compiler_specific.h" +#include "content/public/renderer/render_process_observer.h" + +struct Cef_CrossOriginWhiteListEntry_Params; + +// This class sends and receives control messages on the renderer process. +class CefRenderProcessObserver : public content::RenderProcessObserver { + public: + CefRenderProcessObserver(); + virtual ~CefRenderProcessObserver(); + + // RenderProcessObserver implementation. + virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; + virtual void WebKitInitialized() OVERRIDE; + virtual void OnRenderProcessShutdown() OVERRIDE; + + private: + // Message handlers called on the render thread. + void OnModifyCrossOriginWhitelistEntry( + bool add, + const Cef_CrossOriginWhiteListEntry_Params& params); + void OnClearCrossOriginWhitelist(); + + DISALLOW_COPY_AND_ASSIGN(CefRenderProcessObserver); +}; + +#endif // CEF_LIBCEF_RENDERER_RENDER_PROCESS_OBSERVER_H_ diff --git a/cef3/libcef/renderer/render_urlrequest_impl.cc b/cef3/libcef/renderer/render_urlrequest_impl.cc new file mode 100644 index 000000000..8e564dff4 --- /dev/null +++ b/cef3/libcef/renderer/render_urlrequest_impl.cc @@ -0,0 +1,375 @@ +// 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 "libcef/renderer/render_urlrequest_impl.h" +#include "libcef/common/request_impl.h" +#include "libcef/common/response_impl.h" + +#include "base/logging.h" +#include "base/message_loop.h" +#include "third_party/WebKit/Source/Platform/chromium/public/Platform.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebURLError.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebURLLoader.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebURLLoaderClient.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebURLResponse.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" + +using WebKit::WebString; +using WebKit::WebURL; +using WebKit::WebURLError; +using WebKit::WebURLLoader; +using WebKit::WebURLRequest; +using WebKit::WebURLResponse; + + +namespace { + +class CefWebURLLoaderClient : public WebKit::WebURLLoaderClient { + public: + CefWebURLLoaderClient(CefRenderURLRequest::Context* context, + int request_flags); + virtual ~CefWebURLLoaderClient(); + + // WebKit::WebURLLoaderClient methods. + virtual void willSendRequest( + WebURLLoader* loader, + WebURLRequest& newRequest, + const WebURLResponse& redirectResponse) OVERRIDE; + virtual void didSendData( + WebURLLoader* loader, + unsigned long long bytesSent, + unsigned long long totalBytesToBeSent) OVERRIDE; + virtual void didReceiveResponse( + WebURLLoader* loader, + const WebURLResponse& response) OVERRIDE; + virtual void didDownloadData(WebURLLoader* loader, + int dataLength) OVERRIDE; + virtual void didReceiveData(WebURLLoader* loader, + const char* data, + int dataLength, + int encodedDataLength) OVERRIDE; + virtual void didReceiveCachedMetadata(WebURLLoader* loader, + const char* data, + int dataLength) OVERRIDE; + virtual void didFinishLoading(WebURLLoader* loader, + double finishTime) OVERRIDE; + virtual void didFail(WebURLLoader* loader, + const WebURLError& error) OVERRIDE; + + protected: + // The context_ pointer will outlive this object. + CefRenderURLRequest::Context* context_; + int request_flags_; +}; + +} // namespace + + +// CefRenderURLRequest::Context ----------------------------------------------- + +class CefRenderURLRequest::Context + : public base::RefCountedThreadSafe { + public: + Context(CefRefPtr url_request, + CefRefPtr request, + CefRefPtr client) + : url_request_(url_request), + request_(request), + client_(client), + message_loop_proxy_(MessageLoop::current()->message_loop_proxy()), + status_(UR_IO_PENDING), + error_code_(ERR_NONE), + upload_data_size_(0), + got_upload_progress_complete_(false), + download_data_received_(0), + download_data_total_(-1) { + // Mark the request as read-only. + static_cast(request_.get())->SetReadOnly(true); + } + + virtual ~Context() { + } + + inline bool CalledOnValidThread() { + return message_loop_proxy_->BelongsToCurrentThread(); + } + + bool Start() { + DCHECK(CalledOnValidThread()); + + GURL url = GURL(request_->GetURL().ToString()); + if (!url.is_valid()) + return false; + + loader_.reset(WebKit::webKitPlatformSupport()->createURLLoader()); + url_client_.reset(new CefWebURLLoaderClient(this, request_->GetFlags())); + + WebURLRequest urlRequest; + static_cast(request_.get())->Get(urlRequest); + + if (urlRequest.reportUploadProgress()) { + // Attempt to determine the upload data size. + CefRefPtr post_data = request_->GetPostData(); + if (post_data.get()) { + CefPostData::ElementVector elements; + post_data->GetElements(elements); + if (elements.size() == 1 && elements[0]->GetType() == PDE_TYPE_BYTES) { + CefPostDataElementImpl* impl = + static_cast(elements[0].get()); + upload_data_size_ = impl->GetBytesCount(); + } + } + } + + loader_->loadAsynchronously(urlRequest, url_client_.get()); + return true; + } + + void Cancel() { + DCHECK(CalledOnValidThread()); + + // The request may already be complete. + if (!loader_.get() || status_ != UR_IO_PENDING) + return; + + status_ = UR_CANCELED; + error_code_ = ERR_ABORTED; + + // Will result in a call to OnError(). + loader_->cancel(); + } + + void OnResponse(const WebURLResponse& response) { + DCHECK(CalledOnValidThread()); + + response_ = CefResponse::Create(); + CefResponseImpl* responseImpl = + static_cast(response_.get()); + responseImpl->Set(response); + responseImpl->SetReadOnly(true); + + download_data_total_ = response.expectedContentLength(); + } + + void OnError(const WebURLError& error) { + DCHECK(CalledOnValidThread()); + + if (status_ == UR_IO_PENDING) { + status_ = UR_FAILED; + error_code_ = static_cast(error.reason); + } + + OnComplete(); + } + + void OnComplete() { + DCHECK(CalledOnValidThread()); + + if (status_ == UR_IO_PENDING) { + status_ = UR_SUCCESS; + NotifyUploadProgressIfNecessary(); + } + + if (loader_.get()) + loader_.reset(NULL); + + DCHECK(url_request_.get()); + client_->OnRequestComplete(url_request_.get()); + + // This may result in the Context object being deleted. + url_request_ = NULL; + } + + void OnDownloadProgress(int64 current) { + DCHECK(CalledOnValidThread()); + DCHECK(url_request_.get()); + + NotifyUploadProgressIfNecessary(); + + download_data_received_ += current; + client_->OnDownloadProgress(url_request_.get(), download_data_received_, + download_data_total_); + } + + void OnDownloadData(const char* data, int dataLength) { + DCHECK(CalledOnValidThread()); + DCHECK(url_request_.get()); + client_->OnDownloadData(url_request_.get(), data, dataLength); + } + + void OnUploadProgress(int64 current, int64 total) { + DCHECK(CalledOnValidThread()); + DCHECK(url_request_.get()); + if (current == total) + got_upload_progress_complete_ = true; + client_->OnUploadProgress(url_request_.get(), current, total); + } + + CefRefPtr request() { return request_; } + CefRefPtr client() { return client_; } + CefURLRequest::Status status() { return status_; } + CefURLRequest::ErrorCode error_code() { return error_code_; } + CefRefPtr response() { return response_; } + + private: + void NotifyUploadProgressIfNecessary() { + if (!got_upload_progress_complete_ && upload_data_size_ > 0) { + // URLFetcher sends upload notifications using a timer and will not send + // a notification if the request completes too quickly. We therefore + // send the notification here if necessary. + client_->OnUploadProgress(url_request_.get(), upload_data_size_, + upload_data_size_); + got_upload_progress_complete_ = true; + } + } + + // Members only accessed on the initialization thread. + CefRefPtr url_request_; + CefRefPtr request_; + CefRefPtr client_; + scoped_refptr message_loop_proxy_; + CefURLRequest::Status status_; + CefURLRequest::ErrorCode error_code_; + CefRefPtr response_; + scoped_ptr loader_; + scoped_ptr url_client_; + int64 upload_data_size_; + bool got_upload_progress_complete_; + int64 download_data_received_; + int64 download_data_total_; +}; + + +// CefWebURLLoaderClient -------------------------------------------------- + +namespace { + +CefWebURLLoaderClient::CefWebURLLoaderClient( + CefRenderURLRequest::Context* context, + int request_flags) + : context_(context), + request_flags_(request_flags) { +} + +CefWebURLLoaderClient::~CefWebURLLoaderClient() { +} + +void CefWebURLLoaderClient::willSendRequest( + WebURLLoader* loader, + WebURLRequest& newRequest, + const WebURLResponse& redirectResponse) { +} + +void CefWebURLLoaderClient::didSendData( + WebURLLoader* loader, + unsigned long long bytesSent, + unsigned long long totalBytesToBeSent) { + if (request_flags_ & UR_FLAG_REPORT_UPLOAD_PROGRESS) + context_->OnUploadProgress(bytesSent, totalBytesToBeSent); +} + +void CefWebURLLoaderClient::didReceiveResponse( + WebURLLoader* loader, + const WebURLResponse& response) { + context_->OnResponse(response); +} + +void CefWebURLLoaderClient::didDownloadData(WebURLLoader* loader, + int dataLength) { +} + +void CefWebURLLoaderClient::didReceiveData(WebURLLoader* loader, + const char* data, + int dataLength, + int encodedDataLength) { + context_->OnDownloadProgress(dataLength); + + if (!(request_flags_ & UR_FLAG_NO_DOWNLOAD_DATA)) + context_->OnDownloadData(data, dataLength); +} + +void CefWebURLLoaderClient::didReceiveCachedMetadata(WebURLLoader* loader, + const char* data, + int dataLength) { +} + +void CefWebURLLoaderClient::didFinishLoading(WebURLLoader* loader, + double finishTime) { + context_->OnComplete(); +} + +void CefWebURLLoaderClient::didFail(WebURLLoader* loader, + const WebURLError& error) { + context_->OnError(error); +} + + +} // namespace + + +// CefRenderURLRequest -------------------------------------------------------- + +CefRenderURLRequest::CefRenderURLRequest( + CefRefPtr request, + CefRefPtr client) { + context_ = new Context(this, request, client); +} + +CefRenderURLRequest::~CefRenderURLRequest() { +} + +bool CefRenderURLRequest::Start() { + if (!VerifyContext()) + return false; + return context_->Start(); +} + +CefRefPtr CefRenderURLRequest::GetRequest() { + if (!VerifyContext()) + return NULL; + return context_->request(); +} + +CefRefPtr CefRenderURLRequest::GetClient() { + if (!VerifyContext()) + return NULL; + return context_->client(); +} + +CefURLRequest::Status CefRenderURLRequest::GetRequestStatus() { + if (!VerifyContext()) + return UR_UNKNOWN; + return context_->status(); +} + +CefURLRequest::ErrorCode CefRenderURLRequest::GetRequestError() { + if (!VerifyContext()) + return ERR_NONE; + return context_->error_code(); +} + +CefRefPtr CefRenderURLRequest::GetResponse() { + if (!VerifyContext()) + return NULL; + return context_->response(); +} + +void CefRenderURLRequest::Cancel() { + if (!VerifyContext()) + return; + return context_->Cancel(); +} + +bool CefRenderURLRequest::VerifyContext() { + DCHECK(context_.get()); + if (!context_->CalledOnValidThread()) { + NOTREACHED() << "called on invalid thread"; + return false; + } + + return true; +} diff --git a/cef3/libcef/renderer/render_urlrequest_impl.h b/cef3/libcef/renderer/render_urlrequest_impl.h new file mode 100644 index 000000000..b529b100c --- /dev/null +++ b/cef3/libcef/renderer/render_urlrequest_impl.h @@ -0,0 +1,37 @@ +// 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. + +#ifndef CEF_LIBCEF_RENDERER_RENDER_URLREQUEST_IMPL_H_ +#define CEF_LIBCEF_RENDERER_RENDER_URLREQUEST_IMPL_H_ + +#include "include/cef_urlrequest.h" +#include "base/memory/ref_counted.h" + +class CefRenderURLRequest : public CefURLRequest { + public: + class Context; + + CefRenderURLRequest(CefRefPtr request, + CefRefPtr client); + virtual ~CefRenderURLRequest(); + + bool Start(); + + // CefURLRequest methods. + virtual CefRefPtr GetRequest() OVERRIDE; + virtual CefRefPtr GetClient() OVERRIDE; + virtual Status GetRequestStatus() OVERRIDE; + virtual ErrorCode GetRequestError() OVERRIDE; + virtual CefRefPtr GetResponse() OVERRIDE; + virtual void Cancel() OVERRIDE; + + private: + bool VerifyContext(); + + scoped_refptr context_; + + IMPLEMENT_REFCOUNTING(CefBrowserURLRequest); +}; + +#endif // CEF_LIBCEF_RENDERER_RENDER_URLREQUEST_IMPL_H_ diff --git a/cef3/libcef/renderer/thread_util.h b/cef3/libcef/renderer/thread_util.h new file mode 100644 index 000000000..da9322c7d --- /dev/null +++ b/cef3/libcef/renderer/thread_util.h @@ -0,0 +1,58 @@ +// Copyright (c) 2013 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_LIBCEF_RENDERER_THREAD_UTIL_H_ +#define CEF_LIBCEF_RENDERER_THREAD_UTIL_H_ +#pragma once + +#include "libcef/renderer/content_renderer_client.h" + +#include "base/location.h" +#include "base/logging.h" +#include "content/public/renderer/render_thread.h" + +#define CEF_CURRENTLY_ON_RT() (!!content::RenderThread::Get()) + +#define CEF_REQUIRE_RT() DCHECK(CEF_CURRENTLY_ON_RT()) + +#define CEF_REQUIRE_RT_RETURN(var) \ + if (!CEF_CURRENTLY_ON_RT()) { \ + NOTREACHED() << "called on invalid thread"; \ + return var; \ + } + +#define CEF_REQUIRE_RT_RETURN_VOID() \ + if (!CEF_CURRENTLY_ON_RT()) { \ + NOTREACHED() << "called on invalid thread"; \ + return; \ + } + +#define CEF_RENDER_LOOP() \ + (CefContentRendererClient::Get()->render_task_runner()) + +#define CEF_POST_TASK_RT(task) \ + CEF_RENDER_LOOP()->PostTask(FROM_HERE, task) +#define CEF_POST_DELAYED_TASK_RT(task, delay_ms) \ + CEF_RENDER_LOOP()->PostDelayedTask(FROM_HERE, task, delay_ms) + +// Use this template in conjuction with RefCountedThreadSafe when you want to +// ensure that an object is deleted on the render thread. +struct CefDeleteOnRenderThread { + template + static void Destruct(const T* x) { + if (CEF_CURRENTLY_ON_RT()) { + delete x; + } else { + if (!CEF_RENDER_LOOP()->DeleteSoon(FROM_HERE, x)) { +#if defined(UNIT_TEST) + // Only logged under unit testing because leaks at shutdown + // are acceptable under normal circumstances. + LOG(ERROR) << "DeleteSoon failed on thread " << thread; +#endif // UNIT_TEST + } + } + } +}; + +#endif // CEF_LIBCEF_RENDERER_THREAD_UTIL_H_ diff --git a/cef3/libcef/renderer/v8_impl.cc b/cef3/libcef/renderer/v8_impl.cc new file mode 100644 index 000000000..5288bddc1 --- /dev/null +++ b/cef3/libcef/renderer/v8_impl.cc @@ -0,0 +1,1847 @@ +// Copyright (c) 2013 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 +#include + +#include "base/command_line.h" +#include "base/compiler_specific.h" + +#include "third_party/WebKit/Source/WebCore/config.h" +MSVC_PUSH_WARNING_LEVEL(0); +#include "Frame.h" // NOLINT(build/include) +#include "ScriptController.h" // NOLINT(build/include) +#include "ScriptControllerBase.h" // NOLINT(build/include) +#include "V8Binding.h" // NOLINT(build/include) +#include "V8RecursionScope.h" // NOLINT(build/include) +#include "WorkerContext.h" // NOLINT(build/include) +#include "WorkerScriptController.h" // NOLINT(build/include) +MSVC_POP_WARNING(); +#undef LOG + +#include "libcef/renderer/v8_impl.h" + +#include "libcef/common/cef_switches.h" +#include "libcef/common/content_client.h" +#include "libcef/common/task_runner_impl.h" +#include "libcef/common/tracker.h" +#include "libcef/renderer/browser_impl.h" +#include "libcef/renderer/thread_util.h" + +#include "base/bind.h" +#include "base/lazy_instance.h" +#include "base/string_number_conversions.h" +#include "base/threading/thread_local.h" +#include "googleurl/src/gurl.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h" + +namespace { + +static const char kCefTrackObject[] = "Cef::TrackObject"; +static const char kCefContextState[] = "Cef::ContextState"; + +void MessageListenerCallbackImpl(v8::Handle message, + v8::Handle data); + +// Manages memory and state information associated with a single Isolate. +class CefV8IsolateManager { + public: + CefV8IsolateManager() + : isolate_(v8::Isolate::GetCurrent()), + task_runner_(CefContentRendererClient::Get()->GetCurrentTaskRunner()), + context_safety_impl_(IMPL_HASH), + message_listener_registered_(false), + worker_id_(0) { + DCHECK(isolate_); + DCHECK(task_runner_.get()); + + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + if (command_line.HasSwitch(switches::kContextSafetyImplementation)) { + std::string value = command_line.GetSwitchValueASCII( + switches::kContextSafetyImplementation); + int mode; + if (base::StringToInt(value, &mode)) { + if (mode < 0) + context_safety_impl_ = IMPL_DISABLED; + else if (mode == 1) + context_safety_impl_ = IMPL_VALUE; + } + } + } + ~CefV8IsolateManager() { + DCHECK_EQ(isolate_, v8::Isolate::GetCurrent()); + DCHECK(context_map_.empty()); + } + + scoped_refptr GetContextState( + v8::Handle context) { + DCHECK_EQ(isolate_, v8::Isolate::GetCurrent()); + DCHECK(context.IsEmpty() || isolate_ == context->GetIsolate()); + + if (context_safety_impl_ == IMPL_DISABLED) + return scoped_refptr(); + + if (context.IsEmpty()) { + if (v8::Context::InContext()) + context = v8::Context::GetCurrent(); + else + return scoped_refptr(); + } + + if (context_safety_impl_ == IMPL_HASH) { + int hash = context->Global()->GetIdentityHash(); + ContextMap::const_iterator it = context_map_.find(hash); + if (it != context_map_.end()) + return it->second; + + scoped_refptr state = new CefV8ContextState(); + context_map_.insert(std::make_pair(hash, state)); + + return state; + } else { + if (context_state_key_.IsEmpty()) { + context_state_key_ = + v8::Persistent::New( + isolate_, + v8::String::New(kCefContextState)); + } + + v8::Handle object = context->Global(); + v8::Handle value = object->GetHiddenValue(context_state_key_); + if (!value.IsEmpty()) { + return static_cast( + v8::External::Cast(*value)->Value()); + } + + scoped_refptr state = new CefV8ContextState(); + object->SetHiddenValue(context_state_key_, + v8::External::New(state.get())); + + // Reference will be released in ReleaseContext. + state->AddRef(); + + return state; + } + } + + void ReleaseContext(v8::Handle context) { + DCHECK_EQ(isolate_, v8::Isolate::GetCurrent()); + + if (context_safety_impl_ == IMPL_DISABLED) + return; + + if (context_safety_impl_ == IMPL_HASH) { + int hash = context->Global()->GetIdentityHash(); + ContextMap::iterator it = context_map_.find(hash); + if (it != context_map_.end()) { + it->second->Detach(); + context_map_.erase(it); + } + } else { + if (context_state_key_.IsEmpty()) + return; + + v8::Handle object = context->Global(); + v8::Handle value = object->GetHiddenValue(context_state_key_); + if (value.IsEmpty()) + return; + + scoped_refptr state = + static_cast(v8::External::Cast(*value)->Value()); + state->Detach(); + object->DeleteHiddenValue(context_state_key_); + + // Match the AddRef in GetContextState. + state->Release(); + } + } + + void AddGlobalTrackObject(CefTrackNode* object) { + DCHECK_EQ(isolate_, v8::Isolate::GetCurrent()); + global_manager_.Add(object); + } + + void DeleteGlobalTrackObject(CefTrackNode* object) { + DCHECK_EQ(isolate_, v8::Isolate::GetCurrent()); + global_manager_.Delete(object); + } + + void SetUncaughtExceptionStackSize(int stack_size) { + if (stack_size <= 0) + return; + + if (!message_listener_registered_) { + v8::V8::AddMessageListener(&MessageListenerCallbackImpl); + message_listener_registered_ = true; + } + + v8::V8::SetCaptureStackTraceForUncaughtExceptions(true, + stack_size, v8::StackTrace::kDetailed); + } + + void SetWorkerAttributes(int worker_id, const GURL& worker_url) { + worker_id_ = worker_id; + worker_url_ = worker_url; + } + + v8::Isolate* isolate() const { return isolate_; } + scoped_refptr task_runner() const { + return task_runner_; + } + + int worker_id() const { + return worker_id_; + } + + const GURL& worker_url() const { + return worker_url_; + } + + private: + v8::Isolate* isolate_; + scoped_refptr task_runner_; + + enum ContextSafetyImpl { + IMPL_DISABLED, + IMPL_HASH, + IMPL_VALUE, + }; + ContextSafetyImpl context_safety_impl_; + + // Used with IMPL_HASH. + typedef std::map > ContextMap; + ContextMap context_map_; + + // Used with IMPL_VALUE. + v8::Persistent context_state_key_; + + // Used for globally tracked objects that are not associated with a particular + // context. + CefTrackManager global_manager_; + + // True if the message listener has been registered. + bool message_listener_registered_; + + // Attributes associated with WebWorker threads. + int worker_id_; + GURL worker_url_; +}; + +// Chromium uses the default Isolate for the main render process thread and a +// new Isolate for each WebWorker thread. Continue this pattern by tracking +// Isolate information on a per-thread basis. This implementation will need to +// be re-worked (perhaps using a map keyed on v8::Isolate::GetCurrent()) if +// in the future Chromium begins using the same Isolate across multiple threads. +class CefV8StateManager { +public: + CefV8StateManager() { + } + + void CreateIsolateManager() { + DCHECK(!current_tls_.Get()); + current_tls_.Set(new CefV8IsolateManager()); + } + + void DestroyIsolateManager() { + DCHECK(current_tls_.Get()); + delete current_tls_.Get(); + current_tls_.Set(NULL); + } + + CefV8IsolateManager* GetIsolateManager() { + CefV8IsolateManager* manager = current_tls_.Get(); + DCHECK(manager); + return manager; + } + + private: + base::ThreadLocalPointer current_tls_; +}; + +base::LazyInstance g_v8_state = LAZY_INSTANCE_INITIALIZER; + +CefV8IsolateManager* GetIsolateManager() { + return g_v8_state.Pointer()->GetIsolateManager(); +} + +class V8TrackObject : public CefTrackNode { + public: + V8TrackObject() + : external_memory_(0) { + v8::V8::AdjustAmountOfExternalAllocatedMemory( + static_cast(sizeof(V8TrackObject))); + } + ~V8TrackObject() { + v8::V8::AdjustAmountOfExternalAllocatedMemory( + -static_cast(sizeof(V8TrackObject)) - external_memory_); + } + + inline int GetExternallyAllocatedMemory() { + return external_memory_; + } + + int AdjustExternallyAllocatedMemory(int change_in_bytes) { + int new_value = external_memory_ + change_in_bytes; + if (new_value < 0) { + NOTREACHED() << "External memory usage cannot be less than 0 bytes"; + change_in_bytes = -(external_memory_); + new_value = 0; + } + + if (change_in_bytes != 0) + v8::V8::AdjustAmountOfExternalAllocatedMemory(change_in_bytes); + external_memory_ = new_value; + + return new_value; + } + + inline void SetAccessor(CefRefPtr accessor) { + accessor_ = accessor; + } + + inline CefRefPtr GetAccessor() { + return accessor_; + } + + inline void SetHandler(CefRefPtr handler) { + handler_ = handler; + } + + inline CefRefPtr GetHandler() { + return handler_; + } + + inline void SetUserData(CefRefPtr user_data) { + user_data_ = user_data; + } + + inline CefRefPtr GetUserData() { + return user_data_; + } + + // Attach this track object to the specified V8 object. + void AttachTo(v8::Handle object) { + object->SetHiddenValue(v8::String::New(kCefTrackObject), + v8::External::New(this)); + } + + // Retrieve the track object for the specified V8 object. + static V8TrackObject* Unwrap(v8::Handle object) { + v8::Local value = + object->GetHiddenValue(v8::String::New(kCefTrackObject)); + if (!value.IsEmpty()) + return static_cast(v8::External::Cast(*value)->Value()); + + return NULL; + } + + private: + CefRefPtr accessor_; + CefRefPtr handler_; + CefRefPtr user_data_; + int external_memory_; +}; + +class V8TrackString : public CefTrackNode { + public: + explicit V8TrackString(const std::string& str) : string_(str) {} + const char* GetString() { return string_.c_str(); } + + private: + std::string string_; +}; + + +// Manages the life span of a CefTrackNode associated with a persistent Object +// or Function. +class CefV8MakeWeakParam { + public: + CefV8MakeWeakParam(scoped_refptr context_state, + CefTrackNode* object) + : context_state_(context_state), + object_(object) { + DCHECK(object_); + + v8::V8::AdjustAmountOfExternalAllocatedMemory( + static_cast(sizeof(CefV8MakeWeakParam))); + + if (context_state_.get()) { + // |object_| will be deleted when: + // A. The associated context is released, or + // B. TrackDestructor is called for the weak handle. + DCHECK(context_state_->IsValid()); + context_state_->AddTrackObject(object_); + } else { + // |object_| will be deleted when: + // A. The process shuts down, or + // B. TrackDestructor is called for the weak handle. + GetIsolateManager()->AddGlobalTrackObject(object_); + } + } + ~CefV8MakeWeakParam() { + if (context_state_.get()) { + // If the associated context is still valid then delete |object_|. + // Otherwise, |object_| will already have been deleted. + if (context_state_->IsValid()) + context_state_->DeleteTrackObject(object_); + } else { + GetIsolateManager()->DeleteGlobalTrackObject(object_); + } + + v8::V8::AdjustAmountOfExternalAllocatedMemory( + -static_cast(sizeof(CefV8MakeWeakParam))); + } + + private: + scoped_refptr context_state_; + CefTrackNode* object_; +}; + +// Callback for weak persistent reference destruction. +void TrackDestructor(v8::Isolate* isolate, + v8::Persistent object, + void* parameter) { + if (parameter) + delete static_cast(parameter); + + object.Dispose(isolate); + object.Clear(); +} + + +// Convert a CefString to a V8::String. +v8::Handle GetV8String(const CefString& str) { +#if defined(CEF_STRING_TYPE_UTF16) + // Already a UTF16 string. + return v8::String::New( + reinterpret_cast( + const_cast(str.c_str())), + str.length()); +#elif defined(CEF_STRING_TYPE_UTF8) + // Already a UTF8 string. + return v8::String::New(const_cast(str.c_str()), str.length()); +#else + // Convert the string to UTF8. + std::string tmpStr = str; + return v8::String::New(tmpStr.c_str(), tmpStr.length()); +#endif +} + +#if defined(CEF_STRING_TYPE_UTF16) +void v8impl_string_dtor(char16* str) { + delete [] str; +} +#elif defined(CEF_STRING_TYPE_UTF8) +void v8impl_string_dtor(char* str) { + delete [] str; +} +#endif + +// Convert a v8::String to CefString. +void GetCefString(v8::Handle str, CefString& out) { + if (str.IsEmpty()) + return; + +#if defined(CEF_STRING_TYPE_WIDE) + // Allocate enough space for a worst-case conversion. + int len = str->Utf8Length(); + if (len == 0) + return; + char* buf = new char[len + 1]; + str->WriteUtf8(buf, len + 1); + + // Perform conversion to the wide type. + cef_string_t* retws = out.GetWritableStruct(); + cef_string_utf8_to_wide(buf, len, retws); + + delete [] buf; +#else // !defined(CEF_STRING_TYPE_WIDE) +#if defined(CEF_STRING_TYPE_UTF16) + int len = str->Length(); + if (len == 0) + return; + char16* buf = new char16[len + 1]; + str->Write(reinterpret_cast(buf), 0, len + 1); +#else + // Allocate enough space for a worst-case conversion. + int len = str->Utf8Length(); + if (len == 0) + return; + char* buf = new char[len + 1]; + str->WriteUtf8(buf, len + 1); +#endif + + // Don't perform an extra string copy. + out.clear(); + cef_string_t* retws = out.GetWritableStruct(); + retws->str = buf; + retws->length = len; + retws->dtor = v8impl_string_dtor; +#endif // !defined(CEF_STRING_TYPE_WIDE) +} + +// V8 function callback. +v8::Handle FunctionCallbackImpl(const v8::Arguments& args) { + v8::HandleScope handle_scope; + WebCore::V8RecursionScope recursion_scope( + WebCore::toScriptExecutionContext(v8::Context::GetCurrent())); + + CefV8Handler* handler = + static_cast(v8::External::Cast(*args.Data())->Value()); + + CefV8ValueList params; + for (int i = 0; i < args.Length(); i++) + params.push_back(new CefV8ValueImpl(args[i])); + + CefString func_name; + GetCefString(v8::Handle::Cast(args.Callee()->GetName()), + func_name); + CefRefPtr object = new CefV8ValueImpl(args.This()); + CefRefPtr retval; + CefString exception; + + if (handler->Execute(func_name, object, params, retval, exception)) { + if (!exception.empty()) { + return v8::ThrowException(v8::Exception::Error(GetV8String(exception))); + } else { + CefV8ValueImpl* rv = static_cast(retval.get()); + if (rv && rv->IsValid()) + return rv->GetHandle(true); + } + } + + return v8::Undefined(); +} + +// V8 Accessor callbacks +v8::Handle AccessorGetterCallbackImpl(v8::Local property, + const v8::AccessorInfo& info) { + v8::HandleScope handle_scope; + WebCore::V8RecursionScope recursion_scope( + WebCore::toScriptExecutionContext(v8::Context::GetCurrent())); + + v8::Handle obj = info.This(); + + CefRefPtr accessorPtr; + + V8TrackObject* tracker = V8TrackObject::Unwrap(obj); + if (tracker) + accessorPtr = tracker->GetAccessor(); + + if (accessorPtr.get()) { + CefRefPtr retval; + CefRefPtr object = new CefV8ValueImpl(obj); + CefString name, exception; + GetCefString(property, name); + if (accessorPtr->Get(name, object, retval, exception)) { + if (!exception.empty()) { + return v8::ThrowException( + v8::Exception::Error(GetV8String(exception))); + } else { + CefV8ValueImpl* rv = static_cast(retval.get()); + if (rv && rv->IsValid()) + return rv->GetHandle(true); + } + } + } + + return v8::Undefined(); +} + +void AccessorSetterCallbackImpl(v8::Local property, + v8::Local value, + const v8::AccessorInfo& info) { + v8::HandleScope handle_scope; + WebCore::V8RecursionScope recursion_scope( + WebCore::toScriptExecutionContext(v8::Context::GetCurrent())); + + v8::Handle obj = info.This(); + + CefRefPtr accessorPtr; + + V8TrackObject* tracker = V8TrackObject::Unwrap(obj); + if (tracker) + accessorPtr = tracker->GetAccessor(); + + if (accessorPtr.get()) { + CefRefPtr object = new CefV8ValueImpl(obj); + CefRefPtr cefValue = new CefV8ValueImpl(value); + CefString name, exception; + GetCefString(property, name); + accessorPtr->Set(name, object, cefValue, exception); + if (!exception.empty()) { + v8::ThrowException(v8::Exception::Error(GetV8String(exception))); + return; + } + } +} + +v8::Local CallV8Function(v8::Handle context, + v8::Handle function, + v8::Handle receiver, + int argc, + v8::Handle args[]) { + v8::Local func_rv; + + // Execute the function call using the ScriptController so that inspector + // instrumentation works. + if (CEF_CURRENTLY_ON_RT()) { + RefPtr frame = WebCore::toFrameIfNotDetached(context); + DCHECK(frame); + if (frame && + frame->script()->canExecuteScripts(WebCore::AboutToExecuteScript)) { + func_rv = frame->script()->callFunction(function, receiver, argc, args); + } + } else { + WebCore::WorkerScriptController* controller = + WebCore::WorkerScriptController::controllerForContext(); + DCHECK(controller); + if (controller) { + func_rv = WebCore::ScriptController::callFunctionWithInstrumentation( + controller->workerContext()->scriptExecutionContext(), + function, receiver, argc, args); + } + } + + return func_rv; +} + + +// V8 extension registration. + +class ExtensionWrapper : public v8::Extension { + public: + ExtensionWrapper(const char* extension_name, + const char* javascript_code, + CefV8Handler* handler) + : v8::Extension(extension_name, javascript_code), handler_(handler) { + if (handler) { + // The reference will be released when the process exits. + V8TrackObject* object = new V8TrackObject; + object->SetHandler(handler); + GetIsolateManager()->AddGlobalTrackObject(object); + } + } + + virtual v8::Handle GetNativeFunction( + v8::Handle name) { + if (!handler_) + return v8::Handle(); + + return v8::FunctionTemplate::New(FunctionCallbackImpl, + v8::External::New(handler_)); + } + + private: + CefV8Handler* handler_; +}; + +class CefV8ExceptionImpl : public CefV8Exception { + public: + explicit CefV8ExceptionImpl(v8::Handle message) + : line_number_(0), + start_position_(0), + end_position_(0), + start_column_(0), + end_column_(0) { + if (message.IsEmpty()) + return; + + GetCefString(message->Get(), message_); + GetCefString(message->GetSourceLine(), source_line_); + + if (!message->GetScriptResourceName().IsEmpty()) + GetCefString(message->GetScriptResourceName()->ToString(), script_); + + line_number_ = message->GetLineNumber(); + start_position_ = message->GetStartPosition(); + end_position_ = message->GetEndPosition(); + start_column_ = message->GetStartColumn(); + end_column_ = message->GetEndColumn(); + } + + virtual CefString GetMessage() OVERRIDE { return message_; } + virtual CefString GetSourceLine() OVERRIDE { return source_line_; } + virtual CefString GetScriptResourceName() OVERRIDE { return script_; } + virtual int GetLineNumber() OVERRIDE { return line_number_; } + virtual int GetStartPosition() OVERRIDE { return start_position_; } + virtual int GetEndPosition() OVERRIDE { return end_position_; } + virtual int GetStartColumn() OVERRIDE { return start_column_; } + virtual int GetEndColumn() OVERRIDE { return end_column_; } + + protected: + CefString message_; + CefString source_line_; + CefString script_; + int line_number_; + int start_position_; + int end_position_; + int start_column_; + int end_column_; + + IMPLEMENT_REFCOUNTING(CefV8ExceptionImpl); +}; + +void MessageListenerCallbackImpl(v8::Handle message, + v8::Handle data) { + CefRefPtr application = CefContentClient::Get()->application(); + if (!application.get()) + return; + + CefRefPtr handler = + application->GetRenderProcessHandler(); + if (!handler.get()) + return; + + CefRefPtr context = CefV8Context::GetCurrentContext(); + v8::Handle v8Stack = message->GetStackTrace(); + DCHECK(!v8Stack.IsEmpty()); + CefRefPtr stackTrace = new CefV8StackTraceImpl(v8Stack); + + CefRefPtr exception = new CefV8ExceptionImpl(message); + + if (CEF_CURRENTLY_ON_RT()) { + handler->OnUncaughtException(context->GetBrowser(), context->GetFrame(), + context, exception, stackTrace); + } else { + CefV8IsolateManager* manager = GetIsolateManager(); + DCHECK_GT(manager->worker_id(), 0); + handler->OnWorkerUncaughtException(manager->worker_id(), + manager->worker_url().spec(), context, exception, stackTrace); + } +} + +} // namespace + + +// Global functions. + +void CefV8IsolateCreated() { + g_v8_state.Pointer()->CreateIsolateManager(); +} + +void CefV8IsolateDestroyed() { + g_v8_state.Pointer()->DestroyIsolateManager(); +} + +void CefV8ReleaseContext(v8::Handle context) { + GetIsolateManager()->ReleaseContext(context); +} + +void CefV8SetUncaughtExceptionStackSize(int stack_size) { + GetIsolateManager()->SetUncaughtExceptionStackSize(stack_size); +} + +void CefV8SetWorkerAttributes(int worker_id, const GURL& worker_url) { + GetIsolateManager()->SetWorkerAttributes(worker_id, worker_url); +} + +bool CefRegisterExtension(const CefString& extension_name, + const CefString& javascript_code, + CefRefPtr handler) { + // Verify that this method was called on the correct thread. + CEF_REQUIRE_RT_RETURN(false); + + V8TrackString* name = new V8TrackString(extension_name); + GetIsolateManager()->AddGlobalTrackObject(name); + V8TrackString* code = new V8TrackString(javascript_code); + GetIsolateManager()->AddGlobalTrackObject(code); + + ExtensionWrapper* wrapper = new ExtensionWrapper(name->GetString(), + code->GetString(), handler.get()); + + content::RenderThread::Get()->RegisterExtension(wrapper); + return true; +} + + +// Helper macros + +#define CEF_V8_HAS_ISOLATE() (!!GetIsolateManager()) +#define CEF_V8_REQUIRE_ISOLATE_RETURN(var) \ + if (!CEF_V8_HAS_ISOLATE()) { \ + NOTREACHED() << "V8 isolate is not valid"; \ + return var; \ + } + +#define CEF_V8_CURRENTLY_ON_MLT() (handle_->BelongsToCurrentThread()) +#define CEF_V8_REQUIRE_MLT_RETURN(var) \ + CEF_V8_REQUIRE_ISOLATE_RETURN(var); \ + if (!CEF_V8_CURRENTLY_ON_MLT()) { \ + NOTREACHED() << "called on incorrect thread"; \ + return var; \ + } + +#define CEF_V8_HANDLE_IS_VALID() (handle_->IsValid()) +#define CEF_V8_REQUIRE_VALID_RETURN(ret) \ + CEF_V8_REQUIRE_MLT_RETURN(ret); \ + if (!CEF_V8_HANDLE_IS_VALID()) { \ + NOTREACHED() << "V8 handle is not valid"; \ + return ret; \ + } + +#define CEF_V8_IS_VALID() \ + (CEF_V8_HAS_ISOLATE() && \ + CEF_V8_CURRENTLY_ON_MLT() && \ + CEF_V8_HANDLE_IS_VALID()) + +#define CEF_V8_REQUIRE_OBJECT_RETURN(ret) \ + CEF_V8_REQUIRE_VALID_RETURN(ret); \ + if (!GetHandle(false)->IsObject()) { \ + NOTREACHED() << "V8 value is not an object"; \ + return ret; \ + } + +#define CEF_V8_REQUIRE_ARRAY_RETURN(ret) \ + CEF_V8_REQUIRE_VALID_RETURN(ret); \ + if (!GetHandle(false)->IsArray()) { \ + NOTREACHED() << "V8 value is not an array"; \ + return ret; \ + } + +#define CEF_V8_REQUIRE_FUNCTION_RETURN(ret) \ + CEF_V8_REQUIRE_VALID_RETURN(ret); \ + if (!GetHandle(false)->IsFunction()) { \ + NOTREACHED() << "V8 value is not a function"; \ + return ret; \ + } + + +// CefV8HandleBase + +CefV8HandleBase::~CefV8HandleBase() { + DCHECK(BelongsToCurrentThread()); +} + +bool CefV8HandleBase::BelongsToCurrentThread() const { + return task_runner_->RunsTasksOnCurrentThread(); +} + +CefV8HandleBase::CefV8HandleBase(v8::Handle context) { + CefV8IsolateManager* manager = GetIsolateManager(); + DCHECK(manager); + + isolate_ = manager->isolate(); + task_runner_ = manager->task_runner(); + context_state_ = manager->GetContextState(context); +} + + +// CefV8Context + +// static +CefRefPtr CefV8Context::GetCurrentContext() { + CefRefPtr context; + CEF_V8_REQUIRE_ISOLATE_RETURN(context); + if (v8::Context::InContext()) { + v8::HandleScope handle_scope; + context = new CefV8ContextImpl(v8::Context::GetCurrent()); + } + return context; +} + +// static +CefRefPtr CefV8Context::GetEnteredContext() { + CefRefPtr context; + CEF_V8_REQUIRE_ISOLATE_RETURN(context); + if (v8::Context::InContext()) { + v8::HandleScope handle_scope; + context = new CefV8ContextImpl(v8::Context::GetEntered()); + } + return context; +} + +// static +bool CefV8Context::InContext() { + CEF_V8_REQUIRE_ISOLATE_RETURN(false); + return v8::Context::InContext(); +} + + +// CefV8ContextImpl + +CefV8ContextImpl::CefV8ContextImpl(v8::Handle context) + : handle_(new Handle(context, context)) +#ifndef NDEBUG + , enter_count_(0) +#endif +{ // NOLINT(whitespace/braces) +} + +CefV8ContextImpl::~CefV8ContextImpl() { + DLOG_ASSERT(0 == enter_count_); +} + +CefRefPtr CefV8ContextImpl::GetTaskRunner() { + return new CefTaskRunnerImpl(handle_->task_runner()); +} + +bool CefV8ContextImpl::IsValid() { + return CEF_V8_IS_VALID(); +} + +CefRefPtr CefV8ContextImpl::GetBrowser() { + CefRefPtr browser; + CEF_V8_REQUIRE_VALID_RETURN(browser); + + // Return NULL for WebWorkers. + if (!CEF_CURRENTLY_ON_RT()) + return browser; + + WebKit::WebFrame* webframe = GetWebFrame(); + if (webframe) + browser = CefBrowserImpl::GetBrowserForMainFrame(webframe->top()); + + return browser; +} + +CefRefPtr CefV8ContextImpl::GetFrame() { + CefRefPtr frame; + CEF_V8_REQUIRE_VALID_RETURN(frame); + + // Return NULL for WebWorkers. + if (!CEF_CURRENTLY_ON_RT()) + return frame; + + WebKit::WebFrame* webframe = GetWebFrame(); + if (webframe) { + CefRefPtr browser = + CefBrowserImpl::GetBrowserForMainFrame(webframe->top()); + frame = browser->GetFrame(webframe->identifier()); + } + + return frame; +} + +CefRefPtr CefV8ContextImpl::GetGlobal() { + CEF_V8_REQUIRE_VALID_RETURN(NULL); + + v8::HandleScope handle_scope; + v8::Context::Scope context_scope(GetHandle()); + return new CefV8ValueImpl(GetHandle()->Global()); +} + +bool CefV8ContextImpl::Enter() { + CEF_V8_REQUIRE_VALID_RETURN(false); + + WebCore::V8PerIsolateData::current()->incrementRecursionLevel(); + GetHandle()->Enter(); +#ifndef NDEBUG + ++enter_count_; +#endif + return true; +} + +bool CefV8ContextImpl::Exit() { + CEF_V8_REQUIRE_VALID_RETURN(false); + + DLOG_ASSERT(enter_count_ > 0); + GetHandle()->Exit(); + WebCore::V8PerIsolateData::current()->decrementRecursionLevel(); +#ifndef NDEBUG + --enter_count_; +#endif + return true; +} + +bool CefV8ContextImpl::IsSame(CefRefPtr that) { + CEF_V8_REQUIRE_VALID_RETURN(false); + + v8::HandleScope handle_scope; + + v8::Local thatHandle; + v8::Local thisHandle = GetContext(); + + CefV8ContextImpl* impl = static_cast(that.get()); + if (impl && impl->IsValid()) + thatHandle = impl->GetContext(); + + return (thisHandle == thatHandle); +} + +bool CefV8ContextImpl::Eval(const CefString& code, + CefRefPtr& retval, + CefRefPtr& exception) { + CEF_V8_REQUIRE_VALID_RETURN(false); + + if (code.empty()) { + NOTREACHED() << "invalid input parameter"; + return false; + } + + v8::HandleScope handle_scope; + v8::Local context = GetContext(); + v8::Context::Scope context_scope(context); + v8::Local obj = context->Global(); + + // Retrieve the eval function. + v8::Local val = obj->Get(v8::String::New("eval")); + if (val.IsEmpty() || !val->IsFunction()) + return false; + + v8::Local func = v8::Local::Cast(val); + v8::Handle code_val = GetV8String(code); + + v8::TryCatch try_catch; + try_catch.SetVerbose(true); + + retval = NULL; + exception = NULL; + + v8::Local func_rv = + CallV8Function(context, func, obj, 1, &code_val); + + if (try_catch.HasCaught()) { + exception = new CefV8ExceptionImpl(try_catch.Message()); + return false; + } else if (!func_rv.IsEmpty()) { + retval = new CefV8ValueImpl(func_rv); + } + return true; +} + +v8::Local CefV8ContextImpl::GetContext() { + return v8::Local::New(GetHandle()); +} + +WebKit::WebFrame* CefV8ContextImpl::GetWebFrame() { + CEF_REQUIRE_RT(); + v8::HandleScope handle_scope; + v8::Context::Scope context_scope(GetHandle()); + WebKit::WebFrame* frame = WebKit::WebFrame::frameForCurrentContext(); + return frame; +} + + +// CefV8ValueImpl::Handle + +CefV8ValueImpl::Handle::~Handle() { + // Persist the handle (call MakeWeak) if: + // A. The handle has been passed into a V8 function or used as a return value + // from a V8 callback, and + // B. The associated context, if any, is still valid. + if (should_persist_ && (!context_state_.get() || context_state_->IsValid())) { + handle_.MakeWeak( + isolate(), + (tracker_ ? new CefV8MakeWeakParam(context_state_, tracker_) : NULL), + TrackDestructor); + } else { + handle_.Dispose(isolate()); + handle_.Clear(); + + if (tracker_) + delete tracker_; + } + tracker_ = NULL; +} + + +// CefV8Value + +// static +CefRefPtr CefV8Value::CreateUndefined() { + CEF_V8_REQUIRE_ISOLATE_RETURN(NULL); + v8::HandleScope handle_scope; + return new CefV8ValueImpl(v8::Undefined()); +} + +// static +CefRefPtr CefV8Value::CreateNull() { + CEF_V8_REQUIRE_ISOLATE_RETURN(NULL); + v8::HandleScope handle_scope; + return new CefV8ValueImpl(v8::Null()); +} + +// static +CefRefPtr CefV8Value::CreateBool(bool value) { + CEF_V8_REQUIRE_ISOLATE_RETURN(NULL); + v8::HandleScope handle_scope; + return new CefV8ValueImpl(v8::Boolean::New(value)); +} + +// static +CefRefPtr CefV8Value::CreateInt(int32 value) { + CEF_V8_REQUIRE_ISOLATE_RETURN(NULL); + v8::HandleScope handle_scope; + return new CefV8ValueImpl(v8::Int32::New(value)); +} + +// static +CefRefPtr CefV8Value::CreateUInt(uint32 value) { + CEF_V8_REQUIRE_ISOLATE_RETURN(NULL); + v8::HandleScope handle_scope; + return new CefV8ValueImpl(v8::Int32::NewFromUnsigned(value)); +} + +// static +CefRefPtr CefV8Value::CreateDouble(double value) { + CEF_V8_REQUIRE_ISOLATE_RETURN(NULL); + v8::HandleScope handle_scope; + return new CefV8ValueImpl(v8::Number::New(value)); +} + +// static +CefRefPtr CefV8Value::CreateDate(const CefTime& date) { + CEF_V8_REQUIRE_ISOLATE_RETURN(NULL); + v8::HandleScope handle_scope; + // Convert from seconds to milliseconds. + return new CefV8ValueImpl(v8::Date::New(date.GetDoubleT() * 1000)); +} + +// static +CefRefPtr CefV8Value::CreateString(const CefString& value) { + CEF_V8_REQUIRE_ISOLATE_RETURN(NULL); + v8::HandleScope handle_scope; + return new CefV8ValueImpl(GetV8String(value)); +} + +// static +CefRefPtr CefV8Value::CreateObject( + CefRefPtr accessor) { + CEF_V8_REQUIRE_ISOLATE_RETURN(NULL); + + v8::HandleScope handle_scope; + + v8::Local context = v8::Context::GetCurrent(); + if (context.IsEmpty()) { + NOTREACHED() << "not currently in a V8 context"; + return NULL; + } + + // Create the new V8 object. + v8::Local obj = v8::Object::New(); + + // Create a tracker object that will cause the user data and/or accessor + // reference to be released when the V8 object is destroyed. + V8TrackObject* tracker = new V8TrackObject; + tracker->SetAccessor(accessor); + + // Attach the tracker object. + tracker->AttachTo(obj); + + return new CefV8ValueImpl(obj, tracker); +} + +// static +CefRefPtr CefV8Value::CreateArray(int length) { + CEF_V8_REQUIRE_ISOLATE_RETURN(NULL); + + v8::HandleScope handle_scope; + + v8::Local context = v8::Context::GetCurrent(); + if (context.IsEmpty()) { + NOTREACHED() << "not currently in a V8 context"; + return NULL; + } + + // Create a tracker object that will cause the user data reference to be + // released when the V8 object is destroyed. + V8TrackObject* tracker = new V8TrackObject; + + // Create the new V8 array. + v8::Local arr = v8::Array::New(length); + + // Attach the tracker object. + tracker->AttachTo(arr); + + return new CefV8ValueImpl(arr, tracker); +} + +// static +CefRefPtr CefV8Value::CreateFunction( + const CefString& name, + CefRefPtr handler) { + CEF_V8_REQUIRE_ISOLATE_RETURN(NULL); + + if (!handler.get()) { + NOTREACHED() << "invalid parameter"; + return NULL; + } + + v8::HandleScope handle_scope; + + v8::Local context = v8::Context::GetCurrent(); + if (context.IsEmpty()) { + NOTREACHED() << "not currently in a V8 context"; + return NULL; + } + + // Create a new V8 function template. + v8::Local tmpl = v8::FunctionTemplate::New(); + + v8::Local data = v8::External::New(handler.get()); + + // Set the function handler callback. + tmpl->SetCallHandler(FunctionCallbackImpl, data); + + // Retrieve the function object and set the name. + v8::Local func = tmpl->GetFunction(); + if (func.IsEmpty()) { + NOTREACHED() << "failed to create V8 function"; + return NULL; + } + + func->SetName(GetV8String(name)); + + // Create a tracker object that will cause the user data and/or handler + // reference to be released when the V8 object is destroyed. + V8TrackObject* tracker = new V8TrackObject; + tracker->SetHandler(handler); + + // Attach the tracker object. + tracker->AttachTo(func); + + // Create the CefV8ValueImpl and provide a tracker object that will cause + // the handler reference to be released when the V8 object is destroyed. + return new CefV8ValueImpl(func, tracker); +} + + +// CefV8ValueImpl + +CefV8ValueImpl::CefV8ValueImpl(v8::Handle value, + CefTrackNode* tracker) + : handle_(new Handle(v8::Handle(), value, tracker)), + rethrow_exceptions_(false) { +} + +CefV8ValueImpl::~CefV8ValueImpl() { +} + +bool CefV8ValueImpl::IsValid() { + return CEF_V8_IS_VALID(); +} + +bool CefV8ValueImpl::IsUndefined() { + CEF_V8_REQUIRE_VALID_RETURN(false); + return GetHandle(false)->IsUndefined(); +} + +bool CefV8ValueImpl::IsNull() { + CEF_V8_REQUIRE_VALID_RETURN(false); + return GetHandle(false)->IsNull(); +} + +bool CefV8ValueImpl::IsBool() { + CEF_V8_REQUIRE_VALID_RETURN(false); + return (GetHandle(false)->IsBoolean() || GetHandle(false)->IsTrue() || + GetHandle(false)->IsFalse()); +} + +bool CefV8ValueImpl::IsInt() { + CEF_V8_REQUIRE_VALID_RETURN(false); + return GetHandle(false)->IsInt32(); +} + +bool CefV8ValueImpl::IsUInt() { + CEF_V8_REQUIRE_VALID_RETURN(false); + return GetHandle(false)->IsUint32(); +} + +bool CefV8ValueImpl::IsDouble() { + CEF_V8_REQUIRE_VALID_RETURN(false); + return GetHandle(false)->IsNumber(); +} + +bool CefV8ValueImpl::IsDate() { + CEF_V8_REQUIRE_VALID_RETURN(false); + return GetHandle(false)->IsDate(); +} + +bool CefV8ValueImpl::IsString() { + CEF_V8_REQUIRE_VALID_RETURN(false); + return GetHandle(false)->IsString(); +} + +bool CefV8ValueImpl::IsObject() { + CEF_V8_REQUIRE_VALID_RETURN(false); + return GetHandle(false)->IsObject(); +} + +bool CefV8ValueImpl::IsArray() { + CEF_V8_REQUIRE_VALID_RETURN(false); + return GetHandle(false)->IsArray(); +} + +bool CefV8ValueImpl::IsFunction() { + CEF_V8_REQUIRE_VALID_RETURN(false); + return GetHandle(false)->IsFunction(); +} + +bool CefV8ValueImpl::IsSame(CefRefPtr that) { + CEF_V8_REQUIRE_VALID_RETURN(false); + + v8::HandleScope handle_scope; + + v8::Handle thatHandle; + v8::Handle thisHandle = GetHandle(false); + + CefV8ValueImpl* impl = static_cast(that.get()); + if (impl && impl->IsValid()) + thatHandle = impl->GetHandle(false); + + return (thisHandle == thatHandle); +} + +bool CefV8ValueImpl::GetBoolValue() { + CEF_V8_REQUIRE_VALID_RETURN(false); + if (GetHandle(false)->IsTrue()) { + return true; + } else if (GetHandle(false)->IsFalse()) { + return false; + } else { + v8::HandleScope handle_scope; + v8::Local val = GetHandle(false)->ToBoolean(); + return val->Value(); + } +} + +int32 CefV8ValueImpl::GetIntValue() { + CEF_V8_REQUIRE_VALID_RETURN(0); + v8::HandleScope handle_scope; + v8::Local val = GetHandle(false)->ToInt32(); + return val->Value(); +} + +uint32 CefV8ValueImpl::GetUIntValue() { + CEF_V8_REQUIRE_VALID_RETURN(0); + v8::HandleScope handle_scope; + v8::Local val = GetHandle(false)->ToUint32(); + return val->Value(); +} + +double CefV8ValueImpl::GetDoubleValue() { + CEF_V8_REQUIRE_VALID_RETURN(0.); + v8::HandleScope handle_scope; + v8::Local val = GetHandle(false)->ToNumber(); + return val->Value(); +} + +CefTime CefV8ValueImpl::GetDateValue() { + CEF_V8_REQUIRE_VALID_RETURN(CefTime(0.)); + v8::HandleScope handle_scope; + v8::Local val = GetHandle(false)->ToNumber(); + // Convert from milliseconds to seconds. + return CefTime(val->Value() / 1000); +} + +CefString CefV8ValueImpl::GetStringValue() { + CefString rv; + CEF_V8_REQUIRE_VALID_RETURN(rv); + v8::HandleScope handle_scope; + GetCefString(GetHandle(false)->ToString(), rv); + return rv; +} + +bool CefV8ValueImpl::IsUserCreated() { + CEF_V8_REQUIRE_OBJECT_RETURN(false); + + v8::HandleScope handle_scope; + v8::Local obj = GetHandle(false)->ToObject(); + + V8TrackObject* tracker = V8TrackObject::Unwrap(obj); + return (tracker != NULL); +} + +bool CefV8ValueImpl::HasException() { + CEF_V8_REQUIRE_OBJECT_RETURN(false); + + return (last_exception_.get() != NULL); +} + +CefRefPtr CefV8ValueImpl::GetException() { + CEF_V8_REQUIRE_OBJECT_RETURN(NULL); + + return last_exception_; +} + +bool CefV8ValueImpl::ClearException() { + CEF_V8_REQUIRE_OBJECT_RETURN(false); + + last_exception_ = NULL; + return true; +} + +bool CefV8ValueImpl::WillRethrowExceptions() { + CEF_V8_REQUIRE_OBJECT_RETURN(false); + + return rethrow_exceptions_; +} + +bool CefV8ValueImpl::SetRethrowExceptions(bool rethrow) { + CEF_V8_REQUIRE_OBJECT_RETURN(false); + + rethrow_exceptions_ = rethrow; + return true; +} + +bool CefV8ValueImpl::HasValue(const CefString& key) { + CEF_V8_REQUIRE_OBJECT_RETURN(false); + + v8::HandleScope handle_scope; + v8::Local obj = GetHandle(false)->ToObject(); + return obj->Has(GetV8String(key)); +} + +bool CefV8ValueImpl::HasValue(int index) { + CEF_V8_REQUIRE_OBJECT_RETURN(false); + + if (index < 0) { + NOTREACHED() << "invalid input parameter"; + return false; + } + + v8::HandleScope handle_scope; + v8::Local obj = GetHandle(false)->ToObject(); + return obj->Has(index); +} + +bool CefV8ValueImpl::DeleteValue(const CefString& key) { + CEF_V8_REQUIRE_OBJECT_RETURN(false); + + v8::HandleScope handle_scope; + v8::Local obj = GetHandle(false)->ToObject(); + + v8::TryCatch try_catch; + try_catch.SetVerbose(true); + bool del = obj->Delete(GetV8String(key)); + return (!HasCaught(try_catch) && del); +} + +bool CefV8ValueImpl::DeleteValue(int index) { + CEF_V8_REQUIRE_OBJECT_RETURN(false); + + if (index < 0) { + NOTREACHED() << "invalid input parameter"; + return false; + } + + v8::HandleScope handle_scope; + v8::Local obj = GetHandle(false)->ToObject(); + + v8::TryCatch try_catch; + try_catch.SetVerbose(true); + bool del = obj->Delete(index); + return (!HasCaught(try_catch) && del); +} + +CefRefPtr CefV8ValueImpl::GetValue(const CefString& key) { + CEF_V8_REQUIRE_OBJECT_RETURN(NULL); + + v8::HandleScope handle_scope; + v8::Local obj = GetHandle(false)->ToObject(); + + v8::TryCatch try_catch; + try_catch.SetVerbose(true); + v8::Local value = obj->Get(GetV8String(key)); + if (!HasCaught(try_catch) && !value.IsEmpty()) + return new CefV8ValueImpl(value); + return NULL; +} + +CefRefPtr CefV8ValueImpl::GetValue(int index) { + CEF_V8_REQUIRE_OBJECT_RETURN(NULL); + + if (index < 0) { + NOTREACHED() << "invalid input parameter"; + return NULL; + } + + v8::HandleScope handle_scope; + v8::Local obj = GetHandle(false)->ToObject(); + + v8::TryCatch try_catch; + try_catch.SetVerbose(true); + v8::Local value = obj->Get(v8::Number::New(index)); + if (!HasCaught(try_catch) && !value.IsEmpty()) + return new CefV8ValueImpl(value); + return NULL; +} + +bool CefV8ValueImpl::SetValue(const CefString& key, + CefRefPtr value, + PropertyAttribute attribute) { + CEF_V8_REQUIRE_OBJECT_RETURN(false); + + CefV8ValueImpl* impl = static_cast(value.get()); + if (impl && impl->IsValid()) { + v8::HandleScope handle_scope; + v8::Local obj = GetHandle(false)->ToObject(); + + v8::TryCatch try_catch; + try_catch.SetVerbose(true); + bool set = obj->Set(GetV8String(key), impl->GetHandle(true), + static_cast(attribute)); + return (!HasCaught(try_catch) && set); + } else { + NOTREACHED() << "invalid input parameter"; + return false; + } +} + +bool CefV8ValueImpl::SetValue(int index, CefRefPtr value) { + CEF_V8_REQUIRE_OBJECT_RETURN(false); + + if (index < 0) { + NOTREACHED() << "invalid input parameter"; + return false; + } + + CefV8ValueImpl* impl = static_cast(value.get()); + if (impl && impl->IsValid()) { + v8::HandleScope handle_scope; + v8::Local obj = GetHandle(false)->ToObject(); + + v8::TryCatch try_catch; + try_catch.SetVerbose(true); + bool set = obj->Set(index, impl->GetHandle(true)); + return (!HasCaught(try_catch) && set); + } else { + NOTREACHED() << "invalid input parameter"; + return false; + } +} + +bool CefV8ValueImpl::SetValue(const CefString& key, AccessControl settings, + PropertyAttribute attribute) { + CEF_V8_REQUIRE_OBJECT_RETURN(false); + + v8::HandleScope handle_scope; + v8::Local obj = GetHandle(false)->ToObject(); + + CefRefPtr accessorPtr; + + V8TrackObject* tracker = V8TrackObject::Unwrap(obj); + if (tracker) + accessorPtr = tracker->GetAccessor(); + + // Verify that an accessor exists for this object. + if (!accessorPtr.get()) + return false; + + v8::AccessorGetter getter = AccessorGetterCallbackImpl; + v8::AccessorSetter setter = (attribute & V8_PROPERTY_ATTRIBUTE_READONLY) ? + NULL : AccessorSetterCallbackImpl; + + v8::TryCatch try_catch; + try_catch.SetVerbose(true); + bool set = obj->SetAccessor(GetV8String(key), getter, setter, obj, + static_cast(settings), + static_cast(attribute)); + return (!HasCaught(try_catch) && set); +} + +bool CefV8ValueImpl::GetKeys(std::vector& keys) { + CEF_V8_REQUIRE_OBJECT_RETURN(false); + + v8::HandleScope handle_scope; + v8::Local obj = GetHandle(false)->ToObject(); + v8::Local arr_keys = obj->GetPropertyNames(); + uint32_t len = arr_keys->Length(); + for (uint32_t i = 0; i < len; ++i) { + v8::Local value = arr_keys->Get(v8::Integer::New(i)); + CefString str; + GetCefString(value->ToString(), str); + keys.push_back(str); + } + return true; +} + +bool CefV8ValueImpl::SetUserData(CefRefPtr user_data) { + CEF_V8_REQUIRE_OBJECT_RETURN(false); + + v8::HandleScope handle_scope; + v8::Local obj = GetHandle(false)->ToObject(); + + V8TrackObject* tracker = V8TrackObject::Unwrap(obj); + if (tracker) { + tracker->SetUserData(user_data); + return true; + } + + return false; +} + +CefRefPtr CefV8ValueImpl::GetUserData() { + CEF_V8_REQUIRE_OBJECT_RETURN(NULL); + + v8::HandleScope handle_scope; + v8::Local obj = GetHandle(false)->ToObject(); + + V8TrackObject* tracker = V8TrackObject::Unwrap(obj); + if (tracker) + return tracker->GetUserData(); + + return NULL; +} + +int CefV8ValueImpl::GetExternallyAllocatedMemory() { + CEF_V8_REQUIRE_OBJECT_RETURN(0); + + v8::HandleScope handle_scope; + v8::Local obj = GetHandle(false)->ToObject(); + + V8TrackObject* tracker = V8TrackObject::Unwrap(obj); + if (tracker) + return tracker->GetExternallyAllocatedMemory(); + + return 0; +} + +int CefV8ValueImpl::AdjustExternallyAllocatedMemory(int change_in_bytes) { + CEF_V8_REQUIRE_OBJECT_RETURN(0); + + v8::HandleScope handle_scope; + v8::Local obj = GetHandle(false)->ToObject(); + + V8TrackObject* tracker = V8TrackObject::Unwrap(obj); + if (tracker) + return tracker->AdjustExternallyAllocatedMemory(change_in_bytes); + + return 0; +} + +int CefV8ValueImpl::GetArrayLength() { + CEF_V8_REQUIRE_ARRAY_RETURN(0); + + v8::HandleScope handle_scope; + v8::Local obj = GetHandle(false)->ToObject(); + v8::Local arr = v8::Local::Cast(obj); + return arr->Length(); +} + +CefString CefV8ValueImpl::GetFunctionName() { + CefString rv; + CEF_V8_REQUIRE_FUNCTION_RETURN(rv); + + v8::HandleScope handle_scope; + v8::Local obj = GetHandle(false)->ToObject(); + v8::Local func = v8::Local::Cast(obj); + GetCefString(v8::Handle::Cast(func->GetName()), rv); + return rv; +} + +CefRefPtr CefV8ValueImpl::GetFunctionHandler() { + CEF_V8_REQUIRE_FUNCTION_RETURN(NULL); + + v8::HandleScope handle_scope; + v8::Local obj = GetHandle(false)->ToObject(); + + V8TrackObject* tracker = V8TrackObject::Unwrap(obj); + if (tracker) + return tracker->GetHandler(); + + return NULL; +} + +CefRefPtr CefV8ValueImpl::ExecuteFunction( + CefRefPtr object, + const CefV8ValueList& arguments) { + // An empty context value defaults to the current context. + CefRefPtr context; + return ExecuteFunctionWithContext(context, object, arguments); +} + +CefRefPtr CefV8ValueImpl::ExecuteFunctionWithContext( + CefRefPtr context, + CefRefPtr object, + const CefV8ValueList& arguments) { + CEF_V8_REQUIRE_FUNCTION_RETURN(NULL); + + if (context.get() && !context->IsValid()) { + NOTREACHED() << "invalid V8 context parameter"; + return NULL; + } + if (object.get() && (!object->IsValid() || !object->IsObject())) { + NOTREACHED() << "invalid V8 object parameter"; + return NULL; + } + + int argc = arguments.size(); + if (argc > 0) { + for (int i = 0; i < argc; ++i) { + if (!arguments[i].get() || !arguments[i]->IsValid()) { + NOTREACHED() << "invalid V8 arguments parameter"; + return NULL; + } + } + } + + v8::HandleScope handle_scope; + + v8::Local context_local; + if (context.get()) { + CefV8ContextImpl* context_impl = + static_cast(context.get()); + context_local = context_impl->GetContext(); + } else { + context_local = v8::Context::GetCurrent(); + } + + v8::Context::Scope context_scope(context_local); + + v8::Local obj = GetHandle(false)->ToObject(); + v8::Local func = v8::Local::Cast(obj); + v8::Handle recv; + + // Default to the global object if no object was provided. + if (object.get()) { + CefV8ValueImpl* recv_impl = static_cast(object.get()); + recv = v8::Handle::Cast(recv_impl->GetHandle(true)); + } else { + recv = context_local->Global(); + } + + v8::Handle *argv = NULL; + if (argc > 0) { + argv = new v8::Handle[argc]; + for (int i = 0; i < argc; ++i) { + argv[i] = + static_cast(arguments[i].get())->GetHandle(true); + } + } + + CefRefPtr retval; + + { + v8::TryCatch try_catch; + try_catch.SetVerbose(true); + + v8::Local func_rv = + CallV8Function(context_local, func, recv, argc, argv); + + if (!HasCaught(try_catch) && !func_rv.IsEmpty()) + retval = new CefV8ValueImpl(func_rv); + } + + if (argv) + delete [] argv; + + return retval; +} + +bool CefV8ValueImpl::HasCaught(v8::TryCatch& try_catch) { + if (try_catch.HasCaught()) { + last_exception_ = new CefV8ExceptionImpl(try_catch.Message()); + if (rethrow_exceptions_) + try_catch.ReThrow(); + return true; + } else { + if (last_exception_.get()) + last_exception_ = NULL; + return false; + } +} + + +// CefV8StackTrace + +// static +CefRefPtr CefV8StackTrace::GetCurrent(int frame_limit) { + CEF_V8_REQUIRE_ISOLATE_RETURN(NULL); + + v8::HandleScope handle_scope; + v8::Handle stackTrace = + v8::StackTrace::CurrentStackTrace( + frame_limit, v8::StackTrace::kDetailed); + if (stackTrace.IsEmpty()) + return NULL; + return new CefV8StackTraceImpl(stackTrace); +} + + +// CefV8StackTraceImpl + +CefV8StackTraceImpl::CefV8StackTraceImpl(v8::Handle handle) + : handle_(new Handle(v8::Handle(), handle)) { +} + +CefV8StackTraceImpl::~CefV8StackTraceImpl() { +} + +bool CefV8StackTraceImpl::IsValid() { + return CEF_V8_IS_VALID(); +} + +int CefV8StackTraceImpl::GetFrameCount() { + CEF_V8_REQUIRE_VALID_RETURN(0); + v8::HandleScope handle_scope; + return GetHandle()->GetFrameCount(); +} + +CefRefPtr CefV8StackTraceImpl::GetFrame(int index) { + CEF_V8_REQUIRE_VALID_RETURN(NULL); + v8::HandleScope handle_scope; + v8::Handle stackFrame = GetHandle()->GetFrame(index); + if (stackFrame.IsEmpty()) + return NULL; + return new CefV8StackFrameImpl(stackFrame); +} + + +// CefV8StackFrameImpl + +CefV8StackFrameImpl::CefV8StackFrameImpl(v8::Handle handle) + : handle_(new Handle(v8::Handle(), handle)) { +} + +CefV8StackFrameImpl::~CefV8StackFrameImpl() { +} + +bool CefV8StackFrameImpl::IsValid() { + return CEF_V8_IS_VALID(); +} + +CefString CefV8StackFrameImpl::GetScriptName() { + CefString rv; + CEF_V8_REQUIRE_VALID_RETURN(rv); + v8::HandleScope handle_scope; + GetCefString(v8::Handle::Cast(GetHandle()->GetScriptName()), rv); + return rv; +} + +CefString CefV8StackFrameImpl::GetScriptNameOrSourceURL() { + CefString rv; + CEF_V8_REQUIRE_VALID_RETURN(rv); + v8::HandleScope handle_scope; + GetCefString( + v8::Handle::Cast(GetHandle()->GetScriptNameOrSourceURL()), + rv); + return rv; +} + +CefString CefV8StackFrameImpl::GetFunctionName() { + CefString rv; + CEF_V8_REQUIRE_VALID_RETURN(rv); + v8::HandleScope handle_scope; + GetCefString( + v8::Handle::Cast(GetHandle()->GetFunctionName()), rv); + return rv; +} + +int CefV8StackFrameImpl::GetLineNumber() { + CEF_V8_REQUIRE_VALID_RETURN(0); + v8::HandleScope handle_scope; + return GetHandle()->GetLineNumber(); +} + +int CefV8StackFrameImpl::GetColumn() { + CEF_V8_REQUIRE_VALID_RETURN(0); + v8::HandleScope handle_scope; + return GetHandle()->GetColumn(); +} + +bool CefV8StackFrameImpl::IsEval() { + CEF_V8_REQUIRE_VALID_RETURN(false); + v8::HandleScope handle_scope; + return GetHandle()->IsEval(); +} + +bool CefV8StackFrameImpl::IsConstructor() { + CEF_V8_REQUIRE_VALID_RETURN(false); + v8::HandleScope handle_scope; + return GetHandle()->IsConstructor(); +} diff --git a/cef3/libcef/renderer/v8_impl.h b/cef3/libcef/renderer/v8_impl.h new file mode 100644 index 000000000..b71ba39e4 --- /dev/null +++ b/cef3/libcef/renderer/v8_impl.h @@ -0,0 +1,340 @@ +// Copyright (c) 2013 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_LIBCEF_RENDERER_V8_IMPL_H_ +#define CEF_LIBCEF_RENDERER_V8_IMPL_H_ +#pragma once + +#include + +#include "include/cef_v8.h" +#include "libcef/common/tracker.h" + +#include "v8/include/v8.h" +#include "base/location.h" +#include "base/logging.h" +#include "base/memory/ref_counted.h" +#include "base/sequenced_task_runner.h" + +class CefTrackNode; +class GURL; + +namespace WebKit { +class WebFrame; +}; + +// Call after a V8 Isolate has been created and entered for the first time. +void CefV8IsolateCreated(); + +// Call before a V8 Isolate is exited and destroyed. +void CefV8IsolateDestroyed(); + +// Call to detach all handles associated with the specified context. +void CefV8ReleaseContext(v8::Handle context); + +// Set the stack size for uncaught exceptions. +void CefV8SetUncaughtExceptionStackSize(int stack_size); + +// Set attributes associated with a WebWorker thread. +void CefV8SetWorkerAttributes(int worker_id, const GURL& worker_url); + +// Used to detach handles when the associated context is released. +class CefV8ContextState : public base::RefCounted { + public: + CefV8ContextState() : valid_(true) {} + virtual ~CefV8ContextState() {} + + bool IsValid() { return valid_; } + void Detach() { + DCHECK(valid_); + valid_ = false; + track_manager_.DeleteAll(); + } + + void AddTrackObject(CefTrackNode* object) { + DCHECK(valid_); + track_manager_.Add(object); + } + + void DeleteTrackObject(CefTrackNode* object) { + DCHECK(valid_); + track_manager_.Delete(object); + } + + private: + bool valid_; + CefTrackManager track_manager_; +}; + + +// Use this template in conjuction with RefCountedThreadSafe to ensure that a +// V8 object is deleted on the correct thread. +struct CefV8DeleteOnMessageLoopThread { + template + static void Destruct(const T* x) { + if (x->task_runner()->RunsTasksOnCurrentThread()) { + delete x; + } else { + if (!x->task_runner()->DeleteSoon(FROM_HERE, x)) { +#if defined(UNIT_TEST) + // Only logged under unit testing because leaks at shutdown + // are acceptable under normal circumstances. + LOG(ERROR) << "DeleteSoon failed on thread " << thread; +#endif // UNIT_TEST + } + } + } +}; + +// Base class for V8 Handle types. +class CefV8HandleBase : + public base::RefCountedThreadSafe { + public: + virtual ~CefV8HandleBase(); + + // Returns true if there is no underlying context or if the underlying context + // is valid. + bool IsValid() const { + return (!context_state_.get() || context_state_->IsValid()); + } + + bool BelongsToCurrentThread() const; + + v8::Isolate* isolate() const { return isolate_; } + scoped_refptr task_runner() const { + return task_runner_; + } + + protected: + // |context| is the context that owns this handle. If empty the current + // context will be used. + explicit CefV8HandleBase(v8::Handle context); + + protected: + v8::Isolate* isolate_; + scoped_refptr task_runner_; + scoped_refptr context_state_; +}; + +// Template for V8 Handle types. This class is used to ensure that V8 objects +// are only released on the render thread. +template +class CefV8Handle : public CefV8HandleBase { + public: + typedef v8::Handle handleType; + typedef v8::Persistent persistentType; + + CefV8Handle(v8::Handle context, handleType v) + : CefV8HandleBase(context), + handle_(persistentType::New(isolate(), v)) { + } + virtual ~CefV8Handle() { + handle_.Dispose(isolate()); + handle_.Clear(); + } + + handleType GetHandle() { + DCHECK(IsValid()); + return handle_; + } + + protected: + persistentType handle_; + + DISALLOW_COPY_AND_ASSIGN(CefV8Handle); +}; + +// Specialization for v8::Value with empty implementation to avoid incorrect +// usage. +template <> +class CefV8Handle { +}; + + +class CefV8ContextImpl : public CefV8Context { + public: + explicit CefV8ContextImpl(v8::Handle context); + virtual ~CefV8ContextImpl(); + + virtual CefRefPtr GetTaskRunner() OVERRIDE; + virtual bool IsValid() OVERRIDE; + virtual CefRefPtr GetBrowser() OVERRIDE; + virtual CefRefPtr GetFrame() OVERRIDE; + virtual CefRefPtr GetGlobal() OVERRIDE; + virtual bool Enter() OVERRIDE; + virtual bool Exit() OVERRIDE; + virtual bool IsSame(CefRefPtr that) OVERRIDE; + virtual bool Eval(const CefString& code, + CefRefPtr& retval, + CefRefPtr& exception) OVERRIDE; + + v8::Local GetContext(); + WebKit::WebFrame* GetWebFrame(); + + v8::Handle GetHandle() { return handle_->GetHandle(); } + + protected: + typedef CefV8Handle Handle; + scoped_refptr handle_; + +#ifndef NDEBUG + // Used in debug builds to catch missing Exits in destructor. + int enter_count_; +#endif + + IMPLEMENT_REFCOUNTING(CefV8ContextImpl); + DISALLOW_COPY_AND_ASSIGN(CefV8ContextImpl); +}; + +class CefV8ValueImpl : public CefV8Value { + public: + CefV8ValueImpl(v8::Handle value, CefTrackNode* tracker = NULL); + virtual ~CefV8ValueImpl(); + + virtual bool IsValid() OVERRIDE; + virtual bool IsUndefined() OVERRIDE; + virtual bool IsNull() OVERRIDE; + virtual bool IsBool() OVERRIDE; + virtual bool IsInt() OVERRIDE; + virtual bool IsUInt() OVERRIDE; + virtual bool IsDouble() OVERRIDE; + virtual bool IsDate() OVERRIDE; + virtual bool IsString() OVERRIDE; + virtual bool IsObject() OVERRIDE; + virtual bool IsArray() OVERRIDE; + virtual bool IsFunction() OVERRIDE; + virtual bool IsSame(CefRefPtr value) OVERRIDE; + virtual bool GetBoolValue() OVERRIDE; + virtual int32 GetIntValue() OVERRIDE; + virtual uint32 GetUIntValue() OVERRIDE; + virtual double GetDoubleValue() OVERRIDE; + virtual CefTime GetDateValue() OVERRIDE; + virtual CefString GetStringValue() OVERRIDE; + virtual bool IsUserCreated() OVERRIDE; + virtual bool HasException() OVERRIDE; + virtual CefRefPtr GetException() OVERRIDE; + virtual bool ClearException() OVERRIDE; + virtual bool WillRethrowExceptions() OVERRIDE; + virtual bool SetRethrowExceptions(bool rethrow) OVERRIDE; + virtual bool HasValue(const CefString& key) OVERRIDE; + virtual bool HasValue(int index) OVERRIDE; + virtual bool DeleteValue(const CefString& key) OVERRIDE; + virtual bool DeleteValue(int index) OVERRIDE; + virtual CefRefPtr GetValue(const CefString& key) OVERRIDE; + virtual CefRefPtr GetValue(int index) OVERRIDE; + virtual bool SetValue(const CefString& key, CefRefPtr value, + PropertyAttribute attribute) OVERRIDE; + virtual bool SetValue(int index, CefRefPtr value) OVERRIDE; + virtual bool SetValue(const CefString& key, AccessControl settings, + PropertyAttribute attribute) OVERRIDE; + virtual bool GetKeys(std::vector& keys) OVERRIDE; + virtual bool SetUserData(CefRefPtr user_data) OVERRIDE; + virtual CefRefPtr GetUserData() OVERRIDE; + virtual int GetExternallyAllocatedMemory() OVERRIDE; + virtual int AdjustExternallyAllocatedMemory(int change_in_bytes) OVERRIDE; + virtual int GetArrayLength() OVERRIDE; + virtual CefString GetFunctionName() OVERRIDE; + virtual CefRefPtr GetFunctionHandler() OVERRIDE; + virtual CefRefPtr ExecuteFunction( + CefRefPtr object, + const CefV8ValueList& arguments) OVERRIDE; + virtual CefRefPtr ExecuteFunctionWithContext( + CefRefPtr context, + CefRefPtr object, + const CefV8ValueList& arguments) OVERRIDE; + + v8::Handle GetHandle(bool should_persist) { + return handle_->GetHandle(should_persist); + } + + protected: + // Test for and record any exception. + bool HasCaught(v8::TryCatch& try_catch); + + class Handle : public CefV8HandleBase { + public: + typedef v8::Handle handleType; + typedef v8::Persistent persistentType; + + Handle(v8::Handle context, handleType v, CefTrackNode* tracker) + : CefV8HandleBase(context), + handle_(persistentType::New(isolate(), v)), + tracker_(tracker), + should_persist_(false) { + } + virtual ~Handle(); + + handleType GetHandle(bool should_persist) { + DCHECK(IsValid()); + if (should_persist && !should_persist_) + should_persist_ = true; + return handle_; + } + + private: + persistentType handle_; + + // For Object and Function types, we need to hold on to a reference to their + // internal data or function handler objects that are reference counted. + CefTrackNode* tracker_; + + // True if the handle needs to persist due to it being passed into V8. + bool should_persist_; + + DISALLOW_COPY_AND_ASSIGN(Handle); + }; + scoped_refptr handle_; + + CefRefPtr last_exception_; + bool rethrow_exceptions_; + + IMPLEMENT_REFCOUNTING(CefV8ValueImpl); + DISALLOW_COPY_AND_ASSIGN(CefV8ValueImpl); +}; + +class CefV8StackTraceImpl : public CefV8StackTrace { + public: + explicit CefV8StackTraceImpl(v8::Handle handle); + virtual ~CefV8StackTraceImpl(); + + virtual bool IsValid() OVERRIDE; + virtual int GetFrameCount() OVERRIDE; + virtual CefRefPtr GetFrame(int index) OVERRIDE; + + v8::Handle GetHandle() { return handle_->GetHandle(); } + + protected: + typedef CefV8Handle Handle; + scoped_refptr handle_; + + IMPLEMENT_REFCOUNTING(CefV8StackTraceImpl); + DISALLOW_COPY_AND_ASSIGN(CefV8StackTraceImpl); +}; + +class CefV8StackFrameImpl : public CefV8StackFrame { + public: + explicit CefV8StackFrameImpl(v8::Handle handle); + virtual ~CefV8StackFrameImpl(); + + virtual bool IsValid() OVERRIDE; + virtual CefString GetScriptName() OVERRIDE; + virtual CefString GetScriptNameOrSourceURL() OVERRIDE; + virtual CefString GetFunctionName() OVERRIDE; + virtual int GetLineNumber() OVERRIDE; + virtual int GetColumn() OVERRIDE; + virtual bool IsEval() OVERRIDE; + virtual bool IsConstructor() OVERRIDE; + + v8::Handle GetHandle() { return handle_->GetHandle(); } + + protected: + typedef CefV8Handle Handle; + scoped_refptr handle_; + + IMPLEMENT_REFCOUNTING(CefV8StackFrameImpl); + DISALLOW_COPY_AND_ASSIGN(CefV8StackFrameImpl); +}; + +#endif // CEF_LIBCEF_RENDERER_V8_IMPL_H_ diff --git a/cef3/libcef/renderer/webkit_glue.cc b/cef3/libcef/renderer/webkit_glue.cc new file mode 100644 index 000000000..d7f69915e --- /dev/null +++ b/cef3/libcef/renderer/webkit_glue.cc @@ -0,0 +1,40 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 The Chromium 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 "libcef/renderer/webkit_glue.h" + +#include "base/compiler_specific.h" + +#include "third_party/WebKit/Source/WebCore/config.h" +MSVC_PUSH_WARNING_LEVEL(0); +#include "Page.h" +#include "ScriptController.h" +#include "third_party/WebKit/Source/WebKit/chromium/src/WebFrameImpl.h" +#include "third_party/WebKit/Source/WebKit/chromium/src/WebViewImpl.h" +MSVC_POP_WARNING(); +#undef LOG + +namespace webkit_glue { + +bool CanGoBackOrForward(WebKit::WebView* view, int distance) { + if (!view) + return false; + WebKit::WebViewImpl* impl = reinterpret_cast(view); + return impl->page()->canGoBackOrForward(distance); +} + +void GoBackOrForward(WebKit::WebView* view, int distance) { + if (!view) + return; + WebKit::WebViewImpl* impl = reinterpret_cast(view); + impl->page()->goBackOrForward(distance); +} + +v8::Handle GetV8Context(WebKit::WebFrame* frame) { + WebKit::WebFrameImpl* impl = static_cast(frame); + return WebCore::ScriptController::mainWorldContext(impl->frame()); +} + +} // webkit_glue diff --git a/cef3/libcef/renderer/webkit_glue.h b/cef3/libcef/renderer/webkit_glue.h new file mode 100644 index 000000000..73107f587 --- /dev/null +++ b/cef3/libcef/renderer/webkit_glue.h @@ -0,0 +1,27 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 The Chromium 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_LIBCEF_RENDERER_WEBKIT_GLUE_H_ +#define CEF_LIBCEF_RENDERER_WEBKIT_GLUE_H_ + +#include +#include "v8/include/v8.h" + +namespace WebKit { +class WebFrame; +class WebView; +} + +namespace webkit_glue { + +bool CanGoBackOrForward(WebKit::WebView* view, int distance); +void GoBackOrForward(WebKit::WebView* view, int distance); + +// Retrieve the V8 context associated with the frame. +v8::Handle GetV8Context(WebKit::WebFrame* frame); + +} // webkit_glue + +#endif // CEF_LIBCEF_RENDERER_WEBKIT_GLUE_H_ diff --git a/cef3/libcef/resources/about_version.html b/cef3/libcef/resources/about_version.html new file mode 100644 index 000000000..873957512 --- /dev/null +++ b/cef3/libcef/resources/about_version.html @@ -0,0 +1,123 @@ + + + + + + + About Version + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CEF$$CEF$$
Chromium$$CHROMIUM$$
OS$$OS$$
WebKit$$WEBKIT$$
JavaScript$$JAVASCRIPT$$
Flash$$FLASH$$
User Agent$$USERAGENT$$
Command Line$$COMMANDLINE$$
Module Path$$MODULEPATH$$
Cache Path$$CACHEPATH$$
+
+ + + + diff --git a/cef3/libcef/resources/cef_resources.grd b/cef3/libcef/resources/cef_resources.grd new file mode 100644 index 000000000..f93cfefc2 --- /dev/null +++ b/cef3/libcef/resources/cef_resources.grd @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/cef3/libcef/resources/cef_strings.grd b/cef3/libcef/resources/cef_strings.grd new file mode 100644 index 000000000..7f6fc8c63 --- /dev/null +++ b/cef3/libcef/resources/cef_strings.grd @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + &Back + + + &Forward + + + &Reload + + + Reload no cache + + + &Stop + + + &Undo + + + &Redo + + + Cu&t + + + &Copy + + + &Paste + + + &Delete + + + Select &all + + + &Find... + + + &Print... + + + View Source... + + + Audio Files + + + Image Files + + + Text Files + + + Video Files + + + + diff --git a/cef3/libcef/resources/devtools_discovery_page.html b/cef3/libcef/resources/devtools_discovery_page.html new file mode 100644 index 000000000..87933d1af --- /dev/null +++ b/cef3/libcef/resources/devtools_discovery_page.html @@ -0,0 +1,54 @@ + + +CEF remote debugging + + + + + +
Inspectable WebContents
+
+ + diff --git a/cef3/libcef_dll/cef_logging.h b/cef3/libcef_dll/cef_logging.h new file mode 100644 index 000000000..5d28a004e --- /dev/null +++ b/cef3/libcef_dll/cef_logging.h @@ -0,0 +1,22 @@ +// Copyright (c) 2009 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_LIBCEF_DLL_CEF_LOGGING_H_ +#define CEF_LIBCEF_DLL_CEF_LOGGING_H_ +#pragma once + +#ifdef BUILDING_CEF_SHARED +#include "base/logging.h" +#else +#include // NOLINT(build/include_order) +#define DCHECK(condition) assert(condition) +#define DCHECK_EQ(val1, val2) DCHECK(val1 == val2) +#define DCHECK_NE(val1, val2) DCHECK(val1 != val2) +#define DCHECK_LE(val1, val2) DCHECK(val1 <= val2) +#define DCHECK_LT(val1, val2) DCHECK(val1 < val2) +#define DCHECK_GE(val1, val2) DCHECK(val1 >= val2) +#define DCHECK_GT(val1, val2) DCHECK(val1 > val2) +#endif + +#endif // CEF_LIBCEF_DLL_CEF_LOGGING_H_ diff --git a/cef3/libcef_dll/cpptoc/allow_certificate_error_callback_cpptoc.cc b/cef3/libcef_dll/cpptoc/allow_certificate_error_callback_cpptoc.cc new file mode 100644 index 000000000..8d6adfb57 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/allow_certificate_error_callback_cpptoc.cc @@ -0,0 +1,47 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/allow_certificate_error_callback_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK allow_certificate_error_callback_cont( + struct _cef_allow_certificate_error_callback_t* self, int allow) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefAllowCertificateErrorCallbackCppToC::Get(self)->Continue( + allow?true:false); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefAllowCertificateErrorCallbackCppToC::CefAllowCertificateErrorCallbackCppToC( + CefAllowCertificateErrorCallback* cls) + : CefCppToC(cls) { + struct_.struct_.cont = allow_certificate_error_callback_cont; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/allow_certificate_error_callback_cpptoc.h b/cef3/libcef_dll/cpptoc/allow_certificate_error_callback_cpptoc.h new file mode 100644 index 000000000..2d47ac2dd --- /dev/null +++ b/cef3/libcef_dll/cpptoc/allow_certificate_error_callback_cpptoc.h @@ -0,0 +1,39 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_ALLOW_CERTIFICATE_ERROR_CALLBACK_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_ALLOW_CERTIFICATE_ERROR_CALLBACK_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_request_handler.h" +#include "include/capi/cef_request_handler_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefAllowCertificateErrorCallbackCppToC + : public CefCppToC { + public: + explicit CefAllowCertificateErrorCallbackCppToC( + CefAllowCertificateErrorCallback* cls); + virtual ~CefAllowCertificateErrorCallbackCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_ALLOW_CERTIFICATE_ERROR_CALLBACK_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/app_cpptoc.cc b/cef3/libcef_dll/cpptoc/app_cpptoc.cc new file mode 100644 index 000000000..5973f0f6b --- /dev/null +++ b/cef3/libcef_dll/cpptoc/app_cpptoc.cc @@ -0,0 +1,124 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/app_cpptoc.h" +#include "libcef_dll/cpptoc/browser_process_handler_cpptoc.h" +#include "libcef_dll/cpptoc/render_process_handler_cpptoc.h" +#include "libcef_dll/cpptoc/resource_bundle_handler_cpptoc.h" +#include "libcef_dll/ctocpp/command_line_ctocpp.h" +#include "libcef_dll/ctocpp/scheme_registrar_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK app_on_before_command_line_processing(struct _cef_app_t* self, + const cef_string_t* process_type, + struct _cef_command_line_t* command_line) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: command_line; type: refptr_diff + DCHECK(command_line); + if (!command_line) + return; + // Unverified params: process_type + + // Execute + CefAppCppToC::Get(self)->OnBeforeCommandLineProcessing( + CefString(process_type), + CefCommandLineCToCpp::Wrap(command_line)); +} + +void CEF_CALLBACK app_on_register_custom_schemes(struct _cef_app_t* self, + struct _cef_scheme_registrar_t* registrar) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: registrar; type: refptr_diff + DCHECK(registrar); + if (!registrar) + return; + + // Execute + CefAppCppToC::Get(self)->OnRegisterCustomSchemes( + CefSchemeRegistrarCToCpp::Wrap(registrar)); +} + +struct _cef_resource_bundle_handler_t* CEF_CALLBACK app_get_resource_bundle_handler( + struct _cef_app_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefAppCppToC::Get( + self)->GetResourceBundleHandler(); + + // Return type: refptr_same + return CefResourceBundleHandlerCppToC::Wrap(_retval); +} + +struct _cef_browser_process_handler_t* CEF_CALLBACK app_get_browser_process_handler( + struct _cef_app_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefAppCppToC::Get( + self)->GetBrowserProcessHandler(); + + // Return type: refptr_same + return CefBrowserProcessHandlerCppToC::Wrap(_retval); +} + +struct _cef_render_process_handler_t* CEF_CALLBACK app_get_render_process_handler( + struct _cef_app_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefAppCppToC::Get( + self)->GetRenderProcessHandler(); + + // Return type: refptr_same + return CefRenderProcessHandlerCppToC::Wrap(_retval); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefAppCppToC::CefAppCppToC(CefApp* cls) + : CefCppToC(cls) { + struct_.struct_.on_before_command_line_processing = + app_on_before_command_line_processing; + struct_.struct_.on_register_custom_schemes = app_on_register_custom_schemes; + struct_.struct_.get_resource_bundle_handler = app_get_resource_bundle_handler; + struct_.struct_.get_browser_process_handler = app_get_browser_process_handler; + struct_.struct_.get_render_process_handler = app_get_render_process_handler; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/app_cpptoc.h b/cef3/libcef_dll/cpptoc/app_cpptoc.h new file mode 100644 index 000000000..3daad00fc --- /dev/null +++ b/cef3/libcef_dll/cpptoc/app_cpptoc.h @@ -0,0 +1,36 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_APP_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_APP_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_app.h" +#include "include/capi/cef_app_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefAppCppToC + : public CefCppToC { + public: + explicit CefAppCppToC(CefApp* cls); + virtual ~CefAppCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_APP_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/auth_callback_cpptoc.cc b/cef3/libcef_dll/cpptoc/auth_callback_cpptoc.cc new file mode 100644 index 000000000..cd40410e9 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/auth_callback_cpptoc.cc @@ -0,0 +1,65 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/auth_callback_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK auth_callback_cont(struct _cef_auth_callback_t* self, + const cef_string_t* username, const cef_string_t* password) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: username; type: string_byref_const + DCHECK(username); + if (!username) + return; + // Verify param: password; type: string_byref_const + DCHECK(password); + if (!password) + return; + + // Execute + CefAuthCallbackCppToC::Get(self)->Continue( + CefString(username), + CefString(password)); +} + +void CEF_CALLBACK auth_callback_cancel(struct _cef_auth_callback_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefAuthCallbackCppToC::Get(self)->Cancel(); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefAuthCallbackCppToC::CefAuthCallbackCppToC(CefAuthCallback* cls) + : CefCppToC( + cls) { + struct_.struct_.cont = auth_callback_cont; + struct_.struct_.cancel = auth_callback_cancel; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/auth_callback_cpptoc.h b/cef3/libcef_dll/cpptoc/auth_callback_cpptoc.h new file mode 100644 index 000000000..ba5ebdbe1 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/auth_callback_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_AUTH_CALLBACK_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_AUTH_CALLBACK_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_request_handler.h" +#include "include/capi/cef_request_handler_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefAuthCallbackCppToC + : public CefCppToC { + public: + explicit CefAuthCallbackCppToC(CefAuthCallback* cls); + virtual ~CefAuthCallbackCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_AUTH_CALLBACK_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/base_cpptoc.h b/cef3/libcef_dll/cpptoc/base_cpptoc.h new file mode 100644 index 000000000..1184d718a --- /dev/null +++ b/cef3/libcef_dll/cpptoc/base_cpptoc.h @@ -0,0 +1,146 @@ +// Copyright (c) 2009 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_LIBCEF_DLL_CPPTOC_BASE_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_BASE_CPPTOC_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/capi/cef_base_capi.h" +#include "libcef_dll/cef_logging.h" + + +// CefCppToC implementation for CefBase. +class CefBaseCppToC : public CefBase { + public: + // Use this method to retrieve the underlying class instance from our + // own structure when the structure is passed as the required first + // parameter of a C API function call. No explicit reference counting + // is done in this case. + static CefRefPtr Get(cef_base_t* s) { + DCHECK(s); + + // Cast our structure to the wrapper structure type. + CefBaseCppToC::Struct* wrapperStruct = + reinterpret_cast(s); + // Return the underlying object instance. + return wrapperStruct->class_->GetClass(); + } + + // Use this method to create a wrapper structure for passing our class + // instance to the other side. + static cef_base_t* Wrap(CefRefPtr c) { + if (!c.get()) + return NULL; + + // Wrap our object with the CefCppToC class. + CefBaseCppToC* wrapper = new CefBaseCppToC(c); + // Add a reference to our wrapper object that will be released once our + // structure arrives on the other side. + wrapper->AddRef(); + // Return the structure pointer that can now be passed to the other side. + return wrapper->GetStruct(); + } + + // Use this method to retrieve the underlying class instance when receiving + // our wrapper structure back from the other side. + static CefRefPtr Unwrap(cef_base_t* s) { + if (!s) + return NULL; + + // Cast our structure to the wrapper structure type. + CefBaseCppToC::Struct* wrapperStruct = + reinterpret_cast(s); + // Add the underlying object instance to a smart pointer. + CefRefPtr objectPtr(wrapperStruct->class_->GetClass()); + // Release the reference to our wrapper object that was added before the + // structure was passed back to us. + wrapperStruct->class_->Release(); + // Return the underlying object instance. + return objectPtr; + } + + // Structure representation with pointer to the C++ class. + struct Struct { + cef_base_t struct_; + CefBaseCppToC* class_; + }; + + explicit CefBaseCppToC(CefBase* cls) + : class_(cls) { + DCHECK(cls); + + struct_.class_ = this; + + // zero the underlying structure and set base members + memset(&struct_.struct_, 0, sizeof(cef_base_t)); + struct_.struct_.size = sizeof(cef_base_t); + struct_.struct_.add_ref = struct_add_ref; + struct_.struct_.release = struct_release; + struct_.struct_.get_refct = struct_get_refct; + } + virtual ~CefBaseCppToC() {} + + CefBase* GetClass() { return class_; } + + // If returning the structure across the DLL boundary you should call + // AddRef() on this CefCppToC object. On the other side of the DLL boundary, + // call UnderlyingRelease() on the wrapping CefCToCpp object. + cef_base_t* GetStruct() { return &struct_.struct_; } + + // CefBase methods increment/decrement reference counts on both this object + // and the underlying wrapper class. + int AddRef() { + UnderlyingAddRef(); + return refct_.AddRef(); + } + int Release() { + UnderlyingRelease(); + int retval = refct_.Release(); + if (retval == 0) + delete this; + return retval; + } + int GetRefCt() { return refct_.GetRefCt(); } + + // Increment/decrement reference counts on only the underlying class. + int UnderlyingAddRef() { return class_->AddRef(); } + int UnderlyingRelease() { return class_->Release(); } + int UnderlyingGetRefCt() { return class_->GetRefCt(); } + + private: + static int CEF_CALLBACK struct_add_ref(struct _cef_base_t* base) { + DCHECK(base); + if (!base) + return 0; + + Struct* impl = reinterpret_cast(base); + return impl->class_->AddRef(); + } + + static int CEF_CALLBACK struct_release(struct _cef_base_t* base) { + DCHECK(base); + if (!base) + return 0; + + Struct* impl = reinterpret_cast(base); + return impl->class_->Release(); + } + + static int CEF_CALLBACK struct_get_refct(struct _cef_base_t* base) { + DCHECK(base); + if (!base) + return 0; + + Struct* impl = reinterpret_cast(base); + return impl->class_->GetRefCt(); + } + + protected: + CefRefCount refct_; + Struct struct_; + CefBase* class_; +}; + +#endif // CEF_LIBCEF_DLL_CPPTOC_BASE_CPPTOC_H_ diff --git a/cef3/libcef_dll/cpptoc/before_download_callback_cpptoc.cc b/cef3/libcef_dll/cpptoc/before_download_callback_cpptoc.cc new file mode 100644 index 000000000..048128423 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/before_download_callback_cpptoc.cc @@ -0,0 +1,49 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/before_download_callback_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK before_download_callback_cont( + struct _cef_before_download_callback_t* self, + const cef_string_t* download_path, int show_dialog) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Unverified params: download_path + + // Execute + CefBeforeDownloadCallbackCppToC::Get(self)->Continue( + CefString(download_path), + show_dialog?true:false); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefBeforeDownloadCallbackCppToC::CefBeforeDownloadCallbackCppToC( + CefBeforeDownloadCallback* cls) + : CefCppToC(cls) { + struct_.struct_.cont = before_download_callback_cont; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = + 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/before_download_callback_cpptoc.h b/cef3/libcef_dll/cpptoc/before_download_callback_cpptoc.h new file mode 100644 index 000000000..b430fe0ae --- /dev/null +++ b/cef3/libcef_dll/cpptoc/before_download_callback_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_BEFORE_DOWNLOAD_CALLBACK_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_BEFORE_DOWNLOAD_CALLBACK_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_download_handler.h" +#include "include/capi/cef_download_handler_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefBeforeDownloadCallbackCppToC + : public CefCppToC { + public: + explicit CefBeforeDownloadCallbackCppToC(CefBeforeDownloadCallback* cls); + virtual ~CefBeforeDownloadCallbackCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_BEFORE_DOWNLOAD_CALLBACK_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/binary_value_cpptoc.cc b/cef3/libcef_dll/cpptoc/binary_value_cpptoc.cc new file mode 100644 index 000000000..c4f1e53e7 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/binary_value_cpptoc.cc @@ -0,0 +1,134 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/binary_value_cpptoc.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_binary_value_t* cef_binary_value_create(const void* data, + size_t data_size) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: data; type: simple_byaddr + DCHECK(data); + if (!data) + return NULL; + + // Execute + CefRefPtr _retval = CefBinaryValue::Create( + data, + data_size); + + // Return type: refptr_same + return CefBinaryValueCppToC::Wrap(_retval); +} + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK binary_value_is_valid(struct _cef_binary_value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefBinaryValueCppToC::Get(self)->IsValid(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK binary_value_is_owned(struct _cef_binary_value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefBinaryValueCppToC::Get(self)->IsOwned(); + + // Return type: bool + return _retval; +} + +struct _cef_binary_value_t* CEF_CALLBACK binary_value_copy( + struct _cef_binary_value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefBinaryValueCppToC::Get(self)->Copy(); + + // Return type: refptr_same + return CefBinaryValueCppToC::Wrap(_retval); +} + +size_t CEF_CALLBACK binary_value_get_size(struct _cef_binary_value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + size_t _retval = CefBinaryValueCppToC::Get(self)->GetSize(); + + // Return type: simple + return _retval; +} + +size_t CEF_CALLBACK binary_value_get_data(struct _cef_binary_value_t* self, + void* buffer, size_t buffer_size, size_t data_offset) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: buffer; type: simple_byaddr + DCHECK(buffer); + if (!buffer) + return 0; + + // Execute + size_t _retval = CefBinaryValueCppToC::Get(self)->GetData( + buffer, + buffer_size, + data_offset); + + // Return type: simple + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefBinaryValueCppToC::CefBinaryValueCppToC(CefBinaryValue* cls) + : CefCppToC(cls) { + struct_.struct_.is_valid = binary_value_is_valid; + struct_.struct_.is_owned = binary_value_is_owned; + struct_.struct_.copy = binary_value_copy; + struct_.struct_.get_size = binary_value_get_size; + struct_.struct_.get_data = binary_value_get_data; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/binary_value_cpptoc.h b/cef3/libcef_dll/cpptoc/binary_value_cpptoc.h new file mode 100644 index 000000000..8db176b2d --- /dev/null +++ b/cef3/libcef_dll/cpptoc/binary_value_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_BINARY_VALUE_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_BINARY_VALUE_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_values.h" +#include "include/capi/cef_values_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefBinaryValueCppToC + : public CefCppToC { + public: + explicit CefBinaryValueCppToC(CefBinaryValue* cls); + virtual ~CefBinaryValueCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_BINARY_VALUE_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/browser_cpptoc.cc b/cef3/libcef_dll/cpptoc/browser_cpptoc.cc new file mode 100644 index 000000000..398ea1355 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/browser_cpptoc.cc @@ -0,0 +1,390 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/cpptoc/browser_host_cpptoc.h" +#include "libcef_dll/cpptoc/frame_cpptoc.h" +#include "libcef_dll/cpptoc/process_message_cpptoc.h" +#include "libcef_dll/transfer_util.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +struct _cef_browser_host_t* CEF_CALLBACK browser_get_host( + struct _cef_browser_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefBrowserCppToC::Get(self)->GetHost(); + + // Return type: refptr_same + return CefBrowserHostCppToC::Wrap(_retval); +} + +int CEF_CALLBACK browser_can_go_back(struct _cef_browser_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefBrowserCppToC::Get(self)->CanGoBack(); + + // Return type: bool + return _retval; +} + +void CEF_CALLBACK browser_go_back(struct _cef_browser_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefBrowserCppToC::Get(self)->GoBack(); +} + +int CEF_CALLBACK browser_can_go_forward(struct _cef_browser_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefBrowserCppToC::Get(self)->CanGoForward(); + + // Return type: bool + return _retval; +} + +void CEF_CALLBACK browser_go_forward(struct _cef_browser_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefBrowserCppToC::Get(self)->GoForward(); +} + +int CEF_CALLBACK browser_is_loading(struct _cef_browser_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefBrowserCppToC::Get(self)->IsLoading(); + + // Return type: bool + return _retval; +} + +void CEF_CALLBACK browser_reload(struct _cef_browser_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefBrowserCppToC::Get(self)->Reload(); +} + +void CEF_CALLBACK browser_reload_ignore_cache(struct _cef_browser_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefBrowserCppToC::Get(self)->ReloadIgnoreCache(); +} + +void CEF_CALLBACK browser_stop_load(struct _cef_browser_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefBrowserCppToC::Get(self)->StopLoad(); +} + +int CEF_CALLBACK browser_get_identifier(struct _cef_browser_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefBrowserCppToC::Get(self)->GetIdentifier(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK browser_is_same(struct _cef_browser_t* self, + struct _cef_browser_t* that) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: that; type: refptr_same + DCHECK(that); + if (!that) + return 0; + + // Execute + bool _retval = CefBrowserCppToC::Get(self)->IsSame( + CefBrowserCppToC::Unwrap(that)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK browser_is_popup(struct _cef_browser_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefBrowserCppToC::Get(self)->IsPopup(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK browser_has_document(struct _cef_browser_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefBrowserCppToC::Get(self)->HasDocument(); + + // Return type: bool + return _retval; +} + +struct _cef_frame_t* CEF_CALLBACK browser_get_main_frame( + struct _cef_browser_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefBrowserCppToC::Get(self)->GetMainFrame(); + + // Return type: refptr_same + return CefFrameCppToC::Wrap(_retval); +} + +struct _cef_frame_t* CEF_CALLBACK browser_get_focused_frame( + struct _cef_browser_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefBrowserCppToC::Get(self)->GetFocusedFrame(); + + // Return type: refptr_same + return CefFrameCppToC::Wrap(_retval); +} + +struct _cef_frame_t* CEF_CALLBACK browser_get_frame_byident( + struct _cef_browser_t* self, int64 identifier) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefBrowserCppToC::Get(self)->GetFrame( + identifier); + + // Return type: refptr_same + return CefFrameCppToC::Wrap(_retval); +} + +struct _cef_frame_t* CEF_CALLBACK browser_get_frame(struct _cef_browser_t* self, + const cef_string_t* name) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: name; type: string_byref_const + DCHECK(name); + if (!name) + return NULL; + + // Execute + CefRefPtr _retval = CefBrowserCppToC::Get(self)->GetFrame( + CefString(name)); + + // Return type: refptr_same + return CefFrameCppToC::Wrap(_retval); +} + +size_t CEF_CALLBACK browser_get_frame_count(struct _cef_browser_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + size_t _retval = CefBrowserCppToC::Get(self)->GetFrameCount(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK browser_get_frame_identifiers(struct _cef_browser_t* self, + size_t* identifiersCount, int64* identifiers) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: identifiers; type: simple_vec_byref + DCHECK(identifiersCount && (*identifiersCount == 0 || identifiers)); + if (!identifiersCount || (*identifiersCount > 0 && !identifiers)) + return; + + // Translate param: identifiers; type: simple_vec_byref + std::vector identifiersList; + if (identifiersCount && *identifiersCount > 0 && identifiers) { + for (size_t i = 0; i < *identifiersCount; ++i) { + identifiersList.push_back(identifiers[i]); + } + } + + // Execute + CefBrowserCppToC::Get(self)->GetFrameIdentifiers( + identifiersList); + + // Restore param: identifiers; type: simple_vec_byref + if (identifiersCount && identifiers) { + *identifiersCount = std::min(identifiersList.size(), *identifiersCount); + if (*identifiersCount > 0) { + for (size_t i = 0; i < *identifiersCount; ++i) { + identifiers[i] = identifiersList[i]; + } + } + } +} + +void CEF_CALLBACK browser_get_frame_names(struct _cef_browser_t* self, + cef_string_list_t names) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: names; type: string_vec_byref + DCHECK(names); + if (!names) + return; + + // Translate param: names; type: string_vec_byref + std::vector namesList; + transfer_string_list_contents(names, namesList); + + // Execute + CefBrowserCppToC::Get(self)->GetFrameNames( + namesList); + + // Restore param: names; type: string_vec_byref + cef_string_list_clear(names); + transfer_string_list_contents(namesList, names); +} + +int CEF_CALLBACK browser_send_process_message(struct _cef_browser_t* self, + enum cef_process_id_t target_process, + struct _cef_process_message_t* message) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: message; type: refptr_same + DCHECK(message); + if (!message) + return 0; + + // Execute + bool _retval = CefBrowserCppToC::Get(self)->SendProcessMessage( + target_process, + CefProcessMessageCppToC::Unwrap(message)); + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefBrowserCppToC::CefBrowserCppToC(CefBrowser* cls) + : CefCppToC(cls) { + struct_.struct_.get_host = browser_get_host; + struct_.struct_.can_go_back = browser_can_go_back; + struct_.struct_.go_back = browser_go_back; + struct_.struct_.can_go_forward = browser_can_go_forward; + struct_.struct_.go_forward = browser_go_forward; + struct_.struct_.is_loading = browser_is_loading; + struct_.struct_.reload = browser_reload; + struct_.struct_.reload_ignore_cache = browser_reload_ignore_cache; + struct_.struct_.stop_load = browser_stop_load; + struct_.struct_.get_identifier = browser_get_identifier; + struct_.struct_.is_same = browser_is_same; + struct_.struct_.is_popup = browser_is_popup; + struct_.struct_.has_document = browser_has_document; + struct_.struct_.get_main_frame = browser_get_main_frame; + struct_.struct_.get_focused_frame = browser_get_focused_frame; + struct_.struct_.get_frame_byident = browser_get_frame_byident; + struct_.struct_.get_frame = browser_get_frame; + struct_.struct_.get_frame_count = browser_get_frame_count; + struct_.struct_.get_frame_identifiers = browser_get_frame_identifiers; + struct_.struct_.get_frame_names = browser_get_frame_names; + struct_.struct_.send_process_message = browser_send_process_message; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/browser_cpptoc.h b/cef3/libcef_dll/cpptoc/browser_cpptoc.h new file mode 100644 index 000000000..2a6d25dcb --- /dev/null +++ b/cef3/libcef_dll/cpptoc/browser_cpptoc.h @@ -0,0 +1,38 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_BROWSER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_BROWSER_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_browser.h" +#include "include/capi/cef_browser_capi.h" +#include "include/cef_client.h" +#include "include/capi/cef_client_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefBrowserCppToC + : public CefCppToC { + public: + explicit CefBrowserCppToC(CefBrowser* cls); + virtual ~CefBrowserCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_BROWSER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/browser_host_cpptoc.cc b/cef3/libcef_dll/cpptoc/browser_host_cpptoc.cc new file mode 100644 index 000000000..fc4db80d8 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/browser_host_cpptoc.cc @@ -0,0 +1,535 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/cpptoc/browser_host_cpptoc.h" +#include "libcef_dll/ctocpp/client_ctocpp.h" +#include "libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT int cef_browser_host_create_browser( + const cef_window_info_t* windowInfo, struct _cef_client_t* client, + const cef_string_t* url, const struct _cef_browser_settings_t* settings) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: windowInfo; type: struct_byref_const + DCHECK(windowInfo); + if (!windowInfo) + return 0; + // Verify param: settings; type: struct_byref_const + DCHECK(settings); + if (!settings) + return 0; + // Unverified params: client, url + + // Translate param: windowInfo; type: struct_byref_const + CefWindowInfo windowInfoObj; + if (windowInfo) + windowInfoObj.Set(*windowInfo, false); + // Translate param: settings; type: struct_byref_const + CefBrowserSettings settingsObj; + if (settings) + settingsObj.Set(*settings, false); + + // Execute + bool _retval = CefBrowserHost::CreateBrowser( + windowInfoObj, + CefClientCToCpp::Wrap(client), + CefString(url), + settingsObj); + + // Return type: bool + return _retval; +} + +CEF_EXPORT cef_browser_t* cef_browser_host_create_browser_sync( + const cef_window_info_t* windowInfo, struct _cef_client_t* client, + const cef_string_t* url, const struct _cef_browser_settings_t* settings) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: windowInfo; type: struct_byref_const + DCHECK(windowInfo); + if (!windowInfo) + return NULL; + // Verify param: settings; type: struct_byref_const + DCHECK(settings); + if (!settings) + return NULL; + // Unverified params: client, url + + // Translate param: windowInfo; type: struct_byref_const + CefWindowInfo windowInfoObj; + if (windowInfo) + windowInfoObj.Set(*windowInfo, false); + // Translate param: settings; type: struct_byref_const + CefBrowserSettings settingsObj; + if (settings) + settingsObj.Set(*settings, false); + + // Execute + CefRefPtr _retval = CefBrowserHost::CreateBrowserSync( + windowInfoObj, + CefClientCToCpp::Wrap(client), + CefString(url), + settingsObj); + + // Return type: refptr_same + return CefBrowserCppToC::Wrap(_retval); +} + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +cef_browser_t* CEF_CALLBACK browser_host_get_browser( + struct _cef_browser_host_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefBrowserHostCppToC::Get(self)->GetBrowser(); + + // Return type: refptr_same + return CefBrowserCppToC::Wrap(_retval); +} + +void CEF_CALLBACK browser_host_parent_window_will_close( + struct _cef_browser_host_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefBrowserHostCppToC::Get(self)->ParentWindowWillClose(); +} + +void CEF_CALLBACK browser_host_close_browser(struct _cef_browser_host_t* self, + int force_close) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefBrowserHostCppToC::Get(self)->CloseBrowser( + force_close?true:false); +} + +void CEF_CALLBACK browser_host_set_focus(struct _cef_browser_host_t* self, + int enable) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefBrowserHostCppToC::Get(self)->SetFocus( + enable?true:false); +} + +cef_window_handle_t CEF_CALLBACK browser_host_get_window_handle( + struct _cef_browser_host_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + cef_window_handle_t _retval = CefBrowserHostCppToC::Get( + self)->GetWindowHandle(); + + // Return type: simple + return _retval; +} + +cef_window_handle_t CEF_CALLBACK browser_host_get_opener_window_handle( + struct _cef_browser_host_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + cef_window_handle_t _retval = CefBrowserHostCppToC::Get( + self)->GetOpenerWindowHandle(); + + // Return type: simple + return _retval; +} + +struct _cef_client_t* CEF_CALLBACK browser_host_get_client( + struct _cef_browser_host_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefBrowserHostCppToC::Get(self)->GetClient(); + + // Return type: refptr_diff + return CefClientCToCpp::Unwrap(_retval); +} + +cef_string_userfree_t CEF_CALLBACK browser_host_get_dev_tools_url( + struct _cef_browser_host_t* self, int http_scheme) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefBrowserHostCppToC::Get(self)->GetDevToolsURL( + http_scheme?true:false); + + // Return type: string + return _retval.DetachToUserFree(); +} + +double CEF_CALLBACK browser_host_get_zoom_level( + struct _cef_browser_host_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + double _retval = CefBrowserHostCppToC::Get(self)->GetZoomLevel(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK browser_host_set_zoom_level(struct _cef_browser_host_t* self, + double zoomLevel) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefBrowserHostCppToC::Get(self)->SetZoomLevel( + zoomLevel); +} + +void CEF_CALLBACK browser_host_run_file_dialog(struct _cef_browser_host_t* self, + enum cef_file_dialog_mode_t mode, const cef_string_t* title, + const cef_string_t* default_file_name, cef_string_list_t accept_types, + cef_run_file_dialog_callback_t* callback) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: callback; type: refptr_diff + DCHECK(callback); + if (!callback) + return; + // Unverified params: title, default_file_name, accept_types + + // Translate param: accept_types; type: string_vec_byref_const + std::vector accept_typesList; + transfer_string_list_contents(accept_types, accept_typesList); + + // Execute + CefBrowserHostCppToC::Get(self)->RunFileDialog( + mode, + CefString(title), + CefString(default_file_name), + accept_typesList, + CefRunFileDialogCallbackCToCpp::Wrap(callback)); +} + +void CEF_CALLBACK browser_host_start_download(struct _cef_browser_host_t* self, + const cef_string_t* url) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: url; type: string_byref_const + DCHECK(url); + if (!url) + return; + + // Execute + CefBrowserHostCppToC::Get(self)->StartDownload( + CefString(url)); +} + +void CEF_CALLBACK browser_host_set_mouse_cursor_change_disabled( + struct _cef_browser_host_t* self, int disabled) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefBrowserHostCppToC::Get(self)->SetMouseCursorChangeDisabled( + disabled?true:false); +} + +int CEF_CALLBACK browser_host_is_mouse_cursor_change_disabled( + struct _cef_browser_host_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefBrowserHostCppToC::Get(self)->IsMouseCursorChangeDisabled(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK browser_host_is_window_rendering_disabled( + struct _cef_browser_host_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefBrowserHostCppToC::Get(self)->IsWindowRenderingDisabled(); + + // Return type: bool + return _retval; +} + +void CEF_CALLBACK browser_host_was_resized(struct _cef_browser_host_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefBrowserHostCppToC::Get(self)->WasResized(); +} + +void CEF_CALLBACK browser_host_was_hidden(struct _cef_browser_host_t* self, + int hidden) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefBrowserHostCppToC::Get(self)->WasHidden( + hidden?true:false); +} + +void CEF_CALLBACK browser_host_invalidate(struct _cef_browser_host_t* self, + const cef_rect_t* dirtyRect, enum cef_paint_element_type_t type) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: dirtyRect; type: simple_byref_const + DCHECK(dirtyRect); + if (!dirtyRect) + return; + + // Translate param: dirtyRect; type: simple_byref_const + CefRect dirtyRectVal = dirtyRect?*dirtyRect:CefRect(); + + // Execute + CefBrowserHostCppToC::Get(self)->Invalidate( + dirtyRectVal, + type); +} + +void CEF_CALLBACK browser_host_send_key_event(struct _cef_browser_host_t* self, + const struct _cef_key_event_t* event) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: event; type: struct_byref_const + DCHECK(event); + if (!event) + return; + + // Translate param: event; type: struct_byref_const + CefKeyEvent eventObj; + if (event) + eventObj.Set(*event, false); + + // Execute + CefBrowserHostCppToC::Get(self)->SendKeyEvent( + eventObj); +} + +void CEF_CALLBACK browser_host_send_mouse_click_event( + struct _cef_browser_host_t* self, const struct _cef_mouse_event_t* event, + enum cef_mouse_button_type_t type, int mouseUp, int clickCount) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: event; type: struct_byref_const + DCHECK(event); + if (!event) + return; + + // Translate param: event; type: struct_byref_const + CefMouseEvent eventObj; + if (event) + eventObj.Set(*event, false); + + // Execute + CefBrowserHostCppToC::Get(self)->SendMouseClickEvent( + eventObj, + type, + mouseUp?true:false, + clickCount); +} + +void CEF_CALLBACK browser_host_send_mouse_move_event( + struct _cef_browser_host_t* self, const struct _cef_mouse_event_t* event, + int mouseLeave) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: event; type: struct_byref_const + DCHECK(event); + if (!event) + return; + + // Translate param: event; type: struct_byref_const + CefMouseEvent eventObj; + if (event) + eventObj.Set(*event, false); + + // Execute + CefBrowserHostCppToC::Get(self)->SendMouseMoveEvent( + eventObj, + mouseLeave?true:false); +} + +void CEF_CALLBACK browser_host_send_mouse_wheel_event( + struct _cef_browser_host_t* self, const struct _cef_mouse_event_t* event, + int deltaX, int deltaY) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: event; type: struct_byref_const + DCHECK(event); + if (!event) + return; + + // Translate param: event; type: struct_byref_const + CefMouseEvent eventObj; + if (event) + eventObj.Set(*event, false); + + // Execute + CefBrowserHostCppToC::Get(self)->SendMouseWheelEvent( + eventObj, + deltaX, + deltaY); +} + +void CEF_CALLBACK browser_host_send_focus_event( + struct _cef_browser_host_t* self, int setFocus) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefBrowserHostCppToC::Get(self)->SendFocusEvent( + setFocus?true:false); +} + +void CEF_CALLBACK browser_host_send_capture_lost_event( + struct _cef_browser_host_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefBrowserHostCppToC::Get(self)->SendCaptureLostEvent(); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefBrowserHostCppToC::CefBrowserHostCppToC(CefBrowserHost* cls) + : CefCppToC(cls) { + struct_.struct_.get_browser = browser_host_get_browser; + struct_.struct_.parent_window_will_close = + browser_host_parent_window_will_close; + struct_.struct_.close_browser = browser_host_close_browser; + struct_.struct_.set_focus = browser_host_set_focus; + struct_.struct_.get_window_handle = browser_host_get_window_handle; + struct_.struct_.get_opener_window_handle = + browser_host_get_opener_window_handle; + struct_.struct_.get_client = browser_host_get_client; + struct_.struct_.get_dev_tools_url = browser_host_get_dev_tools_url; + struct_.struct_.get_zoom_level = browser_host_get_zoom_level; + struct_.struct_.set_zoom_level = browser_host_set_zoom_level; + struct_.struct_.run_file_dialog = browser_host_run_file_dialog; + struct_.struct_.start_download = browser_host_start_download; + struct_.struct_.set_mouse_cursor_change_disabled = + browser_host_set_mouse_cursor_change_disabled; + struct_.struct_.is_mouse_cursor_change_disabled = + browser_host_is_mouse_cursor_change_disabled; + struct_.struct_.is_window_rendering_disabled = + browser_host_is_window_rendering_disabled; + struct_.struct_.was_resized = browser_host_was_resized; + struct_.struct_.was_hidden = browser_host_was_hidden; + struct_.struct_.invalidate = browser_host_invalidate; + struct_.struct_.send_key_event = browser_host_send_key_event; + struct_.struct_.send_mouse_click_event = browser_host_send_mouse_click_event; + struct_.struct_.send_mouse_move_event = browser_host_send_mouse_move_event; + struct_.struct_.send_mouse_wheel_event = browser_host_send_mouse_wheel_event; + struct_.struct_.send_focus_event = browser_host_send_focus_event; + struct_.struct_.send_capture_lost_event = + browser_host_send_capture_lost_event; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/browser_host_cpptoc.h b/cef3/libcef_dll/cpptoc/browser_host_cpptoc.h new file mode 100644 index 000000000..6bac2bb27 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/browser_host_cpptoc.h @@ -0,0 +1,39 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_BROWSER_HOST_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_BROWSER_HOST_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_browser.h" +#include "include/capi/cef_browser_capi.h" +#include "include/cef_client.h" +#include "include/capi/cef_client_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefBrowserHostCppToC + : public CefCppToC { + public: + explicit CefBrowserHostCppToC(CefBrowserHost* cls); + virtual ~CefBrowserHostCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_BROWSER_HOST_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/browser_process_handler_cpptoc.cc b/cef3/libcef_dll/cpptoc/browser_process_handler_cpptoc.cc new file mode 100644 index 000000000..6e755915a --- /dev/null +++ b/cef3/libcef_dll/cpptoc/browser_process_handler_cpptoc.cc @@ -0,0 +1,87 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/browser_process_handler_cpptoc.h" +#include "libcef_dll/ctocpp/command_line_ctocpp.h" +#include "libcef_dll/ctocpp/list_value_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK browser_process_handler_on_context_initialized( + struct _cef_browser_process_handler_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefBrowserProcessHandlerCppToC::Get(self)->OnContextInitialized(); +} + +void CEF_CALLBACK browser_process_handler_on_before_child_process_launch( + struct _cef_browser_process_handler_t* self, + struct _cef_command_line_t* command_line) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: command_line; type: refptr_diff + DCHECK(command_line); + if (!command_line) + return; + + // Execute + CefBrowserProcessHandlerCppToC::Get(self)->OnBeforeChildProcessLaunch( + CefCommandLineCToCpp::Wrap(command_line)); +} + +void CEF_CALLBACK browser_process_handler_on_render_process_thread_created( + struct _cef_browser_process_handler_t* self, + struct _cef_list_value_t* extra_info) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: extra_info; type: refptr_diff + DCHECK(extra_info); + if (!extra_info) + return; + + // Execute + CefBrowserProcessHandlerCppToC::Get(self)->OnRenderProcessThreadCreated( + CefListValueCToCpp::Wrap(extra_info)); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefBrowserProcessHandlerCppToC::CefBrowserProcessHandlerCppToC( + CefBrowserProcessHandler* cls) + : CefCppToC(cls) { + struct_.struct_.on_context_initialized = + browser_process_handler_on_context_initialized; + struct_.struct_.on_before_child_process_launch = + browser_process_handler_on_before_child_process_launch; + struct_.struct_.on_render_process_thread_created = + browser_process_handler_on_render_process_thread_created; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/browser_process_handler_cpptoc.h b/cef3/libcef_dll/cpptoc/browser_process_handler_cpptoc.h new file mode 100644 index 000000000..4285b4c1a --- /dev/null +++ b/cef3/libcef_dll/cpptoc/browser_process_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_BROWSER_PROCESS_HANDLER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_BROWSER_PROCESS_HANDLER_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_browser_process_handler.h" +#include "include/capi/cef_browser_process_handler_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefBrowserProcessHandlerCppToC + : public CefCppToC { + public: + explicit CefBrowserProcessHandlerCppToC(CefBrowserProcessHandler* cls); + virtual ~CefBrowserProcessHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_BROWSER_PROCESS_HANDLER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/callback_cpptoc.cc b/cef3/libcef_dll/cpptoc/callback_cpptoc.cc new file mode 100644 index 000000000..45bb2731c --- /dev/null +++ b/cef3/libcef_dll/cpptoc/callback_cpptoc.cc @@ -0,0 +1,53 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/callback_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK callback_cont(struct _cef_callback_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefCallbackCppToC::Get(self)->Continue(); +} + +void CEF_CALLBACK callback_cancel(struct _cef_callback_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefCallbackCppToC::Get(self)->Cancel(); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefCallbackCppToC::CefCallbackCppToC(CefCallback* cls) + : CefCppToC(cls) { + struct_.struct_.cont = callback_cont; + struct_.struct_.cancel = callback_cancel; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/callback_cpptoc.h b/cef3/libcef_dll/cpptoc/callback_cpptoc.h new file mode 100644 index 000000000..9f8198763 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/callback_cpptoc.h @@ -0,0 +1,36 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_CALLBACK_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_CALLBACK_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_callback.h" +#include "include/capi/cef_callback_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefCallbackCppToC + : public CefCppToC { + public: + explicit CefCallbackCppToC(CefCallback* cls); + virtual ~CefCallbackCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_CALLBACK_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/client_cpptoc.cc b/cef3/libcef_dll/cpptoc/client_cpptoc.cc new file mode 100644 index 000000000..5ff860181 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/client_cpptoc.cc @@ -0,0 +1,276 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/client_cpptoc.h" +#include "libcef_dll/cpptoc/context_menu_handler_cpptoc.h" +#include "libcef_dll/cpptoc/dialog_handler_cpptoc.h" +#include "libcef_dll/cpptoc/display_handler_cpptoc.h" +#include "libcef_dll/cpptoc/download_handler_cpptoc.h" +#include "libcef_dll/cpptoc/focus_handler_cpptoc.h" +#include "libcef_dll/cpptoc/geolocation_handler_cpptoc.h" +#include "libcef_dll/cpptoc/jsdialog_handler_cpptoc.h" +#include "libcef_dll/cpptoc/keyboard_handler_cpptoc.h" +#include "libcef_dll/cpptoc/life_span_handler_cpptoc.h" +#include "libcef_dll/cpptoc/load_handler_cpptoc.h" +#include "libcef_dll/cpptoc/render_handler_cpptoc.h" +#include "libcef_dll/cpptoc/request_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/process_message_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +struct _cef_context_menu_handler_t* CEF_CALLBACK client_get_context_menu_handler( + struct _cef_client_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetContextMenuHandler(); + + // Return type: refptr_same + return CefContextMenuHandlerCppToC::Wrap(_retval); +} + +struct _cef_dialog_handler_t* CEF_CALLBACK client_get_dialog_handler( + struct _cef_client_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetDialogHandler(); + + // Return type: refptr_same + return CefDialogHandlerCppToC::Wrap(_retval); +} + +struct _cef_display_handler_t* CEF_CALLBACK client_get_display_handler( + struct _cef_client_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetDisplayHandler(); + + // Return type: refptr_same + return CefDisplayHandlerCppToC::Wrap(_retval); +} + +struct _cef_download_handler_t* CEF_CALLBACK client_get_download_handler( + struct _cef_client_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetDownloadHandler(); + + // Return type: refptr_same + return CefDownloadHandlerCppToC::Wrap(_retval); +} + +struct _cef_focus_handler_t* CEF_CALLBACK client_get_focus_handler( + struct _cef_client_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetFocusHandler(); + + // Return type: refptr_same + return CefFocusHandlerCppToC::Wrap(_retval); +} + +struct _cef_geolocation_handler_t* CEF_CALLBACK client_get_geolocation_handler( + struct _cef_client_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetGeolocationHandler(); + + // Return type: refptr_same + return CefGeolocationHandlerCppToC::Wrap(_retval); +} + +struct _cef_jsdialog_handler_t* CEF_CALLBACK client_get_jsdialog_handler( + struct _cef_client_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetJSDialogHandler(); + + // Return type: refptr_same + return CefJSDialogHandlerCppToC::Wrap(_retval); +} + +struct _cef_keyboard_handler_t* CEF_CALLBACK client_get_keyboard_handler( + struct _cef_client_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetKeyboardHandler(); + + // Return type: refptr_same + return CefKeyboardHandlerCppToC::Wrap(_retval); +} + +struct _cef_life_span_handler_t* CEF_CALLBACK client_get_life_span_handler( + struct _cef_client_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetLifeSpanHandler(); + + // Return type: refptr_same + return CefLifeSpanHandlerCppToC::Wrap(_retval); +} + +struct _cef_load_handler_t* CEF_CALLBACK client_get_load_handler( + struct _cef_client_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetLoadHandler(); + + // Return type: refptr_same + return CefLoadHandlerCppToC::Wrap(_retval); +} + +struct _cef_render_handler_t* CEF_CALLBACK client_get_render_handler( + struct _cef_client_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetRenderHandler(); + + // Return type: refptr_same + return CefRenderHandlerCppToC::Wrap(_retval); +} + +struct _cef_request_handler_t* CEF_CALLBACK client_get_request_handler( + struct _cef_client_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetRequestHandler(); + + // Return type: refptr_same + return CefRequestHandlerCppToC::Wrap(_retval); +} + +int CEF_CALLBACK client_on_process_message_received(struct _cef_client_t* self, + cef_browser_t* browser, enum cef_process_id_t source_process, + struct _cef_process_message_t* message) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: message; type: refptr_diff + DCHECK(message); + if (!message) + return 0; + + // Execute + bool _retval = CefClientCppToC::Get(self)->OnProcessMessageReceived( + CefBrowserCToCpp::Wrap(browser), + source_process, + CefProcessMessageCToCpp::Wrap(message)); + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefClientCppToC::CefClientCppToC(CefClient* cls) + : CefCppToC(cls) { + struct_.struct_.get_context_menu_handler = client_get_context_menu_handler; + struct_.struct_.get_dialog_handler = client_get_dialog_handler; + struct_.struct_.get_display_handler = client_get_display_handler; + struct_.struct_.get_download_handler = client_get_download_handler; + struct_.struct_.get_focus_handler = client_get_focus_handler; + struct_.struct_.get_geolocation_handler = client_get_geolocation_handler; + struct_.struct_.get_jsdialog_handler = client_get_jsdialog_handler; + struct_.struct_.get_keyboard_handler = client_get_keyboard_handler; + struct_.struct_.get_life_span_handler = client_get_life_span_handler; + struct_.struct_.get_load_handler = client_get_load_handler; + struct_.struct_.get_render_handler = client_get_render_handler; + struct_.struct_.get_request_handler = client_get_request_handler; + struct_.struct_.on_process_message_received = + client_on_process_message_received; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/client_cpptoc.h b/cef3/libcef_dll/cpptoc/client_cpptoc.h new file mode 100644 index 000000000..93731f15d --- /dev/null +++ b/cef3/libcef_dll/cpptoc/client_cpptoc.h @@ -0,0 +1,36 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_CLIENT_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_CLIENT_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_client.h" +#include "include/capi/cef_client_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefClientCppToC + : public CefCppToC { + public: + explicit CefClientCppToC(CefClient* cls); + virtual ~CefClientCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_CLIENT_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/command_line_cpptoc.cc b/cef3/libcef_dll/cpptoc/command_line_cpptoc.cc new file mode 100644 index 000000000..ef88fbdd8 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/command_line_cpptoc.cc @@ -0,0 +1,428 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/command_line_cpptoc.h" +#include "libcef_dll/transfer_util.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_command_line_t* cef_command_line_create() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = CefCommandLine::CreateCommandLine(); + + // Return type: refptr_same + return CefCommandLineCppToC::Wrap(_retval); +} + +CEF_EXPORT cef_command_line_t* cef_command_line_get_global() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = CefCommandLine::GetGlobalCommandLine(); + + // Return type: refptr_same + return CefCommandLineCppToC::Wrap(_retval); +} + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK command_line_is_valid(struct _cef_command_line_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefCommandLineCppToC::Get(self)->IsValid(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK command_line_is_read_only(struct _cef_command_line_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefCommandLineCppToC::Get(self)->IsReadOnly(); + + // Return type: bool + return _retval; +} + +struct _cef_command_line_t* CEF_CALLBACK command_line_copy( + struct _cef_command_line_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefCommandLineCppToC::Get(self)->Copy(); + + // Return type: refptr_same + return CefCommandLineCppToC::Wrap(_retval); +} + +void CEF_CALLBACK command_line_init_from_argv(struct _cef_command_line_t* self, + int argc, const char* const* argv) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: argv; type: simple_byaddr + DCHECK(argv); + if (!argv) + return; + + // Execute + CefCommandLineCppToC::Get(self)->InitFromArgv( + argc, + argv); +} + +void CEF_CALLBACK command_line_init_from_string( + struct _cef_command_line_t* self, const cef_string_t* command_line) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: command_line; type: string_byref_const + DCHECK(command_line); + if (!command_line) + return; + + // Execute + CefCommandLineCppToC::Get(self)->InitFromString( + CefString(command_line)); +} + +void CEF_CALLBACK command_line_reset(struct _cef_command_line_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefCommandLineCppToC::Get(self)->Reset(); +} + +void CEF_CALLBACK command_line_get_argv(struct _cef_command_line_t* self, + cef_string_list_t argv) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: argv; type: string_vec_byref + DCHECK(argv); + if (!argv) + return; + + // Translate param: argv; type: string_vec_byref + std::vector argvList; + transfer_string_list_contents(argv, argvList); + + // Execute + CefCommandLineCppToC::Get(self)->GetArgv( + argvList); + + // Restore param: argv; type: string_vec_byref + cef_string_list_clear(argv); + transfer_string_list_contents(argvList, argv); +} + +cef_string_userfree_t CEF_CALLBACK command_line_get_command_line_string( + struct _cef_command_line_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefCommandLineCppToC::Get(self)->GetCommandLineString(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK command_line_get_program( + struct _cef_command_line_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefCommandLineCppToC::Get(self)->GetProgram(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +void CEF_CALLBACK command_line_set_program(struct _cef_command_line_t* self, + const cef_string_t* program) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: program; type: string_byref_const + DCHECK(program); + if (!program) + return; + + // Execute + CefCommandLineCppToC::Get(self)->SetProgram( + CefString(program)); +} + +int CEF_CALLBACK command_line_has_switches(struct _cef_command_line_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefCommandLineCppToC::Get(self)->HasSwitches(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK command_line_has_switch(struct _cef_command_line_t* self, + const cef_string_t* name) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: name; type: string_byref_const + DCHECK(name); + if (!name) + return 0; + + // Execute + bool _retval = CefCommandLineCppToC::Get(self)->HasSwitch( + CefString(name)); + + // Return type: bool + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK command_line_get_switch_value( + struct _cef_command_line_t* self, const cef_string_t* name) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: name; type: string_byref_const + DCHECK(name); + if (!name) + return NULL; + + // Execute + CefString _retval = CefCommandLineCppToC::Get(self)->GetSwitchValue( + CefString(name)); + + // Return type: string + return _retval.DetachToUserFree(); +} + +void CEF_CALLBACK command_line_get_switches(struct _cef_command_line_t* self, + cef_string_map_t switches) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: switches; type: string_map_single_byref + DCHECK(switches); + if (!switches) + return; + + // Translate param: switches; type: string_map_single_byref + std::map switchesMap; + transfer_string_map_contents(switches, switchesMap); + + // Execute + CefCommandLineCppToC::Get(self)->GetSwitches( + switchesMap); + + // Restore param: switches; type: string_map_single_byref + cef_string_map_clear(switches); + transfer_string_map_contents(switchesMap, switches); +} + +void CEF_CALLBACK command_line_append_switch(struct _cef_command_line_t* self, + const cef_string_t* name) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: name; type: string_byref_const + DCHECK(name); + if (!name) + return; + + // Execute + CefCommandLineCppToC::Get(self)->AppendSwitch( + CefString(name)); +} + +void CEF_CALLBACK command_line_append_switch_with_value( + struct _cef_command_line_t* self, const cef_string_t* name, + const cef_string_t* value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: name; type: string_byref_const + DCHECK(name); + if (!name) + return; + // Verify param: value; type: string_byref_const + DCHECK(value); + if (!value) + return; + + // Execute + CefCommandLineCppToC::Get(self)->AppendSwitchWithValue( + CefString(name), + CefString(value)); +} + +int CEF_CALLBACK command_line_has_arguments(struct _cef_command_line_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefCommandLineCppToC::Get(self)->HasArguments(); + + // Return type: bool + return _retval; +} + +void CEF_CALLBACK command_line_get_arguments(struct _cef_command_line_t* self, + cef_string_list_t arguments) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: arguments; type: string_vec_byref + DCHECK(arguments); + if (!arguments) + return; + + // Translate param: arguments; type: string_vec_byref + std::vector argumentsList; + transfer_string_list_contents(arguments, argumentsList); + + // Execute + CefCommandLineCppToC::Get(self)->GetArguments( + argumentsList); + + // Restore param: arguments; type: string_vec_byref + cef_string_list_clear(arguments); + transfer_string_list_contents(argumentsList, arguments); +} + +void CEF_CALLBACK command_line_append_argument(struct _cef_command_line_t* self, + const cef_string_t* argument) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: argument; type: string_byref_const + DCHECK(argument); + if (!argument) + return; + + // Execute + CefCommandLineCppToC::Get(self)->AppendArgument( + CefString(argument)); +} + +void CEF_CALLBACK command_line_prepend_wrapper(struct _cef_command_line_t* self, + const cef_string_t* wrapper) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: wrapper; type: string_byref_const + DCHECK(wrapper); + if (!wrapper) + return; + + // Execute + CefCommandLineCppToC::Get(self)->PrependWrapper( + CefString(wrapper)); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefCommandLineCppToC::CefCommandLineCppToC(CefCommandLine* cls) + : CefCppToC(cls) { + struct_.struct_.is_valid = command_line_is_valid; + struct_.struct_.is_read_only = command_line_is_read_only; + struct_.struct_.copy = command_line_copy; + struct_.struct_.init_from_argv = command_line_init_from_argv; + struct_.struct_.init_from_string = command_line_init_from_string; + struct_.struct_.reset = command_line_reset; + struct_.struct_.get_argv = command_line_get_argv; + struct_.struct_.get_command_line_string = + command_line_get_command_line_string; + struct_.struct_.get_program = command_line_get_program; + struct_.struct_.set_program = command_line_set_program; + struct_.struct_.has_switches = command_line_has_switches; + struct_.struct_.has_switch = command_line_has_switch; + struct_.struct_.get_switch_value = command_line_get_switch_value; + struct_.struct_.get_switches = command_line_get_switches; + struct_.struct_.append_switch = command_line_append_switch; + struct_.struct_.append_switch_with_value = + command_line_append_switch_with_value; + struct_.struct_.has_arguments = command_line_has_arguments; + struct_.struct_.get_arguments = command_line_get_arguments; + struct_.struct_.append_argument = command_line_append_argument; + struct_.struct_.prepend_wrapper = command_line_prepend_wrapper; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/command_line_cpptoc.h b/cef3/libcef_dll/cpptoc/command_line_cpptoc.h new file mode 100644 index 000000000..38e0856b0 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/command_line_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_COMMAND_LINE_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_COMMAND_LINE_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_command_line.h" +#include "include/capi/cef_command_line_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefCommandLineCppToC + : public CefCppToC { + public: + explicit CefCommandLineCppToC(CefCommandLine* cls); + virtual ~CefCommandLineCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_COMMAND_LINE_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/completion_handler_cpptoc.cc b/cef3/libcef_dll/cpptoc/completion_handler_cpptoc.cc new file mode 100644 index 000000000..249135339 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/completion_handler_cpptoc.cc @@ -0,0 +1,44 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/completion_handler_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK completion_handler_on_complete( + struct _cef_completion_handler_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefCompletionHandlerCppToC::Get(self)->OnComplete(); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefCompletionHandlerCppToC::CefCompletionHandlerCppToC( + CefCompletionHandler* cls) + : CefCppToC(cls) { + struct_.struct_.on_complete = completion_handler_on_complete; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/completion_handler_cpptoc.h b/cef3/libcef_dll/cpptoc/completion_handler_cpptoc.h new file mode 100644 index 000000000..7d0e440f8 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/completion_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_COMPLETION_HANDLER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_COMPLETION_HANDLER_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_callback.h" +#include "include/capi/cef_callback_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefCompletionHandlerCppToC + : public CefCppToC { + public: + explicit CefCompletionHandlerCppToC(CefCompletionHandler* cls); + virtual ~CefCompletionHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_COMPLETION_HANDLER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/context_menu_handler_cpptoc.cc b/cef3/libcef_dll/cpptoc/context_menu_handler_cpptoc.cc new file mode 100644 index 000000000..24d99be51 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/context_menu_handler_cpptoc.cc @@ -0,0 +1,132 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/context_menu_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/context_menu_params_ctocpp.h" +#include "libcef_dll/ctocpp/frame_ctocpp.h" +#include "libcef_dll/ctocpp/menu_model_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK context_menu_handler_on_before_context_menu( + struct _cef_context_menu_handler_t* self, cef_browser_t* browser, + struct _cef_frame_t* frame, struct _cef_context_menu_params_t* params, + struct _cef_menu_model_t* model) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return; + // Verify param: params; type: refptr_diff + DCHECK(params); + if (!params) + return; + // Verify param: model; type: refptr_diff + DCHECK(model); + if (!model) + return; + + // Execute + CefContextMenuHandlerCppToC::Get(self)->OnBeforeContextMenu( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + CefContextMenuParamsCToCpp::Wrap(params), + CefMenuModelCToCpp::Wrap(model)); +} + +int CEF_CALLBACK context_menu_handler_on_context_menu_command( + struct _cef_context_menu_handler_t* self, cef_browser_t* browser, + struct _cef_frame_t* frame, struct _cef_context_menu_params_t* params, + int command_id, enum cef_event_flags_t event_flags) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return 0; + // Verify param: params; type: refptr_diff + DCHECK(params); + if (!params) + return 0; + + // Execute + bool _retval = CefContextMenuHandlerCppToC::Get(self)->OnContextMenuCommand( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + CefContextMenuParamsCToCpp::Wrap(params), + command_id, + event_flags); + + // Return type: bool + return _retval; +} + +void CEF_CALLBACK context_menu_handler_on_context_menu_dismissed( + struct _cef_context_menu_handler_t* self, cef_browser_t* browser, + struct _cef_frame_t* frame) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return; + + // Execute + CefContextMenuHandlerCppToC::Get(self)->OnContextMenuDismissed( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame)); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefContextMenuHandlerCppToC::CefContextMenuHandlerCppToC( + CefContextMenuHandler* cls) + : CefCppToC(cls) { + struct_.struct_.on_before_context_menu = + context_menu_handler_on_before_context_menu; + struct_.struct_.on_context_menu_command = + context_menu_handler_on_context_menu_command; + struct_.struct_.on_context_menu_dismissed = + context_menu_handler_on_context_menu_dismissed; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/context_menu_handler_cpptoc.h b/cef3/libcef_dll/cpptoc/context_menu_handler_cpptoc.h new file mode 100644 index 000000000..f7592de0b --- /dev/null +++ b/cef3/libcef_dll/cpptoc/context_menu_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_CONTEXT_MENU_HANDLER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_CONTEXT_MENU_HANDLER_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_context_menu_handler.h" +#include "include/capi/cef_context_menu_handler_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefContextMenuHandlerCppToC + : public CefCppToC { + public: + explicit CefContextMenuHandlerCppToC(CefContextMenuHandler* cls); + virtual ~CefContextMenuHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_CONTEXT_MENU_HANDLER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/context_menu_params_cpptoc.cc b/cef3/libcef_dll/cpptoc/context_menu_params_cpptoc.cc new file mode 100644 index 000000000..0234b4294 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/context_menu_params_cpptoc.cc @@ -0,0 +1,296 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/context_menu_params_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK context_menu_params_get_xcoord( + struct _cef_context_menu_params_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefContextMenuParamsCppToC::Get(self)->GetXCoord(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK context_menu_params_get_ycoord( + struct _cef_context_menu_params_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefContextMenuParamsCppToC::Get(self)->GetYCoord(); + + // Return type: simple + return _retval; +} + +enum cef_context_menu_type_flags_t CEF_CALLBACK context_menu_params_get_type_flags( + struct _cef_context_menu_params_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CM_TYPEFLAG_NONE; + + // Execute + cef_context_menu_type_flags_t _retval = CefContextMenuParamsCppToC::Get( + self)->GetTypeFlags(); + + // Return type: simple + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK context_menu_params_get_link_url( + struct _cef_context_menu_params_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefContextMenuParamsCppToC::Get(self)->GetLinkUrl(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK context_menu_params_get_unfiltered_link_url( + struct _cef_context_menu_params_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefContextMenuParamsCppToC::Get( + self)->GetUnfilteredLinkUrl(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK context_menu_params_get_source_url( + struct _cef_context_menu_params_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefContextMenuParamsCppToC::Get(self)->GetSourceUrl(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +int CEF_CALLBACK context_menu_params_is_image_blocked( + struct _cef_context_menu_params_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefContextMenuParamsCppToC::Get(self)->IsImageBlocked(); + + // Return type: bool + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK context_menu_params_get_page_url( + struct _cef_context_menu_params_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefContextMenuParamsCppToC::Get(self)->GetPageUrl(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK context_menu_params_get_frame_url( + struct _cef_context_menu_params_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefContextMenuParamsCppToC::Get(self)->GetFrameUrl(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK context_menu_params_get_frame_charset( + struct _cef_context_menu_params_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefContextMenuParamsCppToC::Get(self)->GetFrameCharset(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +enum cef_context_menu_media_type_t CEF_CALLBACK context_menu_params_get_media_type( + struct _cef_context_menu_params_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CM_MEDIATYPE_NONE; + + // Execute + cef_context_menu_media_type_t _retval = CefContextMenuParamsCppToC::Get( + self)->GetMediaType(); + + // Return type: simple + return _retval; +} + +enum cef_context_menu_media_state_flags_t CEF_CALLBACK context_menu_params_get_media_state_flags( + struct _cef_context_menu_params_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CM_MEDIAFLAG_NONE; + + // Execute + cef_context_menu_media_state_flags_t _retval = + CefContextMenuParamsCppToC::Get(self)->GetMediaStateFlags(); + + // Return type: simple + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK context_menu_params_get_selection_text( + struct _cef_context_menu_params_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefContextMenuParamsCppToC::Get(self)->GetSelectionText(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +int CEF_CALLBACK context_menu_params_is_editable( + struct _cef_context_menu_params_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefContextMenuParamsCppToC::Get(self)->IsEditable(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK context_menu_params_is_speech_input_enabled( + struct _cef_context_menu_params_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefContextMenuParamsCppToC::Get(self)->IsSpeechInputEnabled(); + + // Return type: bool + return _retval; +} + +enum cef_context_menu_edit_state_flags_t CEF_CALLBACK context_menu_params_get_edit_state_flags( + struct _cef_context_menu_params_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CM_EDITFLAG_NONE; + + // Execute + cef_context_menu_edit_state_flags_t _retval = CefContextMenuParamsCppToC::Get( + self)->GetEditStateFlags(); + + // Return type: simple + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefContextMenuParamsCppToC::CefContextMenuParamsCppToC( + CefContextMenuParams* cls) + : CefCppToC(cls) { + struct_.struct_.get_xcoord = context_menu_params_get_xcoord; + struct_.struct_.get_ycoord = context_menu_params_get_ycoord; + struct_.struct_.get_type_flags = context_menu_params_get_type_flags; + struct_.struct_.get_link_url = context_menu_params_get_link_url; + struct_.struct_.get_unfiltered_link_url = + context_menu_params_get_unfiltered_link_url; + struct_.struct_.get_source_url = context_menu_params_get_source_url; + struct_.struct_.is_image_blocked = context_menu_params_is_image_blocked; + struct_.struct_.get_page_url = context_menu_params_get_page_url; + struct_.struct_.get_frame_url = context_menu_params_get_frame_url; + struct_.struct_.get_frame_charset = context_menu_params_get_frame_charset; + struct_.struct_.get_media_type = context_menu_params_get_media_type; + struct_.struct_.get_media_state_flags = + context_menu_params_get_media_state_flags; + struct_.struct_.get_selection_text = context_menu_params_get_selection_text; + struct_.struct_.is_editable = context_menu_params_is_editable; + struct_.struct_.is_speech_input_enabled = + context_menu_params_is_speech_input_enabled; + struct_.struct_.get_edit_state_flags = + context_menu_params_get_edit_state_flags; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/context_menu_params_cpptoc.h b/cef3/libcef_dll/cpptoc/context_menu_params_cpptoc.h new file mode 100644 index 000000000..9b00b10d0 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/context_menu_params_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_CONTEXT_MENU_PARAMS_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_CONTEXT_MENU_PARAMS_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_context_menu_handler.h" +#include "include/capi/cef_context_menu_handler_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefContextMenuParamsCppToC + : public CefCppToC { + public: + explicit CefContextMenuParamsCppToC(CefContextMenuParams* cls); + virtual ~CefContextMenuParamsCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_CONTEXT_MENU_PARAMS_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/cookie_manager_cpptoc.cc b/cef3/libcef_dll/cpptoc/cookie_manager_cpptoc.cc new file mode 100644 index 000000000..acedc3f1d --- /dev/null +++ b/cef3/libcef_dll/cpptoc/cookie_manager_cpptoc.cc @@ -0,0 +1,222 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/cookie_manager_cpptoc.h" +#include "libcef_dll/ctocpp/completion_handler_ctocpp.h" +#include "libcef_dll/ctocpp/cookie_visitor_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_global_manager() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = CefCookieManager::GetGlobalManager(); + + // Return type: refptr_same + return CefCookieManagerCppToC::Wrap(_retval); +} + +CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_create_manager( + const cef_string_t* path, int persist_session_cookies) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: path + + // Execute + CefRefPtr _retval = CefCookieManager::CreateManager( + CefString(path), + persist_session_cookies?true:false); + + // Return type: refptr_same + return CefCookieManagerCppToC::Wrap(_retval); +} + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK cookie_manager_set_supported_schemes( + struct _cef_cookie_manager_t* self, cef_string_list_t schemes) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: schemes; type: string_vec_byref_const + DCHECK(schemes); + if (!schemes) + return; + + // Translate param: schemes; type: string_vec_byref_const + std::vector schemesList; + transfer_string_list_contents(schemes, schemesList); + + // Execute + CefCookieManagerCppToC::Get(self)->SetSupportedSchemes( + schemesList); +} + +int CEF_CALLBACK cookie_manager_visit_all_cookies( + struct _cef_cookie_manager_t* self, + struct _cef_cookie_visitor_t* visitor) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: visitor; type: refptr_diff + DCHECK(visitor); + if (!visitor) + return 0; + + // Execute + bool _retval = CefCookieManagerCppToC::Get(self)->VisitAllCookies( + CefCookieVisitorCToCpp::Wrap(visitor)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK cookie_manager_visit_url_cookies( + struct _cef_cookie_manager_t* self, const cef_string_t* url, + int includeHttpOnly, struct _cef_cookie_visitor_t* visitor) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: url; type: string_byref_const + DCHECK(url); + if (!url) + return 0; + // Verify param: visitor; type: refptr_diff + DCHECK(visitor); + if (!visitor) + return 0; + + // Execute + bool _retval = CefCookieManagerCppToC::Get(self)->VisitUrlCookies( + CefString(url), + includeHttpOnly?true:false, + CefCookieVisitorCToCpp::Wrap(visitor)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK cookie_manager_set_cookie(struct _cef_cookie_manager_t* self, + const cef_string_t* url, const struct _cef_cookie_t* cookie) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: url; type: string_byref_const + DCHECK(url); + if (!url) + return 0; + // Verify param: cookie; type: struct_byref_const + DCHECK(cookie); + if (!cookie) + return 0; + + // Translate param: cookie; type: struct_byref_const + CefCookie cookieObj; + if (cookie) + cookieObj.Set(*cookie, false); + + // Execute + bool _retval = CefCookieManagerCppToC::Get(self)->SetCookie( + CefString(url), + cookieObj); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK cookie_manager_delete_cookies( + struct _cef_cookie_manager_t* self, const cef_string_t* url, + const cef_string_t* cookie_name) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Unverified params: url, cookie_name + + // Execute + bool _retval = CefCookieManagerCppToC::Get(self)->DeleteCookies( + CefString(url), + CefString(cookie_name)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK cookie_manager_set_storage_path( + struct _cef_cookie_manager_t* self, const cef_string_t* path, + int persist_session_cookies) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Unverified params: path + + // Execute + bool _retval = CefCookieManagerCppToC::Get(self)->SetStoragePath( + CefString(path), + persist_session_cookies?true:false); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK cookie_manager_flush_store(struct _cef_cookie_manager_t* self, + cef_completion_handler_t* handler) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Unverified params: handler + + // Execute + bool _retval = CefCookieManagerCppToC::Get(self)->FlushStore( + CefCompletionHandlerCToCpp::Wrap(handler)); + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefCookieManagerCppToC::CefCookieManagerCppToC(CefCookieManager* cls) + : CefCppToC( + cls) { + struct_.struct_.set_supported_schemes = cookie_manager_set_supported_schemes; + struct_.struct_.visit_all_cookies = cookie_manager_visit_all_cookies; + struct_.struct_.visit_url_cookies = cookie_manager_visit_url_cookies; + struct_.struct_.set_cookie = cookie_manager_set_cookie; + struct_.struct_.delete_cookies = cookie_manager_delete_cookies; + struct_.struct_.set_storage_path = cookie_manager_set_storage_path; + struct_.struct_.flush_store = cookie_manager_flush_store; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/cookie_manager_cpptoc.h b/cef3/libcef_dll/cpptoc/cookie_manager_cpptoc.h new file mode 100644 index 000000000..89b1e12dd --- /dev/null +++ b/cef3/libcef_dll/cpptoc/cookie_manager_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_COOKIE_MANAGER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_COOKIE_MANAGER_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_cookie.h" +#include "include/capi/cef_cookie_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefCookieManagerCppToC + : public CefCppToC { + public: + explicit CefCookieManagerCppToC(CefCookieManager* cls); + virtual ~CefCookieManagerCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_COOKIE_MANAGER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/cookie_visitor_cpptoc.cc b/cef3/libcef_dll/cpptoc/cookie_visitor_cpptoc.cc new file mode 100644 index 000000000..0b26e62b5 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/cookie_visitor_cpptoc.cc @@ -0,0 +1,70 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/cookie_visitor_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK cookie_visitor_visit(struct _cef_cookie_visitor_t* self, + const struct _cef_cookie_t* cookie, int count, int total, + int* deleteCookie) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: cookie; type: struct_byref_const + DCHECK(cookie); + if (!cookie) + return 0; + // Verify param: deleteCookie; type: bool_byref + DCHECK(deleteCookie); + if (!deleteCookie) + return 0; + + // Translate param: cookie; type: struct_byref_const + CefCookie cookieObj; + if (cookie) + cookieObj.Set(*cookie, false); + // Translate param: deleteCookie; type: bool_byref + bool deleteCookieBool = (deleteCookie && *deleteCookie)?true:false; + + // Execute + bool _retval = CefCookieVisitorCppToC::Get(self)->Visit( + cookieObj, + count, + total, + deleteCookieBool); + + // Restore param: deleteCookie; type: bool_byref + if (deleteCookie) + *deleteCookie = deleteCookieBool?true:false; + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefCookieVisitorCppToC::CefCookieVisitorCppToC(CefCookieVisitor* cls) + : CefCppToC( + cls) { + struct_.struct_.visit = cookie_visitor_visit; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/cookie_visitor_cpptoc.h b/cef3/libcef_dll/cpptoc/cookie_visitor_cpptoc.h new file mode 100644 index 000000000..24d7d62f9 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/cookie_visitor_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_COOKIE_VISITOR_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_COOKIE_VISITOR_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_cookie.h" +#include "include/capi/cef_cookie_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefCookieVisitorCppToC + : public CefCppToC { + public: + explicit CefCookieVisitorCppToC(CefCookieVisitor* cls); + virtual ~CefCookieVisitorCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_COOKIE_VISITOR_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/cpptoc.h b/cef3/libcef_dll/cpptoc/cpptoc.h new file mode 100644 index 000000000..3449264f9 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/cpptoc.h @@ -0,0 +1,160 @@ +// Copyright (c) 2009 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_LIBCEF_DLL_CPPTOC_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_CPPTOC_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/capi/cef_base_capi.h" +#include "libcef_dll/cef_logging.h" + + +// Wrap a C++ class with a C structure. This is used when the class +// implementation exists on this side of the DLL boundary but will have methods +// called from the other side of the DLL boundary. +template +class CefCppToC : public CefBase { + public: + // Structure representation with pointer to the C++ class. + struct Struct { + StructName struct_; + CefCppToC* class_; + }; + + // Use this method to retrieve the underlying class instance from our + // own structure when the structure is passed as the required first + // parameter of a C API function call. No explicit reference counting + // is done in this case. + static CefRefPtr Get(StructName* s) { + DCHECK(s); + + // Cast our structure to the wrapper structure type. + Struct* wrapperStruct = reinterpret_cast(s); + // Return the underlying object instance. + return wrapperStruct->class_->GetClass(); + } + + // Use this method to create a wrapper structure for passing our class + // instance to the other side. + static StructName* Wrap(CefRefPtr c) { + if (!c.get()) + return NULL; + + // Wrap our object with the CefCppToC class. + ClassName* wrapper = new ClassName(c); + // Add a reference to our wrapper object that will be released once our + // structure arrives on the other side. + wrapper->AddRef(); + // Return the structure pointer that can now be passed to the other side. + return wrapper->GetStruct(); + } + + // Use this method to retrieve the underlying class instance when receiving + // our wrapper structure back from the other side. + static CefRefPtr Unwrap(StructName* s) { + if (!s) + return NULL; + + // Cast our structure to the wrapper structure type. + Struct* wrapperStruct = reinterpret_cast(s); + // Add the underlying object instance to a smart pointer. + CefRefPtr objectPtr(wrapperStruct->class_->GetClass()); + // Release the reference to our wrapper object that was added before the + // structure was passed back to us. + wrapperStruct->class_->Release(); + // Return the underlying object instance. + return objectPtr; + } + + explicit CefCppToC(BaseName* cls) + : class_(cls) { + DCHECK(cls); + + struct_.class_ = this; + + // zero the underlying structure and set base members + memset(&struct_.struct_, 0, sizeof(StructName)); + struct_.struct_.base.size = sizeof(StructName); + struct_.struct_.base.add_ref = struct_add_ref; + struct_.struct_.base.release = struct_release; + struct_.struct_.base.get_refct = struct_get_refct; + +#ifndef NDEBUG + CefAtomicIncrement(&DebugObjCt); +#endif + } + virtual ~CefCppToC() { +#ifndef NDEBUG + CefAtomicDecrement(&DebugObjCt); +#endif + } + + BaseName* GetClass() { return class_; } + + // If returning the structure across the DLL boundary you should call + // AddRef() on this CefCppToC object. On the other side of the DLL boundary, + // call UnderlyingRelease() on the wrapping CefCToCpp object. + StructName* GetStruct() { return &struct_.struct_; } + + // CefBase methods increment/decrement reference counts on both this object + // and the underlying wrapper class. + int AddRef() { + UnderlyingAddRef(); + return refct_.AddRef(); + } + int Release() { + UnderlyingRelease(); + int retval = refct_.Release(); + if (retval == 0) + delete this; + return retval; + } + int GetRefCt() { return refct_.GetRefCt(); } + + // Increment/decrement reference counts on only the underlying class. + int UnderlyingAddRef() { return class_->AddRef(); } + int UnderlyingRelease() { return class_->Release(); } + int UnderlyingGetRefCt() { return class_->GetRefCt(); } + +#ifndef NDEBUG + // Simple tracking of allocated objects. + static long DebugObjCt; // NOLINT(runtime/int) +#endif + + private: + static int CEF_CALLBACK struct_add_ref(struct _cef_base_t* base) { + DCHECK(base); + if (!base) + return 0; + + Struct* impl = reinterpret_cast(base); + return impl->class_->AddRef(); + } + + static int CEF_CALLBACK struct_release(struct _cef_base_t* base) { + DCHECK(base); + if (!base) + return 0; + + Struct* impl = reinterpret_cast(base); + return impl->class_->Release(); + } + + static int CEF_CALLBACK struct_get_refct(struct _cef_base_t* base) { + DCHECK(base); + if (!base) + return 0; + + Struct* impl = reinterpret_cast(base); + return impl->class_->GetRefCt(); + } + + protected: + CefRefCount refct_; + Struct struct_; + BaseName* class_; +}; + +#endif // CEF_LIBCEF_DLL_CPPTOC_CPPTOC_H_ diff --git a/cef3/libcef_dll/cpptoc/dialog_handler_cpptoc.cc b/cef3/libcef_dll/cpptoc/dialog_handler_cpptoc.cc new file mode 100644 index 000000000..7714183b6 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/dialog_handler_cpptoc.cc @@ -0,0 +1,71 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/dialog_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/file_dialog_callback_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK dialog_handler_on_file_dialog( + struct _cef_dialog_handler_t* self, cef_browser_t* browser, + enum cef_file_dialog_mode_t mode, const cef_string_t* title, + const cef_string_t* default_file_name, cef_string_list_t accept_types, + cef_file_dialog_callback_t* callback) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: callback; type: refptr_diff + DCHECK(callback); + if (!callback) + return 0; + // Unverified params: title, default_file_name, accept_types + + // Translate param: accept_types; type: string_vec_byref_const + std::vector accept_typesList; + transfer_string_list_contents(accept_types, accept_typesList); + + // Execute + bool _retval = CefDialogHandlerCppToC::Get(self)->OnFileDialog( + CefBrowserCToCpp::Wrap(browser), + mode, + CefString(title), + CefString(default_file_name), + accept_typesList, + CefFileDialogCallbackCToCpp::Wrap(callback)); + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefDialogHandlerCppToC::CefDialogHandlerCppToC(CefDialogHandler* cls) + : CefCppToC( + cls) { + struct_.struct_.on_file_dialog = dialog_handler_on_file_dialog; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/dialog_handler_cpptoc.h b/cef3/libcef_dll/cpptoc/dialog_handler_cpptoc.h new file mode 100644 index 000000000..9d69fbadf --- /dev/null +++ b/cef3/libcef_dll/cpptoc/dialog_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_DIALOG_HANDLER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_DIALOG_HANDLER_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_dialog_handler.h" +#include "include/capi/cef_dialog_handler_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefDialogHandlerCppToC + : public CefCppToC { + public: + explicit CefDialogHandlerCppToC(CefDialogHandler* cls); + virtual ~CefDialogHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_DIALOG_HANDLER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/dictionary_value_cpptoc.cc b/cef3/libcef_dll/cpptoc/dictionary_value_cpptoc.cc new file mode 100644 index 000000000..3875fb901 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/dictionary_value_cpptoc.cc @@ -0,0 +1,577 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/binary_value_cpptoc.h" +#include "libcef_dll/cpptoc/dictionary_value_cpptoc.h" +#include "libcef_dll/cpptoc/list_value_cpptoc.h" +#include "libcef_dll/transfer_util.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_dictionary_value_t* cef_dictionary_value_create() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = CefDictionaryValue::Create(); + + // Return type: refptr_same + return CefDictionaryValueCppToC::Wrap(_retval); +} + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK dictionary_value_is_valid( + struct _cef_dictionary_value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefDictionaryValueCppToC::Get(self)->IsValid(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK dictionary_value_is_owned( + struct _cef_dictionary_value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefDictionaryValueCppToC::Get(self)->IsOwned(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK dictionary_value_is_read_only( + struct _cef_dictionary_value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefDictionaryValueCppToC::Get(self)->IsReadOnly(); + + // Return type: bool + return _retval; +} + +struct _cef_dictionary_value_t* CEF_CALLBACK dictionary_value_copy( + struct _cef_dictionary_value_t* self, int exclude_empty_children) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefDictionaryValueCppToC::Get( + self)->Copy( + exclude_empty_children?true:false); + + // Return type: refptr_same + return CefDictionaryValueCppToC::Wrap(_retval); +} + +size_t CEF_CALLBACK dictionary_value_get_size( + struct _cef_dictionary_value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + size_t _retval = CefDictionaryValueCppToC::Get(self)->GetSize(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK dictionary_value_clear(struct _cef_dictionary_value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefDictionaryValueCppToC::Get(self)->Clear(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK dictionary_value_has_key(struct _cef_dictionary_value_t* self, + const cef_string_t* key) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: key; type: string_byref_const + DCHECK(key); + if (!key) + return 0; + + // Execute + bool _retval = CefDictionaryValueCppToC::Get(self)->HasKey( + CefString(key)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK dictionary_value_get_keys(struct _cef_dictionary_value_t* self, + cef_string_list_t keys) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: keys; type: string_vec_byref + DCHECK(keys); + if (!keys) + return 0; + + // Translate param: keys; type: string_vec_byref + std::vector keysList; + transfer_string_list_contents(keys, keysList); + + // Execute + bool _retval = CefDictionaryValueCppToC::Get(self)->GetKeys( + keysList); + + // Restore param: keys; type: string_vec_byref + cef_string_list_clear(keys); + transfer_string_list_contents(keysList, keys); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK dictionary_value_remove(struct _cef_dictionary_value_t* self, + const cef_string_t* key) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: key; type: string_byref_const + DCHECK(key); + if (!key) + return 0; + + // Execute + bool _retval = CefDictionaryValueCppToC::Get(self)->Remove( + CefString(key)); + + // Return type: bool + return _retval; +} + +enum cef_value_type_t CEF_CALLBACK dictionary_value_get_type( + struct _cef_dictionary_value_t* self, const cef_string_t* key) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return VTYPE_INVALID; + // Verify param: key; type: string_byref_const + DCHECK(key); + if (!key) + return VTYPE_INVALID; + + // Execute + cef_value_type_t _retval = CefDictionaryValueCppToC::Get(self)->GetType( + CefString(key)); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK dictionary_value_get_bool(struct _cef_dictionary_value_t* self, + const cef_string_t* key) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: key; type: string_byref_const + DCHECK(key); + if (!key) + return 0; + + // Execute + bool _retval = CefDictionaryValueCppToC::Get(self)->GetBool( + CefString(key)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK dictionary_value_get_int(struct _cef_dictionary_value_t* self, + const cef_string_t* key) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: key; type: string_byref_const + DCHECK(key); + if (!key) + return 0; + + // Execute + int _retval = CefDictionaryValueCppToC::Get(self)->GetInt( + CefString(key)); + + // Return type: simple + return _retval; +} + +double CEF_CALLBACK dictionary_value_get_double( + struct _cef_dictionary_value_t* self, const cef_string_t* key) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: key; type: string_byref_const + DCHECK(key); + if (!key) + return 0; + + // Execute + double _retval = CefDictionaryValueCppToC::Get(self)->GetDouble( + CefString(key)); + + // Return type: simple + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK dictionary_value_get_string( + struct _cef_dictionary_value_t* self, const cef_string_t* key) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: key; type: string_byref_const + DCHECK(key); + if (!key) + return NULL; + + // Execute + CefString _retval = CefDictionaryValueCppToC::Get(self)->GetString( + CefString(key)); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_binary_value_t* CEF_CALLBACK dictionary_value_get_binary( + struct _cef_dictionary_value_t* self, const cef_string_t* key) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: key; type: string_byref_const + DCHECK(key); + if (!key) + return NULL; + + // Execute + CefRefPtr _retval = CefDictionaryValueCppToC::Get( + self)->GetBinary( + CefString(key)); + + // Return type: refptr_same + return CefBinaryValueCppToC::Wrap(_retval); +} + +struct _cef_dictionary_value_t* CEF_CALLBACK dictionary_value_get_dictionary( + struct _cef_dictionary_value_t* self, const cef_string_t* key) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: key; type: string_byref_const + DCHECK(key); + if (!key) + return NULL; + + // Execute + CefRefPtr _retval = CefDictionaryValueCppToC::Get( + self)->GetDictionary( + CefString(key)); + + // Return type: refptr_same + return CefDictionaryValueCppToC::Wrap(_retval); +} + +struct _cef_list_value_t* CEF_CALLBACK dictionary_value_get_list( + struct _cef_dictionary_value_t* self, const cef_string_t* key) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: key; type: string_byref_const + DCHECK(key); + if (!key) + return NULL; + + // Execute + CefRefPtr _retval = CefDictionaryValueCppToC::Get( + self)->GetList( + CefString(key)); + + // Return type: refptr_same + return CefListValueCppToC::Wrap(_retval); +} + +int CEF_CALLBACK dictionary_value_set_null(struct _cef_dictionary_value_t* self, + const cef_string_t* key) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: key; type: string_byref_const + DCHECK(key); + if (!key) + return 0; + + // Execute + bool _retval = CefDictionaryValueCppToC::Get(self)->SetNull( + CefString(key)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK dictionary_value_set_bool(struct _cef_dictionary_value_t* self, + const cef_string_t* key, int value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: key; type: string_byref_const + DCHECK(key); + if (!key) + return 0; + + // Execute + bool _retval = CefDictionaryValueCppToC::Get(self)->SetBool( + CefString(key), + value?true:false); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK dictionary_value_set_int(struct _cef_dictionary_value_t* self, + const cef_string_t* key, int value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: key; type: string_byref_const + DCHECK(key); + if (!key) + return 0; + + // Execute + bool _retval = CefDictionaryValueCppToC::Get(self)->SetInt( + CefString(key), + value); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK dictionary_value_set_double( + struct _cef_dictionary_value_t* self, const cef_string_t* key, + double value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: key; type: string_byref_const + DCHECK(key); + if (!key) + return 0; + + // Execute + bool _retval = CefDictionaryValueCppToC::Get(self)->SetDouble( + CefString(key), + value); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK dictionary_value_set_string( + struct _cef_dictionary_value_t* self, const cef_string_t* key, + const cef_string_t* value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: key; type: string_byref_const + DCHECK(key); + if (!key) + return 0; + // Unverified params: value + + // Execute + bool _retval = CefDictionaryValueCppToC::Get(self)->SetString( + CefString(key), + CefString(value)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK dictionary_value_set_binary( + struct _cef_dictionary_value_t* self, const cef_string_t* key, + cef_binary_value_t* value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: key; type: string_byref_const + DCHECK(key); + if (!key) + return 0; + // Verify param: value; type: refptr_same + DCHECK(value); + if (!value) + return 0; + + // Execute + bool _retval = CefDictionaryValueCppToC::Get(self)->SetBinary( + CefString(key), + CefBinaryValueCppToC::Unwrap(value)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK dictionary_value_set_dictionary( + struct _cef_dictionary_value_t* self, const cef_string_t* key, + struct _cef_dictionary_value_t* value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: key; type: string_byref_const + DCHECK(key); + if (!key) + return 0; + // Verify param: value; type: refptr_same + DCHECK(value); + if (!value) + return 0; + + // Execute + bool _retval = CefDictionaryValueCppToC::Get(self)->SetDictionary( + CefString(key), + CefDictionaryValueCppToC::Unwrap(value)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK dictionary_value_set_list(struct _cef_dictionary_value_t* self, + const cef_string_t* key, struct _cef_list_value_t* value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: key; type: string_byref_const + DCHECK(key); + if (!key) + return 0; + // Verify param: value; type: refptr_same + DCHECK(value); + if (!value) + return 0; + + // Execute + bool _retval = CefDictionaryValueCppToC::Get(self)->SetList( + CefString(key), + CefListValueCppToC::Unwrap(value)); + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefDictionaryValueCppToC::CefDictionaryValueCppToC(CefDictionaryValue* cls) + : CefCppToC(cls) { + struct_.struct_.is_valid = dictionary_value_is_valid; + struct_.struct_.is_owned = dictionary_value_is_owned; + struct_.struct_.is_read_only = dictionary_value_is_read_only; + struct_.struct_.copy = dictionary_value_copy; + struct_.struct_.get_size = dictionary_value_get_size; + struct_.struct_.clear = dictionary_value_clear; + struct_.struct_.has_key = dictionary_value_has_key; + struct_.struct_.get_keys = dictionary_value_get_keys; + struct_.struct_.remove = dictionary_value_remove; + struct_.struct_.get_type = dictionary_value_get_type; + struct_.struct_.get_bool = dictionary_value_get_bool; + struct_.struct_.get_int = dictionary_value_get_int; + struct_.struct_.get_double = dictionary_value_get_double; + struct_.struct_.get_string = dictionary_value_get_string; + struct_.struct_.get_binary = dictionary_value_get_binary; + struct_.struct_.get_dictionary = dictionary_value_get_dictionary; + struct_.struct_.get_list = dictionary_value_get_list; + struct_.struct_.set_null = dictionary_value_set_null; + struct_.struct_.set_bool = dictionary_value_set_bool; + struct_.struct_.set_int = dictionary_value_set_int; + struct_.struct_.set_double = dictionary_value_set_double; + struct_.struct_.set_string = dictionary_value_set_string; + struct_.struct_.set_binary = dictionary_value_set_binary; + struct_.struct_.set_dictionary = dictionary_value_set_dictionary; + struct_.struct_.set_list = dictionary_value_set_list; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/dictionary_value_cpptoc.h b/cef3/libcef_dll/cpptoc/dictionary_value_cpptoc.h new file mode 100644 index 000000000..0b752e9f8 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/dictionary_value_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_DICTIONARY_VALUE_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_DICTIONARY_VALUE_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_values.h" +#include "include/capi/cef_values_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefDictionaryValueCppToC + : public CefCppToC { + public: + explicit CefDictionaryValueCppToC(CefDictionaryValue* cls); + virtual ~CefDictionaryValueCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_DICTIONARY_VALUE_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/display_handler_cpptoc.cc b/cef3/libcef_dll/cpptoc/display_handler_cpptoc.cc new file mode 100644 index 000000000..dcf222d42 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/display_handler_cpptoc.cc @@ -0,0 +1,178 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/display_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/frame_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK display_handler_on_loading_state_change( + struct _cef_display_handler_t* self, cef_browser_t* browser, int isLoading, + int canGoBack, int canGoForward) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + + // Execute + CefDisplayHandlerCppToC::Get(self)->OnLoadingStateChange( + CefBrowserCToCpp::Wrap(browser), + isLoading?true:false, + canGoBack?true:false, + canGoForward?true:false); +} + +void CEF_CALLBACK display_handler_on_address_change( + struct _cef_display_handler_t* self, cef_browser_t* browser, + struct _cef_frame_t* frame, const cef_string_t* url) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return; + // Verify param: url; type: string_byref_const + DCHECK(url); + if (!url) + return; + + // Execute + CefDisplayHandlerCppToC::Get(self)->OnAddressChange( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + CefString(url)); +} + +void CEF_CALLBACK display_handler_on_title_change( + struct _cef_display_handler_t* self, cef_browser_t* browser, + const cef_string_t* title) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Unverified params: title + + // Execute + CefDisplayHandlerCppToC::Get(self)->OnTitleChange( + CefBrowserCToCpp::Wrap(browser), + CefString(title)); +} + +int CEF_CALLBACK display_handler_on_tooltip(struct _cef_display_handler_t* self, + cef_browser_t* browser, cef_string_t* text) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Unverified params: text + + // Translate param: text; type: string_byref + CefString textStr(text); + + // Execute + bool _retval = CefDisplayHandlerCppToC::Get(self)->OnTooltip( + CefBrowserCToCpp::Wrap(browser), + textStr); + + // Return type: bool + return _retval; +} + +void CEF_CALLBACK display_handler_on_status_message( + struct _cef_display_handler_t* self, cef_browser_t* browser, + const cef_string_t* value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Unverified params: value + + // Execute + CefDisplayHandlerCppToC::Get(self)->OnStatusMessage( + CefBrowserCToCpp::Wrap(browser), + CefString(value)); +} + +int CEF_CALLBACK display_handler_on_console_message( + struct _cef_display_handler_t* self, cef_browser_t* browser, + const cef_string_t* message, const cef_string_t* source, int line) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Unverified params: message, source + + // Execute + bool _retval = CefDisplayHandlerCppToC::Get(self)->OnConsoleMessage( + CefBrowserCToCpp::Wrap(browser), + CefString(message), + CefString(source), + line); + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefDisplayHandlerCppToC::CefDisplayHandlerCppToC(CefDisplayHandler* cls) + : CefCppToC(cls) { + struct_.struct_.on_loading_state_change = + display_handler_on_loading_state_change; + struct_.struct_.on_address_change = display_handler_on_address_change; + struct_.struct_.on_title_change = display_handler_on_title_change; + struct_.struct_.on_tooltip = display_handler_on_tooltip; + struct_.struct_.on_status_message = display_handler_on_status_message; + struct_.struct_.on_console_message = display_handler_on_console_message; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/display_handler_cpptoc.h b/cef3/libcef_dll/cpptoc/display_handler_cpptoc.h new file mode 100644 index 000000000..bfa04645d --- /dev/null +++ b/cef3/libcef_dll/cpptoc/display_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_DISPLAY_HANDLER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_DISPLAY_HANDLER_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_display_handler.h" +#include "include/capi/cef_display_handler_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefDisplayHandlerCppToC + : public CefCppToC { + public: + explicit CefDisplayHandlerCppToC(CefDisplayHandler* cls); + virtual ~CefDisplayHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_DISPLAY_HANDLER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/domdocument_cpptoc.cc b/cef3/libcef_dll/cpptoc/domdocument_cpptoc.cc new file mode 100644 index 000000000..74ca72f43 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/domdocument_cpptoc.cc @@ -0,0 +1,303 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/domdocument_cpptoc.h" +#include "libcef_dll/cpptoc/domnode_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +enum cef_dom_document_type_t CEF_CALLBACK domdocument_get_type( + struct _cef_domdocument_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return DOM_DOCUMENT_TYPE_UNKNOWN; + + // Execute + cef_dom_document_type_t _retval = CefDOMDocumentCppToC::Get(self)->GetType(); + + // Return type: simple + return _retval; +} + +struct _cef_domnode_t* CEF_CALLBACK domdocument_get_document( + struct _cef_domdocument_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefDOMDocumentCppToC::Get(self)->GetDocument( + ); + + // Return type: refptr_same + return CefDOMNodeCppToC::Wrap(_retval); +} + +struct _cef_domnode_t* CEF_CALLBACK domdocument_get_body( + struct _cef_domdocument_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefDOMDocumentCppToC::Get(self)->GetBody(); + + // Return type: refptr_same + return CefDOMNodeCppToC::Wrap(_retval); +} + +struct _cef_domnode_t* CEF_CALLBACK domdocument_get_head( + struct _cef_domdocument_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefDOMDocumentCppToC::Get(self)->GetHead(); + + // Return type: refptr_same + return CefDOMNodeCppToC::Wrap(_retval); +} + +cef_string_userfree_t CEF_CALLBACK domdocument_get_title( + struct _cef_domdocument_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefDOMDocumentCppToC::Get(self)->GetTitle(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +struct _cef_domnode_t* CEF_CALLBACK domdocument_get_element_by_id( + struct _cef_domdocument_t* self, const cef_string_t* id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: id; type: string_byref_const + DCHECK(id); + if (!id) + return NULL; + + // Execute + CefRefPtr _retval = CefDOMDocumentCppToC::Get( + self)->GetElementById( + CefString(id)); + + // Return type: refptr_same + return CefDOMNodeCppToC::Wrap(_retval); +} + +struct _cef_domnode_t* CEF_CALLBACK domdocument_get_focused_node( + struct _cef_domdocument_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefDOMDocumentCppToC::Get( + self)->GetFocusedNode(); + + // Return type: refptr_same + return CefDOMNodeCppToC::Wrap(_retval); +} + +int CEF_CALLBACK domdocument_has_selection(struct _cef_domdocument_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefDOMDocumentCppToC::Get(self)->HasSelection(); + + // Return type: bool + return _retval; +} + +struct _cef_domnode_t* CEF_CALLBACK domdocument_get_selection_start_node( + struct _cef_domdocument_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefDOMDocumentCppToC::Get( + self)->GetSelectionStartNode(); + + // Return type: refptr_same + return CefDOMNodeCppToC::Wrap(_retval); +} + +int CEF_CALLBACK domdocument_get_selection_start_offset( + struct _cef_domdocument_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefDOMDocumentCppToC::Get(self)->GetSelectionStartOffset(); + + // Return type: simple + return _retval; +} + +struct _cef_domnode_t* CEF_CALLBACK domdocument_get_selection_end_node( + struct _cef_domdocument_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefDOMDocumentCppToC::Get( + self)->GetSelectionEndNode(); + + // Return type: refptr_same + return CefDOMNodeCppToC::Wrap(_retval); +} + +int CEF_CALLBACK domdocument_get_selection_end_offset( + struct _cef_domdocument_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefDOMDocumentCppToC::Get(self)->GetSelectionEndOffset(); + + // Return type: simple + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK domdocument_get_selection_as_markup( + struct _cef_domdocument_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefDOMDocumentCppToC::Get(self)->GetSelectionAsMarkup(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK domdocument_get_selection_as_text( + struct _cef_domdocument_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefDOMDocumentCppToC::Get(self)->GetSelectionAsText(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK domdocument_get_base_url( + struct _cef_domdocument_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefDOMDocumentCppToC::Get(self)->GetBaseURL(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK domdocument_get_complete_url( + struct _cef_domdocument_t* self, const cef_string_t* partialURL) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: partialURL; type: string_byref_const + DCHECK(partialURL); + if (!partialURL) + return NULL; + + // Execute + CefString _retval = CefDOMDocumentCppToC::Get(self)->GetCompleteURL( + CefString(partialURL)); + + // Return type: string + return _retval.DetachToUserFree(); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefDOMDocumentCppToC::CefDOMDocumentCppToC(CefDOMDocument* cls) + : CefCppToC(cls) { + struct_.struct_.get_type = domdocument_get_type; + struct_.struct_.get_document = domdocument_get_document; + struct_.struct_.get_body = domdocument_get_body; + struct_.struct_.get_head = domdocument_get_head; + struct_.struct_.get_title = domdocument_get_title; + struct_.struct_.get_element_by_id = domdocument_get_element_by_id; + struct_.struct_.get_focused_node = domdocument_get_focused_node; + struct_.struct_.has_selection = domdocument_has_selection; + struct_.struct_.get_selection_start_node = + domdocument_get_selection_start_node; + struct_.struct_.get_selection_start_offset = + domdocument_get_selection_start_offset; + struct_.struct_.get_selection_end_node = domdocument_get_selection_end_node; + struct_.struct_.get_selection_end_offset = + domdocument_get_selection_end_offset; + struct_.struct_.get_selection_as_markup = domdocument_get_selection_as_markup; + struct_.struct_.get_selection_as_text = domdocument_get_selection_as_text; + struct_.struct_.get_base_url = domdocument_get_base_url; + struct_.struct_.get_complete_url = domdocument_get_complete_url; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/domdocument_cpptoc.h b/cef3/libcef_dll/cpptoc/domdocument_cpptoc.h new file mode 100644 index 000000000..5c394b3f0 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/domdocument_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_DOMDOCUMENT_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_DOMDOCUMENT_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_dom.h" +#include "include/capi/cef_dom_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefDOMDocumentCppToC + : public CefCppToC { + public: + explicit CefDOMDocumentCppToC(CefDOMDocument* cls); + virtual ~CefDOMDocumentCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_DOMDOCUMENT_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/domevent_cpptoc.cc b/cef3/libcef_dll/cpptoc/domevent_cpptoc.cc new file mode 100644 index 000000000..41ef97905 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/domevent_cpptoc.cc @@ -0,0 +1,159 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/domdocument_cpptoc.h" +#include "libcef_dll/cpptoc/domevent_cpptoc.h" +#include "libcef_dll/cpptoc/domnode_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +cef_string_userfree_t CEF_CALLBACK domevent_get_type( + struct _cef_domevent_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefDOMEventCppToC::Get(self)->GetType(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +enum cef_dom_event_category_t CEF_CALLBACK domevent_get_category( + struct _cef_domevent_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return DOM_EVENT_CATEGORY_UNKNOWN; + + // Execute + cef_dom_event_category_t _retval = CefDOMEventCppToC::Get(self)->GetCategory( + ); + + // Return type: simple + return _retval; +} + +enum cef_dom_event_phase_t CEF_CALLBACK domevent_get_phase( + struct _cef_domevent_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return DOM_EVENT_PHASE_UNKNOWN; + + // Execute + cef_dom_event_phase_t _retval = CefDOMEventCppToC::Get(self)->GetPhase(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK domevent_can_bubble(struct _cef_domevent_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefDOMEventCppToC::Get(self)->CanBubble(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK domevent_can_cancel(struct _cef_domevent_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefDOMEventCppToC::Get(self)->CanCancel(); + + // Return type: bool + return _retval; +} + +cef_domdocument_t* CEF_CALLBACK domevent_get_document( + struct _cef_domevent_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefDOMEventCppToC::Get(self)->GetDocument( + ); + + // Return type: refptr_same + return CefDOMDocumentCppToC::Wrap(_retval); +} + +cef_domnode_t* CEF_CALLBACK domevent_get_target(struct _cef_domevent_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefDOMEventCppToC::Get(self)->GetTarget(); + + // Return type: refptr_same + return CefDOMNodeCppToC::Wrap(_retval); +} + +cef_domnode_t* CEF_CALLBACK domevent_get_current_target( + struct _cef_domevent_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefDOMEventCppToC::Get( + self)->GetCurrentTarget(); + + // Return type: refptr_same + return CefDOMNodeCppToC::Wrap(_retval); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefDOMEventCppToC::CefDOMEventCppToC(CefDOMEvent* cls) + : CefCppToC(cls) { + struct_.struct_.get_type = domevent_get_type; + struct_.struct_.get_category = domevent_get_category; + struct_.struct_.get_phase = domevent_get_phase; + struct_.struct_.can_bubble = domevent_can_bubble; + struct_.struct_.can_cancel = domevent_can_cancel; + struct_.struct_.get_document = domevent_get_document; + struct_.struct_.get_target = domevent_get_target; + struct_.struct_.get_current_target = domevent_get_current_target; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/domevent_cpptoc.h b/cef3/libcef_dll/cpptoc/domevent_cpptoc.h new file mode 100644 index 000000000..956688d39 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/domevent_cpptoc.h @@ -0,0 +1,36 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_DOMEVENT_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_DOMEVENT_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_dom.h" +#include "include/capi/cef_dom_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefDOMEventCppToC + : public CefCppToC { + public: + explicit CefDOMEventCppToC(CefDOMEvent* cls); + virtual ~CefDOMEventCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_DOMEVENT_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/domevent_listener_cpptoc.cc b/cef3/libcef_dll/cpptoc/domevent_listener_cpptoc.cc new file mode 100644 index 000000000..50e0158a2 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/domevent_listener_cpptoc.cc @@ -0,0 +1,49 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/domevent_listener_cpptoc.h" +#include "libcef_dll/ctocpp/domevent_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK domevent_listener_handle_event( + struct _cef_domevent_listener_t* self, cef_domevent_t* event) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: event; type: refptr_diff + DCHECK(event); + if (!event) + return; + + // Execute + CefDOMEventListenerCppToC::Get(self)->HandleEvent( + CefDOMEventCToCpp::Wrap(event)); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefDOMEventListenerCppToC::CefDOMEventListenerCppToC(CefDOMEventListener* cls) + : CefCppToC(cls) { + struct_.struct_.handle_event = domevent_listener_handle_event; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/domevent_listener_cpptoc.h b/cef3/libcef_dll/cpptoc/domevent_listener_cpptoc.h new file mode 100644 index 000000000..4e8c84d7b --- /dev/null +++ b/cef3/libcef_dll/cpptoc/domevent_listener_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_DOMEVENT_LISTENER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_DOMEVENT_LISTENER_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_dom.h" +#include "include/capi/cef_dom_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefDOMEventListenerCppToC + : public CefCppToC { + public: + explicit CefDOMEventListenerCppToC(CefDOMEventListener* cls); + virtual ~CefDOMEventListenerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_DOMEVENT_LISTENER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/domnode_cpptoc.cc b/cef3/libcef_dll/cpptoc/domnode_cpptoc.cc new file mode 100644 index 000000000..d39a495d7 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/domnode_cpptoc.cc @@ -0,0 +1,494 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/domdocument_cpptoc.h" +#include "libcef_dll/cpptoc/domnode_cpptoc.h" +#include "libcef_dll/ctocpp/domevent_listener_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +enum cef_dom_node_type_t CEF_CALLBACK domnode_get_type( + struct _cef_domnode_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return DOM_NODE_TYPE_UNSUPPORTED; + + // Execute + cef_dom_node_type_t _retval = CefDOMNodeCppToC::Get(self)->GetType(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK domnode_is_text(struct _cef_domnode_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefDOMNodeCppToC::Get(self)->IsText(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK domnode_is_element(struct _cef_domnode_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefDOMNodeCppToC::Get(self)->IsElement(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK domnode_is_editable(struct _cef_domnode_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefDOMNodeCppToC::Get(self)->IsEditable(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK domnode_is_form_control_element(struct _cef_domnode_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefDOMNodeCppToC::Get(self)->IsFormControlElement(); + + // Return type: bool + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK domnode_get_form_control_element_type( + struct _cef_domnode_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefDOMNodeCppToC::Get(self)->GetFormControlElementType(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +int CEF_CALLBACK domnode_is_same(struct _cef_domnode_t* self, + struct _cef_domnode_t* that) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: that; type: refptr_same + DCHECK(that); + if (!that) + return 0; + + // Execute + bool _retval = CefDOMNodeCppToC::Get(self)->IsSame( + CefDOMNodeCppToC::Unwrap(that)); + + // Return type: bool + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK domnode_get_name( + struct _cef_domnode_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefDOMNodeCppToC::Get(self)->GetName(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK domnode_get_value( + struct _cef_domnode_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefDOMNodeCppToC::Get(self)->GetValue(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +int CEF_CALLBACK domnode_set_value(struct _cef_domnode_t* self, + const cef_string_t* value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: value; type: string_byref_const + DCHECK(value); + if (!value) + return 0; + + // Execute + bool _retval = CefDOMNodeCppToC::Get(self)->SetValue( + CefString(value)); + + // Return type: bool + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK domnode_get_as_markup( + struct _cef_domnode_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefDOMNodeCppToC::Get(self)->GetAsMarkup(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_domdocument_t* CEF_CALLBACK domnode_get_document( + struct _cef_domnode_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefDOMNodeCppToC::Get(self)->GetDocument( + ); + + // Return type: refptr_same + return CefDOMDocumentCppToC::Wrap(_retval); +} + +struct _cef_domnode_t* CEF_CALLBACK domnode_get_parent( + struct _cef_domnode_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefDOMNodeCppToC::Get(self)->GetParent(); + + // Return type: refptr_same + return CefDOMNodeCppToC::Wrap(_retval); +} + +struct _cef_domnode_t* CEF_CALLBACK domnode_get_previous_sibling( + struct _cef_domnode_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefDOMNodeCppToC::Get( + self)->GetPreviousSibling(); + + // Return type: refptr_same + return CefDOMNodeCppToC::Wrap(_retval); +} + +struct _cef_domnode_t* CEF_CALLBACK domnode_get_next_sibling( + struct _cef_domnode_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefDOMNodeCppToC::Get(self)->GetNextSibling(); + + // Return type: refptr_same + return CefDOMNodeCppToC::Wrap(_retval); +} + +int CEF_CALLBACK domnode_has_children(struct _cef_domnode_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefDOMNodeCppToC::Get(self)->HasChildren(); + + // Return type: bool + return _retval; +} + +struct _cef_domnode_t* CEF_CALLBACK domnode_get_first_child( + struct _cef_domnode_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefDOMNodeCppToC::Get(self)->GetFirstChild(); + + // Return type: refptr_same + return CefDOMNodeCppToC::Wrap(_retval); +} + +struct _cef_domnode_t* CEF_CALLBACK domnode_get_last_child( + struct _cef_domnode_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefDOMNodeCppToC::Get(self)->GetLastChild(); + + // Return type: refptr_same + return CefDOMNodeCppToC::Wrap(_retval); +} + +void CEF_CALLBACK domnode_add_event_listener(struct _cef_domnode_t* self, + const cef_string_t* eventType, struct _cef_domevent_listener_t* listener, + int useCapture) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: eventType; type: string_byref_const + DCHECK(eventType); + if (!eventType) + return; + // Verify param: listener; type: refptr_diff + DCHECK(listener); + if (!listener) + return; + + // Execute + CefDOMNodeCppToC::Get(self)->AddEventListener( + CefString(eventType), + CefDOMEventListenerCToCpp::Wrap(listener), + useCapture?true:false); +} + +cef_string_userfree_t CEF_CALLBACK domnode_get_element_tag_name( + struct _cef_domnode_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefDOMNodeCppToC::Get(self)->GetElementTagName(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +int CEF_CALLBACK domnode_has_element_attributes(struct _cef_domnode_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefDOMNodeCppToC::Get(self)->HasElementAttributes(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK domnode_has_element_attribute(struct _cef_domnode_t* self, + const cef_string_t* attrName) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: attrName; type: string_byref_const + DCHECK(attrName); + if (!attrName) + return 0; + + // Execute + bool _retval = CefDOMNodeCppToC::Get(self)->HasElementAttribute( + CefString(attrName)); + + // Return type: bool + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK domnode_get_element_attribute( + struct _cef_domnode_t* self, const cef_string_t* attrName) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: attrName; type: string_byref_const + DCHECK(attrName); + if (!attrName) + return NULL; + + // Execute + CefString _retval = CefDOMNodeCppToC::Get(self)->GetElementAttribute( + CefString(attrName)); + + // Return type: string + return _retval.DetachToUserFree(); +} + +void CEF_CALLBACK domnode_get_element_attributes(struct _cef_domnode_t* self, + cef_string_map_t attrMap) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: attrMap; type: string_map_single_byref + DCHECK(attrMap); + if (!attrMap) + return; + + // Translate param: attrMap; type: string_map_single_byref + std::map attrMapMap; + transfer_string_map_contents(attrMap, attrMapMap); + + // Execute + CefDOMNodeCppToC::Get(self)->GetElementAttributes( + attrMapMap); + + // Restore param: attrMap; type: string_map_single_byref + cef_string_map_clear(attrMap); + transfer_string_map_contents(attrMapMap, attrMap); +} + +int CEF_CALLBACK domnode_set_element_attribute(struct _cef_domnode_t* self, + const cef_string_t* attrName, const cef_string_t* value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: attrName; type: string_byref_const + DCHECK(attrName); + if (!attrName) + return 0; + // Verify param: value; type: string_byref_const + DCHECK(value); + if (!value) + return 0; + + // Execute + bool _retval = CefDOMNodeCppToC::Get(self)->SetElementAttribute( + CefString(attrName), + CefString(value)); + + // Return type: bool + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK domnode_get_element_inner_text( + struct _cef_domnode_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefDOMNodeCppToC::Get(self)->GetElementInnerText(); + + // Return type: string + return _retval.DetachToUserFree(); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefDOMNodeCppToC::CefDOMNodeCppToC(CefDOMNode* cls) + : CefCppToC(cls) { + struct_.struct_.get_type = domnode_get_type; + struct_.struct_.is_text = domnode_is_text; + struct_.struct_.is_element = domnode_is_element; + struct_.struct_.is_editable = domnode_is_editable; + struct_.struct_.is_form_control_element = domnode_is_form_control_element; + struct_.struct_.get_form_control_element_type = + domnode_get_form_control_element_type; + struct_.struct_.is_same = domnode_is_same; + struct_.struct_.get_name = domnode_get_name; + struct_.struct_.get_value = domnode_get_value; + struct_.struct_.set_value = domnode_set_value; + struct_.struct_.get_as_markup = domnode_get_as_markup; + struct_.struct_.get_document = domnode_get_document; + struct_.struct_.get_parent = domnode_get_parent; + struct_.struct_.get_previous_sibling = domnode_get_previous_sibling; + struct_.struct_.get_next_sibling = domnode_get_next_sibling; + struct_.struct_.has_children = domnode_has_children; + struct_.struct_.get_first_child = domnode_get_first_child; + struct_.struct_.get_last_child = domnode_get_last_child; + struct_.struct_.add_event_listener = domnode_add_event_listener; + struct_.struct_.get_element_tag_name = domnode_get_element_tag_name; + struct_.struct_.has_element_attributes = domnode_has_element_attributes; + struct_.struct_.has_element_attribute = domnode_has_element_attribute; + struct_.struct_.get_element_attribute = domnode_get_element_attribute; + struct_.struct_.get_element_attributes = domnode_get_element_attributes; + struct_.struct_.set_element_attribute = domnode_set_element_attribute; + struct_.struct_.get_element_inner_text = domnode_get_element_inner_text; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/domnode_cpptoc.h b/cef3/libcef_dll/cpptoc/domnode_cpptoc.h new file mode 100644 index 000000000..c874c2c79 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/domnode_cpptoc.h @@ -0,0 +1,36 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_DOMNODE_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_DOMNODE_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_dom.h" +#include "include/capi/cef_dom_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefDOMNodeCppToC + : public CefCppToC { + public: + explicit CefDOMNodeCppToC(CefDOMNode* cls); + virtual ~CefDOMNodeCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_DOMNODE_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/domvisitor_cpptoc.cc b/cef3/libcef_dll/cpptoc/domvisitor_cpptoc.cc new file mode 100644 index 000000000..e3c649648 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/domvisitor_cpptoc.cc @@ -0,0 +1,48 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/domvisitor_cpptoc.h" +#include "libcef_dll/ctocpp/domdocument_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK domvisitor_visit(struct _cef_domvisitor_t* self, + struct _cef_domdocument_t* document) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: document; type: refptr_diff + DCHECK(document); + if (!document) + return; + + // Execute + CefDOMVisitorCppToC::Get(self)->Visit( + CefDOMDocumentCToCpp::Wrap(document)); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefDOMVisitorCppToC::CefDOMVisitorCppToC(CefDOMVisitor* cls) + : CefCppToC(cls) { + struct_.struct_.visit = domvisitor_visit; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/domvisitor_cpptoc.h b/cef3/libcef_dll/cpptoc/domvisitor_cpptoc.h new file mode 100644 index 000000000..21d015c89 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/domvisitor_cpptoc.h @@ -0,0 +1,36 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_DOMVISITOR_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_DOMVISITOR_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_dom.h" +#include "include/capi/cef_dom_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefDOMVisitorCppToC + : public CefCppToC { + public: + explicit CefDOMVisitorCppToC(CefDOMVisitor* cls); + virtual ~CefDOMVisitorCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_DOMVISITOR_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/download_handler_cpptoc.cc b/cef3/libcef_dll/cpptoc/download_handler_cpptoc.cc new file mode 100644 index 000000000..9963a05ee --- /dev/null +++ b/cef3/libcef_dll/cpptoc/download_handler_cpptoc.cc @@ -0,0 +1,100 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/download_handler_cpptoc.h" +#include "libcef_dll/ctocpp/before_download_callback_ctocpp.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/download_item_ctocpp.h" +#include "libcef_dll/ctocpp/download_item_callback_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK download_handler_on_before_download( + struct _cef_download_handler_t* self, cef_browser_t* browser, + struct _cef_download_item_t* download_item, + const cef_string_t* suggested_name, + cef_before_download_callback_t* callback) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: download_item; type: refptr_diff + DCHECK(download_item); + if (!download_item) + return; + // Verify param: suggested_name; type: string_byref_const + DCHECK(suggested_name); + if (!suggested_name) + return; + // Verify param: callback; type: refptr_diff + DCHECK(callback); + if (!callback) + return; + + // Execute + CefDownloadHandlerCppToC::Get(self)->OnBeforeDownload( + CefBrowserCToCpp::Wrap(browser), + CefDownloadItemCToCpp::Wrap(download_item), + CefString(suggested_name), + CefBeforeDownloadCallbackCToCpp::Wrap(callback)); +} + +void CEF_CALLBACK download_handler_on_download_updated( + struct _cef_download_handler_t* self, cef_browser_t* browser, + struct _cef_download_item_t* download_item, + cef_download_item_callback_t* callback) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: download_item; type: refptr_diff + DCHECK(download_item); + if (!download_item) + return; + // Verify param: callback; type: refptr_diff + DCHECK(callback); + if (!callback) + return; + + // Execute + CefDownloadHandlerCppToC::Get(self)->OnDownloadUpdated( + CefBrowserCToCpp::Wrap(browser), + CefDownloadItemCToCpp::Wrap(download_item), + CefDownloadItemCallbackCToCpp::Wrap(callback)); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefDownloadHandlerCppToC::CefDownloadHandlerCppToC(CefDownloadHandler* cls) + : CefCppToC(cls) { + struct_.struct_.on_before_download = download_handler_on_before_download; + struct_.struct_.on_download_updated = download_handler_on_download_updated; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/download_handler_cpptoc.h b/cef3/libcef_dll/cpptoc/download_handler_cpptoc.h new file mode 100644 index 000000000..b8c9ec319 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/download_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_DOWNLOAD_HANDLER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_DOWNLOAD_HANDLER_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_download_handler.h" +#include "include/capi/cef_download_handler_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefDownloadHandlerCppToC + : public CefCppToC { + public: + explicit CefDownloadHandlerCppToC(CefDownloadHandler* cls); + virtual ~CefDownloadHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_DOWNLOAD_HANDLER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/download_item_callback_cpptoc.cc b/cef3/libcef_dll/cpptoc/download_item_callback_cpptoc.cc new file mode 100644 index 000000000..3ba8f928b --- /dev/null +++ b/cef3/libcef_dll/cpptoc/download_item_callback_cpptoc.cc @@ -0,0 +1,44 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/download_item_callback_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK download_item_callback_cancel( + struct _cef_download_item_callback_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefDownloadItemCallbackCppToC::Get(self)->Cancel(); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefDownloadItemCallbackCppToC::CefDownloadItemCallbackCppToC( + CefDownloadItemCallback* cls) + : CefCppToC(cls) { + struct_.struct_.cancel = download_item_callback_cancel; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/download_item_callback_cpptoc.h b/cef3/libcef_dll/cpptoc/download_item_callback_cpptoc.h new file mode 100644 index 000000000..ebdf6432d --- /dev/null +++ b/cef3/libcef_dll/cpptoc/download_item_callback_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_DOWNLOAD_ITEM_CALLBACK_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_DOWNLOAD_ITEM_CALLBACK_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_download_handler.h" +#include "include/capi/cef_download_handler_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefDownloadItemCallbackCppToC + : public CefCppToC { + public: + explicit CefDownloadItemCallbackCppToC(CefDownloadItemCallback* cls); + virtual ~CefDownloadItemCallbackCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_DOWNLOAD_ITEM_CALLBACK_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/download_item_cpptoc.cc b/cef3/libcef_dll/cpptoc/download_item_cpptoc.cc new file mode 100644 index 000000000..326431426 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/download_item_cpptoc.cc @@ -0,0 +1,284 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/download_item_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK download_item_is_valid(struct _cef_download_item_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefDownloadItemCppToC::Get(self)->IsValid(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK download_item_is_in_progress( + struct _cef_download_item_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefDownloadItemCppToC::Get(self)->IsInProgress(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK download_item_is_complete(struct _cef_download_item_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefDownloadItemCppToC::Get(self)->IsComplete(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK download_item_is_canceled(struct _cef_download_item_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefDownloadItemCppToC::Get(self)->IsCanceled(); + + // Return type: bool + return _retval; +} + +int64 CEF_CALLBACK download_item_get_current_speed( + struct _cef_download_item_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int64 _retval = CefDownloadItemCppToC::Get(self)->GetCurrentSpeed(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK download_item_get_percent_complete( + struct _cef_download_item_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefDownloadItemCppToC::Get(self)->GetPercentComplete(); + + // Return type: simple + return _retval; +} + +int64 CEF_CALLBACK download_item_get_total_bytes( + struct _cef_download_item_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int64 _retval = CefDownloadItemCppToC::Get(self)->GetTotalBytes(); + + // Return type: simple + return _retval; +} + +int64 CEF_CALLBACK download_item_get_received_bytes( + struct _cef_download_item_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int64 _retval = CefDownloadItemCppToC::Get(self)->GetReceivedBytes(); + + // Return type: simple + return _retval; +} + +cef_time_t CEF_CALLBACK download_item_get_start_time( + struct _cef_download_item_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CefTime(); + + // Execute + cef_time_t _retval = CefDownloadItemCppToC::Get(self)->GetStartTime(); + + // Return type: simple + return _retval; +} + +cef_time_t CEF_CALLBACK download_item_get_end_time( + struct _cef_download_item_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CefTime(); + + // Execute + cef_time_t _retval = CefDownloadItemCppToC::Get(self)->GetEndTime(); + + // Return type: simple + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK download_item_get_full_path( + struct _cef_download_item_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefDownloadItemCppToC::Get(self)->GetFullPath(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +int32 CEF_CALLBACK download_item_get_id(struct _cef_download_item_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int32 _retval = CefDownloadItemCppToC::Get(self)->GetId(); + + // Return type: simple + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK download_item_get_url( + struct _cef_download_item_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefDownloadItemCppToC::Get(self)->GetURL(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK download_item_get_suggested_file_name( + struct _cef_download_item_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefDownloadItemCppToC::Get(self)->GetSuggestedFileName(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK download_item_get_content_disposition( + struct _cef_download_item_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefDownloadItemCppToC::Get(self)->GetContentDisposition(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK download_item_get_mime_type( + struct _cef_download_item_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefDownloadItemCppToC::Get(self)->GetMimeType(); + + // Return type: string + return _retval.DetachToUserFree(); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefDownloadItemCppToC::CefDownloadItemCppToC(CefDownloadItem* cls) + : CefCppToC( + cls) { + struct_.struct_.is_valid = download_item_is_valid; + struct_.struct_.is_in_progress = download_item_is_in_progress; + struct_.struct_.is_complete = download_item_is_complete; + struct_.struct_.is_canceled = download_item_is_canceled; + struct_.struct_.get_current_speed = download_item_get_current_speed; + struct_.struct_.get_percent_complete = download_item_get_percent_complete; + struct_.struct_.get_total_bytes = download_item_get_total_bytes; + struct_.struct_.get_received_bytes = download_item_get_received_bytes; + struct_.struct_.get_start_time = download_item_get_start_time; + struct_.struct_.get_end_time = download_item_get_end_time; + struct_.struct_.get_full_path = download_item_get_full_path; + struct_.struct_.get_id = download_item_get_id; + struct_.struct_.get_url = download_item_get_url; + struct_.struct_.get_suggested_file_name = + download_item_get_suggested_file_name; + struct_.struct_.get_content_disposition = + download_item_get_content_disposition; + struct_.struct_.get_mime_type = download_item_get_mime_type; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/download_item_cpptoc.h b/cef3/libcef_dll/cpptoc/download_item_cpptoc.h new file mode 100644 index 000000000..960045f70 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/download_item_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_DOWNLOAD_ITEM_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_DOWNLOAD_ITEM_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_download_item.h" +#include "include/capi/cef_download_item_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefDownloadItemCppToC + : public CefCppToC { + public: + explicit CefDownloadItemCppToC(CefDownloadItem* cls); + virtual ~CefDownloadItemCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_DOWNLOAD_ITEM_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/file_dialog_callback_cpptoc.cc b/cef3/libcef_dll/cpptoc/file_dialog_callback_cpptoc.cc new file mode 100644 index 000000000..ef3dc449c --- /dev/null +++ b/cef3/libcef_dll/cpptoc/file_dialog_callback_cpptoc.cc @@ -0,0 +1,67 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/file_dialog_callback_cpptoc.h" +#include "libcef_dll/transfer_util.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK file_dialog_callback_cont( + struct _cef_file_dialog_callback_t* self, cef_string_list_t file_paths) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: file_paths; type: string_vec_byref_const + DCHECK(file_paths); + if (!file_paths) + return; + + // Translate param: file_paths; type: string_vec_byref_const + std::vector file_pathsList; + transfer_string_list_contents(file_paths, file_pathsList); + + // Execute + CefFileDialogCallbackCppToC::Get(self)->Continue( + file_pathsList); +} + +void CEF_CALLBACK file_dialog_callback_cancel( + struct _cef_file_dialog_callback_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefFileDialogCallbackCppToC::Get(self)->Cancel(); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefFileDialogCallbackCppToC::CefFileDialogCallbackCppToC( + CefFileDialogCallback* cls) + : CefCppToC(cls) { + struct_.struct_.cont = file_dialog_callback_cont; + struct_.struct_.cancel = file_dialog_callback_cancel; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/file_dialog_callback_cpptoc.h b/cef3/libcef_dll/cpptoc/file_dialog_callback_cpptoc.h new file mode 100644 index 000000000..7c430f2d3 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/file_dialog_callback_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_FILE_DIALOG_CALLBACK_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_FILE_DIALOG_CALLBACK_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_dialog_handler.h" +#include "include/capi/cef_dialog_handler_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefFileDialogCallbackCppToC + : public CefCppToC { + public: + explicit CefFileDialogCallbackCppToC(CefFileDialogCallback* cls); + virtual ~CefFileDialogCallbackCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_FILE_DIALOG_CALLBACK_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/focus_handler_cpptoc.cc b/cef3/libcef_dll/cpptoc/focus_handler_cpptoc.cc new file mode 100644 index 000000000..09d7038c4 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/focus_handler_cpptoc.cc @@ -0,0 +1,90 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/focus_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK focus_handler_on_take_focus(struct _cef_focus_handler_t* self, + cef_browser_t* browser, int next) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + + // Execute + CefFocusHandlerCppToC::Get(self)->OnTakeFocus( + CefBrowserCToCpp::Wrap(browser), + next?true:false); +} + +int CEF_CALLBACK focus_handler_on_set_focus(struct _cef_focus_handler_t* self, + cef_browser_t* browser, enum cef_focus_source_t source) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + + // Execute + bool _retval = CefFocusHandlerCppToC::Get(self)->OnSetFocus( + CefBrowserCToCpp::Wrap(browser), + source); + + // Return type: bool + return _retval; +} + +void CEF_CALLBACK focus_handler_on_got_focus(struct _cef_focus_handler_t* self, + cef_browser_t* browser) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + + // Execute + CefFocusHandlerCppToC::Get(self)->OnGotFocus( + CefBrowserCToCpp::Wrap(browser)); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefFocusHandlerCppToC::CefFocusHandlerCppToC(CefFocusHandler* cls) + : CefCppToC( + cls) { + struct_.struct_.on_take_focus = focus_handler_on_take_focus; + struct_.struct_.on_set_focus = focus_handler_on_set_focus; + struct_.struct_.on_got_focus = focus_handler_on_got_focus; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/focus_handler_cpptoc.h b/cef3/libcef_dll/cpptoc/focus_handler_cpptoc.h new file mode 100644 index 000000000..5ed79a643 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/focus_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_FOCUS_HANDLER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_FOCUS_HANDLER_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_focus_handler.h" +#include "include/capi/cef_focus_handler_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefFocusHandlerCppToC + : public CefCppToC { + public: + explicit CefFocusHandlerCppToC(CefFocusHandler* cls); + virtual ~CefFocusHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_FOCUS_HANDLER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/frame_cpptoc.cc b/cef3/libcef_dll/cpptoc/frame_cpptoc.cc new file mode 100644 index 000000000..2b0f8fa49 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/frame_cpptoc.cc @@ -0,0 +1,401 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/cpptoc/frame_cpptoc.h" +#include "libcef_dll/cpptoc/request_cpptoc.h" +#include "libcef_dll/cpptoc/v8context_cpptoc.h" +#include "libcef_dll/ctocpp/domvisitor_ctocpp.h" +#include "libcef_dll/ctocpp/string_visitor_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK frame_is_valid(struct _cef_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefFrameCppToC::Get(self)->IsValid(); + + // Return type: bool + return _retval; +} + +void CEF_CALLBACK frame_undo(struct _cef_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefFrameCppToC::Get(self)->Undo(); +} + +void CEF_CALLBACK frame_redo(struct _cef_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefFrameCppToC::Get(self)->Redo(); +} + +void CEF_CALLBACK frame_cut(struct _cef_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefFrameCppToC::Get(self)->Cut(); +} + +void CEF_CALLBACK frame_copy(struct _cef_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefFrameCppToC::Get(self)->Copy(); +} + +void CEF_CALLBACK frame_paste(struct _cef_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefFrameCppToC::Get(self)->Paste(); +} + +void CEF_CALLBACK frame_del(struct _cef_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefFrameCppToC::Get(self)->Delete(); +} + +void CEF_CALLBACK frame_select_all(struct _cef_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefFrameCppToC::Get(self)->SelectAll(); +} + +void CEF_CALLBACK frame_view_source(struct _cef_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefFrameCppToC::Get(self)->ViewSource(); +} + +void CEF_CALLBACK frame_get_source(struct _cef_frame_t* self, + struct _cef_string_visitor_t* visitor) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: visitor; type: refptr_diff + DCHECK(visitor); + if (!visitor) + return; + + // Execute + CefFrameCppToC::Get(self)->GetSource( + CefStringVisitorCToCpp::Wrap(visitor)); +} + +void CEF_CALLBACK frame_get_text(struct _cef_frame_t* self, + struct _cef_string_visitor_t* visitor) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: visitor; type: refptr_diff + DCHECK(visitor); + if (!visitor) + return; + + // Execute + CefFrameCppToC::Get(self)->GetText( + CefStringVisitorCToCpp::Wrap(visitor)); +} + +void CEF_CALLBACK frame_load_request(struct _cef_frame_t* self, + struct _cef_request_t* request) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: request; type: refptr_same + DCHECK(request); + if (!request) + return; + + // Execute + CefFrameCppToC::Get(self)->LoadRequest( + CefRequestCppToC::Unwrap(request)); +} + +void CEF_CALLBACK frame_load_url(struct _cef_frame_t* self, + const cef_string_t* url) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: url; type: string_byref_const + DCHECK(url); + if (!url) + return; + + // Execute + CefFrameCppToC::Get(self)->LoadURL( + CefString(url)); +} + +void CEF_CALLBACK frame_load_string(struct _cef_frame_t* self, + const cef_string_t* string_val, const cef_string_t* url) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: string_val; type: string_byref_const + DCHECK(string_val); + if (!string_val) + return; + // Verify param: url; type: string_byref_const + DCHECK(url); + if (!url) + return; + + // Execute + CefFrameCppToC::Get(self)->LoadString( + CefString(string_val), + CefString(url)); +} + +void CEF_CALLBACK frame_execute_java_script(struct _cef_frame_t* self, + const cef_string_t* code, const cef_string_t* script_url, + int start_line) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: code; type: string_byref_const + DCHECK(code); + if (!code) + return; + // Unverified params: script_url + + // Execute + CefFrameCppToC::Get(self)->ExecuteJavaScript( + CefString(code), + CefString(script_url), + start_line); +} + +int CEF_CALLBACK frame_is_main(struct _cef_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefFrameCppToC::Get(self)->IsMain(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK frame_is_focused(struct _cef_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefFrameCppToC::Get(self)->IsFocused(); + + // Return type: bool + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK frame_get_name(struct _cef_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefFrameCppToC::Get(self)->GetName(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +int64 CEF_CALLBACK frame_get_identifier(struct _cef_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int64 _retval = CefFrameCppToC::Get(self)->GetIdentifier(); + + // Return type: simple + return _retval; +} + +struct _cef_frame_t* CEF_CALLBACK frame_get_parent(struct _cef_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefFrameCppToC::Get(self)->GetParent(); + + // Return type: refptr_same + return CefFrameCppToC::Wrap(_retval); +} + +cef_string_userfree_t CEF_CALLBACK frame_get_url(struct _cef_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefFrameCppToC::Get(self)->GetURL(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_browser_t* CEF_CALLBACK frame_get_browser(struct _cef_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefFrameCppToC::Get(self)->GetBrowser(); + + // Return type: refptr_same + return CefBrowserCppToC::Wrap(_retval); +} + +struct _cef_v8context_t* CEF_CALLBACK frame_get_v8context( + struct _cef_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefFrameCppToC::Get(self)->GetV8Context(); + + // Return type: refptr_same + return CefV8ContextCppToC::Wrap(_retval); +} + +void CEF_CALLBACK frame_visit_dom(struct _cef_frame_t* self, + cef_domvisitor_t* visitor) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: visitor; type: refptr_diff + DCHECK(visitor); + if (!visitor) + return; + + // Execute + CefFrameCppToC::Get(self)->VisitDOM( + CefDOMVisitorCToCpp::Wrap(visitor)); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefFrameCppToC::CefFrameCppToC(CefFrame* cls) + : CefCppToC(cls) { + struct_.struct_.is_valid = frame_is_valid; + struct_.struct_.undo = frame_undo; + struct_.struct_.redo = frame_redo; + struct_.struct_.cut = frame_cut; + struct_.struct_.copy = frame_copy; + struct_.struct_.paste = frame_paste; + struct_.struct_.del = frame_del; + struct_.struct_.select_all = frame_select_all; + struct_.struct_.view_source = frame_view_source; + struct_.struct_.get_source = frame_get_source; + struct_.struct_.get_text = frame_get_text; + struct_.struct_.load_request = frame_load_request; + struct_.struct_.load_url = frame_load_url; + struct_.struct_.load_string = frame_load_string; + struct_.struct_.execute_java_script = frame_execute_java_script; + struct_.struct_.is_main = frame_is_main; + struct_.struct_.is_focused = frame_is_focused; + struct_.struct_.get_name = frame_get_name; + struct_.struct_.get_identifier = frame_get_identifier; + struct_.struct_.get_parent = frame_get_parent; + struct_.struct_.get_url = frame_get_url; + struct_.struct_.get_browser = frame_get_browser; + struct_.struct_.get_v8context = frame_get_v8context; + struct_.struct_.visit_dom = frame_visit_dom; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = + 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/frame_cpptoc.h b/cef3/libcef_dll/cpptoc/frame_cpptoc.h new file mode 100644 index 000000000..5027e2192 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/frame_cpptoc.h @@ -0,0 +1,40 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_FRAME_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_FRAME_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_frame.h" +#include "include/capi/cef_frame_capi.h" +#include "include/cef_browser.h" +#include "include/capi/cef_browser_capi.h" +#include "include/cef_v8.h" +#include "include/capi/cef_v8_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefFrameCppToC + : public CefCppToC { + public: + explicit CefFrameCppToC(CefFrame* cls); + virtual ~CefFrameCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_FRAME_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/geolocation_callback_cpptoc.cc b/cef3/libcef_dll/cpptoc/geolocation_callback_cpptoc.cc new file mode 100644 index 000000000..402aeefcf --- /dev/null +++ b/cef3/libcef_dll/cpptoc/geolocation_callback_cpptoc.cc @@ -0,0 +1,45 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/geolocation_callback_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK geolocation_callback_cont( + struct _cef_geolocation_callback_t* self, int allow) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefGeolocationCallbackCppToC::Get(self)->Continue( + allow?true:false); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefGeolocationCallbackCppToC::CefGeolocationCallbackCppToC( + CefGeolocationCallback* cls) + : CefCppToC(cls) { + struct_.struct_.cont = geolocation_callback_cont; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/geolocation_callback_cpptoc.h b/cef3/libcef_dll/cpptoc/geolocation_callback_cpptoc.h new file mode 100644 index 000000000..7f8fdd487 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/geolocation_callback_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_GEOLOCATION_CALLBACK_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_GEOLOCATION_CALLBACK_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_geolocation_handler.h" +#include "include/capi/cef_geolocation_handler_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefGeolocationCallbackCppToC + : public CefCppToC { + public: + explicit CefGeolocationCallbackCppToC(CefGeolocationCallback* cls); + virtual ~CefGeolocationCallbackCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_GEOLOCATION_CALLBACK_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/geolocation_handler_cpptoc.cc b/cef3/libcef_dll/cpptoc/geolocation_handler_cpptoc.cc new file mode 100644 index 000000000..d9c852e91 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/geolocation_handler_cpptoc.cc @@ -0,0 +1,91 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/geolocation_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/geolocation_callback_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK geolocation_handler_on_request_geolocation_permission( + struct _cef_geolocation_handler_t* self, cef_browser_t* browser, + const cef_string_t* requesting_url, int request_id, + cef_geolocation_callback_t* callback) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: requesting_url; type: string_byref_const + DCHECK(requesting_url); + if (!requesting_url) + return; + // Verify param: callback; type: refptr_diff + DCHECK(callback); + if (!callback) + return; + + // Execute + CefGeolocationHandlerCppToC::Get(self)->OnRequestGeolocationPermission( + CefBrowserCToCpp::Wrap(browser), + CefString(requesting_url), + request_id, + CefGeolocationCallbackCToCpp::Wrap(callback)); +} + +void CEF_CALLBACK geolocation_handler_on_cancel_geolocation_permission( + struct _cef_geolocation_handler_t* self, cef_browser_t* browser, + const cef_string_t* requesting_url, int request_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: requesting_url; type: string_byref_const + DCHECK(requesting_url); + if (!requesting_url) + return; + + // Execute + CefGeolocationHandlerCppToC::Get(self)->OnCancelGeolocationPermission( + CefBrowserCToCpp::Wrap(browser), + CefString(requesting_url), + request_id); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefGeolocationHandlerCppToC::CefGeolocationHandlerCppToC( + CefGeolocationHandler* cls) + : CefCppToC(cls) { + struct_.struct_.on_request_geolocation_permission = + geolocation_handler_on_request_geolocation_permission; + struct_.struct_.on_cancel_geolocation_permission = + geolocation_handler_on_cancel_geolocation_permission; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/geolocation_handler_cpptoc.h b/cef3/libcef_dll/cpptoc/geolocation_handler_cpptoc.h new file mode 100644 index 000000000..577422796 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/geolocation_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_GEOLOCATION_HANDLER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_GEOLOCATION_HANDLER_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_geolocation_handler.h" +#include "include/capi/cef_geolocation_handler_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefGeolocationHandlerCppToC + : public CefCppToC { + public: + explicit CefGeolocationHandlerCppToC(CefGeolocationHandler* cls); + virtual ~CefGeolocationHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_GEOLOCATION_HANDLER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/get_geolocation_callback_cpptoc.cc b/cef3/libcef_dll/cpptoc/get_geolocation_callback_cpptoc.cc new file mode 100644 index 000000000..e51cda2e8 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/get_geolocation_callback_cpptoc.cc @@ -0,0 +1,57 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/get_geolocation_callback_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK get_geolocation_callback_on_location_update( + struct _cef_get_geolocation_callback_t* self, + const struct _cef_geoposition_t* position) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: position; type: struct_byref_const + DCHECK(position); + if (!position) + return; + + // Translate param: position; type: struct_byref_const + CefGeoposition positionObj; + if (position) + positionObj.Set(*position, false); + + // Execute + CefGetGeolocationCallbackCppToC::Get(self)->OnLocationUpdate( + positionObj); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefGetGeolocationCallbackCppToC::CefGetGeolocationCallbackCppToC( + CefGetGeolocationCallback* cls) + : CefCppToC(cls) { + struct_.struct_.on_location_update = + get_geolocation_callback_on_location_update; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = + 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/get_geolocation_callback_cpptoc.h b/cef3/libcef_dll/cpptoc/get_geolocation_callback_cpptoc.h new file mode 100644 index 000000000..d239c6962 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/get_geolocation_callback_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_GET_GEOLOCATION_CALLBACK_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_GET_GEOLOCATION_CALLBACK_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_geolocation.h" +#include "include/capi/cef_geolocation_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefGetGeolocationCallbackCppToC + : public CefCppToC { + public: + explicit CefGetGeolocationCallbackCppToC(CefGetGeolocationCallback* cls); + virtual ~CefGetGeolocationCallbackCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_GET_GEOLOCATION_CALLBACK_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/jsdialog_callback_cpptoc.cc b/cef3/libcef_dll/cpptoc/jsdialog_callback_cpptoc.cc new file mode 100644 index 000000000..62664de1a --- /dev/null +++ b/cef3/libcef_dll/cpptoc/jsdialog_callback_cpptoc.cc @@ -0,0 +1,46 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/jsdialog_callback_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK jsdialog_callback_cont(struct _cef_jsdialog_callback_t* self, + int success, const cef_string_t* user_input) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Unverified params: user_input + + // Execute + CefJSDialogCallbackCppToC::Get(self)->Continue( + success?true:false, + CefString(user_input)); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefJSDialogCallbackCppToC::CefJSDialogCallbackCppToC(CefJSDialogCallback* cls) + : CefCppToC(cls) { + struct_.struct_.cont = jsdialog_callback_cont; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/jsdialog_callback_cpptoc.h b/cef3/libcef_dll/cpptoc/jsdialog_callback_cpptoc.h new file mode 100644 index 000000000..64ef55627 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/jsdialog_callback_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_JSDIALOG_CALLBACK_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_JSDIALOG_CALLBACK_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_jsdialog_handler.h" +#include "include/capi/cef_jsdialog_handler_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefJSDialogCallbackCppToC + : public CefCppToC { + public: + explicit CefJSDialogCallbackCppToC(CefJSDialogCallback* cls); + virtual ~CefJSDialogCallbackCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_JSDIALOG_CALLBACK_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/jsdialog_handler_cpptoc.cc b/cef3/libcef_dll/cpptoc/jsdialog_handler_cpptoc.cc new file mode 100644 index 000000000..d3dd01940 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/jsdialog_handler_cpptoc.cc @@ -0,0 +1,136 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/jsdialog_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/jsdialog_callback_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK jsdialog_handler_on_jsdialog( + struct _cef_jsdialog_handler_t* self, cef_browser_t* browser, + const cef_string_t* origin_url, const cef_string_t* accept_lang, + enum cef_jsdialog_type_t dialog_type, const cef_string_t* message_text, + const cef_string_t* default_prompt_text, cef_jsdialog_callback_t* callback, + int* suppress_message) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: origin_url; type: string_byref_const + DCHECK(origin_url); + if (!origin_url) + return 0; + // Verify param: callback; type: refptr_diff + DCHECK(callback); + if (!callback) + return 0; + // Verify param: suppress_message; type: bool_byref + DCHECK(suppress_message); + if (!suppress_message) + return 0; + // Unverified params: accept_lang, message_text, default_prompt_text + + // Translate param: suppress_message; type: bool_byref + bool suppress_messageBool = ( + suppress_message && *suppress_message)?true:false; + + // Execute + bool _retval = CefJSDialogHandlerCppToC::Get(self)->OnJSDialog( + CefBrowserCToCpp::Wrap(browser), + CefString(origin_url), + CefString(accept_lang), + dialog_type, + CefString(message_text), + CefString(default_prompt_text), + CefJSDialogCallbackCToCpp::Wrap(callback), + suppress_messageBool); + + // Restore param: suppress_message; type: bool_byref + if (suppress_message) + *suppress_message = suppress_messageBool?true:false; + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK jsdialog_handler_on_before_unload_dialog( + struct _cef_jsdialog_handler_t* self, cef_browser_t* browser, + const cef_string_t* message_text, int is_reload, + cef_jsdialog_callback_t* callback) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: callback; type: refptr_diff + DCHECK(callback); + if (!callback) + return 0; + // Unverified params: message_text + + // Execute + bool _retval = CefJSDialogHandlerCppToC::Get(self)->OnBeforeUnloadDialog( + CefBrowserCToCpp::Wrap(browser), + CefString(message_text), + is_reload?true:false, + CefJSDialogCallbackCToCpp::Wrap(callback)); + + // Return type: bool + return _retval; +} + +void CEF_CALLBACK jsdialog_handler_on_reset_dialog_state( + struct _cef_jsdialog_handler_t* self, cef_browser_t* browser) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + + // Execute + CefJSDialogHandlerCppToC::Get(self)->OnResetDialogState( + CefBrowserCToCpp::Wrap(browser)); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefJSDialogHandlerCppToC::CefJSDialogHandlerCppToC(CefJSDialogHandler* cls) + : CefCppToC(cls) { + struct_.struct_.on_jsdialog = jsdialog_handler_on_jsdialog; + struct_.struct_.on_before_unload_dialog = + jsdialog_handler_on_before_unload_dialog; + struct_.struct_.on_reset_dialog_state = + jsdialog_handler_on_reset_dialog_state; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/jsdialog_handler_cpptoc.h b/cef3/libcef_dll/cpptoc/jsdialog_handler_cpptoc.h new file mode 100644 index 000000000..68a07b83e --- /dev/null +++ b/cef3/libcef_dll/cpptoc/jsdialog_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_JSDIALOG_HANDLER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_JSDIALOG_HANDLER_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_jsdialog_handler.h" +#include "include/capi/cef_jsdialog_handler_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefJSDialogHandlerCppToC + : public CefCppToC { + public: + explicit CefJSDialogHandlerCppToC(CefJSDialogHandler* cls); + virtual ~CefJSDialogHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_JSDIALOG_HANDLER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/keyboard_handler_cpptoc.cc b/cef3/libcef_dll/cpptoc/keyboard_handler_cpptoc.cc new file mode 100644 index 000000000..bee1102e1 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/keyboard_handler_cpptoc.cc @@ -0,0 +1,110 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/keyboard_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK keyboard_handler_on_pre_key_event( + struct _cef_keyboard_handler_t* self, cef_browser_t* browser, + const struct _cef_key_event_t* event, cef_event_handle_t os_event, + int* is_keyboard_shortcut) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: event; type: struct_byref_const + DCHECK(event); + if (!event) + return 0; + // Verify param: is_keyboard_shortcut; type: bool_byaddr + DCHECK(is_keyboard_shortcut); + if (!is_keyboard_shortcut) + return 0; + + // Translate param: event; type: struct_byref_const + CefKeyEvent eventObj; + if (event) + eventObj.Set(*event, false); + // Translate param: is_keyboard_shortcut; type: bool_byaddr + bool is_keyboard_shortcutBool = ( + is_keyboard_shortcut && *is_keyboard_shortcut)?true:false; + + // Execute + bool _retval = CefKeyboardHandlerCppToC::Get(self)->OnPreKeyEvent( + CefBrowserCToCpp::Wrap(browser), + eventObj, + os_event, + &is_keyboard_shortcutBool); + + // Restore param: is_keyboard_shortcut; type: bool_byaddr + if (is_keyboard_shortcut) + *is_keyboard_shortcut = is_keyboard_shortcutBool?true:false; + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK keyboard_handler_on_key_event( + struct _cef_keyboard_handler_t* self, cef_browser_t* browser, + const struct _cef_key_event_t* event, cef_event_handle_t os_event) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: event; type: struct_byref_const + DCHECK(event); + if (!event) + return 0; + + // Translate param: event; type: struct_byref_const + CefKeyEvent eventObj; + if (event) + eventObj.Set(*event, false); + + // Execute + bool _retval = CefKeyboardHandlerCppToC::Get(self)->OnKeyEvent( + CefBrowserCToCpp::Wrap(browser), + eventObj, + os_event); + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefKeyboardHandlerCppToC::CefKeyboardHandlerCppToC(CefKeyboardHandler* cls) + : CefCppToC(cls) { + struct_.struct_.on_pre_key_event = keyboard_handler_on_pre_key_event; + struct_.struct_.on_key_event = keyboard_handler_on_key_event; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/keyboard_handler_cpptoc.h b/cef3/libcef_dll/cpptoc/keyboard_handler_cpptoc.h new file mode 100644 index 000000000..7a4829b7d --- /dev/null +++ b/cef3/libcef_dll/cpptoc/keyboard_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_KEYBOARD_HANDLER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_KEYBOARD_HANDLER_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_keyboard_handler.h" +#include "include/capi/cef_keyboard_handler_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefKeyboardHandlerCppToC + : public CefCppToC { + public: + explicit CefKeyboardHandlerCppToC(CefKeyboardHandler* cls); + virtual ~CefKeyboardHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_KEYBOARD_HANDLER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/life_span_handler_cpptoc.cc b/cef3/libcef_dll/cpptoc/life_span_handler_cpptoc.cc new file mode 100644 index 000000000..09a02fdef --- /dev/null +++ b/cef3/libcef_dll/cpptoc/life_span_handler_cpptoc.cc @@ -0,0 +1,211 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/client_cpptoc.h" +#include "libcef_dll/cpptoc/life_span_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/frame_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK life_span_handler_on_before_popup( + struct _cef_life_span_handler_t* self, cef_browser_t* browser, + cef_frame_t* frame, const cef_string_t* target_url, + const cef_string_t* target_frame_name, + const struct _cef_popup_features_t* popupFeatures, + cef_window_info_t* windowInfo, cef_client_t** client, + struct _cef_browser_settings_t* settings, int* no_javascript_access) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return 0; + // Verify param: popupFeatures; type: struct_byref_const + DCHECK(popupFeatures); + if (!popupFeatures) + return 0; + // Verify param: windowInfo; type: struct_byref + DCHECK(windowInfo); + if (!windowInfo) + return 0; + // Verify param: client; type: refptr_same_byref + DCHECK(client); + if (!client) + return 0; + // Verify param: settings; type: struct_byref + DCHECK(settings); + if (!settings) + return 0; + // Verify param: no_javascript_access; type: bool_byaddr + DCHECK(no_javascript_access); + if (!no_javascript_access) + return 0; + // Unverified params: target_url, target_frame_name + + // Translate param: popupFeatures; type: struct_byref_const + CefPopupFeatures popupFeaturesObj; + if (popupFeatures) + popupFeaturesObj.Set(*popupFeatures, false); + // Translate param: windowInfo; type: struct_byref + CefWindowInfo windowInfoObj; + if (windowInfo) + windowInfoObj.AttachTo(*windowInfo); + // Translate param: client; type: refptr_same_byref + CefRefPtr clientPtr; + if (client && *client) + clientPtr = CefClientCppToC::Unwrap(*client); + CefClient* clientOrig = clientPtr.get(); + // Translate param: settings; type: struct_byref + CefBrowserSettings settingsObj; + if (settings) + settingsObj.AttachTo(*settings); + // Translate param: no_javascript_access; type: bool_byaddr + bool no_javascript_accessBool = ( + no_javascript_access && *no_javascript_access)?true:false; + + // Execute + bool _retval = CefLifeSpanHandlerCppToC::Get(self)->OnBeforePopup( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + CefString(target_url), + CefString(target_frame_name), + popupFeaturesObj, + windowInfoObj, + clientPtr, + settingsObj, + &no_javascript_accessBool); + + // Restore param: windowInfo; type: struct_byref + if (windowInfo) + windowInfoObj.DetachTo(*windowInfo); + // Restore param: client; type: refptr_same_byref + if (client) { + if (clientPtr.get()) { + if (clientPtr.get() != clientOrig) { + *client = CefClientCppToC::Wrap(clientPtr); + } + } else { + *client = NULL; + } + } + // Restore param: settings; type: struct_byref + if (settings) + settingsObj.DetachTo(*settings); + // Restore param: no_javascript_access; type: bool_byaddr + if (no_javascript_access) + *no_javascript_access = no_javascript_accessBool?true:false; + + // Return type: bool + return _retval; +} + +void CEF_CALLBACK life_span_handler_on_after_created( + struct _cef_life_span_handler_t* self, cef_browser_t* browser) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + + // Execute + CefLifeSpanHandlerCppToC::Get(self)->OnAfterCreated( + CefBrowserCToCpp::Wrap(browser)); +} + +int CEF_CALLBACK life_span_handler_run_modal( + struct _cef_life_span_handler_t* self, cef_browser_t* browser) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + + // Execute + bool _retval = CefLifeSpanHandlerCppToC::Get(self)->RunModal( + CefBrowserCToCpp::Wrap(browser)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK life_span_handler_do_close( + struct _cef_life_span_handler_t* self, cef_browser_t* browser) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + + // Execute + bool _retval = CefLifeSpanHandlerCppToC::Get(self)->DoClose( + CefBrowserCToCpp::Wrap(browser)); + + // Return type: bool + return _retval; +} + +void CEF_CALLBACK life_span_handler_on_before_close( + struct _cef_life_span_handler_t* self, cef_browser_t* browser) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + + // Execute + CefLifeSpanHandlerCppToC::Get(self)->OnBeforeClose( + CefBrowserCToCpp::Wrap(browser)); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefLifeSpanHandlerCppToC::CefLifeSpanHandlerCppToC(CefLifeSpanHandler* cls) + : CefCppToC(cls) { + struct_.struct_.on_before_popup = life_span_handler_on_before_popup; + struct_.struct_.on_after_created = life_span_handler_on_after_created; + struct_.struct_.run_modal = life_span_handler_run_modal; + struct_.struct_.do_close = life_span_handler_do_close; + struct_.struct_.on_before_close = life_span_handler_on_before_close; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/life_span_handler_cpptoc.h b/cef3/libcef_dll/cpptoc/life_span_handler_cpptoc.h new file mode 100644 index 000000000..360073aad --- /dev/null +++ b/cef3/libcef_dll/cpptoc/life_span_handler_cpptoc.h @@ -0,0 +1,39 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_LIFE_SPAN_HANDLER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_LIFE_SPAN_HANDLER_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_life_span_handler.h" +#include "include/capi/cef_life_span_handler_capi.h" +#include "include/cef_client.h" +#include "include/capi/cef_client_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefLifeSpanHandlerCppToC + : public CefCppToC { + public: + explicit CefLifeSpanHandlerCppToC(CefLifeSpanHandler* cls); + virtual ~CefLifeSpanHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_LIFE_SPAN_HANDLER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/list_value_cpptoc.cc b/cef3/libcef_dll/cpptoc/list_value_cpptoc.cc new file mode 100644 index 000000000..04075ad0e --- /dev/null +++ b/cef3/libcef_dll/cpptoc/list_value_cpptoc.cc @@ -0,0 +1,528 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/binary_value_cpptoc.h" +#include "libcef_dll/cpptoc/dictionary_value_cpptoc.h" +#include "libcef_dll/cpptoc/list_value_cpptoc.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_list_value_t* cef_list_value_create() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = CefListValue::Create(); + + // Return type: refptr_same + return CefListValueCppToC::Wrap(_retval); +} + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK list_value_is_valid(struct _cef_list_value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefListValueCppToC::Get(self)->IsValid(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK list_value_is_owned(struct _cef_list_value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefListValueCppToC::Get(self)->IsOwned(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK list_value_is_read_only(struct _cef_list_value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefListValueCppToC::Get(self)->IsReadOnly(); + + // Return type: bool + return _retval; +} + +struct _cef_list_value_t* CEF_CALLBACK list_value_copy( + struct _cef_list_value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefListValueCppToC::Get(self)->Copy(); + + // Return type: refptr_same + return CefListValueCppToC::Wrap(_retval); +} + +int CEF_CALLBACK list_value_set_size(struct _cef_list_value_t* self, + size_t size) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefListValueCppToC::Get(self)->SetSize( + size); + + // Return type: bool + return _retval; +} + +size_t CEF_CALLBACK list_value_get_size(struct _cef_list_value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + size_t _retval = CefListValueCppToC::Get(self)->GetSize(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK list_value_clear(struct _cef_list_value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefListValueCppToC::Get(self)->Clear(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK list_value_remove(struct _cef_list_value_t* self, int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return 0; + + // Execute + bool _retval = CefListValueCppToC::Get(self)->Remove( + index); + + // Return type: bool + return _retval; +} + +enum cef_value_type_t CEF_CALLBACK list_value_get_type( + struct _cef_list_value_t* self, int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return VTYPE_INVALID; + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return VTYPE_INVALID; + + // Execute + cef_value_type_t _retval = CefListValueCppToC::Get(self)->GetType( + index); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK list_value_get_bool(struct _cef_list_value_t* self, + int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return 0; + + // Execute + bool _retval = CefListValueCppToC::Get(self)->GetBool( + index); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK list_value_get_int(struct _cef_list_value_t* self, int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return 0; + + // Execute + int _retval = CefListValueCppToC::Get(self)->GetInt( + index); + + // Return type: simple + return _retval; +} + +double CEF_CALLBACK list_value_get_double(struct _cef_list_value_t* self, + int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return 0; + + // Execute + double _retval = CefListValueCppToC::Get(self)->GetDouble( + index); + + // Return type: simple + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK list_value_get_string( + struct _cef_list_value_t* self, int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return NULL; + + // Execute + CefString _retval = CefListValueCppToC::Get(self)->GetString( + index); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_binary_value_t* CEF_CALLBACK list_value_get_binary( + struct _cef_list_value_t* self, int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return NULL; + + // Execute + CefRefPtr _retval = CefListValueCppToC::Get(self)->GetBinary( + index); + + // Return type: refptr_same + return CefBinaryValueCppToC::Wrap(_retval); +} + +cef_dictionary_value_t* CEF_CALLBACK list_value_get_dictionary( + struct _cef_list_value_t* self, int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return NULL; + + // Execute + CefRefPtr _retval = CefListValueCppToC::Get( + self)->GetDictionary( + index); + + // Return type: refptr_same + return CefDictionaryValueCppToC::Wrap(_retval); +} + +struct _cef_list_value_t* CEF_CALLBACK list_value_get_list( + struct _cef_list_value_t* self, int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return NULL; + + // Execute + CefRefPtr _retval = CefListValueCppToC::Get(self)->GetList( + index); + + // Return type: refptr_same + return CefListValueCppToC::Wrap(_retval); +} + +int CEF_CALLBACK list_value_set_null(struct _cef_list_value_t* self, + int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return 0; + + // Execute + bool _retval = CefListValueCppToC::Get(self)->SetNull( + index); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK list_value_set_bool(struct _cef_list_value_t* self, int index, + int value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return 0; + + // Execute + bool _retval = CefListValueCppToC::Get(self)->SetBool( + index, + value?true:false); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK list_value_set_int(struct _cef_list_value_t* self, int index, + int value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return 0; + + // Execute + bool _retval = CefListValueCppToC::Get(self)->SetInt( + index, + value); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK list_value_set_double(struct _cef_list_value_t* self, + int index, double value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return 0; + + // Execute + bool _retval = CefListValueCppToC::Get(self)->SetDouble( + index, + value); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK list_value_set_string(struct _cef_list_value_t* self, + int index, const cef_string_t* value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return 0; + // Unverified params: value + + // Execute + bool _retval = CefListValueCppToC::Get(self)->SetString( + index, + CefString(value)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK list_value_set_binary(struct _cef_list_value_t* self, + int index, cef_binary_value_t* value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return 0; + // Verify param: value; type: refptr_same + DCHECK(value); + if (!value) + return 0; + + // Execute + bool _retval = CefListValueCppToC::Get(self)->SetBinary( + index, + CefBinaryValueCppToC::Unwrap(value)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK list_value_set_dictionary(struct _cef_list_value_t* self, + int index, cef_dictionary_value_t* value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return 0; + // Verify param: value; type: refptr_same + DCHECK(value); + if (!value) + return 0; + + // Execute + bool _retval = CefListValueCppToC::Get(self)->SetDictionary( + index, + CefDictionaryValueCppToC::Unwrap(value)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK list_value_set_list(struct _cef_list_value_t* self, int index, + struct _cef_list_value_t* value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return 0; + // Verify param: value; type: refptr_same + DCHECK(value); + if (!value) + return 0; + + // Execute + bool _retval = CefListValueCppToC::Get(self)->SetList( + index, + CefListValueCppToC::Unwrap(value)); + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefListValueCppToC::CefListValueCppToC(CefListValue* cls) + : CefCppToC(cls) { + struct_.struct_.is_valid = list_value_is_valid; + struct_.struct_.is_owned = list_value_is_owned; + struct_.struct_.is_read_only = list_value_is_read_only; + struct_.struct_.copy = list_value_copy; + struct_.struct_.set_size = list_value_set_size; + struct_.struct_.get_size = list_value_get_size; + struct_.struct_.clear = list_value_clear; + struct_.struct_.remove = list_value_remove; + struct_.struct_.get_type = list_value_get_type; + struct_.struct_.get_bool = list_value_get_bool; + struct_.struct_.get_int = list_value_get_int; + struct_.struct_.get_double = list_value_get_double; + struct_.struct_.get_string = list_value_get_string; + struct_.struct_.get_binary = list_value_get_binary; + struct_.struct_.get_dictionary = list_value_get_dictionary; + struct_.struct_.get_list = list_value_get_list; + struct_.struct_.set_null = list_value_set_null; + struct_.struct_.set_bool = list_value_set_bool; + struct_.struct_.set_int = list_value_set_int; + struct_.struct_.set_double = list_value_set_double; + struct_.struct_.set_string = list_value_set_string; + struct_.struct_.set_binary = list_value_set_binary; + struct_.struct_.set_dictionary = list_value_set_dictionary; + struct_.struct_.set_list = list_value_set_list; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/list_value_cpptoc.h b/cef3/libcef_dll/cpptoc/list_value_cpptoc.h new file mode 100644 index 000000000..7ecfb9948 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/list_value_cpptoc.h @@ -0,0 +1,36 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_LIST_VALUE_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_LIST_VALUE_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_values.h" +#include "include/capi/cef_values_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefListValueCppToC + : public CefCppToC { + public: + explicit CefListValueCppToC(CefListValue* cls); + virtual ~CefListValueCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_LIST_VALUE_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/load_handler_cpptoc.cc b/cef3/libcef_dll/cpptoc/load_handler_cpptoc.cc new file mode 100644 index 000000000..ee3a7bc9e --- /dev/null +++ b/cef3/libcef_dll/cpptoc/load_handler_cpptoc.cc @@ -0,0 +1,155 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/load_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/frame_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK load_handler_on_load_start(struct _cef_load_handler_t* self, + cef_browser_t* browser, cef_frame_t* frame) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return; + + // Execute + CefLoadHandlerCppToC::Get(self)->OnLoadStart( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame)); +} + +void CEF_CALLBACK load_handler_on_load_end(struct _cef_load_handler_t* self, + cef_browser_t* browser, cef_frame_t* frame, int httpStatusCode) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return; + + // Execute + CefLoadHandlerCppToC::Get(self)->OnLoadEnd( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + httpStatusCode); +} + +void CEF_CALLBACK load_handler_on_load_error(struct _cef_load_handler_t* self, + cef_browser_t* browser, cef_frame_t* frame, enum cef_errorcode_t errorCode, + const cef_string_t* errorText, const cef_string_t* failedUrl) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return; + // Verify param: failedUrl; type: string_byref_const + DCHECK(failedUrl); + if (!failedUrl) + return; + // Unverified params: errorText + + // Execute + CefLoadHandlerCppToC::Get(self)->OnLoadError( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + errorCode, + CefString(errorText), + CefString(failedUrl)); +} + +void CEF_CALLBACK load_handler_on_render_process_terminated( + struct _cef_load_handler_t* self, cef_browser_t* browser, + enum cef_termination_status_t status) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + + // Execute + CefLoadHandlerCppToC::Get(self)->OnRenderProcessTerminated( + CefBrowserCToCpp::Wrap(browser), + status); +} + +void CEF_CALLBACK load_handler_on_plugin_crashed( + struct _cef_load_handler_t* self, cef_browser_t* browser, + const cef_string_t* plugin_path) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: plugin_path; type: string_byref_const + DCHECK(plugin_path); + if (!plugin_path) + return; + + // Execute + CefLoadHandlerCppToC::Get(self)->OnPluginCrashed( + CefBrowserCToCpp::Wrap(browser), + CefString(plugin_path)); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefLoadHandlerCppToC::CefLoadHandlerCppToC(CefLoadHandler* cls) + : CefCppToC(cls) { + struct_.struct_.on_load_start = load_handler_on_load_start; + struct_.struct_.on_load_end = load_handler_on_load_end; + struct_.struct_.on_load_error = load_handler_on_load_error; + struct_.struct_.on_render_process_terminated = + load_handler_on_render_process_terminated; + struct_.struct_.on_plugin_crashed = load_handler_on_plugin_crashed; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/load_handler_cpptoc.h b/cef3/libcef_dll/cpptoc/load_handler_cpptoc.h new file mode 100644 index 000000000..7043d0aad --- /dev/null +++ b/cef3/libcef_dll/cpptoc/load_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_LOAD_HANDLER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_LOAD_HANDLER_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_load_handler.h" +#include "include/capi/cef_load_handler_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefLoadHandlerCppToC + : public CefCppToC { + public: + explicit CefLoadHandlerCppToC(CefLoadHandler* cls); + virtual ~CefLoadHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_LOAD_HANDLER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/menu_model_cpptoc.cc b/cef3/libcef_dll/cpptoc/menu_model_cpptoc.cc new file mode 100644 index 000000000..52cca335f --- /dev/null +++ b/cef3/libcef_dll/cpptoc/menu_model_cpptoc.cc @@ -0,0 +1,1020 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/menu_model_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK menu_model_clear(struct _cef_menu_model_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->Clear(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_get_count(struct _cef_menu_model_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefMenuModelCppToC::Get(self)->GetCount(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK menu_model_add_separator(struct _cef_menu_model_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->AddSeparator(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_add_item(struct _cef_menu_model_t* self, + int command_id, const cef_string_t* label) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: label; type: string_byref_const + DCHECK(label); + if (!label) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->AddItem( + command_id, + CefString(label)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_add_check_item(struct _cef_menu_model_t* self, + int command_id, const cef_string_t* label) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: label; type: string_byref_const + DCHECK(label); + if (!label) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->AddCheckItem( + command_id, + CefString(label)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_add_radio_item(struct _cef_menu_model_t* self, + int command_id, const cef_string_t* label, int group_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: label; type: string_byref_const + DCHECK(label); + if (!label) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->AddRadioItem( + command_id, + CefString(label), + group_id); + + // Return type: bool + return _retval; +} + +struct _cef_menu_model_t* CEF_CALLBACK menu_model_add_sub_menu( + struct _cef_menu_model_t* self, int command_id, + const cef_string_t* label) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: label; type: string_byref_const + DCHECK(label); + if (!label) + return NULL; + + // Execute + CefRefPtr _retval = CefMenuModelCppToC::Get(self)->AddSubMenu( + command_id, + CefString(label)); + + // Return type: refptr_same + return CefMenuModelCppToC::Wrap(_retval); +} + +int CEF_CALLBACK menu_model_insert_separator_at(struct _cef_menu_model_t* self, + int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->InsertSeparatorAt( + index); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_insert_item_at(struct _cef_menu_model_t* self, + int index, int command_id, const cef_string_t* label) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: label; type: string_byref_const + DCHECK(label); + if (!label) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->InsertItemAt( + index, + command_id, + CefString(label)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_insert_check_item_at(struct _cef_menu_model_t* self, + int index, int command_id, const cef_string_t* label) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: label; type: string_byref_const + DCHECK(label); + if (!label) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->InsertCheckItemAt( + index, + command_id, + CefString(label)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_insert_radio_item_at(struct _cef_menu_model_t* self, + int index, int command_id, const cef_string_t* label, int group_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: label; type: string_byref_const + DCHECK(label); + if (!label) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->InsertRadioItemAt( + index, + command_id, + CefString(label), + group_id); + + // Return type: bool + return _retval; +} + +struct _cef_menu_model_t* CEF_CALLBACK menu_model_insert_sub_menu_at( + struct _cef_menu_model_t* self, int index, int command_id, + const cef_string_t* label) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: label; type: string_byref_const + DCHECK(label); + if (!label) + return NULL; + + // Execute + CefRefPtr _retval = CefMenuModelCppToC::Get( + self)->InsertSubMenuAt( + index, + command_id, + CefString(label)); + + // Return type: refptr_same + return CefMenuModelCppToC::Wrap(_retval); +} + +int CEF_CALLBACK menu_model_remove(struct _cef_menu_model_t* self, + int command_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->Remove( + command_id); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_remove_at(struct _cef_menu_model_t* self, + int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->RemoveAt( + index); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_get_index_of(struct _cef_menu_model_t* self, + int command_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefMenuModelCppToC::Get(self)->GetIndexOf( + command_id); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK menu_model_get_command_id_at(struct _cef_menu_model_t* self, + int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefMenuModelCppToC::Get(self)->GetCommandIdAt( + index); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK menu_model_set_command_id_at(struct _cef_menu_model_t* self, + int index, int command_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->SetCommandIdAt( + index, + command_id); + + // Return type: bool + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK menu_model_get_label( + struct _cef_menu_model_t* self, int command_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefMenuModelCppToC::Get(self)->GetLabel( + command_id); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK menu_model_get_label_at( + struct _cef_menu_model_t* self, int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefMenuModelCppToC::Get(self)->GetLabelAt( + index); + + // Return type: string + return _retval.DetachToUserFree(); +} + +int CEF_CALLBACK menu_model_set_label(struct _cef_menu_model_t* self, + int command_id, const cef_string_t* label) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: label; type: string_byref_const + DCHECK(label); + if (!label) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->SetLabel( + command_id, + CefString(label)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_set_label_at(struct _cef_menu_model_t* self, + int index, const cef_string_t* label) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: label; type: string_byref_const + DCHECK(label); + if (!label) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->SetLabelAt( + index, + CefString(label)); + + // Return type: bool + return _retval; +} + +enum cef_menu_item_type_t CEF_CALLBACK menu_model_get_type( + struct _cef_menu_model_t* self, int command_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return MENUITEMTYPE_NONE; + + // Execute + cef_menu_item_type_t _retval = CefMenuModelCppToC::Get(self)->GetType( + command_id); + + // Return type: simple + return _retval; +} + +enum cef_menu_item_type_t CEF_CALLBACK menu_model_get_type_at( + struct _cef_menu_model_t* self, int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return MENUITEMTYPE_NONE; + + // Execute + cef_menu_item_type_t _retval = CefMenuModelCppToC::Get(self)->GetTypeAt( + index); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK menu_model_get_group_id(struct _cef_menu_model_t* self, + int command_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefMenuModelCppToC::Get(self)->GetGroupId( + command_id); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK menu_model_get_group_id_at(struct _cef_menu_model_t* self, + int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefMenuModelCppToC::Get(self)->GetGroupIdAt( + index); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK menu_model_set_group_id(struct _cef_menu_model_t* self, + int command_id, int group_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->SetGroupId( + command_id, + group_id); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_set_group_id_at(struct _cef_menu_model_t* self, + int index, int group_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->SetGroupIdAt( + index, + group_id); + + // Return type: bool + return _retval; +} + +struct _cef_menu_model_t* CEF_CALLBACK menu_model_get_sub_menu( + struct _cef_menu_model_t* self, int command_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefMenuModelCppToC::Get(self)->GetSubMenu( + command_id); + + // Return type: refptr_same + return CefMenuModelCppToC::Wrap(_retval); +} + +struct _cef_menu_model_t* CEF_CALLBACK menu_model_get_sub_menu_at( + struct _cef_menu_model_t* self, int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefMenuModelCppToC::Get(self)->GetSubMenuAt( + index); + + // Return type: refptr_same + return CefMenuModelCppToC::Wrap(_retval); +} + +int CEF_CALLBACK menu_model_is_visible(struct _cef_menu_model_t* self, + int command_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->IsVisible( + command_id); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_is_visible_at(struct _cef_menu_model_t* self, + int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->IsVisibleAt( + index); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_set_visible(struct _cef_menu_model_t* self, + int command_id, int visible) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->SetVisible( + command_id, + visible?true:false); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_set_visible_at(struct _cef_menu_model_t* self, + int index, int visible) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->SetVisibleAt( + index, + visible?true:false); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_is_enabled(struct _cef_menu_model_t* self, + int command_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->IsEnabled( + command_id); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_is_enabled_at(struct _cef_menu_model_t* self, + int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->IsEnabledAt( + index); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_set_enabled(struct _cef_menu_model_t* self, + int command_id, int enabled) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->SetEnabled( + command_id, + enabled?true:false); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_set_enabled_at(struct _cef_menu_model_t* self, + int index, int enabled) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->SetEnabledAt( + index, + enabled?true:false); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_is_checked(struct _cef_menu_model_t* self, + int command_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->IsChecked( + command_id); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_is_checked_at(struct _cef_menu_model_t* self, + int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->IsCheckedAt( + index); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_set_checked(struct _cef_menu_model_t* self, + int command_id, int checked) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->SetChecked( + command_id, + checked?true:false); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_set_checked_at(struct _cef_menu_model_t* self, + int index, int checked) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->SetCheckedAt( + index, + checked?true:false); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_has_accelerator(struct _cef_menu_model_t* self, + int command_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->HasAccelerator( + command_id); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_has_accelerator_at(struct _cef_menu_model_t* self, + int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->HasAcceleratorAt( + index); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_set_accelerator(struct _cef_menu_model_t* self, + int command_id, int key_code, int shift_pressed, int ctrl_pressed, + int alt_pressed) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->SetAccelerator( + command_id, + key_code, + shift_pressed?true:false, + ctrl_pressed?true:false, + alt_pressed?true:false); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_set_accelerator_at(struct _cef_menu_model_t* self, + int index, int key_code, int shift_pressed, int ctrl_pressed, + int alt_pressed) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->SetAcceleratorAt( + index, + key_code, + shift_pressed?true:false, + ctrl_pressed?true:false, + alt_pressed?true:false); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_remove_accelerator(struct _cef_menu_model_t* self, + int command_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->RemoveAccelerator( + command_id); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_remove_accelerator_at( + struct _cef_menu_model_t* self, int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->RemoveAcceleratorAt( + index); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_get_accelerator(struct _cef_menu_model_t* self, + int command_id, int* key_code, int* shift_pressed, int* ctrl_pressed, + int* alt_pressed) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: key_code; type: simple_byref + DCHECK(key_code); + if (!key_code) + return 0; + // Verify param: shift_pressed; type: bool_byref + DCHECK(shift_pressed); + if (!shift_pressed) + return 0; + // Verify param: ctrl_pressed; type: bool_byref + DCHECK(ctrl_pressed); + if (!ctrl_pressed) + return 0; + // Verify param: alt_pressed; type: bool_byref + DCHECK(alt_pressed); + if (!alt_pressed) + return 0; + + // Translate param: key_code; type: simple_byref + int key_codeVal = key_code?*key_code:0; + // Translate param: shift_pressed; type: bool_byref + bool shift_pressedBool = (shift_pressed && *shift_pressed)?true:false; + // Translate param: ctrl_pressed; type: bool_byref + bool ctrl_pressedBool = (ctrl_pressed && *ctrl_pressed)?true:false; + // Translate param: alt_pressed; type: bool_byref + bool alt_pressedBool = (alt_pressed && *alt_pressed)?true:false; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->GetAccelerator( + command_id, + key_codeVal, + shift_pressedBool, + ctrl_pressedBool, + alt_pressedBool); + + // Restore param: key_code; type: simple_byref + if (key_code) + *key_code = key_codeVal; + // Restore param: shift_pressed; type: bool_byref + if (shift_pressed) + *shift_pressed = shift_pressedBool?true:false; + // Restore param: ctrl_pressed; type: bool_byref + if (ctrl_pressed) + *ctrl_pressed = ctrl_pressedBool?true:false; + // Restore param: alt_pressed; type: bool_byref + if (alt_pressed) + *alt_pressed = alt_pressedBool?true:false; + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK menu_model_get_accelerator_at(struct _cef_menu_model_t* self, + int index, int* key_code, int* shift_pressed, int* ctrl_pressed, + int* alt_pressed) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: key_code; type: simple_byref + DCHECK(key_code); + if (!key_code) + return 0; + // Verify param: shift_pressed; type: bool_byref + DCHECK(shift_pressed); + if (!shift_pressed) + return 0; + // Verify param: ctrl_pressed; type: bool_byref + DCHECK(ctrl_pressed); + if (!ctrl_pressed) + return 0; + // Verify param: alt_pressed; type: bool_byref + DCHECK(alt_pressed); + if (!alt_pressed) + return 0; + + // Translate param: key_code; type: simple_byref + int key_codeVal = key_code?*key_code:0; + // Translate param: shift_pressed; type: bool_byref + bool shift_pressedBool = (shift_pressed && *shift_pressed)?true:false; + // Translate param: ctrl_pressed; type: bool_byref + bool ctrl_pressedBool = (ctrl_pressed && *ctrl_pressed)?true:false; + // Translate param: alt_pressed; type: bool_byref + bool alt_pressedBool = (alt_pressed && *alt_pressed)?true:false; + + // Execute + bool _retval = CefMenuModelCppToC::Get(self)->GetAcceleratorAt( + index, + key_codeVal, + shift_pressedBool, + ctrl_pressedBool, + alt_pressedBool); + + // Restore param: key_code; type: simple_byref + if (key_code) + *key_code = key_codeVal; + // Restore param: shift_pressed; type: bool_byref + if (shift_pressed) + *shift_pressed = shift_pressedBool?true:false; + // Restore param: ctrl_pressed; type: bool_byref + if (ctrl_pressed) + *ctrl_pressed = ctrl_pressedBool?true:false; + // Restore param: alt_pressed; type: bool_byref + if (alt_pressed) + *alt_pressed = alt_pressedBool?true:false; + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefMenuModelCppToC::CefMenuModelCppToC(CefMenuModel* cls) + : CefCppToC(cls) { + struct_.struct_.clear = menu_model_clear; + struct_.struct_.get_count = menu_model_get_count; + struct_.struct_.add_separator = menu_model_add_separator; + struct_.struct_.add_item = menu_model_add_item; + struct_.struct_.add_check_item = menu_model_add_check_item; + struct_.struct_.add_radio_item = menu_model_add_radio_item; + struct_.struct_.add_sub_menu = menu_model_add_sub_menu; + struct_.struct_.insert_separator_at = menu_model_insert_separator_at; + struct_.struct_.insert_item_at = menu_model_insert_item_at; + struct_.struct_.insert_check_item_at = menu_model_insert_check_item_at; + struct_.struct_.insert_radio_item_at = menu_model_insert_radio_item_at; + struct_.struct_.insert_sub_menu_at = menu_model_insert_sub_menu_at; + struct_.struct_.remove = menu_model_remove; + struct_.struct_.remove_at = menu_model_remove_at; + struct_.struct_.get_index_of = menu_model_get_index_of; + struct_.struct_.get_command_id_at = menu_model_get_command_id_at; + struct_.struct_.set_command_id_at = menu_model_set_command_id_at; + struct_.struct_.get_label = menu_model_get_label; + struct_.struct_.get_label_at = menu_model_get_label_at; + struct_.struct_.set_label = menu_model_set_label; + struct_.struct_.set_label_at = menu_model_set_label_at; + struct_.struct_.get_type = menu_model_get_type; + struct_.struct_.get_type_at = menu_model_get_type_at; + struct_.struct_.get_group_id = menu_model_get_group_id; + struct_.struct_.get_group_id_at = menu_model_get_group_id_at; + struct_.struct_.set_group_id = menu_model_set_group_id; + struct_.struct_.set_group_id_at = menu_model_set_group_id_at; + struct_.struct_.get_sub_menu = menu_model_get_sub_menu; + struct_.struct_.get_sub_menu_at = menu_model_get_sub_menu_at; + struct_.struct_.is_visible = menu_model_is_visible; + struct_.struct_.is_visible_at = menu_model_is_visible_at; + struct_.struct_.set_visible = menu_model_set_visible; + struct_.struct_.set_visible_at = menu_model_set_visible_at; + struct_.struct_.is_enabled = menu_model_is_enabled; + struct_.struct_.is_enabled_at = menu_model_is_enabled_at; + struct_.struct_.set_enabled = menu_model_set_enabled; + struct_.struct_.set_enabled_at = menu_model_set_enabled_at; + struct_.struct_.is_checked = menu_model_is_checked; + struct_.struct_.is_checked_at = menu_model_is_checked_at; + struct_.struct_.set_checked = menu_model_set_checked; + struct_.struct_.set_checked_at = menu_model_set_checked_at; + struct_.struct_.has_accelerator = menu_model_has_accelerator; + struct_.struct_.has_accelerator_at = menu_model_has_accelerator_at; + struct_.struct_.set_accelerator = menu_model_set_accelerator; + struct_.struct_.set_accelerator_at = menu_model_set_accelerator_at; + struct_.struct_.remove_accelerator = menu_model_remove_accelerator; + struct_.struct_.remove_accelerator_at = menu_model_remove_accelerator_at; + struct_.struct_.get_accelerator = menu_model_get_accelerator; + struct_.struct_.get_accelerator_at = menu_model_get_accelerator_at; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/menu_model_cpptoc.h b/cef3/libcef_dll/cpptoc/menu_model_cpptoc.h new file mode 100644 index 000000000..5b74b3b0b --- /dev/null +++ b/cef3/libcef_dll/cpptoc/menu_model_cpptoc.h @@ -0,0 +1,36 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_MENU_MODEL_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_MENU_MODEL_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_menu_model.h" +#include "include/capi/cef_menu_model_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefMenuModelCppToC + : public CefCppToC { + public: + explicit CefMenuModelCppToC(CefMenuModel* cls); + virtual ~CefMenuModelCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_MENU_MODEL_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/permission_handler_cpptoc.cc b/cef3/libcef_dll/cpptoc/permission_handler_cpptoc.cc new file mode 100644 index 000000000..5558de8eb --- /dev/null +++ b/cef3/libcef_dll/cpptoc/permission_handler_cpptoc.cc @@ -0,0 +1,67 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/permission_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/frame_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK permission_handler_on_before_script_extension_load( + struct _cef_permission_handler_t* self, cef_browser_t* browser, + cef_frame_t* frame, const cef_string_t* extensionName) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return 0; + // Verify param: extensionName; type: string_byref_const + DCHECK(extensionName); + if (!extensionName) + return 0; + + // Execute + bool _retval = CefPermissionHandlerCppToC::Get( + self)->OnBeforeScriptExtensionLoad( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + CefString(extensionName)); + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefPermissionHandlerCppToC::CefPermissionHandlerCppToC( + CefPermissionHandler* cls) + : CefCppToC(cls) { + struct_.struct_.on_before_script_extension_load = + permission_handler_on_before_script_extension_load; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/permission_handler_cpptoc.h b/cef3/libcef_dll/cpptoc/permission_handler_cpptoc.h new file mode 100644 index 000000000..6c8d2f86d --- /dev/null +++ b/cef3/libcef_dll/cpptoc/permission_handler_cpptoc.h @@ -0,0 +1,41 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_PERMISSION_HANDLER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_PERMISSION_HANDLER_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_permission_handler.h" +#include "include/capi/cef_permission_handler_capi.h" +#include "include/cef_browser.h" +#include "include/capi/cef_browser_capi.h" +#include "include/cef_frame.h" +#include "include/capi/cef_frame_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefPermissionHandlerCppToC + : public CefCppToC { + public: + explicit CefPermissionHandlerCppToC(CefPermissionHandler* cls); + virtual ~CefPermissionHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_PERMISSION_HANDLER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/post_data_cpptoc.cc b/cef3/libcef_dll/cpptoc/post_data_cpptoc.cc new file mode 100644 index 000000000..9d3df61fd --- /dev/null +++ b/cef3/libcef_dll/cpptoc/post_data_cpptoc.cc @@ -0,0 +1,163 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/post_data_cpptoc.h" +#include "libcef_dll/cpptoc/post_data_element_cpptoc.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_post_data_t* cef_post_data_create() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = CefPostData::Create(); + + // Return type: refptr_same + return CefPostDataCppToC::Wrap(_retval); +} + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK post_data_is_read_only(struct _cef_post_data_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefPostDataCppToC::Get(self)->IsReadOnly(); + + // Return type: bool + return _retval; +} + +size_t CEF_CALLBACK post_data_get_element_count(struct _cef_post_data_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + size_t _retval = CefPostDataCppToC::Get(self)->GetElementCount(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK post_data_get_elements(struct _cef_post_data_t* self, + size_t* elementsCount, struct _cef_post_data_element_t** elements) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: elements; type: refptr_vec_same_byref + DCHECK(elementsCount && (*elementsCount == 0 || elements)); + if (!elementsCount || (*elementsCount > 0 && !elements)) + return; + + // Translate param: elements; type: refptr_vec_same_byref + std::vector > elementsList; + if (elementsCount && *elementsCount > 0 && elements) { + for (size_t i = 0; i < *elementsCount; ++i) { + elementsList.push_back(CefPostDataElementCppToC::Unwrap(elements[i])); + } + } + + // Execute + CefPostDataCppToC::Get(self)->GetElements( + elementsList); + + // Restore param: elements; type: refptr_vec_same_byref + if (elementsCount && elements) { + *elementsCount = std::min(elementsList.size(), *elementsCount); + if (*elementsCount > 0) { + for (size_t i = 0; i < *elementsCount; ++i) { + elements[i] = CefPostDataElementCppToC::Wrap(elementsList[i]); + } + } + } +} + +int CEF_CALLBACK post_data_remove_element(struct _cef_post_data_t* self, + struct _cef_post_data_element_t* element) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: element; type: refptr_same + DCHECK(element); + if (!element) + return 0; + + // Execute + bool _retval = CefPostDataCppToC::Get(self)->RemoveElement( + CefPostDataElementCppToC::Unwrap(element)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK post_data_add_element(struct _cef_post_data_t* self, + struct _cef_post_data_element_t* element) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: element; type: refptr_same + DCHECK(element); + if (!element) + return 0; + + // Execute + bool _retval = CefPostDataCppToC::Get(self)->AddElement( + CefPostDataElementCppToC::Unwrap(element)); + + // Return type: bool + return _retval; +} + +void CEF_CALLBACK post_data_remove_elements(struct _cef_post_data_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefPostDataCppToC::Get(self)->RemoveElements(); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefPostDataCppToC::CefPostDataCppToC(CefPostData* cls) + : CefCppToC(cls) { + struct_.struct_.is_read_only = post_data_is_read_only; + struct_.struct_.get_element_count = post_data_get_element_count; + struct_.struct_.get_elements = post_data_get_elements; + struct_.struct_.remove_element = post_data_remove_element; + struct_.struct_.add_element = post_data_add_element; + struct_.struct_.remove_elements = post_data_remove_elements; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/post_data_cpptoc.h b/cef3/libcef_dll/cpptoc/post_data_cpptoc.h new file mode 100644 index 000000000..0b2886541 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/post_data_cpptoc.h @@ -0,0 +1,36 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_POST_DATA_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_POST_DATA_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_request.h" +#include "include/capi/cef_request_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefPostDataCppToC + : public CefCppToC { + public: + explicit CefPostDataCppToC(CefPostData* cls); + virtual ~CefPostDataCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_POST_DATA_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/post_data_element_cpptoc.cc b/cef3/libcef_dll/cpptoc/post_data_element_cpptoc.cc new file mode 100644 index 000000000..53a928ebf --- /dev/null +++ b/cef3/libcef_dll/cpptoc/post_data_element_cpptoc.cc @@ -0,0 +1,180 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/post_data_element_cpptoc.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_post_data_element_t* cef_post_data_element_create() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = CefPostDataElement::Create(); + + // Return type: refptr_same + return CefPostDataElementCppToC::Wrap(_retval); +} + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK post_data_element_is_read_only( + struct _cef_post_data_element_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefPostDataElementCppToC::Get(self)->IsReadOnly(); + + // Return type: bool + return _retval; +} + +void CEF_CALLBACK post_data_element_set_to_empty( + struct _cef_post_data_element_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefPostDataElementCppToC::Get(self)->SetToEmpty(); +} + +void CEF_CALLBACK post_data_element_set_to_file( + struct _cef_post_data_element_t* self, const cef_string_t* fileName) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: fileName; type: string_byref_const + DCHECK(fileName); + if (!fileName) + return; + + // Execute + CefPostDataElementCppToC::Get(self)->SetToFile( + CefString(fileName)); +} + +void CEF_CALLBACK post_data_element_set_to_bytes( + struct _cef_post_data_element_t* self, size_t size, const void* bytes) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: bytes; type: simple_byaddr + DCHECK(bytes); + if (!bytes) + return; + + // Execute + CefPostDataElementCppToC::Get(self)->SetToBytes( + size, + bytes); +} + +enum cef_postdataelement_type_t CEF_CALLBACK post_data_element_get_type( + struct _cef_post_data_element_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return PDE_TYPE_EMPTY; + + // Execute + cef_postdataelement_type_t _retval = CefPostDataElementCppToC::Get( + self)->GetType(); + + // Return type: simple + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK post_data_element_get_file( + struct _cef_post_data_element_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefPostDataElementCppToC::Get(self)->GetFile(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +size_t CEF_CALLBACK post_data_element_get_bytes_count( + struct _cef_post_data_element_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + size_t _retval = CefPostDataElementCppToC::Get(self)->GetBytesCount(); + + // Return type: simple + return _retval; +} + +size_t CEF_CALLBACK post_data_element_get_bytes( + struct _cef_post_data_element_t* self, size_t size, void* bytes) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: bytes; type: simple_byaddr + DCHECK(bytes); + if (!bytes) + return 0; + + // Execute + size_t _retval = CefPostDataElementCppToC::Get(self)->GetBytes( + size, + bytes); + + // Return type: simple + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefPostDataElementCppToC::CefPostDataElementCppToC(CefPostDataElement* cls) + : CefCppToC(cls) { + struct_.struct_.is_read_only = post_data_element_is_read_only; + struct_.struct_.set_to_empty = post_data_element_set_to_empty; + struct_.struct_.set_to_file = post_data_element_set_to_file; + struct_.struct_.set_to_bytes = post_data_element_set_to_bytes; + struct_.struct_.get_type = post_data_element_get_type; + struct_.struct_.get_file = post_data_element_get_file; + struct_.struct_.get_bytes_count = post_data_element_get_bytes_count; + struct_.struct_.get_bytes = post_data_element_get_bytes; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/post_data_element_cpptoc.h b/cef3/libcef_dll/cpptoc/post_data_element_cpptoc.h new file mode 100644 index 000000000..d7449c7ea --- /dev/null +++ b/cef3/libcef_dll/cpptoc/post_data_element_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_POST_DATA_ELEMENT_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_POST_DATA_ELEMENT_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_request.h" +#include "include/capi/cef_request_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefPostDataElementCppToC + : public CefCppToC { + public: + explicit CefPostDataElementCppToC(CefPostDataElement* cls); + virtual ~CefPostDataElementCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_POST_DATA_ELEMENT_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/process_message_cpptoc.cc b/cef3/libcef_dll/cpptoc/process_message_cpptoc.cc new file mode 100644 index 000000000..2c042c681 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/process_message_cpptoc.cc @@ -0,0 +1,132 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/list_value_cpptoc.h" +#include "libcef_dll/cpptoc/process_message_cpptoc.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_process_message_t* cef_process_message_create( + const cef_string_t* name) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: name; type: string_byref_const + DCHECK(name); + if (!name) + return NULL; + + // Execute + CefRefPtr _retval = CefProcessMessage::Create( + CefString(name)); + + // Return type: refptr_same + return CefProcessMessageCppToC::Wrap(_retval); +} + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK process_message_is_valid(struct _cef_process_message_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefProcessMessageCppToC::Get(self)->IsValid(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK process_message_is_read_only( + struct _cef_process_message_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefProcessMessageCppToC::Get(self)->IsReadOnly(); + + // Return type: bool + return _retval; +} + +struct _cef_process_message_t* CEF_CALLBACK process_message_copy( + struct _cef_process_message_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefProcessMessageCppToC::Get( + self)->Copy(); + + // Return type: refptr_same + return CefProcessMessageCppToC::Wrap(_retval); +} + +cef_string_userfree_t CEF_CALLBACK process_message_get_name( + struct _cef_process_message_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefProcessMessageCppToC::Get(self)->GetName(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +struct _cef_list_value_t* CEF_CALLBACK process_message_get_argument_list( + struct _cef_process_message_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefProcessMessageCppToC::Get( + self)->GetArgumentList(); + + // Return type: refptr_same + return CefListValueCppToC::Wrap(_retval); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefProcessMessageCppToC::CefProcessMessageCppToC(CefProcessMessage* cls) + : CefCppToC(cls) { + struct_.struct_.is_valid = process_message_is_valid; + struct_.struct_.is_read_only = process_message_is_read_only; + struct_.struct_.copy = process_message_copy; + struct_.struct_.get_name = process_message_get_name; + struct_.struct_.get_argument_list = process_message_get_argument_list; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/process_message_cpptoc.h b/cef3/libcef_dll/cpptoc/process_message_cpptoc.h new file mode 100644 index 000000000..1e0253fda --- /dev/null +++ b/cef3/libcef_dll/cpptoc/process_message_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_PROCESS_MESSAGE_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_PROCESS_MESSAGE_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_process_message.h" +#include "include/capi/cef_process_message_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefProcessMessageCppToC + : public CefCppToC { + public: + explicit CefProcessMessageCppToC(CefProcessMessage* cls); + virtual ~CefProcessMessageCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_PROCESS_MESSAGE_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/quota_callback_cpptoc.cc b/cef3/libcef_dll/cpptoc/quota_callback_cpptoc.cc new file mode 100644 index 000000000..5f53336d4 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/quota_callback_cpptoc.cc @@ -0,0 +1,56 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/quota_callback_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK quota_callback_cont(struct _cef_quota_callback_t* self, + int allow) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefQuotaCallbackCppToC::Get(self)->Continue( + allow?true:false); +} + +void CEF_CALLBACK quota_callback_cancel(struct _cef_quota_callback_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefQuotaCallbackCppToC::Get(self)->Cancel(); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefQuotaCallbackCppToC::CefQuotaCallbackCppToC(CefQuotaCallback* cls) + : CefCppToC( + cls) { + struct_.struct_.cont = quota_callback_cont; + struct_.struct_.cancel = quota_callback_cancel; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/quota_callback_cpptoc.h b/cef3/libcef_dll/cpptoc/quota_callback_cpptoc.h new file mode 100644 index 000000000..2312482e4 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/quota_callback_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_QUOTA_CALLBACK_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_QUOTA_CALLBACK_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_request_handler.h" +#include "include/capi/cef_request_handler_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefQuotaCallbackCppToC + : public CefCppToC { + public: + explicit CefQuotaCallbackCppToC(CefQuotaCallback* cls); + virtual ~CefQuotaCallbackCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_QUOTA_CALLBACK_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/read_handler_cpptoc.cc b/cef3/libcef_dll/cpptoc/read_handler_cpptoc.cc new file mode 100644 index 000000000..cc5495019 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/read_handler_cpptoc.cc @@ -0,0 +1,100 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/read_handler_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +size_t CEF_CALLBACK read_handler_read(struct _cef_read_handler_t* self, + void* ptr, size_t size, size_t n) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: ptr; type: simple_byaddr + DCHECK(ptr); + if (!ptr) + return 0; + + // Execute + size_t _retval = CefReadHandlerCppToC::Get(self)->Read( + ptr, + size, + n); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK read_handler_seek(struct _cef_read_handler_t* self, + int64 offset, int whence) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefReadHandlerCppToC::Get(self)->Seek( + offset, + whence); + + // Return type: simple + return _retval; +} + +int64 CEF_CALLBACK read_handler_tell(struct _cef_read_handler_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int64 _retval = CefReadHandlerCppToC::Get(self)->Tell(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK read_handler_eof(struct _cef_read_handler_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefReadHandlerCppToC::Get(self)->Eof(); + + // Return type: simple + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefReadHandlerCppToC::CefReadHandlerCppToC(CefReadHandler* cls) + : CefCppToC(cls) { + struct_.struct_.read = read_handler_read; + struct_.struct_.seek = read_handler_seek; + struct_.struct_.tell = read_handler_tell; + struct_.struct_.eof = read_handler_eof; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/read_handler_cpptoc.h b/cef3/libcef_dll/cpptoc/read_handler_cpptoc.h new file mode 100644 index 000000000..04ffba8d4 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/read_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_READ_HANDLER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_READ_HANDLER_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_stream.h" +#include "include/capi/cef_stream_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefReadHandlerCppToC + : public CefCppToC { + public: + explicit CefReadHandlerCppToC(CefReadHandler* cls); + virtual ~CefReadHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_READ_HANDLER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/render_handler_cpptoc.cc b/cef3/libcef_dll/cpptoc/render_handler_cpptoc.cc new file mode 100644 index 000000000..c77bed238 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/render_handler_cpptoc.cc @@ -0,0 +1,252 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/render_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK render_handler_get_root_screen_rect( + struct _cef_render_handler_t* self, cef_browser_t* browser, + cef_rect_t* rect) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: rect; type: simple_byref + DCHECK(rect); + if (!rect) + return 0; + + // Translate param: rect; type: simple_byref + CefRect rectVal = rect?*rect:CefRect(); + + // Execute + bool _retval = CefRenderHandlerCppToC::Get(self)->GetRootScreenRect( + CefBrowserCToCpp::Wrap(browser), + rectVal); + + // Restore param: rect; type: simple_byref + if (rect) + *rect = rectVal; + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK render_handler_get_view_rect( + struct _cef_render_handler_t* self, cef_browser_t* browser, + cef_rect_t* rect) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: rect; type: simple_byref + DCHECK(rect); + if (!rect) + return 0; + + // Translate param: rect; type: simple_byref + CefRect rectVal = rect?*rect:CefRect(); + + // Execute + bool _retval = CefRenderHandlerCppToC::Get(self)->GetViewRect( + CefBrowserCToCpp::Wrap(browser), + rectVal); + + // Restore param: rect; type: simple_byref + if (rect) + *rect = rectVal; + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK render_handler_get_screen_point( + struct _cef_render_handler_t* self, cef_browser_t* browser, int viewX, + int viewY, int* screenX, int* screenY) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: screenX; type: simple_byref + DCHECK(screenX); + if (!screenX) + return 0; + // Verify param: screenY; type: simple_byref + DCHECK(screenY); + if (!screenY) + return 0; + + // Translate param: screenX; type: simple_byref + int screenXVal = screenX?*screenX:0; + // Translate param: screenY; type: simple_byref + int screenYVal = screenY?*screenY:0; + + // Execute + bool _retval = CefRenderHandlerCppToC::Get(self)->GetScreenPoint( + CefBrowserCToCpp::Wrap(browser), + viewX, + viewY, + screenXVal, + screenYVal); + + // Restore param: screenX; type: simple_byref + if (screenX) + *screenX = screenXVal; + // Restore param: screenY; type: simple_byref + if (screenY) + *screenY = screenYVal; + + // Return type: bool + return _retval; +} + +void CEF_CALLBACK render_handler_on_popup_show( + struct _cef_render_handler_t* self, cef_browser_t* browser, int show) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + + // Execute + CefRenderHandlerCppToC::Get(self)->OnPopupShow( + CefBrowserCToCpp::Wrap(browser), + show?true:false); +} + +void CEF_CALLBACK render_handler_on_popup_size( + struct _cef_render_handler_t* self, cef_browser_t* browser, + const cef_rect_t* rect) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: rect; type: simple_byref_const + DCHECK(rect); + if (!rect) + return; + + // Translate param: rect; type: simple_byref_const + CefRect rectVal = rect?*rect:CefRect(); + + // Execute + CefRenderHandlerCppToC::Get(self)->OnPopupSize( + CefBrowserCToCpp::Wrap(browser), + rectVal); +} + +void CEF_CALLBACK render_handler_on_paint(struct _cef_render_handler_t* self, + cef_browser_t* browser, enum cef_paint_element_type_t type, + size_t dirtyRectsCount, cef_rect_t const* dirtyRects, const void* buffer, + int width, int height) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: dirtyRects; type: simple_vec_byref_const + DCHECK(dirtyRectsCount == 0 || dirtyRects); + if (dirtyRectsCount > 0 && !dirtyRects) + return; + // Verify param: buffer; type: simple_byaddr + DCHECK(buffer); + if (!buffer) + return; + + // Translate param: dirtyRects; type: simple_vec_byref_const + std::vector dirtyRectsList; + if (dirtyRectsCount > 0) { + for (size_t i = 0; i < dirtyRectsCount; ++i) { + dirtyRectsList.push_back(dirtyRects[i]); + } + } + + // Execute + CefRenderHandlerCppToC::Get(self)->OnPaint( + CefBrowserCToCpp::Wrap(browser), + type, + dirtyRectsList, + buffer, + width, + height); +} + +void CEF_CALLBACK render_handler_on_cursor_change( + struct _cef_render_handler_t* self, cef_browser_t* browser, + cef_cursor_handle_t cursor) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + + // Execute + CefRenderHandlerCppToC::Get(self)->OnCursorChange( + CefBrowserCToCpp::Wrap(browser), + cursor); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefRenderHandlerCppToC::CefRenderHandlerCppToC(CefRenderHandler* cls) + : CefCppToC( + cls) { + struct_.struct_.get_root_screen_rect = render_handler_get_root_screen_rect; + struct_.struct_.get_view_rect = render_handler_get_view_rect; + struct_.struct_.get_screen_point = render_handler_get_screen_point; + struct_.struct_.on_popup_show = render_handler_on_popup_show; + struct_.struct_.on_popup_size = render_handler_on_popup_size; + struct_.struct_.on_paint = render_handler_on_paint; + struct_.struct_.on_cursor_change = render_handler_on_cursor_change; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/render_handler_cpptoc.h b/cef3/libcef_dll/cpptoc/render_handler_cpptoc.h new file mode 100644 index 000000000..1fd90fe3f --- /dev/null +++ b/cef3/libcef_dll/cpptoc/render_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_RENDER_HANDLER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_RENDER_HANDLER_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_render_handler.h" +#include "include/capi/cef_render_handler_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefRenderHandlerCppToC + : public CefCppToC { + public: + explicit CefRenderHandlerCppToC(CefRenderHandler* cls); + virtual ~CefRenderHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_RENDER_HANDLER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/render_process_handler_cpptoc.cc b/cef3/libcef_dll/cpptoc/render_process_handler_cpptoc.cc new file mode 100644 index 000000000..11684705a --- /dev/null +++ b/cef3/libcef_dll/cpptoc/render_process_handler_cpptoc.cc @@ -0,0 +1,393 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/render_process_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/domnode_ctocpp.h" +#include "libcef_dll/ctocpp/frame_ctocpp.h" +#include "libcef_dll/ctocpp/list_value_ctocpp.h" +#include "libcef_dll/ctocpp/process_message_ctocpp.h" +#include "libcef_dll/ctocpp/request_ctocpp.h" +#include "libcef_dll/ctocpp/v8context_ctocpp.h" +#include "libcef_dll/ctocpp/v8exception_ctocpp.h" +#include "libcef_dll/ctocpp/v8stack_trace_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK render_process_handler_on_render_thread_created( + struct _cef_render_process_handler_t* self, + struct _cef_list_value_t* extra_info) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: extra_info; type: refptr_diff + DCHECK(extra_info); + if (!extra_info) + return; + + // Execute + CefRenderProcessHandlerCppToC::Get(self)->OnRenderThreadCreated( + CefListValueCToCpp::Wrap(extra_info)); +} + +void CEF_CALLBACK render_process_handler_on_web_kit_initialized( + struct _cef_render_process_handler_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefRenderProcessHandlerCppToC::Get(self)->OnWebKitInitialized(); +} + +void CEF_CALLBACK render_process_handler_on_browser_created( + struct _cef_render_process_handler_t* self, cef_browser_t* browser) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + + // Execute + CefRenderProcessHandlerCppToC::Get(self)->OnBrowserCreated( + CefBrowserCToCpp::Wrap(browser)); +} + +void CEF_CALLBACK render_process_handler_on_browser_destroyed( + struct _cef_render_process_handler_t* self, cef_browser_t* browser) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + + // Execute + CefRenderProcessHandlerCppToC::Get(self)->OnBrowserDestroyed( + CefBrowserCToCpp::Wrap(browser)); +} + +int CEF_CALLBACK render_process_handler_on_before_navigation( + struct _cef_render_process_handler_t* self, cef_browser_t* browser, + cef_frame_t* frame, struct _cef_request_t* request, + enum cef_navigation_type_t navigation_type, int is_redirect) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return 0; + // Verify param: request; type: refptr_diff + DCHECK(request); + if (!request) + return 0; + + // Execute + bool _retval = CefRenderProcessHandlerCppToC::Get(self)->OnBeforeNavigation( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + CefRequestCToCpp::Wrap(request), + navigation_type, + is_redirect?true:false); + + // Return type: bool + return _retval; +} + +void CEF_CALLBACK render_process_handler_on_context_created( + struct _cef_render_process_handler_t* self, cef_browser_t* browser, + cef_frame_t* frame, struct _cef_v8context_t* context) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return; + // Verify param: context; type: refptr_diff + DCHECK(context); + if (!context) + return; + + // Execute + CefRenderProcessHandlerCppToC::Get(self)->OnContextCreated( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + CefV8ContextCToCpp::Wrap(context)); +} + +void CEF_CALLBACK render_process_handler_on_context_released( + struct _cef_render_process_handler_t* self, cef_browser_t* browser, + cef_frame_t* frame, struct _cef_v8context_t* context) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return; + // Verify param: context; type: refptr_diff + DCHECK(context); + if (!context) + return; + + // Execute + CefRenderProcessHandlerCppToC::Get(self)->OnContextReleased( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + CefV8ContextCToCpp::Wrap(context)); +} + +void CEF_CALLBACK render_process_handler_on_uncaught_exception( + struct _cef_render_process_handler_t* self, cef_browser_t* browser, + cef_frame_t* frame, struct _cef_v8context_t* context, + struct _cef_v8exception_t* exception, + struct _cef_v8stack_trace_t* stackTrace) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return; + // Verify param: context; type: refptr_diff + DCHECK(context); + if (!context) + return; + // Verify param: exception; type: refptr_diff + DCHECK(exception); + if (!exception) + return; + // Verify param: stackTrace; type: refptr_diff + DCHECK(stackTrace); + if (!stackTrace) + return; + + // Execute + CefRenderProcessHandlerCppToC::Get(self)->OnUncaughtException( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + CefV8ContextCToCpp::Wrap(context), + CefV8ExceptionCToCpp::Wrap(exception), + CefV8StackTraceCToCpp::Wrap(stackTrace)); +} + +void CEF_CALLBACK render_process_handler_on_worker_context_created( + struct _cef_render_process_handler_t* self, int worker_id, + const cef_string_t* url, struct _cef_v8context_t* context) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: url; type: string_byref_const + DCHECK(url); + if (!url) + return; + // Verify param: context; type: refptr_diff + DCHECK(context); + if (!context) + return; + + // Execute + CefRenderProcessHandlerCppToC::Get(self)->OnWorkerContextCreated( + worker_id, + CefString(url), + CefV8ContextCToCpp::Wrap(context)); +} + +void CEF_CALLBACK render_process_handler_on_worker_context_released( + struct _cef_render_process_handler_t* self, int worker_id, + const cef_string_t* url, struct _cef_v8context_t* context) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: url; type: string_byref_const + DCHECK(url); + if (!url) + return; + // Verify param: context; type: refptr_diff + DCHECK(context); + if (!context) + return; + + // Execute + CefRenderProcessHandlerCppToC::Get(self)->OnWorkerContextReleased( + worker_id, + CefString(url), + CefV8ContextCToCpp::Wrap(context)); +} + +void CEF_CALLBACK render_process_handler_on_worker_uncaught_exception( + struct _cef_render_process_handler_t* self, int worker_id, + const cef_string_t* url, struct _cef_v8context_t* context, + struct _cef_v8exception_t* exception, + struct _cef_v8stack_trace_t* stackTrace) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: url; type: string_byref_const + DCHECK(url); + if (!url) + return; + // Verify param: context; type: refptr_diff + DCHECK(context); + if (!context) + return; + // Verify param: exception; type: refptr_diff + DCHECK(exception); + if (!exception) + return; + // Verify param: stackTrace; type: refptr_diff + DCHECK(stackTrace); + if (!stackTrace) + return; + + // Execute + CefRenderProcessHandlerCppToC::Get(self)->OnWorkerUncaughtException( + worker_id, + CefString(url), + CefV8ContextCToCpp::Wrap(context), + CefV8ExceptionCToCpp::Wrap(exception), + CefV8StackTraceCToCpp::Wrap(stackTrace)); +} + +void CEF_CALLBACK render_process_handler_on_focused_node_changed( + struct _cef_render_process_handler_t* self, cef_browser_t* browser, + cef_frame_t* frame, cef_domnode_t* node) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Unverified params: frame, node + + // Execute + CefRenderProcessHandlerCppToC::Get(self)->OnFocusedNodeChanged( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + CefDOMNodeCToCpp::Wrap(node)); +} + +int CEF_CALLBACK render_process_handler_on_process_message_received( + struct _cef_render_process_handler_t* self, cef_browser_t* browser, + enum cef_process_id_t source_process, cef_process_message_t* message) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: message; type: refptr_diff + DCHECK(message); + if (!message) + return 0; + + // Execute + bool _retval = CefRenderProcessHandlerCppToC::Get( + self)->OnProcessMessageReceived( + CefBrowserCToCpp::Wrap(browser), + source_process, + CefProcessMessageCToCpp::Wrap(message)); + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefRenderProcessHandlerCppToC::CefRenderProcessHandlerCppToC( + CefRenderProcessHandler* cls) + : CefCppToC(cls) { + struct_.struct_.on_render_thread_created = + render_process_handler_on_render_thread_created; + struct_.struct_.on_web_kit_initialized = + render_process_handler_on_web_kit_initialized; + struct_.struct_.on_browser_created = + render_process_handler_on_browser_created; + struct_.struct_.on_browser_destroyed = + render_process_handler_on_browser_destroyed; + struct_.struct_.on_before_navigation = + render_process_handler_on_before_navigation; + struct_.struct_.on_context_created = + render_process_handler_on_context_created; + struct_.struct_.on_context_released = + render_process_handler_on_context_released; + struct_.struct_.on_uncaught_exception = + render_process_handler_on_uncaught_exception; + struct_.struct_.on_worker_context_created = + render_process_handler_on_worker_context_created; + struct_.struct_.on_worker_context_released = + render_process_handler_on_worker_context_released; + struct_.struct_.on_worker_uncaught_exception = + render_process_handler_on_worker_uncaught_exception; + struct_.struct_.on_focused_node_changed = + render_process_handler_on_focused_node_changed; + struct_.struct_.on_process_message_received = + render_process_handler_on_process_message_received; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/render_process_handler_cpptoc.h b/cef3/libcef_dll/cpptoc/render_process_handler_cpptoc.h new file mode 100644 index 000000000..42ecf803b --- /dev/null +++ b/cef3/libcef_dll/cpptoc/render_process_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_RENDER_PROCESS_HANDLER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_RENDER_PROCESS_HANDLER_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_render_process_handler.h" +#include "include/capi/cef_render_process_handler_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefRenderProcessHandlerCppToC + : public CefCppToC { + public: + explicit CefRenderProcessHandlerCppToC(CefRenderProcessHandler* cls); + virtual ~CefRenderProcessHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_RENDER_PROCESS_HANDLER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/request_cpptoc.cc b/cef3/libcef_dll/cpptoc/request_cpptoc.cc new file mode 100644 index 000000000..5201bf57e --- /dev/null +++ b/cef3/libcef_dll/cpptoc/request_cpptoc.cc @@ -0,0 +1,308 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/post_data_cpptoc.h" +#include "libcef_dll/cpptoc/request_cpptoc.h" +#include "libcef_dll/transfer_util.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_request_t* cef_request_create() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = CefRequest::Create(); + + // Return type: refptr_same + return CefRequestCppToC::Wrap(_retval); +} + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK request_is_read_only(struct _cef_request_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefRequestCppToC::Get(self)->IsReadOnly(); + + // Return type: bool + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK request_get_url( + struct _cef_request_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefRequestCppToC::Get(self)->GetURL(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +void CEF_CALLBACK request_set_url(struct _cef_request_t* self, + const cef_string_t* url) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: url; type: string_byref_const + DCHECK(url); + if (!url) + return; + + // Execute + CefRequestCppToC::Get(self)->SetURL( + CefString(url)); +} + +cef_string_userfree_t CEF_CALLBACK request_get_method( + struct _cef_request_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefRequestCppToC::Get(self)->GetMethod(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +void CEF_CALLBACK request_set_method(struct _cef_request_t* self, + const cef_string_t* method) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: method; type: string_byref_const + DCHECK(method); + if (!method) + return; + + // Execute + CefRequestCppToC::Get(self)->SetMethod( + CefString(method)); +} + +struct _cef_post_data_t* CEF_CALLBACK request_get_post_data( + struct _cef_request_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefRequestCppToC::Get(self)->GetPostData(); + + // Return type: refptr_same + return CefPostDataCppToC::Wrap(_retval); +} + +void CEF_CALLBACK request_set_post_data(struct _cef_request_t* self, + struct _cef_post_data_t* postData) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: postData; type: refptr_same + DCHECK(postData); + if (!postData) + return; + + // Execute + CefRequestCppToC::Get(self)->SetPostData( + CefPostDataCppToC::Unwrap(postData)); +} + +void CEF_CALLBACK request_get_header_map(struct _cef_request_t* self, + cef_string_multimap_t headerMap) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: headerMap; type: string_map_multi_byref + DCHECK(headerMap); + if (!headerMap) + return; + + // Translate param: headerMap; type: string_map_multi_byref + std::multimap headerMapMultimap; + transfer_string_multimap_contents(headerMap, headerMapMultimap); + + // Execute + CefRequestCppToC::Get(self)->GetHeaderMap( + headerMapMultimap); + + // Restore param: headerMap; type: string_map_multi_byref + cef_string_multimap_clear(headerMap); + transfer_string_multimap_contents(headerMapMultimap, headerMap); +} + +void CEF_CALLBACK request_set_header_map(struct _cef_request_t* self, + cef_string_multimap_t headerMap) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: headerMap; type: string_map_multi_byref_const + DCHECK(headerMap); + if (!headerMap) + return; + + // Translate param: headerMap; type: string_map_multi_byref_const + std::multimap headerMapMultimap; + transfer_string_multimap_contents(headerMap, headerMapMultimap); + + // Execute + CefRequestCppToC::Get(self)->SetHeaderMap( + headerMapMultimap); +} + +void CEF_CALLBACK request_set(struct _cef_request_t* self, + const cef_string_t* url, const cef_string_t* method, + struct _cef_post_data_t* postData, cef_string_multimap_t headerMap) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: url; type: string_byref_const + DCHECK(url); + if (!url) + return; + // Verify param: method; type: string_byref_const + DCHECK(method); + if (!method) + return; + // Verify param: headerMap; type: string_map_multi_byref_const + DCHECK(headerMap); + if (!headerMap) + return; + // Unverified params: postData + + // Translate param: headerMap; type: string_map_multi_byref_const + std::multimap headerMapMultimap; + transfer_string_multimap_contents(headerMap, headerMapMultimap); + + // Execute + CefRequestCppToC::Get(self)->Set( + CefString(url), + CefString(method), + CefPostDataCppToC::Unwrap(postData), + headerMapMultimap); +} + +int CEF_CALLBACK request_get_flags(struct _cef_request_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return UR_FLAG_NONE; + + // Execute + int _retval = CefRequestCppToC::Get(self)->GetFlags(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK request_set_flags(struct _cef_request_t* self, int flags) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefRequestCppToC::Get(self)->SetFlags( + flags); +} + +cef_string_userfree_t CEF_CALLBACK request_get_first_party_for_cookies( + struct _cef_request_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefRequestCppToC::Get(self)->GetFirstPartyForCookies(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +void CEF_CALLBACK request_set_first_party_for_cookies( + struct _cef_request_t* self, const cef_string_t* url) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: url; type: string_byref_const + DCHECK(url); + if (!url) + return; + + // Execute + CefRequestCppToC::Get(self)->SetFirstPartyForCookies( + CefString(url)); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefRequestCppToC::CefRequestCppToC(CefRequest* cls) + : CefCppToC(cls) { + struct_.struct_.is_read_only = request_is_read_only; + struct_.struct_.get_url = request_get_url; + struct_.struct_.set_url = request_set_url; + struct_.struct_.get_method = request_get_method; + struct_.struct_.set_method = request_set_method; + struct_.struct_.get_post_data = request_get_post_data; + struct_.struct_.set_post_data = request_set_post_data; + struct_.struct_.get_header_map = request_get_header_map; + struct_.struct_.set_header_map = request_set_header_map; + struct_.struct_.set = request_set; + struct_.struct_.get_flags = request_get_flags; + struct_.struct_.set_flags = request_set_flags; + struct_.struct_.get_first_party_for_cookies = + request_get_first_party_for_cookies; + struct_.struct_.set_first_party_for_cookies = + request_set_first_party_for_cookies; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/request_cpptoc.h b/cef3/libcef_dll/cpptoc/request_cpptoc.h new file mode 100644 index 000000000..bf6655ad4 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/request_cpptoc.h @@ -0,0 +1,36 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_REQUEST_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_REQUEST_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_request.h" +#include "include/capi/cef_request_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefRequestCppToC + : public CefCppToC { + public: + explicit CefRequestCppToC(CefRequest* cls); + virtual ~CefRequestCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_REQUEST_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/request_handler_cpptoc.cc b/cef3/libcef_dll/cpptoc/request_handler_cpptoc.cc new file mode 100644 index 000000000..da7cbaf28 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/request_handler_cpptoc.cc @@ -0,0 +1,349 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/request_handler_cpptoc.h" +#include "libcef_dll/cpptoc/resource_handler_cpptoc.h" +#include "libcef_dll/ctocpp/allow_certificate_error_callback_ctocpp.h" +#include "libcef_dll/ctocpp/auth_callback_ctocpp.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/cookie_manager_ctocpp.h" +#include "libcef_dll/ctocpp/frame_ctocpp.h" +#include "libcef_dll/ctocpp/quota_callback_ctocpp.h" +#include "libcef_dll/ctocpp/request_ctocpp.h" +#include "libcef_dll/ctocpp/web_plugin_info_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK request_handler_on_before_resource_load( + struct _cef_request_handler_t* self, cef_browser_t* browser, + cef_frame_t* frame, cef_request_t* request) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return 0; + // Verify param: request; type: refptr_diff + DCHECK(request); + if (!request) + return 0; + + // Execute + bool _retval = CefRequestHandlerCppToC::Get(self)->OnBeforeResourceLoad( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + CefRequestCToCpp::Wrap(request)); + + // Return type: bool + return _retval; +} + +struct _cef_resource_handler_t* CEF_CALLBACK request_handler_get_resource_handler( + struct _cef_request_handler_t* self, cef_browser_t* browser, + cef_frame_t* frame, cef_request_t* request) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return NULL; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return NULL; + // Verify param: request; type: refptr_diff + DCHECK(request); + if (!request) + return NULL; + + // Execute + CefRefPtr _retval = CefRequestHandlerCppToC::Get( + self)->GetResourceHandler( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + CefRequestCToCpp::Wrap(request)); + + // Return type: refptr_same + return CefResourceHandlerCppToC::Wrap(_retval); +} + +void CEF_CALLBACK request_handler_on_resource_redirect( + struct _cef_request_handler_t* self, cef_browser_t* browser, + cef_frame_t* frame, const cef_string_t* old_url, cef_string_t* new_url) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return; + // Verify param: old_url; type: string_byref_const + DCHECK(old_url); + if (!old_url) + return; + // Verify param: new_url; type: string_byref + DCHECK(new_url); + if (!new_url) + return; + + // Translate param: new_url; type: string_byref + CefString new_urlStr(new_url); + + // Execute + CefRequestHandlerCppToC::Get(self)->OnResourceRedirect( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + CefString(old_url), + new_urlStr); +} + +int CEF_CALLBACK request_handler_get_auth_credentials( + struct _cef_request_handler_t* self, cef_browser_t* browser, + cef_frame_t* frame, int isProxy, const cef_string_t* host, int port, + const cef_string_t* realm, const cef_string_t* scheme, + cef_auth_callback_t* callback) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return 0; + // Verify param: host; type: string_byref_const + DCHECK(host); + if (!host) + return 0; + // Verify param: scheme; type: string_byref_const + DCHECK(scheme); + if (!scheme) + return 0; + // Verify param: callback; type: refptr_diff + DCHECK(callback); + if (!callback) + return 0; + // Unverified params: realm + + // Execute + bool _retval = CefRequestHandlerCppToC::Get(self)->GetAuthCredentials( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + isProxy?true:false, + CefString(host), + port, + CefString(realm), + CefString(scheme), + CefAuthCallbackCToCpp::Wrap(callback)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK request_handler_on_quota_request( + struct _cef_request_handler_t* self, cef_browser_t* browser, + const cef_string_t* origin_url, int64 new_size, + cef_quota_callback_t* callback) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: origin_url; type: string_byref_const + DCHECK(origin_url); + if (!origin_url) + return 0; + // Verify param: callback; type: refptr_diff + DCHECK(callback); + if (!callback) + return 0; + + // Execute + bool _retval = CefRequestHandlerCppToC::Get(self)->OnQuotaRequest( + CefBrowserCToCpp::Wrap(browser), + CefString(origin_url), + new_size, + CefQuotaCallbackCToCpp::Wrap(callback)); + + // Return type: bool + return _retval; +} + +cef_cookie_manager_t* CEF_CALLBACK request_handler_get_cookie_manager( + struct _cef_request_handler_t* self, cef_browser_t* browser, + const cef_string_t* main_url) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return NULL; + // Verify param: main_url; type: string_byref_const + DCHECK(main_url); + if (!main_url) + return NULL; + + // Execute + CefRefPtr _retval = CefRequestHandlerCppToC::Get( + self)->GetCookieManager( + CefBrowserCToCpp::Wrap(browser), + CefString(main_url)); + + // Return type: refptr_diff + return CefCookieManagerCToCpp::Unwrap(_retval); +} + +void CEF_CALLBACK request_handler_on_protocol_execution( + struct _cef_request_handler_t* self, cef_browser_t* browser, + const cef_string_t* url, int* allow_os_execution) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: url; type: string_byref_const + DCHECK(url); + if (!url) + return; + // Verify param: allow_os_execution; type: bool_byref + DCHECK(allow_os_execution); + if (!allow_os_execution) + return; + + // Translate param: allow_os_execution; type: bool_byref + bool allow_os_executionBool = ( + allow_os_execution && *allow_os_execution)?true:false; + + // Execute + CefRequestHandlerCppToC::Get(self)->OnProtocolExecution( + CefBrowserCToCpp::Wrap(browser), + CefString(url), + allow_os_executionBool); + + // Restore param: allow_os_execution; type: bool_byref + if (allow_os_execution) + *allow_os_execution = allow_os_executionBool?true:false; +} + +int CEF_CALLBACK request_handler_on_before_plugin_load( + struct _cef_request_handler_t* self, cef_browser_t* browser, + const cef_string_t* url, const cef_string_t* policy_url, + struct _cef_web_plugin_info_t* info) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: info; type: refptr_diff + DCHECK(info); + if (!info) + return 0; + // Unverified params: url, policy_url + + // Execute + bool _retval = CefRequestHandlerCppToC::Get(self)->OnBeforePluginLoad( + CefBrowserCToCpp::Wrap(browser), + CefString(url), + CefString(policy_url), + CefWebPluginInfoCToCpp::Wrap(info)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK request_handler_on_certificate_error( + struct _cef_request_handler_t* self, enum cef_errorcode_t cert_error, + const cef_string_t* request_url, + cef_allow_certificate_error_callback_t* callback) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: request_url; type: string_byref_const + DCHECK(request_url); + if (!request_url) + return 0; + // Verify param: callback; type: refptr_diff + DCHECK(callback); + if (!callback) + return 0; + + // Execute + bool _retval = CefRequestHandlerCppToC::Get(self)->OnCertificateError( + cert_error, + CefString(request_url), + CefAllowCertificateErrorCallbackCToCpp::Wrap(callback)); + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefRequestHandlerCppToC::CefRequestHandlerCppToC(CefRequestHandler* cls) + : CefCppToC(cls) { + struct_.struct_.on_before_resource_load = + request_handler_on_before_resource_load; + struct_.struct_.get_resource_handler = request_handler_get_resource_handler; + struct_.struct_.on_resource_redirect = request_handler_on_resource_redirect; + struct_.struct_.get_auth_credentials = request_handler_get_auth_credentials; + struct_.struct_.on_quota_request = request_handler_on_quota_request; + struct_.struct_.get_cookie_manager = request_handler_get_cookie_manager; + struct_.struct_.on_protocol_execution = request_handler_on_protocol_execution; + struct_.struct_.on_before_plugin_load = request_handler_on_before_plugin_load; + struct_.struct_.on_certificate_error = request_handler_on_certificate_error; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/request_handler_cpptoc.h b/cef3/libcef_dll/cpptoc/request_handler_cpptoc.h new file mode 100644 index 000000000..866ef1152 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/request_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_REQUEST_HANDLER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_REQUEST_HANDLER_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_request_handler.h" +#include "include/capi/cef_request_handler_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefRequestHandlerCppToC + : public CefCppToC { + public: + explicit CefRequestHandlerCppToC(CefRequestHandler* cls); + virtual ~CefRequestHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_REQUEST_HANDLER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/resource_bundle_handler_cpptoc.cc b/cef3/libcef_dll/cpptoc/resource_bundle_handler_cpptoc.cc new file mode 100644 index 000000000..9a6bcd8e8 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/resource_bundle_handler_cpptoc.cc @@ -0,0 +1,98 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/resource_bundle_handler_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK resource_bundle_handler_get_localized_string( + struct _cef_resource_bundle_handler_t* self, int message_id, + cef_string_t* string) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: string; type: string_byref + DCHECK(string); + if (!string) + return 0; + + // Translate param: string; type: string_byref + CefString stringStr(string); + + // Execute + bool _retval = CefResourceBundleHandlerCppToC::Get(self)->GetLocalizedString( + message_id, + stringStr); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK resource_bundle_handler_get_data_resource( + struct _cef_resource_bundle_handler_t* self, int resource_id, void** data, + size_t* data_size) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: data; type: simple_byref + DCHECK(data); + if (!data) + return 0; + // Verify param: data_size; type: simple_byref + DCHECK(data_size); + if (!data_size) + return 0; + + // Translate param: data; type: simple_byref + void* dataVal = data?*data:NULL; + // Translate param: data_size; type: simple_byref + size_t data_sizeVal = data_size?*data_size:0; + + // Execute + bool _retval = CefResourceBundleHandlerCppToC::Get(self)->GetDataResource( + resource_id, + dataVal, + data_sizeVal); + + // Restore param: data; type: simple_byref + if (data) + *data = dataVal; + // Restore param: data_size; type: simple_byref + if (data_size) + *data_size = data_sizeVal; + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefResourceBundleHandlerCppToC::CefResourceBundleHandlerCppToC( + CefResourceBundleHandler* cls) + : CefCppToC(cls) { + struct_.struct_.get_localized_string = + resource_bundle_handler_get_localized_string; + struct_.struct_.get_data_resource = resource_bundle_handler_get_data_resource; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/resource_bundle_handler_cpptoc.h b/cef3/libcef_dll/cpptoc/resource_bundle_handler_cpptoc.h new file mode 100644 index 000000000..8aefc1374 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/resource_bundle_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_RESOURCE_BUNDLE_HANDLER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_RESOURCE_BUNDLE_HANDLER_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_resource_bundle_handler.h" +#include "include/capi/cef_resource_bundle_handler_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefResourceBundleHandlerCppToC + : public CefCppToC { + public: + explicit CefResourceBundleHandlerCppToC(CefResourceBundleHandler* cls); + virtual ~CefResourceBundleHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_RESOURCE_BUNDLE_HANDLER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/resource_handler_cpptoc.cc b/cef3/libcef_dll/cpptoc/resource_handler_cpptoc.cc new file mode 100644 index 000000000..c33b28c54 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/resource_handler_cpptoc.cc @@ -0,0 +1,203 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/resource_handler_cpptoc.h" +#include "libcef_dll/ctocpp/callback_ctocpp.h" +#include "libcef_dll/ctocpp/request_ctocpp.h" +#include "libcef_dll/ctocpp/response_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK resource_handler_process_request( + struct _cef_resource_handler_t* self, cef_request_t* request, + cef_callback_t* callback) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: request; type: refptr_diff + DCHECK(request); + if (!request) + return 0; + // Verify param: callback; type: refptr_diff + DCHECK(callback); + if (!callback) + return 0; + + // Execute + bool _retval = CefResourceHandlerCppToC::Get(self)->ProcessRequest( + CefRequestCToCpp::Wrap(request), + CefCallbackCToCpp::Wrap(callback)); + + // Return type: bool + return _retval; +} + +void CEF_CALLBACK resource_handler_get_response_headers( + struct _cef_resource_handler_t* self, struct _cef_response_t* response, + int64* response_length, cef_string_t* redirectUrl) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: response; type: refptr_diff + DCHECK(response); + if (!response) + return; + // Verify param: response_length; type: simple_byref + DCHECK(response_length); + if (!response_length) + return; + // Verify param: redirectUrl; type: string_byref + DCHECK(redirectUrl); + if (!redirectUrl) + return; + + // Translate param: response_length; type: simple_byref + int64 response_lengthVal = response_length?*response_length:0; + // Translate param: redirectUrl; type: string_byref + CefString redirectUrlStr(redirectUrl); + + // Execute + CefResourceHandlerCppToC::Get(self)->GetResponseHeaders( + CefResponseCToCpp::Wrap(response), + response_lengthVal, + redirectUrlStr); + + // Restore param: response_length; type: simple_byref + if (response_length) + *response_length = response_lengthVal; +} + +int CEF_CALLBACK resource_handler_read_response( + struct _cef_resource_handler_t* self, void* data_out, int bytes_to_read, + int* bytes_read, cef_callback_t* callback) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: data_out; type: simple_byaddr + DCHECK(data_out); + if (!data_out) + return 0; + // Verify param: bytes_read; type: simple_byref + DCHECK(bytes_read); + if (!bytes_read) + return 0; + // Verify param: callback; type: refptr_diff + DCHECK(callback); + if (!callback) + return 0; + + // Translate param: bytes_read; type: simple_byref + int bytes_readVal = bytes_read?*bytes_read:0; + + // Execute + bool _retval = CefResourceHandlerCppToC::Get(self)->ReadResponse( + data_out, + bytes_to_read, + bytes_readVal, + CefCallbackCToCpp::Wrap(callback)); + + // Restore param: bytes_read; type: simple_byref + if (bytes_read) + *bytes_read = bytes_readVal; + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK resource_handler_can_get_cookie( + struct _cef_resource_handler_t* self, const struct _cef_cookie_t* cookie) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: cookie; type: struct_byref_const + DCHECK(cookie); + if (!cookie) + return 0; + + // Translate param: cookie; type: struct_byref_const + CefCookie cookieObj; + if (cookie) + cookieObj.Set(*cookie, false); + + // Execute + bool _retval = CefResourceHandlerCppToC::Get(self)->CanGetCookie( + cookieObj); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK resource_handler_can_set_cookie( + struct _cef_resource_handler_t* self, const struct _cef_cookie_t* cookie) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: cookie; type: struct_byref_const + DCHECK(cookie); + if (!cookie) + return 0; + + // Translate param: cookie; type: struct_byref_const + CefCookie cookieObj; + if (cookie) + cookieObj.Set(*cookie, false); + + // Execute + bool _retval = CefResourceHandlerCppToC::Get(self)->CanSetCookie( + cookieObj); + + // Return type: bool + return _retval; +} + +void CEF_CALLBACK resource_handler_cancel( + struct _cef_resource_handler_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefResourceHandlerCppToC::Get(self)->Cancel(); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefResourceHandlerCppToC::CefResourceHandlerCppToC(CefResourceHandler* cls) + : CefCppToC(cls) { + struct_.struct_.process_request = resource_handler_process_request; + struct_.struct_.get_response_headers = resource_handler_get_response_headers; + struct_.struct_.read_response = resource_handler_read_response; + struct_.struct_.can_get_cookie = resource_handler_can_get_cookie; + struct_.struct_.can_set_cookie = resource_handler_can_set_cookie; + struct_.struct_.cancel = resource_handler_cancel; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/resource_handler_cpptoc.h b/cef3/libcef_dll/cpptoc/resource_handler_cpptoc.h new file mode 100644 index 000000000..8c4972a44 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/resource_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_RESOURCE_HANDLER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_RESOURCE_HANDLER_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_resource_handler.h" +#include "include/capi/cef_resource_handler_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefResourceHandlerCppToC + : public CefCppToC { + public: + explicit CefResourceHandlerCppToC(CefResourceHandler* cls); + virtual ~CefResourceHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_RESOURCE_HANDLER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/response_cpptoc.cc b/cef3/libcef_dll/cpptoc/response_cpptoc.cc new file mode 100644 index 000000000..21ea13f86 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/response_cpptoc.cc @@ -0,0 +1,224 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/response_cpptoc.h" +#include "libcef_dll/transfer_util.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_response_t* cef_response_create() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = CefResponse::Create(); + + // Return type: refptr_same + return CefResponseCppToC::Wrap(_retval); +} + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK response_is_read_only(struct _cef_response_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefResponseCppToC::Get(self)->IsReadOnly(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK response_get_status(struct _cef_response_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefResponseCppToC::Get(self)->GetStatus(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK response_set_status(struct _cef_response_t* self, + int status) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefResponseCppToC::Get(self)->SetStatus( + status); +} + +cef_string_userfree_t CEF_CALLBACK response_get_status_text( + struct _cef_response_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefResponseCppToC::Get(self)->GetStatusText(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +void CEF_CALLBACK response_set_status_text(struct _cef_response_t* self, + const cef_string_t* statusText) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: statusText; type: string_byref_const + DCHECK(statusText); + if (!statusText) + return; + + // Execute + CefResponseCppToC::Get(self)->SetStatusText( + CefString(statusText)); +} + +cef_string_userfree_t CEF_CALLBACK response_get_mime_type( + struct _cef_response_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefResponseCppToC::Get(self)->GetMimeType(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +void CEF_CALLBACK response_set_mime_type(struct _cef_response_t* self, + const cef_string_t* mimeType) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: mimeType; type: string_byref_const + DCHECK(mimeType); + if (!mimeType) + return; + + // Execute + CefResponseCppToC::Get(self)->SetMimeType( + CefString(mimeType)); +} + +cef_string_userfree_t CEF_CALLBACK response_get_header( + struct _cef_response_t* self, const cef_string_t* name) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: name; type: string_byref_const + DCHECK(name); + if (!name) + return NULL; + + // Execute + CefString _retval = CefResponseCppToC::Get(self)->GetHeader( + CefString(name)); + + // Return type: string + return _retval.DetachToUserFree(); +} + +void CEF_CALLBACK response_get_header_map(struct _cef_response_t* self, + cef_string_multimap_t headerMap) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: headerMap; type: string_map_multi_byref + DCHECK(headerMap); + if (!headerMap) + return; + + // Translate param: headerMap; type: string_map_multi_byref + std::multimap headerMapMultimap; + transfer_string_multimap_contents(headerMap, headerMapMultimap); + + // Execute + CefResponseCppToC::Get(self)->GetHeaderMap( + headerMapMultimap); + + // Restore param: headerMap; type: string_map_multi_byref + cef_string_multimap_clear(headerMap); + transfer_string_multimap_contents(headerMapMultimap, headerMap); +} + +void CEF_CALLBACK response_set_header_map(struct _cef_response_t* self, + cef_string_multimap_t headerMap) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: headerMap; type: string_map_multi_byref_const + DCHECK(headerMap); + if (!headerMap) + return; + + // Translate param: headerMap; type: string_map_multi_byref_const + std::multimap headerMapMultimap; + transfer_string_multimap_contents(headerMap, headerMapMultimap); + + // Execute + CefResponseCppToC::Get(self)->SetHeaderMap( + headerMapMultimap); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefResponseCppToC::CefResponseCppToC(CefResponse* cls) + : CefCppToC(cls) { + struct_.struct_.is_read_only = response_is_read_only; + struct_.struct_.get_status = response_get_status; + struct_.struct_.set_status = response_set_status; + struct_.struct_.get_status_text = response_get_status_text; + struct_.struct_.set_status_text = response_set_status_text; + struct_.struct_.get_mime_type = response_get_mime_type; + struct_.struct_.set_mime_type = response_set_mime_type; + struct_.struct_.get_header = response_get_header; + struct_.struct_.get_header_map = response_get_header_map; + struct_.struct_.set_header_map = response_set_header_map; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/response_cpptoc.h b/cef3/libcef_dll/cpptoc/response_cpptoc.h new file mode 100644 index 000000000..7c1c4169a --- /dev/null +++ b/cef3/libcef_dll/cpptoc/response_cpptoc.h @@ -0,0 +1,36 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_RESPONSE_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_RESPONSE_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_response.h" +#include "include/capi/cef_response_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefResponseCppToC + : public CefCppToC { + public: + explicit CefResponseCppToC(CefResponse* cls); + virtual ~CefResponseCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_RESPONSE_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.cc b/cef3/libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.cc new file mode 100644 index 000000000..5bafa8b42 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.cc @@ -0,0 +1,61 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.h" +#include "libcef_dll/ctocpp/browser_host_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK run_file_dialog_callback_cont( + struct _cef_run_file_dialog_callback_t* self, + struct _cef_browser_host_t* browser_host, cef_string_list_t file_paths) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser_host; type: refptr_diff + DCHECK(browser_host); + if (!browser_host) + return; + // Verify param: file_paths; type: string_vec_byref_const + DCHECK(file_paths); + if (!file_paths) + return; + + // Translate param: file_paths; type: string_vec_byref_const + std::vector file_pathsList; + transfer_string_list_contents(file_paths, file_pathsList); + + // Execute + CefRunFileDialogCallbackCppToC::Get(self)->OnFileDialogDismissed( + CefBrowserHostCToCpp::Wrap(browser_host), + file_pathsList); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefRunFileDialogCallbackCppToC::CefRunFileDialogCallbackCppToC( + CefRunFileDialogCallback* cls) + : CefCppToC(cls) { + struct_.struct_.cont = run_file_dialog_callback_cont; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.h b/cef3/libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.h new file mode 100644 index 000000000..0302dc471 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.h @@ -0,0 +1,39 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_RUN_FILE_DIALOG_CALLBACK_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_RUN_FILE_DIALOG_CALLBACK_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_browser.h" +#include "include/capi/cef_browser_capi.h" +#include "include/cef_client.h" +#include "include/capi/cef_client_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefRunFileDialogCallbackCppToC + : public CefCppToC { + public: + explicit CefRunFileDialogCallbackCppToC(CefRunFileDialogCallback* cls); + virtual ~CefRunFileDialogCallbackCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_RUN_FILE_DIALOG_CALLBACK_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/scheme_handler_factory_cpptoc.cc b/cef3/libcef_dll/cpptoc/scheme_handler_factory_cpptoc.cc new file mode 100644 index 000000000..bf1a82e24 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/scheme_handler_factory_cpptoc.cc @@ -0,0 +1,67 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/resource_handler_cpptoc.h" +#include "libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/frame_ctocpp.h" +#include "libcef_dll/ctocpp/request_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +cef_resource_handler_t* CEF_CALLBACK scheme_handler_factory_create( + struct _cef_scheme_handler_factory_t* self, cef_browser_t* browser, + cef_frame_t* frame, const cef_string_t* scheme_name, + cef_request_t* request) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: scheme_name; type: string_byref_const + DCHECK(scheme_name); + if (!scheme_name) + return NULL; + // Verify param: request; type: refptr_diff + DCHECK(request); + if (!request) + return NULL; + // Unverified params: browser, frame + + // Execute + CefRefPtr _retval = CefSchemeHandlerFactoryCppToC::Get( + self)->Create( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + CefString(scheme_name), + CefRequestCToCpp::Wrap(request)); + + // Return type: refptr_same + return CefResourceHandlerCppToC::Wrap(_retval); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefSchemeHandlerFactoryCppToC::CefSchemeHandlerFactoryCppToC( + CefSchemeHandlerFactory* cls) + : CefCppToC(cls) { + struct_.struct_.create = scheme_handler_factory_create; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h b/cef3/libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h new file mode 100644 index 000000000..cb2f1472d --- /dev/null +++ b/cef3/libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_SCHEME_HANDLER_FACTORY_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_SCHEME_HANDLER_FACTORY_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_scheme.h" +#include "include/capi/cef_scheme_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefSchemeHandlerFactoryCppToC + : public CefCppToC { + public: + explicit CefSchemeHandlerFactoryCppToC(CefSchemeHandlerFactory* cls); + virtual ~CefSchemeHandlerFactoryCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_SCHEME_HANDLER_FACTORY_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/scheme_registrar_cpptoc.cc b/cef3/libcef_dll/cpptoc/scheme_registrar_cpptoc.cc new file mode 100644 index 000000000..b289040ae --- /dev/null +++ b/cef3/libcef_dll/cpptoc/scheme_registrar_cpptoc.cc @@ -0,0 +1,55 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/scheme_registrar_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK scheme_registrar_add_custom_scheme( + struct _cef_scheme_registrar_t* self, const cef_string_t* scheme_name, + int is_standard, int is_local, int is_display_isolated) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: scheme_name; type: string_byref_const + DCHECK(scheme_name); + if (!scheme_name) + return 0; + + // Execute + bool _retval = CefSchemeRegistrarCppToC::Get(self)->AddCustomScheme( + CefString(scheme_name), + is_standard?true:false, + is_local?true:false, + is_display_isolated?true:false); + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefSchemeRegistrarCppToC::CefSchemeRegistrarCppToC(CefSchemeRegistrar* cls) + : CefCppToC(cls) { + struct_.struct_.add_custom_scheme = scheme_registrar_add_custom_scheme; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/scheme_registrar_cpptoc.h b/cef3/libcef_dll/cpptoc/scheme_registrar_cpptoc.h new file mode 100644 index 000000000..a6d43492a --- /dev/null +++ b/cef3/libcef_dll/cpptoc/scheme_registrar_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_SCHEME_REGISTRAR_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_SCHEME_REGISTRAR_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_scheme.h" +#include "include/capi/cef_scheme_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefSchemeRegistrarCppToC + : public CefCppToC { + public: + explicit CefSchemeRegistrarCppToC(CefSchemeRegistrar* cls); + virtual ~CefSchemeRegistrarCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_SCHEME_REGISTRAR_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/stream_reader_cpptoc.cc b/cef3/libcef_dll/cpptoc/stream_reader_cpptoc.cc new file mode 100644 index 000000000..7d44987d8 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/stream_reader_cpptoc.cc @@ -0,0 +1,157 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/stream_reader_cpptoc.h" +#include "libcef_dll/ctocpp/read_handler_ctocpp.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_file( + const cef_string_t* fileName) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: fileName; type: string_byref_const + DCHECK(fileName); + if (!fileName) + return NULL; + + // Execute + CefRefPtr _retval = CefStreamReader::CreateForFile( + CefString(fileName)); + + // Return type: refptr_same + return CefStreamReaderCppToC::Wrap(_retval); +} + +CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_data(void* data, + size_t size) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: data; type: simple_byaddr + DCHECK(data); + if (!data) + return NULL; + + // Execute + CefRefPtr _retval = CefStreamReader::CreateForData( + data, + size); + + // Return type: refptr_same + return CefStreamReaderCppToC::Wrap(_retval); +} + +CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_handler( + cef_read_handler_t* handler) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: handler; type: refptr_diff + DCHECK(handler); + if (!handler) + return NULL; + + // Execute + CefRefPtr _retval = CefStreamReader::CreateForHandler( + CefReadHandlerCToCpp::Wrap(handler)); + + // Return type: refptr_same + return CefStreamReaderCppToC::Wrap(_retval); +} + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +size_t CEF_CALLBACK stream_reader_read(struct _cef_stream_reader_t* self, + void* ptr, size_t size, size_t n) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: ptr; type: simple_byaddr + DCHECK(ptr); + if (!ptr) + return 0; + + // Execute + size_t _retval = CefStreamReaderCppToC::Get(self)->Read( + ptr, + size, + n); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK stream_reader_seek(struct _cef_stream_reader_t* self, + int64 offset, int whence) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefStreamReaderCppToC::Get(self)->Seek( + offset, + whence); + + // Return type: simple + return _retval; +} + +int64 CEF_CALLBACK stream_reader_tell(struct _cef_stream_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int64 _retval = CefStreamReaderCppToC::Get(self)->Tell(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK stream_reader_eof(struct _cef_stream_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefStreamReaderCppToC::Get(self)->Eof(); + + // Return type: simple + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefStreamReaderCppToC::CefStreamReaderCppToC(CefStreamReader* cls) + : CefCppToC( + cls) { + struct_.struct_.read = stream_reader_read; + struct_.struct_.seek = stream_reader_seek; + struct_.struct_.tell = stream_reader_tell; + struct_.struct_.eof = stream_reader_eof; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/stream_reader_cpptoc.h b/cef3/libcef_dll/cpptoc/stream_reader_cpptoc.h new file mode 100644 index 000000000..fc42ef6b8 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/stream_reader_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_STREAM_READER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_STREAM_READER_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_stream.h" +#include "include/capi/cef_stream_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefStreamReaderCppToC + : public CefCppToC { + public: + explicit CefStreamReaderCppToC(CefStreamReader* cls); + virtual ~CefStreamReaderCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_STREAM_READER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/stream_writer_cpptoc.cc b/cef3/libcef_dll/cpptoc/stream_writer_cpptoc.cc new file mode 100644 index 000000000..cc3af480f --- /dev/null +++ b/cef3/libcef_dll/cpptoc/stream_writer_cpptoc.cc @@ -0,0 +1,139 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/stream_writer_cpptoc.h" +#include "libcef_dll/ctocpp/write_handler_ctocpp.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_stream_writer_t* cef_stream_writer_create_for_file( + const cef_string_t* fileName) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: fileName; type: string_byref_const + DCHECK(fileName); + if (!fileName) + return NULL; + + // Execute + CefRefPtr _retval = CefStreamWriter::CreateForFile( + CefString(fileName)); + + // Return type: refptr_same + return CefStreamWriterCppToC::Wrap(_retval); +} + +CEF_EXPORT cef_stream_writer_t* cef_stream_writer_create_for_handler( + cef_write_handler_t* handler) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: handler; type: refptr_diff + DCHECK(handler); + if (!handler) + return NULL; + + // Execute + CefRefPtr _retval = CefStreamWriter::CreateForHandler( + CefWriteHandlerCToCpp::Wrap(handler)); + + // Return type: refptr_same + return CefStreamWriterCppToC::Wrap(_retval); +} + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +size_t CEF_CALLBACK stream_writer_write(struct _cef_stream_writer_t* self, + const void* ptr, size_t size, size_t n) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: ptr; type: simple_byaddr + DCHECK(ptr); + if (!ptr) + return 0; + + // Execute + size_t _retval = CefStreamWriterCppToC::Get(self)->Write( + ptr, + size, + n); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK stream_writer_seek(struct _cef_stream_writer_t* self, + int64 offset, int whence) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefStreamWriterCppToC::Get(self)->Seek( + offset, + whence); + + // Return type: simple + return _retval; +} + +int64 CEF_CALLBACK stream_writer_tell(struct _cef_stream_writer_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int64 _retval = CefStreamWriterCppToC::Get(self)->Tell(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK stream_writer_flush(struct _cef_stream_writer_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefStreamWriterCppToC::Get(self)->Flush(); + + // Return type: simple + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefStreamWriterCppToC::CefStreamWriterCppToC(CefStreamWriter* cls) + : CefCppToC( + cls) { + struct_.struct_.write = stream_writer_write; + struct_.struct_.seek = stream_writer_seek; + struct_.struct_.tell = stream_writer_tell; + struct_.struct_.flush = stream_writer_flush; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/stream_writer_cpptoc.h b/cef3/libcef_dll/cpptoc/stream_writer_cpptoc.h new file mode 100644 index 000000000..173748b3e --- /dev/null +++ b/cef3/libcef_dll/cpptoc/stream_writer_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_STREAM_WRITER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_STREAM_WRITER_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_stream.h" +#include "include/capi/cef_stream_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefStreamWriterCppToC + : public CefCppToC { + public: + explicit CefStreamWriterCppToC(CefStreamWriter* cls); + virtual ~CefStreamWriterCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_STREAM_WRITER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/string_visitor_cpptoc.cc b/cef3/libcef_dll/cpptoc/string_visitor_cpptoc.cc new file mode 100644 index 000000000..73edb9dfd --- /dev/null +++ b/cef3/libcef_dll/cpptoc/string_visitor_cpptoc.cc @@ -0,0 +1,48 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/string_visitor_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK string_visitor_visit(struct _cef_string_visitor_t* self, + const cef_string_t* string) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: string; type: string_byref_const + DCHECK(string); + if (!string) + return; + + // Execute + CefStringVisitorCppToC::Get(self)->Visit( + CefString(string)); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefStringVisitorCppToC::CefStringVisitorCppToC(CefStringVisitor* cls) + : CefCppToC( + cls) { + struct_.struct_.visit = string_visitor_visit; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/string_visitor_cpptoc.h b/cef3/libcef_dll/cpptoc/string_visitor_cpptoc.h new file mode 100644 index 000000000..2cdd3b547 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/string_visitor_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_STRING_VISITOR_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_STRING_VISITOR_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_string_visitor.h" +#include "include/capi/cef_string_visitor_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefStringVisitorCppToC + : public CefCppToC { + public: + explicit CefStringVisitorCppToC(CefStringVisitor* cls); + virtual ~CefStringVisitorCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_STRING_VISITOR_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/task_cpptoc.cc b/cef3/libcef_dll/cpptoc/task_cpptoc.cc new file mode 100644 index 000000000..f0de3a4f2 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/task_cpptoc.cc @@ -0,0 +1,40 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/task_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK task_execute(struct _cef_task_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefTaskCppToC::Get(self)->Execute(); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefTaskCppToC::CefTaskCppToC(CefTask* cls) + : CefCppToC(cls) { + struct_.struct_.execute = task_execute; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/task_cpptoc.h b/cef3/libcef_dll/cpptoc/task_cpptoc.h new file mode 100644 index 000000000..495de4c60 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/task_cpptoc.h @@ -0,0 +1,36 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_TASK_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_TASK_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_task.h" +#include "include/capi/cef_task_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefTaskCppToC + : public CefCppToC { + public: + explicit CefTaskCppToC(CefTask* cls); + virtual ~CefTaskCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_TASK_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/task_runner_cpptoc.cc b/cef3/libcef_dll/cpptoc/task_runner_cpptoc.cc new file mode 100644 index 000000000..ad2d0f327 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/task_runner_cpptoc.cc @@ -0,0 +1,153 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/task_runner_cpptoc.h" +#include "libcef_dll/ctocpp/task_ctocpp.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_task_runner_t* cef_task_runner_get_for_current_thread() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = CefTaskRunner::GetForCurrentThread(); + + // Return type: refptr_same + return CefTaskRunnerCppToC::Wrap(_retval); +} + +CEF_EXPORT cef_task_runner_t* cef_task_runner_get_for_thread( + cef_thread_id_t threadId) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = CefTaskRunner::GetForThread( + threadId); + + // Return type: refptr_same + return CefTaskRunnerCppToC::Wrap(_retval); +} + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK task_runner_is_same(struct _cef_task_runner_t* self, + struct _cef_task_runner_t* that) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: that; type: refptr_same + DCHECK(that); + if (!that) + return 0; + + // Execute + bool _retval = CefTaskRunnerCppToC::Get(self)->IsSame( + CefTaskRunnerCppToC::Unwrap(that)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK task_runner_belongs_to_current_thread( + struct _cef_task_runner_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefTaskRunnerCppToC::Get(self)->BelongsToCurrentThread(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK task_runner_belongs_to_thread(struct _cef_task_runner_t* self, + cef_thread_id_t threadId) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefTaskRunnerCppToC::Get(self)->BelongsToThread( + threadId); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK task_runner_post_task(struct _cef_task_runner_t* self, + cef_task_t* task) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: task; type: refptr_diff + DCHECK(task); + if (!task) + return 0; + + // Execute + bool _retval = CefTaskRunnerCppToC::Get(self)->PostTask( + CefTaskCToCpp::Wrap(task)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK task_runner_post_delayed_task(struct _cef_task_runner_t* self, + cef_task_t* task, int64 delay_ms) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: task; type: refptr_diff + DCHECK(task); + if (!task) + return 0; + + // Execute + bool _retval = CefTaskRunnerCppToC::Get(self)->PostDelayedTask( + CefTaskCToCpp::Wrap(task), + delay_ms); + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefTaskRunnerCppToC::CefTaskRunnerCppToC(CefTaskRunner* cls) + : CefCppToC(cls) { + struct_.struct_.is_same = task_runner_is_same; + struct_.struct_.belongs_to_current_thread = + task_runner_belongs_to_current_thread; + struct_.struct_.belongs_to_thread = task_runner_belongs_to_thread; + struct_.struct_.post_task = task_runner_post_task; + struct_.struct_.post_delayed_task = task_runner_post_delayed_task; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/task_runner_cpptoc.h b/cef3/libcef_dll/cpptoc/task_runner_cpptoc.h new file mode 100644 index 000000000..84abc4afc --- /dev/null +++ b/cef3/libcef_dll/cpptoc/task_runner_cpptoc.h @@ -0,0 +1,36 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_TASK_RUNNER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_TASK_RUNNER_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_task.h" +#include "include/capi/cef_task_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefTaskRunnerCppToC + : public CefCppToC { + public: + explicit CefTaskRunnerCppToC(CefTaskRunner* cls); + virtual ~CefTaskRunnerCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_TASK_RUNNER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/trace_client_cpptoc.cc b/cef3/libcef_dll/cpptoc/trace_client_cpptoc.cc new file mode 100644 index 000000000..580d837ba --- /dev/null +++ b/cef3/libcef_dll/cpptoc/trace_client_cpptoc.cc @@ -0,0 +1,79 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/trace_client_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK trace_client_on_trace_data_collected( + struct _cef_trace_client_t* self, const char* fragment, + size_t fragment_size) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: fragment; type: simple_byaddr + DCHECK(fragment); + if (!fragment) + return; + + // Execute + CefTraceClientCppToC::Get(self)->OnTraceDataCollected( + fragment, + fragment_size); +} + +void CEF_CALLBACK trace_client_on_trace_buffer_percent_full_reply( + struct _cef_trace_client_t* self, float percent_full) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefTraceClientCppToC::Get(self)->OnTraceBufferPercentFullReply( + percent_full); +} + +void CEF_CALLBACK trace_client_on_end_tracing_complete( + struct _cef_trace_client_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefTraceClientCppToC::Get(self)->OnEndTracingComplete(); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefTraceClientCppToC::CefTraceClientCppToC(CefTraceClient* cls) + : CefCppToC(cls) { + struct_.struct_.on_trace_data_collected = + trace_client_on_trace_data_collected; + struct_.struct_.on_trace_buffer_percent_full_reply = + trace_client_on_trace_buffer_percent_full_reply; + struct_.struct_.on_end_tracing_complete = + trace_client_on_end_tracing_complete; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/trace_client_cpptoc.h b/cef3/libcef_dll/cpptoc/trace_client_cpptoc.h new file mode 100644 index 000000000..f005ea9ed --- /dev/null +++ b/cef3/libcef_dll/cpptoc/trace_client_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_TRACE_CLIENT_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_TRACE_CLIENT_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_trace.h" +#include "include/capi/cef_trace_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefTraceClientCppToC + : public CefCppToC { + public: + explicit CefTraceClientCppToC(CefTraceClient* cls); + virtual ~CefTraceClientCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_TRACE_CLIENT_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/urlrequest_client_cpptoc.cc b/cef3/libcef_dll/cpptoc/urlrequest_client_cpptoc.cc new file mode 100644 index 000000000..086129203 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/urlrequest_client_cpptoc.cc @@ -0,0 +1,116 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/urlrequest_client_cpptoc.h" +#include "libcef_dll/ctocpp/urlrequest_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK urlrequest_client_on_request_complete( + struct _cef_urlrequest_client_t* self, cef_urlrequest_t* request) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: request; type: refptr_diff + DCHECK(request); + if (!request) + return; + + // Execute + CefURLRequestClientCppToC::Get(self)->OnRequestComplete( + CefURLRequestCToCpp::Wrap(request)); +} + +void CEF_CALLBACK urlrequest_client_on_upload_progress( + struct _cef_urlrequest_client_t* self, cef_urlrequest_t* request, + uint64 current, uint64 total) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: request; type: refptr_diff + DCHECK(request); + if (!request) + return; + + // Execute + CefURLRequestClientCppToC::Get(self)->OnUploadProgress( + CefURLRequestCToCpp::Wrap(request), + current, + total); +} + +void CEF_CALLBACK urlrequest_client_on_download_progress( + struct _cef_urlrequest_client_t* self, cef_urlrequest_t* request, + uint64 current, uint64 total) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: request; type: refptr_diff + DCHECK(request); + if (!request) + return; + + // Execute + CefURLRequestClientCppToC::Get(self)->OnDownloadProgress( + CefURLRequestCToCpp::Wrap(request), + current, + total); +} + +void CEF_CALLBACK urlrequest_client_on_download_data( + struct _cef_urlrequest_client_t* self, cef_urlrequest_t* request, + const void* data, size_t data_length) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: request; type: refptr_diff + DCHECK(request); + if (!request) + return; + // Verify param: data; type: simple_byaddr + DCHECK(data); + if (!data) + return; + + // Execute + CefURLRequestClientCppToC::Get(self)->OnDownloadData( + CefURLRequestCToCpp::Wrap(request), + data, + data_length); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefURLRequestClientCppToC::CefURLRequestClientCppToC(CefURLRequestClient* cls) + : CefCppToC(cls) { + struct_.struct_.on_request_complete = urlrequest_client_on_request_complete; + struct_.struct_.on_upload_progress = urlrequest_client_on_upload_progress; + struct_.struct_.on_download_progress = urlrequest_client_on_download_progress; + struct_.struct_.on_download_data = urlrequest_client_on_download_data; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/urlrequest_client_cpptoc.h b/cef3/libcef_dll/cpptoc/urlrequest_client_cpptoc.h new file mode 100644 index 000000000..6640749a8 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/urlrequest_client_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_URLREQUEST_CLIENT_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_URLREQUEST_CLIENT_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_urlrequest.h" +#include "include/capi/cef_urlrequest_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefURLRequestClientCppToC + : public CefCppToC { + public: + explicit CefURLRequestClientCppToC(CefURLRequestClient* cls); + virtual ~CefURLRequestClientCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_URLREQUEST_CLIENT_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/urlrequest_cpptoc.cc b/cef3/libcef_dll/cpptoc/urlrequest_cpptoc.cc new file mode 100644 index 000000000..cf0b69813 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/urlrequest_cpptoc.cc @@ -0,0 +1,152 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/request_cpptoc.h" +#include "libcef_dll/cpptoc/response_cpptoc.h" +#include "libcef_dll/cpptoc/urlrequest_cpptoc.h" +#include "libcef_dll/ctocpp/urlrequest_client_ctocpp.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_urlrequest_t* cef_urlrequest_create(cef_request_t* request, + struct _cef_urlrequest_client_t* client) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: request; type: refptr_same + DCHECK(request); + if (!request) + return NULL; + // Verify param: client; type: refptr_diff + DCHECK(client); + if (!client) + return NULL; + + // Execute + CefRefPtr _retval = CefURLRequest::Create( + CefRequestCppToC::Unwrap(request), + CefURLRequestClientCToCpp::Wrap(client)); + + // Return type: refptr_same + return CefURLRequestCppToC::Wrap(_retval); +} + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +cef_request_t* CEF_CALLBACK urlrequest_get_request( + struct _cef_urlrequest_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefURLRequestCppToC::Get(self)->GetRequest(); + + // Return type: refptr_same + return CefRequestCppToC::Wrap(_retval); +} + +struct _cef_urlrequest_client_t* CEF_CALLBACK urlrequest_get_client( + struct _cef_urlrequest_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefURLRequestCppToC::Get( + self)->GetClient(); + + // Return type: refptr_diff + return CefURLRequestClientCToCpp::Unwrap(_retval); +} + +enum cef_urlrequest_status_t CEF_CALLBACK urlrequest_get_request_status( + struct _cef_urlrequest_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return UR_UNKNOWN; + + // Execute + cef_urlrequest_status_t _retval = CefURLRequestCppToC::Get( + self)->GetRequestStatus(); + + // Return type: simple + return _retval; +} + +enum cef_errorcode_t CEF_CALLBACK urlrequest_get_request_error( + struct _cef_urlrequest_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return ERR_NONE; + + // Execute + cef_errorcode_t _retval = CefURLRequestCppToC::Get(self)->GetRequestError(); + + // Return type: simple + return _retval; +} + +cef_response_t* CEF_CALLBACK urlrequest_get_response( + struct _cef_urlrequest_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefURLRequestCppToC::Get(self)->GetResponse( + ); + + // Return type: refptr_same + return CefResponseCppToC::Wrap(_retval); +} + +void CEF_CALLBACK urlrequest_cancel(struct _cef_urlrequest_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefURLRequestCppToC::Get(self)->Cancel(); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefURLRequestCppToC::CefURLRequestCppToC(CefURLRequest* cls) + : CefCppToC(cls) { + struct_.struct_.get_request = urlrequest_get_request; + struct_.struct_.get_client = urlrequest_get_client; + struct_.struct_.get_request_status = urlrequest_get_request_status; + struct_.struct_.get_request_error = urlrequest_get_request_error; + struct_.struct_.get_response = urlrequest_get_response; + struct_.struct_.cancel = urlrequest_cancel; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/urlrequest_cpptoc.h b/cef3/libcef_dll/cpptoc/urlrequest_cpptoc.h new file mode 100644 index 000000000..85b824304 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/urlrequest_cpptoc.h @@ -0,0 +1,36 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_URLREQUEST_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_URLREQUEST_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_urlrequest.h" +#include "include/capi/cef_urlrequest_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefURLRequestCppToC + : public CefCppToC { + public: + explicit CefURLRequestCppToC(CefURLRequest* cls); + virtual ~CefURLRequestCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_URLREQUEST_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/v8accessor_cpptoc.cc b/cef3/libcef_dll/cpptoc/v8accessor_cpptoc.cc new file mode 100644 index 000000000..cd92d6c9f --- /dev/null +++ b/cef3/libcef_dll/cpptoc/v8accessor_cpptoc.cc @@ -0,0 +1,126 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/v8accessor_cpptoc.h" +#include "libcef_dll/ctocpp/v8value_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK v8accessor_get(struct _cef_v8accessor_t* self, + const cef_string_t* name, struct _cef_v8value_t* object, + struct _cef_v8value_t** retval, cef_string_t* exception) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: name; type: string_byref_const + DCHECK(name); + if (!name) + return 0; + // Verify param: object; type: refptr_diff + DCHECK(object); + if (!object) + return 0; + // Verify param: retval; type: refptr_diff_byref + DCHECK(retval); + if (!retval) + return 0; + // Verify param: exception; type: string_byref + DCHECK(exception); + if (!exception) + return 0; + + // Translate param: retval; type: refptr_diff_byref + CefRefPtr retvalPtr; + if (retval && *retval) + retvalPtr = CefV8ValueCToCpp::Wrap(*retval); + CefV8Value* retvalOrig = retvalPtr.get(); + // Translate param: exception; type: string_byref + CefString exceptionStr(exception); + + // Execute + bool _retval = CefV8AccessorCppToC::Get(self)->Get( + CefString(name), + CefV8ValueCToCpp::Wrap(object), + retvalPtr, + exceptionStr); + + // Restore param: retval; type: refptr_diff_byref + if (retval) { + if (retvalPtr.get()) { + if (retvalPtr.get() != retvalOrig) { + *retval = CefV8ValueCToCpp::Unwrap(retvalPtr); + } + } else { + *retval = NULL; + } + } + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8accessor_set(struct _cef_v8accessor_t* self, + const cef_string_t* name, struct _cef_v8value_t* object, + struct _cef_v8value_t* value, cef_string_t* exception) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: name; type: string_byref_const + DCHECK(name); + if (!name) + return 0; + // Verify param: object; type: refptr_diff + DCHECK(object); + if (!object) + return 0; + // Verify param: value; type: refptr_diff + DCHECK(value); + if (!value) + return 0; + // Verify param: exception; type: string_byref + DCHECK(exception); + if (!exception) + return 0; + + // Translate param: exception; type: string_byref + CefString exceptionStr(exception); + + // Execute + bool _retval = CefV8AccessorCppToC::Get(self)->Set( + CefString(name), + CefV8ValueCToCpp::Wrap(object), + CefV8ValueCToCpp::Wrap(value), + exceptionStr); + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefV8AccessorCppToC::CefV8AccessorCppToC(CefV8Accessor* cls) + : CefCppToC(cls) { + struct_.struct_.get = v8accessor_get; + struct_.struct_.set = v8accessor_set; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/v8accessor_cpptoc.h b/cef3/libcef_dll/cpptoc/v8accessor_cpptoc.h new file mode 100644 index 000000000..80791a9a1 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/v8accessor_cpptoc.h @@ -0,0 +1,36 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_V8ACCESSOR_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_V8ACCESSOR_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_v8.h" +#include "include/capi/cef_v8_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefV8AccessorCppToC + : public CefCppToC { + public: + explicit CefV8AccessorCppToC(CefV8Accessor* cls); + virtual ~CefV8AccessorCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_V8ACCESSOR_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/v8context_cpptoc.cc b/cef3/libcef_dll/cpptoc/v8context_cpptoc.cc new file mode 100644 index 000000000..c297f2e9f --- /dev/null +++ b/cef3/libcef_dll/cpptoc/v8context_cpptoc.cc @@ -0,0 +1,261 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/cpptoc/frame_cpptoc.h" +#include "libcef_dll/cpptoc/task_runner_cpptoc.h" +#include "libcef_dll/cpptoc/v8context_cpptoc.h" +#include "libcef_dll/cpptoc/v8exception_cpptoc.h" +#include "libcef_dll/cpptoc/v8value_cpptoc.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_v8context_t* cef_v8context_get_current_context() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = CefV8Context::GetCurrentContext(); + + // Return type: refptr_same + return CefV8ContextCppToC::Wrap(_retval); +} + +CEF_EXPORT cef_v8context_t* cef_v8context_get_entered_context() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = CefV8Context::GetEnteredContext(); + + // Return type: refptr_same + return CefV8ContextCppToC::Wrap(_retval); +} + +CEF_EXPORT int cef_v8context_in_context() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + bool _retval = CefV8Context::InContext(); + + // Return type: bool + return _retval; +} + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +cef_task_runner_t* CEF_CALLBACK v8context_get_task_runner( + struct _cef_v8context_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefV8ContextCppToC::Get( + self)->GetTaskRunner(); + + // Return type: refptr_same + return CefTaskRunnerCppToC::Wrap(_retval); +} + +int CEF_CALLBACK v8context_is_valid(struct _cef_v8context_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8ContextCppToC::Get(self)->IsValid(); + + // Return type: bool + return _retval; +} + +cef_browser_t* CEF_CALLBACK v8context_get_browser( + struct _cef_v8context_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefV8ContextCppToC::Get(self)->GetBrowser(); + + // Return type: refptr_same + return CefBrowserCppToC::Wrap(_retval); +} + +cef_frame_t* CEF_CALLBACK v8context_get_frame(struct _cef_v8context_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefV8ContextCppToC::Get(self)->GetFrame(); + + // Return type: refptr_same + return CefFrameCppToC::Wrap(_retval); +} + +struct _cef_v8value_t* CEF_CALLBACK v8context_get_global( + struct _cef_v8context_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefV8ContextCppToC::Get(self)->GetGlobal(); + + // Return type: refptr_same + return CefV8ValueCppToC::Wrap(_retval); +} + +int CEF_CALLBACK v8context_enter(struct _cef_v8context_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8ContextCppToC::Get(self)->Enter(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8context_exit(struct _cef_v8context_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8ContextCppToC::Get(self)->Exit(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8context_is_same(struct _cef_v8context_t* self, + struct _cef_v8context_t* that) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: that; type: refptr_same + DCHECK(that); + if (!that) + return 0; + + // Execute + bool _retval = CefV8ContextCppToC::Get(self)->IsSame( + CefV8ContextCppToC::Unwrap(that)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8context_eval(struct _cef_v8context_t* self, + const cef_string_t* code, struct _cef_v8value_t** retval, + struct _cef_v8exception_t** exception) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: code; type: string_byref_const + DCHECK(code); + if (!code) + return 0; + // Verify param: retval; type: refptr_same_byref + DCHECK(retval); + if (!retval) + return 0; + // Verify param: exception; type: refptr_same_byref + DCHECK(exception); + if (!exception) + return 0; + + // Translate param: retval; type: refptr_same_byref + CefRefPtr retvalPtr; + if (retval && *retval) + retvalPtr = CefV8ValueCppToC::Unwrap(*retval); + CefV8Value* retvalOrig = retvalPtr.get(); + // Translate param: exception; type: refptr_same_byref + CefRefPtr exceptionPtr; + if (exception && *exception) + exceptionPtr = CefV8ExceptionCppToC::Unwrap(*exception); + CefV8Exception* exceptionOrig = exceptionPtr.get(); + + // Execute + bool _retval = CefV8ContextCppToC::Get(self)->Eval( + CefString(code), + retvalPtr, + exceptionPtr); + + // Restore param: retval; type: refptr_same_byref + if (retval) { + if (retvalPtr.get()) { + if (retvalPtr.get() != retvalOrig) { + *retval = CefV8ValueCppToC::Wrap(retvalPtr); + } + } else { + *retval = NULL; + } + } + // Restore param: exception; type: refptr_same_byref + if (exception) { + if (exceptionPtr.get()) { + if (exceptionPtr.get() != exceptionOrig) { + *exception = CefV8ExceptionCppToC::Wrap(exceptionPtr); + } + } else { + *exception = NULL; + } + } + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefV8ContextCppToC::CefV8ContextCppToC(CefV8Context* cls) + : CefCppToC(cls) { + struct_.struct_.get_task_runner = v8context_get_task_runner; + struct_.struct_.is_valid = v8context_is_valid; + struct_.struct_.get_browser = v8context_get_browser; + struct_.struct_.get_frame = v8context_get_frame; + struct_.struct_.get_global = v8context_get_global; + struct_.struct_.enter = v8context_enter; + struct_.struct_.exit = v8context_exit; + struct_.struct_.is_same = v8context_is_same; + struct_.struct_.eval = v8context_eval; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/v8context_cpptoc.h b/cef3/libcef_dll/cpptoc/v8context_cpptoc.h new file mode 100644 index 000000000..8f830a7d3 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/v8context_cpptoc.h @@ -0,0 +1,36 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_V8CONTEXT_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_V8CONTEXT_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_v8.h" +#include "include/capi/cef_v8_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefV8ContextCppToC + : public CefCppToC { + public: + explicit CefV8ContextCppToC(CefV8Context* cls); + virtual ~CefV8ContextCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_V8CONTEXT_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/v8exception_cpptoc.cc b/cef3/libcef_dll/cpptoc/v8exception_cpptoc.cc new file mode 100644 index 000000000..291273444 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/v8exception_cpptoc.cc @@ -0,0 +1,154 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/v8exception_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +cef_string_userfree_t CEF_CALLBACK v8exception_get_message( + struct _cef_v8exception_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefV8ExceptionCppToC::Get(self)->GetMessage(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK v8exception_get_source_line( + struct _cef_v8exception_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefV8ExceptionCppToC::Get(self)->GetSourceLine(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK v8exception_get_script_resource_name( + struct _cef_v8exception_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefV8ExceptionCppToC::Get(self)->GetScriptResourceName(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +int CEF_CALLBACK v8exception_get_line_number(struct _cef_v8exception_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefV8ExceptionCppToC::Get(self)->GetLineNumber(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK v8exception_get_start_position( + struct _cef_v8exception_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefV8ExceptionCppToC::Get(self)->GetStartPosition(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK v8exception_get_end_position(struct _cef_v8exception_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefV8ExceptionCppToC::Get(self)->GetEndPosition(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK v8exception_get_start_column(struct _cef_v8exception_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefV8ExceptionCppToC::Get(self)->GetStartColumn(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK v8exception_get_end_column(struct _cef_v8exception_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefV8ExceptionCppToC::Get(self)->GetEndColumn(); + + // Return type: simple + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefV8ExceptionCppToC::CefV8ExceptionCppToC(CefV8Exception* cls) + : CefCppToC(cls) { + struct_.struct_.get_message = v8exception_get_message; + struct_.struct_.get_source_line = v8exception_get_source_line; + struct_.struct_.get_script_resource_name = + v8exception_get_script_resource_name; + struct_.struct_.get_line_number = v8exception_get_line_number; + struct_.struct_.get_start_position = v8exception_get_start_position; + struct_.struct_.get_end_position = v8exception_get_end_position; + struct_.struct_.get_start_column = v8exception_get_start_column; + struct_.struct_.get_end_column = v8exception_get_end_column; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/v8exception_cpptoc.h b/cef3/libcef_dll/cpptoc/v8exception_cpptoc.h new file mode 100644 index 000000000..d5661e6ac --- /dev/null +++ b/cef3/libcef_dll/cpptoc/v8exception_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_V8EXCEPTION_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_V8EXCEPTION_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_v8.h" +#include "include/capi/cef_v8_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefV8ExceptionCppToC + : public CefCppToC { + public: + explicit CefV8ExceptionCppToC(CefV8Exception* cls); + virtual ~CefV8ExceptionCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_V8EXCEPTION_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/v8handler_cpptoc.cc b/cef3/libcef_dll/cpptoc/v8handler_cpptoc.cc new file mode 100644 index 000000000..49c7c28cc --- /dev/null +++ b/cef3/libcef_dll/cpptoc/v8handler_cpptoc.cc @@ -0,0 +1,99 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/v8handler_cpptoc.h" +#include "libcef_dll/ctocpp/v8value_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK v8handler_execute(struct _cef_v8handler_t* self, + const cef_string_t* name, struct _cef_v8value_t* object, + size_t argumentsCount, struct _cef_v8value_t* const* arguments, + struct _cef_v8value_t** retval, cef_string_t* exception) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: name; type: string_byref_const + DCHECK(name); + if (!name) + return 0; + // Verify param: object; type: refptr_diff + DCHECK(object); + if (!object) + return 0; + // Verify param: arguments; type: refptr_vec_diff_byref_const + DCHECK(argumentsCount == 0 || arguments); + if (argumentsCount > 0 && !arguments) + return 0; + // Verify param: retval; type: refptr_diff_byref + DCHECK(retval); + if (!retval) + return 0; + // Verify param: exception; type: string_byref + DCHECK(exception); + if (!exception) + return 0; + + // Translate param: arguments; type: refptr_vec_diff_byref_const + std::vector > argumentsList; + if (argumentsCount > 0) { + for (size_t i = 0; i < argumentsCount; ++i) { + argumentsList.push_back(CefV8ValueCToCpp::Wrap(arguments[i])); + } + } + // Translate param: retval; type: refptr_diff_byref + CefRefPtr retvalPtr; + if (retval && *retval) + retvalPtr = CefV8ValueCToCpp::Wrap(*retval); + CefV8Value* retvalOrig = retvalPtr.get(); + // Translate param: exception; type: string_byref + CefString exceptionStr(exception); + + // Execute + bool _retval = CefV8HandlerCppToC::Get(self)->Execute( + CefString(name), + CefV8ValueCToCpp::Wrap(object), + argumentsList, + retvalPtr, + exceptionStr); + + // Restore param: retval; type: refptr_diff_byref + if (retval) { + if (retvalPtr.get()) { + if (retvalPtr.get() != retvalOrig) { + *retval = CefV8ValueCToCpp::Unwrap(retvalPtr); + } + } else { + *retval = NULL; + } + } + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefV8HandlerCppToC::CefV8HandlerCppToC(CefV8Handler* cls) + : CefCppToC(cls) { + struct_.struct_.execute = v8handler_execute; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/v8handler_cpptoc.h b/cef3/libcef_dll/cpptoc/v8handler_cpptoc.h new file mode 100644 index 000000000..aab996c24 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/v8handler_cpptoc.h @@ -0,0 +1,36 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_V8HANDLER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_V8HANDLER_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_v8.h" +#include "include/capi/cef_v8_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefV8HandlerCppToC + : public CefCppToC { + public: + explicit CefV8HandlerCppToC(CefV8Handler* cls); + virtual ~CefV8HandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_V8HANDLER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/v8stack_frame_cpptoc.cc b/cef3/libcef_dll/cpptoc/v8stack_frame_cpptoc.cc new file mode 100644 index 000000000..d855b8381 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/v8stack_frame_cpptoc.cc @@ -0,0 +1,157 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/v8stack_frame_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK v8stack_frame_is_valid(struct _cef_v8stack_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8StackFrameCppToC::Get(self)->IsValid(); + + // Return type: bool + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK v8stack_frame_get_script_name( + struct _cef_v8stack_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefV8StackFrameCppToC::Get(self)->GetScriptName(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK v8stack_frame_get_script_name_or_source_url( + struct _cef_v8stack_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefV8StackFrameCppToC::Get( + self)->GetScriptNameOrSourceURL(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK v8stack_frame_get_function_name( + struct _cef_v8stack_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefV8StackFrameCppToC::Get(self)->GetFunctionName(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +int CEF_CALLBACK v8stack_frame_get_line_number( + struct _cef_v8stack_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefV8StackFrameCppToC::Get(self)->GetLineNumber(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK v8stack_frame_get_column(struct _cef_v8stack_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefV8StackFrameCppToC::Get(self)->GetColumn(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK v8stack_frame_is_eval(struct _cef_v8stack_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8StackFrameCppToC::Get(self)->IsEval(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8stack_frame_is_constructor( + struct _cef_v8stack_frame_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8StackFrameCppToC::Get(self)->IsConstructor(); + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefV8StackFrameCppToC::CefV8StackFrameCppToC(CefV8StackFrame* cls) + : CefCppToC( + cls) { + struct_.struct_.is_valid = v8stack_frame_is_valid; + struct_.struct_.get_script_name = v8stack_frame_get_script_name; + struct_.struct_.get_script_name_or_source_url = + v8stack_frame_get_script_name_or_source_url; + struct_.struct_.get_function_name = v8stack_frame_get_function_name; + struct_.struct_.get_line_number = v8stack_frame_get_line_number; + struct_.struct_.get_column = v8stack_frame_get_column; + struct_.struct_.is_eval = v8stack_frame_is_eval; + struct_.struct_.is_constructor = v8stack_frame_is_constructor; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/v8stack_frame_cpptoc.h b/cef3/libcef_dll/cpptoc/v8stack_frame_cpptoc.h new file mode 100644 index 000000000..73158052b --- /dev/null +++ b/cef3/libcef_dll/cpptoc/v8stack_frame_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_V8STACK_FRAME_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_V8STACK_FRAME_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_v8.h" +#include "include/capi/cef_v8_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefV8StackFrameCppToC + : public CefCppToC { + public: + explicit CefV8StackFrameCppToC(CefV8StackFrame* cls); + virtual ~CefV8StackFrameCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_V8STACK_FRAME_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/v8stack_trace_cpptoc.cc b/cef3/libcef_dll/cpptoc/v8stack_trace_cpptoc.cc new file mode 100644 index 000000000..4bc7815bf --- /dev/null +++ b/cef3/libcef_dll/cpptoc/v8stack_trace_cpptoc.cc @@ -0,0 +1,94 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/v8stack_frame_cpptoc.h" +#include "libcef_dll/cpptoc/v8stack_trace_cpptoc.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_v8stack_trace_t* cef_v8stack_trace_get_current(int frame_limit) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = CefV8StackTrace::GetCurrent( + frame_limit); + + // Return type: refptr_same + return CefV8StackTraceCppToC::Wrap(_retval); +} + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK v8stack_trace_is_valid(struct _cef_v8stack_trace_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8StackTraceCppToC::Get(self)->IsValid(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8stack_trace_get_frame_count( + struct _cef_v8stack_trace_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefV8StackTraceCppToC::Get(self)->GetFrameCount(); + + // Return type: simple + return _retval; +} + +struct _cef_v8stack_frame_t* CEF_CALLBACK v8stack_trace_get_frame( + struct _cef_v8stack_trace_t* self, int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefV8StackTraceCppToC::Get( + self)->GetFrame( + index); + + // Return type: refptr_same + return CefV8StackFrameCppToC::Wrap(_retval); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefV8StackTraceCppToC::CefV8StackTraceCppToC(CefV8StackTrace* cls) + : CefCppToC( + cls) { + struct_.struct_.is_valid = v8stack_trace_is_valid; + struct_.struct_.get_frame_count = v8stack_trace_get_frame_count; + struct_.struct_.get_frame = v8stack_trace_get_frame; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/v8stack_trace_cpptoc.h b/cef3/libcef_dll/cpptoc/v8stack_trace_cpptoc.h new file mode 100644 index 000000000..4986e5e2e --- /dev/null +++ b/cef3/libcef_dll/cpptoc/v8stack_trace_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_V8STACK_TRACE_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_V8STACK_TRACE_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_v8.h" +#include "include/capi/cef_v8_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefV8StackTraceCppToC + : public CefCppToC { + public: + explicit CefV8StackTraceCppToC(CefV8StackTrace* cls); + virtual ~CefV8StackTraceCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_V8STACK_TRACE_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/v8value_cpptoc.cc b/cef3/libcef_dll/cpptoc/v8value_cpptoc.cc new file mode 100644 index 000000000..71a7446d7 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/v8value_cpptoc.cc @@ -0,0 +1,973 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/v8context_cpptoc.h" +#include "libcef_dll/cpptoc/v8exception_cpptoc.h" +#include "libcef_dll/cpptoc/v8value_cpptoc.h" +#include "libcef_dll/ctocpp/base_ctocpp.h" +#include "libcef_dll/ctocpp/v8accessor_ctocpp.h" +#include "libcef_dll/ctocpp/v8handler_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_v8value_t* cef_v8value_create_undefined() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = CefV8Value::CreateUndefined(); + + // Return type: refptr_same + return CefV8ValueCppToC::Wrap(_retval); +} + +CEF_EXPORT cef_v8value_t* cef_v8value_create_null() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = CefV8Value::CreateNull(); + + // Return type: refptr_same + return CefV8ValueCppToC::Wrap(_retval); +} + +CEF_EXPORT cef_v8value_t* cef_v8value_create_bool(int value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = CefV8Value::CreateBool( + value?true:false); + + // Return type: refptr_same + return CefV8ValueCppToC::Wrap(_retval); +} + +CEF_EXPORT cef_v8value_t* cef_v8value_create_int(int32 value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = CefV8Value::CreateInt( + value); + + // Return type: refptr_same + return CefV8ValueCppToC::Wrap(_retval); +} + +CEF_EXPORT cef_v8value_t* cef_v8value_create_uint(uint32 value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = CefV8Value::CreateUInt( + value); + + // Return type: refptr_same + return CefV8ValueCppToC::Wrap(_retval); +} + +CEF_EXPORT cef_v8value_t* cef_v8value_create_double(double value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = CefV8Value::CreateDouble( + value); + + // Return type: refptr_same + return CefV8ValueCppToC::Wrap(_retval); +} + +CEF_EXPORT cef_v8value_t* cef_v8value_create_date(const cef_time_t* date) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: date; type: simple_byref_const + DCHECK(date); + if (!date) + return NULL; + + // Translate param: date; type: simple_byref_const + CefTime dateVal = date?*date:CefTime(); + + // Execute + CefRefPtr _retval = CefV8Value::CreateDate( + dateVal); + + // Return type: refptr_same + return CefV8ValueCppToC::Wrap(_retval); +} + +CEF_EXPORT cef_v8value_t* cef_v8value_create_string(const cef_string_t* value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: value + + // Execute + CefRefPtr _retval = CefV8Value::CreateString( + CefString(value)); + + // Return type: refptr_same + return CefV8ValueCppToC::Wrap(_retval); +} + +CEF_EXPORT cef_v8value_t* cef_v8value_create_object( + cef_v8accessor_t* accessor) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: accessor + + // Execute + CefRefPtr _retval = CefV8Value::CreateObject( + CefV8AccessorCToCpp::Wrap(accessor)); + + // Return type: refptr_same + return CefV8ValueCppToC::Wrap(_retval); +} + +CEF_EXPORT cef_v8value_t* cef_v8value_create_array(int length) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = CefV8Value::CreateArray( + length); + + // Return type: refptr_same + return CefV8ValueCppToC::Wrap(_retval); +} + +CEF_EXPORT cef_v8value_t* cef_v8value_create_function(const cef_string_t* name, + cef_v8handler_t* handler) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: name; type: string_byref_const + DCHECK(name); + if (!name) + return NULL; + // Verify param: handler; type: refptr_diff + DCHECK(handler); + if (!handler) + return NULL; + + // Execute + CefRefPtr _retval = CefV8Value::CreateFunction( + CefString(name), + CefV8HandlerCToCpp::Wrap(handler)); + + // Return type: refptr_same + return CefV8ValueCppToC::Wrap(_retval); +} + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK v8value_is_valid(struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->IsValid(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8value_is_undefined(struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->IsUndefined(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8value_is_null(struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->IsNull(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8value_is_bool(struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->IsBool(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8value_is_int(struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->IsInt(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8value_is_uint(struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->IsUInt(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8value_is_double(struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->IsDouble(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8value_is_date(struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->IsDate(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8value_is_string(struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->IsString(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8value_is_object(struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->IsObject(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8value_is_array(struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->IsArray(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8value_is_function(struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->IsFunction(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8value_is_same(struct _cef_v8value_t* self, + struct _cef_v8value_t* that) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: that; type: refptr_same + DCHECK(that); + if (!that) + return 0; + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->IsSame( + CefV8ValueCppToC::Unwrap(that)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8value_get_bool_value(struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->GetBoolValue(); + + // Return type: bool + return _retval; +} + +int32 CEF_CALLBACK v8value_get_int_value(struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int32 _retval = CefV8ValueCppToC::Get(self)->GetIntValue(); + + // Return type: simple + return _retval; +} + +uint32 CEF_CALLBACK v8value_get_uint_value(struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + uint32 _retval = CefV8ValueCppToC::Get(self)->GetUIntValue(); + + // Return type: simple + return _retval; +} + +double CEF_CALLBACK v8value_get_double_value(struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + double _retval = CefV8ValueCppToC::Get(self)->GetDoubleValue(); + + // Return type: simple + return _retval; +} + +cef_time_t CEF_CALLBACK v8value_get_date_value(struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CefTime(); + + // Execute + cef_time_t _retval = CefV8ValueCppToC::Get(self)->GetDateValue(); + + // Return type: simple + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK v8value_get_string_value( + struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefV8ValueCppToC::Get(self)->GetStringValue(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +int CEF_CALLBACK v8value_is_user_created(struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->IsUserCreated(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8value_has_exception(struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->HasException(); + + // Return type: bool + return _retval; +} + +cef_v8exception_t* CEF_CALLBACK v8value_get_exception( + struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefV8ValueCppToC::Get(self)->GetException( + ); + + // Return type: refptr_same + return CefV8ExceptionCppToC::Wrap(_retval); +} + +int CEF_CALLBACK v8value_clear_exception(struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->ClearException(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8value_will_rethrow_exceptions(struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->WillRethrowExceptions(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8value_set_rethrow_exceptions(struct _cef_v8value_t* self, + int rethrow) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->SetRethrowExceptions( + rethrow?true:false); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8value_has_value_bykey(struct _cef_v8value_t* self, + const cef_string_t* key) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Unverified params: key + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->HasValue( + CefString(key)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8value_has_value_byindex(struct _cef_v8value_t* self, + int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return 0; + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->HasValue( + index); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8value_delete_value_bykey(struct _cef_v8value_t* self, + const cef_string_t* key) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Unverified params: key + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->DeleteValue( + CefString(key)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8value_delete_value_byindex(struct _cef_v8value_t* self, + int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return 0; + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->DeleteValue( + index); + + // Return type: bool + return _retval; +} + +struct _cef_v8value_t* CEF_CALLBACK v8value_get_value_bykey( + struct _cef_v8value_t* self, const cef_string_t* key) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Unverified params: key + + // Execute + CefRefPtr _retval = CefV8ValueCppToC::Get(self)->GetValue( + CefString(key)); + + // Return type: refptr_same + return CefV8ValueCppToC::Wrap(_retval); +} + +struct _cef_v8value_t* CEF_CALLBACK v8value_get_value_byindex( + struct _cef_v8value_t* self, int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return NULL; + + // Execute + CefRefPtr _retval = CefV8ValueCppToC::Get(self)->GetValue( + index); + + // Return type: refptr_same + return CefV8ValueCppToC::Wrap(_retval); +} + +int CEF_CALLBACK v8value_set_value_bykey(struct _cef_v8value_t* self, + const cef_string_t* key, struct _cef_v8value_t* value, + enum cef_v8_propertyattribute_t attribute) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: value; type: refptr_same + DCHECK(value); + if (!value) + return 0; + // Unverified params: key + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->SetValue( + CefString(key), + CefV8ValueCppToC::Unwrap(value), + attribute); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8value_set_value_byindex(struct _cef_v8value_t* self, + int index, struct _cef_v8value_t* value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return 0; + // Verify param: value; type: refptr_same + DCHECK(value); + if (!value) + return 0; + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->SetValue( + index, + CefV8ValueCppToC::Unwrap(value)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8value_set_value_byaccessor(struct _cef_v8value_t* self, + const cef_string_t* key, enum cef_v8_accesscontrol_t settings, + enum cef_v8_propertyattribute_t attribute) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Unverified params: key + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->SetValue( + CefString(key), + settings, + attribute); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8value_get_keys(struct _cef_v8value_t* self, + cef_string_list_t keys) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: keys; type: string_vec_byref + DCHECK(keys); + if (!keys) + return 0; + + // Translate param: keys; type: string_vec_byref + std::vector keysList; + transfer_string_list_contents(keys, keysList); + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->GetKeys( + keysList); + + // Restore param: keys; type: string_vec_byref + cef_string_list_clear(keys); + transfer_string_list_contents(keysList, keys); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK v8value_set_user_data(struct _cef_v8value_t* self, + cef_base_t* user_data) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Unverified params: user_data + + // Execute + bool _retval = CefV8ValueCppToC::Get(self)->SetUserData( + CefBaseCToCpp::Wrap(user_data)); + + // Return type: bool + return _retval; +} + +cef_base_t* CEF_CALLBACK v8value_get_user_data(struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefV8ValueCppToC::Get(self)->GetUserData(); + + // Return type: refptr_diff + return CefBaseCToCpp::Unwrap(_retval); +} + +int CEF_CALLBACK v8value_get_externally_allocated_memory( + struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefV8ValueCppToC::Get(self)->GetExternallyAllocatedMemory(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK v8value_adjust_externally_allocated_memory( + struct _cef_v8value_t* self, int change_in_bytes) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefV8ValueCppToC::Get(self)->AdjustExternallyAllocatedMemory( + change_in_bytes); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK v8value_get_array_length(struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefV8ValueCppToC::Get(self)->GetArrayLength(); + + // Return type: simple + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK v8value_get_function_name( + struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefV8ValueCppToC::Get(self)->GetFunctionName(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_v8handler_t* CEF_CALLBACK v8value_get_function_handler( + struct _cef_v8value_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefV8ValueCppToC::Get( + self)->GetFunctionHandler(); + + // Return type: refptr_diff + return CefV8HandlerCToCpp::Unwrap(_retval); +} + +struct _cef_v8value_t* CEF_CALLBACK v8value_execute_function( + struct _cef_v8value_t* self, struct _cef_v8value_t* object, + size_t argumentsCount, struct _cef_v8value_t* const* arguments) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: arguments; type: refptr_vec_same_byref_const + DCHECK(argumentsCount == 0 || arguments); + if (argumentsCount > 0 && !arguments) + return NULL; + // Unverified params: object + + // Translate param: arguments; type: refptr_vec_same_byref_const + std::vector > argumentsList; + if (argumentsCount > 0) { + for (size_t i = 0; i < argumentsCount; ++i) { + argumentsList.push_back(CefV8ValueCppToC::Unwrap(arguments[i])); + } + } + + // Execute + CefRefPtr _retval = CefV8ValueCppToC::Get(self)->ExecuteFunction( + CefV8ValueCppToC::Unwrap(object), + argumentsList); + + // Return type: refptr_same + return CefV8ValueCppToC::Wrap(_retval); +} + +struct _cef_v8value_t* CEF_CALLBACK v8value_execute_function_with_context( + struct _cef_v8value_t* self, cef_v8context_t* context, + struct _cef_v8value_t* object, size_t argumentsCount, + struct _cef_v8value_t* const* arguments) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: context; type: refptr_same + DCHECK(context); + if (!context) + return NULL; + // Verify param: arguments; type: refptr_vec_same_byref_const + DCHECK(argumentsCount == 0 || arguments); + if (argumentsCount > 0 && !arguments) + return NULL; + // Unverified params: object + + // Translate param: arguments; type: refptr_vec_same_byref_const + std::vector > argumentsList; + if (argumentsCount > 0) { + for (size_t i = 0; i < argumentsCount; ++i) { + argumentsList.push_back(CefV8ValueCppToC::Unwrap(arguments[i])); + } + } + + // Execute + CefRefPtr _retval = CefV8ValueCppToC::Get( + self)->ExecuteFunctionWithContext( + CefV8ContextCppToC::Unwrap(context), + CefV8ValueCppToC::Unwrap(object), + argumentsList); + + // Return type: refptr_same + return CefV8ValueCppToC::Wrap(_retval); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefV8ValueCppToC::CefV8ValueCppToC(CefV8Value* cls) + : CefCppToC(cls) { + struct_.struct_.is_valid = v8value_is_valid; + struct_.struct_.is_undefined = v8value_is_undefined; + struct_.struct_.is_null = v8value_is_null; + struct_.struct_.is_bool = v8value_is_bool; + struct_.struct_.is_int = v8value_is_int; + struct_.struct_.is_uint = v8value_is_uint; + struct_.struct_.is_double = v8value_is_double; + struct_.struct_.is_date = v8value_is_date; + struct_.struct_.is_string = v8value_is_string; + struct_.struct_.is_object = v8value_is_object; + struct_.struct_.is_array = v8value_is_array; + struct_.struct_.is_function = v8value_is_function; + struct_.struct_.is_same = v8value_is_same; + struct_.struct_.get_bool_value = v8value_get_bool_value; + struct_.struct_.get_int_value = v8value_get_int_value; + struct_.struct_.get_uint_value = v8value_get_uint_value; + struct_.struct_.get_double_value = v8value_get_double_value; + struct_.struct_.get_date_value = v8value_get_date_value; + struct_.struct_.get_string_value = v8value_get_string_value; + struct_.struct_.is_user_created = v8value_is_user_created; + struct_.struct_.has_exception = v8value_has_exception; + struct_.struct_.get_exception = v8value_get_exception; + struct_.struct_.clear_exception = v8value_clear_exception; + struct_.struct_.will_rethrow_exceptions = v8value_will_rethrow_exceptions; + struct_.struct_.set_rethrow_exceptions = v8value_set_rethrow_exceptions; + struct_.struct_.has_value_bykey = v8value_has_value_bykey; + struct_.struct_.has_value_byindex = v8value_has_value_byindex; + struct_.struct_.delete_value_bykey = v8value_delete_value_bykey; + struct_.struct_.delete_value_byindex = v8value_delete_value_byindex; + struct_.struct_.get_value_bykey = v8value_get_value_bykey; + struct_.struct_.get_value_byindex = v8value_get_value_byindex; + struct_.struct_.set_value_bykey = v8value_set_value_bykey; + struct_.struct_.set_value_byindex = v8value_set_value_byindex; + struct_.struct_.set_value_byaccessor = v8value_set_value_byaccessor; + struct_.struct_.get_keys = v8value_get_keys; + struct_.struct_.set_user_data = v8value_set_user_data; + struct_.struct_.get_user_data = v8value_get_user_data; + struct_.struct_.get_externally_allocated_memory = + v8value_get_externally_allocated_memory; + struct_.struct_.adjust_externally_allocated_memory = + v8value_adjust_externally_allocated_memory; + struct_.struct_.get_array_length = v8value_get_array_length; + struct_.struct_.get_function_name = v8value_get_function_name; + struct_.struct_.get_function_handler = v8value_get_function_handler; + struct_.struct_.execute_function = v8value_execute_function; + struct_.struct_.execute_function_with_context = + v8value_execute_function_with_context; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/v8value_cpptoc.h b/cef3/libcef_dll/cpptoc/v8value_cpptoc.h new file mode 100644 index 000000000..28eae4af6 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/v8value_cpptoc.h @@ -0,0 +1,36 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_V8VALUE_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_V8VALUE_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_v8.h" +#include "include/capi/cef_v8_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefV8ValueCppToC + : public CefCppToC { + public: + explicit CefV8ValueCppToC(CefV8Value* cls); + virtual ~CefV8ValueCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_V8VALUE_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/web_plugin_info_cpptoc.cc b/cef3/libcef_dll/cpptoc/web_plugin_info_cpptoc.cc new file mode 100644 index 000000000..f3c92dddc --- /dev/null +++ b/cef3/libcef_dll/cpptoc/web_plugin_info_cpptoc.cc @@ -0,0 +1,94 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/web_plugin_info_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +cef_string_userfree_t CEF_CALLBACK web_plugin_info_get_name( + struct _cef_web_plugin_info_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefWebPluginInfoCppToC::Get(self)->GetName(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK web_plugin_info_get_path( + struct _cef_web_plugin_info_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefWebPluginInfoCppToC::Get(self)->GetPath(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK web_plugin_info_get_version( + struct _cef_web_plugin_info_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefWebPluginInfoCppToC::Get(self)->GetVersion(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK web_plugin_info_get_description( + struct _cef_web_plugin_info_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefWebPluginInfoCppToC::Get(self)->GetDescription(); + + // Return type: string + return _retval.DetachToUserFree(); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefWebPluginInfoCppToC::CefWebPluginInfoCppToC(CefWebPluginInfo* cls) + : CefCppToC(cls) { + struct_.struct_.get_name = web_plugin_info_get_name; + struct_.struct_.get_path = web_plugin_info_get_path; + struct_.struct_.get_version = web_plugin_info_get_version; + struct_.struct_.get_description = web_plugin_info_get_description; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/web_plugin_info_cpptoc.h b/cef3/libcef_dll/cpptoc/web_plugin_info_cpptoc.h new file mode 100644 index 000000000..34aa700df --- /dev/null +++ b/cef3/libcef_dll/cpptoc/web_plugin_info_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_WEB_PLUGIN_INFO_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_WEB_PLUGIN_INFO_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_web_plugin.h" +#include "include/capi/cef_web_plugin_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefWebPluginInfoCppToC + : public CefCppToC { + public: + explicit CefWebPluginInfoCppToC(CefWebPluginInfo* cls); + virtual ~CefWebPluginInfoCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_WEB_PLUGIN_INFO_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/web_plugin_info_visitor_cpptoc.cc b/cef3/libcef_dll/cpptoc/web_plugin_info_visitor_cpptoc.cc new file mode 100644 index 000000000..755223bd9 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/web_plugin_info_visitor_cpptoc.cc @@ -0,0 +1,56 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/web_plugin_info_visitor_cpptoc.h" +#include "libcef_dll/ctocpp/web_plugin_info_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK web_plugin_info_visitor_visit( + struct _cef_web_plugin_info_visitor_t* self, cef_web_plugin_info_t* info, + int count, int total) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: info; type: refptr_diff + DCHECK(info); + if (!info) + return 0; + + // Execute + bool _retval = CefWebPluginInfoVisitorCppToC::Get(self)->Visit( + CefWebPluginInfoCToCpp::Wrap(info), + count, + total); + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefWebPluginInfoVisitorCppToC::CefWebPluginInfoVisitorCppToC( + CefWebPluginInfoVisitor* cls) + : CefCppToC(cls) { + struct_.struct_.visit = web_plugin_info_visitor_visit; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/web_plugin_info_visitor_cpptoc.h b/cef3/libcef_dll/cpptoc/web_plugin_info_visitor_cpptoc.h new file mode 100644 index 000000000..c81f056ba --- /dev/null +++ b/cef3/libcef_dll/cpptoc/web_plugin_info_visitor_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_WEB_PLUGIN_INFO_VISITOR_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_WEB_PLUGIN_INFO_VISITOR_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_web_plugin.h" +#include "include/capi/cef_web_plugin_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefWebPluginInfoVisitorCppToC + : public CefCppToC { + public: + explicit CefWebPluginInfoVisitorCppToC(CefWebPluginInfoVisitor* cls); + virtual ~CefWebPluginInfoVisitorCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_WEB_PLUGIN_INFO_VISITOR_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/web_plugin_unstable_callback_cpptoc.cc b/cef3/libcef_dll/cpptoc/web_plugin_unstable_callback_cpptoc.cc new file mode 100644 index 000000000..a1e27f086 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/web_plugin_unstable_callback_cpptoc.cc @@ -0,0 +1,53 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/web_plugin_unstable_callback_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK web_plugin_unstable_callback_is_unstable( + struct _cef_web_plugin_unstable_callback_t* self, const cef_string_t* path, + int unstable) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: path; type: string_byref_const + DCHECK(path); + if (!path) + return; + + // Execute + CefWebPluginUnstableCallbackCppToC::Get(self)->IsUnstable( + CefString(path), + unstable?true:false); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefWebPluginUnstableCallbackCppToC::CefWebPluginUnstableCallbackCppToC( + CefWebPluginUnstableCallback* cls) + : CefCppToC( + cls) { + struct_.struct_.is_unstable = web_plugin_unstable_callback_is_unstable; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/web_plugin_unstable_callback_cpptoc.h b/cef3/libcef_dll/cpptoc/web_plugin_unstable_callback_cpptoc.h new file mode 100644 index 000000000..43f62a30d --- /dev/null +++ b/cef3/libcef_dll/cpptoc/web_plugin_unstable_callback_cpptoc.h @@ -0,0 +1,38 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_WEB_PLUGIN_UNSTABLE_CALLBACK_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_WEB_PLUGIN_UNSTABLE_CALLBACK_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_web_plugin.h" +#include "include/capi/cef_web_plugin_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefWebPluginUnstableCallbackCppToC + : public CefCppToC { + public: + explicit CefWebPluginUnstableCallbackCppToC( + CefWebPluginUnstableCallback* cls); + virtual ~CefWebPluginUnstableCallbackCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_WEB_PLUGIN_UNSTABLE_CALLBACK_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/write_handler_cpptoc.cc b/cef3/libcef_dll/cpptoc/write_handler_cpptoc.cc new file mode 100644 index 000000000..001928442 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/write_handler_cpptoc.cc @@ -0,0 +1,101 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/write_handler_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +size_t CEF_CALLBACK write_handler_write(struct _cef_write_handler_t* self, + const void* ptr, size_t size, size_t n) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: ptr; type: simple_byaddr + DCHECK(ptr); + if (!ptr) + return 0; + + // Execute + size_t _retval = CefWriteHandlerCppToC::Get(self)->Write( + ptr, + size, + n); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK write_handler_seek(struct _cef_write_handler_t* self, + int64 offset, int whence) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefWriteHandlerCppToC::Get(self)->Seek( + offset, + whence); + + // Return type: simple + return _retval; +} + +int64 CEF_CALLBACK write_handler_tell(struct _cef_write_handler_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int64 _retval = CefWriteHandlerCppToC::Get(self)->Tell(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK write_handler_flush(struct _cef_write_handler_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefWriteHandlerCppToC::Get(self)->Flush(); + + // Return type: simple + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefWriteHandlerCppToC::CefWriteHandlerCppToC(CefWriteHandler* cls) + : CefCppToC( + cls) { + struct_.struct_.write = write_handler_write; + struct_.struct_.seek = write_handler_seek; + struct_.struct_.tell = write_handler_tell; + struct_.struct_.flush = write_handler_flush; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/write_handler_cpptoc.h b/cef3/libcef_dll/cpptoc/write_handler_cpptoc.h new file mode 100644 index 000000000..eda6ea830 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/write_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_WRITE_HANDLER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_WRITE_HANDLER_CPPTOC_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_stream.h" +#include "include/capi/cef_stream_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefWriteHandlerCppToC + : public CefCppToC { + public: + explicit CefWriteHandlerCppToC(CefWriteHandler* cls); + virtual ~CefWriteHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_WRITE_HANDLER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/xml_reader_cpptoc.cc b/cef3/libcef_dll/cpptoc/xml_reader_cpptoc.cc new file mode 100644 index 000000000..ec16f26c0 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/xml_reader_cpptoc.cc @@ -0,0 +1,558 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/stream_reader_cpptoc.h" +#include "libcef_dll/cpptoc/xml_reader_cpptoc.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_xml_reader_t* cef_xml_reader_create(cef_stream_reader_t* stream, + enum cef_xml_encoding_type_t encodingType, const cef_string_t* URI) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: stream; type: refptr_same + DCHECK(stream); + if (!stream) + return NULL; + // Verify param: URI; type: string_byref_const + DCHECK(URI); + if (!URI) + return NULL; + + // Execute + CefRefPtr _retval = CefXmlReader::Create( + CefStreamReaderCppToC::Unwrap(stream), + encodingType, + CefString(URI)); + + // Return type: refptr_same + return CefXmlReaderCppToC::Wrap(_retval); +} + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK xml_reader_move_to_next_node(struct _cef_xml_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefXmlReaderCppToC::Get(self)->MoveToNextNode(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK xml_reader_close(struct _cef_xml_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefXmlReaderCppToC::Get(self)->Close(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK xml_reader_has_error(struct _cef_xml_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefXmlReaderCppToC::Get(self)->HasError(); + + // Return type: bool + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_error( + struct _cef_xml_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefXmlReaderCppToC::Get(self)->GetError(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +enum cef_xml_node_type_t CEF_CALLBACK xml_reader_get_type( + struct _cef_xml_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return XML_NODE_UNSUPPORTED; + + // Execute + cef_xml_node_type_t _retval = CefXmlReaderCppToC::Get(self)->GetType(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK xml_reader_get_depth(struct _cef_xml_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefXmlReaderCppToC::Get(self)->GetDepth(); + + // Return type: simple + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_local_name( + struct _cef_xml_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefXmlReaderCppToC::Get(self)->GetLocalName(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_prefix( + struct _cef_xml_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefXmlReaderCppToC::Get(self)->GetPrefix(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_qualified_name( + struct _cef_xml_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefXmlReaderCppToC::Get(self)->GetQualifiedName(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_namespace_uri( + struct _cef_xml_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefXmlReaderCppToC::Get(self)->GetNamespaceURI(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_base_uri( + struct _cef_xml_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefXmlReaderCppToC::Get(self)->GetBaseURI(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_xml_lang( + struct _cef_xml_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefXmlReaderCppToC::Get(self)->GetXmlLang(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +int CEF_CALLBACK xml_reader_is_empty_element(struct _cef_xml_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefXmlReaderCppToC::Get(self)->IsEmptyElement(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK xml_reader_has_value(struct _cef_xml_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefXmlReaderCppToC::Get(self)->HasValue(); + + // Return type: bool + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_value( + struct _cef_xml_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefXmlReaderCppToC::Get(self)->GetValue(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +int CEF_CALLBACK xml_reader_has_attributes(struct _cef_xml_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefXmlReaderCppToC::Get(self)->HasAttributes(); + + // Return type: bool + return _retval; +} + +size_t CEF_CALLBACK xml_reader_get_attribute_count( + struct _cef_xml_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + size_t _retval = CefXmlReaderCppToC::Get(self)->GetAttributeCount(); + + // Return type: simple + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_attribute_byindex( + struct _cef_xml_reader_t* self, int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return NULL; + + // Execute + CefString _retval = CefXmlReaderCppToC::Get(self)->GetAttribute( + index); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_attribute_byqname( + struct _cef_xml_reader_t* self, const cef_string_t* qualifiedName) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: qualifiedName; type: string_byref_const + DCHECK(qualifiedName); + if (!qualifiedName) + return NULL; + + // Execute + CefString _retval = CefXmlReaderCppToC::Get(self)->GetAttribute( + CefString(qualifiedName)); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_attribute_bylname( + struct _cef_xml_reader_t* self, const cef_string_t* localName, + const cef_string_t* namespaceURI) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: localName; type: string_byref_const + DCHECK(localName); + if (!localName) + return NULL; + // Verify param: namespaceURI; type: string_byref_const + DCHECK(namespaceURI); + if (!namespaceURI) + return NULL; + + // Execute + CefString _retval = CefXmlReaderCppToC::Get(self)->GetAttribute( + CefString(localName), + CefString(namespaceURI)); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_inner_xml( + struct _cef_xml_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefXmlReaderCppToC::Get(self)->GetInnerXml(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_outer_xml( + struct _cef_xml_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefXmlReaderCppToC::Get(self)->GetOuterXml(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +int CEF_CALLBACK xml_reader_get_line_number(struct _cef_xml_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefXmlReaderCppToC::Get(self)->GetLineNumber(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK xml_reader_move_to_attribute_byindex( + struct _cef_xml_reader_t* self, int index) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return 0; + + // Execute + bool _retval = CefXmlReaderCppToC::Get(self)->MoveToAttribute( + index); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK xml_reader_move_to_attribute_byqname( + struct _cef_xml_reader_t* self, const cef_string_t* qualifiedName) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: qualifiedName; type: string_byref_const + DCHECK(qualifiedName); + if (!qualifiedName) + return 0; + + // Execute + bool _retval = CefXmlReaderCppToC::Get(self)->MoveToAttribute( + CefString(qualifiedName)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK xml_reader_move_to_attribute_bylname( + struct _cef_xml_reader_t* self, const cef_string_t* localName, + const cef_string_t* namespaceURI) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: localName; type: string_byref_const + DCHECK(localName); + if (!localName) + return 0; + // Verify param: namespaceURI; type: string_byref_const + DCHECK(namespaceURI); + if (!namespaceURI) + return 0; + + // Execute + bool _retval = CefXmlReaderCppToC::Get(self)->MoveToAttribute( + CefString(localName), + CefString(namespaceURI)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK xml_reader_move_to_first_attribute( + struct _cef_xml_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefXmlReaderCppToC::Get(self)->MoveToFirstAttribute(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK xml_reader_move_to_next_attribute( + struct _cef_xml_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefXmlReaderCppToC::Get(self)->MoveToNextAttribute(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK xml_reader_move_to_carrying_element( + struct _cef_xml_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefXmlReaderCppToC::Get(self)->MoveToCarryingElement(); + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefXmlReaderCppToC::CefXmlReaderCppToC(CefXmlReader* cls) + : CefCppToC(cls) { + struct_.struct_.move_to_next_node = xml_reader_move_to_next_node; + struct_.struct_.close = xml_reader_close; + struct_.struct_.has_error = xml_reader_has_error; + struct_.struct_.get_error = xml_reader_get_error; + struct_.struct_.get_type = xml_reader_get_type; + struct_.struct_.get_depth = xml_reader_get_depth; + struct_.struct_.get_local_name = xml_reader_get_local_name; + struct_.struct_.get_prefix = xml_reader_get_prefix; + struct_.struct_.get_qualified_name = xml_reader_get_qualified_name; + struct_.struct_.get_namespace_uri = xml_reader_get_namespace_uri; + struct_.struct_.get_base_uri = xml_reader_get_base_uri; + struct_.struct_.get_xml_lang = xml_reader_get_xml_lang; + struct_.struct_.is_empty_element = xml_reader_is_empty_element; + struct_.struct_.has_value = xml_reader_has_value; + struct_.struct_.get_value = xml_reader_get_value; + struct_.struct_.has_attributes = xml_reader_has_attributes; + struct_.struct_.get_attribute_count = xml_reader_get_attribute_count; + struct_.struct_.get_attribute_byindex = xml_reader_get_attribute_byindex; + struct_.struct_.get_attribute_byqname = xml_reader_get_attribute_byqname; + struct_.struct_.get_attribute_bylname = xml_reader_get_attribute_bylname; + struct_.struct_.get_inner_xml = xml_reader_get_inner_xml; + struct_.struct_.get_outer_xml = xml_reader_get_outer_xml; + struct_.struct_.get_line_number = xml_reader_get_line_number; + struct_.struct_.move_to_attribute_byindex = + xml_reader_move_to_attribute_byindex; + struct_.struct_.move_to_attribute_byqname = + xml_reader_move_to_attribute_byqname; + struct_.struct_.move_to_attribute_bylname = + xml_reader_move_to_attribute_bylname; + struct_.struct_.move_to_first_attribute = xml_reader_move_to_first_attribute; + struct_.struct_.move_to_next_attribute = xml_reader_move_to_next_attribute; + struct_.struct_.move_to_carrying_element = + xml_reader_move_to_carrying_element; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/xml_reader_cpptoc.h b/cef3/libcef_dll/cpptoc/xml_reader_cpptoc.h new file mode 100644 index 000000000..ed0b188c0 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/xml_reader_cpptoc.h @@ -0,0 +1,36 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_XML_READER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_XML_READER_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_xml_reader.h" +#include "include/capi/cef_xml_reader_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefXmlReaderCppToC + : public CefCppToC { + public: + explicit CefXmlReaderCppToC(CefXmlReader* cls); + virtual ~CefXmlReaderCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_XML_READER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/cpptoc/zip_reader_cpptoc.cc b/cef3/libcef_dll/cpptoc/zip_reader_cpptoc.cc new file mode 100644 index 000000000..d6e372acc --- /dev/null +++ b/cef3/libcef_dll/cpptoc/zip_reader_cpptoc.cc @@ -0,0 +1,249 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/stream_reader_cpptoc.h" +#include "libcef_dll/cpptoc/zip_reader_cpptoc.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_zip_reader_t* cef_zip_reader_create( + cef_stream_reader_t* stream) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: stream; type: refptr_same + DCHECK(stream); + if (!stream) + return NULL; + + // Execute + CefRefPtr _retval = CefZipReader::Create( + CefStreamReaderCppToC::Unwrap(stream)); + + // Return type: refptr_same + return CefZipReaderCppToC::Wrap(_retval); +} + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK zip_reader_move_to_first_file(struct _cef_zip_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefZipReaderCppToC::Get(self)->MoveToFirstFile(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK zip_reader_move_to_next_file(struct _cef_zip_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefZipReaderCppToC::Get(self)->MoveToNextFile(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK zip_reader_move_to_file(struct _cef_zip_reader_t* self, + const cef_string_t* fileName, int caseSensitive) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: fileName; type: string_byref_const + DCHECK(fileName); + if (!fileName) + return 0; + + // Execute + bool _retval = CefZipReaderCppToC::Get(self)->MoveToFile( + CefString(fileName), + caseSensitive?true:false); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK zip_reader_close(struct _cef_zip_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefZipReaderCppToC::Get(self)->Close(); + + // Return type: bool + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK zip_reader_get_file_name( + struct _cef_zip_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefZipReaderCppToC::Get(self)->GetFileName(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +int64 CEF_CALLBACK zip_reader_get_file_size(struct _cef_zip_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int64 _retval = CefZipReaderCppToC::Get(self)->GetFileSize(); + + // Return type: simple + return _retval; +} + +time_t CEF_CALLBACK zip_reader_get_file_last_modified( + struct _cef_zip_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + time_t _retval = CefZipReaderCppToC::Get(self)->GetFileLastModified(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK zip_reader_open_file(struct _cef_zip_reader_t* self, + const cef_string_t* password) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Unverified params: password + + // Execute + bool _retval = CefZipReaderCppToC::Get(self)->OpenFile( + CefString(password)); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK zip_reader_close_file(struct _cef_zip_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefZipReaderCppToC::Get(self)->CloseFile(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK zip_reader_read_file(struct _cef_zip_reader_t* self, + void* buffer, size_t bufferSize) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: buffer; type: simple_byaddr + DCHECK(buffer); + if (!buffer) + return 0; + + // Execute + int _retval = CefZipReaderCppToC::Get(self)->ReadFile( + buffer, + bufferSize); + + // Return type: simple + return _retval; +} + +int64 CEF_CALLBACK zip_reader_tell(struct _cef_zip_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int64 _retval = CefZipReaderCppToC::Get(self)->Tell(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK zip_reader_eof(struct _cef_zip_reader_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefZipReaderCppToC::Get(self)->Eof(); + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefZipReaderCppToC::CefZipReaderCppToC(CefZipReader* cls) + : CefCppToC(cls) { + struct_.struct_.move_to_first_file = zip_reader_move_to_first_file; + struct_.struct_.move_to_next_file = zip_reader_move_to_next_file; + struct_.struct_.move_to_file = zip_reader_move_to_file; + struct_.struct_.close = zip_reader_close; + struct_.struct_.get_file_name = zip_reader_get_file_name; + struct_.struct_.get_file_size = zip_reader_get_file_size; + struct_.struct_.get_file_last_modified = zip_reader_get_file_last_modified; + struct_.struct_.open_file = zip_reader_open_file; + struct_.struct_.close_file = zip_reader_close_file; + struct_.struct_.read_file = zip_reader_read_file; + struct_.struct_.tell = zip_reader_tell; + struct_.struct_.eof = zip_reader_eof; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/cpptoc/zip_reader_cpptoc.h b/cef3/libcef_dll/cpptoc/zip_reader_cpptoc.h new file mode 100644 index 000000000..58bdd7c71 --- /dev/null +++ b/cef3/libcef_dll/cpptoc/zip_reader_cpptoc.h @@ -0,0 +1,36 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_ZIP_READER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_ZIP_READER_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_zip_reader.h" +#include "include/capi/cef_zip_reader_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefZipReaderCppToC + : public CefCppToC { + public: + explicit CefZipReaderCppToC(CefZipReader* cls); + virtual ~CefZipReaderCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_ZIP_READER_CPPTOC_H_ + diff --git a/cef3/libcef_dll/ctocpp/allow_certificate_error_callback_ctocpp.cc b/cef3/libcef_dll/ctocpp/allow_certificate_error_callback_ctocpp.cc new file mode 100644 index 000000000..a3cd365a2 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/allow_certificate_error_callback_ctocpp.cc @@ -0,0 +1,35 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/allow_certificate_error_callback_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefAllowCertificateErrorCallbackCToCpp::Continue(bool allow) { + if (CEF_MEMBER_MISSING(struct_, cont)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->cont(struct_, + allow); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/allow_certificate_error_callback_ctocpp.h b/cef3/libcef_dll/ctocpp/allow_certificate_error_callback_ctocpp.h new file mode 100644 index 000000000..6ebe9e770 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/allow_certificate_error_callback_ctocpp.h @@ -0,0 +1,45 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_ALLOW_CERTIFICATE_ERROR_CALLBACK_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_ALLOW_CERTIFICATE_ERROR_CALLBACK_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_request_handler.h" +#include "include/capi/cef_request_handler_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefAllowCertificateErrorCallbackCToCpp + : public CefCToCpp { + public: + explicit CefAllowCertificateErrorCallbackCToCpp( + cef_allow_certificate_error_callback_t* str) + : CefCToCpp(str) {} + virtual ~CefAllowCertificateErrorCallbackCToCpp() {} + + // CefAllowCertificateErrorCallback methods + virtual void Continue(bool allow) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_ALLOW_CERTIFICATE_ERROR_CALLBACK_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/app_ctocpp.cc b/cef3/libcef_dll/ctocpp/app_ctocpp.cc new file mode 100644 index 000000000..8c064238d --- /dev/null +++ b/cef3/libcef_dll/ctocpp/app_ctocpp.cc @@ -0,0 +1,105 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/command_line_cpptoc.h" +#include "libcef_dll/cpptoc/scheme_registrar_cpptoc.h" +#include "libcef_dll/ctocpp/app_ctocpp.h" +#include "libcef_dll/ctocpp/browser_process_handler_ctocpp.h" +#include "libcef_dll/ctocpp/render_process_handler_ctocpp.h" +#include "libcef_dll/ctocpp/resource_bundle_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefAppCToCpp::OnBeforeCommandLineProcessing(const CefString& process_type, + CefRefPtr command_line) { + if (CEF_MEMBER_MISSING(struct_, on_before_command_line_processing)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: command_line; type: refptr_diff + DCHECK(command_line.get()); + if (!command_line.get()) + return; + // Unverified params: process_type + + // Execute + struct_->on_before_command_line_processing(struct_, + process_type.GetStruct(), + CefCommandLineCppToC::Wrap(command_line)); +} + +void CefAppCToCpp::OnRegisterCustomSchemes( + CefRefPtr registrar) { + if (CEF_MEMBER_MISSING(struct_, on_register_custom_schemes)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: registrar; type: refptr_diff + DCHECK(registrar.get()); + if (!registrar.get()) + return; + + // Execute + struct_->on_register_custom_schemes(struct_, + CefSchemeRegistrarCppToC::Wrap(registrar)); +} + +CefRefPtr CefAppCToCpp::GetResourceBundleHandler() { + if (CEF_MEMBER_MISSING(struct_, get_resource_bundle_handler)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_resource_bundle_handler_t* _retval = struct_->get_resource_bundle_handler( + struct_); + + // Return type: refptr_same + return CefResourceBundleHandlerCToCpp::Wrap(_retval); +} + +CefRefPtr CefAppCToCpp::GetBrowserProcessHandler() { + if (CEF_MEMBER_MISSING(struct_, get_browser_process_handler)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_browser_process_handler_t* _retval = struct_->get_browser_process_handler( + struct_); + + // Return type: refptr_same + return CefBrowserProcessHandlerCToCpp::Wrap(_retval); +} + +CefRefPtr CefAppCToCpp::GetRenderProcessHandler() { + if (CEF_MEMBER_MISSING(struct_, get_render_process_handler)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_render_process_handler_t* _retval = struct_->get_render_process_handler( + struct_); + + // Return type: refptr_same + return CefRenderProcessHandlerCToCpp::Wrap(_retval); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/app_ctocpp.h b/cef3/libcef_dll/ctocpp/app_ctocpp.h new file mode 100644 index 000000000..3ea54fef3 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/app_ctocpp.h @@ -0,0 +1,48 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_APP_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_APP_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_app.h" +#include "include/capi/cef_app_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefAppCToCpp + : public CefCToCpp { + public: + explicit CefAppCToCpp(cef_app_t* str) + : CefCToCpp(str) {} + virtual ~CefAppCToCpp() {} + + // CefApp methods + virtual void OnBeforeCommandLineProcessing(const CefString& process_type, + CefRefPtr command_line) OVERRIDE; + virtual void OnRegisterCustomSchemes( + CefRefPtr registrar) OVERRIDE; + virtual CefRefPtr GetResourceBundleHandler( + ) OVERRIDE; + virtual CefRefPtr GetBrowserProcessHandler( + ) OVERRIDE; + virtual CefRefPtr GetRenderProcessHandler() OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_APP_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/auth_callback_ctocpp.cc b/cef3/libcef_dll/ctocpp/auth_callback_ctocpp.cc new file mode 100644 index 000000000..736f2ca3d --- /dev/null +++ b/cef3/libcef_dll/ctocpp/auth_callback_ctocpp.cc @@ -0,0 +1,55 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/auth_callback_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefAuthCallbackCToCpp::Continue(const CefString& username, + const CefString& password) { + if (CEF_MEMBER_MISSING(struct_, cont)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: username; type: string_byref_const + DCHECK(!username.empty()); + if (username.empty()) + return; + // Verify param: password; type: string_byref_const + DCHECK(!password.empty()); + if (password.empty()) + return; + + // Execute + struct_->cont(struct_, + username.GetStruct(), + password.GetStruct()); +} + +void CefAuthCallbackCToCpp::Cancel() { + if (CEF_MEMBER_MISSING(struct_, cancel)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->cancel(struct_); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/auth_callback_ctocpp.h b/cef3/libcef_dll/ctocpp/auth_callback_ctocpp.h new file mode 100644 index 000000000..08ae159c9 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/auth_callback_ctocpp.h @@ -0,0 +1,44 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_AUTH_CALLBACK_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_AUTH_CALLBACK_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_request_handler.h" +#include "include/capi/cef_request_handler_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefAuthCallbackCToCpp + : public CefCToCpp { + public: + explicit CefAuthCallbackCToCpp(cef_auth_callback_t* str) + : CefCToCpp( + str) {} + virtual ~CefAuthCallbackCToCpp() {} + + // CefAuthCallback methods + virtual void Continue(const CefString& username, + const CefString& password) OVERRIDE; + virtual void Cancel() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_AUTH_CALLBACK_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/base_ctocpp.h b/cef3/libcef_dll/ctocpp/base_ctocpp.h new file mode 100644 index 000000000..650c08e33 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/base_ctocpp.h @@ -0,0 +1,98 @@ +// Copyright (c) 2009 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_LIBCEF_DLL_CTOCPP_BASE_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_BASE_CTOCPP_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/capi/cef_base_capi.h" +#include "libcef_dll/cef_logging.h" + + +// CefCToCpp implementation for CefBase. +class CefBaseCToCpp : public CefBase { + public: + // Use this method to create a wrapper class instance for a structure + // received from the other side. + static CefRefPtr Wrap(cef_base_t* s) { + if (!s) + return NULL; + + // Wrap their structure with the CefCToCpp object. + CefBaseCToCpp* wrapper = new CefBaseCToCpp(s); + // Put the wrapper object in a smart pointer. + CefRefPtr wrapperPtr(wrapper); + // Release the reference that was added to the CefCppToC wrapper object on + // the other side before their structure was passed to us. + wrapper->UnderlyingRelease(); + // Return the smart pointer. + return wrapperPtr; + } + + // Use this method to retrieve the underlying structure from a wrapper class + // instance for return back to the other side. + static cef_base_t* Unwrap(CefRefPtr c) { + if (!c.get()) + return NULL; + + // Cast the object to our wrapper class type. + CefBaseCToCpp* wrapper = static_cast(c.get()); + // Add a reference to the CefCppToC wrapper object on the other side that + // will be released once the structure is received. + wrapper->UnderlyingAddRef(); + // Return their original structure. + return wrapper->GetStruct(); + } + + explicit CefBaseCToCpp(cef_base_t* str) + : struct_(str) { + DCHECK(str); + } + virtual ~CefBaseCToCpp() {} + + // If returning the structure across the DLL boundary you should call + // UnderlyingAddRef() on this wrapping CefCToCpp object. On the other side of + // the DLL boundary, call Release() on the CefCppToC object. + cef_base_t* GetStruct() { return struct_; } + + // CefBase methods increment/decrement reference counts on both this object + // and the underlying wrapped structure. + int AddRef() { + UnderlyingAddRef(); + return refct_.AddRef(); + } + int Release() { + UnderlyingRelease(); + int retval = refct_.Release(); + if (retval == 0) + delete this; + return retval; + } + int GetRefCt() { return refct_.GetRefCt(); } + + // Increment/decrement reference counts on only the underlying class. + int UnderlyingAddRef() { + if (!struct_->add_ref) + return 0; + return struct_->add_ref(struct_); + } + int UnderlyingRelease() { + if (!struct_->release) + return 0; + return struct_->release(struct_); + } + int UnderlyingGetRefCt() { + if (!struct_->get_refct) + return 0; + return struct_->get_refct(struct_); + } + + protected: + CefRefCount refct_; + cef_base_t* struct_; +}; + + +#endif // CEF_LIBCEF_DLL_CTOCPP_BASE_CTOCPP_H_ diff --git a/cef3/libcef_dll/ctocpp/before_download_callback_ctocpp.cc b/cef3/libcef_dll/ctocpp/before_download_callback_ctocpp.cc new file mode 100644 index 000000000..157debb03 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/before_download_callback_ctocpp.cc @@ -0,0 +1,39 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/before_download_callback_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefBeforeDownloadCallbackCToCpp::Continue(const CefString& download_path, + bool show_dialog) { + if (CEF_MEMBER_MISSING(struct_, cont)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: download_path + + // Execute + struct_->cont(struct_, + download_path.GetStruct(), + show_dialog); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = + 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/before_download_callback_ctocpp.h b/cef3/libcef_dll/ctocpp/before_download_callback_ctocpp.h new file mode 100644 index 000000000..4d7944d3e --- /dev/null +++ b/cef3/libcef_dll/ctocpp/before_download_callback_ctocpp.h @@ -0,0 +1,43 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_BEFORE_DOWNLOAD_CALLBACK_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_BEFORE_DOWNLOAD_CALLBACK_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_download_handler.h" +#include "include/capi/cef_download_handler_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefBeforeDownloadCallbackCToCpp + : public CefCToCpp { + public: + explicit CefBeforeDownloadCallbackCToCpp(cef_before_download_callback_t* str) + : CefCToCpp(str) {} + virtual ~CefBeforeDownloadCallbackCToCpp() {} + + // CefBeforeDownloadCallback methods + virtual void Continue(const CefString& download_path, + bool show_dialog) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_BEFORE_DOWNLOAD_CALLBACK_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/binary_value_ctocpp.cc b/cef3/libcef_dll/ctocpp/binary_value_ctocpp.cc new file mode 100644 index 000000000..e9ad6d39f --- /dev/null +++ b/cef3/libcef_dll/ctocpp/binary_value_ctocpp.cc @@ -0,0 +1,118 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/binary_value_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefBinaryValue::Create(const void* data, + size_t data_size) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: data; type: simple_byaddr + DCHECK(data); + if (!data) + return NULL; + + // Execute + cef_binary_value_t* _retval = cef_binary_value_create( + data, + data_size); + + // Return type: refptr_same + return CefBinaryValueCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefBinaryValueCToCpp::IsValid() { + if (CEF_MEMBER_MISSING(struct_, is_valid)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_valid(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefBinaryValueCToCpp::IsOwned() { + if (CEF_MEMBER_MISSING(struct_, is_owned)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_owned(struct_); + + // Return type: bool + return _retval?true:false; +} + +CefRefPtr CefBinaryValueCToCpp::Copy() { + if (CEF_MEMBER_MISSING(struct_, copy)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_binary_value_t* _retval = struct_->copy(struct_); + + // Return type: refptr_same + return CefBinaryValueCToCpp::Wrap(_retval); +} + +size_t CefBinaryValueCToCpp::GetSize() { + if (CEF_MEMBER_MISSING(struct_, get_size)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + size_t _retval = struct_->get_size(struct_); + + // Return type: simple + return _retval; +} + +size_t CefBinaryValueCToCpp::GetData(void* buffer, size_t buffer_size, + size_t data_offset) { + if (CEF_MEMBER_MISSING(struct_, get_data)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: buffer; type: simple_byaddr + DCHECK(buffer); + if (!buffer) + return 0; + + // Execute + size_t _retval = struct_->get_data(struct_, + buffer, + buffer_size, + data_offset); + + // Return type: simple + return _retval; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/binary_value_ctocpp.h b/cef3/libcef_dll/ctocpp/binary_value_ctocpp.h new file mode 100644 index 000000000..6eb440767 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/binary_value_ctocpp.h @@ -0,0 +1,47 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_BINARY_VALUE_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_BINARY_VALUE_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_values.h" +#include "include/capi/cef_values_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefBinaryValueCToCpp + : public CefCToCpp { + public: + explicit CefBinaryValueCToCpp(cef_binary_value_t* str) + : CefCToCpp( + str) {} + virtual ~CefBinaryValueCToCpp() {} + + // CefBinaryValue methods + virtual bool IsValid() OVERRIDE; + virtual bool IsOwned() OVERRIDE; + virtual CefRefPtr Copy() OVERRIDE; + virtual size_t GetSize() OVERRIDE; + virtual size_t GetData(void* buffer, size_t buffer_size, + size_t data_offset) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_BINARY_VALUE_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/browser_ctocpp.cc b/cef3/libcef_dll/ctocpp/browser_ctocpp.cc new file mode 100644 index 000000000..4b99d471b --- /dev/null +++ b/cef3/libcef_dll/ctocpp/browser_ctocpp.cc @@ -0,0 +1,342 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/browser_host_ctocpp.h" +#include "libcef_dll/ctocpp/frame_ctocpp.h" +#include "libcef_dll/ctocpp/process_message_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +CefRefPtr CefBrowserCToCpp::GetHost() { + if (CEF_MEMBER_MISSING(struct_, get_host)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_browser_host_t* _retval = struct_->get_host(struct_); + + // Return type: refptr_same + return CefBrowserHostCToCpp::Wrap(_retval); +} + +bool CefBrowserCToCpp::CanGoBack() { + if (CEF_MEMBER_MISSING(struct_, can_go_back)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->can_go_back(struct_); + + // Return type: bool + return _retval?true:false; +} + +void CefBrowserCToCpp::GoBack() { + if (CEF_MEMBER_MISSING(struct_, go_back)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->go_back(struct_); +} + +bool CefBrowserCToCpp::CanGoForward() { + if (CEF_MEMBER_MISSING(struct_, can_go_forward)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->can_go_forward(struct_); + + // Return type: bool + return _retval?true:false; +} + +void CefBrowserCToCpp::GoForward() { + if (CEF_MEMBER_MISSING(struct_, go_forward)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->go_forward(struct_); +} + +bool CefBrowserCToCpp::IsLoading() { + if (CEF_MEMBER_MISSING(struct_, is_loading)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_loading(struct_); + + // Return type: bool + return _retval?true:false; +} + +void CefBrowserCToCpp::Reload() { + if (CEF_MEMBER_MISSING(struct_, reload)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->reload(struct_); +} + +void CefBrowserCToCpp::ReloadIgnoreCache() { + if (CEF_MEMBER_MISSING(struct_, reload_ignore_cache)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->reload_ignore_cache(struct_); +} + +void CefBrowserCToCpp::StopLoad() { + if (CEF_MEMBER_MISSING(struct_, stop_load)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->stop_load(struct_); +} + +int CefBrowserCToCpp::GetIdentifier() { + if (CEF_MEMBER_MISSING(struct_, get_identifier)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_identifier(struct_); + + // Return type: simple + return _retval; +} + +bool CefBrowserCToCpp::IsSame(CefRefPtr that) { + if (CEF_MEMBER_MISSING(struct_, is_same)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: that; type: refptr_same + DCHECK(that.get()); + if (!that.get()) + return false; + + // Execute + int _retval = struct_->is_same(struct_, + CefBrowserCToCpp::Unwrap(that)); + + // Return type: bool + return _retval?true:false; +} + +bool CefBrowserCToCpp::IsPopup() { + if (CEF_MEMBER_MISSING(struct_, is_popup)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_popup(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefBrowserCToCpp::HasDocument() { + if (CEF_MEMBER_MISSING(struct_, has_document)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->has_document(struct_); + + // Return type: bool + return _retval?true:false; +} + +CefRefPtr CefBrowserCToCpp::GetMainFrame() { + if (CEF_MEMBER_MISSING(struct_, get_main_frame)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_frame_t* _retval = struct_->get_main_frame(struct_); + + // Return type: refptr_same + return CefFrameCToCpp::Wrap(_retval); +} + +CefRefPtr CefBrowserCToCpp::GetFocusedFrame() { + if (CEF_MEMBER_MISSING(struct_, get_focused_frame)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_frame_t* _retval = struct_->get_focused_frame(struct_); + + // Return type: refptr_same + return CefFrameCToCpp::Wrap(_retval); +} + +CefRefPtr CefBrowserCToCpp::GetFrame(int64 identifier) { + if (CEF_MEMBER_MISSING(struct_, get_frame_byident)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_frame_t* _retval = struct_->get_frame_byident(struct_, + identifier); + + // Return type: refptr_same + return CefFrameCToCpp::Wrap(_retval); +} + +CefRefPtr CefBrowserCToCpp::GetFrame(const CefString& name) { + if (CEF_MEMBER_MISSING(struct_, get_frame)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: name; type: string_byref_const + DCHECK(!name.empty()); + if (name.empty()) + return NULL; + + // Execute + cef_frame_t* _retval = struct_->get_frame(struct_, + name.GetStruct()); + + // Return type: refptr_same + return CefFrameCToCpp::Wrap(_retval); +} + +size_t CefBrowserCToCpp::GetFrameCount() { + if (CEF_MEMBER_MISSING(struct_, get_frame_count)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + size_t _retval = struct_->get_frame_count(struct_); + + // Return type: simple + return _retval; +} + +void CefBrowserCToCpp::GetFrameIdentifiers(std::vector& identifiers) { + if (CEF_MEMBER_MISSING(struct_, get_frame_identifiers)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: identifiers; type: simple_vec_byref + size_t identifiersSize = identifiers.size(); + size_t identifiersCount = std::max(GetFrameCount(), identifiersSize); + int64* identifiersList = NULL; + if (identifiersCount > 0) { + identifiersList = new int64[identifiersCount]; + DCHECK(identifiersList); + if (identifiersList) { + memset(identifiersList, 0, sizeof(int64)*identifiersCount); + } + if (identifiersList && identifiersSize > 0) { + for (size_t i = 0; i < identifiersSize; ++i) { + identifiersList[i] = identifiers[i]; + } + } + } + + // Execute + struct_->get_frame_identifiers(struct_, + &identifiersCount, + identifiersList); + + // Restore param:identifiers; type: simple_vec_byref + identifiers.clear(); + if (identifiersCount > 0 && identifiersList) { + for (size_t i = 0; i < identifiersCount; ++i) { + identifiers.push_back(identifiersList[i]); + } + delete [] identifiersList; + } +} + +void CefBrowserCToCpp::GetFrameNames(std::vector& names) { + if (CEF_MEMBER_MISSING(struct_, get_frame_names)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: names; type: string_vec_byref + cef_string_list_t namesList = cef_string_list_alloc(); + DCHECK(namesList); + if (namesList) + transfer_string_list_contents(names, namesList); + + // Execute + struct_->get_frame_names(struct_, + namesList); + + // Restore param:names; type: string_vec_byref + if (namesList) { + names.clear(); + transfer_string_list_contents(namesList, names); + cef_string_list_free(namesList); + } +} + +bool CefBrowserCToCpp::SendProcessMessage(CefProcessId target_process, + CefRefPtr message) { + if (CEF_MEMBER_MISSING(struct_, send_process_message)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: message; type: refptr_same + DCHECK(message.get()); + if (!message.get()) + return false; + + // Execute + int _retval = struct_->send_process_message(struct_, + target_process, + CefProcessMessageCToCpp::Unwrap(message)); + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/browser_ctocpp.h b/cef3/libcef_dll/ctocpp/browser_ctocpp.h new file mode 100644 index 000000000..c836e74db --- /dev/null +++ b/cef3/libcef_dll/ctocpp/browser_ctocpp.h @@ -0,0 +1,64 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_BROWSER_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include +#include "include/cef_browser.h" +#include "include/capi/cef_browser_capi.h" +#include "include/cef_client.h" +#include "include/capi/cef_client_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefBrowserCToCpp + : public CefCToCpp { + public: + explicit CefBrowserCToCpp(cef_browser_t* str) + : CefCToCpp(str) {} + virtual ~CefBrowserCToCpp() {} + + // CefBrowser methods + virtual CefRefPtr GetHost() OVERRIDE; + virtual bool CanGoBack() OVERRIDE; + virtual void GoBack() OVERRIDE; + virtual bool CanGoForward() OVERRIDE; + virtual void GoForward() OVERRIDE; + virtual bool IsLoading() OVERRIDE; + virtual void Reload() OVERRIDE; + virtual void ReloadIgnoreCache() OVERRIDE; + virtual void StopLoad() OVERRIDE; + virtual int GetIdentifier() OVERRIDE; + virtual bool IsSame(CefRefPtr that) OVERRIDE; + virtual bool IsPopup() OVERRIDE; + virtual bool HasDocument() OVERRIDE; + virtual CefRefPtr GetMainFrame() OVERRIDE; + virtual CefRefPtr GetFocusedFrame() OVERRIDE; + virtual CefRefPtr GetFrame(int64 identifier) OVERRIDE; + virtual CefRefPtr GetFrame(const CefString& name) OVERRIDE; + virtual size_t GetFrameCount() OVERRIDE; + virtual void GetFrameIdentifiers(std::vector& identifiers) OVERRIDE; + virtual void GetFrameNames(std::vector& names) OVERRIDE; + virtual bool SendProcessMessage(CefProcessId target_process, + CefRefPtr message) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_BROWSER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/browser_host_ctocpp.cc b/cef3/libcef_dll/ctocpp/browser_host_ctocpp.cc new file mode 100644 index 000000000..021d3c8de --- /dev/null +++ b/cef3/libcef_dll/ctocpp/browser_host_ctocpp.cc @@ -0,0 +1,385 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/client_cpptoc.h" +#include "libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/browser_host_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// STATIC METHODS - Body may be edited by hand. + +bool CefBrowserHost::CreateBrowser(const CefWindowInfo& windowInfo, + CefRefPtr client, const CefString& url, + const CefBrowserSettings& settings) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: client, url + + // Execute + int _retval = cef_browser_host_create_browser( + &windowInfo, + CefClientCppToC::Wrap(client), + url.GetStruct(), + &settings); + + // Return type: bool + return _retval?true:false; +} + +CefRefPtr CefBrowserHost::CreateBrowserSync( + const CefWindowInfo& windowInfo, CefRefPtr client, + const CefString& url, const CefBrowserSettings& settings) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: client, url + + // Execute + cef_browser_t* _retval = cef_browser_host_create_browser_sync( + &windowInfo, + CefClientCppToC::Wrap(client), + url.GetStruct(), + &settings); + + // Return type: refptr_same + return CefBrowserCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +CefRefPtr CefBrowserHostCToCpp::GetBrowser() { + if (CEF_MEMBER_MISSING(struct_, get_browser)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_browser_t* _retval = struct_->get_browser(struct_); + + // Return type: refptr_same + return CefBrowserCToCpp::Wrap(_retval); +} + +void CefBrowserHostCToCpp::ParentWindowWillClose() { + if (CEF_MEMBER_MISSING(struct_, parent_window_will_close)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->parent_window_will_close(struct_); +} + +void CefBrowserHostCToCpp::CloseBrowser(bool force_close) { + if (CEF_MEMBER_MISSING(struct_, close_browser)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->close_browser(struct_, + force_close); +} + +void CefBrowserHostCToCpp::SetFocus(bool enable) { + if (CEF_MEMBER_MISSING(struct_, set_focus)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->set_focus(struct_, + enable); +} + +CefWindowHandle CefBrowserHostCToCpp::GetWindowHandle() { + if (CEF_MEMBER_MISSING(struct_, get_window_handle)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_window_handle_t _retval = struct_->get_window_handle(struct_); + + // Return type: simple + return _retval; +} + +CefWindowHandle CefBrowserHostCToCpp::GetOpenerWindowHandle() { + if (CEF_MEMBER_MISSING(struct_, get_opener_window_handle)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_window_handle_t _retval = struct_->get_opener_window_handle(struct_); + + // Return type: simple + return _retval; +} + +CefRefPtr CefBrowserHostCToCpp::GetClient() { + if (CEF_MEMBER_MISSING(struct_, get_client)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_client_t* _retval = struct_->get_client(struct_); + + // Return type: refptr_diff + return CefClientCppToC::Unwrap(_retval); +} + +CefString CefBrowserHostCToCpp::GetDevToolsURL(bool http_scheme) { + if (CEF_MEMBER_MISSING(struct_, get_dev_tools_url)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_dev_tools_url(struct_, + http_scheme); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +double CefBrowserHostCToCpp::GetZoomLevel() { + if (CEF_MEMBER_MISSING(struct_, get_zoom_level)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + double _retval = struct_->get_zoom_level(struct_); + + // Return type: simple + return _retval; +} + +void CefBrowserHostCToCpp::SetZoomLevel(double zoomLevel) { + if (CEF_MEMBER_MISSING(struct_, set_zoom_level)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->set_zoom_level(struct_, + zoomLevel); +} + +void CefBrowserHostCToCpp::RunFileDialog(FileDialogMode mode, + const CefString& title, const CefString& default_file_name, + const std::vector& accept_types, + CefRefPtr callback) { + if (CEF_MEMBER_MISSING(struct_, run_file_dialog)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: callback; type: refptr_diff + DCHECK(callback.get()); + if (!callback.get()) + return; + // Unverified params: title, default_file_name, accept_types + + // Translate param: accept_types; type: string_vec_byref_const + cef_string_list_t accept_typesList = cef_string_list_alloc(); + DCHECK(accept_typesList); + if (accept_typesList) + transfer_string_list_contents(accept_types, accept_typesList); + + // Execute + struct_->run_file_dialog(struct_, + mode, + title.GetStruct(), + default_file_name.GetStruct(), + accept_typesList, + CefRunFileDialogCallbackCppToC::Wrap(callback)); + + // Restore param:accept_types; type: string_vec_byref_const + if (accept_typesList) + cef_string_list_free(accept_typesList); +} + +void CefBrowserHostCToCpp::StartDownload(const CefString& url) { + if (CEF_MEMBER_MISSING(struct_, start_download)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: url; type: string_byref_const + DCHECK(!url.empty()); + if (url.empty()) + return; + + // Execute + struct_->start_download(struct_, + url.GetStruct()); +} + +void CefBrowserHostCToCpp::SetMouseCursorChangeDisabled(bool disabled) { + if (CEF_MEMBER_MISSING(struct_, set_mouse_cursor_change_disabled)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->set_mouse_cursor_change_disabled(struct_, + disabled); +} + +bool CefBrowserHostCToCpp::IsMouseCursorChangeDisabled() { + if (CEF_MEMBER_MISSING(struct_, is_mouse_cursor_change_disabled)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_mouse_cursor_change_disabled(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefBrowserHostCToCpp::IsWindowRenderingDisabled() { + if (CEF_MEMBER_MISSING(struct_, is_window_rendering_disabled)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_window_rendering_disabled(struct_); + + // Return type: bool + return _retval?true:false; +} + +void CefBrowserHostCToCpp::WasResized() { + if (CEF_MEMBER_MISSING(struct_, was_resized)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->was_resized(struct_); +} + +void CefBrowserHostCToCpp::WasHidden(bool hidden) { + if (CEF_MEMBER_MISSING(struct_, was_hidden)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->was_hidden(struct_, + hidden); +} + +void CefBrowserHostCToCpp::Invalidate(const CefRect& dirtyRect, + PaintElementType type) { + if (CEF_MEMBER_MISSING(struct_, invalidate)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->invalidate(struct_, + &dirtyRect, + type); +} + +void CefBrowserHostCToCpp::SendKeyEvent(const CefKeyEvent& event) { + if (CEF_MEMBER_MISSING(struct_, send_key_event)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->send_key_event(struct_, + &event); +} + +void CefBrowserHostCToCpp::SendMouseClickEvent(const CefMouseEvent& event, + MouseButtonType type, bool mouseUp, int clickCount) { + if (CEF_MEMBER_MISSING(struct_, send_mouse_click_event)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->send_mouse_click_event(struct_, + &event, + type, + mouseUp, + clickCount); +} + +void CefBrowserHostCToCpp::SendMouseMoveEvent(const CefMouseEvent& event, + bool mouseLeave) { + if (CEF_MEMBER_MISSING(struct_, send_mouse_move_event)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->send_mouse_move_event(struct_, + &event, + mouseLeave); +} + +void CefBrowserHostCToCpp::SendMouseWheelEvent(const CefMouseEvent& event, + int deltaX, int deltaY) { + if (CEF_MEMBER_MISSING(struct_, send_mouse_wheel_event)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->send_mouse_wheel_event(struct_, + &event, + deltaX, + deltaY); +} + +void CefBrowserHostCToCpp::SendFocusEvent(bool setFocus) { + if (CEF_MEMBER_MISSING(struct_, send_focus_event)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->send_focus_event(struct_, + setFocus); +} + +void CefBrowserHostCToCpp::SendCaptureLostEvent() { + if (CEF_MEMBER_MISSING(struct_, send_capture_lost_event)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->send_capture_lost_event(struct_); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/browser_host_ctocpp.h b/cef3/libcef_dll/ctocpp/browser_host_ctocpp.h new file mode 100644 index 000000000..3cd89bdf1 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/browser_host_ctocpp.h @@ -0,0 +1,75 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_HOST_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_BROWSER_HOST_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include +#include "include/cef_browser.h" +#include "include/capi/cef_browser_capi.h" +#include "include/cef_client.h" +#include "include/capi/cef_client_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefBrowserHostCToCpp + : public CefCToCpp { + public: + explicit CefBrowserHostCToCpp(cef_browser_host_t* str) + : CefCToCpp( + str) {} + virtual ~CefBrowserHostCToCpp() {} + + // CefBrowserHost methods + virtual CefRefPtr GetBrowser() OVERRIDE; + virtual void ParentWindowWillClose() OVERRIDE; + virtual void CloseBrowser(bool force_close) OVERRIDE; + virtual void SetFocus(bool enable) OVERRIDE; + virtual CefWindowHandle GetWindowHandle() OVERRIDE; + virtual CefWindowHandle GetOpenerWindowHandle() OVERRIDE; + virtual CefRefPtr GetClient() OVERRIDE; + virtual CefString GetDevToolsURL(bool http_scheme) OVERRIDE; + virtual double GetZoomLevel() OVERRIDE; + virtual void SetZoomLevel(double zoomLevel) OVERRIDE; + virtual void RunFileDialog(FileDialogMode mode, const CefString& title, + const CefString& default_file_name, + const std::vector& accept_types, + CefRefPtr callback) OVERRIDE; + virtual void StartDownload(const CefString& url) OVERRIDE; + virtual void SetMouseCursorChangeDisabled(bool disabled) OVERRIDE; + virtual bool IsMouseCursorChangeDisabled() OVERRIDE; + virtual bool IsWindowRenderingDisabled() OVERRIDE; + virtual void WasResized() OVERRIDE; + virtual void WasHidden(bool hidden) OVERRIDE; + virtual void Invalidate(const CefRect& dirtyRect, + PaintElementType type) OVERRIDE; + virtual void SendKeyEvent(const CefKeyEvent& event) OVERRIDE; + virtual void SendMouseClickEvent(const CefMouseEvent& event, + MouseButtonType type, bool mouseUp, int clickCount) OVERRIDE; + virtual void SendMouseMoveEvent(const CefMouseEvent& event, + bool mouseLeave) OVERRIDE; + virtual void SendMouseWheelEvent(const CefMouseEvent& event, int deltaX, + int deltaY) OVERRIDE; + virtual void SendFocusEvent(bool setFocus) OVERRIDE; + virtual void SendCaptureLostEvent() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_BROWSER_HOST_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/browser_process_handler_ctocpp.cc b/cef3/libcef_dll/ctocpp/browser_process_handler_ctocpp.cc new file mode 100644 index 000000000..fe5d45d96 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/browser_process_handler_ctocpp.cc @@ -0,0 +1,69 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/command_line_cpptoc.h" +#include "libcef_dll/cpptoc/list_value_cpptoc.h" +#include "libcef_dll/ctocpp/browser_process_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefBrowserProcessHandlerCToCpp::OnContextInitialized() { + if (CEF_MEMBER_MISSING(struct_, on_context_initialized)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->on_context_initialized(struct_); +} + +void CefBrowserProcessHandlerCToCpp::OnBeforeChildProcessLaunch( + CefRefPtr command_line) { + if (CEF_MEMBER_MISSING(struct_, on_before_child_process_launch)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: command_line; type: refptr_diff + DCHECK(command_line.get()); + if (!command_line.get()) + return; + + // Execute + struct_->on_before_child_process_launch(struct_, + CefCommandLineCppToC::Wrap(command_line)); +} + +void CefBrowserProcessHandlerCToCpp::OnRenderProcessThreadCreated( + CefRefPtr extra_info) { + if (CEF_MEMBER_MISSING(struct_, on_render_process_thread_created)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: extra_info; type: refptr_diff + DCHECK(extra_info.get()); + if (!extra_info.get()) + return; + + // Execute + struct_->on_render_process_thread_created(struct_, + CefListValueCppToC::Wrap(extra_info)); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/browser_process_handler_ctocpp.h b/cef3/libcef_dll/ctocpp/browser_process_handler_ctocpp.h new file mode 100644 index 000000000..98cff43a5 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/browser_process_handler_ctocpp.h @@ -0,0 +1,46 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_PROCESS_HANDLER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_BROWSER_PROCESS_HANDLER_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_browser_process_handler.h" +#include "include/capi/cef_browser_process_handler_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefBrowserProcessHandlerCToCpp + : public CefCToCpp { + public: + explicit CefBrowserProcessHandlerCToCpp(cef_browser_process_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefBrowserProcessHandlerCToCpp() {} + + // CefBrowserProcessHandler methods + virtual void OnContextInitialized() OVERRIDE; + virtual void OnBeforeChildProcessLaunch( + CefRefPtr command_line) OVERRIDE; + virtual void OnRenderProcessThreadCreated( + CefRefPtr extra_info) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_BROWSER_PROCESS_HANDLER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/callback_ctocpp.cc b/cef3/libcef_dll/ctocpp/callback_ctocpp.cc new file mode 100644 index 000000000..e6cd4799e --- /dev/null +++ b/cef3/libcef_dll/ctocpp/callback_ctocpp.cc @@ -0,0 +1,43 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/callback_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefCallbackCToCpp::Continue() { + if (CEF_MEMBER_MISSING(struct_, cont)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->cont(struct_); +} + +void CefCallbackCToCpp::Cancel() { + if (CEF_MEMBER_MISSING(struct_, cancel)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->cancel(struct_); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/callback_ctocpp.h b/cef3/libcef_dll/ctocpp/callback_ctocpp.h new file mode 100644 index 000000000..9cbe99593 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/callback_ctocpp.h @@ -0,0 +1,41 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_CALLBACK_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_CALLBACK_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_callback.h" +#include "include/capi/cef_callback_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefCallbackCToCpp + : public CefCToCpp { + public: + explicit CefCallbackCToCpp(cef_callback_t* str) + : CefCToCpp(str) {} + virtual ~CefCallbackCToCpp() {} + + // CefCallback methods + virtual void Continue() OVERRIDE; + virtual void Cancel() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_CALLBACK_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/client_ctocpp.cc b/cef3/libcef_dll/ctocpp/client_ctocpp.cc new file mode 100644 index 000000000..5cbfcc0b8 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/client_ctocpp.cc @@ -0,0 +1,221 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/cpptoc/process_message_cpptoc.h" +#include "libcef_dll/ctocpp/client_ctocpp.h" +#include "libcef_dll/ctocpp/context_menu_handler_ctocpp.h" +#include "libcef_dll/ctocpp/dialog_handler_ctocpp.h" +#include "libcef_dll/ctocpp/display_handler_ctocpp.h" +#include "libcef_dll/ctocpp/download_handler_ctocpp.h" +#include "libcef_dll/ctocpp/focus_handler_ctocpp.h" +#include "libcef_dll/ctocpp/geolocation_handler_ctocpp.h" +#include "libcef_dll/ctocpp/jsdialog_handler_ctocpp.h" +#include "libcef_dll/ctocpp/keyboard_handler_ctocpp.h" +#include "libcef_dll/ctocpp/life_span_handler_ctocpp.h" +#include "libcef_dll/ctocpp/load_handler_ctocpp.h" +#include "libcef_dll/ctocpp/render_handler_ctocpp.h" +#include "libcef_dll/ctocpp/request_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +CefRefPtr CefClientCToCpp::GetContextMenuHandler() { + if (CEF_MEMBER_MISSING(struct_, get_context_menu_handler)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_context_menu_handler_t* _retval = struct_->get_context_menu_handler( + struct_); + + // Return type: refptr_same + return CefContextMenuHandlerCToCpp::Wrap(_retval); +} + +CefRefPtr CefClientCToCpp::GetDialogHandler() { + if (CEF_MEMBER_MISSING(struct_, get_dialog_handler)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_dialog_handler_t* _retval = struct_->get_dialog_handler(struct_); + + // Return type: refptr_same + return CefDialogHandlerCToCpp::Wrap(_retval); +} + +CefRefPtr CefClientCToCpp::GetDisplayHandler() { + if (CEF_MEMBER_MISSING(struct_, get_display_handler)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_display_handler_t* _retval = struct_->get_display_handler(struct_); + + // Return type: refptr_same + return CefDisplayHandlerCToCpp::Wrap(_retval); +} + +CefRefPtr CefClientCToCpp::GetDownloadHandler() { + if (CEF_MEMBER_MISSING(struct_, get_download_handler)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_download_handler_t* _retval = struct_->get_download_handler(struct_); + + // Return type: refptr_same + return CefDownloadHandlerCToCpp::Wrap(_retval); +} + +CefRefPtr CefClientCToCpp::GetFocusHandler() { + if (CEF_MEMBER_MISSING(struct_, get_focus_handler)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_focus_handler_t* _retval = struct_->get_focus_handler(struct_); + + // Return type: refptr_same + return CefFocusHandlerCToCpp::Wrap(_retval); +} + +CefRefPtr CefClientCToCpp::GetGeolocationHandler() { + if (CEF_MEMBER_MISSING(struct_, get_geolocation_handler)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_geolocation_handler_t* _retval = struct_->get_geolocation_handler( + struct_); + + // Return type: refptr_same + return CefGeolocationHandlerCToCpp::Wrap(_retval); +} + +CefRefPtr CefClientCToCpp::GetJSDialogHandler() { + if (CEF_MEMBER_MISSING(struct_, get_jsdialog_handler)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_jsdialog_handler_t* _retval = struct_->get_jsdialog_handler(struct_); + + // Return type: refptr_same + return CefJSDialogHandlerCToCpp::Wrap(_retval); +} + +CefRefPtr CefClientCToCpp::GetKeyboardHandler() { + if (CEF_MEMBER_MISSING(struct_, get_keyboard_handler)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_keyboard_handler_t* _retval = struct_->get_keyboard_handler(struct_); + + // Return type: refptr_same + return CefKeyboardHandlerCToCpp::Wrap(_retval); +} + +CefRefPtr CefClientCToCpp::GetLifeSpanHandler() { + if (CEF_MEMBER_MISSING(struct_, get_life_span_handler)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_life_span_handler_t* _retval = struct_->get_life_span_handler(struct_); + + // Return type: refptr_same + return CefLifeSpanHandlerCToCpp::Wrap(_retval); +} + +CefRefPtr CefClientCToCpp::GetLoadHandler() { + if (CEF_MEMBER_MISSING(struct_, get_load_handler)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_load_handler_t* _retval = struct_->get_load_handler(struct_); + + // Return type: refptr_same + return CefLoadHandlerCToCpp::Wrap(_retval); +} + +CefRefPtr CefClientCToCpp::GetRenderHandler() { + if (CEF_MEMBER_MISSING(struct_, get_render_handler)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_render_handler_t* _retval = struct_->get_render_handler(struct_); + + // Return type: refptr_same + return CefRenderHandlerCToCpp::Wrap(_retval); +} + +CefRefPtr CefClientCToCpp::GetRequestHandler() { + if (CEF_MEMBER_MISSING(struct_, get_request_handler)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_request_handler_t* _retval = struct_->get_request_handler(struct_); + + // Return type: refptr_same + return CefRequestHandlerCToCpp::Wrap(_retval); +} + +bool CefClientCToCpp::OnProcessMessageReceived(CefRefPtr browser, + CefProcessId source_process, CefRefPtr message) { + if (CEF_MEMBER_MISSING(struct_, on_process_message_received)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + // Verify param: message; type: refptr_diff + DCHECK(message.get()); + if (!message.get()) + return false; + + // Execute + int _retval = struct_->on_process_message_received(struct_, + CefBrowserCppToC::Wrap(browser), + source_process, + CefProcessMessageCppToC::Wrap(message)); + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/client_ctocpp.h b/cef3/libcef_dll/ctocpp/client_ctocpp.h new file mode 100644 index 000000000..bf2f4c36f --- /dev/null +++ b/cef3/libcef_dll/ctocpp/client_ctocpp.h @@ -0,0 +1,54 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_CLIENT_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_CLIENT_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_client.h" +#include "include/capi/cef_client_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefClientCToCpp + : public CefCToCpp { + public: + explicit CefClientCToCpp(cef_client_t* str) + : CefCToCpp(str) {} + virtual ~CefClientCToCpp() {} + + // CefClient methods + virtual CefRefPtr GetContextMenuHandler() OVERRIDE; + virtual CefRefPtr GetDialogHandler() OVERRIDE; + virtual CefRefPtr GetDisplayHandler() OVERRIDE; + virtual CefRefPtr GetDownloadHandler() OVERRIDE; + virtual CefRefPtr GetFocusHandler() OVERRIDE; + virtual CefRefPtr GetGeolocationHandler() OVERRIDE; + virtual CefRefPtr GetJSDialogHandler() OVERRIDE; + virtual CefRefPtr GetKeyboardHandler() OVERRIDE; + virtual CefRefPtr GetLifeSpanHandler() OVERRIDE; + virtual CefRefPtr GetLoadHandler() OVERRIDE; + virtual CefRefPtr GetRenderHandler() OVERRIDE; + virtual CefRefPtr GetRequestHandler() OVERRIDE; + virtual bool OnProcessMessageReceived(CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_CLIENT_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/command_line_ctocpp.cc b/cef3/libcef_dll/ctocpp/command_line_ctocpp.cc new file mode 100644 index 000000000..88a92e2b7 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/command_line_ctocpp.cc @@ -0,0 +1,398 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "include/cef_version.h" +#include "libcef_dll/ctocpp/command_line_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefCommandLine::CreateCommandLine() { + const char* api_hash = cef_api_hash(0); + if (strcmp(api_hash, CEF_API_HASH_PLATFORM)) { + // The libcef API hash does not match the current header API hash. + DCHECK(false); + return NULL; + } + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_command_line_t* _retval = cef_command_line_create(); + + // Return type: refptr_same + return CefCommandLineCToCpp::Wrap(_retval); +} + +CefRefPtr CefCommandLine::GetGlobalCommandLine() { + const char* api_hash = cef_api_hash(0); + if (strcmp(api_hash, CEF_API_HASH_PLATFORM)) { + // The libcef API hash does not match the current header API hash. + DCHECK(false); + return NULL; + } + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_command_line_t* _retval = cef_command_line_get_global(); + + // Return type: refptr_same + return CefCommandLineCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefCommandLineCToCpp::IsValid() { + if (CEF_MEMBER_MISSING(struct_, is_valid)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_valid(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefCommandLineCToCpp::IsReadOnly() { + if (CEF_MEMBER_MISSING(struct_, is_read_only)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_read_only(struct_); + + // Return type: bool + return _retval?true:false; +} + +CefRefPtr CefCommandLineCToCpp::Copy() { + if (CEF_MEMBER_MISSING(struct_, copy)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_command_line_t* _retval = struct_->copy(struct_); + + // Return type: refptr_same + return CefCommandLineCToCpp::Wrap(_retval); +} + +void CefCommandLineCToCpp::InitFromArgv(int argc, const char* const* argv) { + if (CEF_MEMBER_MISSING(struct_, init_from_argv)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: argv; type: simple_byaddr + DCHECK(argv); + if (!argv) + return; + + // Execute + struct_->init_from_argv(struct_, + argc, + argv); +} + +void CefCommandLineCToCpp::InitFromString(const CefString& command_line) { + if (CEF_MEMBER_MISSING(struct_, init_from_string)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: command_line; type: string_byref_const + DCHECK(!command_line.empty()); + if (command_line.empty()) + return; + + // Execute + struct_->init_from_string(struct_, + command_line.GetStruct()); +} + +void CefCommandLineCToCpp::Reset() { + if (CEF_MEMBER_MISSING(struct_, reset)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->reset(struct_); +} + +void CefCommandLineCToCpp::GetArgv(std::vector& argv) { + if (CEF_MEMBER_MISSING(struct_, get_argv)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: argv; type: string_vec_byref + cef_string_list_t argvList = cef_string_list_alloc(); + DCHECK(argvList); + if (argvList) + transfer_string_list_contents(argv, argvList); + + // Execute + struct_->get_argv(struct_, + argvList); + + // Restore param:argv; type: string_vec_byref + if (argvList) { + argv.clear(); + transfer_string_list_contents(argvList, argv); + cef_string_list_free(argvList); + } +} + +CefString CefCommandLineCToCpp::GetCommandLineString() { + if (CEF_MEMBER_MISSING(struct_, get_command_line_string)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_command_line_string(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefCommandLineCToCpp::GetProgram() { + if (CEF_MEMBER_MISSING(struct_, get_program)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_program(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +void CefCommandLineCToCpp::SetProgram(const CefString& program) { + if (CEF_MEMBER_MISSING(struct_, set_program)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: program; type: string_byref_const + DCHECK(!program.empty()); + if (program.empty()) + return; + + // Execute + struct_->set_program(struct_, + program.GetStruct()); +} + +bool CefCommandLineCToCpp::HasSwitches() { + if (CEF_MEMBER_MISSING(struct_, has_switches)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->has_switches(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefCommandLineCToCpp::HasSwitch(const CefString& name) { + if (CEF_MEMBER_MISSING(struct_, has_switch)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: name; type: string_byref_const + DCHECK(!name.empty()); + if (name.empty()) + return false; + + // Execute + int _retval = struct_->has_switch(struct_, + name.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + +CefString CefCommandLineCToCpp::GetSwitchValue(const CefString& name) { + if (CEF_MEMBER_MISSING(struct_, get_switch_value)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: name; type: string_byref_const + DCHECK(!name.empty()); + if (name.empty()) + return CefString(); + + // Execute + cef_string_userfree_t _retval = struct_->get_switch_value(struct_, + name.GetStruct()); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +void CefCommandLineCToCpp::GetSwitches(SwitchMap& switches) { + if (CEF_MEMBER_MISSING(struct_, get_switches)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: switches; type: string_map_single_byref + cef_string_map_t switchesMap = cef_string_map_alloc(); + DCHECK(switchesMap); + if (switchesMap) + transfer_string_map_contents(switches, switchesMap); + + // Execute + struct_->get_switches(struct_, + switchesMap); + + // Restore param:switches; type: string_map_single_byref + if (switchesMap) { + switches.clear(); + transfer_string_map_contents(switchesMap, switches); + cef_string_map_free(switchesMap); + } +} + +void CefCommandLineCToCpp::AppendSwitch(const CefString& name) { + if (CEF_MEMBER_MISSING(struct_, append_switch)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: name; type: string_byref_const + DCHECK(!name.empty()); + if (name.empty()) + return; + + // Execute + struct_->append_switch(struct_, + name.GetStruct()); +} + +void CefCommandLineCToCpp::AppendSwitchWithValue(const CefString& name, + const CefString& value) { + if (CEF_MEMBER_MISSING(struct_, append_switch_with_value)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: name; type: string_byref_const + DCHECK(!name.empty()); + if (name.empty()) + return; + // Verify param: value; type: string_byref_const + DCHECK(!value.empty()); + if (value.empty()) + return; + + // Execute + struct_->append_switch_with_value(struct_, + name.GetStruct(), + value.GetStruct()); +} + +bool CefCommandLineCToCpp::HasArguments() { + if (CEF_MEMBER_MISSING(struct_, has_arguments)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->has_arguments(struct_); + + // Return type: bool + return _retval?true:false; +} + +void CefCommandLineCToCpp::GetArguments(ArgumentList& arguments) { + if (CEF_MEMBER_MISSING(struct_, get_arguments)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: arguments; type: string_vec_byref + cef_string_list_t argumentsList = cef_string_list_alloc(); + DCHECK(argumentsList); + if (argumentsList) + transfer_string_list_contents(arguments, argumentsList); + + // Execute + struct_->get_arguments(struct_, + argumentsList); + + // Restore param:arguments; type: string_vec_byref + if (argumentsList) { + arguments.clear(); + transfer_string_list_contents(argumentsList, arguments); + cef_string_list_free(argumentsList); + } +} + +void CefCommandLineCToCpp::AppendArgument(const CefString& argument) { + if (CEF_MEMBER_MISSING(struct_, append_argument)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: argument; type: string_byref_const + DCHECK(!argument.empty()); + if (argument.empty()) + return; + + // Execute + struct_->append_argument(struct_, + argument.GetStruct()); +} + +void CefCommandLineCToCpp::PrependWrapper(const CefString& wrapper) { + if (CEF_MEMBER_MISSING(struct_, prepend_wrapper)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: wrapper; type: string_byref_const + DCHECK(!wrapper.empty()); + if (wrapper.empty()) + return; + + // Execute + struct_->prepend_wrapper(struct_, + wrapper.GetStruct()); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/command_line_ctocpp.h b/cef3/libcef_dll/ctocpp/command_line_ctocpp.h new file mode 100644 index 000000000..723885683 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/command_line_ctocpp.h @@ -0,0 +1,63 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_COMMAND_LINE_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_COMMAND_LINE_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include +#include "include/cef_command_line.h" +#include "include/capi/cef_command_line_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefCommandLineCToCpp + : public CefCToCpp { + public: + explicit CefCommandLineCToCpp(cef_command_line_t* str) + : CefCToCpp( + str) {} + virtual ~CefCommandLineCToCpp() {} + + // CefCommandLine methods + virtual bool IsValid() OVERRIDE; + virtual bool IsReadOnly() OVERRIDE; + virtual CefRefPtr Copy() OVERRIDE; + virtual void InitFromArgv(int argc, const char* const* argv) OVERRIDE; + virtual void InitFromString(const CefString& command_line) OVERRIDE; + virtual void Reset() OVERRIDE; + virtual void GetArgv(std::vector& argv) OVERRIDE; + virtual CefString GetCommandLineString() OVERRIDE; + virtual CefString GetProgram() OVERRIDE; + virtual void SetProgram(const CefString& program) OVERRIDE; + virtual bool HasSwitches() OVERRIDE; + virtual bool HasSwitch(const CefString& name) OVERRIDE; + virtual CefString GetSwitchValue(const CefString& name) OVERRIDE; + virtual void GetSwitches(SwitchMap& switches) OVERRIDE; + virtual void AppendSwitch(const CefString& name) OVERRIDE; + virtual void AppendSwitchWithValue(const CefString& name, + const CefString& value) OVERRIDE; + virtual bool HasArguments() OVERRIDE; + virtual void GetArguments(ArgumentList& arguments) OVERRIDE; + virtual void AppendArgument(const CefString& argument) OVERRIDE; + virtual void PrependWrapper(const CefString& wrapper) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_COMMAND_LINE_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/completion_handler_ctocpp.cc b/cef3/libcef_dll/ctocpp/completion_handler_ctocpp.cc new file mode 100644 index 000000000..e5964a8d7 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/completion_handler_ctocpp.cc @@ -0,0 +1,33 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/completion_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefCompletionHandlerCToCpp::OnComplete() { + if (CEF_MEMBER_MISSING(struct_, on_complete)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->on_complete(struct_); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/completion_handler_ctocpp.h b/cef3/libcef_dll/ctocpp/completion_handler_ctocpp.h new file mode 100644 index 000000000..b744ce6c9 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/completion_handler_ctocpp.h @@ -0,0 +1,42 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_COMPLETION_HANDLER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_COMPLETION_HANDLER_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_callback.h" +#include "include/capi/cef_callback_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefCompletionHandlerCToCpp + : public CefCToCpp { + public: + explicit CefCompletionHandlerCToCpp(cef_completion_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefCompletionHandlerCToCpp() {} + + // CefCompletionHandler methods + virtual void OnComplete() OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_COMPLETION_HANDLER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/context_menu_handler_ctocpp.cc b/cef3/libcef_dll/ctocpp/context_menu_handler_ctocpp.cc new file mode 100644 index 000000000..a2a9929e6 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/context_menu_handler_ctocpp.cc @@ -0,0 +1,116 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/cpptoc/context_menu_params_cpptoc.h" +#include "libcef_dll/cpptoc/frame_cpptoc.h" +#include "libcef_dll/cpptoc/menu_model_cpptoc.h" +#include "libcef_dll/ctocpp/context_menu_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefContextMenuHandlerCToCpp::OnBeforeContextMenu( + CefRefPtr browser, CefRefPtr frame, + CefRefPtr params, CefRefPtr model) { + if (CEF_MEMBER_MISSING(struct_, on_before_context_menu)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame.get()); + if (!frame.get()) + return; + // Verify param: params; type: refptr_diff + DCHECK(params.get()); + if (!params.get()) + return; + // Verify param: model; type: refptr_diff + DCHECK(model.get()); + if (!model.get()) + return; + + // Execute + struct_->on_before_context_menu(struct_, + CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), + CefContextMenuParamsCppToC::Wrap(params), + CefMenuModelCppToC::Wrap(model)); +} + +bool CefContextMenuHandlerCToCpp::OnContextMenuCommand( + CefRefPtr browser, CefRefPtr frame, + CefRefPtr params, int command_id, + EventFlags event_flags) { + if (CEF_MEMBER_MISSING(struct_, on_context_menu_command)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + // Verify param: frame; type: refptr_diff + DCHECK(frame.get()); + if (!frame.get()) + return false; + // Verify param: params; type: refptr_diff + DCHECK(params.get()); + if (!params.get()) + return false; + + // Execute + int _retval = struct_->on_context_menu_command(struct_, + CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), + CefContextMenuParamsCppToC::Wrap(params), + command_id, + event_flags); + + // Return type: bool + return _retval?true:false; +} + +void CefContextMenuHandlerCToCpp::OnContextMenuDismissed( + CefRefPtr browser, CefRefPtr frame) { + if (CEF_MEMBER_MISSING(struct_, on_context_menu_dismissed)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame.get()); + if (!frame.get()) + return; + + // Execute + struct_->on_context_menu_dismissed(struct_, + CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame)); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/context_menu_handler_ctocpp.h b/cef3/libcef_dll/ctocpp/context_menu_handler_ctocpp.h new file mode 100644 index 000000000..d828ffc71 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/context_menu_handler_ctocpp.h @@ -0,0 +1,49 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_CONTEXT_MENU_HANDLER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_CONTEXT_MENU_HANDLER_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_context_menu_handler.h" +#include "include/capi/cef_context_menu_handler_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefContextMenuHandlerCToCpp + : public CefCToCpp { + public: + explicit CefContextMenuHandlerCToCpp(cef_context_menu_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefContextMenuHandlerCToCpp() {} + + // CefContextMenuHandler methods + virtual void OnBeforeContextMenu(CefRefPtr browser, + CefRefPtr frame, CefRefPtr params, + CefRefPtr model) OVERRIDE; + virtual bool OnContextMenuCommand(CefRefPtr browser, + CefRefPtr frame, CefRefPtr params, + int command_id, EventFlags event_flags) OVERRIDE; + virtual void OnContextMenuDismissed(CefRefPtr browser, + CefRefPtr frame) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_CONTEXT_MENU_HANDLER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/context_menu_params_ctocpp.cc b/cef3/libcef_dll/ctocpp/context_menu_params_ctocpp.cc new file mode 100644 index 000000000..5fcbf3b47 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/context_menu_params_ctocpp.cc @@ -0,0 +1,249 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/context_menu_params_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +int CefContextMenuParamsCToCpp::GetXCoord() { + if (CEF_MEMBER_MISSING(struct_, get_xcoord)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_xcoord(struct_); + + // Return type: simple + return _retval; +} + +int CefContextMenuParamsCToCpp::GetYCoord() { + if (CEF_MEMBER_MISSING(struct_, get_ycoord)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_ycoord(struct_); + + // Return type: simple + return _retval; +} + +CefContextMenuParams::TypeFlags CefContextMenuParamsCToCpp::GetTypeFlags() { + if (CEF_MEMBER_MISSING(struct_, get_type_flags)) + return CM_TYPEFLAG_NONE; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_context_menu_type_flags_t _retval = struct_->get_type_flags(struct_); + + // Return type: simple + return _retval; +} + +CefString CefContextMenuParamsCToCpp::GetLinkUrl() { + if (CEF_MEMBER_MISSING(struct_, get_link_url)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_link_url(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefContextMenuParamsCToCpp::GetUnfilteredLinkUrl() { + if (CEF_MEMBER_MISSING(struct_, get_unfiltered_link_url)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_unfiltered_link_url(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefContextMenuParamsCToCpp::GetSourceUrl() { + if (CEF_MEMBER_MISSING(struct_, get_source_url)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_source_url(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +bool CefContextMenuParamsCToCpp::IsImageBlocked() { + if (CEF_MEMBER_MISSING(struct_, is_image_blocked)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_image_blocked(struct_); + + // Return type: bool + return _retval?true:false; +} + +CefString CefContextMenuParamsCToCpp::GetPageUrl() { + if (CEF_MEMBER_MISSING(struct_, get_page_url)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_page_url(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefContextMenuParamsCToCpp::GetFrameUrl() { + if (CEF_MEMBER_MISSING(struct_, get_frame_url)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_frame_url(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefContextMenuParamsCToCpp::GetFrameCharset() { + if (CEF_MEMBER_MISSING(struct_, get_frame_charset)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_frame_charset(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefContextMenuParams::MediaType CefContextMenuParamsCToCpp::GetMediaType() { + if (CEF_MEMBER_MISSING(struct_, get_media_type)) + return CM_MEDIATYPE_NONE; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_context_menu_media_type_t _retval = struct_->get_media_type(struct_); + + // Return type: simple + return _retval; +} + +CefContextMenuParams::MediaStateFlags CefContextMenuParamsCToCpp::GetMediaStateFlags( + ) { + if (CEF_MEMBER_MISSING(struct_, get_media_state_flags)) + return CM_MEDIAFLAG_NONE; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_context_menu_media_state_flags_t _retval = struct_->get_media_state_flags( + struct_); + + // Return type: simple + return _retval; +} + +CefString CefContextMenuParamsCToCpp::GetSelectionText() { + if (CEF_MEMBER_MISSING(struct_, get_selection_text)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_selection_text(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +bool CefContextMenuParamsCToCpp::IsEditable() { + if (CEF_MEMBER_MISSING(struct_, is_editable)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_editable(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefContextMenuParamsCToCpp::IsSpeechInputEnabled() { + if (CEF_MEMBER_MISSING(struct_, is_speech_input_enabled)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_speech_input_enabled(struct_); + + // Return type: bool + return _retval?true:false; +} + +CefContextMenuParams::EditStateFlags CefContextMenuParamsCToCpp::GetEditStateFlags( + ) { + if (CEF_MEMBER_MISSING(struct_, get_edit_state_flags)) + return CM_EDITFLAG_NONE; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_context_menu_edit_state_flags_t _retval = struct_->get_edit_state_flags( + struct_); + + // Return type: simple + return _retval; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/context_menu_params_ctocpp.h b/cef3/libcef_dll/ctocpp/context_menu_params_ctocpp.h new file mode 100644 index 000000000..bcbebc9b5 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/context_menu_params_ctocpp.h @@ -0,0 +1,57 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_CONTEXT_MENU_PARAMS_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_CONTEXT_MENU_PARAMS_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_context_menu_handler.h" +#include "include/capi/cef_context_menu_handler_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefContextMenuParamsCToCpp + : public CefCToCpp { + public: + explicit CefContextMenuParamsCToCpp(cef_context_menu_params_t* str) + : CefCToCpp(str) {} + virtual ~CefContextMenuParamsCToCpp() {} + + // CefContextMenuParams methods + virtual int GetXCoord() OVERRIDE; + virtual int GetYCoord() OVERRIDE; + virtual TypeFlags GetTypeFlags() OVERRIDE; + virtual CefString GetLinkUrl() OVERRIDE; + virtual CefString GetUnfilteredLinkUrl() OVERRIDE; + virtual CefString GetSourceUrl() OVERRIDE; + virtual bool IsImageBlocked() OVERRIDE; + virtual CefString GetPageUrl() OVERRIDE; + virtual CefString GetFrameUrl() OVERRIDE; + virtual CefString GetFrameCharset() OVERRIDE; + virtual MediaType GetMediaType() OVERRIDE; + virtual MediaStateFlags GetMediaStateFlags() OVERRIDE; + virtual CefString GetSelectionText() OVERRIDE; + virtual bool IsEditable() OVERRIDE; + virtual bool IsSpeechInputEnabled() OVERRIDE; + virtual EditStateFlags GetEditStateFlags() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_CONTEXT_MENU_PARAMS_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/cookie_manager_ctocpp.cc b/cef3/libcef_dll/ctocpp/cookie_manager_ctocpp.cc new file mode 100644 index 000000000..a12a459b1 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/cookie_manager_ctocpp.cc @@ -0,0 +1,196 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/completion_handler_cpptoc.h" +#include "libcef_dll/cpptoc/cookie_visitor_cpptoc.h" +#include "libcef_dll/ctocpp/cookie_manager_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefCookieManager::GetGlobalManager() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_cookie_manager_t* _retval = cef_cookie_manager_get_global_manager(); + + // Return type: refptr_same + return CefCookieManagerCToCpp::Wrap(_retval); +} + +CefRefPtr CefCookieManager::CreateManager( + const CefString& path, bool persist_session_cookies) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: path + + // Execute + cef_cookie_manager_t* _retval = cef_cookie_manager_create_manager( + path.GetStruct(), + persist_session_cookies); + + // Return type: refptr_same + return CefCookieManagerCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefCookieManagerCToCpp::SetSupportedSchemes( + const std::vector& schemes) { + if (CEF_MEMBER_MISSING(struct_, set_supported_schemes)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: schemes; type: string_vec_byref_const + cef_string_list_t schemesList = cef_string_list_alloc(); + DCHECK(schemesList); + if (schemesList) + transfer_string_list_contents(schemes, schemesList); + + // Execute + struct_->set_supported_schemes(struct_, + schemesList); + + // Restore param:schemes; type: string_vec_byref_const + if (schemesList) + cef_string_list_free(schemesList); +} + +bool CefCookieManagerCToCpp::VisitAllCookies( + CefRefPtr visitor) { + if (CEF_MEMBER_MISSING(struct_, visit_all_cookies)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: visitor; type: refptr_diff + DCHECK(visitor.get()); + if (!visitor.get()) + return false; + + // Execute + int _retval = struct_->visit_all_cookies(struct_, + CefCookieVisitorCppToC::Wrap(visitor)); + + // Return type: bool + return _retval?true:false; +} + +bool CefCookieManagerCToCpp::VisitUrlCookies(const CefString& url, + bool includeHttpOnly, CefRefPtr visitor) { + if (CEF_MEMBER_MISSING(struct_, visit_url_cookies)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: url; type: string_byref_const + DCHECK(!url.empty()); + if (url.empty()) + return false; + // Verify param: visitor; type: refptr_diff + DCHECK(visitor.get()); + if (!visitor.get()) + return false; + + // Execute + int _retval = struct_->visit_url_cookies(struct_, + url.GetStruct(), + includeHttpOnly, + CefCookieVisitorCppToC::Wrap(visitor)); + + // Return type: bool + return _retval?true:false; +} + +bool CefCookieManagerCToCpp::SetCookie(const CefString& url, + const CefCookie& cookie) { + if (CEF_MEMBER_MISSING(struct_, set_cookie)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: url; type: string_byref_const + DCHECK(!url.empty()); + if (url.empty()) + return false; + + // Execute + int _retval = struct_->set_cookie(struct_, + url.GetStruct(), + &cookie); + + // Return type: bool + return _retval?true:false; +} + +bool CefCookieManagerCToCpp::DeleteCookies(const CefString& url, + const CefString& cookie_name) { + if (CEF_MEMBER_MISSING(struct_, delete_cookies)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: url, cookie_name + + // Execute + int _retval = struct_->delete_cookies(struct_, + url.GetStruct(), + cookie_name.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + +bool CefCookieManagerCToCpp::SetStoragePath(const CefString& path, + bool persist_session_cookies) { + if (CEF_MEMBER_MISSING(struct_, set_storage_path)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: path + + // Execute + int _retval = struct_->set_storage_path(struct_, + path.GetStruct(), + persist_session_cookies); + + // Return type: bool + return _retval?true:false; +} + +bool CefCookieManagerCToCpp::FlushStore( + CefRefPtr handler) { + if (CEF_MEMBER_MISSING(struct_, flush_store)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: handler + + // Execute + int _retval = struct_->flush_store(struct_, + CefCompletionHandlerCppToC::Wrap(handler)); + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/cookie_manager_ctocpp.h b/cef3/libcef_dll/ctocpp/cookie_manager_ctocpp.h new file mode 100644 index 000000000..cadd19f4c --- /dev/null +++ b/cef3/libcef_dll/ctocpp/cookie_manager_ctocpp.h @@ -0,0 +1,54 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_COOKIE_MANAGER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_COOKIE_MANAGER_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include +#include "include/cef_cookie.h" +#include "include/capi/cef_cookie_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefCookieManagerCToCpp + : public CefCToCpp { + public: + explicit CefCookieManagerCToCpp(cef_cookie_manager_t* str) + : CefCToCpp(str) {} + virtual ~CefCookieManagerCToCpp() {} + + // CefCookieManager methods + virtual void SetSupportedSchemes( + const std::vector& schemes) OVERRIDE; + virtual bool VisitAllCookies(CefRefPtr visitor) OVERRIDE; + virtual bool VisitUrlCookies(const CefString& url, bool includeHttpOnly, + CefRefPtr visitor) OVERRIDE; + virtual bool SetCookie(const CefString& url, + const CefCookie& cookie) OVERRIDE; + virtual bool DeleteCookies(const CefString& url, + const CefString& cookie_name) OVERRIDE; + virtual bool SetStoragePath(const CefString& path, + bool persist_session_cookies) OVERRIDE; + virtual bool FlushStore(CefRefPtr handler) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_COOKIE_MANAGER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/cookie_visitor_ctocpp.cc b/cef3/libcef_dll/ctocpp/cookie_visitor_ctocpp.cc new file mode 100644 index 000000000..0992e107b --- /dev/null +++ b/cef3/libcef_dll/ctocpp/cookie_visitor_ctocpp.cc @@ -0,0 +1,47 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/cookie_visitor_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefCookieVisitorCToCpp::Visit(const CefCookie& cookie, int count, + int total, bool& deleteCookie) { + if (CEF_MEMBER_MISSING(struct_, visit)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: deleteCookie; type: bool_byref + int deleteCookieInt = deleteCookie; + + // Execute + int _retval = struct_->visit(struct_, + &cookie, + count, + total, + &deleteCookieInt); + + // Restore param:deleteCookie; type: bool_byref + deleteCookie = deleteCookieInt?true:false; + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/cookie_visitor_ctocpp.h b/cef3/libcef_dll/ctocpp/cookie_visitor_ctocpp.h new file mode 100644 index 000000000..379de8e20 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/cookie_visitor_ctocpp.h @@ -0,0 +1,43 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_COOKIE_VISITOR_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_COOKIE_VISITOR_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_cookie.h" +#include "include/capi/cef_cookie_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefCookieVisitorCToCpp + : public CefCToCpp { + public: + explicit CefCookieVisitorCToCpp(cef_cookie_visitor_t* str) + : CefCToCpp(str) {} + virtual ~CefCookieVisitorCToCpp() {} + + // CefCookieVisitor methods + virtual bool Visit(const CefCookie& cookie, int count, int total, + bool& deleteCookie) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_COOKIE_VISITOR_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/ctocpp.h b/cef3/libcef_dll/ctocpp/ctocpp.h new file mode 100644 index 000000000..3697647c4 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/ctocpp.h @@ -0,0 +1,113 @@ +// Copyright (c) 2009 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_LIBCEF_DLL_CTOCPP_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_CTOCPP_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/capi/cef_base_capi.h" +#include "libcef_dll/cef_logging.h" + + +// Wrap a C structure with a C++ class. This is used when the implementation +// exists on the other side of the DLL boundary but will have methods called on +// this side of the DLL boundary. +template +class CefCToCpp : public BaseName { + public: + // Use this method to create a wrapper class instance for a structure + // received from the other side. + static CefRefPtr Wrap(StructName* s) { + if (!s) + return NULL; + + // Wrap their structure with the CefCToCpp object. + ClassName* wrapper = new ClassName(s); + // Put the wrapper object in a smart pointer. + CefRefPtr wrapperPtr(wrapper); + // Release the reference that was added to the CefCppToC wrapper object on + // the other side before their structure was passed to us. + wrapper->UnderlyingRelease(); + // Return the smart pointer. + return wrapperPtr; + } + + // Use this method to retrieve the underlying structure from a wrapper class + // instance for return back to the other side. + static StructName* Unwrap(CefRefPtr c) { + if (!c.get()) + return NULL; + + // Cast the object to our wrapper class type. + ClassName* wrapper = static_cast(c.get()); + // Add a reference to the CefCppToC wrapper object on the other side that + // will be released once the structure is received. + wrapper->UnderlyingAddRef(); + // Return their original structure. + return wrapper->GetStruct(); + } + + explicit CefCToCpp(StructName* str) + : struct_(str) { + DCHECK(str); + +#ifndef NDEBUG + CefAtomicIncrement(&DebugObjCt); +#endif + } + virtual ~CefCToCpp() { +#ifndef NDEBUG + CefAtomicDecrement(&DebugObjCt); +#endif + } + + // If returning the structure across the DLL boundary you should call + // UnderlyingAddRef() on this wrapping CefCToCpp object. On the other side of + // the DLL boundary, call Release() on the CefCppToC object. + StructName* GetStruct() { return struct_; } + + // CefBase methods increment/decrement reference counts on both this object + // and the underlying wrapped structure. + int AddRef() { + UnderlyingAddRef(); + return refct_.AddRef(); + } + int Release() { + UnderlyingRelease(); + int retval = refct_.Release(); + if (retval == 0) + delete this; + return retval; + } + int GetRefCt() { return refct_.GetRefCt(); } + + // Increment/decrement reference counts on only the underlying class. + int UnderlyingAddRef() { + if (!struct_->base.add_ref) + return 0; + return struct_->base.add_ref(&struct_->base); + } + int UnderlyingRelease() { + if (!struct_->base.release) + return 0; + return struct_->base.release(&struct_->base); + } + int UnderlyingGetRefCt() { + if (!struct_->base.get_refct) + return 0; + return struct_->base.get_refct(&struct_->base); + } + +#ifndef NDEBUG + // Simple tracking of allocated objects. + static long DebugObjCt; // NOLINT(runtime/int) +#endif + + protected: + CefRefCount refct_; + StructName* struct_; +}; + +#endif // CEF_LIBCEF_DLL_CTOCPP_CTOCPP_H_ diff --git a/cef3/libcef_dll/ctocpp/dialog_handler_ctocpp.cc b/cef3/libcef_dll/ctocpp/dialog_handler_ctocpp.cc new file mode 100644 index 000000000..009dfde54 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/dialog_handler_ctocpp.cc @@ -0,0 +1,69 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/cpptoc/file_dialog_callback_cpptoc.h" +#include "libcef_dll/ctocpp/dialog_handler_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefDialogHandlerCToCpp::OnFileDialog(CefRefPtr browser, + FileDialogMode mode, const CefString& title, + const CefString& default_file_name, + const std::vector& accept_types, + CefRefPtr callback) { + if (CEF_MEMBER_MISSING(struct_, on_file_dialog)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + // Verify param: callback; type: refptr_diff + DCHECK(callback.get()); + if (!callback.get()) + return false; + // Unverified params: title, default_file_name, accept_types + + // Translate param: accept_types; type: string_vec_byref_const + cef_string_list_t accept_typesList = cef_string_list_alloc(); + DCHECK(accept_typesList); + if (accept_typesList) + transfer_string_list_contents(accept_types, accept_typesList); + + // Execute + int _retval = struct_->on_file_dialog(struct_, + CefBrowserCppToC::Wrap(browser), + mode, + title.GetStruct(), + default_file_name.GetStruct(), + accept_typesList, + CefFileDialogCallbackCppToC::Wrap(callback)); + + // Restore param:accept_types; type: string_vec_byref_const + if (accept_typesList) + cef_string_list_free(accept_typesList); + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/dialog_handler_ctocpp.h b/cef3/libcef_dll/ctocpp/dialog_handler_ctocpp.h new file mode 100644 index 000000000..80b5fdd67 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/dialog_handler_ctocpp.h @@ -0,0 +1,46 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_DIALOG_HANDLER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_DIALOG_HANDLER_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include +#include "include/cef_dialog_handler.h" +#include "include/capi/cef_dialog_handler_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefDialogHandlerCToCpp + : public CefCToCpp { + public: + explicit CefDialogHandlerCToCpp(cef_dialog_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefDialogHandlerCToCpp() {} + + // CefDialogHandler methods + virtual bool OnFileDialog(CefRefPtr browser, FileDialogMode mode, + const CefString& title, const CefString& default_file_name, + const std::vector& accept_types, + CefRefPtr callback) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_DIALOG_HANDLER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/dictionary_value_ctocpp.cc b/cef3/libcef_dll/ctocpp/dictionary_value_ctocpp.cc new file mode 100644 index 000000000..efb99061c --- /dev/null +++ b/cef3/libcef_dll/ctocpp/dictionary_value_ctocpp.cc @@ -0,0 +1,517 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/binary_value_ctocpp.h" +#include "libcef_dll/ctocpp/dictionary_value_ctocpp.h" +#include "libcef_dll/ctocpp/list_value_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefDictionaryValue::Create() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_dictionary_value_t* _retval = cef_dictionary_value_create(); + + // Return type: refptr_same + return CefDictionaryValueCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefDictionaryValueCToCpp::IsValid() { + if (CEF_MEMBER_MISSING(struct_, is_valid)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_valid(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefDictionaryValueCToCpp::IsOwned() { + if (CEF_MEMBER_MISSING(struct_, is_owned)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_owned(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefDictionaryValueCToCpp::IsReadOnly() { + if (CEF_MEMBER_MISSING(struct_, is_read_only)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_read_only(struct_); + + // Return type: bool + return _retval?true:false; +} + +CefRefPtr CefDictionaryValueCToCpp::Copy( + bool exclude_empty_children) { + if (CEF_MEMBER_MISSING(struct_, copy)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_dictionary_value_t* _retval = struct_->copy(struct_, + exclude_empty_children); + + // Return type: refptr_same + return CefDictionaryValueCToCpp::Wrap(_retval); +} + +size_t CefDictionaryValueCToCpp::GetSize() { + if (CEF_MEMBER_MISSING(struct_, get_size)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + size_t _retval = struct_->get_size(struct_); + + // Return type: simple + return _retval; +} + +bool CefDictionaryValueCToCpp::Clear() { + if (CEF_MEMBER_MISSING(struct_, clear)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->clear(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefDictionaryValueCToCpp::HasKey(const CefString& key) { + if (CEF_MEMBER_MISSING(struct_, has_key)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: key; type: string_byref_const + DCHECK(!key.empty()); + if (key.empty()) + return false; + + // Execute + int _retval = struct_->has_key(struct_, + key.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + +bool CefDictionaryValueCToCpp::GetKeys(KeyList& keys) { + if (CEF_MEMBER_MISSING(struct_, get_keys)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: keys; type: string_vec_byref + cef_string_list_t keysList = cef_string_list_alloc(); + DCHECK(keysList); + if (keysList) + transfer_string_list_contents(keys, keysList); + + // Execute + int _retval = struct_->get_keys(struct_, + keysList); + + // Restore param:keys; type: string_vec_byref + if (keysList) { + keys.clear(); + transfer_string_list_contents(keysList, keys); + cef_string_list_free(keysList); + } + + // Return type: bool + return _retval?true:false; +} + +bool CefDictionaryValueCToCpp::Remove(const CefString& key) { + if (CEF_MEMBER_MISSING(struct_, remove)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: key; type: string_byref_const + DCHECK(!key.empty()); + if (key.empty()) + return false; + + // Execute + int _retval = struct_->remove(struct_, + key.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + +CefValueType CefDictionaryValueCToCpp::GetType(const CefString& key) { + if (CEF_MEMBER_MISSING(struct_, get_type)) + return VTYPE_INVALID; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: key; type: string_byref_const + DCHECK(!key.empty()); + if (key.empty()) + return VTYPE_INVALID; + + // Execute + cef_value_type_t _retval = struct_->get_type(struct_, + key.GetStruct()); + + // Return type: simple + return _retval; +} + +bool CefDictionaryValueCToCpp::GetBool(const CefString& key) { + if (CEF_MEMBER_MISSING(struct_, get_bool)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: key; type: string_byref_const + DCHECK(!key.empty()); + if (key.empty()) + return false; + + // Execute + int _retval = struct_->get_bool(struct_, + key.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + +int CefDictionaryValueCToCpp::GetInt(const CefString& key) { + if (CEF_MEMBER_MISSING(struct_, get_int)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: key; type: string_byref_const + DCHECK(!key.empty()); + if (key.empty()) + return 0; + + // Execute + int _retval = struct_->get_int(struct_, + key.GetStruct()); + + // Return type: simple + return _retval; +} + +double CefDictionaryValueCToCpp::GetDouble(const CefString& key) { + if (CEF_MEMBER_MISSING(struct_, get_double)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: key; type: string_byref_const + DCHECK(!key.empty()); + if (key.empty()) + return 0; + + // Execute + double _retval = struct_->get_double(struct_, + key.GetStruct()); + + // Return type: simple + return _retval; +} + +CefString CefDictionaryValueCToCpp::GetString(const CefString& key) { + if (CEF_MEMBER_MISSING(struct_, get_string)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: key; type: string_byref_const + DCHECK(!key.empty()); + if (key.empty()) + return CefString(); + + // Execute + cef_string_userfree_t _retval = struct_->get_string(struct_, + key.GetStruct()); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefRefPtr CefDictionaryValueCToCpp::GetBinary( + const CefString& key) { + if (CEF_MEMBER_MISSING(struct_, get_binary)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: key; type: string_byref_const + DCHECK(!key.empty()); + if (key.empty()) + return NULL; + + // Execute + cef_binary_value_t* _retval = struct_->get_binary(struct_, + key.GetStruct()); + + // Return type: refptr_same + return CefBinaryValueCToCpp::Wrap(_retval); +} + +CefRefPtr CefDictionaryValueCToCpp::GetDictionary( + const CefString& key) { + if (CEF_MEMBER_MISSING(struct_, get_dictionary)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: key; type: string_byref_const + DCHECK(!key.empty()); + if (key.empty()) + return NULL; + + // Execute + cef_dictionary_value_t* _retval = struct_->get_dictionary(struct_, + key.GetStruct()); + + // Return type: refptr_same + return CefDictionaryValueCToCpp::Wrap(_retval); +} + +CefRefPtr CefDictionaryValueCToCpp::GetList( + const CefString& key) { + if (CEF_MEMBER_MISSING(struct_, get_list)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: key; type: string_byref_const + DCHECK(!key.empty()); + if (key.empty()) + return NULL; + + // Execute + cef_list_value_t* _retval = struct_->get_list(struct_, + key.GetStruct()); + + // Return type: refptr_same + return CefListValueCToCpp::Wrap(_retval); +} + +bool CefDictionaryValueCToCpp::SetNull(const CefString& key) { + if (CEF_MEMBER_MISSING(struct_, set_null)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: key; type: string_byref_const + DCHECK(!key.empty()); + if (key.empty()) + return false; + + // Execute + int _retval = struct_->set_null(struct_, + key.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + +bool CefDictionaryValueCToCpp::SetBool(const CefString& key, bool value) { + if (CEF_MEMBER_MISSING(struct_, set_bool)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: key; type: string_byref_const + DCHECK(!key.empty()); + if (key.empty()) + return false; + + // Execute + int _retval = struct_->set_bool(struct_, + key.GetStruct(), + value); + + // Return type: bool + return _retval?true:false; +} + +bool CefDictionaryValueCToCpp::SetInt(const CefString& key, int value) { + if (CEF_MEMBER_MISSING(struct_, set_int)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: key; type: string_byref_const + DCHECK(!key.empty()); + if (key.empty()) + return false; + + // Execute + int _retval = struct_->set_int(struct_, + key.GetStruct(), + value); + + // Return type: bool + return _retval?true:false; +} + +bool CefDictionaryValueCToCpp::SetDouble(const CefString& key, double value) { + if (CEF_MEMBER_MISSING(struct_, set_double)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: key; type: string_byref_const + DCHECK(!key.empty()); + if (key.empty()) + return false; + + // Execute + int _retval = struct_->set_double(struct_, + key.GetStruct(), + value); + + // Return type: bool + return _retval?true:false; +} + +bool CefDictionaryValueCToCpp::SetString(const CefString& key, + const CefString& value) { + if (CEF_MEMBER_MISSING(struct_, set_string)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: key; type: string_byref_const + DCHECK(!key.empty()); + if (key.empty()) + return false; + // Unverified params: value + + // Execute + int _retval = struct_->set_string(struct_, + key.GetStruct(), + value.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + +bool CefDictionaryValueCToCpp::SetBinary(const CefString& key, + CefRefPtr value) { + if (CEF_MEMBER_MISSING(struct_, set_binary)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: key; type: string_byref_const + DCHECK(!key.empty()); + if (key.empty()) + return false; + // Verify param: value; type: refptr_same + DCHECK(value.get()); + if (!value.get()) + return false; + + // Execute + int _retval = struct_->set_binary(struct_, + key.GetStruct(), + CefBinaryValueCToCpp::Unwrap(value)); + + // Return type: bool + return _retval?true:false; +} + +bool CefDictionaryValueCToCpp::SetDictionary(const CefString& key, + CefRefPtr value) { + if (CEF_MEMBER_MISSING(struct_, set_dictionary)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: key; type: string_byref_const + DCHECK(!key.empty()); + if (key.empty()) + return false; + // Verify param: value; type: refptr_same + DCHECK(value.get()); + if (!value.get()) + return false; + + // Execute + int _retval = struct_->set_dictionary(struct_, + key.GetStruct(), + CefDictionaryValueCToCpp::Unwrap(value)); + + // Return type: bool + return _retval?true:false; +} + +bool CefDictionaryValueCToCpp::SetList(const CefString& key, + CefRefPtr value) { + if (CEF_MEMBER_MISSING(struct_, set_list)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: key; type: string_byref_const + DCHECK(!key.empty()); + if (key.empty()) + return false; + // Verify param: value; type: refptr_same + DCHECK(value.get()); + if (!value.get()) + return false; + + // Execute + int _retval = struct_->set_list(struct_, + key.GetStruct(), + CefListValueCToCpp::Unwrap(value)); + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/dictionary_value_ctocpp.h b/cef3/libcef_dll/ctocpp/dictionary_value_ctocpp.h new file mode 100644 index 000000000..79de9f7e6 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/dictionary_value_ctocpp.h @@ -0,0 +1,71 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_DICTIONARY_VALUE_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_DICTIONARY_VALUE_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_values.h" +#include "include/capi/cef_values_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefDictionaryValueCToCpp + : public CefCToCpp { + public: + explicit CefDictionaryValueCToCpp(cef_dictionary_value_t* str) + : CefCToCpp(str) {} + virtual ~CefDictionaryValueCToCpp() {} + + // CefDictionaryValue methods + virtual bool IsValid() OVERRIDE; + virtual bool IsOwned() OVERRIDE; + virtual bool IsReadOnly() OVERRIDE; + virtual CefRefPtr Copy( + bool exclude_empty_children) OVERRIDE; + virtual size_t GetSize() OVERRIDE; + virtual bool Clear() OVERRIDE; + virtual bool HasKey(const CefString& key) OVERRIDE; + virtual bool GetKeys(KeyList& keys) OVERRIDE; + virtual bool Remove(const CefString& key) OVERRIDE; + virtual CefValueType GetType(const CefString& key) OVERRIDE; + virtual bool GetBool(const CefString& key) OVERRIDE; + virtual int GetInt(const CefString& key) OVERRIDE; + virtual double GetDouble(const CefString& key) OVERRIDE; + virtual CefString GetString(const CefString& key) OVERRIDE; + virtual CefRefPtr GetBinary(const CefString& key) OVERRIDE; + virtual CefRefPtr GetDictionary( + const CefString& key) OVERRIDE; + virtual CefRefPtr GetList(const CefString& key) OVERRIDE; + virtual bool SetNull(const CefString& key) OVERRIDE; + virtual bool SetBool(const CefString& key, bool value) OVERRIDE; + virtual bool SetInt(const CefString& key, int value) OVERRIDE; + virtual bool SetDouble(const CefString& key, double value) OVERRIDE; + virtual bool SetString(const CefString& key, const CefString& value) OVERRIDE; + virtual bool SetBinary(const CefString& key, + CefRefPtr value) OVERRIDE; + virtual bool SetDictionary(const CefString& key, + CefRefPtr value) OVERRIDE; + virtual bool SetList(const CefString& key, + CefRefPtr value) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_DICTIONARY_VALUE_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/display_handler_ctocpp.cc b/cef3/libcef_dll/ctocpp/display_handler_ctocpp.cc new file mode 100644 index 000000000..dcceb13fd --- /dev/null +++ b/cef3/libcef_dll/ctocpp/display_handler_ctocpp.cc @@ -0,0 +1,157 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/cpptoc/frame_cpptoc.h" +#include "libcef_dll/ctocpp/display_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefDisplayHandlerCToCpp::OnLoadingStateChange( + CefRefPtr browser, bool isLoading, bool canGoBack, + bool canGoForward) { + if (CEF_MEMBER_MISSING(struct_, on_loading_state_change)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + + // Execute + struct_->on_loading_state_change(struct_, + CefBrowserCppToC::Wrap(browser), + isLoading, + canGoBack, + canGoForward); +} + +void CefDisplayHandlerCToCpp::OnAddressChange(CefRefPtr browser, + CefRefPtr frame, const CefString& url) { + if (CEF_MEMBER_MISSING(struct_, on_address_change)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame.get()); + if (!frame.get()) + return; + // Verify param: url; type: string_byref_const + DCHECK(!url.empty()); + if (url.empty()) + return; + + // Execute + struct_->on_address_change(struct_, + CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), + url.GetStruct()); +} + +void CefDisplayHandlerCToCpp::OnTitleChange(CefRefPtr browser, + const CefString& title) { + if (CEF_MEMBER_MISSING(struct_, on_title_change)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + // Unverified params: title + + // Execute + struct_->on_title_change(struct_, + CefBrowserCppToC::Wrap(browser), + title.GetStruct()); +} + +bool CefDisplayHandlerCToCpp::OnTooltip(CefRefPtr browser, + CefString& text) { + if (CEF_MEMBER_MISSING(struct_, on_tooltip)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + // Unverified params: text + + // Execute + int _retval = struct_->on_tooltip(struct_, + CefBrowserCppToC::Wrap(browser), + text.GetWritableStruct()); + + // Return type: bool + return _retval?true:false; +} + +void CefDisplayHandlerCToCpp::OnStatusMessage(CefRefPtr browser, + const CefString& value) { + if (CEF_MEMBER_MISSING(struct_, on_status_message)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + // Unverified params: value + + // Execute + struct_->on_status_message(struct_, + CefBrowserCppToC::Wrap(browser), + value.GetStruct()); +} + +bool CefDisplayHandlerCToCpp::OnConsoleMessage(CefRefPtr browser, + const CefString& message, const CefString& source, int line) { + if (CEF_MEMBER_MISSING(struct_, on_console_message)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + // Unverified params: message, source + + // Execute + int _retval = struct_->on_console_message(struct_, + CefBrowserCppToC::Wrap(browser), + message.GetStruct(), + source.GetStruct(), + line); + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/display_handler_ctocpp.h b/cef3/libcef_dll/ctocpp/display_handler_ctocpp.h new file mode 100644 index 000000000..04296f055 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/display_handler_ctocpp.h @@ -0,0 +1,53 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_DISPLAY_HANDLER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_DISPLAY_HANDLER_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_display_handler.h" +#include "include/capi/cef_display_handler_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefDisplayHandlerCToCpp + : public CefCToCpp { + public: + explicit CefDisplayHandlerCToCpp(cef_display_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefDisplayHandlerCToCpp() {} + + // CefDisplayHandler methods + virtual void OnLoadingStateChange(CefRefPtr browser, + bool isLoading, bool canGoBack, bool canGoForward) OVERRIDE; + virtual void OnAddressChange(CefRefPtr browser, + CefRefPtr frame, const CefString& url) OVERRIDE; + virtual void OnTitleChange(CefRefPtr browser, + const CefString& title) OVERRIDE; + virtual bool OnTooltip(CefRefPtr browser, + CefString& text) OVERRIDE; + virtual void OnStatusMessage(CefRefPtr browser, + const CefString& value) OVERRIDE; + virtual bool OnConsoleMessage(CefRefPtr browser, + const CefString& message, const CefString& source, int line) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_DISPLAY_HANDLER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/domdocument_ctocpp.cc b/cef3/libcef_dll/ctocpp/domdocument_ctocpp.cc new file mode 100644 index 000000000..3afa95215 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/domdocument_ctocpp.cc @@ -0,0 +1,255 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/domdocument_ctocpp.h" +#include "libcef_dll/ctocpp/domnode_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +CefDOMDocument::Type CefDOMDocumentCToCpp::GetType() { + if (CEF_MEMBER_MISSING(struct_, get_type)) + return DOM_DOCUMENT_TYPE_UNKNOWN; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_dom_document_type_t _retval = struct_->get_type(struct_); + + // Return type: simple + return _retval; +} + +CefRefPtr CefDOMDocumentCToCpp::GetDocument() { + if (CEF_MEMBER_MISSING(struct_, get_document)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_document(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + +CefRefPtr CefDOMDocumentCToCpp::GetBody() { + if (CEF_MEMBER_MISSING(struct_, get_body)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_body(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + +CefRefPtr CefDOMDocumentCToCpp::GetHead() { + if (CEF_MEMBER_MISSING(struct_, get_head)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_head(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + +CefString CefDOMDocumentCToCpp::GetTitle() { + if (CEF_MEMBER_MISSING(struct_, get_title)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_title(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefRefPtr CefDOMDocumentCToCpp::GetElementById( + const CefString& id) { + if (CEF_MEMBER_MISSING(struct_, get_element_by_id)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: id; type: string_byref_const + DCHECK(!id.empty()); + if (id.empty()) + return NULL; + + // Execute + cef_domnode_t* _retval = struct_->get_element_by_id(struct_, + id.GetStruct()); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + +CefRefPtr CefDOMDocumentCToCpp::GetFocusedNode() { + if (CEF_MEMBER_MISSING(struct_, get_focused_node)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_focused_node(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + +bool CefDOMDocumentCToCpp::HasSelection() { + if (CEF_MEMBER_MISSING(struct_, has_selection)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->has_selection(struct_); + + // Return type: bool + return _retval?true:false; +} + +CefRefPtr CefDOMDocumentCToCpp::GetSelectionStartNode() { + if (CEF_MEMBER_MISSING(struct_, get_selection_start_node)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_selection_start_node(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + +int CefDOMDocumentCToCpp::GetSelectionStartOffset() { + if (CEF_MEMBER_MISSING(struct_, get_selection_start_offset)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_selection_start_offset(struct_); + + // Return type: simple + return _retval; +} + +CefRefPtr CefDOMDocumentCToCpp::GetSelectionEndNode() { + if (CEF_MEMBER_MISSING(struct_, get_selection_end_node)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_selection_end_node(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + +int CefDOMDocumentCToCpp::GetSelectionEndOffset() { + if (CEF_MEMBER_MISSING(struct_, get_selection_end_offset)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_selection_end_offset(struct_); + + // Return type: simple + return _retval; +} + +CefString CefDOMDocumentCToCpp::GetSelectionAsMarkup() { + if (CEF_MEMBER_MISSING(struct_, get_selection_as_markup)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_selection_as_markup(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefDOMDocumentCToCpp::GetSelectionAsText() { + if (CEF_MEMBER_MISSING(struct_, get_selection_as_text)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_selection_as_text(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefDOMDocumentCToCpp::GetBaseURL() { + if (CEF_MEMBER_MISSING(struct_, get_base_url)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_base_url(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefDOMDocumentCToCpp::GetCompleteURL(const CefString& partialURL) { + if (CEF_MEMBER_MISSING(struct_, get_complete_url)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: partialURL; type: string_byref_const + DCHECK(!partialURL.empty()); + if (partialURL.empty()) + return CefString(); + + // Execute + cef_string_userfree_t _retval = struct_->get_complete_url(struct_, + partialURL.GetStruct()); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/domdocument_ctocpp.h b/cef3/libcef_dll/ctocpp/domdocument_ctocpp.h new file mode 100644 index 000000000..23fee5b21 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/domdocument_ctocpp.h @@ -0,0 +1,57 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_DOMDOCUMENT_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_DOMDOCUMENT_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_dom.h" +#include "include/capi/cef_dom_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefDOMDocumentCToCpp + : public CefCToCpp { + public: + explicit CefDOMDocumentCToCpp(cef_domdocument_t* str) + : CefCToCpp( + str) {} + virtual ~CefDOMDocumentCToCpp() {} + + // CefDOMDocument methods + virtual Type GetType() OVERRIDE; + virtual CefRefPtr GetDocument() OVERRIDE; + virtual CefRefPtr GetBody() OVERRIDE; + virtual CefRefPtr GetHead() OVERRIDE; + virtual CefString GetTitle() OVERRIDE; + virtual CefRefPtr GetElementById(const CefString& id) OVERRIDE; + virtual CefRefPtr GetFocusedNode() OVERRIDE; + virtual bool HasSelection() OVERRIDE; + virtual CefRefPtr GetSelectionStartNode() OVERRIDE; + virtual int GetSelectionStartOffset() OVERRIDE; + virtual CefRefPtr GetSelectionEndNode() OVERRIDE; + virtual int GetSelectionEndOffset() OVERRIDE; + virtual CefString GetSelectionAsMarkup() OVERRIDE; + virtual CefString GetSelectionAsText() OVERRIDE; + virtual CefString GetBaseURL() OVERRIDE; + virtual CefString GetCompleteURL(const CefString& partialURL) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_DOMDOCUMENT_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/domevent_ctocpp.cc b/cef3/libcef_dll/ctocpp/domevent_ctocpp.cc new file mode 100644 index 000000000..3bec4e5bf --- /dev/null +++ b/cef3/libcef_dll/ctocpp/domevent_ctocpp.cc @@ -0,0 +1,131 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/domdocument_ctocpp.h" +#include "libcef_dll/ctocpp/domevent_ctocpp.h" +#include "libcef_dll/ctocpp/domnode_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +CefString CefDOMEventCToCpp::GetType() { + if (CEF_MEMBER_MISSING(struct_, get_type)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_type(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefDOMEvent::Category CefDOMEventCToCpp::GetCategory() { + if (CEF_MEMBER_MISSING(struct_, get_category)) + return DOM_EVENT_CATEGORY_UNKNOWN; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_dom_event_category_t _retval = struct_->get_category(struct_); + + // Return type: simple + return _retval; +} + +CefDOMEvent::Phase CefDOMEventCToCpp::GetPhase() { + if (CEF_MEMBER_MISSING(struct_, get_phase)) + return DOM_EVENT_PHASE_UNKNOWN; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_dom_event_phase_t _retval = struct_->get_phase(struct_); + + // Return type: simple + return _retval; +} + +bool CefDOMEventCToCpp::CanBubble() { + if (CEF_MEMBER_MISSING(struct_, can_bubble)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->can_bubble(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefDOMEventCToCpp::CanCancel() { + if (CEF_MEMBER_MISSING(struct_, can_cancel)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->can_cancel(struct_); + + // Return type: bool + return _retval?true:false; +} + +CefRefPtr CefDOMEventCToCpp::GetDocument() { + if (CEF_MEMBER_MISSING(struct_, get_document)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domdocument_t* _retval = struct_->get_document(struct_); + + // Return type: refptr_same + return CefDOMDocumentCToCpp::Wrap(_retval); +} + +CefRefPtr CefDOMEventCToCpp::GetTarget() { + if (CEF_MEMBER_MISSING(struct_, get_target)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_target(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + +CefRefPtr CefDOMEventCToCpp::GetCurrentTarget() { + if (CEF_MEMBER_MISSING(struct_, get_current_target)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_current_target(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/domevent_ctocpp.h b/cef3/libcef_dll/ctocpp/domevent_ctocpp.h new file mode 100644 index 000000000..22fbed79f --- /dev/null +++ b/cef3/libcef_dll/ctocpp/domevent_ctocpp.h @@ -0,0 +1,47 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_DOMEVENT_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_DOMEVENT_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_dom.h" +#include "include/capi/cef_dom_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefDOMEventCToCpp + : public CefCToCpp { + public: + explicit CefDOMEventCToCpp(cef_domevent_t* str) + : CefCToCpp(str) {} + virtual ~CefDOMEventCToCpp() {} + + // CefDOMEvent methods + virtual CefString GetType() OVERRIDE; + virtual Category GetCategory() OVERRIDE; + virtual Phase GetPhase() OVERRIDE; + virtual bool CanBubble() OVERRIDE; + virtual bool CanCancel() OVERRIDE; + virtual CefRefPtr GetDocument() OVERRIDE; + virtual CefRefPtr GetTarget() OVERRIDE; + virtual CefRefPtr GetCurrentTarget() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_DOMEVENT_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/domevent_listener_ctocpp.cc b/cef3/libcef_dll/ctocpp/domevent_listener_ctocpp.cc new file mode 100644 index 000000000..ead1952ba --- /dev/null +++ b/cef3/libcef_dll/ctocpp/domevent_listener_ctocpp.cc @@ -0,0 +1,40 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/domevent_cpptoc.h" +#include "libcef_dll/ctocpp/domevent_listener_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefDOMEventListenerCToCpp::HandleEvent(CefRefPtr event) { + if (CEF_MEMBER_MISSING(struct_, handle_event)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: event; type: refptr_diff + DCHECK(event.get()); + if (!event.get()) + return; + + // Execute + struct_->handle_event(struct_, + CefDOMEventCppToC::Wrap(event)); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/domevent_listener_ctocpp.h b/cef3/libcef_dll/ctocpp/domevent_listener_ctocpp.h new file mode 100644 index 000000000..21ebfce08 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/domevent_listener_ctocpp.h @@ -0,0 +1,42 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_DOMEVENT_LISTENER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_DOMEVENT_LISTENER_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_dom.h" +#include "include/capi/cef_dom_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefDOMEventListenerCToCpp + : public CefCToCpp { + public: + explicit CefDOMEventListenerCToCpp(cef_domevent_listener_t* str) + : CefCToCpp(str) {} + virtual ~CefDOMEventListenerCToCpp() {} + + // CefDOMEventListener methods + virtual void HandleEvent(CefRefPtr event) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_DOMEVENT_LISTENER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/domnode_ctocpp.cc b/cef3/libcef_dll/ctocpp/domnode_ctocpp.cc new file mode 100644 index 000000000..f0b3a4756 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/domnode_ctocpp.cc @@ -0,0 +1,436 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/domevent_listener_cpptoc.h" +#include "libcef_dll/ctocpp/domdocument_ctocpp.h" +#include "libcef_dll/ctocpp/domnode_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +CefDOMNode::Type CefDOMNodeCToCpp::GetType() { + if (CEF_MEMBER_MISSING(struct_, get_type)) + return DOM_NODE_TYPE_UNSUPPORTED; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_dom_node_type_t _retval = struct_->get_type(struct_); + + // Return type: simple + return _retval; +} + +bool CefDOMNodeCToCpp::IsText() { + if (CEF_MEMBER_MISSING(struct_, is_text)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_text(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefDOMNodeCToCpp::IsElement() { + if (CEF_MEMBER_MISSING(struct_, is_element)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_element(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefDOMNodeCToCpp::IsEditable() { + if (CEF_MEMBER_MISSING(struct_, is_editable)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_editable(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefDOMNodeCToCpp::IsFormControlElement() { + if (CEF_MEMBER_MISSING(struct_, is_form_control_element)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_form_control_element(struct_); + + // Return type: bool + return _retval?true:false; +} + +CefString CefDOMNodeCToCpp::GetFormControlElementType() { + if (CEF_MEMBER_MISSING(struct_, get_form_control_element_type)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_form_control_element_type( + struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +bool CefDOMNodeCToCpp::IsSame(CefRefPtr that) { + if (CEF_MEMBER_MISSING(struct_, is_same)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: that; type: refptr_same + DCHECK(that.get()); + if (!that.get()) + return false; + + // Execute + int _retval = struct_->is_same(struct_, + CefDOMNodeCToCpp::Unwrap(that)); + + // Return type: bool + return _retval?true:false; +} + +CefString CefDOMNodeCToCpp::GetName() { + if (CEF_MEMBER_MISSING(struct_, get_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefDOMNodeCToCpp::GetValue() { + if (CEF_MEMBER_MISSING(struct_, get_value)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_value(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +bool CefDOMNodeCToCpp::SetValue(const CefString& value) { + if (CEF_MEMBER_MISSING(struct_, set_value)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: value; type: string_byref_const + DCHECK(!value.empty()); + if (value.empty()) + return false; + + // Execute + int _retval = struct_->set_value(struct_, + value.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + +CefString CefDOMNodeCToCpp::GetAsMarkup() { + if (CEF_MEMBER_MISSING(struct_, get_as_markup)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_as_markup(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefRefPtr CefDOMNodeCToCpp::GetDocument() { + if (CEF_MEMBER_MISSING(struct_, get_document)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domdocument_t* _retval = struct_->get_document(struct_); + + // Return type: refptr_same + return CefDOMDocumentCToCpp::Wrap(_retval); +} + +CefRefPtr CefDOMNodeCToCpp::GetParent() { + if (CEF_MEMBER_MISSING(struct_, get_parent)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_parent(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + +CefRefPtr CefDOMNodeCToCpp::GetPreviousSibling() { + if (CEF_MEMBER_MISSING(struct_, get_previous_sibling)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_previous_sibling(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + +CefRefPtr CefDOMNodeCToCpp::GetNextSibling() { + if (CEF_MEMBER_MISSING(struct_, get_next_sibling)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_next_sibling(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + +bool CefDOMNodeCToCpp::HasChildren() { + if (CEF_MEMBER_MISSING(struct_, has_children)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->has_children(struct_); + + // Return type: bool + return _retval?true:false; +} + +CefRefPtr CefDOMNodeCToCpp::GetFirstChild() { + if (CEF_MEMBER_MISSING(struct_, get_first_child)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_first_child(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + +CefRefPtr CefDOMNodeCToCpp::GetLastChild() { + if (CEF_MEMBER_MISSING(struct_, get_last_child)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_last_child(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + +void CefDOMNodeCToCpp::AddEventListener(const CefString& eventType, + CefRefPtr listener, bool useCapture) { + if (CEF_MEMBER_MISSING(struct_, add_event_listener)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: eventType; type: string_byref_const + DCHECK(!eventType.empty()); + if (eventType.empty()) + return; + // Verify param: listener; type: refptr_diff + DCHECK(listener.get()); + if (!listener.get()) + return; + + // Execute + struct_->add_event_listener(struct_, + eventType.GetStruct(), + CefDOMEventListenerCppToC::Wrap(listener), + useCapture); +} + +CefString CefDOMNodeCToCpp::GetElementTagName() { + if (CEF_MEMBER_MISSING(struct_, get_element_tag_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_element_tag_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +bool CefDOMNodeCToCpp::HasElementAttributes() { + if (CEF_MEMBER_MISSING(struct_, has_element_attributes)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->has_element_attributes(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefDOMNodeCToCpp::HasElementAttribute(const CefString& attrName) { + if (CEF_MEMBER_MISSING(struct_, has_element_attribute)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: attrName; type: string_byref_const + DCHECK(!attrName.empty()); + if (attrName.empty()) + return false; + + // Execute + int _retval = struct_->has_element_attribute(struct_, + attrName.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + +CefString CefDOMNodeCToCpp::GetElementAttribute(const CefString& attrName) { + if (CEF_MEMBER_MISSING(struct_, get_element_attribute)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: attrName; type: string_byref_const + DCHECK(!attrName.empty()); + if (attrName.empty()) + return CefString(); + + // Execute + cef_string_userfree_t _retval = struct_->get_element_attribute(struct_, + attrName.GetStruct()); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +void CefDOMNodeCToCpp::GetElementAttributes(AttributeMap& attrMap) { + if (CEF_MEMBER_MISSING(struct_, get_element_attributes)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: attrMap; type: string_map_single_byref + cef_string_map_t attrMapMap = cef_string_map_alloc(); + DCHECK(attrMapMap); + if (attrMapMap) + transfer_string_map_contents(attrMap, attrMapMap); + + // Execute + struct_->get_element_attributes(struct_, + attrMapMap); + + // Restore param:attrMap; type: string_map_single_byref + if (attrMapMap) { + attrMap.clear(); + transfer_string_map_contents(attrMapMap, attrMap); + cef_string_map_free(attrMapMap); + } +} + +bool CefDOMNodeCToCpp::SetElementAttribute(const CefString& attrName, + const CefString& value) { + if (CEF_MEMBER_MISSING(struct_, set_element_attribute)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: attrName; type: string_byref_const + DCHECK(!attrName.empty()); + if (attrName.empty()) + return false; + // Verify param: value; type: string_byref_const + DCHECK(!value.empty()); + if (value.empty()) + return false; + + // Execute + int _retval = struct_->set_element_attribute(struct_, + attrName.GetStruct(), + value.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + +CefString CefDOMNodeCToCpp::GetElementInnerText() { + if (CEF_MEMBER_MISSING(struct_, get_element_inner_text)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_element_inner_text(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/domnode_ctocpp.h b/cef3/libcef_dll/ctocpp/domnode_ctocpp.h new file mode 100644 index 000000000..c5448ad0e --- /dev/null +++ b/cef3/libcef_dll/ctocpp/domnode_ctocpp.h @@ -0,0 +1,67 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_DOMNODE_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_DOMNODE_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_dom.h" +#include "include/capi/cef_dom_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefDOMNodeCToCpp + : public CefCToCpp { + public: + explicit CefDOMNodeCToCpp(cef_domnode_t* str) + : CefCToCpp(str) {} + virtual ~CefDOMNodeCToCpp() {} + + // CefDOMNode methods + virtual Type GetType() OVERRIDE; + virtual bool IsText() OVERRIDE; + virtual bool IsElement() OVERRIDE; + virtual bool IsEditable() OVERRIDE; + virtual bool IsFormControlElement() OVERRIDE; + virtual CefString GetFormControlElementType() OVERRIDE; + virtual bool IsSame(CefRefPtr that) OVERRIDE; + virtual CefString GetName() OVERRIDE; + virtual CefString GetValue() OVERRIDE; + virtual bool SetValue(const CefString& value) OVERRIDE; + virtual CefString GetAsMarkup() OVERRIDE; + virtual CefRefPtr GetDocument() OVERRIDE; + virtual CefRefPtr GetParent() OVERRIDE; + virtual CefRefPtr GetPreviousSibling() OVERRIDE; + virtual CefRefPtr GetNextSibling() OVERRIDE; + virtual bool HasChildren() OVERRIDE; + virtual CefRefPtr GetFirstChild() OVERRIDE; + virtual CefRefPtr GetLastChild() OVERRIDE; + virtual void AddEventListener(const CefString& eventType, + CefRefPtr listener, bool useCapture) OVERRIDE; + virtual CefString GetElementTagName() OVERRIDE; + virtual bool HasElementAttributes() OVERRIDE; + virtual bool HasElementAttribute(const CefString& attrName) OVERRIDE; + virtual CefString GetElementAttribute(const CefString& attrName) OVERRIDE; + virtual void GetElementAttributes(AttributeMap& attrMap) OVERRIDE; + virtual bool SetElementAttribute(const CefString& attrName, + const CefString& value) OVERRIDE; + virtual CefString GetElementInnerText() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_DOMNODE_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/domvisitor_ctocpp.cc b/cef3/libcef_dll/ctocpp/domvisitor_ctocpp.cc new file mode 100644 index 000000000..a3701cb25 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/domvisitor_ctocpp.cc @@ -0,0 +1,40 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/domdocument_cpptoc.h" +#include "libcef_dll/ctocpp/domvisitor_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefDOMVisitorCToCpp::Visit(CefRefPtr document) { + if (CEF_MEMBER_MISSING(struct_, visit)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: document; type: refptr_diff + DCHECK(document.get()); + if (!document.get()) + return; + + // Execute + struct_->visit(struct_, + CefDOMDocumentCppToC::Wrap(document)); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/domvisitor_ctocpp.h b/cef3/libcef_dll/ctocpp/domvisitor_ctocpp.h new file mode 100644 index 000000000..48981eb9b --- /dev/null +++ b/cef3/libcef_dll/ctocpp/domvisitor_ctocpp.h @@ -0,0 +1,40 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_DOMVISITOR_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_DOMVISITOR_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_dom.h" +#include "include/capi/cef_dom_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefDOMVisitorCToCpp + : public CefCToCpp { + public: + explicit CefDOMVisitorCToCpp(cef_domvisitor_t* str) + : CefCToCpp(str) {} + virtual ~CefDOMVisitorCToCpp() {} + + // CefDOMVisitor methods + virtual void Visit(CefRefPtr document) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_DOMVISITOR_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/download_handler_ctocpp.cc b/cef3/libcef_dll/ctocpp/download_handler_ctocpp.cc new file mode 100644 index 000000000..80c857bcb --- /dev/null +++ b/cef3/libcef_dll/ctocpp/download_handler_ctocpp.cc @@ -0,0 +1,88 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/before_download_callback_cpptoc.h" +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/cpptoc/download_item_cpptoc.h" +#include "libcef_dll/cpptoc/download_item_callback_cpptoc.h" +#include "libcef_dll/ctocpp/download_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefDownloadHandlerCToCpp::OnBeforeDownload(CefRefPtr browser, + CefRefPtr download_item, const CefString& suggested_name, + CefRefPtr callback) { + if (CEF_MEMBER_MISSING(struct_, on_before_download)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + // Verify param: download_item; type: refptr_diff + DCHECK(download_item.get()); + if (!download_item.get()) + return; + // Verify param: suggested_name; type: string_byref_const + DCHECK(!suggested_name.empty()); + if (suggested_name.empty()) + return; + // Verify param: callback; type: refptr_diff + DCHECK(callback.get()); + if (!callback.get()) + return; + + // Execute + struct_->on_before_download(struct_, + CefBrowserCppToC::Wrap(browser), + CefDownloadItemCppToC::Wrap(download_item), + suggested_name.GetStruct(), + CefBeforeDownloadCallbackCppToC::Wrap(callback)); +} + +void CefDownloadHandlerCToCpp::OnDownloadUpdated(CefRefPtr browser, + CefRefPtr download_item, + CefRefPtr callback) { + if (CEF_MEMBER_MISSING(struct_, on_download_updated)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + // Verify param: download_item; type: refptr_diff + DCHECK(download_item.get()); + if (!download_item.get()) + return; + // Verify param: callback; type: refptr_diff + DCHECK(callback.get()); + if (!callback.get()) + return; + + // Execute + struct_->on_download_updated(struct_, + CefBrowserCppToC::Wrap(browser), + CefDownloadItemCppToC::Wrap(download_item), + CefDownloadItemCallbackCppToC::Wrap(callback)); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/download_handler_ctocpp.h b/cef3/libcef_dll/ctocpp/download_handler_ctocpp.h new file mode 100644 index 000000000..d8fbd13f9 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/download_handler_ctocpp.h @@ -0,0 +1,48 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_DOWNLOAD_HANDLER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_DOWNLOAD_HANDLER_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_download_handler.h" +#include "include/capi/cef_download_handler_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefDownloadHandlerCToCpp + : public CefCToCpp { + public: + explicit CefDownloadHandlerCToCpp(cef_download_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefDownloadHandlerCToCpp() {} + + // CefDownloadHandler methods + virtual void OnBeforeDownload(CefRefPtr browser, + CefRefPtr download_item, + const CefString& suggested_name, + CefRefPtr callback) OVERRIDE; + virtual void OnDownloadUpdated(CefRefPtr browser, + CefRefPtr download_item, + CefRefPtr callback) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_DOWNLOAD_HANDLER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/download_item_callback_ctocpp.cc b/cef3/libcef_dll/ctocpp/download_item_callback_ctocpp.cc new file mode 100644 index 000000000..092787640 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/download_item_callback_ctocpp.cc @@ -0,0 +1,33 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/download_item_callback_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefDownloadItemCallbackCToCpp::Cancel() { + if (CEF_MEMBER_MISSING(struct_, cancel)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->cancel(struct_); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/download_item_callback_ctocpp.h b/cef3/libcef_dll/ctocpp/download_item_callback_ctocpp.h new file mode 100644 index 000000000..f10b8fd5d --- /dev/null +++ b/cef3/libcef_dll/ctocpp/download_item_callback_ctocpp.h @@ -0,0 +1,42 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_DOWNLOAD_ITEM_CALLBACK_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_DOWNLOAD_ITEM_CALLBACK_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_download_handler.h" +#include "include/capi/cef_download_handler_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefDownloadItemCallbackCToCpp + : public CefCToCpp { + public: + explicit CefDownloadItemCallbackCToCpp(cef_download_item_callback_t* str) + : CefCToCpp(str) {} + virtual ~CefDownloadItemCallbackCToCpp() {} + + // CefDownloadItemCallback methods + virtual void Cancel() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_DOWNLOAD_ITEM_CALLBACK_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/download_item_ctocpp.cc b/cef3/libcef_dll/ctocpp/download_item_ctocpp.cc new file mode 100644 index 000000000..ae50f3ffc --- /dev/null +++ b/cef3/libcef_dll/ctocpp/download_item_ctocpp.cc @@ -0,0 +1,241 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/download_item_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefDownloadItemCToCpp::IsValid() { + if (CEF_MEMBER_MISSING(struct_, is_valid)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_valid(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefDownloadItemCToCpp::IsInProgress() { + if (CEF_MEMBER_MISSING(struct_, is_in_progress)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_in_progress(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefDownloadItemCToCpp::IsComplete() { + if (CEF_MEMBER_MISSING(struct_, is_complete)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_complete(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefDownloadItemCToCpp::IsCanceled() { + if (CEF_MEMBER_MISSING(struct_, is_canceled)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_canceled(struct_); + + // Return type: bool + return _retval?true:false; +} + +int64 CefDownloadItemCToCpp::GetCurrentSpeed() { + if (CEF_MEMBER_MISSING(struct_, get_current_speed)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int64 _retval = struct_->get_current_speed(struct_); + + // Return type: simple + return _retval; +} + +int CefDownloadItemCToCpp::GetPercentComplete() { + if (CEF_MEMBER_MISSING(struct_, get_percent_complete)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_percent_complete(struct_); + + // Return type: simple + return _retval; +} + +int64 CefDownloadItemCToCpp::GetTotalBytes() { + if (CEF_MEMBER_MISSING(struct_, get_total_bytes)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int64 _retval = struct_->get_total_bytes(struct_); + + // Return type: simple + return _retval; +} + +int64 CefDownloadItemCToCpp::GetReceivedBytes() { + if (CEF_MEMBER_MISSING(struct_, get_received_bytes)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int64 _retval = struct_->get_received_bytes(struct_); + + // Return type: simple + return _retval; +} + +CefTime CefDownloadItemCToCpp::GetStartTime() { + if (CEF_MEMBER_MISSING(struct_, get_start_time)) + return CefTime(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_time_t _retval = struct_->get_start_time(struct_); + + // Return type: simple + return _retval; +} + +CefTime CefDownloadItemCToCpp::GetEndTime() { + if (CEF_MEMBER_MISSING(struct_, get_end_time)) + return CefTime(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_time_t _retval = struct_->get_end_time(struct_); + + // Return type: simple + return _retval; +} + +CefString CefDownloadItemCToCpp::GetFullPath() { + if (CEF_MEMBER_MISSING(struct_, get_full_path)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_full_path(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +int32 CefDownloadItemCToCpp::GetId() { + if (CEF_MEMBER_MISSING(struct_, get_id)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int32 _retval = struct_->get_id(struct_); + + // Return type: simple + return _retval; +} + +CefString CefDownloadItemCToCpp::GetURL() { + if (CEF_MEMBER_MISSING(struct_, get_url)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_url(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefDownloadItemCToCpp::GetSuggestedFileName() { + if (CEF_MEMBER_MISSING(struct_, get_suggested_file_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_suggested_file_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefDownloadItemCToCpp::GetContentDisposition() { + if (CEF_MEMBER_MISSING(struct_, get_content_disposition)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_content_disposition(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefDownloadItemCToCpp::GetMimeType() { + if (CEF_MEMBER_MISSING(struct_, get_mime_type)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_mime_type(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/download_item_ctocpp.h b/cef3/libcef_dll/ctocpp/download_item_ctocpp.h new file mode 100644 index 000000000..be2e7b35a --- /dev/null +++ b/cef3/libcef_dll/ctocpp/download_item_ctocpp.h @@ -0,0 +1,57 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_DOWNLOAD_ITEM_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_DOWNLOAD_ITEM_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_download_item.h" +#include "include/capi/cef_download_item_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefDownloadItemCToCpp + : public CefCToCpp { + public: + explicit CefDownloadItemCToCpp(cef_download_item_t* str) + : CefCToCpp( + str) {} + virtual ~CefDownloadItemCToCpp() {} + + // CefDownloadItem methods + virtual bool IsValid() OVERRIDE; + virtual bool IsInProgress() OVERRIDE; + virtual bool IsComplete() OVERRIDE; + virtual bool IsCanceled() OVERRIDE; + virtual int64 GetCurrentSpeed() OVERRIDE; + virtual int GetPercentComplete() OVERRIDE; + virtual int64 GetTotalBytes() OVERRIDE; + virtual int64 GetReceivedBytes() OVERRIDE; + virtual CefTime GetStartTime() OVERRIDE; + virtual CefTime GetEndTime() OVERRIDE; + virtual CefString GetFullPath() OVERRIDE; + virtual int32 GetId() OVERRIDE; + virtual CefString GetURL() OVERRIDE; + virtual CefString GetSuggestedFileName() OVERRIDE; + virtual CefString GetContentDisposition() OVERRIDE; + virtual CefString GetMimeType() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_DOWNLOAD_ITEM_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/file_dialog_callback_ctocpp.cc b/cef3/libcef_dll/ctocpp/file_dialog_callback_ctocpp.cc new file mode 100644 index 000000000..c88c36739 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/file_dialog_callback_ctocpp.cc @@ -0,0 +1,56 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/file_dialog_callback_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefFileDialogCallbackCToCpp::Continue( + const std::vector& file_paths) { + if (CEF_MEMBER_MISSING(struct_, cont)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: file_paths; type: string_vec_byref_const + cef_string_list_t file_pathsList = cef_string_list_alloc(); + DCHECK(file_pathsList); + if (file_pathsList) + transfer_string_list_contents(file_paths, file_pathsList); + + // Execute + struct_->cont(struct_, + file_pathsList); + + // Restore param:file_paths; type: string_vec_byref_const + if (file_pathsList) + cef_string_list_free(file_pathsList); +} + +void CefFileDialogCallbackCToCpp::Cancel() { + if (CEF_MEMBER_MISSING(struct_, cancel)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->cancel(struct_); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/file_dialog_callback_ctocpp.h b/cef3/libcef_dll/ctocpp/file_dialog_callback_ctocpp.h new file mode 100644 index 000000000..53ff2a6c8 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/file_dialog_callback_ctocpp.h @@ -0,0 +1,44 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_FILE_DIALOG_CALLBACK_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_FILE_DIALOG_CALLBACK_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include +#include "include/cef_dialog_handler.h" +#include "include/capi/cef_dialog_handler_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefFileDialogCallbackCToCpp + : public CefCToCpp { + public: + explicit CefFileDialogCallbackCToCpp(cef_file_dialog_callback_t* str) + : CefCToCpp(str) {} + virtual ~CefFileDialogCallbackCToCpp() {} + + // CefFileDialogCallback methods + virtual void Continue(const std::vector& file_paths) OVERRIDE; + virtual void Cancel() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_FILE_DIALOG_CALLBACK_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/focus_handler_ctocpp.cc b/cef3/libcef_dll/ctocpp/focus_handler_ctocpp.cc new file mode 100644 index 000000000..f09ba2701 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/focus_handler_ctocpp.cc @@ -0,0 +1,79 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/ctocpp/focus_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefFocusHandlerCToCpp::OnTakeFocus(CefRefPtr browser, + bool next) { + if (CEF_MEMBER_MISSING(struct_, on_take_focus)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + + // Execute + struct_->on_take_focus(struct_, + CefBrowserCppToC::Wrap(browser), + next); +} + +bool CefFocusHandlerCToCpp::OnSetFocus(CefRefPtr browser, + FocusSource source) { + if (CEF_MEMBER_MISSING(struct_, on_set_focus)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + + // Execute + int _retval = struct_->on_set_focus(struct_, + CefBrowserCppToC::Wrap(browser), + source); + + // Return type: bool + return _retval?true:false; +} + +void CefFocusHandlerCToCpp::OnGotFocus(CefRefPtr browser) { + if (CEF_MEMBER_MISSING(struct_, on_got_focus)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + + // Execute + struct_->on_got_focus(struct_, + CefBrowserCppToC::Wrap(browser)); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/focus_handler_ctocpp.h b/cef3/libcef_dll/ctocpp/focus_handler_ctocpp.h new file mode 100644 index 000000000..93dcfe2ba --- /dev/null +++ b/cef3/libcef_dll/ctocpp/focus_handler_ctocpp.h @@ -0,0 +1,45 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_FOCUS_HANDLER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_FOCUS_HANDLER_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_focus_handler.h" +#include "include/capi/cef_focus_handler_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefFocusHandlerCToCpp + : public CefCToCpp { + public: + explicit CefFocusHandlerCToCpp(cef_focus_handler_t* str) + : CefCToCpp( + str) {} + virtual ~CefFocusHandlerCToCpp() {} + + // CefFocusHandler methods + virtual void OnTakeFocus(CefRefPtr browser, bool next) OVERRIDE; + virtual bool OnSetFocus(CefRefPtr browser, + FocusSource source) OVERRIDE; + virtual void OnGotFocus(CefRefPtr browser) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_FOCUS_HANDLER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/frame_ctocpp.cc b/cef3/libcef_dll/ctocpp/frame_ctocpp.cc new file mode 100644 index 000000000..bcb0b47c8 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/frame_ctocpp.cc @@ -0,0 +1,351 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/domvisitor_cpptoc.h" +#include "libcef_dll/cpptoc/string_visitor_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/frame_ctocpp.h" +#include "libcef_dll/ctocpp/request_ctocpp.h" +#include "libcef_dll/ctocpp/v8context_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefFrameCToCpp::IsValid() { + if (CEF_MEMBER_MISSING(struct_, is_valid)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_valid(struct_); + + // Return type: bool + return _retval?true:false; +} + +void CefFrameCToCpp::Undo() { + if (CEF_MEMBER_MISSING(struct_, undo)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->undo(struct_); +} + +void CefFrameCToCpp::Redo() { + if (CEF_MEMBER_MISSING(struct_, redo)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->redo(struct_); +} + +void CefFrameCToCpp::Cut() { + if (CEF_MEMBER_MISSING(struct_, cut)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->cut(struct_); +} + +void CefFrameCToCpp::Copy() { + if (CEF_MEMBER_MISSING(struct_, copy)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->copy(struct_); +} + +void CefFrameCToCpp::Paste() { + if (CEF_MEMBER_MISSING(struct_, paste)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->paste(struct_); +} + +void CefFrameCToCpp::Delete() { + if (CEF_MEMBER_MISSING(struct_, del)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->del(struct_); +} + +void CefFrameCToCpp::SelectAll() { + if (CEF_MEMBER_MISSING(struct_, select_all)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->select_all(struct_); +} + +void CefFrameCToCpp::ViewSource() { + if (CEF_MEMBER_MISSING(struct_, view_source)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->view_source(struct_); +} + +void CefFrameCToCpp::GetSource(CefRefPtr visitor) { + if (CEF_MEMBER_MISSING(struct_, get_source)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: visitor; type: refptr_diff + DCHECK(visitor.get()); + if (!visitor.get()) + return; + + // Execute + struct_->get_source(struct_, + CefStringVisitorCppToC::Wrap(visitor)); +} + +void CefFrameCToCpp::GetText(CefRefPtr visitor) { + if (CEF_MEMBER_MISSING(struct_, get_text)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: visitor; type: refptr_diff + DCHECK(visitor.get()); + if (!visitor.get()) + return; + + // Execute + struct_->get_text(struct_, + CefStringVisitorCppToC::Wrap(visitor)); +} + +void CefFrameCToCpp::LoadRequest(CefRefPtr request) { + if (CEF_MEMBER_MISSING(struct_, load_request)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: request; type: refptr_same + DCHECK(request.get()); + if (!request.get()) + return; + + // Execute + struct_->load_request(struct_, + CefRequestCToCpp::Unwrap(request)); +} + +void CefFrameCToCpp::LoadURL(const CefString& url) { + if (CEF_MEMBER_MISSING(struct_, load_url)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: url; type: string_byref_const + DCHECK(!url.empty()); + if (url.empty()) + return; + + // Execute + struct_->load_url(struct_, + url.GetStruct()); +} + +void CefFrameCToCpp::LoadString(const CefString& string_val, + const CefString& url) { + if (CEF_MEMBER_MISSING(struct_, load_string)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: string_val; type: string_byref_const + DCHECK(!string_val.empty()); + if (string_val.empty()) + return; + // Verify param: url; type: string_byref_const + DCHECK(!url.empty()); + if (url.empty()) + return; + + // Execute + struct_->load_string(struct_, + string_val.GetStruct(), + url.GetStruct()); +} + +void CefFrameCToCpp::ExecuteJavaScript(const CefString& code, + const CefString& script_url, int start_line) { + if (CEF_MEMBER_MISSING(struct_, execute_java_script)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: code; type: string_byref_const + DCHECK(!code.empty()); + if (code.empty()) + return; + // Unverified params: script_url + + // Execute + struct_->execute_java_script(struct_, + code.GetStruct(), + script_url.GetStruct(), + start_line); +} + +bool CefFrameCToCpp::IsMain() { + if (CEF_MEMBER_MISSING(struct_, is_main)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_main(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefFrameCToCpp::IsFocused() { + if (CEF_MEMBER_MISSING(struct_, is_focused)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_focused(struct_); + + // Return type: bool + return _retval?true:false; +} + +CefString CefFrameCToCpp::GetName() { + if (CEF_MEMBER_MISSING(struct_, get_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +int64 CefFrameCToCpp::GetIdentifier() { + if (CEF_MEMBER_MISSING(struct_, get_identifier)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int64 _retval = struct_->get_identifier(struct_); + + // Return type: simple + return _retval; +} + +CefRefPtr CefFrameCToCpp::GetParent() { + if (CEF_MEMBER_MISSING(struct_, get_parent)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_frame_t* _retval = struct_->get_parent(struct_); + + // Return type: refptr_same + return CefFrameCToCpp::Wrap(_retval); +} + +CefString CefFrameCToCpp::GetURL() { + if (CEF_MEMBER_MISSING(struct_, get_url)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_url(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefRefPtr CefFrameCToCpp::GetBrowser() { + if (CEF_MEMBER_MISSING(struct_, get_browser)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_browser_t* _retval = struct_->get_browser(struct_); + + // Return type: refptr_same + return CefBrowserCToCpp::Wrap(_retval); +} + +CefRefPtr CefFrameCToCpp::GetV8Context() { + if (CEF_MEMBER_MISSING(struct_, get_v8context)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8context_t* _retval = struct_->get_v8context(struct_); + + // Return type: refptr_same + return CefV8ContextCToCpp::Wrap(_retval); +} + +void CefFrameCToCpp::VisitDOM(CefRefPtr visitor) { + if (CEF_MEMBER_MISSING(struct_, visit_dom)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: visitor; type: refptr_diff + DCHECK(visitor.get()); + if (!visitor.get()) + return; + + // Execute + struct_->visit_dom(struct_, + CefDOMVisitorCppToC::Wrap(visitor)); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = + 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/frame_ctocpp.h b/cef3/libcef_dll/ctocpp/frame_ctocpp.h new file mode 100644 index 000000000..55fb342d7 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/frame_ctocpp.h @@ -0,0 +1,69 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_FRAME_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_FRAME_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_frame.h" +#include "include/capi/cef_frame_capi.h" +#include "include/cef_browser.h" +#include "include/capi/cef_browser_capi.h" +#include "include/cef_v8.h" +#include "include/capi/cef_v8_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefFrameCToCpp + : public CefCToCpp { + public: + explicit CefFrameCToCpp(cef_frame_t* str) + : CefCToCpp(str) {} + virtual ~CefFrameCToCpp() {} + + // CefFrame methods + virtual bool IsValid() OVERRIDE; + virtual void Undo() OVERRIDE; + virtual void Redo() OVERRIDE; + virtual void Cut() OVERRIDE; + virtual void Copy() OVERRIDE; + virtual void Paste() OVERRIDE; + virtual void Delete() OVERRIDE; + virtual void SelectAll() OVERRIDE; + virtual void ViewSource() OVERRIDE; + virtual void GetSource(CefRefPtr visitor) OVERRIDE; + virtual void GetText(CefRefPtr visitor) OVERRIDE; + virtual void LoadRequest(CefRefPtr request) OVERRIDE; + virtual void LoadURL(const CefString& url) OVERRIDE; + virtual void LoadString(const CefString& string_val, + const CefString& url) OVERRIDE; + virtual void ExecuteJavaScript(const CefString& code, + const CefString& script_url, int start_line) OVERRIDE; + virtual bool IsMain() OVERRIDE; + virtual bool IsFocused() OVERRIDE; + virtual CefString GetName() OVERRIDE; + virtual int64 GetIdentifier() OVERRIDE; + virtual CefRefPtr GetParent() OVERRIDE; + virtual CefString GetURL() OVERRIDE; + virtual CefRefPtr GetBrowser() OVERRIDE; + virtual CefRefPtr GetV8Context() OVERRIDE; + virtual void VisitDOM(CefRefPtr visitor) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_FRAME_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/geolocation_callback_ctocpp.cc b/cef3/libcef_dll/ctocpp/geolocation_callback_ctocpp.cc new file mode 100644 index 000000000..b0909cb3d --- /dev/null +++ b/cef3/libcef_dll/ctocpp/geolocation_callback_ctocpp.cc @@ -0,0 +1,34 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/geolocation_callback_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefGeolocationCallbackCToCpp::Continue(bool allow) { + if (CEF_MEMBER_MISSING(struct_, cont)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->cont(struct_, + allow); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/geolocation_callback_ctocpp.h b/cef3/libcef_dll/ctocpp/geolocation_callback_ctocpp.h new file mode 100644 index 000000000..52d17a9ca --- /dev/null +++ b/cef3/libcef_dll/ctocpp/geolocation_callback_ctocpp.h @@ -0,0 +1,42 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_GEOLOCATION_CALLBACK_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_GEOLOCATION_CALLBACK_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_geolocation_handler.h" +#include "include/capi/cef_geolocation_handler_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefGeolocationCallbackCToCpp + : public CefCToCpp { + public: + explicit CefGeolocationCallbackCToCpp(cef_geolocation_callback_t* str) + : CefCToCpp(str) {} + virtual ~CefGeolocationCallbackCToCpp() {} + + // CefGeolocationCallback methods + virtual void Continue(bool allow) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_GEOLOCATION_CALLBACK_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/geolocation_handler_ctocpp.cc b/cef3/libcef_dll/ctocpp/geolocation_handler_ctocpp.cc new file mode 100644 index 000000000..19aa6d70f --- /dev/null +++ b/cef3/libcef_dll/ctocpp/geolocation_handler_ctocpp.cc @@ -0,0 +1,78 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/cpptoc/geolocation_callback_cpptoc.h" +#include "libcef_dll/ctocpp/geolocation_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefGeolocationHandlerCToCpp::OnRequestGeolocationPermission( + CefRefPtr browser, const CefString& requesting_url, + int request_id, CefRefPtr callback) { + if (CEF_MEMBER_MISSING(struct_, on_request_geolocation_permission)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + // Verify param: requesting_url; type: string_byref_const + DCHECK(!requesting_url.empty()); + if (requesting_url.empty()) + return; + // Verify param: callback; type: refptr_diff + DCHECK(callback.get()); + if (!callback.get()) + return; + + // Execute + struct_->on_request_geolocation_permission(struct_, + CefBrowserCppToC::Wrap(browser), + requesting_url.GetStruct(), + request_id, + CefGeolocationCallbackCppToC::Wrap(callback)); +} + +void CefGeolocationHandlerCToCpp::OnCancelGeolocationPermission( + CefRefPtr browser, const CefString& requesting_url, + int request_id) { + if (CEF_MEMBER_MISSING(struct_, on_cancel_geolocation_permission)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + // Verify param: requesting_url; type: string_byref_const + DCHECK(!requesting_url.empty()); + if (requesting_url.empty()) + return; + + // Execute + struct_->on_cancel_geolocation_permission(struct_, + CefBrowserCppToC::Wrap(browser), + requesting_url.GetStruct(), + request_id); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/geolocation_handler_ctocpp.h b/cef3/libcef_dll/ctocpp/geolocation_handler_ctocpp.h new file mode 100644 index 000000000..3e35292aa --- /dev/null +++ b/cef3/libcef_dll/ctocpp/geolocation_handler_ctocpp.h @@ -0,0 +1,46 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_GEOLOCATION_HANDLER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_GEOLOCATION_HANDLER_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_geolocation_handler.h" +#include "include/capi/cef_geolocation_handler_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefGeolocationHandlerCToCpp + : public CefCToCpp { + public: + explicit CefGeolocationHandlerCToCpp(cef_geolocation_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefGeolocationHandlerCToCpp() {} + + // CefGeolocationHandler methods + virtual void OnRequestGeolocationPermission(CefRefPtr browser, + const CefString& requesting_url, int request_id, + CefRefPtr callback) OVERRIDE; + virtual void OnCancelGeolocationPermission(CefRefPtr browser, + const CefString& requesting_url, int request_id) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_GEOLOCATION_HANDLER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/get_geolocation_callback_ctocpp.cc b/cef3/libcef_dll/ctocpp/get_geolocation_callback_ctocpp.cc new file mode 100644 index 000000000..b90fcfbbf --- /dev/null +++ b/cef3/libcef_dll/ctocpp/get_geolocation_callback_ctocpp.cc @@ -0,0 +1,36 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/get_geolocation_callback_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefGetGeolocationCallbackCToCpp::OnLocationUpdate( + const CefGeoposition& position) { + if (CEF_MEMBER_MISSING(struct_, on_location_update)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->on_location_update(struct_, + &position); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = + 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/get_geolocation_callback_ctocpp.h b/cef3/libcef_dll/ctocpp/get_geolocation_callback_ctocpp.h new file mode 100644 index 000000000..3cab47b3f --- /dev/null +++ b/cef3/libcef_dll/ctocpp/get_geolocation_callback_ctocpp.h @@ -0,0 +1,42 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_GET_GEOLOCATION_CALLBACK_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_GET_GEOLOCATION_CALLBACK_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_geolocation.h" +#include "include/capi/cef_geolocation_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefGetGeolocationCallbackCToCpp + : public CefCToCpp { + public: + explicit CefGetGeolocationCallbackCToCpp(cef_get_geolocation_callback_t* str) + : CefCToCpp(str) {} + virtual ~CefGetGeolocationCallbackCToCpp() {} + + // CefGetGeolocationCallback methods + virtual void OnLocationUpdate(const CefGeoposition& position) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_GET_GEOLOCATION_CALLBACK_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/jsdialog_callback_ctocpp.cc b/cef3/libcef_dll/ctocpp/jsdialog_callback_ctocpp.cc new file mode 100644 index 000000000..110d01d89 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/jsdialog_callback_ctocpp.cc @@ -0,0 +1,38 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/jsdialog_callback_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefJSDialogCallbackCToCpp::Continue(bool success, + const CefString& user_input) { + if (CEF_MEMBER_MISSING(struct_, cont)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: user_input + + // Execute + struct_->cont(struct_, + success, + user_input.GetStruct()); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/jsdialog_callback_ctocpp.h b/cef3/libcef_dll/ctocpp/jsdialog_callback_ctocpp.h new file mode 100644 index 000000000..6af7a4cb0 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/jsdialog_callback_ctocpp.h @@ -0,0 +1,42 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_JSDIALOG_CALLBACK_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_JSDIALOG_CALLBACK_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_jsdialog_handler.h" +#include "include/capi/cef_jsdialog_handler_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefJSDialogCallbackCToCpp + : public CefCToCpp { + public: + explicit CefJSDialogCallbackCToCpp(cef_jsdialog_callback_t* str) + : CefCToCpp(str) {} + virtual ~CefJSDialogCallbackCToCpp() {} + + // CefJSDialogCallback methods + virtual void Continue(bool success, const CefString& user_input) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_JSDIALOG_CALLBACK_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/jsdialog_handler_ctocpp.cc b/cef3/libcef_dll/ctocpp/jsdialog_handler_ctocpp.cc new file mode 100644 index 000000000..9eceb4189 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/jsdialog_handler_ctocpp.cc @@ -0,0 +1,116 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/cpptoc/jsdialog_callback_cpptoc.h" +#include "libcef_dll/ctocpp/jsdialog_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefJSDialogHandlerCToCpp::OnJSDialog(CefRefPtr browser, + const CefString& origin_url, const CefString& accept_lang, + JSDialogType dialog_type, const CefString& message_text, + const CefString& default_prompt_text, + CefRefPtr callback, bool& suppress_message) { + if (CEF_MEMBER_MISSING(struct_, on_jsdialog)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + // Verify param: origin_url; type: string_byref_const + DCHECK(!origin_url.empty()); + if (origin_url.empty()) + return false; + // Verify param: callback; type: refptr_diff + DCHECK(callback.get()); + if (!callback.get()) + return false; + // Unverified params: accept_lang, message_text, default_prompt_text + + // Translate param: suppress_message; type: bool_byref + int suppress_messageInt = suppress_message; + + // Execute + int _retval = struct_->on_jsdialog(struct_, + CefBrowserCppToC::Wrap(browser), + origin_url.GetStruct(), + accept_lang.GetStruct(), + dialog_type, + message_text.GetStruct(), + default_prompt_text.GetStruct(), + CefJSDialogCallbackCppToC::Wrap(callback), + &suppress_messageInt); + + // Restore param:suppress_message; type: bool_byref + suppress_message = suppress_messageInt?true:false; + + // Return type: bool + return _retval?true:false; +} + +bool CefJSDialogHandlerCToCpp::OnBeforeUnloadDialog( + CefRefPtr browser, const CefString& message_text, + bool is_reload, CefRefPtr callback) { + if (CEF_MEMBER_MISSING(struct_, on_before_unload_dialog)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + // Verify param: callback; type: refptr_diff + DCHECK(callback.get()); + if (!callback.get()) + return false; + // Unverified params: message_text + + // Execute + int _retval = struct_->on_before_unload_dialog(struct_, + CefBrowserCppToC::Wrap(browser), + message_text.GetStruct(), + is_reload, + CefJSDialogCallbackCppToC::Wrap(callback)); + + // Return type: bool + return _retval?true:false; +} + +void CefJSDialogHandlerCToCpp::OnResetDialogState( + CefRefPtr browser) { + if (CEF_MEMBER_MISSING(struct_, on_reset_dialog_state)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + + // Execute + struct_->on_reset_dialog_state(struct_, + CefBrowserCppToC::Wrap(browser)); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/jsdialog_handler_ctocpp.h b/cef3/libcef_dll/ctocpp/jsdialog_handler_ctocpp.h new file mode 100644 index 000000000..46e93bfe7 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/jsdialog_handler_ctocpp.h @@ -0,0 +1,51 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_JSDIALOG_HANDLER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_JSDIALOG_HANDLER_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_jsdialog_handler.h" +#include "include/capi/cef_jsdialog_handler_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefJSDialogHandlerCToCpp + : public CefCToCpp { + public: + explicit CefJSDialogHandlerCToCpp(cef_jsdialog_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefJSDialogHandlerCToCpp() {} + + // CefJSDialogHandler methods + virtual bool OnJSDialog(CefRefPtr browser, + const CefString& origin_url, const CefString& accept_lang, + JSDialogType dialog_type, const CefString& message_text, + const CefString& default_prompt_text, + CefRefPtr callback, + bool& suppress_message) OVERRIDE; + virtual bool OnBeforeUnloadDialog(CefRefPtr browser, + const CefString& message_text, bool is_reload, + CefRefPtr callback) OVERRIDE; + virtual void OnResetDialogState(CefRefPtr browser) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_JSDIALOG_HANDLER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/keyboard_handler_ctocpp.cc b/cef3/libcef_dll/ctocpp/keyboard_handler_ctocpp.cc new file mode 100644 index 000000000..ccfa66f4c --- /dev/null +++ b/cef3/libcef_dll/ctocpp/keyboard_handler_ctocpp.cc @@ -0,0 +1,81 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/ctocpp/keyboard_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefKeyboardHandlerCToCpp::OnPreKeyEvent(CefRefPtr browser, + const CefKeyEvent& event, CefEventHandle os_event, + bool* is_keyboard_shortcut) { + if (CEF_MEMBER_MISSING(struct_, on_pre_key_event)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + // Verify param: is_keyboard_shortcut; type: bool_byaddr + DCHECK(is_keyboard_shortcut); + if (!is_keyboard_shortcut) + return false; + + // Translate param: is_keyboard_shortcut; type: bool_byaddr + int is_keyboard_shortcutInt = is_keyboard_shortcut?*is_keyboard_shortcut:0; + + // Execute + int _retval = struct_->on_pre_key_event(struct_, + CefBrowserCppToC::Wrap(browser), + &event, + os_event, + &is_keyboard_shortcutInt); + + // Restore param:is_keyboard_shortcut; type: bool_byaddr + if (is_keyboard_shortcut) + *is_keyboard_shortcut = is_keyboard_shortcutInt?true:false; + + // Return type: bool + return _retval?true:false; +} + +bool CefKeyboardHandlerCToCpp::OnKeyEvent(CefRefPtr browser, + const CefKeyEvent& event, CefEventHandle os_event) { + if (CEF_MEMBER_MISSING(struct_, on_key_event)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + + // Execute + int _retval = struct_->on_key_event(struct_, + CefBrowserCppToC::Wrap(browser), + &event, + os_event); + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/keyboard_handler_ctocpp.h b/cef3/libcef_dll/ctocpp/keyboard_handler_ctocpp.h new file mode 100644 index 000000000..5a8c2ddd0 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/keyboard_handler_ctocpp.h @@ -0,0 +1,46 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_KEYBOARD_HANDLER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_KEYBOARD_HANDLER_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_keyboard_handler.h" +#include "include/capi/cef_keyboard_handler_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefKeyboardHandlerCToCpp + : public CefCToCpp { + public: + explicit CefKeyboardHandlerCToCpp(cef_keyboard_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefKeyboardHandlerCToCpp() {} + + // CefKeyboardHandler methods + virtual bool OnPreKeyEvent(CefRefPtr browser, + const CefKeyEvent& event, CefEventHandle os_event, + bool* is_keyboard_shortcut) OVERRIDE; + virtual bool OnKeyEvent(CefRefPtr browser, + const CefKeyEvent& event, CefEventHandle os_event) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_KEYBOARD_HANDLER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/life_span_handler_ctocpp.cc b/cef3/libcef_dll/ctocpp/life_span_handler_ctocpp.cc new file mode 100644 index 000000000..48c6285d8 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/life_span_handler_ctocpp.cc @@ -0,0 +1,156 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/cpptoc/frame_cpptoc.h" +#include "libcef_dll/ctocpp/client_ctocpp.h" +#include "libcef_dll/ctocpp/life_span_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefLifeSpanHandlerCToCpp::OnBeforePopup(CefRefPtr browser, + CefRefPtr frame, const CefString& target_url, + const CefString& target_frame_name, const CefPopupFeatures& popupFeatures, + CefWindowInfo& windowInfo, CefRefPtr& client, + CefBrowserSettings& settings, bool* no_javascript_access) { + if (CEF_MEMBER_MISSING(struct_, on_before_popup)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + // Verify param: frame; type: refptr_diff + DCHECK(frame.get()); + if (!frame.get()) + return false; + // Verify param: no_javascript_access; type: bool_byaddr + DCHECK(no_javascript_access); + if (!no_javascript_access) + return false; + // Unverified params: target_url, target_frame_name + + // Translate param: client; type: refptr_same_byref + cef_client_t* clientStruct = NULL; + if (client.get()) + clientStruct = CefClientCToCpp::Unwrap(client); + cef_client_t* clientOrig = clientStruct; + // Translate param: no_javascript_access; type: bool_byaddr + int no_javascript_accessInt = no_javascript_access?*no_javascript_access:0; + + // Execute + int _retval = struct_->on_before_popup(struct_, + CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), + target_url.GetStruct(), + target_frame_name.GetStruct(), + &popupFeatures, + &windowInfo, + &clientStruct, + &settings, + &no_javascript_accessInt); + + // Restore param:client; type: refptr_same_byref + if (clientStruct) { + if (clientStruct != clientOrig) { + client = CefClientCToCpp::Wrap(clientStruct); + } + } else { + client = NULL; + } + // Restore param:no_javascript_access; type: bool_byaddr + if (no_javascript_access) + *no_javascript_access = no_javascript_accessInt?true:false; + + // Return type: bool + return _retval?true:false; +} + +void CefLifeSpanHandlerCToCpp::OnAfterCreated(CefRefPtr browser) { + if (CEF_MEMBER_MISSING(struct_, on_after_created)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + + // Execute + struct_->on_after_created(struct_, + CefBrowserCppToC::Wrap(browser)); +} + +bool CefLifeSpanHandlerCToCpp::RunModal(CefRefPtr browser) { + if (CEF_MEMBER_MISSING(struct_, run_modal)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + + // Execute + int _retval = struct_->run_modal(struct_, + CefBrowserCppToC::Wrap(browser)); + + // Return type: bool + return _retval?true:false; +} + +bool CefLifeSpanHandlerCToCpp::DoClose(CefRefPtr browser) { + if (CEF_MEMBER_MISSING(struct_, do_close)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + + // Execute + int _retval = struct_->do_close(struct_, + CefBrowserCppToC::Wrap(browser)); + + // Return type: bool + return _retval?true:false; +} + +void CefLifeSpanHandlerCToCpp::OnBeforeClose(CefRefPtr browser) { + if (CEF_MEMBER_MISSING(struct_, on_before_close)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + + // Execute + struct_->on_before_close(struct_, + CefBrowserCppToC::Wrap(browser)); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/life_span_handler_ctocpp.h b/cef3/libcef_dll/ctocpp/life_span_handler_ctocpp.h new file mode 100644 index 000000000..72cd6ef9b --- /dev/null +++ b/cef3/libcef_dll/ctocpp/life_span_handler_ctocpp.h @@ -0,0 +1,53 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_LIFE_SPAN_HANDLER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_LIFE_SPAN_HANDLER_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_life_span_handler.h" +#include "include/capi/cef_life_span_handler_capi.h" +#include "include/cef_client.h" +#include "include/capi/cef_client_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefLifeSpanHandlerCToCpp + : public CefCToCpp { + public: + explicit CefLifeSpanHandlerCToCpp(cef_life_span_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefLifeSpanHandlerCToCpp() {} + + // CefLifeSpanHandler methods + virtual bool OnBeforePopup(CefRefPtr browser, + CefRefPtr frame, const CefString& target_url, + const CefString& target_frame_name, + const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, + CefRefPtr& client, CefBrowserSettings& settings, + bool* no_javascript_access) OVERRIDE; + virtual void OnAfterCreated(CefRefPtr browser) OVERRIDE; + virtual bool RunModal(CefRefPtr browser) OVERRIDE; + virtual bool DoClose(CefRefPtr browser) OVERRIDE; + virtual void OnBeforeClose(CefRefPtr browser) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_LIFE_SPAN_HANDLER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/list_value_ctocpp.cc b/cef3/libcef_dll/ctocpp/list_value_ctocpp.cc new file mode 100644 index 000000000..f3a1c1abb --- /dev/null +++ b/cef3/libcef_dll/ctocpp/list_value_ctocpp.cc @@ -0,0 +1,476 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/binary_value_ctocpp.h" +#include "libcef_dll/ctocpp/dictionary_value_ctocpp.h" +#include "libcef_dll/ctocpp/list_value_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefListValue::Create() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_list_value_t* _retval = cef_list_value_create(); + + // Return type: refptr_same + return CefListValueCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefListValueCToCpp::IsValid() { + if (CEF_MEMBER_MISSING(struct_, is_valid)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_valid(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefListValueCToCpp::IsOwned() { + if (CEF_MEMBER_MISSING(struct_, is_owned)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_owned(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefListValueCToCpp::IsReadOnly() { + if (CEF_MEMBER_MISSING(struct_, is_read_only)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_read_only(struct_); + + // Return type: bool + return _retval?true:false; +} + +CefRefPtr CefListValueCToCpp::Copy() { + if (CEF_MEMBER_MISSING(struct_, copy)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_list_value_t* _retval = struct_->copy(struct_); + + // Return type: refptr_same + return CefListValueCToCpp::Wrap(_retval); +} + +bool CefListValueCToCpp::SetSize(size_t size) { + if (CEF_MEMBER_MISSING(struct_, set_size)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->set_size(struct_, + size); + + // Return type: bool + return _retval?true:false; +} + +size_t CefListValueCToCpp::GetSize() { + if (CEF_MEMBER_MISSING(struct_, get_size)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + size_t _retval = struct_->get_size(struct_); + + // Return type: simple + return _retval; +} + +bool CefListValueCToCpp::Clear() { + if (CEF_MEMBER_MISSING(struct_, clear)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->clear(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefListValueCToCpp::Remove(int index) { + if (CEF_MEMBER_MISSING(struct_, remove)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return false; + + // Execute + int _retval = struct_->remove(struct_, + index); + + // Return type: bool + return _retval?true:false; +} + +CefValueType CefListValueCToCpp::GetType(int index) { + if (CEF_MEMBER_MISSING(struct_, get_type)) + return VTYPE_INVALID; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return VTYPE_INVALID; + + // Execute + cef_value_type_t _retval = struct_->get_type(struct_, + index); + + // Return type: simple + return _retval; +} + +bool CefListValueCToCpp::GetBool(int index) { + if (CEF_MEMBER_MISSING(struct_, get_bool)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return false; + + // Execute + int _retval = struct_->get_bool(struct_, + index); + + // Return type: bool + return _retval?true:false; +} + +int CefListValueCToCpp::GetInt(int index) { + if (CEF_MEMBER_MISSING(struct_, get_int)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return 0; + + // Execute + int _retval = struct_->get_int(struct_, + index); + + // Return type: simple + return _retval; +} + +double CefListValueCToCpp::GetDouble(int index) { + if (CEF_MEMBER_MISSING(struct_, get_double)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return 0; + + // Execute + double _retval = struct_->get_double(struct_, + index); + + // Return type: simple + return _retval; +} + +CefString CefListValueCToCpp::GetString(int index) { + if (CEF_MEMBER_MISSING(struct_, get_string)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return CefString(); + + // Execute + cef_string_userfree_t _retval = struct_->get_string(struct_, + index); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefRefPtr CefListValueCToCpp::GetBinary(int index) { + if (CEF_MEMBER_MISSING(struct_, get_binary)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return NULL; + + // Execute + cef_binary_value_t* _retval = struct_->get_binary(struct_, + index); + + // Return type: refptr_same + return CefBinaryValueCToCpp::Wrap(_retval); +} + +CefRefPtr CefListValueCToCpp::GetDictionary(int index) { + if (CEF_MEMBER_MISSING(struct_, get_dictionary)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return NULL; + + // Execute + cef_dictionary_value_t* _retval = struct_->get_dictionary(struct_, + index); + + // Return type: refptr_same + return CefDictionaryValueCToCpp::Wrap(_retval); +} + +CefRefPtr CefListValueCToCpp::GetList(int index) { + if (CEF_MEMBER_MISSING(struct_, get_list)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return NULL; + + // Execute + cef_list_value_t* _retval = struct_->get_list(struct_, + index); + + // Return type: refptr_same + return CefListValueCToCpp::Wrap(_retval); +} + +bool CefListValueCToCpp::SetNull(int index) { + if (CEF_MEMBER_MISSING(struct_, set_null)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return false; + + // Execute + int _retval = struct_->set_null(struct_, + index); + + // Return type: bool + return _retval?true:false; +} + +bool CefListValueCToCpp::SetBool(int index, bool value) { + if (CEF_MEMBER_MISSING(struct_, set_bool)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return false; + + // Execute + int _retval = struct_->set_bool(struct_, + index, + value); + + // Return type: bool + return _retval?true:false; +} + +bool CefListValueCToCpp::SetInt(int index, int value) { + if (CEF_MEMBER_MISSING(struct_, set_int)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return false; + + // Execute + int _retval = struct_->set_int(struct_, + index, + value); + + // Return type: bool + return _retval?true:false; +} + +bool CefListValueCToCpp::SetDouble(int index, double value) { + if (CEF_MEMBER_MISSING(struct_, set_double)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return false; + + // Execute + int _retval = struct_->set_double(struct_, + index, + value); + + // Return type: bool + return _retval?true:false; +} + +bool CefListValueCToCpp::SetString(int index, const CefString& value) { + if (CEF_MEMBER_MISSING(struct_, set_string)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return false; + // Unverified params: value + + // Execute + int _retval = struct_->set_string(struct_, + index, + value.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + +bool CefListValueCToCpp::SetBinary(int index, CefRefPtr value) { + if (CEF_MEMBER_MISSING(struct_, set_binary)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return false; + // Verify param: value; type: refptr_same + DCHECK(value.get()); + if (!value.get()) + return false; + + // Execute + int _retval = struct_->set_binary(struct_, + index, + CefBinaryValueCToCpp::Unwrap(value)); + + // Return type: bool + return _retval?true:false; +} + +bool CefListValueCToCpp::SetDictionary(int index, + CefRefPtr value) { + if (CEF_MEMBER_MISSING(struct_, set_dictionary)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return false; + // Verify param: value; type: refptr_same + DCHECK(value.get()); + if (!value.get()) + return false; + + // Execute + int _retval = struct_->set_dictionary(struct_, + index, + CefDictionaryValueCToCpp::Unwrap(value)); + + // Return type: bool + return _retval?true:false; +} + +bool CefListValueCToCpp::SetList(int index, CefRefPtr value) { + if (CEF_MEMBER_MISSING(struct_, set_list)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return false; + // Verify param: value; type: refptr_same + DCHECK(value.get()); + if (!value.get()) + return false; + + // Execute + int _retval = struct_->set_list(struct_, + index, + CefListValueCToCpp::Unwrap(value)); + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/list_value_ctocpp.h b/cef3/libcef_dll/ctocpp/list_value_ctocpp.h new file mode 100644 index 000000000..56fed43fd --- /dev/null +++ b/cef3/libcef_dll/ctocpp/list_value_ctocpp.h @@ -0,0 +1,64 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_LIST_VALUE_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_LIST_VALUE_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_values.h" +#include "include/capi/cef_values_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefListValueCToCpp + : public CefCToCpp { + public: + explicit CefListValueCToCpp(cef_list_value_t* str) + : CefCToCpp(str) {} + virtual ~CefListValueCToCpp() {} + + // CefListValue methods + virtual bool IsValid() OVERRIDE; + virtual bool IsOwned() OVERRIDE; + virtual bool IsReadOnly() OVERRIDE; + virtual CefRefPtr Copy() OVERRIDE; + virtual bool SetSize(size_t size) OVERRIDE; + virtual size_t GetSize() OVERRIDE; + virtual bool Clear() OVERRIDE; + virtual bool Remove(int index) OVERRIDE; + virtual CefValueType GetType(int index) OVERRIDE; + virtual bool GetBool(int index) OVERRIDE; + virtual int GetInt(int index) OVERRIDE; + virtual double GetDouble(int index) OVERRIDE; + virtual CefString GetString(int index) OVERRIDE; + virtual CefRefPtr GetBinary(int index) OVERRIDE; + virtual CefRefPtr GetDictionary(int index) OVERRIDE; + virtual CefRefPtr GetList(int index) OVERRIDE; + virtual bool SetNull(int index) OVERRIDE; + virtual bool SetBool(int index, bool value) OVERRIDE; + virtual bool SetInt(int index, int value) OVERRIDE; + virtual bool SetDouble(int index, double value) OVERRIDE; + virtual bool SetString(int index, const CefString& value) OVERRIDE; + virtual bool SetBinary(int index, CefRefPtr value) OVERRIDE; + virtual bool SetDictionary(int index, + CefRefPtr value) OVERRIDE; + virtual bool SetList(int index, CefRefPtr value) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_LIST_VALUE_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/load_handler_ctocpp.cc b/cef3/libcef_dll/ctocpp/load_handler_ctocpp.cc new file mode 100644 index 000000000..c52575934 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/load_handler_ctocpp.cc @@ -0,0 +1,141 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/cpptoc/frame_cpptoc.h" +#include "libcef_dll/ctocpp/load_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefLoadHandlerCToCpp::OnLoadStart(CefRefPtr browser, + CefRefPtr frame) { + if (CEF_MEMBER_MISSING(struct_, on_load_start)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame.get()); + if (!frame.get()) + return; + + // Execute + struct_->on_load_start(struct_, + CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame)); +} + +void CefLoadHandlerCToCpp::OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, int httpStatusCode) { + if (CEF_MEMBER_MISSING(struct_, on_load_end)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame.get()); + if (!frame.get()) + return; + + // Execute + struct_->on_load_end(struct_, + CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), + httpStatusCode); +} + +void CefLoadHandlerCToCpp::OnLoadError(CefRefPtr browser, + CefRefPtr frame, ErrorCode errorCode, const CefString& errorText, + const CefString& failedUrl) { + if (CEF_MEMBER_MISSING(struct_, on_load_error)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame.get()); + if (!frame.get()) + return; + // Verify param: failedUrl; type: string_byref_const + DCHECK(!failedUrl.empty()); + if (failedUrl.empty()) + return; + // Unverified params: errorText + + // Execute + struct_->on_load_error(struct_, + CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), + errorCode, + errorText.GetStruct(), + failedUrl.GetStruct()); +} + +void CefLoadHandlerCToCpp::OnRenderProcessTerminated( + CefRefPtr browser, TerminationStatus status) { + if (CEF_MEMBER_MISSING(struct_, on_render_process_terminated)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + + // Execute + struct_->on_render_process_terminated(struct_, + CefBrowserCppToC::Wrap(browser), + status); +} + +void CefLoadHandlerCToCpp::OnPluginCrashed(CefRefPtr browser, + const CefString& plugin_path) { + if (CEF_MEMBER_MISSING(struct_, on_plugin_crashed)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + // Verify param: plugin_path; type: string_byref_const + DCHECK(!plugin_path.empty()); + if (plugin_path.empty()) + return; + + // Execute + struct_->on_plugin_crashed(struct_, + CefBrowserCppToC::Wrap(browser), + plugin_path.GetStruct()); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/load_handler_ctocpp.h b/cef3/libcef_dll/ctocpp/load_handler_ctocpp.h new file mode 100644 index 000000000..ec866ed00 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/load_handler_ctocpp.h @@ -0,0 +1,52 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_LOAD_HANDLER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_LOAD_HANDLER_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_load_handler.h" +#include "include/capi/cef_load_handler_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefLoadHandlerCToCpp + : public CefCToCpp { + public: + explicit CefLoadHandlerCToCpp(cef_load_handler_t* str) + : CefCToCpp( + str) {} + virtual ~CefLoadHandlerCToCpp() {} + + // CefLoadHandler methods + virtual void OnLoadStart(CefRefPtr browser, + CefRefPtr frame) OVERRIDE; + virtual void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, int httpStatusCode) OVERRIDE; + virtual void OnLoadError(CefRefPtr browser, + CefRefPtr frame, ErrorCode errorCode, + const CefString& errorText, const CefString& failedUrl) OVERRIDE; + virtual void OnRenderProcessTerminated(CefRefPtr browser, + TerminationStatus status) OVERRIDE; + virtual void OnPluginCrashed(CefRefPtr browser, + const CefString& plugin_path) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_LOAD_HANDLER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/menu_model_ctocpp.cc b/cef3/libcef_dll/ctocpp/menu_model_ctocpp.cc new file mode 100644 index 000000000..8714af8d9 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/menu_model_ctocpp.cc @@ -0,0 +1,839 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/menu_model_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefMenuModelCToCpp::Clear() { + if (CEF_MEMBER_MISSING(struct_, clear)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->clear(struct_); + + // Return type: bool + return _retval?true:false; +} + +int CefMenuModelCToCpp::GetCount() { + if (CEF_MEMBER_MISSING(struct_, get_count)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_count(struct_); + + // Return type: simple + return _retval; +} + +bool CefMenuModelCToCpp::AddSeparator() { + if (CEF_MEMBER_MISSING(struct_, add_separator)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->add_separator(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::AddItem(int command_id, const CefString& label) { + if (CEF_MEMBER_MISSING(struct_, add_item)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: label; type: string_byref_const + DCHECK(!label.empty()); + if (label.empty()) + return false; + + // Execute + int _retval = struct_->add_item(struct_, + command_id, + label.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::AddCheckItem(int command_id, const CefString& label) { + if (CEF_MEMBER_MISSING(struct_, add_check_item)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: label; type: string_byref_const + DCHECK(!label.empty()); + if (label.empty()) + return false; + + // Execute + int _retval = struct_->add_check_item(struct_, + command_id, + label.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::AddRadioItem(int command_id, const CefString& label, + int group_id) { + if (CEF_MEMBER_MISSING(struct_, add_radio_item)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: label; type: string_byref_const + DCHECK(!label.empty()); + if (label.empty()) + return false; + + // Execute + int _retval = struct_->add_radio_item(struct_, + command_id, + label.GetStruct(), + group_id); + + // Return type: bool + return _retval?true:false; +} + +CefRefPtr CefMenuModelCToCpp::AddSubMenu(int command_id, + const CefString& label) { + if (CEF_MEMBER_MISSING(struct_, add_sub_menu)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: label; type: string_byref_const + DCHECK(!label.empty()); + if (label.empty()) + return NULL; + + // Execute + cef_menu_model_t* _retval = struct_->add_sub_menu(struct_, + command_id, + label.GetStruct()); + + // Return type: refptr_same + return CefMenuModelCToCpp::Wrap(_retval); +} + +bool CefMenuModelCToCpp::InsertSeparatorAt(int index) { + if (CEF_MEMBER_MISSING(struct_, insert_separator_at)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->insert_separator_at(struct_, + index); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::InsertItemAt(int index, int command_id, + const CefString& label) { + if (CEF_MEMBER_MISSING(struct_, insert_item_at)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: label; type: string_byref_const + DCHECK(!label.empty()); + if (label.empty()) + return false; + + // Execute + int _retval = struct_->insert_item_at(struct_, + index, + command_id, + label.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::InsertCheckItemAt(int index, int command_id, + const CefString& label) { + if (CEF_MEMBER_MISSING(struct_, insert_check_item_at)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: label; type: string_byref_const + DCHECK(!label.empty()); + if (label.empty()) + return false; + + // Execute + int _retval = struct_->insert_check_item_at(struct_, + index, + command_id, + label.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::InsertRadioItemAt(int index, int command_id, + const CefString& label, int group_id) { + if (CEF_MEMBER_MISSING(struct_, insert_radio_item_at)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: label; type: string_byref_const + DCHECK(!label.empty()); + if (label.empty()) + return false; + + // Execute + int _retval = struct_->insert_radio_item_at(struct_, + index, + command_id, + label.GetStruct(), + group_id); + + // Return type: bool + return _retval?true:false; +} + +CefRefPtr CefMenuModelCToCpp::InsertSubMenuAt(int index, + int command_id, const CefString& label) { + if (CEF_MEMBER_MISSING(struct_, insert_sub_menu_at)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: label; type: string_byref_const + DCHECK(!label.empty()); + if (label.empty()) + return NULL; + + // Execute + cef_menu_model_t* _retval = struct_->insert_sub_menu_at(struct_, + index, + command_id, + label.GetStruct()); + + // Return type: refptr_same + return CefMenuModelCToCpp::Wrap(_retval); +} + +bool CefMenuModelCToCpp::Remove(int command_id) { + if (CEF_MEMBER_MISSING(struct_, remove)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->remove(struct_, + command_id); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::RemoveAt(int index) { + if (CEF_MEMBER_MISSING(struct_, remove_at)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->remove_at(struct_, + index); + + // Return type: bool + return _retval?true:false; +} + +int CefMenuModelCToCpp::GetIndexOf(int command_id) { + if (CEF_MEMBER_MISSING(struct_, get_index_of)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_index_of(struct_, + command_id); + + // Return type: simple + return _retval; +} + +int CefMenuModelCToCpp::GetCommandIdAt(int index) { + if (CEF_MEMBER_MISSING(struct_, get_command_id_at)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_command_id_at(struct_, + index); + + // Return type: simple + return _retval; +} + +bool CefMenuModelCToCpp::SetCommandIdAt(int index, int command_id) { + if (CEF_MEMBER_MISSING(struct_, set_command_id_at)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->set_command_id_at(struct_, + index, + command_id); + + // Return type: bool + return _retval?true:false; +} + +CefString CefMenuModelCToCpp::GetLabel(int command_id) { + if (CEF_MEMBER_MISSING(struct_, get_label)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_label(struct_, + command_id); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefMenuModelCToCpp::GetLabelAt(int index) { + if (CEF_MEMBER_MISSING(struct_, get_label_at)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_label_at(struct_, + index); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +bool CefMenuModelCToCpp::SetLabel(int command_id, const CefString& label) { + if (CEF_MEMBER_MISSING(struct_, set_label)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: label; type: string_byref_const + DCHECK(!label.empty()); + if (label.empty()) + return false; + + // Execute + int _retval = struct_->set_label(struct_, + command_id, + label.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::SetLabelAt(int index, const CefString& label) { + if (CEF_MEMBER_MISSING(struct_, set_label_at)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: label; type: string_byref_const + DCHECK(!label.empty()); + if (label.empty()) + return false; + + // Execute + int _retval = struct_->set_label_at(struct_, + index, + label.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + +CefMenuModel::MenuItemType CefMenuModelCToCpp::GetType(int command_id) { + if (CEF_MEMBER_MISSING(struct_, get_type)) + return MENUITEMTYPE_NONE; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_menu_item_type_t _retval = struct_->get_type(struct_, + command_id); + + // Return type: simple + return _retval; +} + +CefMenuModel::MenuItemType CefMenuModelCToCpp::GetTypeAt(int index) { + if (CEF_MEMBER_MISSING(struct_, get_type_at)) + return MENUITEMTYPE_NONE; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_menu_item_type_t _retval = struct_->get_type_at(struct_, + index); + + // Return type: simple + return _retval; +} + +int CefMenuModelCToCpp::GetGroupId(int command_id) { + if (CEF_MEMBER_MISSING(struct_, get_group_id)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_group_id(struct_, + command_id); + + // Return type: simple + return _retval; +} + +int CefMenuModelCToCpp::GetGroupIdAt(int index) { + if (CEF_MEMBER_MISSING(struct_, get_group_id_at)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_group_id_at(struct_, + index); + + // Return type: simple + return _retval; +} + +bool CefMenuModelCToCpp::SetGroupId(int command_id, int group_id) { + if (CEF_MEMBER_MISSING(struct_, set_group_id)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->set_group_id(struct_, + command_id, + group_id); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::SetGroupIdAt(int index, int group_id) { + if (CEF_MEMBER_MISSING(struct_, set_group_id_at)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->set_group_id_at(struct_, + index, + group_id); + + // Return type: bool + return _retval?true:false; +} + +CefRefPtr CefMenuModelCToCpp::GetSubMenu(int command_id) { + if (CEF_MEMBER_MISSING(struct_, get_sub_menu)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_menu_model_t* _retval = struct_->get_sub_menu(struct_, + command_id); + + // Return type: refptr_same + return CefMenuModelCToCpp::Wrap(_retval); +} + +CefRefPtr CefMenuModelCToCpp::GetSubMenuAt(int index) { + if (CEF_MEMBER_MISSING(struct_, get_sub_menu_at)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_menu_model_t* _retval = struct_->get_sub_menu_at(struct_, + index); + + // Return type: refptr_same + return CefMenuModelCToCpp::Wrap(_retval); +} + +bool CefMenuModelCToCpp::IsVisible(int command_id) { + if (CEF_MEMBER_MISSING(struct_, is_visible)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_visible(struct_, + command_id); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::IsVisibleAt(int index) { + if (CEF_MEMBER_MISSING(struct_, is_visible_at)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_visible_at(struct_, + index); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::SetVisible(int command_id, bool visible) { + if (CEF_MEMBER_MISSING(struct_, set_visible)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->set_visible(struct_, + command_id, + visible); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::SetVisibleAt(int index, bool visible) { + if (CEF_MEMBER_MISSING(struct_, set_visible_at)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->set_visible_at(struct_, + index, + visible); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::IsEnabled(int command_id) { + if (CEF_MEMBER_MISSING(struct_, is_enabled)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_enabled(struct_, + command_id); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::IsEnabledAt(int index) { + if (CEF_MEMBER_MISSING(struct_, is_enabled_at)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_enabled_at(struct_, + index); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::SetEnabled(int command_id, bool enabled) { + if (CEF_MEMBER_MISSING(struct_, set_enabled)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->set_enabled(struct_, + command_id, + enabled); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::SetEnabledAt(int index, bool enabled) { + if (CEF_MEMBER_MISSING(struct_, set_enabled_at)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->set_enabled_at(struct_, + index, + enabled); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::IsChecked(int command_id) { + if (CEF_MEMBER_MISSING(struct_, is_checked)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_checked(struct_, + command_id); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::IsCheckedAt(int index) { + if (CEF_MEMBER_MISSING(struct_, is_checked_at)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_checked_at(struct_, + index); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::SetChecked(int command_id, bool checked) { + if (CEF_MEMBER_MISSING(struct_, set_checked)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->set_checked(struct_, + command_id, + checked); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::SetCheckedAt(int index, bool checked) { + if (CEF_MEMBER_MISSING(struct_, set_checked_at)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->set_checked_at(struct_, + index, + checked); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::HasAccelerator(int command_id) { + if (CEF_MEMBER_MISSING(struct_, has_accelerator)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->has_accelerator(struct_, + command_id); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::HasAcceleratorAt(int index) { + if (CEF_MEMBER_MISSING(struct_, has_accelerator_at)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->has_accelerator_at(struct_, + index); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::SetAccelerator(int command_id, int key_code, + bool shift_pressed, bool ctrl_pressed, bool alt_pressed) { + if (CEF_MEMBER_MISSING(struct_, set_accelerator)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->set_accelerator(struct_, + command_id, + key_code, + shift_pressed, + ctrl_pressed, + alt_pressed); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::SetAcceleratorAt(int index, int key_code, + bool shift_pressed, bool ctrl_pressed, bool alt_pressed) { + if (CEF_MEMBER_MISSING(struct_, set_accelerator_at)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->set_accelerator_at(struct_, + index, + key_code, + shift_pressed, + ctrl_pressed, + alt_pressed); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::RemoveAccelerator(int command_id) { + if (CEF_MEMBER_MISSING(struct_, remove_accelerator)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->remove_accelerator(struct_, + command_id); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::RemoveAcceleratorAt(int index) { + if (CEF_MEMBER_MISSING(struct_, remove_accelerator_at)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->remove_accelerator_at(struct_, + index); + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::GetAccelerator(int command_id, int& key_code, + bool& shift_pressed, bool& ctrl_pressed, bool& alt_pressed) { + if (CEF_MEMBER_MISSING(struct_, get_accelerator)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: shift_pressed; type: bool_byref + int shift_pressedInt = shift_pressed; + // Translate param: ctrl_pressed; type: bool_byref + int ctrl_pressedInt = ctrl_pressed; + // Translate param: alt_pressed; type: bool_byref + int alt_pressedInt = alt_pressed; + + // Execute + int _retval = struct_->get_accelerator(struct_, + command_id, + &key_code, + &shift_pressedInt, + &ctrl_pressedInt, + &alt_pressedInt); + + // Restore param:shift_pressed; type: bool_byref + shift_pressed = shift_pressedInt?true:false; + // Restore param:ctrl_pressed; type: bool_byref + ctrl_pressed = ctrl_pressedInt?true:false; + // Restore param:alt_pressed; type: bool_byref + alt_pressed = alt_pressedInt?true:false; + + // Return type: bool + return _retval?true:false; +} + +bool CefMenuModelCToCpp::GetAcceleratorAt(int index, int& key_code, + bool& shift_pressed, bool& ctrl_pressed, bool& alt_pressed) { + if (CEF_MEMBER_MISSING(struct_, get_accelerator_at)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: shift_pressed; type: bool_byref + int shift_pressedInt = shift_pressed; + // Translate param: ctrl_pressed; type: bool_byref + int ctrl_pressedInt = ctrl_pressed; + // Translate param: alt_pressed; type: bool_byref + int alt_pressedInt = alt_pressed; + + // Execute + int _retval = struct_->get_accelerator_at(struct_, + index, + &key_code, + &shift_pressedInt, + &ctrl_pressedInt, + &alt_pressedInt); + + // Restore param:shift_pressed; type: bool_byref + shift_pressed = shift_pressedInt?true:false; + // Restore param:ctrl_pressed; type: bool_byref + ctrl_pressed = ctrl_pressedInt?true:false; + // Restore param:alt_pressed; type: bool_byref + alt_pressed = alt_pressedInt?true:false; + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/menu_model_ctocpp.h b/cef3/libcef_dll/ctocpp/menu_model_ctocpp.h new file mode 100644 index 000000000..ce76b5dd4 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/menu_model_ctocpp.h @@ -0,0 +1,98 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_MENU_MODEL_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_MENU_MODEL_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_menu_model.h" +#include "include/capi/cef_menu_model_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefMenuModelCToCpp + : public CefCToCpp { + public: + explicit CefMenuModelCToCpp(cef_menu_model_t* str) + : CefCToCpp(str) {} + virtual ~CefMenuModelCToCpp() {} + + // CefMenuModel methods + virtual bool Clear() OVERRIDE; + virtual int GetCount() OVERRIDE; + virtual bool AddSeparator() OVERRIDE; + virtual bool AddItem(int command_id, const CefString& label) OVERRIDE; + virtual bool AddCheckItem(int command_id, const CefString& label) OVERRIDE; + virtual bool AddRadioItem(int command_id, const CefString& label, + int group_id) OVERRIDE; + virtual CefRefPtr AddSubMenu(int command_id, + const CefString& label) OVERRIDE; + virtual bool InsertSeparatorAt(int index) OVERRIDE; + virtual bool InsertItemAt(int index, int command_id, + const CefString& label) OVERRIDE; + virtual bool InsertCheckItemAt(int index, int command_id, + const CefString& label) OVERRIDE; + virtual bool InsertRadioItemAt(int index, int command_id, + const CefString& label, int group_id) OVERRIDE; + virtual CefRefPtr InsertSubMenuAt(int index, int command_id, + const CefString& label) OVERRIDE; + virtual bool Remove(int command_id) OVERRIDE; + virtual bool RemoveAt(int index) OVERRIDE; + virtual int GetIndexOf(int command_id) OVERRIDE; + virtual int GetCommandIdAt(int index) OVERRIDE; + virtual bool SetCommandIdAt(int index, int command_id) OVERRIDE; + virtual CefString GetLabel(int command_id) OVERRIDE; + virtual CefString GetLabelAt(int index) OVERRIDE; + virtual bool SetLabel(int command_id, const CefString& label) OVERRIDE; + virtual bool SetLabelAt(int index, const CefString& label) OVERRIDE; + virtual MenuItemType GetType(int command_id) OVERRIDE; + virtual MenuItemType GetTypeAt(int index) OVERRIDE; + virtual int GetGroupId(int command_id) OVERRIDE; + virtual int GetGroupIdAt(int index) OVERRIDE; + virtual bool SetGroupId(int command_id, int group_id) OVERRIDE; + virtual bool SetGroupIdAt(int index, int group_id) OVERRIDE; + virtual CefRefPtr GetSubMenu(int command_id) OVERRIDE; + virtual CefRefPtr GetSubMenuAt(int index) OVERRIDE; + virtual bool IsVisible(int command_id) OVERRIDE; + virtual bool IsVisibleAt(int index) OVERRIDE; + virtual bool SetVisible(int command_id, bool visible) OVERRIDE; + virtual bool SetVisibleAt(int index, bool visible) OVERRIDE; + virtual bool IsEnabled(int command_id) OVERRIDE; + virtual bool IsEnabledAt(int index) OVERRIDE; + virtual bool SetEnabled(int command_id, bool enabled) OVERRIDE; + virtual bool SetEnabledAt(int index, bool enabled) OVERRIDE; + virtual bool IsChecked(int command_id) OVERRIDE; + virtual bool IsCheckedAt(int index) OVERRIDE; + virtual bool SetChecked(int command_id, bool checked) OVERRIDE; + virtual bool SetCheckedAt(int index, bool checked) OVERRIDE; + virtual bool HasAccelerator(int command_id) OVERRIDE; + virtual bool HasAcceleratorAt(int index) OVERRIDE; + virtual bool SetAccelerator(int command_id, int key_code, bool shift_pressed, + bool ctrl_pressed, bool alt_pressed) OVERRIDE; + virtual bool SetAcceleratorAt(int index, int key_code, bool shift_pressed, + bool ctrl_pressed, bool alt_pressed) OVERRIDE; + virtual bool RemoveAccelerator(int command_id) OVERRIDE; + virtual bool RemoveAcceleratorAt(int index) OVERRIDE; + virtual bool GetAccelerator(int command_id, int& key_code, + bool& shift_pressed, bool& ctrl_pressed, bool& alt_pressed) OVERRIDE; + virtual bool GetAcceleratorAt(int index, int& key_code, bool& shift_pressed, + bool& ctrl_pressed, bool& alt_pressed) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_MENU_MODEL_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/permission_handler_ctocpp.cc b/cef3/libcef_dll/ctocpp/permission_handler_ctocpp.cc new file mode 100644 index 000000000..700e91b39 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/permission_handler_ctocpp.cc @@ -0,0 +1,56 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/cpptoc/frame_cpptoc.h" +#include "libcef_dll/ctocpp/permission_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefPermissionHandlerCToCpp::OnBeforeScriptExtensionLoad( + CefRefPtr browser, CefRefPtr frame, + const CefString& extensionName) { + if (CEF_MEMBER_MISSING(struct_, on_before_script_extension_load)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + // Verify param: frame; type: refptr_diff + DCHECK(frame.get()); + if (!frame.get()) + return false; + // Verify param: extensionName; type: string_byref_const + DCHECK(!extensionName.empty()); + if (extensionName.empty()) + return false; + + // Execute + int _retval = struct_->on_before_script_extension_load(struct_, + CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), + extensionName.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/permission_handler_ctocpp.h b/cef3/libcef_dll/ctocpp/permission_handler_ctocpp.h new file mode 100644 index 000000000..0bffa2a81 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/permission_handler_ctocpp.h @@ -0,0 +1,47 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_PERMISSION_HANDLER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_PERMISSION_HANDLER_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_permission_handler.h" +#include "include/capi/cef_permission_handler_capi.h" +#include "include/cef_browser.h" +#include "include/capi/cef_browser_capi.h" +#include "include/cef_frame.h" +#include "include/capi/cef_frame_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefPermissionHandlerCToCpp + : public CefCToCpp { + public: + explicit CefPermissionHandlerCToCpp(cef_permission_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefPermissionHandlerCToCpp() {} + + // CefPermissionHandler methods + virtual bool OnBeforeScriptExtensionLoad(CefRefPtr browser, + CefRefPtr frame, const CefString& extensionName) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_PERMISSION_HANDLER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/post_data_ctocpp.cc b/cef3/libcef_dll/ctocpp/post_data_ctocpp.cc new file mode 100644 index 000000000..a5dfd3727 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/post_data_ctocpp.cc @@ -0,0 +1,149 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/post_data_ctocpp.h" +#include "libcef_dll/ctocpp/post_data_element_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefPostData::Create() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_post_data_t* _retval = cef_post_data_create(); + + // Return type: refptr_same + return CefPostDataCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefPostDataCToCpp::IsReadOnly() { + if (CEF_MEMBER_MISSING(struct_, is_read_only)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_read_only(struct_); + + // Return type: bool + return _retval?true:false; +} + +size_t CefPostDataCToCpp::GetElementCount() { + if (CEF_MEMBER_MISSING(struct_, get_element_count)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + size_t _retval = struct_->get_element_count(struct_); + + // Return type: simple + return _retval; +} + +void CefPostDataCToCpp::GetElements(ElementVector& elements) { + if (CEF_MEMBER_MISSING(struct_, get_elements)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: elements; type: refptr_vec_same_byref + size_t elementsSize = elements.size(); + size_t elementsCount = std::max(GetElementCount(), elementsSize); + cef_post_data_element_t** elementsList = NULL; + if (elementsCount > 0) { + elementsList = new cef_post_data_element_t*[elementsCount]; + DCHECK(elementsList); + if (elementsList) { + memset(elementsList, 0, sizeof(cef_post_data_element_t*)*elementsCount); + } + if (elementsList && elementsSize > 0) { + for (size_t i = 0; i < elementsSize; ++i) { + elementsList[i] = CefPostDataElementCToCpp::Unwrap(elements[i]); + } + } + } + + // Execute + struct_->get_elements(struct_, + &elementsCount, + elementsList); + + // Restore param:elements; type: refptr_vec_same_byref + elements.clear(); + if (elementsCount > 0 && elementsList) { + for (size_t i = 0; i < elementsCount; ++i) { + elements.push_back(CefPostDataElementCToCpp::Wrap(elementsList[i])); + } + delete [] elementsList; + } +} + +bool CefPostDataCToCpp::RemoveElement(CefRefPtr element) { + if (CEF_MEMBER_MISSING(struct_, remove_element)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: element; type: refptr_same + DCHECK(element.get()); + if (!element.get()) + return false; + + // Execute + int _retval = struct_->remove_element(struct_, + CefPostDataElementCToCpp::Unwrap(element)); + + // Return type: bool + return _retval?true:false; +} + +bool CefPostDataCToCpp::AddElement(CefRefPtr element) { + if (CEF_MEMBER_MISSING(struct_, add_element)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: element; type: refptr_same + DCHECK(element.get()); + if (!element.get()) + return false; + + // Execute + int _retval = struct_->add_element(struct_, + CefPostDataElementCToCpp::Unwrap(element)); + + // Return type: bool + return _retval?true:false; +} + +void CefPostDataCToCpp::RemoveElements() { + if (CEF_MEMBER_MISSING(struct_, remove_elements)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->remove_elements(struct_); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/post_data_ctocpp.h b/cef3/libcef_dll/ctocpp/post_data_ctocpp.h new file mode 100644 index 000000000..7f66f8e7c --- /dev/null +++ b/cef3/libcef_dll/ctocpp/post_data_ctocpp.h @@ -0,0 +1,45 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_POST_DATA_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_POST_DATA_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_request.h" +#include "include/capi/cef_request_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefPostDataCToCpp + : public CefCToCpp { + public: + explicit CefPostDataCToCpp(cef_post_data_t* str) + : CefCToCpp(str) {} + virtual ~CefPostDataCToCpp() {} + + // CefPostData methods + virtual bool IsReadOnly() OVERRIDE; + virtual size_t GetElementCount() OVERRIDE; + virtual void GetElements(ElementVector& elements) OVERRIDE; + virtual bool RemoveElement(CefRefPtr element) OVERRIDE; + virtual bool AddElement(CefRefPtr element) OVERRIDE; + virtual void RemoveElements() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_POST_DATA_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/post_data_element_ctocpp.cc b/cef3/libcef_dll/ctocpp/post_data_element_ctocpp.cc new file mode 100644 index 000000000..3cc117bbd --- /dev/null +++ b/cef3/libcef_dll/ctocpp/post_data_element_ctocpp.cc @@ -0,0 +1,153 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/post_data_element_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefPostDataElement::Create() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_post_data_element_t* _retval = cef_post_data_element_create(); + + // Return type: refptr_same + return CefPostDataElementCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefPostDataElementCToCpp::IsReadOnly() { + if (CEF_MEMBER_MISSING(struct_, is_read_only)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_read_only(struct_); + + // Return type: bool + return _retval?true:false; +} + +void CefPostDataElementCToCpp::SetToEmpty() { + if (CEF_MEMBER_MISSING(struct_, set_to_empty)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->set_to_empty(struct_); +} + +void CefPostDataElementCToCpp::SetToFile(const CefString& fileName) { + if (CEF_MEMBER_MISSING(struct_, set_to_file)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: fileName; type: string_byref_const + DCHECK(!fileName.empty()); + if (fileName.empty()) + return; + + // Execute + struct_->set_to_file(struct_, + fileName.GetStruct()); +} + +void CefPostDataElementCToCpp::SetToBytes(size_t size, const void* bytes) { + if (CEF_MEMBER_MISSING(struct_, set_to_bytes)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: bytes; type: simple_byaddr + DCHECK(bytes); + if (!bytes) + return; + + // Execute + struct_->set_to_bytes(struct_, + size, + bytes); +} + +CefPostDataElement::Type CefPostDataElementCToCpp::GetType() { + if (CEF_MEMBER_MISSING(struct_, get_type)) + return PDE_TYPE_EMPTY; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_postdataelement_type_t _retval = struct_->get_type(struct_); + + // Return type: simple + return _retval; +} + +CefString CefPostDataElementCToCpp::GetFile() { + if (CEF_MEMBER_MISSING(struct_, get_file)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_file(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +size_t CefPostDataElementCToCpp::GetBytesCount() { + if (CEF_MEMBER_MISSING(struct_, get_bytes_count)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + size_t _retval = struct_->get_bytes_count(struct_); + + // Return type: simple + return _retval; +} + +size_t CefPostDataElementCToCpp::GetBytes(size_t size, void* bytes) { + if (CEF_MEMBER_MISSING(struct_, get_bytes)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: bytes; type: simple_byaddr + DCHECK(bytes); + if (!bytes) + return 0; + + // Execute + size_t _retval = struct_->get_bytes(struct_, + size, + bytes); + + // Return type: simple + return _retval; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/post_data_element_ctocpp.h b/cef3/libcef_dll/ctocpp/post_data_element_ctocpp.h new file mode 100644 index 000000000..932a2aac9 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/post_data_element_ctocpp.h @@ -0,0 +1,49 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_POST_DATA_ELEMENT_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_POST_DATA_ELEMENT_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_request.h" +#include "include/capi/cef_request_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefPostDataElementCToCpp + : public CefCToCpp { + public: + explicit CefPostDataElementCToCpp(cef_post_data_element_t* str) + : CefCToCpp(str) {} + virtual ~CefPostDataElementCToCpp() {} + + // CefPostDataElement methods + virtual bool IsReadOnly() OVERRIDE; + virtual void SetToEmpty() OVERRIDE; + virtual void SetToFile(const CefString& fileName) OVERRIDE; + virtual void SetToBytes(size_t size, const void* bytes) OVERRIDE; + virtual Type GetType() OVERRIDE; + virtual CefString GetFile() OVERRIDE; + virtual size_t GetBytesCount() OVERRIDE; + virtual size_t GetBytes(size_t size, void* bytes) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_POST_DATA_ELEMENT_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/process_message_ctocpp.cc b/cef3/libcef_dll/ctocpp/process_message_ctocpp.cc new file mode 100644 index 000000000..38a0f1643 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/process_message_ctocpp.cc @@ -0,0 +1,110 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/list_value_ctocpp.h" +#include "libcef_dll/ctocpp/process_message_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefProcessMessage::Create(const CefString& name) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: name; type: string_byref_const + DCHECK(!name.empty()); + if (name.empty()) + return NULL; + + // Execute + cef_process_message_t* _retval = cef_process_message_create( + name.GetStruct()); + + // Return type: refptr_same + return CefProcessMessageCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefProcessMessageCToCpp::IsValid() { + if (CEF_MEMBER_MISSING(struct_, is_valid)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_valid(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefProcessMessageCToCpp::IsReadOnly() { + if (CEF_MEMBER_MISSING(struct_, is_read_only)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_read_only(struct_); + + // Return type: bool + return _retval?true:false; +} + +CefRefPtr CefProcessMessageCToCpp::Copy() { + if (CEF_MEMBER_MISSING(struct_, copy)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_process_message_t* _retval = struct_->copy(struct_); + + // Return type: refptr_same + return CefProcessMessageCToCpp::Wrap(_retval); +} + +CefString CefProcessMessageCToCpp::GetName() { + if (CEF_MEMBER_MISSING(struct_, get_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefRefPtr CefProcessMessageCToCpp::GetArgumentList() { + if (CEF_MEMBER_MISSING(struct_, get_argument_list)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_list_value_t* _retval = struct_->get_argument_list(struct_); + + // Return type: refptr_same + return CefListValueCToCpp::Wrap(_retval); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/process_message_ctocpp.h b/cef3/libcef_dll/ctocpp/process_message_ctocpp.h new file mode 100644 index 000000000..6df657fe9 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/process_message_ctocpp.h @@ -0,0 +1,46 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_PROCESS_MESSAGE_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_PROCESS_MESSAGE_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_process_message.h" +#include "include/capi/cef_process_message_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefProcessMessageCToCpp + : public CefCToCpp { + public: + explicit CefProcessMessageCToCpp(cef_process_message_t* str) + : CefCToCpp(str) {} + virtual ~CefProcessMessageCToCpp() {} + + // CefProcessMessage methods + virtual bool IsValid() OVERRIDE; + virtual bool IsReadOnly() OVERRIDE; + virtual CefRefPtr Copy() OVERRIDE; + virtual CefString GetName() OVERRIDE; + virtual CefRefPtr GetArgumentList() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_PROCESS_MESSAGE_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/quota_callback_ctocpp.cc b/cef3/libcef_dll/ctocpp/quota_callback_ctocpp.cc new file mode 100644 index 000000000..06ed1b9d9 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/quota_callback_ctocpp.cc @@ -0,0 +1,44 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/quota_callback_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefQuotaCallbackCToCpp::Continue(bool allow) { + if (CEF_MEMBER_MISSING(struct_, cont)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->cont(struct_, + allow); +} + +void CefQuotaCallbackCToCpp::Cancel() { + if (CEF_MEMBER_MISSING(struct_, cancel)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->cancel(struct_); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/quota_callback_ctocpp.h b/cef3/libcef_dll/ctocpp/quota_callback_ctocpp.h new file mode 100644 index 000000000..f59c1ef6a --- /dev/null +++ b/cef3/libcef_dll/ctocpp/quota_callback_ctocpp.h @@ -0,0 +1,43 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_QUOTA_CALLBACK_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_QUOTA_CALLBACK_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_request_handler.h" +#include "include/capi/cef_request_handler_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefQuotaCallbackCToCpp + : public CefCToCpp { + public: + explicit CefQuotaCallbackCToCpp(cef_quota_callback_t* str) + : CefCToCpp(str) {} + virtual ~CefQuotaCallbackCToCpp() {} + + // CefQuotaCallback methods + virtual void Continue(bool allow) OVERRIDE; + virtual void Cancel() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_QUOTA_CALLBACK_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/read_handler_ctocpp.cc b/cef3/libcef_dll/ctocpp/read_handler_ctocpp.cc new file mode 100644 index 000000000..b4066d609 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/read_handler_ctocpp.cc @@ -0,0 +1,85 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/read_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +size_t CefReadHandlerCToCpp::Read(void* ptr, size_t size, size_t n) { + if (CEF_MEMBER_MISSING(struct_, read)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: ptr; type: simple_byaddr + DCHECK(ptr); + if (!ptr) + return 0; + + // Execute + size_t _retval = struct_->read(struct_, + ptr, + size, + n); + + // Return type: simple + return _retval; +} + +int CefReadHandlerCToCpp::Seek(int64 offset, int whence) { + if (CEF_MEMBER_MISSING(struct_, seek)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->seek(struct_, + offset, + whence); + + // Return type: simple + return _retval; +} + +int64 CefReadHandlerCToCpp::Tell() { + if (CEF_MEMBER_MISSING(struct_, tell)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int64 _retval = struct_->tell(struct_); + + // Return type: simple + return _retval; +} + +int CefReadHandlerCToCpp::Eof() { + if (CEF_MEMBER_MISSING(struct_, eof)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->eof(struct_); + + // Return type: simple + return _retval; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/read_handler_ctocpp.h b/cef3/libcef_dll/ctocpp/read_handler_ctocpp.h new file mode 100644 index 000000000..06742cbdb --- /dev/null +++ b/cef3/libcef_dll/ctocpp/read_handler_ctocpp.h @@ -0,0 +1,45 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_READ_HANDLER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_READ_HANDLER_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_stream.h" +#include "include/capi/cef_stream_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefReadHandlerCToCpp + : public CefCToCpp { + public: + explicit CefReadHandlerCToCpp(cef_read_handler_t* str) + : CefCToCpp( + str) {} + virtual ~CefReadHandlerCToCpp() {} + + // CefReadHandler methods + virtual size_t Read(void* ptr, size_t size, size_t n) OVERRIDE; + virtual int Seek(int64 offset, int whence) OVERRIDE; + virtual int64 Tell() OVERRIDE; + virtual int Eof() OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_READ_HANDLER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/render_handler_ctocpp.cc b/cef3/libcef_dll/ctocpp/render_handler_ctocpp.cc new file mode 100644 index 000000000..9b268a101 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/render_handler_ctocpp.cc @@ -0,0 +1,189 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/ctocpp/render_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefRenderHandlerCToCpp::GetRootScreenRect(CefRefPtr browser, + CefRect& rect) { + if (CEF_MEMBER_MISSING(struct_, get_root_screen_rect)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + + // Execute + int _retval = struct_->get_root_screen_rect(struct_, + CefBrowserCppToC::Wrap(browser), + &rect); + + // Return type: bool + return _retval?true:false; +} + +bool CefRenderHandlerCToCpp::GetViewRect(CefRefPtr browser, + CefRect& rect) { + if (CEF_MEMBER_MISSING(struct_, get_view_rect)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + + // Execute + int _retval = struct_->get_view_rect(struct_, + CefBrowserCppToC::Wrap(browser), + &rect); + + // Return type: bool + return _retval?true:false; +} + +bool CefRenderHandlerCToCpp::GetScreenPoint(CefRefPtr browser, + int viewX, int viewY, int& screenX, int& screenY) { + if (CEF_MEMBER_MISSING(struct_, get_screen_point)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + + // Execute + int _retval = struct_->get_screen_point(struct_, + CefBrowserCppToC::Wrap(browser), + viewX, + viewY, + &screenX, + &screenY); + + // Return type: bool + return _retval?true:false; +} + +void CefRenderHandlerCToCpp::OnPopupShow(CefRefPtr browser, + bool show) { + if (CEF_MEMBER_MISSING(struct_, on_popup_show)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + + // Execute + struct_->on_popup_show(struct_, + CefBrowserCppToC::Wrap(browser), + show); +} + +void CefRenderHandlerCToCpp::OnPopupSize(CefRefPtr browser, + const CefRect& rect) { + if (CEF_MEMBER_MISSING(struct_, on_popup_size)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + + // Execute + struct_->on_popup_size(struct_, + CefBrowserCppToC::Wrap(browser), + &rect); +} + +void CefRenderHandlerCToCpp::OnPaint(CefRefPtr browser, + PaintElementType type, const RectList& dirtyRects, const void* buffer, + int width, int height) { + if (CEF_MEMBER_MISSING(struct_, on_paint)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + // Verify param: buffer; type: simple_byaddr + DCHECK(buffer); + if (!buffer) + return; + + // Translate param: dirtyRects; type: simple_vec_byref_const + const size_t dirtyRectsCount = dirtyRects.size(); + cef_rect_t* dirtyRectsList = NULL; + if (dirtyRectsCount > 0) { + dirtyRectsList = new cef_rect_t[dirtyRectsCount]; + DCHECK(dirtyRectsList); + if (dirtyRectsList) { + for (size_t i = 0; i < dirtyRectsCount; ++i) { + dirtyRectsList[i] = dirtyRects[i]; + } + } + } + + // Execute + struct_->on_paint(struct_, + CefBrowserCppToC::Wrap(browser), + type, + dirtyRectsCount, + dirtyRectsList, + buffer, + width, + height); + + // Restore param:dirtyRects; type: simple_vec_byref_const + if (dirtyRectsList) + delete [] dirtyRectsList; +} + +void CefRenderHandlerCToCpp::OnCursorChange(CefRefPtr browser, + CefCursorHandle cursor) { + if (CEF_MEMBER_MISSING(struct_, on_cursor_change)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + + // Execute + struct_->on_cursor_change(struct_, + CefBrowserCppToC::Wrap(browser), + cursor); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/render_handler_ctocpp.h b/cef3/libcef_dll/ctocpp/render_handler_ctocpp.h new file mode 100644 index 000000000..0c00c187e --- /dev/null +++ b/cef3/libcef_dll/ctocpp/render_handler_ctocpp.h @@ -0,0 +1,55 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_RENDER_HANDLER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_RENDER_HANDLER_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_render_handler.h" +#include "include/capi/cef_render_handler_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefRenderHandlerCToCpp + : public CefCToCpp { + public: + explicit CefRenderHandlerCToCpp(cef_render_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefRenderHandlerCToCpp() {} + + // CefRenderHandler methods + virtual bool GetRootScreenRect(CefRefPtr browser, + CefRect& rect) OVERRIDE; + virtual bool GetViewRect(CefRefPtr browser, + CefRect& rect) OVERRIDE; + virtual bool GetScreenPoint(CefRefPtr browser, int viewX, + int viewY, int& screenX, int& screenY) OVERRIDE; + virtual void OnPopupShow(CefRefPtr browser, bool show) OVERRIDE; + virtual void OnPopupSize(CefRefPtr browser, + const CefRect& rect) OVERRIDE; + virtual void OnPaint(CefRefPtr browser, PaintElementType type, + const RectList& dirtyRects, const void* buffer, int width, + int height) OVERRIDE; + virtual void OnCursorChange(CefRefPtr browser, + CefCursorHandle cursor) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_RENDER_HANDLER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/render_process_handler_ctocpp.cc b/cef3/libcef_dll/ctocpp/render_process_handler_ctocpp.cc new file mode 100644 index 000000000..0374e5e7b --- /dev/null +++ b/cef3/libcef_dll/ctocpp/render_process_handler_ctocpp.cc @@ -0,0 +1,351 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/cpptoc/domnode_cpptoc.h" +#include "libcef_dll/cpptoc/frame_cpptoc.h" +#include "libcef_dll/cpptoc/list_value_cpptoc.h" +#include "libcef_dll/cpptoc/process_message_cpptoc.h" +#include "libcef_dll/cpptoc/request_cpptoc.h" +#include "libcef_dll/cpptoc/v8context_cpptoc.h" +#include "libcef_dll/cpptoc/v8exception_cpptoc.h" +#include "libcef_dll/cpptoc/v8stack_trace_cpptoc.h" +#include "libcef_dll/ctocpp/render_process_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefRenderProcessHandlerCToCpp::OnRenderThreadCreated( + CefRefPtr extra_info) { + if (CEF_MEMBER_MISSING(struct_, on_render_thread_created)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: extra_info; type: refptr_diff + DCHECK(extra_info.get()); + if (!extra_info.get()) + return; + + // Execute + struct_->on_render_thread_created(struct_, + CefListValueCppToC::Wrap(extra_info)); +} + +void CefRenderProcessHandlerCToCpp::OnWebKitInitialized() { + if (CEF_MEMBER_MISSING(struct_, on_web_kit_initialized)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->on_web_kit_initialized(struct_); +} + +void CefRenderProcessHandlerCToCpp::OnBrowserCreated( + CefRefPtr browser) { + if (CEF_MEMBER_MISSING(struct_, on_browser_created)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + + // Execute + struct_->on_browser_created(struct_, + CefBrowserCppToC::Wrap(browser)); +} + +void CefRenderProcessHandlerCToCpp::OnBrowserDestroyed( + CefRefPtr browser) { + if (CEF_MEMBER_MISSING(struct_, on_browser_destroyed)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + + // Execute + struct_->on_browser_destroyed(struct_, + CefBrowserCppToC::Wrap(browser)); +} + +bool CefRenderProcessHandlerCToCpp::OnBeforeNavigation( + CefRefPtr browser, CefRefPtr frame, + CefRefPtr request, NavigationType navigation_type, + bool is_redirect) { + if (CEF_MEMBER_MISSING(struct_, on_before_navigation)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + // Verify param: frame; type: refptr_diff + DCHECK(frame.get()); + if (!frame.get()) + return false; + // Verify param: request; type: refptr_diff + DCHECK(request.get()); + if (!request.get()) + return false; + + // Execute + int _retval = struct_->on_before_navigation(struct_, + CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), + CefRequestCppToC::Wrap(request), + navigation_type, + is_redirect); + + // Return type: bool + return _retval?true:false; +} + +void CefRenderProcessHandlerCToCpp::OnContextCreated( + CefRefPtr browser, CefRefPtr frame, + CefRefPtr context) { + if (CEF_MEMBER_MISSING(struct_, on_context_created)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame.get()); + if (!frame.get()) + return; + // Verify param: context; type: refptr_diff + DCHECK(context.get()); + if (!context.get()) + return; + + // Execute + struct_->on_context_created(struct_, + CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), + CefV8ContextCppToC::Wrap(context)); +} + +void CefRenderProcessHandlerCToCpp::OnContextReleased( + CefRefPtr browser, CefRefPtr frame, + CefRefPtr context) { + if (CEF_MEMBER_MISSING(struct_, on_context_released)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame.get()); + if (!frame.get()) + return; + // Verify param: context; type: refptr_diff + DCHECK(context.get()); + if (!context.get()) + return; + + // Execute + struct_->on_context_released(struct_, + CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), + CefV8ContextCppToC::Wrap(context)); +} + +void CefRenderProcessHandlerCToCpp::OnUncaughtException( + CefRefPtr browser, CefRefPtr frame, + CefRefPtr context, CefRefPtr exception, + CefRefPtr stackTrace) { + if (CEF_MEMBER_MISSING(struct_, on_uncaught_exception)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame.get()); + if (!frame.get()) + return; + // Verify param: context; type: refptr_diff + DCHECK(context.get()); + if (!context.get()) + return; + // Verify param: exception; type: refptr_diff + DCHECK(exception.get()); + if (!exception.get()) + return; + // Verify param: stackTrace; type: refptr_diff + DCHECK(stackTrace.get()); + if (!stackTrace.get()) + return; + + // Execute + struct_->on_uncaught_exception(struct_, + CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), + CefV8ContextCppToC::Wrap(context), + CefV8ExceptionCppToC::Wrap(exception), + CefV8StackTraceCppToC::Wrap(stackTrace)); +} + +void CefRenderProcessHandlerCToCpp::OnWorkerContextCreated(int worker_id, + const CefString& url, CefRefPtr context) { + if (CEF_MEMBER_MISSING(struct_, on_worker_context_created)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: url; type: string_byref_const + DCHECK(!url.empty()); + if (url.empty()) + return; + // Verify param: context; type: refptr_diff + DCHECK(context.get()); + if (!context.get()) + return; + + // Execute + struct_->on_worker_context_created(struct_, + worker_id, + url.GetStruct(), + CefV8ContextCppToC::Wrap(context)); +} + +void CefRenderProcessHandlerCToCpp::OnWorkerContextReleased(int worker_id, + const CefString& url, CefRefPtr context) { + if (CEF_MEMBER_MISSING(struct_, on_worker_context_released)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: url; type: string_byref_const + DCHECK(!url.empty()); + if (url.empty()) + return; + // Verify param: context; type: refptr_diff + DCHECK(context.get()); + if (!context.get()) + return; + + // Execute + struct_->on_worker_context_released(struct_, + worker_id, + url.GetStruct(), + CefV8ContextCppToC::Wrap(context)); +} + +void CefRenderProcessHandlerCToCpp::OnWorkerUncaughtException(int worker_id, + const CefString& url, CefRefPtr context, + CefRefPtr exception, + CefRefPtr stackTrace) { + if (CEF_MEMBER_MISSING(struct_, on_worker_uncaught_exception)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: url; type: string_byref_const + DCHECK(!url.empty()); + if (url.empty()) + return; + // Verify param: context; type: refptr_diff + DCHECK(context.get()); + if (!context.get()) + return; + // Verify param: exception; type: refptr_diff + DCHECK(exception.get()); + if (!exception.get()) + return; + // Verify param: stackTrace; type: refptr_diff + DCHECK(stackTrace.get()); + if (!stackTrace.get()) + return; + + // Execute + struct_->on_worker_uncaught_exception(struct_, + worker_id, + url.GetStruct(), + CefV8ContextCppToC::Wrap(context), + CefV8ExceptionCppToC::Wrap(exception), + CefV8StackTraceCppToC::Wrap(stackTrace)); +} + +void CefRenderProcessHandlerCToCpp::OnFocusedNodeChanged( + CefRefPtr browser, CefRefPtr frame, + CefRefPtr node) { + if (CEF_MEMBER_MISSING(struct_, on_focused_node_changed)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + // Unverified params: frame, node + + // Execute + struct_->on_focused_node_changed(struct_, + CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), + CefDOMNodeCppToC::Wrap(node)); +} + +bool CefRenderProcessHandlerCToCpp::OnProcessMessageReceived( + CefRefPtr browser, CefProcessId source_process, + CefRefPtr message) { + if (CEF_MEMBER_MISSING(struct_, on_process_message_received)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + // Verify param: message; type: refptr_diff + DCHECK(message.get()); + if (!message.get()) + return false; + + // Execute + int _retval = struct_->on_process_message_received(struct_, + CefBrowserCppToC::Wrap(browser), + source_process, + CefProcessMessageCppToC::Wrap(message)); + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/render_process_handler_ctocpp.h b/cef3/libcef_dll/ctocpp/render_process_handler_ctocpp.h new file mode 100644 index 000000000..ae115483c --- /dev/null +++ b/cef3/libcef_dll/ctocpp/render_process_handler_ctocpp.h @@ -0,0 +1,69 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_RENDER_PROCESS_HANDLER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_RENDER_PROCESS_HANDLER_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_render_process_handler.h" +#include "include/capi/cef_render_process_handler_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefRenderProcessHandlerCToCpp + : public CefCToCpp { + public: + explicit CefRenderProcessHandlerCToCpp(cef_render_process_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefRenderProcessHandlerCToCpp() {} + + // CefRenderProcessHandler methods + virtual void OnRenderThreadCreated( + CefRefPtr extra_info) OVERRIDE; + virtual void OnWebKitInitialized() OVERRIDE; + virtual void OnBrowserCreated(CefRefPtr browser) OVERRIDE; + virtual void OnBrowserDestroyed(CefRefPtr browser) OVERRIDE; + virtual bool OnBeforeNavigation(CefRefPtr browser, + CefRefPtr frame, CefRefPtr request, + NavigationType navigation_type, bool is_redirect) OVERRIDE; + virtual void OnContextCreated(CefRefPtr browser, + CefRefPtr frame, CefRefPtr context) OVERRIDE; + virtual void OnContextReleased(CefRefPtr browser, + CefRefPtr frame, CefRefPtr context) OVERRIDE; + virtual void OnUncaughtException(CefRefPtr browser, + CefRefPtr frame, CefRefPtr context, + CefRefPtr exception, + CefRefPtr stackTrace) OVERRIDE; + virtual void OnWorkerContextCreated(int worker_id, const CefString& url, + CefRefPtr context) OVERRIDE; + virtual void OnWorkerContextReleased(int worker_id, const CefString& url, + CefRefPtr context) OVERRIDE; + virtual void OnWorkerUncaughtException(int worker_id, const CefString& url, + CefRefPtr context, CefRefPtr exception, + CefRefPtr stackTrace) OVERRIDE; + virtual void OnFocusedNodeChanged(CefRefPtr browser, + CefRefPtr frame, CefRefPtr node) OVERRIDE; + virtual bool OnProcessMessageReceived(CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_RENDER_PROCESS_HANDLER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/request_ctocpp.cc b/cef3/libcef_dll/ctocpp/request_ctocpp.cc new file mode 100644 index 000000000..4921e3f2d --- /dev/null +++ b/cef3/libcef_dll/ctocpp/request_ctocpp.cc @@ -0,0 +1,277 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/post_data_ctocpp.h" +#include "libcef_dll/ctocpp/request_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefRequest::Create() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_request_t* _retval = cef_request_create(); + + // Return type: refptr_same + return CefRequestCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefRequestCToCpp::IsReadOnly() { + if (CEF_MEMBER_MISSING(struct_, is_read_only)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_read_only(struct_); + + // Return type: bool + return _retval?true:false; +} + +CefString CefRequestCToCpp::GetURL() { + if (CEF_MEMBER_MISSING(struct_, get_url)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_url(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +void CefRequestCToCpp::SetURL(const CefString& url) { + if (CEF_MEMBER_MISSING(struct_, set_url)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: url; type: string_byref_const + DCHECK(!url.empty()); + if (url.empty()) + return; + + // Execute + struct_->set_url(struct_, + url.GetStruct()); +} + +CefString CefRequestCToCpp::GetMethod() { + if (CEF_MEMBER_MISSING(struct_, get_method)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_method(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +void CefRequestCToCpp::SetMethod(const CefString& method) { + if (CEF_MEMBER_MISSING(struct_, set_method)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: method; type: string_byref_const + DCHECK(!method.empty()); + if (method.empty()) + return; + + // Execute + struct_->set_method(struct_, + method.GetStruct()); +} + +CefRefPtr CefRequestCToCpp::GetPostData() { + if (CEF_MEMBER_MISSING(struct_, get_post_data)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_post_data_t* _retval = struct_->get_post_data(struct_); + + // Return type: refptr_same + return CefPostDataCToCpp::Wrap(_retval); +} + +void CefRequestCToCpp::SetPostData(CefRefPtr postData) { + if (CEF_MEMBER_MISSING(struct_, set_post_data)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: postData; type: refptr_same + DCHECK(postData.get()); + if (!postData.get()) + return; + + // Execute + struct_->set_post_data(struct_, + CefPostDataCToCpp::Unwrap(postData)); +} + +void CefRequestCToCpp::GetHeaderMap(HeaderMap& headerMap) { + if (CEF_MEMBER_MISSING(struct_, get_header_map)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: headerMap; type: string_map_multi_byref + cef_string_multimap_t headerMapMultimap = cef_string_multimap_alloc(); + DCHECK(headerMapMultimap); + if (headerMapMultimap) + transfer_string_multimap_contents(headerMap, headerMapMultimap); + + // Execute + struct_->get_header_map(struct_, + headerMapMultimap); + + // Restore param:headerMap; type: string_map_multi_byref + if (headerMapMultimap) { + headerMap.clear(); + transfer_string_multimap_contents(headerMapMultimap, headerMap); + cef_string_multimap_free(headerMapMultimap); + } +} + +void CefRequestCToCpp::SetHeaderMap(const HeaderMap& headerMap) { + if (CEF_MEMBER_MISSING(struct_, set_header_map)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: headerMap; type: string_map_multi_byref_const + cef_string_multimap_t headerMapMultimap = cef_string_multimap_alloc(); + DCHECK(headerMapMultimap); + if (headerMapMultimap) + transfer_string_multimap_contents(headerMap, headerMapMultimap); + + // Execute + struct_->set_header_map(struct_, + headerMapMultimap); + + // Restore param:headerMap; type: string_map_multi_byref_const + if (headerMapMultimap) + cef_string_multimap_free(headerMapMultimap); +} + +void CefRequestCToCpp::Set(const CefString& url, const CefString& method, + CefRefPtr postData, const HeaderMap& headerMap) { + if (CEF_MEMBER_MISSING(struct_, set)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: url; type: string_byref_const + DCHECK(!url.empty()); + if (url.empty()) + return; + // Verify param: method; type: string_byref_const + DCHECK(!method.empty()); + if (method.empty()) + return; + // Unverified params: postData + + // Translate param: headerMap; type: string_map_multi_byref_const + cef_string_multimap_t headerMapMultimap = cef_string_multimap_alloc(); + DCHECK(headerMapMultimap); + if (headerMapMultimap) + transfer_string_multimap_contents(headerMap, headerMapMultimap); + + // Execute + struct_->set(struct_, + url.GetStruct(), + method.GetStruct(), + CefPostDataCToCpp::Unwrap(postData), + headerMapMultimap); + + // Restore param:headerMap; type: string_map_multi_byref_const + if (headerMapMultimap) + cef_string_multimap_free(headerMapMultimap); +} + +int CefRequestCToCpp::GetFlags() { + if (CEF_MEMBER_MISSING(struct_, get_flags)) + return UR_FLAG_NONE; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_flags(struct_); + + // Return type: simple + return _retval; +} + +void CefRequestCToCpp::SetFlags(int flags) { + if (CEF_MEMBER_MISSING(struct_, set_flags)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->set_flags(struct_, + flags); +} + +CefString CefRequestCToCpp::GetFirstPartyForCookies() { + if (CEF_MEMBER_MISSING(struct_, get_first_party_for_cookies)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_first_party_for_cookies(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +void CefRequestCToCpp::SetFirstPartyForCookies(const CefString& url) { + if (CEF_MEMBER_MISSING(struct_, set_first_party_for_cookies)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: url; type: string_byref_const + DCHECK(!url.empty()); + if (url.empty()) + return; + + // Execute + struct_->set_first_party_for_cookies(struct_, + url.GetStruct()); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/request_ctocpp.h b/cef3/libcef_dll/ctocpp/request_ctocpp.h new file mode 100644 index 000000000..5f70cb282 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/request_ctocpp.h @@ -0,0 +1,54 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_REQUEST_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_REQUEST_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_request.h" +#include "include/capi/cef_request_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefRequestCToCpp + : public CefCToCpp { + public: + explicit CefRequestCToCpp(cef_request_t* str) + : CefCToCpp(str) {} + virtual ~CefRequestCToCpp() {} + + // CefRequest methods + virtual bool IsReadOnly() OVERRIDE; + virtual CefString GetURL() OVERRIDE; + virtual void SetURL(const CefString& url) OVERRIDE; + virtual CefString GetMethod() OVERRIDE; + virtual void SetMethod(const CefString& method) OVERRIDE; + virtual CefRefPtr GetPostData() OVERRIDE; + virtual void SetPostData(CefRefPtr postData) OVERRIDE; + virtual void GetHeaderMap(HeaderMap& headerMap) OVERRIDE; + virtual void SetHeaderMap(const HeaderMap& headerMap) OVERRIDE; + virtual void Set(const CefString& url, const CefString& method, + CefRefPtr postData, const HeaderMap& headerMap) OVERRIDE; + virtual int GetFlags() OVERRIDE; + virtual void SetFlags(int flags) OVERRIDE; + virtual CefString GetFirstPartyForCookies() OVERRIDE; + virtual void SetFirstPartyForCookies(const CefString& url) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_REQUEST_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/request_handler_ctocpp.cc b/cef3/libcef_dll/ctocpp/request_handler_ctocpp.cc new file mode 100644 index 000000000..84455a842 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/request_handler_ctocpp.cc @@ -0,0 +1,310 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/allow_certificate_error_callback_cpptoc.h" +#include "libcef_dll/cpptoc/auth_callback_cpptoc.h" +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/cpptoc/cookie_manager_cpptoc.h" +#include "libcef_dll/cpptoc/frame_cpptoc.h" +#include "libcef_dll/cpptoc/quota_callback_cpptoc.h" +#include "libcef_dll/cpptoc/request_cpptoc.h" +#include "libcef_dll/cpptoc/web_plugin_info_cpptoc.h" +#include "libcef_dll/ctocpp/request_handler_ctocpp.h" +#include "libcef_dll/ctocpp/resource_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefRequestHandlerCToCpp::OnBeforeResourceLoad( + CefRefPtr browser, CefRefPtr frame, + CefRefPtr request) { + if (CEF_MEMBER_MISSING(struct_, on_before_resource_load)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + // Verify param: frame; type: refptr_diff + DCHECK(frame.get()); + if (!frame.get()) + return false; + // Verify param: request; type: refptr_diff + DCHECK(request.get()); + if (!request.get()) + return false; + + // Execute + int _retval = struct_->on_before_resource_load(struct_, + CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), + CefRequestCppToC::Wrap(request)); + + // Return type: bool + return _retval?true:false; +} + +CefRefPtr CefRequestHandlerCToCpp::GetResourceHandler( + CefRefPtr browser, CefRefPtr frame, + CefRefPtr request) { + if (CEF_MEMBER_MISSING(struct_, get_resource_handler)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return NULL; + // Verify param: frame; type: refptr_diff + DCHECK(frame.get()); + if (!frame.get()) + return NULL; + // Verify param: request; type: refptr_diff + DCHECK(request.get()); + if (!request.get()) + return NULL; + + // Execute + cef_resource_handler_t* _retval = struct_->get_resource_handler(struct_, + CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), + CefRequestCppToC::Wrap(request)); + + // Return type: refptr_same + return CefResourceHandlerCToCpp::Wrap(_retval); +} + +void CefRequestHandlerCToCpp::OnResourceRedirect(CefRefPtr browser, + CefRefPtr frame, const CefString& old_url, CefString& new_url) { + if (CEF_MEMBER_MISSING(struct_, on_resource_redirect)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame.get()); + if (!frame.get()) + return; + // Verify param: old_url; type: string_byref_const + DCHECK(!old_url.empty()); + if (old_url.empty()) + return; + + // Execute + struct_->on_resource_redirect(struct_, + CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), + old_url.GetStruct(), + new_url.GetWritableStruct()); +} + +bool CefRequestHandlerCToCpp::GetAuthCredentials(CefRefPtr browser, + CefRefPtr frame, bool isProxy, const CefString& host, int port, + const CefString& realm, const CefString& scheme, + CefRefPtr callback) { + if (CEF_MEMBER_MISSING(struct_, get_auth_credentials)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + // Verify param: frame; type: refptr_diff + DCHECK(frame.get()); + if (!frame.get()) + return false; + // Verify param: host; type: string_byref_const + DCHECK(!host.empty()); + if (host.empty()) + return false; + // Verify param: scheme; type: string_byref_const + DCHECK(!scheme.empty()); + if (scheme.empty()) + return false; + // Verify param: callback; type: refptr_diff + DCHECK(callback.get()); + if (!callback.get()) + return false; + // Unverified params: realm + + // Execute + int _retval = struct_->get_auth_credentials(struct_, + CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), + isProxy, + host.GetStruct(), + port, + realm.GetStruct(), + scheme.GetStruct(), + CefAuthCallbackCppToC::Wrap(callback)); + + // Return type: bool + return _retval?true:false; +} + +bool CefRequestHandlerCToCpp::OnQuotaRequest(CefRefPtr browser, + const CefString& origin_url, int64 new_size, + CefRefPtr callback) { + if (CEF_MEMBER_MISSING(struct_, on_quota_request)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + // Verify param: origin_url; type: string_byref_const + DCHECK(!origin_url.empty()); + if (origin_url.empty()) + return false; + // Verify param: callback; type: refptr_diff + DCHECK(callback.get()); + if (!callback.get()) + return false; + + // Execute + int _retval = struct_->on_quota_request(struct_, + CefBrowserCppToC::Wrap(browser), + origin_url.GetStruct(), + new_size, + CefQuotaCallbackCppToC::Wrap(callback)); + + // Return type: bool + return _retval?true:false; +} + +CefRefPtr CefRequestHandlerCToCpp::GetCookieManager( + CefRefPtr browser, const CefString& main_url) { + if (CEF_MEMBER_MISSING(struct_, get_cookie_manager)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return NULL; + // Verify param: main_url; type: string_byref_const + DCHECK(!main_url.empty()); + if (main_url.empty()) + return NULL; + + // Execute + cef_cookie_manager_t* _retval = struct_->get_cookie_manager(struct_, + CefBrowserCppToC::Wrap(browser), + main_url.GetStruct()); + + // Return type: refptr_diff + return CefCookieManagerCppToC::Unwrap(_retval); +} + +void CefRequestHandlerCToCpp::OnProtocolExecution(CefRefPtr browser, + const CefString& url, bool& allow_os_execution) { + if (CEF_MEMBER_MISSING(struct_, on_protocol_execution)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return; + // Verify param: url; type: string_byref_const + DCHECK(!url.empty()); + if (url.empty()) + return; + + // Translate param: allow_os_execution; type: bool_byref + int allow_os_executionInt = allow_os_execution; + + // Execute + struct_->on_protocol_execution(struct_, + CefBrowserCppToC::Wrap(browser), + url.GetStruct(), + &allow_os_executionInt); + + // Restore param:allow_os_execution; type: bool_byref + allow_os_execution = allow_os_executionInt?true:false; +} + +bool CefRequestHandlerCToCpp::OnBeforePluginLoad(CefRefPtr browser, + const CefString& url, const CefString& policy_url, + CefRefPtr info) { + if (CEF_MEMBER_MISSING(struct_, on_before_plugin_load)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + // Verify param: info; type: refptr_diff + DCHECK(info.get()); + if (!info.get()) + return false; + // Unverified params: url, policy_url + + // Execute + int _retval = struct_->on_before_plugin_load(struct_, + CefBrowserCppToC::Wrap(browser), + url.GetStruct(), + policy_url.GetStruct(), + CefWebPluginInfoCppToC::Wrap(info)); + + // Return type: bool + return _retval?true:false; +} + +bool CefRequestHandlerCToCpp::OnCertificateError(cef_errorcode_t cert_error, + const CefString& request_url, + CefRefPtr callback) { + if (CEF_MEMBER_MISSING(struct_, on_certificate_error)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: request_url; type: string_byref_const + DCHECK(!request_url.empty()); + if (request_url.empty()) + return false; + // Verify param: callback; type: refptr_diff + DCHECK(callback.get()); + if (!callback.get()) + return false; + + // Execute + int _retval = struct_->on_certificate_error(struct_, + cert_error, + request_url.GetStruct(), + CefAllowCertificateErrorCallbackCppToC::Wrap(callback)); + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/request_handler_ctocpp.h b/cef3/libcef_dll/ctocpp/request_handler_ctocpp.h new file mode 100644 index 000000000..789690fbb --- /dev/null +++ b/cef3/libcef_dll/ctocpp/request_handler_ctocpp.h @@ -0,0 +1,66 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_REQUEST_HANDLER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_REQUEST_HANDLER_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_request_handler.h" +#include "include/capi/cef_request_handler_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefRequestHandlerCToCpp + : public CefCToCpp { + public: + explicit CefRequestHandlerCToCpp(cef_request_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefRequestHandlerCToCpp() {} + + // CefRequestHandler methods + virtual bool OnBeforeResourceLoad(CefRefPtr browser, + CefRefPtr frame, CefRefPtr request) OVERRIDE; + virtual CefRefPtr GetResourceHandler( + CefRefPtr browser, CefRefPtr frame, + CefRefPtr request) OVERRIDE; + virtual void OnResourceRedirect(CefRefPtr browser, + CefRefPtr frame, const CefString& old_url, + CefString& new_url) OVERRIDE; + virtual bool GetAuthCredentials(CefRefPtr browser, + CefRefPtr frame, bool isProxy, const CefString& host, int port, + const CefString& realm, const CefString& scheme, + CefRefPtr callback) OVERRIDE; + virtual bool OnQuotaRequest(CefRefPtr browser, + const CefString& origin_url, int64 new_size, + CefRefPtr callback) OVERRIDE; + virtual CefRefPtr GetCookieManager( + CefRefPtr browser, const CefString& main_url) OVERRIDE; + virtual void OnProtocolExecution(CefRefPtr browser, + const CefString& url, bool& allow_os_execution) OVERRIDE; + virtual bool OnBeforePluginLoad(CefRefPtr browser, + const CefString& url, const CefString& policy_url, + CefRefPtr info) OVERRIDE; + virtual bool OnCertificateError(cef_errorcode_t cert_error, + const CefString& request_url, + CefRefPtr callback) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_REQUEST_HANDLER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/resource_bundle_handler_ctocpp.cc b/cef3/libcef_dll/ctocpp/resource_bundle_handler_ctocpp.cc new file mode 100644 index 000000000..ff85a27ab --- /dev/null +++ b/cef3/libcef_dll/ctocpp/resource_bundle_handler_ctocpp.cc @@ -0,0 +1,56 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/resource_bundle_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefResourceBundleHandlerCToCpp::GetLocalizedString(int message_id, + CefString& string) { + if (CEF_MEMBER_MISSING(struct_, get_localized_string)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_localized_string(struct_, + message_id, + string.GetWritableStruct()); + + // Return type: bool + return _retval?true:false; +} + +bool CefResourceBundleHandlerCToCpp::GetDataResource(int resource_id, + void*& data, size_t& data_size) { + if (CEF_MEMBER_MISSING(struct_, get_data_resource)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_data_resource(struct_, + resource_id, + &data, + &data_size); + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/resource_bundle_handler_ctocpp.h b/cef3/libcef_dll/ctocpp/resource_bundle_handler_ctocpp.h new file mode 100644 index 000000000..c05398062 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/resource_bundle_handler_ctocpp.h @@ -0,0 +1,44 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_RESOURCE_BUNDLE_HANDLER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_RESOURCE_BUNDLE_HANDLER_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_resource_bundle_handler.h" +#include "include/capi/cef_resource_bundle_handler_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefResourceBundleHandlerCToCpp + : public CefCToCpp { + public: + explicit CefResourceBundleHandlerCToCpp(cef_resource_bundle_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefResourceBundleHandlerCToCpp() {} + + // CefResourceBundleHandler methods + virtual bool GetLocalizedString(int message_id, CefString& string) OVERRIDE; + virtual bool GetDataResource(int resource_id, void*& data, + size_t& data_size) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_RESOURCE_BUNDLE_HANDLER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/resource_handler_ctocpp.cc b/cef3/libcef_dll/ctocpp/resource_handler_ctocpp.cc new file mode 100644 index 000000000..f28527e07 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/resource_handler_ctocpp.cc @@ -0,0 +1,136 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/callback_cpptoc.h" +#include "libcef_dll/cpptoc/request_cpptoc.h" +#include "libcef_dll/cpptoc/response_cpptoc.h" +#include "libcef_dll/ctocpp/resource_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefResourceHandlerCToCpp::ProcessRequest(CefRefPtr request, + CefRefPtr callback) { + if (CEF_MEMBER_MISSING(struct_, process_request)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: request; type: refptr_diff + DCHECK(request.get()); + if (!request.get()) + return false; + // Verify param: callback; type: refptr_diff + DCHECK(callback.get()); + if (!callback.get()) + return false; + + // Execute + int _retval = struct_->process_request(struct_, + CefRequestCppToC::Wrap(request), + CefCallbackCppToC::Wrap(callback)); + + // Return type: bool + return _retval?true:false; +} + +void CefResourceHandlerCToCpp::GetResponseHeaders( + CefRefPtr response, int64& response_length, + CefString& redirectUrl) { + if (CEF_MEMBER_MISSING(struct_, get_response_headers)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: response; type: refptr_diff + DCHECK(response.get()); + if (!response.get()) + return; + + // Execute + struct_->get_response_headers(struct_, + CefResponseCppToC::Wrap(response), + &response_length, + redirectUrl.GetWritableStruct()); +} + +bool CefResourceHandlerCToCpp::ReadResponse(void* data_out, int bytes_to_read, + int& bytes_read, CefRefPtr callback) { + if (CEF_MEMBER_MISSING(struct_, read_response)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: data_out; type: simple_byaddr + DCHECK(data_out); + if (!data_out) + return false; + // Verify param: callback; type: refptr_diff + DCHECK(callback.get()); + if (!callback.get()) + return false; + + // Execute + int _retval = struct_->read_response(struct_, + data_out, + bytes_to_read, + &bytes_read, + CefCallbackCppToC::Wrap(callback)); + + // Return type: bool + return _retval?true:false; +} + +bool CefResourceHandlerCToCpp::CanGetCookie(const CefCookie& cookie) { + if (CEF_MEMBER_MISSING(struct_, can_get_cookie)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->can_get_cookie(struct_, + &cookie); + + // Return type: bool + return _retval?true:false; +} + +bool CefResourceHandlerCToCpp::CanSetCookie(const CefCookie& cookie) { + if (CEF_MEMBER_MISSING(struct_, can_set_cookie)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->can_set_cookie(struct_, + &cookie); + + // Return type: bool + return _retval?true:false; +} + +void CefResourceHandlerCToCpp::Cancel() { + if (CEF_MEMBER_MISSING(struct_, cancel)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->cancel(struct_); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/resource_handler_ctocpp.h b/cef3/libcef_dll/ctocpp/resource_handler_ctocpp.h new file mode 100644 index 000000000..b72144f38 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/resource_handler_ctocpp.h @@ -0,0 +1,50 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_RESOURCE_HANDLER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_RESOURCE_HANDLER_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_resource_handler.h" +#include "include/capi/cef_resource_handler_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefResourceHandlerCToCpp + : public CefCToCpp { + public: + explicit CefResourceHandlerCToCpp(cef_resource_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefResourceHandlerCToCpp() {} + + // CefResourceHandler methods + virtual bool ProcessRequest(CefRefPtr request, + CefRefPtr callback) OVERRIDE; + virtual void GetResponseHeaders(CefRefPtr response, + int64& response_length, CefString& redirectUrl) OVERRIDE; + virtual bool ReadResponse(void* data_out, int bytes_to_read, int& bytes_read, + CefRefPtr callback) OVERRIDE; + virtual bool CanGetCookie(const CefCookie& cookie) OVERRIDE; + virtual bool CanSetCookie(const CefCookie& cookie) OVERRIDE; + virtual void Cancel() OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_RESOURCE_HANDLER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/response_ctocpp.cc b/cef3/libcef_dll/ctocpp/response_ctocpp.cc new file mode 100644 index 000000000..a0602d174 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/response_ctocpp.cc @@ -0,0 +1,202 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/response_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefResponse::Create() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_response_t* _retval = cef_response_create(); + + // Return type: refptr_same + return CefResponseCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefResponseCToCpp::IsReadOnly() { + if (CEF_MEMBER_MISSING(struct_, is_read_only)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_read_only(struct_); + + // Return type: bool + return _retval?true:false; +} + +int CefResponseCToCpp::GetStatus() { + if (CEF_MEMBER_MISSING(struct_, get_status)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_status(struct_); + + // Return type: simple + return _retval; +} + +void CefResponseCToCpp::SetStatus(int status) { + if (CEF_MEMBER_MISSING(struct_, set_status)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->set_status(struct_, + status); +} + +CefString CefResponseCToCpp::GetStatusText() { + if (CEF_MEMBER_MISSING(struct_, get_status_text)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_status_text(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +void CefResponseCToCpp::SetStatusText(const CefString& statusText) { + if (CEF_MEMBER_MISSING(struct_, set_status_text)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: statusText; type: string_byref_const + DCHECK(!statusText.empty()); + if (statusText.empty()) + return; + + // Execute + struct_->set_status_text(struct_, + statusText.GetStruct()); +} + +CefString CefResponseCToCpp::GetMimeType() { + if (CEF_MEMBER_MISSING(struct_, get_mime_type)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_mime_type(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +void CefResponseCToCpp::SetMimeType(const CefString& mimeType) { + if (CEF_MEMBER_MISSING(struct_, set_mime_type)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: mimeType; type: string_byref_const + DCHECK(!mimeType.empty()); + if (mimeType.empty()) + return; + + // Execute + struct_->set_mime_type(struct_, + mimeType.GetStruct()); +} + +CefString CefResponseCToCpp::GetHeader(const CefString& name) { + if (CEF_MEMBER_MISSING(struct_, get_header)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: name; type: string_byref_const + DCHECK(!name.empty()); + if (name.empty()) + return CefString(); + + // Execute + cef_string_userfree_t _retval = struct_->get_header(struct_, + name.GetStruct()); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +void CefResponseCToCpp::GetHeaderMap(HeaderMap& headerMap) { + if (CEF_MEMBER_MISSING(struct_, get_header_map)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: headerMap; type: string_map_multi_byref + cef_string_multimap_t headerMapMultimap = cef_string_multimap_alloc(); + DCHECK(headerMapMultimap); + if (headerMapMultimap) + transfer_string_multimap_contents(headerMap, headerMapMultimap); + + // Execute + struct_->get_header_map(struct_, + headerMapMultimap); + + // Restore param:headerMap; type: string_map_multi_byref + if (headerMapMultimap) { + headerMap.clear(); + transfer_string_multimap_contents(headerMapMultimap, headerMap); + cef_string_multimap_free(headerMapMultimap); + } +} + +void CefResponseCToCpp::SetHeaderMap(const HeaderMap& headerMap) { + if (CEF_MEMBER_MISSING(struct_, set_header_map)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: headerMap; type: string_map_multi_byref_const + cef_string_multimap_t headerMapMultimap = cef_string_multimap_alloc(); + DCHECK(headerMapMultimap); + if (headerMapMultimap) + transfer_string_multimap_contents(headerMap, headerMapMultimap); + + // Execute + struct_->set_header_map(struct_, + headerMapMultimap); + + // Restore param:headerMap; type: string_map_multi_byref_const + if (headerMapMultimap) + cef_string_multimap_free(headerMapMultimap); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/response_ctocpp.h b/cef3/libcef_dll/ctocpp/response_ctocpp.h new file mode 100644 index 000000000..aa4191646 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/response_ctocpp.h @@ -0,0 +1,49 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_RESPONSE_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_RESPONSE_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_response.h" +#include "include/capi/cef_response_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefResponseCToCpp + : public CefCToCpp { + public: + explicit CefResponseCToCpp(cef_response_t* str) + : CefCToCpp(str) {} + virtual ~CefResponseCToCpp() {} + + // CefResponse methods + virtual bool IsReadOnly() OVERRIDE; + virtual int GetStatus() OVERRIDE; + virtual void SetStatus(int status) OVERRIDE; + virtual CefString GetStatusText() OVERRIDE; + virtual void SetStatusText(const CefString& statusText) OVERRIDE; + virtual CefString GetMimeType() OVERRIDE; + virtual void SetMimeType(const CefString& mimeType) OVERRIDE; + virtual CefString GetHeader(const CefString& name) OVERRIDE; + virtual void GetHeaderMap(HeaderMap& headerMap) OVERRIDE; + virtual void SetHeaderMap(const HeaderMap& headerMap) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_RESPONSE_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.cc b/cef3/libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.cc new file mode 100644 index 000000000..73471d15e --- /dev/null +++ b/cef3/libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.cc @@ -0,0 +1,54 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/browser_host_cpptoc.h" +#include "libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefRunFileDialogCallbackCToCpp::OnFileDialogDismissed( + CefRefPtr browser_host, + const std::vector& file_paths) { + if (CEF_MEMBER_MISSING(struct_, cont)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser_host; type: refptr_diff + DCHECK(browser_host.get()); + if (!browser_host.get()) + return; + + // Translate param: file_paths; type: string_vec_byref_const + cef_string_list_t file_pathsList = cef_string_list_alloc(); + DCHECK(file_pathsList); + if (file_pathsList) + transfer_string_list_contents(file_paths, file_pathsList); + + // Execute + struct_->cont(struct_, + CefBrowserHostCppToC::Wrap(browser_host), + file_pathsList); + + // Restore param:file_paths; type: string_vec_byref_const + if (file_pathsList) + cef_string_list_free(file_pathsList); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.h b/cef3/libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.h new file mode 100644 index 000000000..28202fefd --- /dev/null +++ b/cef3/libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.h @@ -0,0 +1,46 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_RUN_FILE_DIALOG_CALLBACK_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_RUN_FILE_DIALOG_CALLBACK_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include +#include "include/cef_browser.h" +#include "include/capi/cef_browser_capi.h" +#include "include/cef_client.h" +#include "include/capi/cef_client_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefRunFileDialogCallbackCToCpp + : public CefCToCpp { + public: + explicit CefRunFileDialogCallbackCToCpp(cef_run_file_dialog_callback_t* str) + : CefCToCpp(str) {} + virtual ~CefRunFileDialogCallbackCToCpp() {} + + // CefRunFileDialogCallback methods + virtual void OnFileDialogDismissed(CefRefPtr browser_host, + const std::vector& file_paths) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_RUN_FILE_DIALOG_CALLBACK_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/scheme_handler_factory_ctocpp.cc b/cef3/libcef_dll/ctocpp/scheme_handler_factory_ctocpp.cc new file mode 100644 index 000000000..2f8e4b648 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/scheme_handler_factory_ctocpp.cc @@ -0,0 +1,56 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/cpptoc/frame_cpptoc.h" +#include "libcef_dll/cpptoc/request_cpptoc.h" +#include "libcef_dll/ctocpp/resource_handler_ctocpp.h" +#include "libcef_dll/ctocpp/scheme_handler_factory_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +CefRefPtr CefSchemeHandlerFactoryCToCpp::Create( + CefRefPtr browser, CefRefPtr frame, + const CefString& scheme_name, CefRefPtr request) { + if (CEF_MEMBER_MISSING(struct_, create)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: scheme_name; type: string_byref_const + DCHECK(!scheme_name.empty()); + if (scheme_name.empty()) + return NULL; + // Verify param: request; type: refptr_diff + DCHECK(request.get()); + if (!request.get()) + return NULL; + // Unverified params: browser, frame + + // Execute + cef_resource_handler_t* _retval = struct_->create(struct_, + CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), + scheme_name.GetStruct(), + CefRequestCppToC::Wrap(request)); + + // Return type: refptr_same + return CefResourceHandlerCToCpp::Wrap(_retval); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/scheme_handler_factory_ctocpp.h b/cef3/libcef_dll/ctocpp/scheme_handler_factory_ctocpp.h new file mode 100644 index 000000000..1fa863b6f --- /dev/null +++ b/cef3/libcef_dll/ctocpp/scheme_handler_factory_ctocpp.h @@ -0,0 +1,44 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_SCHEME_HANDLER_FACTORY_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_SCHEME_HANDLER_FACTORY_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_scheme.h" +#include "include/capi/cef_scheme_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefSchemeHandlerFactoryCToCpp + : public CefCToCpp { + public: + explicit CefSchemeHandlerFactoryCToCpp(cef_scheme_handler_factory_t* str) + : CefCToCpp(str) {} + virtual ~CefSchemeHandlerFactoryCToCpp() {} + + // CefSchemeHandlerFactory methods + virtual CefRefPtr Create(CefRefPtr browser, + CefRefPtr frame, const CefString& scheme_name, + CefRefPtr request) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_SCHEME_HANDLER_FACTORY_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/scheme_registrar_ctocpp.cc b/cef3/libcef_dll/ctocpp/scheme_registrar_ctocpp.cc new file mode 100644 index 000000000..3eb6fc3ed --- /dev/null +++ b/cef3/libcef_dll/ctocpp/scheme_registrar_ctocpp.cc @@ -0,0 +1,46 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/scheme_registrar_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefSchemeRegistrarCToCpp::AddCustomScheme(const CefString& scheme_name, + bool is_standard, bool is_local, bool is_display_isolated) { + if (CEF_MEMBER_MISSING(struct_, add_custom_scheme)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: scheme_name; type: string_byref_const + DCHECK(!scheme_name.empty()); + if (scheme_name.empty()) + return false; + + // Execute + int _retval = struct_->add_custom_scheme(struct_, + scheme_name.GetStruct(), + is_standard, + is_local, + is_display_isolated); + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/scheme_registrar_ctocpp.h b/cef3/libcef_dll/ctocpp/scheme_registrar_ctocpp.h new file mode 100644 index 000000000..4fbdd20c3 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/scheme_registrar_ctocpp.h @@ -0,0 +1,43 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_SCHEME_REGISTRAR_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_SCHEME_REGISTRAR_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_scheme.h" +#include "include/capi/cef_scheme_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefSchemeRegistrarCToCpp + : public CefCToCpp { + public: + explicit CefSchemeRegistrarCToCpp(cef_scheme_registrar_t* str) + : CefCToCpp(str) {} + virtual ~CefSchemeRegistrarCToCpp() {} + + // CefSchemeRegistrar methods + virtual bool AddCustomScheme(const CefString& scheme_name, bool is_standard, + bool is_local, bool is_display_isolated) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_SCHEME_REGISTRAR_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/stream_reader_ctocpp.cc b/cef3/libcef_dll/ctocpp/stream_reader_ctocpp.cc new file mode 100644 index 000000000..6f63d9ff1 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/stream_reader_ctocpp.cc @@ -0,0 +1,141 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/read_handler_cpptoc.h" +#include "libcef_dll/ctocpp/stream_reader_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefStreamReader::CreateForFile( + const CefString& fileName) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: fileName; type: string_byref_const + DCHECK(!fileName.empty()); + if (fileName.empty()) + return NULL; + + // Execute + cef_stream_reader_t* _retval = cef_stream_reader_create_for_file( + fileName.GetStruct()); + + // Return type: refptr_same + return CefStreamReaderCToCpp::Wrap(_retval); +} + +CefRefPtr CefStreamReader::CreateForData(void* data, + size_t size) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: data; type: simple_byaddr + DCHECK(data); + if (!data) + return NULL; + + // Execute + cef_stream_reader_t* _retval = cef_stream_reader_create_for_data( + data, + size); + + // Return type: refptr_same + return CefStreamReaderCToCpp::Wrap(_retval); +} + +CefRefPtr CefStreamReader::CreateForHandler( + CefRefPtr handler) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: handler; type: refptr_diff + DCHECK(handler.get()); + if (!handler.get()) + return NULL; + + // Execute + cef_stream_reader_t* _retval = cef_stream_reader_create_for_handler( + CefReadHandlerCppToC::Wrap(handler)); + + // Return type: refptr_same + return CefStreamReaderCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +size_t CefStreamReaderCToCpp::Read(void* ptr, size_t size, size_t n) { + if (CEF_MEMBER_MISSING(struct_, read)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: ptr; type: simple_byaddr + DCHECK(ptr); + if (!ptr) + return 0; + + // Execute + size_t _retval = struct_->read(struct_, + ptr, + size, + n); + + // Return type: simple + return _retval; +} + +int CefStreamReaderCToCpp::Seek(int64 offset, int whence) { + if (CEF_MEMBER_MISSING(struct_, seek)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->seek(struct_, + offset, + whence); + + // Return type: simple + return _retval; +} + +int64 CefStreamReaderCToCpp::Tell() { + if (CEF_MEMBER_MISSING(struct_, tell)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int64 _retval = struct_->tell(struct_); + + // Return type: simple + return _retval; +} + +int CefStreamReaderCToCpp::Eof() { + if (CEF_MEMBER_MISSING(struct_, eof)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->eof(struct_); + + // Return type: simple + return _retval; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/stream_reader_ctocpp.h b/cef3/libcef_dll/ctocpp/stream_reader_ctocpp.h new file mode 100644 index 000000000..a856ee6d9 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/stream_reader_ctocpp.h @@ -0,0 +1,45 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_STREAM_READER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_STREAM_READER_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_stream.h" +#include "include/capi/cef_stream_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefStreamReaderCToCpp + : public CefCToCpp { + public: + explicit CefStreamReaderCToCpp(cef_stream_reader_t* str) + : CefCToCpp( + str) {} + virtual ~CefStreamReaderCToCpp() {} + + // CefStreamReader methods + virtual size_t Read(void* ptr, size_t size, size_t n) OVERRIDE; + virtual int Seek(int64 offset, int whence) OVERRIDE; + virtual int64 Tell() OVERRIDE; + virtual int Eof() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_STREAM_READER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/stream_writer_ctocpp.cc b/cef3/libcef_dll/ctocpp/stream_writer_ctocpp.cc new file mode 100644 index 000000000..7c0561a8b --- /dev/null +++ b/cef3/libcef_dll/ctocpp/stream_writer_ctocpp.cc @@ -0,0 +1,123 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/write_handler_cpptoc.h" +#include "libcef_dll/ctocpp/stream_writer_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefStreamWriter::CreateForFile( + const CefString& fileName) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: fileName; type: string_byref_const + DCHECK(!fileName.empty()); + if (fileName.empty()) + return NULL; + + // Execute + cef_stream_writer_t* _retval = cef_stream_writer_create_for_file( + fileName.GetStruct()); + + // Return type: refptr_same + return CefStreamWriterCToCpp::Wrap(_retval); +} + +CefRefPtr CefStreamWriter::CreateForHandler( + CefRefPtr handler) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: handler; type: refptr_diff + DCHECK(handler.get()); + if (!handler.get()) + return NULL; + + // Execute + cef_stream_writer_t* _retval = cef_stream_writer_create_for_handler( + CefWriteHandlerCppToC::Wrap(handler)); + + // Return type: refptr_same + return CefStreamWriterCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +size_t CefStreamWriterCToCpp::Write(const void* ptr, size_t size, size_t n) { + if (CEF_MEMBER_MISSING(struct_, write)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: ptr; type: simple_byaddr + DCHECK(ptr); + if (!ptr) + return 0; + + // Execute + size_t _retval = struct_->write(struct_, + ptr, + size, + n); + + // Return type: simple + return _retval; +} + +int CefStreamWriterCToCpp::Seek(int64 offset, int whence) { + if (CEF_MEMBER_MISSING(struct_, seek)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->seek(struct_, + offset, + whence); + + // Return type: simple + return _retval; +} + +int64 CefStreamWriterCToCpp::Tell() { + if (CEF_MEMBER_MISSING(struct_, tell)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int64 _retval = struct_->tell(struct_); + + // Return type: simple + return _retval; +} + +int CefStreamWriterCToCpp::Flush() { + if (CEF_MEMBER_MISSING(struct_, flush)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->flush(struct_); + + // Return type: simple + return _retval; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/stream_writer_ctocpp.h b/cef3/libcef_dll/ctocpp/stream_writer_ctocpp.h new file mode 100644 index 000000000..dc148e656 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/stream_writer_ctocpp.h @@ -0,0 +1,45 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_STREAM_WRITER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_STREAM_WRITER_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_stream.h" +#include "include/capi/cef_stream_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefStreamWriterCToCpp + : public CefCToCpp { + public: + explicit CefStreamWriterCToCpp(cef_stream_writer_t* str) + : CefCToCpp( + str) {} + virtual ~CefStreamWriterCToCpp() {} + + // CefStreamWriter methods + virtual size_t Write(const void* ptr, size_t size, size_t n) OVERRIDE; + virtual int Seek(int64 offset, int whence) OVERRIDE; + virtual int64 Tell() OVERRIDE; + virtual int Flush() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_STREAM_WRITER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/string_visitor_ctocpp.cc b/cef3/libcef_dll/ctocpp/string_visitor_ctocpp.cc new file mode 100644 index 000000000..e5aa2edc4 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/string_visitor_ctocpp.cc @@ -0,0 +1,39 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/string_visitor_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefStringVisitorCToCpp::Visit(const CefString& string) { + if (CEF_MEMBER_MISSING(struct_, visit)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: string; type: string_byref_const + DCHECK(!string.empty()); + if (string.empty()) + return; + + // Execute + struct_->visit(struct_, + string.GetStruct()); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/string_visitor_ctocpp.h b/cef3/libcef_dll/ctocpp/string_visitor_ctocpp.h new file mode 100644 index 000000000..3e1e28b58 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/string_visitor_ctocpp.h @@ -0,0 +1,42 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_STRING_VISITOR_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_STRING_VISITOR_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_string_visitor.h" +#include "include/capi/cef_string_visitor_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefStringVisitorCToCpp + : public CefCToCpp { + public: + explicit CefStringVisitorCToCpp(cef_string_visitor_t* str) + : CefCToCpp(str) {} + virtual ~CefStringVisitorCToCpp() {} + + // CefStringVisitor methods + virtual void Visit(const CefString& string) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_STRING_VISITOR_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/task_ctocpp.cc b/cef3/libcef_dll/ctocpp/task_ctocpp.cc new file mode 100644 index 000000000..6b3baa845 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/task_ctocpp.cc @@ -0,0 +1,32 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/task_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefTaskCToCpp::Execute() { + if (CEF_MEMBER_MISSING(struct_, execute)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->execute(struct_); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/task_ctocpp.h b/cef3/libcef_dll/ctocpp/task_ctocpp.h new file mode 100644 index 000000000..ec44e40e4 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/task_ctocpp.h @@ -0,0 +1,40 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_TASK_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_TASK_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_task.h" +#include "include/capi/cef_task_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefTaskCToCpp + : public CefCToCpp { + public: + explicit CefTaskCToCpp(cef_task_t* str) + : CefCToCpp(str) {} + virtual ~CefTaskCToCpp() {} + + // CefTask methods + virtual void Execute() OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_TASK_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/task_runner_ctocpp.cc b/cef3/libcef_dll/ctocpp/task_runner_ctocpp.cc new file mode 100644 index 000000000..ccf7961c8 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/task_runner_ctocpp.cc @@ -0,0 +1,134 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/task_cpptoc.h" +#include "libcef_dll/ctocpp/task_runner_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefTaskRunner::GetForCurrentThread() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_task_runner_t* _retval = cef_task_runner_get_for_current_thread(); + + // Return type: refptr_same + return CefTaskRunnerCToCpp::Wrap(_retval); +} + +CefRefPtr CefTaskRunner::GetForThread(CefThreadId threadId) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_task_runner_t* _retval = cef_task_runner_get_for_thread( + threadId); + + // Return type: refptr_same + return CefTaskRunnerCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefTaskRunnerCToCpp::IsSame(CefRefPtr that) { + if (CEF_MEMBER_MISSING(struct_, is_same)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: that; type: refptr_same + DCHECK(that.get()); + if (!that.get()) + return false; + + // Execute + int _retval = struct_->is_same(struct_, + CefTaskRunnerCToCpp::Unwrap(that)); + + // Return type: bool + return _retval?true:false; +} + +bool CefTaskRunnerCToCpp::BelongsToCurrentThread() { + if (CEF_MEMBER_MISSING(struct_, belongs_to_current_thread)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->belongs_to_current_thread(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefTaskRunnerCToCpp::BelongsToThread(CefThreadId threadId) { + if (CEF_MEMBER_MISSING(struct_, belongs_to_thread)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->belongs_to_thread(struct_, + threadId); + + // Return type: bool + return _retval?true:false; +} + +bool CefTaskRunnerCToCpp::PostTask(CefRefPtr task) { + if (CEF_MEMBER_MISSING(struct_, post_task)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: task; type: refptr_diff + DCHECK(task.get()); + if (!task.get()) + return false; + + // Execute + int _retval = struct_->post_task(struct_, + CefTaskCppToC::Wrap(task)); + + // Return type: bool + return _retval?true:false; +} + +bool CefTaskRunnerCToCpp::PostDelayedTask(CefRefPtr task, + int64 delay_ms) { + if (CEF_MEMBER_MISSING(struct_, post_delayed_task)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: task; type: refptr_diff + DCHECK(task.get()); + if (!task.get()) + return false; + + // Execute + int _retval = struct_->post_delayed_task(struct_, + CefTaskCppToC::Wrap(task), + delay_ms); + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/task_runner_ctocpp.h b/cef3/libcef_dll/ctocpp/task_runner_ctocpp.h new file mode 100644 index 000000000..ef671934c --- /dev/null +++ b/cef3/libcef_dll/ctocpp/task_runner_ctocpp.h @@ -0,0 +1,45 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_TASK_RUNNER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_TASK_RUNNER_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_task.h" +#include "include/capi/cef_task_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefTaskRunnerCToCpp + : public CefCToCpp { + public: + explicit CefTaskRunnerCToCpp(cef_task_runner_t* str) + : CefCToCpp(str) {} + virtual ~CefTaskRunnerCToCpp() {} + + // CefTaskRunner methods + virtual bool IsSame(CefRefPtr that) OVERRIDE; + virtual bool BelongsToCurrentThread() OVERRIDE; + virtual bool BelongsToThread(CefThreadId threadId) OVERRIDE; + virtual bool PostTask(CefRefPtr task) OVERRIDE; + virtual bool PostDelayedTask(CefRefPtr task, + int64 delay_ms) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_TASK_RUNNER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/trace_client_ctocpp.cc b/cef3/libcef_dll/ctocpp/trace_client_ctocpp.cc new file mode 100644 index 000000000..37416bba8 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/trace_client_ctocpp.cc @@ -0,0 +1,62 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/trace_client_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefTraceClientCToCpp::OnTraceDataCollected(const char* fragment, + size_t fragment_size) { + if (CEF_MEMBER_MISSING(struct_, on_trace_data_collected)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: fragment; type: simple_byaddr + DCHECK(fragment); + if (!fragment) + return; + + // Execute + struct_->on_trace_data_collected(struct_, + fragment, + fragment_size); +} + +void CefTraceClientCToCpp::OnTraceBufferPercentFullReply(float percent_full) { + if (CEF_MEMBER_MISSING(struct_, on_trace_buffer_percent_full_reply)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->on_trace_buffer_percent_full_reply(struct_, + percent_full); +} + +void CefTraceClientCToCpp::OnEndTracingComplete() { + if (CEF_MEMBER_MISSING(struct_, on_end_tracing_complete)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->on_end_tracing_complete(struct_); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/trace_client_ctocpp.h b/cef3/libcef_dll/ctocpp/trace_client_ctocpp.h new file mode 100644 index 000000000..ab453ca12 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/trace_client_ctocpp.h @@ -0,0 +1,45 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_TRACE_CLIENT_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_TRACE_CLIENT_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_trace.h" +#include "include/capi/cef_trace_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefTraceClientCToCpp + : public CefCToCpp { + public: + explicit CefTraceClientCToCpp(cef_trace_client_t* str) + : CefCToCpp( + str) {} + virtual ~CefTraceClientCToCpp() {} + + // CefTraceClient methods + virtual void OnTraceDataCollected(const char* fragment, + size_t fragment_size) OVERRIDE; + virtual void OnTraceBufferPercentFullReply(float percent_full) OVERRIDE; + virtual void OnEndTracingComplete() OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_TRACE_CLIENT_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/urlrequest_client_ctocpp.cc b/cef3/libcef_dll/ctocpp/urlrequest_client_ctocpp.cc new file mode 100644 index 000000000..b468f23bd --- /dev/null +++ b/cef3/libcef_dll/ctocpp/urlrequest_client_ctocpp.cc @@ -0,0 +1,102 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/urlrequest_cpptoc.h" +#include "libcef_dll/ctocpp/urlrequest_client_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefURLRequestClientCToCpp::OnRequestComplete( + CefRefPtr request) { + if (CEF_MEMBER_MISSING(struct_, on_request_complete)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: request; type: refptr_diff + DCHECK(request.get()); + if (!request.get()) + return; + + // Execute + struct_->on_request_complete(struct_, + CefURLRequestCppToC::Wrap(request)); +} + +void CefURLRequestClientCToCpp::OnUploadProgress( + CefRefPtr request, uint64 current, uint64 total) { + if (CEF_MEMBER_MISSING(struct_, on_upload_progress)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: request; type: refptr_diff + DCHECK(request.get()); + if (!request.get()) + return; + + // Execute + struct_->on_upload_progress(struct_, + CefURLRequestCppToC::Wrap(request), + current, + total); +} + +void CefURLRequestClientCToCpp::OnDownloadProgress( + CefRefPtr request, uint64 current, uint64 total) { + if (CEF_MEMBER_MISSING(struct_, on_download_progress)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: request; type: refptr_diff + DCHECK(request.get()); + if (!request.get()) + return; + + // Execute + struct_->on_download_progress(struct_, + CefURLRequestCppToC::Wrap(request), + current, + total); +} + +void CefURLRequestClientCToCpp::OnDownloadData(CefRefPtr request, + const void* data, size_t data_length) { + if (CEF_MEMBER_MISSING(struct_, on_download_data)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: request; type: refptr_diff + DCHECK(request.get()); + if (!request.get()) + return; + // Verify param: data; type: simple_byaddr + DCHECK(data); + if (!data) + return; + + // Execute + struct_->on_download_data(struct_, + CefURLRequestCppToC::Wrap(request), + data, + data_length); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/urlrequest_client_ctocpp.h b/cef3/libcef_dll/ctocpp/urlrequest_client_ctocpp.h new file mode 100644 index 000000000..6a4d6405c --- /dev/null +++ b/cef3/libcef_dll/ctocpp/urlrequest_client_ctocpp.h @@ -0,0 +1,48 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_URLREQUEST_CLIENT_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_URLREQUEST_CLIENT_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_urlrequest.h" +#include "include/capi/cef_urlrequest_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefURLRequestClientCToCpp + : public CefCToCpp { + public: + explicit CefURLRequestClientCToCpp(cef_urlrequest_client_t* str) + : CefCToCpp(str) {} + virtual ~CefURLRequestClientCToCpp() {} + + // CefURLRequestClient methods + virtual void OnRequestComplete(CefRefPtr request) OVERRIDE; + virtual void OnUploadProgress(CefRefPtr request, + uint64 current, uint64 total) OVERRIDE; + virtual void OnDownloadProgress(CefRefPtr request, + uint64 current, uint64 total) OVERRIDE; + virtual void OnDownloadData(CefRefPtr request, + const void* data, size_t data_length) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_URLREQUEST_CLIENT_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/urlrequest_ctocpp.cc b/cef3/libcef_dll/ctocpp/urlrequest_ctocpp.cc new file mode 100644 index 000000000..c91fe9dc5 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/urlrequest_ctocpp.cc @@ -0,0 +1,126 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/urlrequest_client_cpptoc.h" +#include "libcef_dll/ctocpp/request_ctocpp.h" +#include "libcef_dll/ctocpp/response_ctocpp.h" +#include "libcef_dll/ctocpp/urlrequest_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefURLRequest::Create(CefRefPtr request, + CefRefPtr client) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: request; type: refptr_same + DCHECK(request.get()); + if (!request.get()) + return NULL; + // Verify param: client; type: refptr_diff + DCHECK(client.get()); + if (!client.get()) + return NULL; + + // Execute + cef_urlrequest_t* _retval = cef_urlrequest_create( + CefRequestCToCpp::Unwrap(request), + CefURLRequestClientCppToC::Wrap(client)); + + // Return type: refptr_same + return CefURLRequestCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +CefRefPtr CefURLRequestCToCpp::GetRequest() { + if (CEF_MEMBER_MISSING(struct_, get_request)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_request_t* _retval = struct_->get_request(struct_); + + // Return type: refptr_same + return CefRequestCToCpp::Wrap(_retval); +} + +CefRefPtr CefURLRequestCToCpp::GetClient() { + if (CEF_MEMBER_MISSING(struct_, get_client)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_urlrequest_client_t* _retval = struct_->get_client(struct_); + + // Return type: refptr_diff + return CefURLRequestClientCppToC::Unwrap(_retval); +} + +CefURLRequest::Status CefURLRequestCToCpp::GetRequestStatus() { + if (CEF_MEMBER_MISSING(struct_, get_request_status)) + return UR_UNKNOWN; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_urlrequest_status_t _retval = struct_->get_request_status(struct_); + + // Return type: simple + return _retval; +} + +CefURLRequest::ErrorCode CefURLRequestCToCpp::GetRequestError() { + if (CEF_MEMBER_MISSING(struct_, get_request_error)) + return ERR_NONE; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_errorcode_t _retval = struct_->get_request_error(struct_); + + // Return type: simple + return _retval; +} + +CefRefPtr CefURLRequestCToCpp::GetResponse() { + if (CEF_MEMBER_MISSING(struct_, get_response)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_response_t* _retval = struct_->get_response(struct_); + + // Return type: refptr_same + return CefResponseCToCpp::Wrap(_retval); +} + +void CefURLRequestCToCpp::Cancel() { + if (CEF_MEMBER_MISSING(struct_, cancel)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->cancel(struct_); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/urlrequest_ctocpp.h b/cef3/libcef_dll/ctocpp/urlrequest_ctocpp.h new file mode 100644 index 000000000..793b9b97f --- /dev/null +++ b/cef3/libcef_dll/ctocpp/urlrequest_ctocpp.h @@ -0,0 +1,45 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_URLREQUEST_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_URLREQUEST_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_urlrequest.h" +#include "include/capi/cef_urlrequest_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefURLRequestCToCpp + : public CefCToCpp { + public: + explicit CefURLRequestCToCpp(cef_urlrequest_t* str) + : CefCToCpp(str) {} + virtual ~CefURLRequestCToCpp() {} + + // CefURLRequest methods + virtual CefRefPtr GetRequest() OVERRIDE; + virtual CefRefPtr GetClient() OVERRIDE; + virtual Status GetRequestStatus() OVERRIDE; + virtual ErrorCode GetRequestError() OVERRIDE; + virtual CefRefPtr GetResponse() OVERRIDE; + virtual void Cancel() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_URLREQUEST_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/v8accessor_ctocpp.cc b/cef3/libcef_dll/ctocpp/v8accessor_ctocpp.cc new file mode 100644 index 000000000..9d5c6767d --- /dev/null +++ b/cef3/libcef_dll/ctocpp/v8accessor_ctocpp.cc @@ -0,0 +1,99 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/v8value_cpptoc.h" +#include "libcef_dll/ctocpp/v8accessor_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefV8AccessorCToCpp::Get(const CefString& name, + const CefRefPtr object, CefRefPtr& retval, + CefString& exception) { + if (CEF_MEMBER_MISSING(struct_, get)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: name; type: string_byref_const + DCHECK(!name.empty()); + if (name.empty()) + return false; + // Verify param: object; type: refptr_diff + DCHECK(object.get()); + if (!object.get()) + return false; + + // Translate param: retval; type: refptr_diff_byref + cef_v8value_t* retvalStruct = NULL; + if (retval.get()) + retvalStruct = CefV8ValueCppToC::Wrap(retval); + cef_v8value_t* retvalOrig = retvalStruct; + + // Execute + int _retval = struct_->get(struct_, + name.GetStruct(), + CefV8ValueCppToC::Wrap(object), + &retvalStruct, + exception.GetWritableStruct()); + + // Restore param:retval; type: refptr_diff_byref + if (retvalStruct) { + if (retvalStruct != retvalOrig) { + retval = CefV8ValueCppToC::Unwrap(retvalStruct); + } + } else { + retval = NULL; + } + + // Return type: bool + return _retval?true:false; +} + +bool CefV8AccessorCToCpp::Set(const CefString& name, + const CefRefPtr object, const CefRefPtr value, + CefString& exception) { + if (CEF_MEMBER_MISSING(struct_, set)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: name; type: string_byref_const + DCHECK(!name.empty()); + if (name.empty()) + return false; + // Verify param: object; type: refptr_diff + DCHECK(object.get()); + if (!object.get()) + return false; + // Verify param: value; type: refptr_diff + DCHECK(value.get()); + if (!value.get()) + return false; + + // Execute + int _retval = struct_->set(struct_, + name.GetStruct(), + CefV8ValueCppToC::Wrap(object), + CefV8ValueCppToC::Wrap(value), + exception.GetWritableStruct()); + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/v8accessor_ctocpp.h b/cef3/libcef_dll/ctocpp/v8accessor_ctocpp.h new file mode 100644 index 000000000..e09004418 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/v8accessor_ctocpp.h @@ -0,0 +1,43 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_V8ACCESSOR_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_V8ACCESSOR_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_v8.h" +#include "include/capi/cef_v8_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefV8AccessorCToCpp + : public CefCToCpp { + public: + explicit CefV8AccessorCToCpp(cef_v8accessor_t* str) + : CefCToCpp(str) {} + virtual ~CefV8AccessorCToCpp() {} + + // CefV8Accessor methods + virtual bool Get(const CefString& name, const CefRefPtr object, + CefRefPtr& retval, CefString& exception) OVERRIDE; + virtual bool Set(const CefString& name, const CefRefPtr object, + const CefRefPtr value, CefString& exception) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_V8ACCESSOR_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/v8context_ctocpp.cc b/cef3/libcef_dll/ctocpp/v8context_ctocpp.cc new file mode 100644 index 000000000..5427893a7 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/v8context_ctocpp.cc @@ -0,0 +1,221 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/frame_ctocpp.h" +#include "libcef_dll/ctocpp/task_runner_ctocpp.h" +#include "libcef_dll/ctocpp/v8context_ctocpp.h" +#include "libcef_dll/ctocpp/v8exception_ctocpp.h" +#include "libcef_dll/ctocpp/v8value_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefV8Context::GetCurrentContext() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8context_t* _retval = cef_v8context_get_current_context(); + + // Return type: refptr_same + return CefV8ContextCToCpp::Wrap(_retval); +} + +CefRefPtr CefV8Context::GetEnteredContext() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8context_t* _retval = cef_v8context_get_entered_context(); + + // Return type: refptr_same + return CefV8ContextCToCpp::Wrap(_retval); +} + +bool CefV8Context::InContext() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = cef_v8context_in_context(); + + // Return type: bool + return _retval?true:false; +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +CefRefPtr CefV8ContextCToCpp::GetTaskRunner() { + if (CEF_MEMBER_MISSING(struct_, get_task_runner)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_task_runner_t* _retval = struct_->get_task_runner(struct_); + + // Return type: refptr_same + return CefTaskRunnerCToCpp::Wrap(_retval); +} + +bool CefV8ContextCToCpp::IsValid() { + if (CEF_MEMBER_MISSING(struct_, is_valid)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_valid(struct_); + + // Return type: bool + return _retval?true:false; +} + +CefRefPtr CefV8ContextCToCpp::GetBrowser() { + if (CEF_MEMBER_MISSING(struct_, get_browser)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_browser_t* _retval = struct_->get_browser(struct_); + + // Return type: refptr_same + return CefBrowserCToCpp::Wrap(_retval); +} + +CefRefPtr CefV8ContextCToCpp::GetFrame() { + if (CEF_MEMBER_MISSING(struct_, get_frame)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_frame_t* _retval = struct_->get_frame(struct_); + + // Return type: refptr_same + return CefFrameCToCpp::Wrap(_retval); +} + +CefRefPtr CefV8ContextCToCpp::GetGlobal() { + if (CEF_MEMBER_MISSING(struct_, get_global)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8value_t* _retval = struct_->get_global(struct_); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + +bool CefV8ContextCToCpp::Enter() { + if (CEF_MEMBER_MISSING(struct_, enter)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->enter(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ContextCToCpp::Exit() { + if (CEF_MEMBER_MISSING(struct_, exit)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->exit(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ContextCToCpp::IsSame(CefRefPtr that) { + if (CEF_MEMBER_MISSING(struct_, is_same)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: that; type: refptr_same + DCHECK(that.get()); + if (!that.get()) + return false; + + // Execute + int _retval = struct_->is_same(struct_, + CefV8ContextCToCpp::Unwrap(that)); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ContextCToCpp::Eval(const CefString& code, + CefRefPtr& retval, CefRefPtr& exception) { + if (CEF_MEMBER_MISSING(struct_, eval)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: code; type: string_byref_const + DCHECK(!code.empty()); + if (code.empty()) + return false; + + // Translate param: retval; type: refptr_same_byref + cef_v8value_t* retvalStruct = NULL; + if (retval.get()) + retvalStruct = CefV8ValueCToCpp::Unwrap(retval); + cef_v8value_t* retvalOrig = retvalStruct; + // Translate param: exception; type: refptr_same_byref + cef_v8exception_t* exceptionStruct = NULL; + if (exception.get()) + exceptionStruct = CefV8ExceptionCToCpp::Unwrap(exception); + cef_v8exception_t* exceptionOrig = exceptionStruct; + + // Execute + int _retval = struct_->eval(struct_, + code.GetStruct(), + &retvalStruct, + &exceptionStruct); + + // Restore param:retval; type: refptr_same_byref + if (retvalStruct) { + if (retvalStruct != retvalOrig) { + retval = CefV8ValueCToCpp::Wrap(retvalStruct); + } + } else { + retval = NULL; + } + // Restore param:exception; type: refptr_same_byref + if (exceptionStruct) { + if (exceptionStruct != exceptionOrig) { + exception = CefV8ExceptionCToCpp::Wrap(exceptionStruct); + } + } else { + exception = NULL; + } + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/v8context_ctocpp.h b/cef3/libcef_dll/ctocpp/v8context_ctocpp.h new file mode 100644 index 000000000..f364361b2 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/v8context_ctocpp.h @@ -0,0 +1,49 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_V8CONTEXT_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_V8CONTEXT_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_v8.h" +#include "include/capi/cef_v8_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefV8ContextCToCpp + : public CefCToCpp { + public: + explicit CefV8ContextCToCpp(cef_v8context_t* str) + : CefCToCpp(str) {} + virtual ~CefV8ContextCToCpp() {} + + // CefV8Context methods + virtual CefRefPtr GetTaskRunner() OVERRIDE; + virtual bool IsValid() OVERRIDE; + virtual CefRefPtr GetBrowser() OVERRIDE; + virtual CefRefPtr GetFrame() OVERRIDE; + virtual CefRefPtr GetGlobal() OVERRIDE; + virtual bool Enter() OVERRIDE; + virtual bool Exit() OVERRIDE; + virtual bool IsSame(CefRefPtr that) OVERRIDE; + virtual bool Eval(const CefString& code, CefRefPtr& retval, + CefRefPtr& exception) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_V8CONTEXT_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/v8exception_ctocpp.cc b/cef3/libcef_dll/ctocpp/v8exception_ctocpp.cc new file mode 100644 index 000000000..633a21dc4 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/v8exception_ctocpp.cc @@ -0,0 +1,133 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/v8exception_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +CefString CefV8ExceptionCToCpp::GetMessage() { + if (CEF_MEMBER_MISSING(struct_, get_message)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_message(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefV8ExceptionCToCpp::GetSourceLine() { + if (CEF_MEMBER_MISSING(struct_, get_source_line)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_source_line(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefV8ExceptionCToCpp::GetScriptResourceName() { + if (CEF_MEMBER_MISSING(struct_, get_script_resource_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_script_resource_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +int CefV8ExceptionCToCpp::GetLineNumber() { + if (CEF_MEMBER_MISSING(struct_, get_line_number)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_line_number(struct_); + + // Return type: simple + return _retval; +} + +int CefV8ExceptionCToCpp::GetStartPosition() { + if (CEF_MEMBER_MISSING(struct_, get_start_position)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_start_position(struct_); + + // Return type: simple + return _retval; +} + +int CefV8ExceptionCToCpp::GetEndPosition() { + if (CEF_MEMBER_MISSING(struct_, get_end_position)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_end_position(struct_); + + // Return type: simple + return _retval; +} + +int CefV8ExceptionCToCpp::GetStartColumn() { + if (CEF_MEMBER_MISSING(struct_, get_start_column)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_start_column(struct_); + + // Return type: simple + return _retval; +} + +int CefV8ExceptionCToCpp::GetEndColumn() { + if (CEF_MEMBER_MISSING(struct_, get_end_column)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_end_column(struct_); + + // Return type: simple + return _retval; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/v8exception_ctocpp.h b/cef3/libcef_dll/ctocpp/v8exception_ctocpp.h new file mode 100644 index 000000000..1006a4c0c --- /dev/null +++ b/cef3/libcef_dll/ctocpp/v8exception_ctocpp.h @@ -0,0 +1,49 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_V8EXCEPTION_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_V8EXCEPTION_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_v8.h" +#include "include/capi/cef_v8_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefV8ExceptionCToCpp + : public CefCToCpp { + public: + explicit CefV8ExceptionCToCpp(cef_v8exception_t* str) + : CefCToCpp( + str) {} + virtual ~CefV8ExceptionCToCpp() {} + + // CefV8Exception methods + virtual CefString GetMessage() OVERRIDE; + virtual CefString GetSourceLine() OVERRIDE; + virtual CefString GetScriptResourceName() OVERRIDE; + virtual int GetLineNumber() OVERRIDE; + virtual int GetStartPosition() OVERRIDE; + virtual int GetEndPosition() OVERRIDE; + virtual int GetStartColumn() OVERRIDE; + virtual int GetEndColumn() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_V8EXCEPTION_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/v8handler_ctocpp.cc b/cef3/libcef_dll/ctocpp/v8handler_ctocpp.cc new file mode 100644 index 000000000..4ff8439ca --- /dev/null +++ b/cef3/libcef_dll/ctocpp/v8handler_ctocpp.cc @@ -0,0 +1,84 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/v8value_cpptoc.h" +#include "libcef_dll/ctocpp/v8handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefV8HandlerCToCpp::Execute(const CefString& name, + CefRefPtr object, const CefV8ValueList& arguments, + CefRefPtr& retval, CefString& exception) { + if (CEF_MEMBER_MISSING(struct_, execute)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: name; type: string_byref_const + DCHECK(!name.empty()); + if (name.empty()) + return false; + // Verify param: object; type: refptr_diff + DCHECK(object.get()); + if (!object.get()) + return false; + + // Translate param: arguments; type: refptr_vec_diff_byref_const + const size_t argumentsCount = arguments.size(); + cef_v8value_t** argumentsList = NULL; + if (argumentsCount > 0) { + argumentsList = new cef_v8value_t*[argumentsCount]; + DCHECK(argumentsList); + if (argumentsList) { + for (size_t i = 0; i < argumentsCount; ++i) { + argumentsList[i] = CefV8ValueCppToC::Wrap(arguments[i]); + } + } + } + // Translate param: retval; type: refptr_diff_byref + cef_v8value_t* retvalStruct = NULL; + if (retval.get()) + retvalStruct = CefV8ValueCppToC::Wrap(retval); + cef_v8value_t* retvalOrig = retvalStruct; + + // Execute + int _retval = struct_->execute(struct_, + name.GetStruct(), + CefV8ValueCppToC::Wrap(object), + argumentsCount, + argumentsList, + &retvalStruct, + exception.GetWritableStruct()); + + // Restore param:arguments; type: refptr_vec_diff_byref_const + if (argumentsList) + delete [] argumentsList; + // Restore param:retval; type: refptr_diff_byref + if (retvalStruct) { + if (retvalStruct != retvalOrig) { + retval = CefV8ValueCppToC::Unwrap(retvalStruct); + } + } else { + retval = NULL; + } + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/v8handler_ctocpp.h b/cef3/libcef_dll/ctocpp/v8handler_ctocpp.h new file mode 100644 index 000000000..534ccdfe1 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/v8handler_ctocpp.h @@ -0,0 +1,42 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_V8HANDLER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_V8HANDLER_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_v8.h" +#include "include/capi/cef_v8_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefV8HandlerCToCpp + : public CefCToCpp { + public: + explicit CefV8HandlerCToCpp(cef_v8handler_t* str) + : CefCToCpp(str) {} + virtual ~CefV8HandlerCToCpp() {} + + // CefV8Handler methods + virtual bool Execute(const CefString& name, CefRefPtr object, + const CefV8ValueList& arguments, CefRefPtr& retval, + CefString& exception) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_V8HANDLER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/v8stack_frame_ctocpp.cc b/cef3/libcef_dll/ctocpp/v8stack_frame_ctocpp.cc new file mode 100644 index 000000000..a0de4d3a0 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/v8stack_frame_ctocpp.cc @@ -0,0 +1,134 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/v8stack_frame_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefV8StackFrameCToCpp::IsValid() { + if (CEF_MEMBER_MISSING(struct_, is_valid)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_valid(struct_); + + // Return type: bool + return _retval?true:false; +} + +CefString CefV8StackFrameCToCpp::GetScriptName() { + if (CEF_MEMBER_MISSING(struct_, get_script_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_script_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefV8StackFrameCToCpp::GetScriptNameOrSourceURL() { + if (CEF_MEMBER_MISSING(struct_, get_script_name_or_source_url)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_script_name_or_source_url( + struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefV8StackFrameCToCpp::GetFunctionName() { + if (CEF_MEMBER_MISSING(struct_, get_function_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_function_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +int CefV8StackFrameCToCpp::GetLineNumber() { + if (CEF_MEMBER_MISSING(struct_, get_line_number)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_line_number(struct_); + + // Return type: simple + return _retval; +} + +int CefV8StackFrameCToCpp::GetColumn() { + if (CEF_MEMBER_MISSING(struct_, get_column)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_column(struct_); + + // Return type: simple + return _retval; +} + +bool CefV8StackFrameCToCpp::IsEval() { + if (CEF_MEMBER_MISSING(struct_, is_eval)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_eval(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8StackFrameCToCpp::IsConstructor() { + if (CEF_MEMBER_MISSING(struct_, is_constructor)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_constructor(struct_); + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/v8stack_frame_ctocpp.h b/cef3/libcef_dll/ctocpp/v8stack_frame_ctocpp.h new file mode 100644 index 000000000..7d1cace31 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/v8stack_frame_ctocpp.h @@ -0,0 +1,49 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_V8STACK_FRAME_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_V8STACK_FRAME_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_v8.h" +#include "include/capi/cef_v8_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefV8StackFrameCToCpp + : public CefCToCpp { + public: + explicit CefV8StackFrameCToCpp(cef_v8stack_frame_t* str) + : CefCToCpp( + str) {} + virtual ~CefV8StackFrameCToCpp() {} + + // CefV8StackFrame methods + virtual bool IsValid() OVERRIDE; + virtual CefString GetScriptName() OVERRIDE; + virtual CefString GetScriptNameOrSourceURL() OVERRIDE; + virtual CefString GetFunctionName() OVERRIDE; + virtual int GetLineNumber() OVERRIDE; + virtual int GetColumn() OVERRIDE; + virtual bool IsEval() OVERRIDE; + virtual bool IsConstructor() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_V8STACK_FRAME_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/v8stack_trace_ctocpp.cc b/cef3/libcef_dll/ctocpp/v8stack_trace_ctocpp.cc new file mode 100644 index 000000000..0764c7ead --- /dev/null +++ b/cef3/libcef_dll/ctocpp/v8stack_trace_ctocpp.cc @@ -0,0 +1,78 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/v8stack_frame_ctocpp.h" +#include "libcef_dll/ctocpp/v8stack_trace_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefV8StackTrace::GetCurrent(int frame_limit) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8stack_trace_t* _retval = cef_v8stack_trace_get_current( + frame_limit); + + // Return type: refptr_same + return CefV8StackTraceCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefV8StackTraceCToCpp::IsValid() { + if (CEF_MEMBER_MISSING(struct_, is_valid)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_valid(struct_); + + // Return type: bool + return _retval?true:false; +} + +int CefV8StackTraceCToCpp::GetFrameCount() { + if (CEF_MEMBER_MISSING(struct_, get_frame_count)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_frame_count(struct_); + + // Return type: simple + return _retval; +} + +CefRefPtr CefV8StackTraceCToCpp::GetFrame(int index) { + if (CEF_MEMBER_MISSING(struct_, get_frame)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8stack_frame_t* _retval = struct_->get_frame(struct_, + index); + + // Return type: refptr_same + return CefV8StackFrameCToCpp::Wrap(_retval); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/v8stack_trace_ctocpp.h b/cef3/libcef_dll/ctocpp/v8stack_trace_ctocpp.h new file mode 100644 index 000000000..8e72b8865 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/v8stack_trace_ctocpp.h @@ -0,0 +1,44 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_V8STACK_TRACE_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_V8STACK_TRACE_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_v8.h" +#include "include/capi/cef_v8_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefV8StackTraceCToCpp + : public CefCToCpp { + public: + explicit CefV8StackTraceCToCpp(cef_v8stack_trace_t* str) + : CefCToCpp( + str) {} + virtual ~CefV8StackTraceCToCpp() {} + + // CefV8StackTrace methods + virtual bool IsValid() OVERRIDE; + virtual int GetFrameCount() OVERRIDE; + virtual CefRefPtr GetFrame(int index) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_V8STACK_TRACE_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/v8value_ctocpp.cc b/cef3/libcef_dll/ctocpp/v8value_ctocpp.cc new file mode 100644 index 000000000..36d2063d2 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/v8value_ctocpp.cc @@ -0,0 +1,874 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/base_cpptoc.h" +#include "libcef_dll/cpptoc/v8accessor_cpptoc.h" +#include "libcef_dll/cpptoc/v8handler_cpptoc.h" +#include "libcef_dll/ctocpp/v8context_ctocpp.h" +#include "libcef_dll/ctocpp/v8exception_ctocpp.h" +#include "libcef_dll/ctocpp/v8value_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefV8Value::CreateUndefined() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8value_t* _retval = cef_v8value_create_undefined(); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + +CefRefPtr CefV8Value::CreateNull() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8value_t* _retval = cef_v8value_create_null(); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + +CefRefPtr CefV8Value::CreateBool(bool value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8value_t* _retval = cef_v8value_create_bool( + value); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + +CefRefPtr CefV8Value::CreateInt(int32 value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8value_t* _retval = cef_v8value_create_int( + value); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + +CefRefPtr CefV8Value::CreateUInt(uint32 value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8value_t* _retval = cef_v8value_create_uint( + value); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + +CefRefPtr CefV8Value::CreateDouble(double value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8value_t* _retval = cef_v8value_create_double( + value); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + +CefRefPtr CefV8Value::CreateDate(const CefTime& date) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8value_t* _retval = cef_v8value_create_date( + &date); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + +CefRefPtr CefV8Value::CreateString(const CefString& value) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: value + + // Execute + cef_v8value_t* _retval = cef_v8value_create_string( + value.GetStruct()); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + +CefRefPtr CefV8Value::CreateObject( + CefRefPtr accessor) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: accessor + + // Execute + cef_v8value_t* _retval = cef_v8value_create_object( + CefV8AccessorCppToC::Wrap(accessor)); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + +CefRefPtr CefV8Value::CreateArray(int length) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8value_t* _retval = cef_v8value_create_array( + length); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + +CefRefPtr CefV8Value::CreateFunction(const CefString& name, + CefRefPtr handler) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: name; type: string_byref_const + DCHECK(!name.empty()); + if (name.empty()) + return NULL; + // Verify param: handler; type: refptr_diff + DCHECK(handler.get()); + if (!handler.get()) + return NULL; + + // Execute + cef_v8value_t* _retval = cef_v8value_create_function( + name.GetStruct(), + CefV8HandlerCppToC::Wrap(handler)); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefV8ValueCToCpp::IsValid() { + if (CEF_MEMBER_MISSING(struct_, is_valid)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_valid(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ValueCToCpp::IsUndefined() { + if (CEF_MEMBER_MISSING(struct_, is_undefined)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_undefined(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ValueCToCpp::IsNull() { + if (CEF_MEMBER_MISSING(struct_, is_null)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_null(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ValueCToCpp::IsBool() { + if (CEF_MEMBER_MISSING(struct_, is_bool)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_bool(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ValueCToCpp::IsInt() { + if (CEF_MEMBER_MISSING(struct_, is_int)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_int(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ValueCToCpp::IsUInt() { + if (CEF_MEMBER_MISSING(struct_, is_uint)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_uint(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ValueCToCpp::IsDouble() { + if (CEF_MEMBER_MISSING(struct_, is_double)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_double(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ValueCToCpp::IsDate() { + if (CEF_MEMBER_MISSING(struct_, is_date)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_date(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ValueCToCpp::IsString() { + if (CEF_MEMBER_MISSING(struct_, is_string)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_string(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ValueCToCpp::IsObject() { + if (CEF_MEMBER_MISSING(struct_, is_object)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_object(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ValueCToCpp::IsArray() { + if (CEF_MEMBER_MISSING(struct_, is_array)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_array(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ValueCToCpp::IsFunction() { + if (CEF_MEMBER_MISSING(struct_, is_function)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_function(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ValueCToCpp::IsSame(CefRefPtr that) { + if (CEF_MEMBER_MISSING(struct_, is_same)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: that; type: refptr_same + DCHECK(that.get()); + if (!that.get()) + return false; + + // Execute + int _retval = struct_->is_same(struct_, + CefV8ValueCToCpp::Unwrap(that)); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ValueCToCpp::GetBoolValue() { + if (CEF_MEMBER_MISSING(struct_, get_bool_value)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_bool_value(struct_); + + // Return type: bool + return _retval?true:false; +} + +int32 CefV8ValueCToCpp::GetIntValue() { + if (CEF_MEMBER_MISSING(struct_, get_int_value)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int32 _retval = struct_->get_int_value(struct_); + + // Return type: simple + return _retval; +} + +uint32 CefV8ValueCToCpp::GetUIntValue() { + if (CEF_MEMBER_MISSING(struct_, get_uint_value)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + uint32 _retval = struct_->get_uint_value(struct_); + + // Return type: simple + return _retval; +} + +double CefV8ValueCToCpp::GetDoubleValue() { + if (CEF_MEMBER_MISSING(struct_, get_double_value)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + double _retval = struct_->get_double_value(struct_); + + // Return type: simple + return _retval; +} + +CefTime CefV8ValueCToCpp::GetDateValue() { + if (CEF_MEMBER_MISSING(struct_, get_date_value)) + return CefTime(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_time_t _retval = struct_->get_date_value(struct_); + + // Return type: simple + return _retval; +} + +CefString CefV8ValueCToCpp::GetStringValue() { + if (CEF_MEMBER_MISSING(struct_, get_string_value)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_string_value(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +bool CefV8ValueCToCpp::IsUserCreated() { + if (CEF_MEMBER_MISSING(struct_, is_user_created)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_user_created(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ValueCToCpp::HasException() { + if (CEF_MEMBER_MISSING(struct_, has_exception)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->has_exception(struct_); + + // Return type: bool + return _retval?true:false; +} + +CefRefPtr CefV8ValueCToCpp::GetException() { + if (CEF_MEMBER_MISSING(struct_, get_exception)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8exception_t* _retval = struct_->get_exception(struct_); + + // Return type: refptr_same + return CefV8ExceptionCToCpp::Wrap(_retval); +} + +bool CefV8ValueCToCpp::ClearException() { + if (CEF_MEMBER_MISSING(struct_, clear_exception)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->clear_exception(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ValueCToCpp::WillRethrowExceptions() { + if (CEF_MEMBER_MISSING(struct_, will_rethrow_exceptions)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->will_rethrow_exceptions(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ValueCToCpp::SetRethrowExceptions(bool rethrow) { + if (CEF_MEMBER_MISSING(struct_, set_rethrow_exceptions)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->set_rethrow_exceptions(struct_, + rethrow); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ValueCToCpp::HasValue(const CefString& key) { + if (CEF_MEMBER_MISSING(struct_, has_value_bykey)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: key + + // Execute + int _retval = struct_->has_value_bykey(struct_, + key.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ValueCToCpp::HasValue(int index) { + if (CEF_MEMBER_MISSING(struct_, has_value_byindex)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return false; + + // Execute + int _retval = struct_->has_value_byindex(struct_, + index); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ValueCToCpp::DeleteValue(const CefString& key) { + if (CEF_MEMBER_MISSING(struct_, delete_value_bykey)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: key + + // Execute + int _retval = struct_->delete_value_bykey(struct_, + key.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ValueCToCpp::DeleteValue(int index) { + if (CEF_MEMBER_MISSING(struct_, delete_value_byindex)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return false; + + // Execute + int _retval = struct_->delete_value_byindex(struct_, + index); + + // Return type: bool + return _retval?true:false; +} + +CefRefPtr CefV8ValueCToCpp::GetValue(const CefString& key) { + if (CEF_MEMBER_MISSING(struct_, get_value_bykey)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: key + + // Execute + cef_v8value_t* _retval = struct_->get_value_bykey(struct_, + key.GetStruct()); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + +CefRefPtr CefV8ValueCToCpp::GetValue(int index) { + if (CEF_MEMBER_MISSING(struct_, get_value_byindex)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return NULL; + + // Execute + cef_v8value_t* _retval = struct_->get_value_byindex(struct_, + index); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + +bool CefV8ValueCToCpp::SetValue(const CefString& key, + CefRefPtr value, PropertyAttribute attribute) { + if (CEF_MEMBER_MISSING(struct_, set_value_bykey)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: value; type: refptr_same + DCHECK(value.get()); + if (!value.get()) + return false; + // Unverified params: key + + // Execute + int _retval = struct_->set_value_bykey(struct_, + key.GetStruct(), + CefV8ValueCToCpp::Unwrap(value), + attribute); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ValueCToCpp::SetValue(int index, CefRefPtr value) { + if (CEF_MEMBER_MISSING(struct_, set_value_byindex)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return false; + // Verify param: value; type: refptr_same + DCHECK(value.get()); + if (!value.get()) + return false; + + // Execute + int _retval = struct_->set_value_byindex(struct_, + index, + CefV8ValueCToCpp::Unwrap(value)); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ValueCToCpp::SetValue(const CefString& key, AccessControl settings, + PropertyAttribute attribute) { + if (CEF_MEMBER_MISSING(struct_, set_value_byaccessor)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: key + + // Execute + int _retval = struct_->set_value_byaccessor(struct_, + key.GetStruct(), + settings, + attribute); + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ValueCToCpp::GetKeys(std::vector& keys) { + if (CEF_MEMBER_MISSING(struct_, get_keys)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: keys; type: string_vec_byref + cef_string_list_t keysList = cef_string_list_alloc(); + DCHECK(keysList); + if (keysList) + transfer_string_list_contents(keys, keysList); + + // Execute + int _retval = struct_->get_keys(struct_, + keysList); + + // Restore param:keys; type: string_vec_byref + if (keysList) { + keys.clear(); + transfer_string_list_contents(keysList, keys); + cef_string_list_free(keysList); + } + + // Return type: bool + return _retval?true:false; +} + +bool CefV8ValueCToCpp::SetUserData(CefRefPtr user_data) { + if (CEF_MEMBER_MISSING(struct_, set_user_data)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: user_data + + // Execute + int _retval = struct_->set_user_data(struct_, + CefBaseCppToC::Wrap(user_data)); + + // Return type: bool + return _retval?true:false; +} + +CefRefPtr CefV8ValueCToCpp::GetUserData() { + if (CEF_MEMBER_MISSING(struct_, get_user_data)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_base_t* _retval = struct_->get_user_data(struct_); + + // Return type: refptr_diff + return CefBaseCppToC::Unwrap(_retval); +} + +int CefV8ValueCToCpp::GetExternallyAllocatedMemory() { + if (CEF_MEMBER_MISSING(struct_, get_externally_allocated_memory)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_externally_allocated_memory(struct_); + + // Return type: simple + return _retval; +} + +int CefV8ValueCToCpp::AdjustExternallyAllocatedMemory(int change_in_bytes) { + if (CEF_MEMBER_MISSING(struct_, adjust_externally_allocated_memory)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->adjust_externally_allocated_memory(struct_, + change_in_bytes); + + // Return type: simple + return _retval; +} + +int CefV8ValueCToCpp::GetArrayLength() { + if (CEF_MEMBER_MISSING(struct_, get_array_length)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_array_length(struct_); + + // Return type: simple + return _retval; +} + +CefString CefV8ValueCToCpp::GetFunctionName() { + if (CEF_MEMBER_MISSING(struct_, get_function_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_function_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefRefPtr CefV8ValueCToCpp::GetFunctionHandler() { + if (CEF_MEMBER_MISSING(struct_, get_function_handler)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8handler_t* _retval = struct_->get_function_handler(struct_); + + // Return type: refptr_diff + return CefV8HandlerCppToC::Unwrap(_retval); +} + +CefRefPtr CefV8ValueCToCpp::ExecuteFunction( + CefRefPtr object, const CefV8ValueList& arguments) { + if (CEF_MEMBER_MISSING(struct_, execute_function)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: object + + // Translate param: arguments; type: refptr_vec_same_byref_const + const size_t argumentsCount = arguments.size(); + cef_v8value_t** argumentsList = NULL; + if (argumentsCount > 0) { + argumentsList = new cef_v8value_t*[argumentsCount]; + DCHECK(argumentsList); + if (argumentsList) { + for (size_t i = 0; i < argumentsCount; ++i) { + argumentsList[i] = CefV8ValueCToCpp::Unwrap(arguments[i]); + } + } + } + + // Execute + cef_v8value_t* _retval = struct_->execute_function(struct_, + CefV8ValueCToCpp::Unwrap(object), + argumentsCount, + argumentsList); + + // Restore param:arguments; type: refptr_vec_same_byref_const + if (argumentsList) + delete [] argumentsList; + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + +CefRefPtr CefV8ValueCToCpp::ExecuteFunctionWithContext( + CefRefPtr context, CefRefPtr object, + const CefV8ValueList& arguments) { + if (CEF_MEMBER_MISSING(struct_, execute_function_with_context)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: context; type: refptr_same + DCHECK(context.get()); + if (!context.get()) + return NULL; + // Unverified params: object + + // Translate param: arguments; type: refptr_vec_same_byref_const + const size_t argumentsCount = arguments.size(); + cef_v8value_t** argumentsList = NULL; + if (argumentsCount > 0) { + argumentsList = new cef_v8value_t*[argumentsCount]; + DCHECK(argumentsList); + if (argumentsList) { + for (size_t i = 0; i < argumentsCount; ++i) { + argumentsList[i] = CefV8ValueCToCpp::Unwrap(arguments[i]); + } + } + } + + // Execute + cef_v8value_t* _retval = struct_->execute_function_with_context(struct_, + CefV8ContextCToCpp::Unwrap(context), + CefV8ValueCToCpp::Unwrap(object), + argumentsCount, + argumentsList); + + // Restore param:arguments; type: refptr_vec_same_byref_const + if (argumentsList) + delete [] argumentsList; + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/v8value_ctocpp.h b/cef3/libcef_dll/ctocpp/v8value_ctocpp.h new file mode 100644 index 000000000..552b020b5 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/v8value_ctocpp.h @@ -0,0 +1,89 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_V8VALUE_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_V8VALUE_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include +#include "include/cef_v8.h" +#include "include/capi/cef_v8_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefV8ValueCToCpp + : public CefCToCpp { + public: + explicit CefV8ValueCToCpp(cef_v8value_t* str) + : CefCToCpp(str) {} + virtual ~CefV8ValueCToCpp() {} + + // CefV8Value methods + virtual bool IsValid() OVERRIDE; + virtual bool IsUndefined() OVERRIDE; + virtual bool IsNull() OVERRIDE; + virtual bool IsBool() OVERRIDE; + virtual bool IsInt() OVERRIDE; + virtual bool IsUInt() OVERRIDE; + virtual bool IsDouble() OVERRIDE; + virtual bool IsDate() OVERRIDE; + virtual bool IsString() OVERRIDE; + virtual bool IsObject() OVERRIDE; + virtual bool IsArray() OVERRIDE; + virtual bool IsFunction() OVERRIDE; + virtual bool IsSame(CefRefPtr that) OVERRIDE; + virtual bool GetBoolValue() OVERRIDE; + virtual int32 GetIntValue() OVERRIDE; + virtual uint32 GetUIntValue() OVERRIDE; + virtual double GetDoubleValue() OVERRIDE; + virtual CefTime GetDateValue() OVERRIDE; + virtual CefString GetStringValue() OVERRIDE; + virtual bool IsUserCreated() OVERRIDE; + virtual bool HasException() OVERRIDE; + virtual CefRefPtr GetException() OVERRIDE; + virtual bool ClearException() OVERRIDE; + virtual bool WillRethrowExceptions() OVERRIDE; + virtual bool SetRethrowExceptions(bool rethrow) OVERRIDE; + virtual bool HasValue(const CefString& key) OVERRIDE; + virtual bool HasValue(int index) OVERRIDE; + virtual bool DeleteValue(const CefString& key) OVERRIDE; + virtual bool DeleteValue(int index) OVERRIDE; + virtual CefRefPtr GetValue(const CefString& key) OVERRIDE; + virtual CefRefPtr GetValue(int index) OVERRIDE; + virtual bool SetValue(const CefString& key, CefRefPtr value, + PropertyAttribute attribute) OVERRIDE; + virtual bool SetValue(int index, CefRefPtr value) OVERRIDE; + virtual bool SetValue(const CefString& key, AccessControl settings, + PropertyAttribute attribute) OVERRIDE; + virtual bool GetKeys(std::vector& keys) OVERRIDE; + virtual bool SetUserData(CefRefPtr user_data) OVERRIDE; + virtual CefRefPtr GetUserData() OVERRIDE; + virtual int GetExternallyAllocatedMemory() OVERRIDE; + virtual int AdjustExternallyAllocatedMemory(int change_in_bytes) OVERRIDE; + virtual int GetArrayLength() OVERRIDE; + virtual CefString GetFunctionName() OVERRIDE; + virtual CefRefPtr GetFunctionHandler() OVERRIDE; + virtual CefRefPtr ExecuteFunction(CefRefPtr object, + const CefV8ValueList& arguments) OVERRIDE; + virtual CefRefPtr ExecuteFunctionWithContext( + CefRefPtr context, CefRefPtr object, + const CefV8ValueList& arguments) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_V8VALUE_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/web_plugin_info_ctocpp.cc b/cef3/libcef_dll/ctocpp/web_plugin_info_ctocpp.cc new file mode 100644 index 000000000..602021219 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/web_plugin_info_ctocpp.cc @@ -0,0 +1,83 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/web_plugin_info_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +CefString CefWebPluginInfoCToCpp::GetName() { + if (CEF_MEMBER_MISSING(struct_, get_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefWebPluginInfoCToCpp::GetPath() { + if (CEF_MEMBER_MISSING(struct_, get_path)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_path(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefWebPluginInfoCToCpp::GetVersion() { + if (CEF_MEMBER_MISSING(struct_, get_version)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_version(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefWebPluginInfoCToCpp::GetDescription() { + if (CEF_MEMBER_MISSING(struct_, get_description)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_description(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/web_plugin_info_ctocpp.h b/cef3/libcef_dll/ctocpp/web_plugin_info_ctocpp.h new file mode 100644 index 000000000..c1be75da0 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/web_plugin_info_ctocpp.h @@ -0,0 +1,45 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_WEB_PLUGIN_INFO_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_WEB_PLUGIN_INFO_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_web_plugin.h" +#include "include/capi/cef_web_plugin_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefWebPluginInfoCToCpp + : public CefCToCpp { + public: + explicit CefWebPluginInfoCToCpp(cef_web_plugin_info_t* str) + : CefCToCpp(str) {} + virtual ~CefWebPluginInfoCToCpp() {} + + // CefWebPluginInfo methods + virtual CefString GetName() OVERRIDE; + virtual CefString GetPath() OVERRIDE; + virtual CefString GetVersion() OVERRIDE; + virtual CefString GetDescription() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_WEB_PLUGIN_INFO_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/web_plugin_info_visitor_ctocpp.cc b/cef3/libcef_dll/ctocpp/web_plugin_info_visitor_ctocpp.cc new file mode 100644 index 000000000..ea3b9691f --- /dev/null +++ b/cef3/libcef_dll/ctocpp/web_plugin_info_visitor_ctocpp.cc @@ -0,0 +1,46 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/web_plugin_info_cpptoc.h" +#include "libcef_dll/ctocpp/web_plugin_info_visitor_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefWebPluginInfoVisitorCToCpp::Visit(CefRefPtr info, + int count, int total) { + if (CEF_MEMBER_MISSING(struct_, visit)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: info; type: refptr_diff + DCHECK(info.get()); + if (!info.get()) + return false; + + // Execute + int _retval = struct_->visit(struct_, + CefWebPluginInfoCppToC::Wrap(info), + count, + total); + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/web_plugin_info_visitor_ctocpp.h b/cef3/libcef_dll/ctocpp/web_plugin_info_visitor_ctocpp.h new file mode 100644 index 000000000..02927f0e9 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/web_plugin_info_visitor_ctocpp.h @@ -0,0 +1,43 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_WEB_PLUGIN_INFO_VISITOR_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_WEB_PLUGIN_INFO_VISITOR_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_web_plugin.h" +#include "include/capi/cef_web_plugin_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefWebPluginInfoVisitorCToCpp + : public CefCToCpp { + public: + explicit CefWebPluginInfoVisitorCToCpp(cef_web_plugin_info_visitor_t* str) + : CefCToCpp(str) {} + virtual ~CefWebPluginInfoVisitorCToCpp() {} + + // CefWebPluginInfoVisitor methods + virtual bool Visit(CefRefPtr info, int count, + int total) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_WEB_PLUGIN_INFO_VISITOR_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/web_plugin_unstable_callback_ctocpp.cc b/cef3/libcef_dll/ctocpp/web_plugin_unstable_callback_ctocpp.cc new file mode 100644 index 000000000..9feb35922 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/web_plugin_unstable_callback_ctocpp.cc @@ -0,0 +1,42 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/web_plugin_unstable_callback_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefWebPluginUnstableCallbackCToCpp::IsUnstable(const CefString& path, + bool unstable) { + if (CEF_MEMBER_MISSING(struct_, is_unstable)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: path; type: string_byref_const + DCHECK(!path.empty()); + if (path.empty()) + return; + + // Execute + struct_->is_unstable(struct_, + path.GetStruct(), + unstable); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/web_plugin_unstable_callback_ctocpp.h b/cef3/libcef_dll/ctocpp/web_plugin_unstable_callback_ctocpp.h new file mode 100644 index 000000000..6d534fc4d --- /dev/null +++ b/cef3/libcef_dll/ctocpp/web_plugin_unstable_callback_ctocpp.h @@ -0,0 +1,44 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_WEB_PLUGIN_UNSTABLE_CALLBACK_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_WEB_PLUGIN_UNSTABLE_CALLBACK_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_web_plugin.h" +#include "include/capi/cef_web_plugin_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefWebPluginUnstableCallbackCToCpp + : public CefCToCpp { + public: + explicit CefWebPluginUnstableCallbackCToCpp( + cef_web_plugin_unstable_callback_t* str) + : CefCToCpp( + str) {} + virtual ~CefWebPluginUnstableCallbackCToCpp() {} + + // CefWebPluginUnstableCallback methods + virtual void IsUnstable(const CefString& path, bool unstable) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_WEB_PLUGIN_UNSTABLE_CALLBACK_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/write_handler_ctocpp.cc b/cef3/libcef_dll/ctocpp/write_handler_ctocpp.cc new file mode 100644 index 000000000..19745e429 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/write_handler_ctocpp.cc @@ -0,0 +1,85 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/write_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +size_t CefWriteHandlerCToCpp::Write(const void* ptr, size_t size, size_t n) { + if (CEF_MEMBER_MISSING(struct_, write)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: ptr; type: simple_byaddr + DCHECK(ptr); + if (!ptr) + return 0; + + // Execute + size_t _retval = struct_->write(struct_, + ptr, + size, + n); + + // Return type: simple + return _retval; +} + +int CefWriteHandlerCToCpp::Seek(int64 offset, int whence) { + if (CEF_MEMBER_MISSING(struct_, seek)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->seek(struct_, + offset, + whence); + + // Return type: simple + return _retval; +} + +int64 CefWriteHandlerCToCpp::Tell() { + if (CEF_MEMBER_MISSING(struct_, tell)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int64 _retval = struct_->tell(struct_); + + // Return type: simple + return _retval; +} + +int CefWriteHandlerCToCpp::Flush() { + if (CEF_MEMBER_MISSING(struct_, flush)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->flush(struct_); + + // Return type: simple + return _retval; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/write_handler_ctocpp.h b/cef3/libcef_dll/ctocpp/write_handler_ctocpp.h new file mode 100644 index 000000000..fb13edc2c --- /dev/null +++ b/cef3/libcef_dll/ctocpp/write_handler_ctocpp.h @@ -0,0 +1,45 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_WRITE_HANDLER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_WRITE_HANDLER_CTOCPP_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_stream.h" +#include "include/capi/cef_stream_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefWriteHandlerCToCpp + : public CefCToCpp { + public: + explicit CefWriteHandlerCToCpp(cef_write_handler_t* str) + : CefCToCpp( + str) {} + virtual ~CefWriteHandlerCToCpp() {} + + // CefWriteHandler methods + virtual size_t Write(const void* ptr, size_t size, size_t n) OVERRIDE; + virtual int Seek(int64 offset, int whence) OVERRIDE; + virtual int64 Tell() OVERRIDE; + virtual int Flush() OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_WRITE_HANDLER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/xml_reader_ctocpp.cc b/cef3/libcef_dll/ctocpp/xml_reader_ctocpp.cc new file mode 100644 index 000000000..be5c533b7 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/xml_reader_ctocpp.cc @@ -0,0 +1,501 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/stream_reader_ctocpp.h" +#include "libcef_dll/ctocpp/xml_reader_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefXmlReader::Create(CefRefPtr stream, + EncodingType encodingType, const CefString& URI) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: stream; type: refptr_same + DCHECK(stream.get()); + if (!stream.get()) + return NULL; + // Verify param: URI; type: string_byref_const + DCHECK(!URI.empty()); + if (URI.empty()) + return NULL; + + // Execute + cef_xml_reader_t* _retval = cef_xml_reader_create( + CefStreamReaderCToCpp::Unwrap(stream), + encodingType, + URI.GetStruct()); + + // Return type: refptr_same + return CefXmlReaderCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefXmlReaderCToCpp::MoveToNextNode() { + if (CEF_MEMBER_MISSING(struct_, move_to_next_node)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->move_to_next_node(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefXmlReaderCToCpp::Close() { + if (CEF_MEMBER_MISSING(struct_, close)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->close(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefXmlReaderCToCpp::HasError() { + if (CEF_MEMBER_MISSING(struct_, has_error)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->has_error(struct_); + + // Return type: bool + return _retval?true:false; +} + +CefString CefXmlReaderCToCpp::GetError() { + if (CEF_MEMBER_MISSING(struct_, get_error)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_error(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefXmlReader::NodeType CefXmlReaderCToCpp::GetType() { + if (CEF_MEMBER_MISSING(struct_, get_type)) + return XML_NODE_UNSUPPORTED; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_xml_node_type_t _retval = struct_->get_type(struct_); + + // Return type: simple + return _retval; +} + +int CefXmlReaderCToCpp::GetDepth() { + if (CEF_MEMBER_MISSING(struct_, get_depth)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_depth(struct_); + + // Return type: simple + return _retval; +} + +CefString CefXmlReaderCToCpp::GetLocalName() { + if (CEF_MEMBER_MISSING(struct_, get_local_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_local_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefXmlReaderCToCpp::GetPrefix() { + if (CEF_MEMBER_MISSING(struct_, get_prefix)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_prefix(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefXmlReaderCToCpp::GetQualifiedName() { + if (CEF_MEMBER_MISSING(struct_, get_qualified_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_qualified_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefXmlReaderCToCpp::GetNamespaceURI() { + if (CEF_MEMBER_MISSING(struct_, get_namespace_uri)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_namespace_uri(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefXmlReaderCToCpp::GetBaseURI() { + if (CEF_MEMBER_MISSING(struct_, get_base_uri)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_base_uri(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefXmlReaderCToCpp::GetXmlLang() { + if (CEF_MEMBER_MISSING(struct_, get_xml_lang)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_xml_lang(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +bool CefXmlReaderCToCpp::IsEmptyElement() { + if (CEF_MEMBER_MISSING(struct_, is_empty_element)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_empty_element(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefXmlReaderCToCpp::HasValue() { + if (CEF_MEMBER_MISSING(struct_, has_value)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->has_value(struct_); + + // Return type: bool + return _retval?true:false; +} + +CefString CefXmlReaderCToCpp::GetValue() { + if (CEF_MEMBER_MISSING(struct_, get_value)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_value(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +bool CefXmlReaderCToCpp::HasAttributes() { + if (CEF_MEMBER_MISSING(struct_, has_attributes)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->has_attributes(struct_); + + // Return type: bool + return _retval?true:false; +} + +size_t CefXmlReaderCToCpp::GetAttributeCount() { + if (CEF_MEMBER_MISSING(struct_, get_attribute_count)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + size_t _retval = struct_->get_attribute_count(struct_); + + // Return type: simple + return _retval; +} + +CefString CefXmlReaderCToCpp::GetAttribute(int index) { + if (CEF_MEMBER_MISSING(struct_, get_attribute_byindex)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return CefString(); + + // Execute + cef_string_userfree_t _retval = struct_->get_attribute_byindex(struct_, + index); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefXmlReaderCToCpp::GetAttribute(const CefString& qualifiedName) { + if (CEF_MEMBER_MISSING(struct_, get_attribute_byqname)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: qualifiedName; type: string_byref_const + DCHECK(!qualifiedName.empty()); + if (qualifiedName.empty()) + return CefString(); + + // Execute + cef_string_userfree_t _retval = struct_->get_attribute_byqname(struct_, + qualifiedName.GetStruct()); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefXmlReaderCToCpp::GetAttribute(const CefString& localName, + const CefString& namespaceURI) { + if (CEF_MEMBER_MISSING(struct_, get_attribute_bylname)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: localName; type: string_byref_const + DCHECK(!localName.empty()); + if (localName.empty()) + return CefString(); + // Verify param: namespaceURI; type: string_byref_const + DCHECK(!namespaceURI.empty()); + if (namespaceURI.empty()) + return CefString(); + + // Execute + cef_string_userfree_t _retval = struct_->get_attribute_bylname(struct_, + localName.GetStruct(), + namespaceURI.GetStruct()); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefXmlReaderCToCpp::GetInnerXml() { + if (CEF_MEMBER_MISSING(struct_, get_inner_xml)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_inner_xml(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefXmlReaderCToCpp::GetOuterXml() { + if (CEF_MEMBER_MISSING(struct_, get_outer_xml)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_outer_xml(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +int CefXmlReaderCToCpp::GetLineNumber() { + if (CEF_MEMBER_MISSING(struct_, get_line_number)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_line_number(struct_); + + // Return type: simple + return _retval; +} + +bool CefXmlReaderCToCpp::MoveToAttribute(int index) { + if (CEF_MEMBER_MISSING(struct_, move_to_attribute_byindex)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK_GE(index, 0); + if (index < 0) + return false; + + // Execute + int _retval = struct_->move_to_attribute_byindex(struct_, + index); + + // Return type: bool + return _retval?true:false; +} + +bool CefXmlReaderCToCpp::MoveToAttribute(const CefString& qualifiedName) { + if (CEF_MEMBER_MISSING(struct_, move_to_attribute_byqname)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: qualifiedName; type: string_byref_const + DCHECK(!qualifiedName.empty()); + if (qualifiedName.empty()) + return false; + + // Execute + int _retval = struct_->move_to_attribute_byqname(struct_, + qualifiedName.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + +bool CefXmlReaderCToCpp::MoveToAttribute(const CefString& localName, + const CefString& namespaceURI) { + if (CEF_MEMBER_MISSING(struct_, move_to_attribute_bylname)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: localName; type: string_byref_const + DCHECK(!localName.empty()); + if (localName.empty()) + return false; + // Verify param: namespaceURI; type: string_byref_const + DCHECK(!namespaceURI.empty()); + if (namespaceURI.empty()) + return false; + + // Execute + int _retval = struct_->move_to_attribute_bylname(struct_, + localName.GetStruct(), + namespaceURI.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + +bool CefXmlReaderCToCpp::MoveToFirstAttribute() { + if (CEF_MEMBER_MISSING(struct_, move_to_first_attribute)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->move_to_first_attribute(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefXmlReaderCToCpp::MoveToNextAttribute() { + if (CEF_MEMBER_MISSING(struct_, move_to_next_attribute)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->move_to_next_attribute(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefXmlReaderCToCpp::MoveToCarryingElement() { + if (CEF_MEMBER_MISSING(struct_, move_to_carrying_element)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->move_to_carrying_element(struct_); + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/xml_reader_ctocpp.h b/cef3/libcef_dll/ctocpp/xml_reader_ctocpp.h new file mode 100644 index 000000000..ab8653c76 --- /dev/null +++ b/cef3/libcef_dll/ctocpp/xml_reader_ctocpp.h @@ -0,0 +1,70 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_XML_READER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_XML_READER_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_xml_reader.h" +#include "include/capi/cef_xml_reader_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefXmlReaderCToCpp + : public CefCToCpp { + public: + explicit CefXmlReaderCToCpp(cef_xml_reader_t* str) + : CefCToCpp(str) {} + virtual ~CefXmlReaderCToCpp() {} + + // CefXmlReader methods + virtual bool MoveToNextNode() OVERRIDE; + virtual bool Close() OVERRIDE; + virtual bool HasError() OVERRIDE; + virtual CefString GetError() OVERRIDE; + virtual NodeType GetType() OVERRIDE; + virtual int GetDepth() OVERRIDE; + virtual CefString GetLocalName() OVERRIDE; + virtual CefString GetPrefix() OVERRIDE; + virtual CefString GetQualifiedName() OVERRIDE; + virtual CefString GetNamespaceURI() OVERRIDE; + virtual CefString GetBaseURI() OVERRIDE; + virtual CefString GetXmlLang() OVERRIDE; + virtual bool IsEmptyElement() OVERRIDE; + virtual bool HasValue() OVERRIDE; + virtual CefString GetValue() OVERRIDE; + virtual bool HasAttributes() OVERRIDE; + virtual size_t GetAttributeCount() OVERRIDE; + virtual CefString GetAttribute(int index) OVERRIDE; + virtual CefString GetAttribute(const CefString& qualifiedName) OVERRIDE; + virtual CefString GetAttribute(const CefString& localName, + const CefString& namespaceURI) OVERRIDE; + virtual CefString GetInnerXml() OVERRIDE; + virtual CefString GetOuterXml() OVERRIDE; + virtual int GetLineNumber() OVERRIDE; + virtual bool MoveToAttribute(int index) OVERRIDE; + virtual bool MoveToAttribute(const CefString& qualifiedName) OVERRIDE; + virtual bool MoveToAttribute(const CefString& localName, + const CefString& namespaceURI) OVERRIDE; + virtual bool MoveToFirstAttribute() OVERRIDE; + virtual bool MoveToNextAttribute() OVERRIDE; + virtual bool MoveToCarryingElement() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_XML_READER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/ctocpp/zip_reader_ctocpp.cc b/cef3/libcef_dll/ctocpp/zip_reader_ctocpp.cc new file mode 100644 index 000000000..a1dc226ed --- /dev/null +++ b/cef3/libcef_dll/ctocpp/zip_reader_ctocpp.cc @@ -0,0 +1,220 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/stream_reader_ctocpp.h" +#include "libcef_dll/ctocpp/zip_reader_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefZipReader::Create( + CefRefPtr stream) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: stream; type: refptr_same + DCHECK(stream.get()); + if (!stream.get()) + return NULL; + + // Execute + cef_zip_reader_t* _retval = cef_zip_reader_create( + CefStreamReaderCToCpp::Unwrap(stream)); + + // Return type: refptr_same + return CefZipReaderCToCpp::Wrap(_retval); +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefZipReaderCToCpp::MoveToFirstFile() { + if (CEF_MEMBER_MISSING(struct_, move_to_first_file)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->move_to_first_file(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefZipReaderCToCpp::MoveToNextFile() { + if (CEF_MEMBER_MISSING(struct_, move_to_next_file)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->move_to_next_file(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefZipReaderCToCpp::MoveToFile(const CefString& fileName, + bool caseSensitive) { + if (CEF_MEMBER_MISSING(struct_, move_to_file)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: fileName; type: string_byref_const + DCHECK(!fileName.empty()); + if (fileName.empty()) + return false; + + // Execute + int _retval = struct_->move_to_file(struct_, + fileName.GetStruct(), + caseSensitive); + + // Return type: bool + return _retval?true:false; +} + +bool CefZipReaderCToCpp::Close() { + if (CEF_MEMBER_MISSING(struct_, close)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->close(struct_); + + // Return type: bool + return _retval?true:false; +} + +CefString CefZipReaderCToCpp::GetFileName() { + if (CEF_MEMBER_MISSING(struct_, get_file_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_file_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +int64 CefZipReaderCToCpp::GetFileSize() { + if (CEF_MEMBER_MISSING(struct_, get_file_size)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int64 _retval = struct_->get_file_size(struct_); + + // Return type: simple + return _retval; +} + +time_t CefZipReaderCToCpp::GetFileLastModified() { + if (CEF_MEMBER_MISSING(struct_, get_file_last_modified)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + time_t _retval = struct_->get_file_last_modified(struct_); + + // Return type: simple + return _retval; +} + +bool CefZipReaderCToCpp::OpenFile(const CefString& password) { + if (CEF_MEMBER_MISSING(struct_, open_file)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: password + + // Execute + int _retval = struct_->open_file(struct_, + password.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + +bool CefZipReaderCToCpp::CloseFile() { + if (CEF_MEMBER_MISSING(struct_, close_file)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->close_file(struct_); + + // Return type: bool + return _retval?true:false; +} + +int CefZipReaderCToCpp::ReadFile(void* buffer, size_t bufferSize) { + if (CEF_MEMBER_MISSING(struct_, read_file)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: buffer; type: simple_byaddr + DCHECK(buffer); + if (!buffer) + return 0; + + // Execute + int _retval = struct_->read_file(struct_, + buffer, + bufferSize); + + // Return type: simple + return _retval; +} + +int64 CefZipReaderCToCpp::Tell() { + if (CEF_MEMBER_MISSING(struct_, tell)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int64 _retval = struct_->tell(struct_); + + // Return type: simple + return _retval; +} + +bool CefZipReaderCToCpp::Eof() { + if (CEF_MEMBER_MISSING(struct_, eof)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->eof(struct_); + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef3/libcef_dll/ctocpp/zip_reader_ctocpp.h b/cef3/libcef_dll/ctocpp/zip_reader_ctocpp.h new file mode 100644 index 000000000..812516d5a --- /dev/null +++ b/cef3/libcef_dll/ctocpp/zip_reader_ctocpp.h @@ -0,0 +1,52 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_ZIP_READER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_ZIP_READER_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_zip_reader.h" +#include "include/capi/cef_zip_reader_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefZipReaderCToCpp + : public CefCToCpp { + public: + explicit CefZipReaderCToCpp(cef_zip_reader_t* str) + : CefCToCpp(str) {} + virtual ~CefZipReaderCToCpp() {} + + // CefZipReader methods + virtual bool MoveToFirstFile() OVERRIDE; + virtual bool MoveToNextFile() OVERRIDE; + virtual bool MoveToFile(const CefString& fileName, + bool caseSensitive) OVERRIDE; + virtual bool Close() OVERRIDE; + virtual CefString GetFileName() OVERRIDE; + virtual int64 GetFileSize() OVERRIDE; + virtual time_t GetFileLastModified() OVERRIDE; + virtual bool OpenFile(const CefString& password) OVERRIDE; + virtual bool CloseFile() OVERRIDE; + virtual int ReadFile(void* buffer, size_t bufferSize) OVERRIDE; + virtual int64 Tell() OVERRIDE; + virtual bool Eof() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_ZIP_READER_CTOCPP_H_ + diff --git a/cef3/libcef_dll/libcef_dll.cc b/cef3/libcef_dll/libcef_dll.cc new file mode 100644 index 000000000..8c40830da --- /dev/null +++ b/cef3/libcef_dll/libcef_dll.cc @@ -0,0 +1,708 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "include/cef_app.h" +#include "include/capi/cef_app_capi.h" +#include "include/cef_geolocation.h" +#include "include/capi/cef_geolocation_capi.h" +#include "include/cef_origin_whitelist.h" +#include "include/capi/cef_origin_whitelist_capi.h" +#include "include/cef_path_util.h" +#include "include/capi/cef_path_util_capi.h" +#include "include/cef_process_util.h" +#include "include/capi/cef_process_util_capi.h" +#include "include/cef_scheme.h" +#include "include/capi/cef_scheme_capi.h" +#include "include/cef_task.h" +#include "include/capi/cef_task_capi.h" +#include "include/cef_trace.h" +#include "include/capi/cef_trace_capi.h" +#include "include/cef_url.h" +#include "include/capi/cef_url_capi.h" +#include "include/cef_v8.h" +#include "include/capi/cef_v8_capi.h" +#include "include/cef_web_plugin.h" +#include "include/capi/cef_web_plugin_capi.h" +#include "libcef_dll/cpptoc/allow_certificate_error_callback_cpptoc.h" +#include "libcef_dll/cpptoc/auth_callback_cpptoc.h" +#include "libcef_dll/cpptoc/before_download_callback_cpptoc.h" +#include "libcef_dll/cpptoc/binary_value_cpptoc.h" +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/cpptoc/browser_host_cpptoc.h" +#include "libcef_dll/cpptoc/callback_cpptoc.h" +#include "libcef_dll/cpptoc/command_line_cpptoc.h" +#include "libcef_dll/cpptoc/context_menu_params_cpptoc.h" +#include "libcef_dll/cpptoc/cookie_manager_cpptoc.h" +#include "libcef_dll/cpptoc/domdocument_cpptoc.h" +#include "libcef_dll/cpptoc/domevent_cpptoc.h" +#include "libcef_dll/cpptoc/domnode_cpptoc.h" +#include "libcef_dll/cpptoc/dictionary_value_cpptoc.h" +#include "libcef_dll/cpptoc/download_item_cpptoc.h" +#include "libcef_dll/cpptoc/download_item_callback_cpptoc.h" +#include "libcef_dll/cpptoc/file_dialog_callback_cpptoc.h" +#include "libcef_dll/cpptoc/frame_cpptoc.h" +#include "libcef_dll/cpptoc/geolocation_callback_cpptoc.h" +#include "libcef_dll/cpptoc/jsdialog_callback_cpptoc.h" +#include "libcef_dll/cpptoc/list_value_cpptoc.h" +#include "libcef_dll/cpptoc/menu_model_cpptoc.h" +#include "libcef_dll/cpptoc/process_message_cpptoc.h" +#include "libcef_dll/cpptoc/quota_callback_cpptoc.h" +#include "libcef_dll/cpptoc/scheme_registrar_cpptoc.h" +#include "libcef_dll/cpptoc/stream_reader_cpptoc.h" +#include "libcef_dll/cpptoc/stream_writer_cpptoc.h" +#include "libcef_dll/cpptoc/task_runner_cpptoc.h" +#include "libcef_dll/cpptoc/urlrequest_cpptoc.h" +#include "libcef_dll/cpptoc/v8context_cpptoc.h" +#include "libcef_dll/cpptoc/v8exception_cpptoc.h" +#include "libcef_dll/cpptoc/v8stack_frame_cpptoc.h" +#include "libcef_dll/cpptoc/v8stack_trace_cpptoc.h" +#include "libcef_dll/cpptoc/v8value_cpptoc.h" +#include "libcef_dll/cpptoc/web_plugin_info_cpptoc.h" +#include "libcef_dll/cpptoc/xml_reader_cpptoc.h" +#include "libcef_dll/cpptoc/zip_reader_cpptoc.h" +#include "libcef_dll/ctocpp/app_ctocpp.h" +#include "libcef_dll/ctocpp/browser_process_handler_ctocpp.h" +#include "libcef_dll/ctocpp/completion_handler_ctocpp.h" +#include "libcef_dll/ctocpp/context_menu_handler_ctocpp.h" +#include "libcef_dll/ctocpp/cookie_visitor_ctocpp.h" +#include "libcef_dll/ctocpp/domevent_listener_ctocpp.h" +#include "libcef_dll/ctocpp/domvisitor_ctocpp.h" +#include "libcef_dll/ctocpp/dialog_handler_ctocpp.h" +#include "libcef_dll/ctocpp/display_handler_ctocpp.h" +#include "libcef_dll/ctocpp/download_handler_ctocpp.h" +#include "libcef_dll/ctocpp/focus_handler_ctocpp.h" +#include "libcef_dll/ctocpp/geolocation_handler_ctocpp.h" +#include "libcef_dll/ctocpp/get_geolocation_callback_ctocpp.h" +#include "libcef_dll/ctocpp/jsdialog_handler_ctocpp.h" +#include "libcef_dll/ctocpp/keyboard_handler_ctocpp.h" +#include "libcef_dll/ctocpp/life_span_handler_ctocpp.h" +#include "libcef_dll/ctocpp/load_handler_ctocpp.h" +#include "libcef_dll/ctocpp/read_handler_ctocpp.h" +#include "libcef_dll/ctocpp/render_handler_ctocpp.h" +#include "libcef_dll/ctocpp/render_process_handler_ctocpp.h" +#include "libcef_dll/ctocpp/request_handler_ctocpp.h" +#include "libcef_dll/ctocpp/resource_bundle_handler_ctocpp.h" +#include "libcef_dll/ctocpp/resource_handler_ctocpp.h" +#include "libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.h" +#include "libcef_dll/ctocpp/scheme_handler_factory_ctocpp.h" +#include "libcef_dll/ctocpp/string_visitor_ctocpp.h" +#include "libcef_dll/ctocpp/task_ctocpp.h" +#include "libcef_dll/ctocpp/trace_client_ctocpp.h" +#include "libcef_dll/ctocpp/urlrequest_client_ctocpp.h" +#include "libcef_dll/ctocpp/v8accessor_ctocpp.h" +#include "libcef_dll/ctocpp/v8handler_ctocpp.h" +#include "libcef_dll/ctocpp/web_plugin_info_visitor_ctocpp.h" +#include "libcef_dll/ctocpp/web_plugin_unstable_callback_ctocpp.h" +#include "libcef_dll/ctocpp/write_handler_ctocpp.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT int cef_execute_process(const struct _cef_main_args_t* args, + struct _cef_app_t* application) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: args; type: struct_byref_const + DCHECK(args); + if (!args) + return 0; + // Unverified params: application + + // Translate param: args; type: struct_byref_const + CefMainArgs argsObj; + if (args) + argsObj.Set(*args, false); + + // Execute + int _retval = CefExecuteProcess( + argsObj, + CefAppCToCpp::Wrap(application)); + + // Return type: simple + return _retval; +} + +CEF_EXPORT int cef_initialize(const struct _cef_main_args_t* args, + const struct _cef_settings_t* settings, struct _cef_app_t* application) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: args; type: struct_byref_const + DCHECK(args); + if (!args) + return 0; + // Verify param: settings; type: struct_byref_const + DCHECK(settings); + if (!settings) + return 0; + // Unverified params: application + + // Translate param: args; type: struct_byref_const + CefMainArgs argsObj; + if (args) + argsObj.Set(*args, false); + // Translate param: settings; type: struct_byref_const + CefSettings settingsObj; + if (settings) + settingsObj.Set(*settings, false); + + // Execute + bool _retval = CefInitialize( + argsObj, + settingsObj, + CefAppCToCpp::Wrap(application)); + + // Return type: bool + return _retval; +} + +CEF_EXPORT void cef_shutdown() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefShutdown(); + +#ifndef NDEBUG + // Check that all wrapper objects have been destroyed + DCHECK_EQ(CefAllowCertificateErrorCallbackCppToC::DebugObjCt, 0); + DCHECK_EQ(CefAuthCallbackCppToC::DebugObjCt, 0); + DCHECK_EQ(CefBeforeDownloadCallbackCppToC::DebugObjCt, 0); + DCHECK_EQ(CefBinaryValueCppToC::DebugObjCt, 0); + DCHECK_EQ(CefBrowserCppToC::DebugObjCt, 0); + DCHECK_EQ(CefBrowserHostCppToC::DebugObjCt, 0); + DCHECK_EQ(CefBrowserProcessHandlerCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefCallbackCppToC::DebugObjCt, 0); + DCHECK_EQ(CefCompletionHandlerCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefContextMenuHandlerCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefContextMenuParamsCppToC::DebugObjCt, 0); + DCHECK_EQ(CefCookieManagerCppToC::DebugObjCt, 0); + DCHECK_EQ(CefCookieVisitorCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefDOMDocumentCppToC::DebugObjCt, 0); + DCHECK_EQ(CefDOMEventCppToC::DebugObjCt, 0); + DCHECK_EQ(CefDOMEventListenerCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefDOMNodeCppToC::DebugObjCt, 0); + DCHECK_EQ(CefDOMVisitorCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefDialogHandlerCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefDictionaryValueCppToC::DebugObjCt, 0); + DCHECK_EQ(CefDisplayHandlerCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefDownloadHandlerCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefDownloadItemCallbackCppToC::DebugObjCt, 0); + DCHECK_EQ(CefDownloadItemCppToC::DebugObjCt, 0); + DCHECK_EQ(CefFileDialogCallbackCppToC::DebugObjCt, 0); + DCHECK_EQ(CefFocusHandlerCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefFrameCppToC::DebugObjCt, 0); + DCHECK_EQ(CefGeolocationCallbackCppToC::DebugObjCt, 0); + DCHECK_EQ(CefGeolocationHandlerCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefGetGeolocationCallbackCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefJSDialogCallbackCppToC::DebugObjCt, 0); + DCHECK_EQ(CefJSDialogHandlerCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefKeyboardHandlerCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefLifeSpanHandlerCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefListValueCppToC::DebugObjCt, 0); + DCHECK_EQ(CefLoadHandlerCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefMenuModelCppToC::DebugObjCt, 0); + DCHECK_EQ(CefProcessMessageCppToC::DebugObjCt, 0); + DCHECK_EQ(CefQuotaCallbackCppToC::DebugObjCt, 0); + DCHECK_EQ(CefReadHandlerCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefRenderHandlerCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefRenderProcessHandlerCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefRequestHandlerCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefResourceBundleHandlerCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefResourceHandlerCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefRunFileDialogCallbackCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefSchemeHandlerFactoryCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefSchemeRegistrarCppToC::DebugObjCt, 0); + DCHECK_EQ(CefStreamReaderCppToC::DebugObjCt, 0); + DCHECK_EQ(CefStreamWriterCppToC::DebugObjCt, 0); + DCHECK_EQ(CefStringVisitorCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefTaskCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefTaskRunnerCppToC::DebugObjCt, 0); + DCHECK_EQ(CefTraceClientCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefURLRequestClientCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefURLRequestCppToC::DebugObjCt, 0); + DCHECK_EQ(CefV8AccessorCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefV8ContextCppToC::DebugObjCt, 0); + DCHECK_EQ(CefV8ExceptionCppToC::DebugObjCt, 0); + DCHECK_EQ(CefV8HandlerCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefV8StackFrameCppToC::DebugObjCt, 0); + DCHECK_EQ(CefV8StackTraceCppToC::DebugObjCt, 0); + DCHECK_EQ(CefV8ValueCppToC::DebugObjCt, 0); + DCHECK_EQ(CefWebPluginInfoCppToC::DebugObjCt, 0); + DCHECK_EQ(CefWebPluginInfoVisitorCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefWebPluginUnstableCallbackCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefWriteHandlerCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefXmlReaderCppToC::DebugObjCt, 0); + DCHECK_EQ(CefZipReaderCppToC::DebugObjCt, 0); +#endif // !NDEBUG +} + +CEF_EXPORT void cef_do_message_loop_work() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefDoMessageLoopWork(); +} + +CEF_EXPORT void cef_run_message_loop() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRunMessageLoop(); +} + +CEF_EXPORT void cef_quit_message_loop() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefQuitMessageLoop(); +} + +CEF_EXPORT int cef_get_geolocation( + struct _cef_get_geolocation_callback_t* callback) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: callback; type: refptr_diff + DCHECK(callback); + if (!callback) + return 0; + + // Execute + bool _retval = CefGetGeolocation( + CefGetGeolocationCallbackCToCpp::Wrap(callback)); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_add_cross_origin_whitelist_entry( + const cef_string_t* source_origin, const cef_string_t* target_protocol, + const cef_string_t* target_domain, int allow_target_subdomains) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: source_origin; type: string_byref_const + DCHECK(source_origin); + if (!source_origin) + return 0; + // Verify param: target_protocol; type: string_byref_const + DCHECK(target_protocol); + if (!target_protocol) + return 0; + // Unverified params: target_domain + + // Execute + bool _retval = CefAddCrossOriginWhitelistEntry( + CefString(source_origin), + CefString(target_protocol), + CefString(target_domain), + allow_target_subdomains?true:false); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_remove_cross_origin_whitelist_entry( + const cef_string_t* source_origin, const cef_string_t* target_protocol, + const cef_string_t* target_domain, int allow_target_subdomains) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: source_origin; type: string_byref_const + DCHECK(source_origin); + if (!source_origin) + return 0; + // Verify param: target_protocol; type: string_byref_const + DCHECK(target_protocol); + if (!target_protocol) + return 0; + // Unverified params: target_domain + + // Execute + bool _retval = CefRemoveCrossOriginWhitelistEntry( + CefString(source_origin), + CefString(target_protocol), + CefString(target_domain), + allow_target_subdomains?true:false); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_clear_cross_origin_whitelist() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + bool _retval = CefClearCrossOriginWhitelist(); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_get_path(enum cef_path_key_t key, cef_string_t* path) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: path; type: string_byref + DCHECK(path); + if (!path) + return 0; + + // Translate param: path; type: string_byref + CefString pathStr(path); + + // Execute + bool _retval = CefGetPath( + key, + pathStr); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_launch_process(struct _cef_command_line_t* command_line) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: command_line; type: refptr_same + DCHECK(command_line); + if (!command_line) + return 0; + + // Execute + bool _retval = CefLaunchProcess( + CefCommandLineCppToC::Unwrap(command_line)); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_register_scheme_handler_factory( + const cef_string_t* scheme_name, const cef_string_t* domain_name, + struct _cef_scheme_handler_factory_t* factory) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: scheme_name; type: string_byref_const + DCHECK(scheme_name); + if (!scheme_name) + return 0; + // Unverified params: domain_name, factory + + // Execute + bool _retval = CefRegisterSchemeHandlerFactory( + CefString(scheme_name), + CefString(domain_name), + CefSchemeHandlerFactoryCToCpp::Wrap(factory)); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_clear_scheme_handler_factories() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + bool _retval = CefClearSchemeHandlerFactories(); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_currently_on(cef_thread_id_t threadId) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + bool _retval = CefCurrentlyOn( + threadId); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_post_task(cef_thread_id_t threadId, + struct _cef_task_t* task) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: task; type: refptr_diff + DCHECK(task); + if (!task) + return 0; + + // Execute + bool _retval = CefPostTask( + threadId, + CefTaskCToCpp::Wrap(task)); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_post_delayed_task(cef_thread_id_t threadId, + struct _cef_task_t* task, int64 delay_ms) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: task; type: refptr_diff + DCHECK(task); + if (!task) + return 0; + + // Execute + bool _retval = CefPostDelayedTask( + threadId, + CefTaskCToCpp::Wrap(task), + delay_ms); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_begin_tracing(struct _cef_trace_client_t* client, + const cef_string_t* categories) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: client, categories + + // Execute + bool _retval = CefBeginTracing( + CefTraceClientCToCpp::Wrap(client), + CefString(categories)); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_get_trace_buffer_percent_full_async() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + bool _retval = CefGetTraceBufferPercentFullAsync(); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_end_tracing_async() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + bool _retval = CefEndTracingAsync(); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int64 cef_now_from_system_trace_time() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int64 _retval = CefNowFromSystemTraceTime(); + + // Return type: simple + return _retval; +} + +CEF_EXPORT int cef_parse_url(const cef_string_t* url, + struct _cef_urlparts_t* parts) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: url; type: string_byref_const + DCHECK(url); + if (!url) + return 0; + // Verify param: parts; type: struct_byref + DCHECK(parts); + if (!parts) + return 0; + + // Translate param: parts; type: struct_byref + CefURLParts partsObj; + if (parts) + partsObj.AttachTo(*parts); + + // Execute + bool _retval = CefParseURL( + CefString(url), + partsObj); + + // Restore param: parts; type: struct_byref + if (parts) + partsObj.DetachTo(*parts); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_create_url(const struct _cef_urlparts_t* parts, + cef_string_t* url) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: parts; type: struct_byref_const + DCHECK(parts); + if (!parts) + return 0; + // Verify param: url; type: string_byref + DCHECK(url); + if (!url) + return 0; + + // Translate param: parts; type: struct_byref_const + CefURLParts partsObj; + if (parts) + partsObj.Set(*parts, false); + // Translate param: url; type: string_byref + CefString urlStr(url); + + // Execute + bool _retval = CefCreateURL( + partsObj, + urlStr); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_register_extension(const cef_string_t* extension_name, + const cef_string_t* javascript_code, struct _cef_v8handler_t* handler) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: extension_name; type: string_byref_const + DCHECK(extension_name); + if (!extension_name) + return 0; + // Verify param: javascript_code; type: string_byref_const + DCHECK(javascript_code); + if (!javascript_code) + return 0; + // Unverified params: handler + + // Execute + bool _retval = CefRegisterExtension( + CefString(extension_name), + CefString(javascript_code), + CefV8HandlerCToCpp::Wrap(handler)); + + // Return type: bool + return _retval; +} + +CEF_EXPORT void cef_visit_web_plugin_info( + struct _cef_web_plugin_info_visitor_t* visitor) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: visitor; type: refptr_diff + DCHECK(visitor); + if (!visitor) + return; + + // Execute + CefVisitWebPluginInfo( + CefWebPluginInfoVisitorCToCpp::Wrap(visitor)); +} + +CEF_EXPORT void cef_refresh_web_plugins() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefreshWebPlugins(); +} + +CEF_EXPORT void cef_add_web_plugin_path(const cef_string_t* path) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: path; type: string_byref_const + DCHECK(path); + if (!path) + return; + + // Execute + CefAddWebPluginPath( + CefString(path)); +} + +CEF_EXPORT void cef_add_web_plugin_directory(const cef_string_t* dir) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: dir; type: string_byref_const + DCHECK(dir); + if (!dir) + return; + + // Execute + CefAddWebPluginDirectory( + CefString(dir)); +} + +CEF_EXPORT void cef_remove_web_plugin_path(const cef_string_t* path) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: path; type: string_byref_const + DCHECK(path); + if (!path) + return; + + // Execute + CefRemoveWebPluginPath( + CefString(path)); +} + +CEF_EXPORT void cef_unregister_internal_web_plugin(const cef_string_t* path) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: path; type: string_byref_const + DCHECK(path); + if (!path) + return; + + // Execute + CefUnregisterInternalWebPlugin( + CefString(path)); +} + +CEF_EXPORT void cef_force_web_plugin_shutdown(const cef_string_t* path) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: path; type: string_byref_const + DCHECK(path); + if (!path) + return; + + // Execute + CefForceWebPluginShutdown( + CefString(path)); +} + +CEF_EXPORT void cef_register_web_plugin_crash(const cef_string_t* path) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: path; type: string_byref_const + DCHECK(path); + if (!path) + return; + + // Execute + CefRegisterWebPluginCrash( + CefString(path)); +} + +CEF_EXPORT void cef_is_web_plugin_unstable(const cef_string_t* path, + struct _cef_web_plugin_unstable_callback_t* callback) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: path; type: string_byref_const + DCHECK(path); + if (!path) + return; + // Verify param: callback; type: refptr_diff + DCHECK(callback); + if (!callback) + return; + + // Execute + CefIsWebPluginUnstable( + CefString(path), + CefWebPluginUnstableCallbackCToCpp::Wrap(callback)); +} + diff --git a/cef3/libcef_dll/libcef_dll.rc b/cef3/libcef_dll/libcef_dll.rc new file mode 100644 index 000000000..6e5752258 --- /dev/null +++ b/cef3/libcef_dll/libcef_dll.rc @@ -0,0 +1,143 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#define APSTUDIO_HIDDEN_SYMBOLS +#include "windows.h" +#include "include/cef_version.h" +#undef APSTUDIO_HIDDEN_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""windows.h""\r\n" + "#include ""include/version.h""\r\n" + "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ALERT DIALOGEX 0, 0, 241, 76 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "JavaScript Alert" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "OK",IDOK,184,55,50,14 + LTEXT "",IDC_DIALOGTEXT,16,17,210,30 +END + +IDD_CONFIRM DIALOGEX 0, 0, 241, 76 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "JavaScript Confirm" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + PUSHBUTTON "Cancel",IDCANCEL,184,55,50,14 + DEFPUSHBUTTON "OK",IDOK,131,55,50,14 + LTEXT "",IDC_DIALOGTEXT,16,17,210,30 +END + +IDD_PROMPT DIALOGEX 0, 0, 241, 76 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "JavaScript Prompt" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "OK",IDOK,131,55,50,14 + LTEXT "",IDC_DIALOGTEXT,16,17,210,18 + PUSHBUTTON "Cancel",IDCANCEL,184,55,50,14 + EDITTEXT IDC_PROMPTEDIT,15,33,210,14,ES_AUTOHSCROLL +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION CEF_VERSION_MAJOR,CHROME_VERSION_BUILD,CEF_REVISION,0 + PRODUCTVERSION CEF_VERSION_MAJOR,CHROME_VERSION_BUILD,CEF_REVISION,0 + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "Chromium Embedded Framework (CEF) Dynamic Link Library" + VALUE "FileVersion", MAKE_STRING(CEF_VERSION_MAJOR) "." MAKE_STRING(CHROME_VERSION_BUILD) "." MAKE_STRING(CEF_REVISION) + VALUE "InternalName", "libcef" + VALUE "LegalCopyright", "Copyright (C) " MAKE_STRING(COPYRIGHT_YEAR) " The Chromium Embedded Framework Authors" + VALUE "OriginalFilename", "libcef.dll" + VALUE "ProductName", "Chromium Embedded Framework (CEF) Dynamic Link Library" + VALUE "ProductVersion", MAKE_STRING(CEF_VERSION_MAJOR) "." MAKE_STRING(CHROME_VERSION_BUILD) "." MAKE_STRING(CEF_REVISION) + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/cef3/libcef_dll/libcef_dll2.cc b/cef3/libcef_dll/libcef_dll2.cc new file mode 100644 index 000000000..20ceb5d89 --- /dev/null +++ b/cef3/libcef_dll/libcef_dll2.cc @@ -0,0 +1,31 @@ +// 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 "include/cef_version.h" +#include "cef_logging.h" + +CEF_EXPORT int cef_build_revision() { + return CEF_REVISION; +} + +CEF_EXPORT int cef_version_info(int entry) { + switch (entry) { + case 0: return CEF_VERSION_MAJOR; + case 1: return CEF_REVISION; + case 2: return CHROME_VERSION_MAJOR; + case 3: return CHROME_VERSION_MINOR; + case 4: return CHROME_VERSION_BUILD; + case 5: return CHROME_VERSION_PATCH; + default: return 0; + } +} + +CEF_EXPORT const char* cef_api_hash(int entry) { + switch (entry) { + case 0: return CEF_API_HASH_PLATFORM; + case 1: return CEF_API_HASH_UNIVERSAL; + default: return NULL; + } +} diff --git a/cef3/libcef_dll/resource.h b/cef3/libcef_dll/resource.h new file mode 100644 index 000000000..cbeef193d --- /dev/null +++ b/cef3/libcef_dll/resource.h @@ -0,0 +1,26 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by libcef_dll.rc +// + +// Avoid files associated with MacOS +#define _X86_ + +#define IDD_ALERT 130 +#define IDD_CONFIRM 131 +#define IDD_PROMPT 132 +#define IDC_PROMPTEDIT 1000 +#define IDC_DIALOGTEXT 1001 + + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NO_MFC 1 +#define _APS_NEXT_RESOURCE_VALUE 130 +#define _APS_NEXT_COMMAND_VALUE 32000 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 110 +#endif +#endif diff --git a/cef3/libcef_dll/transfer_util.cpp b/cef3/libcef_dll/transfer_util.cpp new file mode 100644 index 000000000..e9d8d4e22 --- /dev/null +++ b/cef3/libcef_dll/transfer_util.cpp @@ -0,0 +1,72 @@ +// Copyright (c) 2009 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 "transfer_util.h" + +void transfer_string_list_contents(cef_string_list_t fromList, + StringList& toList) +{ + int size = cef_string_list_size(fromList); + CefString value; + + for(int i = 0; i < size; i++) { + cef_string_list_value(fromList, i, value.GetWritableStruct()); + toList.push_back(value); + } +} + +void transfer_string_list_contents(const StringList& fromList, + cef_string_list_t toList) +{ + size_t size = fromList.size(); + for(size_t i = 0; i < size; ++i) + cef_string_list_append(toList, fromList[i].GetStruct()); +} + +void transfer_string_map_contents(cef_string_map_t fromMap, + StringMap& toMap) +{ + int size = cef_string_map_size(fromMap); + CefString key, value; + + for(int i = 0; i < size; ++i) { + cef_string_map_key(fromMap, i, key.GetWritableStruct()); + cef_string_map_value(fromMap, i, value.GetWritableStruct()); + + toMap.insert(std::make_pair(key, value)); + } +} + +void transfer_string_map_contents(const StringMap& fromMap, + cef_string_map_t toMap) +{ + StringMap::const_iterator it = fromMap.begin(); + for(; it != fromMap.end(); ++it) + cef_string_map_append(toMap, it->first.GetStruct(), it->second.GetStruct()); +} + +void transfer_string_multimap_contents(cef_string_multimap_t fromMap, + StringMultimap& toMap) +{ + int size = cef_string_multimap_size(fromMap); + CefString key, value; + + for(int i = 0; i < size; ++i) { + cef_string_multimap_key(fromMap, i, key.GetWritableStruct()); + cef_string_multimap_value(fromMap, i, value.GetWritableStruct()); + + toMap.insert(std::make_pair(key, value)); + } +} + +void transfer_string_multimap_contents(const StringMultimap& fromMap, + cef_string_multimap_t toMap) +{ + StringMultimap::const_iterator it = fromMap.begin(); + for(; it != fromMap.end(); ++it) { + cef_string_multimap_append(toMap, + it->first.GetStruct(), + it->second.GetStruct()); + } +} diff --git a/cef3/libcef_dll/transfer_util.h b/cef3/libcef_dll/transfer_util.h new file mode 100644 index 000000000..88dff1a38 --- /dev/null +++ b/cef3/libcef_dll/transfer_util.h @@ -0,0 +1,37 @@ +// Copyright (c) 2009 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_LIBCEF_DLL_TRANSFER_UTIL_H_ +#define CEF_LIBCEF_DLL_TRANSFER_UTIL_H_ +#pragma once + +#include +#include + +#include "include/internal/cef_string_list.h" +#include "include/internal/cef_string_map.h" +#include "include/internal/cef_string_multimap.h" + +// Copy contents from one list type to another. +typedef std::vector StringList; +void transfer_string_list_contents(cef_string_list_t fromList, + StringList& toList); +void transfer_string_list_contents(const StringList& fromList, + cef_string_list_t toList); + +// Copy contents from one map type to another. +typedef std::map StringMap; +void transfer_string_map_contents(cef_string_map_t fromMap, + StringMap& toMap); +void transfer_string_map_contents(const StringMap& fromMap, + cef_string_map_t toMap); + +// Copy contents from one map type to another. +typedef std::multimap StringMultimap; +void transfer_string_multimap_contents(cef_string_multimap_t fromMap, + StringMultimap& toMap); +void transfer_string_multimap_contents(const StringMultimap& fromMap, + cef_string_multimap_t toMap); + +#endif // CEF_LIBCEF_DLL_TRANSFER_UTIL_H_ diff --git a/cef3/libcef_dll/wrapper/cef_byte_read_handler.cc b/cef3/libcef_dll/wrapper/cef_byte_read_handler.cc new file mode 100644 index 000000000..77a0188f6 --- /dev/null +++ b/cef3/libcef_dll/wrapper/cef_byte_read_handler.cc @@ -0,0 +1,64 @@ +// Copyright (c) 2010 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 "include/wrapper/cef_byte_read_handler.h" +#include +#include "libcef_dll/cef_logging.h" + +CefByteReadHandler::CefByteReadHandler(const unsigned char* bytes, size_t size, + CefRefPtr source) + : bytes_(bytes), size_(size), offset_(0), source_(source) { +} + +size_t CefByteReadHandler::Read(void* ptr, size_t size, size_t n) { + AutoLock lock_scope(this); + size_t s = static_cast(size_ - offset_) / size; + size_t ret = std::min(n, s); + memcpy(ptr, bytes_ + offset_, ret * size); + offset_ += ret * size; + return ret; +} + +int CefByteReadHandler::Seek(int64 offset, int whence) { + int rv = -1L; + AutoLock lock_scope(this); + switch (whence) { + case SEEK_CUR: + if (offset_ + offset > size_ || offset_ + offset < 0) + break; + offset_ += offset; + rv = 0; + break; + case SEEK_END: { +#if defined(OS_WIN) + int64 offset_abs = _abs64(offset); +#else + int64 offset_abs = abs(offset); +#endif + if (offset_abs > size_) + break; + offset_ = size_ - offset_abs; + rv = 0; + break; + } + case SEEK_SET: + if (offset > size_ || offset < 0) + break; + offset_ = offset; + rv = 0; + break; + } + + return rv; +} + +int64 CefByteReadHandler::Tell() { + AutoLock lock_scope(this); + return offset_; +} + +int CefByteReadHandler::Eof() { + AutoLock lock_scope(this); + return (offset_ >= size_); +} diff --git a/cef3/libcef_dll/wrapper/cef_stream_resource_handler.cc b/cef3/libcef_dll/wrapper/cef_stream_resource_handler.cc new file mode 100644 index 000000000..91f5e94cf --- /dev/null +++ b/cef3/libcef_dll/wrapper/cef_stream_resource_handler.cc @@ -0,0 +1,62 @@ +// 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 "include/wrapper/cef_stream_resource_handler.h" +#include "include/cef_callback.h" +#include "include/cef_request.h" +#include "include/cef_stream.h" +#include "libcef_dll/cef_logging.h" + +CefStreamResourceHandler::CefStreamResourceHandler( + const CefString& mime_type, + CefRefPtr stream) + : status_code_(200), + mime_type_(mime_type), + stream_(stream) { + DCHECK(!mime_type_.empty()); + DCHECK(stream_.get()); +} + +CefStreamResourceHandler::CefStreamResourceHandler( + int status_code, + const CefString& mime_type, + CefResponse::HeaderMap header_map, + CefRefPtr stream) + : status_code_(status_code), + mime_type_(mime_type), + header_map_(header_map), + stream_(stream) { + DCHECK(!mime_type_.empty()); + DCHECK(stream_.get()); +} + +bool CefStreamResourceHandler::ProcessRequest(CefRefPtr request, + CefRefPtr callback) { + callback->Continue(); + return true; +} + +void CefStreamResourceHandler::GetResponseHeaders( + CefRefPtr response, + int64& response_length, + CefString& redirectUrl) { + response->SetStatus(status_code_); + response->SetMimeType(mime_type_); + + if (!header_map_.empty()) + response->SetHeaderMap(header_map_); + + response_length = -1; +} + +bool CefStreamResourceHandler::ReadResponse(void* data_out, + int bytes_to_read, + int& bytes_read, + CefRefPtr callback) { + bytes_read = stream_->Read(data_out, 1, bytes_to_read); + return (bytes_read > 0); +} + +void CefStreamResourceHandler::Cancel() { +} diff --git a/cef3/libcef_dll/wrapper/cef_xml_object.cc b/cef3/libcef_dll/wrapper/cef_xml_object.cc new file mode 100644 index 000000000..49b1ff586 --- /dev/null +++ b/cef3/libcef_dll/wrapper/cef_xml_object.cc @@ -0,0 +1,456 @@ +// Copyright (c) 2010 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 "include/wrapper/cef_xml_object.h" +#include "include/cef_stream.h" +#include "libcef_dll/cef_logging.h" +#include + +namespace { + +class CefXmlObjectLoader { + public: + explicit CefXmlObjectLoader(CefRefPtr root_object) + : root_object_(root_object) { + } + + bool Load(CefRefPtr stream, + CefXmlReader::EncodingType encodingType, + const CefString& URI) { + CefRefPtr reader( + CefXmlReader::Create(stream, encodingType, URI)); + if (!reader.get()) + return false; + + bool ret = reader->MoveToNextNode(); + if (ret) { + CefRefPtr cur_object(root_object_), new_object; + CefXmlObject::ObjectVector queue; + int cur_depth, value_depth = -1; + CefXmlReader::NodeType cur_type; + std::stringstream cur_value; + bool last_has_ns = false; + + queue.push_back(root_object_); + + do { + cur_depth = reader->GetDepth(); + if (value_depth >= 0 && cur_depth > value_depth) { + // The current node has already been parsed as part of a value. + continue; + } + + cur_type = reader->GetType(); + if (cur_type == XML_NODE_ELEMENT_START) { + if (cur_depth == value_depth) { + // Add to the current value. + cur_value << std::string(reader->GetOuterXml()); + continue; + } else if (last_has_ns && reader->GetPrefix().empty()) { + if (!cur_object->HasChildren()) { + // Start a new value because the last element has a namespace and + // this element does not. + value_depth = cur_depth; + cur_value << std::string(reader->GetOuterXml()); + } else { + // Value following a child element is not allowed. + std::stringstream ss; + ss << L"Value following child element, line " << + reader->GetLineNumber(); + load_error_ = ss.str(); + ret = false; + break; + } + } else { + // Start a new element. + new_object = new CefXmlObject(reader->GetQualifiedName()); + cur_object->AddChild(new_object); + last_has_ns = !reader->GetPrefix().empty(); + + if (!reader->IsEmptyElement()) { + // The new element potentially has a value and/or children, so + // set the current object and add the object to the queue. + cur_object = new_object; + queue.push_back(cur_object); + } + + if (reader->HasAttributes() && reader->MoveToFirstAttribute()) { + // Read all object attributes. + do { + new_object->SetAttributeValue(reader->GetQualifiedName(), + reader->GetValue()); + } while (reader->MoveToNextAttribute()); + reader->MoveToCarryingElement(); + } + } + } else if (cur_type == XML_NODE_ELEMENT_END) { + if (cur_depth == value_depth) { + // Ending an element that is already in the value. + continue; + } else if (cur_depth < value_depth) { + // Done with parsing the value portion of the current element. + cur_object->SetValue(cur_value.str()); + cur_value.str(""); + value_depth = -1; + } + + // Pop the current element from the queue. + queue.pop_back(); + + if (queue.empty() || + cur_object->GetName() != reader->GetQualifiedName()) { + // Open tag without close tag or close tag without open tag should + // never occur (the parser catches this error). + DCHECK(false); + std::stringstream ss; + ss << "Mismatched end tag for " << + std::string(cur_object->GetName()) << + ", line " << reader->GetLineNumber(); + load_error_ = ss.str(); + ret = false; + break; + } + + // Set the current object to the previous object in the queue. + cur_object = queue.back().get(); + } else if (cur_type == XML_NODE_TEXT || cur_type == XML_NODE_CDATA || + cur_type == XML_NODE_ENTITY_REFERENCE) { + if (cur_depth == value_depth) { + // Add to the current value. + cur_value << std::string(reader->GetValue()); + } else if (!cur_object->HasChildren()) { + // Start a new value. + value_depth = cur_depth; + cur_value << std::string(reader->GetValue()); + } else { + // Value following a child element is not allowed. + std::stringstream ss; + ss << "Value following child element, line " << + reader->GetLineNumber(); + load_error_ = ss.str(); + ret = false; + break; + } + } + } while (reader->MoveToNextNode()); + } + + if (reader->HasError()) { + load_error_ = reader->GetError(); + return false; + } + + return ret; + } + + CefString GetLoadError() { return load_error_; } + + private: + CefString load_error_; + CefRefPtr root_object_; +}; + +} // namespace + +CefXmlObject::CefXmlObject(const CefString& name) + : name_(name), parent_(NULL) { +} + +CefXmlObject::~CefXmlObject() { +} + +bool CefXmlObject::Load(CefRefPtr stream, + CefXmlReader::EncodingType encodingType, + const CefString& URI, CefString* loadError) { + AutoLock lock_scope(this); + Clear(); + + CefXmlObjectLoader loader(this); + if (!loader.Load(stream, encodingType, URI)) { + if (loadError) + *loadError = loader.GetLoadError(); + return false; + } + return true; +} + +void CefXmlObject::Set(CefRefPtr object) { + DCHECK(object.get()); + + AutoLock lock_scope1(this); + AutoLock lock_scope2(object); + + Clear(); + name_ = object->GetName(); + Append(object, true); +} + +void CefXmlObject::Append(CefRefPtr object, + bool overwriteAttributes) { + DCHECK(object.get()); + + AutoLock lock_scope1(this); + AutoLock lock_scope2(object); + + if (object->HasChildren()) { + ObjectVector children; + object->GetChildren(children); + ObjectVector::const_iterator it = children.begin(); + for (; it != children.end(); ++it) + AddChild((*it)->Duplicate()); + } + + if (object->HasAttributes()) { + AttributeMap attributes; + object->GetAttributes(attributes); + AttributeMap::const_iterator it = attributes.begin(); + for (; it != attributes.end(); ++it) { + if (overwriteAttributes || !HasAttribute(it->first)) + SetAttributeValue(it->first, it->second); + } + } +} + +CefRefPtr CefXmlObject::Duplicate() { + CefRefPtr new_obj; + { + AutoLock lock_scope(this); + new_obj = new CefXmlObject(name_); + new_obj->Append(this, true); + } + return new_obj; +} + +void CefXmlObject::Clear() { + AutoLock lock_scope(this); + ClearChildren(); + ClearAttributes(); +} + +CefString CefXmlObject::GetName() { + CefString name; + { + AutoLock lock_scope(this); + name = name_; + } + return name; +} + +bool CefXmlObject::SetName(const CefString& name) { + DCHECK(!name.empty()); + if (name.empty()) + return false; + + AutoLock lock_scope(this); + name_ = name; + return true; +} + +bool CefXmlObject::HasParent() { + AutoLock lock_scope(this); + return (parent_ != NULL); +} + +CefRefPtr CefXmlObject::GetParent() { + CefRefPtr parent; + { + AutoLock lock_scope(this); + parent = parent_; + } + return parent; +} + +bool CefXmlObject::HasValue() { + AutoLock lock_scope(this); + return !value_.empty(); +} + +CefString CefXmlObject::GetValue() { + CefString value; + { + AutoLock lock_scope(this); + value = value_; + } + return value; +} + +bool CefXmlObject::SetValue(const CefString& value) { + AutoLock lock_scope(this); + DCHECK(children_.empty()); + if (!children_.empty()) + return false; + value_ = value; + return true; +} + +bool CefXmlObject::HasAttributes() { + AutoLock lock_scope(this); + return !attributes_.empty(); +} + +size_t CefXmlObject::GetAttributeCount() { + AutoLock lock_scope(this); + return attributes_.size(); +} + +bool CefXmlObject::HasAttribute(const CefString& name) { + if (name.empty()) + return false; + + AutoLock lock_scope(this); + AttributeMap::const_iterator it = attributes_.find(name); + return (it != attributes_.end()); +} + +CefString CefXmlObject::GetAttributeValue(const CefString& name) { + DCHECK(!name.empty()); + CefString value; + if (!name.empty()) { + AutoLock lock_scope(this); + AttributeMap::const_iterator it = attributes_.find(name); + if (it != attributes_.end()) + value = it->second; + } + return value; +} + +bool CefXmlObject::SetAttributeValue(const CefString& name, + const CefString& value) { + DCHECK(!name.empty()); + if (name.empty()) + return false; + + AutoLock lock_scope(this); + AttributeMap::iterator it = attributes_.find(name); + if (it != attributes_.end()) { + it->second = value; + } else { + attributes_.insert(std::make_pair(name, value)); + } + return true; +} + +size_t CefXmlObject::GetAttributes(AttributeMap& attributes) { + AutoLock lock_scope(this); + attributes = attributes_; + return attributes_.size(); +} + +void CefXmlObject::ClearAttributes() { + AutoLock lock_scope(this); + attributes_.clear(); +} + +bool CefXmlObject::HasChildren() { + AutoLock lock_scope(this); + return !children_.empty(); +} + +size_t CefXmlObject::GetChildCount() { + AutoLock lock_scope(this); + return children_.size(); +} + +bool CefXmlObject::HasChild(CefRefPtr child) { + DCHECK(child.get()); + + AutoLock lock_scope(this); + ObjectVector::const_iterator it = children_.begin(); + for (; it != children_.end(); ++it) { + if ((*it).get() == child.get()) + return true; + } + return false; +} + +bool CefXmlObject::AddChild(CefRefPtr child) { + DCHECK(child.get()); + if (!child.get()) + return false; + + AutoLock lock_scope1(child); + + DCHECK(child->GetParent() == NULL); + if (child->GetParent() != NULL) + return false; + + AutoLock lock_scope2(this); + + children_.push_back(child); + child->SetParent(this); + return true; +} + +bool CefXmlObject::RemoveChild(CefRefPtr child) { + DCHECK(child.get()); + + AutoLock lock_scope(this); + ObjectVector::iterator it = children_.begin(); + for (; it != children_.end(); ++it) { + if ((*it).get() == child.get()) { + children_.erase(it); + child->SetParent(NULL); + return true; + } + } + return false; +} + +size_t CefXmlObject::GetChildren(ObjectVector& children) { + AutoLock lock_scope(this); + children = children_; + return children_.size(); +} + +void CefXmlObject::ClearChildren() { + AutoLock lock_scope(this); + ObjectVector::iterator it = children_.begin(); + for (; it != children_.end(); ++it) + (*it)->SetParent(NULL); + children_.clear(); +} + +CefRefPtr CefXmlObject::FindChild(const CefString& name) { + DCHECK(!name.empty()); + if (name.empty()) + return NULL; + + AutoLock lock_scope(this); + ObjectVector::const_iterator it = children_.begin(); + for (; it != children_.end(); ++it) { + if ((*it)->GetName() == name) + return (*it); + } + return NULL; +} + +size_t CefXmlObject::FindChildren(const CefString& name, + ObjectVector& children) { + DCHECK(!name.empty()); + if (name.empty()) + return 0; + + size_t ct = 0; + + AutoLock lock_scope(this); + ObjectVector::const_iterator it = children_.begin(); + for (; it != children_.end(); ++it) { + if ((*it)->GetName() == name) { + children.push_back(*it); + ct++; + } + } + return ct; +} + +void CefXmlObject::SetParent(CefXmlObject* parent) { + AutoLock lock_scope(this); + if (parent) { + DCHECK(parent_ == NULL); + parent_ = parent; + } else { + DCHECK(parent_ != NULL); + parent_ = NULL; + } +} diff --git a/cef3/libcef_dll/wrapper/cef_zip_archive.cc b/cef3/libcef_dll/wrapper/cef_zip_archive.cc new file mode 100644 index 000000000..b248e40d2 --- /dev/null +++ b/cef3/libcef_dll/wrapper/cef_zip_archive.cc @@ -0,0 +1,162 @@ +// Copyright (c) 2010 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. + +#if defined(__linux__) +#include +#endif + +#include +#include +#include "include/wrapper/cef_zip_archive.h" +#include "include/cef_stream.h" +#include "include/cef_zip_reader.h" +#include "include/wrapper/cef_byte_read_handler.h" +#include "libcef_dll/cef_logging.h" + +namespace { + +class CefZipFile : public CefZipArchive::File { + public: + explicit CefZipFile(size_t size) : data_(size) {} + ~CefZipFile() {} + + // Returns the read-only data contained in the file. + virtual const unsigned char* GetData() { return &data_[0]; } + + // Returns the size of the data in the file. + virtual size_t GetDataSize() { return data_.size(); } + + // Returns a CefStreamReader object for streaming the contents of the file. + virtual CefRefPtr GetStreamReader() { + CefRefPtr handler( + new CefByteReadHandler(GetData(), GetDataSize(), this)); + return CefStreamReader::CreateForHandler(handler); + } + + std::vector* GetDataVector() { return &data_; } + + private: + std::vector data_; + + IMPLEMENT_REFCOUNTING(CefZipFile); +}; + +} // namespace + +// CefZipArchive implementation + +CefZipArchive::CefZipArchive() { +} + +CefZipArchive::~CefZipArchive() { +} + +size_t CefZipArchive::Load(CefRefPtr stream, + bool overwriteExisting) { + AutoLock lock_scope(this); + + CefRefPtr reader(CefZipReader::Create(stream)); + if (!reader.get()) + return 0; + + if (!reader->MoveToFirstFile()) + return 0; + + std::wstring name; + CefRefPtr contents; + FileMap::iterator it; + std::vector* data; + size_t count = 0, size, offset; + + do { + size = static_cast(reader->GetFileSize()); + if (size == 0) { + // Skip directories and empty files. + continue; + } + + if (!reader->OpenFile(CefString())) + break; + + name = reader->GetFileName(); + std::transform(name.begin(), name.end(), name.begin(), towlower); + + it = contents_.find(name); + if (it != contents_.end()) { + if (overwriteExisting) + contents_.erase(it); + else // Skip files that already exist. + continue; + } + + contents = new CefZipFile(size); + data = contents->GetDataVector(); + offset = 0; + + // Read the file contents. + do { + offset += reader->ReadFile(&(*data)[offset], size - offset); + } while (offset < size && !reader->Eof()); + + DCHECK(offset == size); + + reader->CloseFile(); + count++; + + // Add the file to the map. + contents_.insert(std::make_pair(name, contents.get())); + } while (reader->MoveToNextFile()); + + return count; +} + +void CefZipArchive::Clear() { + AutoLock lock_scope(this); + contents_.clear(); +} + +size_t CefZipArchive::GetFileCount() { + AutoLock lock_scope(this); + return contents_.size(); +} + +bool CefZipArchive::HasFile(const CefString& fileName) { + std::wstring str = fileName; + std::transform(str.begin(), str.end(), str.begin(), towlower); + + AutoLock lock_scope(this); + FileMap::const_iterator it = contents_.find(CefString(str)); + return (it != contents_.end()); +} + +CefRefPtr CefZipArchive::GetFile( + const CefString& fileName) { + std::wstring str = fileName; + std::transform(str.begin(), str.end(), str.begin(), towlower); + + AutoLock lock_scope(this); + FileMap::const_iterator it = contents_.find(CefString(str)); + if (it != contents_.end()) + return it->second; + return NULL; +} + +bool CefZipArchive::RemoveFile(const CefString& fileName) { + std::wstring str = fileName; + std::transform(str.begin(), str.end(), str.begin(), towlower); + + AutoLock lock_scope(this); + FileMap::iterator it = contents_.find(CefString(str)); + if (it != contents_.end()) { + contents_.erase(it); + return true; + } + return false; +} + +size_t CefZipArchive::GetFiles(FileMap& map) { + AutoLock lock_scope(this); + map = contents_; + return contents_.size(); +} diff --git a/cef3/libcef_dll/wrapper/libcef_dll_wrapper.cc b/cef3/libcef_dll/wrapper/libcef_dll_wrapper.cc new file mode 100644 index 000000000..9917c175e --- /dev/null +++ b/cef3/libcef_dll/wrapper/libcef_dll_wrapper.cc @@ -0,0 +1,660 @@ +// Copyright (c) 2013 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "include/cef_app.h" +#include "include/capi/cef_app_capi.h" +#include "include/cef_geolocation.h" +#include "include/capi/cef_geolocation_capi.h" +#include "include/cef_origin_whitelist.h" +#include "include/capi/cef_origin_whitelist_capi.h" +#include "include/cef_path_util.h" +#include "include/capi/cef_path_util_capi.h" +#include "include/cef_process_util.h" +#include "include/capi/cef_process_util_capi.h" +#include "include/cef_scheme.h" +#include "include/capi/cef_scheme_capi.h" +#include "include/cef_task.h" +#include "include/capi/cef_task_capi.h" +#include "include/cef_trace.h" +#include "include/capi/cef_trace_capi.h" +#include "include/cef_url.h" +#include "include/capi/cef_url_capi.h" +#include "include/cef_v8.h" +#include "include/capi/cef_v8_capi.h" +#include "include/cef_web_plugin.h" +#include "include/capi/cef_web_plugin_capi.h" +#include "include/cef_version.h" +#include "libcef_dll/cpptoc/app_cpptoc.h" +#include "libcef_dll/cpptoc/browser_process_handler_cpptoc.h" +#include "libcef_dll/cpptoc/completion_handler_cpptoc.h" +#include "libcef_dll/cpptoc/context_menu_handler_cpptoc.h" +#include "libcef_dll/cpptoc/cookie_visitor_cpptoc.h" +#include "libcef_dll/cpptoc/domevent_listener_cpptoc.h" +#include "libcef_dll/cpptoc/domvisitor_cpptoc.h" +#include "libcef_dll/cpptoc/dialog_handler_cpptoc.h" +#include "libcef_dll/cpptoc/display_handler_cpptoc.h" +#include "libcef_dll/cpptoc/download_handler_cpptoc.h" +#include "libcef_dll/cpptoc/focus_handler_cpptoc.h" +#include "libcef_dll/cpptoc/geolocation_handler_cpptoc.h" +#include "libcef_dll/cpptoc/get_geolocation_callback_cpptoc.h" +#include "libcef_dll/cpptoc/jsdialog_handler_cpptoc.h" +#include "libcef_dll/cpptoc/keyboard_handler_cpptoc.h" +#include "libcef_dll/cpptoc/life_span_handler_cpptoc.h" +#include "libcef_dll/cpptoc/load_handler_cpptoc.h" +#include "libcef_dll/cpptoc/read_handler_cpptoc.h" +#include "libcef_dll/cpptoc/render_handler_cpptoc.h" +#include "libcef_dll/cpptoc/render_process_handler_cpptoc.h" +#include "libcef_dll/cpptoc/request_handler_cpptoc.h" +#include "libcef_dll/cpptoc/resource_bundle_handler_cpptoc.h" +#include "libcef_dll/cpptoc/resource_handler_cpptoc.h" +#include "libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.h" +#include "libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h" +#include "libcef_dll/cpptoc/string_visitor_cpptoc.h" +#include "libcef_dll/cpptoc/task_cpptoc.h" +#include "libcef_dll/cpptoc/trace_client_cpptoc.h" +#include "libcef_dll/cpptoc/urlrequest_client_cpptoc.h" +#include "libcef_dll/cpptoc/v8accessor_cpptoc.h" +#include "libcef_dll/cpptoc/v8handler_cpptoc.h" +#include "libcef_dll/cpptoc/web_plugin_info_visitor_cpptoc.h" +#include "libcef_dll/cpptoc/web_plugin_unstable_callback_cpptoc.h" +#include "libcef_dll/cpptoc/write_handler_cpptoc.h" +#include "libcef_dll/ctocpp/allow_certificate_error_callback_ctocpp.h" +#include "libcef_dll/ctocpp/auth_callback_ctocpp.h" +#include "libcef_dll/ctocpp/before_download_callback_ctocpp.h" +#include "libcef_dll/ctocpp/binary_value_ctocpp.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/browser_host_ctocpp.h" +#include "libcef_dll/ctocpp/callback_ctocpp.h" +#include "libcef_dll/ctocpp/command_line_ctocpp.h" +#include "libcef_dll/ctocpp/context_menu_params_ctocpp.h" +#include "libcef_dll/ctocpp/cookie_manager_ctocpp.h" +#include "libcef_dll/ctocpp/domdocument_ctocpp.h" +#include "libcef_dll/ctocpp/domevent_ctocpp.h" +#include "libcef_dll/ctocpp/domnode_ctocpp.h" +#include "libcef_dll/ctocpp/dictionary_value_ctocpp.h" +#include "libcef_dll/ctocpp/download_item_ctocpp.h" +#include "libcef_dll/ctocpp/download_item_callback_ctocpp.h" +#include "libcef_dll/ctocpp/file_dialog_callback_ctocpp.h" +#include "libcef_dll/ctocpp/frame_ctocpp.h" +#include "libcef_dll/ctocpp/geolocation_callback_ctocpp.h" +#include "libcef_dll/ctocpp/jsdialog_callback_ctocpp.h" +#include "libcef_dll/ctocpp/list_value_ctocpp.h" +#include "libcef_dll/ctocpp/menu_model_ctocpp.h" +#include "libcef_dll/ctocpp/process_message_ctocpp.h" +#include "libcef_dll/ctocpp/quota_callback_ctocpp.h" +#include "libcef_dll/ctocpp/scheme_registrar_ctocpp.h" +#include "libcef_dll/ctocpp/stream_reader_ctocpp.h" +#include "libcef_dll/ctocpp/stream_writer_ctocpp.h" +#include "libcef_dll/ctocpp/task_runner_ctocpp.h" +#include "libcef_dll/ctocpp/urlrequest_ctocpp.h" +#include "libcef_dll/ctocpp/v8context_ctocpp.h" +#include "libcef_dll/ctocpp/v8exception_ctocpp.h" +#include "libcef_dll/ctocpp/v8stack_frame_ctocpp.h" +#include "libcef_dll/ctocpp/v8stack_trace_ctocpp.h" +#include "libcef_dll/ctocpp/v8value_ctocpp.h" +#include "libcef_dll/ctocpp/web_plugin_info_ctocpp.h" +#include "libcef_dll/ctocpp/xml_reader_ctocpp.h" +#include "libcef_dll/ctocpp/zip_reader_ctocpp.h" + +// Define used to facilitate parsing. +#define CEF_GLOBAL + + +// GLOBAL METHODS - Body may be edited by hand. + +CEF_GLOBAL int CefExecuteProcess(const CefMainArgs& args, + CefRefPtr application) { + const char* api_hash = cef_api_hash(0); + if (strcmp(api_hash, CEF_API_HASH_PLATFORM)) { + // The libcef API hash does not match the current header API hash. + DCHECK(false); + return 0; + } + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: application + + // Execute + int _retval = cef_execute_process( + &args, + CefAppCppToC::Wrap(application)); + + // Return type: simple + return _retval; +} + +CEF_GLOBAL bool CefInitialize(const CefMainArgs& args, + const CefSettings& settings, CefRefPtr application) { + const char* api_hash = cef_api_hash(0); + if (strcmp(api_hash, CEF_API_HASH_PLATFORM)) { + // The libcef API hash does not match the current header API hash. + DCHECK(false); + return false; + } + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: application + + // Execute + int _retval = cef_initialize( + &args, + &settings, + CefAppCppToC::Wrap(application)); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL void CefShutdown() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_shutdown(); + +#ifndef NDEBUG + // Check that all wrapper objects have been destroyed + DCHECK_EQ(CefAllowCertificateErrorCallbackCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefAuthCallbackCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefBeforeDownloadCallbackCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefBinaryValueCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefBrowserCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefBrowserHostCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefBrowserProcessHandlerCppToC::DebugObjCt, 0); + DCHECK_EQ(CefCallbackCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefCompletionHandlerCppToC::DebugObjCt, 0); + DCHECK_EQ(CefContextMenuHandlerCppToC::DebugObjCt, 0); + DCHECK_EQ(CefContextMenuParamsCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefCookieManagerCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefCookieVisitorCppToC::DebugObjCt, 0); + DCHECK_EQ(CefDOMDocumentCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefDOMEventCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefDOMEventListenerCppToC::DebugObjCt, 0); + DCHECK_EQ(CefDOMNodeCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefDOMVisitorCppToC::DebugObjCt, 0); + DCHECK_EQ(CefDialogHandlerCppToC::DebugObjCt, 0); + DCHECK_EQ(CefDictionaryValueCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefDisplayHandlerCppToC::DebugObjCt, 0); + DCHECK_EQ(CefDownloadHandlerCppToC::DebugObjCt, 0); + DCHECK_EQ(CefDownloadItemCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefDownloadItemCallbackCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefFileDialogCallbackCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefFocusHandlerCppToC::DebugObjCt, 0); + DCHECK_EQ(CefFrameCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefGeolocationCallbackCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefGeolocationHandlerCppToC::DebugObjCt, 0); + DCHECK_EQ(CefGetGeolocationCallbackCppToC::DebugObjCt, 0); + DCHECK_EQ(CefJSDialogCallbackCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefJSDialogHandlerCppToC::DebugObjCt, 0); + DCHECK_EQ(CefKeyboardHandlerCppToC::DebugObjCt, 0); + DCHECK_EQ(CefLifeSpanHandlerCppToC::DebugObjCt, 0); + DCHECK_EQ(CefListValueCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefLoadHandlerCppToC::DebugObjCt, 0); + DCHECK_EQ(CefMenuModelCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefProcessMessageCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefQuotaCallbackCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefReadHandlerCppToC::DebugObjCt, 0); + DCHECK_EQ(CefRenderHandlerCppToC::DebugObjCt, 0); + DCHECK_EQ(CefRenderProcessHandlerCppToC::DebugObjCt, 0); + DCHECK_EQ(CefRequestHandlerCppToC::DebugObjCt, 0); + DCHECK_EQ(CefResourceBundleHandlerCppToC::DebugObjCt, 0); + DCHECK_EQ(CefResourceHandlerCppToC::DebugObjCt, 0); + DCHECK_EQ(CefRunFileDialogCallbackCppToC::DebugObjCt, 0); + DCHECK_EQ(CefSchemeHandlerFactoryCppToC::DebugObjCt, 0); + DCHECK_EQ(CefSchemeRegistrarCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefStreamReaderCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefStreamWriterCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefStringVisitorCppToC::DebugObjCt, 0); + DCHECK_EQ(CefTaskCppToC::DebugObjCt, 0); + DCHECK_EQ(CefTaskRunnerCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefTraceClientCppToC::DebugObjCt, 0); + DCHECK_EQ(CefURLRequestCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefURLRequestClientCppToC::DebugObjCt, 0); + DCHECK_EQ(CefV8AccessorCppToC::DebugObjCt, 0); + DCHECK_EQ(CefV8ContextCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefV8ExceptionCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefV8HandlerCppToC::DebugObjCt, 0); + DCHECK_EQ(CefV8StackFrameCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefV8StackTraceCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefV8ValueCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefWebPluginInfoCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefWebPluginInfoVisitorCppToC::DebugObjCt, 0); + DCHECK_EQ(CefWebPluginUnstableCallbackCppToC::DebugObjCt, 0); + DCHECK_EQ(CefWriteHandlerCppToC::DebugObjCt, 0); + DCHECK_EQ(CefXmlReaderCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefZipReaderCToCpp::DebugObjCt, 0); +#endif // !NDEBUG +} + +CEF_GLOBAL void CefDoMessageLoopWork() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_do_message_loop_work(); +} + +CEF_GLOBAL void CefRunMessageLoop() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_run_message_loop(); +} + +CEF_GLOBAL void CefQuitMessageLoop() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_quit_message_loop(); +} + +CEF_GLOBAL bool CefGetGeolocation( + CefRefPtr callback) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: callback; type: refptr_diff + DCHECK(callback.get()); + if (!callback.get()) + return false; + + // Execute + int _retval = cef_get_geolocation( + CefGetGeolocationCallbackCppToC::Wrap(callback)); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefAddCrossOriginWhitelistEntry(const CefString& source_origin, + const CefString& target_protocol, const CefString& target_domain, + bool allow_target_subdomains) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: source_origin; type: string_byref_const + DCHECK(!source_origin.empty()); + if (source_origin.empty()) + return false; + // Verify param: target_protocol; type: string_byref_const + DCHECK(!target_protocol.empty()); + if (target_protocol.empty()) + return false; + // Unverified params: target_domain + + // Execute + int _retval = cef_add_cross_origin_whitelist_entry( + source_origin.GetStruct(), + target_protocol.GetStruct(), + target_domain.GetStruct(), + allow_target_subdomains); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefRemoveCrossOriginWhitelistEntry( + const CefString& source_origin, const CefString& target_protocol, + const CefString& target_domain, bool allow_target_subdomains) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: source_origin; type: string_byref_const + DCHECK(!source_origin.empty()); + if (source_origin.empty()) + return false; + // Verify param: target_protocol; type: string_byref_const + DCHECK(!target_protocol.empty()); + if (target_protocol.empty()) + return false; + // Unverified params: target_domain + + // Execute + int _retval = cef_remove_cross_origin_whitelist_entry( + source_origin.GetStruct(), + target_protocol.GetStruct(), + target_domain.GetStruct(), + allow_target_subdomains); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefClearCrossOriginWhitelist() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = cef_clear_cross_origin_whitelist(); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefGetPath(PathKey key, CefString& path) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = cef_get_path( + key, + path.GetWritableStruct()); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefLaunchProcess(CefRefPtr command_line) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: command_line; type: refptr_same + DCHECK(command_line.get()); + if (!command_line.get()) + return false; + + // Execute + int _retval = cef_launch_process( + CefCommandLineCToCpp::Unwrap(command_line)); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefRegisterSchemeHandlerFactory(const CefString& scheme_name, + const CefString& domain_name, + CefRefPtr factory) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: scheme_name; type: string_byref_const + DCHECK(!scheme_name.empty()); + if (scheme_name.empty()) + return false; + // Unverified params: domain_name, factory + + // Execute + int _retval = cef_register_scheme_handler_factory( + scheme_name.GetStruct(), + domain_name.GetStruct(), + CefSchemeHandlerFactoryCppToC::Wrap(factory)); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefClearSchemeHandlerFactories() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = cef_clear_scheme_handler_factories(); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefCurrentlyOn(CefThreadId threadId) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = cef_currently_on( + threadId); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefPostTask(CefThreadId threadId, CefRefPtr task) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: task; type: refptr_diff + DCHECK(task.get()); + if (!task.get()) + return false; + + // Execute + int _retval = cef_post_task( + threadId, + CefTaskCppToC::Wrap(task)); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefPostDelayedTask(CefThreadId threadId, + CefRefPtr task, int64 delay_ms) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: task; type: refptr_diff + DCHECK(task.get()); + if (!task.get()) + return false; + + // Execute + int _retval = cef_post_delayed_task( + threadId, + CefTaskCppToC::Wrap(task), + delay_ms); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefBeginTracing(CefRefPtr client, + const CefString& categories) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: client, categories + + // Execute + int _retval = cef_begin_tracing( + CefTraceClientCppToC::Wrap(client), + categories.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefGetTraceBufferPercentFullAsync() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = cef_get_trace_buffer_percent_full_async(); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefEndTracingAsync() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = cef_end_tracing_async(); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL int64 CefNowFromSystemTraceTime() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int64 _retval = cef_now_from_system_trace_time(); + + // Return type: simple + return _retval; +} + +CEF_GLOBAL bool CefParseURL(const CefString& url, CefURLParts& parts) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: url; type: string_byref_const + DCHECK(!url.empty()); + if (url.empty()) + return false; + + // Execute + int _retval = cef_parse_url( + url.GetStruct(), + &parts); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefCreateURL(const CefURLParts& parts, CefString& url) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = cef_create_url( + &parts, + url.GetWritableStruct()); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefRegisterExtension(const CefString& extension_name, + const CefString& javascript_code, CefRefPtr handler) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: extension_name; type: string_byref_const + DCHECK(!extension_name.empty()); + if (extension_name.empty()) + return false; + // Verify param: javascript_code; type: string_byref_const + DCHECK(!javascript_code.empty()); + if (javascript_code.empty()) + return false; + // Unverified params: handler + + // Execute + int _retval = cef_register_extension( + extension_name.GetStruct(), + javascript_code.GetStruct(), + CefV8HandlerCppToC::Wrap(handler)); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL void CefVisitWebPluginInfo( + CefRefPtr visitor) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: visitor; type: refptr_diff + DCHECK(visitor.get()); + if (!visitor.get()) + return; + + // Execute + cef_visit_web_plugin_info( + CefWebPluginInfoVisitorCppToC::Wrap(visitor)); +} + +CEF_GLOBAL void CefRefreshWebPlugins() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_refresh_web_plugins(); +} + +CEF_GLOBAL void CefAddWebPluginPath(const CefString& path) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: path; type: string_byref_const + DCHECK(!path.empty()); + if (path.empty()) + return; + + // Execute + cef_add_web_plugin_path( + path.GetStruct()); +} + +CEF_GLOBAL void CefAddWebPluginDirectory(const CefString& dir) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: dir; type: string_byref_const + DCHECK(!dir.empty()); + if (dir.empty()) + return; + + // Execute + cef_add_web_plugin_directory( + dir.GetStruct()); +} + +CEF_GLOBAL void CefRemoveWebPluginPath(const CefString& path) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: path; type: string_byref_const + DCHECK(!path.empty()); + if (path.empty()) + return; + + // Execute + cef_remove_web_plugin_path( + path.GetStruct()); +} + +CEF_GLOBAL void CefUnregisterInternalWebPlugin(const CefString& path) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: path; type: string_byref_const + DCHECK(!path.empty()); + if (path.empty()) + return; + + // Execute + cef_unregister_internal_web_plugin( + path.GetStruct()); +} + +CEF_GLOBAL void CefForceWebPluginShutdown(const CefString& path) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: path; type: string_byref_const + DCHECK(!path.empty()); + if (path.empty()) + return; + + // Execute + cef_force_web_plugin_shutdown( + path.GetStruct()); +} + +CEF_GLOBAL void CefRegisterWebPluginCrash(const CefString& path) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: path; type: string_byref_const + DCHECK(!path.empty()); + if (path.empty()) + return; + + // Execute + cef_register_web_plugin_crash( + path.GetStruct()); +} + +CEF_GLOBAL void CefIsWebPluginUnstable(const CefString& path, + CefRefPtr callback) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: path; type: string_byref_const + DCHECK(!path.empty()); + if (path.empty()) + return; + // Verify param: callback; type: refptr_diff + DCHECK(callback.get()); + if (!callback.get()) + return; + + // Execute + cef_is_web_plugin_unstable( + path.GetStruct(), + CefWebPluginUnstableCallbackCppToC::Wrap(callback)); +} + diff --git a/cef3/libcef_dll/wrapper/libcef_dll_wrapper2.cc b/cef3/libcef_dll/wrapper/libcef_dll_wrapper2.cc new file mode 100644 index 000000000..dc8ba7b02 --- /dev/null +++ b/cef3/libcef_dll/wrapper/libcef_dll_wrapper2.cc @@ -0,0 +1,4 @@ +// 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. + diff --git a/cef3/patch/README.txt b/cef3/patch/README.txt new file mode 100644 index 000000000..f96fe36a4 --- /dev/null +++ b/cef3/patch/README.txt @@ -0,0 +1,20 @@ +There may be instances where CEF requires changes to the Chromium/WebKit code +base that are not desired by the Chromium/WebKit projects as a whole. To address +this situation the CEF project adds a patch capability as part of the CEF GYP +project generation step. The patch capability works as follows: + +1. The CEF developer creates one or more patch files containing all required + changes to the Chromium/WebKit code base and places those patch files in the + "patches" subdirectory. +2. The CEF developer adds an entry for each patch file in the "patch.cfg" file. +3. CEF applies the patches to the Chromium/WebKit source tree using the + patcher.py tool in the tools directory. If necessary the patcher.py tool + also rewrites the "patch_state.h" file which defines the CEF_PATCHES_APPLIED + preprocessor value. + +To disable automatic application of patches to the Chromium/WebKit code base +create an empty "NOPATCH" file in the "patch" directory. Sections of the CEF +code base that otherwise require patches will be disabled using the +CEF_PATCHES_APPLIED preprocessor value defined in the "patch_state.h" file. Be +warned that not applying all required patches may break important CEF +functionality. diff --git a/cef3/patch/patch.cfg b/cef3/patch/patch.cfg new file mode 100644 index 000000000..95b545ef5 --- /dev/null +++ b/cef3/patch/patch.cfg @@ -0,0 +1,51 @@ +# Each map in the list associates a patch file name with a target path and +# optional condition. All paths in the patch file must be relative to the +# target path. Each map should include a comment linking to the code review +# or bug report that the patch relates to. If a condition is provided the +# patch will only be applied if an environment variable with the specified +# name exists. + +patches = [ + { + # Necessary for grit integration + 'name': 'gritsettings', + 'path': '../tools/gritsettings/', + }, + { + # http://codereview.chromium.org/8086022/ + 'name': 'build', + 'path': '../build/', + }, + { + # http://code.google.com/p/chromiumembedded/issues/detail?id=496 + 'name': 'zlib', + 'path': '../third_party/zlib/', + }, + { + # http://code.google.com/p/gyp/issues/detail?id=443 + 'name': 'message_loop_443', + 'path': '../base/', + }, + { + # http://code.google.com/p/chromiumembedded/issues/detail?id=451 + 'name': 'webkit_451', + 'path': '../third_party/WebKit/Source/', + }, + { + # https://code.google.com/p/chromiumembedded/issues/detail?id=505 + # https://code.google.com/p/chromiumembedded/issues/detail?id=899 + 'name': 'webkit_features', + 'path': '../third_party/WebKit/Source/WebKit/chromium/', + }, + { + # http://code.google.com/p/chromiumembedded/issues/detail?id=933 + 'name': 'webkit_933', + 'path': '../third_party/WebKit/Source/WebKit/chromium/src/', + }, + { + # http://code.google.com/p/chromiumembedded/issues/detail?id=364 + 'name': 'spi_webcore_364', + 'path': '../third_party/WebKit/Source/WebCore/', + 'condition': 'CEF_SPI_BUILD', + }, +] diff --git a/cef3/patch/patches/build.patch b/cef3/patch/patches/build.patch new file mode 100644 index 000000000..e73ddb02c --- /dev/null +++ b/cef3/patch/patches/build.patch @@ -0,0 +1,27 @@ +Index: common.gypi +=================================================================== +--- common.gypi (revision 102269) ++++ common.gypi (working copy) +@@ -9,6 +9,9 @@ + # Variables expected to be overriden on the GYP command line (-D) or by + # ~/.gyp/include.gypi. + 'variables': { ++ # Directory for CEF source files. This will be set by cef.gypi. ++ 'cef_directory%' : '', ++ + # Putting a variables dict inside another variables dict looks kind of + # weird. This is done so that 'host_arch', 'chromeos', etc are defined as + # variables within the outer variables dict here. This is necessary +Index: mac/strip_save_dsym +=================================================================== +--- mac/strip_save_dsym (revision 102269) ++++ mac/strip_save_dsym (working copy) +@@ -48,7 +48,7 @@ + "bundle"] + macho_types_re = "Mach-O (?:64-bit )?(?:" + "|".join(macho_types) + ")" + +- file_cmd = subprocess.Popen(["/usr/bin/file", "-b", "--", macho], ++ file_cmd = subprocess.Popen(["/usr/bin/file", "-b", "-L", "--", macho], + stdout=subprocess.PIPE) + + archs = [] diff --git a/cef3/patch/patches/gritsettings.patch b/cef3/patch/patches/gritsettings.patch new file mode 100644 index 000000000..ea71cce84 --- /dev/null +++ b/cef3/patch/patches/gritsettings.patch @@ -0,0 +1,17 @@ +Index: resource_ids +=================================================================== +--- resource_ids (revision 149431) ++++ resource_ids (working copy) +@@ -16,6 +16,12 @@ + { + "SRCDIR": "../..", + ++ "cef/libcef/resources/cef_resources.grd": { ++ "includes": [27500], ++ }, ++ "cef/libcef/resources/cef_strings.grd": { ++ "messages": [28000], ++ }, + "chrome/browser/browser_resources.grd": { + "includes": [500], + "structures": [750], diff --git a/cef3/patch/patches/message_loop_443.patch b/cef3/patch/patches/message_loop_443.patch new file mode 100644 index 000000000..6448d9b4e --- /dev/null +++ b/cef3/patch/patches/message_loop_443.patch @@ -0,0 +1,13 @@ +Index: message_loop.cc +=================================================================== +--- message_loop.cc (revision 181864) ++++ message_loop.cc (working copy) +@@ -193,7 +193,7 @@ + MessageLoop::~MessageLoop() { + DCHECK_EQ(this, current()); + +- DCHECK(!run_loop_); ++ //DCHECK(!run_loop_); + + // Clean up any unprocessed tasks, but take care: deleting a task could + // result in the addition of more tasks (e.g., via DeleteSoon). We set a diff --git a/cef3/patch/patches/spi_webcore_364.patch b/cef3/patch/patches/spi_webcore_364.patch new file mode 100644 index 000000000..234db8dad --- /dev/null +++ b/cef3/patch/patches/spi_webcore_364.patch @@ -0,0 +1,39 @@ +Index: page/FrameView.cpp +=================================================================== +--- page/FrameView.cpp (revision 146842) ++++ page/FrameView.cpp (working copy) +@@ -209,10 +209,12 @@ + if (!page) + return; + ++#if 0 + if (m_frame == page->mainFrame()) { + ScrollableArea::setVerticalScrollElasticity(ScrollElasticityAllowed); + ScrollableArea::setHorizontalScrollElasticity(ScrollElasticityAllowed); + } ++#endif + } + + PassRefPtr FrameView::create(Frame* frame) +Index: platform/mac/NSScrollerImpDetails.mm +=================================================================== +--- platform/mac/NSScrollerImpDetails.mm (revision 146842) ++++ platform/mac/NSScrollerImpDetails.mm (working copy) +@@ -34,6 +34,7 @@ + #if PLATFORM(CHROMIUM) + bool isScrollbarOverlayAPIAvailable() + { ++#if 0 + static bool apiAvailable; + static bool shouldInitialize = true; + if (shouldInitialize) { +@@ -44,6 +45,9 @@ + && [scrollerImpPairClass instancesRespondToSelector:@selector(scrollerStyle)]; + } + return apiAvailable; ++#else ++ return false; ++#endif + } + #endif + diff --git a/cef3/patch/patches/webkit_451.patch b/cef3/patch/patches/webkit_451.patch new file mode 100644 index 000000000..bb371c50f --- /dev/null +++ b/cef3/patch/patches/webkit_451.patch @@ -0,0 +1,263 @@ +Index: Platform/chromium/public/WebWorkerScriptObserver.h +=================================================================== +--- Platform/chromium/public/WebWorkerScriptObserver.h (revision 0) ++++ Platform/chromium/public/WebWorkerScriptObserver.h (revision 0) +@@ -0,0 +1,50 @@ ++/* ++ * Copyright (C) 2013 Google Inc. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * ++ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY ++ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY ++ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ++ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ++ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ++ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ */ ++ ++#ifndef WebWorkerScriptObserver_h ++#define WebWorkerScriptObserver_h ++ ++#include ++ ++namespace WebKit { ++ ++ class WebURL; ++ class WebWorkerRunLoop; ++ ++ class WebWorkerScriptObserver { ++ public: ++ // Notifies that a new script context has been created for a worker. ++ // This will be called only once per worker context. ++ virtual void didCreateWorkerScriptContext(const WebWorkerRunLoop&, const WebURL&, v8::Handle) { } ++ ++ // WebKit is about to release its reference to a v8 context for a worker. ++ virtual void willReleaseWorkerScriptContext(const WebWorkerRunLoop&, const WebURL&, v8::Handle) { } ++ ++ protected: ++ virtual ~WebWorkerScriptObserver() { } ++ }; ++ ++} // namespace WebKit ++ ++#endif + +Property changes on: Platform\chromium\public\WebWorkerScriptObserver.h +___________________________________________________________________ +Added: svn:eol-style + + LF + +Index: WebCore/bindings/v8/WorkerScriptController.cpp +=================================================================== +--- WebCore/bindings/v8/WorkerScriptController.cpp (revision 145278) ++++ WebCore/bindings/v8/WorkerScriptController.cpp (working copy) +@@ -51,11 +51,23 @@ + + #if PLATFORM(CHROMIUM) + #include ++#include + #include ++#include + #endif + + namespace WebCore { + ++namespace { ++ ++static Vector& observerVector() ++{ ++ AtomicallyInitializedStatic(Vector&, observers = *new Vector); ++ return observers; ++} ++ ++} // namespace ++ + WorkerScriptController::WorkerScriptController(WorkerContext* workerContext) + : m_workerContext(workerContext) + , m_isolate(v8::Isolate::New()) +@@ -73,6 +85,8 @@ + WorkerScriptController::~WorkerScriptController() + { + m_domDataStore.clear(); ++ if (!m_context.isEmpty()) ++ notifyWillReleaseWorkerScriptContext(); + #if PLATFORM(CHROMIUM) + // The corresponding call to didStartWorkerRunLoop is in + // WorkerThread::workerThread(). +@@ -134,6 +148,8 @@ + v8::Handle globalObject = v8::Handle::Cast(m_context->Global()->GetPrototype()); + globalObject->SetPrototype(jsWorkerContext); + ++ notifyDidCreateWorkerScriptContext(); ++ + return true; + } + +@@ -258,6 +274,39 @@ + return workerContext->script(); + } + ++void WorkerScriptController::addObserver(WebKit::WebWorkerScriptObserver* observer) ++{ ++ if (WebCore::WorkerThread::workerThreadCount() > 0) ++ return; ++ ++ observerVector().append(observer); ++} ++ ++void WorkerScriptController::removeObserver(WebKit::WebWorkerScriptObserver* observer) ++{ ++ if (WebCore::WorkerThread::workerThreadCount() > 0) ++ return; ++ ++ Vector& observers = observerVector(); ++ size_t pos = observers.find(observer); ++ if (pos != notFound) ++ observers.remove(pos); ++} ++ ++void WorkerScriptController::notifyDidCreateWorkerScriptContext() ++{ ++ const Vector& observers = observerVector(); ++ for (Vector::const_iterator i = observers.begin(); i != observers.end(); ++i) ++ (*i)->didCreateWorkerScriptContext(WebKit::WebWorkerRunLoop(&m_workerContext->thread()->runLoop()), m_workerContext->url(), m_context.get()); ++} ++ ++void WorkerScriptController::notifyWillReleaseWorkerScriptContext() ++{ ++ const Vector& observers = observerVector(); ++ for (Vector::const_iterator i = observers.begin(); i != observers.end(); ++i) ++ (*i)->willReleaseWorkerScriptContext(WebKit::WebWorkerRunLoop(&m_workerContext->thread()->runLoop()), m_workerContext->url(), m_context.get()); ++} ++ + } // namespace WebCore + + #endif // ENABLE(WORKERS) +Index: WebCore/bindings/v8/WorkerScriptController.h +=================================================================== +--- WebCore/bindings/v8/WorkerScriptController.h (revision 145278) ++++ WebCore/bindings/v8/WorkerScriptController.h (working copy) +@@ -40,6 +40,10 @@ + #include + #include + ++namespace WebKit { ++class WebWorkerScriptObserver; ++} ++ + namespace WebCore { + + class ScriptSourceCode; +@@ -95,10 +99,17 @@ + // Returns a local handle of the context. + v8::Local context() { return v8::Local::New(m_context.get()); } + ++ // Add or remove an observer. Can only be called while no WebWorkers exist. ++ static void addObserver(WebKit::WebWorkerScriptObserver*); ++ static void removeObserver(WebKit::WebWorkerScriptObserver*); ++ + private: + bool initializeContextIfNeeded(); + void disposeContext(); + ++ void notifyDidCreateWorkerScriptContext(); ++ void notifyWillReleaseWorkerScriptContext(); ++ + WorkerContext* m_workerContext; + v8::Isolate* m_isolate; + ScopedPersistent m_context; +Index: WebKit/chromium/public/WebWorkerInfo.h +=================================================================== +--- WebKit/chromium/public/WebWorkerInfo.h (revision 145278) ++++ WebKit/chromium/public/WebWorkerInfo.h (working copy) +@@ -35,9 +35,15 @@ + + namespace WebKit { + ++class WebWorkerScriptObserver; ++ + class WebWorkerInfo { + public: + WEBKIT_EXPORT static unsigned dedicatedWorkerCount(); ++ ++ // Add or remove an observer. Can only be called while no WebWorkers exist. ++ WEBKIT_EXPORT static void addScriptObserver(WebWorkerScriptObserver*); ++ WEBKIT_EXPORT static void removeScriptObserver(WebWorkerScriptObserver*); + }; + + } +Index: WebKit/chromium/public/WebWorkerScriptObserver.h +=================================================================== +--- WebKit/chromium/public/WebWorkerScriptObserver.h (revision 0) ++++ WebKit/chromium/public/WebWorkerScriptObserver.h (revision 0) +@@ -0,0 +1,25 @@ ++/* ++ * Copyright (C) 2013 Google Inc. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * ++ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY ++ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY ++ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ++ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ++ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ++ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ */ ++ ++#include "../../../Platform/chromium/public/WebWorkerScriptObserver.h" + +Property changes on: WebKit\chromium\public\WebWorkerScriptObserver.h +___________________________________________________________________ +Added: svn:eol-style + + LF + +Index: WebKit/chromium/src/WebWorkerInfo.cpp +=================================================================== +--- WebKit/chromium/src/WebWorkerInfo.cpp (revision 145278) ++++ WebKit/chromium/src/WebWorkerInfo.cpp (working copy) +@@ -31,6 +31,7 @@ + #include "config.h" + #include "WebWorkerInfo.h" + ++#include "WorkerScriptController.h" + #include "WorkerThread.h" + + namespace WebKit { +@@ -40,4 +41,14 @@ + return WebCore::WorkerThread::workerThreadCount(); + } + ++void WebWorkerInfo::addScriptObserver(WebWorkerScriptObserver* observer) ++{ ++ WebCore::WorkerScriptController::addObserver(observer); + } ++ ++void WebWorkerInfo::removeScriptObserver(WebWorkerScriptObserver* observer) ++{ ++ WebCore::WorkerScriptController::removeObserver(observer); ++} ++ ++} diff --git a/cef3/patch/patches/webkit_933.patch b/cef3/patch/patches/webkit_933.patch new file mode 100644 index 000000000..dc39bd7ba --- /dev/null +++ b/cef3/patch/patches/webkit_933.patch @@ -0,0 +1,13 @@ +Index: WebNode.cpp +=================================================================== +--- WebNode.cpp (revision 146842) ++++ WebNode.cpp (working copy) +@@ -181,7 +181,7 @@ + void WebNode::addEventListener(const WebString& eventType, WebDOMEventListener* listener, bool useCapture) + { + // Please do not add more eventTypes to this list without an API review. +- RELEASE_ASSERT(eventType == "mousedown"); ++ //RELEASE_ASSERT(eventType == "mousedown"); + + EventListenerWrapper* listenerWrapper = listener->createEventListenerWrapper(eventType, useCapture, m_private.get()); + // The listenerWrapper is only referenced by the actual Node. Once it goes diff --git a/cef3/patch/patches/webkit_features.patch b/cef3/patch/patches/webkit_features.patch new file mode 100644 index 000000000..639899d09 --- /dev/null +++ b/cef3/patch/patches/webkit_features.patch @@ -0,0 +1,13 @@ +Index: features.gypi +=================================================================== +--- features.gypi (revision 145278) ++++ features.gypi (working copy) +@@ -193,7 +193,7 @@ + 'ENABLE_CALENDAR_PICKER=1', + 'ENABLE_DATALIST_ELEMENT=1', + 'ENABLE_INPUT_SPEECH=1', +- 'ENABLE_INPUT_TYPE_COLOR=1', ++ 'ENABLE_INPUT_TYPE_COLOR=0', + 'ENABLE_INPUT_TYPE_WEEK=1', + 'ENABLE_INPUT_MULTIPLE_FIELDS_UI=1', + 'ENABLE_LEGACY_NOTIFICATIONS=1', diff --git a/cef3/patch/patches/zlib.patch b/cef3/patch/patches/zlib.patch new file mode 100644 index 000000000..0e40c4f0d --- /dev/null +++ b/cef3/patch/patches/zlib.patch @@ -0,0 +1,13 @@ +Index: contrib/minizip/unzip.c +=================================================================== +--- contrib/minizip/unzip.c (revision 176706) ++++ contrib/minizip/unzip.c (working copy) +@@ -69,7 +69,7 @@ + #include + + #ifndef NOUNCRYPT +- #define NOUNCRYPT ++// #define NOUNCRYPT + #endif + + #include "third_party/zlib/zlib.h" diff --git a/cef3/tests/cefclient/binding_test.cpp b/cef3/tests/cefclient/binding_test.cpp new file mode 100644 index 000000000..5b78aa458 --- /dev/null +++ b/cef3/tests/cefclient/binding_test.cpp @@ -0,0 +1,66 @@ +// 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/binding_test.h" + +#include +#include + +#include "include/wrapper/cef_stream_resource_handler.h" + +namespace binding_test { + +namespace { + +const char* kMessageName = "binding_test"; + +// Handle messages in the browser process. +class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate { + public: + ProcessMessageDelegate() { + } + + // From ClientHandler::ProcessMessageDelegate. + virtual bool OnProcessMessageReceived( + CefRefPtr handler, + CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) OVERRIDE { + std::string message_name = message->GetName(); + if (message_name == kMessageName) { + // Handle the message. + std::string result; + + CefRefPtr args = message->GetArgumentList(); + 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()); + } else { + result = "Invalid request"; + } + + // Send the result back to the render process. + CefRefPtr response = + CefProcessMessage::Create(kMessageName); + response->GetArgumentList()->SetString(0, result); + browser->SendProcessMessage(PID_RENDERER, response); + + return true; + } + + return false; + } + + IMPLEMENT_REFCOUNTING(ProcessMessageDelegate); +}; + +} // namespace + +void CreateProcessMessageDelegates( + ClientHandler::ProcessMessageDelegateSet& delegates) { + delegates.insert(new ProcessMessageDelegate); +} + +} // namespace binding_test diff --git a/cef3/tests/cefclient/binding_test.h b/cef3/tests/cefclient/binding_test.h new file mode 100644 index 000000000..db6e8305b --- /dev/null +++ b/cef3/tests/cefclient/binding_test.h @@ -0,0 +1,19 @@ +// 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. + +#ifndef CEF_TESTS_CEFCLIENT_BINDING_TEST_H_ +#define CEF_TESTS_CEFCLIENT_BINDING_TEST_H_ +#pragma once + +#include "cefclient/client_handler.h" + +namespace binding_test { + +// Delegate creation. Called from ClientHandler. +void CreateProcessMessageDelegates( + ClientHandler::ProcessMessageDelegateSet& delegates); + +} // namespace binding_test + +#endif // CEF_TESTS_CEFCLIENT_BINDING_TEST_H_ diff --git a/cef3/tests/cefclient/cefclient.cpp b/cef3/tests/cefclient/cefclient.cpp new file mode 100644 index 000000000..e41e993c0 --- /dev/null +++ b/cef3/tests/cefclient/cefclient.cpp @@ -0,0 +1,183 @@ +// Copyright (c) 2013 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/cefclient.h" +#include +#include +#include +#include +#include "include/cef_app.h" +#include "include/cef_browser.h" +#include "include/cef_command_line.h" +#include "include/cef_frame.h" +#include "include/cef_runnable.h" +#include "include/cef_web_plugin.h" +#include "cefclient/client_handler.h" +#include "cefclient/client_switches.h" +#include "cefclient/string_util.h" +#include "cefclient/util.h" + +CefRefPtr g_handler; +CefRefPtr g_command_line; + +CefRefPtr AppGetBrowser() { + if (!g_handler.get()) + return NULL; + return g_handler->GetBrowser(); +} + +CefWindowHandle AppGetMainHwnd() { + if (!g_handler.get()) + return NULL; + return g_handler->GetMainHwnd(); +} + +void AppInitCommandLine(int argc, const char* const* argv) { + g_command_line = CefCommandLine::CreateCommandLine(); +#if defined(OS_WIN) + g_command_line->InitFromString(::GetCommandLineW()); +#else + g_command_line->InitFromArgv(argc, argv); +#endif +} + +// Returns the application command line object. +CefRefPtr AppGetCommandLine() { + return g_command_line; +} + +// Returns the application settings based on command line arguments. +void AppGetSettings(CefSettings& settings) { + ASSERT(g_command_line.get()); + if (!g_command_line.get()) + return; + + CefString str; + +#if defined(OS_WIN) + settings.multi_threaded_message_loop = + g_command_line->HasSwitch(cefclient::kMultiThreadedMessageLoop); +#endif + + CefString(&settings.cache_path) = + g_command_line->GetSwitchValue(cefclient::kCachePath); + + // Specify a port to enable DevTools if one isn't already specified. + if (!g_command_line->HasSwitch("remote-debugging-port")) + settings.remote_debugging_port = 8088; +} + +bool AppIsOffScreenRenderingEnabled() { + ASSERT(g_command_line.get()); + if (!g_command_line.get()) + return false; + + return g_command_line->HasSwitch(cefclient::kOffScreenRenderingEnabled); +} + +void RunGetSourceTest(CefRefPtr browser) { + class Visitor : public CefStringVisitor { + public: + explicit Visitor(CefRefPtr browser) : browser_(browser) {} + virtual void Visit(const CefString& string) OVERRIDE { + std::string source = StringReplace(string, "<", "<"); + source = StringReplace(source, ">", ">"); + std::stringstream ss; + ss << "Source:
" << source << "
"; + browser_->GetMainFrame()->LoadString(ss.str(), "http://tests/getsource"); + } + private: + CefRefPtr browser_; + IMPLEMENT_REFCOUNTING(Visitor); + }; + + browser->GetMainFrame()->GetSource(new Visitor(browser)); +} + +void RunGetTextTest(CefRefPtr browser) { + class Visitor : public CefStringVisitor { + public: + explicit Visitor(CefRefPtr browser) : browser_(browser) {} + virtual void Visit(const CefString& string) OVERRIDE { + std::string text = StringReplace(string, "<", "<"); + text = StringReplace(text, ">", ">"); + std::stringstream ss; + ss << "Text:
" << text << "
"; + browser_->GetMainFrame()->LoadString(ss.str(), "http://tests/gettext"); + } + private: + CefRefPtr browser_; + IMPLEMENT_REFCOUNTING(Visitor); + }; + + browser->GetMainFrame()->GetText(new Visitor(browser)); +} + +void RunRequestTest(CefRefPtr browser) { + // Create a new request + CefRefPtr request(CefRequest::Create()); + + // Set the request URL + request->SetURL("http://tests/request"); + + // Add post data to the request. The correct method and content- + // type headers will be set by CEF. + CefRefPtr postDataElement(CefPostDataElement::Create()); + std::string data = "arg1=val1&arg2=val2"; + postDataElement->SetToBytes(data.length(), data.c_str()); + CefRefPtr postData(CefPostData::Create()); + postData->AddElement(postDataElement); + request->SetPostData(postData); + + // Add a custom header + CefRequest::HeaderMap headerMap; + headerMap.insert( + std::make_pair("X-My-Header", "My Header Value")); + request->SetHeaderMap(headerMap); + + // Load the request + browser->GetMainFrame()->LoadRequest(request); +} + +void RunPopupTest(CefRefPtr browser) { + browser->GetMainFrame()->ExecuteJavaScript( + "window.open('http://www.google.com');", "about:blank", 0); +} + +void RunPluginInfoTest(CefRefPtr browser) { + class Visitor : public CefWebPluginInfoVisitor { + public: + explicit Visitor(CefRefPtr browser) + : browser_(browser) { + html_ = "Plugin Info Test" + "\nInstalled plugins:"; + } + ~Visitor() { + html_ += "\n"; + + // Load the html in the browser. + browser_->GetMainFrame()->LoadString(html_, "http://tests/plugin_info"); + } + + virtual bool Visit(CefRefPtr info, int count, int total) + OVERRIDE { + html_ += "\n

Name: " + info->GetName().ToString() + + "\n
Description: " + info->GetDescription().ToString() + + "\n
Version: " + info->GetVersion().ToString() + + "\n
Path: " + info->GetPath().ToString(); + return true; + } + + private: + std::string html_; + CefRefPtr browser_; + IMPLEMENT_REFCOUNTING(Visitor); + }; + + CefVisitWebPluginInfo(new Visitor(browser)); +} + +void RunOtherTests(CefRefPtr browser) { + browser->GetMainFrame()->LoadURL("http://tests/other_tests"); +} diff --git a/cef3/tests/cefclient/cefclient.h b/cef3/tests/cefclient/cefclient.h new file mode 100644 index 000000000..d04046dd3 --- /dev/null +++ b/cef3/tests/cefclient/cefclient.h @@ -0,0 +1,54 @@ +// Copyright (c) 2013 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_CEFCLIENT_H_ +#define CEF_TESTS_CEFCLIENT_CEFCLIENT_H_ +#pragma once + +#include +#include "include/cef_base.h" +#include "cefclient/client_app.h" + +class CefApp; +class CefBrowser; +class CefCommandLine; + +// Returns the main browser window instance. +CefRefPtr AppGetBrowser(); + +// Returns the main application window handle. +CefWindowHandle AppGetMainHwnd(); + +// Returns the application working directory. +std::string AppGetWorkingDirectory(); + +// Initialize the application command line. +void AppInitCommandLine(int argc, const char* const* argv); + +// Returns the application command line object. +CefRefPtr AppGetCommandLine(); + +// Returns the application settings based on command line arguments. +void AppGetSettings(CefSettings& settings); + +// Returns true if off-screen rendering is enabled via the command line +// argument. +bool AppIsOffScreenRenderingEnabled(); + +// Quit the application message loop. +void AppQuitMessageLoop(); + +// Implementations for various tests. +void RunGetSourceTest(CefRefPtr browser); +void RunGetTextTest(CefRefPtr browser); +void RunRequestTest(CefRefPtr browser); +void RunPopupTest(CefRefPtr browser); +void RunPluginInfoTest(CefRefPtr browser); +void RunOtherTests(CefRefPtr browser); + +#if defined(OS_WIN) +void RunTransparentPopupTest(CefRefPtr browser); +#endif + +#endif // CEF_TESTS_CEFCLIENT_CEFCLIENT_H_ diff --git a/cef3/tests/cefclient/cefclient.rc b/cef3/tests/cefclient/cefclient.rc new file mode 100644 index 000000000..61e0d43da --- /dev/null +++ b/cef3/tests/cefclient/cefclient.rc @@ -0,0 +1,167 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#define APSTUDIO_HIDDEN_SYMBOLS +#include "windows.h" +#undef APSTUDIO_HIDDEN_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Binary +// + +IDS_BINDING BINARY "res\\binding.html" +IDS_DIALOGS BINARY "res\\dialogs.html" +IDS_DOMACCESS BINARY "res\\domaccess.html" +IDS_LOCALSTORAGE BINARY "res\\localstorage.html" +IDS_LOGO BINARY "res\\logo.png" +IDS_OTHER_TESTS BINARY "res\\other_tests.html" +IDS_PERFORMANCE BINARY "res\\performance.html" +IDS_TRANSPARENCY BINARY "res\\transparency.html" +IDS_WINDOW BINARY "res\\window.html" +IDS_XMLHTTPREQUEST BINARY "res\\xmlhttprequest.html" + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_CEFCLIENT ICON "res\cefclient.ico" +IDI_SMALL ICON "res\small.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDC_CEFCLIENT MENU +BEGIN + POPUP "&File" + BEGIN + MENUITEM "E&xit", IDM_EXIT + END + POPUP "&Help" + BEGIN + MENUITEM "&About ...", IDM_ABOUT + END + POPUP "Tests" + BEGIN + MENUITEM "Get Source", ID_TESTS_GETSOURCE + MENUITEM "Get Text", ID_TESTS_GETTEXT + MENUITEM "Popup Window", ID_TESTS_POPUP + MENUITEM "Request", ID_TESTS_REQUEST + MENUITEM "Plugin Info", ID_TESTS_PLUGIN_INFO + MENUITEM "Zoom In", ID_TESTS_ZOOM_IN + MENUITEM "Zoom Out", ID_TESTS_ZOOM_OUT + MENUITEM "Zoom Reset", ID_TESTS_ZOOM_RESET + MENUITEM "Begin Tracing", ID_TESTS_TRACING_BEGIN + MENUITEM "End Tracing", ID_TESTS_TRACING_END + MENUITEM "Other Tests", ID_TESTS_OTHER_TESTS + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDC_CEFCLIENT ACCELERATORS +BEGIN + "?", IDM_ABOUT, ASCII, ALT + "/", IDM_ABOUT, ASCII, ALT +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ABOUTBOX DIALOG 22, 17, 230, 75 +STYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU +CAPTION "About" +FONT 8, "System" +BEGIN + ICON IDI_CEFCLIENT,IDC_MYICON,14,9,16,16 + LTEXT "cefclient Version 1.0",IDC_STATIC,49,10,119,8,SS_NOPREFIX + LTEXT "Copyright (C) 2008",IDC_STATIC,49,20,119,8 + DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""windows.h""\r\n" + "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + IDS_APP_TITLE "cefclient" + IDC_CEFCLIENT "CEFCLIENT" + IDS_OSR_WIDGET_CLASS "CEFCLIENT-OSR-WIDGET" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/cef3/tests/cefclient/cefclient_gtk.cpp b/cef3/tests/cefclient/cefclient_gtk.cpp new file mode 100644 index 000000000..f7c658bd5 --- /dev/null +++ b/cef3/tests/cefclient/cefclient_gtk.cpp @@ -0,0 +1,355 @@ +// Copyright (c) 2013 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 +#include +#include +#include +#include "cefclient/cefclient.h" +#include "include/cef_app.h" +#include "include/cef_browser.h" +#include "include/cef_frame.h" +#include "include/cef_runnable.h" +#include "cefclient/client_handler.h" +#include "cefclient/scheme_test.h" +#include "cefclient/string_util.h" + +char szWorkingDir[512]; // The current working directory + +// The global ClientHandler reference. +extern CefRefPtr g_handler; + +void destroy(GtkWidget* widget, gpointer data) { + // Quitting CEF is handled in ClientHandler::OnBeforeClose(). +} + +gboolean delete_event(GtkWidget* widget, GdkEvent* event, + GtkWindow* window) { + if (g_handler.get() && !g_handler->IsClosing()) { + CefRefPtr browser = g_handler->GetBrowser(); + if (browser.get()) { + // Notify the browser window that we would like to close it. This + // will result in a call to ClientHandler::DoClose() if the + // JavaScript 'onbeforeunload' event handler allows it. + browser->GetHost()->CloseBrowser(false); + + // Cancel the close. + return TRUE; + } + } + + // Allow the close. + return FALSE; +} + +void TerminationSignalHandler(int signatl) { + AppQuitMessageLoop(); +} + +// Callback for Tests > Get Source... menu item. +gboolean GetSourceActivated(GtkWidget* widget) { + if (g_handler.get() && g_handler->GetBrowserId()) + RunGetSourceTest(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + +// Callback for Tests > Get Text... menu item. +gboolean GetTextActivated(GtkWidget* widget) { + if (g_handler.get() && g_handler->GetBrowserId()) + RunGetTextTest(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + +// Callback for Tests > Popup Window... menu item. +gboolean PopupWindowActivated(GtkWidget* widget) { + if (g_handler.get() && g_handler->GetBrowserId()) + RunPopupTest(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + +// Callback for Tests > Request... menu item. +gboolean RequestActivated(GtkWidget* widget) { + if (g_handler.get() && g_handler->GetBrowserId()) + RunRequestTest(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + +// Callback for Tests > Plugin Info... menu item. +gboolean PluginInfoActivated(GtkWidget* widget) { + if (g_handler.get() && g_handler->GetBrowserId()) + RunPluginInfoTest(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + +// Callback for Tests > Zoom In... menu item. +gboolean ZoomInActivated(GtkWidget* widget) { + if (g_handler.get() && g_handler->GetBrowserId()) { + CefRefPtr browser = g_handler->GetBrowser(); + browser->GetHost()->SetZoomLevel(browser->GetHost()->GetZoomLevel() + 0.5); + } + + return FALSE; // Don't stop this message. +} + +// Callback for Tests > Zoom Out... menu item. +gboolean ZoomOutActivated(GtkWidget* widget) { + if (g_handler.get() && g_handler->GetBrowserId()) { + CefRefPtr browser = g_handler->GetBrowser(); + browser->GetHost()->SetZoomLevel(browser->GetHost()->GetZoomLevel() - 0.5); + } + + return FALSE; // Don't stop this message. +} + +// Callback for Tests > Zoom Reset... menu item. +gboolean ZoomResetActivated(GtkWidget* widget) { + if (g_handler.get() && g_handler->GetBrowserId()) { + CefRefPtr browser = g_handler->GetBrowser(); + browser->GetHost()->SetZoomLevel(0.0); + } + + return FALSE; // Don't stop this message. +} + +// Callback for Tests > Begin Tracing menu item. +gboolean BeginTracingActivated(GtkWidget* widget) { + if (g_handler.get()) + g_handler->BeginTracing(); + + return FALSE; // Don't stop this message. +} + +// Callback for Tests > End Tracing menu item. +gboolean EndTracingActivated(GtkWidget* widget) { + if (g_handler.get()) + g_handler->EndTracing(); + + return FALSE; // Don't stop this message. +} + +// Callback for Tests > Other Tests... menu item. +gboolean OtherTestsActivated(GtkWidget* widget) { + if (g_handler.get() && g_handler->GetBrowserId()) + RunOtherTests(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + +// Callback for when you click the back button. +void BackButtonClicked(GtkButton* button) { + if (g_handler.get() && g_handler->GetBrowserId()) + g_handler->GetBrowser()->GoBack(); +} + +// Callback for when you click the forward button. +void ForwardButtonClicked(GtkButton* button) { + if (g_handler.get() && g_handler->GetBrowserId()) + g_handler->GetBrowser()->GoForward(); +} + +// Callback for when you click the stop button. +void StopButtonClicked(GtkButton* button) { + if (g_handler.get() && g_handler->GetBrowserId()) + g_handler->GetBrowser()->StopLoad(); +} + +// Callback for when you click the reload button. +void ReloadButtonClicked(GtkButton* button) { + if (g_handler.get() && g_handler->GetBrowserId()) + g_handler->GetBrowser()->Reload(); +} + +// Callback for when you press enter in the URL box. +void URLEntryActivate(GtkEntry* entry) { + if (!g_handler.get() || !g_handler->GetBrowserId()) + return; + + const gchar* url = gtk_entry_get_text(entry); + g_handler->GetBrowser()->GetMainFrame()->LoadURL(std::string(url).c_str()); +} + +// GTK utility functions ---------------------------------------------- + +GtkWidget* AddMenuEntry(GtkWidget* menu_widget, const char* text, + GCallback callback) { + GtkWidget* entry = gtk_menu_item_new_with_label(text); + g_signal_connect(entry, "activate", callback, NULL); + gtk_menu_shell_append(GTK_MENU_SHELL(menu_widget), entry); + return entry; +} + +GtkWidget* CreateMenu(GtkWidget* menu_bar, const char* text) { + GtkWidget* menu_widget = gtk_menu_new(); + GtkWidget* menu_header = gtk_menu_item_new_with_label(text); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_header), menu_widget); + gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), menu_header); + return menu_widget; +} + +GtkWidget* CreateMenuBar() { + GtkWidget* menu_bar = gtk_menu_bar_new(); + GtkWidget* debug_menu = CreateMenu(menu_bar, "Tests"); + + AddMenuEntry(debug_menu, "Get Source", + G_CALLBACK(GetSourceActivated)); + AddMenuEntry(debug_menu, "Get Text", + G_CALLBACK(GetTextActivated)); + AddMenuEntry(debug_menu, "Popup Window", + G_CALLBACK(PopupWindowActivated)); + AddMenuEntry(debug_menu, "Request", + G_CALLBACK(RequestActivated)); + AddMenuEntry(debug_menu, "Plugin Info", + G_CALLBACK(PluginInfoActivated)); + AddMenuEntry(debug_menu, "Zoom In", + G_CALLBACK(ZoomInActivated)); + AddMenuEntry(debug_menu, "Zoom Out", + G_CALLBACK(ZoomOutActivated)); + AddMenuEntry(debug_menu, "Zoom Reset", + G_CALLBACK(ZoomResetActivated)); + AddMenuEntry(debug_menu, "Begin Tracing", + G_CALLBACK(BeginTracingActivated)); + AddMenuEntry(debug_menu, "End Tracing", + G_CALLBACK(EndTracingActivated)); + AddMenuEntry(debug_menu, "Other Tests", + G_CALLBACK(OtherTestsActivated)); + return menu_bar; +} + +// WebViewDelegate::TakeFocus in the test webview delegate. +static gboolean HandleFocus(GtkWidget* widget, + GdkEventFocus* focus) { + if (g_handler.get() && g_handler->GetBrowserId()) { + // Give focus to the browser window. + g_handler->GetBrowser()->GetHost()->SetFocus(true); + } + + return TRUE; +} + +int main(int argc, char* argv[]) { + CefMainArgs main_args(argc, argv); + CefRefPtr app(new ClientApp); + + // Execute the secondary process, if any. + int exit_code = CefExecuteProcess(main_args, app.get()); + if (exit_code >= 0) + return exit_code; + + if (!getcwd(szWorkingDir, sizeof (szWorkingDir))) + return -1; + + GtkWidget* window; + + gtk_init(&argc, &argv); + + // Parse command line arguments. + AppInitCommandLine(argc, argv); + + CefSettings settings; + + // Populate the settings based on command line arguments. + AppGetSettings(settings); + + // Initialize CEF. + CefInitialize(main_args, settings, app.get()); + + // Register the scheme handler. + scheme_test::InitTest(); + + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_default_size(GTK_WINDOW(window), 800, 600); + + g_signal_connect(window, "focus", G_CALLBACK(&HandleFocus), NULL); + + GtkWidget* vbox = gtk_vbox_new(FALSE, 0); + + GtkWidget* menu_bar = CreateMenuBar(); + + gtk_box_pack_start(GTK_BOX(vbox), menu_bar, FALSE, FALSE, 0); + + GtkWidget* toolbar = gtk_toolbar_new(); + // Turn off the labels on the toolbar buttons. + gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS); + + GtkToolItem* back = gtk_tool_button_new_from_stock(GTK_STOCK_GO_BACK); + g_signal_connect(back, "clicked", + G_CALLBACK(BackButtonClicked), NULL); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), back, -1 /* append */); + + GtkToolItem* forward = gtk_tool_button_new_from_stock(GTK_STOCK_GO_FORWARD); + g_signal_connect(forward, "clicked", + G_CALLBACK(ForwardButtonClicked), NULL); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), forward, -1 /* append */); + + GtkToolItem* reload = gtk_tool_button_new_from_stock(GTK_STOCK_REFRESH); + g_signal_connect(reload, "clicked", + G_CALLBACK(ReloadButtonClicked), NULL); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), reload, -1 /* append */); + + GtkToolItem* stop = gtk_tool_button_new_from_stock(GTK_STOCK_STOP); + g_signal_connect(stop, "clicked", + G_CALLBACK(StopButtonClicked), NULL); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), stop, -1 /* append */); + + GtkWidget* m_editWnd = gtk_entry_new(); + g_signal_connect(G_OBJECT(m_editWnd), "activate", + G_CALLBACK(URLEntryActivate), NULL); + + GtkToolItem* tool_item = gtk_tool_item_new(); + gtk_container_add(GTK_CONTAINER(tool_item), m_editWnd); + gtk_tool_item_set_expand(tool_item, TRUE); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tool_item, -1); // append + + gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); + + g_signal_connect(G_OBJECT(window), "destroy", + G_CALLBACK(destroy), NULL); + g_signal_connect(G_OBJECT(window), "delete_event", + G_CALLBACK(delete_event), window); + + // Create the handler. + g_handler = new ClientHandler(); + g_handler->SetMainHwnd(vbox); + g_handler->SetEditHwnd(m_editWnd); + g_handler->SetButtonHwnds(GTK_WIDGET(back), GTK_WIDGET(forward), + GTK_WIDGET(reload), GTK_WIDGET(stop)); + + // Create the browser view. + CefWindowInfo window_info; + CefBrowserSettings browserSettings; + + window_info.SetAsChild(vbox); + + CefBrowserHost::CreateBrowserSync( + window_info, g_handler.get(), + g_handler->GetStartupURL(), browserSettings); + + gtk_container_add(GTK_CONTAINER(window), vbox); + gtk_widget_show_all(GTK_WIDGET(window)); + + // Install an signal handler so we clean up after ourselves. + signal(SIGINT, TerminationSignalHandler); + signal(SIGTERM, TerminationSignalHandler); + + CefRunMessageLoop(); + + CefShutdown(); + + return 0; +} + +// Global functions + +std::string AppGetWorkingDirectory() { + return szWorkingDir; +} + +void AppQuitMessageLoop() { + CefQuitMessageLoop(); +} diff --git a/cef3/tests/cefclient/cefclient_mac.mm b/cef3/tests/cefclient/cefclient_mac.mm new file mode 100644 index 000000000..09d8b0cb0 --- /dev/null +++ b/cef3/tests/cefclient/cefclient_mac.mm @@ -0,0 +1,495 @@ +// Copyright (c) 2013 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import +#include +#include "cefclient/cefclient.h" +#include "include/cef_app.h" +#import "include/cef_application_mac.h" +#include "include/cef_browser.h" +#include "include/cef_frame.h" +#include "include/cef_runnable.h" +#include "cefclient/client_handler.h" +#include "cefclient/resource_util.h" +#include "cefclient/scheme_test.h" +#include "cefclient/string_util.h" + +// The global ClientHandler reference. +extern CefRefPtr g_handler; + +char szWorkingDir[512]; // The current working directory + +// Sizes for URL bar layout +#define BUTTON_HEIGHT 22 +#define BUTTON_WIDTH 72 +#define BUTTON_MARGIN 8 +#define URLBAR_HEIGHT 32 + +// Content area size for newly created windows. +const int kWindowWidth = 800; +const int kWindowHeight = 600; + +// Provide the CefAppProtocol implementation required by CEF. +@interface ClientApplication : NSApplication { +@private + BOOL handlingSendEvent_; +} +@end + +@implementation ClientApplication +- (BOOL)isHandlingSendEvent { + return handlingSendEvent_; +} + +- (void)setHandlingSendEvent:(BOOL)handlingSendEvent { + handlingSendEvent_ = handlingSendEvent; +} + +- (void)sendEvent:(NSEvent*)event { + CefScopedSendingEvent sendingEventScoper; + [super sendEvent:event]; +} +@end + + +// Receives notifications from controls and the browser window. Will delete +// itself when done. +@interface ClientWindowDelegate : NSObject +- (IBAction)goBack:(id)sender; +- (IBAction)goForward:(id)sender; +- (IBAction)reload:(id)sender; +- (IBAction)stopLoading:(id)sender; +- (IBAction)takeURLStringValueFrom:(NSTextField *)sender; +- (void)alert:(NSString*)title withMessage:(NSString*)message; +- (void)notifyConsoleMessage:(id)object; +- (void)notifyDownloadComplete:(id)object; +- (void)notifyDownloadError:(id)object; +@end + +@implementation ClientWindowDelegate + +- (IBAction)goBack:(id)sender { + if (g_handler.get() && g_handler->GetBrowserId()) + g_handler->GetBrowser()->GoBack(); +} + +- (IBAction)goForward:(id)sender { + if (g_handler.get() && g_handler->GetBrowserId()) + g_handler->GetBrowser()->GoForward(); +} + +- (IBAction)reload:(id)sender { + if (g_handler.get() && g_handler->GetBrowserId()) + g_handler->GetBrowser()->Reload(); +} + +- (IBAction)stopLoading:(id)sender { + if (g_handler.get() && g_handler->GetBrowserId()) + g_handler->GetBrowser()->StopLoad(); +} + +- (IBAction)takeURLStringValueFrom:(NSTextField *)sender { + if (!g_handler.get() || !g_handler->GetBrowserId()) + return; + + NSString *url = [sender stringValue]; + + // if it doesn't already have a prefix, add http. If we can't parse it, + // just don't bother rather than making things worse. + NSURL* tempUrl = [NSURL URLWithString:url]; + if (tempUrl && ![tempUrl scheme]) + url = [@"http://" stringByAppendingString:url]; + + std::string urlStr = [url UTF8String]; + g_handler->GetBrowser()->GetMainFrame()->LoadURL(urlStr); +} + +- (void)alert:(NSString*)title withMessage:(NSString*)message { + NSAlert *alert = [NSAlert alertWithMessageText:title + defaultButton:@"OK" + alternateButton:nil + otherButton:nil + informativeTextWithFormat:message]; + [alert runModal]; +} + +- (void)notifyConsoleMessage:(id)object { + std::stringstream ss; + ss << "Console messages will be written to " << g_handler->GetLogFile(); + NSString* str = [NSString stringWithUTF8String:(ss.str().c_str())]; + [self alert:@"Console Messages" withMessage:str]; +} + +- (void)notifyDownloadComplete:(id)object { + std::stringstream ss; + ss << "File \"" << g_handler->GetLastDownloadFile() << + "\" downloaded successfully."; + NSString* str = [NSString stringWithUTF8String:(ss.str().c_str())]; + [self alert:@"File Download" withMessage:str]; +} + +- (void)notifyDownloadError:(id)object { + std::stringstream ss; + ss << "File \"" << g_handler->GetLastDownloadFile() << + "\" failed to download."; + NSString* str = [NSString stringWithUTF8String:(ss.str().c_str())]; + [self alert:@"File Download" withMessage:str]; +} + +- (void)windowDidBecomeKey:(NSNotification*)notification { + if (g_handler.get() && g_handler->GetBrowserId()) { + // Give focus to the browser window. + g_handler->GetBrowser()->GetHost()->SetFocus(true); + } +} + +// Called when the window is about to close. Perform the self-destruction +// sequence by getting rid of the window. By returning YES, we allow the window +// to be removed from the screen. +- (BOOL)windowShouldClose:(id)window { + if (g_handler.get() && !g_handler->IsClosing()) { + CefRefPtr browser = g_handler->GetBrowser(); + if (browser.get()) { + // Notify the browser window that we would like to close it. This + // will result in a call to ClientHandler::DoClose() if the + // JavaScript 'onbeforeunload' event handler allows it. + browser->GetHost()->CloseBrowser(false); + + // Cancel the close. + return NO; + } + } + + // Try to make the window go away. + [window autorelease]; + + // Clean ourselves up after clearing the stack of anything that might have the + // window on it. + [self performSelectorOnMainThread:@selector(cleanup:) + withObject:window + waitUntilDone:NO]; + + // Allow the close. + return YES; +} + +// Deletes itself. +- (void)cleanup:(id)window { + [self release]; +} + +@end + + +NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) { + NSButton* button = [[[NSButton alloc] initWithFrame:*rect] autorelease]; + [button setTitle:title]; + [button setBezelStyle:NSSmallSquareBezelStyle]; + [button setAutoresizingMask:(NSViewMaxXMargin | NSViewMinYMargin)]; + [parent addSubview:button]; + rect->origin.x += BUTTON_WIDTH; + return button; +} + +// Receives notifications from the application. Will delete itself when done. +@interface ClientAppDelegate : NSObject +- (void)createApp:(id)object; +- (IBAction)testGetSource:(id)sender; +- (IBAction)testGetText:(id)sender; +- (IBAction)testPopupWindow:(id)sender; +- (IBAction)testRequest:(id)sender; +- (IBAction)testPluginInfo:(id)sender; +- (IBAction)testZoomIn:(id)sender; +- (IBAction)testZoomOut:(id)sender; +- (IBAction)testZoomReset:(id)sender; +- (IBAction)testBeginTracing:(id)sender; +- (IBAction)testEndTracing:(id)sender; +- (IBAction)testOtherTests:(id)sender; +@end + +@implementation ClientAppDelegate + +// Create the application on the UI thread. +- (void)createApp:(id)object { + [NSApplication sharedApplication]; + [NSBundle loadNibNamed:@"MainMenu" owner:NSApp]; + + // Set the delegate for application events. + [NSApp setDelegate:self]; + + // Add the Tests menu. + NSMenu* menubar = [NSApp mainMenu]; + NSMenuItem *testItem = [[[NSMenuItem alloc] initWithTitle:@"Tests" + action:nil + keyEquivalent:@""] autorelease]; + NSMenu *testMenu = [[[NSMenu alloc] initWithTitle:@"Tests"] autorelease]; + [testMenu addItemWithTitle:@"Get Source" + action:@selector(testGetSource:) + keyEquivalent:@""]; + [testMenu addItemWithTitle:@"Get Text" + action:@selector(testGetText:) + keyEquivalent:@""]; + [testMenu addItemWithTitle:@"Popup Window" + action:@selector(testPopupWindow:) + keyEquivalent:@""]; + [testMenu addItemWithTitle:@"Request" + action:@selector(testRequest:) + keyEquivalent:@""]; + [testMenu addItemWithTitle:@"Plugin Info" + action:@selector(testPluginInfo:) + keyEquivalent:@""]; + [testMenu addItemWithTitle:@"Zoom In" + action:@selector(testZoomIn:) + keyEquivalent:@""]; + [testMenu addItemWithTitle:@"Zoom Out" + action:@selector(testZoomOut:) + keyEquivalent:@""]; + [testMenu addItemWithTitle:@"Zoom Reset" + action:@selector(testZoomReset:) + keyEquivalent:@""]; + [testMenu addItemWithTitle:@"Begin Tracing" + action:@selector(testBeginTracing:) + keyEquivalent:@""]; + [testMenu addItemWithTitle:@"End Tracing" + action:@selector(testEndTracing:) + keyEquivalent:@""]; + [testMenu addItemWithTitle:@"Other Tests" + action:@selector(testOtherTests:) + keyEquivalent:@""]; + [testItem setSubmenu:testMenu]; + [menubar addItem:testItem]; + + // Create the delegate for control and browser window events. + ClientWindowDelegate* delegate = [[ClientWindowDelegate alloc] init]; + + // Create the main application window. + NSRect screen_rect = [[NSScreen mainScreen] visibleFrame]; + NSRect window_rect = { {0, screen_rect.size.height - kWindowHeight}, + {kWindowWidth, kWindowHeight} }; + NSWindow* mainWnd = [[UnderlayOpenGLHostingWindow alloc] + initWithContentRect:window_rect + styleMask:(NSTitledWindowMask | + NSClosableWindowMask | + NSMiniaturizableWindowMask | + NSResizableWindowMask ) + backing:NSBackingStoreBuffered + defer:NO]; + [mainWnd setTitle:@"cefclient"]; + [mainWnd setDelegate:delegate]; + + // Rely on the window delegate to clean us up rather than immediately + // releasing when the window gets closed. We use the delegate to do + // everything from the autorelease pool so the window isn't on the stack + // during cleanup (ie, a window close from javascript). + [mainWnd setReleasedWhenClosed:NO]; + + NSView* contentView = [mainWnd contentView]; + + // Create the buttons. + NSRect button_rect = [contentView bounds]; + button_rect.origin.y = window_rect.size.height - URLBAR_HEIGHT + + (URLBAR_HEIGHT - BUTTON_HEIGHT) / 2; + button_rect.size.height = BUTTON_HEIGHT; + button_rect.origin.x += BUTTON_MARGIN; + button_rect.size.width = BUTTON_WIDTH; + + NSButton* button = MakeButton(&button_rect, @"Back", contentView); + [button setTarget:delegate]; + [button setAction:@selector(goBack:)]; + + button = MakeButton(&button_rect, @"Forward", contentView); + [button setTarget:delegate]; + [button setAction:@selector(goForward:)]; + + button = MakeButton(&button_rect, @"Reload", contentView); + [button setTarget:delegate]; + [button setAction:@selector(reload:)]; + + button = MakeButton(&button_rect, @"Stop", contentView); + [button setTarget:delegate]; + [button setAction:@selector(stopLoading:)]; + + // Create the URL text field. + button_rect.origin.x += BUTTON_MARGIN; + button_rect.size.width = [contentView bounds].size.width - + button_rect.origin.x - BUTTON_MARGIN; + NSTextField* editWnd = [[NSTextField alloc] initWithFrame:button_rect]; + [contentView addSubview:editWnd]; + [editWnd setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)]; + [editWnd setTarget:delegate]; + [editWnd setAction:@selector(takeURLStringValueFrom:)]; + [[editWnd cell] setWraps:NO]; + [[editWnd cell] setScrollable:YES]; + + // Create the handler. + g_handler = new ClientHandler(); + g_handler->SetMainHwnd(contentView); + g_handler->SetEditHwnd(editWnd); + + // Create the browser view. + CefWindowInfo window_info; + CefBrowserSettings settings; + + window_info.SetAsChild(contentView, 0, 0, kWindowWidth, kWindowHeight); + CefBrowserHost::CreateBrowser(window_info, g_handler.get(), + g_handler->GetStartupURL(), settings); + + // Show the window. + [mainWnd makeKeyAndOrderFront: nil]; + + // Size the window. + NSRect r = [mainWnd contentRectForFrameRect:[mainWnd frame]]; + r.size.width = kWindowWidth; + r.size.height = kWindowHeight + URLBAR_HEIGHT; + [mainWnd setFrame:[mainWnd frameRectForContentRect:r] display:YES]; +} + +- (IBAction)testGetSource:(id)sender { + if (g_handler.get() && g_handler->GetBrowserId()) + RunGetSourceTest(g_handler->GetBrowser()); +} + +- (IBAction)testGetText:(id)sender { + if (g_handler.get() && g_handler->GetBrowserId()) + RunGetTextTest(g_handler->GetBrowser()); +} + +- (IBAction)testPopupWindow:(id)sender { + if (g_handler.get() && g_handler->GetBrowserId()) + RunPopupTest(g_handler->GetBrowser()); +} + +- (IBAction)testRequest:(id)sender { + if (g_handler.get() && g_handler->GetBrowserId()) + RunRequestTest(g_handler->GetBrowser()); +} + +- (IBAction)testPluginInfo:(id)sender { + if (g_handler.get() && g_handler->GetBrowserId()) + RunPluginInfoTest(g_handler->GetBrowser()); +} + +- (IBAction)testZoomIn:(id)sender { + if (g_handler.get() && g_handler->GetBrowserId()) { + CefRefPtr browser = g_handler->GetBrowser(); + browser->GetHost()->SetZoomLevel(browser->GetHost()->GetZoomLevel() + 0.5); + } +} + +- (IBAction)testZoomOut:(id)sender { + if (g_handler.get() && g_handler->GetBrowserId()) { + CefRefPtr browser = g_handler->GetBrowser(); + browser->GetHost()->SetZoomLevel(browser->GetHost()->GetZoomLevel() - 0.5); + } +} + +- (IBAction)testZoomReset:(id)sender { + if (g_handler.get() && g_handler->GetBrowserId()) { + CefRefPtr browser = g_handler->GetBrowser(); + browser->GetHost()->SetZoomLevel(0.0); + } +} + +- (IBAction)testBeginTracing:(id)sender { + if (g_handler.get()) + g_handler->BeginTracing(); +} + +- (IBAction)testEndTracing:(id)sender { + if (g_handler.get()) + g_handler->EndTracing(); +} + +- (IBAction)testOtherTests:(id)sender { + if (g_handler.get() && g_handler->GetBrowserId()) + RunOtherTests(g_handler->GetBrowser()); +} + +// Called when the application’s Quit menu item is selected. +- (NSApplicationTerminateReply)applicationShouldTerminate: + (NSApplication *)sender { + // Request that all browser windows close. + if (g_handler.get()) + g_handler->CloseAllBrowsers(false); + + // Cancel the termination. The application will exit after all windows have + // closed. + return NSTerminateCancel; +} + +// Sent immediately before the application terminates. This signal should not +// be called because we cancel the termination. +- (void)applicationWillTerminate:(NSNotification *)aNotification { + ASSERT(false); // Not reached. +} + +@end + + +int main(int argc, char* argv[]) { + CefMainArgs main_args(argc, argv); + CefRefPtr app(new ClientApp); + + // Execute the secondary process, if any. + int exit_code = CefExecuteProcess(main_args, app.get()); + if (exit_code >= 0) + return exit_code; + + // Retrieve the current working directory. + getcwd(szWorkingDir, sizeof(szWorkingDir)); + + // Initialize the AutoRelease pool. + NSAutoreleasePool* autopool = [[NSAutoreleasePool alloc] init]; + + // Initialize the ClientApplication instance. + [ClientApplication sharedApplication]; + + // Parse command line arguments. + AppInitCommandLine(argc, argv); + + CefSettings settings; + + // Populate the settings based on command line arguments. + AppGetSettings(settings); + + // Initialize CEF. + CefInitialize(main_args, settings, app.get()); + + // Register the scheme handler. + scheme_test::InitTest(); + + // Create the application delegate and window. + NSObject* delegate = [[ClientAppDelegate alloc] init]; + [delegate performSelectorOnMainThread:@selector(createApp:) withObject:nil + waitUntilDone:NO]; + + // Run the application message loop. + CefRunMessageLoop(); + + // Shut down CEF. + CefShutdown(); + + // Release the handler. + g_handler = NULL; + + // Release the delegate. + [delegate release]; + + // Release the AutoRelease pool. + [autopool release]; + + return 0; +} + + +// Global functions + +std::string AppGetWorkingDirectory() { + return szWorkingDir; +} + +void AppQuitMessageLoop() { + CefQuitMessageLoop(); +} diff --git a/cef3/tests/cefclient/cefclient_osr_widget_win.cpp b/cef3/tests/cefclient/cefclient_osr_widget_win.cpp new file mode 100644 index 000000000..14709c59f --- /dev/null +++ b/cef3/tests/cefclient/cefclient_osr_widget_win.cpp @@ -0,0 +1,654 @@ +// 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 "cefclient/cefclient_osr_widget_win.h" + +#include + +#include "include/cef_runnable.h" +#include "cefclient/resource.h" +#include "cefclient/util.h" + +// static +CefRefPtr OSRWindow::Create(OSRBrowserProvider* browser_provider, + bool transparent) { + ASSERT(browser_provider); + if (!browser_provider) + return NULL; + + return new OSRWindow(browser_provider, transparent); +} + +// static +CefRefPtr OSRWindow::From( + CefRefPtr renderHandler) { + return static_cast(renderHandler.get()); +} + +bool OSRWindow::CreateWidget(HWND hWndParent, const RECT& rect, + HINSTANCE hInst, LPCTSTR className) { + ASSERT(hWnd_ == NULL && hDC_ == NULL && hRC_ == NULL); + + RegisterOSRClass(hInst, className); + hWnd_ = ::CreateWindow(className, 0, + WS_BORDER | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE, + rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, + hWndParent, 0, hInst, 0); + + if (!hWnd_) + return false; + + SetWindowLongPtr(hWnd_, GWLP_USERDATA, reinterpret_cast(this)); + + // Reference released in OnDestroyed(). + AddRef(); + + return true; +} + +void OSRWindow::DestroyWidget() { + if (IsWindow(hWnd_)) + DestroyWindow(hWnd_); +} + +void OSRWindow::OnBeforeClose(CefRefPtr browser) { + DisableGL(); +} + +bool OSRWindow::GetRootScreenRect(CefRefPtr browser, + CefRect& rect) { + RECT window_rect = {0}; + HWND root_window = GetAncestor(hWnd_, GA_ROOT); + if (::GetWindowRect(root_window, &window_rect)) { + rect = CefRect(window_rect.left, + window_rect.top, + window_rect.right - window_rect.left, + window_rect.bottom - window_rect.top); + return true; + } + return false; +} + +bool OSRWindow::GetViewRect(CefRefPtr browser, + CefRect& rect) { + RECT clientRect; + if (!::GetClientRect(hWnd_, &clientRect)) + return false; + rect.x = rect.y = 0; + rect.width = clientRect.right; + rect.height = clientRect.bottom; + return true; +} + +bool OSRWindow::GetScreenPoint(CefRefPtr browser, + int viewX, + int viewY, + int& screenX, + int& screenY) { + if (!::IsWindow(hWnd_)) + return false; + + // Convert the point from view coordinates to actual screen coordinates. + POINT screen_pt = {viewX, viewY}; + ClientToScreen(hWnd_, &screen_pt); + screenX = screen_pt.x; + screenY = screen_pt.y; + return true; +} + +void OSRWindow::OnPopupShow(CefRefPtr browser, + bool show) { + renderer_.OnPopupShow(browser, show); +} + +void OSRWindow::OnPopupSize(CefRefPtr browser, + const CefRect& rect) { + renderer_.OnPopupSize(browser, rect); +} + +void OSRWindow::OnPaint(CefRefPtr browser, + PaintElementType type, + const RectList& dirtyRects, + const void* buffer, + int width, int height) { + if (painting_popup_) { + renderer_.OnPaint(browser, type, dirtyRects, buffer, width, height); + return; + } + if (!hDC_) + EnableGL(); + + wglMakeCurrent(hDC_, hRC_); + renderer_.OnPaint(browser, type, dirtyRects, buffer, width, height); + if (type == PET_VIEW && !renderer_.popup_rect().IsEmpty()) { + painting_popup_ = true; + CefRect client_popup_rect(0, 0, + renderer_.popup_rect().width, + renderer_.popup_rect().height); + browser->GetHost()->Invalidate(client_popup_rect, PET_POPUP); + painting_popup_ = false; + } + renderer_.Render(); + SwapBuffers(hDC_); +} + +void OSRWindow::OnCursorChange(CefRefPtr browser, + CefCursorHandle cursor) { + if (!::IsWindow(hWnd_)) + return; + + // Change the plugin window's cursor. + SetClassLong(hWnd_, GCL_HCURSOR, + static_cast(reinterpret_cast(cursor))); + SetCursor(cursor); +} + +void OSRWindow::Invalidate() { + if (!CefCurrentlyOn(TID_UI)) { + CefPostTask(TID_UI, NewCefRunnableMethod(this, &OSRWindow::Invalidate)); + return; + } + + // Don't post another task if the previous task is still pending. + if (render_task_pending_) + return; + + render_task_pending_ = true; + + // Render at 30fps. + static const int kRenderDelay = 1 / 30; + CefPostDelayedTask(TID_UI, NewCefRunnableMethod(this, &OSRWindow::Render), + kRenderDelay); +} + +OSRWindow::OSRWindow(OSRBrowserProvider* browser_provider, bool transparent) + : renderer_(transparent), + browser_provider_(browser_provider), + hWnd_(NULL), + hDC_(NULL), + hRC_(NULL), + painting_popup_(false), + render_task_pending_(false) { +} + +OSRWindow::~OSRWindow() { + DestroyWidget(); +} + +void OSRWindow::Render() { + ASSERT(CefCurrentlyOn(TID_UI)); + if (render_task_pending_) + render_task_pending_ = false; + + if (!hDC_) + EnableGL(); + + wglMakeCurrent(hDC_, hRC_); + renderer_.Render(); + SwapBuffers(hDC_); +} + +void OSRWindow::EnableGL() { + ASSERT(CefCurrentlyOn(TID_UI)); + + PIXELFORMATDESCRIPTOR pfd; + int format; + + // Get the device context. + hDC_ = GetDC(hWnd_); + + // Set the pixel format for the DC. + ZeroMemory(&pfd, sizeof(pfd)); + pfd.nSize = sizeof(pfd); + pfd.nVersion = 1; + pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; + pfd.iPixelType = PFD_TYPE_RGBA; + pfd.cColorBits = 24; + pfd.cDepthBits = 16; + pfd.iLayerType = PFD_MAIN_PLANE; + format = ChoosePixelFormat(hDC_, &pfd); + SetPixelFormat(hDC_, format, &pfd); + + // Create and enable the render context. + hRC_ = wglCreateContext(hDC_); + wglMakeCurrent(hDC_, hRC_); + + renderer_.Initialize(); +} + +void OSRWindow::DisableGL() { + ASSERT(CefCurrentlyOn(TID_UI)); + + if (!hDC_) + return; + + renderer_.Cleanup(); + + if (IsWindow(hWnd_)) { + wglMakeCurrent(NULL, NULL); + wglDeleteContext(hRC_); + ReleaseDC(hWnd_, hDC_); + } + + hDC_ = NULL; + hRC_ = NULL; +} + +void OSRWindow::OnDestroyed() { + SetWindowLongPtr(hWnd_, GWLP_USERDATA, 0L); + hWnd_ = NULL; + Release(); +} + +ATOM OSRWindow::RegisterOSRClass(HINSTANCE hInstance, LPCTSTR className) { + WNDCLASSEX wcex; + + wcex.cbSize = sizeof(WNDCLASSEX); + wcex.style = CS_OWNDC; + wcex.lpfnWndProc = &OSRWindow::WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = NULL; + wcex.hCursor = LoadCursor(NULL, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); + wcex.lpszMenuName = NULL; + wcex.lpszClassName = className; + wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); + return RegisterClassEx(&wcex); +} + +bool OSRWindow::isKeyDown(WPARAM wparam) { + return (GetKeyState(wparam) & 0x8000) != 0; +} + +int OSRWindow::GetCefMouseModifiers(WPARAM wparam) { + int modifiers = 0; + if (wparam & MK_CONTROL) + modifiers |= EVENTFLAG_CONTROL_DOWN; + if (wparam & MK_SHIFT) + modifiers |= EVENTFLAG_SHIFT_DOWN; + if (isKeyDown(VK_MENU)) + modifiers |= EVENTFLAG_ALT_DOWN; + if (wparam & MK_LBUTTON) + modifiers |= EVENTFLAG_LEFT_MOUSE_BUTTON; + if (wparam & MK_MBUTTON) + modifiers |= EVENTFLAG_MIDDLE_MOUSE_BUTTON; + if (wparam & MK_RBUTTON) + modifiers |= EVENTFLAG_RIGHT_MOUSE_BUTTON; + + // Low bit set from GetKeyState indicates "toggled". + if (::GetKeyState(VK_NUMLOCK) & 1) + modifiers |= EVENTFLAG_NUM_LOCK_ON; + if (::GetKeyState(VK_CAPITAL) & 1) + modifiers |= EVENTFLAG_CAPS_LOCK_ON; + return modifiers; +} + +int OSRWindow::GetCefKeyboardModifiers(WPARAM wparam, LPARAM lparam) { + int modifiers = 0; + if (isKeyDown(VK_SHIFT)) + modifiers |= EVENTFLAG_SHIFT_DOWN; + if (isKeyDown(VK_CONTROL)) + modifiers |= EVENTFLAG_CONTROL_DOWN; + if (isKeyDown(VK_MENU)) + modifiers |= EVENTFLAG_ALT_DOWN; + + // Low bit set from GetKeyState indicates "toggled". + if (::GetKeyState(VK_NUMLOCK) & 1) + modifiers |= EVENTFLAG_NUM_LOCK_ON; + if (::GetKeyState(VK_CAPITAL) & 1) + modifiers |= EVENTFLAG_CAPS_LOCK_ON; + + switch (wparam) { + case VK_RETURN: + if ((lparam >> 16) & KF_EXTENDED) + modifiers |= EVENTFLAG_IS_KEY_PAD; + break; + case VK_INSERT: + case VK_DELETE: + case VK_HOME: + case VK_END: + case VK_PRIOR: + case VK_NEXT: + case VK_UP: + case VK_DOWN: + case VK_LEFT: + case VK_RIGHT: + if (!((lparam >> 16) & KF_EXTENDED)) + modifiers |= EVENTFLAG_IS_KEY_PAD; + break; + case VK_NUMLOCK: + case VK_NUMPAD0: + case VK_NUMPAD1: + case VK_NUMPAD2: + case VK_NUMPAD3: + case VK_NUMPAD4: + case VK_NUMPAD5: + case VK_NUMPAD6: + case VK_NUMPAD7: + case VK_NUMPAD8: + case VK_NUMPAD9: + case VK_DIVIDE: + case VK_MULTIPLY: + case VK_SUBTRACT: + case VK_ADD: + case VK_DECIMAL: + case VK_CLEAR: + modifiers |= EVENTFLAG_IS_KEY_PAD; + break; + case VK_SHIFT: + if (isKeyDown(VK_LSHIFT)) + modifiers |= EVENTFLAG_IS_LEFT; + else if (isKeyDown(VK_RSHIFT)) + modifiers |= EVENTFLAG_IS_RIGHT; + break; + case VK_CONTROL: + if (isKeyDown(VK_LCONTROL)) + modifiers |= EVENTFLAG_IS_LEFT; + else if (isKeyDown(VK_RCONTROL)) + modifiers |= EVENTFLAG_IS_RIGHT; + break; + case VK_MENU: + if (isKeyDown(VK_LMENU)) + modifiers |= EVENTFLAG_IS_LEFT; + else if (isKeyDown(VK_RMENU)) + modifiers |= EVENTFLAG_IS_RIGHT; + break; + case VK_LWIN: + modifiers |= EVENTFLAG_IS_LEFT; + break; + case VK_RWIN: + modifiers |= EVENTFLAG_IS_RIGHT; + break; + } + return modifiers; +} + +bool OSRWindow::IsOverPopupWidget(int x, int y) const { + const CefRect& rc = renderer_.popup_rect(); + int popup_right = rc.x + rc.width; + int popup_bottom = rc.y + rc.height; + return (x >= rc.x) && (x < popup_right) && + (y >= rc.y) && (y < popup_bottom); +} + +int OSRWindow::GetPopupXOffset() const { + return renderer_.original_popup_rect().x - renderer_.popup_rect().x; +} + +int OSRWindow::GetPopupYOffset() const { + return renderer_.original_popup_rect().y - renderer_.popup_rect().y; +} + +void OSRWindow::ApplyPopupOffset(int& x, int& y) const { + if (IsOverPopupWidget(x, y)) { + x += GetPopupXOffset(); + y += GetPopupYOffset(); + } +} + +// Plugin window procedure. +// static +LRESULT CALLBACK OSRWindow::WndProc(HWND hWnd, UINT message, + WPARAM wParam, LPARAM lParam) { + static POINT lastMousePos, curMousePos; + static bool mouseRotation = false; + static bool mouseTracking = false; + + static int lastClickX = 0; + static int lastClickY = 0; + static CefBrowserHost::MouseButtonType lastClickButton = MBT_LEFT; + static int gLastClickCount = 0; + static double gLastClickTime = 0; + + static bool gLastMouseDownOnView = false; + + OSRWindow* window = + reinterpret_cast(GetWindowLongPtr(hWnd, GWLP_USERDATA)); + CefRefPtr browser; + if (window && window->browser_provider_->GetBrowser().get()) + browser = window->browser_provider_->GetBrowser()->GetHost(); + + LONG currentTime = 0; + bool cancelPreviousClick = false; + + if (message == WM_LBUTTONDOWN || message == WM_RBUTTONDOWN || + message == WM_MBUTTONDOWN || message == WM_MOUSEMOVE || + message == WM_MOUSELEAVE) { + currentTime = GetMessageTime(); + int x = GET_X_LPARAM(lParam); + int y = GET_Y_LPARAM(lParam); + cancelPreviousClick = + (abs(lastClickX - x) > (GetSystemMetrics(SM_CXDOUBLECLK) / 2)) + || (abs(lastClickY - y) > (GetSystemMetrics(SM_CYDOUBLECLK) / 2)) + || ((currentTime - gLastClickTime) > GetDoubleClickTime()); + if (cancelPreviousClick && + (message == WM_MOUSEMOVE || message == WM_MOUSELEAVE)) { + gLastClickCount = 0; + lastClickX = 0; + lastClickY = 0; + gLastClickTime = 0; + } + } + + switch (message) { + case WM_DESTROY: + if (window) + window->OnDestroyed(); + return 0; + + case WM_LBUTTONDOWN: + case WM_RBUTTONDOWN: + case WM_MBUTTONDOWN: { + SetCapture(hWnd); + SetFocus(hWnd); + int x = GET_X_LPARAM(lParam); + int y = GET_Y_LPARAM(lParam); + if (wParam & MK_SHIFT) { + // Start rotation effect. + lastMousePos.x = curMousePos.x = x; + lastMousePos.y = curMousePos.y = y; + mouseRotation = true; + } else { + CefBrowserHost::MouseButtonType btnType = + (message == WM_LBUTTONDOWN ? MBT_LEFT : ( + message == WM_RBUTTONDOWN ? MBT_RIGHT : MBT_MIDDLE)); + if (!cancelPreviousClick && (btnType == lastClickButton)) { + ++gLastClickCount; + } else { + gLastClickCount = 1; + lastClickX = x; + lastClickY = y; + } + gLastClickTime = currentTime; + lastClickButton = btnType; + + if (browser.get()) { + CefMouseEvent mouse_event; + mouse_event.x = x; + mouse_event.y = y; + gLastMouseDownOnView = !window->IsOverPopupWidget(x, y); + window->ApplyPopupOffset(mouse_event.x, mouse_event.y); + mouse_event.modifiers = GetCefMouseModifiers(wParam); + browser->SendMouseClickEvent(mouse_event, btnType, false, + gLastClickCount); + } + } + break; + } + + case WM_LBUTTONUP: + case WM_RBUTTONUP: + case WM_MBUTTONUP: + if (GetCapture() == hWnd) + ReleaseCapture(); + if (mouseRotation) { + // End rotation effect. + mouseRotation = false; + window->renderer_.SetSpin(0, 0); + window->Invalidate(); + } else { + int x = GET_X_LPARAM(lParam); + int y = GET_Y_LPARAM(lParam); + CefBrowserHost::MouseButtonType btnType = + (message == WM_LBUTTONUP ? MBT_LEFT : ( + message == WM_RBUTTONUP ? MBT_RIGHT : MBT_MIDDLE)); + if (browser.get()) { + CefMouseEvent mouse_event; + mouse_event.x = x; + mouse_event.y = y; + if (gLastMouseDownOnView && + window->IsOverPopupWidget(x, y) && + (window->GetPopupXOffset() || window->GetPopupYOffset())) { + break; + } + window->ApplyPopupOffset(mouse_event.x, mouse_event.y); + mouse_event.modifiers = GetCefMouseModifiers(wParam); + browser->SendMouseClickEvent(mouse_event, btnType, true, + gLastClickCount); + } + } + break; + + case WM_MOUSEMOVE: { + int x = GET_X_LPARAM(lParam); + int y = GET_Y_LPARAM(lParam); + if (mouseRotation) { + // Apply rotation effect. + curMousePos.x = x; + curMousePos.y = y; + window->renderer_.IncrementSpin((curMousePos.x - lastMousePos.x), + (curMousePos.y - lastMousePos.y)); + lastMousePos.x = curMousePos.x; + lastMousePos.y = curMousePos.y; + window->Invalidate(); + } else { + if (!mouseTracking) { + // Start tracking mouse leave. Required for the WM_MOUSELEAVE event to + // be generated. + TRACKMOUSEEVENT tme; + tme.cbSize = sizeof(TRACKMOUSEEVENT); + tme.dwFlags = TME_LEAVE; + tme.hwndTrack = hWnd; + TrackMouseEvent(&tme); + mouseTracking = true; + } + if (browser.get()) { + CefMouseEvent mouse_event; + mouse_event.x = x; + mouse_event.y = y; + window->ApplyPopupOffset(mouse_event.x, mouse_event.y); + mouse_event.modifiers = GetCefMouseModifiers(wParam); + browser->SendMouseMoveEvent(mouse_event, false); + } + } + break; + } + + case WM_MOUSELEAVE: + if (mouseTracking) { + // Stop tracking mouse leave. + TRACKMOUSEEVENT tme; + tme.cbSize = sizeof(TRACKMOUSEEVENT); + tme.dwFlags = TME_LEAVE & TME_CANCEL; + tme.hwndTrack = hWnd; + TrackMouseEvent(&tme); + mouseTracking = false; + } + if (browser.get()) { + CefMouseEvent mouse_event; + mouse_event.x = 0; + mouse_event.y = 0; + mouse_event.modifiers = GetCefMouseModifiers(wParam); + browser->SendMouseMoveEvent(mouse_event, true); + } + break; + + case WM_MOUSEWHEEL: + if (browser.get()) { + POINT screen_point = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; + HWND scrolled_wnd = ::WindowFromPoint(screen_point); + if (scrolled_wnd != hWnd) { + break; + } + ScreenToClient(hWnd, &screen_point); + int delta = GET_WHEEL_DELTA_WPARAM(wParam); + + CefMouseEvent mouse_event; + mouse_event.x = screen_point.x; + mouse_event.y = screen_point.y; + window->ApplyPopupOffset(mouse_event.x, mouse_event.y); + mouse_event.modifiers = GetCefMouseModifiers(wParam); + + browser->SendMouseWheelEvent(mouse_event, + isKeyDown(VK_SHIFT) ? delta : 0, + !isKeyDown(VK_SHIFT) ? delta : 0); + } + break; + + case WM_SIZE: + if (browser.get()) + browser->WasResized(); + break; + + case WM_SETFOCUS: + case WM_KILLFOCUS: + if (browser.get()) + browser->SendFocusEvent(message == WM_SETFOCUS); + break; + + case WM_CAPTURECHANGED: + case WM_CANCELMODE: + if (!mouseRotation) { + if (browser.get()) + browser->SendCaptureLostEvent(); + } + break; + case WM_SYSCHAR: + case WM_SYSKEYDOWN: + case WM_SYSKEYUP: + case WM_KEYDOWN: + case WM_KEYUP: + case WM_CHAR: { + CefKeyEvent event; + event.windows_key_code = wParam; + event.native_key_code = lParam; + event.is_system_key = message == WM_SYSCHAR || + message == WM_SYSKEYDOWN || + message == WM_SYSKEYUP; + + if (message == WM_KEYDOWN || message == WM_SYSKEYDOWN) + event.type = KEYEVENT_RAWKEYDOWN; + else if (message == WM_KEYUP || message == WM_SYSKEYUP) + event.type = KEYEVENT_KEYUP; + else + event.type = KEYEVENT_CHAR; + event.modifiers = GetCefKeyboardModifiers(wParam, lParam); + if (browser.get()) + browser->SendKeyEvent(event); + break; + } + + case WM_PAINT: { + PAINTSTRUCT ps; + RECT rc; + BeginPaint(hWnd, &ps); + rc = ps.rcPaint; + EndPaint(hWnd, &ps); + if (browser.get()) { + browser->Invalidate(CefRect(rc.left, + rc.top, + rc.right - rc.left, + rc.bottom - rc.top), PET_VIEW); + } + return 0; + } + + case WM_ERASEBKGND: + return 0; + } + + return DefWindowProc(hWnd, message, wParam, lParam); +} diff --git a/cef3/tests/cefclient/cefclient_osr_widget_win.h b/cef3/tests/cefclient/cefclient_osr_widget_win.h new file mode 100644 index 000000000..8b04541de --- /dev/null +++ b/cef3/tests/cefclient/cefclient_osr_widget_win.h @@ -0,0 +1,101 @@ +// 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_CEFCLIENT_OSR_WIDGET_WIN_H_ +#define CEF_TESTS_CEFCLIENT_CEFCLIENT_OSR_WIDGET_WIN_H_ +#pragma once + +#include "include/cef_render_handler.h" +#include "cefclient/client_handler.h" +#include "cefclient/osrenderer.h" + +class OSRBrowserProvider { + public: + virtual CefRefPtr GetBrowser() =0; + + protected: + virtual ~OSRBrowserProvider() {} +}; + +class OSRWindow : public ClientHandler::RenderHandler { + public: + // Create a new OSRWindow instance. |browser_provider| must outlive this + // object. + static CefRefPtr Create(OSRBrowserProvider* browser_provider, + bool transparent); + + static CefRefPtr From( + CefRefPtr renderHandler); + + // Create the underlying window. + bool CreateWidget(HWND hWndParent, const RECT& rect, + HINSTANCE hInst, LPCTSTR className); + + // Destroy the underlying window. + void DestroyWidget(); + + HWND hwnd() const { + return hWnd_; + } + + // ClientHandler::RenderHandler methods + virtual void OnBeforeClose(CefRefPtr browser) OVERRIDE; + + // CefRenderHandler methods + virtual bool GetRootScreenRect(CefRefPtr browser, + CefRect& rect) OVERRIDE; + virtual bool GetViewRect(CefRefPtr browser, + CefRect& rect) OVERRIDE; + virtual bool GetScreenPoint(CefRefPtr browser, + int viewX, + int viewY, + int& screenX, + int& screenY) OVERRIDE; + virtual void OnPopupShow(CefRefPtr browser, + bool show) OVERRIDE; + virtual void OnPopupSize(CefRefPtr browser, + const CefRect& rect) OVERRIDE; + virtual void OnPaint(CefRefPtr browser, + PaintElementType type, + const RectList& dirtyRects, + const void* buffer, + int width, + int height) OVERRIDE; + virtual void OnCursorChange(CefRefPtr browser, + CefCursorHandle cursor) OVERRIDE; + + void Invalidate(); + + private: + OSRWindow(OSRBrowserProvider* browser_provider, bool transparent); + virtual ~OSRWindow(); + + void Render(); + void EnableGL(); + void DisableGL(); + void OnDestroyed(); + static ATOM RegisterOSRClass(HINSTANCE hInstance, LPCTSTR className); + static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, + LPARAM lParam); + static int GetCefKeyboardModifiers(WPARAM wparam, LPARAM lparam); + static int GetCefMouseModifiers(WPARAM wparam); + static bool isKeyDown(WPARAM wparam); + bool IsOverPopupWidget(int x, int y) const; + int GetPopupXOffset() const; + int GetPopupYOffset() const; + void ApplyPopupOffset(int& x, int& y) const; + + ClientOSRenderer renderer_; + OSRBrowserProvider* browser_provider_; + HWND hWnd_; + HDC hDC_; + HGLRC hRC_; + + bool painting_popup_; + bool render_task_pending_; + + IMPLEMENT_REFCOUNTING(OSRWindow); +}; + +#endif // CEF_TESTS_CEFCLIENT_CEFCLIENT_OSR_WIDGET_WIN_H_ diff --git a/cef3/tests/cefclient/cefclient_win.cpp b/cef3/tests/cefclient/cefclient_win.cpp new file mode 100644 index 000000000..88fe55cec --- /dev/null +++ b/cef3/tests/cefclient/cefclient_win.cpp @@ -0,0 +1,590 @@ +// Copyright (c) 2013 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/cefclient.h" +#include +#include +#include +#include +#include +#include +#include "include/cef_app.h" +#include "include/cef_browser.h" +#include "include/cef_frame.h" +#include "include/cef_runnable.h" +#include "cefclient/cefclient_osr_widget_win.h" +#include "cefclient/client_handler.h" +#include "cefclient/client_switches.h" +#include "cefclient/resource.h" +#include "cefclient/scheme_test.h" +#include "cefclient/string_util.h" + +#define MAX_LOADSTRING 100 +#define MAX_URL_LENGTH 255 +#define BUTTON_WIDTH 72 +#define URLBAR_HEIGHT 24 + +// Global Variables: +HINSTANCE hInst; // current instance +TCHAR szTitle[MAX_LOADSTRING]; // The title bar text +TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name +TCHAR szOSRWindowClass[MAX_LOADSTRING]; // the OSR window class name +char szWorkingDir[MAX_PATH]; // The current working directory + +// Forward declarations of functions included in this code module: +ATOM MyRegisterClass(HINSTANCE hInstance); +BOOL InitInstance(HINSTANCE, int); +LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); +INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); + +// Used for processing messages on the main application thread while running +// in multi-threaded message loop mode. +HWND hMessageWnd = NULL; +HWND CreateMessageWindow(HINSTANCE hInstance); +LRESULT CALLBACK MessageWndProc(HWND, UINT, WPARAM, LPARAM); + +// The global ClientHandler reference. +extern CefRefPtr g_handler; + +class MainBrowserProvider : public OSRBrowserProvider { + virtual CefRefPtr GetBrowser() { + if (g_handler.get()) + return g_handler->GetBrowser(); + + return NULL; + } +} g_main_browser_provider; + +#if defined(OS_WIN) +// Add Common Controls to the application manifest because it's required to +// support the default tooltip implementation. +#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") // NOLINT(whitespace/line_length) +#endif + +// Program entry point function. +int APIENTRY wWinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPTSTR lpCmdLine, + int nCmdShow) { + UNREFERENCED_PARAMETER(hPrevInstance); + UNREFERENCED_PARAMETER(lpCmdLine); + + CefMainArgs main_args(hInstance); + CefRefPtr app(new ClientApp); + + // Execute the secondary process, if any. + int exit_code = CefExecuteProcess(main_args, app.get()); + if (exit_code >= 0) + return exit_code; + + // Retrieve the current working directory. + if (_getcwd(szWorkingDir, MAX_PATH) == NULL) + szWorkingDir[0] = 0; + + // Parse command line arguments. The passed in values are ignored on Windows. + AppInitCommandLine(0, NULL); + + CefSettings settings; + + // Populate the settings based on command line arguments. + AppGetSettings(settings); + + // Initialize CEF. + CefInitialize(main_args, settings, app.get()); + + // Register the scheme handler. + scheme_test::InitTest(); + + HACCEL hAccelTable; + + // Initialize global strings + LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); + LoadString(hInstance, IDC_CEFCLIENT, szWindowClass, MAX_LOADSTRING); + LoadString(hInstance, IDS_OSR_WIDGET_CLASS, szOSRWindowClass, MAX_LOADSTRING); + MyRegisterClass(hInstance); + + // Perform application initialization + if (!InitInstance (hInstance, nCmdShow)) + return FALSE; + + hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_CEFCLIENT)); + + int result = 0; + + if (!settings.multi_threaded_message_loop) { + // Run the CEF message loop. This function will block until the application + // recieves a WM_QUIT message. + CefRunMessageLoop(); + } else { + // Create a hidden window for message processing. + hMessageWnd = CreateMessageWindow(hInstance); + ASSERT(hMessageWnd); + + MSG msg; + + // Run the application message loop. + while (GetMessage(&msg, NULL, 0, 0)) { + if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + + DestroyWindow(hMessageWnd); + hMessageWnd = NULL; + + result = static_cast(msg.wParam); + } + + // Shut down CEF. + CefShutdown(); + + return result; +} + +// +// FUNCTION: MyRegisterClass() +// +// PURPOSE: Registers the window class. +// +// COMMENTS: +// +// This function and its usage are only necessary if you want this code +// to be compatible with Win32 systems prior to the 'RegisterClassEx' +// function that was added to Windows 95. It is important to call this +// function so that the application will get 'well formed' small icons +// associated with it. +// +ATOM MyRegisterClass(HINSTANCE hInstance) { + WNDCLASSEX wcex; + + wcex.cbSize = sizeof(WNDCLASSEX); + + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_CEFCLIENT)); + wcex.hCursor = LoadCursor(NULL, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wcex.lpszMenuName = MAKEINTRESOURCE(IDC_CEFCLIENT); + wcex.lpszClassName = szWindowClass; + wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); + + return RegisterClassEx(&wcex); +} + +// +// FUNCTION: InitInstance(HINSTANCE, int) +// +// PURPOSE: Saves instance handle and creates main window +// +// COMMENTS: +// +// In this function, we save the instance handle in a global variable and +// create and display the main program window. +// +BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { + HWND hWnd; + + hInst = hInstance; // Store instance handle in our global variable + + hWnd = CreateWindow(szWindowClass, szTitle, + WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, CW_USEDEFAULT, 0, + CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); + + if (!hWnd) + return FALSE; + + ShowWindow(hWnd, nCmdShow); + UpdateWindow(hWnd); + + return TRUE; +} + +// Change the zoom factor on the UI thread. +static void ModifyZoom(CefRefPtr browser, double delta) { + if (CefCurrentlyOn(TID_UI)) { + browser->GetHost()->SetZoomLevel( + browser->GetHost()->GetZoomLevel() + delta); + } else { + CefPostTask(TID_UI, NewCefRunnableFunction(ModifyZoom, browser, delta)); + } +} + +// +// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) +// +// PURPOSE: Processes messages for the main window. +// +LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, + LPARAM lParam) { + static HWND backWnd = NULL, forwardWnd = NULL, reloadWnd = NULL, + stopWnd = NULL, editWnd = NULL; + static WNDPROC editWndOldProc = NULL; + + // Static members used for the find dialog. + static FINDREPLACE fr; + static WCHAR szFindWhat[80] = {0}; + static WCHAR szLastFindWhat[80] = {0}; + static bool findNext = false; + static bool lastMatchCase = false; + + int wmId, wmEvent; + PAINTSTRUCT ps; + HDC hdc; + + if (hWnd == editWnd) { + // Callback for the edit window + switch (message) { + case WM_CHAR: + if (wParam == VK_RETURN && g_handler.get()) { + // When the user hits the enter key load the URL + CefRefPtr browser = g_handler->GetBrowser(); + wchar_t strPtr[MAX_URL_LENGTH+1] = {0}; + *((LPWORD)strPtr) = MAX_URL_LENGTH; + LRESULT strLen = SendMessage(hWnd, EM_GETLINE, 0, (LPARAM)strPtr); + if (strLen > 0) { + strPtr[strLen] = 0; + browser->GetMainFrame()->LoadURL(strPtr); + } + + return 0; + } + } + + return (LRESULT)CallWindowProc(editWndOldProc, hWnd, message, wParam, + lParam); + } else { + // Callback for the main window + switch (message) { + case WM_CREATE: { + // Create the single static handler class instance + g_handler = new ClientHandler(); + g_handler->SetMainHwnd(hWnd); + + // Create the child windows used for navigation + RECT rect; + int x = 0; + + GetClientRect(hWnd, &rect); + + backWnd = CreateWindow(L"BUTTON", L"Back", + WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON + | WS_DISABLED, x, 0, BUTTON_WIDTH, URLBAR_HEIGHT, + hWnd, (HMENU) IDC_NAV_BACK, hInst, 0); + x += BUTTON_WIDTH; + + forwardWnd = CreateWindow(L"BUTTON", L"Forward", + WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON + | WS_DISABLED, x, 0, BUTTON_WIDTH, + URLBAR_HEIGHT, hWnd, (HMENU) IDC_NAV_FORWARD, + hInst, 0); + x += BUTTON_WIDTH; + + reloadWnd = CreateWindow(L"BUTTON", L"Reload", + WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON + | WS_DISABLED, x, 0, BUTTON_WIDTH, + URLBAR_HEIGHT, hWnd, (HMENU) IDC_NAV_RELOAD, + hInst, 0); + x += BUTTON_WIDTH; + + stopWnd = CreateWindow(L"BUTTON", L"Stop", + WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON + | WS_DISABLED, x, 0, BUTTON_WIDTH, URLBAR_HEIGHT, + hWnd, (HMENU) IDC_NAV_STOP, hInst, 0); + x += BUTTON_WIDTH; + + editWnd = CreateWindow(L"EDIT", 0, + WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | + ES_AUTOVSCROLL | ES_AUTOHSCROLL| WS_DISABLED, + x, 0, rect.right - BUTTON_WIDTH * 4, + URLBAR_HEIGHT, hWnd, 0, hInst, 0); + + // Assign the edit window's WNDPROC to this function so that we can + // capture the enter key + editWndOldProc = + reinterpret_cast(GetWindowLongPtr(editWnd, GWLP_WNDPROC)); + SetWindowLongPtr(editWnd, GWLP_WNDPROC, + reinterpret_cast(WndProc)); + g_handler->SetEditHwnd(editWnd); + g_handler->SetButtonHwnds(backWnd, forwardWnd, reloadWnd, stopWnd); + + rect.top += URLBAR_HEIGHT; + + CefWindowInfo info; + CefBrowserSettings settings; + + if (AppIsOffScreenRenderingEnabled()) { + CefRefPtr cmd_line = AppGetCommandLine(); + bool transparent = + cmd_line->HasSwitch(cefclient::kTransparentPaintingEnabled); + + CefRefPtr osr_window = + OSRWindow::Create(&g_main_browser_provider, transparent); + osr_window->CreateWidget(hWnd, rect, hInst, szOSRWindowClass); + info.SetAsOffScreen(osr_window->hwnd()); + info.SetTransparentPainting(transparent ? TRUE : FALSE); + g_handler->SetOSRHandler(osr_window.get()); + } else { + // Initialize window info to the defaults for a child window. + info.SetAsChild(hWnd, rect); + } + + // Creat the new child browser window + CefBrowserHost::CreateBrowser(info, g_handler.get(), + g_handler->GetStartupURL(), settings); + + return 0; + } + + case WM_COMMAND: { + CefRefPtr browser; + if (g_handler.get()) + browser = g_handler->GetBrowser(); + + wmId = LOWORD(wParam); + wmEvent = HIWORD(wParam); + // Parse the menu selections: + switch (wmId) { + case IDM_ABOUT: + DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); + return 0; + case IDM_EXIT: + if (g_handler.get()) + g_handler->CloseAllBrowsers(false); + return 0; + case ID_WARN_CONSOLEMESSAGE: + if (g_handler.get()) { + std::wstringstream ss; + ss << L"Console messages will be written to " + << std::wstring(CefString(g_handler->GetLogFile())); + MessageBox(hWnd, ss.str().c_str(), L"Console Messages", + MB_OK | MB_ICONINFORMATION); + } + return 0; + case ID_WARN_DOWNLOADCOMPLETE: + case ID_WARN_DOWNLOADERROR: + if (g_handler.get()) { + std::wstringstream ss; + ss << L"File \"" << + std::wstring(CefString(g_handler->GetLastDownloadFile())) << + L"\" "; + + if (wmId == ID_WARN_DOWNLOADCOMPLETE) + ss << L"downloaded successfully."; + else + ss << L"failed to download."; + + MessageBox(hWnd, ss.str().c_str(), L"File Download", + MB_OK | MB_ICONINFORMATION); + } + return 0; + case IDC_NAV_BACK: // Back button + if (browser.get()) + browser->GoBack(); + return 0; + case IDC_NAV_FORWARD: // Forward button + if (browser.get()) + browser->GoForward(); + return 0; + case IDC_NAV_RELOAD: // Reload button + if (browser.get()) + browser->Reload(); + return 0; + case IDC_NAV_STOP: // Stop button + if (browser.get()) + browser->StopLoad(); + return 0; + case ID_TESTS_GETSOURCE: // Test the GetSource function + if (browser.get()) + RunGetSourceTest(browser); + return 0; + case ID_TESTS_GETTEXT: // Test the GetText function + if (browser.get()) + RunGetTextTest(browser); + return 0; + case ID_TESTS_POPUP: // Test a popup window + if (browser.get()) + RunPopupTest(browser); + return 0; + case ID_TESTS_REQUEST: // Test a request + if (browser.get()) + RunRequestTest(browser); + return 0; + case ID_TESTS_PLUGIN_INFO: // Test plugin info + if (browser.get()) + RunPluginInfoTest(browser); + return 0; + case ID_TESTS_ZOOM_IN: + if (browser.get()) + ModifyZoom(browser, 0.5); + return 0; + case ID_TESTS_ZOOM_OUT: + if (browser.get()) + ModifyZoom(browser, -0.5); + return 0; + case ID_TESTS_ZOOM_RESET: + if (browser.get()) + browser->GetHost()->SetZoomLevel(0.0); + return 0; + case ID_TESTS_TRACING_BEGIN: + g_handler->BeginTracing(); + return 0; + case ID_TESTS_TRACING_END: + g_handler->EndTracing(); + return 0; + case ID_TESTS_OTHER_TESTS: + if (browser.get()) + RunOtherTests(browser); + return 0; + } + break; + } + + case WM_PAINT: + hdc = BeginPaint(hWnd, &ps); + EndPaint(hWnd, &ps); + return 0; + + case WM_SETFOCUS: + if (g_handler.get() && g_handler->GetBrowser()) { + // Pass focus to the browser window + CefWindowHandle hwnd = + g_handler->GetBrowser()->GetHost()->GetWindowHandle(); + if (hwnd) + PostMessage(hwnd, WM_SETFOCUS, wParam, NULL); + } + return 0; + + case WM_SIZE: + // Minimizing resizes the window to 0x0 which causes our layout to go all + // screwy, so we just ignore it. + if (wParam != SIZE_MINIMIZED && g_handler.get() && + g_handler->GetBrowser()) { + CefWindowHandle hwnd = + g_handler->GetBrowser()->GetHost()->GetWindowHandle(); + if (hwnd) { + // Resize the browser window and address bar to match the new frame + // window size + RECT rect; + GetClientRect(hWnd, &rect); + rect.top += URLBAR_HEIGHT; + + int urloffset = rect.left + BUTTON_WIDTH * 4; + + HDWP hdwp = BeginDeferWindowPos(1); + hdwp = DeferWindowPos(hdwp, editWnd, NULL, urloffset, + 0, rect.right - urloffset, URLBAR_HEIGHT, SWP_NOZORDER); + hdwp = DeferWindowPos(hdwp, hwnd, NULL, + rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, + SWP_NOZORDER); + EndDeferWindowPos(hdwp); + } + } + break; + + case WM_ERASEBKGND: + if (g_handler.get() && g_handler->GetBrowser()) { + CefWindowHandle hwnd = + g_handler->GetBrowser()->GetHost()->GetWindowHandle(); + if (hwnd) { + // Dont erase the background if the browser window has been loaded + // (this avoids flashing) + return 0; + } + } + break; + + case WM_CLOSE: + if (g_handler.get() && !g_handler->IsClosing()) { + CefRefPtr browser = g_handler->GetBrowser(); + if (browser.get()) { + // Notify the browser window that we would like to close it. This + // will result in a call to ClientHandler::DoClose() if the + // JavaScript 'onbeforeunload' event handler allows it. + browser->GetHost()->CloseBrowser(false); + + // Cancel the close. + return 0; + } + } + + // Allow the close. + break; + + case WM_DESTROY: + // Quitting CEF is handled in ClientHandler::OnBeforeClose(). + return 0; + } + + return DefWindowProc(hWnd, message, wParam, lParam); + } +} + +// Message handler for about box. +INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { + UNREFERENCED_PARAMETER(lParam); + switch (message) { + case WM_INITDIALOG: + return (INT_PTR)TRUE; + + case WM_COMMAND: + if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { + EndDialog(hDlg, LOWORD(wParam)); + return (INT_PTR)TRUE; + } + break; + } + return (INT_PTR)FALSE; +} + +HWND CreateMessageWindow(HINSTANCE hInstance) { + static const wchar_t kWndClass[] = L"ClientMessageWindow"; + + WNDCLASSEX wc = {0}; + wc.cbSize = sizeof(wc); + wc.lpfnWndProc = MessageWndProc; + wc.hInstance = hInstance; + wc.lpszClassName = kWndClass; + RegisterClassEx(&wc); + + return CreateWindow(kWndClass, 0, 0, 0, 0, 0, 0, HWND_MESSAGE, 0, + hInstance, 0); +} + +LRESULT CALLBACK MessageWndProc(HWND hWnd, UINT message, WPARAM wParam, + LPARAM lParam) { + switch (message) { + case WM_COMMAND: { + int wmId = LOWORD(wParam); + switch (wmId) { + case ID_QUIT: + PostQuitMessage(0); + return 0; + } + } + } + return DefWindowProc(hWnd, message, wParam, lParam); +} + + +// Global functions + +std::string AppGetWorkingDirectory() { + return szWorkingDir; +} + +void AppQuitMessageLoop() { + CefRefPtr command_line = AppGetCommandLine(); + if (command_line->HasSwitch(cefclient::kMultiThreadedMessageLoop)) { + // Running in multi-threaded message loop mode. Need to execute + // PostQuitMessage on the main application thread. + ASSERT(hMessageWnd); + PostMessage(hMessageWnd, WM_COMMAND, ID_QUIT, 0); + } else { + CefQuitMessageLoop(); + } +} diff --git a/cef3/tests/cefclient/client_app.cpp b/cef3/tests/cefclient/client_app.cpp new file mode 100644 index 000000000..3fc87e534 --- /dev/null +++ b/cef3/tests/cefclient/client_app.cpp @@ -0,0 +1,431 @@ +// Copyright (c) 2013 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. + +// This file is shared by cefclient and cef_unittests so don't include using +// a qualified path. +#include "client_app.h" // NOLINT(build/include) + +#include + +#include "include/cef_cookie.h" +#include "include/cef_process_message.h" +#include "include/cef_task.h" +#include "include/cef_v8.h" +#include "util.h" // NOLINT(build/include) + +namespace { + +// Forward declarations. +void SetList(CefRefPtr source, CefRefPtr target); +void SetList(CefRefPtr source, CefRefPtr target); + +// Transfer a V8 value to a List index. +void SetListValue(CefRefPtr list, int index, + CefRefPtr value) { + if (value->IsArray()) { + CefRefPtr new_list = CefListValue::Create(); + SetList(value, new_list); + list->SetList(index, new_list); + } else if (value->IsString()) { + list->SetString(index, value->GetStringValue()); + } else if (value->IsBool()) { + list->SetBool(index, value->GetBoolValue()); + } else if (value->IsInt()) { + list->SetInt(index, value->GetIntValue()); + } else if (value->IsDouble()) { + list->SetDouble(index, value->GetDoubleValue()); + } +} + +// Transfer a V8 array to a List. +void SetList(CefRefPtr source, CefRefPtr target) { + ASSERT(source->IsArray()); + + int arg_length = source->GetArrayLength(); + if (arg_length == 0) + return; + + // Start with null types in all spaces. + target->SetSize(arg_length); + + for (int i = 0; i < arg_length; ++i) + SetListValue(target, i, source->GetValue(i)); +} + +// Transfer a List value to a V8 array index. +void SetListValue(CefRefPtr list, int index, + CefRefPtr value) { + CefRefPtr new_value; + + CefValueType type = value->GetType(index); + switch (type) { + case VTYPE_LIST: { + CefRefPtr list = value->GetList(index); + new_value = CefV8Value::CreateArray(list->GetSize()); + SetList(list, new_value); + } break; + case VTYPE_BOOL: + new_value = CefV8Value::CreateBool(value->GetBool(index)); + break; + case VTYPE_DOUBLE: + new_value = CefV8Value::CreateDouble(value->GetDouble(index)); + break; + case VTYPE_INT: + new_value = CefV8Value::CreateInt(value->GetInt(index)); + break; + case VTYPE_STRING: + new_value = CefV8Value::CreateString(value->GetString(index)); + break; + default: + break; + } + + if (new_value.get()) { + list->SetValue(index, new_value); + } else { + list->SetValue(index, CefV8Value::CreateNull()); + } +} + +// Transfer a List to a V8 array. +void SetList(CefRefPtr source, CefRefPtr target) { + ASSERT(target->IsArray()); + + int arg_length = source->GetSize(); + if (arg_length == 0) + return; + + for (int i = 0; i < arg_length; ++i) + SetListValue(target, i, source); +} + + +// Handles the native implementation for the client_app extension. +class ClientAppExtensionHandler : public CefV8Handler { + public: + explicit ClientAppExtensionHandler(CefRefPtr client_app) + : client_app_(client_app) { + } + + virtual bool Execute(const CefString& name, + CefRefPtr object, + const CefV8ValueList& arguments, + CefRefPtr& retval, + CefString& exception) { + bool handled = false; + + if (name == "sendMessage") { + // Send a message to the browser process. + if ((arguments.size() == 1 || arguments.size() == 2) && + arguments[0]->IsString()) { + CefRefPtr browser = + CefV8Context::GetCurrentContext()->GetBrowser(); + ASSERT(browser.get()); + + CefString name = arguments[0]->GetStringValue(); + if (!name.empty()) { + CefRefPtr message = + CefProcessMessage::Create(name); + + // Translate the arguments, if any. + if (arguments.size() == 2 && arguments[1]->IsArray()) + SetList(arguments[1], message->GetArgumentList()); + + browser->SendProcessMessage(PID_BROWSER, message); + handled = true; + } + } + } else if (name == "setMessageCallback") { + // Set a message callback. + if (arguments.size() == 2 && arguments[0]->IsString() && + arguments[1]->IsFunction()) { + std::string name = arguments[0]->GetStringValue(); + CefRefPtr context = CefV8Context::GetCurrentContext(); + int browser_id = context->GetBrowser()->GetIdentifier(); + client_app_->SetMessageCallback(name, browser_id, context, + arguments[1]); + handled = true; + } + } else if (name == "removeMessageCallback") { + // Remove a message callback. + if (arguments.size() == 1 && arguments[0]->IsString()) { + std::string name = arguments[0]->GetStringValue(); + CefRefPtr context = CefV8Context::GetCurrentContext(); + int browser_id = context->GetBrowser()->GetIdentifier(); + bool removed = client_app_->RemoveMessageCallback(name, browser_id); + retval = CefV8Value::CreateBool(removed); + handled = true; + } + } + + if (!handled) + exception = "Invalid method arguments"; + + return true; + } + + private: + CefRefPtr client_app_; + + IMPLEMENT_REFCOUNTING(ClientAppExtensionHandler); +}; + +} // namespace + + +ClientApp::ClientApp() { + CreateBrowserDelegates(browser_delegates_); + CreateRenderDelegates(render_delegates_); + + // Default schemes that support cookies. + cookieable_schemes_.push_back("http"); + cookieable_schemes_.push_back("https"); +} + +void ClientApp::SetMessageCallback(const std::string& message_name, + int browser_id, + CefRefPtr context, + CefRefPtr function) { + ASSERT(CefCurrentlyOn(TID_RENDERER)); + + callback_map_.insert( + std::make_pair(std::make_pair(message_name, browser_id), + std::make_pair(context, function))); +} + +bool ClientApp::RemoveMessageCallback(const std::string& message_name, + int browser_id) { + ASSERT(CefCurrentlyOn(TID_RENDERER)); + + CallbackMap::iterator it = + callback_map_.find(std::make_pair(message_name, browser_id)); + if (it != callback_map_.end()) { + callback_map_.erase(it); + return true; + } + + return false; +} + +void ClientApp::OnContextInitialized() { + // Register cookieable schemes with the global cookie manager. + CefRefPtr manager = CefCookieManager::GetGlobalManager(); + ASSERT(manager.get()); + manager->SetSupportedSchemes(cookieable_schemes_); + + BrowserDelegateSet::iterator it = browser_delegates_.begin(); + for (; it != browser_delegates_.end(); ++it) + (*it)->OnContextInitialized(this); +} + +void ClientApp::OnBeforeChildProcessLaunch( + CefRefPtr command_line) { + BrowserDelegateSet::iterator it = browser_delegates_.begin(); + for (; it != browser_delegates_.end(); ++it) + (*it)->OnBeforeChildProcessLaunch(this, command_line); +} + +void ClientApp::OnRenderProcessThreadCreated( + CefRefPtr extra_info) { + BrowserDelegateSet::iterator it = browser_delegates_.begin(); + for (; it != browser_delegates_.end(); ++it) + (*it)->OnRenderProcessThreadCreated(this, extra_info); +} + +void ClientApp::OnRenderThreadCreated(CefRefPtr extra_info) { + RenderDelegateSet::iterator it = render_delegates_.begin(); + for (; it != render_delegates_.end(); ++it) + (*it)->OnRenderThreadCreated(this, extra_info); +} + +void ClientApp::OnWebKitInitialized() { + // Register the client_app extension. + std::string app_code = + "var app;" + "if (!app)" + " app = {};" + "(function() {" + " app.sendMessage = function(name, arguments) {" + " native function sendMessage();" + " return sendMessage(name, arguments);" + " };" + " app.setMessageCallback = function(name, callback) {" + " native function setMessageCallback();" + " return setMessageCallback(name, callback);" + " };" + " app.removeMessageCallback = function(name) {" + " native function removeMessageCallback();" + " return removeMessageCallback(name);" + " };" + "})();"; + CefRegisterExtension("v8/app", app_code, + new ClientAppExtensionHandler(this)); + + RenderDelegateSet::iterator it = render_delegates_.begin(); + for (; it != render_delegates_.end(); ++it) + (*it)->OnWebKitInitialized(this); +} + +void ClientApp::OnBrowserCreated(CefRefPtr browser) { + RenderDelegateSet::iterator it = render_delegates_.begin(); + for (; it != render_delegates_.end(); ++it) + (*it)->OnBrowserCreated(this, browser); +} + +void ClientApp::OnBrowserDestroyed(CefRefPtr browser) { + RenderDelegateSet::iterator it = render_delegates_.begin(); + for (; it != render_delegates_.end(); ++it) + (*it)->OnBrowserDestroyed(this, browser); +} + +bool ClientApp::OnBeforeNavigation(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr request, + NavigationType navigation_type, + bool is_redirect) { + RenderDelegateSet::iterator it = render_delegates_.begin(); + for (; it != render_delegates_.end(); ++it) { + if ((*it)->OnBeforeNavigation(this, browser, frame, request, + navigation_type, is_redirect)) { + return true; + } + } + + return false; +} + +void ClientApp::OnContextCreated(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context) { + RenderDelegateSet::iterator it = render_delegates_.begin(); + for (; it != render_delegates_.end(); ++it) + (*it)->OnContextCreated(this, browser, frame, context); +} + +void ClientApp::OnContextReleased(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context) { + RenderDelegateSet::iterator it = render_delegates_.begin(); + for (; it != render_delegates_.end(); ++it) + (*it)->OnContextReleased(this, browser, frame, context); + + // Remove any JavaScript callbacks registered for the context that has been + // released. + if (!callback_map_.empty()) { + CallbackMap::iterator it = callback_map_.begin(); + for (; it != callback_map_.end();) { + if (it->second.first->IsSame(context)) + callback_map_.erase(it++); + else + ++it; + } + } +} + +void ClientApp::OnUncaughtException(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context, + CefRefPtr exception, + CefRefPtr stackTrace) { + RenderDelegateSet::iterator it = render_delegates_.begin(); + for (; it != render_delegates_.end(); ++it) { + (*it)->OnUncaughtException(this, browser, frame, context, exception, + stackTrace); + } +} + +void ClientApp::OnWorkerContextCreated(int worker_id, + const CefString& url, + CefRefPtr context) { + RenderDelegateSet::iterator it = render_delegates_.begin(); + for (; it != render_delegates_.end(); ++it) + (*it)->OnWorkerContextCreated(this, worker_id, url, context); +} + +void ClientApp::OnWorkerContextReleased(int worker_id, + const CefString& url, + CefRefPtr context) { + RenderDelegateSet::iterator it = render_delegates_.begin(); + for (; it != render_delegates_.end(); ++it) + (*it)->OnWorkerContextReleased(this, worker_id, url, context); +} + +void ClientApp::OnWorkerUncaughtException( + int worker_id, + const CefString& url, + CefRefPtr context, + CefRefPtr exception, + CefRefPtr stackTrace) { + RenderDelegateSet::iterator it = render_delegates_.begin(); + for (; it != render_delegates_.end(); ++it) { + (*it)->OnWorkerUncaughtException(this, worker_id, url, context, exception, + stackTrace); + } +} + +void ClientApp::OnFocusedNodeChanged(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr node) { + RenderDelegateSet::iterator it = render_delegates_.begin(); + for (; it != render_delegates_.end(); ++it) + (*it)->OnFocusedNodeChanged(this, browser, frame, node); +} + +bool ClientApp::OnProcessMessageReceived( + CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) { + ASSERT(source_process == PID_BROWSER); + + bool handled = false; + + RenderDelegateSet::iterator it = render_delegates_.begin(); + for (; it != render_delegates_.end() && !handled; ++it) { + handled = (*it)->OnProcessMessageReceived(this, browser, source_process, + message); + } + + if (handled) + return true; + + // Execute the registered JavaScript callback if any. + if (!callback_map_.empty()) { + CefString message_name = message->GetName(); + CallbackMap::const_iterator it = callback_map_.find( + std::make_pair(message_name.ToString(), + browser->GetIdentifier())); + if (it != callback_map_.end()) { + // Keep a local reference to the objects. The callback may remove itself + // from the callback map. + CefRefPtr context = it->second.first; + CefRefPtr callback = it->second.second; + + // Enter the context. + context->Enter(); + + CefV8ValueList arguments; + + // First argument is the message name. + arguments.push_back(CefV8Value::CreateString(message_name)); + + // Second argument is the list of message arguments. + CefRefPtr list = message->GetArgumentList(); + CefRefPtr args = CefV8Value::CreateArray(list->GetSize()); + SetList(list, args); + arguments.push_back(args); + + // Execute the callback. + CefRefPtr retval = callback->ExecuteFunction(NULL, arguments); + if (retval.get()) { + if (retval->IsBool()) + handled = retval->GetBoolValue(); + } + + // Exit the context. + context->Exit(); + } + } + + return handled; +} diff --git a/cef3/tests/cefclient/client_app.h b/cef3/tests/cefclient/client_app.h new file mode 100644 index 000000000..0e371d1b5 --- /dev/null +++ b/cef3/tests/cefclient/client_app.h @@ -0,0 +1,230 @@ +// Copyright (c) 2013 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_APP_H_ +#define CEF_TESTS_CEFCLIENT_CLIENT_APP_H_ +#pragma once + +#include +#include +#include +#include +#include +#include "include/cef_app.h" + +class ClientApp : public CefApp, + public CefBrowserProcessHandler, + public CefRenderProcessHandler { + public: + // Interface for browser delegates. All BrowserDelegates must be returned via + // CreateBrowserDelegates. Do not perform work in the BrowserDelegate + // constructor. See CefBrowserProcessHandler for documentation. + class BrowserDelegate : public virtual CefBase { + public: + virtual void OnContextInitialized(CefRefPtr app) {} + + virtual void OnBeforeChildProcessLaunch( + CefRefPtr app, + CefRefPtr command_line) {} + + virtual void OnRenderProcessThreadCreated( + CefRefPtr app, + CefRefPtr extra_info) {} + }; + + typedef std::set > BrowserDelegateSet; + + // Interface for renderer delegates. All RenderDelegates must be returned via + // CreateRenderDelegates. Do not perform work in the RenderDelegate + // constructor. See CefRenderProcessHandler for documentation. + class RenderDelegate : public virtual CefBase { + public: + virtual void OnRenderThreadCreated(CefRefPtr app, + CefRefPtr extra_info) {} + + virtual void OnWebKitInitialized(CefRefPtr app) {} + + virtual void OnBrowserCreated(CefRefPtr app, + CefRefPtr browser) {} + + virtual void OnBrowserDestroyed(CefRefPtr app, + CefRefPtr browser) {} + + virtual bool OnBeforeNavigation(CefRefPtr app, + CefRefPtr browser, + CefRefPtr frame, + CefRefPtr request, + cef_navigation_type_t navigation_type, + bool is_redirect) { + return false; + } + + virtual void OnContextCreated(CefRefPtr app, + CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context) {} + + virtual void OnContextReleased(CefRefPtr app, + CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context) {} + + virtual void OnUncaughtException(CefRefPtr app, + CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context, + CefRefPtr exception, + CefRefPtr stackTrace) {} + + virtual void OnWorkerContextCreated(CefRefPtr app, + int worker_id, + const CefString& url, + CefRefPtr context) {} + + virtual void OnWorkerContextReleased(CefRefPtr app, + int worker_id, + const CefString& url, + CefRefPtr context) {} + + virtual void OnWorkerUncaughtException( + CefRefPtr app, + int worker_id, + const CefString& url, + CefRefPtr context, + CefRefPtr exception, + CefRefPtr stackTrace) {} + + virtual void OnFocusedNodeChanged(CefRefPtr app, + CefRefPtr browser, + CefRefPtr frame, + CefRefPtr node) {} + + // Called when a process message is received. Return true if the message was + // handled and should not be passed on to other handlers. RenderDelegates + // should check for unique message names to avoid interfering with each + // other. + virtual bool OnProcessMessageReceived( + CefRefPtr app, + CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) { + return false; + } + }; + + typedef std::set > RenderDelegateSet; + + ClientApp(); + + // Set a JavaScript callback for the specified |message_name| and |browser_id| + // combination. Will automatically be removed when the associated context is + // released. Callbacks can also be set in JavaScript using the + // app.setMessageCallback function. + void SetMessageCallback(const std::string& message_name, + int browser_id, + CefRefPtr context, + CefRefPtr function); + + // Removes the JavaScript callback for the specified |message_name| and + // |browser_id| combination. Returns true if a callback was removed. Callbacks + // can also be removed in JavaScript using the app.removeMessageCallback + // function. + bool RemoveMessageCallback(const std::string& message_name, + int browser_id); + + private: + // Creates all of the BrowserDelegate objects. Implemented in + // client_app_delegates. + static void CreateBrowserDelegates(BrowserDelegateSet& delegates); + + // Creates all of the RenderDelegate objects. Implemented in + // client_app_delegates. + static void CreateRenderDelegates(RenderDelegateSet& delegates); + + // Registers custom schemes. Implemented in client_app_delegates. + static void RegisterCustomSchemes(CefRefPtr registrar, + std::vector& cookiable_schemes); + + // CefApp methods. + virtual void OnRegisterCustomSchemes( + CefRefPtr registrar) OVERRIDE { + RegisterCustomSchemes(registrar, cookieable_schemes_); + } + virtual CefRefPtr GetBrowserProcessHandler() + OVERRIDE { return this; } + virtual CefRefPtr GetRenderProcessHandler() + OVERRIDE { return this; } + + // CefBrowserProcessHandler methods. + virtual void OnContextInitialized() OVERRIDE; + virtual void OnBeforeChildProcessLaunch( + CefRefPtr command_line) OVERRIDE; + virtual void OnRenderProcessThreadCreated(CefRefPtr extra_info) + OVERRIDE; + + // CefRenderProcessHandler methods. + virtual void OnRenderThreadCreated(CefRefPtr extra_info) + OVERRIDE; + virtual void OnWebKitInitialized() OVERRIDE; + virtual void OnBrowserCreated(CefRefPtr browser) OVERRIDE; + virtual void OnBrowserDestroyed(CefRefPtr browser) OVERRIDE; + virtual bool OnBeforeNavigation(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr request, + NavigationType navigation_type, + bool is_redirect) OVERRIDE; + virtual void OnContextCreated(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context) OVERRIDE; + virtual void OnContextReleased(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context) OVERRIDE; + virtual void OnUncaughtException(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context, + CefRefPtr exception, + CefRefPtr stackTrace) + OVERRIDE; + virtual void OnWorkerContextCreated( + int worker_id, + const CefString& url, + CefRefPtr context) OVERRIDE; + virtual void OnWorkerContextReleased( + int worker_id, + const CefString& url, + CefRefPtr context) OVERRIDE; + virtual void OnWorkerUncaughtException( + int worker_id, + const CefString& url, + CefRefPtr context, + CefRefPtr exception, + CefRefPtr stackTrace) + OVERRIDE; + virtual void OnFocusedNodeChanged(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr node) OVERRIDE; + virtual bool OnProcessMessageReceived( + CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) OVERRIDE; + + // Map of message callbacks. + typedef std::map, + std::pair, CefRefPtr > > + CallbackMap; + CallbackMap callback_map_; + + // Set of supported BrowserDelegates. + BrowserDelegateSet browser_delegates_; + + // Set of supported RenderDelegates. + RenderDelegateSet render_delegates_; + + // Schemes that will be registered with the global cookie manager. + std::vector cookieable_schemes_; + + IMPLEMENT_REFCOUNTING(ClientApp); +}; + +#endif // CEF_TESTS_CEFCLIENT_CLIENT_APP_H_ diff --git a/cef3/tests/cefclient/client_app_delegates.cpp b/cef3/tests/cefclient/client_app_delegates.cpp new file mode 100644 index 000000000..23f16db40 --- /dev/null +++ b/cef3/tests/cefclient/client_app_delegates.cpp @@ -0,0 +1,27 @@ +// 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" +#include "cefclient/client_renderer.h" +#include "cefclient/dom_test.h" +#include "cefclient/performance_test.h" +#include "cefclient/scheme_test.h" + +// static +void ClientApp::CreateBrowserDelegates(BrowserDelegateSet& delegates) { +} + +// static +void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) { + client_renderer::CreateRenderDelegates(delegates); + dom_test::CreateRenderDelegates(delegates); + performance_test::CreateRenderDelegates(delegates); +} + +// static +void ClientApp::RegisterCustomSchemes( + CefRefPtr registrar, + std::vector& cookiable_schemes) { + scheme_test::RegisterCustomSchemes(registrar, cookiable_schemes); +} diff --git a/cef3/tests/cefclient/client_handler.cpp b/cef3/tests/cefclient/client_handler.cpp new file mode 100644 index 000000000..3b5630eb8 --- /dev/null +++ b/cef3/tests/cefclient/client_handler.cpp @@ -0,0 +1,778 @@ +// Copyright (c) 2013 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_handler.h" +#include +#include +#include +#include +#include "include/cef_browser.h" +#include "include/cef_frame.h" +#include "include/cef_path_util.h" +#include "include/cef_process_util.h" +#include "include/cef_runnable.h" +#include "include/cef_trace.h" +#include "include/cef_url.h" +#include "include/wrapper/cef_stream_resource_handler.h" +#include "cefclient/binding_test.h" +#include "cefclient/cefclient.h" +#include "cefclient/client_renderer.h" +#include "cefclient/client_switches.h" +#include "cefclient/dialog_test.h" +#include "cefclient/dom_test.h" +#include "cefclient/resource_util.h" +#include "cefclient/string_util.h" +#include "cefclient/window_test.h" + +namespace { + +// Custom menu command Ids. +enum client_menu_ids { + CLIENT_ID_SHOW_DEVTOOLS = MENU_ID_USER_FIRST, + CLIENT_ID_TESTMENU_SUBMENU, + CLIENT_ID_TESTMENU_CHECKITEM, + CLIENT_ID_TESTMENU_RADIOITEM1, + CLIENT_ID_TESTMENU_RADIOITEM2, + CLIENT_ID_TESTMENU_RADIOITEM3, +}; + +const char kTestOrigin[] = "http://tests/"; + +// Retrieve the file name and mime type based on the specified url. +bool ParseTestUrl(const std::string& url, + std::string* file_name, + std::string* mime_type) { + // Retrieve the path component. + CefURLParts parts; + CefParseURL(url, parts); + std::string file = CefString(&parts.path); + if (file.size() < 2) + return false; + + // Remove the leading slash. + file = file.substr(1); + + // Verify that the file name is valid. + for(size_t i = 0; i < file.size(); ++i) { + const char c = file[i]; + if (!isalpha(c) && !isdigit(c) && c != '_' && c != '.') + return false; + } + + // Determine the mime type based on the file extension, if any. + size_t pos = file.rfind("."); + if (pos != std::string::npos) { + std::string ext = file.substr(pos + 1); + if (ext == "html") + *mime_type = "text/html"; + else if (ext == "png") + *mime_type = "image/png"; + else + return false; + } else { + // Default to an html extension if none is specified. + *mime_type = "text/html"; + file += ".html"; + } + + *file_name = file; + return true; +} + +} // namespace + +int ClientHandler::m_BrowserCount = 0; + +ClientHandler::ClientHandler() + : m_MainHwnd(NULL), + m_BrowserId(0), + m_bIsClosing(false), + m_EditHwnd(NULL), + m_BackHwnd(NULL), + m_ForwardHwnd(NULL), + m_StopHwnd(NULL), + m_ReloadHwnd(NULL), + m_bFocusOnEditableField(false) { + CreateProcessMessageDelegates(process_message_delegates_); + + // Read command line settings. + CefRefPtr command_line = + CefCommandLine::GetGlobalCommandLine(); + + if (command_line->HasSwitch(cefclient::kUrl)) + m_StartupURL = command_line->GetSwitchValue(cefclient::kUrl); + if (m_StartupURL.empty()) + m_StartupURL = "http://www.google.com/"; + + // Also use external dev tools if off-screen rendering is enabled since we + // disallow popup windows. + m_bExternalDevTools = + command_line->HasSwitch(cefclient::kExternalDevTools) || + AppIsOffScreenRenderingEnabled(); + + m_bMouseCursorChangeDisabled = + command_line->HasSwitch(cefclient::kMouseCursorChangeDisabled); +} + +ClientHandler::~ClientHandler() { +} + +bool ClientHandler::OnProcessMessageReceived( + CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) { + // Check for messages from the client renderer. + std::string message_name = message->GetName(); + if (message_name == client_renderer::kFocusedNodeChangedMessage) { + // A message is sent from ClientRenderDelegate to tell us whether the + // currently focused DOM node is editable. Use of |m_bFocusOnEditableField| + // is redundant with CefKeyEvent.focus_on_editable_field in OnPreKeyEvent + // but is useful for demonstration purposes. + m_bFocusOnEditableField = message->GetArgumentList()->GetBool(0); + return true; + } + + bool handled = false; + + // Execute delegate callbacks. + ProcessMessageDelegateSet::iterator it = process_message_delegates_.begin(); + for (; it != process_message_delegates_.end() && !handled; ++it) { + handled = (*it)->OnProcessMessageReceived(this, browser, source_process, + message); + } + + return handled; +} + +void ClientHandler::OnBeforeContextMenu( + CefRefPtr browser, + CefRefPtr frame, + CefRefPtr params, + CefRefPtr model) { + if ((params->GetTypeFlags() & (CM_TYPEFLAG_PAGE | CM_TYPEFLAG_FRAME)) != 0) { + // Add a separator if the menu already has items. + if (model->GetCount() > 0) + model->AddSeparator(); + + // Add a "Show DevTools" item to all context menus. + model->AddItem(CLIENT_ID_SHOW_DEVTOOLS, "&Show DevTools"); + + CefString devtools_url = browser->GetHost()->GetDevToolsURL(true); + if (devtools_url.empty() || + m_OpenDevToolsURLs.find(devtools_url) != m_OpenDevToolsURLs.end()) { + // Disable the menu option if DevTools isn't enabled or if a window is + // already open for the current URL. + model->SetEnabled(CLIENT_ID_SHOW_DEVTOOLS, false); + } + + // Test context menu features. + BuildTestMenu(model); + } +} + +bool ClientHandler::OnContextMenuCommand( + CefRefPtr browser, + CefRefPtr frame, + CefRefPtr params, + int command_id, + EventFlags event_flags) { + switch (command_id) { + case CLIENT_ID_SHOW_DEVTOOLS: + ShowDevTools(browser); + return true; + default: // Allow default handling, if any. + return ExecuteTestMenu(command_id); + } +} + +void ClientHandler::OnLoadingStateChange(CefRefPtr browser, + bool isLoading, + bool canGoBack, + bool canGoForward) { + REQUIRE_UI_THREAD(); + SetLoading(isLoading); + SetNavState(canGoBack, canGoForward); +} + +bool ClientHandler::OnConsoleMessage(CefRefPtr browser, + const CefString& message, + const CefString& source, + int line) { + REQUIRE_UI_THREAD(); + + bool first_message; + std::string logFile; + + { + AutoLock lock_scope(this); + + first_message = m_LogFile.empty(); + if (first_message) { + std::stringstream ss; + ss << AppGetWorkingDirectory(); +#if defined(OS_WIN) + ss << "\\"; +#else + ss << "/"; +#endif + ss << "console.log"; + m_LogFile = ss.str(); + } + logFile = m_LogFile; + } + + FILE* file = fopen(logFile.c_str(), "a"); + if (file) { + std::stringstream ss; + ss << "Message: " << std::string(message) << "\r\nSource: " << + std::string(source) << "\r\nLine: " << line << + "\r\n-----------------------\r\n"; + fputs(ss.str().c_str(), file); + fclose(file); + + if (first_message) + SendNotification(NOTIFY_CONSOLE_MESSAGE); + } + + return false; +} + +void ClientHandler::OnBeforeDownload( + CefRefPtr browser, + CefRefPtr download_item, + const CefString& suggested_name, + CefRefPtr callback) { + REQUIRE_UI_THREAD(); + // Continue the download and show the "Save As" dialog. + callback->Continue(GetDownloadPath(suggested_name), true); +} + +void ClientHandler::OnDownloadUpdated( + CefRefPtr browser, + CefRefPtr download_item, + CefRefPtr callback) { + REQUIRE_UI_THREAD(); + if (download_item->IsComplete()) { + SetLastDownloadFile(download_item->GetFullPath()); + SendNotification(NOTIFY_DOWNLOAD_COMPLETE); + } +} + +void ClientHandler::OnRequestGeolocationPermission( + CefRefPtr browser, + const CefString& requesting_url, + int request_id, + CefRefPtr callback) { + // Allow geolocation access from all websites. + callback->Continue(true); +} + +bool ClientHandler::OnPreKeyEvent(CefRefPtr browser, + const CefKeyEvent& event, + CefEventHandle os_event, + bool* is_keyboard_shortcut) { + if (!event.focus_on_editable_field && event.windows_key_code == 0x20) { + // Special handling for the space character when an input element does not + // have focus. Handling the event in OnPreKeyEvent() keeps the event from + // being processed in the renderer. If we instead handled the event in the + // OnKeyEvent() method the space key would cause the window to scroll in + // addition to showing the alert box. + if (event.type == KEYEVENT_RAWKEYDOWN) { + browser->GetMainFrame()->ExecuteJavaScript( + "alert('You pressed the space bar!');", "", 0); + } + return true; + } + + return false; +} + +bool ClientHandler::OnBeforePopup(CefRefPtr browser, + CefRefPtr frame, + const CefString& target_url, + const CefString& target_frame_name, + const CefPopupFeatures& popupFeatures, + CefWindowInfo& windowInfo, + CefRefPtr& client, + CefBrowserSettings& settings, + bool* no_javascript_access) { + if (browser->GetHost()->IsWindowRenderingDisabled()) { + // Cancel popups in off-screen rendering mode. + return true; + } + return false; +} + +void ClientHandler::OnAfterCreated(CefRefPtr browser) { + REQUIRE_UI_THREAD(); + + // Disable mouse cursor change if requested via the command-line flag. + if (m_bMouseCursorChangeDisabled) + browser->GetHost()->SetMouseCursorChangeDisabled(true); + + AutoLock lock_scope(this); + if (!m_Browser.get()) { + // We need to keep the main child window, but not popup windows + m_Browser = browser; + m_BrowserId = browser->GetIdentifier(); + } else if (browser->IsPopup()) { + // Add to the list of popup browsers. + m_PopupBrowsers.push_back(browser); + } + + m_BrowserCount++; +} + +bool ClientHandler::DoClose(CefRefPtr browser) { + REQUIRE_UI_THREAD(); + + // Closing the main window requires special handling. See the DoClose() + // documentation in the CEF header for a detailed destription of this + // process. + if (m_BrowserId == browser->GetIdentifier()) { + // Notify the browser that the parent window is about to close. + browser->GetHost()->ParentWindowWillClose(); + + // Set a flag to indicate that the window close should be allowed. + m_bIsClosing = true; + } + + // Allow the close. For windowed browsers this will result in the OS close + // event being sent. + return false; +} + +void ClientHandler::OnBeforeClose(CefRefPtr browser) { + REQUIRE_UI_THREAD(); + + if (m_BrowserId == browser->GetIdentifier()) { + // Free the browser pointer so that the browser can be destroyed + m_Browser = NULL; + + if (m_OSRHandler.get()) { + m_OSRHandler->OnBeforeClose(browser); + m_OSRHandler = NULL; + } + } else if (browser->IsPopup()) { + // Remove the record for DevTools popup windows. + std::set::iterator it = + m_OpenDevToolsURLs.find(browser->GetMainFrame()->GetURL()); + if (it != m_OpenDevToolsURLs.end()) + m_OpenDevToolsURLs.erase(it); + + // Remove from the browser popup list. + BrowserList::iterator bit = m_PopupBrowsers.begin(); + for (; bit != m_PopupBrowsers.end(); ++bit) { + if ((*bit)->IsSame(browser)) { + m_PopupBrowsers.erase(bit); + break; + } + } + } + + if (--m_BrowserCount == 0) { + // All browser windows have closed. Quit the application message loop. + AppQuitMessageLoop(); + } +} + +void ClientHandler::OnLoadStart(CefRefPtr browser, + CefRefPtr frame) { + REQUIRE_UI_THREAD(); + + if (m_BrowserId == browser->GetIdentifier() && frame->IsMain()) { + // We've just started loading a page + SetLoading(true); + } +} + +void ClientHandler::OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) { + REQUIRE_UI_THREAD(); + + if (m_BrowserId == browser->GetIdentifier() && frame->IsMain()) { + // We've just finished loading a page + SetLoading(false); + + // Continue the DOM test. + if (frame->GetURL() == dom_test::kTestUrl) + dom_test::OnLoadEnd(browser); + } +} + +void ClientHandler::OnLoadError(CefRefPtr browser, + CefRefPtr frame, + ErrorCode errorCode, + const CefString& errorText, + const CefString& failedUrl) { + REQUIRE_UI_THREAD(); + + // Don't display an error for downloaded files. + if (errorCode == ERR_ABORTED) + return; + + // Don't display an error for external protocols that we allow the OS to + // handle. See OnProtocolExecution(). + if (errorCode == ERR_UNKNOWN_URL_SCHEME) { + std::string urlStr = frame->GetURL(); + if (urlStr.find("spotify:") == 0) + return; + } + + // Display a load error message. + std::stringstream ss; + ss << "

Failed to load URL " << std::string(failedUrl) << + " with error " << std::string(errorText) << " (" << errorCode << + ").

"; + frame->LoadString(ss.str(), failedUrl); +} + +void ClientHandler::OnRenderProcessTerminated(CefRefPtr browser, + TerminationStatus status) { + // Load the startup URL if that's not the website that we terminated on. + CefRefPtr frame = browser->GetMainFrame(); + std::string url = frame->GetURL(); + std::transform(url.begin(), url.end(), url.begin(), tolower); + + std::string startupURL = GetStartupURL(); + if (url.find(startupURL) != 0) + frame->LoadURL(startupURL); +} + +CefRefPtr ClientHandler::GetResourceHandler( + CefRefPtr browser, + CefRefPtr frame, + CefRefPtr request) { + std::string url = request->GetURL(); + if (url.find(kTestOrigin) == 0) { + // Handle URLs in the test origin. + std::string file_name, mime_type; + if (ParseTestUrl(url, &file_name, &mime_type)) { + if (file_name == "request.html") { + // Show the request contents. + std::string dump; + DumpRequestContents(request, dump); + CefRefPtr stream = + CefStreamReader::CreateForData( + static_cast(const_cast(dump.c_str())), + dump.size()); + ASSERT(stream.get()); + return new CefStreamResourceHandler("text/plain", stream); + } else { + // Load the resource from file. + CefRefPtr stream = + GetBinaryResourceReader(file_name.c_str()); + if (stream.get()) + return new CefStreamResourceHandler(mime_type, stream); + } + } + } + + return NULL; +} + +bool ClientHandler::OnQuotaRequest(CefRefPtr browser, + const CefString& origin_url, + int64 new_size, + CefRefPtr callback) { + static const int64 max_size = 1024 * 1024 * 20; // 20mb. + + // Grant the quota request if the size is reasonable. + callback->Continue(new_size <= max_size); + return true; +} + +void ClientHandler::OnProtocolExecution(CefRefPtr browser, + const CefString& url, + bool& allow_os_execution) { + std::string urlStr = url; + + // Allow OS execution of Spotify URIs. + if (urlStr.find("spotify:") == 0) + allow_os_execution = true; +} + +bool ClientHandler::GetRootScreenRect(CefRefPtr browser, + CefRect& rect) { + if (!m_OSRHandler.get()) + return false; + return m_OSRHandler->GetRootScreenRect(browser, rect); +} + +bool ClientHandler::GetViewRect(CefRefPtr browser, CefRect& rect) { + if (!m_OSRHandler.get()) + return false; + return m_OSRHandler->GetViewRect(browser, rect); +} + +bool ClientHandler::GetScreenPoint(CefRefPtr browser, + int viewX, + int viewY, + int& screenX, + int& screenY) { + if (!m_OSRHandler.get()) + return false; + return m_OSRHandler->GetScreenPoint(browser, viewX, viewY, screenX, screenY); +} + +void ClientHandler::OnPopupShow(CefRefPtr browser, + bool show) { + if (!m_OSRHandler.get()) + return; + return m_OSRHandler->OnPopupShow(browser, show); +} + +void ClientHandler::OnPopupSize(CefRefPtr browser, + const CefRect& rect) { + if (!m_OSRHandler.get()) + return; + return m_OSRHandler->OnPopupSize(browser, rect); +} + +void ClientHandler::OnPaint(CefRefPtr browser, + PaintElementType type, + const RectList& dirtyRects, + const void* buffer, + int width, + int height) { + if (!m_OSRHandler.get()) + return; + m_OSRHandler->OnPaint(browser, type, dirtyRects, buffer, width, height); +} + +void ClientHandler::OnCursorChange(CefRefPtr browser, + CefCursorHandle cursor) { + if (!m_OSRHandler.get()) + return; + m_OSRHandler->OnCursorChange(browser, cursor); +} + +void ClientHandler::SetMainHwnd(CefWindowHandle hwnd) { + AutoLock lock_scope(this); + m_MainHwnd = hwnd; +} + +void ClientHandler::SetEditHwnd(CefWindowHandle hwnd) { + AutoLock lock_scope(this); + m_EditHwnd = hwnd; +} + +void ClientHandler::SetButtonHwnds(CefWindowHandle backHwnd, + CefWindowHandle forwardHwnd, + CefWindowHandle reloadHwnd, + CefWindowHandle stopHwnd) { + AutoLock lock_scope(this); + m_BackHwnd = backHwnd; + m_ForwardHwnd = forwardHwnd; + m_ReloadHwnd = reloadHwnd; + m_StopHwnd = stopHwnd; +} + +void ClientHandler::CloseAllBrowsers(bool force_close) { + if (!CefCurrentlyOn(TID_UI)) { + // Execute on the UI thread. + CefPostTask(TID_UI, + NewCefRunnableMethod(this, &ClientHandler::CloseAllBrowsers, + force_close)); + return; + } + + if (!m_PopupBrowsers.empty()) { + // Request that any popup browsers close. + BrowserList::const_iterator it = m_PopupBrowsers.begin(); + for (; it != m_PopupBrowsers.end(); ++it) + (*it)->GetHost()->CloseBrowser(force_close); + } + + if (m_Browser.get()) { + // Request that the main browser close. + m_Browser->GetHost()->CloseBrowser(force_close); + } +} + +std::string ClientHandler::GetLogFile() { + AutoLock lock_scope(this); + return m_LogFile; +} + +void ClientHandler::SetLastDownloadFile(const std::string& fileName) { + AutoLock lock_scope(this); + m_LastDownloadFile = fileName; +} + +std::string ClientHandler::GetLastDownloadFile() { + AutoLock lock_scope(this); + return m_LastDownloadFile; +} + +void ClientHandler::ShowDevTools(CefRefPtr browser) { + std::string devtools_url = browser->GetHost()->GetDevToolsURL(true); + if (!devtools_url.empty()) { + if (m_bExternalDevTools) { + // Open DevTools in an external browser window. + LaunchExternalBrowser(devtools_url); + } else if (m_OpenDevToolsURLs.find(devtools_url) == + m_OpenDevToolsURLs.end()) { + // Open DevTools in a popup window. + m_OpenDevToolsURLs.insert(devtools_url); + browser->GetMainFrame()->ExecuteJavaScript( + "window.open('" + devtools_url + "');", "about:blank", 0); + } + } +} + +// static +void ClientHandler::LaunchExternalBrowser(const std::string& url) { + if (CefCurrentlyOn(TID_PROCESS_LAUNCHER)) { + // Retrieve the current executable path. + CefString file_exe; + if (!CefGetPath(PK_FILE_EXE, file_exe)) + return; + + // Create the command line. + CefRefPtr command_line = + CefCommandLine::CreateCommandLine(); + command_line->SetProgram(file_exe); + command_line->AppendSwitchWithValue(cefclient::kUrl, url); + + // Launch the process. + CefLaunchProcess(command_line); + } else { + // Execute on the PROCESS_LAUNCHER thread. + CefPostTask(TID_PROCESS_LAUNCHER, + NewCefRunnableFunction(&ClientHandler::LaunchExternalBrowser, url)); + } +} + +void ClientHandler::BeginTracing() { + if (CefCurrentlyOn(TID_UI)) { + class Client : public CefTraceClient, + public CefRunFileDialogCallback { + public: + explicit Client(CefRefPtr handler) + : handler_(handler), + trace_data_("{\"traceEvents\":["), + first_(true) { + } + + virtual void OnTraceDataCollected(const char* fragment, + size_t fragment_size) OVERRIDE { + if (first_) + first_ = false; + else + trace_data_.append(","); + trace_data_.append(fragment, fragment_size); + } + + virtual void OnEndTracingComplete() OVERRIDE { + REQUIRE_UI_THREAD(); + trace_data_.append("]}"); + + static const char kDefaultFileName[] = "trace.txt"; + std::string path = handler_->GetDownloadPath(kDefaultFileName); + if (path.empty()) + path = kDefaultFileName; + + handler_->GetBrowser()->GetHost()->RunFileDialog( + FILE_DIALOG_SAVE, CefString(), path, std::vector(), + this); + } + + virtual void OnFileDialogDismissed( + CefRefPtr browser_host, + const std::vector& file_paths) OVERRIDE { + if (!file_paths.empty()) + handler_->Save(file_paths.front(), trace_data_); + } + + private: + CefRefPtr handler_; + std::string trace_data_; + bool first_; + + IMPLEMENT_REFCOUNTING(Callback); + }; + + CefBeginTracing(new Client(this), CefString()); + } else { + CefPostTask(TID_UI, + NewCefRunnableMethod(this, &ClientHandler::BeginTracing)); + } +} + +void ClientHandler::EndTracing() { + if (CefCurrentlyOn(TID_UI)) { + CefEndTracingAsync(); + } else { + CefPostTask(TID_UI, + NewCefRunnableMethod(this, &ClientHandler::BeginTracing)); + } +} + +bool ClientHandler::Save(const std::string& path, const std::string& data) { + FILE* f = fopen(path.c_str(), "w"); + if (!f) + return false; + size_t total = 0; + do { + size_t write = fwrite(data.c_str() + total, 1, data.size() - total, f); + if (write == 0) + break; + total += write; + } while (total < data.size()); + fclose(f); + return true; +} + +// static +void ClientHandler::CreateProcessMessageDelegates( + ProcessMessageDelegateSet& delegates) { + // Create the binding test delegates. + binding_test::CreateProcessMessageDelegates(delegates); + + // Create the dialog test delegates. + dialog_test::CreateProcessMessageDelegates(delegates); + + // Create the window test delegates. + window_test::CreateProcessMessageDelegates(delegates); +} + +void ClientHandler::BuildTestMenu(CefRefPtr model) { + if (model->GetCount() > 0) + model->AddSeparator(); + + // Build the sub menu. + CefRefPtr submenu = + model->AddSubMenu(CLIENT_ID_TESTMENU_SUBMENU, "Context Menu Test"); + submenu->AddCheckItem(CLIENT_ID_TESTMENU_CHECKITEM, "Check Item"); + submenu->AddRadioItem(CLIENT_ID_TESTMENU_RADIOITEM1, "Radio Item 1", 0); + submenu->AddRadioItem(CLIENT_ID_TESTMENU_RADIOITEM2, "Radio Item 2", 0); + submenu->AddRadioItem(CLIENT_ID_TESTMENU_RADIOITEM3, "Radio Item 3", 0); + + // Check the check item. + if (m_TestMenuState.check_item) + submenu->SetChecked(CLIENT_ID_TESTMENU_CHECKITEM, true); + + // Check the selected radio item. + submenu->SetChecked( + CLIENT_ID_TESTMENU_RADIOITEM1 + m_TestMenuState.radio_item, true); +} + +bool ClientHandler::ExecuteTestMenu(int command_id) { + if (command_id == CLIENT_ID_TESTMENU_CHECKITEM) { + // Toggle the check item. + m_TestMenuState.check_item ^= 1; + return true; + } else if (command_id >= CLIENT_ID_TESTMENU_RADIOITEM1 && + command_id <= CLIENT_ID_TESTMENU_RADIOITEM3) { + // Store the selected radio item. + m_TestMenuState.radio_item = (command_id - CLIENT_ID_TESTMENU_RADIOITEM1); + return true; + } + + // Allow default handling to proceed. + return false; +} + diff --git a/cef3/tests/cefclient/client_handler.h b/cef3/tests/cefclient/client_handler.h new file mode 100644 index 000000000..ef8afe962 --- /dev/null +++ b/cef3/tests/cefclient/client_handler.h @@ -0,0 +1,341 @@ +// 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_ +#pragma once + +#include +#include +#include +#include +#include "include/cef_client.h" +#include "cefclient/util.h" + + +// Define this value to redirect all popup URLs to the main application browser +// window. +// #define TEST_REDIRECT_POPUP_URLS + + +// ClientHandler implementation. +class ClientHandler : public CefClient, + public CefContextMenuHandler, + public CefDisplayHandler, + public CefDownloadHandler, + public CefGeolocationHandler, + public CefKeyboardHandler, + public CefLifeSpanHandler, + public CefLoadHandler, + public CefRenderHandler, + public CefRequestHandler { + public: + // Interface for process message delegates. Do not perform work in the + // RenderDelegate constructor. + class ProcessMessageDelegate : public virtual CefBase { + public: + // Called when a process message is received. Return true if the message was + // handled and should not be passed on to other handlers. + // ProcessMessageDelegates should check for unique message names to avoid + // interfering with each other. + virtual bool OnProcessMessageReceived( + CefRefPtr handler, + CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) { + return false; + } + }; + + typedef std::set > + ProcessMessageDelegateSet; + + // Interface implemented to handle off-screen rendering. + class RenderHandler : public CefRenderHandler { + public: + virtual void OnBeforeClose(CefRefPtr browser) =0; + }; + + ClientHandler(); + virtual ~ClientHandler(); + + // CefClient methods + virtual CefRefPtr GetContextMenuHandler() OVERRIDE { + return this; + } + virtual CefRefPtr GetDisplayHandler() OVERRIDE { + return this; + } + virtual CefRefPtr GetDownloadHandler() OVERRIDE { + return this; + } + virtual CefRefPtr GetGeolocationHandler() OVERRIDE { + return this; + } + virtual CefRefPtr GetKeyboardHandler() OVERRIDE { + return this; + } + virtual CefRefPtr GetLifeSpanHandler() OVERRIDE { + return this; + } + virtual CefRefPtr GetLoadHandler() OVERRIDE { + return this; + } + virtual CefRefPtr GetRenderHandler() OVERRIDE { + return this; + } + virtual CefRefPtr GetRequestHandler() OVERRIDE { + return this; + } + virtual bool OnProcessMessageReceived(CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) + OVERRIDE; + + // CefContextMenuHandler methods + virtual void OnBeforeContextMenu(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr params, + CefRefPtr model) OVERRIDE; + virtual bool OnContextMenuCommand(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr params, + int command_id, + EventFlags event_flags) OVERRIDE; + + // CefDisplayHandler methods + virtual void OnLoadingStateChange(CefRefPtr browser, + bool isLoading, + bool canGoBack, + bool canGoForward) OVERRIDE; + virtual void OnAddressChange(CefRefPtr browser, + CefRefPtr frame, + const CefString& url) OVERRIDE; + virtual void OnTitleChange(CefRefPtr browser, + const CefString& title) OVERRIDE; + virtual bool OnConsoleMessage(CefRefPtr browser, + const CefString& message, + const CefString& source, + int line) OVERRIDE; + + // CefDownloadHandler methods + virtual void OnBeforeDownload( + CefRefPtr browser, + CefRefPtr download_item, + const CefString& suggested_name, + CefRefPtr callback) OVERRIDE; + virtual void OnDownloadUpdated( + CefRefPtr browser, + CefRefPtr download_item, + CefRefPtr callback) OVERRIDE; + + // CefGeolocationHandler methods + virtual void OnRequestGeolocationPermission( + CefRefPtr browser, + const CefString& requesting_url, + int request_id, + CefRefPtr callback) OVERRIDE; + + // CefKeyboardHandler methods + virtual bool OnPreKeyEvent(CefRefPtr browser, + const CefKeyEvent& event, + CefEventHandle os_event, + bool* is_keyboard_shortcut) OVERRIDE; + + // CefLifeSpanHandler methods + virtual bool OnBeforePopup(CefRefPtr browser, + CefRefPtr frame, + const CefString& target_url, + const CefString& target_frame_name, + const CefPopupFeatures& popupFeatures, + CefWindowInfo& windowInfo, + CefRefPtr& client, + CefBrowserSettings& settings, + bool* no_javascript_access) OVERRIDE; + virtual void OnAfterCreated(CefRefPtr browser) OVERRIDE; + virtual bool DoClose(CefRefPtr browser) OVERRIDE; + virtual void OnBeforeClose(CefRefPtr browser) OVERRIDE; + + // CefLoadHandler methods + virtual void OnLoadStart(CefRefPtr browser, + CefRefPtr frame) OVERRIDE; + virtual void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) OVERRIDE; + virtual void OnLoadError(CefRefPtr browser, + CefRefPtr frame, + ErrorCode errorCode, + const CefString& errorText, + const CefString& failedUrl) OVERRIDE; + virtual void OnRenderProcessTerminated(CefRefPtr browser, + TerminationStatus status) OVERRIDE; + + // CefRequestHandler methods + virtual CefRefPtr GetResourceHandler( + CefRefPtr browser, + CefRefPtr frame, + CefRefPtr request) OVERRIDE; + virtual bool OnQuotaRequest(CefRefPtr browser, + const CefString& origin_url, + int64 new_size, + CefRefPtr callback) OVERRIDE; + virtual void OnProtocolExecution(CefRefPtr browser, + const CefString& url, + bool& allow_os_execution) OVERRIDE; + + // CefRenderHandler methods + virtual bool GetRootScreenRect(CefRefPtr browser, + CefRect& rect) OVERRIDE; + virtual bool GetViewRect(CefRefPtr browser, + CefRect& rect) OVERRIDE; + virtual bool GetScreenPoint(CefRefPtr browser, + int viewX, + int viewY, + int& screenX, + int& screenY) OVERRIDE; + virtual void OnPopupShow(CefRefPtr browser, bool show) OVERRIDE; + virtual void OnPopupSize(CefRefPtr browser, + const CefRect& rect) OVERRIDE; + virtual void OnPaint(CefRefPtr browser, + PaintElementType type, + const RectList& dirtyRects, + const void* buffer, + int width, + int height) OVERRIDE; + virtual void OnCursorChange(CefRefPtr browser, + CefCursorHandle cursor) OVERRIDE; + + void SetMainHwnd(CefWindowHandle hwnd); + CefWindowHandle GetMainHwnd() { return m_MainHwnd; } + void SetEditHwnd(CefWindowHandle hwnd); + void SetOSRHandler(CefRefPtr handler) { + m_OSRHandler = handler; + } + CefRefPtr GetOSRHandler() { return m_OSRHandler; } + void SetButtonHwnds(CefWindowHandle backHwnd, + CefWindowHandle forwardHwnd, + CefWindowHandle reloadHwnd, + CefWindowHandle stopHwnd); + + CefRefPtr GetBrowser() { return m_Browser; } + int GetBrowserId() { return m_BrowserId; } + + // Request that all existing browser windows close. + void CloseAllBrowsers(bool force_close); + + // Returns true if the main browser window is currently closing. Used in + // combination with DoClose() and the OS close notification to properly handle + // 'onbeforeunload' JavaScript events during window close. + bool IsClosing() { return m_bIsClosing; } + + std::string GetLogFile(); + + void SetLastDownloadFile(const std::string& fileName); + std::string GetLastDownloadFile(); + + // Send a notification to the application. Notifications should not block the + // caller. + enum NotificationType { + NOTIFY_CONSOLE_MESSAGE, + NOTIFY_DOWNLOAD_COMPLETE, + NOTIFY_DOWNLOAD_ERROR, + }; + void SendNotification(NotificationType type); + + void ShowDevTools(CefRefPtr browser); + + // Returns the startup URL. + std::string GetStartupURL() { return m_StartupURL; } + + // Create an external browser window that loads the specified URL. + static void LaunchExternalBrowser(const std::string& url); + + void BeginTracing(); + void EndTracing(); + + bool Save(const std::string& path, const std::string& data); + + protected: + void SetLoading(bool isLoading); + void SetNavState(bool canGoBack, bool canGoForward); + + // Create all of ProcessMessageDelegate objects. + static void CreateProcessMessageDelegates( + ProcessMessageDelegateSet& delegates); + + // Test context menu creation. + void BuildTestMenu(CefRefPtr model); + bool ExecuteTestMenu(int command_id); + struct TestMenuState { + TestMenuState() : check_item(true), radio_item(0) {} + bool check_item; + int radio_item; + } m_TestMenuState; + + // Returns the full download path for the specified file, or an empty path to + // use the default temp directory. + std::string GetDownloadPath(const std::string& file_name); + + // The child browser window + CefRefPtr m_Browser; + + // List of any popup browser windows. Only accessed on the CEF UI thread. + typedef std::list > BrowserList; + BrowserList m_PopupBrowsers; + + // The main frame window handle + CefWindowHandle m_MainHwnd; + + // The child browser id + int m_BrowserId; + + // True if the main browser window is currently closing. + bool m_bIsClosing; + + // The edit window handle + CefWindowHandle m_EditHwnd; + + // The button window handles + CefWindowHandle m_BackHwnd; + CefWindowHandle m_ForwardHwnd; + CefWindowHandle m_StopHwnd; + CefWindowHandle m_ReloadHwnd; + + CefRefPtr m_OSRHandler; + + // Support for logging. + std::string m_LogFile; + + // Support for downloading files. + std::string m_LastDownloadFile; + + // True if an editable field currently has focus. + bool m_bFocusOnEditableField; + + // Registered delegates. + ProcessMessageDelegateSet process_message_delegates_; + + // If true DevTools will be opened in an external browser window. + bool m_bExternalDevTools; + + // List of open DevTools URLs if not using an external browser window. + std::set m_OpenDevToolsURLs; + + // The startup URL. + std::string m_StartupURL; + + // True if mouse cursor change is disabled. + bool m_bMouseCursorChangeDisabled; + + // Number of currently existing browser windows. The application will exit + // when the number of windows reaches 0. + static int m_BrowserCount; + + // Include the default reference counting implementation. + IMPLEMENT_REFCOUNTING(ClientHandler); + // Include the default locking implementation. + IMPLEMENT_LOCKING(ClientHandler); +}; + +#endif // CEF_TESTS_CEFCLIENT_CLIENT_HANDLER_H_ diff --git a/cef3/tests/cefclient/client_handler_gtk.cpp b/cef3/tests/cefclient/client_handler_gtk.cpp new file mode 100644 index 000000000..2cd10e4c3 --- /dev/null +++ b/cef3/tests/cefclient/client_handler_gtk.cpp @@ -0,0 +1,59 @@ +// 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 +#include +#include "cefclient/client_handler.h" +#include "include/cef_browser.h" +#include "include/cef_frame.h" + +void ClientHandler::OnAddressChange(CefRefPtr browser, + CefRefPtr frame, + const CefString& url) { + REQUIRE_UI_THREAD(); + + if (m_BrowserId == browser->GetIdentifier() && frame->IsMain()) { + // Set the edit window text + std::string urlStr(url); + gtk_entry_set_text(GTK_ENTRY(m_EditHwnd), urlStr.c_str()); + } +} + +void ClientHandler::OnTitleChange(CefRefPtr browser, + const CefString& title) { + REQUIRE_UI_THREAD(); + + GtkWidget* window = gtk_widget_get_ancestor( + GTK_WIDGET(browser->GetHost()->GetWindowHandle()), + GTK_TYPE_WINDOW); + std::string titleStr(title); + gtk_window_set_title(GTK_WINDOW(window), titleStr.c_str()); +} + +void ClientHandler::SendNotification(NotificationType type) { + // TODO(port): Implement this method. +} + +void ClientHandler::SetLoading(bool isLoading) { + if (isLoading) + gtk_widget_set_sensitive(GTK_WIDGET(m_StopHwnd), true); + else + gtk_widget_set_sensitive(GTK_WIDGET(m_StopHwnd), false); +} + +void ClientHandler::SetNavState(bool canGoBack, bool canGoForward) { + if (canGoBack) + gtk_widget_set_sensitive(GTK_WIDGET(m_BackHwnd), true); + else + gtk_widget_set_sensitive(GTK_WIDGET(m_BackHwnd), false); + + if (canGoForward) + gtk_widget_set_sensitive(GTK_WIDGET(m_ForwardHwnd), true); + else + gtk_widget_set_sensitive(GTK_WIDGET(m_ForwardHwnd), false); +} + +std::string ClientHandler::GetDownloadPath(const std::string& file_name) { + return std::string(); +} diff --git a/cef3/tests/cefclient/client_handler_mac.mm b/cef3/tests/cefclient/client_handler_mac.mm new file mode 100644 index 000000000..0a6f91a40 --- /dev/null +++ b/cef3/tests/cefclient/client_handler_mac.mm @@ -0,0 +1,70 @@ +// 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. + +#import + +#include "cefclient/client_handler.h" +#include "include/cef_browser.h" +#include "include/cef_frame.h" +#include "cefclient/cefclient.h" + +void ClientHandler::OnAddressChange(CefRefPtr browser, + CefRefPtr frame, + const CefString& url) { + REQUIRE_UI_THREAD(); + + if (m_BrowserId == browser->GetIdentifier() && frame->IsMain()) { + // Set the edit window text + NSTextField* textField = (NSTextField*)m_EditHwnd; + std::string urlStr(url); + NSString* str = [NSString stringWithUTF8String:urlStr.c_str()]; + [textField setStringValue:str]; + } +} + +void ClientHandler::OnTitleChange(CefRefPtr browser, + const CefString& title) { + REQUIRE_UI_THREAD(); + + // Set the frame window title bar + NSView* view = (NSView*)browser->GetHost()->GetWindowHandle(); + NSWindow* window = [view window]; + std::string titleStr(title); + NSString* str = [NSString stringWithUTF8String:titleStr.c_str()]; + [window setTitle:str]; +} + +void ClientHandler::SendNotification(NotificationType type) { + SEL sel = nil; + switch(type) { + case NOTIFY_CONSOLE_MESSAGE: + sel = @selector(notifyConsoleMessage:); + break; + case NOTIFY_DOWNLOAD_COMPLETE: + sel = @selector(notifyDownloadComplete:); + break; + case NOTIFY_DOWNLOAD_ERROR: + sel = @selector(notifyDownloadError:); + break; + } + + if (sel == nil) + return; + + NSWindow* window = [AppGetMainHwnd() window]; + NSObject* delegate = [window delegate]; + [delegate performSelectorOnMainThread:sel withObject:nil waitUntilDone:NO]; +} + +void ClientHandler::SetLoading(bool isLoading) { + // TODO(port): Change button status. +} + +void ClientHandler::SetNavState(bool canGoBack, bool canGoForward) { + // TODO(port): Change button status. +} + +std::string ClientHandler::GetDownloadPath(const std::string& file_name) { + return std::string(); +} diff --git a/cef3/tests/cefclient/client_handler_win.cpp b/cef3/tests/cefclient/client_handler_win.cpp new file mode 100644 index 000000000..99bde8d47 --- /dev/null +++ b/cef3/tests/cefclient/client_handler_win.cpp @@ -0,0 +1,82 @@ +// 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 "cefclient/client_handler.h" + +#include +#include +#include + +#include "include/cef_browser.h" +#include "include/cef_frame.h" +#include "cefclient/resource.h" + +void ClientHandler::OnAddressChange(CefRefPtr browser, + CefRefPtr frame, + const CefString& url) { + REQUIRE_UI_THREAD(); + + if (m_BrowserId == browser->GetIdentifier() && frame->IsMain()) { + // Set the edit window text + SetWindowText(m_EditHwnd, std::wstring(url).c_str()); + } +} + +void ClientHandler::OnTitleChange(CefRefPtr browser, + const CefString& title) { + REQUIRE_UI_THREAD(); + + // Set the frame window title bar + CefWindowHandle hwnd = browser->GetHost()->GetWindowHandle(); + if (m_BrowserId == browser->GetIdentifier()) { + // The frame window will be the parent of the browser window + hwnd = GetParent(hwnd); + } + SetWindowText(hwnd, std::wstring(title).c_str()); +} + +void ClientHandler::SendNotification(NotificationType type) { + UINT id; + switch (type) { + case NOTIFY_CONSOLE_MESSAGE: + id = ID_WARN_CONSOLEMESSAGE; + break; + case NOTIFY_DOWNLOAD_COMPLETE: + id = ID_WARN_DOWNLOADCOMPLETE; + break; + case NOTIFY_DOWNLOAD_ERROR: + id = ID_WARN_DOWNLOADERROR; + break; + default: + return; + } + PostMessage(m_MainHwnd, WM_COMMAND, id, 0); +} + +void ClientHandler::SetLoading(bool isLoading) { + ASSERT(m_EditHwnd != NULL && m_ReloadHwnd != NULL && m_StopHwnd != NULL); + EnableWindow(m_EditHwnd, TRUE); + EnableWindow(m_ReloadHwnd, !isLoading); + EnableWindow(m_StopHwnd, isLoading); +} + +void ClientHandler::SetNavState(bool canGoBack, bool canGoForward) { + ASSERT(m_BackHwnd != NULL && m_ForwardHwnd != NULL); + EnableWindow(m_BackHwnd, canGoBack); + EnableWindow(m_ForwardHwnd, canGoForward); +} + +std::string ClientHandler::GetDownloadPath(const std::string& file_name) { + TCHAR szFolderPath[MAX_PATH]; + std::string path; + + // Save the file in the user's "My Documents" folder. + if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, + NULL, 0, szFolderPath))) { + path = CefString(szFolderPath); + path += "\\" + file_name; + } + + return path; +} diff --git a/cef3/tests/cefclient/client_renderer.cpp b/cef3/tests/cefclient/client_renderer.cpp new file mode 100644 index 000000000..17b5a43f3 --- /dev/null +++ b/cef3/tests/cefclient/client_renderer.cpp @@ -0,0 +1,52 @@ +// 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_renderer.h" + +#include +#include + +#include "include/cef_dom.h" +#include "cefclient/util.h" + +namespace client_renderer { + +const char kFocusedNodeChangedMessage[] = "ClientRenderer.FocusedNodeChanged"; + +namespace { + +class ClientRenderDelegate : public ClientApp::RenderDelegate { + public: + ClientRenderDelegate() + : last_node_is_editable_(false) { + } + + virtual void OnFocusedNodeChanged(CefRefPtr app, + CefRefPtr browser, + CefRefPtr frame, + CefRefPtr node) OVERRIDE { + bool is_editable = (node.get() && node->IsEditable()); + if (is_editable != last_node_is_editable_) { + // Notify the browser of the change in focused element type. + last_node_is_editable_ = is_editable; + CefRefPtr message = + CefProcessMessage::Create(kFocusedNodeChangedMessage); + message->GetArgumentList()->SetBool(0, is_editable); + browser->SendProcessMessage(PID_BROWSER, message); + } + } + + private: + bool last_node_is_editable_; + + IMPLEMENT_REFCOUNTING(ClientRenderDelegate); +}; + +} // namespace + +void CreateRenderDelegates(ClientApp::RenderDelegateSet& delegates) { + delegates.insert(new ClientRenderDelegate); +} + +} // namespace client_renderer diff --git a/cef3/tests/cefclient/client_renderer.h b/cef3/tests/cefclient/client_renderer.h new file mode 100644 index 000000000..37b08408d --- /dev/null +++ b/cef3/tests/cefclient/client_renderer.h @@ -0,0 +1,22 @@ +// 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. + +#ifndef CEF_TESTS_CEFCLIENT_CLIENT_RENDERER_H_ +#define CEF_TESTS_CEFCLIENT_CLIENT_RENDERER_H_ +#pragma once + +#include "include/cef_base.h" +#include "cefclient/client_app.h" + +namespace client_renderer { + +// Message sent when the focused node changes. +extern const char kFocusedNodeChangedMessage[]; + +// Create the render delegate. +void CreateRenderDelegates(ClientApp::RenderDelegateSet& delegates); + +} // namespace client_renderer + +#endif // CEF_TESTS_CEFCLIENT_CLIENT_RENDERER_H_ diff --git a/cef3/tests/cefclient/client_switches.cpp b/cef3/tests/cefclient/client_switches.cpp new file mode 100644 index 000000000..98c0a6901 --- /dev/null +++ b/cef3/tests/cefclient/client_switches.cpp @@ -0,0 +1,29 @@ +// Copyright (c) 2013 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. + +// This file is shared by cefclient and cef_unittests so don't include using +// a qualified path. +#include "client_switches.h" // NOLINT(build/include) + +namespace cefclient { + +// CEF and Chromium support a wide range of command-line switches. This file +// only contains command-line switches specific to the cefclient application. +// View CEF/Chromium documentation or search for *_switches.cc files in the +// Chromium source code to identify other existing command-line switches. +// Below is a partial listing of relevant *_switches.cc files: +// base/base_switches.cc +// cef/libcef/common/cef_switches.cc +// chrome/common/chrome_switches.cc (not all apply) +// content/public/common/content_switches.cc + +const char kMultiThreadedMessageLoop[] = "multi-threaded-message-loop"; +const char kCachePath[] = "cache-path"; +const char kUrl[] = "url"; +const char kExternalDevTools[] = "external-devtools"; +const char kOffScreenRenderingEnabled[] = "off-screen-rendering-enabled"; +const char kTransparentPaintingEnabled[] = "transparent-painting-enabled"; +const char kMouseCursorChangeDisabled[] = "mouse-cursor-change-disabled"; + +} // namespace cefclient diff --git a/cef3/tests/cefclient/client_switches.h b/cef3/tests/cefclient/client_switches.h new file mode 100644 index 000000000..f69d67713 --- /dev/null +++ b/cef3/tests/cefclient/client_switches.h @@ -0,0 +1,23 @@ +// Copyright (c) 2013 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. + +// Defines all of the command line switches used by cefclient. + +#ifndef CEF_TESTS_CEFCLIENT_CEFCLIENT_SWITCHES_H_ +#define CEF_TESTS_CEFCLIENT_CEFCLIENT_SWITCHES_H_ +#pragma once + +namespace cefclient { + +extern const char kMultiThreadedMessageLoop[]; +extern const char kCachePath[]; +extern const char kUrl[]; +extern const char kExternalDevTools[]; +extern const char kOffScreenRenderingEnabled[]; +extern const char kTransparentPaintingEnabled[]; +extern const char kMouseCursorChangeDisabled[]; + +} // namespace cefclient + +#endif // CEF_TESTS_CEFCLIENT_CEFCLIENT_SWITCHES_H_ diff --git a/cef3/tests/cefclient/dialog_test.cpp b/cef3/tests/cefclient/dialog_test.cpp new file mode 100644 index 000000000..a6171781d --- /dev/null +++ b/cef3/tests/cefclient/dialog_test.cpp @@ -0,0 +1,102 @@ +// 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/dialog_test.h" +#include "include/cef_browser.h" + +#include + +namespace dialog_test { + +namespace { + +const char* kTestUrl = "http://tests/dialogs"; +const char* kFileOpenMessageName = "DialogTest.FileOpen"; +const char* kFileOpenMultipleMessageName = "DialogTest.FileOpenMultiple"; +const char* kFileSaveMessageName = "DialogTest.FileSave"; + +class RunFileDialogCallback : public CefRunFileDialogCallback { + public: + explicit RunFileDialogCallback(const std::string& message_name) + : message_name_(message_name) { + } + + virtual void OnFileDialogDismissed( + CefRefPtr browser_host, + const std::vector& file_paths) OVERRIDE { + // Send a message back to the render process with the same name and the list + // of file paths. + CefRefPtr message = + CefProcessMessage::Create(message_name_); + CefRefPtr args = message->GetArgumentList(); + CefRefPtr val = CefListValue::Create(); + for (size_t i = 0; i < file_paths.size(); ++i) + val->SetString(i, file_paths[i]); + args->SetList(0, val); + + // This will result in a call to the callback registered via JavaScript in + // dialogs.html. + browser_host->GetBrowser()->SendProcessMessage(PID_RENDERER, message); + } + + private: + std::string message_name_; + + IMPLEMENT_REFCOUNTING(RunFileDialogCallback); +}; + +// Handle messages in the browser process. +class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate { + public: + ProcessMessageDelegate() { + } + + // From ClientHandler::ProcessMessageDelegate. + virtual bool OnProcessMessageReceived( + CefRefPtr handler, + CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) OVERRIDE { + std::string url = browser->GetMainFrame()->GetURL(); + if (url.find(kTestUrl) != 0) + return false; + + // Sample file type filter. + std::vector file_types; + file_types.push_back("text/*"); + file_types.push_back(".log"); + file_types.push_back(".patch"); + + std::string message_name = message->GetName(); + if (message_name == kFileOpenMessageName) { + browser->GetHost()->RunFileDialog(FILE_DIALOG_OPEN, "My Open Dialog", + "test.txt", file_types, new RunFileDialogCallback(message_name)); + return true; + } else if (message_name == kFileOpenMultipleMessageName) { + browser->GetHost()->RunFileDialog(FILE_DIALOG_OPEN_MULTIPLE, + "My Open Multiple Dialog", CefString(), file_types, + new RunFileDialogCallback(message_name)); + return true; + } else if (message_name == kFileSaveMessageName) { + browser->GetHost()->RunFileDialog(FILE_DIALOG_SAVE, "My Save Dialog", + "test.txt", file_types, new RunFileDialogCallback(message_name)); + return true; + } else { + ASSERT(false); // Not reached. + } + + return false; + } + + IMPLEMENT_REFCOUNTING(ProcessMessageDelegate); +}; + +} // namespace + +void CreateProcessMessageDelegates( + ClientHandler::ProcessMessageDelegateSet& delegates) { + delegates.insert(new ProcessMessageDelegate); +} + +} // namespace dialog_test diff --git a/cef3/tests/cefclient/dialog_test.h b/cef3/tests/cefclient/dialog_test.h new file mode 100644 index 000000000..f06af1673 --- /dev/null +++ b/cef3/tests/cefclient/dialog_test.h @@ -0,0 +1,19 @@ +// 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. + +#ifndef CEF_TESTS_CEFCLIENT_DIALOG_TEST_H_ +#define CEF_TESTS_CEFCLIENT_DIALOG_TEST_H_ +#pragma once + +#include "cefclient/client_handler.h" + +namespace dialog_test { + +// Delegate creation. Called from ClientHandler. +void CreateProcessMessageDelegates( + ClientHandler::ProcessMessageDelegateSet& delegates); + +} // namespace dialog_test + +#endif // CEF_TESTS_CEFCLIENT_DIALOG_TEST_H_ diff --git a/cef3/tests/cefclient/dom_test.cpp b/cef3/tests/cefclient/dom_test.cpp new file mode 100644 index 000000000..0dad68675 --- /dev/null +++ b/cef3/tests/cefclient/dom_test.cpp @@ -0,0 +1,134 @@ +// 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/dom_test.h" + +#include +#include + +#include "include/cef_dom.h" +#include "cefclient/util.h" + +namespace dom_test { + +const char kTestUrl[] = "http://tests/domaccess"; + +namespace { + +const char* kMessageName = "DOMTest.Message"; + +class ClientDOMEventListener : public CefDOMEventListener { + public: + ClientDOMEventListener() { + } + + virtual void HandleEvent(CefRefPtr event) OVERRIDE { + CefRefPtr document = event->GetDocument(); + ASSERT(document.get()); + + std::stringstream ss; + + CefRefPtr button = event->GetTarget(); + ASSERT(button.get()); + std::string buttonValue = button->GetElementAttribute("value"); + ss << "You clicked the " << buttonValue.c_str() << " button. "; + + if (document->HasSelection()) { + std::string startName, endName; + + // Determine the start name by first trying to locate the "id" attribute + // and then defaulting to the tag name. + { + CefRefPtr node = document->GetSelectionStartNode(); + if (!node->IsElement()) + node = node->GetParent(); + if (node->IsElement() && node->HasElementAttribute("id")) + startName = node->GetElementAttribute("id"); + else + startName = node->GetName(); + } + + // Determine the end name by first trying to locate the "id" attribute + // and then defaulting to the tag name. + { + CefRefPtr node = document->GetSelectionEndNode(); + if (!node->IsElement()) + node = node->GetParent(); + if (node->IsElement() && node->HasElementAttribute("id")) + endName = node->GetElementAttribute("id"); + else + endName = node->GetName(); + } + + ss << "The selection is from " << + startName.c_str() << ":" << document->GetSelectionStartOffset() << + " to " << + endName.c_str() << ":" << document->GetSelectionEndOffset(); + } else { + ss << "Nothing is selected."; + } + + // Update the description. + CefRefPtr desc = document->GetElementById("description"); + ASSERT(desc.get()); + CefRefPtr text = desc->GetFirstChild(); + ASSERT(text.get()); + ASSERT(text->IsText()); + text->SetValue(ss.str()); + } + + IMPLEMENT_REFCOUNTING(ClientDOMEventListener); +}; + +class ClientDOMVisitor : public CefDOMVisitor { + public: + ClientDOMVisitor() { + } + + virtual void Visit(CefRefPtr document) OVERRIDE { + // Register a click listener for the button. + CefRefPtr button = document->GetElementById("button"); + ASSERT(button.get()); + button->AddEventListener("click", new ClientDOMEventListener(), false); + } + + IMPLEMENT_REFCOUNTING(ClientDOMVisitor); +}; + +class DOMRenderDelegate : public ClientApp::RenderDelegate { + public: + DOMRenderDelegate() { + } + + virtual bool OnProcessMessageReceived( + CefRefPtr app, + CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) OVERRIDE { + if (message->GetName() == kMessageName) { + // Visit the DOM to attach the event listener. + browser->GetMainFrame()->VisitDOM(new ClientDOMVisitor); + return true; + } + + return false; + } + + private: + IMPLEMENT_REFCOUNTING(DOMRenderDelegate); +}; + +} // namespace + +void CreateRenderDelegates(ClientApp::RenderDelegateSet& delegates) { + delegates.insert(new DOMRenderDelegate); +} + +void OnLoadEnd(CefRefPtr browser) { + // Send a message to the render process to continue the test setup. + browser->SendProcessMessage(PID_RENDERER, + CefProcessMessage::Create(kMessageName)); +} + +} // namespace dom_test diff --git a/cef3/tests/cefclient/dom_test.h b/cef3/tests/cefclient/dom_test.h new file mode 100644 index 000000000..37d5dbc0e --- /dev/null +++ b/cef3/tests/cefclient/dom_test.h @@ -0,0 +1,25 @@ +// 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. + +#ifndef CEF_TESTS_CEFCLIENT_DOM_TEST_H_ +#define CEF_TESTS_CEFCLIENT_DOM_TEST_H_ +#pragma once + +#include "include/cef_base.h" +#include "cefclient/client_app.h" + +namespace dom_test { + +// The DOM test URL. +extern const char kTestUrl[]; + +// Create the render delegate. +void CreateRenderDelegates(ClientApp::RenderDelegateSet& delegates); + +// Continue the test after the page has loaded. +void OnLoadEnd(CefRefPtr browser); + +} // namespace dom_test + +#endif // CEF_TESTS_CEFCLIENT_DOM_TEST_H_ diff --git a/cef3/tests/cefclient/mac/English.lproj/InfoPlist.strings b/cef3/tests/cefclient/mac/English.lproj/InfoPlist.strings new file mode 100644 index 000000000..fe2abe11b --- /dev/null +++ b/cef3/tests/cefclient/mac/English.lproj/InfoPlist.strings @@ -0,0 +1,3 @@ +/* Localized versions of Info.plist keys */ + +NSHumanReadableCopyright = "© Chromium Embedded Framework Authors, 2010"; diff --git a/cef3/tests/cefclient/mac/English.lproj/MainMenu.xib b/cef3/tests/cefclient/mac/English.lproj/MainMenu.xib new file mode 100644 index 000000000..e4f7c1fc3 --- /dev/null +++ b/cef3/tests/cefclient/mac/English.lproj/MainMenu.xib @@ -0,0 +1,2880 @@ + + + + 1050 + 10F569 + 820 + 1038.29 + 461.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 820 + + + YES + + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + + + PluginDependencyRecalculationVersion + + + + YES + + NSApplication + + + FirstResponder + + + NSApplication + + + AMainMenu + + YES + + + cefclient + + 1048576 + 2147483647 + + NSImage + NSMenuCheckmark + + + NSImage + NSMenuMixedState + + submenuAction: + + TestShell + + YES + + + About cefclient + + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Preferences… + , + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Services + + 1048576 + 2147483647 + + + submenuAction: + + Services + + YES + + _NSServicesMenu + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Hide cefclient + h + 1048576 + 2147483647 + + + + + + Hide Others + h + 1572864 + 2147483647 + + + + + + Show All + + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Quit cefclient + q + 1048576 + 2147483647 + + + + + _NSAppleMenu + + + + + File + + 1048576 + 2147483647 + + + submenuAction: + + File + + YES + + + New + n + 1048576 + 2147483647 + + + + + + Open… + o + 1048576 + 2147483647 + + + + + + Open Recent + + 1048576 + 2147483647 + + + submenuAction: + + Open Recent + + YES + + + Clear Menu + + 1048576 + 2147483647 + + + + + _NSRecentDocumentsMenu + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Close + w + 1048576 + 2147483647 + + + + + + Save + s + 1048576 + 2147483647 + + + + + + Save As… + S + 1179648 + 2147483647 + + + + + + Revert to Saved + + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Page Setup... + P + 1179648 + 2147483647 + + + + + + + Print… + p + 1048576 + 2147483647 + + + + + + + + + Edit + + 1048576 + 2147483647 + + + submenuAction: + + Edit + + YES + + + Undo + z + 1048576 + 2147483647 + + + + + + Redo + Z + 1179648 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Cut + x + 1048576 + 2147483647 + + + + + + Copy + c + 1048576 + 2147483647 + + + + + + Paste + v + 1048576 + 2147483647 + + + + + + Delete + + 1048576 + 2147483647 + + + + + + Select All + a + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Find + + 1048576 + 2147483647 + + + submenuAction: + + Find + + YES + + + Find… + f + 1048576 + 2147483647 + + + 1 + + + + Find Next + g + 1048576 + 2147483647 + + + 2 + + + + Find Previous + G + 1179648 + 2147483647 + + + 3 + + + + Use Selection for Find + e + 1048576 + 2147483647 + + + 7 + + + + Jump to Selection + j + 1048576 + 2147483647 + + + + + + + + + Spelling and Grammar + + 1048576 + 2147483647 + + + submenuAction: + + Spelling and Grammar + + YES + + + Show Spelling… + : + 1048576 + 2147483647 + + + + + + Check Spelling + ; + 1048576 + 2147483647 + + + + + + Check Spelling While Typing + + 1048576 + 2147483647 + + + + + + Check Grammar With Spelling + + 1048576 + 2147483647 + + + + + + + + + Substitutions + + 1048576 + 2147483647 + + + submenuAction: + + Substitutions + + YES + + + Smart Copy/Paste + f + 1048576 + 2147483647 + + + 1 + + + + Smart Quotes + g + 1048576 + 2147483647 + + + 2 + + + + Smart Links + G + 1179648 + 2147483647 + + + 3 + + + + + + + Speech + + 1048576 + 2147483647 + + + submenuAction: + + Speech + + YES + + + Start Speaking + + 1048576 + 2147483647 + + + + + + Stop Speaking + + 1048576 + 2147483647 + + + + + + + + + + + + Format + + 1048576 + 2147483647 + + + submenuAction: + + Format + + YES + + + Show Fonts + t + 1048576 + 2147483647 + + + + + + Show Colors + C + 1179648 + 2147483647 + + + + + + + + + View + + 1048576 + 2147483647 + + + submenuAction: + + View + + YES + + + Show Toolbar + t + 1572864 + 2147483647 + + + + + + Customize Toolbar… + + 1048576 + 2147483647 + + + + + + + + + Window + + 1048576 + 2147483647 + + + submenuAction: + + Window + + YES + + + Minimize + m + 1048576 + 2147483647 + + + + + + Zoom + + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Bring All to Front + + 1048576 + 2147483647 + + + + + _NSWindowsMenu + + + + + Help + + 1048576 + 2147483647 + + + submenuAction: + + Help + + YES + + + cefclient Help + ? + 1048576 + 2147483647 + + + + + + + + _NSMainMenu + + + YES + + + + + YES + + + performMiniaturize: + + + + 37 + + + + arrangeInFront: + + + + 39 + + + + print: + + + + 86 + + + + runPageLayout: + + + + 87 + + + + clearRecentDocuments: + + + + 127 + + + + orderFrontStandardAboutPanel: + + + + 142 + + + + performClose: + + + + 193 + + + + toggleContinuousSpellChecking: + + + + 222 + + + + undo: + + + + 223 + + + + copy: + + + + 224 + + + + checkSpelling: + + + + 225 + + + + paste: + + + + 226 + + + + stopSpeaking: + + + + 227 + + + + cut: + + + + 228 + + + + showGuessPanel: + + + + 230 + + + + redo: + + + + 231 + + + + selectAll: + + + + 232 + + + + startSpeaking: + + + + 233 + + + + delete: + + + + 235 + + + + performZoom: + + + + 240 + + + + performFindPanelAction: + + + + 241 + + + + centerSelectionInVisibleArea: + + + + 245 + + + + toggleGrammarChecking: + + + + 347 + + + + toggleSmartInsertDelete: + + + + 355 + + + + toggleAutomaticQuoteSubstitution: + + + + 356 + + + + toggleAutomaticLinkDetection: + + + + 357 + + + + showHelp: + + + + 360 + + + + orderFrontColorPanel: + + + + 361 + + + + saveDocument: + + + + 362 + + + + saveDocumentAs: + + + + 363 + + + + revertDocumentToSaved: + + + + 364 + + + + runToolbarCustomizationPalette: + + + + 365 + + + + toggleToolbarShown: + + + + 366 + + + + hide: + + + + 367 + + + + hideOtherApplications: + + + + 368 + + + + terminate: + + + + 369 + + + + unhideAllApplications: + + + + 370 + + + + newDocument: + + + + 373 + + + + openDocument: + + + + 374 + + + + + YES + + 0 + + YES + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 29 + + + YES + + + + + + + + + + MainMenu + + + 19 + + + YES + + + + + + 56 + + + YES + + + + + + 103 + + + YES + + + + 1 + + + 217 + + + YES + + + + + + 83 + + + YES + + + + + + 81 + + + YES + + + + + + + + + + + + + + + + 75 + + + 3 + + + 80 + + + 8 + + + 78 + + + 6 + + + 72 + + + + + 82 + + + 9 + + + 124 + + + YES + + + + + + 77 + + + 5 + + + 73 + + + 1 + + + 79 + + + 7 + + + 112 + + + 10 + + + 74 + + + 2 + + + 125 + + + YES + + + + + + 126 + + + + + 205 + + + YES + + + + + + + + + + + + + + + + + + 202 + + + + + 198 + + + + + 207 + + + + + 214 + + + + + 199 + + + + + 203 + + + + + 197 + + + + + 206 + + + + + 215 + + + + + 218 + + + YES + + + + + + 216 + + + YES + + + + + + 200 + + + YES + + + + + + + + + 219 + + + + + 201 + + + + + 204 + + + + + 220 + + + YES + + + + + + + + + + 213 + + + + + 210 + + + + + 221 + + + + + 208 + + + + + 209 + + + + + 106 + + + YES + + + + 2 + + + 111 + + + + + 57 + + + YES + + + + + + + + + + + + + + + + 58 + + + + + 134 + + + + + 150 + + + + + 136 + + + 1111 + + + 144 + + + + + 129 + + + 121 + + + 143 + + + + + 236 + + + + + 131 + + + YES + + + + + + 149 + + + + + 145 + + + + + 130 + + + + + 24 + + + YES + + + + + + + + + 92 + + + + + 5 + + + + + 239 + + + + + 23 + + + + + 295 + + + YES + + + + + + 296 + + + YES + + + + + + + 297 + + + + + 298 + + + + + 299 + + + YES + + + + + + 300 + + + YES + + + + + + + 344 + + + + + 345 + + + + + 211 + + + YES + + + + + + 212 + + + YES + + + + + + + 195 + + + + + 196 + + + + + 346 + + + + + 348 + + + YES + + + + + + 349 + + + YES + + + + + + + + 350 + + + + + 351 + + + + + 354 + + + + + 389 + + + + + + + YES + + YES + -3.IBPluginDependency + 103.IBPluginDependency + 103.ImportedFromIB2 + 106.IBEditorWindowLastContentRect + 106.IBPluginDependency + 106.ImportedFromIB2 + 106.editorWindowContentRectSynchronizationRect + 111.IBPluginDependency + 111.ImportedFromIB2 + 112.IBPluginDependency + 112.ImportedFromIB2 + 124.IBPluginDependency + 124.ImportedFromIB2 + 125.IBPluginDependency + 125.ImportedFromIB2 + 125.editorWindowContentRectSynchronizationRect + 126.IBPluginDependency + 126.ImportedFromIB2 + 129.IBPluginDependency + 129.ImportedFromIB2 + 130.IBPluginDependency + 130.ImportedFromIB2 + 130.editorWindowContentRectSynchronizationRect + 131.IBPluginDependency + 131.ImportedFromIB2 + 134.IBPluginDependency + 134.ImportedFromIB2 + 136.IBPluginDependency + 136.ImportedFromIB2 + 143.IBPluginDependency + 143.ImportedFromIB2 + 144.IBPluginDependency + 144.ImportedFromIB2 + 145.IBPluginDependency + 145.ImportedFromIB2 + 149.IBPluginDependency + 149.ImportedFromIB2 + 150.IBPluginDependency + 150.ImportedFromIB2 + 19.IBPluginDependency + 19.ImportedFromIB2 + 195.IBPluginDependency + 195.ImportedFromIB2 + 196.IBPluginDependency + 196.ImportedFromIB2 + 197.IBPluginDependency + 197.ImportedFromIB2 + 198.IBPluginDependency + 198.ImportedFromIB2 + 199.IBPluginDependency + 199.ImportedFromIB2 + 200.IBEditorWindowLastContentRect + 200.IBPluginDependency + 200.ImportedFromIB2 + 200.editorWindowContentRectSynchronizationRect + 201.IBPluginDependency + 201.ImportedFromIB2 + 202.IBPluginDependency + 202.ImportedFromIB2 + 203.IBPluginDependency + 203.ImportedFromIB2 + 204.IBPluginDependency + 204.ImportedFromIB2 + 205.IBEditorWindowLastContentRect + 205.IBPluginDependency + 205.ImportedFromIB2 + 205.editorWindowContentRectSynchronizationRect + 206.IBPluginDependency + 206.ImportedFromIB2 + 207.IBPluginDependency + 207.ImportedFromIB2 + 208.IBPluginDependency + 208.ImportedFromIB2 + 209.IBPluginDependency + 209.ImportedFromIB2 + 210.IBPluginDependency + 210.ImportedFromIB2 + 211.IBPluginDependency + 211.ImportedFromIB2 + 212.IBEditorWindowLastContentRect + 212.IBPluginDependency + 212.ImportedFromIB2 + 212.editorWindowContentRectSynchronizationRect + 213.IBPluginDependency + 213.ImportedFromIB2 + 214.IBPluginDependency + 214.ImportedFromIB2 + 215.IBPluginDependency + 215.ImportedFromIB2 + 216.IBPluginDependency + 216.ImportedFromIB2 + 217.IBPluginDependency + 217.ImportedFromIB2 + 218.IBPluginDependency + 218.ImportedFromIB2 + 219.IBPluginDependency + 219.ImportedFromIB2 + 220.IBEditorWindowLastContentRect + 220.IBPluginDependency + 220.ImportedFromIB2 + 220.editorWindowContentRectSynchronizationRect + 221.IBPluginDependency + 221.ImportedFromIB2 + 23.IBPluginDependency + 23.ImportedFromIB2 + 236.IBPluginDependency + 236.ImportedFromIB2 + 239.IBPluginDependency + 239.ImportedFromIB2 + 24.IBEditorWindowLastContentRect + 24.IBPluginDependency + 24.ImportedFromIB2 + 24.editorWindowContentRectSynchronizationRect + 29.IBEditorWindowLastContentRect + 29.IBPluginDependency + 29.ImportedFromIB2 + 29.WindowOrigin + 29.editorWindowContentRectSynchronizationRect + 295.IBPluginDependency + 296.IBEditorWindowLastContentRect + 296.IBPluginDependency + 296.editorWindowContentRectSynchronizationRect + 297.IBPluginDependency + 298.IBPluginDependency + 299.IBPluginDependency + 300.IBEditorWindowLastContentRect + 300.IBPluginDependency + 300.editorWindowContentRectSynchronizationRect + 344.IBPluginDependency + 345.IBPluginDependency + 346.IBPluginDependency + 346.ImportedFromIB2 + 348.IBPluginDependency + 348.ImportedFromIB2 + 349.IBEditorWindowLastContentRect + 349.IBPluginDependency + 349.ImportedFromIB2 + 349.editorWindowContentRectSynchronizationRect + 350.IBPluginDependency + 350.ImportedFromIB2 + 351.IBPluginDependency + 351.ImportedFromIB2 + 354.IBPluginDependency + 354.ImportedFromIB2 + 389.IBPluginDependency + 5.IBPluginDependency + 5.ImportedFromIB2 + 56.IBPluginDependency + 56.ImportedFromIB2 + 57.IBEditorWindowLastContentRect + 57.IBPluginDependency + 57.ImportedFromIB2 + 57.editorWindowContentRectSynchronizationRect + 58.IBPluginDependency + 58.ImportedFromIB2 + 72.IBPluginDependency + 72.ImportedFromIB2 + 73.IBPluginDependency + 73.ImportedFromIB2 + 74.IBPluginDependency + 74.ImportedFromIB2 + 75.IBPluginDependency + 75.ImportedFromIB2 + 77.IBPluginDependency + 77.ImportedFromIB2 + 78.IBPluginDependency + 78.ImportedFromIB2 + 79.IBPluginDependency + 79.ImportedFromIB2 + 80.IBPluginDependency + 80.ImportedFromIB2 + 81.IBEditorWindowLastContentRect + 81.IBPluginDependency + 81.ImportedFromIB2 + 81.editorWindowContentRectSynchronizationRect + 82.IBPluginDependency + 82.ImportedFromIB2 + 83.IBPluginDependency + 83.ImportedFromIB2 + 92.IBPluginDependency + 92.ImportedFromIB2 + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + {{906, 713}, {164, 23}} + com.apple.InterfaceBuilder.CocoaPlugin + + {{375, 955}, {171, 23}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + {{522, 812}, {146, 23}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + {{436, 809}, {64, 6}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + {{915, 473}, {272, 83}} + com.apple.InterfaceBuilder.CocoaPlugin + + {{608, 612}, {275, 83}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + {{675, 493}, {240, 243}} + com.apple.InterfaceBuilder.CocoaPlugin + + {{144, 735}, {243, 243}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + {{915, 473}, {164, 43}} + com.apple.InterfaceBuilder.CocoaPlugin + + {{608, 612}, {167, 43}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + {{915, 473}, {238, 103}} + com.apple.InterfaceBuilder.CocoaPlugin + + {{608, 612}, {241, 103}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + {{835, 663}, {194, 73}} + com.apple.InterfaceBuilder.CocoaPlugin + + {{304, 905}, {197, 73}} + {{541, 736}, {426, 20}} + com.apple.InterfaceBuilder.CocoaPlugin + + {74, 862} + {{6, 836}, {430, 20}} + com.apple.InterfaceBuilder.CocoaPlugin + {{785, 693}, {231, 43}} + com.apple.InterfaceBuilder.CocoaPlugin + {{254, 935}, {234, 43}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{719, 693}, {173, 43}} + com.apple.InterfaceBuilder.CocoaPlugin + {{188, 935}, {176, 43}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + {{915, 473}, {212, 63}} + com.apple.InterfaceBuilder.CocoaPlugin + + {{608, 612}, {215, 63}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + {{553, 553}, {193, 183}} + com.apple.InterfaceBuilder.CocoaPlugin + + {{18, 653}, {200, 183}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + {{633, 533}, {196, 203}} + com.apple.InterfaceBuilder.CocoaPlugin + + {{102, 775}, {199, 203}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + + + + YES + + + YES + + + + + YES + + + YES + + + + 439 + + + + YES + + NSApplication + NSResponder + + IBFrameworkSource + AppKit.framework/Headers/NSApplication.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSApplicationScripting.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSColorPanel.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSHelpManager.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSPageLayout.h + + + + NSBrowser + NSControl + + IBFrameworkSource + AppKit.framework/Headers/NSBrowser.h + + + + NSControl + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSControl.h + + + + NSController + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSController.h + + + + NSDocument + NSObject + + YES + + YES + printDocument: + revertDocumentToSaved: + runPageLayout: + saveDocument: + saveDocumentAs: + saveDocumentTo: + + + YES + id + id + id + id + id + id + + + + YES + + YES + printDocument: + revertDocumentToSaved: + runPageLayout: + saveDocument: + saveDocumentAs: + saveDocumentTo: + + + YES + + printDocument: + id + + + revertDocumentToSaved: + id + + + runPageLayout: + id + + + saveDocument: + id + + + saveDocumentAs: + id + + + saveDocumentTo: + id + + + + + IBFrameworkSource + AppKit.framework/Headers/NSDocument.h + + + + NSDocument + + IBFrameworkSource + AppKit.framework/Headers/NSDocumentScripting.h + + + + NSDocumentController + NSObject + + YES + + YES + clearRecentDocuments: + newDocument: + openDocument: + saveAllDocuments: + + + YES + id + id + id + id + + + + YES + + YES + clearRecentDocuments: + newDocument: + openDocument: + saveAllDocuments: + + + YES + + clearRecentDocuments: + id + + + newDocument: + id + + + openDocument: + id + + + saveAllDocuments: + id + + + + + IBFrameworkSource + AppKit.framework/Headers/NSDocumentController.h + + + + NSFormatter + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFormatter.h + + + + NSMatrix + NSControl + + IBFrameworkSource + AppKit.framework/Headers/NSMatrix.h + + + + NSMenu + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSMenu.h + + + + NSMenuItem + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSMenuItem.h + + + + NSMovieView + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSMovieView.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSAccessibility.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSAlert.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSAnimation.h + + + + NSObject + + + + NSObject + + + + NSObject + + + + NSObject + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSComboBox.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSComboBoxCell.h + + + + NSObject + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSDatePickerCell.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSDictionaryController.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSDragging.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSDrawer.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSFontManager.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSFontPanel.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSImage.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSKeyValueBinding.h + + + + NSObject + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSNibLoading.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSOutlineView.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSPasteboard.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSRuleEditor.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSSavePanel.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSSound.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSSpeechRecognizer.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSSpeechSynthesizer.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSSplitView.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSTabView.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSTableView.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSText.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSTextStorage.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSTextView.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSTokenField.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSTokenFieldCell.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSToolbar.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSToolbarItem.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSView.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSWindow.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSClassDescription.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSConnection.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSMetadata.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSNetServices.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObjectScripting.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSPort.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSPortCoder.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptClassDescription.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptObjectSpecifiers.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptWhoseTests.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSSpellServer.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSStream.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLDownload.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSXMLParser.h + + + + NSObject + + IBFrameworkSource + Print.framework/Headers/PDEPluginInterface.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CAAnimation.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CALayer.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CIImageProvider.h + + + + NSResponder + + IBFrameworkSource + AppKit.framework/Headers/NSInterfaceStyle.h + + + + NSResponder + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSResponder.h + + + + NSTableView + NSControl + + + + NSText + NSView + + + + NSUserDefaultsController + NSController + + IBFrameworkSource + AppKit.framework/Headers/NSUserDefaultsController.h + + + + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSClipView.h + + + + NSView + + + + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSRulerView.h + + + + NSView + NSResponder + + + + NSWindow + + + + NSWindow + NSResponder + + + + NSWindow + + IBFrameworkSource + AppKit.framework/Headers/NSWindowScripting.h + + + + + 0 + IBCocoaFramework + + com.apple.InterfaceBuilder.CocoaPlugin.macosx + + + + com.apple.InterfaceBuilder.CocoaPlugin.macosx + + + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 + + + YES + ../../../../cef.xcodeproj + 3 + + YES + + YES + NSMenuCheckmark + NSMenuMixedState + + + YES + {9, 8} + {7, 2} + + + + diff --git a/cef3/tests/cefclient/mac/Info.plist b/cef3/tests/cefclient/mac/Info.plist new file mode 100644 index 000000000..83c535e41 --- /dev/null +++ b/cef3/tests/cefclient/mac/Info.plist @@ -0,0 +1,28 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + cefclient.icns + CFBundleIdentifier + org.cef.cefclient + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleVersion + 1.0 + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/cef3/tests/cefclient/mac/cefclient.icns b/cef3/tests/cefclient/mac/cefclient.icns new file mode 100644 index 000000000..f36742de2 Binary files /dev/null and b/cef3/tests/cefclient/mac/cefclient.icns differ diff --git a/cef3/tests/cefclient/mac/helper-Info.plist b/cef3/tests/cefclient/mac/helper-Info.plist new file mode 100644 index 000000000..ed5abfae9 --- /dev/null +++ b/cef3/tests/cefclient/mac/helper-Info.plist @@ -0,0 +1,30 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${EXECUTABLE_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + org.cef.cefclient.helper + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleSignature + ???? + LSFileQuarantineEnabled + + LSMinimumSystemVersion + 10.5.0 + LSUIElement + 1 + NSSupportsAutomaticGraphicsSwitching + + + diff --git a/cef3/tests/cefclient/osrenderer.cpp b/cef3/tests/cefclient/osrenderer.cpp new file mode 100644 index 000000000..a6f3409d3 --- /dev/null +++ b/cef3/tests/cefclient/osrenderer.cpp @@ -0,0 +1,273 @@ +// 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/osrenderer.h" + +#if defined(OS_WIN) +#include +#include +#elif defined(OS_MACOSX) +#include +#else +#error Platform is not supported. +#endif + +#include "cefclient/util.h" + +#ifndef GL_BGR +#define GL_BGR 0x80E0 +#endif +#ifndef GL_BGRA +#define GL_BGRA 0x80E1 +#endif +#ifndef GL_UNSIGNED_INT_8_8_8_8_REV +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#endif + + +ClientOSRenderer::ClientOSRenderer(bool transparent) + : transparent_(transparent), + initialized_(false), + texture_id_(0), + view_width_(0), + view_height_(0), + spin_x_(0), + spin_y_(0) { +} + +ClientOSRenderer::~ClientOSRenderer() { + Cleanup(); +} + +void ClientOSRenderer::Initialize() { + if (initialized_) + return; + + glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); + + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + + // Necessary for non-power-of-2 textures to render correctly. + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + // Create the texture. + glGenTextures(1, &texture_id_); + ASSERT(texture_id_ != 0); + + glBindTexture(GL_TEXTURE_2D, texture_id_); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + initialized_ = true; +} + +void ClientOSRenderer::Cleanup() { + if (texture_id_ != 0) + glDeleteTextures(1, &texture_id_); +} + +void ClientOSRenderer::Render() { + if (view_width_ == 0 || view_height_ == 0) + return; + + ASSERT(initialized_); + + struct { + float tu, tv; + float x, y, z; + } static vertices[] = { + {0.0f, 1.0f, -1.0f, -1.0f, 0.0f}, + {1.0f, 1.0f, 1.0f, -1.0f, 0.0f}, + {1.0f, 0.0f, 1.0f, 1.0f, 0.0f}, + {0.0f, 0.0f, -1.0f, 1.0f, 0.0f} + }; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + // Match GL units to screen coordinates. + glViewport(0, 0, view_width_, view_height_); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, 0, view_width_, view_height_, 0.1, 100.0); + + // Draw the background gradient. + glPushAttrib(GL_ALL_ATTRIB_BITS); + glBegin(GL_QUADS); + glColor4f(1.0, 0.0, 0.0, 1.0); // red + glVertex2f(-1.0, -1.0); + glVertex2f(1.0, -1.0); + glColor4f(0.0, 0.0, 1.0, 1.0); // blue + glVertex2f(1.0, 1.0); + glVertex2f(-1.0, 1.0); + glEnd(); + glPopAttrib(); + + // Rotate the view based on the mouse spin. + if (spin_x_ != 0) + glRotatef(-spin_x_, 1.0f, 0.0f, 0.0f); + if (spin_y_ != 0) + glRotatef(-spin_y_, 0.0f, 1.0f, 0.0f); + + if (transparent_) { + // Alpha blending style. Texture values have premultiplied alpha. + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + + // Enable alpha blending. + glEnable(GL_BLEND); + } + + // Enable 2D textures. + glEnable(GL_TEXTURE_2D); + + // Draw the facets with the texture. + ASSERT(texture_id_ != 0); + glBindTexture(GL_TEXTURE_2D, texture_id_); + glInterleavedArrays(GL_T2F_V3F, 0, vertices); + glDrawArrays(GL_QUADS, 0, 4); + + // Disable 2D textures. + glDisable(GL_TEXTURE_2D); + + if (transparent_) { + // Disable alpha blending. + glDisable(GL_BLEND); + } +} + +void ClientOSRenderer::OnPopupShow(CefRefPtr browser, + bool show) { + if (!show) { + // Clear the popup rectangle. + CefRect popup_rect = popup_rect_; + popup_rect_.Set(0, 0, 0, 0); + original_popup_rect_.Set(0, 0, 0, 0); + // Invalidate the previous popup rectangle so that it will be repainted. + browser->GetHost()->Invalidate(popup_rect, PET_VIEW); + } +} + +void ClientOSRenderer::OnPopupSize(CefRefPtr browser, + const CefRect& rect) { + if (rect.width <= 0 || rect.height <= 0) + return; + original_popup_rect_ = rect; + popup_rect_ = GetPopupRectInWebView(original_popup_rect_); +} + +CefRect ClientOSRenderer::GetPopupRectInWebView(const CefRect& original_rect) { + CefRect rc(original_rect); + // if x or y are negative, move them to 0. + if (rc.x < 0) + rc.x = 0; + if (rc.y < 0) + rc.y = 0; + // if popup goes outside the view, try to reposition origin + if (rc.x + rc.width > view_width_) + rc.x = view_width_ - rc.width; + if (rc.y + rc.height > view_height_) + rc.y = view_height_ - rc.height; + // if x or y became negative, move them to 0 again. + if (rc.x < 0) + rc.x = 0; + if (rc.y < 0) + rc.y = 0; + return rc; +} + +void ClientOSRenderer::OnPaint(CefRefPtr browser, + CefRenderHandler::PaintElementType type, + const CefRenderHandler::RectList& dirtyRects, + const void* buffer, int width, int height) { + if (!initialized_) + Initialize(); + + if (transparent_) { + // Enable alpha blending. + glEnable(GL_BLEND); + } + + // Enable 2D textures. + glEnable(GL_TEXTURE_2D); + + ASSERT(texture_id_ != 0); + glBindTexture(GL_TEXTURE_2D, texture_id_); + + if (type == PET_VIEW) { + int old_width = view_width_; + int old_height = view_height_; + + view_width_ = width; + view_height_ = height; + + glPixelStorei(GL_UNPACK_ROW_LENGTH, view_width_); + + if (old_width != view_width_ || old_height != view_height_) { + // Update/resize the whole texture. + glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); + glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, view_width_, view_height_, 0, + GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, buffer); + } else { + // Update just the dirty rectangles. + CefRenderHandler::RectList::const_iterator i = dirtyRects.begin(); + for (; i != dirtyRects.end(); ++i) { + const CefRect& rect = *i; + glPixelStorei(GL_UNPACK_SKIP_PIXELS, rect.x); + glPixelStorei(GL_UNPACK_SKIP_ROWS, rect.y); + glTexSubImage2D(GL_TEXTURE_2D, 0, rect.x, rect.y, rect.width, + rect.height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, + buffer); + } + } + } else if (type == PET_POPUP && popup_rect_.width > 0 && + popup_rect_.height > 0) { + int skip_pixels = 0, x = popup_rect_.x; + int skip_rows = 0, y = popup_rect_.y; + int w = width; + int h = height; + + // Adjust the popup to fit inside the view. + if (x < 0) { + skip_pixels = -x; + x = 0; + } + if (y < 0) { + skip_rows = -y; + y = 0; + } + if (x + w > view_width_) + w -= x + w - view_width_; + if (y + h > view_height_) + h -= y + h - view_height_; + + // Update the popup rectangle. + glPixelStorei(GL_UNPACK_ROW_LENGTH, width); + glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels); + glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows); + glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_BGRA, + GL_UNSIGNED_INT_8_8_8_8_REV, buffer); + } + + // Disable 2D textures. + glDisable(GL_TEXTURE_2D); + + if (transparent_) { + // Disable alpha blending. + glDisable(GL_BLEND); + } +} + +void ClientOSRenderer::SetSpin(float spinX, float spinY) { + spin_x_ = spinX; + spin_y_ = spinY; +} + +void ClientOSRenderer::IncrementSpin(float spinDX, float spinDY) { + spin_x_ -= spinDX; + spin_y_ -= spinDY; +} diff --git a/cef3/tests/cefclient/osrenderer.h b/cef3/tests/cefclient/osrenderer.h new file mode 100644 index 000000000..f549cf183 --- /dev/null +++ b/cef3/tests/cefclient/osrenderer.h @@ -0,0 +1,64 @@ +// 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. + +#ifndef CEF_TESTS_CEFCLIENT_OSRENDERER_H_ +#define CEF_TESTS_CEFCLIENT_OSRENDERER_H_ +#pragma once + +#include "include/cef_browser.h" +#include "include/cef_render_handler.h" + +class ClientOSRenderer { + public: + // The context must outlive this object. + explicit ClientOSRenderer(bool transparent); + virtual ~ClientOSRenderer(); + + // Initialize the OpenGL environment. + void Initialize(); + + // Clean up the OpenGL environment. + void Cleanup(); + + // Render to the screen. + void Render(); + + // Forwarded from CefRenderHandler callbacks. + void OnPopupShow(CefRefPtr browser, + bool show); + void OnPopupSize(CefRefPtr browser, + const CefRect& rect); + void OnPaint(CefRefPtr browser, + CefRenderHandler::PaintElementType type, + const CefRenderHandler::RectList& dirtyRects, + const void* buffer, int width, int height); + + // Apply spin. + void SetSpin(float spinX, float spinY); + void IncrementSpin(float spinDX, float spinDY); + + bool IsTransparent() { return transparent_; } + + int GetViewWidth() { return view_width_; } + int GetViewHeight() { return view_height_; } + + const CefRect& popup_rect() const { return popup_rect_; } + const CefRect& original_popup_rect() const { return original_popup_rect_; } + + CefRect GetPopupRectInWebView(const CefRect& original_rect); + + private: + bool transparent_; + bool initialized_; + unsigned int texture_id_; + int view_width_; + int view_height_; + CefRect popup_rect_; + CefRect original_popup_rect_; + float spin_x_; + float spin_y_; +}; + +#endif // CEF_TESTS_CEFCLIENT_OSRENDERER_H_ + diff --git a/cef3/tests/cefclient/performance_test.cpp b/cef3/tests/cefclient/performance_test.cpp new file mode 100644 index 000000000..2108f770d --- /dev/null +++ b/cef3/tests/cefclient/performance_test.cpp @@ -0,0 +1,113 @@ +// 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/performance_test.h" + +#include +#include + +#include "include/wrapper/cef_stream_resource_handler.h" +#include "cefclient/performance_test_setup.h" + +namespace performance_test { + +// Use more interations for a Release build. +#ifdef NDEBUG +const size_t kDefaultIterations = 100000; +#else +const size_t kDefaultIterations = 10000; +#endif + +namespace { + +const char kGetPerfTests[] = "GetPerfTests"; +const char kRunPerfTest[] = "RunPerfTest"; + +class V8Handler : public CefV8Handler { + public: + V8Handler() { + } + + virtual bool Execute(const CefString& name, + CefRefPtr object, + const CefV8ValueList& arguments, + CefRefPtr& retval, + CefString& exception) { + if (name == kRunPerfTest) { + if (arguments.size() == 1 && arguments[0]->IsString()) { + // Run the specified perf test. + bool found = false; + + std::string test = arguments[0]->GetStringValue(); + for (size_t i = 0; i < kPerfTestsCount; ++i) { + if (test == kPerfTests[i].name) { + // Execute the test. + int64 delta = kPerfTests[i].test(kPerfTests[i].iterations); + + retval = CefV8Value::CreateInt(delta); + found = true; + break; + } + } + + if (!found) { + std::string msg = "Unknown test: "; + msg.append(test); + exception = msg; + } + } else { + exception = "Invalid function parameters"; + } + } else if (name == kGetPerfTests) { + // Retrieve the list of perf tests. + retval = CefV8Value::CreateArray(kPerfTestsCount); + for (size_t i = 0; i < kPerfTestsCount; ++i) { + CefRefPtr val = CefV8Value::CreateArray(2); + val->SetValue(0, CefV8Value::CreateString(kPerfTests[i].name)); + val->SetValue(1, CefV8Value::CreateUInt(kPerfTests[i].iterations)); + retval->SetValue(i, val); + } + } + + return true; + } + + private: + IMPLEMENT_REFCOUNTING(V8Handler); +}; + +// Handle bindings in the render process. +class RenderDelegate : public ClientApp::RenderDelegate { + public: + RenderDelegate() { + } + + virtual void OnContextCreated(CefRefPtr app, + CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context) OVERRIDE { + CefRefPtr object = context->GetGlobal(); + + CefRefPtr handler = new V8Handler(); + + // Bind test functions. + object->SetValue(kGetPerfTests, + CefV8Value::CreateFunction(kGetPerfTests, handler), + V8_PROPERTY_ATTRIBUTE_READONLY); + object->SetValue(kRunPerfTest, + CefV8Value::CreateFunction(kRunPerfTest, handler), + V8_PROPERTY_ATTRIBUTE_READONLY); + } + + private: + IMPLEMENT_REFCOUNTING(RenderDelegate); +}; + +} // namespace + +void CreateRenderDelegates(ClientApp::RenderDelegateSet& delegates) { + delegates.insert(new RenderDelegate); +} + +} // namespace performance_test diff --git a/cef3/tests/cefclient/performance_test.h b/cef3/tests/cefclient/performance_test.h new file mode 100644 index 000000000..0b8ed9097 --- /dev/null +++ b/cef3/tests/cefclient/performance_test.h @@ -0,0 +1,18 @@ +// 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. + +#ifndef CEF_TESTS_CEFCLIENT_PERFORMANCE_TEST_H_ +#define CEF_TESTS_CEFCLIENT_PERFORMANCE_TEST_H_ +#pragma once + +#include "cefclient/client_app.h" + +namespace performance_test { + +// Render delegate creation. Called from client_app_delegates.cpp. +void CreateRenderDelegates(ClientApp::RenderDelegateSet& delegates); + +} // namespace performance_test + +#endif // CEF_TESTS_CEFCLIENT_PERFORMANCE_TEST_H_ diff --git a/cef3/tests/cefclient/performance_test_setup.h b/cef3/tests/cefclient/performance_test_setup.h new file mode 100644 index 000000000..a4f2647ef --- /dev/null +++ b/cef3/tests/cefclient/performance_test_setup.h @@ -0,0 +1,99 @@ +// 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. + +#ifndef CEF_TESTS_CEFCLIENT_PERFORMANCE_TEST_SETUP_H_ +#define CEF_TESTS_CEFCLIENT_PERFORMANCE_TEST_SETUP_H_ +#pragma once + +#include "cefclient/util.h" + +namespace performance_test { + +// Default number of iterations. +extern const size_t kDefaultIterations; + +// Test name. +#define PERF_TEST_NAME(name) PerfTest##name + +// Entry in test array. +#define PERF_TEST_ENTRY_EX(name, iterations) \ + { #name, PERF_TEST_NAME(name), iterations } +#define PERF_TEST_ENTRY(name) PERF_TEST_ENTRY_EX(name, kDefaultIterations) + +// Test function declaration. +#define PERF_TEST_RESULT int64 +#define PERF_TEST_PARAM_ITERATIONS iterations +#define PERF_TEST_PARAMS size_t PERF_TEST_PARAM_ITERATIONS +#define PERF_TEST_FUNC(name) \ + PERF_TEST_RESULT PERF_TEST_NAME(name)(PERF_TEST_PARAMS) + +// Typedef for test pointers. +typedef PERF_TEST_RESULT(PerfTest(PERF_TEST_PARAMS)); + +class CefTimer { + public: + CefTimer() : running_(false) { + } + + bool IsRunning() { return running_; } + + void Start() { + ASSERT(!running_); + running_ = true; + start_.Now(); + } + + void Stop() { + stop_.Now(); + ASSERT(running_); + running_ = false; + } + + int64 Delta() { + ASSERT(!running_); + return start_.Delta(stop_); + } + + private: + bool running_; + CefTime start_; + CefTime stop_; +}; + +// Peform test iterations using a user-provided timing result variable. +#define PERF_ITERATIONS_START_EX() \ + { \ + CefTimer _timer; \ + _timer.Start(); \ + for (size_t _i = 0; _i < PERF_TEST_PARAM_ITERATIONS; ++_i) { + +#define PERF_ITERATIONS_END_EX(result) \ + } \ + _timer.Stop(); \ + result = _timer.Delta(); \ + } + +// Perform test iterations and return the timing result. +#define PERF_ITERATIONS_START() \ + int64 _result = 0; \ + PERF_ITERATIONS_START_EX() + +#define PERF_ITERATIONS_END() \ + PERF_ITERATIONS_END_EX(_result) \ + return _result; + +// Perf test entry structure. +struct PerfTestEntry { + const char* name; + PerfTest* test; + size_t iterations; +}; + +// Array of perf tests. +extern const PerfTestEntry kPerfTests[]; +extern const size_t kPerfTestsCount; + +} // namespace performance_test + +#endif // CEF_TESTS_CEFCLIENT_PERFORMANCE_TEST_H_ diff --git a/cef3/tests/cefclient/performance_test_tests.cpp b/cef3/tests/cefclient/performance_test_tests.cpp new file mode 100644 index 000000000..389a126a2 --- /dev/null +++ b/cef3/tests/cefclient/performance_test_tests.cpp @@ -0,0 +1,328 @@ +// 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/performance_test.h" +#include "cefclient/performance_test_setup.h" +#include "include/cef_v8.h" + +namespace performance_test { + +namespace { + +// Test function implementations. + +PERF_TEST_FUNC(V8NullCreate) { + PERF_ITERATIONS_START() + CefRefPtr value = CefV8Value::CreateNull(); + PERF_ITERATIONS_END() +} + +PERF_TEST_FUNC(V8BoolCreate) { + PERF_ITERATIONS_START() + CefRefPtr value = CefV8Value::CreateBool(true); + PERF_ITERATIONS_END() +} + +PERF_TEST_FUNC(V8IntCreate) { + PERF_ITERATIONS_START() + CefRefPtr value = CefV8Value::CreateInt(-5); + PERF_ITERATIONS_END() +} + +PERF_TEST_FUNC(V8UIntCreate) { + PERF_ITERATIONS_START() + CefRefPtr value = CefV8Value::CreateUInt(10); + PERF_ITERATIONS_END() +} + +PERF_TEST_FUNC(V8DoubleCreate) { + PERF_ITERATIONS_START() + CefRefPtr value = CefV8Value::CreateDouble(12.432); + PERF_ITERATIONS_END() +} + +PERF_TEST_FUNC(V8DateCreate) { + static cef_time_t time = {2012, 1, 0, 1}; + + PERF_ITERATIONS_START() + CefRefPtr value = CefV8Value::CreateDate(time); + PERF_ITERATIONS_END() +} + +PERF_TEST_FUNC(V8StringCreate) { + CefString str = "test string"; + + PERF_ITERATIONS_START() + CefRefPtr value = CefV8Value::CreateString(str); + PERF_ITERATIONS_END() +} + +PERF_TEST_FUNC(V8ArrayCreate) { + PERF_ITERATIONS_START() + CefRefPtr value = CefV8Value::CreateArray(1); + PERF_ITERATIONS_END() +} + +PERF_TEST_FUNC(V8ArraySetValue) { + CefRefPtr val = CefV8Value::CreateBool(true); + CefRefPtr array = CefV8Value::CreateArray(1); + array->SetValue(0, val); + + PERF_ITERATIONS_START() + array->SetValue(0, val); + PERF_ITERATIONS_END() +} + +PERF_TEST_FUNC(V8ArrayGetValue) { + CefRefPtr val = CefV8Value::CreateBool(true); + CefRefPtr array = CefV8Value::CreateArray(1); + array->SetValue(0, val); + + PERF_ITERATIONS_START() + CefRefPtr ret = array->GetValue(0); + PERF_ITERATIONS_END() +} + +PERF_TEST_FUNC(V8FunctionCreate) { + class Handler : public CefV8Handler { + public: + Handler() {} + virtual bool Execute(const CefString& name, + CefRefPtr object, + const CefV8ValueList& arguments, + CefRefPtr& retval, + CefString& exception) OVERRIDE { return false; } + IMPLEMENT_REFCOUNTING(Handler); + }; + + CefString name = "name"; + CefRefPtr handler = new Handler(); + + PERF_ITERATIONS_START() + CefRefPtr value = CefV8Value::CreateFunction(name, handler); + PERF_ITERATIONS_END() +} + +PERF_TEST_FUNC(V8FunctionExecute) { + class Handler : public CefV8Handler { + public: + Handler() {} + virtual bool Execute(const CefString& name, + CefRefPtr object, + const CefV8ValueList& arguments, + CefRefPtr& retval, + CefString& exception) OVERRIDE { return true; } + IMPLEMENT_REFCOUNTING(Handler); + }; + + CefString name = "name"; + CefRefPtr handler = new Handler(); + CefRefPtr func = CefV8Value::CreateFunction(name, handler); + CefRefPtr obj = CefV8Context::GetCurrentContext()->GetGlobal(); + CefV8ValueList args; + + PERF_ITERATIONS_START() + func->ExecuteFunction(obj, args); + PERF_ITERATIONS_END() +} + +PERF_TEST_FUNC(V8FunctionExecuteWithContext) { + class Handler : public CefV8Handler { + public: + Handler() {} + virtual bool Execute(const CefString& name, + CefRefPtr object, + const CefV8ValueList& arguments, + CefRefPtr& retval, + CefString& exception) OVERRIDE { return true; } + IMPLEMENT_REFCOUNTING(Handler); + }; + + CefString name = "name"; + CefRefPtr handler = new Handler(); + CefRefPtr func = CefV8Value::CreateFunction(name, handler); + CefRefPtr context = CefV8Context::GetCurrentContext(); + CefRefPtr obj = context->GetGlobal(); + CefV8ValueList args; + + PERF_ITERATIONS_START() + func->ExecuteFunctionWithContext(context, obj, args); + PERF_ITERATIONS_END() +} + +PERF_TEST_FUNC(V8ObjectCreate) { + PERF_ITERATIONS_START() + CefRefPtr value = CefV8Value::CreateObject(NULL); + PERF_ITERATIONS_END() +} + +PERF_TEST_FUNC(V8ObjectCreateWithAccessor) { + class Accessor : public CefV8Accessor { + public: + Accessor() {} + virtual bool Get(const CefString& name, + const CefRefPtr object, + CefRefPtr& retval, + CefString& exception) OVERRIDE { + return true; + } + virtual bool Set(const CefString& name, + const CefRefPtr object, + const CefRefPtr value, + CefString& exception) OVERRIDE { + return true; + } + IMPLEMENT_REFCOUNTING(Accessor); + }; + + CefRefPtr accessor = new Accessor(); + + PERF_ITERATIONS_START() + CefRefPtr value = CefV8Value::CreateObject(accessor); + PERF_ITERATIONS_END() +} + + +PERF_TEST_FUNC(V8ObjectSetValue) { + CefString name = "name"; + CefRefPtr val = CefV8Value::CreateBool(true); + CefRefPtr obj = CefV8Value::CreateObject(NULL); + obj->SetValue(name, val, V8_PROPERTY_ATTRIBUTE_NONE); + + PERF_ITERATIONS_START() + obj->SetValue(name, val, V8_PROPERTY_ATTRIBUTE_NONE); + PERF_ITERATIONS_END() +} + +PERF_TEST_FUNC(V8ObjectGetValue) { + CefString name = "name"; + CefRefPtr val = CefV8Value::CreateBool(true); + CefRefPtr obj = CefV8Value::CreateObject(NULL); + obj->SetValue(name, val, V8_PROPERTY_ATTRIBUTE_NONE); + + PERF_ITERATIONS_START() + CefRefPtr ret = obj->GetValue(name); + PERF_ITERATIONS_END() +} + +PERF_TEST_FUNC(V8ObjectSetValueWithAccessor) { + class Accessor : public CefV8Accessor { + public: + Accessor() {} + virtual bool Get(const CefString& name, + const CefRefPtr object, + CefRefPtr& retval, + CefString& exception) OVERRIDE { + return true; + } + virtual bool Set(const CefString& name, + const CefRefPtr object, + const CefRefPtr value, + CefString& exception) OVERRIDE { + val_ = value; + return true; + } + CefRefPtr val_; + IMPLEMENT_REFCOUNTING(Accessor); + }; + + CefRefPtr accessor = new Accessor(); + + CefString name = "name"; + CefRefPtr val = CefV8Value::CreateBool(true); + CefRefPtr obj = CefV8Value::CreateObject(accessor); + obj->SetValue(name, V8_ACCESS_CONTROL_DEFAULT, V8_PROPERTY_ATTRIBUTE_NONE); + obj->SetValue(name, val, V8_PROPERTY_ATTRIBUTE_NONE); + + PERF_ITERATIONS_START() + obj->SetValue(name, val, V8_PROPERTY_ATTRIBUTE_NONE); + PERF_ITERATIONS_END() +} + +PERF_TEST_FUNC(V8ObjectGetValueWithAccessor) { + class Accessor : public CefV8Accessor { + public: + Accessor() : val_(CefV8Value::CreateBool(true)) {} + virtual bool Get(const CefString& name, + const CefRefPtr object, + CefRefPtr& retval, + CefString& exception) OVERRIDE { + retval = val_; + return true; + } + virtual bool Set(const CefString& name, + const CefRefPtr object, + const CefRefPtr value, + CefString& exception) OVERRIDE { + return true; + } + CefRefPtr val_; + IMPLEMENT_REFCOUNTING(Accessor); + }; + + CefRefPtr accessor = new Accessor(); + + CefString name = "name"; + CefRefPtr val = CefV8Value::CreateBool(true); + CefRefPtr obj = CefV8Value::CreateObject(accessor); + obj->SetValue(name, V8_ACCESS_CONTROL_DEFAULT, V8_PROPERTY_ATTRIBUTE_NONE); + obj->SetValue(name, val, V8_PROPERTY_ATTRIBUTE_NONE); + + PERF_ITERATIONS_START() + CefRefPtr ret = obj->GetValue(name); + PERF_ITERATIONS_END() +} + +PERF_TEST_FUNC(V8ContextEnterExit) { + CefRefPtr context = CefV8Context::GetCurrentContext(); + + PERF_ITERATIONS_START() + context->Enter(); + context->Exit(); + PERF_ITERATIONS_END() +} + +PERF_TEST_FUNC(V8ContextEval) { + CefRefPtr context = CefV8Context::GetCurrentContext(); + CefString jsCode = "var i = 0;"; + CefRefPtr retval; + CefRefPtr exception; + + PERF_ITERATIONS_START() + context->Eval(jsCode, retval, exception); + PERF_ITERATIONS_END() +} + +} // namespace + + +// Test function entries. + +const PerfTestEntry kPerfTests[] = { + PERF_TEST_ENTRY(V8NullCreate), + PERF_TEST_ENTRY(V8BoolCreate), + PERF_TEST_ENTRY(V8IntCreate), + PERF_TEST_ENTRY(V8UIntCreate), + PERF_TEST_ENTRY(V8DoubleCreate), + PERF_TEST_ENTRY(V8DateCreate), + PERF_TEST_ENTRY(V8StringCreate), + PERF_TEST_ENTRY(V8ArrayCreate), + PERF_TEST_ENTRY(V8ArraySetValue), + PERF_TEST_ENTRY(V8ArrayGetValue), + PERF_TEST_ENTRY(V8FunctionCreate), + PERF_TEST_ENTRY(V8FunctionExecute), + PERF_TEST_ENTRY(V8FunctionExecuteWithContext), + PERF_TEST_ENTRY(V8ObjectCreate), + PERF_TEST_ENTRY(V8ObjectCreateWithAccessor), + PERF_TEST_ENTRY(V8ObjectSetValue), + PERF_TEST_ENTRY(V8ObjectGetValue), + PERF_TEST_ENTRY(V8ObjectSetValueWithAccessor), + PERF_TEST_ENTRY(V8ObjectGetValueWithAccessor), + PERF_TEST_ENTRY(V8ContextEnterExit), + PERF_TEST_ENTRY(V8ContextEval), +}; + +const size_t kPerfTestsCount = (sizeof(kPerfTests) / sizeof(kPerfTests[0])); + +} // namespace performance_test diff --git a/cef3/tests/cefclient/process_helper_mac.cpp b/cef3/tests/cefclient/process_helper_mac.cpp new file mode 100644 index 000000000..eb7986d6c --- /dev/null +++ b/cef3/tests/cefclient/process_helper_mac.cpp @@ -0,0 +1,32 @@ +// 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 "include/cef_app.h" + +// This file is shared by cefclient and cef_unittests so don't include using +// a qualified path. +#include "client_app.h" // NOLINT(build/include) + +// Stub implementations. +std::string AppGetWorkingDirectory() { + return std::string(); +} +CefWindowHandle AppGetMainHwnd() { + return NULL; +} +void AppQuitMessageLoop() { +} +bool AppIsOffScreenRenderingEnabled() { + return false; +} + +// Process entry point. +int main(int argc, char* argv[]) { + CefMainArgs main_args(argc, argv); + + CefRefPtr app(new ClientApp); + + // Execute the secondary process. + return CefExecuteProcess(main_args, app); +} diff --git a/cef3/tests/cefclient/res/binding.html b/cef3/tests/cefclient/res/binding.html new file mode 100644 index 000000000..edb1f4a00 --- /dev/null +++ b/cef3/tests/cefclient/res/binding.html @@ -0,0 +1,27 @@ + + +Binding Test + + + + +
+Message: +
+
You should see the reverse of your message below: +
+
+ + diff --git a/cef3/tests/cefclient/res/cefclient.ico b/cef3/tests/cefclient/res/cefclient.ico new file mode 100644 index 000000000..d551aa3aa Binary files /dev/null and b/cef3/tests/cefclient/res/cefclient.ico differ diff --git a/cef3/tests/cefclient/res/dialogs.html b/cef3/tests/cefclient/res/dialogs.html new file mode 100644 index 000000000..c31dff165 --- /dev/null +++ b/cef3/tests/cefclient/res/dialogs.html @@ -0,0 +1,64 @@ + + +Dialog Test + + + +
+Click a button to show the associated dialog type. +
+
+
+
input type="file": +
+
+
+

+
+ + diff --git a/cef3/tests/cefclient/res/domaccess.html b/cef3/tests/cefclient/res/domaccess.html new file mode 100644 index 000000000..68ff69647 --- /dev/null +++ b/cef3/tests/cefclient/res/domaccess.html @@ -0,0 +1,13 @@ + + +

Select some portion of the below page content and click the "Describe Selection" button. The selected region will then be described below.

+

This is p1

+

This is p2

+

This is p3

+

This is p4

+
+ +

The description will appear here.

+
+ + diff --git a/cef3/tests/cefclient/res/localstorage.html b/cef3/tests/cefclient/res/localstorage.html new file mode 100644 index 000000000..a794305b7 --- /dev/null +++ b/cef3/tests/cefclient/res/localstorage.html @@ -0,0 +1,24 @@ + + + +Click the "Add Line" button to add a line or the "Clear" button to clear.
+This data will persist across sessions if a cache path was specified.
+ + +
+ + + diff --git a/cef3/tests/cefclient/res/logo.png b/cef3/tests/cefclient/res/logo.png new file mode 100644 index 000000000..41dd728df Binary files /dev/null and b/cef3/tests/cefclient/res/logo.png differ diff --git a/cef3/tests/cefclient/res/other_tests.html b/cef3/tests/cefclient/res/other_tests.html new file mode 100644 index 000000000..e6fc0990f --- /dev/null +++ b/cef3/tests/cefclient/res/other_tests.html @@ -0,0 +1,29 @@ + + +Other Tests + + +

Various other internal and external tests.

+ + + diff --git a/cef3/tests/cefclient/res/performance.html b/cef3/tests/cefclient/res/performance.html new file mode 100644 index 000000000..df7f0a5d7 --- /dev/null +++ b/cef3/tests/cefclient/res/performance.html @@ -0,0 +1,293 @@ + + + + Performance Tests + + + +

Performance Tests

+ Filter: +
+ +
+ + + + + + + + + + + + + +
NameIterations per RunAvg (ms)Min (ms)Max (ms)StdDev (ms)Runs (ms)
+
+ +
+ + Result 1: +
Result 2: +
+ +
+ + + + + + + + + + +
NameResult 1 Avg (ms)Result 2 Avg (ms)% Diff
+
+ + + + + diff --git a/cef3/tests/cefclient/res/small.ico b/cef3/tests/cefclient/res/small.ico new file mode 100644 index 000000000..d551aa3aa Binary files /dev/null and b/cef3/tests/cefclient/res/small.ico differ diff --git a/cef3/tests/cefclient/res/transparency.html b/cef3/tests/cefclient/res/transparency.html new file mode 100644 index 000000000..a8dd3b46e --- /dev/null +++ b/cef3/tests/cefclient/res/transparency.html @@ -0,0 +1,63 @@ + + + +Transparency Examples + + + + +

Image Transparency

+Hover over an image to make it fully opaque.
+klematis +klematis + +

Block Transparency

+White 0% White 25% White 50% White 75% White 100% +
+Black 0% Black 25% Black 50% Black 75% Black 100% + + + diff --git a/cef3/tests/cefclient/res/window.html b/cef3/tests/cefclient/res/window.html new file mode 100644 index 000000000..c901cb620 --- /dev/null +++ b/cef3/tests/cefclient/res/window.html @@ -0,0 +1,44 @@ + + +Window Test + + + +
+Click a button to perform the associated window action. +
+
+
(minimizes and then restores the window as topmost) +
X: Y: Width: Height: +
+ + diff --git a/cef3/tests/cefclient/res/xmlhttprequest.html b/cef3/tests/cefclient/res/xmlhttprequest.html new file mode 100644 index 000000000..638c63c82 --- /dev/null +++ b/cef3/tests/cefclient/res/xmlhttprequest.html @@ -0,0 +1,19 @@ + + + +
+URL: +
+
+
+ + diff --git a/cef3/tests/cefclient/resource.h b/cef3/tests/cefclient/resource.h new file mode 100644 index 000000000..e565d057e --- /dev/null +++ b/cef3/tests/cefclient/resource.h @@ -0,0 +1,66 @@ +// Copyright (c) 2013 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. + +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by cefclient.rc +// +#define BINARY 256 +#define IDC_MYICON 2 +#define IDD_CEFCLIENT_DIALOG 102 +#define IDS_APP_TITLE 103 +#define IDD_ABOUTBOX 103 +#define IDM_ABOUT 104 +#define IDM_EXIT 105 +#define IDI_CEFCLIENT 107 +#define IDI_SMALL 108 +#define IDC_CEFCLIENT 109 +#define IDS_OSR_WIDGET_CLASS 110 +#define IDR_MAINFRAME 128 +#define IDC_NAV_BACK 200 +#define IDC_NAV_FORWARD 201 +#define IDC_NAV_RELOAD 202 +#define IDC_NAV_STOP 203 +#define ID_WARN_CONSOLEMESSAGE 32000 +#define ID_WARN_DOWNLOADCOMPLETE 32001 +#define ID_WARN_DOWNLOADERROR 32002 +#define ID_QUIT 32500 +#define ID_TESTS_GETSOURCE 32700 +#define ID_TESTS_GETTEXT 32701 +#define ID_TESTS_OTHER_TESTS 32702 +#define ID_TESTS_PLUGIN_INFO 32703 +#define ID_TESTS_POPUP 32704 +#define ID_TESTS_REQUEST 32705 +#define ID_TESTS_TRACING_BEGIN 32706 +#define ID_TESTS_TRACING_END 32707 +#define ID_TESTS_ZOOM_IN 32708 +#define ID_TESTS_ZOOM_OUT 32709 +#define ID_TESTS_ZOOM_RESET 32710 +#define IDC_STATIC -1 +#define IDS_BINDING 1000 +#define IDS_DIALOGS 1001 +#define IDS_DOMACCESS 1002 +#define IDS_LOCALSTORAGE 1003 +#define IDS_LOGO 1004 +#define IDS_LOGOBALL 1005 +#define IDS_OTHER_TESTS 1006 +#define IDS_PERFORMANCE 1007 +#define IDS_TRANSPARENCY 1008 +#define IDS_WINDOW 1009 +#define IDS_XMLHTTPREQUEST 1010 + +// Avoid files associated with MacOS +#define _X86_ + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NO_MFC 1 +#define _APS_NEXT_RESOURCE_VALUE 130 +#define _APS_NEXT_COMMAND_VALUE 32774 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 111 +#endif +#endif diff --git a/cef3/tests/cefclient/resource_util.h b/cef3/tests/cefclient/resource_util.h new file mode 100644 index 000000000..d38830792 --- /dev/null +++ b/cef3/tests/cefclient/resource_util.h @@ -0,0 +1,23 @@ +// Copyright (c) 2013 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_RESOURCE_UTIL_H_ +#define CEF_TESTS_CEFCLIENT_RESOURCE_UTIL_H_ +#pragma once + +#include +#include "include/cef_stream.h" + +#if defined(OS_POSIX) +// Returns the directory containing resource files. +bool GetResourceDir(std::string& dir); +#endif + +// Retrieve a resource as a string. +bool LoadBinaryResource(const char* resource_name, std::string& resource_data); + +// Retrieve a resource as a steam reader. +CefRefPtr GetBinaryResourceReader(const char* resource_name); + +#endif // CEF_TESTS_CEFCLIENT_RESOURCE_UTIL_H_ diff --git a/cef3/tests/cefclient/resource_util_linux.cpp b/cef3/tests/cefclient/resource_util_linux.cpp new file mode 100644 index 000000000..aa4f4a939 --- /dev/null +++ b/cef3/tests/cefclient/resource_util_linux.cpp @@ -0,0 +1,29 @@ +// Copyright (c) 2013 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 The Chromium 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/resource_util.h" +#include +#include + +bool GetResourceDir(std::string& dir) { + char buff[1024]; + + // Retrieve the executable path. + ssize_t len = readlink("/proc/self/exe", buff, sizeof(buff)-1); + if (len == -1) + return false; + + buff[len] = 0; + + // Remove the executable name from the path. + char* pos = strrchr(buff, '/'); + if (!pos) + return false; + + // Add "files" to the path. + strcpy(pos+1, "files"); // NOLINT(runtime/printf) + dir = std::string(buff); + return true; +} diff --git a/cef3/tests/cefclient/resource_util_mac.mm b/cef3/tests/cefclient/resource_util_mac.mm new file mode 100644 index 000000000..c4652a0cf --- /dev/null +++ b/cef3/tests/cefclient/resource_util_mac.mm @@ -0,0 +1,59 @@ +// Copyright (c) 2013 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 The Chromium 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/resource_util.h" +#import +#include +#include +#include "cefclient/util.h" + +namespace { + +bool AmIBundled() { + // Implementation adapted from Chromium's base/mac/foundation_util.mm + ProcessSerialNumber psn = {0, kCurrentProcess}; + + FSRef fsref; + OSStatus pbErr; + if ((pbErr = GetProcessBundleLocation(&psn, &fsref)) != noErr) { + ASSERT(false); + return false; + } + + FSCatalogInfo info; + OSErr fsErr; + if ((fsErr = FSGetCatalogInfo(&fsref, kFSCatInfoNodeFlags, &info, + NULL, NULL, NULL)) != noErr) { + ASSERT(false); + return false; + } + + return (info.nodeFlags & kFSNodeIsDirectoryMask); +} + +} // namespace + +bool GetResourceDir(std::string& dir) { + // Implementation adapted from Chromium's base/base_path_mac.mm + if (AmIBundled()) { + // Retrieve the executable directory. + uint32_t pathSize = 0; + _NSGetExecutablePath(NULL, &pathSize); + if (pathSize > 0) { + dir.resize(pathSize); + _NSGetExecutablePath(const_cast(dir.c_str()), &pathSize); + } + + // Trim executable name up to the last separator + std::string::size_type last_separator = dir.find_last_of("/"); + dir.resize(last_separator); + dir.append("/../Resources"); + return true; + } else { + // TODO: Provide unbundled path + ASSERT(false); + return false; + } +} diff --git a/cef3/tests/cefclient/resource_util_posix.cpp b/cef3/tests/cefclient/resource_util_posix.cpp new file mode 100644 index 000000000..68a4331f6 --- /dev/null +++ b/cef3/tests/cefclient/resource_util_posix.cpp @@ -0,0 +1,59 @@ +// Copyright (c) 2013 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/resource_util.h" +#include + +namespace { + +bool FileExists(const char* path) { + FILE* f = fopen(path, "rb"); + if (f) { + fclose(f); + return true; + } + return false; +} + +bool ReadFileToString(const char* path, std::string& data) { + // Implementation adapted from base/file_util.cc + FILE* file = fopen(path, "rb"); + if (!file) + return false; + + char buf[1 << 16]; + size_t len; + while ((len = fread(buf, 1, sizeof(buf), file)) > 0) + data.append(buf, len); + fclose(file); + + return true; +} + +} // namespace + +bool LoadBinaryResource(const char* resource_name, std::string& resource_data) { + std::string path; + if (!GetResourceDir(path)) + return false; + + path.append("/"); + path.append(resource_name); + + return ReadFileToString(path.c_str(), resource_data); +} + +CefRefPtr GetBinaryResourceReader(const char* resource_name) { + std::string path; + if (!GetResourceDir(path)) + return NULL; + + path.append("/"); + path.append(resource_name); + + if (!FileExists(path.c_str())) + return NULL; + + return CefStreamReader::CreateForFile(path); +} diff --git a/cef3/tests/cefclient/resource_util_win.cpp b/cef3/tests/cefclient/resource_util_win.cpp new file mode 100644 index 000000000..b8f7a5ff9 --- /dev/null +++ b/cef3/tests/cefclient/resource_util_win.cpp @@ -0,0 +1,90 @@ +// Copyright (c) 2013 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/resource_util.h" +#include "include/cef_stream.h" +#include "include/wrapper/cef_byte_read_handler.h" +#include "cefclient/resource.h" +#include "cefclient/util.h" + +namespace { + +bool LoadBinaryResource(int binaryId, DWORD &dwSize, LPBYTE &pBytes) { + HINSTANCE hInst = GetModuleHandle(NULL); + HRSRC hRes = FindResource(hInst, MAKEINTRESOURCE(binaryId), + MAKEINTRESOURCE(256)); + if (hRes) { + HGLOBAL hGlob = LoadResource(hInst, hRes); + if (hGlob) { + dwSize = SizeofResource(hInst, hRes); + pBytes = (LPBYTE)LockResource(hGlob); + if (dwSize > 0 && pBytes) + return true; + } + } + + return false; +} + +int GetResourceId(const char* resource_name) { + // Map of resource labels to BINARY id values. + static struct _resource_map { + char* name; + int id; + } resource_map[] = { + {"binding.html", IDS_BINDING}, + {"dialogs.html", IDS_DIALOGS}, + {"domaccess.html", IDS_DOMACCESS}, + {"localstorage.html", IDS_LOCALSTORAGE}, + {"logo.png", IDS_LOGO}, + {"other_tests.html", IDS_OTHER_TESTS}, + {"performance.html", IDS_PERFORMANCE}, + {"transparency.html", IDS_TRANSPARENCY}, + {"window.html", IDS_WINDOW}, + {"xmlhttprequest.html", IDS_XMLHTTPREQUEST}, + }; + + for (int i = 0; i < sizeof(resource_map)/sizeof(_resource_map); ++i) { + if (!strcmp(resource_map[i].name, resource_name)) + return resource_map[i].id; + } + + return 0; +} + +} // namespace + +bool LoadBinaryResource(const char* resource_name, std::string& resource_data) { + int resource_id = GetResourceId(resource_name); + if (resource_id == 0) + return false; + + DWORD dwSize; + LPBYTE pBytes; + + if (LoadBinaryResource(resource_id, dwSize, pBytes)) { + resource_data = std::string(reinterpret_cast(pBytes), dwSize); + return true; + } + + ASSERT(FALSE); // The resource should be found. + return false; +} + +CefRefPtr GetBinaryResourceReader(const char* resource_name) { + int resource_id = GetResourceId(resource_name); + if (resource_id == 0) + return NULL; + + DWORD dwSize; + LPBYTE pBytes; + + if (LoadBinaryResource(resource_id, dwSize, pBytes)) { + return CefStreamReader::CreateForHandler( + new CefByteReadHandler(pBytes, dwSize, NULL)); + } + + ASSERT(FALSE); // The resource should be found. + return NULL; +} diff --git a/cef3/tests/cefclient/scheme_test.cpp b/cef3/tests/cefclient/scheme_test.cpp new file mode 100644 index 000000000..2f010bd02 --- /dev/null +++ b/cef3/tests/cefclient/scheme_test.cpp @@ -0,0 +1,165 @@ +// 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/scheme_test.h" +#include +#include +#include "include/cef_browser.h" +#include "include/cef_callback.h" +#include "include/cef_frame.h" +#include "include/cef_resource_handler.h" +#include "include/cef_response.h" +#include "include/cef_request.h" +#include "include/cef_scheme.h" +#include "cefclient/resource_util.h" +#include "cefclient/string_util.h" +#include "cefclient/util.h" + +#if defined(OS_WIN) +#include "cefclient/resource.h" +#endif + +namespace scheme_test { + +namespace { + +// Implementation of the schema handler for client:// requests. +class ClientSchemeHandler : public CefResourceHandler { + public: + ClientSchemeHandler() : offset_(0) {} + + virtual bool ProcessRequest(CefRefPtr request, + CefRefPtr callback) + OVERRIDE { + REQUIRE_IO_THREAD(); + + bool handled = false; + + AutoLock lock_scope(this); + + std::string url = request->GetURL(); + if (strstr(url.c_str(), "handler.html") != NULL) { + // Build the response html + data_ = "Client Scheme Handler" + "This contents of this page page are served by the " + "ClientSchemeHandler class handling the client:// protocol." + "
You should see an image:" + "
";
+
+      // Output a string representation of the request
+      std::string dump;
+      DumpRequestContents(request, dump);
+      data_.append(dump);
+
+      data_.append("

Try the test form:" + "
" + "" + "" + "" + "
"); + + handled = true; + + // Set the resulting mime type + mime_type_ = "text/html"; + } else if (strstr(url.c_str(), "client.png") != NULL) { + // Load the response image + if (LoadBinaryResource("logo.png", data_)) { + handled = true; + // Set the resulting mime type + mime_type_ = "image/png"; + } + } + + if (handled) { + // Indicate the headers are available. + callback->Continue(); + return true; + } + + return false; + } + + virtual void GetResponseHeaders(CefRefPtr response, + int64& response_length, + CefString& redirectUrl) OVERRIDE { + REQUIRE_IO_THREAD(); + + ASSERT(!data_.empty()); + + response->SetMimeType(mime_type_); + response->SetStatus(200); + + // Set the resulting response length + response_length = data_.length(); + } + + virtual void Cancel() OVERRIDE { + REQUIRE_IO_THREAD(); + } + + virtual bool ReadResponse(void* data_out, + int bytes_to_read, + int& bytes_read, + CefRefPtr callback) + OVERRIDE { + REQUIRE_IO_THREAD(); + + bool has_data = false; + bytes_read = 0; + + AutoLock lock_scope(this); + + if (offset_ < data_.length()) { + // Copy the next block of data into the buffer. + int transfer_size = + std::min(bytes_to_read, static_cast(data_.length() - offset_)); + memcpy(data_out, data_.c_str() + offset_, transfer_size); + offset_ += transfer_size; + + bytes_read = transfer_size; + has_data = true; + } + + return has_data; + } + + private: + std::string data_; + std::string mime_type_; + size_t offset_; + + IMPLEMENT_REFCOUNTING(ClientSchemeHandler); + IMPLEMENT_LOCKING(ClientSchemeHandler); +}; + +// Implementation of the factory for for creating schema handlers. +class ClientSchemeHandlerFactory : public CefSchemeHandlerFactory { + public: + // Return a new scheme handler instance to handle the request. + virtual CefRefPtr Create(CefRefPtr browser, + CefRefPtr frame, + const CefString& scheme_name, + CefRefPtr request) + OVERRIDE { + REQUIRE_IO_THREAD(); + return new ClientSchemeHandler(); + } + + IMPLEMENT_REFCOUNTING(ClientSchemeHandlerFactory); +}; + +} // namespace + +void RegisterCustomSchemes(CefRefPtr registrar, + std::vector& cookiable_schemes) { + registrar->AddCustomScheme("client", true, false, false); +} + +void InitTest() { + CefRegisterSchemeHandlerFactory("client", "tests", + new ClientSchemeHandlerFactory()); +} + +} // namespace scheme_test diff --git a/cef3/tests/cefclient/scheme_test.h b/cef3/tests/cefclient/scheme_test.h new file mode 100644 index 000000000..36f670835 --- /dev/null +++ b/cef3/tests/cefclient/scheme_test.h @@ -0,0 +1,26 @@ +// Copyright (c) 2009 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_SCHEME_TEST_H_ +#define CEF_TESTS_CEFCLIENT_SCHEME_TEST_H_ +#pragma once + +#include +#include "include/cef_base.h" + +class CefBrowser; +class CefSchemeRegistrar; + +namespace scheme_test { + +// Register the scheme. +void RegisterCustomSchemes(CefRefPtr registrar, + std::vector& cookiable_schemes); + +// Create the scheme handler. +void InitTest(); + +} // namespace scheme_test + +#endif // CEF_TESTS_CEFCLIENT_SCHEME_TEST_H_ diff --git a/cef3/tests/cefclient/string_util.cpp b/cef3/tests/cefclient/string_util.cpp new file mode 100644 index 000000000..ebeca5c03 --- /dev/null +++ b/cef3/tests/cefclient/string_util.cpp @@ -0,0 +1,74 @@ +// Copyright (c) 2010 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/string_util.h" +#include +#include +#include "include/cef_request.h" + +void DumpRequestContents(CefRefPtr request, std::string& str) { + std::stringstream ss; + + ss << "URL: " << std::string(request->GetURL()); + ss << "\nMethod: " << std::string(request->GetMethod()); + + CefRequest::HeaderMap headerMap; + request->GetHeaderMap(headerMap); + if (headerMap.size() > 0) { + ss << "\nHeaders:"; + CefRequest::HeaderMap::const_iterator it = headerMap.begin(); + for (; it != headerMap.end(); ++it) { + ss << "\n\t" << std::string((*it).first) << ": " << + std::string((*it).second); + } + } + + CefRefPtr postData = request->GetPostData(); + if (postData.get()) { + CefPostData::ElementVector elements; + postData->GetElements(elements); + if (elements.size() > 0) { + ss << "\nPost Data:"; + CefRefPtr element; + CefPostData::ElementVector::const_iterator it = elements.begin(); + for (; it != elements.end(); ++it) { + element = (*it); + if (element->GetType() == PDE_TYPE_BYTES) { + // the element is composed of bytes + ss << "\n\tBytes: "; + if (element->GetBytesCount() == 0) { + ss << "(empty)"; + } else { + // retrieve the data. + size_t size = element->GetBytesCount(); + char* bytes = new char[size]; + element->GetBytes(size, bytes); + ss << std::string(bytes, size); + delete [] bytes; + } + } else if (element->GetType() == PDE_TYPE_FILE) { + ss << "\n\tFile: " << std::string(element->GetFile()); + } + } + } + } + + str = ss.str(); +} + +std::string StringReplace(const std::string& str, const std::string& from, + const std::string& to) { + std::string result = str; + std::string::size_type pos = 0; + std::string::size_type from_len = from.length(); + std::string::size_type to_len = to.length(); + do { + pos = result.find(from, pos); + if (pos != std::string::npos) { + result.replace(pos, from_len, to); + pos += to_len; + } + } while (pos != std::string::npos); + return result; +} diff --git a/cef3/tests/cefclient/string_util.h b/cef3/tests/cefclient/string_util.h new file mode 100644 index 000000000..c43e6f210 --- /dev/null +++ b/cef3/tests/cefclient/string_util.h @@ -0,0 +1,21 @@ +// Copyright (c) 2010 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_STRING_UTIL_H_ +#define CEF_TESTS_CEFCLIENT_STRING_UTIL_H_ +#pragma once + +#include +#include "include/cef_base.h" + +class CefRequest; + +// Dump the contents of the request into a string. +void DumpRequestContents(CefRefPtr request, std::string& str); + +// Replace all instances of |from| with |to| in |str|. +std::string StringReplace(const std::string& str, const std::string& from, + const std::string& to); + +#endif // CEF_TESTS_CEFCLIENT_STRING_UTIL_H_ diff --git a/cef3/tests/cefclient/util.h b/cef3/tests/cefclient/util.h new file mode 100644 index 000000000..ba0305c1c --- /dev/null +++ b/cef3/tests/cefclient/util.h @@ -0,0 +1,37 @@ +// 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_UTIL_H_ +#define CEF_TESTS_CEFCLIENT_UTIL_H_ +#pragma once + +#include "include/cef_task.h" + +#if defined(OS_WIN) + +#include // NOLINT(build/include_order) + +#ifndef NDEBUG +#define ASSERT(condition) if (!(condition)) { DebugBreak(); } +#else +#define ASSERT(condition) ((void)0) +#endif + +#else // !OS_WIN + +#include // NOLINT(build/include_order) + +#ifndef NDEBUG +#define ASSERT(condition) if (!(condition)) { assert(false); } +#else +#define ASSERT(condition) ((void)0) +#endif + +#endif // !OS_WIN + +#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_ diff --git a/cef3/tests/cefclient/window_test.cpp b/cef3/tests/cefclient/window_test.cpp new file mode 100644 index 000000000..c4375b85d --- /dev/null +++ b/cef3/tests/cefclient/window_test.cpp @@ -0,0 +1,90 @@ +// Copyright (c) 2013 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/window_test.h" + +#include +#include + +#include "include/wrapper/cef_stream_resource_handler.h" + +namespace window_test { + +namespace { + +const char* kMessagePositionName = "WindowTest.Position"; +const char* kMessageMinimizeName = "WindowTest.Minimize"; +const char* kMessageMaximizeName = "WindowTest.Maximize"; +const char* kMessageRestoreName = "WindowTest.Restore"; + +// Handle messages in the browser process. +class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate { + public: + ProcessMessageDelegate() { + } + + // From ClientHandler::ProcessMessageDelegate. + virtual bool OnProcessMessageReceived( + CefRefPtr handler, + CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) OVERRIDE { + std::string message_name = message->GetName(); + if (message_name == kMessagePositionName) { + CefRefPtr args = message->GetArgumentList(); + if (args->GetSize() >= 4) { + int x = args->GetInt(0); + int y = args->GetInt(1); + int width = args->GetInt(2); + int height = args->GetInt(3); + SetPos(browser->GetHost()->GetWindowHandle(), x, y, width, height); + } + return true; + } else if (message_name == kMessageMinimizeName) { + Minimize(browser->GetHost()->GetWindowHandle()); + return true; + } else if (message_name == kMessageMaximizeName) { + Maximize(browser->GetHost()->GetWindowHandle()); + return true; + } else if (message_name == kMessageRestoreName) { + Restore(browser->GetHost()->GetWindowHandle()); + return true; + } + + return false; + } + + IMPLEMENT_REFCOUNTING(ProcessMessageDelegate); +}; + +} // namespace + +void CreateProcessMessageDelegates( + ClientHandler::ProcessMessageDelegateSet& delegates) { + delegates.insert(new ProcessMessageDelegate); +} + +void ModifyBounds(const CefRect& display, CefRect& window) { + window.x += display.x; + window.y += display.y; + + if (window.x < display.x) + window.x = display.x; + if (window.y < display.y) + window.y = display.y; + if (window.width < 100) + window.width = 100; + else if (window.width >= display.width) + window.width = display.width; + if (window.height < 100) + window.height = 100; + else if (window.height >= display.height) + window.height = display.height; + if (window.x + window.width >= display.x + display.width) + window.x = display.x + display.width - window.width; + if (window.y + window.height >= display.y + display.height) + window.y = display.y + display.height - window.height; +} + +} // namespace window_test diff --git a/cef3/tests/cefclient/window_test.h b/cef3/tests/cefclient/window_test.h new file mode 100644 index 000000000..b91c467ac --- /dev/null +++ b/cef3/tests/cefclient/window_test.h @@ -0,0 +1,29 @@ +// Copyright (c) 2013 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_WINDOW_TEST_H_ +#define CEF_TESTS_CEFCLIENT_WINDOW_TEST_H_ +#pragma once + +#include "cefclient/client_handler.h" + +namespace window_test { + +// Delegate creation. Called from ClientHandler. +void CreateProcessMessageDelegates( + ClientHandler::ProcessMessageDelegateSet& delegates); + +// Fit |window| inside |display|. Coordinates are relative to the upper-left +// corner of the display. +void ModifyBounds(const CefRect& display, CefRect& window); + +// Platform implementations. +void SetPos(CefWindowHandle handle, int x, int y, int width, int height); +void Minimize(CefWindowHandle handle); +void Maximize(CefWindowHandle handle); +void Restore(CefWindowHandle handle); + +} // namespace window_test + +#endif // CEF_TESTS_CEFCLIENT_WINDOW_TEST_H_ diff --git a/cef3/tests/cefclient/window_test_gtk.cpp b/cef3/tests/cefclient/window_test_gtk.cpp new file mode 100644 index 000000000..49dd5760a --- /dev/null +++ b/cef3/tests/cefclient/window_test_gtk.cpp @@ -0,0 +1,72 @@ +// Copyright (c) 2013 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/window_test.h" + +#include + +namespace window_test { + +namespace { + +GtkWindow* GetWindow(CefWindowHandle handle) { + return GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(handle))); +} + +bool IsMaximized(GtkWindow* window) { + GdkWindow* gdk_window = gtk_widget_get_window(GTK_WIDGET(window)); + gint state = gdk_window_get_state(gdk_window); + return (state & GDK_WINDOW_STATE_MAXIMIZED) ? true : false; +} + +} // namespace + +void SetPos(CefWindowHandle handle, int x, int y, int width, int height) { + GtkWindow* window = GetWindow(handle); + GdkWindow* gdk_window = gtk_widget_get_window(GTK_WIDGET(window)); + + // Make sure the window isn't minimized or maximized. + if (IsMaximized(window)) + gtk_window_unmaximize(window); + else + gtk_window_present(window); + + // Retrieve information about the display that contains the window. + GdkScreen* screen = gdk_screen_get_default(); + gint monitor = gdk_screen_get_monitor_at_window(screen, gdk_window); + GdkRectangle rect; + gdk_screen_get_monitor_geometry(screen, monitor, &rect); + + // Make sure the window is inside the display. + CefRect display_rect(rect.x, rect.y, rect.width, rect.height); + CefRect window_rect(x, y, width, height); + ModifyBounds(display_rect, window_rect); + + gdk_window_move_resize(gdk_window, window_rect.x, window_rect.y, + window_rect.width, window_rect.height); +} + +void Minimize(CefWindowHandle handle) { + GtkWindow* window = GetWindow(handle); + + // Unmaximize the window before minimizing so restore behaves correctly. + if (IsMaximized(window)) + gtk_window_unmaximize(window); + + gtk_window_iconify(window); +} + +void Maximize(CefWindowHandle handle) { + gtk_window_maximize(GetWindow(handle)); +} + +void Restore(CefWindowHandle handle) { + GtkWindow* window = GetWindow(handle); + if (IsMaximized(window)) + gtk_window_unmaximize(window); + else + gtk_window_present(window); +} + +} // namespace window_test diff --git a/cef3/tests/cefclient/window_test_mac.mm b/cef3/tests/cefclient/window_test_mac.mm new file mode 100644 index 000000000..c61d1b5b1 --- /dev/null +++ b/cef3/tests/cefclient/window_test_mac.mm @@ -0,0 +1,69 @@ +// Copyright (c) 2013 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/window_test.h" + +#import + +namespace window_test { + +namespace { + +NSWindow* GetWindow(CefWindowHandle handle) { + NSView* view = (NSView*)handle; + return [view window]; +} + +} // namespace + +void SetPos(CefWindowHandle handle, int x, int y, int width, int height) { + NSWindow* window = GetWindow(handle); + + // Make sure the window isn't minimized or maximized. + if ([window isMiniaturized]) + [window deminiaturize:nil]; + else if ([window isZoomed]) + [window performZoom:nil]; + + // Retrieve information for the display that contains the window. + NSScreen* screen = [window screen]; + if (screen == nil) + screen = [NSScreen mainScreen]; + NSRect frame = [screen frame]; + NSRect visibleFrame = [screen visibleFrame]; + + // Make sure the window is inside the display. + CefRect display_rect( + visibleFrame.origin.x, + frame.size.height - visibleFrame.size.height - visibleFrame.origin.y, + visibleFrame.size.width, + visibleFrame.size.height); + CefRect window_rect(x, y, width, height); + ModifyBounds(display_rect, window_rect); + + NSRect newRect; + newRect.origin.x = window_rect.x; + newRect.origin.y = frame.size.height - window_rect.height - window_rect.y; + newRect.size.width = window_rect.width; + newRect.size.height = window_rect.height; + [window setFrame:newRect display:YES]; +} + +void Minimize(CefWindowHandle handle) { + [GetWindow(handle) performMiniaturize:nil]; +} + +void Maximize(CefWindowHandle handle) { + [GetWindow(handle) performZoom:nil]; +} + +void Restore(CefWindowHandle handle) { + NSWindow* window = GetWindow(handle); + if ([window isMiniaturized]) + [window deminiaturize:nil]; + else if ([window isZoomed]) + [window performZoom:nil]; +} + +} // namespace window_test diff --git a/cef3/tests/cefclient/window_test_win.cpp b/cef3/tests/cefclient/window_test_win.cpp new file mode 100644 index 000000000..2a6e44fad --- /dev/null +++ b/cef3/tests/cefclient/window_test_win.cpp @@ -0,0 +1,78 @@ +// Copyright (c) 2013 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/window_test.h" + +namespace window_test { + +namespace { + +// Toggles the current display state. +void Toggle(CefWindowHandle handle, UINT nCmdShow) { + HWND root_wnd = ::GetAncestor(handle, GA_ROOT); + + // Retrieve current window placement information. + WINDOWPLACEMENT placement; + ::GetWindowPlacement(root_wnd, &placement); + + if (placement.showCmd == nCmdShow) + ::ShowWindow(root_wnd, SW_RESTORE); + else + ::ShowWindow(root_wnd, nCmdShow); +} + +} // namespace + +void SetPos(CefWindowHandle handle, int x, int y, int width, int height) { + HWND root_wnd = ::GetAncestor(handle, GA_ROOT); + + // Retrieve current window placement information. + WINDOWPLACEMENT placement; + ::GetWindowPlacement(root_wnd, &placement); + + // Retrieve information about the display that contains the window. + HMONITOR monitor = MonitorFromRect(&placement.rcNormalPosition, + MONITOR_DEFAULTTONEAREST); + MONITORINFO info; + info.cbSize = sizeof(info); + GetMonitorInfo(monitor, &info); + + // Make sure the window is inside the display. + CefRect display_rect( + info.rcWork.left, + info.rcWork.top, + info.rcWork.right - info.rcWork.left, + info.rcWork.bottom - info.rcWork.top); + CefRect window_rect(x, y, width, height); + ModifyBounds(display_rect, window_rect); + + if (placement.showCmd == SW_MINIMIZE || placement.showCmd == SW_MAXIMIZE) { + // The window is currently minimized or maximized. Restore it to the desired + // position. + placement.rcNormalPosition.left = window_rect.x; + placement.rcNormalPosition.right = window_rect.x + window_rect.width; + placement.rcNormalPosition.top = window_rect.y; + placement.rcNormalPosition.bottom = window_rect.y + window_rect.height; + ::SetWindowPlacement(root_wnd, &placement); + ::ShowWindow(root_wnd, SW_RESTORE); + } else { + // Set the window position. + ::SetWindowPos(root_wnd, NULL, window_rect.x, window_rect.y, + window_rect.width, window_rect.height, SWP_NOZORDER); + } +} + +void Minimize(CefWindowHandle handle) { + Toggle(handle, SW_MINIMIZE); +} + +void Maximize(CefWindowHandle handle) { + Toggle(handle, SW_MAXIMIZE); +} + +void Restore(CefWindowHandle handle) { + ::ShowWindow(::GetAncestor(handle, GA_ROOT), SW_RESTORE); +} + +} // namespace window_test diff --git a/cef3/tests/unittests/client_app_delegates.cc b/cef3/tests/unittests/client_app_delegates.cc new file mode 100644 index 000000000..bf2a63268 --- /dev/null +++ b/cef3/tests/unittests/client_app_delegates.cc @@ -0,0 +1,63 @@ +// 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 "tests/cefclient/client_app.h" + +// static +void ClientApp::CreateBrowserDelegates(BrowserDelegateSet& delegates) { + // Bring in the V8 tests. + extern void CreateV8BrowserTests(BrowserDelegateSet& delegates); + CreateV8BrowserTests(delegates); + + // Bring in the Navigation tests. + extern void CreateNavigationBrowserTests(BrowserDelegateSet& delegates); + CreateNavigationBrowserTests(delegates); +} + +// static +void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) { + // Bring in the process message tests. + extern void CreateProcessMessageRendererTests( + ClientApp::RenderDelegateSet& delegates); + CreateProcessMessageRendererTests(delegates); + + // Bring in the V8 tests. + extern void CreateV8RendererTests(RenderDelegateSet& delegates); + CreateV8RendererTests(delegates); + + // Bring in the DOM tests. + extern void CreateDOMRendererTests(RenderDelegateSet& delegates); + CreateDOMRendererTests(delegates); + + // Bring in the URLRequest tests. + extern void CreateURLRequestRendererTests(RenderDelegateSet& delegates); + CreateURLRequestRendererTests(delegates); + + // Bring in the Navigation tests. + extern void CreateNavigationRendererTests(RenderDelegateSet& delegates); + CreateNavigationRendererTests(delegates); +} + +// static +void ClientApp::RegisterCustomSchemes( + CefRefPtr registrar, + std::vector& cookiable_schemes) { + // Bring in the scheme handler tests. + extern void RegisterSchemeHandlerCustomSchemes( + CefRefPtr registrar, + std::vector& cookiable_schemes); + RegisterSchemeHandlerCustomSchemes(registrar, cookiable_schemes); + + // Bring in the cookie tests. + extern void RegisterCookieCustomSchemes( + CefRefPtr registrar, + std::vector& cookiable_schemes); + RegisterCookieCustomSchemes(registrar, cookiable_schemes); + + // Bring in the URLRequest tests. + extern void RegisterURLRequestCustomSchemes( + CefRefPtr registrar, + std::vector& cookiable_schemes); + RegisterURLRequestCustomSchemes(registrar, cookiable_schemes); +} diff --git a/cef3/tests/unittests/command_line_unittest.cc b/cef3/tests/unittests/command_line_unittest.cc new file mode 100644 index 000000000..19c4b47b6 --- /dev/null +++ b/cef3/tests/unittests/command_line_unittest.cc @@ -0,0 +1,118 @@ +// 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 "include/cef_command_line.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +void VerifyCommandLine(CefRefPtr command_line) { + std::string program = command_line->GetProgram(); + EXPECT_EQ("test.exe", program); + + EXPECT_TRUE(command_line->HasSwitches()); + + EXPECT_TRUE(command_line->HasSwitch("switch1")); + std::string switch1 = command_line->GetSwitchValue("switch1"); + EXPECT_EQ("", switch1); + EXPECT_TRUE(command_line->HasSwitch("switch2")); + std::string switch2 = command_line->GetSwitchValue("switch2"); + EXPECT_EQ("val2", switch2); + EXPECT_TRUE(command_line->HasSwitch("switch3")); + std::string switch3 = command_line->GetSwitchValue("switch3"); + EXPECT_EQ("val3", switch3); + EXPECT_TRUE(command_line->HasSwitch("switch4")); + std::string switch4 = command_line->GetSwitchValue("switch4"); + EXPECT_EQ("val 4", switch4); + EXPECT_FALSE(command_line->HasSwitch("switchnoexist")); + + CefCommandLine::SwitchMap switches; + command_line->GetSwitches(switches); + EXPECT_EQ((size_t)4, switches.size()); + + bool has1 = false, has2 = false, has3 = false, has4 = false; + + CefCommandLine::SwitchMap::const_iterator it = switches.begin(); + for (; it != switches.end(); ++it) { + std::string name = it->first; + std::string val = it->second; + + if (name == "switch1") { + has1 = true; + EXPECT_EQ("", val); + } else if (name == "switch2") { + has2 = true; + EXPECT_EQ("val2", val); + } else if (name == "switch3") { + has3 = true; + EXPECT_EQ("val3", val); + } else if (name == "switch4") { + has4 = true; + EXPECT_EQ("val 4", val); + } + } + + EXPECT_TRUE(has1); + EXPECT_TRUE(has2); + EXPECT_TRUE(has3); + EXPECT_TRUE(has4); + + EXPECT_TRUE(command_line->HasArguments()); + + CefCommandLine::ArgumentList args; + command_line->GetArguments(args); + EXPECT_EQ((size_t)2, args.size()); + std::string arg0 = args[0]; + EXPECT_EQ("arg1", arg0); + std::string arg1 = args[1]; + EXPECT_EQ("arg 2", arg1); + + command_line->Reset(); + EXPECT_FALSE(command_line->HasSwitches()); + EXPECT_FALSE(command_line->HasArguments()); + std::string cur_program = command_line->GetProgram(); + EXPECT_EQ(program, cur_program); +} + +} // namespace + +// Test creating a command line from argc/argv or string. +TEST(CommandLineTest, Init) { + CefRefPtr command_line = CefCommandLine::CreateCommandLine(); + EXPECT_TRUE(command_line.get() != NULL); + +#if defined(OS_WIN) + command_line->InitFromString("test.exe --switch1 -switch2=val2 /switch3=val3 " + "-switch4=\"val 4\" arg1 \"arg 2\""); +#else + const char* args[] = { + "test.exe", + "--switch1", + "-switch2=val2", + "-switch3=val3", + "-switch4=val 4", + "arg1", + "arg 2" + }; + command_line->InitFromArgv(sizeof(args) / sizeof(char*), args); +#endif + + VerifyCommandLine(command_line); +} + +// Test creating a command line using set and append methods. +TEST(CommandLineTest, Manual) { + CefRefPtr command_line = CefCommandLine::CreateCommandLine(); + EXPECT_TRUE(command_line.get() != NULL); + + command_line->SetProgram("test.exe"); + command_line->AppendSwitch("switch1"); + command_line->AppendSwitchWithValue("switch2", "val2"); + command_line->AppendSwitchWithValue("switch3", "val3"); + command_line->AppendSwitchWithValue("switch4", "val 4"); + command_line->AppendArgument("arg1"); + command_line->AppendArgument("arg 2"); + + VerifyCommandLine(command_line); +} diff --git a/cef3/tests/unittests/cookie_unittest.cc b/cef3/tests/unittests/cookie_unittest.cc new file mode 100644 index 000000000..23da601ed --- /dev/null +++ b/cef3/tests/unittests/cookie_unittest.cc @@ -0,0 +1,1045 @@ +// 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 +#include "include/cef_cookie.h" +#include "include/cef_runnable.h" +#include "include/cef_scheme.h" +#include "tests/unittests/test_handler.h" +#include "tests/unittests/test_suite.h" +#include "base/files/scoped_temp_dir.h" +#include "base/synchronization/waitable_event.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +const char* kTestUrl = "http://www.test.com/path/to/cookietest/foo.html"; +const char* kTestDomain = "www.test.com"; +const char* kTestPath = "/path/to/cookietest"; + +typedef std::vector CookieVector; + +void IOT_Set(CefRefPtr manager, + const CefString& url, CookieVector* cookies, + base::WaitableEvent* event) { + CookieVector::const_iterator it = cookies->begin(); + for (; it != cookies->end(); ++it) + EXPECT_TRUE(manager->SetCookie(url, *it)); + event->Signal(); +} + +void IOT_Delete(CefRefPtr manager, + const CefString& url, const CefString& cookie_name, + base::WaitableEvent* event) { + EXPECT_TRUE(manager->DeleteCookies(url, cookie_name)); + event->Signal(); +} + +class TestVisitor : public CefCookieVisitor { + public: + TestVisitor(CookieVector* cookies, bool deleteCookies, + base::WaitableEvent* event) + : cookies_(cookies), + delete_cookies_(deleteCookies), + event_(event) { + } + virtual ~TestVisitor() { + event_->Signal(); + } + + virtual bool Visit(const CefCookie& cookie, int count, int total, + bool& deleteCookie) { + cookies_->push_back(cookie); + if (delete_cookies_) + deleteCookie = true; + return true; + } + + CookieVector* cookies_; + bool delete_cookies_; + base::WaitableEvent* event_; + + IMPLEMENT_REFCOUNTING(TestVisitor); +}; + +// Set the cookies. +void SetCookies(CefRefPtr manager, + const CefString& url, CookieVector& cookies, + base::WaitableEvent& event) { + CefPostTask(TID_IO, NewCefRunnableFunction(IOT_Set, manager, url, + &cookies, &event)); + event.Wait(); +} + +// Delete the cookie. +void DeleteCookies(CefRefPtr manager, + const CefString& url, const CefString& cookie_name, + base::WaitableEvent& event) { + CefPostTask(TID_IO, NewCefRunnableFunction(IOT_Delete, manager, url, + cookie_name, &event)); + event.Wait(); +} + +// Create a test cookie. If |withDomain| is true a domain cookie will be +// created, otherwise a host cookie will be created. +void CreateCookie(CefRefPtr manager, + CefCookie& cookie, bool withDomain, + bool sessionCookie, + base::WaitableEvent& event) { + CefString(&cookie.name).FromASCII("my_cookie"); + CefString(&cookie.value).FromASCII("My Value"); + if (withDomain) + CefString(&cookie.domain).FromASCII(kTestDomain); + CefString(&cookie.path).FromASCII(kTestPath); + if (!sessionCookie) { + cookie.has_expires = true; + cookie.expires.year = 2200; + cookie.expires.month = 4; + cookie.expires.day_of_week = 5; + cookie.expires.day_of_month = 11; + } + + CookieVector cookies; + cookies.push_back(cookie); + + SetCookies(manager, kTestUrl, cookies, event); +} + +// Retrieve the test cookie. If |withDomain| is true check that the cookie +// is a domain cookie, otherwise a host cookie. if |deleteCookies| is true +// the cookie will be deleted when it's retrieved. +void GetCookie(CefRefPtr manager, + const CefCookie& cookie, bool withDomain, + base::WaitableEvent& event, bool deleteCookies) { + CookieVector cookies; + + // Get the cookie and delete it. + EXPECT_TRUE(manager->VisitUrlCookies(kTestUrl, false, + new TestVisitor(&cookies, deleteCookies, &event))); + event.Wait(); + + EXPECT_EQ((CookieVector::size_type)1, cookies.size()); + + const CefCookie& cookie_read = cookies[0]; + EXPECT_EQ(CefString(&cookie_read.name), "my_cookie"); + EXPECT_EQ(CefString(&cookie_read.value), "My Value"); + if (withDomain) + EXPECT_EQ(CefString(&cookie_read.domain), ".www.test.com"); + else + EXPECT_EQ(CefString(&cookie_read.domain), kTestDomain); + EXPECT_EQ(CefString(&cookie_read.path), kTestPath); + EXPECT_EQ(cookie.has_expires, cookie_read.has_expires); + EXPECT_EQ(cookie.expires.year, cookie_read.expires.year); + EXPECT_EQ(cookie.expires.month, cookie_read.expires.month); + EXPECT_EQ(cookie.expires.day_of_week, cookie_read.expires.day_of_week); + EXPECT_EQ(cookie.expires.day_of_month, cookie_read.expires.day_of_month); + EXPECT_EQ(cookie.expires.hour, cookie_read.expires.hour); + EXPECT_EQ(cookie.expires.minute, cookie_read.expires.minute); + EXPECT_EQ(cookie.expires.second, cookie_read.expires.second); + EXPECT_EQ(cookie.expires.millisecond, cookie_read.expires.millisecond); +} + +// Visit URL cookies. +void VisitUrlCookies(CefRefPtr manager, + const CefString& url, + bool includeHttpOnly, + CookieVector& cookies, + bool deleteCookies, + base::WaitableEvent& event) { + EXPECT_TRUE(manager->VisitUrlCookies(url, includeHttpOnly, + new TestVisitor(&cookies, deleteCookies, &event))); + event.Wait(); +} + +// Visit all cookies. +void VisitAllCookies(CefRefPtr manager, + CookieVector& cookies, + bool deleteCookies, + base::WaitableEvent& event) { + EXPECT_TRUE(manager->VisitAllCookies( + new TestVisitor(&cookies, deleteCookies, &event))); + event.Wait(); +} + +// Verify that no cookies exist. If |withUrl| is true it will only check for +// cookies matching the URL. +void VerifyNoCookies(CefRefPtr manager, + base::WaitableEvent& event, bool withUrl) { + CookieVector cookies; + + // Verify that the cookie has been deleted. + if (withUrl) { + EXPECT_TRUE(manager->VisitUrlCookies(kTestUrl, false, + new TestVisitor(&cookies, false, &event))); + } else { + EXPECT_TRUE(manager->VisitAllCookies( + new TestVisitor(&cookies, false, &event))); + } + event.Wait(); + + EXPECT_EQ((CookieVector::size_type)0, cookies.size()); +} + +// Delete all system cookies. +void DeleteAllCookies(CefRefPtr manager, + base::WaitableEvent& event) { + CefPostTask(TID_IO, NewCefRunnableFunction(IOT_Delete, manager, CefString(), + CefString(), &event)); + event.Wait(); +} + +void TestDomainCookie(CefRefPtr manager) { + base::WaitableEvent event(false, false); + CefCookie cookie; + + // Create a domain cookie. + CreateCookie(manager, cookie, true, false, event); + + // Retrieve, verify and delete the domain cookie. + GetCookie(manager, cookie, true, event, true); + + // Verify that the cookie was deleted. + VerifyNoCookies(manager, event, true); +} + +void TestHostCookie(CefRefPtr manager) { + base::WaitableEvent event(false, false); + CefCookie cookie; + + // Create a host cookie. + CreateCookie(manager, cookie, false, false, event); + + // Retrieve, verify and delete the host cookie. + GetCookie(manager, cookie, false, event, true); + + // Verify that the cookie was deleted. + VerifyNoCookies(manager, event, true); +} + +void TestMultipleCookies(CefRefPtr manager) { + base::WaitableEvent event(false, false); + std::stringstream ss; + int i; + + CookieVector cookies; + + const int kNumCookies = 4; + + // Create the cookies. + for (i = 0; i < kNumCookies; i++) { + CefCookie cookie; + + ss << "my_cookie" << i; + CefString(&cookie.name).FromASCII(ss.str().c_str()); + ss.str(""); + ss << "My Value " << i; + CefString(&cookie.value).FromASCII(ss.str().c_str()); + ss.str(""); + + cookies.push_back(cookie); + } + + // Set the cookies. + SetCookies(manager, kTestUrl, cookies, event); + cookies.clear(); + + // Get the cookies without deleting them. + VisitUrlCookies(manager, kTestUrl, false, cookies, false, event); + + EXPECT_EQ((CookieVector::size_type)kNumCookies, cookies.size()); + + CookieVector::const_iterator it = cookies.begin(); + for (i = 0; it != cookies.end(); ++it, ++i) { + const CefCookie& cookie = *it; + + ss << "my_cookie" << i; + EXPECT_EQ(CefString(&cookie.name), ss.str()); + ss.str(""); + ss << "My Value " << i; + EXPECT_EQ(CefString(&cookie.value), ss.str()); + ss.str(""); + } + + cookies.clear(); + + // Delete the 2nd cookie. + DeleteCookies(manager, kTestUrl, CefString("my_cookie1"), event); + + // Verify that the cookie has been deleted. + VisitUrlCookies(manager, kTestUrl, false, cookies, false, event); + + EXPECT_EQ((CookieVector::size_type)3, cookies.size()); + EXPECT_EQ(CefString(&cookies[0].name), "my_cookie0"); + EXPECT_EQ(CefString(&cookies[1].name), "my_cookie2"); + EXPECT_EQ(CefString(&cookies[2].name), "my_cookie3"); + + cookies.clear(); + + // Delete the rest of the cookies. + DeleteCookies(manager, kTestUrl, CefString(), event); + + // Verify that the cookies have been deleted. + VisitUrlCookies(manager, kTestUrl, false, cookies, false, event); + + EXPECT_EQ((CookieVector::size_type)0, cookies.size()); + + // Create the cookies. + for (i = 0; i < kNumCookies; i++) { + CefCookie cookie; + + ss << "my_cookie" << i; + CefString(&cookie.name).FromASCII(ss.str().c_str()); + ss.str(""); + ss << "My Value " << i; + CefString(&cookie.value).FromASCII(ss.str().c_str()); + ss.str(""); + + cookies.push_back(cookie); + } + + // Delete all of the cookies using the visitor. + VisitUrlCookies(manager, kTestUrl, false, cookies, true, event); + + cookies.clear(); + + // Verify that the cookies have been deleted. + VisitUrlCookies(manager, kTestUrl, false, cookies, false, event); + + EXPECT_EQ((CookieVector::size_type)0, cookies.size()); +} + +void TestAllCookies(CefRefPtr manager) { + base::WaitableEvent event(false, false); + CookieVector cookies; + + // Delete all system cookies just in case something is left over from a + // different test. + DeleteCookies(manager, CefString(), CefString(), event); + + // Verify that all system cookies have been deleted. + VisitAllCookies(manager, cookies, false, event); + + EXPECT_EQ((CookieVector::size_type)0, cookies.size()); + + // Create cookies with 2 separate hosts. + CefCookie cookie1; + const char* kUrl1 = "http://www.foo.com"; + CefString(&cookie1.name).FromASCII("my_cookie1"); + CefString(&cookie1.value).FromASCII("My Value 1"); + + cookies.push_back(cookie1); + SetCookies(manager, kUrl1, cookies, event); + cookies.clear(); + + CefCookie cookie2; + const char* kUrl2 = "http://www.bar.com"; + CefString(&cookie2.name).FromASCII("my_cookie2"); + CefString(&cookie2.value).FromASCII("My Value 2"); + + cookies.push_back(cookie2); + SetCookies(manager, kUrl2, cookies, event); + cookies.clear(); + + // Verify that all system cookies can be retrieved. + VisitAllCookies(manager, cookies, false, event); + + EXPECT_EQ((CookieVector::size_type)2, cookies.size()); + EXPECT_EQ(CefString(&cookies[0].name), "my_cookie1"); + EXPECT_EQ(CefString(&cookies[0].value), "My Value 1"); + EXPECT_EQ(CefString(&cookies[0].domain), "www.foo.com"); + EXPECT_EQ(CefString(&cookies[1].name), "my_cookie2"); + EXPECT_EQ(CefString(&cookies[1].value), "My Value 2"); + EXPECT_EQ(CefString(&cookies[1].domain), "www.bar.com"); + cookies.clear(); + + // Verify that the cookies can be retrieved separately. + VisitUrlCookies(manager, kUrl1, false, cookies, false, event); + + EXPECT_EQ((CookieVector::size_type)1, cookies.size()); + EXPECT_EQ(CefString(&cookies[0].name), "my_cookie1"); + EXPECT_EQ(CefString(&cookies[0].value), "My Value 1"); + EXPECT_EQ(CefString(&cookies[0].domain), "www.foo.com"); + cookies.clear(); + + VisitUrlCookies(manager, kUrl2, false, cookies, false, event); + + EXPECT_EQ((CookieVector::size_type)1, cookies.size()); + EXPECT_EQ(CefString(&cookies[0].name), "my_cookie2"); + EXPECT_EQ(CefString(&cookies[0].value), "My Value 2"); + EXPECT_EQ(CefString(&cookies[0].domain), "www.bar.com"); + cookies.clear(); + + // Delete all of the system cookies. + DeleteAllCookies(manager, event); + + // Verify that all system cookies have been deleted. + VerifyNoCookies(manager, event, false); +} + +void TestChangeDirectory(CefRefPtr manager, + const CefString& original_dir) { + base::WaitableEvent event(false, false); + CefCookie cookie; + + base::ScopedTempDir temp_dir; + + // Create a new temporary directory. + EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); + + // Delete all of the system cookies. + DeleteAllCookies(manager, event); + + // Set the new temporary directory as the storage location. + EXPECT_TRUE(manager->SetStoragePath(temp_dir.path().value(), false)); + + // Wait for the storage location change to complete on the IO thread. + WaitForIOThread(); + + // Verify that no cookies exist. + VerifyNoCookies(manager, event, true); + + // Create a domain cookie. + CreateCookie(manager, cookie, true, false, event); + + // Retrieve and verify the domain cookie. + GetCookie(manager, cookie, true, event, false); + + // Restore the original storage location. + EXPECT_TRUE(manager->SetStoragePath(original_dir, false)); + + // Wait for the storage location change to complete on the IO thread. + WaitForIOThread(); + + // Verify that no cookies exist. + VerifyNoCookies(manager, event, true); + + // Set the new temporary directory as the storage location. + EXPECT_TRUE(manager->SetStoragePath(temp_dir.path().value(), false)); + + // Wait for the storage location change to complete on the IO thread. + WaitForIOThread(); + + // Retrieve and verify the domain cookie that was set previously. + GetCookie(manager, cookie, true, event, false); + + // Restore the original storage location. + EXPECT_TRUE(manager->SetStoragePath(original_dir, false)); + + // Wait for the storage location change to complete on the IO thread. + WaitForIOThread(); +} + +} // namespace + +// Test creation of a domain cookie. +TEST(CookieTest, DomainCookieGlobal) { + CefRefPtr manager = CefCookieManager::GetGlobalManager(); + EXPECT_TRUE(manager.get()); + + TestDomainCookie(manager); +} + +// Test creation of a domain cookie. +TEST(CookieTest, DomainCookieInMemory) { + CefRefPtr manager = + CefCookieManager::CreateManager(CefString(), false); + EXPECT_TRUE(manager.get()); + + TestDomainCookie(manager); +} + +// Test creation of a domain cookie. +TEST(CookieTest, DomainCookieOnDisk) { + base::ScopedTempDir temp_dir; + + // Create a new temporary directory. + EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); + + CefRefPtr manager = + CefCookieManager::CreateManager(temp_dir.path().value(), false); + EXPECT_TRUE(manager.get()); + + TestDomainCookie(manager); +} + +// Test creation of a host cookie. +TEST(CookieTest, HostCookieGlobal) { + CefRefPtr manager = CefCookieManager::GetGlobalManager(); + EXPECT_TRUE(manager.get()); + + TestHostCookie(manager); +} + +// Test creation of a host cookie. +TEST(CookieTest, HostCookieInMemory) { + CefRefPtr manager = + CefCookieManager::CreateManager(CefString(), false); + EXPECT_TRUE(manager.get()); + + TestHostCookie(manager); +} + +// Test creation of a host cookie. +TEST(CookieTest, HostCookieOnDisk) { + base::ScopedTempDir temp_dir; + + // Create a new temporary directory. + EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); + + CefRefPtr manager = + CefCookieManager::CreateManager(temp_dir.path().value(), false); + EXPECT_TRUE(manager.get()); + + TestHostCookie(manager); +} + +// Test creation of multiple cookies. +TEST(CookieTest, MultipleCookiesGlobal) { + CefRefPtr manager = CefCookieManager::GetGlobalManager(); + EXPECT_TRUE(manager.get()); + + TestMultipleCookies(manager); +} + +// Test creation of multiple cookies. +TEST(CookieTest, MultipleCookiesInMemory) { + CefRefPtr manager = + CefCookieManager::CreateManager(CefString(), false); + EXPECT_TRUE(manager.get()); + + TestMultipleCookies(manager); +} + +// Test creation of multiple cookies. +TEST(CookieTest, MultipleCookiesOnDisk) { + base::ScopedTempDir temp_dir; + + // Create a new temporary directory. + EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); + + CefRefPtr manager = + CefCookieManager::CreateManager(temp_dir.path().value(), false); + EXPECT_TRUE(manager.get()); + + TestMultipleCookies(manager); +} + +TEST(CookieTest, AllCookiesGlobal) { + CefRefPtr manager = CefCookieManager::GetGlobalManager(); + EXPECT_TRUE(manager.get()); + + TestAllCookies(manager); +} + +TEST(CookieTest, AllCookiesInMemory) { + CefRefPtr manager = + CefCookieManager::CreateManager(CefString(), false); + EXPECT_TRUE(manager.get()); + + TestAllCookies(manager); +} + +TEST(CookieTest, AllCookiesOnDisk) { + base::ScopedTempDir temp_dir; + + // Create a new temporary directory. + EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); + + CefRefPtr manager = + CefCookieManager::CreateManager(temp_dir.path().value(), false); + EXPECT_TRUE(manager.get()); + + TestAllCookies(manager); +} + +TEST(CookieTest, ChangeDirectoryGlobal) { + CefRefPtr manager = CefCookieManager::GetGlobalManager(); + EXPECT_TRUE(manager.get()); + + std::string cache_path; + CefTestSuite::GetCachePath(cache_path); + + TestChangeDirectory(manager, cache_path); +} + +TEST(CookieTest, ChangeDirectoryCreated) { + CefRefPtr manager = + CefCookieManager::CreateManager(CefString(), false); + EXPECT_TRUE(manager.get()); + + TestChangeDirectory(manager, CefString()); +} + + +namespace { + +class TestCompletionHandler : public CefCompletionHandler { + public: + explicit TestCompletionHandler(base::WaitableEvent* event) + : event_(event) {} + + virtual void OnComplete() OVERRIDE { + event_->Signal(); + } + + private: + base::WaitableEvent* event_; + + IMPLEMENT_REFCOUNTING(TestCompletionHandler); +}; + +} // namespace + +TEST(CookieTest, SessionCookieNoPersist) { + base::ScopedTempDir temp_dir; + base::WaitableEvent event(false, false); + CefCookie cookie; + + // Create a new temporary directory. + EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); + + CefRefPtr manager = + CefCookieManager::CreateManager(temp_dir.path().value(), false); + EXPECT_TRUE(manager.get()); + + // Create a session cookie. + CreateCookie(manager, cookie, true, true, event); + + // Retrieve and verify the cookie. + GetCookie(manager, cookie, true, event, false); + + // Flush the cookie store to disk. + manager->FlushStore(new TestCompletionHandler(&event)); + event.Wait(); + + // Create a new manager to read the same cookie store. + manager = + CefCookieManager::CreateManager(temp_dir.path().value(), false); + + // Verify that the cookie doesn't exist. + VerifyNoCookies(manager, event, true); +} + +TEST(CookieTest, SessionCookieWillPersist) { + base::ScopedTempDir temp_dir; + base::WaitableEvent event(false, false); + CefCookie cookie; + + // Create a new temporary directory. + EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); + + CefRefPtr manager = + CefCookieManager::CreateManager(temp_dir.path().value(), true); + EXPECT_TRUE(manager.get()); + + // Create a session cookie. + CreateCookie(manager, cookie, true, true, event); + + // Retrieve and verify the cookie. + GetCookie(manager, cookie, true, event, false); + + // Flush the cookie store to disk. + manager->FlushStore(new TestCompletionHandler(&event)); + event.Wait(); + + // Create a new manager to read the same cookie store. + manager = + CefCookieManager::CreateManager(temp_dir.path().value(), true); + + // Verify that the cookie exists. + GetCookie(manager, cookie, true, event, false); +} + + +namespace { + +const char* kCookieJSUrl1 = "http://tests/cookie1.html"; +const char* kCookieJSUrl2 = "http://tests/cookie2.html"; + +class CookieTestJSHandler : public TestHandler { + public: + CookieTestJSHandler() {} + + virtual void RunTest() OVERRIDE { + // Create =new in-memory managers. + manager1_ = CefCookieManager::CreateManager(CefString(), false); + manager2_ = CefCookieManager::CreateManager(CefString(), false); + + std::string page = + "" + "" + "COOKIE TEST1"; + AddResource(kCookieJSUrl1, page, "text/html"); + + page = + "" + "" + "COOKIE TEST2"; + AddResource(kCookieJSUrl2, page, "text/html"); + + // Create the browser + CreateBrowser(kCookieJSUrl1); + } + + virtual void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) OVERRIDE { + std::string url = frame->GetURL(); + if (url == kCookieJSUrl1) { + got_load_end1_.yes(); + VerifyCookie(manager1_, url, "name1", "value1", got_cookie1_); + + // Go to the next URL + frame->LoadURL(kCookieJSUrl2); + } else { + got_load_end2_.yes(); + VerifyCookie(manager2_, url, "name2", "value2", got_cookie2_); + + DestroyTest(); + } + } + + virtual CefRefPtr GetCookieManager( + CefRefPtr browser, + const CefString& main_url) OVERRIDE { + if (main_url == kCookieJSUrl1) { + // Return the first cookie manager. + got_cookie_manager1_.yes(); + return manager1_; + } else { + // Return the second cookie manager. + got_cookie_manager2_.yes(); + return manager2_; + } + } + + // Verify that the cookie was set successfully. + void VerifyCookie(CefRefPtr manager, + const std::string& url, + const std::string& name, + const std::string& value, + TrackCallback& callback) { + base::WaitableEvent event(false, false); + CookieVector cookies; + + // Get the cookie. + VisitUrlCookies(manager, url, false, cookies, false, event); + + if (cookies.size() == 1 && CefString(&cookies[0].name) == name && + CefString(&cookies[0].value) == value) { + callback.yes(); + } + } + + CefRefPtr manager1_; + CefRefPtr manager2_; + + TrackCallback got_cookie_manager1_; + TrackCallback got_cookie_manager2_; + TrackCallback got_load_end1_; + TrackCallback got_load_end2_; + TrackCallback got_cookie1_; + TrackCallback got_cookie2_; +}; + +} // namespace + +// Verify use of multiple cookie managers vis JS. +TEST(CookieTest, GetCookieManagerJS) { + CefRefPtr handler = new CookieTestJSHandler(); + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_cookie_manager1_); + EXPECT_TRUE(handler->got_cookie_manager2_); + EXPECT_TRUE(handler->got_load_end1_); + EXPECT_TRUE(handler->got_load_end2_); + EXPECT_TRUE(handler->got_cookie1_); + EXPECT_TRUE(handler->got_cookie2_); +} + + +namespace { + +class CookieTestSchemeHandler : public TestHandler { + public: + class SchemeHandler : public CefResourceHandler { + public: + explicit SchemeHandler(CookieTestSchemeHandler* handler) + : handler_(handler), + offset_(0) {} + + virtual bool ProcessRequest(CefRefPtr request, + CefRefPtr callback) + OVERRIDE { + std::string url = request->GetURL(); + if (url == handler_->url1_) { + content_ = "COOKIE TEST1"; + cookie_ = "name1=value1"; + handler_->got_process_request1_.yes(); + } else if (url == handler_->url2_) { + content_ = "COOKIE TEST2"; + cookie_ = "name2=value2"; + handler_->got_process_request2_.yes(); + } else if (url == handler_->url3_) { + content_ = "COOKIE TEST3"; + handler_->got_process_request3_.yes(); + + // Verify that the cookie was passed in. + CefRequest::HeaderMap headerMap; + request->GetHeaderMap(headerMap); + CefRequest::HeaderMap::iterator it = headerMap.find("Cookie"); + if (it != headerMap.end() && it->second == "name2=value2") + handler_->got_process_request_cookie_.yes(); + + } + callback->Continue(); + return true; + } + + virtual void GetResponseHeaders(CefRefPtr response, + int64& response_length, + CefString& redirectUrl) OVERRIDE { + response_length = content_.size(); + + response->SetStatus(200); + response->SetMimeType("text/html"); + + if (!cookie_.empty()) { + CefResponse::HeaderMap headerMap; + response->GetHeaderMap(headerMap); + headerMap.insert(std::make_pair("Set-Cookie", cookie_)); + response->SetHeaderMap(headerMap); + } + } + + virtual bool ReadResponse(void* data_out, + int bytes_to_read, + int& bytes_read, + CefRefPtr callback) + OVERRIDE { + bool has_data = false; + bytes_read = 0; + + size_t size = content_.size(); + if (offset_ < size) { + int transfer_size = + std::min(bytes_to_read, static_cast(size - offset_)); + memcpy(data_out, content_.c_str() + offset_, transfer_size); + offset_ += transfer_size; + + bytes_read = transfer_size; + has_data = true; + } + + return has_data; + } + + virtual void Cancel() OVERRIDE { + } + + private: + CookieTestSchemeHandler* handler_; + std::string content_; + size_t offset_; + std::string cookie_; + + IMPLEMENT_REFCOUNTING(SchemeHandler); + }; + + class SchemeHandlerFactory : public CefSchemeHandlerFactory { + public: + explicit SchemeHandlerFactory(CookieTestSchemeHandler* handler) + : handler_(handler) {} + + virtual CefRefPtr Create( + CefRefPtr browser, + CefRefPtr frame, + const CefString& scheme_name, + CefRefPtr request) OVERRIDE { + std::string url = request->GetURL(); + if (url == handler_->url3_) { + // Verify that the cookie was not passed in. + CefRequest::HeaderMap headerMap; + request->GetHeaderMap(headerMap); + CefRequest::HeaderMap::iterator it = headerMap.find("Cookie"); + if (it != headerMap.end() && it->second == "name2=value2") + handler_->got_create_cookie_.yes(); + } + + return new SchemeHandler(handler_); + } + + private: + CookieTestSchemeHandler* handler_; + + IMPLEMENT_REFCOUNTING(SchemeHandlerFactory); + }; + + CookieTestSchemeHandler(const std::string& scheme) : scheme_(scheme) { + url1_ = scheme + "://cookie-tests/cookie1.html"; + url2_ = scheme + "://cookie-tests/cookie2.html"; + url3_ = scheme + "://cookie-tests/cookie3.html"; + } + + virtual void RunTest() OVERRIDE { + // Create new in-memory managers. + manager1_ = CefCookieManager::CreateManager(CefString(), false); + manager2_ = CefCookieManager::CreateManager(CefString(), false); + + if (scheme_ != "http") { + std::vector schemes; + schemes.push_back("http"); + schemes.push_back("https"); + schemes.push_back(scheme_); + + manager1_->SetSupportedSchemes(schemes); + manager2_->SetSupportedSchemes(schemes); + } + + // Register the scheme handler. + CefRegisterSchemeHandlerFactory(scheme_, "cookie-tests", + new SchemeHandlerFactory(this)); + + // Create the browser + CreateBrowser(url1_); + } + + virtual void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) OVERRIDE { + std::string url = frame->GetURL(); + if (url == url1_) { + got_load_end1_.yes(); + VerifyCookie(manager1_, url, "name1", "value1", got_cookie1_); + + // Go to the next URL + frame->LoadURL(url2_); + } else if (url == url2_) { + got_load_end2_.yes(); + VerifyCookie(manager2_, url, "name2", "value2", got_cookie2_); + + // Go to the next URL + frame->LoadURL(url3_); + } else { + got_load_end3_.yes(); + VerifyCookie(manager2_, url, "name2", "value2", got_cookie3_); + + // Unregister the scheme handler. + CefRegisterSchemeHandlerFactory(scheme_, "cookie-tests", NULL); + + DestroyTest(); + } + } + + virtual CefRefPtr GetCookieManager( + CefRefPtr browser, + const CefString& main_url) OVERRIDE { + if (main_url == url1_) { + // Return the first cookie manager. + got_cookie_manager1_.yes(); + return manager1_; + } else { + // Return the second cookie manager. + got_cookie_manager2_.yes(); + return manager2_; + } + } + + // Verify that the cookie was set successfully. + void VerifyCookie(CefRefPtr manager, + const std::string& url, + const std::string& name, + const std::string& value, + TrackCallback& callback) { + base::WaitableEvent event(false, false); + CookieVector cookies; + + // Get the cookie. + VisitUrlCookies(manager, url, false, cookies, false, event); + + if (cookies.size() == 1 && CefString(&cookies[0].name) == name && + CefString(&cookies[0].value) == value) { + callback.yes(); + } + } + + std::string scheme_; + std::string url1_; + std::string url2_; + std::string url3_; + + CefRefPtr manager1_; + CefRefPtr manager2_; + + TrackCallback got_process_request1_; + TrackCallback got_process_request2_; + TrackCallback got_process_request3_; + TrackCallback got_create_cookie_; + TrackCallback got_process_request_cookie_; + TrackCallback got_cookie_manager1_; + TrackCallback got_cookie_manager2_; + TrackCallback got_load_end1_; + TrackCallback got_load_end2_; + TrackCallback got_load_end3_; + TrackCallback got_cookie1_; + TrackCallback got_cookie2_; + TrackCallback got_cookie3_; +}; + +} // namespace + +// Verify use of multiple cookie managers via HTTP. +TEST(CookieTest, GetCookieManagerHttp) { + CefRefPtr handler = + new CookieTestSchemeHandler("http"); + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_process_request1_); + EXPECT_TRUE(handler->got_process_request2_); + EXPECT_TRUE(handler->got_process_request3_); + EXPECT_FALSE(handler->got_create_cookie_); + EXPECT_TRUE(handler->got_process_request_cookie_); + EXPECT_TRUE(handler->got_cookie_manager1_); + EXPECT_TRUE(handler->got_cookie_manager2_); + EXPECT_TRUE(handler->got_load_end1_); + EXPECT_TRUE(handler->got_load_end2_); + EXPECT_TRUE(handler->got_load_end3_); + EXPECT_TRUE(handler->got_cookie1_); + EXPECT_TRUE(handler->got_cookie2_); + EXPECT_TRUE(handler->got_cookie3_); +} + +// Verify use of multiple cookie managers via a custom scheme. +TEST(CookieTest, GetCookieManagerCustom) { + CefRefPtr handler = + new CookieTestSchemeHandler("ccustom"); + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_process_request1_); + EXPECT_TRUE(handler->got_process_request2_); + EXPECT_TRUE(handler->got_process_request3_); + EXPECT_FALSE(handler->got_create_cookie_); + EXPECT_TRUE(handler->got_process_request_cookie_); + EXPECT_TRUE(handler->got_cookie_manager1_); + EXPECT_TRUE(handler->got_cookie_manager2_); + EXPECT_TRUE(handler->got_load_end1_); + EXPECT_TRUE(handler->got_load_end2_); + EXPECT_TRUE(handler->got_load_end3_); + EXPECT_TRUE(handler->got_cookie1_); + EXPECT_TRUE(handler->got_cookie2_); + EXPECT_TRUE(handler->got_cookie3_); +} + +// Entry point for registering custom schemes. +// Called from client_app_delegates.cc. +void RegisterCookieCustomSchemes( + CefRefPtr registrar, + std::vector& cookiable_schemes) { + // Used by GetCookieManagerCustom test. + registrar->AddCustomScheme("ccustom", true, false, false); +} diff --git a/cef3/tests/unittests/dialog_unittest.cc b/cef3/tests/unittests/dialog_unittest.cc new file mode 100644 index 000000000..735580ae5 --- /dev/null +++ b/cef3/tests/unittests/dialog_unittest.cc @@ -0,0 +1,267 @@ +// 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 "include/cef_runnable.h" +#include "tests/unittests/test_handler.h" +#include "tests/unittests/test_util.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +const char* kTestUrl = "http://tests/DialogTestHandler"; + +class DialogTestHandler : public TestHandler { + public: + struct TestConfig { + explicit TestConfig(FileDialogMode dialog_mode) + : mode(dialog_mode), + title("Test Title"), + default_file_name("Test File Name"), + callback_async(false), + callback_cancel(false) { + accept_types.push_back("text/*"); + accept_types.push_back(".js"); + accept_types.push_back(".css"); + } + + FileDialogMode mode; + CefString title; + CefString default_file_name; + std::vector accept_types; + + bool callback_async; // True if the callback should execute asynchronously. + bool callback_cancel; // True if the callback should cancel. + std::vector callback_paths; // Resulting paths if not cancelled. + }; + + class Callback : public CefRunFileDialogCallback { + public: + explicit Callback(DialogTestHandler* handler) + : handler_(handler) { + } + + virtual void OnFileDialogDismissed( + CefRefPtr browser_host, + const std::vector& file_paths) OVERRIDE { + handler_->got_onfiledialogdismissed_.yes(); + + std::string url = browser_host->GetBrowser()->GetMainFrame()->GetURL(); + EXPECT_STREQ(kTestUrl, url.c_str()); + + if (handler_->config_.callback_cancel) + EXPECT_TRUE(file_paths.empty()); + else + TestStringVectorEqual(handler_->config_.callback_paths, file_paths); + + handler_->DestroyTest(); + handler_ = NULL; + } + + private: + DialogTestHandler* handler_; + + IMPLEMENT_REFCOUNTING(Callback); + }; + + explicit DialogTestHandler(const TestConfig& config) + : config_(config) { + } + + virtual void RunTest() OVERRIDE { + AddResource(kTestUrl, "TEST", "text/html"); + + // Create the browser + CreateBrowser(kTestUrl); + } + + virtual void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) OVERRIDE { + browser->GetHost()->RunFileDialog(config_.mode, + config_.title, + config_.default_file_name, + config_.accept_types, + new Callback(this)); + } + + void ExecuteCallback(CefRefPtr callback) { + if (config_.callback_cancel) + callback->Cancel(); + else + callback->Continue(config_.callback_paths); + } + + // CefDialogHandler + virtual bool OnFileDialog( + CefRefPtr browser, + FileDialogMode mode, + const CefString& title, + const CefString& default_file_name, + const std::vector& accept_types, + CefRefPtr callback) OVERRIDE { + got_onfiledialog_.yes(); + + std::string url = browser->GetMainFrame()->GetURL(); + EXPECT_STREQ(kTestUrl, url.c_str()); + + EXPECT_EQ(config_.mode, mode); + EXPECT_STREQ(config_.title.ToString().c_str(), title.ToString().c_str()); + EXPECT_STREQ(config_.default_file_name.ToString().c_str(), + default_file_name.ToString().c_str()); + TestStringVectorEqual(config_.accept_types, accept_types); + + if (config_.callback_async) { + CefPostTask(TID_UI, + NewCefRunnableMethod(this, &DialogTestHandler::ExecuteCallback, + callback)); + } else { + ExecuteCallback(callback); + } + + return true; + } + + virtual void DestroyTest() OVERRIDE { + EXPECT_TRUE(got_onfiledialog_); + EXPECT_TRUE(got_onfiledialogdismissed_); + + TestHandler::DestroyTest(); + } + + TestConfig config_; + + TrackCallback got_onfiledialog_; + TrackCallback got_onfiledialogdismissed_; +}; + +} // namespace + +// Test with all parameters empty. +TEST(DialogTest, FileEmptyParams) { + DialogTestHandler::TestConfig config(FILE_DIALOG_OPEN); + config.title.clear(); + config.default_file_name.clear(); + config.accept_types.clear(); + config.callback_async = false; + config.callback_cancel = false; + + CefRefPtr handler = new DialogTestHandler(config); + handler->ExecuteTest(); +} + +TEST(DialogTest, FileOpen) { + DialogTestHandler::TestConfig config(FILE_DIALOG_OPEN); + config.callback_async = false; + config.callback_cancel = false; + config.callback_paths.push_back("/path/to/file1.txt"); + + CefRefPtr handler = new DialogTestHandler(config); + handler->ExecuteTest(); +} + +TEST(DialogTest, FileOpenCancel) { + DialogTestHandler::TestConfig config(FILE_DIALOG_OPEN); + config.callback_async = false; + config.callback_cancel = true; + + CefRefPtr handler = new DialogTestHandler(config); + handler->ExecuteTest(); +} + +TEST(DialogTest, FileOpenAsync) { + DialogTestHandler::TestConfig config(FILE_DIALOG_OPEN); + config.callback_async = true; + config.callback_cancel = false; + config.callback_paths.push_back("/path/to/file1.txt"); + + CefRefPtr handler = new DialogTestHandler(config); + handler->ExecuteTest(); +} + +TEST(DialogTest, FileOpenAsyncCancel) { + DialogTestHandler::TestConfig config(FILE_DIALOG_OPEN); + config.callback_async = false; + config.callback_cancel = true; + + CefRefPtr handler = new DialogTestHandler(config); + handler->ExecuteTest(); +} + +TEST(DialogTest, FileOpenMultiple) { + DialogTestHandler::TestConfig config(FILE_DIALOG_OPEN_MULTIPLE); + config.callback_async = false; + config.callback_cancel = false; + config.callback_paths.push_back("/path/to/file1.txt"); + config.callback_paths.push_back("/path/to/file2.txt"); + + CefRefPtr handler = new DialogTestHandler(config); + handler->ExecuteTest(); +} + +TEST(DialogTest, FileOpenMultipleCancel) { + DialogTestHandler::TestConfig config(FILE_DIALOG_OPEN_MULTIPLE); + config.callback_async = false; + config.callback_cancel = true; + + CefRefPtr handler = new DialogTestHandler(config); + handler->ExecuteTest(); +} + +TEST(DialogTest, FileOpenMultipleAsync) { + DialogTestHandler::TestConfig config(FILE_DIALOG_OPEN_MULTIPLE); + config.callback_async = true; + config.callback_cancel = false; + config.callback_paths.push_back("/path/to/file1.txt"); + config.callback_paths.push_back("/path/to/file2.txt"); + + CefRefPtr handler = new DialogTestHandler(config); + handler->ExecuteTest(); +} + +TEST(DialogTest, FileOpenMultipleAsyncCancel) { + DialogTestHandler::TestConfig config(FILE_DIALOG_OPEN_MULTIPLE); + config.callback_async = false; + config.callback_cancel = true; + + CefRefPtr handler = new DialogTestHandler(config); + handler->ExecuteTest(); +} + +TEST(DialogTest, FileSave) { + DialogTestHandler::TestConfig config(FILE_DIALOG_SAVE); + config.callback_async = false; + config.callback_cancel = false; + config.callback_paths.push_back("/path/to/file1.txt"); + + CefRefPtr handler = new DialogTestHandler(config); + handler->ExecuteTest(); +} + +TEST(DialogTest, FileSaveCancel) { + DialogTestHandler::TestConfig config(FILE_DIALOG_SAVE); + config.callback_async = false; + config.callback_cancel = true; + + CefRefPtr handler = new DialogTestHandler(config); + handler->ExecuteTest(); +} + +TEST(DialogTest, FileSaveAsync) { + DialogTestHandler::TestConfig config(FILE_DIALOG_SAVE); + config.callback_async = true; + config.callback_cancel = false; + config.callback_paths.push_back("/path/to/file1.txt"); + + CefRefPtr handler = new DialogTestHandler(config); + handler->ExecuteTest(); +} + +TEST(DialogTest, FileSaveAsyncCancel) { + DialogTestHandler::TestConfig config(FILE_DIALOG_SAVE); + config.callback_async = false; + config.callback_cancel = true; + + CefRefPtr handler = new DialogTestHandler(config); + handler->ExecuteTest(); +} diff --git a/cef3/tests/unittests/display_unittest.cc b/cef3/tests/unittests/display_unittest.cc new file mode 100644 index 000000000..3f77978a4 --- /dev/null +++ b/cef3/tests/unittests/display_unittest.cc @@ -0,0 +1,104 @@ +// Copyright (c) 2013 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 +#include "include/cef_runnable.h" +#include "tests/unittests/test_handler.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +// How it works: +// 1. Load kTitleUrl1 (title should be kTitleStr1) +// 2. Load kTitleUrl2 (title should be kTitleStr2) +// 3. History back to kTitleUrl1 (title should be kTitleStr1) +// 4. History forward to kTitleUrl2 (title should be kTitleStr2) +// 5. Set title via JavaScript (title should be kTitleStr3) + +const char kTitleUrl1[] = "http://tests-title/nav1.html"; +const char kTitleUrl2[] = "http://tests-title/nav2.html"; +const char kTitleStr1[] = "Title 1"; +const char kTitleStr2[] = "Title 2"; +const char kTitleStr3[] = "Title 3"; + +// Browser side. +class TitleTestHandler : public TestHandler { + public: + TitleTestHandler() + : step_(0) {} + + virtual void RunTest() OVERRIDE { + // Add the resources that we will navigate to/from. + AddResource(kTitleUrl1, + "" + std::string(kTitleStr1) + + "Nav1", "text/html"); + AddResource(kTitleUrl2, + "" + std::string(kTitleStr2) + + "Nav2" + + "" + + "", "text/html"); + + // Create the browser. + CreateBrowser(kTitleUrl1); + } + + virtual void OnTitleChange(CefRefPtr browser, + const CefString& title) OVERRIDE { + std::string title_str = title; + if (step_ == 0 || step_ == 2) { + EXPECT_STREQ(kTitleStr1, title_str.c_str()); + } else if (step_ == 1 || step_ == 3) { + EXPECT_STREQ(kTitleStr2, title_str.c_str()); + } else if (step_ == 4) { + EXPECT_STREQ(kTitleStr3, title_str.c_str()); + } + + got_title_[step_].yes(); + + if (step_ == 4) + DestroyTest(); + } + + virtual void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) OVERRIDE { + switch (step_++) { + case 0: + frame->LoadURL(kTitleUrl2); + break; + case 1: + browser->GoBack(); + break; + case 2: + browser->GoForward(); + break; + case 3: + frame->ExecuteJavaScript("setTitle()", kTitleUrl2, 0); + break; + default: + EXPECT_TRUE(false); // Not reached. + } + } + + private: + virtual void DestroyTest() OVERRIDE { + for (int i = 0; i < 5; ++i) + EXPECT_TRUE(got_title_[i]) << "step " << i; + + TestHandler::DestroyTest(); + } + + int step_; + + TrackCallback got_title_[5]; +}; + +} // namespace + +// Test title notifications. +TEST(DisplayTest, Title) { + CefRefPtr handler = new TitleTestHandler(); + handler->ExecuteTest(); +} diff --git a/cef3/tests/unittests/dom_unittest.cc b/cef3/tests/unittests/dom_unittest.cc new file mode 100644 index 000000000..26ba0d453 --- /dev/null +++ b/cef3/tests/unittests/dom_unittest.cc @@ -0,0 +1,332 @@ +// 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 "include/cef_dom.h" +#include "tests/cefclient/client_app.h" +#include "tests/unittests/test_handler.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +const char* kTestUrl = "http://tests/DOMTest.Test"; +const char* kTestMessage = "DOMTest.Message"; + +enum DOMTestType { + DOM_TEST_STRUCTURE, + DOM_TEST_MODIFY, +}; + +class TestDOMVisitor : public CefDOMVisitor { + public: + explicit TestDOMVisitor(CefRefPtr browser, DOMTestType test_type) + : browser_(browser), + test_type_(test_type) { + } + + void TestHeadNodeStructure(CefRefPtr headNode) { + EXPECT_TRUE(headNode.get()); + EXPECT_TRUE(headNode->IsElement()); + EXPECT_FALSE(headNode->IsText()); + EXPECT_EQ(headNode->GetName(), "HEAD"); + EXPECT_EQ(headNode->GetElementTagName(), "HEAD"); + + EXPECT_TRUE(headNode->HasChildren()); + EXPECT_FALSE(headNode->HasElementAttributes()); + + CefRefPtr titleNode = headNode->GetFirstChild(); + EXPECT_TRUE(titleNode.get()); + EXPECT_TRUE(titleNode->IsElement()); + EXPECT_FALSE(titleNode->IsText()); + EXPECT_EQ(titleNode->GetName(), "TITLE"); + EXPECT_EQ(titleNode->GetElementTagName(), "TITLE"); + EXPECT_TRUE(titleNode->GetParent()->IsSame(headNode)); + + EXPECT_FALSE(titleNode->GetNextSibling().get()); + EXPECT_FALSE(titleNode->GetPreviousSibling().get()); + EXPECT_TRUE(titleNode->HasChildren()); + EXPECT_FALSE(titleNode->HasElementAttributes()); + + CefRefPtr textNode = titleNode->GetFirstChild(); + EXPECT_TRUE(textNode.get()); + EXPECT_FALSE(textNode->IsElement()); + EXPECT_TRUE(textNode->IsText()); + EXPECT_EQ(textNode->GetValue(), "The Title"); + EXPECT_TRUE(textNode->GetParent()->IsSame(titleNode)); + + EXPECT_FALSE(textNode->GetNextSibling().get()); + EXPECT_FALSE(textNode->GetPreviousSibling().get()); + EXPECT_FALSE(textNode->HasChildren()); + } + + void TestBodyNodeStructure(CefRefPtr bodyNode) { + EXPECT_TRUE(bodyNode.get()); + EXPECT_TRUE(bodyNode->IsElement()); + EXPECT_FALSE(bodyNode->IsText()); + EXPECT_EQ(bodyNode->GetName(), "BODY"); + EXPECT_EQ(bodyNode->GetElementTagName(), "BODY"); + + EXPECT_TRUE(bodyNode->HasChildren()); + EXPECT_FALSE(bodyNode->HasElementAttributes()); + + CefRefPtr h1Node = bodyNode->GetFirstChild(); + EXPECT_TRUE(h1Node.get()); + EXPECT_TRUE(h1Node->IsElement()); + EXPECT_FALSE(h1Node->IsText()); + EXPECT_EQ(h1Node->GetName(), "H1"); + EXPECT_EQ(h1Node->GetElementTagName(), "H1"); + + EXPECT_FALSE(h1Node->GetNextSibling().get()); + EXPECT_FALSE(h1Node->GetPreviousSibling().get()); + EXPECT_TRUE(h1Node->HasChildren()); + EXPECT_FALSE(h1Node->HasElementAttributes()); + + CefRefPtr textNode = h1Node->GetFirstChild(); + EXPECT_TRUE(textNode.get()); + EXPECT_FALSE(textNode->IsElement()); + EXPECT_TRUE(textNode->IsText()); + EXPECT_EQ(textNode->GetValue(), "Hello From"); + + EXPECT_FALSE(textNode->GetPreviousSibling().get()); + EXPECT_FALSE(textNode->HasChildren()); + + CefRefPtr brNode = textNode->GetNextSibling(); + EXPECT_TRUE(brNode.get()); + EXPECT_TRUE(brNode->IsElement()); + EXPECT_FALSE(brNode->IsText()); + EXPECT_EQ(brNode->GetName(), "BR"); + EXPECT_EQ(brNode->GetElementTagName(), "BR"); + + EXPECT_FALSE(brNode->HasChildren()); + + EXPECT_TRUE(brNode->HasElementAttributes()); + EXPECT_TRUE(brNode->HasElementAttribute("class")); + EXPECT_EQ(brNode->GetElementAttribute("class"), "some_class"); + EXPECT_TRUE(brNode->HasElementAttribute("id")); + EXPECT_EQ(brNode->GetElementAttribute("id"), "some_id"); + EXPECT_FALSE(brNode->HasElementAttribute("no_existing")); + + CefDOMNode::AttributeMap map; + brNode->GetElementAttributes(map); + ASSERT_EQ(map.size(), (size_t)2); + EXPECT_EQ(map["class"], "some_class"); + EXPECT_EQ(map["id"], "some_id"); + + // Can also retrieve by ID. + brNode = bodyNode->GetDocument()->GetElementById("some_id"); + EXPECT_TRUE(brNode.get()); + EXPECT_TRUE(brNode->IsElement()); + EXPECT_FALSE(brNode->IsText()); + EXPECT_EQ(brNode->GetName(), "BR"); + EXPECT_EQ(brNode->GetElementTagName(), "BR"); + + textNode = brNode->GetNextSibling(); + EXPECT_TRUE(textNode.get()); + EXPECT_FALSE(textNode->IsElement()); + EXPECT_TRUE(textNode->IsText()); + EXPECT_EQ(textNode->GetValue(), "Main Frame"); + + EXPECT_FALSE(textNode->GetNextSibling().get()); + EXPECT_FALSE(textNode->HasChildren()); + } + + // Test document structure by iterating through the DOM tree. + void TestStructure(CefRefPtr document) { + EXPECT_EQ(document->GetTitle(), "The Title"); + EXPECT_EQ(document->GetBaseURL(), kTestUrl); + EXPECT_EQ(document->GetCompleteURL("foo.html"), "http://tests/foo.html"); + + // Navigate the complete document structure. + CefRefPtr docNode = document->GetDocument(); + EXPECT_TRUE(docNode.get()); + EXPECT_FALSE(docNode->IsElement()); + EXPECT_FALSE(docNode->IsText()); + + CefRefPtr htmlNode = docNode->GetFirstChild(); + EXPECT_TRUE(htmlNode.get()); + EXPECT_TRUE(htmlNode->IsElement()); + EXPECT_FALSE(htmlNode->IsText()); + EXPECT_EQ(htmlNode->GetName(), "HTML"); + EXPECT_EQ(htmlNode->GetElementTagName(), "HTML"); + + EXPECT_TRUE(htmlNode->HasChildren()); + EXPECT_FALSE(htmlNode->HasElementAttributes()); + + CefRefPtr headNode = htmlNode->GetFirstChild(); + TestHeadNodeStructure(headNode); + + CefRefPtr bodyNode = headNode->GetNextSibling(); + TestBodyNodeStructure(bodyNode); + + // Retrieve the head node directly. + headNode = document->GetHead(); + TestHeadNodeStructure(headNode); + + // Retrieve the body node directly. + bodyNode = document->GetBody(); + TestBodyNodeStructure(bodyNode); + } + + // Test document modification by changing the H1 tag. + void TestModify(CefRefPtr document) { + CefRefPtr bodyNode = document->GetBody(); + CefRefPtr h1Node = bodyNode->GetFirstChild(); + + ASSERT_EQ(h1Node->GetAsMarkup(), + "

Hello From
" + "Main Frame

"); + + CefRefPtr textNode = h1Node->GetFirstChild(); + ASSERT_EQ(textNode->GetValue(), "Hello From"); + ASSERT_TRUE(textNode->SetValue("A Different Message From")); + ASSERT_EQ(textNode->GetValue(), "A Different Message From"); + + CefRefPtr brNode = textNode->GetNextSibling(); + EXPECT_EQ(brNode->GetElementAttribute("class"), "some_class"); + EXPECT_TRUE(brNode->SetElementAttribute("class", "a_different_class")); + EXPECT_EQ(brNode->GetElementAttribute("class"), "a_different_class"); + + ASSERT_EQ(h1Node->GetAsMarkup(), + "

A Different Message From
Main Frame

"); + + ASSERT_FALSE(h1Node->SetValue("Something Different")); + } + + virtual void Visit(CefRefPtr document) OVERRIDE { + if (test_type_ == DOM_TEST_STRUCTURE) + TestStructure(document); + else if (test_type_ == DOM_TEST_MODIFY) + TestModify(document); + + DestroyTest(); + } + + protected: + // Return from the test. + void DestroyTest() { + // Check if the test has failed. + bool result = !TestFailed(); + + // Return the result to the browser process. + CefRefPtr return_msg = + CefProcessMessage::Create(kTestMessage); + EXPECT_TRUE(return_msg->GetArgumentList()->SetBool(0, result)); + EXPECT_TRUE(browser_->SendProcessMessage(PID_BROWSER, return_msg)); + } + + CefRefPtr browser_; + DOMTestType test_type_; + + IMPLEMENT_REFCOUNTING(TestDOMVisitor); +}; + +// Used in the render process. +class DOMRendererTest : public ClientApp::RenderDelegate { + public: + DOMRendererTest() { + } + + virtual bool OnProcessMessageReceived( + CefRefPtr app, + CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) OVERRIDE { + if (message->GetName() == kTestMessage) { + EXPECT_EQ(message->GetArgumentList()->GetSize(), (size_t)1); + int test_type = message->GetArgumentList()->GetInt(0); + + browser->GetMainFrame()->VisitDOM( + new TestDOMVisitor(browser, static_cast(test_type))); + return true; + } + return false; + } + + private: + IMPLEMENT_REFCOUNTING(DOMRendererTest); +}; + +// Used in the browser process. +class TestDOMHandler : public TestHandler { + public: + explicit TestDOMHandler(DOMTestType test) + : test_type_(test) { + } + + virtual void RunTest() OVERRIDE { + std::stringstream mainHtml; + mainHtml << + "" + "The Title" + "" + "

Hello From
" + "Main Frame

" + "" + ""; + + AddResource(kTestUrl, mainHtml.str(), "text/html"); + CreateBrowser(kTestUrl); + } + + virtual void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) OVERRIDE { + if (frame->IsMain()) { + // Start the test in the render process. + CefRefPtr message( + CefProcessMessage::Create(kTestMessage)); + message->GetArgumentList()->SetInt(0, test_type_); + EXPECT_TRUE(browser->SendProcessMessage(PID_RENDERER, message)); + } + } + + virtual bool OnProcessMessageReceived( + CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) OVERRIDE { + EXPECT_STREQ(message->GetName().ToString().c_str(), kTestMessage); + + got_message_.yes(); + + if (message->GetArgumentList()->GetBool(0)) + got_success_.yes(); + + // Test is complete. + DestroyTest(); + + return true; + } + + DOMTestType test_type_; + TrackCallback got_message_; + TrackCallback got_success_; +}; + +} // namespace + +// Test DOM structure reading. +TEST(DOMTest, Read) { + CefRefPtr handler = + new TestDOMHandler(DOM_TEST_STRUCTURE); + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_message_); + EXPECT_TRUE(handler->got_success_); +} + +// Test DOM modifications. +TEST(DOMTest, Modify) { + CefRefPtr handler = + new TestDOMHandler(DOM_TEST_MODIFY); + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_message_); + EXPECT_TRUE(handler->got_success_); +} + +// Entry point for creating DOM renderer test objects. +// Called from client_app_delegates.cc. +void CreateDOMRendererTests(ClientApp::RenderDelegateSet& delegates) { + delegates.insert(new DOMRendererTest); +} diff --git a/cef3/tests/unittests/download_unittest.cc b/cef3/tests/unittests/download_unittest.cc new file mode 100644 index 000000000..dbd619d29 --- /dev/null +++ b/cef3/tests/unittests/download_unittest.cc @@ -0,0 +1,265 @@ +// Copyright (c) 2013 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 "include/cef_scheme.h" +#include "base/file_util.h" +#include "base/files/scoped_temp_dir.h" +#include "tests/unittests/test_handler.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +const char kTestDomain[] = "test-download"; +const char kTestEntryUrl[] = "http://test-download/test.html"; +const char kTestDownloadUrl[] = "http://test-download/download.txt"; +const char kTestFileName[] = "download_test.txt"; +const char kTestContentDisposition[] = + "attachment; filename=\"download_test.txt\""; +const char kTestMimeType[] = "text/plain"; +const char kTestContent[] = "Download test text"; + +class DownloadSchemeHandler : public CefResourceHandler { + public: + explicit DownloadSchemeHandler(TrackCallback* got_download_request) + : got_download_request_(got_download_request), + offset_(0) {} + + virtual bool ProcessRequest(CefRefPtr request, + CefRefPtr callback) + OVERRIDE { + std::string url = request->GetURL(); + if (url == kTestEntryUrl) { + content_ = "Download Test"; + mime_type_ = "text/html"; + } else if (url == kTestDownloadUrl) { + got_download_request_->yes(); + content_ = kTestContent; + mime_type_ = kTestMimeType; + content_disposition_ = kTestContentDisposition; + } else { + EXPECT_TRUE(false); // Not reached. + return false; + } + + callback->Continue(); + return true; + } + + virtual void GetResponseHeaders(CefRefPtr response, + int64& response_length, + CefString& redirectUrl) OVERRIDE { + response_length = content_.size(); + + response->SetStatus(200); + response->SetMimeType(mime_type_); + + if (!content_disposition_.empty()) { + CefResponse::HeaderMap headerMap; + response->GetHeaderMap(headerMap); + headerMap.insert( + std::make_pair("Content-Disposition", content_disposition_)); + response->SetHeaderMap(headerMap); + } + } + + virtual bool ReadResponse(void* data_out, + int bytes_to_read, + int& bytes_read, + CefRefPtr callback) + OVERRIDE { + bool has_data = false; + bytes_read = 0; + + size_t size = content_.size(); + if (offset_ < size) { + int transfer_size = + std::min(bytes_to_read, static_cast(size - offset_)); + memcpy(data_out, content_.c_str() + offset_, transfer_size); + offset_ += transfer_size; + + bytes_read = transfer_size; + has_data = true; + } + + return has_data; + } + + virtual void Cancel() OVERRIDE { + } + + private: + TrackCallback* got_download_request_; + std::string content_; + std::string mime_type_; + std::string content_disposition_; + size_t offset_; + + IMPLEMENT_REFCOUNTING(SchemeHandler); +}; + +class DownloadSchemeHandlerFactory : public CefSchemeHandlerFactory { + public: + explicit DownloadSchemeHandlerFactory(TrackCallback* got_download_request) + : got_download_request_(got_download_request) {} + + virtual CefRefPtr Create( + CefRefPtr browser, + CefRefPtr frame, + const CefString& scheme_name, + CefRefPtr request) OVERRIDE { + return new DownloadSchemeHandler(got_download_request_); + } + + private: + TrackCallback* got_download_request_; + + IMPLEMENT_REFCOUNTING(SchemeHandlerFactory); +}; + +class DownloadTestHandler : public TestHandler { + public: + DownloadTestHandler() {} + + virtual void RunTest() OVERRIDE { + CefRegisterSchemeHandlerFactory("http", kTestDomain, + new DownloadSchemeHandlerFactory(&got_download_request_)); + + // Create a new temporary directory. + EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); + test_path_ = temp_dir_.path().AppendASCII(kTestFileName); + + // Create the browser + CreateBrowser(kTestEntryUrl); + } + + virtual void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) OVERRIDE { + EXPECT_STREQ(kTestEntryUrl, frame->GetURL().ToString().c_str()); + + // Begin the download. + browser->GetHost()->StartDownload(kTestDownloadUrl); + } + + virtual void OnBeforeDownload( + CefRefPtr browser, + CefRefPtr download_item, + const CefString& suggested_name, + CefRefPtr callback) OVERRIDE { + EXPECT_TRUE(CefCurrentlyOn(TID_UI)); + EXPECT_FALSE(got_on_before_download_); + + got_on_before_download_.yes(); + + EXPECT_TRUE(browser->IsSame(GetBrowser())); + EXPECT_STREQ(kTestFileName, suggested_name.ToString().c_str()); + EXPECT_TRUE(download_item.get()); + EXPECT_TRUE(callback.get()); + + download_id_ = download_item->GetId(); + EXPECT_LT(0, download_id_); + + EXPECT_TRUE(download_item->IsValid()); + EXPECT_TRUE(download_item->IsInProgress()); + EXPECT_FALSE(download_item->IsComplete()); + EXPECT_FALSE(download_item->IsCanceled()); + EXPECT_EQ(0LL, download_item->GetCurrentSpeed()); + EXPECT_EQ(0, download_item->GetPercentComplete()); + EXPECT_EQ(static_cast(sizeof(kTestContent)-1), + download_item->GetTotalBytes()); + EXPECT_EQ(0LL, download_item->GetReceivedBytes()); + EXPECT_EQ(0UL, download_item->GetFullPath().length()); + EXPECT_STREQ(kTestDownloadUrl, download_item->GetURL().ToString().c_str()); + EXPECT_EQ(0UL, download_item->GetSuggestedFileName().length()); + EXPECT_STREQ(kTestContentDisposition, + download_item->GetContentDisposition().ToString().c_str()); + EXPECT_STREQ(kTestMimeType, download_item->GetMimeType().ToString().c_str()); + + callback->Continue(test_path_.value(), false); + } + + virtual void OnDownloadUpdated( + CefRefPtr browser, + CefRefPtr download_item, + CefRefPtr callback) OVERRIDE { + EXPECT_TRUE(CefCurrentlyOn(TID_UI)); + + got_on_download_updated_.yes(); + + EXPECT_TRUE(browser->IsSame(GetBrowser())); + EXPECT_TRUE(download_item.get()); + EXPECT_TRUE(callback.get()); + + if (got_on_before_download_) + EXPECT_EQ(download_id_, download_item->GetId()); + + EXPECT_LE(0LL, download_item->GetCurrentSpeed()); + EXPECT_LE(0, download_item->GetPercentComplete()); + + EXPECT_TRUE(download_item->IsValid()); + EXPECT_FALSE(download_item->IsCanceled()); + EXPECT_STREQ(kTestDownloadUrl, download_item->GetURL().ToString().c_str()); + EXPECT_STREQ(kTestContentDisposition, + download_item->GetContentDisposition().ToString().c_str()); + EXPECT_STREQ(kTestMimeType, + download_item->GetMimeType().ToString().c_str()); + + std::string full_path = download_item->GetFullPath(); + if (!full_path.empty()) { + got_full_path_.yes(); + EXPECT_STREQ(CefString(test_path_.value()).ToString().c_str(), + full_path.c_str()); + } + + if (download_item->IsComplete()) { + EXPECT_FALSE(download_item->IsInProgress()); + EXPECT_EQ(100, download_item->GetPercentComplete()); + EXPECT_EQ(static_cast(sizeof(kTestContent)-1), + download_item->GetReceivedBytes()); + EXPECT_EQ(static_cast(sizeof(kTestContent)-1), + download_item->GetTotalBytes()); + + DestroyTest(); + } else { + EXPECT_TRUE(download_item->IsInProgress()); + EXPECT_LE(0LL, download_item->GetReceivedBytes()); + } + } + + virtual void DestroyTest() OVERRIDE { + CefRegisterSchemeHandlerFactory("http", kTestDomain, NULL); + + EXPECT_TRUE(got_download_request_); + EXPECT_TRUE(got_on_before_download_); + EXPECT_TRUE(got_on_download_updated_); + EXPECT_TRUE(got_full_path_); + + // Verify the file contents. + std::string contents; + EXPECT_TRUE(file_util::ReadFileToString(test_path_, &contents)); + EXPECT_STREQ(kTestContent, contents.c_str()); + + EXPECT_TRUE(temp_dir_.Delete()); + + TestHandler::DestroyTest(); + } + + private: + base::ScopedTempDir temp_dir_; + base::FilePath test_path_; + int download_id_; + + TrackCallback got_download_request_; + TrackCallback got_on_before_download_; + TrackCallback got_on_download_updated_; + TrackCallback got_full_path_; +}; + +} // namespace + +// Verify that downloads work. +TEST(DownloadTest, Download) { + CefRefPtr handler = new DownloadTestHandler(); + handler->ExecuteTest(); +} diff --git a/cef3/tests/unittests/geolocation_unittest.cc b/cef3/tests/unittests/geolocation_unittest.cc new file mode 100644 index 000000000..edfc02043 --- /dev/null +++ b/cef3/tests/unittests/geolocation_unittest.cc @@ -0,0 +1,204 @@ +// 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 "include/cef_geolocation.h" +#include "include/cef_runnable.h" +#include "tests/unittests/test_handler.h" +#include "tests/unittests/test_util.h" +#include "base/synchronization/waitable_event.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +const char* kTestOrigin = "http://tests/"; +const char* kTestUrl = "http://tests/GeolocationTestHandler"; +const char* kTestAllowUrl = "http://tests/GeolocationTestHandler.Allow"; +const char* kTestDenyUrl = "http://tests/GeolocationTestHandler.Deny"; +const char* kTestCancelUrl = "http://tests/GeolocationTestHandler.Cancel"; + +enum TestMode { + TEST_ALLOW, + TEST_DENY, + TEST_CANCEL, +}; + +class GeolocationTestHandler : public TestHandler { + public: + GeolocationTestHandler(const TestMode& mode, bool async) + : mode_(mode), + async_(async), + request_id_(-1) { + } + + virtual void RunTest() OVERRIDE { + std::string html = + "TEST START"; + AddResource(kTestUrl, html, "text/html"); + + std::string end_html = "TEST END"; + AddResource(kTestAllowUrl, end_html, "text/html"); + AddResource(kTestDenyUrl, end_html, "text/html"); + AddResource(kTestCancelUrl, end_html, "text/html"); + + // Create the browser + CreateBrowser(kTestUrl); + } + + virtual void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) OVERRIDE { + std::string url = frame->GetURL(); + if (url != kTestUrl) { + if (url == kTestAllowUrl) + got_allow_.yes(); + else if (url == kTestDenyUrl) + got_deny_.yes(); + else if (url == kTestCancelUrl) + got_cancel_.yes(); + + DestroyTest(); + } + } + + void ExecuteCallback(CefRefPtr callback) { + if (mode_ == TEST_ALLOW) + callback->Continue(true); + else if (mode_ == TEST_DENY) + callback->Continue(false); + } + + virtual void OnRequestGeolocationPermission( + CefRefPtr browser, + const CefString& requesting_url, + int request_id, + CefRefPtr callback) OVERRIDE { + got_requestgeolocationpermission_.yes(); + + EXPECT_TRUE(CefCurrentlyOn(TID_IO)); + + EXPECT_STREQ(kTestOrigin, requesting_url.ToString().c_str()); + request_id_ = request_id; + + if (!async_) { + ExecuteCallback(callback); + } else { + CefPostTask(TID_UI, + NewCefRunnableMethod(this, &GeolocationTestHandler::ExecuteCallback, + callback)); + } + } + + virtual void OnCancelGeolocationPermission( + CefRefPtr browser, + const CefString& requesting_url, + int request_id) OVERRIDE { + got_cancelgeolocationpermission_.yes(); + + EXPECT_TRUE(CefCurrentlyOn(TID_IO)); + + EXPECT_STREQ(kTestOrigin, requesting_url.ToString().c_str()); + EXPECT_EQ(request_id, request_id_); + } + + virtual void DestroyTest() OVERRIDE { + EXPECT_TRUE(got_requestgeolocationpermission_); + if (mode_ == TEST_CANCEL) + EXPECT_TRUE(got_cancelgeolocationpermission_); + else + EXPECT_FALSE(got_cancelgeolocationpermission_); + + TestHandler::DestroyTest(); + } + + TestMode mode_; + bool async_; + + int request_id_; + + TrackCallback got_requestgeolocationpermission_; + TrackCallback got_cancelgeolocationpermission_; + TrackCallback got_allow_; + TrackCallback got_cancel_; + TrackCallback got_deny_; +}; + +} // namespace + +TEST(GeolocationTest, HandlerAllow) { + CefRefPtr handler = + new GeolocationTestHandler(TEST_ALLOW, false); + handler->ExecuteTest(); + EXPECT_TRUE(handler->got_allow_); +} + +TEST(GeolocationTest, HandlerAllowAsync) { + CefRefPtr handler = + new GeolocationTestHandler(TEST_ALLOW, true); + handler->ExecuteTest(); + EXPECT_TRUE(handler->got_allow_); +} + +TEST(GeolocationTest, HandlerDeny) { + CefRefPtr handler = + new GeolocationTestHandler(TEST_DENY, false); + handler->ExecuteTest(); + EXPECT_TRUE(handler->got_deny_); +} + +TEST(GeolocationTest, HandlerDenyAsync) { + CefRefPtr handler = + new GeolocationTestHandler(TEST_DENY, true); + handler->ExecuteTest(); + EXPECT_TRUE(handler->got_deny_); +} + +TEST(GeolocationTest, HandlerCancel) { + CefRefPtr handler = + new GeolocationTestHandler(TEST_CANCEL, false); + handler->ExecuteTest(); + EXPECT_TRUE(handler->got_cancel_); +} + + +namespace { + +class TestGetGeolocationCallback : public CefGetGeolocationCallback { + public: + explicit TestGetGeolocationCallback(base::WaitableEvent* event) + : event_(event) { + } + + virtual void OnLocationUpdate(const CefGeoposition& position) OVERRIDE { + EXPECT_TRUE(CefCurrentlyOn(TID_UI)); + EXPECT_EQ(position.error_code, GEOPOSITON_ERROR_NONE); + EXPECT_NE(position.latitude, 0.0); + EXPECT_NE(position.longitude, 0.0); + EXPECT_NE(position.accuracy, 0.0); + EXPECT_NE(position.timestamp.year, 0); + event_->Signal(); + } + +private: + base::WaitableEvent* event_; + + IMPLEMENT_REFCOUNTING(TestGetGeolocationCallback); +}; + +} // namespace + +TEST(GeolocationTest, GetGeolocation) { + base::WaitableEvent event(false, false); + CefGetGeolocation(new TestGetGeolocationCallback(&event)); + event.Wait(); +} diff --git a/cef3/tests/unittests/jsdialog_unittest.cc b/cef3/tests/unittests/jsdialog_unittest.cc new file mode 100644 index 000000000..df5312152 --- /dev/null +++ b/cef3/tests/unittests/jsdialog_unittest.cc @@ -0,0 +1,413 @@ +// 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 "include/cef_runnable.h" +#include "tests/unittests/test_handler.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +const char* kStartUrl = "http://tests/JSDialogTestHandler.Start"; +const char* kEndUrl = "http://tests/JSDialogTestHandler.End?r="; + +class JSDialogTestHandler : public TestHandler { + public: + enum TestType { + TYPE_ALERT, + TYPE_CONFIRM, + TYPE_PROMPT, + TYPE_ONBEFOREUNLOAD, + }; + enum TestMode { + MODE_SUPPRESS, + MODE_RUN_IMMEDIATE, + MODE_RUN_DELAYED, + }; + + JSDialogTestHandler(TestType type, + TestMode mode, + bool success, + const std::string& user_input, + const std::string& result) + : type_(type), + mode_(mode), + success_(success), + user_input_(user_input), + result_(result) { + } + + virtual void RunTest() OVERRIDE { + std::string content = "START"; + + AddResource(kStartUrl, content, "text/html"); + AddResource(kEndUrl, "END", "text/html"); + + // Create the browser + CreateBrowser(kStartUrl); + } + + virtual void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) OVERRIDE { + if (!frame->IsMain()) + return; + + std::string url = frame->GetURL(); + if (url.find(kEndUrl) == 0) { + got_onloadend_.yes(); + + std::string result = url.substr(strlen(kEndUrl)); + EXPECT_STREQ(result_.c_str(), result.c_str()); + + DestroyTest(); + } else if (type_ == TYPE_ONBEFOREUNLOAD) { + // Trigger the onunload handler. + frame->LoadURL(kEndUrl); + } + } + + virtual void Continue(CefRefPtr callback) { + callback->Continue(success_, user_input_); + } + + virtual bool OnJSDialog(CefRefPtr browser, + const CefString& origin_url, + const CefString& accept_lang, + JSDialogType dialog_type, + const CefString& message_text, + const CefString& default_prompt_text, + CefRefPtr callback, + bool& suppress_message) OVERRIDE { + got_onjsdialog_.yes(); + + EXPECT_STREQ("http://tests/", origin_url.ToString().c_str()); + EXPECT_TRUE(accept_lang.empty()); + + if (type_ == TYPE_ALERT) { + EXPECT_EQ(JSDIALOGTYPE_ALERT, dialog_type); + EXPECT_STREQ("My alert message", message_text.ToString().c_str()); + EXPECT_TRUE(default_prompt_text.empty()); + } else if (type_ == TYPE_CONFIRM) { + EXPECT_EQ(JSDIALOGTYPE_CONFIRM, dialog_type); + EXPECT_STREQ("My confirm message", message_text.ToString().c_str()); + EXPECT_TRUE(default_prompt_text.empty()); + } else if (type_ == TYPE_PROMPT) { + EXPECT_EQ(JSDIALOGTYPE_PROMPT, dialog_type); + EXPECT_STREQ("My prompt message", message_text.ToString().c_str()); + EXPECT_STREQ("my default", default_prompt_text.ToString().c_str()); + } + + EXPECT_FALSE(suppress_message); + + if (mode_ == MODE_SUPPRESS) { + // Suppress the dialog. + suppress_message = true; + return false; + } else if (mode_ == MODE_RUN_IMMEDIATE) { + // Continue immediately. + callback->Continue(success_, user_input_); + } else if (mode_ == MODE_RUN_DELAYED) { + // Continue asynchronously. + CefPostTask(TID_UI, + NewCefRunnableMethod(this, &JSDialogTestHandler::Continue, callback)); + } + + return true; + } + + virtual bool OnBeforeUnloadDialog(CefRefPtr browser, + const CefString& message_text, + bool is_reload, + CefRefPtr callback) + OVERRIDE { + got_onbeforeunloaddialog_.yes(); + + if (type_ == TYPE_ONBEFOREUNLOAD) { + EXPECT_STREQ("My unload message", message_text.ToString().c_str()); + EXPECT_FALSE(is_reload); + } + + if (mode_ == MODE_RUN_IMMEDIATE) { + // Continue immediately. + callback->Continue(success_, user_input_); + } else if (mode_ == MODE_RUN_DELAYED) { + // Continue asynchronously. + CefPostTask(TID_UI, + NewCefRunnableMethod(this, &JSDialogTestHandler::Continue, callback)); + } + + return true; + } + + virtual void OnResetDialogState(CefRefPtr browser) OVERRIDE { + got_onresetdialogstate_.yes(); + } + + TestType type_; + TestMode mode_; + bool success_; + std::string user_input_; + std::string result_; + + TrackCallback got_onjsdialog_; + TrackCallback got_onbeforeunloaddialog_; + TrackCallback got_onresetdialogstate_; + TrackCallback got_onloadend_; +}; + +} // namespace + +// Alert dialog with suppression. +TEST(JSDialogTest, AlertSuppress) { + CefRefPtr handler = + new JSDialogTestHandler(JSDialogTestHandler::TYPE_ALERT, + JSDialogTestHandler::MODE_SUPPRESS, + true, // success + "", // user_input + ""); // result + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_onjsdialog_); + EXPECT_FALSE(handler->got_onbeforeunloaddialog_); + EXPECT_TRUE(handler->got_onresetdialogstate_); + EXPECT_TRUE(handler->got_onloadend_); +} + +// Alert dialog with immediate callback. +TEST(JSDialogTest, AlertRunImmediate) { + CefRefPtr handler = + new JSDialogTestHandler(JSDialogTestHandler::TYPE_ALERT, + JSDialogTestHandler::MODE_RUN_IMMEDIATE, + true, // success + "", // user_input + ""); // result + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_onjsdialog_); + EXPECT_FALSE(handler->got_onbeforeunloaddialog_); + EXPECT_TRUE(handler->got_onresetdialogstate_); + EXPECT_TRUE(handler->got_onloadend_); +} + +// Alert dialog with delayed callback. +TEST(JSDialogTest, AlertRunDelayed) { + CefRefPtr handler = + new JSDialogTestHandler(JSDialogTestHandler::TYPE_ALERT, + JSDialogTestHandler::MODE_RUN_DELAYED, + true, // success + "", // user_input + ""); // result + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_onjsdialog_); + EXPECT_FALSE(handler->got_onbeforeunloaddialog_); + EXPECT_TRUE(handler->got_onresetdialogstate_); + EXPECT_TRUE(handler->got_onloadend_); +} + +// Confirm dialog with suppression. +TEST(JSDialogTest, ConfirmSuppress) { + CefRefPtr handler = + new JSDialogTestHandler(JSDialogTestHandler::TYPE_CONFIRM, + JSDialogTestHandler::MODE_SUPPRESS, + true, // success + "", // user_input + "cancel"); // result + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_onjsdialog_); + EXPECT_FALSE(handler->got_onbeforeunloaddialog_); + EXPECT_TRUE(handler->got_onresetdialogstate_); + EXPECT_TRUE(handler->got_onloadend_); +} + +// Confirm dialog run immediately return OK. +TEST(JSDialogTest, ConfirmRunImmediateOk) { + CefRefPtr handler = + new JSDialogTestHandler(JSDialogTestHandler::TYPE_CONFIRM, + JSDialogTestHandler::MODE_RUN_IMMEDIATE, + true, // success + "", // user_input + "ok"); // result + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_onjsdialog_); + EXPECT_FALSE(handler->got_onbeforeunloaddialog_); + EXPECT_TRUE(handler->got_onresetdialogstate_); + EXPECT_TRUE(handler->got_onloadend_); +} + +// Confirm dialog run immediately return Cancel. +TEST(JSDialogTest, ConfirmRunImmediateCancel) { + CefRefPtr handler = + new JSDialogTestHandler(JSDialogTestHandler::TYPE_CONFIRM, + JSDialogTestHandler::MODE_RUN_IMMEDIATE, + false, // success + "", // user_input + "cancel"); // result + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_onjsdialog_); + EXPECT_FALSE(handler->got_onbeforeunloaddialog_); + EXPECT_TRUE(handler->got_onresetdialogstate_); + EXPECT_TRUE(handler->got_onloadend_); +} + +// Confirm dialog run delayed return OK. +TEST(JSDialogTest, ConfirmRunDelayedOk) { + CefRefPtr handler = + new JSDialogTestHandler(JSDialogTestHandler::TYPE_CONFIRM, + JSDialogTestHandler::MODE_RUN_DELAYED, + true, // success + "", // user_input + "ok"); // result + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_onjsdialog_); + EXPECT_FALSE(handler->got_onbeforeunloaddialog_); + EXPECT_TRUE(handler->got_onresetdialogstate_); + EXPECT_TRUE(handler->got_onloadend_); +} + +// Confirm dialog run delayed return Cancel. +TEST(JSDialogTest, ConfirmRunDelayedCancel) { + CefRefPtr handler = + new JSDialogTestHandler(JSDialogTestHandler::TYPE_CONFIRM, + JSDialogTestHandler::MODE_RUN_DELAYED, + false, // success + "", // user_input + "cancel"); // result + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_onjsdialog_); + EXPECT_FALSE(handler->got_onbeforeunloaddialog_); + EXPECT_TRUE(handler->got_onresetdialogstate_); + EXPECT_TRUE(handler->got_onloadend_); +} + +// Prompt dialog with suppression. +TEST(JSDialogTest, PromptSuppress) { + CefRefPtr handler = + new JSDialogTestHandler(JSDialogTestHandler::TYPE_PROMPT, + JSDialogTestHandler::MODE_SUPPRESS, + true, // success + "some_value", // user_input + "null"); // result + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_onjsdialog_); + EXPECT_FALSE(handler->got_onbeforeunloaddialog_); + EXPECT_TRUE(handler->got_onresetdialogstate_); + EXPECT_TRUE(handler->got_onloadend_); +} + +// Prompt dialog run immediately return OK. +TEST(JSDialogTest, PromptRunImmediateOk) { + CefRefPtr handler = + new JSDialogTestHandler(JSDialogTestHandler::TYPE_PROMPT, + JSDialogTestHandler::MODE_RUN_IMMEDIATE, + true, // success + "some_value", // user_input + "some_value"); // result + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_onjsdialog_); + EXPECT_FALSE(handler->got_onbeforeunloaddialog_); + EXPECT_TRUE(handler->got_onresetdialogstate_); + EXPECT_TRUE(handler->got_onloadend_); +} + +// Prompt dialog run immediately return Cancel. +TEST(JSDialogTest, PromptRunImmediateCancel) { + CefRefPtr handler = + new JSDialogTestHandler(JSDialogTestHandler::TYPE_PROMPT, + JSDialogTestHandler::MODE_RUN_IMMEDIATE, + false, // success + "some_value", // user_input + "null"); // result + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_onjsdialog_); + EXPECT_FALSE(handler->got_onbeforeunloaddialog_); + EXPECT_TRUE(handler->got_onresetdialogstate_); + EXPECT_TRUE(handler->got_onloadend_); +} + +// Prompt dialog run delayed return OK. +TEST(JSDialogTest, PromptRunDelayedOk) { + CefRefPtr handler = + new JSDialogTestHandler(JSDialogTestHandler::TYPE_PROMPT, + JSDialogTestHandler::MODE_RUN_DELAYED, + true, // success + "some_value", // user_input + "some_value"); // result + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_onjsdialog_); + EXPECT_FALSE(handler->got_onbeforeunloaddialog_); + EXPECT_TRUE(handler->got_onresetdialogstate_); + EXPECT_TRUE(handler->got_onloadend_); +} + +// Prompt dialog run delayed return Cancel. +TEST(JSDialogTest, PromptRunDelayedCancel) { + CefRefPtr handler = + new JSDialogTestHandler(JSDialogTestHandler::TYPE_PROMPT, + JSDialogTestHandler::MODE_RUN_DELAYED, + false, // success + "some_value", // user_input + "null"); // result + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_onjsdialog_); + EXPECT_FALSE(handler->got_onbeforeunloaddialog_); + EXPECT_TRUE(handler->got_onresetdialogstate_); + EXPECT_TRUE(handler->got_onloadend_); +} + +// OnBeforeUnload dialog with immediate callback. +TEST(JSDialogTest, OnBeforeUnloadRunImmediate) { + CefRefPtr handler = + new JSDialogTestHandler(JSDialogTestHandler::TYPE_ONBEFOREUNLOAD, + JSDialogTestHandler::MODE_RUN_IMMEDIATE, + true, // success + "", // user_input + ""); // result + handler->ExecuteTest(); + + EXPECT_FALSE(handler->got_onjsdialog_); + EXPECT_TRUE(handler->got_onbeforeunloaddialog_); + EXPECT_TRUE(handler->got_onresetdialogstate_); + EXPECT_TRUE(handler->got_onloadend_); +} + +// OnBeforeUnload dialog with delayed callback. +TEST(JSDialogTest, OnBeforeUnloadRunDelayed) { + CefRefPtr handler = + new JSDialogTestHandler(JSDialogTestHandler::TYPE_ONBEFOREUNLOAD, + JSDialogTestHandler::MODE_RUN_DELAYED, + true, // success + "", // user_input + ""); // result + handler->ExecuteTest(); + + EXPECT_FALSE(handler->got_onjsdialog_); + EXPECT_TRUE(handler->got_onbeforeunloaddialog_); + EXPECT_TRUE(handler->got_onresetdialogstate_); + EXPECT_TRUE(handler->got_onloadend_); +} diff --git a/cef3/tests/unittests/life_span_unittest.cc b/cef3/tests/unittests/life_span_unittest.cc new file mode 100644 index 000000000..2ac45d179 --- /dev/null +++ b/cef3/tests/unittests/life_span_unittest.cc @@ -0,0 +1,306 @@ +// Copyright (c) 2013 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 "include/cef_runnable.h" +#include "tests/unittests/test_handler.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +const char kLifeSpanUrl[] = "http://tests-life-span/test.html"; +const char kUnloadDialogText[] = "Are you sure?"; +const char kUnloadMsg[] = "LifeSpanTestHandler.Unload"; + +// Browser side. +class LifeSpanTestHandler : public TestHandler { + public: + struct Settings { + Settings() + : force_close(false), + add_onunload_handler(false), + allow_do_close(true), + accept_before_unload_dialog(true) {} + + bool force_close; + bool add_onunload_handler; + bool allow_do_close; + bool accept_before_unload_dialog; + }; + + explicit LifeSpanTestHandler(const Settings& settings) + : settings_(settings), + executing_delay_close_(false) {} + + virtual void RunTest() OVERRIDE { + // Add the resources that we will navigate to/from. + std::string page = "Page"; + AddResource(kLifeSpanUrl, page, "text/html"); + + // Create the browser. + CreateBrowser(kLifeSpanUrl); + } + + virtual void OnAfterCreated(CefRefPtr browser) OVERRIDE { + got_after_created_.yes(); + TestHandler::OnAfterCreated(browser); + } + + virtual bool DoClose(CefRefPtr browser) OVERRIDE { + if (executing_delay_close_) + return false; + + EXPECT_TRUE(browser->IsSame(GetBrowser())); + + got_do_close_.yes(); + + if (!settings_.allow_do_close) { + // The close will be canceled. + ScheduleDelayClose(); + } + + return !settings_.allow_do_close; + } + + virtual void OnBeforeClose(CefRefPtr browser) OVERRIDE { + if (!executing_delay_close_) { + got_before_close_.yes(); + EXPECT_TRUE(browser->IsSame(GetBrowser())); + } + + TestHandler::OnBeforeClose(browser); + } + + virtual bool OnBeforeUnloadDialog( + CefRefPtr browser, + const CefString& message_text, + bool is_reload, + CefRefPtr callback) OVERRIDE { + if (executing_delay_close_) { + callback->Continue(true, CefString()); + return true; + } + + EXPECT_TRUE(browser->IsSame(GetBrowser())); + EXPECT_STREQ(kUnloadDialogText, message_text.ToString().c_str()); + EXPECT_FALSE(is_reload); + EXPECT_TRUE(callback.get()); + + if (!settings_.accept_before_unload_dialog) { + // The close will be canceled. + ScheduleDelayClose(); + } + + got_before_unload_dialog_.yes(); + callback->Continue(settings_.accept_before_unload_dialog, CefString()); + return true; + } + + virtual void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) OVERRIDE { + got_load_end_.yes(); + EXPECT_TRUE(browser->IsSame(GetBrowser())); + + // Attempt to close the browser. + browser->GetHost()->CloseBrowser(settings_.force_close); + } + + virtual bool OnProcessMessageReceived( + CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) OVERRIDE { + const std::string& message_name = message->GetName(); + if (message_name == kUnloadMsg) { + if (!executing_delay_close_) + got_unload_message_.yes(); + return true; + } + + return false; + } + + TrackCallback got_after_created_; + TrackCallback got_do_close_; + TrackCallback got_before_close_; + TrackCallback got_before_unload_dialog_; + TrackCallback got_unload_message_; + TrackCallback got_load_end_; + TrackCallback got_delay_close_; + + private: + // Wait a bit to make sure no additional events are received and then close + // the window. + void ScheduleDelayClose() { + CefPostDelayedTask(TID_UI, + NewCefRunnableMethod(this, &LifeSpanTestHandler::DelayClose), 100); + } + + void DelayClose() { + got_delay_close_.yes(); + executing_delay_close_ = true; + DestroyTest(); + } + + Settings settings_; + + // Forces the window to close (bypasses test conditions). + bool executing_delay_close_; +}; + +} // namespace + +TEST(LifeSpanTest, DoCloseAllow) { + LifeSpanTestHandler::Settings settings; + settings.allow_do_close = true; + CefRefPtr handler = new LifeSpanTestHandler(settings); + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_after_created_); + EXPECT_TRUE(handler->got_do_close_); + EXPECT_TRUE(handler->got_before_close_); + EXPECT_FALSE(handler->got_before_unload_dialog_); + EXPECT_TRUE(handler->got_unload_message_); + EXPECT_TRUE(handler->got_load_end_); + EXPECT_FALSE(handler->got_delay_close_); +} + +TEST(LifeSpanTest, DoCloseAllowForce) { + LifeSpanTestHandler::Settings settings; + settings.allow_do_close = true; + settings.force_close = true; + CefRefPtr handler = new LifeSpanTestHandler(settings); + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_after_created_); + EXPECT_TRUE(handler->got_do_close_); + EXPECT_TRUE(handler->got_before_close_); + EXPECT_FALSE(handler->got_before_unload_dialog_); + EXPECT_TRUE(handler->got_unload_message_); + EXPECT_TRUE(handler->got_load_end_); + EXPECT_FALSE(handler->got_delay_close_); +} + +TEST(LifeSpanTest, DoCloseDisallow) { + LifeSpanTestHandler::Settings settings; + settings.allow_do_close = false; + CefRefPtr handler = new LifeSpanTestHandler(settings); + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_after_created_); + EXPECT_TRUE(handler->got_do_close_); + EXPECT_FALSE(handler->got_before_close_); + EXPECT_FALSE(handler->got_before_unload_dialog_); + EXPECT_TRUE(handler->got_unload_message_); + EXPECT_TRUE(handler->got_load_end_); + EXPECT_TRUE(handler->got_delay_close_); +} + +TEST(LifeSpanTest, DoCloseDisallowForce) { + LifeSpanTestHandler::Settings settings; + settings.allow_do_close = false; + settings.force_close = true; + CefRefPtr handler = new LifeSpanTestHandler(settings); + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_after_created_); + EXPECT_TRUE(handler->got_do_close_); + EXPECT_FALSE(handler->got_before_close_); + EXPECT_FALSE(handler->got_before_unload_dialog_); + EXPECT_TRUE(handler->got_unload_message_); + EXPECT_TRUE(handler->got_load_end_); + EXPECT_TRUE(handler->got_delay_close_); +} + +TEST(LifeSpanTest, DoCloseDisallowWithOnUnloadAllow) { + LifeSpanTestHandler::Settings settings; + settings.allow_do_close = false; + settings.add_onunload_handler = true; + settings.accept_before_unload_dialog = true; + CefRefPtr handler = new LifeSpanTestHandler(settings); + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_after_created_); + EXPECT_TRUE(handler->got_do_close_); + EXPECT_FALSE(handler->got_before_close_); + EXPECT_TRUE(handler->got_before_unload_dialog_); + EXPECT_TRUE(handler->got_unload_message_); + EXPECT_TRUE(handler->got_load_end_); + EXPECT_TRUE(handler->got_delay_close_); +} + +TEST(LifeSpanTest, DoCloseAllowWithOnUnloadForce) { + LifeSpanTestHandler::Settings settings; + settings.allow_do_close = true; + settings.add_onunload_handler = true; + settings.force_close = true; + CefRefPtr handler = new LifeSpanTestHandler(settings); + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_after_created_); + EXPECT_TRUE(handler->got_do_close_); + EXPECT_TRUE(handler->got_before_close_); + EXPECT_FALSE(handler->got_before_unload_dialog_); + EXPECT_TRUE(handler->got_unload_message_); + EXPECT_TRUE(handler->got_load_end_); + EXPECT_FALSE(handler->got_delay_close_); +} + +TEST(LifeSpanTest, DoCloseDisallowWithOnUnloadForce) { + LifeSpanTestHandler::Settings settings; + settings.allow_do_close = false; + settings.add_onunload_handler = true; + settings.force_close = true; + CefRefPtr handler = new LifeSpanTestHandler(settings); + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_after_created_); + EXPECT_TRUE(handler->got_do_close_); + EXPECT_FALSE(handler->got_before_close_); + EXPECT_FALSE(handler->got_before_unload_dialog_); + EXPECT_TRUE(handler->got_unload_message_); + EXPECT_TRUE(handler->got_load_end_); + EXPECT_TRUE(handler->got_delay_close_); +} + +TEST(LifeSpanTest, OnUnloadAllow) { + LifeSpanTestHandler::Settings settings; + settings.add_onunload_handler = true; + settings.accept_before_unload_dialog = true; + CefRefPtr handler = new LifeSpanTestHandler(settings); + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_after_created_); + EXPECT_TRUE(handler->got_do_close_); + EXPECT_TRUE(handler->got_before_close_); + EXPECT_TRUE(handler->got_before_unload_dialog_); + EXPECT_TRUE(handler->got_unload_message_); + EXPECT_TRUE(handler->got_load_end_); + EXPECT_FALSE(handler->got_delay_close_); +} + +TEST(LifeSpanTest, OnUnloadDisallow) { + LifeSpanTestHandler::Settings settings; + settings.add_onunload_handler = true; + settings.accept_before_unload_dialog = false; + CefRefPtr handler = new LifeSpanTestHandler(settings); + handler->ExecuteTest(); + + EXPECT_TRUE(handler->got_after_created_); + EXPECT_FALSE(handler->got_do_close_); + EXPECT_FALSE(handler->got_before_close_); + EXPECT_TRUE(handler->got_before_unload_dialog_); + EXPECT_FALSE(handler->got_unload_message_); + EXPECT_TRUE(handler->got_load_end_); + EXPECT_TRUE(handler->got_delay_close_); +} diff --git a/cef3/tests/unittests/mac/English.lproj/InfoPlist.strings b/cef3/tests/unittests/mac/English.lproj/InfoPlist.strings new file mode 100644 index 000000000..fe2abe11b --- /dev/null +++ b/cef3/tests/unittests/mac/English.lproj/InfoPlist.strings @@ -0,0 +1,3 @@ +/* Localized versions of Info.plist keys */ + +NSHumanReadableCopyright = "© Chromium Embedded Framework Authors, 2010"; diff --git a/cef3/tests/unittests/mac/English.lproj/MainMenu.xib b/cef3/tests/unittests/mac/English.lproj/MainMenu.xib new file mode 100644 index 000000000..e4f7c1fc3 --- /dev/null +++ b/cef3/tests/unittests/mac/English.lproj/MainMenu.xib @@ -0,0 +1,2880 @@ + + + + 1050 + 10F569 + 820 + 1038.29 + 461.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 820 + + + YES + + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + + + PluginDependencyRecalculationVersion + + + + YES + + NSApplication + + + FirstResponder + + + NSApplication + + + AMainMenu + + YES + + + cefclient + + 1048576 + 2147483647 + + NSImage + NSMenuCheckmark + + + NSImage + NSMenuMixedState + + submenuAction: + + TestShell + + YES + + + About cefclient + + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Preferences… + , + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Services + + 1048576 + 2147483647 + + + submenuAction: + + Services + + YES + + _NSServicesMenu + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Hide cefclient + h + 1048576 + 2147483647 + + + + + + Hide Others + h + 1572864 + 2147483647 + + + + + + Show All + + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Quit cefclient + q + 1048576 + 2147483647 + + + + + _NSAppleMenu + + + + + File + + 1048576 + 2147483647 + + + submenuAction: + + File + + YES + + + New + n + 1048576 + 2147483647 + + + + + + Open… + o + 1048576 + 2147483647 + + + + + + Open Recent + + 1048576 + 2147483647 + + + submenuAction: + + Open Recent + + YES + + + Clear Menu + + 1048576 + 2147483647 + + + + + _NSRecentDocumentsMenu + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Close + w + 1048576 + 2147483647 + + + + + + Save + s + 1048576 + 2147483647 + + + + + + Save As… + S + 1179648 + 2147483647 + + + + + + Revert to Saved + + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Page Setup... + P + 1179648 + 2147483647 + + + + + + + Print… + p + 1048576 + 2147483647 + + + + + + + + + Edit + + 1048576 + 2147483647 + + + submenuAction: + + Edit + + YES + + + Undo + z + 1048576 + 2147483647 + + + + + + Redo + Z + 1179648 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Cut + x + 1048576 + 2147483647 + + + + + + Copy + c + 1048576 + 2147483647 + + + + + + Paste + v + 1048576 + 2147483647 + + + + + + Delete + + 1048576 + 2147483647 + + + + + + Select All + a + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Find + + 1048576 + 2147483647 + + + submenuAction: + + Find + + YES + + + Find… + f + 1048576 + 2147483647 + + + 1 + + + + Find Next + g + 1048576 + 2147483647 + + + 2 + + + + Find Previous + G + 1179648 + 2147483647 + + + 3 + + + + Use Selection for Find + e + 1048576 + 2147483647 + + + 7 + + + + Jump to Selection + j + 1048576 + 2147483647 + + + + + + + + + Spelling and Grammar + + 1048576 + 2147483647 + + + submenuAction: + + Spelling and Grammar + + YES + + + Show Spelling… + : + 1048576 + 2147483647 + + + + + + Check Spelling + ; + 1048576 + 2147483647 + + + + + + Check Spelling While Typing + + 1048576 + 2147483647 + + + + + + Check Grammar With Spelling + + 1048576 + 2147483647 + + + + + + + + + Substitutions + + 1048576 + 2147483647 + + + submenuAction: + + Substitutions + + YES + + + Smart Copy/Paste + f + 1048576 + 2147483647 + + + 1 + + + + Smart Quotes + g + 1048576 + 2147483647 + + + 2 + + + + Smart Links + G + 1179648 + 2147483647 + + + 3 + + + + + + + Speech + + 1048576 + 2147483647 + + + submenuAction: + + Speech + + YES + + + Start Speaking + + 1048576 + 2147483647 + + + + + + Stop Speaking + + 1048576 + 2147483647 + + + + + + + + + + + + Format + + 1048576 + 2147483647 + + + submenuAction: + + Format + + YES + + + Show Fonts + t + 1048576 + 2147483647 + + + + + + Show Colors + C + 1179648 + 2147483647 + + + + + + + + + View + + 1048576 + 2147483647 + + + submenuAction: + + View + + YES + + + Show Toolbar + t + 1572864 + 2147483647 + + + + + + Customize Toolbar… + + 1048576 + 2147483647 + + + + + + + + + Window + + 1048576 + 2147483647 + + + submenuAction: + + Window + + YES + + + Minimize + m + 1048576 + 2147483647 + + + + + + Zoom + + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Bring All to Front + + 1048576 + 2147483647 + + + + + _NSWindowsMenu + + + + + Help + + 1048576 + 2147483647 + + + submenuAction: + + Help + + YES + + + cefclient Help + ? + 1048576 + 2147483647 + + + + + + + + _NSMainMenu + + + YES + + + + + YES + + + performMiniaturize: + + + + 37 + + + + arrangeInFront: + + + + 39 + + + + print: + + + + 86 + + + + runPageLayout: + + + + 87 + + + + clearRecentDocuments: + + + + 127 + + + + orderFrontStandardAboutPanel: + + + + 142 + + + + performClose: + + + + 193 + + + + toggleContinuousSpellChecking: + + + + 222 + + + + undo: + + + + 223 + + + + copy: + + + + 224 + + + + checkSpelling: + + + + 225 + + + + paste: + + + + 226 + + + + stopSpeaking: + + + + 227 + + + + cut: + + + + 228 + + + + showGuessPanel: + + + + 230 + + + + redo: + + + + 231 + + + + selectAll: + + + + 232 + + + + startSpeaking: + + + + 233 + + + + delete: + + + + 235 + + + + performZoom: + + + + 240 + + + + performFindPanelAction: + + + + 241 + + + + centerSelectionInVisibleArea: + + + + 245 + + + + toggleGrammarChecking: + + + + 347 + + + + toggleSmartInsertDelete: + + + + 355 + + + + toggleAutomaticQuoteSubstitution: + + + + 356 + + + + toggleAutomaticLinkDetection: + + + + 357 + + + + showHelp: + + + + 360 + + + + orderFrontColorPanel: + + + + 361 + + + + saveDocument: + + + + 362 + + + + saveDocumentAs: + + + + 363 + + + + revertDocumentToSaved: + + + + 364 + + + + runToolbarCustomizationPalette: + + + + 365 + + + + toggleToolbarShown: + + + + 366 + + + + hide: + + + + 367 + + + + hideOtherApplications: + + + + 368 + + + + terminate: + + + + 369 + + + + unhideAllApplications: + + + + 370 + + + + newDocument: + + + + 373 + + + + openDocument: + + + + 374 + + + + + YES + + 0 + + YES + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 29 + + + YES + + + + + + + + + + MainMenu + + + 19 + + + YES + + + + + + 56 + + + YES + + + + + + 103 + + + YES + + + + 1 + + + 217 + + + YES + + + + + + 83 + + + YES + + + + + + 81 + + + YES + + + + + + + + + + + + + + + + 75 + + + 3 + + + 80 + + + 8 + + + 78 + + + 6 + + + 72 + + + + + 82 + + + 9 + + + 124 + + + YES + + + + + + 77 + + + 5 + + + 73 + + + 1 + + + 79 + + + 7 + + + 112 + + + 10 + + + 74 + + + 2 + + + 125 + + + YES + + + + + + 126 + + + + + 205 + + + YES + + + + + + + + + + + + + + + + + + 202 + + + + + 198 + + + + + 207 + + + + + 214 + + + + + 199 + + + + + 203 + + + + + 197 + + + + + 206 + + + + + 215 + + + + + 218 + + + YES + + + + + + 216 + + + YES + + + + + + 200 + + + YES + + + + + + + + + 219 + + + + + 201 + + + + + 204 + + + + + 220 + + + YES + + + + + + + + + + 213 + + + + + 210 + + + + + 221 + + + + + 208 + + + + + 209 + + + + + 106 + + + YES + + + + 2 + + + 111 + + + + + 57 + + + YES + + + + + + + + + + + + + + + + 58 + + + + + 134 + + + + + 150 + + + + + 136 + + + 1111 + + + 144 + + + + + 129 + + + 121 + + + 143 + + + + + 236 + + + + + 131 + + + YES + + + + + + 149 + + + + + 145 + + + + + 130 + + + + + 24 + + + YES + + + + + + + + + 92 + + + + + 5 + + + + + 239 + + + + + 23 + + + + + 295 + + + YES + + + + + + 296 + + + YES + + + + + + + 297 + + + + + 298 + + + + + 299 + + + YES + + + + + + 300 + + + YES + + + + + + + 344 + + + + + 345 + + + + + 211 + + + YES + + + + + + 212 + + + YES + + + + + + + 195 + + + + + 196 + + + + + 346 + + + + + 348 + + + YES + + + + + + 349 + + + YES + + + + + + + + 350 + + + + + 351 + + + + + 354 + + + + + 389 + + + + + + + YES + + YES + -3.IBPluginDependency + 103.IBPluginDependency + 103.ImportedFromIB2 + 106.IBEditorWindowLastContentRect + 106.IBPluginDependency + 106.ImportedFromIB2 + 106.editorWindowContentRectSynchronizationRect + 111.IBPluginDependency + 111.ImportedFromIB2 + 112.IBPluginDependency + 112.ImportedFromIB2 + 124.IBPluginDependency + 124.ImportedFromIB2 + 125.IBPluginDependency + 125.ImportedFromIB2 + 125.editorWindowContentRectSynchronizationRect + 126.IBPluginDependency + 126.ImportedFromIB2 + 129.IBPluginDependency + 129.ImportedFromIB2 + 130.IBPluginDependency + 130.ImportedFromIB2 + 130.editorWindowContentRectSynchronizationRect + 131.IBPluginDependency + 131.ImportedFromIB2 + 134.IBPluginDependency + 134.ImportedFromIB2 + 136.IBPluginDependency + 136.ImportedFromIB2 + 143.IBPluginDependency + 143.ImportedFromIB2 + 144.IBPluginDependency + 144.ImportedFromIB2 + 145.IBPluginDependency + 145.ImportedFromIB2 + 149.IBPluginDependency + 149.ImportedFromIB2 + 150.IBPluginDependency + 150.ImportedFromIB2 + 19.IBPluginDependency + 19.ImportedFromIB2 + 195.IBPluginDependency + 195.ImportedFromIB2 + 196.IBPluginDependency + 196.ImportedFromIB2 + 197.IBPluginDependency + 197.ImportedFromIB2 + 198.IBPluginDependency + 198.ImportedFromIB2 + 199.IBPluginDependency + 199.ImportedFromIB2 + 200.IBEditorWindowLastContentRect + 200.IBPluginDependency + 200.ImportedFromIB2 + 200.editorWindowContentRectSynchronizationRect + 201.IBPluginDependency + 201.ImportedFromIB2 + 202.IBPluginDependency + 202.ImportedFromIB2 + 203.IBPluginDependency + 203.ImportedFromIB2 + 204.IBPluginDependency + 204.ImportedFromIB2 + 205.IBEditorWindowLastContentRect + 205.IBPluginDependency + 205.ImportedFromIB2 + 205.editorWindowContentRectSynchronizationRect + 206.IBPluginDependency + 206.ImportedFromIB2 + 207.IBPluginDependency + 207.ImportedFromIB2 + 208.IBPluginDependency + 208.ImportedFromIB2 + 209.IBPluginDependency + 209.ImportedFromIB2 + 210.IBPluginDependency + 210.ImportedFromIB2 + 211.IBPluginDependency + 211.ImportedFromIB2 + 212.IBEditorWindowLastContentRect + 212.IBPluginDependency + 212.ImportedFromIB2 + 212.editorWindowContentRectSynchronizationRect + 213.IBPluginDependency + 213.ImportedFromIB2 + 214.IBPluginDependency + 214.ImportedFromIB2 + 215.IBPluginDependency + 215.ImportedFromIB2 + 216.IBPluginDependency + 216.ImportedFromIB2 + 217.IBPluginDependency + 217.ImportedFromIB2 + 218.IBPluginDependency + 218.ImportedFromIB2 + 219.IBPluginDependency + 219.ImportedFromIB2 + 220.IBEditorWindowLastContentRect + 220.IBPluginDependency + 220.ImportedFromIB2 + 220.editorWindowContentRectSynchronizationRect + 221.IBPluginDependency + 221.ImportedFromIB2 + 23.IBPluginDependency + 23.ImportedFromIB2 + 236.IBPluginDependency + 236.ImportedFromIB2 + 239.IBPluginDependency + 239.ImportedFromIB2 + 24.IBEditorWindowLastContentRect + 24.IBPluginDependency + 24.ImportedFromIB2 + 24.editorWindowContentRectSynchronizationRect + 29.IBEditorWindowLastContentRect + 29.IBPluginDependency + 29.ImportedFromIB2 + 29.WindowOrigin + 29.editorWindowContentRectSynchronizationRect + 295.IBPluginDependency + 296.IBEditorWindowLastContentRect + 296.IBPluginDependency + 296.editorWindowContentRectSynchronizationRect + 297.IBPluginDependency + 298.IBPluginDependency + 299.IBPluginDependency + 300.IBEditorWindowLastContentRect + 300.IBPluginDependency + 300.editorWindowContentRectSynchronizationRect + 344.IBPluginDependency + 345.IBPluginDependency + 346.IBPluginDependency + 346.ImportedFromIB2 + 348.IBPluginDependency + 348.ImportedFromIB2 + 349.IBEditorWindowLastContentRect + 349.IBPluginDependency + 349.ImportedFromIB2 + 349.editorWindowContentRectSynchronizationRect + 350.IBPluginDependency + 350.ImportedFromIB2 + 351.IBPluginDependency + 351.ImportedFromIB2 + 354.IBPluginDependency + 354.ImportedFromIB2 + 389.IBPluginDependency + 5.IBPluginDependency + 5.ImportedFromIB2 + 56.IBPluginDependency + 56.ImportedFromIB2 + 57.IBEditorWindowLastContentRect + 57.IBPluginDependency + 57.ImportedFromIB2 + 57.editorWindowContentRectSynchronizationRect + 58.IBPluginDependency + 58.ImportedFromIB2 + 72.IBPluginDependency + 72.ImportedFromIB2 + 73.IBPluginDependency + 73.ImportedFromIB2 + 74.IBPluginDependency + 74.ImportedFromIB2 + 75.IBPluginDependency + 75.ImportedFromIB2 + 77.IBPluginDependency + 77.ImportedFromIB2 + 78.IBPluginDependency + 78.ImportedFromIB2 + 79.IBPluginDependency + 79.ImportedFromIB2 + 80.IBPluginDependency + 80.ImportedFromIB2 + 81.IBEditorWindowLastContentRect + 81.IBPluginDependency + 81.ImportedFromIB2 + 81.editorWindowContentRectSynchronizationRect + 82.IBPluginDependency + 82.ImportedFromIB2 + 83.IBPluginDependency + 83.ImportedFromIB2 + 92.IBPluginDependency + 92.ImportedFromIB2 + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + {{906, 713}, {164, 23}} + com.apple.InterfaceBuilder.CocoaPlugin + + {{375, 955}, {171, 23}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + {{522, 812}, {146, 23}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + {{436, 809}, {64, 6}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + {{915, 473}, {272, 83}} + com.apple.InterfaceBuilder.CocoaPlugin + + {{608, 612}, {275, 83}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + {{675, 493}, {240, 243}} + com.apple.InterfaceBuilder.CocoaPlugin + + {{144, 735}, {243, 243}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + {{915, 473}, {164, 43}} + com.apple.InterfaceBuilder.CocoaPlugin + + {{608, 612}, {167, 43}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + {{915, 473}, {238, 103}} + com.apple.InterfaceBuilder.CocoaPlugin + + {{608, 612}, {241, 103}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + {{835, 663}, {194, 73}} + com.apple.InterfaceBuilder.CocoaPlugin + + {{304, 905}, {197, 73}} + {{541, 736}, {426, 20}} + com.apple.InterfaceBuilder.CocoaPlugin + + {74, 862} + {{6, 836}, {430, 20}} + com.apple.InterfaceBuilder.CocoaPlugin + {{785, 693}, {231, 43}} + com.apple.InterfaceBuilder.CocoaPlugin + {{254, 935}, {234, 43}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{719, 693}, {173, 43}} + com.apple.InterfaceBuilder.CocoaPlugin + {{188, 935}, {176, 43}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + {{915, 473}, {212, 63}} + com.apple.InterfaceBuilder.CocoaPlugin + + {{608, 612}, {215, 63}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + {{553, 553}, {193, 183}} + com.apple.InterfaceBuilder.CocoaPlugin + + {{18, 653}, {200, 183}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + {{633, 533}, {196, 203}} + com.apple.InterfaceBuilder.CocoaPlugin + + {{102, 775}, {199, 203}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + + + + YES + + + YES + + + + + YES + + + YES + + + + 439 + + + + YES + + NSApplication + NSResponder + + IBFrameworkSource + AppKit.framework/Headers/NSApplication.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSApplicationScripting.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSColorPanel.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSHelpManager.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSPageLayout.h + + + + NSBrowser + NSControl + + IBFrameworkSource + AppKit.framework/Headers/NSBrowser.h + + + + NSControl + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSControl.h + + + + NSController + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSController.h + + + + NSDocument + NSObject + + YES + + YES + printDocument: + revertDocumentToSaved: + runPageLayout: + saveDocument: + saveDocumentAs: + saveDocumentTo: + + + YES + id + id + id + id + id + id + + + + YES + + YES + printDocument: + revertDocumentToSaved: + runPageLayout: + saveDocument: + saveDocumentAs: + saveDocumentTo: + + + YES + + printDocument: + id + + + revertDocumentToSaved: + id + + + runPageLayout: + id + + + saveDocument: + id + + + saveDocumentAs: + id + + + saveDocumentTo: + id + + + + + IBFrameworkSource + AppKit.framework/Headers/NSDocument.h + + + + NSDocument + + IBFrameworkSource + AppKit.framework/Headers/NSDocumentScripting.h + + + + NSDocumentController + NSObject + + YES + + YES + clearRecentDocuments: + newDocument: + openDocument: + saveAllDocuments: + + + YES + id + id + id + id + + + + YES + + YES + clearRecentDocuments: + newDocument: + openDocument: + saveAllDocuments: + + + YES + + clearRecentDocuments: + id + + + newDocument: + id + + + openDocument: + id + + + saveAllDocuments: + id + + + + + IBFrameworkSource + AppKit.framework/Headers/NSDocumentController.h + + + + NSFormatter + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFormatter.h + + + + NSMatrix + NSControl + + IBFrameworkSource + AppKit.framework/Headers/NSMatrix.h + + + + NSMenu + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSMenu.h + + + + NSMenuItem + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSMenuItem.h + + + + NSMovieView + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSMovieView.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSAccessibility.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSAlert.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSAnimation.h + + + + NSObject + + + + NSObject + + + + NSObject + + + + NSObject + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSComboBox.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSComboBoxCell.h + + + + NSObject + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSDatePickerCell.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSDictionaryController.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSDragging.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSDrawer.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSFontManager.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSFontPanel.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSImage.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSKeyValueBinding.h + + + + NSObject + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSNibLoading.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSOutlineView.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSPasteboard.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSRuleEditor.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSSavePanel.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSSound.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSSpeechRecognizer.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSSpeechSynthesizer.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSSplitView.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSTabView.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSTableView.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSText.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSTextStorage.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSTextView.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSTokenField.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSTokenFieldCell.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSToolbar.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSToolbarItem.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSView.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSWindow.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSClassDescription.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSConnection.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSMetadata.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSNetServices.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObjectScripting.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSPort.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSPortCoder.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptClassDescription.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptObjectSpecifiers.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptWhoseTests.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSSpellServer.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSStream.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLDownload.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSXMLParser.h + + + + NSObject + + IBFrameworkSource + Print.framework/Headers/PDEPluginInterface.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CAAnimation.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CALayer.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CIImageProvider.h + + + + NSResponder + + IBFrameworkSource + AppKit.framework/Headers/NSInterfaceStyle.h + + + + NSResponder + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSResponder.h + + + + NSTableView + NSControl + + + + NSText + NSView + + + + NSUserDefaultsController + NSController + + IBFrameworkSource + AppKit.framework/Headers/NSUserDefaultsController.h + + + + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSClipView.h + + + + NSView + + + + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSRulerView.h + + + + NSView + NSResponder + + + + NSWindow + + + + NSWindow + NSResponder + + + + NSWindow + + IBFrameworkSource + AppKit.framework/Headers/NSWindowScripting.h + + + + + 0 + IBCocoaFramework + + com.apple.InterfaceBuilder.CocoaPlugin.macosx + + + + com.apple.InterfaceBuilder.CocoaPlugin.macosx + + + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 + + + YES + ../../../../cef.xcodeproj + 3 + + YES + + YES + NSMenuCheckmark + NSMenuMixedState + + + YES + {9, 8} + {7, 2} + + + + diff --git a/cef3/tests/unittests/mac/Info.plist b/cef3/tests/unittests/mac/Info.plist new file mode 100644 index 000000000..3d5f27c20 --- /dev/null +++ b/cef3/tests/unittests/mac/Info.plist @@ -0,0 +1,28 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + unittests.icns + CFBundleIdentifier + org.cef.unittests + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleVersion + 1.0 + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/cef3/tests/unittests/mac/unittests.icns b/cef3/tests/unittests/mac/unittests.icns new file mode 100644 index 000000000..f36742de2 Binary files /dev/null and b/cef3/tests/unittests/mac/unittests.icns differ diff --git a/cef3/tests/unittests/navigation_unittest.cc b/cef3/tests/unittests/navigation_unittest.cc new file mode 100644 index 000000000..ba2c99a5b --- /dev/null +++ b/cef3/tests/unittests/navigation_unittest.cc @@ -0,0 +1,1561 @@ +// 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 +#include "include/cef_callback.h" +#include "include/cef_runnable.h" +#include "include/cef_scheme.h" +#include "tests/cefclient/client_app.h" +#include "tests/unittests/test_handler.h" +#include "tests/unittests/test_util.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +const char kHNav1[] = "http://tests-hnav/nav1.html"; +const char kHNav2[] = "http://tests-hnav/nav2.html"; +const char kHNav3[] = "http://tests-hnav/nav3.html"; +const char kHistoryNavMsg[] = "NavigationTest.HistoryNav"; + +enum NavAction { + NA_LOAD = 1, + NA_BACK, + NA_FORWARD, + NA_CLEAR +}; + +typedef struct { + NavAction action; // What to do + const char* target; // Where to be after navigation + bool can_go_back; // After navigation, can go back? + bool can_go_forward; // After navigation, can go forward? +} NavListItem; + +// Array of navigation actions: X = current page, . = history exists +static NavListItem kHNavList[] = { + // kHNav1 | kHNav2 | kHNav3 + {NA_LOAD, kHNav1, false, false}, // X + {NA_LOAD, kHNav2, true, false}, // . X + {NA_BACK, kHNav1, false, true}, // X . + {NA_FORWARD, kHNav2, true, false}, // . X + {NA_LOAD, kHNav3, true, false}, // . . X + {NA_BACK, kHNav2, true, true}, // . X . + // TODO(cef): Enable once ClearHistory is implemented + // {NA_CLEAR, kHNav2, false, false}, // X +}; + +#define NAV_LIST_SIZE() (sizeof(kHNavList) / sizeof(NavListItem)) + +bool g_history_nav_test = false; + +// Browser side. +class HistoryNavBrowserTest : public ClientApp::BrowserDelegate { + public: + HistoryNavBrowserTest() {} + + virtual void OnBeforeChildProcessLaunch( + CefRefPtr app, + CefRefPtr command_line) OVERRIDE { + if (!g_history_nav_test) + return; + + // Indicate to the render process that the test should be run. + command_line->AppendSwitchWithValue("test", kHistoryNavMsg); + } + + protected: + IMPLEMENT_REFCOUNTING(HistoryNavBrowserTest); +}; + +// Renderer side. +class HistoryNavRendererTest : public ClientApp::RenderDelegate { + public: + HistoryNavRendererTest() + : run_test_(false), + nav_(0) {} + + virtual void OnRenderThreadCreated( + CefRefPtr app, + CefRefPtr extra_info) OVERRIDE { + if (!g_history_nav_test) { + // Check that the test should be run. + CefRefPtr command_line = + CefCommandLine::GetGlobalCommandLine(); + const std::string& test = command_line->GetSwitchValue("test"); + if (test != kHistoryNavMsg) + return; + } + + run_test_ = true; + } + + virtual bool OnBeforeNavigation(CefRefPtr app, + CefRefPtr browser, + CefRefPtr frame, + CefRefPtr request, + cef_navigation_type_t navigation_type, + bool is_redirect) OVERRIDE { + if (!run_test_) + return false; + + const NavListItem& item = kHNavList[nav_]; + + std::string url = request->GetURL(); + EXPECT_STREQ(item.target, url.c_str()); + + if (item.action == NA_LOAD) + EXPECT_EQ(NAVIGATION_OTHER, navigation_type); + else if (item.action == NA_BACK || item.action == NA_FORWARD) + EXPECT_EQ(NAVIGATION_BACK_FORWARD, navigation_type); + + if (nav_ > 0) { + const NavListItem& last_item = kHNavList[nav_ - 1]; + EXPECT_EQ(last_item.can_go_back, browser->CanGoBack()); + EXPECT_EQ(last_item.can_go_forward, browser->CanGoForward()); + } else { + EXPECT_FALSE(browser->CanGoBack()); + EXPECT_FALSE(browser->CanGoForward()); + } + + SendTestResults(browser); + nav_++; + + return false; + } + + protected: + // Send the test results. + void SendTestResults(CefRefPtr browser) { + // Check if the test has failed. + bool result = !TestFailed(); + + // Return the result to the browser process. + CefRefPtr return_msg = + CefProcessMessage::Create(kHistoryNavMsg); + CefRefPtr args = return_msg->GetArgumentList(); + EXPECT_TRUE(args.get()); + EXPECT_TRUE(args->SetInt(0, nav_)); + EXPECT_TRUE(args->SetBool(1, result)); + EXPECT_TRUE(browser->SendProcessMessage(PID_BROWSER, return_msg)); + } + + bool run_test_; + int nav_; + + IMPLEMENT_REFCOUNTING(HistoryNavRendererTest); +}; + +// Browser side. +class HistoryNavTestHandler : public TestHandler { + public: + HistoryNavTestHandler() + : nav_(0), + load_end_confirmation_(false), + renderer_confirmation_(false) {} + + virtual void RunTest() OVERRIDE { + // Add the resources that we will navigate to/from. + AddResource(kHNav1, "Nav1", "text/html"); + AddResource(kHNav2, "Nav2", "text/html"); + AddResource(kHNav3, "Nav3", "text/html"); + + // Create the browser. + CreateBrowser(CefString()); + } + + void RunNav(CefRefPtr browser) { + if (nav_ == NAV_LIST_SIZE()) { + // End of the nav list. + DestroyTest(); + return; + } + + const NavListItem& item = kHNavList[nav_]; + + // Perform the action. + switch (item.action) { + case NA_LOAD: + browser->GetMainFrame()->LoadURL(item.target); + break; + case NA_BACK: + browser->GoBack(); + break; + case NA_FORWARD: + browser->GoForward(); + break; + case NA_CLEAR: + // TODO(cef): Enable once ClearHistory is implemented + // browser->GetHost()->ClearHistory(); + // Not really a navigation action so go to the next one. + nav_++; + RunNav(browser); + break; + default: + break; + } + } + + void RunNextNavIfReady(CefRefPtr browser) { + if (load_end_confirmation_ && renderer_confirmation_) { + load_end_confirmation_ = false; + renderer_confirmation_ = false; + nav_++; + RunNav(browser); + } + } + + virtual void OnAfterCreated(CefRefPtr browser) OVERRIDE { + TestHandler::OnAfterCreated(browser); + + RunNav(browser); + } + + virtual bool OnBeforeResourceLoad(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr request) OVERRIDE { + const NavListItem& item = kHNavList[nav_]; + + got_before_resource_load_[nav_].yes(); + + std::string url = request->GetURL(); + if (url == item.target) + got_correct_target_[nav_].yes(); + + return false; + } + + virtual void OnLoadingStateChange(CefRefPtr browser, + bool isLoading, + bool canGoBack, + bool canGoForward) OVERRIDE { + const NavListItem& item = kHNavList[nav_]; + + got_loading_state_change_[nav_].yes(); + + if (item.can_go_back == canGoBack) + got_correct_can_go_back_[nav_].yes(); + if (item.can_go_forward == canGoForward) + got_correct_can_go_forward_[nav_].yes(); + } + + virtual void OnLoadStart(CefRefPtr browser, + CefRefPtr frame) OVERRIDE { + if(browser->IsPopup() || !frame->IsMain()) + return; + + const NavListItem& item = kHNavList[nav_]; + + got_load_start_[nav_].yes(); + + std::string url1 = browser->GetMainFrame()->GetURL(); + std::string url2 = frame->GetURL(); + if (url1 == item.target && url2 == item.target) + got_correct_load_start_url_[nav_].yes(); + } + + virtual void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) OVERRIDE { + if (browser->IsPopup() || !frame->IsMain()) + return; + + const NavListItem& item = kHNavList[nav_]; + + got_load_end_[nav_].yes(); + + std::string url1 = browser->GetMainFrame()->GetURL(); + std::string url2 = frame->GetURL(); + if (url1 == item.target && url2 == item.target) + got_correct_load_end_url_[nav_].yes(); + + if (item.can_go_back == browser->CanGoBack()) + got_correct_can_go_back2_[nav_].yes(); + if (item.can_go_forward == browser->CanGoForward()) + got_correct_can_go_forward2_[nav_].yes(); + + load_end_confirmation_ = true; + RunNextNavIfReady(browser); + } + + virtual bool OnProcessMessageReceived( + CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) OVERRIDE { + if (message->GetName().ToString() == kHistoryNavMsg) { + got_before_navigation_[nav_].yes(); + + // Test that the renderer side succeeded. + CefRefPtr args = message->GetArgumentList(); + EXPECT_TRUE(args.get()); + EXPECT_EQ(nav_, args->GetInt(0)); + EXPECT_TRUE(args->GetBool(1)); + + renderer_confirmation_ = true; + RunNextNavIfReady(browser); + return true; + } + + // Message not handled. + return false; + } + + int nav_; + bool load_end_confirmation_; + bool renderer_confirmation_; + + TrackCallback got_before_navigation_[NAV_LIST_SIZE()]; + TrackCallback got_before_resource_load_[NAV_LIST_SIZE()]; + TrackCallback got_correct_target_[NAV_LIST_SIZE()]; + TrackCallback got_loading_state_change_[NAV_LIST_SIZE()]; + TrackCallback got_correct_can_go_back_[NAV_LIST_SIZE()]; + TrackCallback got_correct_can_go_forward_[NAV_LIST_SIZE()]; + TrackCallback got_load_start_[NAV_LIST_SIZE()]; + TrackCallback got_correct_load_start_url_[NAV_LIST_SIZE()]; + TrackCallback got_load_end_[NAV_LIST_SIZE()]; + TrackCallback got_correct_load_end_url_[NAV_LIST_SIZE()]; + TrackCallback got_correct_can_go_back2_[NAV_LIST_SIZE()]; + TrackCallback got_correct_can_go_forward2_[NAV_LIST_SIZE()]; +}; + +} // namespace + +// Verify history navigation. +TEST(NavigationTest, History) { + g_history_nav_test = true; + CefRefPtr handler = + new HistoryNavTestHandler(); + handler->ExecuteTest(); + g_history_nav_test = false; + + for (size_t i = 0; i < NAV_LIST_SIZE(); ++i) { + if (kHNavList[i].action != NA_CLEAR) { + ASSERT_TRUE(handler->got_before_navigation_[i]) << "i = " << i; + ASSERT_TRUE(handler->got_before_resource_load_[i]) << "i = " << i; + ASSERT_TRUE(handler->got_correct_target_[i]) << "i = " << i; + ASSERT_TRUE(handler->got_load_start_[i]) << "i = " << i; + ASSERT_TRUE(handler->got_correct_load_start_url_[i]) << "i = " << i; + } + + ASSERT_TRUE(handler->got_loading_state_change_[i]) << "i = " << i; + ASSERT_TRUE(handler->got_correct_can_go_back_[i]) << "i = " << i; + ASSERT_TRUE(handler->got_correct_can_go_forward_[i]) << "i = " << i; + + if (kHNavList[i].action != NA_CLEAR) { + ASSERT_TRUE(handler->got_load_end_[i]) << "i = " << i; + ASSERT_TRUE(handler->got_correct_load_end_url_[i]) << "i = " << i; + ASSERT_TRUE(handler->got_correct_can_go_back2_[i]) << "i = " << i; + ASSERT_TRUE(handler->got_correct_can_go_forward2_[i]) << "i = " << i; + } + } +} + + +namespace { + +const char kFNav1[] = "http://tests/nav1.html"; +const char kFNav2[] = "http://tests/nav2.html"; +const char kFNav3[] = "http://tests/nav3.html"; + +class FrameNameIdentNavTestHandler : public TestHandler { + public: + FrameNameIdentNavTestHandler() : browse_ct_(0) {} + + virtual void RunTest() OVERRIDE { + // Add the frame resources. + std::stringstream ss; + + // Page with named frame + ss << "Nav1" + "", "text/html"); + AddResource(kV8ContextChildTestUrl, "" + "CHILD", + "text/html"); + CreateBrowser(kV8ContextParentTestUrl); + } else if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION || + test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) { + AddResource(kV8OnUncaughtExceptionTestUrl, "" + "

OnUncaughtException

" + "\n" + "\n", + "text/html"); + CreateBrowser(kV8OnUncaughtExceptionTestUrl); + } else if (test_mode_ == V8TEST_WORKER_BINDING) { + AddResource(kV8WorkerParentTestUrl, "" + "" + "", "text/html"); + AddResource(kV8WorkerTestUrl, + "function cb() { self.close(); return true; }\n" + "self.run_async(cb);", + "application/javascript"); + CreateBrowser(kV8WorkerParentTestUrl); + } else if (test_mode_ == V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION || + test_mode_ == V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) { + AddResource(kV8WorkerParentTestUrl, "" + "" + "", "text/html"); + AddResource(kV8WorkerTestUrl, + "function test(){ test2(); }\n" + "function test2(){ asd(); }\n" + "self.onmessage = function(event) { self.setTimeout(test, 0); }", + "application/javascript"); + CreateBrowser(kV8WorkerParentTestUrl); + } else { + EXPECT_TRUE(test_url_ != NULL); + AddResource(test_url_, "" + "TEST", "text/html"); + CreateBrowser(test_url_); + } + } + + virtual void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) OVERRIDE { + if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS || + test_mode_ == V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) { + if (browser->IsPopup()) { + EXPECT_STREQ( + GetBrowser()->GetHost()->GetDevToolsURL(true).ToString().c_str(), + frame->GetURL().ToString().c_str()); + CefRefPtr return_msg = + CefProcessMessage::Create(kV8DevToolsLoadHookMsg); + EXPECT_TRUE(browser->SendProcessMessage(PID_RENDERER, return_msg)); + } else { + // Send the DevTools url message only for the main browser. + CefRefPtr return_msg = + CefProcessMessage::Create(kV8DevToolsURLMsg); + EXPECT_TRUE(return_msg->GetArgumentList()->SetString(0, + browser->GetHost()->GetDevToolsURL(true))); + EXPECT_TRUE(browser->SendProcessMessage(PID_RENDERER, return_msg)); + } + } else { + const std::string& url = frame->GetURL(); + if (url != kV8NavTestUrl && + url.find("http://tests/") != std::string::npos) { + // Run the test. + CefRefPtr return_msg = + CefProcessMessage::Create(kV8RunTestMsg); + EXPECT_TRUE(browser->SendProcessMessage(PID_RENDERER, return_msg)); + } + } + } + + virtual bool OnProcessMessageReceived( + CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) OVERRIDE { + EXPECT_TRUE(browser.get()); + EXPECT_EQ(PID_RENDERER, source_process); + EXPECT_TRUE(message.get()); + EXPECT_TRUE(message->IsReadOnly()); + + got_message_.yes(); + + if (message->GetArgumentList()->GetBool(0)) + got_success_.yes(); + + // Test is complete. + DestroyTest(); + + return true; + } + + V8TestMode test_mode_; + const char* test_url_; + TrackCallback got_message_; + TrackCallback got_success_; +}; + +} // namespace + + +// Entry point for creating V8 browser test objects. +// Called from client_app_delegates.cc. +void CreateV8BrowserTests(ClientApp::BrowserDelegateSet& delegates) { + delegates.insert(new V8BrowserTest); +} + +// Entry point for creating V8 renderer test objects. +// Called from client_app_delegates.cc. +void CreateV8RendererTests(ClientApp::RenderDelegateSet& delegates) { + delegates.insert(new V8RendererTest); +} + + +// Helpers for defining V8 tests. +#define V8_TEST_EX(name, test_mode, test_url) \ + TEST(V8Test, name) { \ + g_current_test_mode = test_mode; \ + CefRefPtr handler = \ + new V8TestHandler(test_mode, test_url); \ + handler->ExecuteTest(); \ + EXPECT_TRUE(handler->got_message_); \ + EXPECT_TRUE(handler->got_success_); \ + g_current_test_mode = V8TEST_NONE; \ + } + +#define V8_TEST(name, test_mode) \ + V8_TEST_EX(name, test_mode, kV8TestUrl) + + +// Define the tests. +V8_TEST(NullCreate, V8TEST_NULL_CREATE); +V8_TEST(BoolCreate, V8TEST_BOOL_CREATE); +V8_TEST(IntCreate, V8TEST_INT_CREATE); +V8_TEST(UIntCreate, V8TEST_UINT_CREATE); +V8_TEST(DoubleCreate, V8TEST_DOUBLE_CREATE); +V8_TEST(DateCreate, V8TEST_DATE_CREATE); +V8_TEST(StringCreate, V8TEST_STRING_CREATE); +V8_TEST(ArrayCreate, V8TEST_ARRAY_CREATE); +V8_TEST(ArrayValue, V8TEST_ARRAY_VALUE); +V8_TEST(ObjectCreate, V8TEST_OBJECT_CREATE); +V8_TEST(ObjectUserData, V8TEST_OBJECT_USERDATA); +V8_TEST(ObjectAccessor, V8TEST_OBJECT_ACCESSOR); +V8_TEST(ObjectAccessorException, V8TEST_OBJECT_ACCESSOR_EXCEPTION); +V8_TEST(ObjectAccessorFail, V8TEST_OBJECT_ACCESSOR_FAIL); +V8_TEST(ObjectAccessorReadOnly, V8TEST_OBJECT_ACCESSOR_READONLY); +V8_TEST(ObjectValue, V8TEST_OBJECT_VALUE); +V8_TEST(ObjectValueReadOnly, V8TEST_OBJECT_VALUE_READONLY); +V8_TEST(ObjectValueEnum, V8TEST_OBJECT_VALUE_ENUM); +V8_TEST(ObjectValueDontEnum, V8TEST_OBJECT_VALUE_DONTENUM); +V8_TEST(ObjectValueDelete, V8TEST_OBJECT_VALUE_DELETE); +V8_TEST(ObjectValueDontDelete, V8TEST_OBJECT_VALUE_DONTDELETE); +V8_TEST(ObjectValueEmptyKey, V8TEST_OBJECT_VALUE_EMPTYKEY); +V8_TEST(FunctionCreate, V8TEST_FUNCTION_CREATE); +V8_TEST(FunctionHandler, V8TEST_FUNCTION_HANDLER); +V8_TEST(FunctionHandlerException, V8TEST_FUNCTION_HANDLER_EXCEPTION); +V8_TEST(FunctionHandlerFail, V8TEST_FUNCTION_HANDLER_FAIL); +V8_TEST(FunctionHandlerNoObject, V8TEST_FUNCTION_HANDLER_NO_OBJECT); +V8_TEST(FunctionHandlerWithContext, V8TEST_FUNCTION_HANDLER_WITH_CONTEXT); +V8_TEST(ContextEval, V8TEST_CONTEXT_EVAL); +V8_TEST(ContextEvalException, V8TEST_CONTEXT_EVAL_EXCEPTION); +V8_TEST_EX(ContextEntered, V8TEST_CONTEXT_ENTERED, NULL); +V8_TEST(ContextInvalid, V8TEST_CONTEXT_INVALID); +V8_TEST_EX(Binding, V8TEST_BINDING, kV8BindingTestUrl); +V8_TEST(StackTrace, V8TEST_STACK_TRACE); +V8_TEST(OnUncaughtException, V8TEST_ON_UNCAUGHT_EXCEPTION); +V8_TEST(OnUncaughtExceptionDevTools, V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS); +V8_TEST(Extension, V8TEST_EXTENSION); +V8_TEST(WorkerBinding, V8TEST_WORKER_BINDING); +V8_TEST(WorkerOnUncaughtException, V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION); +V8_TEST(WorkerOnUncaughtExceptionDevTools, + V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS); diff --git a/cef3/tests/unittests/values_unittest.cc b/cef3/tests/unittests/values_unittest.cc new file mode 100644 index 000000000..46ec3dc91 --- /dev/null +++ b/cef3/tests/unittests/values_unittest.cc @@ -0,0 +1,734 @@ +// Copyright (c) 2013 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 "include/cef_task.h" +#include "include/cef_values.h" +#include "tests/unittests/test_handler.h" +#include "tests/unittests/test_util.h" +#include "testing/gtest/include/gtest/gtest.h" + + +namespace { + +// Dictionary test keys. +const char* kNullKey = "null_key"; +const char* kBoolKey = "bool_key"; +const char* kIntKey = "int_key"; +const char* kDoubleKey = "double_key"; +const char* kStringKey = "string_key"; +const char* kBinaryKey = "binary_key"; +const char* kDictionaryKey = "dict_key"; +const char* kListKey = "list_key"; + +// List test indexes. +enum { + kNullIndex = 0, + kBoolIndex, + kIntIndex, + kDoubleIndex, + kStringIndex, + kBinaryIndex, + kDictionaryIndex, + kListIndex, +}; + +// Dictionary/list test values. +const bool kBoolValue = true; +const int kIntValue = 12; +const double kDoubleValue = 4.5432; +const char* kStringValue = "My string value"; + + +// BINARY TEST HELPERS + +// Test a binary value. +void TestBinary(CefRefPtr value, char* data, size_t data_size) { + // Testing requires strings longer than 15 characters. + EXPECT_GT(data_size, (size_t)15); + + EXPECT_EQ(data_size, value->GetSize()); + + char* buff = new char[data_size+1]; + char old_char; + + // Test full read. + memset(buff, 0, data_size+1); + EXPECT_EQ(data_size, value->GetData(buff, data_size, 0)); + EXPECT_TRUE(!strcmp(buff, data)); + + // Test partial read with offset. + memset(buff, 0, data_size+1); + old_char = data[15]; + data[15] = 0; + EXPECT_EQ((size_t)10, value->GetData(buff, 10, 5)); + EXPECT_TRUE(!strcmp(buff, data+5)); + data[15] = old_char; + + // Test that changes to the original data have no effect. + memset(buff, 0, data_size+1); + old_char = data[0]; + data[0] = '.'; + EXPECT_EQ((size_t)1, value->GetData(buff, 1, 0)); + EXPECT_EQ(old_char, buff[0]); + data[0] = old_char; + + // Test copy. + CefRefPtr copy = value->Copy(); + TestBinaryEqual(copy, value); + + delete [] buff; +} + +// Used to test access of binary data on a different thread. +class BinaryTask : public CefTask { + public: + BinaryTask(CefRefPtr value, char* data, size_t data_size) + : value_(value), + data_(data), + data_size_(data_size) {} + + virtual void Execute() OVERRIDE { + TestBinary(value_, data_, data_size_); + } + + private: + CefRefPtr value_; + char* data_; + size_t data_size_; + + IMPLEMENT_REFCOUNTING(BinaryTask); +}; + + +// DICTIONARY TEST HELPERS + +// Test dictionary null value. +void TestDictionaryNull(CefRefPtr value) { + EXPECT_FALSE(value->HasKey(kNullKey)); + EXPECT_TRUE(value->SetNull(kNullKey)); + EXPECT_TRUE(value->HasKey(kNullKey)); + EXPECT_EQ(VTYPE_NULL, value->GetType(kNullKey)); +} + +// Test dictionary bool value. +void TestDictionaryBool(CefRefPtr value) { + EXPECT_FALSE(value->HasKey(kBoolKey)); + EXPECT_TRUE(value->SetBool(kBoolKey, kBoolValue)); + EXPECT_TRUE(value->HasKey(kBoolKey)); + EXPECT_EQ(VTYPE_BOOL, value->GetType(kBoolKey)); + EXPECT_EQ(kBoolValue, value->GetBool(kBoolKey)); +} + +// Test dictionary int value. +void TestDictionaryInt(CefRefPtr value) { + EXPECT_FALSE(value->HasKey(kIntKey)); + EXPECT_TRUE(value->SetInt(kIntKey, kIntValue)); + EXPECT_TRUE(value->HasKey(kIntKey)); + EXPECT_EQ(VTYPE_INT, value->GetType(kIntKey)); + EXPECT_EQ(kIntValue, value->GetInt(kIntKey)); +} + +// Test dictionary double value. +void TestDictionaryDouble(CefRefPtr value) { + EXPECT_FALSE(value->HasKey(kDoubleKey)); + EXPECT_TRUE(value->SetDouble(kDoubleKey, kDoubleValue)); + EXPECT_TRUE(value->HasKey(kDoubleKey)); + EXPECT_EQ(VTYPE_DOUBLE, value->GetType(kDoubleKey)); + EXPECT_EQ(kDoubleValue, value->GetDouble(kDoubleKey)); +} + +// Test dictionary string value. +void TestDictionaryString(CefRefPtr value) { + EXPECT_FALSE(value->HasKey(kStringKey)); + EXPECT_TRUE(value->SetString(kStringKey, kStringValue)); + EXPECT_TRUE(value->HasKey(kStringKey)); + EXPECT_EQ(VTYPE_STRING, value->GetType(kStringKey)); + EXPECT_EQ(kStringValue, value->GetString(kStringKey).ToString()); +} + +// Test dictionary binary value. +void TestDictionaryBinary(CefRefPtr value, + char* binary_data, size_t binary_data_size, + CefRefPtr& binary_value) { + binary_value = CefBinaryValue::Create(binary_data, binary_data_size); + EXPECT_TRUE(binary_value.get()); + EXPECT_TRUE(binary_value->IsValid()); + EXPECT_FALSE(binary_value->IsOwned()); + EXPECT_FALSE(value->HasKey(kBinaryKey)); + EXPECT_TRUE(value->SetBinary(kBinaryKey, binary_value)); + EXPECT_FALSE(binary_value->IsValid()); // Value should be detached + EXPECT_TRUE(value->HasKey(kBinaryKey)); + EXPECT_EQ(VTYPE_BINARY, value->GetType(kBinaryKey)); + binary_value = value->GetBinary(kBinaryKey); + EXPECT_TRUE(binary_value.get()); + EXPECT_TRUE(binary_value->IsValid()); + EXPECT_TRUE(binary_value->IsOwned()); + TestBinary(binary_value, binary_data, binary_data_size); +} + +// Test dictionary dictionary value. +void TestDictionaryDictionary(CefRefPtr value, + CefRefPtr& dictionary_value) { + dictionary_value = CefDictionaryValue::Create(); + EXPECT_TRUE(dictionary_value.get()); + EXPECT_TRUE(dictionary_value->IsValid()); + EXPECT_FALSE(dictionary_value->IsOwned()); + EXPECT_FALSE(dictionary_value->IsReadOnly()); + EXPECT_TRUE(dictionary_value->SetInt(kIntKey, kIntValue)); + EXPECT_EQ((size_t)1, dictionary_value->GetSize()); + EXPECT_FALSE(value->HasKey(kDictionaryKey)); + EXPECT_TRUE(value->SetDictionary(kDictionaryKey, dictionary_value)); + EXPECT_FALSE(dictionary_value->IsValid()); // Value should be detached + EXPECT_TRUE(value->HasKey(kDictionaryKey)); + EXPECT_EQ(VTYPE_DICTIONARY, value->GetType(kDictionaryKey)); + dictionary_value = value->GetDictionary(kDictionaryKey); + EXPECT_TRUE(dictionary_value.get()); + EXPECT_TRUE(dictionary_value->IsValid()); + EXPECT_TRUE(dictionary_value->IsOwned()); + EXPECT_FALSE(dictionary_value->IsReadOnly()); + EXPECT_EQ((size_t)1, dictionary_value->GetSize()); + EXPECT_EQ(kIntValue, dictionary_value->GetInt(kIntKey)); +} + +// Test dictionary list value. +void TestDictionaryList(CefRefPtr value, + CefRefPtr& list_value) { + list_value = CefListValue::Create(); + EXPECT_TRUE(list_value.get()); + EXPECT_TRUE(list_value->IsValid()); + EXPECT_FALSE(list_value->IsOwned()); + EXPECT_FALSE(list_value->IsReadOnly()); + EXPECT_TRUE(list_value->SetInt(0, kIntValue)); + EXPECT_EQ((size_t)1, list_value->GetSize()); + EXPECT_FALSE(value->HasKey(kListKey)); + EXPECT_TRUE(value->SetList(kListKey, list_value)); + EXPECT_FALSE(list_value->IsValid()); // Value should be detached + EXPECT_TRUE(value->HasKey(kListKey)); + EXPECT_EQ(VTYPE_LIST, value->GetType(kListKey)); + list_value = value->GetList(kListKey); + EXPECT_TRUE(list_value.get()); + EXPECT_TRUE(list_value->IsValid()); + EXPECT_TRUE(list_value->IsOwned()); + EXPECT_FALSE(list_value->IsReadOnly()); + EXPECT_EQ((size_t)1, list_value->GetSize()); + EXPECT_EQ(kIntValue, list_value->GetInt(0)); +} + +// Test dictionary value. +void TestDictionary(CefRefPtr value, + char* binary_data, size_t binary_data_size) { + CefRefPtr binary_value; + CefRefPtr dictionary_value; + CefRefPtr list_value; + + // Test the size. + EXPECT_EQ((size_t)0, value->GetSize()); + + TestDictionaryNull(value); + TestDictionaryBool(value); + TestDictionaryInt(value); + TestDictionaryDouble(value); + TestDictionaryString(value); + TestDictionaryBinary(value, binary_data, binary_data_size, binary_value); + TestDictionaryDictionary(value, dictionary_value); + TestDictionaryList(value, list_value); + + // Test the size. + EXPECT_EQ((size_t)8, value->GetSize()); + + // Test copy. + CefRefPtr copy = value->Copy(false); + TestDictionaryEqual(value, copy); + + // Test removal. + EXPECT_TRUE(value->Remove(kNullKey)); + EXPECT_FALSE(value->HasKey(kNullKey)); + + EXPECT_TRUE(value->Remove(kBoolKey)); + EXPECT_FALSE(value->HasKey(kBoolKey)); + + EXPECT_TRUE(value->Remove(kIntKey)); + EXPECT_FALSE(value->HasKey(kIntKey)); + + EXPECT_TRUE(value->Remove(kDoubleKey)); + EXPECT_FALSE(value->HasKey(kDoubleKey)); + + EXPECT_TRUE(value->Remove(kStringKey)); + EXPECT_FALSE(value->HasKey(kStringKey)); + + EXPECT_TRUE(value->Remove(kBinaryKey)); + EXPECT_FALSE(value->HasKey(kBinaryKey)); + EXPECT_FALSE(binary_value->IsValid()); // Value should be detached + + EXPECT_TRUE(value->Remove(kDictionaryKey)); + EXPECT_FALSE(value->HasKey(kDictionaryKey)); + EXPECT_FALSE(dictionary_value->IsValid()); // Value should be detached + + EXPECT_TRUE(value->Remove(kListKey)); + EXPECT_FALSE(value->HasKey(kListKey)); + EXPECT_FALSE(list_value->IsValid()); // Value should be detached + + // Test the size. + EXPECT_EQ((size_t)0, value->GetSize()); + + // Re-add some values. + TestDictionaryNull(value); + TestDictionaryBool(value); + TestDictionaryDictionary(value, dictionary_value); + + // Test the size. + EXPECT_EQ((size_t)3, value->GetSize()); + + // Clear the values. + EXPECT_TRUE(value->Clear()); + EXPECT_EQ((size_t)0, value->GetSize()); + EXPECT_FALSE(dictionary_value->IsValid()); // Value should be detached +} + +// Used to test access of dictionary data on a different thread. +class DictionaryTask : public CefTask { + public: + DictionaryTask(CefRefPtr value, char* binary_data, + size_t binary_data_size) + : value_(value), + binary_data_(binary_data), + binary_data_size_(binary_data_size) {} + + virtual void Execute() OVERRIDE { + TestDictionary(value_, binary_data_, binary_data_size_); + } + + private: + CefRefPtr value_; + char* binary_data_; + size_t binary_data_size_; + + IMPLEMENT_REFCOUNTING(DictionaryTask); +}; + + +// LIST TEST HELPERS + +// Test list null value. +void TestListNull(CefRefPtr value, int index) { + CefValueType type = value->GetType(index); + EXPECT_TRUE(type == VTYPE_INVALID || type == VTYPE_NULL); + + EXPECT_TRUE(value->SetNull(index)); + EXPECT_EQ(VTYPE_NULL, value->GetType(index)); +} + +// Test list bool value. +void TestListBool(CefRefPtr value, int index) { + CefValueType type = value->GetType(index); + EXPECT_TRUE(type == VTYPE_INVALID || type == VTYPE_NULL); + + EXPECT_TRUE(value->SetBool(index, kBoolValue)); + EXPECT_EQ(VTYPE_BOOL, value->GetType(index)); + EXPECT_EQ(kBoolValue, value->GetBool(index)); +} + +// Test list int value. +void TestListInt(CefRefPtr value, int index) { + CefValueType type = value->GetType(index); + EXPECT_TRUE(type == VTYPE_INVALID || type == VTYPE_NULL); + + EXPECT_TRUE(value->SetInt(index, kIntValue)); + EXPECT_EQ(VTYPE_INT, value->GetType(index)); + EXPECT_EQ(kIntValue, value->GetInt(index)); +} + +// Test list double value. +void TestListDouble(CefRefPtr value, int index) { + CefValueType type = value->GetType(index); + EXPECT_TRUE(type == VTYPE_INVALID || type == VTYPE_NULL); + + EXPECT_TRUE(value->SetDouble(index, kDoubleValue)); + EXPECT_EQ(VTYPE_DOUBLE, value->GetType(index)); + EXPECT_EQ(kDoubleValue, value->GetDouble(index)); +} + +// Test list string value. +void TestListString(CefRefPtr value, int index) { + CefValueType type = value->GetType(index); + EXPECT_TRUE(type == VTYPE_INVALID || type == VTYPE_NULL); + + EXPECT_TRUE(value->SetString(index, kStringValue)); + EXPECT_EQ(VTYPE_STRING, value->GetType(index)); + EXPECT_EQ(kStringValue, value->GetString(index).ToString()); +} + +// Test list binary value. +void TestListBinary(CefRefPtr value, int index, + char* binary_data, size_t binary_data_size, + CefRefPtr& binary_value) { + binary_value = CefBinaryValue::Create(binary_data, binary_data_size); + EXPECT_TRUE(binary_value.get()); + EXPECT_TRUE(binary_value->IsValid()); + EXPECT_FALSE(binary_value->IsOwned()); + + CefValueType type = value->GetType(index); + EXPECT_TRUE(type == VTYPE_INVALID || type == VTYPE_NULL); + + EXPECT_TRUE(value->SetBinary(index, binary_value)); + EXPECT_FALSE(binary_value->IsValid()); // Value should be detached + EXPECT_EQ(VTYPE_BINARY, value->GetType(index)); + binary_value = value->GetBinary(index); + EXPECT_TRUE(binary_value.get()); + EXPECT_TRUE(binary_value->IsValid()); + EXPECT_TRUE(binary_value->IsOwned()); + TestBinary(binary_value, binary_data, binary_data_size); +} + +// Test list dictionary value. +void TestListDictionary(CefRefPtr value, int index, + CefRefPtr& dictionary_value) { + dictionary_value = CefDictionaryValue::Create(); + EXPECT_TRUE(dictionary_value.get()); + EXPECT_TRUE(dictionary_value->IsValid()); + EXPECT_FALSE(dictionary_value->IsOwned()); + EXPECT_FALSE(dictionary_value->IsReadOnly()); + EXPECT_TRUE(dictionary_value->SetInt(kIntKey, kIntValue)); + EXPECT_EQ((size_t)1, dictionary_value->GetSize()); + + CefValueType type = value->GetType(index); + EXPECT_TRUE(type == VTYPE_INVALID || type == VTYPE_NULL); + + EXPECT_TRUE(value->SetDictionary(index, dictionary_value)); + EXPECT_FALSE(dictionary_value->IsValid()); // Value should be detached + EXPECT_EQ(VTYPE_DICTIONARY, value->GetType(index)); + dictionary_value = value->GetDictionary(index); + EXPECT_TRUE(dictionary_value.get()); + EXPECT_TRUE(dictionary_value->IsValid()); + EXPECT_TRUE(dictionary_value->IsOwned()); + EXPECT_FALSE(dictionary_value->IsReadOnly()); + EXPECT_EQ((size_t)1, dictionary_value->GetSize()); + EXPECT_EQ(kIntValue, dictionary_value->GetInt(kIntKey)); +} + +// Test list list value. +void TestListList(CefRefPtr value, int index, + CefRefPtr& list_value) { + list_value = CefListValue::Create(); + EXPECT_TRUE(list_value.get()); + EXPECT_TRUE(list_value->IsValid()); + EXPECT_FALSE(list_value->IsOwned()); + EXPECT_FALSE(list_value->IsReadOnly()); + EXPECT_TRUE(list_value->SetInt(0, kIntValue)); + EXPECT_EQ((size_t)1, list_value->GetSize()); + + CefValueType type = value->GetType(index); + EXPECT_TRUE(type == VTYPE_INVALID || type == VTYPE_NULL); + + EXPECT_TRUE(value->SetList(index, list_value)); + EXPECT_FALSE(list_value->IsValid()); // Value should be detached + EXPECT_EQ(VTYPE_LIST, value->GetType(index)); + list_value = value->GetList(index); + EXPECT_TRUE(list_value.get()); + EXPECT_TRUE(list_value->IsValid()); + EXPECT_TRUE(list_value->IsOwned()); + EXPECT_FALSE(list_value->IsReadOnly()); + EXPECT_EQ((size_t)1, list_value->GetSize()); + EXPECT_EQ(kIntValue, list_value->GetInt(0)); +} + +// Test list value. +void TestList(CefRefPtr value, + char* binary_data, size_t binary_data_size) { + CefRefPtr binary_value; + CefRefPtr dictionary_value; + CefRefPtr list_value; + + // Test the size. + EXPECT_EQ((size_t)0, value->GetSize()); + + // Set the size. + EXPECT_TRUE(value->SetSize(8)); + EXPECT_EQ((size_t)8, value->GetSize()); + + EXPECT_EQ(VTYPE_NULL, value->GetType(kNullIndex)); + TestListNull(value, kNullIndex); + EXPECT_EQ(VTYPE_NULL, value->GetType(kBoolIndex)); + TestListBool(value, kBoolIndex); + EXPECT_EQ(VTYPE_NULL, value->GetType(kIntIndex)); + TestListInt(value, kIntIndex); + EXPECT_EQ(VTYPE_NULL, value->GetType(kDoubleIndex)); + TestListDouble(value, kDoubleIndex); + EXPECT_EQ(VTYPE_NULL, value->GetType(kStringIndex)); + TestListString(value, kStringIndex); + EXPECT_EQ(VTYPE_NULL, value->GetType(kBinaryIndex)); + TestListBinary(value, kBinaryIndex, binary_data, binary_data_size, + binary_value); + EXPECT_EQ(VTYPE_NULL, value->GetType(kDictionaryIndex)); + TestListDictionary(value, kDictionaryIndex, dictionary_value); + EXPECT_EQ(VTYPE_NULL, value->GetType(kListIndex)); + TestListList(value, kListIndex, list_value); + + // Test the size. + EXPECT_EQ((size_t)8, value->GetSize()); + + // Test copy. + CefRefPtr copy = value->Copy(); + TestListEqual(value, copy); + + // Test removal (in reverse order so indexes stay valid). + EXPECT_TRUE(value->Remove(kListIndex)); + EXPECT_EQ((size_t)7, value->GetSize()); + EXPECT_FALSE(list_value->IsValid()); // Value should be detached + + EXPECT_TRUE(value->Remove(kDictionaryIndex)); + EXPECT_EQ((size_t)6, value->GetSize()); + EXPECT_FALSE(dictionary_value->IsValid()); // Value should be detached + + EXPECT_TRUE(value->Remove(kBinaryIndex)); + EXPECT_EQ((size_t)5, value->GetSize()); + EXPECT_FALSE(binary_value->IsValid()); // Value should be detached + + EXPECT_TRUE(value->Remove(kStringIndex)); + EXPECT_EQ((size_t)4, value->GetSize()); + + EXPECT_TRUE(value->Remove(kDoubleIndex)); + EXPECT_EQ((size_t)3, value->GetSize()); + + EXPECT_TRUE(value->Remove(kIntIndex)); + EXPECT_EQ((size_t)2, value->GetSize()); + + EXPECT_TRUE(value->Remove(kBoolIndex)); + EXPECT_EQ((size_t)1, value->GetSize()); + + EXPECT_TRUE(value->Remove(kNullIndex)); + EXPECT_EQ((size_t)0, value->GetSize()); + + // Re-add some values. + EXPECT_EQ(VTYPE_INVALID, value->GetType(0)); + TestListNull(value, 0); + EXPECT_EQ(VTYPE_INVALID, value->GetType(1)); + TestListBool(value, 1); + EXPECT_EQ(VTYPE_INVALID, value->GetType(2)); + TestListList(value, 2, list_value); + + // Test the size. + EXPECT_EQ((size_t)3, value->GetSize()); + + // Clear the values. + EXPECT_TRUE(value->Clear()); + EXPECT_EQ((size_t)0, value->GetSize()); + EXPECT_FALSE(list_value->IsValid()); // Value should be detached + + // Add some values in random order. + EXPECT_EQ(VTYPE_INVALID, value->GetType(2)); + TestListInt(value, 2); + EXPECT_EQ(VTYPE_NULL, value->GetType(0)); + TestListBool(value, 0); + EXPECT_EQ(VTYPE_NULL, value->GetType(1)); + TestListList(value, 1, list_value); + + EXPECT_EQ(VTYPE_BOOL, value->GetType(0)); + EXPECT_EQ(VTYPE_LIST, value->GetType(1)); + EXPECT_EQ(VTYPE_INT, value->GetType(2)); + + // Test the size. + EXPECT_EQ((size_t)3, value->GetSize()); + + // Clear some values. + EXPECT_TRUE(value->SetSize(1)); + EXPECT_EQ((size_t)1, value->GetSize()); + EXPECT_FALSE(list_value->IsValid()); // Value should be detached + + EXPECT_EQ(VTYPE_BOOL, value->GetType(0)); + EXPECT_EQ(VTYPE_INVALID, value->GetType(1)); + EXPECT_EQ(VTYPE_INVALID, value->GetType(2)); + + // Clear all values. + EXPECT_TRUE(value->Clear()); + EXPECT_EQ((size_t)0, value->GetSize()); +} + +// Used to test access of list data on a different thread. +class ListTask : public CefTask { + public: + ListTask(CefRefPtr value, char* binary_data, + size_t binary_data_size) + : value_(value), + binary_data_(binary_data), + binary_data_size_(binary_data_size) {} + + virtual void Execute() OVERRIDE { + TestList(value_, binary_data_, binary_data_size_); + } + + private: + CefRefPtr value_; + char* binary_data_; + size_t binary_data_size_; + + IMPLEMENT_REFCOUNTING(ListTask); +}; + +} // namespace + + +// Test binary value access. +TEST(ValuesTest, BinaryAccess) { + char data[] = "This is my test data"; + + CefRefPtr value = + CefBinaryValue::Create(data, sizeof(data)-1); + EXPECT_TRUE(value.get()); + EXPECT_TRUE(value->IsValid()); + EXPECT_FALSE(value->IsOwned()); + + // Test on this thread. + TestBinary(value, data, sizeof(data)-1); +} + +// Test binary value access on a different thread. +TEST(ValuesTest, BinaryAccessOtherThread) { + char data[] = "This is my test data"; + + CefRefPtr value = + CefBinaryValue::Create(data, sizeof(data)-1); + EXPECT_TRUE(value.get()); + EXPECT_TRUE(value->IsValid()); + EXPECT_FALSE(value->IsOwned()); + + // Test on a different thread. + CefPostTask(TID_UI, new BinaryTask(value, data, sizeof(data)-1)); + WaitForUIThread(); +} + +// Test dictionary value access. +TEST(ValuesTest, DictionaryAccess) { + CefRefPtr value = CefDictionaryValue::Create(); + EXPECT_TRUE(value.get()); + EXPECT_TRUE(value->IsValid()); + EXPECT_FALSE(value->IsOwned()); + EXPECT_FALSE(value->IsReadOnly()); + + char binary_data[] = "This is my test data"; + + // Test on this thread. + TestDictionary(value, binary_data, sizeof(binary_data)-1); +} + +// Test dictionary value access on a different thread. +TEST(ValuesTest, DictionaryAccessOtherThread) { + CefRefPtr value = CefDictionaryValue::Create(); + EXPECT_TRUE(value.get()); + EXPECT_TRUE(value->IsValid()); + EXPECT_FALSE(value->IsOwned()); + EXPECT_FALSE(value->IsReadOnly()); + + char binary_data[] = "This is my test data"; + + // Test on a different thread. + CefPostTask(TID_UI, + new DictionaryTask(value, binary_data, sizeof(binary_data)-1)); + WaitForUIThread(); +} + +// Test dictionary value nested detachment +TEST(ValuesTest, DictionaryDetachment) { + CefRefPtr value = CefDictionaryValue::Create(); + EXPECT_TRUE(value.get()); + EXPECT_TRUE(value->IsValid()); + EXPECT_FALSE(value->IsOwned()); + EXPECT_FALSE(value->IsReadOnly()); + + CefRefPtr dictionary_value = CefDictionaryValue::Create(); + CefRefPtr dictionary_value2 = + CefDictionaryValue::Create(); + CefRefPtr dictionary_value3 = + CefDictionaryValue::Create(); + + dictionary_value2->SetDictionary(kDictionaryKey, dictionary_value3); + EXPECT_FALSE(dictionary_value3->IsValid()); + dictionary_value->SetDictionary(kDictionaryKey, dictionary_value2); + EXPECT_FALSE(dictionary_value2->IsValid()); + value->SetDictionary(kDictionaryKey, dictionary_value); + EXPECT_FALSE(dictionary_value->IsValid()); + + dictionary_value = value->GetDictionary(kDictionaryKey); + EXPECT_TRUE(dictionary_value.get()); + EXPECT_TRUE(dictionary_value->IsValid()); + + dictionary_value2 = dictionary_value->GetDictionary(kDictionaryKey); + EXPECT_TRUE(dictionary_value2.get()); + EXPECT_TRUE(dictionary_value2->IsValid()); + + dictionary_value3 = dictionary_value2->GetDictionary(kDictionaryKey); + EXPECT_TRUE(dictionary_value3.get()); + EXPECT_TRUE(dictionary_value3->IsValid()); + + EXPECT_TRUE(value->Remove(kDictionaryKey)); + EXPECT_FALSE(dictionary_value->IsValid()); + EXPECT_FALSE(dictionary_value2->IsValid()); + EXPECT_FALSE(dictionary_value3->IsValid()); +} + +// Test list value access. +TEST(ValuesTest, ListAccess) { + CefRefPtr value = CefListValue::Create(); + EXPECT_TRUE(value.get()); + EXPECT_TRUE(value->IsValid()); + EXPECT_FALSE(value->IsOwned()); + EXPECT_FALSE(value->IsReadOnly()); + + char binary_data[] = "This is my test data"; + + // Test on this thread. + TestList(value, binary_data, sizeof(binary_data)-1); +} + +// Test list value access on a different thread. +TEST(ValuesTest, ListAccessOtherThread) { + CefRefPtr value = CefListValue::Create(); + EXPECT_TRUE(value.get()); + EXPECT_TRUE(value->IsValid()); + EXPECT_FALSE(value->IsOwned()); + EXPECT_FALSE(value->IsReadOnly()); + + char binary_data[] = "This is my test data"; + + // Test on a different thread. + CefPostTask(TID_UI, new ListTask(value, binary_data, sizeof(binary_data)-1)); + WaitForUIThread(); +} + +// Test list value nested detachment +TEST(ValuesTest, ListDetachment) { + CefRefPtr value = CefListValue::Create(); + EXPECT_TRUE(value.get()); + EXPECT_TRUE(value->IsValid()); + EXPECT_FALSE(value->IsOwned()); + EXPECT_FALSE(value->IsReadOnly()); + + CefRefPtr list_value = CefListValue::Create(); + CefRefPtr list_value2 = CefListValue::Create(); + CefRefPtr list_value3 = CefListValue::Create(); + + list_value2->SetList(0, list_value3); + EXPECT_FALSE(list_value3->IsValid()); + list_value->SetList(0, list_value2); + EXPECT_FALSE(list_value2->IsValid()); + value->SetList(0, list_value); + EXPECT_FALSE(list_value->IsValid()); + + list_value = value->GetList(0); + EXPECT_TRUE(list_value.get()); + EXPECT_TRUE(list_value->IsValid()); + + list_value2 = list_value->GetList(0); + EXPECT_TRUE(list_value2.get()); + EXPECT_TRUE(list_value2->IsValid()); + + list_value3 = list_value2->GetList(0); + EXPECT_TRUE(list_value3.get()); + EXPECT_TRUE(list_value3->IsValid()); + + EXPECT_TRUE(value->Remove(0)); + EXPECT_FALSE(list_value->IsValid()); + EXPECT_FALSE(list_value2->IsValid()); + EXPECT_FALSE(list_value3->IsValid()); +} diff --git a/cef3/tests/unittests/version_unittest.cc b/cef3/tests/unittests/version_unittest.cc new file mode 100644 index 000000000..adc84200a --- /dev/null +++ b/cef3/tests/unittests/version_unittest.cc @@ -0,0 +1,24 @@ +// Copyright (c) 2013 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 "include/cef_version.h" +#include "testing/gtest/include/gtest/gtest.h" + +TEST(VersionTest, BuildRevision) { + EXPECT_EQ(CEF_REVISION, cef_build_revision()); +} + +TEST(VersionTest, VersionInfo) { + EXPECT_EQ(CEF_VERSION_MAJOR, cef_version_info(0)); + EXPECT_EQ(CEF_REVISION, cef_version_info(1)); + EXPECT_EQ(CHROME_VERSION_MAJOR, cef_version_info(2)); + EXPECT_EQ(CHROME_VERSION_MINOR, cef_version_info(3)); + EXPECT_EQ(CHROME_VERSION_BUILD, cef_version_info(4)); + EXPECT_EQ(CHROME_VERSION_PATCH, cef_version_info(5)); +} + +TEST(VersionTest, ApiHash) { + EXPECT_STREQ(CEF_API_HASH_PLATFORM, cef_api_hash(0)); + EXPECT_STREQ(CEF_API_HASH_UNIVERSAL, cef_api_hash(1)); +} diff --git a/cef3/tests/unittests/xml_reader_unittest.cc b/cef3/tests/unittests/xml_reader_unittest.cc new file mode 100644 index 000000000..fcc85600e --- /dev/null +++ b/cef3/tests/unittests/xml_reader_unittest.cc @@ -0,0 +1,642 @@ +// Copyright (c) 2010 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 "include/cef_stream.h" +#include "include/cef_xml_reader.h" +#include "include/wrapper/cef_xml_object.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +char g_test_xml[] = + "\n" + "\n" + "\n" + " \n" + "]>\n" + "\n" + " value A\n" + " \n" + " \n" + " value B1\n" + " data]]>\n" + " &EB;\n" + " this is mixed content &EA;\n" + " \n" + " " + "\n" + "\n"; + +} // namespace + +// Test XML reading +TEST(XmlReaderTest, Read) { + // Create the stream reader. + CefRefPtr stream( + CefStreamReader::CreateForData(g_test_xml, sizeof(g_test_xml) - 1)); + ASSERT_TRUE(stream.get() != NULL); + + // Create the XML reader. + CefRefPtr reader( + CefXmlReader::Create(stream, XML_ENCODING_NONE, + "http://www.example.org/example.xml")); + ASSERT_TRUE(reader.get() != NULL); + + // Move to the processing instruction node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 0); + ASSERT_EQ(reader->GetType(), XML_NODE_PROCESSING_INSTRUCTION); + ASSERT_EQ(reader->GetLocalName(), "my_instruction"); + ASSERT_EQ(reader->GetQualifiedName(), "my_instruction"); + ASSERT_TRUE(reader->HasValue()); + ASSERT_EQ(reader->GetValue(), "my_value"); + + // Move to the DOCTYPE node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 0); + ASSERT_EQ(reader->GetType(), XML_NODE_DOCUMENT_TYPE); + ASSERT_EQ(reader->GetLocalName(), "my_document"); + ASSERT_EQ(reader->GetQualifiedName(), "my_document"); + ASSERT_FALSE(reader->HasValue()); + + // Move to ns:obj element start node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 0); + ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_START); + ASSERT_EQ(reader->GetLocalName(), "obj"); + ASSERT_EQ(reader->GetPrefix(), "ns"); + ASSERT_EQ(reader->GetQualifiedName(), "ns:obj"); + ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); + ASSERT_TRUE(reader->HasAttributes()); + ASSERT_EQ(reader->GetAttributeCount(), (size_t)1); + ASSERT_EQ(reader->GetAttribute(0), "http://www.example.org/ns"); + ASSERT_EQ(reader->GetAttribute("xmlns:ns"), "http://www.example.org/ns"); + ASSERT_EQ(reader->GetAttribute("ns", "http://www.w3.org/2000/xmlns/"), + "http://www.example.org/ns"); + + // Move to the whitespace node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetType(), XML_NODE_WHITESPACE); + + // Move to the ns:objA element start node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 1); + ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_START); + ASSERT_EQ(reader->GetLocalName(), "objA"); + ASSERT_EQ(reader->GetPrefix(), "ns"); + ASSERT_EQ(reader->GetQualifiedName(), "ns:objA"); + ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); + ASSERT_FALSE(reader->IsEmptyElement()); + ASSERT_FALSE(reader->HasAttributes()); + ASSERT_FALSE(reader->HasValue()); + + // Move to the ns:objA value node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 2); + ASSERT_EQ(reader->GetType(), XML_NODE_TEXT); + ASSERT_EQ(reader->GetLocalName(), "#text"); + ASSERT_EQ(reader->GetQualifiedName(), "#text"); + ASSERT_TRUE(reader->HasValue()); + ASSERT_EQ(reader->GetValue(), "value A"); + + // Move to the ns:objA element ending node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 1); + ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_END); + ASSERT_EQ(reader->GetLocalName(), "objA"); + ASSERT_EQ(reader->GetPrefix(), "ns"); + ASSERT_EQ(reader->GetQualifiedName(), "ns:objA"); + ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); + ASSERT_FALSE(reader->IsEmptyElement()); + ASSERT_FALSE(reader->HasAttributes()); + ASSERT_FALSE(reader->HasValue()); + + // Move to the whitespace node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 1); + ASSERT_EQ(reader->GetType(), XML_NODE_WHITESPACE); + + // Move to the comment node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 1); + ASSERT_EQ(reader->GetType(), XML_NODE_COMMENT); + ASSERT_EQ(reader->GetLocalName(), "#comment"); + ASSERT_EQ(reader->GetQualifiedName(), "#comment"); + ASSERT_TRUE(reader->HasValue()); + ASSERT_EQ(reader->GetValue(), " my comment "); + + // Move to the whitespace node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetType(), XML_NODE_WHITESPACE); + + // Move to the ns:objB element start node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 1); + ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_START); + ASSERT_EQ(reader->GetLocalName(), "objB"); + ASSERT_EQ(reader->GetPrefix(), "ns"); + ASSERT_EQ(reader->GetQualifiedName(), "ns:objB"); + ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); + ASSERT_FALSE(reader->IsEmptyElement()); + ASSERT_FALSE(reader->HasAttributes()); + ASSERT_FALSE(reader->HasValue()); + + // Move to the whitespace node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetType(), XML_NODE_WHITESPACE); + + // Move to the ns:objB_1 element start node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 2); + ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_START); + ASSERT_EQ(reader->GetLocalName(), "objB_1"); + ASSERT_EQ(reader->GetPrefix(), "ns"); + ASSERT_EQ(reader->GetQualifiedName(), "ns:objB_1"); + ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); + ASSERT_FALSE(reader->IsEmptyElement()); + ASSERT_FALSE(reader->HasAttributes()); + ASSERT_FALSE(reader->HasValue()); + + // Move to the ns:objB_1 value node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 3); + ASSERT_EQ(reader->GetType(), XML_NODE_TEXT); + ASSERT_TRUE(reader->HasValue()); + ASSERT_EQ(reader->GetValue(), "value B1"); + + // Move to the ns:objB_1 element ending node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 2); + ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_END); + ASSERT_EQ(reader->GetLocalName(), "objB_1"); + ASSERT_EQ(reader->GetPrefix(), "ns"); + ASSERT_EQ(reader->GetQualifiedName(), "ns:objB_1"); + ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); + ASSERT_FALSE(reader->IsEmptyElement()); + ASSERT_FALSE(reader->HasAttributes()); + ASSERT_FALSE(reader->HasValue()); + + // Move to the whitespace node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetType(), XML_NODE_WHITESPACE); + + // Move to the ns:objB_2 element start node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 2); + ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_START); + ASSERT_EQ(reader->GetLocalName(), "objB_2"); + ASSERT_EQ(reader->GetPrefix(), "ns"); + ASSERT_EQ(reader->GetQualifiedName(), "ns:objB_2"); + ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); + ASSERT_FALSE(reader->IsEmptyElement()); + ASSERT_FALSE(reader->HasAttributes()); + ASSERT_FALSE(reader->HasValue()); + + // Move to the ns:objB_2 value node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 3); + ASSERT_EQ(reader->GetType(), XML_NODE_CDATA); + ASSERT_TRUE(reader->HasValue()); + ASSERT_EQ(reader->GetValue(), "some
data"); + + // Move to the ns:objB_2 element ending node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 2); + ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_END); + ASSERT_EQ(reader->GetLocalName(), "objB_2"); + ASSERT_EQ(reader->GetPrefix(), "ns"); + ASSERT_EQ(reader->GetQualifiedName(), "ns:objB_2"); + ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); + ASSERT_FALSE(reader->IsEmptyElement()); + ASSERT_FALSE(reader->HasAttributes()); + ASSERT_FALSE(reader->HasValue()); + + // Move to the whitespace node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetType(), XML_NODE_WHITESPACE); + + // Move to the ns:objB_3 element start node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 2); + ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_START); + ASSERT_EQ(reader->GetLocalName(), "objB_3"); + ASSERT_EQ(reader->GetPrefix(), "ns"); + ASSERT_EQ(reader->GetQualifiedName(), "ns:objB_3"); + ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); + ASSERT_FALSE(reader->IsEmptyElement()); + ASSERT_FALSE(reader->HasAttributes()); + ASSERT_FALSE(reader->HasValue()); + + // Move to the EB entity reference node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 3); + ASSERT_EQ(reader->GetType(), XML_NODE_ENTITY_REFERENCE); + ASSERT_EQ(reader->GetLocalName(), "EB"); + ASSERT_EQ(reader->GetQualifiedName(), "EB"); + ASSERT_TRUE(reader->HasValue()); + ASSERT_EQ(reader->GetValue(), "EB Value"); + + // Move to the ns:objB_3 element ending node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 2); + ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_END); + ASSERT_EQ(reader->GetLocalName(), "objB_3"); + ASSERT_EQ(reader->GetPrefix(), "ns"); + ASSERT_EQ(reader->GetQualifiedName(), "ns:objB_3"); + ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); + ASSERT_FALSE(reader->IsEmptyElement()); + ASSERT_FALSE(reader->HasAttributes()); + ASSERT_FALSE(reader->HasValue()); + + // Move to the whitespace node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetType(), XML_NODE_WHITESPACE); + + // Move to the ns:objB_4 element start node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 2); + ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_START); + ASSERT_EQ(reader->GetLocalName(), "objB_4"); + ASSERT_EQ(reader->GetPrefix(), "ns"); + ASSERT_EQ(reader->GetQualifiedName(), "ns:objB_4"); + ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); + ASSERT_FALSE(reader->IsEmptyElement()); + ASSERT_FALSE(reader->HasAttributes()); + ASSERT_FALSE(reader->HasValue()); + ASSERT_EQ(reader->GetInnerXml(), "this is mixed content &EA;"); + ASSERT_EQ(reader->GetOuterXml(), + "" + "this is mixed content &EA;"); + + // Move to the element node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 3); + ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_START); + ASSERT_EQ(reader->GetLocalName(), "b"); + ASSERT_EQ(reader->GetQualifiedName(), "b"); + ASSERT_FALSE(reader->IsEmptyElement()); + ASSERT_FALSE(reader->HasAttributes()); + ASSERT_FALSE(reader->HasValue()); + + // Move to the text node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 4); + ASSERT_EQ(reader->GetType(), XML_NODE_TEXT); + ASSERT_EQ(reader->GetLocalName(), "#text"); + ASSERT_EQ(reader->GetQualifiedName(), "#text"); + ASSERT_TRUE(reader->HasValue()); + ASSERT_EQ(reader->GetValue(), "this is"); + + // Move to the element node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 3); + ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_END); + ASSERT_EQ(reader->GetLocalName(), "b"); + ASSERT_EQ(reader->GetQualifiedName(), "b"); + + // Move to the text node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 3); + ASSERT_EQ(reader->GetType(), XML_NODE_TEXT); + ASSERT_EQ(reader->GetLocalName(), "#text"); + ASSERT_EQ(reader->GetQualifiedName(), "#text"); + ASSERT_TRUE(reader->HasValue()); + ASSERT_EQ(reader->GetValue(), " mixed content "); + + // Move to the EA entity reference node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 3); + ASSERT_EQ(reader->GetType(), XML_NODE_ENTITY_REFERENCE); + ASSERT_EQ(reader->GetLocalName(), "EA"); + ASSERT_EQ(reader->GetQualifiedName(), "EA"); + ASSERT_TRUE(reader->HasValue()); + ASSERT_EQ(reader->GetValue(), "EA Value"); + + // Move to the ns:objB_4 element ending node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 2); + ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_END); + ASSERT_EQ(reader->GetLocalName(), "objB_4"); + ASSERT_EQ(reader->GetPrefix(), "ns"); + ASSERT_EQ(reader->GetQualifiedName(), "ns:objB_4"); + ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); + ASSERT_FALSE(reader->IsEmptyElement()); + ASSERT_FALSE(reader->HasAttributes()); + ASSERT_FALSE(reader->HasValue()); + + // Move to the whitespace node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetType(), XML_NODE_WHITESPACE); + + // Move to the ns:objB element ending node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 1); + ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_END); + ASSERT_EQ(reader->GetLocalName(), "objB"); + ASSERT_EQ(reader->GetPrefix(), "ns"); + ASSERT_EQ(reader->GetQualifiedName(), "ns:objB"); + ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); + ASSERT_FALSE(reader->IsEmptyElement()); + ASSERT_FALSE(reader->HasAttributes()); + ASSERT_FALSE(reader->HasValue()); + + // Move to the whitespace node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetType(), XML_NODE_WHITESPACE); + + // Move to the ns:objC element start node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 1); + ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_START); + ASSERT_EQ(reader->GetLocalName(), "objC"); + ASSERT_EQ(reader->GetPrefix(), "ns"); + ASSERT_EQ(reader->GetQualifiedName(), "ns:objC"); + ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); + ASSERT_TRUE(reader->IsEmptyElement()); + ASSERT_TRUE(reader->HasAttributes()); + ASSERT_FALSE(reader->HasValue()); + ASSERT_EQ(reader->GetAttributeCount(), (size_t)2); + ASSERT_EQ(reader->GetAttribute(0), "value C1"); + ASSERT_EQ(reader->GetAttribute("ns:attr1"), "value C1"); + ASSERT_EQ(reader->GetAttribute("attr1", "http://www.example.org/ns"), + "value C1"); + ASSERT_EQ(reader->GetAttribute(1), "value C2"); + ASSERT_EQ(reader->GetAttribute("ns:attr2"), "value C2"); + ASSERT_EQ(reader->GetAttribute("attr2", "http://www.example.org/ns"), + "value C2"); + + // Move to the ns:attr1 attribute. + ASSERT_TRUE(reader->MoveToFirstAttribute()); + ASSERT_EQ(reader->GetDepth(), 2); + ASSERT_EQ(reader->GetType(), XML_NODE_ATTRIBUTE); + ASSERT_EQ(reader->GetLocalName(), "attr1"); + ASSERT_EQ(reader->GetPrefix(), "ns"); + ASSERT_EQ(reader->GetQualifiedName(), "ns:attr1"); + ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); + ASSERT_TRUE(reader->HasValue()); + ASSERT_FALSE(reader->IsEmptyElement()); + ASSERT_FALSE(reader->HasAttributes()); + ASSERT_EQ(reader->GetValue(), "value C1"); + + // Move to the ns:attr2 attribute. + ASSERT_TRUE(reader->MoveToNextAttribute()); + ASSERT_EQ(reader->GetDepth(), 2); + ASSERT_EQ(reader->GetType(), XML_NODE_ATTRIBUTE); + ASSERT_EQ(reader->GetLocalName(), "attr2"); + ASSERT_EQ(reader->GetPrefix(), "ns"); + ASSERT_EQ(reader->GetQualifiedName(), "ns:attr2"); + ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); + ASSERT_TRUE(reader->HasValue()); + ASSERT_FALSE(reader->IsEmptyElement()); + ASSERT_FALSE(reader->HasAttributes()); + ASSERT_EQ(reader->GetValue(), "value C2"); + + // No more attributes. + ASSERT_FALSE(reader->MoveToNextAttribute()); + + // Return to the ns:objC element start node. + ASSERT_TRUE(reader->MoveToCarryingElement()); + ASSERT_EQ(reader->GetDepth(), 1); + ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_START); + ASSERT_EQ(reader->GetQualifiedName(), "ns:objC"); + + // Move to the ns:attr1 attribute. + ASSERT_TRUE(reader->MoveToAttribute(0)); + ASSERT_EQ(reader->GetDepth(), 2); + ASSERT_EQ(reader->GetType(), XML_NODE_ATTRIBUTE); + ASSERT_EQ(reader->GetLocalName(), "attr1"); + ASSERT_EQ(reader->GetPrefix(), "ns"); + ASSERT_EQ(reader->GetQualifiedName(), "ns:attr1"); + ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); + ASSERT_TRUE(reader->HasValue()); + ASSERT_FALSE(reader->IsEmptyElement()); + ASSERT_FALSE(reader->HasAttributes()); + ASSERT_EQ(reader->GetValue(), "value C1"); + + // Return to the ns:objC element start node. + ASSERT_TRUE(reader->MoveToCarryingElement()); + ASSERT_EQ(reader->GetDepth(), 1); + ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_START); + ASSERT_EQ(reader->GetQualifiedName(), "ns:objC"); + + // Move to the ns:attr2 attribute. + ASSERT_TRUE(reader->MoveToAttribute("ns:attr2")); + ASSERT_EQ(reader->GetDepth(), 2); + ASSERT_EQ(reader->GetType(), XML_NODE_ATTRIBUTE); + ASSERT_EQ(reader->GetLocalName(), "attr2"); + ASSERT_EQ(reader->GetPrefix(), "ns"); + ASSERT_EQ(reader->GetQualifiedName(), "ns:attr2"); + ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); + ASSERT_TRUE(reader->HasValue()); + ASSERT_FALSE(reader->IsEmptyElement()); + ASSERT_FALSE(reader->HasAttributes()); + ASSERT_EQ(reader->GetValue(), "value C2"); + + // Move to the ns:attr1 attribute without returning to the ns:objC element. + ASSERT_TRUE(reader->MoveToAttribute("attr1", "http://www.example.org/ns")); + ASSERT_EQ(reader->GetDepth(), 2); + ASSERT_EQ(reader->GetType(), XML_NODE_ATTRIBUTE); + ASSERT_EQ(reader->GetLocalName(), "attr1"); + ASSERT_EQ(reader->GetPrefix(), "ns"); + ASSERT_EQ(reader->GetQualifiedName(), "ns:attr1"); + ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); + ASSERT_TRUE(reader->HasValue()); + ASSERT_FALSE(reader->IsEmptyElement()); + ASSERT_FALSE(reader->HasAttributes()); + ASSERT_EQ(reader->GetValue(), "value C1"); + + // Move to the ns:objD element start node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 1); + ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_START); + ASSERT_EQ(reader->GetLocalName(), "objD"); + ASSERT_EQ(reader->GetPrefix(), "ns"); + ASSERT_EQ(reader->GetQualifiedName(), "ns:objD"); + ASSERT_FALSE(reader->IsEmptyElement()); + ASSERT_FALSE(reader->HasAttributes()); + ASSERT_FALSE(reader->HasValue()); + + // Move to the ns:objD element end node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 1); + ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_END); + ASSERT_EQ(reader->GetLocalName(), "objD"); + ASSERT_EQ(reader->GetPrefix(), "ns"); + ASSERT_EQ(reader->GetQualifiedName(), "ns:objD"); + ASSERT_FALSE(reader->IsEmptyElement()); + ASSERT_FALSE(reader->HasAttributes()); + ASSERT_FALSE(reader->HasValue()); + + // Move to the whitespace node without returning to the ns:objC element. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetType(), XML_NODE_WHITESPACE); + + // Move to ns:obj element ending node. + ASSERT_TRUE(reader->MoveToNextNode()); + ASSERT_EQ(reader->GetDepth(), 0); + ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_END); + ASSERT_EQ(reader->GetLocalName(), "obj"); + ASSERT_EQ(reader->GetPrefix(), "ns"); + ASSERT_EQ(reader->GetQualifiedName(), "ns:obj"); + ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); + ASSERT_FALSE(reader->IsEmptyElement()); + ASSERT_TRUE(reader->HasAttributes()); + ASSERT_FALSE(reader->HasValue()); + // Strangely, the end node will report if the starting node has attributes + // but will not provide access to them. + ASSERT_TRUE(reader->HasAttributes()); + ASSERT_EQ(reader->GetAttributeCount(), (size_t)0); + + // And we're done. + ASSERT_FALSE(reader->MoveToNextNode()); + + ASSERT_TRUE(reader->Close()); +} + +// Test XML read error handling. +TEST(XmlReaderTest, ReadError) { + char test_str[] = + "\n" + "\n"; + + // Create the stream reader. + CefRefPtr stream( + CefStreamReader::CreateForData(test_str, sizeof(test_str) - 1)); + ASSERT_TRUE(stream.get() != NULL); + + // Create the XML reader. + CefRefPtr reader( + CefXmlReader::Create(stream, XML_ENCODING_NONE, + "http://www.example.org/example.xml")); + ASSERT_TRUE(reader.get() != NULL); + + // Move to the processing instruction node and generate parser error. + ASSERT_FALSE(reader->MoveToNextNode()); + ASSERT_TRUE(reader->HasError()); +} + +// Test XmlObject load behavior. +TEST(XmlReaderTest, ObjectLoad) { + // Create the stream reader. + CefRefPtr stream( + CefStreamReader::CreateForData(g_test_xml, sizeof(g_test_xml) - 1)); + ASSERT_TRUE(stream.get() != NULL); + + // Create the XML reader. + CefRefPtr object(new CefXmlObject("object")); + ASSERT_TRUE(object->Load(stream, XML_ENCODING_NONE, + "http://www.example.org/example.xml", NULL)); + + ASSERT_FALSE(object->HasAttributes()); + ASSERT_TRUE(object->HasChildren()); + ASSERT_EQ(object->GetChildCount(), (size_t)1); + + CefRefPtr obj(object->FindChild("ns:obj")); + ASSERT_TRUE(obj.get()); + ASSERT_TRUE(obj->HasChildren()); + ASSERT_EQ(obj->GetChildCount(), (size_t)4); + + CefRefPtr obj_child(obj->FindChild("ns:objC")); + ASSERT_TRUE(obj_child.get()); + ASSERT_EQ(obj_child->GetName(), "ns:objC"); + ASSERT_FALSE(obj_child->HasChildren()); + ASSERT_FALSE(obj_child->HasValue()); + ASSERT_TRUE(obj_child->HasAttributes()); + + CefXmlObject::ObjectVector obj_children; + ASSERT_EQ(obj->GetChildren(obj_children), (size_t)4); + ASSERT_EQ(obj_children.size(), (size_t)4); + + CefXmlObject::ObjectVector::const_iterator it = obj_children.begin(); + for (int ct = 0; it != obj_children.end(); ++it, ++ct) { + obj_child = *it; + ASSERT_TRUE(obj_child.get()); + if (ct == 0) { + // ns:objA + ASSERT_EQ(obj_child->GetName(), "ns:objA"); + ASSERT_FALSE(obj_child->HasChildren()); + ASSERT_TRUE(obj_child->HasValue()); + ASSERT_FALSE(obj_child->HasAttributes()); + ASSERT_EQ(obj_child->GetValue(), "value A"); + } else if (ct == 1) { + // ns:objB + ASSERT_EQ(obj_child->GetName(), "ns:objB"); + ASSERT_TRUE(obj_child->HasChildren()); + ASSERT_FALSE(obj_child->HasValue()); + ASSERT_FALSE(obj_child->HasAttributes()); + ASSERT_EQ(obj_child->GetChildCount(), (size_t)4); + obj_child = obj_child->FindChild("ns:objB_4"); + ASSERT_TRUE(obj_child.get()); + ASSERT_TRUE(obj_child->HasValue()); + ASSERT_EQ(obj_child->GetValue(), + "this is mixed content EA Value"); + } else if (ct == 2) { + // ns:objC + ASSERT_EQ(obj_child->GetName(), "ns:objC"); + ASSERT_FALSE(obj_child->HasChildren()); + ASSERT_FALSE(obj_child->HasValue()); + ASSERT_TRUE(obj_child->HasAttributes()); + + CefXmlObject::AttributeMap attribs; + ASSERT_EQ(obj_child->GetAttributes(attribs), (size_t)2); + ASSERT_EQ(attribs.size(), (size_t)2); + ASSERT_EQ(attribs["ns:attr1"], "value C1"); + ASSERT_EQ(attribs["ns:attr2"], "value C2"); + + ASSERT_EQ(obj_child->GetAttributeCount(), (size_t)2); + ASSERT_TRUE(obj_child->HasAttribute("ns:attr1")); + ASSERT_EQ(obj_child->GetAttributeValue("ns:attr1"), "value C1"); + ASSERT_TRUE(obj_child->HasAttribute("ns:attr2")); + ASSERT_EQ(obj_child->GetAttributeValue("ns:attr2"), "value C2"); + } else if (ct == 3) { + // ns:objD + ASSERT_EQ(obj_child->GetName(), "ns:objD"); + ASSERT_FALSE(obj_child->HasChildren()); + ASSERT_FALSE(obj_child->HasValue()); + ASSERT_FALSE(obj_child->HasAttributes()); + } + } +} + +// Test XmlObject load error handling behavior. +TEST(XmlReaderTest, ObjectLoadError) { + // Test start/end tag mismatch error. + { + char error_xml[] = "\n\n\n"; + + // Create the stream reader. + CefRefPtr stream( + CefStreamReader::CreateForData(error_xml, sizeof(error_xml) - 1)); + ASSERT_TRUE(stream.get() != NULL); + + CefString error_str; + + // Create the XML reader. + CefRefPtr object(new CefXmlObject("object")); + ASSERT_FALSE(object->Load(stream, XML_ENCODING_NONE, + "http://www.example.org/example.xml", &error_str)); + ASSERT_EQ(error_str, + "Opening and ending tag mismatch: foo line 2 and obj, line 3"); + } + + // Test value following child error. + { + char error_xml[] = "\n\ndisallowed value\n"; + + // Create the stream reader. + CefRefPtr stream( + CefStreamReader::CreateForData(error_xml, sizeof(error_xml) - 1)); + ASSERT_TRUE(stream.get() != NULL); + + CefString error_str; + + // Create the XML reader. + CefRefPtr object(new CefXmlObject("object")); + ASSERT_FALSE(object->Load(stream, XML_ENCODING_NONE, + "http://www.example.org/example.xml", &error_str)); + ASSERT_EQ(error_str, + "Value following child element, line 4"); + } +} diff --git a/cef3/tests/unittests/zip_reader_unittest.cc b/cef3/tests/unittests/zip_reader_unittest.cc new file mode 100644 index 000000000..41f83fdde --- /dev/null +++ b/cef3/tests/unittests/zip_reader_unittest.cc @@ -0,0 +1,253 @@ +// Copyright (c) 2010 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 "include/cef_stream.h" +#include "include/cef_zip_reader.h" +#include "include/wrapper/cef_zip_archive.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + + unsigned char g_test_zip[] = { + 0x50, 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x67, 0x7f, + 0x57, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, + 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x50, 0x4b, 0x03, 0x04, 0x0a, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x7f, 0x57, 0x3d, 0xf8, 0x47, 0x0c, + 0xc6, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, + 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, + 0x65, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x2e, 0x74, 0x78, 0x74, + 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x20, 0x6f, 0x66, 0x20, + 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x2e, 0x50, 0x4b, 0x03, 0x04, 0x0a, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x7f, 0x57, 0x3d, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, + 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, + 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x31, 0x2f, 0x50, + 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x7f, 0x57, + 0x3d, 0x43, 0xe3, 0x11, 0x5f, 0x14, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, + 0x00, 0x21, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, + 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, + 0x20, 0x31, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x61, 0x2e, 0x74, + 0x78, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x20, 0x6f, + 0x66, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x41, 0x2e, 0x50, 0x4b, + 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x7f, 0x57, 0x3d, + 0x80, 0xb0, 0x3c, 0x74, 0x14, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x21, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, + 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, + 0x31, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x62, 0x2e, 0x74, 0x78, + 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x20, 0x6f, 0x66, + 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x42, 0x2e, 0x50, 0x4b, 0x03, + 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x7f, 0x57, 0x3d, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, + 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, + 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x31, + 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x31, 0x61, 0x2f, 0x50, + 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x7f, 0x57, + 0x3d, 0x15, 0xed, 0x04, 0x2c, 0x15, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, + 0x00, 0x2c, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, + 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, + 0x20, 0x31, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x31, 0x61, + 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x61, 0x31, 0x2e, 0x74, 0x78, + 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x20, 0x6f, 0x66, + 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x41, 0x31, 0x2e, 0x50, 0x4b, + 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x7f, 0x57, 0x3d, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x16, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, + 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, + 0x32, 0x2f, 0x50, 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x80, 0x57, 0x3d, 0x1a, 0x5d, 0x57, 0x5d, 0x14, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, + 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, + 0x64, 0x65, 0x72, 0x20, 0x32, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x32, + 0x61, 0x2e, 0x74, 0x78, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, + 0x73, 0x20, 0x6f, 0x66, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x32, 0x41, + 0x2e, 0x50, 0x4b, 0x01, 0x02, 0x14, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x67, 0x7f, 0x57, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, + 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, + 0x50, 0x4b, 0x01, 0x02, 0x14, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x70, 0x7f, 0x57, 0x3d, 0xf8, 0x47, 0x0c, 0xc6, 0x13, 0x00, 0x00, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x74, 0x65, + 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, + 0x69, 0x6c, 0x65, 0x20, 0x31, 0x2e, 0x74, 0x78, 0x74, 0x50, 0x4b, 0x01, + 0x02, 0x14, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x7f, 0x57, + 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, + 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, + 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, + 0x65, 0x72, 0x20, 0x31, 0x2f, 0x50, 0x4b, 0x01, 0x02, 0x14, 0x00, 0x0a, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x7f, 0x57, 0x3d, 0x43, 0xe3, 0x11, + 0x5f, 0x14, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0xa7, + 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, + 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x31, + 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x61, 0x2e, 0x74, 0x78, 0x74, + 0x50, 0x4b, 0x01, 0x02, 0x14, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x78, 0x7f, 0x57, 0x3d, 0x80, 0xb0, 0x3c, 0x74, 0x14, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x00, 0x00, 0x74, 0x65, + 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, + 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x31, 0x2f, 0x66, 0x69, 0x6c, 0x65, + 0x20, 0x31, 0x62, 0x2e, 0x74, 0x78, 0x74, 0x50, 0x4b, 0x01, 0x02, 0x14, + 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x7f, 0x57, 0x3d, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, + 0x00, 0x4d, 0x01, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, + 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, + 0x20, 0x31, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x31, 0x61, + 0x2f, 0x50, 0x4b, 0x01, 0x02, 0x14, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x7c, 0x7f, 0x57, 0x3d, 0x15, 0xed, 0x04, 0x2c, 0x15, 0x00, 0x00, + 0x00, 0x15, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x8b, 0x01, 0x00, 0x00, 0x74, + 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, + 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x31, 0x2f, 0x66, 0x6f, 0x6c, + 0x64, 0x65, 0x72, 0x20, 0x31, 0x61, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x20, + 0x31, 0x61, 0x31, 0x2e, 0x74, 0x78, 0x74, 0x50, 0x4b, 0x01, 0x02, 0x14, + 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x7f, 0x57, 0x3d, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, + 0x00, 0xea, 0x01, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, + 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, + 0x20, 0x32, 0x2f, 0x50, 0x4b, 0x01, 0x02, 0x14, 0x00, 0x0a, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x02, 0x80, 0x57, 0x3d, 0x1a, 0x5d, 0x57, 0x5d, 0x14, + 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x1e, 0x02, 0x00, + 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, + 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x32, 0x2f, 0x66, + 0x69, 0x6c, 0x65, 0x20, 0x32, 0x61, 0x2e, 0x74, 0x78, 0x74, 0x50, 0x4b, + 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x09, 0x00, 0x9d, 0x02, + 0x00, 0x00, 0x71, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + +} // namespace + +// Test Zip reading. +TEST(ZipReaderTest, Read) { + // Create the stream reader. + CefRefPtr stream( + CefStreamReader::CreateForData(g_test_zip, sizeof(g_test_zip) - 1)); + ASSERT_TRUE(stream.get() != NULL); + + // Create the Zip reader. + CefRefPtr reader(CefZipReader::Create(stream)); + ASSERT_TRUE(reader.get() != NULL); + + char buff[25]; + + // Walk through the archive contents. + ASSERT_TRUE(reader->MoveToFirstFile()); + ASSERT_EQ(reader->GetFileName(), "test_archive/"); + ASSERT_EQ(reader->GetFileSize(), 0); + + ASSERT_TRUE(reader->MoveToNextFile()); + ASSERT_EQ(reader->GetFileName(), "test_archive/file 1.txt"); + ASSERT_EQ(reader->GetFileSize(), 19); + ASSERT_TRUE(reader->OpenFile("")); + ASSERT_EQ(reader->ReadFile(buff, sizeof(buff)), 19); + ASSERT_TRUE(!strncmp(buff, "Contents of file 1.", 19)); + + ASSERT_TRUE(reader->MoveToNextFile()); + ASSERT_EQ(reader->GetFileName(), "test_archive/folder 1/"); + ASSERT_EQ(reader->GetFileSize(), 0); + + ASSERT_TRUE(reader->MoveToNextFile()); + ASSERT_EQ(reader->GetFileName(), "test_archive/folder 1/file 1a.txt"); + ASSERT_EQ(reader->GetFileSize(), 20); + ASSERT_TRUE(reader->OpenFile("")); + ASSERT_EQ(reader->ReadFile(buff, sizeof(buff)), 20); + ASSERT_TRUE(reader->CloseFile()); + ASSERT_TRUE(!strncmp(buff, "Contents of file 1A.", 20)); + + ASSERT_TRUE(reader->MoveToNextFile()); + ASSERT_EQ(reader->GetFileName(), "test_archive/folder 1/file 1b.txt"); + ASSERT_EQ(reader->GetFileSize(), 20); + ASSERT_TRUE(reader->OpenFile("")); + ASSERT_EQ(reader->ReadFile(buff, sizeof(buff)), 20); + ASSERT_TRUE(reader->CloseFile()); + ASSERT_TRUE(!strncmp(buff, "Contents of file 1B.", 20)); + + ASSERT_TRUE(reader->MoveToNextFile()); + ASSERT_EQ(reader->GetFileName(), "test_archive/folder 1/folder 1a/"); + ASSERT_EQ(reader->GetFileSize(), 0); + + ASSERT_TRUE(reader->MoveToNextFile()); + ASSERT_EQ(reader->GetFileName(), + "test_archive/folder 1/folder 1a/file 1a1.txt"); + ASSERT_EQ(reader->GetFileSize(), 21); + ASSERT_TRUE(reader->OpenFile("")); + ASSERT_EQ(reader->ReadFile(buff, sizeof(buff)), 21); + ASSERT_TRUE(reader->CloseFile()); + ASSERT_TRUE(!strncmp(buff, "Contents of file 1A1.", 21)); + + ASSERT_TRUE(reader->MoveToNextFile()); + ASSERT_EQ(reader->GetFileName(), "test_archive/folder 2/"); + ASSERT_EQ(reader->GetFileSize(), 0); + + ASSERT_TRUE(reader->MoveToNextFile()); + ASSERT_EQ(reader->GetFileName(), "test_archive/folder 2/file 2a.txt"); + ASSERT_EQ(reader->GetFileSize(), 20); + ASSERT_TRUE(reader->OpenFile("")); + ASSERT_EQ(reader->ReadFile(buff, sizeof(buff)), 20); + ASSERT_TRUE(reader->CloseFile()); + ASSERT_TRUE(!strncmp(buff, "Contents of file 2A.", 20)); + + ASSERT_FALSE(reader->MoveToNextFile()); + + // Try seeking a particular file + ASSERT_TRUE(reader->MoveToFile("TEST_ARCHIVE/FOLDER 1/FILE 1B.TXT", false)); + ASSERT_EQ(reader->GetFileName(), "test_archive/folder 1/file 1b.txt"); + ASSERT_EQ(reader->GetFileSize(), 20); + ASSERT_TRUE(reader->OpenFile("")); + ASSERT_EQ(reader->ReadFile(buff, sizeof(buff)), 20); + ASSERT_TRUE(reader->CloseFile()); + ASSERT_TRUE(!strncmp(buff, "Contents of file 1B.", 20)); + + ASSERT_TRUE(reader->MoveToFile("test_archive/folder 1/file 1b.txt", true)); + ASSERT_FALSE(reader->MoveToFile("test_archive/folder 1/FILE 1B.txt", true)); + + ASSERT_TRUE(reader->Close()); +} + +// Test CefZipArchive object. +TEST(ZipReaderTest, ReadArchive) { + // Create the stream reader. + CefRefPtr stream( + CefStreamReader::CreateForData(g_test_zip, sizeof(g_test_zip) - 1)); + ASSERT_TRUE(stream.get() != NULL); + + // Create the Zip archive object. + CefRefPtr archive(new CefZipArchive()); + + ASSERT_EQ(archive->Load(stream, false), (size_t)5); + + ASSERT_TRUE(archive->HasFile("test_archive/file 1.txt")); + ASSERT_TRUE(archive->HasFile("test_archive/folder 1/file 1a.txt")); + ASSERT_TRUE(archive->HasFile("test_archive/FOLDER 1/file 1b.txt")); + ASSERT_TRUE(archive->HasFile("test_archive/folder 1/folder 1a/file 1a1.txt")); + ASSERT_TRUE(archive->HasFile("test_archive/folder 2/file 2a.txt")); + + // Test content retrieval. + CefRefPtr file; + file = archive->GetFile("test_archive/folder 2/file 2a.txt"); + ASSERT_TRUE(file.get()); + + ASSERT_EQ(file->GetDataSize(), (size_t)20); + ASSERT_TRUE(!strncmp(reinterpret_cast(file->GetData()), + "Contents of file 2A.", 20)); + + // Test stream reading. + CefRefPtr reader(file->GetStreamReader()); + ASSERT_TRUE(reader.get()); + + char buff[8]; + ASSERT_EQ(reader->Read(buff, 1, 8), (size_t)8); + ASSERT_TRUE(!strncmp(buff, "Contents", 8)); + ASSERT_EQ(reader->Read(buff, 1, 8), (size_t)8); + ASSERT_TRUE(!strncmp(buff, " of file", 8)); + ASSERT_EQ(reader->Read(buff, 1, 8), (size_t)4); + ASSERT_TRUE(!strncmp(buff, " 2A.", 4)); + ASSERT_TRUE(reader->Eof()); +} diff --git a/cef3/tools/automate/automate-git.py b/cef3/tools/automate/automate-git.py new file mode 100644 index 000000000..4afb4d37a --- /dev/null +++ b/cef3/tools/automate/automate-git.py @@ -0,0 +1,404 @@ +# 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. + +from optparse import OptionParser +from subprocess import Popen, PIPE, STDOUT +from tempfile import mktemp +import os +import shlex +import shutil +import sys +import urllib + +# default URL values +chromium_url = 'http://git.chromium.org/chromium/src.git' +depot_tools_url = 'http://src.chromium.org/svn/trunk/tools/depot_tools' + +def check_url(url): + """ Check the URL and raise an exception if invalid. """ + if ':' in url[:7]: + parts = url.split(':', 1) + if (parts[0] in ["http", "https", "git"] and \ + parts[1] == urllib.quote(parts[1])): + return url + sys.stderr.write('Invalid URL: '+url+"\n") + raise Exception('Invalid URL: '+url) + +def get_exec_environ(): + env = os.environ + env['PATH'] = depot_tools_dir + os.pathsep + env['PATH'] + return env + +def run(args, **kwargs): + '''Run a command and capture the output iteratively''' + if isinstance(args, str): + args = shlex.split(args.replace('\\', '\\\\')) + cwd = kwargs.get("cwd", os.getcwd()) + quiet = kwargs.get("quiet", False) + print "-> Running '%s' in %s" % (" ".join(args), os.path.relpath(cwd)) + cmd = Popen(args, cwd=cwd, stdout=PIPE, stderr=STDOUT, + env=kwargs.get("env", get_exec_environ()), + shell=(sys.platform == 'win32')) + output = '' + while True: + out = cmd.stdout.read(1) + if out == '' and cmd.poll() != None: + break + output += out + if not quiet: + sys.stdout.write(out) + if cmd.wait() != 0: + raise Exception("Command failed: \"%s\"" % " ".join(args), output) + return output + +def get_current_branch(path): + return run("git rev-parse --abbrev-ref HEAD", cwd=path, quiet=True) + +def get_chromium_compat_rev(cef_url, path, cef_rev): + if not os.path.isdir(path): + path = mktemp() + run("git clone --depth 1 %s %s" % (cef_url, path), quiet = True) + if cef_rev == "None": + cef_rev = get_git_rev(path, get_current_branch(path)) + compat_cmd = "git cat-file -p %s:CHROMIUM_BUILD_COMPATIBILITY.txt" % cef_rev + compat_value = run(compat_cmd, cwd = path, quiet = True) + config = eval(compat_value, {'__builtins__': None}, None) + if not 'chromium_revision' in config: + raise Exception("Missing chromium_revision value") + return str(int(config['chromium_revision'])) + +def get_svn_rev(path, branch): + svn_rev = "None" + cmd = ("git log --grep=^git-svn-id: -n 1 %s" % branch).split() + try: + process = Popen(cmd, cwd=path, stdout = PIPE, stderr = PIPE) + for line in process.stdout: + if line.find("git-svn-id") > 0: + svn_rev = line.split("@")[1].split()[0] + break + except IOError, (errno, strerror): + sys.stderr.write('Failed to read git log: ' + strerror + "\n") + raise + return svn_rev + +def get_git_rev_for_svn_rvn(path, svn_rev): + git_rev = "None" + cmd = ("git log --grep=^git-svn-id:.*@%s --oneline" % svn_rev).split() + try: + process = Popen(cmd, cwd=path, stdout = PIPE, stderr = PIPE) + git_rev = process.communicate()[0].split()[0] + except IOError, (errno, strerror): + sys.stderr.write('Failed to read git log: ' + strerror + "\n") + raise + return git_rev + +def get_git_rev(path, branch): + git_rev = "None" + cmd = ("git describe --always %s" % branch).split() + try: + process = Popen(cmd, cwd=path, stdout = PIPE, stderr = PIPE) + git_rev = process.communicate()[0].strip() + except IOError, (errno, strerror): + sys.stderr.write('Failed to read git log: ' + strerror + "\n") + raise + return git_rev + +def get_git_origin(path): + git_origin = "None" + get_origin_cmd = "git remote show origin -n".split() + try: + process = Popen(get_origin_cmd, cwd=path, stdout = PIPE, stderr = PIPE) + for line in process.stdout: + if line.startswith(" Fetch URL: "): + git_origin = line.replace(" Fetch URL: ", "").strip() + break + except IOError, (errno, strerror): + sys.stderr.write('Failed to read git log: ' + strerror + "\n") + raise + return git_origin + +def get_checkout_info(path, fetch_latest = True): + """ Retrieves the origin URL, git HEAD revision and last SVN revision """ + url = 'None' + origin_svn_rev = 'None' + origin_git_rev = 'None' + local_svn_rev = 'None' + local_git_rev = 'None' + if os.path.isdir(path): + if fetch_latest: + run("git fetch", cwd = path, quiet = True) + url = get_git_origin(path) + branch = get_current_branch(path) + origin_svn_rev = get_svn_rev(path, "origin/%s" % branch) + origin_git_rev = get_git_rev(path, "origin/%s" % branch) + local_svn_rev = get_svn_rev(path, branch) + local_git_rev = get_git_rev(path, branch) + return { + 'url' : url, + 'local' : { + 'svn-revision' : local_svn_rev, + 'git-revision' : local_git_rev + }, + 'origin' : { + 'svn-revision' : origin_svn_rev, + 'git-revision' : origin_git_rev + } + } + +def onerror(func, path, exc_info): + """ + Error handler for ``shutil.rmtree``. + + If the error is due to an access error (read only file) + it attempts to add write permission and then retries. + + If the error is for another reason it re-raises the error. + + Usage : ``shutil.rmtree(path, onerror=onerror)`` + """ + import stat + if not os.access(path, os.W_OK): + # Is the error an access error ? + os.chmod(path, stat.S_IWUSR) + func(path) + else: + raise + +# cannot be loaded as a module +if __name__ != "__main__": + sys.stderr.write('This file cannot be loaded as a module!') + sys.exit() + +# parse command-line options +desc = """ +This utility implements automation for the download, update, build and +distribution of CEF. +""" + +parser = OptionParser(description=desc) +parser.add_option('--url', dest='url', + help='CEF source URL') +parser.add_option('--download-dir', dest='downloaddir', metavar='DIR', + help='download directory with no spaces [required]') +parser.add_option('--revision', dest='revision', + help='CEF source revision') +parser.add_option('--force-config', + action='store_true', dest='forceconfig', default=False, + help='force Chromium configuration') +parser.add_option('--force-clean', + action='store_true', dest='forceclean', default=False, + help='force revert of all Chromium changes, deletion of '+\ + 'all unversioned files including the CEF folder and '+\ + 'trigger the force-update, force-build and '+\ + 'force-distrib options') +parser.add_option('--force-update', + action='store_true', dest='forceupdate', default=False, + help='force Chromium and CEF update') +parser.add_option('--force-build', + action='store_true', dest='forcebuild', default=False, + help='force CEF debug and release builds') +parser.add_option('--force-distrib', + action='store_true', dest='forcedistrib', default=False, + help='force creation of CEF binary distribution') +parser.add_option('--no-debug-build', + action='store_true', dest='nodebugbuild', default=False, + help="don't perform the CEF debug build") +parser.add_option('--no-release-build', + action='store_true', dest='noreleasebuild', default=False, + help="don't perform the CEF release build") +parser.add_option('--no-distrib', + action='store_true', dest='nodistrib', default=False, + help="don't create the CEF binary distribution") +(options, args) = parser.parse_args() + +# the downloaddir and url options are required +if options.downloaddir is None: + print "ERROR: Download directory is required" + parser.print_help(sys.stderr) + sys.exit() +if options.url is None: + print "ERROR: CEF URL is required" + parser.print_help(sys.stderr) + sys.exit() + +cef_url = check_url(options.url) +download_dir = os.path.abspath(options.downloaddir) +if not os.path.exists(download_dir): + # create the download directory + os.makedirs(download_dir) + +# Test the operating system. +platform = ''; +if sys.platform == 'win32': + platform = 'windows' +elif sys.platform == 'darwin': + platform = 'macosx' +elif sys.platform.startswith('linux'): + platform = 'linux' + +# set the expected script extension +if platform == 'windows': + script_ext = '.bat' +else: + script_ext = '.sh' + +# check if the "depot_tools" directory exists +depot_tools_dir = os.path.join(download_dir, 'depot_tools') +if not os.path.exists(depot_tools_dir): + # checkout depot_tools + run('svn checkout %s %s' % (depot_tools_url, depot_tools_dir), + cwd = download_dir, quiet = True) + +chromium_dir = os.path.join(download_dir, 'chromium') +if not os.path.exists(chromium_dir): + # create the "chromium" directory + os.makedirs(chromium_dir) + +chromium_src_dir = os.path.join(chromium_dir, 'src') +cef_src_dir = os.path.join(chromium_src_dir, 'cef') +cef_tools_dir = os.path.join(cef_src_dir, 'tools') + +# retrieve the current CEF URL and revision +info = get_checkout_info(cef_src_dir) +cef_rev = info['origin']['git-revision'] +if not options.revision is None: + cef_rev = str(options.revision) +current_cef_url = info['url'] +current_cef_rev = info['local']['git-revision'] + +# retrieve the compatible Chromium revision +chromium_rev = get_chromium_compat_rev(cef_url, cef_src_dir, cef_rev) + +# retrieve the current Chromium URL and revision +info = get_checkout_info(chromium_src_dir, False) +current_chromium_url = info['url'] +current_chromium_rev = info['local']['svn-revision'] + +# test if the CEF URL changed +cef_url_changed = current_cef_url != cef_url +print "-- CEF URL: %s" % current_cef_url +if cef_url_changed: + print "\t-> CHANGED TO: %s" % cef_url + +# test if the CEF revision changed +cef_rev_changed = current_cef_rev != cef_rev +print "-- CEF Revision: %s" % current_cef_rev +if cef_url_changed: + print "\t-> CHANGED TO: %s" % cef_rev + +# test if the Chromium URL changed +chromium_url_changed = current_chromium_url != chromium_url +print "-- Chromium URL: %s" % current_chromium_url +if cef_url_changed: + print "\t-> CHANGED TO: %s" % chromium_url + +# test if the Chromium revision changed +chromium_rev_changed = current_chromium_rev != chromium_rev +print "-- Chromium Revision: %s" % current_chromium_rev +if cef_url_changed: + print "\t-> CHANGED TO: %s" % chromium_rev + +# true if anything changed +any_changed = chromium_url_changed or chromium_rev_changed or \ + cef_url_changed or cef_rev_changed +if not any_changed: + print "*** NO CHANGE ***" + +if chromium_url_changed or options.forceconfig: + # run gclient config to create the .gclient file + run('gclient config %s --git-deps' % chromium_url, cwd = chromium_dir) + + path = os.path.join(chromium_dir, '.gclient') + if not os.path.exists(path): + raise Exception('.gclient file was not created') + + # read the resulting .gclient file + fp = open(path, 'r') + data = fp.read() + fp.close() + + # populate "custom_deps" section + data = data.replace('"custom_deps" : {', '"custom_deps" : {'+\ + "\n "+'"src/third_party/WebKit/LayoutTests": None,'+\ + "\n "+'"src/chrome_frame/tools/test/reference_build/chrome": None,'+\ + "\n "+'"src/chrome/tools/test/reference_build/chrome_mac": None,'+\ + "\n "+'"src/chrome/tools/test/reference_build/chrome_win": None,'+\ + "\n "+'"src/chrome/tools/test/reference_build/chrome_linux": None,') + + # write the new .gclient file + fp = open(path, 'w') + fp.write(data) + fp.close() + +if options.forceclean: + if os.path.exists(chromium_src_dir): + # revert all Chromium changes and delete all unversioned files + run('gclient revert -n', cwd = chromium_dir) + + # remove the build output directories + output_dirs = [] + if platform == 'windows': + output_dirs.append(os.path.join(chromium_src_dir, 'build\\Debug')) + output_dirs.append(os.path.join(chromium_src_dir, 'build\\Release')) + elif platform == 'macosx': + output_dirs.append(os.path.join(chromium_src_dir, 'xcodebuild')) + elif platform == 'linux': + output_dirs.append(os.path.join(chromium_src_dir, 'out')) + + for output_dir in output_dirs: + if os.path.exists(output_dir): + shutil.rmtree(output_dir, onerror=onerror) + + # force update, build and distrib steps + options.forceupdate = True + options.forcebuild = True + options.forcedistrib = True + +if chromium_url_changed or chromium_rev_changed or options.forceupdate: + # download/update the Chromium source cod + fetch_rev = "HEAD" + if os.path.isdir(chromium_src_dir): + fetch_rev = get_git_rev_for_svn_rvn( + chromium_src_dir, current_chromium_rev) + run('gclient sync --jobs 8 -n --force --revision=src@%s' % fetch_rev, + cwd = chromium_dir) + checkout_rev = get_git_rev_for_svn_rvn(chromium_src_dir, chromium_rev) + run('gclient sync --jobs 8 --revision=src@%s' % checkout_rev, + cwd = chromium_dir) + +if not os.path.exists(cef_src_dir) or cef_url_changed: + if cef_url_changed and os.path.exists(cef_src_dir): + # delete the cef directory (it will be re-downloaded) + shutil.rmtree(cef_src_dir) + # download the CEF source code + run("git clone %s %s" % (cef_url, cef_src_dir)) +elif cef_rev_changed or options.forceupdate: + # update the CEF source code + stashed = run("git stash", cwd = cef_src_dir).find( + "No local changes to save") < 0 + ref = cef_rev + if ref == "None": + ref = "origin/%s" % get_current_branch(cef_src_dir) + run("git fetch origin", cwd = cef_src_dir) + run("git reset --hard %s" % ref, cwd = cef_src_dir) + if stashed: + run("git stash pop", cwd = cef_src_dir) + +if any_changed or options.forceupdate: + # create CEF projects + path = os.path.join(cef_src_dir, 'cef_create_projects' + script_ext) + run(path, cwd = cef_src_dir, quiet = True) + +if any_changed or options.forcebuild: + path = os.path.join(cef_tools_dir, 'build_projects' + script_ext) + if not options.nodebugbuild: + run(path +' Debug', cwd = cef_tools_dir) + if not options.noreleasebuild: + run(path +' Release', cwd = cef_tools_dir) + +if any_changed or options.forcedistrib: + if not options.nodistrib: + # make CEF binary distribution + path = os.path.join(cef_tools_dir, 'make_distrib' + script_ext) + run(path, cwd = cef_tools_dir) diff --git a/cef3/tools/automate/automate.README.txt b/cef3/tools/automate/automate.README.txt new file mode 100644 index 000000000..505be746a --- /dev/null +++ b/cef3/tools/automate/automate.README.txt @@ -0,0 +1,99 @@ +Chromium Embedded Framework (CEF) Automation Tool +------------------------------------------------------------------------------- + +Document Last Updated: October 10, 2011 + + +OVERVIEW +-------- + +The CEF Automation Tool can perform the following actions in an automated manner: + +1. Download/update the Chromium and CEF source code. +2. Build the CEF Debug and Release targets. +3. Create the CEF binary distribution package. + + +SETUP +----- + +1. Install Subversion [1] and Python [2]. Make sure the bin directories for both + programs are discoverable via your system PATH configuration. On Windows + install CppDoc [3] in the default location (assumes a 64bit version of + Windows 7). + +2. Install build tools. On Windows install Visual Studio 2008 or newer and all + required prerequisite software [4]. On Mac install Xcode 3.2 or newer. + +3. Configure the GYP environment. On Windows set the GYP_MSVS_VERSION + environment variable to "2008" or "2010" depending on which version of Visual + Studio you're building with. On Mac Lion set the GYP_DEFINES environment + variable to 'mac_sdk=10.6'. + +4. Checkout the "automate" folder to a location on your hard drive. For the + trunk version of CEF you can use the following command: + + svn checkout http://chromiumembedded.googlecode.com/svn/trunk/cef3/tools/automate /path/to/automate + +5. Run the automate.py script at whatever interval is appropriate (for each + CEF commit, once per day, once per week, etc): + + python /path/to/automate/automate.py --download-dir=/path/to/download + + +HOW IT WORKS +------------ + +The automate.py script performs the following actions in the download directory +specified by the "--download-dir" flag. This path value must contain no spaces. + +1. Retrieve the Chromium URL and revision associated with a CEF URL and + revision. A specific CEF URL and revision can be specified using the "--url" + and "--revision" flags. Otherwise, the current CEF trunk URL [7] and HEAD + revision will be used. The Chromium URL and revision are retrieved by + querying the SVN repository for a CHROMIUM_BUILD_COMPATIBILITY.txt file. + +2. If a "depot_tools" folder does not already exist download depot_tools [5]. + The depot_tools folder will be added to the beginning of the PATH to support + execution of the below steps. + +3. If a "chromium" folder does not already exist create it and configure + gclient [6] using the Chromium URL retrieved in step 1. To force execution of + this step use the "--force-config" flag. + +4. If the "--force-clean" flag is specified all Chromium changes will be + reverted, all unversioned files including the CEF folder will be deleted and + steps 6-10 will be triggered automatically. + +5. If both Chromium and CEF are already at the correct URL and revision the + script will exit at this point. To force execution of steps 6-8 use the + "--force-update" flag. To force execution of step 9 use the "--force-build" + flag. To force execution of step 10 use the "--force-distrib" flag. + +6. Use gclient [6] to update the Chromium source code to the correct revision. + +7. If a "chromium/src/cef" folder does not already exist download the CEF source + code at the correct revision. Otherwise, update CEF source code to the + correct revision. + +8. Run the "chromium/src/cef/cef_create_projects.[sh|bat]" script to apply CEF + patches and generate CEF project files. + +9. Run the "chromium/src/cef/tools/build_projects.[sh|bat]" script twice; once + to build the Debug target and once to build the Release target. + +10.Run the "chromium/src/cef/tools/make_distrib.[sh|bat]" script to build the + binary distribution package. The resulting package will be output in a + "chromium/src/cef/binary_distrib/cef_binary_rXXX_[windows|macosx]" folder. + + +REFERENCES +---------- + +[1] http://subversion.apache.org/ +[2] http://www.python.org/ +[3] http://www.cppdoc.com/ +[4] http://dev.chromium.org/developers/how-tos/build-instructions-windows +[5] http://dev.chromium.org/developers/how-tos/depottools +[6] http://dev.chromium.org/developers/how-tos/get-the-code +[7] http://chromiumembedded.googlecode.com/svn/trunk/cef3 diff --git a/cef3/tools/automate/automate.py b/cef3/tools/automate/automate.py new file mode 100644 index 000000000..95476b4bf --- /dev/null +++ b/cef3/tools/automate/automate.py @@ -0,0 +1,389 @@ +# 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. + +from optparse import OptionParser +import os +import re +import shlex +import shutil +import subprocess +import sys +import urllib + +# default URL values +cef_url = 'http://chromiumembedded.googlecode.com/svn/trunk/cef3' +depot_tools_url = 'http://src.chromium.org/svn/trunk/tools/depot_tools' + +def run(command_line, working_dir, depot_tools_dir=None): + # add depot_tools to the path + env = os.environ + if not depot_tools_dir is None: + env['PATH'] = depot_tools_dir+os.pathsep+env['PATH'] + + sys.stdout.write('-------- Running "'+command_line+'" in "'+\ + working_dir+'"...'+"\n") + args = shlex.split(command_line.replace('\\', '\\\\')) + return subprocess.check_call(args, cwd=working_dir, env=env, + shell=(sys.platform == 'win32')) + +def check_url(url): + """ Check the URL and raise an exception if invalid. """ + if ':' in url[:7]: + parts = url.split(':', 1) + if (parts[0] == 'http' or parts[0] == 'https') and \ + parts[1] == urllib.quote(parts[1]): + return url + sys.stderr.write('Invalid URL: '+url+"\n") + raise Exception('Invalid URL: '+url) + +def get_svn_info(path): + """ Retrieves the URL and revision from svn info. """ + url = 'None' + rev = 'None' + if path[0:4] == 'http' or os.path.exists(path): + try: + stream = os.popen('svn info '+path) + for line in stream: + if line[0:4] == "URL:": + url = check_url(line[5:-1]) + elif line[0:9] == "Revision:": + rev = str(int(line[10:-1])) + except IOError, (errno, strerror): + sys.stderr.write('Failed to read svn info: '+strerror+"\n") + raise + return {'url': url, 'revision': rev} + +def onerror(func, path, exc_info): + """ + Error handler for ``shutil.rmtree``. + + If the error is due to an access error (read only file) + it attempts to add write permission and then retries. + + If the error is for another reason it re-raises the error. + + Usage : ``shutil.rmtree(path, onerror=onerror)`` + """ + import stat + if not os.access(path, os.W_OK): + # Is the error an access error ? + os.chmod(path, stat.S_IWUSR) + func(path) + else: + raise + +# cannot be loaded as a module +if __name__ != "__main__": + sys.stderr.write('This file cannot be loaded as a module!') + sys.exit() + +# parse command-line options +disc = """ +This utility implements automation for the download, update, build and +distribution of CEF. +""" + +parser = OptionParser(description=disc) +parser.add_option('--download-dir', dest='downloaddir', metavar='DIR', + help='download directory with no spaces [required]') +parser.add_option('--revision', dest='revision', type="int", + help='CEF source revision') +parser.add_option('--url', dest='url', + help='CEF source URL') +parser.add_option('--force-config', + action='store_true', dest='forceconfig', default=False, + help='force Chromium configuration') +parser.add_option('--force-clean', + action='store_true', dest='forceclean', default=False, + help='force revert of all Chromium changes, deletion of '+\ + 'all unversioned files including the CEF folder and '+\ + 'trigger the force-update, force-build and '+\ + 'force-distrib options') +parser.add_option('--force-update', + action='store_true', dest='forceupdate', default=False, + help='force Chromium and CEF update') +parser.add_option('--force-build', + action='store_true', dest='forcebuild', default=False, + help='force CEF debug and release builds') +parser.add_option('--force-distrib', + action='store_true', dest='forcedistrib', default=False, + help='force creation of CEF binary distribution') +parser.add_option('--no-debug-build', + action='store_true', dest='nodebugbuild', default=False, + help="don't perform the CEF debug build") +parser.add_option('--no-release-build', + action='store_true', dest='noreleasebuild', default=False, + help="don't perform the CEF release build") +parser.add_option('--no-distrib', + action='store_true', dest='nodistrib', default=False, + help="don't create the CEF binary distribution") +(options, args) = parser.parse_args() + +# the downloaddir option is required +if options.downloaddir is None: + parser.print_help(sys.stderr) + sys.exit() + +# script directory +script_dir = os.path.dirname(__file__) + +if not options.url is None: + # set the CEF URL + cef_url = check_url(options.url) + +if not options.revision is None: + # set the CEF revision + cef_rev = str(options.revision) +else: + # retrieve the CEF revision from the remote repo + info = get_svn_info(cef_url) + cef_rev = info['revision'] + if cef_rev == 'None': + sys.stderr.write('No SVN info for: '+cef_url+"\n") + raise Exception('No SVN info for: '+cef_url) + +# Retrieve the Chromium URL and revision from the CEF repo +compat_url = cef_url + "/CHROMIUM_BUILD_COMPATIBILITY.txt?r="+cef_rev + +release_url = None +chromium_url = None +chromium_rev = None + +try: + # Read the remote URL contents + handle = urllib.urlopen(compat_url) + compat_value = handle.read().strip() + handle.close() + + # Parse the contents + config = eval(compat_value, {'__builtins__': None}, None) + + if 'release_url' in config: + # building from a release + release_url = check_url(config['release_url']) + else: + # building from chromium src + if not 'chromium_url' in config: + raise Exception("Missing chromium_url value") + if not 'chromium_revision' in config: + raise Exception("Missing chromium_revision value") + + chromium_url = check_url(config['chromium_url']) + chromium_rev = str(int(config['chromium_revision'])) +except Exception, e: + sys.stderr.write('Failed to read URL and revision information from '+ \ + compat_url+"\n") + raise + +download_dir = options.downloaddir +if not os.path.exists(download_dir): + # create the download directory + os.makedirs(download_dir) + +# Test the operating system. +platform = ''; +if sys.platform == 'win32': + platform = 'windows' +elif sys.platform == 'darwin': + platform = 'macosx' +elif sys.platform.startswith('linux'): + platform = 'linux' + +# set the expected script extension +if platform == 'windows': + script_ext = '.bat' +else: + script_ext = '.sh' + +# check if the "depot_tools" directory exists +depot_tools_dir = os.path.join(download_dir, 'depot_tools') +if not os.path.exists(depot_tools_dir): + # checkout depot_tools + run('svn checkout '+depot_tools_url+' '+depot_tools_dir, download_dir) + +# check if the "chromium" directory exists +chromium_dir = os.path.join(download_dir, 'chromium') +if not os.path.exists(chromium_dir): + # create the "chromium" directory + os.makedirs(chromium_dir) + +chromium_src_dir = os.path.join(chromium_dir, 'src') +cef_src_dir = os.path.join(chromium_src_dir, 'cef') +cef_tools_dir = os.path.join(cef_src_dir, 'tools') + +# retrieve the current CEF URL and revision +info = get_svn_info(cef_src_dir) +current_cef_url = info['url'] +current_cef_rev = info['revision'] + +if release_url is None: + # retrieve the current Chromium URL and revision + info = get_svn_info(chromium_src_dir) + current_chromium_url = info['url'] + current_chromium_rev = info['revision'] + +# test if the CEF URL changed +cef_url_changed = current_cef_url != cef_url +sys.stdout.write('CEF URL: '+current_cef_url+"\n") +if cef_url_changed: + sys.stdout.write(' -> CHANGED TO: '+cef_url+"\n") + +# test if the CEF revision changed +cef_rev_changed = current_cef_rev != cef_rev +sys.stdout.write('CEF Revision: '+current_cef_rev+"\n") +if cef_rev_changed: + sys.stdout.write(' -> CHANGED TO: '+cef_rev+"\n") + +release_url_changed = False +chromium_url_changed = False +chromium_rev_changed = False + +if release_url is None: + # test if the Chromium URL changed + chromium_url_changed = current_chromium_url != chromium_url + sys.stdout.write('Chromium URL: '+current_chromium_url+"\n") + if chromium_url_changed: + sys.stdout.write(' -> CHANGED TO: '+chromium_url+"\n") + + # test if the Chromium revision changed + chromium_rev_changed = current_chromium_rev != chromium_rev + sys.stdout.write('Chromium Revision: '+current_chromium_rev+"\n") + if chromium_rev_changed: + sys.stdout.write(' -> CHANGED TO: '+chromium_rev+"\n") +else: + # test if the release URL changed + current_release_url = 'None' + + path = os.path.join(chromium_dir, '.gclient') + if os.path.exists(path): + # read the .gclient file + fp = open(path, 'r') + data = fp.read() + fp.close() + + # Parse the contents + config_dict = {} + try: + exec(data, config_dict) + current_release_url = config_dict['solutions'][0]['url'] + except Exception, e: + sys.stderr.write('Failed to parse existing .glient file.\n') + raise + + release_url_changed = current_release_url != release_url + sys.stdout.write('Release URL: '+current_release_url+"\n") + if release_url_changed: + sys.stdout.write(' -> CHANGED TO: '+release_url+"\n") + +# true if anything changed +any_changed = release_url_changed or chromium_url_changed or \ + chromium_rev_changed or cef_url_changed or cef_rev_changed +if not any_changed: + sys.stdout.write("No changes.\n") + +if release_url_changed or chromium_url_changed or options.forceconfig: + if release_url is None: + url = chromium_url + else: + url = release_url + + # run gclient config to create the .gclient file + run('gclient config '+url, chromium_dir, depot_tools_dir) + + path = os.path.join(chromium_dir, '.gclient') + if not os.path.exists(path): + sys.stderr.write(".gclient file was not created\n") + raise Exception('.gclient file was not created') + + # read the resulting .gclient file + fp = open(path, 'r') + data = fp.read() + fp.close() + + custom_deps = \ + "\n "+'"src/third_party/WebKit/LayoutTests": None,'+\ + "\n "+'"src/chrome_frame/tools/test/reference_build/chrome": None,'+\ + "\n "+'"src/chrome/tools/test/reference_build/chrome_mac": None,'+\ + "\n "+'"src/chrome/tools/test/reference_build/chrome_win": None,'+\ + "\n "+'"src/chrome/tools/test/reference_build/chrome_linux": None,' + + if not release_url is None: + # TODO: Read the DEPS file and exclude all non-src directories. + custom_deps += \ + "\n "+'"chromeos": None,'+\ + "\n "+'"depot_tools": None,' + + # populate "custom_deps" section + data = data.replace('"custom_deps" : {', '"custom_deps" : {'+custom_deps) + + # write the new .gclient file + fp = open(path, 'w') + fp.write(data) + fp.close() + +if options.forceclean: + if os.path.exists(chromium_src_dir): + # revert all Chromium changes and delete all unversioned files + run('gclient revert -n', chromium_dir, depot_tools_dir) + + # remove the build output directories + output_dirs = [] + if platform == 'windows': + output_dirs.append(os.path.join(chromium_src_dir, 'build\\Debug')) + output_dirs.append(os.path.join(chromium_src_dir, 'build\\Release')) + elif platform == 'macosx': + output_dirs.append(os.path.join(chromium_src_dir, 'xcodebuild')) + elif platform == 'linux': + output_dirs.append(os.path.join(chromium_src_dir, 'out')) + + for output_dir in output_dirs: + if os.path.exists(output_dir): + shutil.rmtree(output_dir, onerror=onerror) + + # force update, build and distrib steps + options.forceupdate = True + options.forcebuild = True + options.forcedistrib = True + +if release_url is None: + if chromium_url_changed or chromium_rev_changed or options.forceupdate: + # download/update the Chromium source code + run('gclient sync --revision src@'+chromium_rev+' --jobs 8 --force', \ + chromium_dir, depot_tools_dir) +elif release_url_changed or options.forceupdate: + # download/update the release source code + run('gclient sync --jobs 8 --force', chromium_dir, depot_tools_dir) + +if not os.path.exists(cef_src_dir) or cef_url_changed: + if cef_url_changed and os.path.exists(cef_src_dir): + # delete the cef directory (it will be re-downloaded) + shutil.rmtree(cef_src_dir) + + # download the CEF source code + run('svn checkout '+cef_url+' -r '+cef_rev+' '+cef_src_dir, download_dir) +elif cef_rev_changed or options.forceupdate: + # update the CEF source code + run('svn update -r '+cef_rev+' '+cef_src_dir, download_dir) + +if any_changed or options.forceupdate: + # create CEF projects + path = os.path.join(cef_src_dir, 'cef_create_projects'+script_ext) + run(path, cef_src_dir, depot_tools_dir) + +if any_changed or options.forcebuild: + path = os.path.join(cef_tools_dir, 'build_projects'+script_ext) + + if not options.nodebugbuild: + # make CEF Debug build + run(path+' Debug', cef_tools_dir, depot_tools_dir) + + if not options.noreleasebuild: + # make CEF Release build + run(path+' Release', cef_tools_dir, depot_tools_dir) + +if any_changed or options.forcedistrib: + if not options.nodistrib: + # make CEF binary distribution + path = os.path.join(cef_tools_dir, 'make_distrib'+script_ext) + run(path, cef_tools_dir, depot_tools_dir) diff --git a/cef3/tools/build_projects.bat b/cef3/tools/build_projects.bat new file mode 100644 index 000000000..e8e2ed99f --- /dev/null +++ b/cef3/tools/build_projects.bat @@ -0,0 +1,48 @@ +@echo off +set RC= +setlocal + +if "%1" == "" ( +echo ERROR: Please specify a build target: Debug or Release +set ERRORLEVEL=1 +goto end +) + +if "%2" == "" ( +set PROJECT_NAME=cefclient +) else ( +set PROJECT_NAME=%2 +) + +echo Configuring Visual Studio environment... +if "%GYP_MSVS_VERSION%" == "2008" ( +call "%VS90COMNTOOLS%vsvars32.bat" +set PROJECT_EXT=.vcproj +) else ( +call "%VS100COMNTOOLS%vsvars32.bat" +set PROJECT_EXT=.vcxproj +set CEF_MSBUILD_PATH=%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe +) + +if exist "%CEF_MSBUILD_PATH%" ( +"%CEF_MSBUILD_PATH%" /v:m /p:Configuration=%1;Platform=Win32 /t:"%PROJECT_NAME%" ..\cef.sln +) else if exist "%DevEnvDir%\devenv.com" ( +echo Building %1 target for %PROJECT_NAME% project... +"%DevEnvDir%\devenv.com" /build %1 ..\cef.sln /project %PROJECT_NAME%%PROJECT_EXT% +) else if exist "%VCINSTALLDIR%\vcpackages\vcbuild.exe" ( +echo Building %1 target for all projects... +"%VCINSTALLDIR%\vcpackages\vcbuild.exe" ..\cef.sln "%1|Win32" +) else ( +echo ERROR: Cannot find Visual Studio builder +set ERRORLEVEL=1 +) + +:end +endlocal & set RC=%ERRORLEVEL% +goto omega + +:returncode +exit /B %RC% + +:omega +call :returncode %RC% diff --git a/cef3/tools/build_projects.sh b/cef3/tools/build_projects.sh new file mode 100755 index 000000000..13eade15d --- /dev/null +++ b/cef3/tools/build_projects.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +if [ -z "$1" ]; then + echo "ERROR: Please specify a build target: Debug or Release" +else + if [ -z "$2" ]; then + PROJECT_NAME='cefclient' + else + PROJECT_NAME=$2 + fi + if [ `uname` = "Linux" ]; then + pushd ../../ + make -j16 $PROJECT_NAME BUILDTYPE=$1 + popd + else + xcodebuild -project ../cef.xcodeproj -configuration $1 -target "$PROJECT_NAME" + fi +fi diff --git a/cef3/tools/cef_api_hash.py b/cef3/tools/cef_api_hash.py new file mode 100644 index 000000000..2b720cd3f --- /dev/null +++ b/cef3/tools/cef_api_hash.py @@ -0,0 +1,246 @@ +# Copyright (c) 2013 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. + +from file_util import * +import os +import re +import shutil +import string +import sys +import textwrap +import time +import itertools +import hashlib + + +class cef_api_hash: + """ CEF API hash calculator """ + + def __init__(self, headerdir, debugdir = None, verbose = False): + if headerdir is None or len(headerdir) == 0: + raise AssertionError("headerdir is not specified") + + self.__headerdir = headerdir; + self.__debugdir = debugdir; + self.__verbose = verbose; + self.__debug_enabled = not (self.__debugdir is None) and len(self.__debugdir) > 0; + + self.platforms = [ "windows", "macosx", "linux" ]; + + self.platform_files = { + "windows": [ + "internal/cef_types_win.h" + ], + "macosx": [ + "internal/cef_types_mac.h", + ], + "linux": [ + "internal/cef_types_linux.h" + ] + }; + + self.included_files = [ + "cef_trace_event.h" + ]; + + self.excluded_files = [ + "cef_version.h", + "internal/cef_tuple.h", + "internal/cef_types_wrappers.h", + "internal/cef_string_wrappers.h", + "internal/cef_win.h", + "internal/cef_mac.h", + "internal/cef_linux.h", + ]; + + def calculate(self): + filenames = [filename for filename in self.__get_filenames() if not filename in self.excluded_files] + + objects = [] + for filename in filenames: + if self.__verbose: + print "Processing " + filename + "..." + content = read_file(os.path.join(self.__headerdir, filename), True) + platforms = list([p for p in self.platforms if self.__is_platform_filename(filename, p)]) + + # Parse cef_string.h happens in special case: grab only defined CEF_STRING_TYPE_xxx declaration + content_objects = None + if filename == "internal/cef_string.h": + content_objects = self.__parse_string_type(content) + else: + content_objects = self.__parse_objects(content) + + for o in content_objects: + o["text"] = self.__prepare_text(o["text"]) + o["platforms"] = platforms + o["filename"] = filename + objects.append(o) + + # objects will be sorted including filename, to make stable universal hashes + objects = sorted(objects, key = lambda o: o["name"] + "@" + o["filename"]) + + if self.__debug_enabled: + namelen = max([len(o["name"]) for o in objects]) + filenamelen = max([len(o["filename"]) for o in objects]) + dumpsig = []; + for o in objects: + dumpsig.append(format(o["name"], str(namelen) + "s") + "|" + format(o["filename"], "" + str(filenamelen) + "s") + "|" + o["text"]); + self.__write_debug_file("objects.txt", dumpsig) + + revisions = { }; + + for platform in itertools.chain(["universal"], self.platforms): + sig = self.__get_final_sig(objects, platform) + if self.__debug_enabled: + self.__write_debug_file(platform + ".sig", sig) + rev = hashlib.sha1(sig).digest(); + revstr = ''.join(format(ord(i),'0>2x') for i in rev) + revisions[platform] = revstr + + return revisions + + def __parse_objects(self, content): + """ Returns array of objects in content file. """ + objects = [] + content = re.sub("//.*\n", "", content) + + # function declarations + for m in re.finditer("\nCEF_EXPORT\s+?.*?\s+?(\w+)\s*?\(.*?\)\s*?;", content, flags = re.DOTALL): + object = { + "name": m.group(1), + "text": m.group(0).strip() + } + objects.append(object) + + # structs + for m in re.finditer("\ntypedef\s+?struct\s+?(\w+)\s+?\{.*?\}\s+?(\w+)\s*?;", content, flags = re.DOTALL): + object = { + "name": m.group(2), + "text": m.group(0).strip() + } + objects.append(object) + + # enums + for m in re.finditer("\nenum\s+?(\w+)\s+?\{.*?\}\s*?;", content, flags = re.DOTALL): + object = { + "name": m.group(1), + "text": m.group(0).strip() + } + objects.append(object) + + # typedefs + for m in re.finditer("\ntypedef\s+?.*?\s+(\w+);", content, flags = 0): + object = { + "name": m.group(1), + "text": m.group(0).strip() + } + objects.append(object) + + return objects + + def __parse_string_type(self, content): + """ Grab defined CEF_STRING_TYPE_xxx """ + objects = [] + for m in re.finditer("\n\s*?#\s*?define\s+?(CEF_STRING_TYPE_\w+)\s+?.*?\n", content, flags = 0): + object = { + "name": m.group(1), + "text": m.group(0), + } + objects.append(object) + return objects + + def __prepare_text(self, text): + text = text.strip() + text = re.sub("\s+", " ", text); + text = re.sub("\(\s+", "(", text); + return text + + def __get_final_sig(self, objects, platform): + sig = [] + + for o in objects: + if platform == "universal" or platform in o["platforms"]: + sig.append(o["text"]) + + return "\n".join(sig) + + def __get_filenames(self): + """ Returns file names to be processed, relative to headerdir """ + headers = [os.path.join(self.__headerdir, filename) for filename in self.included_files]; + headers = itertools.chain(headers, get_files(os.path.join(self.__headerdir, "capi", "*.h"))) + headers = itertools.chain(headers, get_files(os.path.join(self.__headerdir, "internal", "*.h"))) + + for v in self.platform_files.values(): + headers = itertools.chain(headers, [os.path.join(self.__headerdir, f) for f in v]) + + normalized = [os.path.relpath(filename, self.__headerdir) for filename in headers]; + normalized = [f.replace('\\', '/').lower() for f in normalized]; + + return list(set(normalized)); + + def __is_platform_filename(self, filename, platform): + if platform == "universal": + return True + if not platform in self.platform_files: + return False + listed = False + for p in self.platforms: + if filename in self.platform_files[p]: + if p == platform: + return True + else: + listed = True + return not listed + + def __write_debug_file(self, filename, content): + make_dir(self.__debugdir); + outfile = os.path.join(self.__debugdir, filename); + dir = os.path.dirname(outfile); + make_dir(dir); + if not isinstance(content, basestring): + content = "\n".join(content) + write_file(outfile, content) + + +if __name__ == "__main__": + from optparse import OptionParser + import time + + disc = """ + This utility calculates CEF API hash. + """ + + parser = OptionParser(description=disc) + parser.add_option('--cpp-header-dir', dest='cppheaderdir', metavar='DIR', + help='input directory for C++ header files [required]') + parser.add_option('--debug-dir', dest='debugdir', metavar='DIR', + help='intermediate directory for easy debugging') + parser.add_option('-v', '--verbose', + action='store_true', dest='verbose', default=False, + help='output detailed status information') + (options, args) = parser.parse_args() + + # the cppheader option is required + if options.cppheaderdir is None: + parser.print_help(sys.stdout) + sys.exit() + + # calculate + c_start_time = time.time() + + calc = cef_api_hash(options.cppheaderdir, options.debugdir, options.verbose); + revisions = calc.calculate(); + + c_completed_in = time.time() - c_start_time + + print "{" + for k in sorted(revisions.keys()): + print format("\"" + k + "\"", ">12s") + ": \"" + revisions[k] + "\"" + print "}" + # print + # print 'Completed in: ' + str(c_completed_in) + # print + + # print "Press any key to continue..."; + # sys.stdin.readline(); diff --git a/cef3/tools/cef_parser.py b/cef3/tools/cef_parser.py new file mode 100644 index 000000000..a6a275e99 --- /dev/null +++ b/cef3/tools/cef_parser.py @@ -0,0 +1,1852 @@ +# 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. + +from date_util import * +from file_util import * +import os +import re +import shutil +import string +import sys +import textwrap +import time + + +def notify(msg): + """ Display a message. """ + sys.stdout.write(' NOTE: '+msg+'\n') + +def wrap_text(text, indent = '', maxchars = 80): + """ Wrap the text to the specified number of characters. If + necessary a line will be broken and wrapped after a word. + """ + result = '' + lines = textwrap.wrap(text, maxchars - len(indent)) + for line in lines: + result += indent+line+'\n' + return result + +def wrap_code(code, indent = ' ', maxchars = 80, splitchars = '(=,'): + """ Wrap the code lines to the specified number of characters. If + necessary a line will be broken and wrapped after one of the split + characters. + """ + output = '' + + # normalize line endings + code = code.replace("\r\n", "\n") + + # break the code chunk into lines + lines = string.split(code, '\n') + for line in lines: + if len(line) <= maxchars: + # line is short enough that it doesn't need to be wrapped + output += line + '\n' + continue + + # retrieve the whitespace at the beginning of the line for later use + # as padding + ws = '' + for char in line: + if char.isspace(): + ws += char + else: + break + + # iterate over all characters in the string keeping track of where the + # last valid break character was found and wrapping the line + # accordingly + lastsplit = 0 + nextsplit = -1 + splitct = 0 + pos = 0 + for char in line: + if splitchars.find(char) >= 0: + # a new split position has been found + nextsplit = pos + size = pos - lastsplit + 1 + if splitct > 0: + size += len(ws) + len(indent) + if size >= maxchars: + # the line is too long + section = line[lastsplit:nextsplit+1] + if len(section) > 0: + # output the line portion between the last split and the + # next split + if splitct > 0: + # start a new line and trim the line section + output += '\n'+ws+indent + section = string.strip(section) + output += section + lastsplit = nextsplit + 1 + splitct += 1 + pos += 1 + if len(line) - lastsplit > 0: + # output the remainder of the line + section = line[lastsplit:] + if splitct > 0: + # start a new line and trim the line section + output += '\n'+ws+indent + section = string.strip(section) + output += section + output += '\n' + + return output + +def get_capi_file_name(cppname): + """ Convert a C++ header file name to a C API header file name. """ + return cppname[:-2]+'_capi.h' + +def get_capi_name(cppname, isclassname, prefix = None): + """ Convert a C++ CamelCaps name to a C API underscore name. """ + result = '' + lastchr = '' + for chr in cppname: + # add an underscore if the current character is an upper case letter + # and the last character was a lower case letter + if len(result) > 0 and not chr.isdigit() \ + and string.upper(chr) == chr \ + and not string.upper(lastchr) == lastchr: + result += '_' + result += string.lower(chr) + lastchr = chr + + if isclassname: + result += '_t' + + if not prefix is None: + if prefix[0:3] == 'cef': + # if the prefix name is duplicated in the function name + # remove that portion of the function name + subprefix = prefix[3:] + pos = result.find(subprefix) + if pos >= 0: + result = result[0:pos]+ result[pos+len(subprefix):] + result = prefix+'_'+result + + return result + +def get_prev_line(body, pos): + """ Retrieve the start and end positions and value for the line immediately + before the line containing the specified position. + """ + end = string.rfind(body, '\n', 0, pos) + start = body.rfind('\n', 0, end)+1 + line = body[start:end] + return { 'start' : start, 'end' : end, 'line' : line } + +def get_comment(body, name): + """ Retrieve the comment for a class or function. """ + result = [] + + pos = body.find(name) + while pos > 0: + data = get_prev_line(body, pos) + line = string.strip(data['line']) + pos = data['start'] + if len(line) == 0: + # check if the next previous line is a comment + prevdata = get_prev_line(body, pos) + if string.strip(prevdata['line'])[0:2] == '//': + result.append(None) + else: + break + elif line[0:2] == '/*' or line[-2:] == '*/': + continue + elif line[0:2] == '//': + # keep the comment line including any leading spaces + result.append(line[2:]) + else: + break + + result.reverse() + return result + +def format_comment(comment, indent, translate_map = None, maxchars = 80): + """ Return the comments array as a formatted string. """ + result = '' + wrapme = '' + hasemptyline = False + for line in comment: + # if the line starts with a leading space, remove that space + if not line is None and len(line) > 0 and line[0:1] == ' ': + line = line[1:] + didremovespace = True + else: + didremovespace = False + + if line is None or len(line) == 0 or line[0:1] == ' ' \ + or line[0:1] == '/': + # the previous paragraph, if any, has ended + if len(wrapme) > 0: + if not translate_map is None: + # apply the translation + for key in translate_map.keys(): + wrapme = wrapme.replace(key, translate_map[key]) + # output the previous paragraph + result += wrap_text(wrapme, indent+'// ', maxchars) + wrapme = '' + + if not line is None: + if len(line) == 0 or line[0:1] == ' ' or line[0:1] == '/': + # blank lines or anything that's further indented should be + # output as-is + result += indent+'//' + if len(line) > 0: + if didremovespace: + result += ' '+line + else: + result += line + result += '\n' + else: + # add to the current paragraph + wrapme += line+' ' + else: + # output an empty line + hasemptyline = True + result += '\n' + + if len(wrapme) > 0: + if not translate_map is None: + # apply the translation + for key in translate_map.keys(): + wrapme = wrapme.replace(key, translate_map[key]) + # output the previous paragraph + result += wrap_text(wrapme, indent+'// ', maxchars) + + if hasemptyline: + # an empty line means a break between comments, so the comment is + # probably a section heading and should have an extra line before it + result = '\n' + result + return result + +def format_translation_changes(old, new): + """ Return a comment stating what is different between the old and new + function prototype parts. + """ + changed = False + result = '' + + # normalize C API attributes + oldargs = [x.replace('struct _', '') for x in old['args']] + oldretval = old['retval'].replace('struct _', '') + newargs = [x.replace('struct _', '') for x in new['args']] + newretval = new['retval'].replace('struct _', '') + + # check if the prototype has changed + oldset = set(oldargs) + newset = set(newargs) + if len(oldset.symmetric_difference(newset)) > 0: + changed = True + result += '\n // WARNING - CHANGED ATTRIBUTES' + + # in the implementation set only + oldonly = oldset.difference(newset) + for arg in oldonly: + result += '\n // REMOVED: '+arg + + # in the current set only + newonly = newset.difference(oldset) + for arg in newonly: + result += '\n // ADDED: '+arg + + # check if the return value has changed + if oldretval != newretval: + changed = True + result += '\n // WARNING - CHANGED RETURN VALUE'+ \ + '\n // WAS: '+old['retval']+ \ + '\n // NOW: '+new['retval'] + + if changed: + result += '\n #pragma message("Warning: "__FILE__": '+new['name']+ \ + ' prototype has changed")\n' + + return result + +def format_translation_includes(body): + """ Return the necessary list of includes based on the contents of the + body. + """ + result = '' + + if body.find('cef_api_hash(') > 0: + result += '#include "include/cef_version.h"\n' + + # identify what CppToC classes are being used + p = re.compile('([A-Za-z0-9_]{1,})CppToC') + list = sorted(set(p.findall(body))) + for item in list: + result += '#include "libcef_dll/cpptoc/'+ \ + get_capi_name(item[3:], False)+'_cpptoc.h"\n' + + # identify what CToCpp classes are being used + p = re.compile('([A-Za-z0-9_]{1,})CToCpp') + list = sorted(set(p.findall(body))) + for item in list: + result += '#include "libcef_dll/ctocpp/'+ \ + get_capi_name(item[3:], False)+'_ctocpp.h"\n' + + if body.find('transfer_') > 0: + result += '#include "libcef_dll/transfer_util.h"\n' + + return result + +def str_to_dict(str): + """ Convert a string to a dictionary. If the same key has multiple values + the values will be stored in a list. """ + dict = {} + parts = string.split(str, ',') + for part in parts: + part = string.strip(part) + if len(part) == 0: + continue + sparts = string.split(part, '=') + if len(sparts) > 2: + raise Exception('Invalid dictionary pair format: '+part) + name = string.strip(sparts[0]) + if len(sparts) == 2: + val = string.strip(sparts[1]) + else: + val = True + if name in dict: + # a value with this name already exists + curval = dict[name] + if not isinstance(curval, list): + # convert the string value to a list + dict[name] = [curval] + dict[name].append(val) + else: + dict[name] = val + return dict + +def dict_to_str(dict): + """ Convert a dictionary to a string. """ + str = [] + for name in dict.keys(): + if not isinstance(dict[name], list): + if dict[name] is True: + # currently a bool value + str.append(name) + else: + # currently a string value + str.append(name+'='+dict[name]) + else: + # currently a list value + for val in dict[name]: + str.append(name+'='+val) + return string.join(str, ',') + + +# regex for matching comment-formatted attributes +_cre_attrib = '/\*--cef\(([A-Za-z0-9_ ,=:\n]{0,})\)--\*/' +# regex for matching class and function names +_cre_cfname = '([A-Za-z0-9_]{1,})' +# regex for matching function return values +_cre_retval = '([A-Za-z0-9_<>:,\*\&]{1,})' +# regex for matching typedef value and name combination +_cre_typedef = '([A-Za-z0-9_<>:,\*\& ]{1,})' +# regex for matching function return value and name combination +_cre_func = '([A-Za-z][A-Za-z0-9_<>:,\*\& ]{1,})' +# regex for matching virtual function modifiers +_cre_vfmod = '([A-Za-z0-9_]{0,})' +# regex for matching arbitrary whitespace +_cre_space = '[\s]{1,}' + +# Simple translation types. Format is: +# 'cpp_type' : ['capi_type', 'capi_default_value'] +_simpletypes = { + 'void' : ['void', ''], + 'void*' : ['void*', 'NULL'], + 'int' : ['int', '0'], + 'int32' : ['int32', '0'], + 'uint32' : ['uint32', '0'], + 'int64' : ['int64', '0'], + 'uint64' : ['uint64', '0'], + 'double' : ['double', '0'], + 'float' : ['float', '0'], + 'long' : ['long', '0'], + 'unsigned long' : ['unsigned long', '0'], + 'long long' : ['long long', '0'], + 'size_t' : ['size_t', '0'], + 'time_t' : ['time_t', '0'], + 'bool' : ['int', '0'], + 'char': ['char', '0'], + 'char* const': ['char* const', 'NULL'], + 'CefCursorHandle' : ['cef_cursor_handle_t', 'NULL'], + 'CefEventHandle' : ['cef_event_handle_t', 'NULL'], + 'CefWindowHandle' : ['cef_window_handle_t', 'NULL'], + 'CefRect' : ['cef_rect_t', 'CefRect()'], + 'CefThreadId' : ['cef_thread_id_t', 'TID_UI'], + 'CefTime' : ['cef_time_t', 'CefTime()'], +} + +def get_function_impls(content, ident): + """ Retrieve the function parts from the specified contents as a set of + return value, name, arguments and body. Ident must occur somewhere in + the value. + """ + # extract the functions + p = re.compile('\n'+_cre_func+'\((.*?)\)([A-Za-z0-9_\s]{0,})'+ + '\{(.*?)\n\}', + re.MULTILINE | re.DOTALL) + list = p.findall(content) + + # build the function map with the function name as the key + result = [] + for retval, argval, vfmod, body in list: + if retval.find(ident) < 0: + # the identifier was not found + continue + + # remove the identifier + retval = string.replace(retval, ident, '') + retval = string.strip(retval) + + # retrieve the function name + parts = string.split(retval, ' ') + name = parts[-1] + del parts[-1] + retval = string.join(parts, ' ') + + # parse the arguments + args = [] + for v in string.split(argval, ','): + v = string.strip(v) + if len(v) > 0: + args.append(v) + + result.append({ + 'retval' : string.strip(retval), + 'name' : name, + 'args' : args, + 'vfmod' : string.strip(vfmod), + 'body' : body + }) + + return result + +def get_next_function_impl(existing, name): + result = None + for item in existing: + if item['name'] == name: + result = item + existing.remove(item) + break + return result + +def get_copyright(): + result = \ +"""// Copyright (c) $YEAR$ 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +""" + # add the copyright year + return result.replace('$YEAR$', get_year()) + + +class obj_header: + """ Class representing a C++ header file. """ + + def __init__(self): + self.filenames = [] + self.typedefs = [] + self.funcs = [] + self.classes = [] + + def add_directory(self, directory): + """ Add all header files from the specified directory. """ + files = get_files(os.path.join(directory, '*.h')) + for file in files: + self.add_file(file) + + def add_file(self, filepath): + """ Add a header file. """ + + filename = os.path.split(filepath)[1] + added = False + + # read the input file into memory + data = read_file(filepath) + + # remove space from between template definition end brackets + data = data.replace("> >", ">>") + + # extract global typedefs + p = re.compile('\ntypedef'+_cre_space+_cre_typedef+';', + re.MULTILINE | re.DOTALL) + list = p.findall(data) + if len(list) > 0: + # build the global typedef objects + for value in list: + pos = value.rfind(' ') + if pos < 0: + raise Exception('Invalid typedef: '+value) + alias = value[pos+1:] + value = value[:pos] + self.typedefs.append(obj_typedef(self, filename, value, alias)) + + # extract global functions + p = re.compile('\n'+_cre_attrib+'\n'+_cre_func+'\((.*?)\)', + re.MULTILINE | re.DOTALL) + list = p.findall(data) + if len(list) > 0: + added = True + + # build the global function objects + for attrib, retval, argval in list: + comment = get_comment(data, retval+'('+argval+');') + self.funcs.append(obj_function(self, filename, attrib, retval, + argval, comment)) + + # extract forward declarations + p = re.compile('\nclass'+_cre_space+_cre_cfname+';') + forward_declares = p.findall(data) + + # extract classes + p = re.compile('\n'+_cre_attrib+ + '\nclass'+_cre_space+_cre_cfname+_cre_space+ + ':'+_cre_space+'public'+_cre_space+'virtual'+ + _cre_space+'CefBase'+_cre_space+ + '{(.*?)};', re.MULTILINE | re.DOTALL) + list = p.findall(data) + if len(list) > 0: + added = True + + # build the class objects + for attrib, name, body in list: + comment = get_comment(data, name+' : public virtual CefBase') + self.classes.append( + obj_class(self, filename, attrib, name, body, comment, + forward_declares)) + + if added: + # a global function or class was read from the header file + self.filenames.append(filename) + + def __repr__(self): + result = '' + + if len(self.typedefs) > 0: + strlist = [] + for cls in self.typedefs: + strlist.append(str(cls)) + result += string.join(strlist, "\n") + "\n\n" + + if len(self.funcs) > 0: + strlist = [] + for cls in self.funcs: + strlist.append(str(cls)) + result += string.join(strlist, "\n") + "\n\n" + + if len(self.classes) > 0: + strlist = [] + for cls in self.classes: + strlist.append(str(cls)) + result += string.join(strlist, "\n") + + return result + + def get_file_names(self): + """ Return the array of header file names. """ + return self.filenames + + def get_typedefs(self): + """ Return the array of typedef objects. """ + return self.typedefs + + def get_funcs(self, filename = None): + """ Return the array of function objects. """ + if filename is None: + return self.funcs + else: + # only return the functions in the specified file + res = [] + for func in self.funcs: + if func.get_file_name() == filename: + res.append(func) + return res + + def get_classes(self, filename = None): + """ Return the array of class objects. """ + if filename is None: + return self.classes + else: + # only return the classes in the specified file + res = [] + for cls in self.classes: + if cls.get_file_name() == filename: + res.append(cls) + return res + + def get_class(self, classname, defined_structs = None): + """ Return the specified class or None if not found. """ + for cls in self.classes: + if cls.get_name() == classname: + return cls + elif not defined_structs is None: + defined_structs.append(cls.get_capi_name()) + return None + + def get_class_names(self): + """ Returns the names of all classes in this object. """ + result = [] + for cls in self.classes: + result.append(cls.get_name()) + return result + + def get_types(self, list): + """ Return a dictionary mapping data types to analyzed values. """ + for cls in self.typedefs: + cls.get_types(list) + + for cls in self.classes: + cls.get_types(list) + + def get_alias_translation(self, alias): + """ Return a translation of alias to value based on typedef + statements. """ + for cls in self.typedefs: + if cls.alias == alias: + return cls.value + return None + + def get_analysis(self, value, named = True): + """ Return an analysis of the value based the header file context. """ + return obj_analysis([self], value, named) + + def get_defined_structs(self): + """ Return a list of names already defined structure names. """ + return ['cef_print_info_t', 'cef_window_info_t', 'cef_base_t'] + + def get_capi_translations(self): + """ Return a dictionary that maps C++ terminology to C API terminology. + """ + # strings that will be changed in C++ comments + map = { + 'class' : 'structure', + 'Class' : 'Structure', + 'interface' : 'structure', + 'Interface' : 'Structure', + 'true' : 'true (1)', + 'false' : 'false (0)', + 'empty' : 'NULL', + 'method' : 'function' + } + + # add mappings for all classes and functions + funcs = self.get_funcs() + for func in funcs: + map[func.get_name()+'()'] = func.get_capi_name()+'()' + + classes = self.get_classes() + for cls in classes: + map[cls.get_name()] = cls.get_capi_name() + + funcs = cls.get_virtual_funcs() + for func in funcs: + map[func.get_name()+'()'] = func.get_capi_name()+'()' + + funcs = cls.get_static_funcs() + for func in funcs: + map[func.get_name()+'()'] = func.get_capi_name()+'()' + + return map + + +class obj_class: + """ Class representing a C++ class. """ + + def __init__(self, parent, filename, attrib, name, body, comment, + forward_declares): + if not isinstance(parent, obj_header): + raise Exception('Invalid parent object type') + + self.parent = parent + self.filename = filename + self.attribs = str_to_dict(attrib) + self.name = name + self.comment = comment + self.forward_declares = forward_declares + + # extract typedefs + p = re.compile('\n'+_cre_space+'typedef'+_cre_space+_cre_typedef+';', + re.MULTILINE | re.DOTALL) + list = p.findall(body) + + # build the typedef objects + self.typedefs = [] + for value in list: + pos = value.rfind(' ') + if pos < 0: + raise Exception('Invalid typedef: '+value) + alias = value[pos+1:] + value = value[:pos] + self.typedefs.append(obj_typedef(self, filename, value, alias)) + + # extract static functions + p = re.compile('\n'+_cre_space+_cre_attrib+'\n'+_cre_space+'static'+ + _cre_space+_cre_func+'\((.*?)\)', + re.MULTILINE | re.DOTALL) + list = p.findall(body) + + # build the static function objects + self.staticfuncs = [] + for attrib, retval, argval in list: + comment = get_comment(body, retval+'('+argval+')') + self.staticfuncs.append( + obj_function_static(self, attrib, retval, argval, comment)) + + # extract virtual functions + p = re.compile('\n'+_cre_space+_cre_attrib+'\n'+_cre_space+'virtual'+ + _cre_space+_cre_func+'\((.*?)\)'+_cre_space+_cre_vfmod, + re.MULTILINE | re.DOTALL) + list = p.findall(body) + + # build the virtual function objects + self.virtualfuncs = [] + for attrib, retval, argval, vfmod in list: + comment = get_comment(body, retval+'('+argval+')') + self.virtualfuncs.append( + obj_function_virtual(self, attrib, retval, argval, comment, + vfmod)) + + def __repr__(self): + result = '/* '+dict_to_str(self.attribs)+' */ class '+self.name+"\n{" + + if len(self.typedefs) > 0: + result += "\n\t" + strlist = [] + for cls in self.typedefs: + strlist.append(str(cls)) + result += string.join(strlist, "\n\t") + + if len(self.staticfuncs) > 0: + result += "\n\t" + strlist = [] + for cls in self.staticfuncs: + strlist.append(str(cls)) + result += string.join(strlist, "\n\t") + + if len(self.virtualfuncs) > 0: + result += "\n\t" + strlist = [] + for cls in self.virtualfuncs: + strlist.append(str(cls)) + result += string.join(strlist, "\n\t") + + result += "\n};\n" + return result + + def get_file_name(self): + """ Return the C++ header file name. """ + return self.filename + + def get_capi_file_name(self): + """ Return the CAPI header file name. """ + return get_capi_file_name(self.filename) + + def get_name(self): + """ Return the class name. """ + return self.name + + def get_capi_name(self): + """ Return the CAPI structure name for this class. """ + return get_capi_name(self.name, True) + + def get_comment(self): + """ Return the class comment as an array of lines. """ + return self.comment + + def get_forward_declares(self): + """ Return the list of classes that are forward declared for this + class. """ + return self.forward_declares + + def get_attribs(self): + """ Return all attributes as a dictionary. """ + return self.attribs + + def has_attrib(self, name): + """ Return true if the specified attribute exists. """ + return name in self.attribs + + def get_attrib(self, name): + """ Return the first or only value for specified attribute. """ + if name in self.attribs: + if isinstance(self.attribs[name], list): + # the value is a list + return self.attribs[name][0] + else: + # the value is a string + return self.attribs[name] + return None + + def get_attrib_list(self, name): + """ Return all values for specified attribute as a list. """ + if name in self.attribs: + if isinstance(self.attribs[name], list): + # the value is already a list + return self.attribs[name] + else: + # convert the value to a list + return [self.attribs[name]] + return None + + def get_typedefs(self): + """ Return the array of typedef objects. """ + return self.typedefs + + def has_typedef_alias(self, alias): + """ Returns true if the specified typedef alias is defined in the scope + of this class declaration. """ + for typedef in self.typedefs: + if typedef.get_alias() == alias: + return True + return False + + def get_static_funcs(self): + """ Return the array of static function objects. """ + return self.staticfuncs + + def get_virtual_funcs(self): + """ Return the array of virtual function objects. """ + return self.virtualfuncs + + def get_types(self, list): + """ Return a dictionary mapping data types to analyzed values. """ + for cls in self.typedefs: + cls.get_types(list) + + for cls in self.staticfuncs: + cls.get_types(list) + + for cls in self.virtualfuncs: + cls.get_types(list) + + def get_alias_translation(self, alias): + for cls in self.typedefs: + if cls.alias == alias: + return cls.value + return None + + def get_analysis(self, value, named = True): + """ Return an analysis of the value based on the class definition + context. + """ + return obj_analysis([self, self.parent], value, named) + + def is_library_side(self): + """ Returns true if the class is implemented by the library. """ + return self.attribs['source'] == 'library' + + def is_client_side(self): + """ Returns true if the class is implemented by the client. """ + return self.attribs['source'] == 'client' + + +class obj_typedef: + """ Class representing a typedef statement. """ + + def __init__(self, parent, filename, value, alias): + if not isinstance(parent, obj_header) \ + and not isinstance(parent, obj_class): + raise Exception('Invalid parent object type') + + self.parent = parent + self.filename = filename + self.alias = alias + self.value = self.parent.get_analysis(value, False) + + def __repr__(self): + return 'typedef '+self.value.get_type()+' '+self.alias+';' + + def get_file_name(self): + """ Return the C++ header file name. """ + return self.filename + + def get_capi_file_name(self): + """ Return the CAPI header file name. """ + return get_capi_file_name(self.filename) + + def get_alias(self): + """ Return the alias. """ + return self.alias + + def get_value(self): + """ Return an analysis of the value based on the class or header file + definition context. + """ + return self.value + + def get_types(self, list): + """ Return a dictionary mapping data types to analyzed values. """ + name = self.value.get_type() + if not name in list: + list[name] = self.value + + +class obj_function: + """ Class representing a function. """ + + def __init__(self, parent, filename, attrib, retval, argval, comment): + self.parent = parent + self.filename = filename + self.attribs = str_to_dict(attrib) + self.retval = obj_argument(self, retval) + self.name = self.retval.remove_name() + self.comment = comment + + # build the argument objects + self.arguments = [] + arglist = string.split(argval, ',') + for arg in arglist: + arg = string.strip(arg) + if len(arg) > 0: + argument = obj_argument(self, arg) + if argument.needs_attrib_count_func() and \ + argument.get_attrib_count_func() is None: + raise Exception("A 'count_func' attribute is required "+ \ + "for the '"+argument.get_name()+ \ + "' parameter to "+self.get_qualified_name()) + self.arguments.append(argument) + + if self.retval.needs_attrib_default_retval() and \ + self.retval.get_attrib_default_retval() is None: + raise Exception("A 'default_retval' attribute is required for "+ \ + self.get_qualified_name()) + + def __repr__(self): + return '/* '+dict_to_str(self.attribs)+' */ '+self.get_cpp_proto() + + def get_file_name(self): + """ Return the C++ header file name. """ + return self.filename + + def get_capi_file_name(self): + """ Return the CAPI header file name. """ + return get_capi_file_name(self.filename) + + def get_name(self): + """ Return the function name. """ + return self.name + + def get_qualified_name(self): + """ Return the fully qualified function name. """ + if isinstance(self.parent, obj_header): + # global function + return self.name + else: + # member function + return self.parent.get_name()+'::'+self.name + + def get_capi_name(self, prefix = None): + """ Return the CAPI function name. """ + if 'capi_name' in self.attribs: + return self.attribs['capi_name'] + return get_capi_name(self.name, False, prefix) + + def get_comment(self): + """ Return the function comment as an array of lines. """ + return self.comment + + def get_attribs(self): + """ Return all attributes as a dictionary. """ + return self.attribs + + def has_attrib(self, name): + """ Return true if the specified attribute exists. """ + return name in self.attribs + + def get_attrib(self, name): + """ Return the first or only value for specified attribute. """ + if name in self.attribs: + if isinstance(self.attribs[name], list): + # the value is a list + return self.attribs[name][0] + else: + # the value is a string + return self.attribs[name] + return None + + def get_attrib_list(self, name): + """ Return all values for specified attribute as a list. """ + if name in self.attribs: + if isinstance(self.attribs[name], list): + # the value is already a list + return self.attribs[name] + else: + # convert the value to a list + return [self.attribs[name]] + return None + + def get_retval(self): + """ Return the return value object. """ + return self.retval + + def get_arguments(self): + """ Return the argument array. """ + return self.arguments + + def get_types(self, list): + """ Return a dictionary mapping data types to analyzed values. """ + for cls in self.arguments: + cls.get_types(list) + + def get_capi_parts(self, defined_structs = [], prefix = None): + """ Return the parts of the C API function definition. """ + retval = '' + dict = self.retval.get_type().get_capi(defined_structs) + if dict['format'] == 'single': + retval = dict['value'] + + name = self.get_capi_name(prefix) + args = [] + + if isinstance(self, obj_function_virtual): + # virtual functions get themselves as the first argument + str = 'struct _'+self.parent.get_capi_name()+'* self' + if isinstance(self, obj_function_virtual) and self.is_const(): + # const virtual functions get const self pointers + str = 'const '+str + args.append(str) + + if len(self.arguments) > 0: + for cls in self.arguments: + type = cls.get_type() + dict = type.get_capi(defined_structs) + if dict['format'] == 'single': + args.append(dict['value']) + elif dict['format'] == 'multi-arg': + # add an additional argument for the size of the array + type_name = type.get_name() + if type.is_const(): + # for const arrays pass the size argument by value + args.append('size_t '+type_name+'Count') + else: + # for non-const arrays pass the size argument by address + args.append('size_t* '+type_name+'Count') + args.append(dict['value']) + + return { 'retval' : retval, 'name' : name, 'args' : args } + + def get_capi_proto(self, defined_structs = [], prefix = None): + """ Return the prototype of the C API function. """ + parts = self.get_capi_parts(defined_structs, prefix) + result = parts['retval']+' '+parts['name']+ \ + '('+string.join(parts['args'], ', ')+')' + return result + + def get_cpp_parts(self, isimpl = False): + """ Return the parts of the C++ function definition. """ + retval = str(self.retval) + name = self.name + + args = [] + if len(self.arguments) > 0: + for cls in self.arguments: + args.append(str(cls)) + + if isimpl and isinstance(self, obj_function_virtual): + # enumeration return values must be qualified with the class name + # if the type is defined in the class declaration scope. + type = self.get_retval().get_type() + if type.is_result_struct() and type.is_result_struct_enum() and \ + self.parent.has_typedef_alias(retval): + retval = self.parent.get_name()+'::'+retval + + return { 'retval' : retval, 'name' : name, 'args' : args } + + def get_cpp_proto(self, classname = None): + """ Return the prototype of the C++ function. """ + parts = self.get_cpp_parts() + result = parts['retval']+' ' + if not classname is None: + result += classname+'::' + result += parts['name']+'('+string.join(parts['args'], ', ')+')' + if isinstance(self, obj_function_virtual) and self.is_const(): + result += ' const' + return result + + def is_same_side(self, other_class_name): + """ Returns true if this function is on the same side (library or + client) and the specified class. """ + if isinstance(self.parent, obj_class): + # this function is part of a class + this_is_library_side = self.parent.is_library_side() + header = self.parent.parent + else: + # this function is global + this_is_library_side = True + header = self.parent + + if other_class_name == 'CefBase': + other_is_library_side = False + else: + other_class = header.get_class(other_class_name) + if other_class is None: + raise Exception('Unknown class: '+other_class_name) + other_is_library_side = other_class.is_library_side() + + return other_is_library_side == this_is_library_side + + +class obj_function_static(obj_function): + """ Class representing a static function. """ + + def __init__(self, parent, attrib, retval, argval, comment): + if not isinstance(parent, obj_class): + raise Exception('Invalid parent object type') + obj_function.__init__(self, parent, parent.filename, attrib, retval, + argval, comment) + + def __repr__(self): + return 'static '+obj_function.__repr__(self)+';' + + def get_capi_name(self, prefix = None): + """ Return the CAPI function name. """ + if prefix is None: + # by default static functions are prefixed with the class name + prefix = get_capi_name(self.parent.get_name(), False) + return obj_function.get_capi_name(self, prefix) + +class obj_function_virtual(obj_function): + """ Class representing a virtual function. """ + + def __init__(self, parent, attrib, retval, argval, comment, vfmod): + if not isinstance(parent, obj_class): + raise Exception('Invalid parent object type') + obj_function.__init__(self, parent, parent.filename, attrib, retval, + argval, comment) + if vfmod == 'const': + self.isconst = True + else: + self.isconst = False + + def __repr__(self): + return 'virtual '+obj_function.__repr__(self)+';' + + def is_const(self): + """ Returns true if the method declaration is const. """ + return self.isconst + + +class obj_argument: + """ Class representing a function argument. """ + + def __init__(self, parent, argval): + if not isinstance(parent, obj_function): + raise Exception('Invalid parent object type') + + self.parent = parent + self.type = self.parent.parent.get_analysis(argval) + + def __repr__(self): + result = '' + if self.type.is_const(): + result += 'const ' + result += self.type.get_type() + if self.type.is_byref(): + result += '&' + elif self.type.is_byaddr(): + result += '*' + if self.type.has_name(): + result += ' '+self.type.get_name() + return result + + def get_name(self): + """ Return the name for this argument. """ + return self.type.get_name() + + def remove_name(self): + """ Remove and return the name value. """ + name = self.type.get_name() + self.type.name = None + return name + + def get_type(self): + """ Return an analysis of the argument type based on the class + definition context. + """ + return self.type + + def get_types(self, list): + """ Return a dictionary mapping data types to analyzed values. """ + name = self.type.get_type() + if not name in list: + list[name] = self.type + + def needs_attrib_count_func(self): + """ Returns true if this argument requires a 'count_func' attribute. """ + # A 'count_func' attribute is required for non-const non-string vector + # attribute types + return self.type.has_name() and \ + self.type.is_result_vector() and \ + not self.type.is_result_vector_string() and \ + not self.type.is_const() + + def get_attrib_count_func(self): + """ Returns the count function for this argument. """ + # The 'count_func' attribute value format is name:function + if not self.parent.has_attrib('count_func'): + return None + name = self.type.get_name() + vals = self.parent.get_attrib_list('count_func') + for val in vals: + parts = string.split(val, ':') + if len(parts) != 2: + raise Exception("Invalid 'count_func' attribute value for "+ \ + self.parent.get_qualified_name()+': '+val) + if string.strip(parts[0]) == name: + return string.strip(parts[1]) + return None + + def needs_attrib_default_retval(self): + """ Returns true if this argument requires a 'default_retval' attribute. + """ + # A 'default_retval' attribute is required for enumeration return value + # types. + return not self.type.has_name() and \ + self.type.is_result_struct() and \ + self.type.is_result_struct_enum() + + def get_attrib_default_retval(self): + """ Returns the defualt return value for this argument. """ + return self.parent.get_attrib('default_retval') + + def get_arg_type(self): + """ Returns the argument type as defined in translator.README.txt. """ + if not self.type.has_name(): + raise Exception('Cannot be called for retval types') + + # simple or enumeration type + if (self.type.is_result_simple() and \ + self.type.get_type() != 'bool') or \ + (self.type.is_result_struct() and \ + self.type.is_result_struct_enum()): + if self.type.is_byref(): + if self.type.is_const(): + return 'simple_byref_const' + return 'simple_byref' + elif self.type.is_byaddr(): + return 'simple_byaddr' + return 'simple_byval' + + # boolean type + if self.type.get_type() == 'bool': + if self.type.is_byref(): + return 'bool_byref' + elif self.type.is_byaddr(): + return 'bool_byaddr' + return 'bool_byval' + + # structure type + if self.type.is_result_struct() and self.type.is_byref(): + if self.type.is_const(): + return 'struct_byref_const' + return 'struct_byref' + + # string type + if self.type.is_result_string() and self.type.is_byref(): + if self.type.is_const(): + return 'string_byref_const' + return 'string_byref' + + # refptr type + if self.type.is_result_refptr(): + same_side = self.parent.is_same_side(self.type.get_refptr_type()) + if self.type.is_byref(): + if same_side: + return 'refptr_same_byref' + return 'refptr_diff_byref' + if same_side: + return 'refptr_same' + return 'refptr_diff' + + + if self.type.is_result_vector(): + # all vector types must be passed by reference + if not self.type.is_byref(): + return 'invalid' + + if self.type.is_result_vector_string(): + # string vector type + if self.type.is_const(): + return 'string_vec_byref_const' + return 'string_vec_byref' + + if self.type.is_result_vector_simple(): + if self.type.get_vector_type() != 'bool': + # simple/enumeration vector types + if self.type.is_const(): + return 'simple_vec_byref_const' + return 'simple_vec_byref' + + # boolean vector types + if self.type.is_const(): + return 'bool_vec_byref_const' + return 'bool_vec_byref' + + if self.type.is_result_vector_refptr(): + # refptr vector types + same_side = self.parent.is_same_side(self.type.get_refptr_type()) + if self.type.is_const(): + if same_side: + return 'refptr_vec_same_byref_const' + return 'refptr_vec_diff_byref_const' + if same_side: + return 'refptr_vec_same_byref' + return 'refptr_vec_diff_byref' + + + # string single map type + if self.type.is_result_map_single(): + if not self.type.is_byref(): + return 'invalid' + if self.type.is_const(): + return 'string_map_single_byref_const' + return 'string_map_single_byref' + + # string multi map type + if self.type.is_result_map_multi(): + if not self.type.is_byref(): + return 'invalid' + if self.type.is_const(): + return 'string_map_multi_byref_const' + return 'string_map_multi_byref' + + return 'invalid' + + def get_retval_type(self): + """ Returns the retval type as defined in translator.README.txt. """ + if self.type.has_name(): + raise Exception('Cannot be called for argument types') + + # unsupported modifiers + if self.type.is_const() or self.type.is_byref() or \ + self.type.is_byaddr(): + return 'invalid' + + # void types don't have a return value + if self.type.get_type() == 'void': + return 'none' + + if (self.type.is_result_simple() and \ + self.type.get_type() != 'bool') or \ + (self.type.is_result_struct() and self.type.is_result_struct_enum()): + return 'simple' + + if self.type.get_type() == 'bool': + return 'bool' + + if self.type.is_result_string(): + return 'string' + + if self.type.is_result_refptr(): + if self.parent.is_same_side(self.type.get_refptr_type()): + return 'refptr_same' + else: + return 'refptr_diff' + + return 'invalid' + + def get_retval_default(self, for_capi): + """ Returns the default return value based on the retval type. """ + # start with the default retval attribute, if any. + retval = self.get_attrib_default_retval() + if not retval is None: + if for_capi: + # apply any appropriate C API translations. + if retval == 'true': + return '1' + if retval == 'false': + return '0' + return retval + + # next look at the retval type value. + type = self.get_retval_type() + if type == 'simple': + return self.get_type().get_result_simple_default() + elif type == 'bool': + if for_capi: + return '0' + return 'false' + elif type == 'string': + if for_capi: + return 'NULL' + return 'CefString()' + elif type == 'refptr_same' or type == 'refptr_diff': + return 'NULL' + + return '' + +class obj_analysis: + """ Class representing an analysis of a data type value. """ + + def __init__(self, scopelist, value, named): + self.value = value + self.result_type = 'unknown' + self.result_value = None + self.result_default = None + self.refptr_type = None + + # parse the argument string + partlist = string.split(string.strip(value)) + + if named == True: + # extract the name value + self.name = partlist[-1] + del partlist[-1] + else: + self.name = None + + if len(partlist) == 0: + raise Exception('Invalid argument value: '+value) + + # check const status + if partlist[0] == 'const': + self.isconst = True + del partlist[0] + else: + self.isconst = False + + # combine the data type + self.type = string.join(partlist, ' ') + + # extract the last character of the data type + endchar = self.type[-1] + + # check if the value is passed by reference + if endchar == '&': + self.isbyref = True + self.type = self.type[:-1] + else: + self.isbyref = False + + # check if the value is passed by address + if endchar == '*': + self.isbyaddr = True + self.type = self.type[:-1] + else: + self.isbyaddr = False + + # see if the value is directly identifiable + if self._check_advanced(self.type) == True: + return + + # not identifiable, so look it up + translation = None + for scope in scopelist: + if not isinstance(scope, obj_header) \ + and not isinstance(scope, obj_class): + raise Exception('Invalid scope object type') + translation = scope.get_alias_translation(self.type) + if not translation is None: + break + + if translation is None: + raise Exception('Failed to translate type: '+self.type) + + # the translation succeeded so keep the result + self.result_type = translation.result_type + self.result_value = translation.result_value + + def _check_advanced(self, value): + # check for vectors + if value.find('std::vector') == 0: + self.result_type = 'vector' + val = string.strip(value[12:-1]) + self.result_value = [ + self._get_basic(val) + ] + self.result_value[0]['vector_type'] = val + return True + + # check for maps + if value.find('std::map') == 0: + self.result_type = 'map' + vals = string.split(value[9:-1], ',') + if len(vals) == 2: + self.result_value = [ + self._get_basic(string.strip(vals[0])), + self._get_basic(string.strip(vals[1])) + ] + return True + + # check for multimaps + if value.find('std::multimap') == 0: + self.result_type = 'multimap' + vals = string.split(value[14:-1], ',') + if len(vals) == 2: + self.result_value = [ + self._get_basic(string.strip(vals[0])), + self._get_basic(string.strip(vals[1])) + ] + return True + + # check for basic types + basic = self._get_basic(value) + if not basic is None: + self.result_type = basic['result_type'] + self.result_value = basic['result_value'] + if 'refptr_type' in basic: + self.refptr_type = basic['refptr_type'] + if 'result_default' in basic: + self.result_default = basic['result_default'] + return True + + return False + + def _get_basic(self, value): + # check for string values + if value == "CefString": + return { + 'result_type' : 'string', + 'result_value' : None + } + + # check for simple direct translations + if value in _simpletypes.keys(): + return { + 'result_type' : 'simple', + 'result_value' : _simpletypes[value][0], + 'result_default' : _simpletypes[value][1], + } + + # check if already a C API structure + if value[-2:] == '_t': + return { + 'result_type' : 'structure', + 'result_value' : value + } + + # check for CEF reference pointers + p = re.compile('^CefRefPtr<(.*?)>$', re.DOTALL) + list = p.findall(value) + if len(list) == 1: + return { + 'result_type' : 'refptr', + 'result_value' : get_capi_name(list[0], True)+'*', + 'refptr_type' : list[0] + } + + # check for CEF structure types + if value[0:3] == 'Cef' and value[-4:] != 'List': + return { + 'result_type' : 'structure', + 'result_value' : get_capi_name(value, True) + } + + return None + + def __repr__(self): + return '('+self.result_type+') '+str(self.result_value) + + def has_name(self): + """ Returns true if a name value exists. """ + return (not self.name is None) + + def get_name(self): + """ Return the name. """ + return self.name + + def get_value(self): + """ Return the C++ value (type + name). """ + return self.value + + def get_type(self): + """ Return the C++ type. """ + return self.type + + def get_refptr_type(self): + """ Return the C++ class type referenced by a CefRefPtr. """ + if self.is_result_vector() and self.is_result_vector_refptr(): + # return the vector RefPtr type + return self.result_value[0]['refptr_type'] + # return the basic RefPtr type + return self.refptr_type + + def get_vector_type(self): + """ Return the C++ class type referenced by a std::vector. """ + if self.is_result_vector(): + return self.result_value[0]['vector_type'] + return None + + def is_const(self): + """ Returns true if the argument value is constant. """ + return self.isconst + + def is_byref(self): + """ Returns true if the argument is passed by reference. """ + return self.isbyref + + def is_byaddr(self): + """ Returns true if the argument is passed by address. """ + return self.isbyaddr + + def is_result_simple(self): + """ Returns true if this is a simple argument type. """ + return (self.result_type == 'simple') + + def get_result_simple_type_root(self): + """ Return the simple structure or basic type name. """ + return self.result_value + + def get_result_simple_type(self): + """ Return the simple type. """ + result = '' + if self.is_const(): + result += 'const ' + result += self.result_value + if self.is_byaddr() or self.is_byref(): + result += '*' + return result + + def get_result_simple_default(self): + """ Return the default value fo the basic type. """ + return self.result_default + + def is_result_refptr(self): + """ Returns true if this is a reference pointer type. """ + return (self.result_type == 'refptr') + + def get_result_refptr_type_root(self): + """ Return the refptr type structure name. """ + return self.result_value[:-1] + + def get_result_refptr_type(self, defined_structs = []): + """ Return the refptr type. """ + result = '' + if not self.result_value[:-1] in defined_structs: + result += 'struct _' + result += self.result_value + if self.is_byref() or self.is_byaddr(): + result += '*' + return result + + def is_result_struct(self): + """ Returns true if this is a structure type. """ + return (self.result_type == 'structure') + + def is_result_struct_enum(self): + """ Returns true if this struct type is likely an enumeration. """ + # structure values that are passed by reference or address must be + # structures and not enumerations + if not self.is_byref() and not self.is_byaddr(): + return True + return False + + def get_result_struct_type(self, defined_structs = []): + """ Return the structure or enumeration type. """ + result = '' + is_enum = self.is_result_struct_enum() + if not is_enum: + if self.is_const(): + result += 'const ' + if not self.result_value in defined_structs: + result += 'struct _' + else: + result += 'enum ' + result += self.result_value + if not is_enum: + result += '*' + return result + + def is_result_string(self): + """ Returns true if this is a string type. """ + return (self.result_type == 'string') + + def get_result_string_type(self): + """ Return the string type. """ + if not self.has_name(): + # Return values are string structs that the user must free. Use + # the name of the structure as a hint. + return 'cef_string_userfree_t' + elif not self.is_const() and (self.is_byref() or self.is_byaddr()): + # Parameters passed by reference or address. Use the normal + # non-const string struct. + return 'cef_string_t*' + # Const parameters use the const string struct. + return 'const cef_string_t*' + + def is_result_vector(self): + """ Returns true if this is a vector type. """ + return (self.result_type == 'vector') + + def is_result_vector_string(self): + """ Returns true if this is a string vector. """ + return self.result_value[0]['result_type'] == 'string' + + def is_result_vector_simple(self): + """ Returns true if this is a string vector. """ + return self.result_value[0]['result_type'] == 'simple' + + def is_result_vector_refptr(self): + """ Returns true if this is a string vector. """ + return self.result_value[0]['result_type'] == 'refptr' + + def get_result_vector_type_root(self): + """ Return the vector structure or basic type name. """ + return self.result_value[0]['result_value'] + + def get_result_vector_type(self, defined_structs = []): + """ Return the vector type. """ + if not self.has_name(): + raise Exception('Cannot use vector as a return type') + + type = self.result_value[0]['result_type'] + value = self.result_value[0]['result_value'] + + result = {} + if type == 'string': + result['value'] = 'cef_string_list_t' + result['format'] = 'single' + return result + + if type == 'simple': + str = value + if self.is_const(): + str += ' const' + str += '*' + result['value'] = str + elif type == 'refptr': + str = '' + if not value[:-1] in defined_structs: + str += 'struct _' + str += value + if self.is_const(): + str += ' const' + str += '*' + result['value'] = str + else: + raise Exception('Unsupported vector type: '+type) + + # vector values must be passed as a value array parameter + # and a size parameter + result['format'] = 'multi-arg' + return result + + def is_result_map(self): + """ Returns true if this is a map type. """ + return (self.result_type == 'map' or self.result_type == 'multimap') + + def is_result_map_single(self): + """ Returns true if this is a single map type. """ + return (self.result_type == 'map') + + def is_result_map_multi(self): + """ Returns true if this is a multi map type. """ + return (self.result_type == 'multimap') + + def get_result_map_type(self, defined_structs = []): + """ Return the map type. """ + if not self.has_name(): + raise Exception('Cannot use map as a return type') + if self.result_value[0]['result_type'] == 'string' \ + and self.result_value[1]['result_type'] == 'string': + if self.result_type == 'map': + return { + 'value' : 'cef_string_map_t', + 'format' : 'single' + } + elif self.result_type == 'multimap': + return { + 'value' : 'cef_string_multimap_t', + 'format' : 'multi' + } + raise Exception('Only mappings of strings to strings are supported') + + def get_capi(self, defined_structs = []): + """ Format the value for the C API. """ + result = '' + format = 'single' + if self.is_result_simple(): + result += self.get_result_simple_type() + elif self.is_result_refptr(): + result += self.get_result_refptr_type(defined_structs) + elif self.is_result_struct(): + result += self.get_result_struct_type(defined_structs) + elif self.is_result_string(): + result += self.get_result_string_type() + elif self.is_result_map(): + resdict = self.get_result_map_type(defined_structs) + if resdict['format'] == 'single' or resdict['format'] == 'multi': + result += resdict['value'] + else: + raise Exception('Unsupported map type') + elif self.is_result_vector(): + resdict = self.get_result_vector_type(defined_structs) + if resdict['format'] != 'single': + format = resdict['format'] + result += resdict['value'] + + if self.has_name(): + result += ' '+self.get_name() + + return {'format' : format, 'value' : result} + + +# test the module +if __name__ == "__main__": + import pprint + import sys + + # verify that the correct number of command-line arguments are provided + if len(sys.argv) != 2: + sys.stderr.write('Usage: '+sys.argv[0]+' ') + sys.exit() + + pp = pprint.PrettyPrinter(indent=4) + + # create the header object + header = obj_header() + header.add_directory(sys.argv[1]) + + # output the type mapping + types = {} + header.get_types(types) + pp.pprint(types) + sys.stdout.write('\n') + + # output the parsed C++ data + sys.stdout.write(wrap_code(str(header), '\t')) + + # output the C API formatted data + defined_names = header.get_defined_structs() + result = '' + + # global functions + funcs = header.get_funcs() + if len(funcs) > 0: + for func in funcs: + result += func.get_capi_proto(defined_names)+';\n' + result += '\n' + + classes = header.get_classes() + for cls in classes: + # virtual functions are inside a structure + result += 'struct '+cls.get_capi_name()+'\n{\n' + funcs = cls.get_virtual_funcs() + if len(funcs) > 0: + for func in funcs: + result += '\t'+func.get_capi_proto(defined_names)+';\n' + result += '}\n\n' + + defined_names.append(cls.get_capi_name()) + + # static functions become global + funcs = cls.get_static_funcs() + if len(funcs) > 0: + for func in funcs: + result += func.get_capi_proto(defined_names)+';\n' + result += '\n' + sys.stdout.write(wrap_code(result, '\t')) diff --git a/cef3/tools/check_revision.py b/cef3/tools/check_revision.py new file mode 100644 index 000000000..e9334dca2 --- /dev/null +++ b/cef3/tools/check_revision.py @@ -0,0 +1,87 @@ +# 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. + +from file_util import * +from optparse import OptionParser +from svn_util import * +import sys + +# cannot be loaded as a module +if __name__ != "__main__": + sys.stderr.write('This file cannot be loaded as a module!') + sys.exit() + + +# parse command-line options +disc = """ +This utility checks that the correct Chromium revision is being used. +""" + +parser = OptionParser(description=disc) +parser.add_option('-q', '--quiet', + action='store_true', dest='quiet', default=False, + help='do not output detailed status information') +(options, args) = parser.parse_args() + +# The CEF root directory is the parent directory of _this_ script. +cef_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) + +# Retrieve the CEF SVN info. +cef_info = get_svn_info(cef_dir) +if not options.quiet: + sys.stdout.write('Using CEF revision '+cef_info['revision']+' @ '+\ + cef_info['url']+"\n") + +# Retrieve the Chromium SVN info. +src_dir = os.path.join(cef_dir, os.pardir) +chromium_info = get_svn_info(src_dir) +if not options.quiet: + sys.stdout.write('Using Chromium revision '+chromium_info['revision']+' @ '+\ + chromium_info['url']+"\n") + +# Parse the compatibility file contents. +compat_file = os.path.join(cef_dir, 'CHROMIUM_BUILD_COMPATIBILITY.txt') +config = eval(read_file(compat_file), {'__builtins__': None}, None) + +error = False + +if 'release_url' in config: + current_release_url = None + path = os.path.join(os.path.join(src_dir, os.pardir), '.gclient') + if os.path.exists(path): + # read the .gclient file + fp = open(path, 'r') + data = fp.read() + fp.close() + + # Parse the contents + config_dict = {} + try: + exec(data, config_dict) + current_release_url = config_dict['solutions'][0]['url'] + except Exception, e: + sys.stderr.write('Failed to parse existing .glient file.\n') + raise + + if not options.quiet: + sys.stdout.write('Using Chromium release '+current_release_url+"\n") + + if current_release_url != config['release_url']: + error = True + sys.stderr.write("\nWARNING: Incorrect Chromium release URL; found "+\ + current_release_url+', expected '+config['release_url']+"\n") +else: + if chromium_info['url'] != config['chromium_url']: + error = True + sys.stderr.write("\nWARNING: Incorrect Chromium URL; found "+\ + chromium_info['url']+', expected '+config['chromium_url']+"\n") + + if chromium_info['revision'] != config['chromium_revision']: + error = True + sys.stderr.write("\nWARNING: Incorrect Chromium revision; found "+\ + chromium_info['revision']+', expected '+config['chromium_revision']+"\n") + +if error: + sys.stderr.write("\nPlease see CHROMIUM_BUILD_COMPATIBILITY.txt for "\ + "instructions.\n") diff --git a/cef3/tools/check_style.bat b/cef3/tools/check_style.bat new file mode 100644 index 000000000..43612cf91 --- /dev/null +++ b/cef3/tools/check_style.bat @@ -0,0 +1,2 @@ +@echo off +..\..\third_party\python_26\python.exe check_style.py %* diff --git a/cef3/tools/check_style.py b/cef3/tools/check_style.py new file mode 100644 index 000000000..d734e76fb --- /dev/null +++ b/cef3/tools/check_style.py @@ -0,0 +1,129 @@ +# Copyright (c) 2012 The Chromium Embedded Framework Authors. +# Portions copyright (c) 2011 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import os, re, string, sys +from file_util import * +import git_util as git +import svn_util as svn + +# script directory +script_dir = os.path.dirname(__file__) + +# CEF root directory +cef_dir = os.path.abspath(os.path.join(script_dir, os.pardir)) + +# Valid extensions for files we want to lint. +DEFAULT_LINT_WHITELIST_REGEX = r"(.*\.cpp|.*\.cc|.*\.h)" +DEFAULT_LINT_BLACKLIST_REGEX = r"$^" + +try: + # depot_tools may already be in the import path. + import cpplint + import cpplint_chromium +except ImportError, e: + # Search the PATH environment variable to find the depot_tools folder. + depot_tools = None; + paths = os.environ.get('PATH').split(os.pathsep) + for path in paths: + if os.path.exists(os.path.join(path, 'cpplint_chromium.py')): + depot_tools = path + break + + if depot_tools is None: + print >> sys.stderr, 'Error: could not find depot_tools in PATH.' + sys.exit(2) + + # Add depot_tools to import path. + sys.path.append(depot_tools) + import cpplint + import cpplint_chromium + +# The default implementation of FileInfo.RepositoryName looks for the top-most +# directory that contains a .git or .svn folder. This is a problem for CEF +# because the CEF root folder (which may have an arbitrary name) lives inside +# the Chromium src folder. Reimplement in a dumb but sane way. +def patch_RepositoryName(self): + fullname = self.FullName() + project_dir = os.path.dirname(fullname) + if os.path.exists(fullname): + root_dir = project_dir + while os.path.basename(project_dir) != "src": + project_dir = os.path.dirname(project_dir) + prefix = os.path.commonprefix([root_dir, project_dir]) + components = fullname[len(prefix) + 1:].split('/') + return string.join(["cef"] + components[1:], '/') + return fullname + +def check_style(args, white_list = None, black_list = None): + """ Execute cpplint with the specified arguments. """ + + # Apply patches. + cpplint.FileInfo.RepositoryName = patch_RepositoryName + + # Process cpplint arguments. + filenames = cpplint.ParseArguments(args) + + if not white_list: + white_list = DEFAULT_LINT_WHITELIST_REGEX + white_regex = re.compile(white_list) + if not black_list: + black_list = DEFAULT_LINT_BLACKLIST_REGEX + black_regex = re.compile(black_list) + + extra_check_functions = [cpplint_chromium.CheckPointerDeclarationWhitespace] + + for filename in filenames: + if white_regex.match(filename): + if black_regex.match(filename): + print "Ignoring file %s" % filename + else: + cpplint.ProcessFile(filename, cpplint._cpplint_state.verbose_level, + extra_check_functions) + else: + print "Skipping file %s" % filename + + print "Total errors found: %d\n" % cpplint._cpplint_state.error_count + return 1 + +def get_changed_files(): + """ Retrieve the list of changed files. """ + try: + return svn.get_changed_files(cef_dir) + except: + return git.get_changed_files(cef_dir) + +if __name__ == "__main__": + # Start with the default parameters. + args = [ + # * Disable the 'build/class' test because it errors uselessly with C + # structure pointers and template declarations. + # * Disable the 'runtime/references' test because CEF allows non-const + # arguments passed by reference. + # * Disable the 'runtime/sizeof' test because it has a high number of + # false positives and adds marginal value. + '--filter=-build/class,-runtime/references,-runtime/sizeof', + ] + + # Add anything passed on the command-line. + args += sys.argv[1:] + + # Pre-process the arguments before passing to the linter. + new_args = [] + changed = [] + for arg in args: + if arg == '--changed': + # Add any changed files. + changed = get_changed_files() + elif arg[:2] == '--' or not os.path.isdir(arg): + # Pass argument unchanged. + new_args.append(arg) + else: + # Add all files in the directory. + new_args += get_files(os.path.join(arg, '*')) + + if len(changed) > 0: + new_args += changed + + check_style(new_args) diff --git a/cef3/tools/check_style.sh b/cef3/tools/check_style.sh new file mode 100755 index 000000000..3a38a6ab7 --- /dev/null +++ b/cef3/tools/check_style.sh @@ -0,0 +1,2 @@ +#!/bin/sh +python check_style.py $@ diff --git a/cef3/tools/date_util.py b/cef3/tools/date_util.py new file mode 100644 index 000000000..c19af17b4 --- /dev/null +++ b/cef3/tools/date_util.py @@ -0,0 +1,13 @@ +# 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. + +import datetime + +def get_year(): + """ Returns the current year. """ + return str(datetime.datetime.now().year) + +def get_date(): + """ Returns the current date. """ + return datetime.datetime.now().strftime('%B %d, %Y') diff --git a/cef3/tools/distrib/README-TRANSFER.txt b/cef3/tools/distrib/README-TRANSFER.txt new file mode 100644 index 000000000..6843cc201 --- /dev/null +++ b/cef3/tools/distrib/README-TRANSFER.txt @@ -0,0 +1,5 @@ +Files in this directory have been copied from other locations in the Chromium +source tree. They have been modified only to the extent necessary to work in +the CEF Binary Distribution directory structure. Below is a listing of the +original file locations. + diff --git a/cef3/tools/distrib/cefclient.gyp b/cef3/tools/distrib/cefclient.gyp new file mode 100644 index 000000000..2d9f6ee3d --- /dev/null +++ b/cef3/tools/distrib/cefclient.gyp @@ -0,0 +1,246 @@ +# 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. + +{ + 'variables': { + 'chromium_code': 1, + 'conditions': [ + [ 'OS=="mac"', { + # Don't use clang with CEF binary releases due to Chromium tree structure dependency. + 'clang': 0, + }] + ] + }, + 'includes': [ + # Bring in the source file lists for cefclient. + 'cef_paths2.gypi', + ], + 'targets': [ + { + 'target_name': 'cefclient', + 'type': 'executable', + 'mac_bundle': 1, + 'msvs_guid': '6617FED9-C5D4-4907-BF55-A90062A6683F', + 'dependencies': [ + 'libcef_dll_wrapper', + ], + 'defines': [ + 'USING_CEF_SHARED', + ], + 'include_dirs': [ + '.', + ], + 'sources': [ + '<@(includes_common)', + '<@(includes_wrapper)', + '<@(cefclient_sources_common)', + ], + 'mac_bundle_resources': [ + '<@(cefclient_bundle_resources_mac)', + ], + 'mac_bundle_resources!': [ + # TODO(mark): Come up with a fancier way to do this (mac_info_plist?) + # that automatically sets the correct INFOPLIST_FILE setting and adds + # the file to a source group. + 'cefclient/mac/Info.plist', + ], + 'xcode_settings': { + 'INFOPLIST_FILE': 'cefclient/mac/Info.plist', + # Target build path. + 'SYMROOT': 'xcodebuild', + }, + 'conditions': [ + ['OS=="win"', { + 'msvs_settings': { + 'VCLinkerTool': { + # Set /SUBSYSTEM:WINDOWS. + 'SubSystem': '2', + 'EntryPointSymbol' : 'wWinMainCRTStartup', + }, + }, + 'link_settings': { + 'libraries': [ + '-lcomctl32.lib', + '-lshlwapi.lib', + '-lrpcrt4.lib', + '-lopengl32.lib', + '-lglu32.lib', + '-llib/$(ConfigurationName)/libcef.lib' + ], + }, + 'sources': [ + '<@(includes_win)', + '<@(cefclient_sources_win)', + ], + }], + [ 'OS=="mac"', { + 'product_name': 'cefclient', + 'dependencies': [ + 'cefclient_helper_app', + ], + 'copies': [ + { + # Add library dependencies to the bundle. + 'destination': '<(PRODUCT_DIR)/cefclient.app/Contents/Frameworks/Chromium Embedded Framework.framework/Libraries/', + 'files': [ + '$(CONFIGURATION)/libcef.dylib', + '$(CONFIGURATION)/ffmpegsumo.so', + ], + }, + { + # Add other resources to the bundle. + 'destination': '<(PRODUCT_DIR)/cefclient.app/Contents/Frameworks/Chromium Embedded Framework.framework/', + 'files': [ + 'Resources/', + ], + }, + { + # Add the helper app. + 'destination': '<(PRODUCT_DIR)/cefclient.app/Contents/Frameworks', + 'files': [ + '<(PRODUCT_DIR)/cefclient Helper.app', + '$(CONFIGURATION)/libplugin_carbon_interpose.dylib', + ], + }, + ], + 'postbuilds': [ + { + 'postbuild_name': 'Fix Framework Link', + 'action': [ + 'install_name_tool', + '-change', + '@executable_path/libcef.dylib', + '@executable_path/../Frameworks/Chromium Embedded Framework.framework/Libraries/libcef.dylib', + '${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}' + ], + }, + { + # This postbuid step is responsible for creating the following + # helpers: + # + # cefclient Helper EH.app and cefclient Helper NP.app are created + # from cefclient Helper.app. + # + # The EH helper is marked for an executable heap. The NP helper + # is marked for no PIE (ASLR). + 'postbuild_name': 'Make More Helpers', + 'action': [ + 'tools/make_more_helpers.sh', + 'Frameworks', + 'cefclient', + ], + }, + ], + 'link_settings': { + 'libraries': [ + '$(SDKROOT)/System/Library/Frameworks/AppKit.framework', + '$(CONFIGURATION)/libcef.dylib', + ], + }, + 'sources': [ + '<@(includes_mac)', + '<@(cefclient_sources_mac)', + ], + }], + [ 'OS=="linux" or OS=="freebsd" or OS=="openbsd"', { + 'copies': [ + { + 'destination': '<(PRODUCT_DIR)/files', + 'files': [ + '<@(cefclient_bundle_resources_linux)', + ], + }, + ], + 'sources': [ + '<@(includes_linux)', + '<@(cefclient_sources_linux)', + ], + }], + ], + }, + { + 'target_name': 'libcef_dll_wrapper', + 'type': 'static_library', + 'msvs_guid': 'A9D6DC71-C0DC-4549-AEA0-3B15B44E86A9', + 'defines': [ + 'USING_CEF_SHARED', + ], + 'include_dirs': [ + '.', + ], + 'sources': [ + '<@(includes_common)', + '<@(includes_capi)', + '<@(includes_wrapper)', + '<@(libcef_dll_wrapper_sources_common)', + ], + 'xcode_settings': { + # Target build path. + 'SYMROOT': 'xcodebuild', + }, + }, + ], + 'conditions': [ + ['OS=="mac"', { + 'targets': [ + { + 'target_name': 'cefclient_helper_app', + 'type': 'executable', + 'variables': { 'enable_wexit_time_destructors': 1, }, + 'product_name': 'cefclient Helper', + 'mac_bundle': 1, + 'dependencies': [ + 'libcef_dll_wrapper', + ], + 'defines': [ + 'USING_CEF_SHARED', + ], + 'include_dirs': [ + '.', + ], + 'link_settings': { + 'libraries': [ + '$(SDKROOT)/System/Library/Frameworks/AppKit.framework', + '$(CONFIGURATION)/libcef.dylib', + ], + }, + 'sources': [ + '<@(cefclient_sources_mac_helper)', + ], + # TODO(mark): Come up with a fancier way to do this. It should only + # be necessary to list helper-Info.plist once, not the three times it + # is listed here. + 'mac_bundle_resources!': [ + 'cefclient/mac/helper-Info.plist', + ], + # TODO(mark): For now, don't put any resources into this app. Its + # resources directory will be a symbolic link to the browser app's + # resources directory. + 'mac_bundle_resources/': [ + ['exclude', '.*'], + ], + 'xcode_settings': { + 'INFOPLIST_FILE': 'cefclient/mac/helper-Info.plist', + }, + 'postbuilds': [ + { + # The framework defines its load-time path + # (DYLIB_INSTALL_NAME_BASE) relative to the main executable + # (chrome). A different relative path needs to be used in + # cefclient_helper_app. + 'postbuild_name': 'Fix Framework Link', + 'action': [ + 'install_name_tool', + '-change', + '@executable_path/libcef.dylib', + '@executable_path/../../../../Frameworks/Chromium Embedded Framework.framework/Libraries/libcef.dylib', + '${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}' + ], + }, + ], + }, # target cefclient_helper_app + ], + }], # OS=="mac" + ], +} diff --git a/cef3/tools/distrib/linux/README.txt b/cef3/tools/distrib/linux/README.txt new file mode 100644 index 000000000..f2ce664ab --- /dev/null +++ b/cef3/tools/distrib/linux/README.txt @@ -0,0 +1,89 @@ +Chromium Embedded Framework (CEF) Binary Distribution +------------------------------------------------------------------------------- + +Date: $DATE$ + +CEF Version: $CEF_VER$ +CEF URL: $CEF_URL$@$CEF_REV$ + +Chromium Verison: $CHROMIUM_VER$ +Chromium URL: $CHROMIUM_URL$@$CHROMIUM_REV$ + + +This distribution contains all components necessary to build and distribute an +application using CEF. Please see the LICENSING section of this document for +licensing terms and conditions. + + +CONTENTS +-------- + +cefclient Contains the cefclient sample application configured to build + using the files in this distribution. + +Debug Contains libcef.so and other components required to run the debug + version of CEF-based applications. + +docs Contains C++ API documentation generated from the CEF header files. + +include Contains all required CEF header files. + +libcef_dll Contains the source code for the libcef_dll_wrapper static library + that all applications using the CEF C++ API must link against. + +Release Contains libcef.so and other components required to run the + release version of CEF-based applications. + + +USAGE +----- + +Run 'make -j4 cefclient BUILDTYPE=Debug' to build the cefclient target in +Debug mode. + +Please visit the CEF Website for additional usage information. + +http://code.google.com/p/chromiumembedded + + +REDISTRIBUTION +-------------- + +This binary distribution contains the below components. Components listed under +the "required" section must be redistributed with all applications using CEF. +Components listed under the "optional" section may be excluded if the related +features will not be used. + +Required components: + +* CEF core library + libcef.so + +Optional components: + +* Localized resources + locales/ + Note: Contains localized strings for WebKit UI controls. A .pak file is loaded + from this folder based on the value of environment variables which are read + with the following precedence order: LANGUAGE, LC_ALL, LC_MESSAGES and LANG. + Only configured locales need to be distributed. If no locale is configured the + default locale of "en-US" will be used. Locale file loading can be disabled + completely using CefSettings.pack_loading_disabled. The locales folder path + can be customized using CefSettings.locales_dir_path. + +* Other resources + cef.pak + devtools_resources.pak + Note: Contains WebKit image and inspector resources. Pack file loading can be + disabled completely using CefSettings.pack_loading_disabled. The resources + directory path can be customized using CefSettings.resources_dir_path. + + +LICENSING +--------- + +The CEF project is BSD licensed. Please read the LICENSE.txt file included with +this binary distribution for licensing terms and conditions. Other software +included in this distribution is provided under other licenses. Please visit +"about:credits" in a CEF-based application for complete Chromium and third-party +licensing information. diff --git a/cef3/tools/distrib/mac/README.txt b/cef3/tools/distrib/mac/README.txt new file mode 100644 index 000000000..b77d77cf7 --- /dev/null +++ b/cef3/tools/distrib/mac/README.txt @@ -0,0 +1,104 @@ +Chromium Embedded Framework (CEF) Binary Distribution +------------------------------------------------------------------------------- + +Date: $DATE$ + +CEF Version: $CEF_VER$ +CEF URL: $CEF_URL$@$CEF_REV$ + +Chromium Verison: $CHROMIUM_VER$ +Chromium URL: $CHROMIUM_URL$@$CHROMIUM_REV$ + + +This distribution contains all components necessary to build and distribute an +application using CEF. Please see the LICENSING section of this document for +licensing terms and conditions. + + +CONTENTS +-------- + +cefclient Contains the cefclient sample application configured to build + using the files in this distribution. + +Debug Contains libcef.dylib and other components required to run the debug + version of CEF-based applications. + +docs Contains C++ API documentation generated from the CEF header files. + +include Contains all required CEF header files. + +libcef_dll Contains the source code for the libcef_dll_wrapper static library + that all applications using the CEF C++ API must link against. + +Release Contains libcef.dylib and other components required to run the + release version of CEF-based applications. + +Resources Contains images and resources required by applications using CEF. + The contents of this folder should be transferred to the + Contents/Resources folder in the app bundle. + +tools Scripts that perform post-processing on Mac release targets. + + +USAGE +----- + +Xcode 3 and 4: Open the cefclient.xcodeproj project and build. + +When using Xcode 4.2 or newer you will need to change the "Compiler for +C/C++/Objective-C" setting to "LLVM GCC 4.2" under "Build Settings" for +each target. + +Please visit the CEF Website for additional usage information. + +http://code.google.com/p/chromiumembedded + + +REDISTRIBUTION +-------------- + +This binary distribution contains the below components. Components listed under +the "required" section must be redistributed with all applications using CEF. +Components listed under the "optional" section may be excluded if the related +features will not be used. + +Required components: + +* CEF core library + libcef.dylib + +* Cursor resources + Resources/*.png + Resources/*.tiff + +Optional components: + +* Localized resources + Resources/*.lproj/ + Note: Contains localized strings for WebKit UI controls. A .pak file is loaded + from this folder based on the CefSettings.locale value. Only configured + locales need to be distributed. If no locale is configured the default locale + of "en" will be used. Locale file loading can be disabled completely using + CefSettings.pack_loading_disabled. + +* Other resources + Resources/cef.pak + Resources/devtools_resources.pak + Note: Contains WebKit image and inspector resources. Pack file loading can be + disabled completely using CefSettings.pack_loading_disabled. The resources + directory path can be customized using CefSettings.resources_dir_path. + +* FFmpeg audio and video support + ffmpegsumo.so + Note: Without this component HTML5 audio and video will not function. + + +LICENSING +--------- + +The CEF project is BSD licensed. Please read the LICENSE.txt file included with +this binary distribution for licensing terms and conditions. Other software +included in this distribution is provided under other licenses. Please visit +"about:credits" in a CEF-based application for complete Chromium and third-party +licensing information. diff --git a/cef3/tools/distrib/mac/transfer.cfg b/cef3/tools/distrib/mac/transfer.cfg new file mode 100644 index 000000000..952c06166 --- /dev/null +++ b/cef3/tools/distrib/mac/transfer.cfg @@ -0,0 +1,33 @@ +# Additional handling of transfer files. +# target: Target location relative to the target release directory. This +# value is required. +# source: Source location relative to the CEF root directory. This value +# is optional. If specified the target will be copied to this location +# and a TRANSFER-README.txt file will be created. +# post-process: Post-processing operation to perform. This value is +# optional and may be any one of the following: +# 'normalize_headers': Replace fully-qualified project header paths with +# the optionally specified 'new_header_path' value. + +[ + { + 'source' : '../build/mac/change_mach_o_flags_from_xcode.sh', + 'target' : 'tools/change_mach_o_flags_from_xcode.sh', + }, + { + 'source' : '../build/mac/change_mach_o_flags.py', + 'target' : 'tools/change_mach_o_flags.py', + }, + { + 'source' : '../build/mac/strip_from_xcode', + 'target' : 'tools/strip_from_xcode', + }, + { + 'source' : '../build/mac/strip_save_dsym', + 'target' : 'tools/strip_save_dsym', + }, + { + 'source' : '../build/mac/make_more_helpers.sh', + 'target' : 'tools/make_more_helpers.sh', + }, +] diff --git a/cef3/tools/distrib/transfer.cfg b/cef3/tools/distrib/transfer.cfg new file mode 100644 index 000000000..a0e42dc57 --- /dev/null +++ b/cef3/tools/distrib/transfer.cfg @@ -0,0 +1,13 @@ +# Additional handling of transfer files. +# target: Target location relative to the target release directory. This +# value is required. +# source: Source location relative to the CEF root directory. This value +# is optional. If specified the target will be copied to this location +# and a TRANSFER-README.txt file will be created. +# post-process: Post-processing operation to perform. This value is +# optional and may be any one of the following: +# 'normalize_headers': Replace fully-qualified project header paths with +# the optionally specified 'new_header_path' value. + +[ +] \ No newline at end of file diff --git a/cef3/tools/distrib/win/README.txt b/cef3/tools/distrib/win/README.txt new file mode 100644 index 000000000..2923fd1d1 --- /dev/null +++ b/cef3/tools/distrib/win/README.txt @@ -0,0 +1,118 @@ +Chromium Embedded Framework (CEF) Binary Distribution +------------------------------------------------------------------------------- + +Date: $DATE$ + +CEF Version: $CEF_VER$ +CEF URL: $CEF_URL$@$CEF_REV$ + +Chromium Verison: $CHROMIUM_VER$ +Chromium URL: $CHROMIUM_URL$@$CHROMIUM_REV$ + + +This distribution contains all components necessary to build and distribute an +application using CEF. Please see the LICENSING section of this document for +licensing terms and conditions. + + +CONTENTS +-------- + +cefclient Contains the cefclient sample application configured to build + using the files in this distribution. + +Debug Contains libcef.dll and other components required to run the debug + version of CEF-based applications. Also acts as the build target for + the Debug build of cefclient. + +docs Contains C++ API documentation generated from the CEF header files. + +include Contains all required CEF header files. + +lib Contains Debug and Release versions of the libcef.lib library file + that all CEF-based applications must link against. + +libcef_dll Contains the source code for the libcef_dll_wrapper static library + that all applications using the CEF C++ API must link against. + +Release Contains libcef.dll and other components required to run the release + version of CEF-based applications. Also acts as the build target for + the Release build of cefclient. + + +USAGE +----- + +Visual Studio 2012 and Visual Studio 2010: + Open the cefclient2010.sln solution in Visual Studio and build. + +Visual Studio 2008: + Open the cefclient2008.sln solution in Visual Studio and build. + +Visual Studio 2005: + 1. Open the cefclient.vcproj and libcef_dll_wrapper.vcproj files in a text + editor. Change Version="9.00" to Version="8.00". + 2. Open the cefclient2005.sln file in a text editor. Change "Version 9.00" to + "Version 8.00". + 3. Open the cefclient2005.sln solution in Visual Studio and build. + +Please visit the CEF Website for additional usage information. + +http://code.google.com/p/chromiumembedded + + +REDISTRIBUTION +-------------- + +This binary distribution contains the below components. Components listed under +the "required" section must be redistributed with all applications using CEF. +Components listed under the "optional" section may be excluded if the related +features will not be used. + +Required components: + +* CEF core library + libcef.dll + +* Unicode support + icudt.dll + +Optional components: + +* Localized resources + locales/ + Note: Contains localized strings for WebKit UI controls. A .pak file is loaded + from this folder based on the CefSettings.locale value. Only configured + locales need to be distributed. If no locale is configured the default locale + of "en-US" will be used. Locale file loading can be disabled completely using + CefSettings.pack_loading_disabled. The locales folder path can be customized + using CefSettings.locales_dir_path. + +* Other resources + cef.pak + devtools_resources.pak + Note: Contains WebKit image and inspector resources. Pack file loading can be + disabled completely using CefSettings.pack_loading_disabled. The resources + directory path can be customized using CefSettings.resources_dir_path. + +* FFmpeg audio and video support + ffmpegsumo.dll + Note: Without this component HTML5 audio and video will not function. + +* Angle and Direct3D support + d3dcompiler_43.dll (required for Windows XP) + d3dcompiler_46.dll (required for Windows Vista and newer) + libEGL.dll + libGLESv2.dll + Note: Without these components HTML5 accelerated content like 2D canvas, 3D + CSS and WebGL will not function. + + +LICENSING +--------- + +The CEF project is BSD licensed. Please read the LICENSE.txt file included with +this binary distribution for licensing terms and conditions. Other software +included in this distribution is provided under other licenses. Please visit +"about:credits" in a CEF-based application for complete Chromium and third-party +licensing information. diff --git a/cef3/tools/distrib/win/d3dcompiler_43.dll b/cef3/tools/distrib/win/d3dcompiler_43.dll new file mode 100644 index 000000000..ab9616191 Binary files /dev/null and b/cef3/tools/distrib/win/d3dcompiler_43.dll differ diff --git a/cef3/tools/file_util.py b/cef3/tools/file_util.py new file mode 100644 index 000000000..b94e13601 --- /dev/null +++ b/cef3/tools/file_util.py @@ -0,0 +1,119 @@ +# 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. + +from glob import iglob +import os +import shutil +import sys +import time + +def read_file(name, normalize = True): + """ Read a file. """ + try: + f = open(name, 'r') + # read the data + data = f.read() + if normalize: + # normalize line endings + data = data.replace("\r\n", "\n") + return data + except IOError, (errno, strerror): + sys.stderr.write('Failed to read file '+name+': '+strerror) + raise + else: + f.close() + +def write_file(name, data): + """ Write a file. """ + try: + f = open(name, 'w') + # write the data + f.write(data) + except IOError, (errno, strerror): + sys.stderr.write('Failed to write file '+name+': '+strerror) + raise + else: + f.close() + +def path_exists(name): + """ Returns true if the path currently exists. """ + return os.path.exists(name) + +def backup_file(name): + """ Rename the file to a name that includes the current time stamp. """ + move_file(name, name+'.'+time.strftime('%Y-%m-%d-%H-%M-%S')) + +def copy_file(src, dst, quiet = True): + """ Copy a file. """ + try: + shutil.copy(src, dst) + if not quiet: + sys.stdout.write('Transferring '+src+' file.\n') + except IOError, (errno, strerror): + sys.stderr.write('Failed to copy file from '+src+' to '+dst+': '+strerror) + raise + +def move_file(src, dst, quiet = True): + """ Move a file. """ + try: + shutil.move(src, dst) + if not quiet: + sys.stdout.write('Moving '+src+' file.\n') + except IOError, (errno, strerror): + sys.stderr.write('Failed to move file from '+src+' to '+dst+': '+strerror) + raise + +def copy_files(src_glob, dst_folder, quiet = True): + """ Copy multiple files. """ + for fname in iglob(src_glob): + dst = os.path.join(dst_folder, os.path.basename(fname)) + if os.path.isdir(fname): + copy_dir(fname, dst, quiet) + else: + copy_file(fname, dst, quiet) + +def copy_dir(src, dst, quiet = True): + """ Copy a directory tree. """ + try: + remove_dir(dst, quiet) + shutil.copytree(src, dst) + if not quiet: + sys.stdout.write('Transferring '+src+' directory.\n') + except IOError, (errno, strerror): + sys.stderr.write('Failed to copy directory from '+src+' to '+dst+': '+strerror) + raise + +def remove_dir(name, quiet = True): + """ Remove the specified directory. """ + try: + if path_exists(name): + shutil.rmtree(name) + if not quiet: + sys.stdout.write('Removing '+name+' directory.\n') + except IOError, (errno, strerror): + sys.stderr.write('Failed to remove directory '+name+': '+strerror) + raise + +def make_dir(name, quiet = True): + """ Create the specified directory. """ + try: + if not path_exists(name): + if not quiet: + sys.stdout.write('Creating '+name+' directory.\n') + os.makedirs(name) + except IOError, (errno, strerror): + sys.stderr.write('Failed to create directory '+name+': '+strerror) + raise + +def get_files(search_glob): + """ Returns all files matching the search glob. """ + return iglob(search_glob) + +def read_version_file(file, args): + """ Read and parse a version file (key=value pairs, one per line). """ + lines = read_file(file).split("\n") + for line in lines: + parts = line.split('=', 1) + if len(parts) == 2: + args[parts[0]] = parts[1] diff --git a/cef3/tools/gclient_hook.py b/cef3/tools/gclient_hook.py new file mode 100644 index 000000000..c4be02cc4 --- /dev/null +++ b/cef3/tools/gclient_hook.py @@ -0,0 +1,32 @@ +# Copyright (c) 2011 The Chromium Embedded Framework Authors. +# Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +from gclient_util import * +import os, sys + +# The CEF root directory is the parent directory of _this_ script. +cef_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) + +print "\nChecking CEF and Chromium revisions..." +gyper = [ 'python', 'tools/check_revision.py' ] +RunAction(cef_dir, gyper) + +print "\nGenerating CEF version header file..." +gyper = [ 'python', 'tools/make_version_header.py', + '--header', 'include/cef_version.h', + '--cef_version', 'VERSION', + '--chrome_version', '../chrome/VERSION', + '--cpp_header_dir', 'include' ] +RunAction(cef_dir, gyper) + +print "\nPatching build configuration and source files for CEF..." +patcher = [ 'python', 'tools/patcher.py', + '--patch-config', 'patch/patch.cfg' ]; +RunAction(cef_dir, patcher) + +print "\nGenerating CEF project files..." +os.environ['CEF_DIRECTORY'] = os.path.basename(cef_dir); +gyper = [ 'python', 'tools/gyp_cef', 'cef.gyp', '-I', 'cef.gypi' ] +RunAction(cef_dir, gyper) diff --git a/cef3/tools/gclient_util.py b/cef3/tools/gclient_util.py new file mode 100644 index 000000000..300841456 --- /dev/null +++ b/cef3/tools/gclient_util.py @@ -0,0 +1,45 @@ +# Copyright (c) 2011 The Chromium Embedded Framework Authors. +# Portions copyright (c) 2011 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import os, sys + +try: + # depot_tools may already be in the import path. + import gclient_utils +except ImportError, e: + # Search the PATH environment variable to find the depot_tools folder. + depot_tools = None; + paths = os.environ.get('PATH').split(os.pathsep) + for path in paths: + if os.path.exists(os.path.join(path, 'gclient_utils.py')): + depot_tools = path + break + + if depot_tools is None: + print >> sys.stderr, 'Error: could not find depot_tools in PATH.' + sys.exit(2) + + # Add depot_tools to import path. + sys.path.append(depot_tools) + import gclient_utils + +# Copied from gclient.py python code. +def RunAction(dir, command): + """Runs the action.""" + if command[0] == 'python': + # If the hook specified "python" as the first item, the action is a + # Python script. Run it by starting a new copy of the same + # interpreter. + command[0] = sys.executable + + try: + gclient_utils.CheckCallAndFilterAndHeader( + command, cwd=dir, always=True) + except gclient_utils.Error, e: + # Use a discrete exit status code of 2 to indicate that a hook action + # failed. Users of this script may wish to treat hook action failures + # differently from VC failures. + print >> sys.stderr, 'Error: %s' % str(e) + sys.exit(2) diff --git a/cef3/tools/git_util.py b/cef3/tools/git_util.py new file mode 100644 index 000000000..a641c83fa --- /dev/null +++ b/cef3/tools/git_util.py @@ -0,0 +1,24 @@ +# 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 + +from subprocess import Popen, PIPE + +def get_svn_revision(path=".", branch="master"): + svn_rev = "None" + cmd = ("git log --grep=^git-svn-id: -n 1 %s" % branch).split() + try: + process = Popen(cmd, cwd=path, stdout = PIPE, stderr = PIPE) + for line in process.stdout: + if line.find("git-svn-id") > 0: + svn_rev = line.split("@")[1].split()[0] + break + except IOError, (errno, strerror): + sys.stderr.write('Failed to read git log: ' + strerror + "\n") + raise + return svn_rev + +def get_changed_files(path="."): + """ Retrieves the list of changed files. """ + # not implemented + return [] diff --git a/cef3/tools/gyp_cef b/cef3/tools/gyp_cef new file mode 100755 index 000000000..4ccdb64e5 --- /dev/null +++ b/cef3/tools/gyp_cef @@ -0,0 +1,156 @@ +#!/usr/bin/env python + +# Copyright (c) 2011 The Chromium Embedded Framework Authors. +# Portions copyright (c) 2011 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# This script is wrapper for CEF/Chromium that adds some support for how GYP +# is invoked by Chromium beyond what can be done in the gclient hooks. + +import glob +import os +import shlex +import subprocess +import sys + +# The CEF root directory is the parent directory of _this_ script. +cef_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) + +# The Chromium source directory is the parent directory of CEF. +chrome_src = os.path.abspath(os.path.join(cef_dir, os.pardir)) + +sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib')) +import gyp + +# Add paths so that pymod_do_main(...) can import files. +sys.path.insert(1, os.path.join(chrome_src, 'tools', 'grit')) +sys.path.insert(1, os.path.join(chrome_src, 'chrome', 'tools', 'build')) +sys.path.insert(1, os.path.join(chrome_src, 'third_party', 'WebKit', + 'Source', 'WebCore', 'WebCore.gyp', 'scripts')) + +# On Windows, Psyco shortens warm runs of build/gyp_chromium by about +# 20 seconds on a z600 machine with 12 GB of RAM, from 90 down to 70 +# seconds. Conversely, memory usage of build/gyp_chromium with Psyco +# maxes out at about 158 MB vs. 132 MB without it. +# +# Psyco uses native libraries, so we need to load a different +# installation depending on which OS we are running under. It has not +# been tested whether using Psyco on our Mac and Linux builds is worth +# it (the GYP running time is a lot shorter, so the JIT startup cost +# may not be worth it). +if sys.platform == 'win32': + try: + sys.path.insert(0, os.path.join(chrome_src, 'third_party', 'psyco_win32')) + import psyco + except: + psyco = None +else: + psyco = None + +def apply_gyp_environment(file_path=None): + """ + Reads in a *.gyp_env file and applies the valid keys to os.environ. + """ + if not file_path or not os.path.exists(file_path): + return + file_contents = open(file_path).read() + try: + file_data = eval(file_contents, {'__builtins__': None}, None) + except SyntaxError, e: + e.filename = os.path.abspath(file_path) + raise + supported_vars = ( 'CHROMIUM_GYP_SYNTAX_CHECK', + 'GYP_DEFINES', + 'GYP_GENERATOR_FLAGS', + 'GYP_GENERATOR_OUTPUT', ) + for var in supported_vars: + val = file_data.get(var) + if val: + if var in os.environ: + print 'INFO: Environment value for "%s" overrides value in %s.' % ( + var, os.path.abspath(file_path) + ) + else: + os.environ[var] = val + +def additional_include_files(args=[]): + """ + Returns a list of additional (.gypi) files to include, without + duplicating ones that are already specified on the command line. + """ + # Determine the include files specified on the command line. + # This doesn't cover all the different option formats you can use, + # but it's mainly intended to avoid duplicating flags on the automatic + # makefile regeneration which only uses this format. + specified_includes = set() + for arg in args: + if arg.startswith('-I') and len(arg) > 2: + specified_includes.add(os.path.realpath(arg[2:])) + + result = [] + def AddInclude(path): + if os.path.realpath(path) not in specified_includes: + result.append(path) + + # Always include common.gypi. + AddInclude(os.path.join(chrome_src, 'build', 'common.gypi')) + + # Optionally add supplemental .gypi files if present. + supplements = glob.glob(os.path.join(chrome_src, '*', 'supplement.gypi')) + for supplement in supplements: + AddInclude(supplement) + + return result + +if __name__ == '__main__': + args = sys.argv[1:] + + # Use the Psyco JIT if available. + if psyco: + psyco.profile() + print "Enabled Psyco JIT." + + # Fall back on hermetic python if we happen to get run under cygwin. + # TODO(bradnelson): take this out once this issue is fixed: + # http://code.google.com/p/gyp/issues/detail?id=177 + if sys.platform == 'cygwin': + python_dir = os.path.join(chrome_src, 'third_party', 'python_26') + env = os.environ.copy() + env['PATH'] = python_dir + os.pathsep + env.get('PATH', '') + p = subprocess.Popen( + [os.path.join(python_dir, 'python.exe')] + sys.argv, + env=env, shell=False) + p.communicate() + sys.exit(p.returncode) + + if 'SKIP_CHROMIUM_GYP_ENV' not in os.environ: + # Update the environment based on chromium.gyp_env + gyp_env_path = os.path.join(os.path.dirname(chrome_src), 'chromium.gyp_env') + apply_gyp_environment(gyp_env_path) + + args.extend(['-I' + i for i in additional_include_files(args)]) + + # There shouldn't be a circular dependency relationship between .gyp files, + # but in Chromium's .gyp files, on non-Mac platforms, circular relationships + # currently exist. The check for circular dependencies is currently + # bypassed on other platforms, but is left enabled on the Mac, where a + # violation of the rule causes Xcode to misbehave badly. + # TODO(mark): Find and kill remaining circular dependencies, and remove this + # option. http://crbug.com/35878. + # TODO(tc): Fix circular dependencies in ChromiumOS then add linux2 to the + # list. + if sys.platform not in ('darwin',): + args.append('--no-circular-check') + + # If CHROMIUM_GYP_SYNTAX_CHECK is set to 1, it will invoke gyp with --check + # to enfore syntax checking. + syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK') + if syntax_check and int(syntax_check): + args.append('--check') + + print 'Updating projects from gyp files...' + sys.stdout.flush() + + # Off we go... + sys.exit(gyp.main(args)) diff --git a/cef3/tools/make_capi_header.py b/cef3/tools/make_capi_header.py new file mode 100644 index 000000000..b0b667a59 --- /dev/null +++ b/cef3/tools/make_capi_header.py @@ -0,0 +1,174 @@ +# 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. + +from cef_parser import * +from date_util import * + +def make_capi_global_funcs(funcs, defined_names, translate_map, indent): + result = '' + first = True + for func in funcs: + comment = func.get_comment() + if first or len(comment) > 0: + result += '\n'+format_comment(comment, indent, translate_map); + if func.get_retval().get_type().is_result_string(): + result += indent+'// The resulting string must be freed by calling cef_string_userfree_free().\n' + result += wrap_code(indent+'CEF_EXPORT '+ + func.get_capi_proto(defined_names)+';') + if first: + first = False + return result + +def make_capi_member_funcs(funcs, defined_names, translate_map, indent): + result = '' + first = True + for func in funcs: + comment = func.get_comment() + if first or len(comment) > 0: + result += '\n'+format_comment(comment, indent, translate_map) + if func.get_retval().get_type().is_result_string(): + result += indent+'// The resulting string must be freed by calling cef_string_userfree_free().\n' + parts = func.get_capi_parts() + result += wrap_code(indent+parts['retval']+' (CEF_CALLBACK *'+ + parts['name']+')('+ + string.join(parts['args'], ', ')+');') + if first: + first = False + return result + +def make_capi_header(header, filename): + # structure names that have already been defined + defined_names = header.get_defined_structs() + + # map of strings that will be changed in C++ comments + translate_map = header.get_capi_translations() + + # header string + result = \ +"""// Copyright (c) $YEAR$ Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef $GUARD$ +#define $GUARD$ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "include/capi/cef_base_capi.h" + +""" + # output global functions + funcs = header.get_funcs(filename) + if len(funcs) > 0: + result += make_capi_global_funcs(funcs, defined_names, translate_map, '') + + # output classes + classes = header.get_classes(filename) + for cls in classes: + # virtual functions are inside the structure + classname = cls.get_capi_name() + result += '\n'+format_comment(cls.get_comment(), '', translate_map); + result += 'typedef struct _'+classname+ \ + ' {\n ///\n // Base structure.\n ///\n cef_base_t base;\n' + funcs = cls.get_virtual_funcs() + result += make_capi_member_funcs(funcs, defined_names, + translate_map, ' ') + result += '} '+classname+';\n\n' + + defined_names.append(cls.get_capi_name()) + + # static functions become global + funcs = cls.get_static_funcs() + if len(funcs) > 0: + result += make_capi_global_funcs(funcs, defined_names, + translate_map, '')+'\n' + + # footer string + result += \ +""" +#ifdef __cplusplus +} +#endif + +#endif // $GUARD$ +""" + + # add the copyright year + result = result.replace('$YEAR$', get_year()) + # add the guard string + guard = 'CEF_INCLUDE_CAPI_'+string.upper(filename.replace('.', '_capi_'))+'_' + result = result.replace('$GUARD$', guard) + + return result + + +def write_capi_header(header, filepath, backup): + capi_path = get_capi_file_name(filepath) + if path_exists(capi_path): + oldcontents = read_file(capi_path) + else: + oldcontents = '' + + filename = os.path.split(filepath)[1] + newcontents = make_capi_header(header, filename) + if newcontents != oldcontents: + if backup and oldcontents != '': + backup_file(capi_path) + write_file(capi_path, newcontents) + return True + + return False + + +# test the module +if __name__ == "__main__": + import sys + + # verify that the correct number of command-line arguments are provided + if len(sys.argv) < 2: + sys.stderr.write('Usage: '+sys.argv[0]+' ') + sys.exit() + + # create the header object + header = obj_header() + header.add_file(sys.argv[1]) + + # dump the result to stdout + filename = os.path.split(sys.argv[1])[1] + sys.stdout.write(make_capi_header(header, filename)) diff --git a/cef3/tools/make_cppdocs.bat b/cef3/tools/make_cppdocs.bat new file mode 100644 index 000000000..279436074 --- /dev/null +++ b/cef3/tools/make_cppdocs.bat @@ -0,0 +1,18 @@ +@echo off +setlocal + +if "%1"=="" ( +set CPPDOC_EXE="C:\Program Files (x86)\richfeit\CppDoc\CppDoc.exe" +set CPPDOC_REV="XXX" +) else ( +set CPPDOC_EXE="C:\Program Files (x86)\richfeit\CppDoc\cppdoc_cmd.exe" +set CPPDOC_REV="%1" +) + +if not exist %CPPDOC_EXE% ( +echo ERROR: Please install CppDoc from http://www.cppdoc.com/ +) else ( +%CPPDOC_EXE% -overwrite -title="CEF3 C++ API Docs - Revision %CPPDOC_REV%" -footer="
Chromium Embedded Framework (CEF) Copyright © 2012 Marshall A. Greenblatt
" -namespace-as-project -comment-format="///;//;///" -classdir=projects -module="cppdoc-standard" -extensions=h -languages="c=cpp,cc=cpp,cpp=cpp,cs=csharp,cxx=cpp,h=cpp,hpp=cpp,hxx=cpp,java=java" -D"OS_WIN" -D"USING_CEF_SHARED" -D"__cplusplus" -D"CEF_STRING_TYPE_UTF16" -enable-author=false -enable-deprecations=true -enable-since=true -enable-version=false -file-links-for-globals=false -generate-deprecations-list=false -generate-hierarchy=true -header-background-dark="#ccccff" -header-background-light="#eeeeff" -include-private=false -include-protected=true -index-file-base=index -overview-html=overview.html -reduce-summary-font=true -selected-text-background=navy -selected-text-foreground=white -separate-index-pages=false -show-cppdoc-version=false -show-timestamp=false -summary-html=project.html -suppress-details=false -suppress-frames-links=false -table-background=white -wrap-long-lines=false ..\include #cef_runnable.h #cef_tuple.h #capi "..\docs\index.html" +) + +endlocal \ No newline at end of file diff --git a/cef3/tools/make_cpptoc_header.py b/cef3/tools/make_cpptoc_header.py new file mode 100644 index 000000000..4f930e224 --- /dev/null +++ b/cef3/tools/make_cpptoc_header.py @@ -0,0 +1,106 @@ +# 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. + +from cef_parser import * + +def make_cpptoc_header(header, clsname): + cls = header.get_class(clsname) + if cls is None: + raise Exception('Class does not exist: '+clsname) + + dllside = cls.is_library_side() + defname = string.upper(get_capi_name(clsname[3:], False)) + capiname = cls.get_capi_name() + + result = get_copyright() + + result += '#ifndef CEF_LIBCEF_DLL_CPPTOC_'+defname+'_CPPTOC_H_\n'+ \ + '#define CEF_LIBCEF_DLL_CPPTOC_'+defname+'_CPPTOC_H_\n' + \ + '#pragma once\n' + + if dllside: + result += """ +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED +""" + else: + result += """ +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED +""" + + # include the headers for this class + result += '\n#include "include/'+cls.get_file_name()+'"\n' \ + '#include "include/capi/'+cls.get_capi_file_name()+'"\n' + + # include headers for any forward declared classes that are not in the same file + declares = cls.get_forward_declares() + for declare in declares: + dcls = header.get_class(declare) + if dcls.get_file_name() != cls.get_file_name(): + result += '#include "include/'+dcls.get_file_name()+'"\n' \ + '#include "include/capi/'+dcls.get_capi_file_name()+'"\n' + + result += """#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +""" + + if dllside: + result += '// This class may be instantiated and accessed DLL-side only.\n' + else: + result += '// This class may be instantiated and accessed wrapper-side only.\n' + + result += 'class '+clsname+'CppToC\n'+ \ + ' : public CefCppToC<'+clsname+'CppToC, '+clsname+', '+capiname+'> {\n'+ \ + ' public:\n'+ \ + ' explicit '+clsname+'CppToC('+clsname+'* cls);\n'+ \ + ' virtual ~'+clsname+'CppToC() {}\n'+ \ + '};\n\n' + + if dllside: + result += '#endif // BUILDING_CEF_SHARED\n' + else: + result += '#endif // USING_CEF_SHARED\n' + + result += '#endif // CEF_LIBCEF_DLL_CPPTOC_'+defname+'_CPPTOC_H_\n' + + return wrap_code(result) + + +def write_cpptoc_header(header, clsname, dir, backup): + file = dir+os.sep+get_capi_name(clsname[3:], False)+'_cpptoc.h' + + if path_exists(file): + oldcontents = read_file(file) + else: + oldcontents = '' + + newcontents = make_cpptoc_header(header, clsname) + if newcontents != oldcontents: + if backup and oldcontents != '': + backup_file(file) + write_file(file, newcontents) + return True + + return False + + +# test the module +if __name__ == "__main__": + import sys + + # verify that the correct number of command-line arguments are provided + if len(sys.argv) < 3: + sys.stderr.write('Usage: '+sys.argv[0]+' ') + sys.exit() + + # create the header object + header = obj_header() + header.add_file(sys.argv[1]) + + # dump the result to stdout + sys.stdout.write(make_cpptoc_header(header, sys.argv[2])) diff --git a/cef3/tools/make_cpptoc_impl.py b/cef3/tools/make_cpptoc_impl.py new file mode 100644 index 000000000..0872b362e --- /dev/null +++ b/cef3/tools/make_cpptoc_impl.py @@ -0,0 +1,563 @@ +# 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. + +from cef_parser import * + +def make_cpptoc_impl_proto(name, func, parts): + if isinstance(func, obj_function_virtual): + proto = parts['retval']+' CEF_CALLBACK' + else: + proto = 'CEF_EXPORT '+parts['retval'] + + proto += ' '+name+'('+string.join(parts['args'], ', ')+')' + return proto + +def make_cpptoc_function_impl_existing(name, func, impl, defined_names): + notify(name+' has manual edits') + + # retrieve the C API prototype parts + parts = func.get_capi_parts(defined_names) + + changes = format_translation_changes(impl, parts) + if len(changes) > 0: + notify(name+' prototype changed') + + return wrap_code(make_cpptoc_impl_proto(name, func, parts))+'{'+ \ + changes+impl['body']+'\n}\n' + return result + +def make_cpptoc_function_impl_new(name, func, defined_names): + # retrieve the C API prototype parts + parts = func.get_capi_parts(defined_names) + result = make_cpptoc_impl_proto(name, func, parts)+' {' + + invalid = [] + + # retrieve the function arguments + args = func.get_arguments() + + # determine the argument types + for arg in args: + if arg.get_arg_type() == 'invalid': + invalid.append(arg.get_name()) + + # retrieve the function return value + retval = func.get_retval() + retval_type = retval.get_retval_type() + if retval_type == 'invalid': + invalid.append('(return value)') + retval_default = '' + else: + retval_default = retval.get_retval_default(True) + if len(retval_default) > 0: + retval_default = ' '+retval_default; + + if len(invalid) > 0: + notify(name+' could not be autogenerated') + # code could not be auto-generated + result += '\n // BEGIN DELETE BEFORE MODIFYING' + result += '\n // AUTO-GENERATED CONTENT' + result += '\n // COULD NOT IMPLEMENT DUE TO: '+string.join(invalid, ', ') + result += '\n #pragma message("Warning: "__FILE__": '+name+' is not implemented")' + result += '\n // END DELETE BEFORE MODIFYING' + result += '\n}\n\n' + return wrap_code(result) + + result += '\n // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING\n' + + result_len = len(result) + + optional = [] + + # parameter verification + if isinstance(func, obj_function_virtual): + result += '\n DCHECK(self);'\ + '\n if (!self)'\ + '\n return'+retval_default+';' + + for arg in args: + arg_type = arg.get_arg_type() + arg_name = arg.get_type().get_name() + + # skip optional params + optional_params = arg.parent.get_attrib_list('optional_param') + if not optional_params is None and arg_name in optional_params: + optional.append(arg_name) + continue + + comment = '\n // Verify param: '+arg_name+'; type: '+arg_type + + if arg_type == 'simple_byref' or arg_type == 'simple_byref_const' or \ + arg_type == 'simple_byaddr' or arg_type == 'bool_byref' or arg_type == 'bool_byaddr' or \ + arg_type == 'struct_byref_const' or arg_type == 'struct_byref' or \ + arg_type == 'string_byref_const' or arg_type == 'string_byref' or \ + arg_type == 'refptr_same' or arg_type == 'refptr_same_byref' or \ + arg_type == 'refptr_diff' or arg_type == 'refptr_diff_byref' or \ + arg_type == 'string_vec_byref' or arg_type == 'string_vec_byref_const' or \ + arg_type == 'string_map_single_byref' or arg_type == 'string_map_single_byref_const' or \ + arg_type == 'string_map_multi_byref' or arg_type == 'string_map_multi_byref_const': + result += comment+\ + '\n DCHECK('+arg_name+');'\ + '\n if (!'+arg_name+')'\ + '\n return'+retval_default+';' + elif arg_type == 'simple_vec_byref' or arg_type == 'bool_vec_byref' or \ + arg_type == 'refptr_vec_same_byref' or arg_type == 'refptr_vec_diff_byref': + result += comment+\ + '\n DCHECK('+arg_name+'Count && (*'+arg_name+'Count == 0 || '+arg_name+'));'\ + '\n if (!'+arg_name+'Count || (*'+arg_name+'Count > 0 && !'+arg_name+'))'\ + '\n return'+retval_default+';' + elif arg_type == 'simple_vec_byref_const' or arg_type == 'bool_vec_byref_const' or \ + arg_type == 'refptr_vec_same_byref_const' or arg_type == 'refptr_vec_diff_byref_const': + result += comment+\ + '\n DCHECK('+arg_name+'Count == 0 || '+arg_name+');'\ + '\n if ('+arg_name+'Count > 0 && !'+arg_name+')'\ + '\n return'+retval_default+';' + + # check index params + index_params = arg.parent.get_attrib_list('index_param') + if not index_params is None and arg_name in index_params: + result += comment+\ + '\n DCHECK_GE('+arg_name+', 0);'\ + '\n if ('+arg_name+' < 0)'\ + '\n return'+retval_default+';' + + if len(optional) > 0: + result += '\n // Unverified params: '+string.join(optional,', ') + + if len(result) != result_len: + result += '\n' + result_len = len(result) + + # parameter translation + params = [] + + for arg in args: + arg_type = arg.get_arg_type() + arg_name = arg.get_type().get_name() + + comment = '\n // Translate param: '+arg_name+'; type: '+arg_type + + if arg_type == 'simple_byval' or arg_type == 'simple_byaddr': + params.append(arg_name) + elif arg_type == 'simple_byref' or arg_type == 'simple_byref_const': + data_type = arg.get_type().get_type() + default = arg.get_type().get_result_simple_default() + result += comment+\ + '\n '+data_type+' '+arg_name+'Val = '+arg_name+'?*'+arg_name+':'+default+';' + params.append(arg_name+'Val') + elif arg_type == 'bool_byval': + params.append(arg_name+'?true:false') + elif arg_type == 'bool_byref' or arg_type == 'bool_byaddr': + result += comment+\ + '\n bool '+arg_name+'Bool = ('+arg_name+' && *'+arg_name+')?true:false;' + if arg_type == 'bool_byref': + params.append(arg_name+'Bool') + else: + params.append('&'+arg_name+'Bool') + elif arg_type == 'struct_byref_const': + struct_type = arg.get_type().get_type() + result += comment+\ + '\n '+struct_type+' '+arg_name+'Obj;'\ + '\n if ('+arg_name+')'\ + '\n '+arg_name+'Obj.Set(*'+arg_name+', false);' + params.append(arg_name+'Obj') + elif arg_type == 'struct_byref': + struct_type = arg.get_type().get_type() + result += comment+\ + '\n '+struct_type+' '+arg_name+'Obj;'\ + '\n if ('+arg_name+')'\ + '\n '+arg_name+'Obj.AttachTo(*'+arg_name+');' + params.append(arg_name+'Obj') + elif arg_type == 'string_byref_const': + params.append('CefString('+arg_name+')') + elif arg_type == 'string_byref': + result += comment+\ + '\n CefString '+arg_name+'Str('+arg_name+');' + params.append(arg_name+'Str') + elif arg_type == 'refptr_same' or arg_type == 'refptr_diff': + refptr_class = arg.get_type().get_refptr_type() + if arg_type == 'refptr_same': + params.append(refptr_class+'CppToC::Unwrap('+arg_name+')') + else: + params.append(refptr_class+'CToCpp::Wrap('+arg_name+')') + elif arg_type == 'refptr_same_byref' or arg_type == 'refptr_diff_byref': + refptr_class = arg.get_type().get_refptr_type() + if arg_type == 'refptr_same_byref': + assign = refptr_class+'CppToC::Unwrap(*'+arg_name+')' + else: + assign = refptr_class+'CToCpp::Wrap(*'+arg_name+')' + result += comment+\ + '\n CefRefPtr<'+refptr_class+'> '+arg_name+'Ptr;'\ + '\n if ('+arg_name+' && *'+arg_name+')'\ + '\n '+arg_name+'Ptr = '+assign+';'\ + '\n '+refptr_class+'* '+arg_name+'Orig = '+arg_name+'Ptr.get();' + params.append(arg_name+'Ptr') + elif arg_type == 'string_vec_byref' or arg_type == 'string_vec_byref_const': + result += comment+\ + '\n std::vector '+arg_name+'List;'\ + '\n transfer_string_list_contents('+arg_name+', '+arg_name+'List);' + params.append(arg_name+'List') + elif arg_type == 'string_map_single_byref' or arg_type == 'string_map_single_byref_const': + result += comment+\ + '\n std::map '+arg_name+'Map;'\ + '\n transfer_string_map_contents('+arg_name+', '+arg_name+'Map);' + params.append(arg_name+'Map') + elif arg_type == 'string_map_multi_byref' or arg_type == 'string_map_multi_byref_const': + result += comment+\ + '\n std::multimap '+arg_name+'Multimap;'\ + '\n transfer_string_multimap_contents('+arg_name+', '+arg_name+'Multimap);' + params.append(arg_name+'Multimap') + elif arg_type == 'simple_vec_byref' or arg_type == 'bool_vec_byref' or \ + arg_type == 'refptr_vec_same_byref' or arg_type == 'refptr_vec_diff_byref': + vec_type = arg.get_type().get_vector_type() + if arg_type == 'simple_vec_byref': + assign = arg_name+'[i]' + elif arg_type == 'bool_vec_byref': + assign = arg_name+'[i]?true:false' + elif arg_type == 'refptr_vec_same_byref': + refptr_class = arg.get_type().get_refptr_type() + assign = refptr_class+'CppToC::Unwrap('+arg_name+'[i])' + elif arg_type == 'refptr_vec_diff_byref': + refptr_class = arg.get_type().get_refptr_type() + assign = refptr_class+'CToCpp::Wrap('+arg_name+'[i])' + result += comment+\ + '\n std::vector<'+vec_type+' > '+arg_name+'List;'\ + '\n if ('+arg_name+'Count && *'+arg_name+'Count > 0 && '+arg_name+') {'\ + '\n for (size_t i = 0; i < *'+arg_name+'Count; ++i) {'\ + '\n '+arg_name+'List.push_back('+assign+');'\ + '\n }'\ + '\n }' + params.append(arg_name+'List') + elif arg_type == 'simple_vec_byref_const' or arg_type == 'bool_vec_byref_const' or \ + arg_type == 'refptr_vec_same_byref_const' or arg_type == 'refptr_vec_diff_byref_const': + vec_type = arg.get_type().get_vector_type() + if arg_type == 'simple_vec_byref_const': + assign = arg_name+'[i]' + elif arg_type == 'bool_vec_byref_const': + assign = arg_name+'[i]?true:false' + elif arg_type == 'refptr_vec_same_byref_const': + refptr_class = arg.get_type().get_refptr_type() + assign = refptr_class+'CppToC::Unwrap('+arg_name+'[i])' + elif arg_type == 'refptr_vec_diff_byref_const': + refptr_class = arg.get_type().get_refptr_type() + assign = refptr_class+'CToCpp::Wrap('+arg_name+'[i])' + result += comment+\ + '\n std::vector<'+vec_type+' > '+arg_name+'List;'\ + '\n if ('+arg_name+'Count > 0) {'\ + '\n for (size_t i = 0; i < '+arg_name+'Count; ++i) {'\ + '\n '+arg_name+'List.push_back('+assign+');'\ + '\n }'\ + '\n }' + params.append(arg_name+'List') + + if len(result) != result_len: + result += '\n' + result_len = len(result) + + # execution + result += '\n // Execute\n ' + + if retval_type != 'none': + # has a return value + if retval_type == 'simple': + result += retval.get_type().get_result_simple_type() + else: + result += retval.get_type().get_type() + result += ' _retval = ' + + if isinstance(func.parent, obj_class): + # virtual and static class methods + if isinstance(func, obj_function_virtual): + result += func.parent.get_name()+'CppToC::Get(self)->' + else: + result += func.parent.get_name()+'::' + result += func.get_name()+'(' + + if len(params) > 0: + result += '\n '+string.join(params,',\n ') + + result += ');\n' + + result_len = len(result) + + # parameter restoration + for arg in args: + arg_type = arg.get_arg_type() + arg_name = arg.get_type().get_name() + + comment = '\n // Restore param: '+arg_name+'; type: '+arg_type + + if arg_type == 'simple_byref': + result += comment+\ + '\n if ('+arg_name+')'\ + '\n *'+arg_name+' = '+arg_name+'Val;' + elif arg_type == 'bool_byref' or arg_type == 'bool_byaddr': + result += comment+\ + '\n if ('+arg_name+')'\ + '\n *'+arg_name+' = '+arg_name+'Bool?true:false;' + elif arg_type == 'struct_byref': + result += comment+\ + '\n if ('+arg_name+')'\ + '\n '+arg_name+'Obj.DetachTo(*'+arg_name+');' + elif arg_type == 'refptr_same_byref' or arg_type == 'refptr_diff_byref': + refptr_class = arg.get_type().get_refptr_type() + if arg_type == 'refptr_same_byref': + assign = refptr_class+'CppToC::Wrap('+arg_name+'Ptr)' + else: + assign = refptr_class+'CToCpp::Unwrap('+arg_name+'Ptr)' + result += comment+\ + '\n if ('+arg_name+') {'\ + '\n if ('+arg_name+'Ptr.get()) {'\ + '\n if ('+arg_name+'Ptr.get() != '+arg_name+'Orig) {'\ + '\n *'+arg_name+' = '+assign+';'\ + '\n }'\ + '\n } else {'\ + '\n *'+arg_name+' = NULL;'\ + '\n }'\ + '\n }' + elif arg_type == 'string_vec_byref': + result += comment+\ + '\n cef_string_list_clear('+arg_name+');'\ + '\n transfer_string_list_contents('+arg_name+'List, '+arg_name+');' + elif arg_type == 'string_map_single_byref': + result += comment+\ + '\n cef_string_map_clear('+arg_name+');'\ + '\n transfer_string_map_contents('+arg_name+'Map, '+arg_name+');' + elif arg_type == 'string_map_multi_byref': + result += comment+\ + '\n cef_string_multimap_clear('+arg_name+');'\ + '\n transfer_string_multimap_contents('+arg_name+'Multimap, '+arg_name+');' + elif arg_type == 'simple_vec_byref' or arg_type == 'bool_vec_byref' or \ + arg_type == 'refptr_vec_same_byref' or arg_type == 'refptr_vec_diff_byref': + if arg_type == 'simple_vec_byref' or arg_type == 'bool_vec_byref': + assign = arg_name+'List[i]' + elif arg_type == 'refptr_vec_same_byref': + refptr_class = arg.get_type().get_refptr_type() + assign = refptr_class+'CppToC::Wrap('+arg_name+'List[i])' + elif arg_type == 'refptr_vec_diff_byref': + refptr_class = arg.get_type().get_refptr_type() + assign = refptr_class+'CToCpp::Unwrap('+arg_name+'List[i])' + result += comment+\ + '\n if ('+arg_name+'Count && '+arg_name+') {'\ + '\n *'+arg_name+'Count = std::min('+arg_name+'List.size(), *'+arg_name+'Count);'\ + '\n if (*'+arg_name+'Count > 0) {'\ + '\n for (size_t i = 0; i < *'+arg_name+'Count; ++i) {'\ + '\n '+arg_name+'[i] = '+assign+';'\ + '\n }'\ + '\n }'\ + '\n }' + + if len(result) != result_len: + result += '\n' + result_len = len(result) + + # special handling for the global cef_shutdown function + if name == 'cef_shutdown' and isinstance(func.parent, obj_header): + classes = func.parent.get_classes() + + names = [] + for cls in classes: + if cls.has_attrib('no_debugct_check'): + continue; + + if cls.is_library_side(): + names.append(cls.get_name()+'CppToC') + else: + names.append(cls.get_name()+'CToCpp') + + if len(names) > 0: + names = sorted(names) + result += '\n#ifndef NDEBUG'\ + '\n // Check that all wrapper objects have been destroyed' + for name in names: + result += '\n DCHECK_EQ('+name+'::DebugObjCt, 0);'; + result += '\n#endif // !NDEBUG' + + if len(result) != result_len: + result += '\n' + result_len = len(result) + + # return translation + if retval_type != 'none': + # has a return value + result += '\n // Return type: '+retval_type + if retval_type == 'simple' or retval_type == 'bool': + result += '\n return _retval;' + elif retval_type == 'string': + result += '\n return _retval.DetachToUserFree();' + elif retval_type == 'refptr_same': + refptr_class = retval.get_type().get_refptr_type() + result += '\n return '+refptr_class+'CppToC::Wrap(_retval);' + elif retval_type == 'refptr_diff': + refptr_class = retval.get_type().get_refptr_type() + result += '\n return '+refptr_class+'CToCpp::Unwrap(_retval);' + + if len(result) != result_len: + result += '\n' + + result += '}\n' + return wrap_code(result) + +def make_cpptoc_function_impl(funcs, existing, prefixname, defined_names): + impl = '' + + for func in funcs: + if not prefixname is None: + name = prefixname+'_'+func.get_capi_name() + else: + name = func.get_capi_name() + value = get_next_function_impl(existing, name) + if not value is None \ + and value['body'].find('// AUTO-GENERATED CONTENT') < 0: + # an implementation exists that was not auto-generated + impl += make_cpptoc_function_impl_existing(name, func, value, defined_names) + else: + impl += make_cpptoc_function_impl_new(name, func, defined_names) + + return impl + +def make_cpptoc_class_impl(header, clsname, impl): + # structure names that have already been defined + defined_names = header.get_defined_structs() + + # retrieve the class and populate the defined names + cls = header.get_class(clsname, defined_names) + if cls is None: + raise Exception('Class does not exist: '+clsname) + + capiname = cls.get_capi_name() + prefixname = get_capi_name(clsname[3:], False) + + # retrieve the existing virtual function implementations + existing = get_function_impls(impl, 'CEF_CALLBACK') + + # generate virtual functions + virtualimpl = make_cpptoc_function_impl(cls.get_virtual_funcs(), existing, prefixname, defined_names) + if len(virtualimpl) > 0: + virtualimpl = '\n// MEMBER FUNCTIONS - Body may be edited by hand.\n\n'+virtualimpl + + # the current class is already defined for static functions + defined_names.append(cls.get_capi_name()) + + # retrieve the existing static function implementations + existing = get_function_impls(impl, 'CEF_EXPORT') + + # generate static functions + staticimpl = make_cpptoc_function_impl(cls.get_static_funcs(), existing, None, defined_names) + if len(staticimpl) > 0: + staticimpl = '\n// GLOBAL FUNCTIONS - Body may be edited by hand.\n\n'+staticimpl + + resultingimpl = staticimpl + virtualimpl + + # determine what includes are required by identifying what translation + # classes are being used + includes = format_translation_includes(resultingimpl) + + # build the final output + result = get_copyright() + + result += includes+'\n'+resultingimpl+'\n' + + const = '// CONSTRUCTOR - Do not edit by hand.\n\n'+ \ + clsname+'CppToC::'+clsname+'CppToC('+clsname+'* cls)\n'+ \ + ' : CefCppToC<'+clsname+'CppToC, '+clsname+', '+capiname+'>(cls) '+ \ + '{\n'; + + funcs = cls.get_virtual_funcs() + for func in funcs: + name = func.get_capi_name() + const += ' struct_.struct_.'+name+' = '+prefixname+'_'+name+';\n' + + const += '}\n\n'+ \ + '#ifndef NDEBUG\n'+ \ + 'template<> long CefCppToC<'+clsname+'CppToC, '+clsname+', '+capiname+'>::DebugObjCt = 0;\n'+ \ + '#endif\n' + result += wrap_code(const) + + return result + +def make_cpptoc_global_impl(header, impl): + # structure names that have already been defined + defined_names = header.get_defined_structs() + + # retrieve the existing global function implementations + existing = get_function_impls(impl, 'CEF_EXPORT') + + # generate global functions + impl = make_cpptoc_function_impl(header.get_funcs(), existing, None, defined_names) + if len(impl) > 0: + impl = '\n// GLOBAL FUNCTIONS - Body may be edited by hand.\n\n'+impl + + includes = '' + + # include required headers for global functions + filenames = [] + for func in header.get_funcs(): + filename = func.get_file_name() + if not filename in filenames: + includes += '#include "include/'+func.get_file_name()+'"\n' \ + '#include "include/capi/'+func.get_capi_file_name()+'"\n' + filenames.append(filename) + + # determine what includes are required by identifying what translation + # classes are being used + includes += format_translation_includes(impl) + + # build the final output + result = get_copyright() + + result += includes+'\n'+impl + + return result + +def write_cpptoc_impl(header, clsname, dir, backup): + if clsname is None: + # global file + file = dir + else: + # class file + file = dir+os.sep+get_capi_name(clsname[3:], False)+'_cpptoc.cc' + + if path_exists(file): + oldcontents = read_file(file) + else: + oldcontents = '' + + if clsname is None: + newcontents = make_cpptoc_global_impl(header, oldcontents) + else: + newcontents = make_cpptoc_class_impl(header, clsname, oldcontents) + if newcontents != oldcontents: + if backup and oldcontents != '': + backup_file(file) + write_file(file, newcontents) + return True + + return False + + +# test the module +if __name__ == "__main__": + import sys + + # verify that the correct number of command-line arguments are provided + if len(sys.argv) < 4: + sys.stderr.write('Usage: '+sys.argv[0]+' ') + sys.exit() + + # create the header object + header = obj_header() + header.add_file(sys.argv[1]) + + # read the existing implementation file into memory + try: + f = open(sys.argv[3], 'r') + data = f.read() + except IOError, (errno, strerror): + raise Exception('Failed to read file '+sys.argv[3]+': '+strerror) + else: + f.close() + + # dump the result to stdout + sys.stdout.write(make_cpptoc_class_impl(header, sys.argv[2], data)) diff --git a/cef3/tools/make_ctocpp_header.py b/cef3/tools/make_ctocpp_header.py new file mode 100644 index 000000000..027ac8a14 --- /dev/null +++ b/cef3/tools/make_ctocpp_header.py @@ -0,0 +1,122 @@ +# 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. + +from cef_parser import * + +def make_ctocpp_header(header, clsname): + cls = header.get_class(clsname) + if cls is None: + raise Exception('Class does not exist: '+clsname) + + clientside = cls.is_client_side() + defname = string.upper(get_capi_name(clsname[3:], False)) + capiname = cls.get_capi_name() + + result = get_copyright() + + result += '#ifndef CEF_LIBCEF_DLL_CTOCPP_'+defname+'_CTOCPP_H_\n'+ \ + '#define CEF_LIBCEF_DLL_CTOCPP_'+defname+'_CTOCPP_H_\n' + \ + '#pragma once\n' + + if clientside: + result += """ +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED +""" + else: + result += """ +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED +""" + + # build the function body + func_body = '' + funcs = cls.get_virtual_funcs() + for func in funcs: + func_body += ' virtual '+func.get_cpp_proto()+' OVERRIDE;\n' + + # include standard headers + if func_body.find('std::map') > 0 or func_body.find('std::multimap') > 0: + result += '\n#include ' + if func_body.find('std::vector') > 0: + result += '\n#include ' + + # include the headers for this class + result += '\n#include "include/'+cls.get_file_name()+'"'+ \ + '\n#include "include/capi/'+cls.get_capi_file_name()+'"\n' + + # include headers for any forward declared classes that are not in the same file + declares = cls.get_forward_declares() + for declare in declares: + dcls = header.get_class(declare) + if dcls.get_file_name() != cls.get_file_name(): + result += '#include "include/'+dcls.get_file_name()+'"\n' \ + '#include "include/capi/'+dcls.get_capi_file_name()+'"\n' + + result += """#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +""" + + if clientside: + result += '// This class may be instantiated and accessed DLL-side only.\n' + else: + result += '// This class may be instantiated and accessed wrapper-side only.\n' + + result += 'class '+clsname+'CToCpp\n'+ \ + ' : public CefCToCpp<'+clsname+'CToCpp, '+clsname+', '+capiname+'> {\n'+ \ + ' public:\n'+ \ + ' explicit '+clsname+'CToCpp('+capiname+'* str)\n'+ \ + ' : CefCToCpp<'+clsname+'CToCpp, '+clsname+', '+capiname+'>(str) {}\n'+ \ + ' virtual ~'+clsname+'CToCpp() {}\n\n'+ \ + ' // '+clsname+' methods\n'; + + result += func_body + result += '};\n\n' + + if clientside: + result += '#endif // BUILDING_CEF_SHARED\n' + else: + result += '#endif // USING_CEF_SHARED\n' + + result += '#endif // CEF_LIBCEF_DLL_CTOCPP_'+defname+'_CTOCPP_H_\n' + + return wrap_code(result) + + +def write_ctocpp_header(header, clsname, dir, backup): + file = dir+os.sep+get_capi_name(clsname[3:], False)+'_ctocpp.h' + + if path_exists(file): + oldcontents = read_file(file) + else: + oldcontents = '' + + newcontents = make_ctocpp_header(header, clsname) + if newcontents != oldcontents: + if backup and oldcontents != '': + backup_file(file) + write_file(file, newcontents) + return True + + return False + + +# test the module +if __name__ == "__main__": + import sys + + # verify that the correct number of command-line arguments are provided + if len(sys.argv) < 3: + sys.stderr.write('Usage: '+sys.argv[0]+' ') + sys.exit() + + # create the header object + header = obj_header() + header.add_file(sys.argv[1]) + + # dump the result to stdout + sys.stdout.write(make_ctocpp_header(header, sys.argv[2])) diff --git a/cef3/tools/make_ctocpp_impl.py b/cef3/tools/make_ctocpp_impl.py new file mode 100644 index 000000000..dab3c9f13 --- /dev/null +++ b/cef3/tools/make_ctocpp_impl.py @@ -0,0 +1,576 @@ +# 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. + +from cef_parser import * + +def make_ctocpp_impl_proto(clsname, name, func, parts): + const = '' + + if clsname is None: + proto = 'CEF_GLOBAL '+parts['retval']+' ' + else: + proto = parts['retval']+' '+clsname + if isinstance(func, obj_function_virtual): + proto += 'CToCpp' + if func.is_const(): + const = ' const' + + proto += '::' + + proto += name+'('+string.join(parts['args'], ', ')+')'+const + return proto + +def make_ctocpp_function_impl_existing(clsname, name, func, impl): + notify(name+' has manual edits') + + # retrieve the C++ prototype parts + parts = func.get_cpp_parts(True) + + changes = format_translation_changes(impl, parts) + if len(changes) > 0: + notify(name+' prototype changed') + + return wrap_code(make_ctocpp_impl_proto(clsname, name, func, parts))+'{'+ \ + changes+impl['body']+'\n}\n' + +def make_ctocpp_function_impl_new(clsname, name, func): + # build the C++ prototype + parts = func.get_cpp_parts(True) + result = make_ctocpp_impl_proto(clsname, name, func, parts)+' {' + + invalid = [] + + # retrieve the function arguments + args = func.get_arguments() + + # determine the argument types + for arg in args: + if arg.get_arg_type() == 'invalid': + invalid.append(arg.get_name()) + + # retrieve the function return value + retval = func.get_retval() + retval_type = retval.get_retval_type() + if retval_type == 'invalid': + invalid.append('(return value)') + retval_default = '' + else: + retval_default = retval.get_retval_default(False) + if len(retval_default) > 0: + retval_default = ' '+retval_default; + + # add API hash check + if func.has_attrib('api_hash_check'): + result += '\n const char* api_hash = cef_api_hash(0);'\ + '\n if (strcmp(api_hash, CEF_API_HASH_PLATFORM)) {'\ + '\n // The libcef API hash does not match the current header API hash.'\ + '\n DCHECK(false);'\ + '\n return'+retval_default+';'\ + '\n }\n' + + if isinstance(func, obj_function_virtual): + # add the structure size check + result += '\n if (CEF_MEMBER_MISSING(struct_, '+func.get_capi_name()+'))' + result += '\n return'+retval_default+';\n' + + if len(invalid) > 0: + notify(name+' could not be autogenerated') + # code could not be auto-generated + result += '\n // BEGIN DELETE BEFORE MODIFYING' + result += '\n // AUTO-GENERATED CONTENT' + result += '\n // COULD NOT IMPLEMENT DUE TO: '+string.join(invalid, ', ') + result += '\n #pragma message("Warning: "__FILE__": '+name+' is not implemented")' + result += '\n // END DELETE BEFORE MODIFYING' + result += '\n}\n\n' + return wrap_code(result) + + result += '\n // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING\n' + + result_len = len(result) + + optional = [] + + # parameter verification + for arg in args: + arg_type = arg.get_arg_type() + arg_name = arg.get_type().get_name() + + # skip optional params + optional_params = arg.parent.get_attrib_list('optional_param') + if not optional_params is None and arg_name in optional_params: + optional.append(arg_name) + continue + + comment = '\n // Verify param: '+arg_name+'; type: '+arg_type + + if arg_type == 'simple_byaddr' or arg_type == 'bool_byaddr': + result += comment+\ + '\n DCHECK('+arg_name+');'\ + '\n if (!'+arg_name+')'\ + '\n return'+retval_default+';' + elif arg_type == 'refptr_same' or arg_type == 'refptr_diff': + result += comment+\ + '\n DCHECK('+arg_name+'.get());'\ + '\n if (!'+arg_name+'.get())'\ + '\n return'+retval_default+';' + elif arg_type == 'string_byref_const': + result += comment+\ + '\n DCHECK(!'+arg_name+'.empty());'\ + '\n if ('+arg_name+'.empty())'\ + '\n return'+retval_default+';' + + # check index params + index_params = arg.parent.get_attrib_list('index_param') + if not index_params is None and arg_name in index_params: + result += comment+\ + '\n DCHECK_GE('+arg_name+', 0);'\ + '\n if ('+arg_name+' < 0)'\ + '\n return'+retval_default+';' + + if len(optional) > 0: + result += '\n // Unverified params: '+string.join(optional,', ') + + if len(result) != result_len: + result += '\n' + result_len = len(result) + + # parameter translation + params = [] + if isinstance(func, obj_function_virtual): + params.append('struct_') + + for arg in args: + arg_type = arg.get_arg_type() + arg_name = arg.get_type().get_name() + + comment = '\n // Translate param: '+arg_name+'; type: '+arg_type + + if arg_type == 'simple_byval' or arg_type == 'simple_byaddr' or \ + arg_type == 'bool_byval': + params.append(arg_name) + elif arg_type == 'simple_byref' or arg_type == 'simple_byref_const' or \ + arg_type == 'struct_byref_const' or arg_type == 'struct_byref': + params.append('&'+arg_name) + elif arg_type == 'bool_byref': + result += comment+\ + '\n int '+arg_name+'Int = '+arg_name+';' + params.append('&'+arg_name+'Int') + elif arg_type == 'bool_byaddr': + result += comment+\ + '\n int '+arg_name+'Int = '+arg_name+'?*'+arg_name+':0;' + params.append('&'+arg_name+'Int') + elif arg_type == 'string_byref_const': + params.append(arg_name+'.GetStruct()') + elif arg_type == 'string_byref': + params.append(arg_name+'.GetWritableStruct()') + elif arg_type == 'refptr_same': + refptr_class = arg.get_type().get_refptr_type() + params.append(refptr_class+'CToCpp::Unwrap('+arg_name+')') + elif arg_type == 'refptr_diff': + refptr_class = arg.get_type().get_refptr_type() + params.append(refptr_class+'CppToC::Wrap('+arg_name+')') + elif arg_type == 'refptr_same_byref' or arg_type == 'refptr_diff_byref': + refptr_class = arg.get_type().get_refptr_type() + refptr_struct = arg.get_type().get_result_refptr_type_root() + if arg_type == 'refptr_same_byref': + assign = refptr_class+'CToCpp::Unwrap('+arg_name+')' + else: + assign = refptr_class+'CppToC::Wrap('+arg_name+')' + result += comment+\ + '\n '+refptr_struct+'* '+arg_name+'Struct = NULL;'\ + '\n if ('+arg_name+'.get())'\ + '\n '+arg_name+'Struct = '+assign+';'\ + '\n '+refptr_struct+'* '+arg_name+'Orig = '+arg_name+'Struct;' + params.append('&'+arg_name+'Struct') + elif arg_type == 'string_vec_byref' or arg_type == 'string_vec_byref_const': + result += comment+\ + '\n cef_string_list_t '+arg_name+'List = cef_string_list_alloc();'\ + '\n DCHECK('+arg_name+'List);'\ + '\n if ('+arg_name+'List)'\ + '\n transfer_string_list_contents('+arg_name+', '+arg_name+'List);' + params.append(arg_name+'List') + elif arg_type == 'string_map_single_byref' or arg_type == 'string_map_single_byref_const': + result += comment+\ + '\n cef_string_map_t '+arg_name+'Map = cef_string_map_alloc();'\ + '\n DCHECK('+arg_name+'Map);'\ + '\n if ('+arg_name+'Map)'\ + '\n transfer_string_map_contents('+arg_name+', '+arg_name+'Map);' + params.append(arg_name+'Map') + elif arg_type == 'string_map_multi_byref' or arg_type == 'string_map_multi_byref_const': + result += comment+\ + '\n cef_string_multimap_t '+arg_name+'Multimap = cef_string_multimap_alloc();'\ + '\n DCHECK('+arg_name+'Multimap);'\ + '\n if ('+arg_name+'Multimap)'\ + '\n transfer_string_multimap_contents('+arg_name+', '+arg_name+'Multimap);' + params.append(arg_name+'Multimap') + elif arg_type == 'simple_vec_byref' or arg_type == 'bool_vec_byref' or \ + arg_type == 'refptr_vec_same_byref' or arg_type == 'refptr_vec_diff_byref': + count_func = arg.get_attrib_count_func() + vec_type = arg.get_type().get_result_vector_type_root() + if arg_type == 'refptr_vec_same_byref': + refptr_class = arg.get_type().get_refptr_type() + assign = refptr_class+'CToCpp::Unwrap('+arg_name+'[i])' + elif arg_type == 'refptr_vec_diff_byref': + refptr_class = arg.get_type().get_refptr_type() + assign = refptr_class+'CppToC::Wrap('+arg_name+'[i])' + else: + assign = arg_name+'[i]' + result += comment+\ + '\n size_t '+arg_name+'Size = '+arg_name+'.size();'\ + '\n size_t '+arg_name+'Count = std::max('+count_func+'(), '+arg_name+'Size);'\ + '\n '+vec_type+'* '+arg_name+'List = NULL;'\ + '\n if ('+arg_name+'Count > 0) {'\ + '\n '+arg_name+'List = new '+vec_type+'['+arg_name+'Count];'\ + '\n DCHECK('+arg_name+'List);'\ + '\n if ('+arg_name+'List) {'\ + '\n memset('+arg_name+'List, 0, sizeof('+vec_type+')*'+arg_name+'Count);'\ + '\n }'\ + '\n if ('+arg_name+'List && '+arg_name+'Size > 0) {'\ + '\n for (size_t i = 0; i < '+arg_name+'Size; ++i) {'\ + '\n '+arg_name+'List[i] = '+assign+';'\ + '\n }'\ + '\n }'\ + '\n }' + params.append('&'+arg_name+'Count') + params.append(arg_name+'List') + elif arg_type == 'simple_vec_byref_const' or arg_type == 'bool_vec_byref_const' or \ + arg_type == 'refptr_vec_same_byref_const' or arg_type == 'refptr_vec_diff_byref_const': + count_func = arg.get_attrib_count_func() + vec_type = arg.get_type().get_result_vector_type_root() + if arg_type == 'refptr_vec_same_byref_const': + refptr_class = arg.get_type().get_refptr_type() + assign = refptr_class+'CToCpp::Unwrap('+arg_name+'[i])' + elif arg_type == 'refptr_vec_diff_byref_const': + refptr_class = arg.get_type().get_refptr_type() + assign = refptr_class+'CppToC::Wrap('+arg_name+'[i])' + else: + assign = arg_name+'[i]' + result += comment+\ + '\n const size_t '+arg_name+'Count = '+arg_name+'.size();'\ + '\n '+vec_type+'* '+arg_name+'List = NULL;'\ + '\n if ('+arg_name+'Count > 0) {'\ + '\n '+arg_name+'List = new '+vec_type+'['+arg_name+'Count];'\ + '\n DCHECK('+arg_name+'List);'\ + '\n if ('+arg_name+'List) {'\ + '\n for (size_t i = 0; i < '+arg_name+'Count; ++i) {'\ + '\n '+arg_name+'List[i] = '+assign+';'\ + '\n }'\ + '\n }'\ + '\n }' + params.append(arg_name+'Count') + params.append(arg_name+'List') + + if len(result) != result_len: + result += '\n' + result_len = len(result) + + # execution + result += '\n // Execute\n ' + + if retval_type != 'none': + # has a return value + if retval_type == 'simple' or retval_type == 'bool': + result += retval.get_type().get_result_simple_type_root() + elif retval_type == 'string': + result += 'cef_string_userfree_t' + elif retval_type == 'refptr_same' or retval_type == 'refptr_diff': + refptr_struct = retval.get_type().get_result_refptr_type_root() + result += refptr_struct+'*' + + result += ' _retval = ' + + if isinstance(func, obj_function_virtual): + result += 'struct_->' + result += func.get_capi_name()+'(' + + if len(params) > 0: + if not isinstance(func, obj_function_virtual): + result += '\n ' + result += string.join(params,',\n ') + + result += ');\n' + + result_len = len(result) + + # parameter restoration + for arg in args: + arg_type = arg.get_arg_type() + arg_name = arg.get_type().get_name() + + comment = '\n // Restore param:'+arg_name+'; type: '+arg_type + + if arg_type == 'bool_byref': + result += comment+\ + '\n '+arg_name+' = '+arg_name+'Int?true:false;' + elif arg_type == 'bool_byaddr': + result += comment+\ + '\n if ('+arg_name+')'\ + '\n *'+arg_name+' = '+arg_name+'Int?true:false;' + elif arg_type == 'refptr_same_byref' or arg_type == 'refptr_diff_byref': + refptr_class = arg.get_type().get_refptr_type() + refptr_struct = arg.get_type().get_result_refptr_type_root() + if arg_type == 'refptr_same_byref': + assign = refptr_class+'CToCpp::Wrap('+arg_name+'Struct)' + else: + assign = refptr_class+'CppToC::Unwrap('+arg_name+'Struct)' + result += comment+\ + '\n if ('+arg_name+'Struct) {'\ + '\n if ('+arg_name+'Struct != '+arg_name+'Orig) {'\ + '\n '+arg_name+' = '+assign+';'\ + '\n }'\ + '\n } else {'\ + '\n '+arg_name+' = NULL;'\ + '\n }' + elif arg_type == 'string_vec_byref': + result += comment+\ + '\n if ('+arg_name+'List) {'\ + '\n '+arg_name+'.clear();'\ + '\n transfer_string_list_contents('+arg_name+'List, '+arg_name+');'\ + '\n cef_string_list_free('+arg_name+'List);'\ + '\n }' + elif arg_type == 'string_vec_byref_const': + result += comment+\ + '\n if ('+arg_name+'List)'\ + '\n cef_string_list_free('+arg_name+'List);' + elif arg_type == 'string_map_single_byref': + result += comment+\ + '\n if ('+arg_name+'Map) {'\ + '\n '+arg_name+'.clear();'\ + '\n transfer_string_map_contents('+arg_name+'Map, '+arg_name+');'\ + '\n cef_string_map_free('+arg_name+'Map);'\ + '\n }' + elif arg_type == 'string_map_single_byref_const': + result += comment+\ + '\n if ('+arg_name+'Map)'\ + '\n cef_string_map_free('+arg_name+'Map);' + elif arg_type == 'string_map_multi_byref': + result += comment+\ + '\n if ('+arg_name+'Multimap) {'\ + '\n '+arg_name+'.clear();'\ + '\n transfer_string_multimap_contents('+arg_name+'Multimap, '+arg_name+');'\ + '\n cef_string_multimap_free('+arg_name+'Multimap);'\ + '\n }' + elif arg_type == 'string_map_multi_byref_const': + result += comment+\ + '\n if ('+arg_name+'Multimap)'\ + '\n cef_string_multimap_free('+arg_name+'Multimap);' + elif arg_type == 'simple_vec_byref' or arg_type == 'bool_vec_byref' or \ + arg_type == 'refptr_vec_same_byref' or arg_type == 'refptr_vec_diff_byref': + count_func = arg.get_attrib_count_func() + vec_type = arg.get_type().get_result_vector_type_root() + if arg_type == 'refptr_vec_same_byref': + refptr_class = arg.get_type().get_refptr_type() + assign = refptr_class+'CToCpp::Wrap('+arg_name+'List[i])' + elif arg_type == 'refptr_vec_diff_byref': + refptr_class = arg.get_type().get_refptr_type() + assign = refptr_class+'CppToC::Unwrap('+arg_name+'List[i])' + elif arg_type == 'bool_vec_byref': + assign = arg_name+'List[i]?true:false' + else: + assign = arg_name+'List[i]' + result += comment+\ + '\n '+arg_name+'.clear();'\ + '\n if ('+arg_name+'Count > 0 && '+arg_name+'List) {'\ + '\n for (size_t i = 0; i < '+arg_name+'Count; ++i) {'\ + '\n '+arg_name+'.push_back('+assign+');'\ + '\n }'\ + '\n delete [] '+arg_name+'List;'\ + '\n }' + elif arg_type == 'simple_vec_byref_const' or arg_type == 'bool_vec_byref_const' or \ + arg_type == 'refptr_vec_same_byref_const' or arg_type == 'refptr_vec_diff_byref_const': + result += comment+\ + '\n if ('+arg_name+'List)'\ + '\n delete [] '+arg_name+'List;' + + if len(result) != result_len: + result += '\n' + result_len = len(result) + + # special handling for the global CefShutdown function + if name == 'CefShutdown' and isinstance(func.parent, obj_header): + classes = func.parent.get_classes() + + names = [] + for cls in classes: + if cls.has_attrib('no_debugct_check'): + continue; + + if cls.is_library_side(): + names.append(cls.get_name()+'CToCpp') + else: + names.append(cls.get_name()+'CppToC') + + if len(names) > 0: + names = sorted(names) + result += '\n#ifndef NDEBUG'\ + '\n // Check that all wrapper objects have been destroyed' + for name in names: + result += '\n DCHECK_EQ('+name+'::DebugObjCt, 0);'; + result += '\n#endif // !NDEBUG' + + if len(result) != result_len: + result += '\n' + result_len = len(result) + + # return translation + if retval_type != 'none': + # has a return value + result += '\n // Return type: '+retval_type + if retval_type == 'simple': + result += '\n return _retval;' + elif retval_type == 'bool': + result += '\n return _retval?true:false;' + elif retval_type == 'string': + result += '\n CefString _retvalStr;'\ + '\n _retvalStr.AttachToUserFree(_retval);'\ + '\n return _retvalStr;' + elif retval_type == 'refptr_same': + refptr_class = retval.get_type().get_refptr_type() + result += '\n return '+refptr_class+'CToCpp::Wrap(_retval);' + elif retval_type == 'refptr_diff': + refptr_class = retval.get_type().get_refptr_type() + result += '\n return '+refptr_class+'CppToC::Unwrap(_retval);' + + if len(result) != result_len: + result += '\n' + + result += '}\n' + return wrap_code(result) + +def make_ctocpp_function_impl(clsname, funcs, existing): + impl = '' + + for func in funcs: + name = func.get_name() + value = get_next_function_impl(existing, name) + if not value is None \ + and value['body'].find('// AUTO-GENERATED CONTENT') < 0: + # an implementation exists that was not auto-generated + impl += make_ctocpp_function_impl_existing(clsname, name, func, value) + else: + impl += make_ctocpp_function_impl_new(clsname, name, func) + + return impl + +def make_ctocpp_class_impl(header, clsname, impl): + cls = header.get_class(clsname) + if cls is None: + raise Exception('Class does not exist: '+clsname) + + capiname = cls.get_capi_name() + + # retrieve the existing virtual function implementations + existing = get_function_impls(impl, clsname+'CToCpp::') + + # generate virtual functions + virtualimpl = make_ctocpp_function_impl(clsname, cls.get_virtual_funcs(), existing) + if len(virtualimpl) > 0: + virtualimpl = '\n// VIRTUAL METHODS - Body may be edited by hand.\n\n'+virtualimpl + + # retrieve the existing static function implementations + existing = get_function_impls(impl, clsname+'::') + + # generate static functions + staticimpl = make_ctocpp_function_impl(clsname, cls.get_static_funcs(), existing) + if len(staticimpl) > 0: + staticimpl = '\n// STATIC METHODS - Body may be edited by hand.\n\n'+staticimpl + + resultingimpl = staticimpl + virtualimpl + + # determine what includes are required by identifying what translation + # classes are being used + includes = format_translation_includes(resultingimpl) + + # build the final output + result = get_copyright() + + result += includes+'\n'+resultingimpl+'\n' + + result += wrap_code('#ifndef NDEBUG\n'+ \ + 'template<> long CefCToCpp<'+clsname+'CToCpp, '+clsname+', '+capiname+'>::DebugObjCt = 0;\n'+ \ + '#endif\n') + + return result + +def make_ctocpp_global_impl(header, impl): + # retrieve the existing global function implementations + existing = get_function_impls(impl, 'CEF_GLOBAL') + + # generate static functions + impl = make_ctocpp_function_impl(None, header.get_funcs(), existing) + if len(impl) > 0: + impl = '\n// GLOBAL METHODS - Body may be edited by hand.\n\n'+impl + + includes = '' + + # include required headers for global functions + filenames = [] + for func in header.get_funcs(): + filename = func.get_file_name() + if not filename in filenames: + includes += '#include "include/'+func.get_file_name()+'"\n' \ + '#include "include/capi/'+func.get_capi_file_name()+'"\n' + filenames.append(filename) + + # determine what includes are required by identifying what translation + # classes are being used + includes += format_translation_includes(impl) + + # build the final output + result = get_copyright() + + result += includes+'\n// Define used to facilitate parsing.\n#define CEF_GLOBAL\n\n'+impl + + return result + +def write_ctocpp_impl(header, clsname, dir, backup): + if clsname is None: + # global file + file = dir + else: + # class file + file = dir+os.sep+get_capi_name(clsname[3:], False)+'_ctocpp.cc' + + if path_exists(file): + oldcontents = read_file(file) + else: + oldcontents = '' + + if clsname is None: + newcontents = make_ctocpp_global_impl(header, oldcontents) + else: + newcontents = make_ctocpp_class_impl(header, clsname, oldcontents) + if newcontents != oldcontents: + if backup and oldcontents != '': + backup_file(file) + write_file(file, newcontents) + return True + + return False + + +# test the module +if __name__ == "__main__": + import sys + + # verify that the correct number of command-line arguments are provided + if len(sys.argv) < 4: + sys.stderr.write('Usage: '+sys.argv[0]+' ') + sys.exit() + + # create the header object + header = obj_header() + header.add_file(sys.argv[1]) + + # read the existing implementation file into memory + try: + f = open(sys.argv[3], 'r') + data = f.read() + except IOError, (errno, strerror): + raise Exception('Failed to read file '+sys.argv[3]+': '+strerror) + else: + f.close() + + # dump the result to stdout + sys.stdout.write(make_ctocpp_class_impl(header, sys.argv[2], data)) diff --git a/cef3/tools/make_distrib.bat b/cef3/tools/make_distrib.bat new file mode 100644 index 000000000..b6663905d --- /dev/null +++ b/cef3/tools/make_distrib.bat @@ -0,0 +1,2 @@ +@echo off +..\..\third_party\python_26\python.exe make_distrib.py --output-dir ..\binary_distrib\ %* diff --git a/cef3/tools/make_distrib.py b/cef3/tools/make_distrib.py new file mode 100644 index 000000000..d6aa1e700 --- /dev/null +++ b/cef3/tools/make_distrib.py @@ -0,0 +1,468 @@ +# 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. + +from date_util import * +from file_util import * +from gclient_util import * +from optparse import OptionParser +import os +import re +import shlex +import subprocess +from svn_util import * +import sys +import zipfile + +def create_archive(input_dir, zip_file): + """ Creates a zip archive of the specified input directory. """ + zf = zipfile.ZipFile(zip_file, 'w', zipfile.ZIP_DEFLATED) + def addDir(dir): + for f in os.listdir(dir): + full_path = os.path.join(dir, f) + if os.path.isdir(full_path): + addDir(full_path) + else: + zf.write(full_path, os.path.relpath(full_path, \ + os.path.join(input_dir, os.pardir))) + addDir(input_dir) + zf.close() + +def create_readme(src, output_dir, cef_url, cef_rev, cef_ver, chromium_url, \ + chromium_rev, chromium_ver, date): + """ Creates the README.TXT file. """ + data = read_file(src) + data = data.replace('$CEF_URL$', cef_url) + data = data.replace('$CEF_REV$', cef_rev) + data = data.replace('$CEF_VER$', cef_ver) + data = data.replace('$CHROMIUM_URL$', chromium_url) + data = data.replace('$CHROMIUM_REV$', chromium_rev) + data = data.replace('$CHROMIUM_VER$', chromium_ver) + data = data.replace('$DATE$', date) + write_file(os.path.join(output_dir, 'README.txt'), data) + if not options.quiet: + sys.stdout.write('Creating README.TXT file.\n') + +def eval_file(src): + """ Loads and evaluates the contents of the specified file. """ + return eval(read_file(src), {'__builtins__': None}, None) + +def transfer_gypi_files(src_dir, gypi_paths, gypi_path_prefix, dst_dir, quiet): + """ Transfer files from one location to another. """ + for path in gypi_paths: + # skip gyp includes + if path[:2] == '<@': + continue + src = os.path.join(src_dir, path) + dst = os.path.join(dst_dir, path.replace(gypi_path_prefix, '')) + dst_path = os.path.dirname(dst) + make_dir(dst_path, quiet) + copy_file(src, dst, quiet) + +def normalize_headers(file, new_path = ''): + """ Normalize headers post-processing. Remove the path component from any + project include directives. """ + data = read_file(file) + data = re.sub(r'''#include \"(?!include\/)[a-zA-Z0-9_\/]+\/+([a-zA-Z0-9_\.]+)\"''', \ + "// Include path modified for CEF Binary Distribution.\n#include \""+new_path+"\\1\"", data) + write_file(file, data) + +def transfer_files(cef_dir, script_dir, transfer_cfg, output_dir, quiet): + """ Transfer files based on the specified configuration. """ + if not path_exists(transfer_cfg): + return + + configs = eval_file(transfer_cfg) + for cfg in configs: + dst = os.path.join(output_dir, cfg['target']) + + # perform a copy if source is specified + if not cfg['source'] is None: + src = os.path.join(cef_dir, cfg['source']) + dst_path = os.path.dirname(dst) + make_dir(dst_path, quiet) + copy_file(src, dst, quiet) + + # place a readme file in the destination directory + readme = os.path.join(dst_path, 'README-TRANSFER.txt') + if not path_exists(readme): + copy_file(os.path.join(script_dir, 'distrib/README-TRANSFER.txt'), readme) + open(readme, 'ab').write(cfg['source']+"\n") + + # perform any required post-processing + if 'post-process' in cfg: + post = cfg['post-process'] + if post == 'normalize_headers': + new_path = '' + if cfg.has_key('new_header_path'): + new_path = cfg['new_header_path'] + normalize_headers(dst, new_path) + +def generate_msvs_projects(version): + """ Generate MSVS projects for the specified version. """ + sys.stdout.write('Generating '+version+' project files...') + os.environ['GYP_MSVS_VERSION'] = version + gyper = [ 'python', 'tools/gyp_cef', os.path.relpath(os.path.join(output_dir, 'cefclient.gyp'), cef_dir) ] + RunAction(cef_dir, gyper); + move_file(os.path.relpath(os.path.join(output_dir, 'cefclient.sln')), \ + os.path.relpath(os.path.join(output_dir, 'cefclient'+version+'.sln'))) + +def fix_msvs_projects(): + """ Fix the output directory path in all .vcproj and .vcxproj files. """ + files = [] + for file in get_files(os.path.join(output_dir, '*.vcproj')): + files.append(file) + for file in get_files(os.path.join(output_dir, '*.vcxproj')): + files.append(file) + for file in files: + data = read_file(file) + data = data.replace('../../..\\build\\', '') + data = data.replace('..\\..\\..\\build\\', '') + write_file(file, data) + +def run(command_line, working_dir): + """ Run a command. """ + sys.stdout.write('-------- Running "'+command_line+'" in "'+\ + working_dir+'"...'+"\n") + args = shlex.split(command_line.replace('\\', '\\\\')) + return subprocess.check_call(args, cwd=working_dir, env=os.environ, + shell=(sys.platform == 'win32')) + +# cannot be loaded as a module +if __name__ != "__main__": + sys.stderr.write('This file cannot be loaded as a module!') + sys.exit() + +# parse command-line options +disc = """ +This utility builds the CEF Binary Distribution. +""" + +parser = OptionParser(description=disc) +parser.add_option('--output-dir', dest='outputdir', metavar='DIR', + help='output directory [required]') +parser.add_option('--allow-partial', + action='store_true', dest='allowpartial', default=False, + help='allow creation of partial distributions') +parser.add_option('--no-symbols', + action='store_true', dest='nosymbols', default=False, + help='do not create symbol files') +parser.add_option('-q', '--quiet', + action='store_true', dest='quiet', default=False, + help='do not output detailed status information') +(options, args) = parser.parse_args() + +# the outputdir option is required +if options.outputdir is None: + parser.print_help(sys.stdout) + sys.exit() + +# script directory +script_dir = os.path.dirname(__file__) + +# CEF root directory +cef_dir = os.path.abspath(os.path.join(script_dir, os.pardir)) + +# src directory +src_dir = os.path.abspath(os.path.join(cef_dir, os.pardir)) + +# retrieve url, revision and date information +cef_info = get_svn_info(cef_dir) +cef_url = cef_info['url'] +cef_rev = cef_info['revision'] +chromium_info = get_svn_info(os.path.join(cef_dir, os.pardir)) +chromium_url = chromium_info['url'] +chromium_rev = chromium_info['revision'] +date = get_date() + +# Read and parse the version file (key=value pairs, one per line) +args = {} +read_version_file(os.path.join(cef_dir, 'VERSION'), args) +read_version_file(os.path.join(cef_dir, '../chrome/VERSION'), args) + +cef_ver = args['CEF_MAJOR']+'.'+args['BUILD']+'.'+cef_rev +chromium_ver = args['MAJOR']+'.'+args['MINOR']+'.'+args['BUILD']+'.'+args['PATCH'] + +# Test the operating system. +platform = ''; +if sys.platform == 'win32': + platform = 'windows' +elif sys.platform == 'darwin': + platform = 'macosx' +elif sys.platform.startswith('linux'): + platform = 'linux' + +# output directory +output_dir = os.path.abspath(os.path.join(options.outputdir, \ + 'cef_binary_'+cef_ver+'_'+platform)) +remove_dir(output_dir, options.quiet) +make_dir(output_dir, options.quiet) + +if not options.nosymbols: + # symbol directory + symbol_dir = os.path.abspath(os.path.join(options.outputdir, \ + 'cef_binary_'+cef_ver+'_'+platform+'_symbols')) + remove_dir(symbol_dir, options.quiet) + make_dir(symbol_dir, options.quiet) + +# transfer the LICENSE.txt file +copy_file(os.path.join(cef_dir, 'LICENSE.txt'), output_dir, options.quiet) + +# read the variables list from the autogenerated cef_paths.gypi file +cef_paths = eval_file(os.path.join(cef_dir, 'cef_paths.gypi')) +cef_paths = cef_paths['variables'] + +# read the variables list from the manually edited cef_paths2.gypi file +cef_paths2 = eval_file(os.path.join(cef_dir, 'cef_paths2.gypi')) +cef_paths2 = cef_paths2['variables'] + +# create the include directory +include_dir = os.path.join(output_dir, 'include') +make_dir(include_dir, options.quiet) + +# create the cefclient directory +cefclient_dir = os.path.join(output_dir, 'cefclient') +make_dir(cefclient_dir, options.quiet) + +# create the libcef_dll_wrapper directory +wrapper_dir = os.path.join(output_dir, 'libcef_dll') +make_dir(wrapper_dir, options.quiet) + +# transfer common include files +transfer_gypi_files(cef_dir, cef_paths2['includes_common'], \ + 'include/', include_dir, options.quiet) +transfer_gypi_files(cef_dir, cef_paths2['includes_capi'], \ + 'include/', include_dir, options.quiet) +transfer_gypi_files(cef_dir, cef_paths2['includes_wrapper'], \ + 'include/', include_dir, options.quiet) +transfer_gypi_files(cef_dir, cef_paths['autogen_cpp_includes'], \ + 'include/', include_dir, options.quiet) +transfer_gypi_files(cef_dir, cef_paths['autogen_capi_includes'], \ + 'include/', include_dir, options.quiet) + +# transfer common cefclient files +transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_common'], \ + 'tests/cefclient/', cefclient_dir, options.quiet) + +# transfer common libcef_dll_wrapper files +transfer_gypi_files(cef_dir, cef_paths2['libcef_dll_wrapper_sources_common'], \ + 'libcef_dll/', wrapper_dir, options.quiet) +transfer_gypi_files(cef_dir, cef_paths['autogen_client_side'], \ + 'libcef_dll/', wrapper_dir, options.quiet) + +# transfer gyp files +copy_file(os.path.join(script_dir, 'distrib/cefclient.gyp'), output_dir, options.quiet) +paths_gypi = os.path.join(cef_dir, 'cef_paths2.gypi') +data = read_file(paths_gypi) +data = data.replace('tests/cefclient/', 'cefclient/') +write_file(os.path.join(output_dir, 'cef_paths2.gypi'), data) +copy_file(os.path.join(cef_dir, 'cef_paths.gypi'), \ + os.path.join(output_dir, 'cef_paths.gypi'), options.quiet) + +# transfer additional files +transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/transfer.cfg'), \ + output_dir, options.quiet) + +if platform == 'windows': + # create the README.TXT file + create_readme(os.path.join(script_dir, 'distrib/win/README.txt'), output_dir, cef_url, \ + cef_rev, cef_ver, chromium_url, chromium_rev, chromium_ver, date) + + # transfer include files + transfer_gypi_files(cef_dir, cef_paths2['includes_win'], \ + 'include/', include_dir, options.quiet) + + # transfer cefclient files + transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_win'], \ + 'tests/cefclient/', cefclient_dir, options.quiet) + + # transfer build/Debug files + build_dir = os.path.join(src_dir, 'build/Debug'); + if not options.allowpartial or path_exists(build_dir): + dst_dir = os.path.join(output_dir, 'Debug') + make_dir(dst_dir, options.quiet) + copy_files(os.path.join(script_dir, 'distrib/win/*.dll'), dst_dir, options.quiet) + copy_files(os.path.join(build_dir, '*.dll'), dst_dir, options.quiet) + copy_file(os.path.join(build_dir, 'cefclient.exe'), dst_dir, options.quiet) + copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet) + copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet) + copy_dir(os.path.join(build_dir, 'locales'), os.path.join(dst_dir, 'locales'), \ + options.quiet) + + # transfer lib/Debug files + dst_dir = os.path.join(output_dir, 'lib/Debug') + make_dir(dst_dir, options.quiet) + copy_file(os.path.join(build_dir, 'lib/libcef.lib'), dst_dir, options.quiet) + else: + sys.stderr.write("No Debug build files.\n") + + # transfer build/Release files + build_dir = os.path.join(src_dir, 'build/Release'); + if not options.allowpartial or path_exists(build_dir): + dst_dir = os.path.join(output_dir, 'Release') + make_dir(dst_dir, options.quiet) + copy_files(os.path.join(script_dir, 'distrib/win/*.dll'), dst_dir, options.quiet) + copy_files(os.path.join(build_dir, '*.dll'), dst_dir, options.quiet) + copy_file(os.path.join(build_dir, 'cefclient.exe'), dst_dir, options.quiet) + copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet) + copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet) + copy_dir(os.path.join(build_dir, 'locales'), os.path.join(dst_dir, 'locales'), \ + options.quiet) + + # transfer lib/Release files + dst_dir = os.path.join(output_dir, 'lib/Release') + make_dir(dst_dir, options.quiet) + copy_file(os.path.join(build_dir, 'lib/libcef.lib'), dst_dir, options.quiet) + + if not options.nosymbols: + # transfer symbols + copy_file(os.path.join(build_dir, 'libcef.dll.pdb'), symbol_dir, options.quiet) + else: + sys.stderr.write("No Release build files.\n") + + # generate doc files + os.popen('make_cppdocs.bat '+cef_rev) + + # transfer docs files + dst_dir = os.path.join(output_dir, 'docs') + src_dir = os.path.join(cef_dir, 'docs') + if path_exists(src_dir): + copy_dir(src_dir, dst_dir, options.quiet) + + # transfer additional files, if any + transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/win/transfer.cfg'), \ + output_dir, options.quiet) + + # generate the project files + generate_msvs_projects('2005'); + generate_msvs_projects('2008'); + generate_msvs_projects('2010'); + fix_msvs_projects(); + +elif platform == 'macosx': + # create the README.TXT file + create_readme(os.path.join(script_dir, 'distrib/mac/README.txt'), output_dir, cef_url, \ + cef_rev, cef_ver, chromium_url, chromium_rev, chromium_ver, date) + + # transfer include files + transfer_gypi_files(cef_dir, cef_paths2['includes_mac'], \ + 'include/', include_dir, options.quiet) + + # transfer cefclient files + transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_mac'], \ + 'tests/cefclient/', cefclient_dir, options.quiet) + transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_mac_helper'], \ + 'tests/cefclient/', cefclient_dir, options.quiet) + + # transfer cefclient/mac files + copy_dir(os.path.join(cef_dir, 'tests/cefclient/mac/'), os.path.join(output_dir, 'cefclient/mac/'), \ + options.quiet) + + # transfer xcodebuild/Debug files + build_dir = os.path.join(src_dir, 'xcodebuild/Debug') + if not options.allowpartial or path_exists(build_dir): + dst_dir = os.path.join(output_dir, 'Debug') + make_dir(dst_dir, options.quiet) + copy_file(os.path.join(build_dir, 'ffmpegsumo.so'), dst_dir, options.quiet) + copy_file(os.path.join(build_dir, 'libcef.dylib'), dst_dir, options.quiet) + copy_file(os.path.join(build_dir, 'libplugin_carbon_interpose.dylib'), dst_dir, options.quiet) + else: + build_dir = None + + # transfer xcodebuild/Release files + build_dir = os.path.join(src_dir, 'xcodebuild/Release') + if not options.allowpartial or path_exists(build_dir): + dst_dir = os.path.join(output_dir, 'Release') + make_dir(dst_dir, options.quiet) + copy_file(os.path.join(build_dir, 'ffmpegsumo.so'), dst_dir, options.quiet) + copy_file(os.path.join(build_dir, 'libcef.dylib'), dst_dir, options.quiet) + copy_file(os.path.join(build_dir, 'libplugin_carbon_interpose.dylib'), dst_dir, options.quiet) + + if not options.nosymbols: + # create the real dSYM file from the "fake" dSYM file + sys.stdout.write("Creating the real dSYM file...\n") + src_path = os.path.join(build_dir, 'libcef.dylib.dSYM/Contents/Resources/DWARF/libcef.dylib') + dst_path = os.path.join(symbol_dir, 'libcef.dylib.dSYM') + run('dsymutil '+src_path+' -o '+dst_path, cef_dir) + else: + build_dir = None + + if not build_dir is None: + # transfer resource files + dst_dir = os.path.join(output_dir, 'Resources') + make_dir(dst_dir, options.quiet) + copy_files(os.path.join(build_dir, 'cefclient.app/Contents/Frameworks/Chromium Embedded Framework.framework/Resources/*.*'), \ + dst_dir, options.quiet) + + # transfer additional files, if any + transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/mac/transfer.cfg'), \ + output_dir, options.quiet) + + # Generate Xcode project files + sys.stdout.write('Generating Xcode project files...') + gyper = [ 'python', 'tools/gyp_cef', os.path.relpath(os.path.join(output_dir, 'cefclient.gyp'), cef_dir) ] + RunAction(cef_dir, gyper); + + # Post-process the Xcode project to fix file paths + src_file = os.path.join(output_dir, 'cefclient.xcodeproj/project.pbxproj') + data = read_file(src_file) + data = data.replace('../../../build/mac/', 'tools/') + data = data.replace('../../../build', 'build') + data = data.replace('../../../xcodebuild', 'xcodebuild') + write_file(src_file, data) + +elif platform == 'linux': + # create the README.TXT file + create_readme(os.path.join(script_dir, 'distrib/linux/README.txt'), output_dir, cef_url, \ + cef_rev, cef_ver, chromium_url, chromium_rev, chromium_ver, date) + + # transfer out/Debug files + build_dir = os.path.join(src_dir, 'out/Debug'); + if not options.allowpartial or path_exists(build_dir): + dst_dir = os.path.join(output_dir, 'Debug') + make_dir(dst_dir, options.quiet) + copy_dir(os.path.join(build_dir, 'lib.target'), os.path.join(dst_dir, 'lib.target'), options.quiet) + copy_file(os.path.join(build_dir, 'cefclient'), dst_dir, options.quiet) + copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet) + copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet) + copy_dir(os.path.join(build_dir, 'locales'), os.path.join(dst_dir, 'locales'), options.quiet) + else: + sys.stderr.write("No Debug build files.\n") + + # transfer out/Release files + build_dir = os.path.join(src_dir, 'out/Release'); + if not options.allowpartial or path_exists(build_dir): + dst_dir = os.path.join(output_dir, 'Release') + make_dir(dst_dir, options.quiet) + copy_dir(os.path.join(build_dir, 'lib.target'), os.path.join(dst_dir, 'lib.target'), options.quiet) + copy_file(os.path.join(build_dir, 'cefclient'), dst_dir, options.quiet) + copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet) + copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet) + copy_dir(os.path.join(build_dir, 'locales'), os.path.join(dst_dir, 'locales'), options.quiet) + else: + sys.stderr.write("No Release build files.\n") + + # transfer include files + transfer_gypi_files(cef_dir, cef_paths2['includes_linux'], \ + 'include/', include_dir, options.quiet) + + # transfer cefclient files + transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_linux'], \ + 'tests/cefclient/', cefclient_dir, options.quiet) + + # transfer additional files, if any + transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/linux/transfer.cfg'), \ + output_dir, options.quiet) + +# Create an archive of the output directory +zip_file = os.path.split(output_dir)[1] + '.zip' +if not options.quiet: + sys.stdout.write('Creating '+zip_file+"...\n") +create_archive(output_dir, os.path.join(output_dir, os.pardir, zip_file)) + +if not options.nosymbols: + # Create an archive of the symbol directory + zip_file = os.path.split(symbol_dir)[1] + '.zip' + if not options.quiet: + sys.stdout.write('Creating '+zip_file+"...\n") + create_archive(symbol_dir, os.path.join(symbol_dir, os.pardir, zip_file)) diff --git a/cef3/tools/make_distrib.sh b/cef3/tools/make_distrib.sh new file mode 100755 index 000000000..273a3e16b --- /dev/null +++ b/cef3/tools/make_distrib.sh @@ -0,0 +1,2 @@ +#!/bin/sh +python make_distrib.py --output-dir ../binary_distrib/ $@ diff --git a/cef3/tools/make_gypi_file.py b/cef3/tools/make_gypi_file.py new file mode 100644 index 000000000..e5cefd7a9 --- /dev/null +++ b/cef3/tools/make_gypi_file.py @@ -0,0 +1,108 @@ +# 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. + +from cef_parser import * + +def make_gypi_file(header): + # header string + result = \ +"""# Copyright (c) $YEAR$ 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. +# +# --------------------------------------------------------------------------- +# +# This file was generated by the CEF translator tool and should not edited +# by hand. See the translator.README.txt file in the tools directory for +# more information. +# + +{ + 'variables': { +""" + + filenames = sorted(header.get_file_names()) + + # cpp includes + result += " 'autogen_cpp_includes': [\n" + for filename in filenames: + result += " 'include/"+filename+"',\n" + result += " ],\n" + + # capi includes + result += " 'autogen_capi_includes': [\n" + for filename in filenames: + result += " 'include/capi/"+get_capi_file_name(filename)+"',\n" + result += " ],\n" + + classes = sorted(header.get_class_names()) + + # library side includes + result += " 'autogen_library_side': [\n" + for clsname in classes: + cls = header.get_class(clsname) + filename = get_capi_name(clsname[3:], False) + if cls.is_library_side(): + result += " 'libcef_dll/cpptoc/"+filename+"_cpptoc.cc',\n" \ + " 'libcef_dll/cpptoc/"+filename+"_cpptoc.h',\n" + else: + result += " 'libcef_dll/ctocpp/"+filename+"_ctocpp.cc',\n" \ + " 'libcef_dll/ctocpp/"+filename+"_ctocpp.h',\n" + result += " ],\n" + + # client side includes + result += " 'autogen_client_side': [\n" + for clsname in classes: + cls = header.get_class(clsname) + filename = get_capi_name(clsname[3:], False) + if cls.is_library_side(): + result += " 'libcef_dll/ctocpp/"+filename+"_ctocpp.cc',\n" \ + " 'libcef_dll/ctocpp/"+filename+"_ctocpp.h',\n" + else: + result += " 'libcef_dll/cpptoc/"+filename+"_cpptoc.cc',\n" \ + " 'libcef_dll/cpptoc/"+filename+"_cpptoc.h',\n" + result += " ],\n" + + # footer string + result += \ +""" }, +} +""" + + # add the copyright year + result = result.replace('$YEAR$', get_year()) + + return result + +def write_gypi_file(header, file, backup): + if path_exists(file): + oldcontents = read_file(file) + else: + oldcontents = '' + + newcontents = make_gypi_file(header) + if newcontents != oldcontents: + if backup and oldcontents != '': + backup_file(file) + write_file(file, newcontents) + return True + + return False + + +# test the module +if __name__ == "__main__": + import sys + + # verify that the correct number of command-line arguments are provided + if len(sys.argv) < 2: + sys.stderr.write('Usage: '+sys.argv[0]+' ') + sys.exit() + + # create the header object + header = obj_header() + header.add_file(sys.argv[1]) + + # dump the result to stdout + sys.stdout.write(make_gypi_file(header)) diff --git a/cef3/tools/make_pack_header.py b/cef3/tools/make_pack_header.py new file mode 100644 index 000000000..0b4cb2e04 --- /dev/null +++ b/cef3/tools/make_pack_header.py @@ -0,0 +1,121 @@ +#!/usr/bin/env python +# 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. + +""" +A simple utility function to merge pack resource files into a single resource file. +""" + +from date_util import * +from file_util import * +import os +import re +import string +import sys + + +def MakeFileSegment(input): + result = """ + +// --------------------------------------------------------------------------- +// From $FILE$: +""" + + filename = os.path.split(input)[1] + result = result.replace('$FILE$', filename) + + contents = read_file(input) + + # identify the defines in the file + p = re.compile('#define\s([A-Za-z0-9_]{1,})\s([0-9]{1,})') + list = p.findall(contents) + for name, id in list: + result += "\n#define %s %s" % (name, id) + + return result + + +def MakeFile(output, input): + # header string + result = \ +"""// Copyright (c) $YEAR$ Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file is generated by the make_pack_header.py tool. +// + +#ifndef $GUARD$ +#define $GUARD$ +#pragma once""" + + # sort the input files by name + input = sorted(input, key=lambda path: os.path.split(path)[1]) + + # generate the file segments + for file in input: + result += MakeFileSegment(file) + + # footer string + result += \ +""" + +#endif // $GUARD$ +""" + + # add the copyright year + result = result.replace('$YEAR$', get_year()) + # add the guard string + filename = os.path.split(output)[1] + guard = 'CEF_INCLUDE_'+string.upper(filename.replace('.', '_'))+'_' + result = result.replace('$GUARD$', guard) + + if path_exists(output): + old_contents = read_file(output) + else: + old_contents = '' + + if (result != old_contents): + write_file(output, result) + sys.stdout.write('File '+output+' updated.\n') + else: + sys.stdout.write('File '+output+' is already up to date.\n') + +def main(argv): + if len(argv) < 3: + print ("Usage:\n %s [input_file2] ... " % + argv[0]) + sys.exit(-1) + MakeFile(argv[1], argv[2:]) + + +if '__main__' == __name__: + main(sys.argv) diff --git a/cef3/tools/make_version_header.bat b/cef3/tools/make_version_header.bat new file mode 100644 index 000000000..c143163a5 --- /dev/null +++ b/cef3/tools/make_version_header.bat @@ -0,0 +1,2 @@ +@echo off +..\third_party\python_26\python.exe tools\make_version_header.py --header include\cef_version.h --cef_version VERSION --chrome_version ../chrome/VERSION --cpp_header_dir include diff --git a/cef3/tools/make_version_header.py b/cef3/tools/make_version_header.py new file mode 100644 index 000000000..080f09b83 --- /dev/null +++ b/cef3/tools/make_version_header.py @@ -0,0 +1,174 @@ +# 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. + +from date_util import * +from file_util import * +from optparse import OptionParser +from cef_api_hash import cef_api_hash +import svn_util as svn +import git_util as git +import sys + +# cannot be loaded as a module +if __name__ != "__main__": + sys.stderr.write('This file cannot be loaded as a module!') + sys.exit() + + +# parse command-line options +disc = """ +This utility creates the version header file. +""" + +parser = OptionParser(description=disc) +parser.add_option('--header', dest='header', metavar='FILE', + help='output version header file [required]') +parser.add_option('--cef_version', dest='cef_version', metavar='FILE', + help='input CEF version config file [required]') +parser.add_option('--chrome_version', dest='chrome_version', metavar='FILE', + help='input Chrome version config file [required]') +parser.add_option('--cpp_header_dir', dest='cpp_header_dir', metavar='DIR', + help='input directory for C++ header files [required]') +parser.add_option('-q', '--quiet', + action='store_true', dest='quiet', default=False, + help='do not output detailed status information') +(options, args) = parser.parse_args() + +# the header option is required +if options.header is None or options.cef_version is None or options.chrome_version is None or options.cpp_header_dir is None: + parser.print_help(sys.stdout) + sys.exit() + +def write_svn_header(header, chrome_version, cef_version, cpp_header_dir): + """ Creates the header file for the current revision and Chrome version information + if the information has changed or if the file doesn't already exist. """ + + if not path_exists(chrome_version): + raise Exception('Chrome version file '+chrome_version+' does not exist.') + if not path_exists(cef_version): + raise Exception('CEF version file '+cef_version+' does not exist.') + + args = {} + read_version_file(chrome_version, args) + read_version_file(cef_version, args) + + if path_exists(header): + oldcontents = read_file(header) + else: + oldcontents = '' + + year = get_year() + + try: + revision = svn.get_revision() + except: + revision = git.get_svn_revision() + + # calculate api hashes + api_hash_calculator = cef_api_hash(cpp_header_dir, verbose = False) + api_hashes = api_hash_calculator.calculate() + + newcontents = '// Copyright (c) '+year+' Marshall A. Greenblatt. All rights reserved.\n'+\ + '//\n'+\ + '// Redistribution and use in source and binary forms, with or without\n'+\ + '// modification, are permitted provided that the following conditions are\n'+\ + '// met:\n'+\ + '//\n'+\ + '// * Redistributions of source code must retain the above copyright\n'+\ + '// notice, this list of conditions and the following disclaimer.\n'+\ + '// * Redistributions in binary form must reproduce the above\n'+\ + '// copyright notice, this list of conditions and the following disclaimer\n'+\ + '// in the documentation and/or other materials provided with the\n'+\ + '// distribution.\n'+\ + '// * Neither the name of Google Inc. nor the name Chromium Embedded\n'+\ + '// Framework nor the names of its contributors may be used to endorse\n'+\ + '// or promote products derived from this software without specific prior\n'+\ + '// written permission.\n'+\ + '//\n'+\ + '// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n'+\ + '// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n'+\ + '// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n'+\ + '// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n'+\ + '// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n'+\ + '// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n'+\ + '// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n'+\ + '// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n'+\ + '// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n'+\ + '// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n'+\ + '// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n'+\ + '//\n'+\ + '// ---------------------------------------------------------------------------\n'+\ + '//\n'+\ + '// This file is generated by the make_version_header.py tool.\n'+\ + '//\n\n'+\ + '#ifndef CEF_INCLUDE_CEF_VERSION_H_\n'+\ + '#define CEF_INCLUDE_CEF_VERSION_H_\n\n'+\ + '#define CEF_VERSION_MAJOR ' + args['CEF_MAJOR'] + '\n'+\ + '#define CEF_REVISION ' + revision + '\n'+\ + '#define COPYRIGHT_YEAR ' + year + '\n\n'+\ + '#define CHROME_VERSION_MAJOR ' + args['MAJOR'] + '\n'+\ + '#define CHROME_VERSION_MINOR ' + args['MINOR'] + '\n'+\ + '#define CHROME_VERSION_BUILD ' + args['BUILD'] + '\n'+\ + '#define CHROME_VERSION_PATCH ' + args['PATCH'] + '\n\n'+\ + '#define DO_MAKE_STRING(p) #p\n'+\ + '#define MAKE_STRING(p) DO_MAKE_STRING(p)\n\n'+\ + '#ifndef APSTUDIO_HIDDEN_SYMBOLS\n\n'\ + '#ifdef __cplusplus\n'+\ + 'extern "C" {\n'+\ + '#endif\n\n'+\ + '#include "internal/cef_export.h"\n\n'+\ + '// The API hash is created by analyzing CEF header files for C API type\n'+\ + '// definitions. The hash value will change when header files are modified\n'+\ + '// in a way that may cause binary incompatibility with other builds. The\n'+\ + '// universal hash value will change if any platform is affected whereas the\n'+\ + '// platform hash values will change only if that particular platform is\n'+\ + '// affected.\n'+\ + '#define CEF_API_HASH_UNIVERSAL "' + api_hashes['universal'] + '"\n'+\ + '#if defined(OS_WIN)\n'+\ + '#define CEF_API_HASH_PLATFORM "' + api_hashes['windows'] + '"\n'+\ + '#elif defined(OS_MACOSX)\n'+\ + '#define CEF_API_HASH_PLATFORM "' + api_hashes['macosx'] + '"\n'+\ + '#elif defined(OS_LINUX)\n'+\ + '#define CEF_API_HASH_PLATFORM "' + api_hashes['linux'] + '"\n'+\ + '#endif\n\n'+\ + '///\n'+\ + '// Returns the CEF build revision for the libcef library.\n'+\ + '///\n'+\ + 'CEF_EXPORT int cef_build_revision();\n\n'+\ + '///\n'+\ + '// Returns CEF version information for the libcef library. The |entry|\n'+\ + '// parameter describes which version component will be returned:\n'+\ + '// 0 - CEF_VERSION_MAJOR\n'+\ + '// 1 - CEF_REVISION\n'+\ + '// 2 - CHROME_VERSION_MAJOR\n'+\ + '// 3 - CHROME_VERSION_MINOR\n'+\ + '// 4 - CHROME_VERSION_BUILD\n'+\ + '// 5 - CHROME_VERSION_PATCH\n'+\ + '///\n'+\ + 'CEF_EXPORT int cef_version_info(int entry);\n\n'+\ + '///\n'+\ + '// Returns CEF API hashes for the libcef library. The returned string is owned\n'+\ + '// by the library and should not be freed. The |entry| parameter describes which\n'+\ + '// hash value will be returned:\n'+\ + '// 0 - CEF_API_HASH_PLATFORM\n'+\ + '// 1 - CEF_API_HASH_UNIVERSAL\n'+\ + '///\n'+\ + 'CEF_EXPORT const char* cef_api_hash(int entry);\n\n'+\ + '#ifdef __cplusplus\n'+\ + '}\n'+\ + '#endif\n\n'+\ + '#endif // APSTUDIO_HIDDEN_SYMBOLS\n\n'+\ + '#endif // CEF_INCLUDE_CEF_VERSION_H_\n' + if newcontents != oldcontents: + write_file(header, newcontents) + return True + + return False + +written = write_svn_header(options.header, options.chrome_version, options.cef_version, options.cpp_header_dir) +if not options.quiet: + if written: + sys.stdout.write('File '+options.header+' updated.\n') + else: + sys.stdout.write('File '+options.header+' is already up to date.\n') diff --git a/cef3/tools/make_version_header.sh b/cef3/tools/make_version_header.sh new file mode 100755 index 000000000..4cac35f4a --- /dev/null +++ b/cef3/tools/make_version_header.sh @@ -0,0 +1,2 @@ +#!/bin/sh +python tools/make_version_header.py --header include/cef_version.h --cef_version VERSION --chrome_version ../chrome/VERSION --cpp_header_dir include diff --git a/cef3/tools/patch.bat b/cef3/tools/patch.bat new file mode 100644 index 000000000..b21981a0d --- /dev/null +++ b/cef3/tools/patch.bat @@ -0,0 +1,2 @@ +@echo off +..\third_party\python_26\python.exe tools\patcher.py --patch-config patch/patch.cfg \ No newline at end of file diff --git a/cef3/tools/patch.sh b/cef3/tools/patch.sh new file mode 100755 index 000000000..b9dde9bc0 --- /dev/null +++ b/cef3/tools/patch.sh @@ -0,0 +1,2 @@ +#!/bin/sh +python tools/patcher.py --patch-config patch/patch.cfg diff --git a/cef3/tools/patch_util.py b/cef3/tools/patch_util.py new file mode 100644 index 000000000..0d6c5bf00 --- /dev/null +++ b/cef3/tools/patch_util.py @@ -0,0 +1,593 @@ +""" Patch utility to apply unified diffs """ +""" Brute-force line-by-line parsing + + Project home: http://code.google.com/p/python-patch/ + + This file is subject to the MIT license available here: + http://www.opensource.org/licenses/mit-license.php + + CEF Changes + ----------- + + 2013/01/03 + - Add support for patches containing new files + + 2009/07/22 + - Add a 'root_directory' argument to PatchInfo::apply + - Fix a Python 2.4 compile error in PatchInfo::parse_stream + +""" + +__author__ = "techtonik.rainforce.org" +__version__ = "8.12-1" + +import copy +import logging +import os +import re +from stat import * +# cStringIO doesn't support unicode in 2.5 +from StringIO import StringIO +from logging import debug, info, warning + +from os.path import exists, isfile +from os import unlink + +debugmode = False + + +def from_file(filename): + """ read and parse patch file + return PatchInfo() object + """ + + info("reading patch from file %s" % filename) + fp = open(filename, "rb") + patch = PatchInfo(fp) + fp.close() + return patch + + +def from_string(s): + """ parse text string and return PatchInfo() object """ + return PatchInfo( + StringIO.StringIO(s) + ) + + +class HunkInfo(object): + """ parsed hunk data (hunk starts with @@ -R +R @@) """ + + def __init__(self): + # define HunkInfo data members + self.startsrc=None + self.linessrc=None + self.starttgt=None + self.linestgt=None + self.invalid=False + self.text=[] + + def copy(self): + return copy.copy(self) + +# def apply(self, estream): +# """ write hunk data into enumerable stream +# return strings one by one until hunk is +# over +# +# enumerable stream are tuples (lineno, line) +# where lineno starts with 0 +# """ +# pass + + + + +class PatchInfo(object): + """ patch information container """ + + def __init__(self, stream=None): + """ parse incoming stream """ + + # define PatchInfo data members + # table with a row for every source file + + #: list of source filenames + self.source=None + self.target=None + #: list of lists of hunks + self.hunks=None + #: file endings statistics for every hunk + self.hunkends=None + + if stream: + self.parse_stream(stream) + + def copy(self): + return copy.copy(self) + + def parse_stream(self, stream): + """ parse unified diff """ + self.source = [] + self.target = [] + self.hunks = [] + self.hunkends = [] + + # define possible file regions that will direct the parser flow + header = False # comments before the patch body + filenames = False # lines starting with --- and +++ + + hunkhead = False # @@ -R +R @@ sequence + hunkbody = False # + hunkskip = False # skipping invalid hunk mode + + header = True + lineends = dict(lf=0, crlf=0, cr=0) + nextfileno = 0 + nexthunkno = 0 #: even if index starts with 0 user messages number hunks from 1 + + # hunkinfo holds parsed values, hunkactual - calculated + hunkinfo = HunkInfo() + hunkactual = dict(linessrc=None, linestgt=None) + + fe = enumerate(stream) + for lineno, line in fe: + + # analyze state + if header and line.startswith("--- "): + header = False + # switch to filenames state + filenames = True + #: skip hunkskip and hunkbody code until you read definition of hunkhead + if hunkbody: + # process line first + if re.match(r"^[- \+\\]", line): + # gather stats about line endings + if line.endswith("\r\n"): + self.hunkends[nextfileno-1]["crlf"] += 1 + elif line.endswith("\n"): + self.hunkends[nextfileno-1]["lf"] += 1 + elif line.endswith("\r"): + self.hunkends[nextfileno-1]["cr"] += 1 + + if line.startswith("-"): + hunkactual["linessrc"] += 1 + elif line.startswith("+"): + hunkactual["linestgt"] += 1 + elif not line.startswith("\\"): + hunkactual["linessrc"] += 1 + hunkactual["linestgt"] += 1 + hunkinfo.text.append(line) + # todo: handle \ No newline cases + else: + warning("invalid hunk no.%d at %d for target file %s" % (nexthunkno, lineno+1, self.target[nextfileno-1])) + # add hunk status node + self.hunks[nextfileno-1].append(hunkinfo.copy()) + self.hunks[nextfileno-1][nexthunkno-1]["invalid"] = True + # switch to hunkskip state + hunkbody = False + hunkskip = True + + # check exit conditions + if hunkactual["linessrc"] > hunkinfo.linessrc or hunkactual["linestgt"] > hunkinfo.linestgt: + warning("extra hunk no.%d lines at %d for target %s" % (nexthunkno, lineno+1, self.target[nextfileno-1])) + # add hunk status node + self.hunks[nextfileno-1].append(hunkinfo.copy()) + self.hunks[nextfileno-1][nexthunkno-1]["invalid"] = True + # switch to hunkskip state + hunkbody = False + hunkskip = True + elif hunkinfo.linessrc == hunkactual["linessrc"] and hunkinfo.linestgt == hunkactual["linestgt"]: + self.hunks[nextfileno-1].append(hunkinfo.copy()) + # switch to hunkskip state + hunkbody = False + hunkskip = True + + # detect mixed window/unix line ends + ends = self.hunkends[nextfileno-1] + if ((ends["cr"]!=0) + (ends["crlf"]!=0) + (ends["lf"]!=0)) > 1: + warning("inconsistent line ends in patch hunks for %s" % self.source[nextfileno-1]) + if debugmode: + debuglines = dict(ends) + debuglines.update(file=self.target[nextfileno-1], hunk=nexthunkno) + debug("crlf: %(crlf)d lf: %(lf)d cr: %(cr)d\t - file: %(file)s hunk: %(hunk)d" % debuglines) + + if hunkskip: + match = re.match("^@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))?", line) + if match: + # switch to hunkhead state + hunkskip = False + hunkhead = True + elif line.startswith("--- "): + # switch to filenames state + hunkskip = False + filenames = True + if debugmode and len(self.source) > 0: + debug("- %2d hunks for %s" % (len(self.hunks[nextfileno-1]), self.source[nextfileno-1])) + + if filenames: + if line.startswith("--- "): + if nextfileno in self.source: + warning("skipping invalid patch for %s" % self.source[nextfileno]) + del self.source[nextfileno] + # double source filename line is encountered + # attempt to restart from this second line + re_filename = "^--- ([^\t]+)" + match = re.match(re_filename, line) + if not match: + warning("skipping invalid filename at line %d" % lineno) + # switch back to header state + filenames = False + header = True + else: + self.source.append(match.group(1)) + elif not line.startswith("+++ "): + if nextfileno in self.source: + warning("skipping invalid patch with no target for %s" % self.source[nextfileno]) + del self.source[nextfileno] + else: + # this should be unreachable + warning("skipping invalid target patch") + filenames = False + header = True + else: + if nextfileno in self.target: + warning("skipping invalid patch - double target at line %d" % lineno) + del self.source[nextfileno] + del self.target[nextfileno] + nextfileno -= 1 + # double target filename line is encountered + # switch back to header state + filenames = False + header = True + else: + re_filename = "^\+\+\+ ([^\t]+)" + match = re.match(re_filename, line) + if not match: + warning("skipping invalid patch - no target filename at line %d" % lineno) + # switch back to header state + filenames = False + header = True + else: + self.target.append(match.group(1)) + nextfileno += 1 + # switch to hunkhead state + filenames = False + hunkhead = True + nexthunkno = 0 + self.hunks.append([]) + self.hunkends.append(lineends.copy()) + continue + + + if hunkhead: + match = re.match("^@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))?", line) + if not match: + if nextfileno-1 not in self.hunks: + warning("skipping invalid patch with no hunks for file %s" % self.target[nextfileno-1]) + # switch to header state + hunkhead = False + header = True + continue + else: + # switch to header state + hunkhead = False + header = True + else: + hunkinfo.startsrc = int(match.group(1)) + if match.group(3): + hunkinfo.linessrc = int(match.group(3)) + else: + hunkinfo.linessrc = 1 + hunkinfo.starttgt = int(match.group(4)) + if match.group(6): + hunkinfo.linestgt = int(match.group(6)) + else: + hunkinfo.linestgt = 1 + hunkinfo.invalid = False + hunkinfo.text = [] + + hunkactual["linessrc"] = hunkactual["linestgt"] = 0 + + # switch to hunkbody state + hunkhead = False + hunkbody = True + nexthunkno += 1 + continue + else: + if not hunkskip: + warning("patch file incomplete - %s" % filename) + # sys.exit(?) + else: + # duplicated message when an eof is reached + if debugmode and len(self.source) > 0: + debug("- %2d hunks for %s" % (len(self.hunks[nextfileno-1]), self.source[nextfileno-1])) + + info("total files: %d total hunks: %d" % (len(self.source), sum(len(hset) for hset in self.hunks))) + + def apply(self, root_directory = None): + """ apply parsed patch """ + + total = len(self.source) + for fileno, filename in enumerate(self.source): + + f2patch = filename + if not root_directory is None: + f2patch = root_directory + f2patch + if not exists(f2patch): + # if the patch contains a single hunk at position 0 consider it a new file + if len(self.hunks[fileno]) == 1 and self.hunks[fileno][0].startsrc == 0: + hunklines = [x[1:].rstrip("\r\n") for x in self.hunks[fileno][0].text if x[0] in " +"] + if len(hunklines) > 0: + warning("creating file %s" % (f2patch)) + f = open(f2patch, "wb") + for line in hunklines: + f.write(line + "\n") + f.close() + continue + + f2patch = self.target[fileno] + if not exists(f2patch): + warning("source/target file does not exist\n--- %s\n+++ %s" % (filename, f2patch)) + continue + if not isfile(f2patch): + warning("not a file - %s" % f2patch) + continue + filename = f2patch + + info("processing %d/%d:\t %s" % (fileno+1, total, filename)) + + # validate before patching + f2fp = open(filename) + hunkno = 0 + hunk = self.hunks[fileno][hunkno] + hunkfind = [] + hunkreplace = [] + validhunks = 0 + canpatch = False + for lineno, line in enumerate(f2fp): + if lineno+1 < hunk.startsrc: + continue + elif lineno+1 == hunk.startsrc: + hunkfind = [x[1:].rstrip("\r\n") for x in hunk.text if x[0] in " -"] + hunkreplace = [x[1:].rstrip("\r\n") for x in hunk.text if x[0] in " +"] + #pprint(hunkreplace) + hunklineno = 0 + + # todo \ No newline at end of file + + # check hunks in source file + if lineno+1 < hunk.startsrc+len(hunkfind)-1: + if line.rstrip("\r\n") == hunkfind[hunklineno]: + hunklineno+=1 + else: + debug("hunk no.%d doesn't match source file %s" % (hunkno+1, filename)) + # file may be already patched, but we will check other hunks anyway + hunkno += 1 + if hunkno < len(self.hunks[fileno]): + hunk = self.hunks[fileno][hunkno] + continue + else: + break + + # check if processed line is the last line + if lineno+1 == hunk.startsrc+len(hunkfind)-1: + debug("file %s hunk no.%d -- is ready to be patched" % (filename, hunkno+1)) + hunkno+=1 + validhunks+=1 + if hunkno < len(self.hunks[fileno]): + hunk = self.hunks[fileno][hunkno] + else: + if validhunks == len(self.hunks[fileno]): + # patch file + canpatch = True + break + else: + if hunkno < len(self.hunks[fileno]) and \ + (len(self.hunks[fileno]) != 1 or self.hunks[fileno][0].startsrc != 0): + warning("premature end of source file %s at hunk %d" % (filename, hunkno+1)) + + f2fp.close() + + if validhunks < len(self.hunks[fileno]): + if check_patched(filename, self.hunks[fileno]): + warning("already patched %s" % filename) + else: + warning("source file is different - %s" % filename) + if canpatch: + backupname = filename+".orig" + if exists(backupname): + warning("can't backup original file to %s - aborting" % backupname) + else: + import shutil + shutil.move(filename, backupname) + if patch_hunks(backupname, filename, self.hunks[fileno]): + warning("successfully patched %s" % filename) + unlink(backupname) + else: + warning("error patching file %s" % filename) + shutil.copy(filename, filename+".invalid") + warning("invalid version is saved to %s" % filename+".invalid") + # todo: proper rejects + shutil.move(backupname, filename) + + # todo: check for premature eof + + + +def check_patched(filename, hunks): + matched = True + fp = open(filename) + + class NoMatch(Exception): + pass + + # special case for new files + try: + if len(hunks) == 1 and hunks[0].startsrc == 0: + hunklines = [x[1:].rstrip("\r\n") for x in hunks[0].text if x[0] in " +"] + if len(hunklines) > 0: + for line in hunklines: + srcline = fp.readline() + if not len(srcline) or srcline.rstrip("\r\n") != line: + raise NoMatch + srcline = fp.readline() + if len(srcline): + raise NoMatch + fp.close() + return True + except NoMatch: + fp.close() + fp = open(filename) + + lineno = 1 + line = fp.readline() + hno = None + try: + if not len(line): + raise NoMatch + for hno, h in enumerate(hunks): + # skip to line just before hunk starts + while lineno < h.starttgt-1: + line = fp.readline() + lineno += 1 + if not len(line): + raise NoMatch + for hline in h.text: + # todo: \ No newline at the end of file + if not hline.startswith("-") and not hline.startswith("\\"): + line = fp.readline() + lineno += 1 + if not len(line): + raise NoMatch + if line.rstrip("\r\n") != hline[1:].rstrip("\r\n"): + warning("file is not patched - failed hunk: %d" % (hno+1)) + raise NoMatch + except NoMatch: + matched = False + # todo: display failed hunk, i.e. expected/found + + fp.close() + return matched + + + +def patch_stream(instream, hunks): + """ given a source stream and hunks iterable, yield patched stream + + converts lineends in hunk lines to the best suitable format + autodetected from input + """ + + # todo: At the moment substituted lineends may not be the same + # at the start and at the end of patching. Also issue a + # warning/throw about mixed lineends (is it really needed?) + + hunks = iter(hunks) + + srclineno = 1 + + lineends = {'\n':0, '\r\n':0, '\r':0} + def get_line(): + """ + local utility function - return line from source stream + collecting line end statistics on the way + """ + line = instream.readline() + # 'U' mode works only with text files + if line.endswith("\r\n"): + lineends["\r\n"] += 1 + elif line.endswith("\n"): + lineends["\n"] += 1 + elif line.endswith("\r"): + lineends["\r"] += 1 + return line + + + for hno, h in enumerate(hunks): + debug("hunk %d" % (hno+1)) + # skip to line just before hunk starts + while srclineno < h.startsrc: + yield get_line() + srclineno += 1 + + for hline in h.text: + # todo: check \ No newline at the end of file + if hline.startswith("-") or hline.startswith("\\"): + get_line() + srclineno += 1 + continue + else: + if not hline.startswith("+"): + get_line() + srclineno += 1 + line2write = hline[1:] + # detect if line ends are consistent in source file + if sum([bool(lineends[x]) for x in lineends]) == 1: + newline = [x for x in lineends if lineends[x] != 0][0] + yield line2write.rstrip("\r\n")+newline + else: # newlines are mixed + yield line2write + + for line in instream: + yield line + + + +def patch_hunks(srcname, tgtname, hunks): + # get the current file mode + mode = os.stat(srcname)[ST_MODE] + + src = open(srcname, "rb") + tgt = open(tgtname, "wb") + + debug("processing target file %s" % tgtname) + + tgt.writelines(patch_stream(src, hunks)) + + tgt.close() + src.close() + + # restore the file mode + os.chmod(tgtname, mode) + + return True + + + + + + +from optparse import OptionParser +from os.path import exists +import sys + +if __name__ == "__main__": + opt = OptionParser(usage="%prog [options] unipatch-file", version="python-patch %s" % __version__) + opt.add_option("-d", action="store_true", dest="debugmode", help="debug mode") + (options, args) = opt.parse_args() + + if not args: + opt.print_version() + print("") + opt.print_help() + sys.exit() + debugmode = options.debugmode + patchfile = args[0] + if not exists(patchfile) or not isfile(patchfile): + sys.exit("patch file does not exist - %s" % patchfile) + + + if debugmode: + logging.basicConfig(level=logging.DEBUG, format="%(levelname)8s %(message)s") + else: + logging.basicConfig(level=logging.INFO, format="%(message)s") + + + + patch = from_file(patchfile) + #pprint(patch) + patch.apply() + + # todo: document and test line ends handling logic - patch.py detects proper line-endings + # for inserted hunks and issues a warning if patched file has incosistent line ends diff --git a/cef3/tools/patcher.README.txt b/cef3/tools/patcher.README.txt new file mode 100644 index 000000000..2078770a4 --- /dev/null +++ b/cef3/tools/patcher.README.txt @@ -0,0 +1,32 @@ +Chromium Embedded Framework (CEF) Patch Application Tool -- patcher.py +------------------------------------------------------------------------------- + +Document Last Updated: July 23, 2009 + + +OVERVIEW +-------- + +The CEF patch application tool is used by the patch project to apply patches +to the Chromium and WebKit code bases. Currently only unified diff format is +supported. See the README.txt file in the patch directory for information on +how the patch project uses this tool. + +The 'patcher.bat' file can be used to run the patch application tool with +command-line arguments that match the default CEF directory structure and +output options. Run 'patcher.py -h' for a complete list of available command- +line arguments. + + +CREDITS +------- + +Thanks go to techtonik for developing the python-patch script. The +patch_util.py file is a slightly modified version of the original script which +can be found here: http://code.google.com/p/python-patch/ + + +WORK REMAINING +-------------- + +o Add support for the GIT patch format. diff --git a/cef3/tools/patcher.py b/cef3/tools/patcher.py new file mode 100644 index 000000000..09cb9c5fa --- /dev/null +++ b/cef3/tools/patcher.py @@ -0,0 +1,103 @@ +# Copyright (c) 2009 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. + +import pickle +from optparse import OptionParser +import os +import sys +from file_util import * +from patch_util import * + + +# cannot be loaded as a module +if __name__ != "__main__": + sys.stderr.write('This file cannot be loaded as a module!') + sys.exit() + + +# parse command-line options +disc = """ +This utility applies patch files. +""" + +parser = OptionParser(description=disc) +parser.add_option('--patch-config', dest='patchconfig', metavar='DIR', + help='patch configuration file') +(options, args) = parser.parse_args() + +# the patchconfig option is required +if options.patchconfig is None: + parser.print_help(sys.stdout) + sys.exit() + +# normalize the patch directory value +patchdir = os.path.dirname(os.path.abspath(options.patchconfig)).replace('\\', '/') +if patchdir[-1] != '/': + patchdir += '/' + +# check if the patching should be skipped +if os.path.isfile(patchdir + 'NOPATCH'): + nopatch = True + sys.stdout.write('NOPATCH exists -- files have not been patched.\n') +else: + nopatch = False + # locate the patch configuration file + if not os.path.isfile(options.patchconfig): + sys.stderr.write('File '+options.patchconfig+' does not exist.\n') + sys.exit() + + scope = {} + execfile(options.patchconfig, scope) + patches = scope["patches"] + + for patch in patches: + file = patchdir+'patches/'+patch['name']+'.patch' + dopatch = True + + if 'condition' in patch: + # Check that the environment variable is set. + if patch['condition'] not in os.environ: + sys.stderr.write('Skipping patch file '+file+'\n') + dopatch = False + + if dopatch: + if not os.path.isfile(file): + sys.stderr.write('Patch file '+file+' does not exist.\n') + else: + sys.stderr.write('Reading patch file '+file+'\n') + dir = patch['path'] + patchObj = from_file(file) + patchObj.apply(dir) + if 'note' in patch: + separator = '-' * 79 + '\n' + sys.stderr.write(separator) + sys.stderr.write('NOTE: '+patch['note']+'\n') + sys.stderr.write(separator) + +# read the current include file, if any +incfile = patchdir + 'patch_state.h' +if nopatch: + incnew = """// This file is generated by the patch tool and should not be edited manually. +#ifndef _PATCH_STATE_H +#define _PATCH_STATE_H +// No patches have been applied to the Chromium/WebKit source base. +#define CEF_PATCHES_APPLIED 0 +#endif // _PATCH_STATE_H +""" +else: + incnew = """// This file is generated by the patch tool and should not be edited manually. +#ifndef _PATCH_STATE_H +#define _PATCH_STATE_H +// Patches have been applied to the Chromium/WebKit source base. +#define CEF_PATCHES_APPLIED 1 +#endif // _PATCH_STATE_H +""" + +inccur = '' +if os.path.isfile(incfile): + inccur = read_file(incfile) + +if inccur != incnew: + sys.stdout.write('Writing file '+incfile+'.\n') + write_file(incfile, incnew) \ No newline at end of file diff --git a/cef3/tools/repack_locales.py b/cef3/tools/repack_locales.py new file mode 100644 index 000000000..5cf52be17 --- /dev/null +++ b/cef3/tools/repack_locales.py @@ -0,0 +1,184 @@ +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Helper script to repack paks for a list of locales. + +Gyp doesn't have any built-in looping capability, so this just provides a way to +loop over a list of locales when repacking pak files, thus avoiding a +proliferation of mostly duplicate, cut-n-paste gyp actions. +""" + +import getopt +import os +import sys + +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', + 'tools', 'grit')) +from grit.format import data_pack + +# Some build paths defined by gyp. +GRIT_DIR = None +SHARE_INT_DIR = None +INT_DIR = None + + +class Usage(Exception): + def __init__(self, msg): + self.msg = msg + + +def calc_output(locale): + """Determine the file that will be generated for the given locale.""" + #e.g. '<(INTERMEDIATE_DIR)/repack/da.pak', + # For Fake Bidi, generate it at a fixed path so that tests can safely + # reference it. + if locale == 'fake-bidi': + return '%s/%s.pak' % (INT_DIR, locale) + if sys.platform in ('darwin',): + # For Cocoa to find the locale at runtime, it needs to use '_' instead + # of '-' (http://crbug.com/20441). Also, 'en-US' should be represented + # simply as 'en' (http://crbug.com/19165, http://crbug.com/25578). + if locale == 'en-US': + locale = 'en' + return '%s/repack/%s.lproj/locale.pak' % (INT_DIR, locale.replace('-', '_')) + else: + return os.path.join(INT_DIR, 'repack', locale + '.pak') + + +def calc_inputs(locale): + """Determine the files that need processing for the given locale.""" + inputs = [] + + #e.g. '<(grit_out_dir)/generated_resources_da.pak' + #inputs.append(os.path.join(GRIT_DIR, 'generated_resources_%s.pak' % locale)) + + #e.g. '<(grit_out_dir)/locale_settings_da.pak' + #inputs.append(os.path.join(GRIT_DIR, 'locale_settings_%s.pak' % locale)) + + #e.g. '<(grit_out_dir)/platform_locale_settings_da.pak' + #inputs.append(os.path.join(GRIT_DIR, + # 'platform_locale_settings_%s.pak' % locale)) + + #e.g. '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_strings_da.pak' + inputs.append(os.path.join(SHARE_INT_DIR, 'webkit', + 'webkit_strings_%s.pak' % locale)) + + #e.g. '<(SHARED_INTERMEDIATE_DIR)/ui/ui_strings_da.pak', + inputs.append(os.path.join(SHARE_INT_DIR, 'ui', 'ui_strings', + 'ui_strings_%s.pak' % locale)) + + #e.g. '<(SHARED_INTERMEDIATE_DIR)/ui/app_locale_settings_da.pak', + inputs.append(os.path.join(SHARE_INT_DIR, 'ui', 'app_locale_settings', + 'app_locale_settings_%s.pak' % locale)) + + #e.g. '<(SHARED_INTERMEDIATE_DIR)/cef/cef_strings_da.pak' + inputs.append(os.path.join(SHARE_INT_DIR, 'cef', + 'cef_strings_%s.pak' % locale)) + + return inputs + + +def list_outputs(locales): + """Returns the names of files that will be generated for the given locales. + + This is to provide gyp the list of output files, so build targets can + properly track what needs to be built. + """ + outputs = [] + for locale in locales: + outputs.append(calc_output(locale)) + # Quote each element so filename spaces don't mess up gyp's attempt to parse + # it into a list. + return " ".join(['"%s"' % x for x in outputs]) + + +def list_inputs(locales): + """Returns the names of files that will be processed for the given locales. + + This is to provide gyp the list of input files, so build targets can properly + track their prerequisites. + """ + inputs = [] + for locale in locales: + inputs += calc_inputs(locale) + # Quote each element so filename spaces don't mess up gyp's attempt to parse + # it into a list. + return " ".join(['"%s"' % x for x in inputs]) + + +def repack_locales(locales): + """ Loop over and repack the given locales.""" + for locale in locales: + inputs = [] + inputs += calc_inputs(locale) + output = calc_output(locale) + data_pack.DataPack.RePack(output, inputs) + + +def DoMain(argv): + global GRIT_DIR + global SHARE_INT_DIR + global INT_DIR + + short_options = 'iog:s:x:b:h' + long_options = 'help' + + print_inputs = False + print_outputs = False + usage_msg = '' + + helpstr = """\ +Usage: %s [-h] [-i | -o] -g -x -s [...] + -h, --help Print this help, then exit. + -i Print the expected input file list, then exit. + -o Print the expected output file list, then exit. + -g DIR GRIT build files output directory. + -x DIR Intermediate build files output directory. + -s DIR Shared intermediate build files output directory. + locale [...] One or more locales to repack.""" % ( + os.path.basename(__file__)) + + try: + opts, locales = getopt.getopt(argv, short_options, long_options) + except getopt.GetoptError, msg: + raise Usage(str(msg)) + + if not locales: + usage_msg = 'Please specificy at least one locale to process.\n' + + for o, a in opts: + if o in ('-i'): + print_inputs = True + elif o in ('-o'): + print_outputs = True + elif o in ('-g'): + GRIT_DIR = a + elif o in ('-s'): + SHARE_INT_DIR = a + elif o in ('-x'): + INT_DIR = a + elif o in ('-h', '--help'): + raise Usage(helpstr) + + if not (GRIT_DIR and INT_DIR and SHARE_INT_DIR): + usage_msg += 'Please specify all of "-g" and "-x" and "-s".\n' + if print_inputs and print_outputs: + usage_msg += 'Please specify only one of "-i" or "-o".\n' + + if usage_msg: + raise Usage(usage_msg) + + if print_inputs: + return list_inputs(locales) + + if print_outputs: + return list_outputs(locales) + + return repack_locales(locales) + +if __name__ == '__main__': + results = DoMain(sys.argv[1:]) + if results: + print results diff --git a/cef3/tools/revision.py b/cef3/tools/revision.py new file mode 100644 index 000000000..1096c12dd --- /dev/null +++ b/cef3/tools/revision.py @@ -0,0 +1,19 @@ +# 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. + +import svn_util as svn +import git_util as git +import sys + +# cannot be loaded as a module +if __name__ != "__main__": + sys.stderr.write('This file cannot be loaded as a module!') + sys.exit() + +try: + sys.stdout.write(svn.get_revision()) +except: + sys.stdout.write(git.get_svn_revision()) + + diff --git a/cef3/tools/svn_util.py b/cef3/tools/svn_util.py new file mode 100644 index 000000000..39f2dda82 --- /dev/null +++ b/cef3/tools/svn_util.py @@ -0,0 +1,57 @@ +# 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. + +import os +import sys +import urllib + +def check_url(url): + """ Check the URL and raise an exception if invalid. """ + if ':' in url[:7]: + parts = url.split(':', 1) + if (parts[0] == 'http' or parts[0] == 'https' or parts[0] == 'svn') and \ + parts[1] == urllib.quote(parts[1]): + return url + sys.stderr.write('Invalid URL: '+url+"\n") + raise Exception('Invalid URL: '+url) + +def get_svn_info(path): + """ Retrieves the URL and revision from svn info. """ + url = 'None' + rev = 'None' + if path[0:4] == 'http' or os.path.exists(path): + try: + stream = os.popen('svn info '+path) + for line in stream: + if line[0:4] == "URL:": + url = check_url(line[5:-1]) + elif line[0:9] == "Revision:": + rev = str(int(line[10:-1])) + except IOError, (errno, strerror): + sys.stderr.write('Failed to read svn info: '+strerror+"\n") + raise + return {'url': url, 'revision': rev} + +def get_revision(path = '.'): + """ Retrieves the revision from svn info. """ + info = get_svn_info(path) + if info['revision'] == 'None': + raise Exception('Unable to retrieve SVN revision for "'+path+'"') + return info['revision'] + +def get_changed_files(path = '.'): + """ Retrieves the list of changed files from svn status. """ + files = [] + if os.path.exists(path): + try: + stream = os.popen('svn status '+path) + for line in stream: + status = line[0] + # Return paths with add, modify and switch status. + if status == 'A' or status == 'M' or status == 'S': + files.append(line[8:].strip()) + except IOError, (errno, strerror): + sys.stderr.write('Failed to read svn status: '+strerror+"\n") + raise + return files diff --git a/cef3/tools/translator.README.txt b/cef3/tools/translator.README.txt new file mode 100644 index 000000000..2be478f36 --- /dev/null +++ b/cef3/tools/translator.README.txt @@ -0,0 +1,1697 @@ +Chromium Embedded Framework (CEF) Translator Tool -- translator.py +------------------------------------------------------------------------------- + +Document Last Updated: February 14, 2012 + + +OVERVIEW +-------- + +The CEF translator tool automatically generates CEF source code based on the +contents of the CEF header file (cef.h). The generated source code includes the +main C API header file (cef_capi.h) and all files in the libcef_dll/cpptoc and +libcef_dll/ctocpp directories. + +If any differences are detected between the new translator-generated output and +the file that currently exists on disk a backup of the existing file will be +created before the new file is written (this behavior can be controlled using +a command-line switch -- see 'translator.py -h' for more information). Header +files (*.h) are completely generated by the translator and should never be +edited by hand. Implementation files (*.cc) may contain user-created content +within method and function body blocks. The user-created content is extracted +from the existing file and inserted into the new translator-generated file. Any +differences between existing method/function prototypes and new method/function +prototypes in manually edited implementations will be noted as a warning in new +output file. + + // WARNING - CHANGED ATTRIBUTES + // REMOVED: const wchar_t* key + // ADDED: int index + // WARNING - CHANGED RETURN VALUE + // WAS: void + // NOW: int + #pragma message("Warning: "__FILE__": MyFunction prototype has changed") + +Auto-generated implementations will be added in the new output file for any +methods/functions that exist in the CEF header file but did not exist in the +current on-disk implementation file. Each time the translator re-generates the +implementation file it will warn if an implementation could not be auto- +generated. Delete the indicated portion of the generated code after adding the +implementation manually. + + size_t CEF_CALLBACK frame_new_func(struct _cef_frame_t* self) + { + // BEGIN DELETE BEFORE MODIFYING + // AUTO-GENERATED CONTENT + #pragma message("Warning: "__FILE__": frame_new_func is not implemented") + // END DELETE BEFORE MODIFYING + } + +If the complete function or method implementation has been auto-generated the +body of the function or method will contain the following comment. + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + +If you edit the implementation manually you should remove this comment so that +CEF will not discard your changes on the next run of the translator tool. + +The 'translator.[bat|sh]' file can be used to run the translator tool with +command- line arguments that match the default CEF directory structure and +output options. Run 'translator.py -h' for a complete list of available command- +line arguments. + + +HEADER ATTRIBUTES +----------------- + +Comment-based attribute tags are added before each function, class and method +definition in the CEF header file to provide the translator with additional +information about how the output should be generated. The attribute tags must +be in the form of a comma-delimited list of name=value pairs. Attribute names +and values must contain only alpha-numeric characters, numbers and underscores, +and must all exist on a single line. + + /*--cef(name1=value1,name2=value2,name3=value3)--*/ + +Supported method/function attributes: + + capi_name=[string] (Optional) Force a specific output name for the + resulting C API function. + optional_param=[param] (Optional) Parameter name that will be optional + instead of required. + index_param=[param] (Optional) Parameter name representing an index + value that will be verified as >= 0. + default_retval=[string] (Required for enumeration types, Optional for other + types) Specify the default return value. + count_func=[param:func] (Required for non-const non-string std::vector + types) Specify the C++ function that returns the + count of elements for a vector parameter. + api_hash_check (Optional) If set an API hash check will be added + to the CToCpp version of the method/function. + +Supported class attributes: + + source=[library|client] (Required) Indicates whether the class + implementation is provided by the library or the + client. This effects the generation of guard + blocks in the cpptoc and ctocpp header files. + no_debugct_check (Optional) If set the debug reference count + of the object will not be checked on shutdown. + + +TRANSLATION RULES +----------------- + +All C++ names in the CEF header file are written in CamelCaps format and all +C API translations are generated in lowercase_underscore format. + + +Translating Classes and Methods +------------------------------- + +Class names and global function names must be prefixed with the 'Cef' string. + + Global function translation + C++: void CefShutdown() + C API: void cef_shutdown() + +The translation of a C++ class name to a C API structure name is prefixed with +'_' and postfixed with '_t'. A typedef of the C API structure to a value +without the prefixed '_' is also provided and may be used interchangeably. + + Class name translation + C++: class CefPostData + C API: typedef struct _cef_post_data_t { ... } cef_post_data_t + +The translation of a C++ virtual class method to a C API member function adds a +'self' structure pointer as the first parameter. This will always be a pointer +to the structure that contains the member function. + + Virtual method translation + C++: virtual void SetFocus(bool enable) + C API: void set_focus(struct _cef_browser_t* self, int enable) + +The translation of a C++ static class method to a C API global function +is prefixed with 'cef_classname_' where 'classname' is the +lowercase_underscore name of the class that contains the static method. Any +repeat of 'classname' in the function name is removed. + + Static method translation + C++: static CefRefPtr CreateRequest() + C API: struct _cef_request_t* cef_request_create() + +Implementation of the wrapper method/function body is generally formatted as +follows. + + Static/Global CppToC (without Return): + + CEF_EXPORT void cef_function(capi_params) + { + // Parameter Verification (Optional) + // Verify the C parameter values. + // ... + + // Parameter Translation (Optional) + // Convert C parameter values to C++ parameter values. + // ... + + // Execution + CefFunction(cpp_arams); + + // Parameter Restoration (Optional) + // Retore the C parameter values if changed. + // ... + } + + Static/Global CppToC (with Return): + + CEF_EXPORT capi_retval cef_function(capi_params) + { + // Parameter Verification (Optional) + // Verify the C parameter values. + // ... + + // Parameter Translation (Optional) + // Convert C parameter values to C++ parameter values. + // ... + + // Execution + cpp_retval _rv = CefFunction(cpp_params); + + // Parameter Restoration (Optional) + // Restore the C parameter values if changed. + // ... + + // Return Translation + // Convert the C++ return value to a C return value. + return ...; + } + + Static/Global CToCpp (without Return): + + void CefFunction(cpp_params) + { + // Parameter Verification (Optional) + // Verify the C++ parameter values. + // ... + + // Parameter Translation (Optional) + // Convert C++ parameter values to C parameter values. + // ... + + // Execution + cef_function(capi_params); + + // Parameter Restoration (Optional) + // Restore the C++ parameter values if changed. + // ... + } + + Static/Global CToCpp (with Return): + + cpp_retval CefFunction(cpp_params) + { + // Parameter Verification (Optional) + // Verify the C++ parameter values. + // ... + + // Parameter Translation (Optional) + // Convert C++ parameter values to C parameter values. + // ... + + // Execution + capi_retval _rv = cef_function(capi_params); + + // Parameter Restoration (Optional) + // Restore the C++ parameter values if changed. + // ... + + // Return Translation + // Convert the C return value to a C++ return value. + return ...; + } + + Member CppToC (without Return): + + CEF_CALLBACK void class_function(cef_class_t* self, capi_params) + { + // Parameter Verification. + // Verify the C parameter values. + DCHECK(self); + DCHECK(...); + if (!self || ...) + return; + + // Parameter Translation (Optional) + // Convert the C parameter values to C++ parameter values. + // ... + + // Execution + CefClassCppToC::Get(self)->CefFunction(cpp_params); + + // Parameter Restoration (Optional) + // Restore the C parameter values if changed. + // ... + } + + Member CppToC (with Return): + + CEF_CALLBACK capi_retval class_function(cef_class_t* self, capi_params) + { + // Parameter Verification. + // Verify the C parameter values. + DCHECK(self); + DCHECK(...); + if (!self || ...) + return default_retval; // Configured or defaulted automatically. + + // Parameter Translation (Optional) + // Convert the C parameter values to C++ parameter values. + // ... + + // Execution + cpp_retval _rv = CefClassCppToC::Get(self)->CefFunction(cpp_params); + + // Parameter Restoration (Optional) + // Restore the C parameter values if changed. + // ... + + // Return Translation + // Convert the C++ return value to a C return value. + return ...; + } + + Member CToCpp (without Return): + + void CefClassCToCpp::Function(cpp_params) + { + // Structure Verification + if (CEF_MEMBER_MISSING(struct_, function)) + return; + + // Parameter Verification (Optional) + // Verify the C++ parameter values. + // ... + + // Parameter Translation (Optional) + // Convert C++ parameter values to C parameter values. + // ... + + // Execution + struct_->class_function(struct_, capi_params); + + // Parameter Restoration (Optional) + // Restore the C++ parameter values if changed. + // ... + } + + Member CToCpp (with Return): + + cpp_retval CefClassCToCpp::Function(cpp_params) + { + // Structure Verification + if (CEF_MEMBER_MISSING(struct_, function)) + return default_retval; // Configured or defaulted automatically. + + // Parameter Verification (Optional) + // Verify the C++ parameter values. + // ... + + // Parameter Translation (Optional) + // Convert C++ parameter values to C parameter values. + // ... + + // Execution + capi_retval _rv = struct_->class_function(struct_, capi_params); + + // Parameter Restoration (Optional) + // Restore the C++ parameter values if changed. + // ... + + // Return Translation + // Convert the C return value to a C++ return value. + return ...; + } + + +Translating Data Types +---------------------- + +Data types that are available in both C++ and C are left unchanged. This +includes the 'double', 'int', 'long', 'size_t' and 'void' basic types. Other +data types have differing levels of support as indicated below. The translation +tool will terminate with an exception if it encounters a data type that it +cannot translate. + +Parameters: + + Simple/enumeration type by value (simple_byval): + C++: int value + C API: int value + + // CppToC Example + CEF_EXPORT void cef_function(int value) + { + // Execution + CefFunction(value); + } + + // CToCpp Example + void CefFunction(int value) + { + // Execution + cef_function(value); + } + + Simple/enumeration type by reference (simple_byref): + C++: int& value + C API: int* value + + // CppToC Example + CEF_EXPORT void cef_function(int* value) + { + // Parameter Verification + DHECK(value); + if (!value) + return; + + // Parameter Translation + int valueVal = value?*value:0; + + // Execution + CefFunction(valueVal); + + // Parameter Restoration + if (value) + *value = valueVal; + } + + // CToCpp Example + void CefFunction(int& value) + { + // Execution + cef_function(&value); + } + + Simple/enumeration const type by reference (simple_byref_const): + C++: const int& value + C API: const int* value + + // CppToC Example + CEF_EXPORT void cef_function(const int* value) + { + // Parameter Verification + DHECK(value); + if (!value) + return; + + // Parameter Translation + int valueVal = value?*value:0; + + // Execution + CefFunction(valueVal); + } + + // CToCpp Example + void CefFunction(const int& value) + { + // Execution + cef_function(&value); + } + + Simple/enumeration type by address (simple_byaddr): + C++: int* value + C API: int* value + + // CppToC Example + CEF_EXPORT void cef_function(int* value) + { + // Parameter Verification + DHECK(value); + if (!value) + return; + + // Execution + CefFunction(value); + } + + // CToCpp Example + void CefFunction(int* value) + { + // Parameter Verification + DHECK(value); + if (!value) + return; + + // Execution + cef_function(value); + } + + Boolean type by value (bool_byval): + C++: bool value + C API: int value + + // CppToC Example + CEF_EXPORT void cef_function(int value) + { + // Execution + CefFunction(value?true:false); + } + + // CToCpp Example + void CefFunction(bool value) + { + // Execution + cef_function(value); + } + + Boolean type by reference (bool_byref): + C++: bool& value + C API: int* value + + // CppToC Example + CEF_EXPORT void cef_function(int* value) + { + // Parameter Verification + DHECK(value); + if (!value) + return; + + // Parameter Translation + bool valueBool = (value && *value)?true:false; + + // Execution + CefFunction(valueBool); + + // Parameter Restoration + if (value) + *value = valueBool?true:false; + } + + // CToCpp Example + void CefFunction(bool& value) + { + // Parameter Translation + int valueInt = value; + + // Execution + cef_function(&valueInt); + + // Parameter Restoration + value = valueInt?true:false; + } + + Boolean type by address (bool_byaddr): + C++: bool* value + C API: int* value + + // CppToC Example + CEF_EXPORT void cef_function(int* value) + { + // Parameter Verification + DHECK(value); + if (!value) + return; + + // Parameter Translation + bool valueBool = (value && *value)?true:false; + + // Execution + CefFunction(&valueBool); + + // Parameter Restoration + if (value) + *value = valueBool?true:false; + } + + // CToCpp Example + void CefFunction(bool* value) + { + // Parameter Verification + DHECK(value); + if (!value) + return; + + // Parameter Translation + int valueInt = value?*value:0; + + // Execution + cef_function(&valueInt); + + // Parameter Restoration + if (value) + *value = valueInt?true:false; + } + + Structure const type by reference (struct_byref_const): + C++: const CefPopupFeatures& value + C API: const cef_popup_features_t* value + + // CppToC Example + CEF_EXPORT void cef_function(const cef_popup_features_t* value) + { + // Parameter Verification + DHECK(value); + if (!value) + return; + + // Parameter Translation + CefPopupFeatures valueObj; + // Reference the existing values instead of copying. + if (value) + valueObj.Set(*value, false); + + // Execution + CefFunction(valueObj); + } + + // CToCpp Example + void CefFunction(const CefPopupFeatures& value) + { + // Execution + cef_function(&value); + } + + Structure non-const type by reference (struct_byref): + C++: CefWindowInfo& value + C API: cef_window_info_t* value + + // CppToC Example + CEF_EXPORT void cef_function(cef_window_info_t* value) + { + // Parameter Verification + DHECK(value); + if (!value) + return; + + // Parameter Translation + CefWindowInfo valueObj; + // Take ownership of the values. + if (value) + valueObj.AttachTo(*value); + + // Execution + CefFunction(valueObj); + + // Parameter Restoration + // Return the values to the structure. + if (value) + valueObj.DetachTo(*value); + } + + // CToCpp Example + void CefFunction(CefWindowInfo& value) + { + // Execution + cef_function(&value); + } + + String const type by reference (string_byref_const): + C++: const CefString& value + C API: const cef_string_t* value + + // CppToC Example + CEF_EXPORT void cef_function(const cef_string_t* value) + { + // Parameter Verification + DHECK(value); + if (!value) + return; + + // Execution + CefFunction(CefString(value)); + } + + // CToCpp Example + void CefFunction(const CefString& value) + { + // Execution + cef_function(value.GetStruct()); + } + + String non-const type by reference (string_byref): + C++: CefString& value + C API: cef_string_t* value + + // CppToC Example + CEF_EXPORT void cef_function(cef_string_t* value) + { + // Parameter Verification + DHECK(value); + if (!value) + return; + + // Parameter Translation + CefString valueStr(value); + + // Execution + CefFunction(valueStr); + } + + // CToCpp Example + void CefFunction(CefString& value) + { + // Execution + cef_function(value.GetWritableStruct()); + } + + Smart pointer type same boundary side (refptr_same): + C++: CefRefPtr value + C API: cef_browser_t* value + + // CppToC Example + CEF_EXPORT void cef_function(cef_browser_t* value) + { + // Parameter Verification + DHECK(value); + if (!value) + return; + + // Execution + CefFunction(CefBrowserCppToC::Unwrap(value)); + } + + // CToCpp Example + void CefFunction(CefRefPtr value) + { + // Execution + cef_function(CefBrowserCToCpp::Unwrap(value)); + } + + Smart pointer type same boundary side by reference (refptr_same_byref): + C++: CefRefPtr& value + C API: cef_client_t** value + + // CppToC Example + CEF_EXPORT void cef_function(cef_client_t** value) + { + // Parameter Verification + DHECK(value); + if (!value) + return; + + // Parameter Translation + CefRefPtr valuePtr; + if (value && *value) + valuePtr = CefClientCppToC::Unwrap(*value); + CefClient* valueOrig = valuePtr.get(); + + // Execution + CefFunction(valuePtr); + + // Parameter Restoration + if (value) { + if (valuePtr.get()) { + if (valuePtr.get() != valueOrig) { + // The value has been changed. + *value = CefClientCppToC::Wrap(valuePtr); + } + } else { + *value = NULL; + } + } + } + + // CToCpp Example + void CefFunction(CefRefPtr& value) + { + // Parameter Translation + cef_client_t* valueStruct = NULL; + if(value.get()) + valueStruct = CefClientCToCpp::Unwrap(value); + cef_client_t* valueOrig = valueStruct; + + // Execution + cef_function(valueStuct); + + // Parameter Restoration + if (valueStruct) { + if (valueStruct != valueOrig) { + // The value was changed. + value = CefClientCToCpp::Wrap(valueStruct); + } + } else { + value = NULL; + } + } + + Smart pointer type different boundary side (refptr_diff): + C++: CefRefPtr value + C API: cef_browser_t* value + + // CppToC Example + CEF_EXPORT void cef_function(cef_browser_t* value) + { + // Parameter Verification + DHECK(value); + if (!value) + return; + + // Execution + CefFunction(CefBrowserCToCpp::Wrap(value)); + } + + // CToCpp Example + void CefFunction(CefRefPtr value) + { + // Execution + cef_function(CefBrowserCppToC::Wrap(value)); + } + + Smart pointer type different boundary side by reference (refptr_diff_byref): + C++: CefRefPtr& value + C API: cef_client_t** value + + // CppToC Example + CEF_EXPORT void cef_function(cef_client_t** value) + { + // Parameter Verification + DHECK(value); + if (!value) + return; + + // Parameter Translation + CefRefPtr valuePtr; + if (value && *value) + valuePtr = CefClientCToCpp::Wrap(*value); + CefClient* valueOrig = valuePtr.get(); + + // Execution + CefFunction(valuePtr); + + // Parameter Restoration + if (value) { + if (valuePtr.get()) { + if (valuePtr.get() != valueOrig) { + // The value has been changed. + *value = CefClientCToCpp::Unwrap(valuePtr); + } + } else { + *value = NULL; + } + } + } + + // CToCpp Example + void CefFunction(CefRefPtr& value) + { + // Parameter Translation + cef_client_t* valueStruct = NULL; + if(value.get()) + valueStruct = CefClientCppToC::Wrap(value); + cef_client_t* valueOrig = valueStruct; + + // Execution + cef_function(valueStuct); + + // Parameter Restoration + if (valueStruct) { + if (valueStruct != valueOrig) { + // The value was changed. + value = CefClientCppToC::Unwrap(valueStruct); + } + } else { + value = NULL; + } + } + + String vector type by reference (string_vec_byref): + C++: std::vector& value + C API: cef_string_list_t value + + // CppToC Example + CEF_EXPORT void cef_function(cef_string_list_t value) + { + // Parameter Verification + DHECK(value); + if (!value) + return; + + // Parameter Translation + std::vector valueList; + transfer_string_list_contents(value, valueList); + + // Execution + CefFunction(valueList); + + // Parameter Restoration + cef_string_list_clear(value); + transfer_string_list_contents(valueList, value); + } + + // CToCpp Example + void CefFunction(std::vector& value) + { + // Parameter Translation + cef_string_list_t valueList = cef_string_list_alloc(); + DCHECK(valueList); + if (valueList) + transfer_string_list_contents(value, valueList); + + // Execution + cef_function(valueList); + + // Parameter Restoration + if (valueList) { + value.clear(); + transfer_string_list_contents(valueList, value); + cef_string_list_free(valueList); + } + } + + String vector const type by reference (string_vec_byref_const): + C++: const std::vector& value + C API: cef_string_list_t value + + // CppToC Example + CEF_EXPORT void cef_function(cef_string_list_t value) + { + // Parameter Verification + DHECK(value); + if (!value) + return; + + // Parameter Translation + std::vector valueList; + transfer_string_list_contents(value, valueList); + + // Execution + CefFunction(valueList); + } + + // CToCpp Example + void CefFunction(const std::vector& value) + { + // Parameter Translation + cef_string_list_t valueList = cef_string_list_alloc(); + DCHECK(valueList); + if (valueList) + transfer_string_list_contents(value, valueList); + + // Execution + cef_function(valueList); + + // Parameter Restoration + if (valueList) + cef_string_list_free(valueList); + } + + String-to-string single map type by reference (string_map_single_byref): + C++: std::map& value + C API: cef_string_map_t value + + // CppToC Example + CEF_EXPORT void cef_function(cef_string_map_t value) + { + // Parameter Verification + DHECK(value); + if (!value) + return; + + // Parameter Translation + std::map valueMap; + transfer_string_map_contents(value, valueMap); + + // Execution + CefFunction(valueMap); + + // Parameter Restoration + cef_string_map_clear(value); + transfer_string_map_contents(valueMap, value); + } + + // CToCpp Example + void CefFunction(std::map& value) + { + // Parameter Translation + cef_string_map_t valueMap = cef_string_map_alloc(); + DCHECK(valueMap); + if (valueMap) + transfer_string_map_contents(value, valueMap); + + // Execution + cef_function(valueMap); + + // Parameter Restoration + if (valueMap) { + value.clear(); + transfer_string_map_contents(valueMap, value); + cef_string_map_free(valueMap); + } + } + + String-to-string single map const type by reference + (string_map_single_byref_const): + C++: const std::map& value + C API: cef_string_map_t value + + // CppToC Example + CEF_EXPORT void cef_function(cef_string_map_t value) + { + // Parameter Verification + DHECK(value); + if (!value) + return; + + // Parameter Translation + std::map valueMap; + transfer_string_map_contents(value, valueMap); + + // Execution + CefFunction(valueMap); + } + + // CToCpp Example + void CefFunction(const std::map& value) + { + // Parameter Translation + cef_string_map_t valueMap = cef_string_map_alloc(); + DCHECK(valueMap); + if (valueMap) + transfer_string_map_contents(value, valueMap); + + // Execution + cef_function(valueMap); + + // Parameter Restoration + if (valueMap) + cef_string_map_free(valueMap); + } + + String-to-string multi map type by reference (string_map_multi_byref): + C++: std::multimap& value + C API: cef_string_multimap_t value + + // CppToC Example + CEF_EXPORT void cef_function(cef_string_multimap_t value) + { + // Parameter Verification + DHECK(value); + if (!value) + return; + + // Parameter Translation + std::multimap valueMultimap; + transfer_string_multimap_contents(value, valueMultimap); + + // Execution + CefFunction(valueMultimap); + + // Parameter Restoration + cef_string_multimap_clear(value); + transfer_string_multimap_contents(valueMultimap, value); + } + + // CToCpp Example + void CefFunction(std::multimap& value) + { + // Parameter Translation + cef_string_multimap_t valueMultimap = cef_string_multimap_alloc(); + DCHECK(valueMultimap); + if (valueMultimap) + transfer_string_multimap_contents(value, valueMultimap); + + // Execution + cef_function(valueMultimap); + + // Parameter Restoration + if (valueMultimap) { + value.clear(); + transfer_string_multimap_contents(valueMultimap, value); + cef_string_multimap_free(valueMultimap); + } + } + + String-to-string multi map const type by reference + (string_map_multi_byref_const): + C++: const std::multimap& value + C API: cef_string_multimap_t value + + // CppToC Example + CEF_EXPORT void cef_function(cef_string_multimap_t value) + { + // Parameter Verification + DHECK(value); + if (!value) + return; + + // Parameter Translation + std::multimap valueMultimap; + transfer_string_multimap_contents(value, valueMultimap); + + // Execution + CefFunction(valueMultimap); + } + + // CToCpp Example + void CefFunction(const std::multimap& value) + { + // Parameter Translation + cef_string_multimap_t valueMultimap = cef_string_multimap_alloc(); + DCHECK(valueMultimap); + if (valueMultimap) + transfer_string_multimap_contents(value, valueMultimap); + + // Execution + cef_function(valueMultimap); + + // Parameter Restoration + if (valueMultimap) + cef_string_multimap_free(valueMultimap); + } + + Simple/Enumeration vector non-const type by reference (simple_vec_byref): + C++: std::vector& value + C API: size_t* valueCount, int* value + + // CppToC Example + CEF_EXPORT void cef_function(size_t* valueCount, int* value) + { + // Parameter Verification + DCHECK(valueCount && (*valueCount == 0 || value)); + if (!valueCount || (*valueCount > 0 && !value)) + return; + + // Parameter Translation + std::vector valueList; + if (valueCount && *valueCount > 0 && value) { + for (size_t i = 0; i < *valueCount; ++i) + valueList.push_back(value[i]); + } + + // Execution + CefFunction(valueList); + + // Parameter Restoration + if (valueCount && value) { + *valueCount = std::min(valueList.size(), *valueCount); + if (*valueCount > 0) { + for (size_t i = 0; i < *valueCount; ++i) + value[i] = valueList[i]; + } + } + } + + // CToCpp Example + void CefFunction(std::vector& value) + { + // Parameter Translation + // Function identified by the "count_func" method attribute. + size_t valueSize = value.size(); + size_t valueCount = std::max(GetFunctionCount(), valueSize); + int* valueList = NULL; + if (valueCount > 0) { + valueList = new int[valueCount]; + DCHECK(valueList); + if (valueList) + memset(valueList, 0, sizeof(int)*valueCount); + if (valueList && valueSize > 0) { + for (size_t i = 0; i < valueSize; ++i) { + valueList[i] = value[i]; + } + } + } + + // Execution + cef_function(&valueCount, valueList); + + // Parameter Restoration + value.clear(); + if (valueCount > 0 && valueList) { + for (size_t i = 0; i < valueCount; ++i) + value.push_back(valueList[i]); + delete [] valueList; + } + } + + Simple/Enumeration vector const type by reference (simple_vec_byref_const): + C++: const std::vector& value + C API: size_t valueCount, int const* value + + // CppToC Example + CEF_EXPORT void cef_function(size_t valueCount, int const* value) + { + // Parameter Verification + DCHECK(valueCount == 0 || value); + if (valueCount > 0 && !value) + return; + + // Parameter Translation + std::vector valueList; + if (valueCount > 0) { + for (size_t i = 0; i < valueCount; ++i) + valueList.push_back(value[i]); + } + + // Execution + CefFunction(valueList); + } + + // CToCpp Example + void CefFunction(const std::vector& value) + { + // Parameter Translation + const size_t valueCount = value.size(); + int* valueList = NULL; + if (valueCount > 0) { + valueList = new int[valueCount]; + DCHECK(valueList); + if (valueList) { + for (size_t i = 0; i < valueCount; ++i) + valueList[i] = value[i]; + } + } + + // Execution + cef_function(valueCount, valueList); + + // Parameter Restoration + if (valueList) + delete [] valueList; + } + + Boolean vector non-const type by reference (bool_vec_byref): + C++: std::vector& value + C API: size_t* valueCount, int* value + + // CppToC Example + CEF_EXPORT void cef_function(size_t* valueCount, int* value) + { + // Parameter Verification + DCHECK(valueCount && (*valueCount == 0 || value)); + if (!valueCount || (*valueCount > 0 && !value)) + return; + + // Parameter Translation + std::vector valueList; + if (valueCount && *valueCount > 0 && value) { + for (size_t i = 0; i < *valueCount; ++i) + valueList.push_back(value[i]?true:false); + } + + // Execution + CefFunction(valueList); + + // Parameter Restoration + if (valueCount && value) { + *valueCount = std::min(valueList.size(), *valueCount); + if (*valueCount > 0) { + for (size_t i = 0; i < *valueCount; ++i) + value[i] = valueList[i]; + } + } + } + + // CToCpp Example + void CefFunction(std::vector& value) + { + // Parameter Translation + // Function identified by the "count_func" method attribute. + size_t valueSize = value.size(); + size_t valueCount = std::max(GetFunctionCount(), valueSize); + int* valueList = NULL; + if (valueCount > 0) { + valueList = new int[valueCount]; + DCHECK(valueList); + if (valueList) + memset(valueList, 0, sizeof(int)*valueCount); + if (valueList && valueSize > 0) { + for (size_t i = 0; i < valueSize; ++i) { + valueList[i] = value[i]; + } + } + } + + // Execution + cef_function(&valueCount, valueList); + + // Parameter Restoration + value.clear(); + if (valueCount > 0 && valueList) { + for (size_t i = 0; i < valueCount; ++i) + value.push_back(valueList[i]?true:false); + delete [] valueList; + } + } + + Boolean vector const type by reference (bool_vec_byref_const): + C++: const std::vector& value + C API: size_t valueCount, int const* value + + // CppToC Example + CEF_EXPORT void cef_function(size_t valueCount, int const* value) + { + // Parameter Verification + DCHECK(valueCount == 0 || value); + if (valueCount > 0 && !value) + return; + + // Parameter Translation + std::vector valueList; + if (valueCount > 0) { + for (size_t i = 0; i < valueCount; ++i) + valueList.push_back(value[i]?true:false); + } + + // Execution + CefFunction(valueList); + } + + // CToCpp Example + void CefFunction(const std::vector& value) + { + // Parameter Translation + const size_t valueCount = value.size(); + int* valueList = NULL; + if (valueCount > 0) { + valueList = new int[valueCount]; + DCHECK(valueList) + if (valueList) { + for (size_t i = 0; i < valueCount; ++i) + valueList[i] = value[i]; + } + } + + // Execution + cef_function(valueCount, valueList); + + // Parameter Restoration + if (valueList) + delete [] valueList; + } + + Smart pointer vector non-const type same boundary side by reference + (refptr_vec_same_byref): + C++: std::vector>& value + C API: size_t* valueCount, cef_post_data_element_t** value + + // CppToC Example + CEF_EXPORT void cef_function(size_t* valueCount, + cef_post_data_element_t** value) + { + // Parameter Verification + DCHECK(valueCount && (*valueCount == 0 || value)); + if (!valueCount || (*valueCount > 0 && !value)) + return; + + // Parameter Translation + std::vector> valueList; + if (valueCount && *valueCount > 0 && value) { + for (size_t i = 0; i < *valueCount; ++i) + valueList.push_back(CefPostDataElementCppToC::Unwrap(value[i])); + } + + // Execution + CefFunction(valueList); + + // Parameter Restoration + if (valueCount && value) { + *valueCount = std::min(valueList.size(), *valueCount); + if (*valueCount > 0) { + for (size_t i = 0; i < *valueCount; ++i) + value[i] = CefPostDataElementCppToC::Wrap(valueList[i]); + } + } + } + + // CToCpp Example + void CefFunction(std::vector& value) + { + // Parameter Translation + // Function identified by the "count_func" method attribute. + size_t valueSize = value.size(); + size_t valueCount = std::max(GetFunctionCount(), valueSize); + cef_post_data_element_t** valueList = NULL; + if (valueCount > 0) { + valueList = new cef_post_data_element_t*[valueCount]; + DCHECK(valueList); + if (valueList) + memset(valueList, 0, sizeof(cef_post_data_element_t*)*valueCount); + if (valueList && valueSize > 0) { + for (size_t i = 0; i < valueSize; ++i) { + valueList[i] = CefPostDataElementCToCpp::Unwrap(value[i]); + } + } + } + + // Execution + cef_function(&valueCount, valueList); + + // Parameter Restoration + value.clear(); + if (valueCount > 0 && valueList) { + for (size_t i = 0; i < valueCount; ++i) + value.push_back(CefPostDataElementCToCpp::Wrap(valueList[i])); + delete [] valueList; + } + } + + Smart pointer vector const type same boundary side by reference + (refptr_vec_same_byref_const): + C++: const std::vector>& value + C API: size_t valueCount, const cef_v8value_t** value + + // CppToC Example + CEF_EXPORT void cef_function(size_t valueCount, + const cef_v8value_t** value) + { + // Parameter Verification + DCHECK(valueCount == 0 || value); + if (valueCount > 0 && !value) + return; + + // Parameter Translation + std::vector> valueList; + if (valueCount > 0) { + for (size_t i = 0; i < valueCount; ++i) + valueList.push_back(CefV8ValueCppToC::Unwrap(value[i])); + } + + // Execution + CefFunction(valueList); + } + + // CToCpp Example + void CefFunction(const std::vector& value) + { + // Parameter Translation + const size_t valueCount = value.size(); + cef_v8value_t** valueList = NULL; + if (valueCount > 0) { + valueList = new int[valueCount]; + DCHECK(valueList); + if (valueList) { + for (size_t i = 0; i < valueCount; ++i) + valueList[i] = CefV8ValueCToCpp::Unwrap(value[i]); + } + } + + // Execution + cef_function(valueCount, valueList); + + // Parameter Restoration + if (valueList) + delete [] valueList; + } + + Smart pointer vector non-const type different boundary side by reference + (refptr_vec_diff_byref): + C++: std::vector>& value + C API: size_t* valueCount, cef_post_data_element_t** value + + // CppToC Example + CEF_EXPORT void cef_function(size_t* valueCount, + cef_post_data_element_t** value) + { + // Parameter Verification + DCHECK(valueCount && (*valueCount == 0 || value)); + if (!valueCount || (*valueCount > 0 && !value)) + return; + + // Parameter Translation + std::vector> valueList; + if (valueCount && *valueCount > 0 && value) { + for (size_t i = 0; i < *valueCount; ++i) + valueList.push_back(CefPostDataElementCToCpp::Wrap(value[i])); + } + + // Execution + CefFunction(valueList); + + // Parameter Restoration + if (valueCount && value) { + *valueCount = std::min(valueList.size(), *valueCount); + if (*valueCount > 0) { + for (size_t i = 0; i < *valueCount; ++i) + value[i] = CefPostDataElementCToCpp::Unwrap(valueList[i]); + } + } + } + + // CToCpp Example + void CefFunction(std::vector& value) + { + // Parameter Translation + // Function identified by the "count_func" method attribute. + size_t valueSize = value.size(); + size_t valueCount = std::max(GetFunctionCount(), valueSize); + cef_post_data_element_t** valueList = NULL; + if (valueCount > 0) { + valueList = new cef_post_data_element_t*[valueCount]; + DCHECK(valueList); + if (valueList) + memset(valueList, 0, sizeof(cef_post_data_element_t*)*valueCount); + if (valueList && valueSize > 0) { + for (size_t i = 0; i < valueSize; ++i) { + valueList[i] = CefPostDataElementCppToC::Wrap(value[i]); + } + } + } + + // Execution + cef_function(&valueCount, valueList); + + // Parameter Restoration + value.clear(); + if (valueCount > 0 && valueList) { + for (size_t i = 0; i < valueCount; ++i) + value.push_back(CefPostDataElementCppToC::Unwrap(valueList[i])); + delete [] valueList; + } + } + + Smart pointer vector const type different boundary side by reference + (refptr_vec_diff_byref_const): + C++: const std::vector>& value + C API: size_t valueCount, const cef_v8value_t** value + + // CppToC Example + CEF_EXPORT void cef_function(size_t valueCount, + const cef_v8value_t** value) + { + // Parameter Verification + DCHECK(valueCount == 0 || value); + if (valueCount > 0 && !value) + return; + + // Parameter Translation + std::vector> valueList; + if (valueCount > 0) { + for (size_t i = 0; i < valueCount; ++i) + valueList.push_back(CefV8ValueCToCpp::Wrap(value[i])); + } + + // Execution + CefFunction(valueList); + } + + // CToCpp Example + void CefFunction(const std::vector& value) + { + // Parameter Translation + const size_t valueCount = value.size(); + cef_v8value_t** valueList = NULL; + if (valueCount > 0) { + valueList = new int[valueCount]; + DCHECK(valueList); + if (valueList) { + for (size_t i = 0; i < valueCount; ++i) + valueList[i] = CefV8ValueCppToC::Wrap(value[i]); + } + } + + // Execution + cef_function(valueCount, valueList); + + // Parameter Restoration + if (valueList) + delete [] valueList; + } + +Return Values: + + Simple/Enumeration type (simple): + C++: int + C API: int + + // CppToC Example + CEF_EXPORT int cef_function() + { + // Execution + int _rv = CefFunction(); + + // Return Translation + return _rv; + } + + // CToCpp Example + int CefFunction() + { + // Execution + int _rv = cef_function(); + + // Return Translation + return _rv; + } + + Boolean type (bool): + C++: bool + C API: int + + // CppToC Example + CEF_EXPORT int cef_function() + { + // Execution + bool _rv = CefFunction(); + + // Return Translation + return _rv; + } + + // CToCpp Example + bool CefFunction() + { + // Execution + int _rv = cef_function(); + + // Return Translation + return _rv?true:false; + } + + String non-const by reference type (string): + C++: CefString + C API: cef_string_userfree_t + + // CppToC Example + CEF_EXPORT cef_string_userfree_t cef_function() + { + // Execution + CefString _rv = CefFunction(); + + // Return Translation + return _rv.DetachToUserFree(); + } + + // CToCpp Example + CefString CefFunction() + { + // Execution + cef_string_userfree_t _rv = cef_function(); + + // Return Translation + CefString _rvStr; + _rvStr.AttachToUserFree(_rv); + return _rvStr; + } + + Smart pointer type same boundary side (refptr_same): + C++: CefRefPtr + C API: cef_browser_t* + + // CppToC Example + CEF_EXPORT cef_browser_t* cef_function() + { + // Execution + CefRefPtr _rv = CefFunction(); + + // Return Translation + return CefBrowserCppToC::Wrap(_rv); + } + + // CToCpp Example + CefString CefFunction() + { + // Execution + cef_browser_t* _rv = cef_function(); + + // Return Translation + return CefBrowserCToCpp::Wrap(_rv); + } + + Smart pointer type different boundary side (refptr_diff): + C++: CefRefPtr + C API: cef_browser_t* + + // CppToC Example + CEF_EXPORT cef_browser_t* cef_function() + { + // Execution + CefRefPtr _rv = CefFunction(); + + // Return Translation + return CefBrowserCToCpp::Unwrap(_rv); + } + + // CToCpp Example + CefString CefFunction() + { + // Execution + cef_browser_t* _rv = cef_function(); + + // Return Translation + return CefBrowserCppToC::Unwrap(_rv); + } + + +Translating Comments +-------------------- + +Comments from the CEF header file are reproduced in the C API header file with +any referenced C++ types and terminology changed to reflect C API types and +terminology. + +C++: +// Create a new CefV8Value object of the specified type. These methods +// should only be called from within the JavaScript context -- either in a +// CefV8Handler::Execute() callback or a CefHandler::HandleJSBinding() +// callback. + +C API: +// Create a new cef_v8value_t object of the specified type. These functions +// should only be called from within the JavaScript context -- either in a +// cef_v8handler_t::execute() callback or a cef_handler_t::handle_jsbinding() +// callback. + +Situations where the user is responsible for freeing strings allocated and +returned by the library are also noted by comments in the C API header file. + +C API: + // The resulting string must be freed by calling cef_string_free(). + +A comment must occur immediately before the function, class or method that it +documents with no extra space in between. Comments may span multiple lines +but each line must start with the '//' comment identifier. + +C++: + // Set focus for the browser window. If |enable| is true focus will be set + // to the window. Otherwise, focus will be removed. + /*--cef()--*/ + virtual void SetFocus(bool enable) =0; + +If two comments are separated by an empty line it will be assumed that the +higher comment represents a section header and additional space will be added +before it in the translated output. + +C++: + // ARRAY METHODS - These methods are only available on arrays. + + // Returns the number of elements in the array. + /*--cef()--*/ + virtual int GetArrayLength() =0; + +Empty lines and lines with the comment identifier but no content are considered +paragraph breaks for the purposes of wrapping the translated text. Any content +indented more than one space is reproduced as-is without content translation +or wrapping. + +C++: +// Register a new V8 extension with the specified JavaScript extension code and +// handler. Functions implemented by the handler are prototyped using the +// keyword 'native'. The calling of a native function is restricted to the scope +// in which the prototype of the native function is defined. +// +// Example JavaScript extension code: +// +// // create the 'example' global object if it doesn't already exist. +// if (!example) +// example = {}; diff --git a/cef3/tools/translator.bat b/cef3/tools/translator.bat new file mode 100644 index 000000000..44b80f385 --- /dev/null +++ b/cef3/tools/translator.bat @@ -0,0 +1,3 @@ +@echo off +..\..\third_party\python_26\python.exe translator.py --cpp-header-dir ..\include --capi-header-dir ..\include\capi --cpptoc-global-impl ..\libcef_dll\libcef_dll.cc --ctocpp-global-impl ..\libcef_dll\wrapper\libcef_dll_wrapper.cc --cpptoc-dir ..\libcef_dll\cpptoc --ctocpp-dir ..\libcef_dll\ctocpp --gypi-file ..\cef_paths.gypi +pause \ No newline at end of file diff --git a/cef3/tools/translator.py b/cef3/tools/translator.py new file mode 100644 index 000000000..ab8b584c3 --- /dev/null +++ b/cef3/tools/translator.py @@ -0,0 +1,163 @@ +# Copyright (c) 2009 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. + +import sys +from cef_parser import * +from make_capi_header import * +from make_cpptoc_header import * +from make_cpptoc_impl import * +from make_ctocpp_header import * +from make_ctocpp_impl import * +from make_gypi_file import * +from optparse import OptionParser + + +# cannot be loaded as a module +if __name__ != "__main__": + sys.stderr.write('This file cannot be loaded as a module!') + sys.exit() + + +# parse command-line options +disc = """ +This utility generates files for the CEF C++ to C API translation layer. +""" + +parser = OptionParser(description=disc) +parser.add_option('--cpp-header-dir', dest='cppheaderdir', metavar='DIR', + help='input directory for C++ header files [required]') +parser.add_option('--capi-header-dir', dest='capiheaderdir', metavar='DIR', + help='output directory for C API header files') +parser.add_option('--cpptoc-global-impl', dest='cpptocglobalimpl', metavar='FILE', + help='input/output file for CppToC global translations') +parser.add_option('--ctocpp-global-impl', dest='ctocppglobalimpl', metavar='FILE', + help='input/output file for CppToC global translations') +parser.add_option('--cpptoc-dir', dest='cpptocdir', metavar='DIR', + help='input/output directory for CppToC class translations') +parser.add_option('--ctocpp-dir', dest='ctocppdir', metavar='DIR', + help='input/output directory for CppToC class translations') +parser.add_option('--gypi-file', dest='gypifile', metavar='FILE', + help='output file for path information') +parser.add_option('--no-cpptoc-header', + action='store_true', dest='nocpptocheader', default=False, + help='do not output the CppToC headers') +parser.add_option('--no-cpptoc-impl', + action='store_true', dest='nocpptocimpl', default=False, + help='do not output the CppToC implementations') +parser.add_option('--no-ctocpp-header', + action='store_true', dest='noctocppheader', default=False, + help='do not output the CToCpp headers') +parser.add_option('--no-ctocpp-impl', + action='store_true', dest='noctocppimpl', default=False, + help='do not output the CToCpp implementations') +parser.add_option('--no-backup', + action='store_true', dest='nobackup', default=False, + help='do not create a backup of modified files') +parser.add_option('-c', '--classes', dest='classes', action='append', + help='only translate the specified classes') +parser.add_option('-q', '--quiet', + action='store_true', dest='quiet', default=False, + help='do not output detailed status information') +(options, args) = parser.parse_args() + +# the cppheader option is required +if options.cppheaderdir is None: + parser.print_help(sys.stdout) + sys.exit() + +# make sure the header exists +if not path_exists(options.cppheaderdir): + sys.stderr.write('File '+options.cppheaderdir+' does not exist.') + sys.exit() + +# create the header object +if not options.quiet: + sys.stdout.write('Parsing C++ headers from '+options.cppheaderdir+'...\n') +header = obj_header() +header.add_directory(options.cppheaderdir) + +writect = 0 + +if not options.capiheaderdir is None: + #output the C API header + if not options.quiet: + sys.stdout.write('In C API header directory '+options.capiheaderdir+'...\n') + filenames = sorted(header.get_file_names()) + for filename in filenames: + if not options.quiet: + sys.stdout.write('Generating '+filename+' C API header...\n') + writect += write_capi_header(header, + os.path.join(options.capiheaderdir, filename), + not options.nobackup) + +# build the list of classes to parse +allclasses = header.get_class_names() +if not options.classes is None: + for cls in options.classes: + if not cls in allclasses: + sys.stderr.write('ERROR: Unknown class: '+cls) + sys.exit() + classes = options.classes +else: + classes = allclasses + +classes = sorted(classes) + +if not options.cpptocglobalimpl is None: + # output CppToC global file + if not options.quiet: + sys.stdout.write('Generating CppToC global implementation...\n') + writect += write_cpptoc_impl(header, None, options.cpptocglobalimpl, \ + not options.nobackup) + +if not options.ctocppglobalimpl is None: + # output CToCpp global file + if not options.quiet: + sys.stdout.write('Generating CToCpp global implementation...\n') + writect += write_ctocpp_impl(header, None, options.ctocppglobalimpl, \ + not options.nobackup) + +if not options.cpptocdir is None: + # output CppToC class files + if not options.quiet: + sys.stdout.write('In CppToC directory '+options.cpptocdir+'...\n') + + for cls in classes: + if not options.nocpptocheader: + if not options.quiet: + sys.stdout.write('Generating '+cls+'CppToC class header...\n') + writect += write_cpptoc_header(header, cls, options.cpptocdir, + not options.nobackup) + if not options.nocpptocimpl: + if not options.quiet: + sys.stdout.write('Generating '+cls+'CppToC class implementation...\n') + writect += write_cpptoc_impl(header, cls, options.cpptocdir, + not options.nobackup) + +if not options.ctocppdir is None: + # output CppToC class files + if not options.quiet: + sys.stdout.write('In CToCpp directory '+options.ctocppdir+'...\n') + for cls in classes: + if not options.nocpptocheader: + if not options.quiet: + sys.stdout.write('Generating '+cls+'CToCpp class header...\n') + writect += write_ctocpp_header(header, cls, options.ctocppdir, + not options.nobackup) + if not options.nocpptocimpl: + if not options.quiet: + sys.stdout.write('Generating '+cls+'CToCpp class implementation...\n') + writect += write_ctocpp_impl(header, cls, options.ctocppdir, + not options.nobackup) + +if not options.gypifile is None: + # output the gypi file + if not options.quiet: + sys.stdout.write('Generating '+options.gypifile+' file...\n') + writect += write_gypi_file(header, options.gypifile, not options.nobackup) + +if not options.quiet: + sys.stdout.write('Done - Wrote '+str(writect)+' files.\n') + + diff --git a/cef3/tools/translator.sh b/cef3/tools/translator.sh new file mode 100755 index 000000000..abd1c6e91 --- /dev/null +++ b/cef3/tools/translator.sh @@ -0,0 +1,2 @@ +#!/bin/sh +python translator.py --cpp-header-dir ../include --capi-header-dir ../include/capi --cpptoc-global-impl ../libcef_dll/libcef_dll.cc --ctocpp-global-impl ../libcef_dll/wrapper/libcef_dll_wrapper.cc --cpptoc-dir ../libcef_dll/cpptoc --ctocpp-dir ../libcef_dll/ctocpp --gypi-file ../cef_paths.gypi