- Add keyboard and focus notifications (issue #508).

- Add CefDOMNode::IsEditable method.
- List interfaces alphabetically in CefClient.
- Correct error checking for code and command input.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@680 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2012-06-11 15:52:49 +00:00
parent 3715c23777
commit d8caf27e3b
60 changed files with 1940 additions and 408 deletions

View File

@ -21,9 +21,11 @@
'include/cef_cookie.h',
'include/cef_display_handler.h',
'include/cef_dom.h',
'include/cef_focus_handler.h',
'include/cef_frame.h',
'include/cef_geolocation_handler.h',
'include/cef_jsdialog_handler.h',
'include/cef_keyboard_handler.h',
'include/cef_life_span_handler.h',
'include/cef_load_handler.h',
'include/cef_menu_model.h',
@ -57,9 +59,11 @@
'include/capi/cef_cookie_capi.h',
'include/capi/cef_display_handler_capi.h',
'include/capi/cef_dom_capi.h',
'include/capi/cef_focus_handler_capi.h',
'include/capi/cef_frame_capi.h',
'include/capi/cef_geolocation_handler_capi.h',
'include/capi/cef_jsdialog_handler_capi.h',
'include/capi/cef_keyboard_handler_capi.h',
'include/capi/cef_life_span_handler_capi.h',
'include/capi/cef_load_handler_capi.h',
'include/capi/cef_menu_model_capi.h',
@ -122,6 +126,8 @@
'libcef_dll/cpptoc/dictionary_value_cpptoc.h',
'libcef_dll/ctocpp/display_handler_ctocpp.cc',
'libcef_dll/ctocpp/display_handler_ctocpp.h',
'libcef_dll/ctocpp/focus_handler_ctocpp.cc',
'libcef_dll/ctocpp/focus_handler_ctocpp.h',
'libcef_dll/cpptoc/frame_cpptoc.cc',
'libcef_dll/cpptoc/frame_cpptoc.h',
'libcef_dll/cpptoc/geolocation_callback_cpptoc.cc',
@ -132,6 +138,8 @@
'libcef_dll/cpptoc/jsdialog_callback_cpptoc.h',
'libcef_dll/ctocpp/jsdialog_handler_ctocpp.cc',
'libcef_dll/ctocpp/jsdialog_handler_ctocpp.h',
'libcef_dll/ctocpp/keyboard_handler_ctocpp.cc',
'libcef_dll/ctocpp/keyboard_handler_ctocpp.h',
'libcef_dll/ctocpp/life_span_handler_ctocpp.cc',
'libcef_dll/ctocpp/life_span_handler_ctocpp.h',
'libcef_dll/cpptoc/list_value_cpptoc.cc',
@ -234,6 +242,8 @@
'libcef_dll/ctocpp/dictionary_value_ctocpp.h',
'libcef_dll/cpptoc/display_handler_cpptoc.cc',
'libcef_dll/cpptoc/display_handler_cpptoc.h',
'libcef_dll/cpptoc/focus_handler_cpptoc.cc',
'libcef_dll/cpptoc/focus_handler_cpptoc.h',
'libcef_dll/ctocpp/frame_ctocpp.cc',
'libcef_dll/ctocpp/frame_ctocpp.h',
'libcef_dll/ctocpp/geolocation_callback_ctocpp.cc',
@ -244,6 +254,8 @@
'libcef_dll/ctocpp/jsdialog_callback_ctocpp.h',
'libcef_dll/cpptoc/jsdialog_handler_cpptoc.cc',
'libcef_dll/cpptoc/jsdialog_handler_cpptoc.h',
'libcef_dll/cpptoc/keyboard_handler_cpptoc.cc',
'libcef_dll/cpptoc/keyboard_handler_cpptoc.h',
'libcef_dll/cpptoc/life_span_handler_cpptoc.cc',
'libcef_dll/cpptoc/life_span_handler_cpptoc.h',
'libcef_dll/ctocpp/list_value_ctocpp.cc',

View File

@ -89,6 +89,8 @@
'tests/cefclient/client_app_delegates.cpp',
'tests/cefclient/client_handler.cpp',
'tests/cefclient/client_handler.h',
'tests/cefclient/client_renderer.cpp',
'tests/cefclient/client_renderer.h',
'tests/cefclient/client_switches.cpp',
'tests/cefclient/client_switches.h',
'tests/cefclient/dom_test.cpp',
@ -130,6 +132,8 @@
'tests/cefclient/client_handler.cpp',
'tests/cefclient/client_handler.h',
'tests/cefclient/client_handler_mac.mm',
'tests/cefclient/client_renderer.cpp',
'tests/cefclient/client_renderer.h',
'tests/cefclient/client_switches.cpp',
'tests/cefclient/client_switches.h',
'tests/cefclient/dom_test.cpp',

View File

@ -54,6 +54,45 @@ typedef struct _cef_client_t {
///
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 browser display state events.
///
struct _cef_display_handler_t* (CEF_CALLBACK *get_display_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.
///
@ -72,33 +111,6 @@ typedef struct _cef_client_t {
struct _cef_request_handler_t* (CEF_CALLBACK *get_request_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 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 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);
///
// 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

View File

@ -205,6 +205,11 @@ typedef struct _cef_domnode_t {
///
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.
///

View File

@ -0,0 +1,87 @@
// 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.
//
// ---------------------------------------------------------------------------
//
// 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_

View File

@ -0,0 +1,83 @@
// 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.
//
// ---------------------------------------------------------------------------
//
// 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_

View File

@ -100,6 +100,19 @@ typedef struct _cef_render_process_handler_t {
struct _cef_browser_t* browser, struct _cef_frame_t* frame,
struct _cef_v8context_t* context);
///
// 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

View File

@ -41,8 +41,10 @@
#include "include/cef_base.h"
#include "include/cef_context_menu_handler.h"
#include "include/cef_display_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"
@ -54,6 +56,57 @@
/*--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<CefContextMenuHandler> GetContextMenuHandler() {
return NULL;
}
///
// Return the handler for browser display state events.
///
/*--cef()--*/
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() {
return NULL;
}
///
// Return the handler for focus events.
///
/*--cef()--*/
virtual CefRefPtr<CefFocusHandler> 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<CefGeolocationHandler> GetGeolocationHandler() {
return NULL;
}
///
// Return the handler for JavaScript dialogs. If no handler is provided the
// default implementation will be used.
///
/*--cef()--*/
virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() {
return NULL;
}
///
// Return the handler for keyboard events.
///
/*--cef()--*/
virtual CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() {
return NULL;
}
///
// Return the handler for browser life span events.
///
@ -78,41 +131,6 @@ class CefClient : public virtual CefBase {
return NULL;
}
///
// Return the handler for browser display state events.
///
/*--cef()--*/
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() {
return NULL;
}
///
// Return the handler for geolocation permissions requests. If no handler is
// provided geolocation access will be denied by default.
///
/*--cef()--*/
virtual CefRefPtr<CefGeolocationHandler> GetGeolocationHandler() {
return NULL;
}
///
// Return the handler for JavaScript dialogs. If no handler is provided the
// default implementation will be used.
///
/*--cef()--*/
virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() {
return NULL;
}
///
// Return the handler for context menus. If no handler is provided the default
// implementation will be used.
///
/*--cef()--*/
virtual CefRefPtr<CefContextMenuHandler> GetContextMenuHandler() {
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

View File

@ -200,6 +200,12 @@ class CefDOMNode : public virtual CefBase {
/*--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.
///

View File

@ -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<CefBrowser> 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<CefBrowser> browser,
FocusSource source) { return false; }
///
// Called when the browser component has received focus.
///
/*--cef()--*/
virtual void OnGotFocus(CefRefPtr<CefBrowser> browser) {}
};
#endif // CEF_INCLUDE_CEF_FOCUS_HANDLER_H_

View File

@ -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<CefBrowser> 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<CefBrowser> browser,
const CefKeyEvent& event,
CefEventHandle os_event) { return false; }
};
#endif // CEF_INCLUDE_CEF_KEYBOARD_HANDLER_H_

View File

@ -40,6 +40,7 @@
#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"
@ -94,6 +95,19 @@ class CefRenderProcessHandler : public virtual CefBase {
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Context> context) {}
///
// 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<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefDOMNode> 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

View File

@ -69,8 +69,9 @@ class CefCriticalSection {
};
// Handle types.
#define CefWindowHandle cef_window_handle_t
#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;

View File

@ -45,10 +45,6 @@ inline long CefAtomicDecrement(long volatile *pDest) { // NOLINT(runtime/int)
return __sync_sub_and_fetch(pDest, 1);
}
// Handle types.
#define CefWindowHandle cef_window_handle_t
#define CefCursorHandle cef_cursor_handle_t
// Critical section wrapper.
class CefCriticalSection {
public:
@ -72,6 +68,11 @@ class CefCriticalSection {
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;

View File

@ -75,6 +75,15 @@ typedef int int32;
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
@ -945,6 +954,94 @@ enum cef_context_menu_edit_state_flags_t {
CM_EDITFLAG_CAN_TRANSLATE = 1 << 7,
};
///
// Key event types.
///
enum cef_key_event_type_t {
KEYEVENT_RAWKEYDOWN = 0,
KEYEVENT_KEYDOWN,
KEYEVENT_KEYUP,
KEYEVENT_CHAR
};
///
// Key event modifiers.
///
enum cef_key_event_modifiers_t {
KEY_SHIFT = 1 << 0,
KEY_CTRL = 1 << 1,
KEY_ALT = 1 << 2,
KEY_META = 1 << 3,
KEY_KEYPAD = 1 << 4, // Only used on Mac OS-X
};
///
// 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_key_event_modifiers_t for values.
///
int 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,
};
///
// 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

View File

@ -42,9 +42,10 @@
extern "C" {
#endif
// Window handle.
// Handle types.
#define cef_cursor_handle_t GtkCursor*
#define cef_event_handle_t GdkEvent*
#define cef_window_handle_t GtkWidget*
#define cef_cursor_handle_t void*
///
// Structure representing CefExecuteProcess arguments.

View File

@ -37,18 +37,25 @@
#if defined(OS_MACOSX)
#include "include/internal/cef_string.h"
// Window handle.
// 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
#define cef_cursor_handle_t void*
#ifdef __cplusplus
extern "C" {

View File

@ -42,9 +42,10 @@
extern "C" {
#endif
// Window handle.
#define cef_window_handle_t HWND
// Handle types.
#define cef_cursor_handle_t HCURSOR
#define cef_event_handle_t MSG*
#define cef_window_handle_t HWND
///
// Structure representing CefExecuteProcess arguments.

View File

@ -174,6 +174,31 @@ 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<CefKeyEventTraits> CefKeyEvent;
struct CefPopupFeaturesTraits {
typedef cef_popup_features_t struct_type;

View File

@ -68,8 +68,9 @@ class CefCriticalSection {
///
// Handle types.
///
#define CefWindowHandle cef_window_handle_t
#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;

View File

@ -55,6 +55,47 @@ void CreateBrowserWithHelper(CreateBrowserHelper* helper) {
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 |= KEY_SHIFT;
if (event.modifiers & WebKit::WebKeyboardEvent::ControlKey)
cef_event.modifiers |= KEY_CTRL;
if (event.modifiers & WebKit::WebKeyboardEvent::AltKey)
cef_event.modifiers |= KEY_ALT;
if (event.modifiers & WebKit::WebKeyboardEvent::MetaKey)
cef_event.modifiers |= KEY_META;
if (event.modifiers & WebKit::WebKeyboardEvent::IsKeyPad)
cef_event.modifiers |= KEY_KEYPAD;
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;
}
} // namespace
@ -268,8 +309,7 @@ void CefBrowserHostImpl::SetFocus(bool enable) {
return;
if (CEF_CURRENTLY_ON_UIT()) {
if (web_contents_.get())
web_contents_->Focus();
OnSetFocus(FOCUS_SOURCE_SYSTEM);
} else {
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::SetFocus, this, enable));
@ -572,8 +612,7 @@ void CefBrowserHostImpl::Navigate(const CefNavigateParams& params) {
Send(new CefMsg_LoadRequest(routing_id(), request));
if (web_contents_.get())
web_contents_->Focus();
OnSetFocus(FOCUS_SOURCE_NAVIGATION);
}
void CefBrowserHostImpl::LoadRequest(int64 frame_id,
@ -629,7 +668,7 @@ void CefBrowserHostImpl::LoadURL(int64 frame_id, const std::string& url) {
content::Referrer(),
content::PAGE_TRANSITION_TYPED,
std::string());
web_contents_->Focus();
OnSetFocus(FOCUS_SOURCE_NAVIGATION);
}
} else {
CEF_POST_TASK(CEF_UIT,
@ -666,6 +705,7 @@ void CefBrowserHostImpl::SendCommand(
CefRefPtr<CefResponseManager::Handler> 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()) {
@ -702,6 +742,8 @@ void CefBrowserHostImpl::SendCode(
CefRefPtr<CefResponseManager::Handler> 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()) {
@ -792,6 +834,24 @@ void CefBrowserHostImpl::LoadingStateChanged(content::WebContents* source) {
}
}
bool CefBrowserHostImpl::TakeFocus(bool reverse) {
if (client_.get()) {
CefRefPtr<CefFocusHandler> handler = client_->GetFocusHandler();
if (handler.get())
handler->OnTakeFocus(this, !reverse);
}
return false;
}
void CefBrowserHostImpl::WebContentsFocused(content::WebContents* contents) {
if (client_.get()) {
CefRefPtr<CefFocusHandler> handler = client_->GetFocusHandler();
if (handler.get())
handler->OnGotFocus(this);
}
}
bool CefBrowserHostImpl::HandleContextMenu(
const content::ContextMenuParams& params) {
if (!menu_creator_.get())
@ -799,12 +859,57 @@ bool CefBrowserHostImpl::HandleContextMenu(
return menu_creator_->CreateContextMenu(params);
}
bool CefBrowserHostImpl::PreHandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event,
bool* is_keyboard_shortcut) {
if (client_.get()) {
CefRefPtr<CefKeyboardHandler> 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<CefEventHandle>(&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(
const content::NativeWebKeyboardEvent& event) {
// Check to see if event should be ignored.
if (event.skip_in_browser)
return;
if (client_.get()) {
CefRefPtr<CefKeyboardHandler> handler = client_->GetKeyboardHandler();
if (handler.get()) {
CefKeyEvent cef_event;
if (GetCefKeyEvent(event, cef_event)) {
#if defined(OS_WIN)
CefEventHandle os_event = const_cast<CefEventHandle>(&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);
}
@ -1073,7 +1178,8 @@ void CefBrowserHostImpl::OnResponseAck(int request_id) {
void CefBrowserHostImpl::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED);
DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED ||
type == content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE);
if (type == content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED) {
std::pair<content::NavigationEntry*, bool>* title =
@ -1094,6 +1200,8 @@ void CefBrowserHostImpl::Observe(int type,
received_page_title_ = title->second;
}
} else if (type == content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE) {
focus_on_editable_field_ = *content::Details<bool>(details).ptr();
}
}
@ -1121,13 +1229,18 @@ CefBrowserHostImpl::CefBrowserHostImpl(const CefWindowInfo& window_info,
has_document_(false),
queue_messages_(true),
main_frame_id_(CefFrameHostImpl::kInvalidFrameId),
focused_frame_id_(CefFrameHostImpl::kInvalidFrameId) {
focused_frame_id_(CefFrameHostImpl::kInvalidFrameId),
is_in_onsetfocus_(false),
focus_on_editable_field_(false) {
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<content::WebContents>(web_contents));
registrar_->Add(this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
content::Source<content::RenderViewHost>(
web_contents->GetRenderViewHost()));
response_manager_.reset(new CefResponseManager);
placeholder_frame_ =
@ -1290,3 +1403,26 @@ void CefBrowserHostImpl::OnLoadEnd(CefRefPtr<CefFrame> frame,
}
}
}
void CefBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
CEF_REQUIRE_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<CefFocusHandler> 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_->Focus();
}

View File

@ -197,8 +197,13 @@ class CefBrowserHostImpl : public CefBrowserHost,
content::WebContents* source,
const content::OpenURLParams& params) OVERRIDE;
virtual void LoadingStateChanged(content::WebContents* source) OVERRIDE;
virtual bool TakeFocus(bool reverse) OVERRIDE;
virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE;
virtual bool HandleContextMenu(const content::ContextMenuParams& params)
OVERRIDE;
virtual bool PreHandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event,
bool* is_keyboard_shortcut) OVERRIDE;
virtual void HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) OVERRIDE;
virtual bool ShouldCreateWebContents(
@ -317,6 +322,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
const string16& error_description);
void OnLoadEnd(CefRefPtr<CefFrame> frame,
const GURL& url);
void OnSetFocus(cef_focus_source_t source);
CefWindowInfo window_info_;
CefBrowserSettings settings_;
@ -367,6 +373,14 @@ class CefBrowserHostImpl : public CefBrowserHost,
// Used when no other frame exists. Provides limited functionality.
CefRefPtr<CefFrameHostImpl> placeholder_frame_;
// 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_;
// Used for managing notification subscriptions.
scoped_ptr<content::NotificationRegistrar> registrar_;

View File

@ -37,6 +37,17 @@
[super dealloc];
}
- (BOOL)acceptsFirstResponder {
return browser_ && browser_->GetWebContents();
}
- (BOOL)becomeFirstResponder {
if (browser_ && browser_->GetWebContents())
browser_->OnSetFocus(FOCUS_SOURCE_SYSTEM);
return YES;
}
@end

View File

@ -129,11 +129,8 @@ LRESULT CALLBACK CefBrowserHostImpl::WndProc(HWND hwnd, UINT message,
return 0;
case WM_SETFOCUS:
if (browser) {
content::WebContents* web_contents = browser->GetWebContents();
if (web_contents)
web_contents->Focus();
}
if (browser)
browser->OnSetFocus(FOCUS_SOURCE_SYSTEM);
return 0;
case WM_ERASEBKGND:

View File

@ -153,6 +153,11 @@ void CefFrameHostImpl::LoadString(const CefString& string,
void CefFrameHostImpl::ExecuteJavaScript(const CefString& jsCode,
const CefString& 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,

View File

@ -13,6 +13,7 @@
#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"
@ -459,6 +460,29 @@ void CefBrowserImpl::FrameDetached(WebFrame* frame) {
}
void CefBrowserImpl::FocusedNodeChanged(const WebKit::WebNode& node) {
// Notify the handler.
CefRefPtr<CefApp> app = CefContentClient::Get()->application();
if (app.get()) {
CefRefPtr<CefRenderProcessHandler> 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<CefDOMDocumentImpl> 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().
@ -582,7 +606,6 @@ void CefBrowserImpl::OnRequest(const Cef_Request_Params& params) {
params.arguments.GetString(1, &code);
DCHECK(!code.empty());
params.arguments.GetString(2, &script_url);
DCHECK(!script_url.empty());
params.arguments.GetInteger(3, &script_start_line);
DCHECK_GE(script_start_line, 0);
@ -633,9 +656,7 @@ void CefBrowserImpl::OnRequest(const Cef_Request_Params& params) {
string16 string, url;
params.arguments.GetString(0, &string);
DCHECK(!string.empty());
params.arguments.GetString(1, &url);
DCHECK(!url.empty());
web_frame->loadHTMLString(UTF16ToUTF8(string), GURL(UTF16ToUTF8(url)));
}

View File

@ -81,7 +81,7 @@ class CefBrowserImpl : public CefBrowser,
void LoadRequest(const CefMsg_LoadRequest_Params& params);
// Returns the matching WebFrameImpl reference or creates a new one.
// Returns the matching CefFrameImpl reference or creates a new one.
CefRefPtr<CefFrameImpl> GetWebFrameImpl(WebKit::WebFrame* frame);
CefRefPtr<CefFrameImpl> GetWebFrameImpl(int64 frame_id);

View File

@ -148,6 +148,32 @@ bool CefDOMNodeImpl::IsElement() {
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<WebElement>();
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;

View File

@ -21,6 +21,7 @@ class CefDOMNodeImpl : public CefDOMNode {
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<CefDOMNode> that) OVERRIDE;

View File

@ -163,6 +163,11 @@ void CefFrameImpl::ExecuteJavaScript(const CefString& jsCode,
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(

View File

@ -13,8 +13,10 @@
#include "libcef_dll/cpptoc/client_cpptoc.h"
#include "libcef_dll/cpptoc/context_menu_handler_cpptoc.h"
#include "libcef_dll/cpptoc/display_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/request_handler_cpptoc.h"
@ -24,6 +26,102 @@
// 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<CefContextMenuHandler> _retval = CefClientCppToC::Get(
self)->GetContextMenuHandler();
// Return type: refptr_same
return CefContextMenuHandlerCppToC::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<CefDisplayHandler> _retval = CefClientCppToC::Get(
self)->GetDisplayHandler();
// Return type: refptr_same
return CefDisplayHandlerCppToC::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<CefFocusHandler> _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<CefGeolocationHandler> _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<CefJSDialogHandler> _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<CefKeyboardHandler> _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
@ -72,70 +170,6 @@ struct _cef_request_handler_t* CEF_CALLBACK client_get_request_handler(
return CefRequestHandlerCppToC::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<CefDisplayHandler> _retval = CefClientCppToC::Get(
self)->GetDisplayHandler();
// Return type: refptr_same
return CefDisplayHandlerCppToC::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<CefGeolocationHandler> _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<CefJSDialogHandler> _retval = CefClientCppToC::Get(
self)->GetJSDialogHandler();
// Return type: refptr_same
return CefJSDialogHandlerCppToC::Wrap(_retval);
}
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<CefContextMenuHandler> _retval = CefClientCppToC::Get(
self)->GetContextMenuHandler();
// Return type: refptr_same
return CefContextMenuHandlerCppToC::Wrap(_retval);
}
int CEF_CALLBACK client_on_process_message_recieved(struct _cef_client_t* self,
cef_browser_t* browser, enum cef_process_id_t source_process,
struct _cef_process_message_t* message) {
@ -168,13 +202,15 @@ int CEF_CALLBACK client_on_process_message_recieved(struct _cef_client_t* self,
CefClientCppToC::CefClientCppToC(CefClient* cls)
: CefCppToC<CefClientCppToC, CefClient, cef_client_t>(cls) {
struct_.struct_.get_context_menu_handler = client_get_context_menu_handler;
struct_.struct_.get_display_handler = client_get_display_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_request_handler = client_get_request_handler;
struct_.struct_.get_display_handler = client_get_display_handler;
struct_.struct_.get_geolocation_handler = client_get_geolocation_handler;
struct_.struct_.get_jsdialog_handler = client_get_jsdialog_handler;
struct_.struct_.get_context_menu_handler = client_get_context_menu_handler;
struct_.struct_.on_process_message_recieved =
client_on_process_message_recieved;
}

View File

@ -61,6 +61,20 @@ int CEF_CALLBACK domnode_is_element(struct _cef_domnode_t* self) {
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
@ -447,6 +461,7 @@ CefDOMNodeCppToC::CefDOMNodeCppToC(CefDOMNode* 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;

View File

@ -0,0 +1,90 @@
// 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/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<CefFocusHandlerCppToC, CefFocusHandler, cef_focus_handler_t>(
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<CefFocusHandlerCppToC, CefFocusHandler,
cef_focus_handler_t>::DebugObjCt = 0;
#endif

View File

@ -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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only 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<CefFocusHandlerCppToC, CefFocusHandler,
cef_focus_handler_t> {
public:
explicit CefFocusHandlerCppToC(CefFocusHandler* cls);
virtual ~CefFocusHandlerCppToC() {}
};
#endif // USING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CPPTOC_FOCUS_HANDLER_CPPTOC_H_

View File

@ -0,0 +1,110 @@
// 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/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<CefKeyboardHandlerCppToC, CefKeyboardHandler,
cef_keyboard_handler_t>(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<CefKeyboardHandlerCppToC, CefKeyboardHandler,
cef_keyboard_handler_t>::DebugObjCt = 0;
#endif

View File

@ -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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only 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<CefKeyboardHandlerCppToC, CefKeyboardHandler,
cef_keyboard_handler_t> {
public:
explicit CefKeyboardHandlerCppToC(CefKeyboardHandler* cls);
virtual ~CefKeyboardHandlerCppToC() {}
};
#endif // USING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CPPTOC_KEYBOARD_HANDLER_CPPTOC_H_

View File

@ -12,6 +12,7 @@
#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/process_message_ctocpp.h"
#include "libcef_dll/ctocpp/v8context_ctocpp.h"
@ -133,6 +134,27 @@ void CEF_CALLBACK render_process_handler_on_context_released(
CefV8ContextCToCpp::Wrap(context));
}
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_recieved(
struct _cef_render_process_handler_t* self, cef_browser_t* browser,
enum cef_process_id_t source_process, cef_process_message_t* message) {
@ -180,6 +202,8 @@ CefRenderProcessHandlerCppToC::CefRenderProcessHandlerCppToC(
render_process_handler_on_context_created;
struct_.struct_.on_context_released =
render_process_handler_on_context_released;
struct_.struct_.on_focused_node_changed =
render_process_handler_on_focused_node_changed;
struct_.struct_.on_process_message_recieved =
render_process_handler_on_process_message_recieved;
}

View File

@ -15,8 +15,10 @@
#include "libcef_dll/ctocpp/client_ctocpp.h"
#include "libcef_dll/ctocpp/context_menu_handler_ctocpp.h"
#include "libcef_dll/ctocpp/display_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/request_handler_ctocpp.h"
@ -24,6 +26,86 @@
// VIRTUAL METHODS - Body may be edited by hand.
CefRefPtr<CefContextMenuHandler> 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<CefDisplayHandler> 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<CefFocusHandler> 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<CefGeolocationHandler> 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<CefJSDialogHandler> 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<CefKeyboardHandler> 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<CefLifeSpanHandler> CefClientCToCpp::GetLifeSpanHandler() {
if (CEF_MEMBER_MISSING(struct_, get_life_span_handler))
return NULL;
@ -63,60 +145,6 @@ CefRefPtr<CefRequestHandler> CefClientCToCpp::GetRequestHandler() {
return CefRequestHandlerCToCpp::Wrap(_retval);
}
CefRefPtr<CefDisplayHandler> 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<CefGeolocationHandler> 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<CefJSDialogHandler> 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<CefContextMenuHandler> 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);
}
bool CefClientCToCpp::OnProcessMessageRecieved(CefRefPtr<CefBrowser> browser,
CefProcessId source_process, CefRefPtr<CefProcessMessage> message) {
if (CEF_MEMBER_MISSING(struct_, on_process_message_recieved))

View File

@ -32,13 +32,15 @@ class CefClientCToCpp
virtual ~CefClientCToCpp() {}
// CefClient methods
virtual CefRefPtr<CefContextMenuHandler> GetContextMenuHandler() OVERRIDE;
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE;
virtual CefRefPtr<CefFocusHandler> GetFocusHandler() OVERRIDE;
virtual CefRefPtr<CefGeolocationHandler> GetGeolocationHandler() OVERRIDE;
virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() OVERRIDE;
virtual CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() OVERRIDE;
virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() OVERRIDE;
virtual CefRefPtr<CefLoadHandler> GetLoadHandler() OVERRIDE;
virtual CefRefPtr<CefRequestHandler> GetRequestHandler() OVERRIDE;
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE;
virtual CefRefPtr<CefGeolocationHandler> GetGeolocationHandler() OVERRIDE;
virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() OVERRIDE;
virtual CefRefPtr<CefContextMenuHandler> GetContextMenuHandler() OVERRIDE;
virtual bool OnProcessMessageRecieved(CefRefPtr<CefBrowser> browser,
CefProcessId source_process,
CefRefPtr<CefProcessMessage> message) OVERRIDE;

View File

@ -57,6 +57,19 @@ bool CefDOMNodeCToCpp::IsElement() {
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;

View File

@ -35,6 +35,7 @@ class CefDOMNodeCToCpp
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<CefDOMNode> that) OVERRIDE;

View File

@ -0,0 +1,79 @@
// 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/ctocpp/focus_handler_ctocpp.h"
// VIRTUAL METHODS - Body may be edited by hand.
void CefFocusHandlerCToCpp::OnTakeFocus(CefRefPtr<CefBrowser> 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<CefBrowser> 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<CefBrowser> 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<CefFocusHandlerCToCpp, CefFocusHandler,
cef_focus_handler_t>::DebugObjCt = 0;
#endif

View File

@ -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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only 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<CefFocusHandlerCToCpp, CefFocusHandler,
cef_focus_handler_t> {
public:
explicit CefFocusHandlerCToCpp(cef_focus_handler_t* str)
: CefCToCpp<CefFocusHandlerCToCpp, CefFocusHandler, cef_focus_handler_t>(
str) {}
virtual ~CefFocusHandlerCToCpp() {}
// CefFocusHandler methods
virtual void OnTakeFocus(CefRefPtr<CefBrowser> browser, bool next) OVERRIDE;
virtual bool OnSetFocus(CefRefPtr<CefBrowser> browser,
FocusSource source) OVERRIDE;
virtual void OnGotFocus(CefRefPtr<CefBrowser> browser) OVERRIDE;
};
#endif // BUILDING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CTOCPP_FOCUS_HANDLER_CTOCPP_H_

View File

@ -0,0 +1,81 @@
// 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/ctocpp/keyboard_handler_ctocpp.h"
// VIRTUAL METHODS - Body may be edited by hand.
bool CefKeyboardHandlerCToCpp::OnPreKeyEvent(CefRefPtr<CefBrowser> 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<CefBrowser> 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<CefKeyboardHandlerCToCpp, CefKeyboardHandler,
cef_keyboard_handler_t>::DebugObjCt = 0;
#endif

View File

@ -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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only 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<CefKeyboardHandlerCToCpp, CefKeyboardHandler,
cef_keyboard_handler_t> {
public:
explicit CefKeyboardHandlerCToCpp(cef_keyboard_handler_t* str)
: CefCToCpp<CefKeyboardHandlerCToCpp, CefKeyboardHandler,
cef_keyboard_handler_t>(str) {}
virtual ~CefKeyboardHandlerCToCpp() {}
// CefKeyboardHandler methods
virtual bool OnPreKeyEvent(CefRefPtr<CefBrowser> browser,
const CefKeyEvent& event, CefEventHandle os_event,
bool* is_keyboard_shortcut) OVERRIDE;
virtual bool OnKeyEvent(CefRefPtr<CefBrowser> browser,
const CefKeyEvent& event, CefEventHandle os_event) OVERRIDE;
};
#endif // BUILDING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CTOCPP_KEYBOARD_HANDLER_CTOCPP_H_

View File

@ -11,6 +11,7 @@
//
#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/process_message_cpptoc.h"
#include "libcef_dll/cpptoc/v8context_cpptoc.h"
@ -129,6 +130,27 @@ void CefRenderProcessHandlerCToCpp::OnContextReleased(
CefV8ContextCppToC::Wrap(context));
}
void CefRenderProcessHandlerCToCpp::OnFocusedNodeChanged(
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
CefRefPtr<CefDOMNode> 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::OnProcessMessageRecieved(
CefRefPtr<CefBrowser> browser, CefProcessId source_process,
CefRefPtr<CefProcessMessage> message) {

View File

@ -42,6 +42,8 @@ class CefRenderProcessHandlerCToCpp
CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) OVERRIDE;
virtual void OnContextReleased(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) OVERRIDE;
virtual void OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefDOMNode> node) OVERRIDE;
virtual bool OnProcessMessageRecieved(CefRefPtr<CefBrowser> browser,
CefProcessId source_process,
CefRefPtr<CefProcessMessage> message) OVERRIDE;

View File

@ -60,8 +60,10 @@
#include "libcef_dll/ctocpp/domevent_listener_ctocpp.h"
#include "libcef_dll/ctocpp/domvisitor_ctocpp.h"
#include "libcef_dll/ctocpp/display_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/proxy_handler_ctocpp.h"
@ -162,11 +164,13 @@ CEF_EXPORT void cef_shutdown() {
DCHECK_EQ(CefDOMVisitorCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefDictionaryValueCppToC::DebugObjCt, 0);
DCHECK_EQ(CefDisplayHandlerCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefFocusHandlerCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefFrameCppToC::DebugObjCt, 0);
DCHECK_EQ(CefGeolocationCallbackCppToC::DebugObjCt, 0);
DCHECK_EQ(CefGeolocationHandlerCToCpp::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);

View File

@ -31,8 +31,10 @@
#include "libcef_dll/cpptoc/domevent_listener_cpptoc.h"
#include "libcef_dll/cpptoc/domvisitor_cpptoc.h"
#include "libcef_dll/cpptoc/display_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/proxy_handler_cpptoc.h"
@ -154,11 +156,13 @@ CEF_GLOBAL void CefShutdown() {
DCHECK_EQ(CefDOMVisitorCppToC::DebugObjCt, 0);
DCHECK_EQ(CefDictionaryValueCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefDisplayHandlerCppToC::DebugObjCt, 0);
DCHECK_EQ(CefFocusHandlerCppToC::DebugObjCt, 0);
DCHECK_EQ(CefFrameCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefGeolocationCallbackCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefGeolocationHandlerCppToC::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);

View File

@ -269,6 +269,15 @@ void ClientApp::OnContextReleased(CefRefPtr<CefBrowser> browser,
}
}
void ClientApp::OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefDOMNode> node) {
// Execute delegate callbacks.
RenderDelegateSet::iterator it = render_delegates_.begin();
for (; it != render_delegates_.end(); ++it)
(*it)->OnFocusedNodeChanged(this, browser, frame, node);
}
bool ClientApp::OnProcessMessageRecieved(
CefRefPtr<CefBrowser> browser,
CefProcessId source_process,

View File

@ -43,6 +43,13 @@ class ClientApp : public CefApp,
CefRefPtr<CefV8Context> context) {
};
// Called when the focused node in a frame has changed.
virtual void OnFocusedNodeChanged(CefRefPtr<ClientApp> app,
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefDOMNode> 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
@ -112,6 +119,9 @@ class ClientApp : public CefApp,
virtual void OnContextReleased(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Context> context) OVERRIDE;
virtual void OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefDOMNode> node) OVERRIDE;
virtual bool OnProcessMessageRecieved(
CefRefPtr<CefBrowser> browser,
CefProcessId source_process,

View File

@ -3,11 +3,13 @@
// can be found in the LICENSE file.
#include "cefclient/client_app.h"
#include "cefclient/client_renderer.h"
#include "cefclient/dom_test.h"
#include "cefclient/scheme_test.h"
// static
void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) {
client_renderer::CreateRenderDelegates(delegates);
dom_test::CreateRenderDelegates(delegates);
}

View File

@ -11,6 +11,7 @@
#include "include/wrapper/cef_stream_resource_handler.h"
#include "cefclient/binding_test.h"
#include "cefclient/cefclient.h"
#include "cefclient/client_renderer.h"
#include "cefclient/dom_test.h"
#include "cefclient/resource_util.h"
#include "cefclient/string_util.h"
@ -34,7 +35,7 @@ ClientHandler::ClientHandler()
m_ForwardHwnd(NULL),
m_StopHwnd(NULL),
m_ReloadHwnd(NULL),
m_bFormElementHasFocus(false) {
m_bFocusOnEditableField(false) {
CreateProcessMessageDelegates(process_message_delegates_);
CreateRequestDelegates(request_delegates_);
}
@ -46,6 +47,17 @@ bool ClientHandler::OnProcessMessageRecieved(
CefRefPtr<CefBrowser> browser,
CefProcessId source_process,
CefRefPtr<CefProcessMessage> 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.
@ -58,6 +70,129 @@ bool ClientHandler::OnProcessMessageRecieved(
return handled;
}
void ClientHandler::OnBeforeContextMenu(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefContextMenuParams> params,
CefRefPtr<CefMenuModel> 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<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefContextMenuParams> 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<CefBrowser> browser,
bool isLoading,
bool canGoBack,
bool canGoForward) {
REQUIRE_UI_THREAD();
SetLoading(isLoading);
SetNavState(canGoBack, canGoForward);
}
bool ClientHandler::OnConsoleMessage(CefRefPtr<CefBrowser> 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::OnRequestGeolocationPermission(
CefRefPtr<CefBrowser> browser,
const CefString& requesting_url,
int request_id,
CefRefPtr<CefGeolocationCallback> callback) {
// Allow geolocation access from all websites.
callback->Continue(true);
}
bool ClientHandler::OnPreKeyEvent(CefRefPtr<CefBrowser> browser,
const CefKeyEvent& event,
CefEventHandle os_event,
bool* is_keyboard_shortcut) {
ASSERT(m_bFocusOnEditableField == event.focus_on_editable_field);
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;
}
void ClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
REQUIRE_UI_THREAD();
@ -194,108 +329,6 @@ CefRefPtr<CefResourceHandler> ClientHandler::GetResourceHandler(
return handler;
}
void ClientHandler::OnLoadingStateChange(CefRefPtr<CefBrowser> browser,
bool isLoading,
bool canGoBack,
bool canGoForward) {
REQUIRE_UI_THREAD();
SetLoading(isLoading);
SetNavState(canGoBack, canGoForward);
}
bool ClientHandler::OnConsoleMessage(CefRefPtr<CefBrowser> 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::OnRequestGeolocationPermission(
CefRefPtr<CefBrowser> browser,
const CefString& requesting_url,
int request_id,
CefRefPtr<CefGeolocationCallback> callback) {
// Allow geolocation access from all websites.
callback->Continue(true);
}
void ClientHandler::OnBeforeContextMenu(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefContextMenuParams> params,
CefRefPtr<CefMenuModel> 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<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefContextMenuParams> 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::SetMainHwnd(CefWindowHandle hwnd) {
AutoLock lock_scope(this);
m_MainHwnd = hwnd;

View File

@ -20,12 +20,13 @@
// ClientHandler implementation.
class ClientHandler : public CefClient,
public CefLifeSpanHandler,
public CefLoadHandler,
public CefRequestHandler,
public CefContextMenuHandler,
public CefDisplayHandler,
public CefGeolocationHandler,
public CefContextMenuHandler {
public CefKeyboardHandler,
public CefLifeSpanHandler,
public CefLoadHandler,
public CefRequestHandler {
public:
// Interface for process message delegates. Do not perform work in the
// RenderDelegate constructor.
@ -67,6 +68,18 @@ class ClientHandler : public CefClient,
virtual ~ClientHandler();
// CefClient methods
virtual CefRefPtr<CefContextMenuHandler> GetContextMenuHandler() OVERRIDE {
return this;
}
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE {
return this;
}
virtual CefRefPtr<CefGeolocationHandler> GetGeolocationHandler() OVERRIDE {
return this;
}
virtual CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() OVERRIDE {
return this;
}
virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() OVERRIDE {
return this;
}
@ -76,48 +89,21 @@ class ClientHandler : public CefClient,
virtual CefRefPtr<CefRequestHandler> GetRequestHandler() OVERRIDE {
return this;
}
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE {
return this;
}
virtual CefRefPtr<CefGeolocationHandler> GetGeolocationHandler() OVERRIDE {
return this;
}
virtual CefRefPtr<CefContextMenuHandler> GetContextMenuHandler() OVERRIDE {
return this;
}
virtual bool OnProcessMessageRecieved(CefRefPtr<CefBrowser> browser,
CefProcessId source_process,
CefRefPtr<CefProcessMessage> message)
OVERRIDE;
// CefLifeSpanHandler methods
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser,
const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo,
const CefString& url,
CefRefPtr<CefClient>& client,
CefBrowserSettings& settings) OVERRIDE;
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
virtual bool DoClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
// CefLoadHandler methods
virtual void OnLoadStart(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame) OVERRIDE;
virtual void OnLoadEnd(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
int httpStatusCode) OVERRIDE;
virtual void OnLoadError(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
ErrorCode errorCode,
const CefString& errorText,
const CefString& failedUrl) OVERRIDE;
// CefRequestHandler methods
virtual CefRefPtr<CefResourceHandler> GetResourceHandler(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request) OVERRIDE;
// CefContextMenuHandler methods
virtual void OnBeforeContextMenu(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefContextMenuParams> params,
CefRefPtr<CefMenuModel> model) OVERRIDE;
virtual bool OnContextMenuCommand(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefContextMenuParams> params,
int command_id,
EventFlags event_flags) OVERRIDE;
// CefDisplayHandler methods
virtual void OnLoadingStateChange(CefRefPtr<CefBrowser> browser,
@ -141,16 +127,34 @@ class ClientHandler : public CefClient,
int request_id,
CefRefPtr<CefGeolocationCallback> callback) OVERRIDE;
// CefContextMenuHandler methods
virtual void OnBeforeContextMenu(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefContextMenuParams> params,
CefRefPtr<CefMenuModel> model) OVERRIDE;
virtual bool OnContextMenuCommand(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefContextMenuParams> params,
int command_id,
EventFlags event_flags) OVERRIDE;
// CefKeyboardHandler methods
virtual bool OnPreKeyEvent(CefRefPtr<CefBrowser> browser,
const CefKeyEvent& event,
CefEventHandle os_event,
bool* is_keyboard_shortcut) OVERRIDE;
// CefLifeSpanHandler methods
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
virtual bool DoClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
// CefLoadHandler methods
virtual void OnLoadStart(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame) OVERRIDE;
virtual void OnLoadEnd(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
int httpStatusCode) OVERRIDE;
virtual void OnLoadError(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
ErrorCode errorCode,
const CefString& errorText,
const CefString& failedUrl) OVERRIDE;
// CefRequestHandler methods
virtual CefRefPtr<CefResourceHandler> GetResourceHandler(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request) OVERRIDE;
void SetMainHwnd(CefWindowHandle hwnd);
CefWindowHandle GetMainHwnd() { return m_MainHwnd; }
@ -224,8 +228,8 @@ class ClientHandler : public CefClient,
// Support for downloading files.
std::string m_LastDownloadFile;
// True if a form element currently has focus
bool m_bFormElementHasFocus;
// True if an editable field currently has focus.
bool m_bFocusOnEditableField;
// Registered delegates.
ProcessMessageDelegateSet process_message_delegates_;

View File

@ -8,18 +8,6 @@
#include "include/cef_browser.h"
#include "include/cef_frame.h"
// ClientHandler::ClientLifeSpanHandler implementation
bool ClientHandler::OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser,
const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo,
const CefString& url,
CefRefPtr<CefClient>& client,
CefBrowserSettings& settings) {
REQUIRE_UI_THREAD();
return false;
}
void ClientHandler::OnAddressChange(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& url) {

View File

@ -9,19 +9,6 @@
#include "include/cef_frame.h"
#include "cefclient/cefclient.h"
// ClientHandler::ClientLifeSpanHandler implementation
bool ClientHandler::OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser,
const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo,
const CefString& url,
CefRefPtr<CefClient>& client,
CefBrowserSettings& settings) {
REQUIRE_UI_THREAD();
return false;
}
void ClientHandler::OnAddressChange(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& url) {

View File

@ -8,17 +8,6 @@
#include "include/cef_frame.h"
#include "cefclient/resource.h"
bool ClientHandler::OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser,
const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo,
const CefString& url,
CefRefPtr<CefClient>& client,
CefBrowserSettings& settings) {
REQUIRE_UI_THREAD();
return false;
}
void ClientHandler::OnAddressChange(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& url) {

View File

@ -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 <sstream>
#include <string>
#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<ClientApp> app,
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefDOMNode> 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<CefProcessMessage> 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

View File

@ -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_

View File

@ -372,6 +372,7 @@ _simpletypes = {
'bool' : ['int', '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'],