Add context menu support (issue #509):

- Add new CefContextMenuHandler, CefContextMenuParams and CefMenuModel classes.
- Add cef_strings.grd and related infrastructure for supporting translation of CEF strings.
- Generate include/cef_pack_resources.h and include/cef_pack_strings.h files at build time that include all IDs used by CEF pack files.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@595 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2012-04-19 20:31:46 +00:00
parent 07bba96106
commit 7bc494880f
52 changed files with 6578 additions and 36 deletions

110
cef.gyp
View File

@ -491,6 +491,21 @@
'<@(libcef_dll_wrapper_sources_common)',
],
},
{
# Create the pack file for CEF strings.
'target_name': 'cef_strings',
'type': 'none',
'actions': [
{
'action_name': 'cef_strings',
'variables': {
'grit_grd_file': 'libcef/resources/cef_strings.grd',
},
'includes': [ '../build/grit_action.gypi' ],
},
],
'includes': [ '../build/grit_target.gypi' ],
},
{
# Create the locale-specific pack files.
'target_name': 'cef_locales',
@ -498,6 +513,7 @@
'dependencies': [
'<(DEPTH)/ui/base/strings/ui_strings.gyp:ui_strings',
'<(DEPTH)/webkit/support/webkit_support.gyp:webkit_strings',
'cef_strings',
],
'variables': {
'repack_locales_cmd': ['python', 'tools/repack_locales.py'],
@ -574,7 +590,7 @@
{
'action_name': 'cef_resources',
'variables': {
'grit_grd_file': 'libcef/browser/resources/cef_resources.grd',
'grit_grd_file': 'libcef/resources/cef_resources.grd',
},
'includes': [ '../build/grit_action.gypi' ],
},
@ -605,6 +621,7 @@
],
'variables': {
'repack_path': '<(DEPTH)/tools/grit/grit/format/repack.py',
'make_pack_header_path': 'tools/make_pack_header.py',
},
'actions': [
{
@ -638,6 +655,56 @@
'action': ['python', '<(repack_path)', '<@(_outputs)',
'<@(pak_inputs)'],
},
{
'action_name': 'make_pack_resources_header',
'variables': {
'header_inputs': [
'<(SHARED_INTERMEDIATE_DIR)/content/grit/content_resources.h',
'<(SHARED_INTERMEDIATE_DIR)/net/grit/net_resources.h',
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/grit/ui_resources.h',
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources_standard/grit/ui_resources_standard.h',
'<(SHARED_INTERMEDIATE_DIR)/webkit/grit/devtools_resources.h',
'<(SHARED_INTERMEDIATE_DIR)/webkit/grit/webkit_chromium_resources.h',
'<(SHARED_INTERMEDIATE_DIR)/webkit/grit/webkit_resources.h',
'<(grit_out_dir)/grit/cef_resources.h',
],
'conditions': [
['OS != "mac"', {
'header_inputs': [
'<(SHARED_INTERMEDIATE_DIR)/ui/gfx/grit/gfx_resources.h',
]
}],
],
},
'inputs': [
'<(make_pack_header_path)',
'<@(header_inputs)',
],
'outputs': [
'include/cef_pack_resources.h',
],
'action': ['python', '<(make_pack_header_path)', '<@(_outputs)',
'<@(header_inputs)'],
},
{
'action_name': 'make_pack_strings_header',
'variables': {
'header_inputs': [
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_strings/grit/ui_strings.h',
'<(SHARED_INTERMEDIATE_DIR)/webkit/grit/webkit_strings.h',
'<(grit_out_dir)/grit/cef_strings.h',
],
},
'inputs': [
'<(make_pack_header_path)',
'<@(header_inputs)',
],
'outputs': [
'include/cef_pack_strings.h',
],
'action': ['python', '<(make_pack_header_path)', '<@(_outputs)',
'<@(header_inputs)'],
},
],
'conditions': [
['OS != "mac"', {
@ -709,6 +776,8 @@
'libcef/browser/content_browser_client.h',
'libcef/browser/context.cc',
'libcef/browser/context.h',
'libcef/browser/context_menu_params_impl.cc',
'libcef/browser/context_menu_params_impl.h',
'libcef/browser/cookie_manager_impl.cc',
'libcef/browser/cookie_manager_impl.h',
'libcef/browser/devtools_delegate.cc',
@ -720,6 +789,10 @@
'libcef/browser/javascript_dialog.h',
'libcef/browser/javascript_dialog_creator.cc',
'libcef/browser/javascript_dialog_creator.h',
'libcef/browser/menu_creator.cc',
'libcef/browser/menu_creator.h',
'libcef/browser/menu_model_impl.cc',
'libcef/browser/menu_model_impl.h',
'libcef/browser/navigate_params.cc',
'libcef/browser/navigate_params.h',
'libcef/browser/origin_whitelist_impl.cc',
@ -810,6 +883,18 @@
'libcef/browser/browser_host_impl_win.cc',
'libcef/browser/browser_main_win.cc',
'libcef/browser/javascript_dialog_win.cc',
'libcef/browser/menu_creator_runner_win.cc',
'libcef/browser/menu_creator_runner_win.h',
# Include sources for context menu implementation.
'<(DEPTH)/ui/views/controls/menu/menu_2.cc',
'<(DEPTH)/ui/views/controls/menu/menu_2.h',
'<(DEPTH)/ui/views/controls/menu/menu_config.cc',
'<(DEPTH)/ui/views/controls/menu/menu_config.h',
'<(DEPTH)/ui/views/controls/menu/menu_config_win.cc',
'<(DEPTH)/ui/views/controls/menu/menu_listener.cc',
'<(DEPTH)/ui/views/controls/menu/menu_listener.h',
'<(DEPTH)/ui/views/controls/menu/native_menu_win.cc',
'<(DEPTH)/ui/views/controls/menu/native_menu_win.h',
],
}],
[ 'OS=="mac"', {
@ -820,12 +905,23 @@
'libcef/browser/browser_host_impl_mac.mm',
'libcef/browser/browser_main_mac.mm',
'libcef/browser/javascript_dialog_mac.mm',
'libcef/browser/menu_creator_runner_mac.h',
'libcef/browser/menu_creator_runner_mac.mm',
# Include necessary Mozilla sources. Remove these lines once they're
# included by content_browser.gypi. See crbug.com/120719.
'<(DEPTH)/third_party/mozilla/NSString+Utils.h',
'<(DEPTH)/third_party/mozilla/NSString+Utils.mm',
'<(DEPTH)/third_party/mozilla/NSURL+Utils.h',
'<(DEPTH)/third_party/mozilla/NSURL+Utils.m',
# Include sources for context menu implementation.
'<(DEPTH)/chrome/browser/disposition_utils.cc',
'<(DEPTH)/chrome/browser/disposition_utils.h',
'<(DEPTH)/chrome/browser/event_disposition.cc',
'<(DEPTH)/chrome/browser/event_disposition.h',
'<(DEPTH)/chrome/browser/ui/cocoa/event_utils.mm',
'<(DEPTH)/chrome/browser/ui/cocoa/event_utils.h',
'<(DEPTH)/chrome/browser/ui/cocoa/menu_controller.mm',
'<(DEPTH)/chrome/browser/ui/cocoa/menu_controller.h',
],
}],
[ 'OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
@ -833,6 +929,18 @@
'<@(includes_linux)',
'libcef/browser/browser_host_impl_gtk.cc',
'libcef/browser/browser_main_gtk.cc',
'libcef/browser/gtk_util_stub.cc',
'libcef/browser/menu_creator_runner_gtk.cc',
'libcef/browser/menu_creator_runner_gtk.h',
# Include sources for context menu implementation.
'<(DEPTH)/chrome/browser/ui/gtk/gtk_custom_menu.cc',
'<(DEPTH)/chrome/browser/ui/gtk/gtk_custom_menu.h',
'<(DEPTH)/chrome/browser/ui/gtk/gtk_custom_menu_item.cc',
'<(DEPTH)/chrome/browser/ui/gtk/gtk_custom_menu_item.h',
'<(DEPTH)/chrome/browser/ui/gtk/menu_gtk.cc',
'<(DEPTH)/chrome/browser/ui/gtk/menu_gtk.h',
'<(DEPTH)/chrome/browser/ui/views/event_utils.cc',
'<(DEPTH)/chrome/browser/ui/views/event_utils.h',
],
}],
],

View File

@ -17,6 +17,7 @@
'include/cef_callback.h',
'include/cef_client.h',
'include/cef_command_line.h',
'include/cef_context_menu_handler.h',
'include/cef_cookie.h',
'include/cef_display_handler.h',
'include/cef_frame.h',
@ -24,6 +25,7 @@
'include/cef_jsdialog_handler.h',
'include/cef_life_span_handler.h',
'include/cef_load_handler.h',
'include/cef_menu_model.h',
'include/cef_origin_whitelist.h',
'include/cef_process_message.h',
'include/cef_proxy_handler.h',
@ -49,6 +51,7 @@
'include/capi/cef_callback_capi.h',
'include/capi/cef_client_capi.h',
'include/capi/cef_command_line_capi.h',
'include/capi/cef_context_menu_handler_capi.h',
'include/capi/cef_cookie_capi.h',
'include/capi/cef_display_handler_capi.h',
'include/capi/cef_frame_capi.h',
@ -56,6 +59,7 @@
'include/capi/cef_jsdialog_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',
'include/capi/cef_origin_whitelist_capi.h',
'include/capi/cef_process_message_capi.h',
'include/capi/cef_proxy_handler_capi.h',
@ -92,6 +96,10 @@
'libcef_dll/ctocpp/client_ctocpp.h',
'libcef_dll/cpptoc/command_line_cpptoc.cc',
'libcef_dll/cpptoc/command_line_cpptoc.h',
'libcef_dll/ctocpp/context_menu_handler_ctocpp.cc',
'libcef_dll/ctocpp/context_menu_handler_ctocpp.h',
'libcef_dll/cpptoc/context_menu_params_cpptoc.cc',
'libcef_dll/cpptoc/context_menu_params_cpptoc.h',
'libcef_dll/cpptoc/cookie_manager_cpptoc.cc',
'libcef_dll/cpptoc/cookie_manager_cpptoc.h',
'libcef_dll/ctocpp/cookie_visitor_ctocpp.cc',
@ -116,6 +124,8 @@
'libcef_dll/cpptoc/list_value_cpptoc.h',
'libcef_dll/ctocpp/load_handler_ctocpp.cc',
'libcef_dll/ctocpp/load_handler_ctocpp.h',
'libcef_dll/cpptoc/menu_model_cpptoc.cc',
'libcef_dll/cpptoc/menu_model_cpptoc.h',
'libcef_dll/cpptoc/post_data_cpptoc.cc',
'libcef_dll/cpptoc/post_data_cpptoc.h',
'libcef_dll/cpptoc/post_data_element_cpptoc.cc',
@ -182,6 +192,10 @@
'libcef_dll/cpptoc/client_cpptoc.h',
'libcef_dll/ctocpp/command_line_ctocpp.cc',
'libcef_dll/ctocpp/command_line_ctocpp.h',
'libcef_dll/cpptoc/context_menu_handler_cpptoc.cc',
'libcef_dll/cpptoc/context_menu_handler_cpptoc.h',
'libcef_dll/ctocpp/context_menu_params_ctocpp.cc',
'libcef_dll/ctocpp/context_menu_params_ctocpp.h',
'libcef_dll/ctocpp/cookie_manager_ctocpp.cc',
'libcef_dll/ctocpp/cookie_manager_ctocpp.h',
'libcef_dll/cpptoc/cookie_visitor_cpptoc.cc',
@ -206,6 +220,8 @@
'libcef_dll/ctocpp/list_value_ctocpp.h',
'libcef_dll/cpptoc/load_handler_cpptoc.cc',
'libcef_dll/cpptoc/load_handler_cpptoc.h',
'libcef_dll/ctocpp/menu_model_ctocpp.cc',
'libcef_dll/ctocpp/menu_model_ctocpp.h',
'libcef_dll/ctocpp/post_data_ctocpp.cc',
'libcef_dll/ctocpp/post_data_ctocpp.h',
'libcef_dll/ctocpp/post_data_element_ctocpp.cc',

View File

@ -92,6 +92,13 @@ typedef struct _cef_client_t {
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

@ -0,0 +1,221 @@
// 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_CONTEXT_MENU_HANDLER_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "include/capi/cef_base_capi.h"
///
// Implement this structure to handle context menu events. The functions of this
// structure will be called on the UI thread.
///
typedef struct _cef_context_menu_handler_t {
///
// Base structure.
///
cef_base_t base;
///
// Called before a context menu is displayed. |params| provides information
// about the context menu state. |model| initially contains the default
// context menu. The |model| can be cleared to show no context menu or
// modified to show a custom menu. Do not keep references to |params| or
// |model| outside of this callback.
///
void (CEF_CALLBACK *on_before_context_menu)(
struct _cef_context_menu_handler_t* self, struct _cef_browser_t* browser,
struct _cef_frame_t* frame, struct _cef_context_menu_params_t* params,
struct _cef_menu_model_t* model);
///
// Called to execute a command selected from the context menu. Return true (1)
// if the command was handled or false (0) for the default implementation. See
// cef_menu_id_t for the command ids that have default implementations. All
// user-defined command ids should be between MENU_ID_USER_FIRST and
// MENU_ID_USER_LAST. |params| will have the same values as what was passed to
// on_before_context_menu(). Do not keep a reference to |params| outside of
// this callback.
///
int (CEF_CALLBACK *on_context_menu_command)(
struct _cef_context_menu_handler_t* self, struct _cef_browser_t* browser,
struct _cef_frame_t* frame, struct _cef_context_menu_params_t* params,
int command_id, enum cef_event_flags_t event_flags);
///
// Called when the context menu is dismissed irregardless of whether the menu
// was NULL or a command was selected.
///
void (CEF_CALLBACK *on_context_menu_dismissed)(
struct _cef_context_menu_handler_t* self, struct _cef_browser_t* browser,
struct _cef_frame_t* frame);
} cef_context_menu_handler_t;
///
// Provides information about the context menu state. The ethods of this
// structure can only be accessed on browser process the UI thread.
///
typedef struct _cef_context_menu_params_t {
///
// Base structure.
///
cef_base_t base;
///
// Returns the X coordinate of the mouse where the context menu was invoked.
// Coords are relative to the associated RenderView's origin.
///
int (CEF_CALLBACK *get_xcoord)(struct _cef_context_menu_params_t* self);
///
// Returns the Y coordinate of the mouse where the context menu was invoked.
// Coords are relative to the associated RenderView's origin.
///
int (CEF_CALLBACK *get_ycoord)(struct _cef_context_menu_params_t* self);
///
// Returns flags representing the type of node that the context menu was
// invoked on.
///
enum cef_context_menu_type_flags_t (CEF_CALLBACK *get_type_flags)(
struct _cef_context_menu_params_t* self);
///
// Returns the URL of the link, if any, that encloses the node that the
// context menu was invoked on.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_link_url)(
struct _cef_context_menu_params_t* self);
///
// Returns the link URL, if any, to be used ONLY for "copy link address". We
// don't validate this field in the frontend process.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_unfiltered_link_url)(
struct _cef_context_menu_params_t* self);
///
// Returns the source URL, if any, for the element that the context menu was
// invoked on. Example of elements with source URLs are img, audio, and video.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_source_url)(
struct _cef_context_menu_params_t* self);
///
// Returns true (1) if the context menu was invoked on a blocked image.
///
int (CEF_CALLBACK *is_image_blocked)(struct _cef_context_menu_params_t* self);
///
// Returns the URL of the top level page that the context menu was invoked on.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_page_url)(
struct _cef_context_menu_params_t* self);
///
// Returns the URL of the subframe that the context menu was invoked on.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_frame_url)(
struct _cef_context_menu_params_t* self);
///
// Returns the character encoding of the subframe that the context menu was
// invoked on.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_frame_charset)(
struct _cef_context_menu_params_t* self);
///
// Returns the type of context node that the context menu was invoked on.
///
enum cef_context_menu_media_type_t (CEF_CALLBACK *get_media_type)(
struct _cef_context_menu_params_t* self);
///
// Returns flags representing the actions supported by the media element, if
// any, that the context menu was invoked on.
///
enum cef_context_menu_media_state_flags_t (
CEF_CALLBACK *get_media_state_flags)(
struct _cef_context_menu_params_t* self);
///
// Returns the text of the selection, if any, that the context menu was
// invoked on.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_selection_text)(
struct _cef_context_menu_params_t* self);
///
// Returns true (1) if the context menu was invoked on an editable node.
///
int (CEF_CALLBACK *is_editable)(struct _cef_context_menu_params_t* self);
///
// Returns true (1) if the context menu was invoked on an editable node where
// speech-input is enabled.
///
int (CEF_CALLBACK *is_speech_input_enabled)(
struct _cef_context_menu_params_t* self);
///
// Returns flags representing the actions supported by the editable node, if
// any, that the context menu was invoked on.
///
enum cef_context_menu_edit_state_flags_t (CEF_CALLBACK *get_edit_state_flags)(
struct _cef_context_menu_params_t* self);
} cef_context_menu_params_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_

View File

@ -0,0 +1,388 @@
// 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_MENU_MODEL_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_MENU_MODEL_CAPI_H_
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "include/capi/cef_base_capi.h"
///
// Supports creation and modification of menus. See cef_menu_id_t for the
// command ids that have default implementations. All user-defined command ids
// should be between MENU_ID_USER_FIRST and MENU_ID_USER_LAST. The functions of
// this structure can only be accessed on the browser process the UI thread.
///
typedef struct _cef_menu_model_t {
///
// Base structure.
///
cef_base_t base;
///
// Clears the menu. Returns true (1) on success.
///
int (CEF_CALLBACK *clear)(struct _cef_menu_model_t* self);
///
// Returns the number of items in this menu.
///
int (CEF_CALLBACK *get_count)(struct _cef_menu_model_t* self);
//
// Add a separator to the menu. Returns true (1) on success.
///
int (CEF_CALLBACK *add_separator)(struct _cef_menu_model_t* self);
//
// Add an item to the menu. Returns true (1) on success.
///
int (CEF_CALLBACK *add_item)(struct _cef_menu_model_t* self, int command_id,
const cef_string_t* label);
//
// Add a check item to the menu. Returns true (1) on success.
///
int (CEF_CALLBACK *add_check_item)(struct _cef_menu_model_t* self,
int command_id, const cef_string_t* label);
//
// Add a radio item to the menu. Only a single item with the specified
// |group_id| can be checked at a time. Returns true (1) on success.
///
int (CEF_CALLBACK *add_radio_item)(struct _cef_menu_model_t* self,
int command_id, const cef_string_t* label, int group_id);
//
// Add a sub-menu to the menu. The new sub-menu is returned.
///
struct _cef_menu_model_t* (CEF_CALLBACK *add_sub_menu)(
struct _cef_menu_model_t* self, int command_id,
const cef_string_t* label);
//
// Insert a separator in the menu at the specified |index|. Returns true (1)
// on success.
///
int (CEF_CALLBACK *insert_separator_at)(struct _cef_menu_model_t* self,
int index);
//
// Insert an item in the menu at the specified |index|. Returns true (1) on
// success.
///
int (CEF_CALLBACK *insert_item_at)(struct _cef_menu_model_t* self, int index,
int command_id, const cef_string_t* label);
//
// Insert a check item in the menu at the specified |index|. Returns true (1)
// on success.
///
int (CEF_CALLBACK *insert_check_item_at)(struct _cef_menu_model_t* self,
int index, int command_id, const cef_string_t* label);
//
// Insert a radio item in the menu at the specified |index|. Only a single
// item with the specified |group_id| can be checked at a time. Returns true
// (1) on success.
///
int (CEF_CALLBACK *insert_radio_item_at)(struct _cef_menu_model_t* self,
int index, int command_id, const cef_string_t* label, int group_id);
//
// Insert a sub-menu in the menu at the specified |index|. The new sub-menu is
// returned.
///
struct _cef_menu_model_t* (CEF_CALLBACK *insert_sub_menu_at)(
struct _cef_menu_model_t* self, int index, int command_id,
const cef_string_t* label);
///
// Removes the item with the specified |command_id|. Returns true (1) on
// success.
///
int (CEF_CALLBACK *remove)(struct _cef_menu_model_t* self, int command_id);
///
// Removes the item at the specified |index|. Returns true (1) on success.
///
int (CEF_CALLBACK *remove_at)(struct _cef_menu_model_t* self, int index);
///
// Returns the index associated with the specified |command_id| or -1 if not
// found due to the command id not existing in the menu.
///
int (CEF_CALLBACK *get_index_of)(struct _cef_menu_model_t* self,
int command_id);
///
// Returns the command id at the specified |index| or -1 if not found due to
// invalid range or the index being a separator.
///
int (CEF_CALLBACK *get_command_id_at)(struct _cef_menu_model_t* self,
int index);
///
// Sets the command id at the specified |index|. Returns true (1) on success.
///
int (CEF_CALLBACK *set_command_id_at)(struct _cef_menu_model_t* self,
int index, int command_id);
///
// Returns the label for the specified |command_id| or NULL if not found.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_label)(
struct _cef_menu_model_t* self, int command_id);
///
// Returns the label at the specified |index| or NULL if not found due to
// invalid range or the index being a separator.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_label_at)(
struct _cef_menu_model_t* self, int index);
///
// Sets the label for the specified |command_id|. Returns true (1) on success.
///
int (CEF_CALLBACK *set_label)(struct _cef_menu_model_t* self, int command_id,
const cef_string_t* label);
///
// Set the label at the specified |index|. Returns true (1) on success.
///
int (CEF_CALLBACK *set_label_at)(struct _cef_menu_model_t* self, int index,
const cef_string_t* label);
///
// Returns the item type for the specified |command_id|.
///
enum cef_menu_item_type_t (CEF_CALLBACK *get_type)(
struct _cef_menu_model_t* self, int command_id);
///
// Returns the item type at the specified |index|.
///
enum cef_menu_item_type_t (CEF_CALLBACK *get_type_at)(
struct _cef_menu_model_t* self, int index);
///
// Returns the group id for the specified |command_id| or -1 if invalid.
///
int (CEF_CALLBACK *get_group_id)(struct _cef_menu_model_t* self,
int command_id);
///
// Returns the group id at the specified |index| or -1 if invalid.
///
int (CEF_CALLBACK *get_group_id_at)(struct _cef_menu_model_t* self,
int index);
///
// Sets the group id for the specified |command_id|. Returns true (1) on
// success.
///
int (CEF_CALLBACK *set_group_id)(struct _cef_menu_model_t* self,
int command_id, int group_id);
///
// Sets the group id at the specified |index|. Returns true (1) on success.
///
int (CEF_CALLBACK *set_group_id_at)(struct _cef_menu_model_t* self, int index,
int group_id);
///
// Returns the submenu for the specified |command_id| or NULL if invalid.
///
struct _cef_menu_model_t* (CEF_CALLBACK *get_sub_menu)(
struct _cef_menu_model_t* self, int command_id);
///
// Returns the submenu at the specified |index| or NULL if invalid.
///
struct _cef_menu_model_t* (CEF_CALLBACK *get_sub_menu_at)(
struct _cef_menu_model_t* self, int index);
//
// Returns true (1) if the specified |command_id| is visible.
///
int (CEF_CALLBACK *is_visible)(struct _cef_menu_model_t* self,
int command_id);
//
// Returns true (1) if the specified |index| is visible.
///
int (CEF_CALLBACK *is_visible_at)(struct _cef_menu_model_t* self, int index);
//
// Change the visibility of the specified |command_id|. Returns true (1) on
// success.
///
int (CEF_CALLBACK *set_visible)(struct _cef_menu_model_t* self,
int command_id, int visible);
//
// Change the visibility at the specified |index|. Returns true (1) on
// success.
///
int (CEF_CALLBACK *set_visible_at)(struct _cef_menu_model_t* self, int index,
int visible);
//
// Returns true (1) if the specified |command_id| is enabled.
///
int (CEF_CALLBACK *is_enabled)(struct _cef_menu_model_t* self,
int command_id);
//
// Returns true (1) if the specified |index| is enabled.
///
int (CEF_CALLBACK *is_enabled_at)(struct _cef_menu_model_t* self, int index);
//
// Change the enabled status of the specified |command_id|. Returns true (1)
// on success.
///
int (CEF_CALLBACK *set_enabled)(struct _cef_menu_model_t* self,
int command_id, int enabled);
//
// Change the enabled status at the specified |index|. Returns true (1) on
// success.
///
int (CEF_CALLBACK *set_enabled_at)(struct _cef_menu_model_t* self, int index,
int enabled);
//
// Returns true (1) if the specified |command_id| is checked. Only applies to
// check and radio items.
///
int (CEF_CALLBACK *is_checked)(struct _cef_menu_model_t* self,
int command_id);
//
// Returns true (1) if the specified |index| is checked. Only applies to check
// and radio items.
///
int (CEF_CALLBACK *is_checked_at)(struct _cef_menu_model_t* self, int index);
//
// Check the specified |command_id|. Only applies to check and radio items.
// Returns true (1) on success.
///
int (CEF_CALLBACK *set_checked)(struct _cef_menu_model_t* self,
int command_id, int checked);
//
// Check the specified |index|. Only applies to check and radio items. Returns
// true (1) on success.
///
int (CEF_CALLBACK *set_checked_at)(struct _cef_menu_model_t* self, int index,
int checked);
//
// Returns true (1) if the specified |command_id| has a keyboard accelerator
// assigned.
///
int (CEF_CALLBACK *has_accelerator)(struct _cef_menu_model_t* self,
int command_id);
//
// Returns true (1) if the specified |index| has a keyboard accelerator
// assigned.
///
int (CEF_CALLBACK *has_accelerator_at)(struct _cef_menu_model_t* self,
int index);
//
// Set the keyboard accelerator for the specified |command_id|. |key_code| can
// be any virtual key or character value. Returns true (1) on success.
///
int (CEF_CALLBACK *set_accelerator)(struct _cef_menu_model_t* self,
int command_id, int key_code, int shift_pressed, int ctrl_pressed,
int alt_pressed);
//
// Set the keyboard accelerator at the specified |index|. |key_code| can be
// any virtual key or character value. Returns true (1) on success.
///
int (CEF_CALLBACK *set_accelerator_at)(struct _cef_menu_model_t* self,
int index, int key_code, int shift_pressed, int ctrl_pressed,
int alt_pressed);
//
// Remove the keyboard accelerator for the specified |command_id|. Returns
// true (1) on success.
///
int (CEF_CALLBACK *remove_accelerator)(struct _cef_menu_model_t* self,
int command_id);
//
// Remove the keyboard accelerator at the specified |index|. Returns true (1)
// on success.
///
int (CEF_CALLBACK *remove_accelerator_at)(struct _cef_menu_model_t* self,
int index);
//
// Retrieves the keyboard accelerator for the specified |command_id|. Returns
// true (1) on success.
///
int (CEF_CALLBACK *get_accelerator)(struct _cef_menu_model_t* self,
int command_id, int* key_code, int* shift_pressed, int* ctrl_pressed,
int* alt_pressed);
//
// Retrieves the keyboard accelerator for the specified |index|. Returns true
// (1) on success.
///
int (CEF_CALLBACK *get_accelerator_at)(struct _cef_menu_model_t* self,
int index, int* key_code, int* shift_pressed, int* ctrl_pressed,
int* alt_pressed);
} cef_menu_model_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_MENU_MODEL_CAPI_H_

View File

@ -59,12 +59,7 @@ typedef struct _cef_resource_bundle_handler_t {
// Called to retrieve a localized translation for the string specified by
// |message_id|. To provide the translation set |string| to the translation
// string and return true (1). To use the default translation return false
// (0).
//
// WARNING: Be cautious when implementing this function. ID values are auto-
// generated when CEF is built and may change between versions. Existing ID
// values can be discovered by searching for *_strings.h in the
// "obj/global_intermediate" build output directory.
// (0). Supported message IDs are listed in cef_pack_strings.h.
///
int (CEF_CALLBACK *get_localized_string)(
struct _cef_resource_bundle_handler_t* self, int message_id,
@ -75,12 +70,8 @@ typedef struct _cef_resource_bundle_handler_t {
// provide the resource data set |data| and |data_size| to the data pointer
// and size respectively and return true (1). To use the default resource data
// return false (0). The resource data will not be copied and must remain
// resident in memory.
//
// WARNING: Be cautious when implementing this function. ID values are auto-
// generated when CEF is built and may change between versions. Existing ID
// values can be discovered by searching for *_resources.h in the
// "obj/global_intermediate" build output directory.
// resident in memory. Supported resource IDs are listed in
// cef_pack_resources.h.
///
int (CEF_CALLBACK *get_data_resource)(
struct _cef_resource_bundle_handler_t* self, int resource_id, void** data,

View File

@ -39,6 +39,7 @@
#pragma once
#include "include/cef_base.h"
#include "include/cef_context_menu_handler.h"
#include "include/cef_display_handler.h"
#include "include/cef_geolocation_handler.h"
#include "include/cef_jsdialog_handler.h"
@ -103,6 +104,15 @@ class CefClient : public virtual CefBase {
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

@ -0,0 +1,216 @@
// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// The contents of this file must follow a specific format in order to
// support the CEF translator tool. See the translator.README.txt file in the
// tools directory for more information.
//
#ifndef CEF_INCLUDE_CEF_CONTEXT_MENU_HANDLER_H_
#define CEF_INCLUDE_CEF_CONTEXT_MENU_HANDLER_H_
#pragma once
#include "include/cef_base.h"
#include "include/cef_browser.h"
#include "include/cef_frame.h"
#include "include/cef_menu_model.h"
class CefContextMenuParams;
///
// Implement this interface to handle context menu events. The methods of this
// class will be called on the UI thread.
///
/*--cef(source=client)--*/
class CefContextMenuHandler : public virtual CefBase {
public:
typedef cef_event_flags_t EventFlags;
///
// Called before a context menu is displayed. |params| provides information
// about the context menu state. |model| initially contains the default
// context menu. The |model| can be cleared to show no context menu or
// modified to show a custom menu. Do not keep references to |params| or
// |model| outside of this callback.
///
/*--cef()--*/
virtual void OnBeforeContextMenu(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefContextMenuParams> params,
CefRefPtr<CefMenuModel> model) {}
///
// Called to execute a command selected from the context menu. Return true if
// the command was handled or false for the default implementation. See
// cef_menu_id_t for the command ids that have default implementations. All
// user-defined command ids should be between MENU_ID_USER_FIRST and
// MENU_ID_USER_LAST. |params| will have the same values as what was passed to
// OnBeforeContextMenu(). Do not keep a reference to |params| outside of this
// callback.
///
/*--cef()--*/
virtual bool OnContextMenuCommand(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefContextMenuParams> params,
int command_id,
EventFlags event_flags) { return false; }
///
// Called when the context menu is dismissed irregardless of whether the menu
// was empty or a command was selected.
///
/*--cef()--*/
virtual void OnContextMenuDismissed(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame) {}
};
///
// Provides information about the context menu state. The ethods of this class
// can only be accessed on browser process the UI thread.
///
/*--cef(source=library)--*/
class CefContextMenuParams : public virtual CefBase {
public:
typedef cef_context_menu_type_flags_t TypeFlags;
typedef cef_context_menu_media_type_t MediaType;
typedef cef_context_menu_media_state_flags_t MediaStateFlags;
typedef cef_context_menu_edit_state_flags_t EditStateFlags;
///
// Returns the X coordinate of the mouse where the context menu was invoked.
// Coords are relative to the associated RenderView's origin.
///
/*--cef()--*/
virtual int GetXCoord() =0;
///
// Returns the Y coordinate of the mouse where the context menu was invoked.
// Coords are relative to the associated RenderView's origin.
///
/*--cef()--*/
virtual int GetYCoord() =0;
///
// Returns flags representing the type of node that the context menu was
// invoked on.
///
/*--cef(default_retval=CM_TYPEFLAG_NONE)--*/
virtual TypeFlags GetTypeFlags() =0;
///
// Returns the URL of the link, if any, that encloses the node that the
// context menu was invoked on.
///
/*--cef()--*/
virtual CefString GetLinkUrl() =0;
///
// Returns the link URL, if any, to be used ONLY for "copy link address". We
// don't validate this field in the frontend process.
///
/*--cef()--*/
virtual CefString GetUnfilteredLinkUrl() =0;
///
// Returns the source URL, if any, for the element that the context menu was
// invoked on. Example of elements with source URLs are img, audio, and video.
///
/*--cef()--*/
virtual CefString GetSourceUrl() =0;
///
// Returns true if the context menu was invoked on a blocked image.
///
/*--cef()--*/
virtual bool IsImageBlocked() =0;
///
// Returns the URL of the top level page that the context menu was invoked on.
///
/*--cef()--*/
virtual CefString GetPageUrl() =0;
///
// Returns the URL of the subframe that the context menu was invoked on.
///
/*--cef()--*/
virtual CefString GetFrameUrl() =0;
///
// Returns the character encoding of the subframe that the context menu was
// invoked on.
///
/*--cef()--*/
virtual CefString GetFrameCharset() =0;
///
// Returns the type of context node that the context menu was invoked on.
///
/*--cef(default_retval=CM_MEDIATYPE_NONE)--*/
virtual MediaType GetMediaType() =0;
///
// Returns flags representing the actions supported by the media element, if
// any, that the context menu was invoked on.
///
/*--cef(default_retval=CM_MEDIAFLAG_NONE)--*/
virtual MediaStateFlags GetMediaStateFlags() =0;
///
// Returns the text of the selection, if any, that the context menu was
// invoked on.
///
/*--cef()--*/
virtual CefString GetSelectionText() =0;
///
// Returns true if the context menu was invoked on an editable node.
///
/*--cef()--*/
virtual bool IsEditable() =0;
///
// Returns true if the context menu was invoked on an editable node where
// speech-input is enabled.
///
/*--cef()--*/
virtual bool IsSpeechInputEnabled() =0;
///
// Returns flags representing the actions supported by the editable node, if
// any, that the context menu was invoked on.
///
/*--cef(default_retval=CM_EDITFLAG_NONE)--*/
virtual EditStateFlags GetEditStateFlags() =0;
};
#endif // CEF_INCLUDE_CEF_CONTEXT_MENU_HANDLER_H_

402
include/cef_menu_model.h Normal file
View File

@ -0,0 +1,402 @@
// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// The contents of this file must follow a specific format in order to
// support the CEF translator tool. See the translator.README.txt file in the
// tools directory for more information.
//
#ifndef CEF_INCLUDE_CEF_MENU_MODEL_H_
#define CEF_INCLUDE_CEF_MENU_MODEL_H_
#pragma once
#include "include/cef_base.h"
///
// Supports creation and modification of menus. See cef_menu_id_t for the
// command ids that have default implementations. All user-defined command ids
// should be between MENU_ID_USER_FIRST and MENU_ID_USER_LAST. The methods of
// this class can only be accessed on the browser process the UI thread.
///
/*--cef(source=library)--*/
class CefMenuModel : public virtual CefBase {
public:
typedef cef_menu_item_type_t MenuItemType;
///
// Clears the menu. Returns true on success.
///
/*--cef()--*/
virtual bool Clear() =0;
///
// Returns the number of items in this menu.
///
/*--cef()--*/
virtual int GetCount() =0;
//
// Add a separator to the menu. Returns true on success.
///
/*--cef()--*/
virtual bool AddSeparator() =0;
//
// Add an item to the menu. Returns true on success.
///
/*--cef()--*/
virtual bool AddItem(int command_id,
const CefString& label) =0;
//
// Add a check item to the menu. Returns true on success.
///
/*--cef()--*/
virtual bool AddCheckItem(int command_id,
const CefString& label) =0;
//
// Add a radio item to the menu. Only a single item with the specified
// |group_id| can be checked at a time. Returns true on success.
///
/*--cef()--*/
virtual bool AddRadioItem(int command_id,
const CefString& label,
int group_id) =0;
//
// Add a sub-menu to the menu. The new sub-menu is returned.
///
/*--cef()--*/
virtual CefRefPtr<CefMenuModel> AddSubMenu(int command_id,
const CefString& label) =0;
//
// Insert a separator in the menu at the specified |index|. Returns true on
// success.
///
/*--cef()--*/
virtual bool InsertSeparatorAt(int index) =0;
//
// Insert an item in the menu at the specified |index|. Returns true on
// success.
///
/*--cef()--*/
virtual bool InsertItemAt(int index,
int command_id,
const CefString& label) =0;
//
// Insert a check item in the menu at the specified |index|. Returns true on
// success.
///
/*--cef()--*/
virtual bool InsertCheckItemAt(int index,
int command_id,
const CefString& label) =0;
//
// Insert a radio item in the menu at the specified |index|. Only a single
// item with the specified |group_id| can be checked at a time. Returns true
// on success.
///
/*--cef()--*/
virtual bool InsertRadioItemAt(int index,
int command_id,
const CefString& label,
int group_id) =0;
//
// Insert a sub-menu in the menu at the specified |index|. The new sub-menu
// is returned.
///
/*--cef()--*/
virtual CefRefPtr<CefMenuModel> InsertSubMenuAt(int index,
int command_id,
const CefString& label) =0;
///
// Removes the item with the specified |command_id|. Returns true on success.
///
/*--cef()--*/
virtual bool Remove(int command_id) =0;
///
// Removes the item at the specified |index|. Returns true on success.
///
/*--cef()--*/
virtual bool RemoveAt(int index) =0;
///
// Returns the index associated with the specified |command_id| or -1 if not
// found due to the command id not existing in the menu.
///
/*--cef()--*/
virtual int GetIndexOf(int command_id) =0;
///
// Returns the command id at the specified |index| or -1 if not found due to
// invalid range or the index being a separator.
///
/*--cef()--*/
virtual int GetCommandIdAt(int index) =0;
///
// Sets the command id at the specified |index|. Returns true on success.
///
/*--cef()--*/
virtual bool SetCommandIdAt(int index, int command_id) =0;
///
// Returns the label for the specified |command_id| or empty if not found.
///
/*--cef()--*/
virtual CefString GetLabel(int command_id) =0;
///
// Returns the label at the specified |index| or empty if not found due to
// invalid range or the index being a separator.
///
/*--cef()--*/
virtual CefString GetLabelAt(int index) =0;
///
// Sets the label for the specified |command_id|. Returns true on success.
///
/*--cef()--*/
virtual bool SetLabel(int command_id, const CefString& label) =0;
///
// Set the label at the specified |index|. Returns true on success.
///
/*--cef()--*/
virtual bool SetLabelAt(int index, const CefString& label) =0;
///
// Returns the item type for the specified |command_id|.
///
/*--cef(default_retval=MENUITEMTYPE_NONE)--*/
virtual MenuItemType GetType(int command_id) =0;
///
// Returns the item type at the specified |index|.
///
/*--cef(default_retval=MENUITEMTYPE_NONE)--*/
virtual MenuItemType GetTypeAt(int index) =0;
///
// Returns the group id for the specified |command_id| or -1 if invalid.
///
/*--cef()--*/
virtual int GetGroupId(int command_id) =0;
///
// Returns the group id at the specified |index| or -1 if invalid.
///
/*--cef()--*/
virtual int GetGroupIdAt(int index) =0;
///
// Sets the group id for the specified |command_id|. Returns true on success.
///
/*--cef()--*/
virtual bool SetGroupId(int command_id, int group_id) =0;
///
// Sets the group id at the specified |index|. Returns true on success.
///
/*--cef()--*/
virtual bool SetGroupIdAt(int index, int group_id) =0;
///
// Returns the submenu for the specified |command_id| or empty if invalid.
///
/*--cef()--*/
virtual CefRefPtr<CefMenuModel> GetSubMenu(int command_id) =0;
///
// Returns the submenu at the specified |index| or empty if invalid.
///
/*--cef()--*/
virtual CefRefPtr<CefMenuModel> GetSubMenuAt(int index) =0;
//
// Returns true if the specified |command_id| is visible.
///
/*--cef()--*/
virtual bool IsVisible(int command_id) =0;
//
// Returns true if the specified |index| is visible.
///
/*--cef()--*/
virtual bool IsVisibleAt(int index) =0;
//
// Change the visibility of the specified |command_id|. Returns true on
// success.
///
/*--cef()--*/
virtual bool SetVisible(int command_id, bool visible) =0;
//
// Change the visibility at the specified |index|. Returns true on success.
///
/*--cef()--*/
virtual bool SetVisibleAt(int index, bool visible) =0;
//
// Returns true if the specified |command_id| is enabled.
///
/*--cef()--*/
virtual bool IsEnabled(int command_id) =0;
//
// Returns true if the specified |index| is enabled.
///
/*--cef()--*/
virtual bool IsEnabledAt(int index) =0;
//
// Change the enabled status of the specified |command_id|. Returns true on
// success.
///
/*--cef()--*/
virtual bool SetEnabled(int command_id, bool enabled) =0;
//
// Change the enabled status at the specified |index|. Returns true on
// success.
///
/*--cef()--*/
virtual bool SetEnabledAt(int index, bool enabled) =0;
//
// Returns true if the specified |command_id| is checked. Only applies to
// check and radio items.
///
/*--cef()--*/
virtual bool IsChecked(int command_id) =0;
//
// Returns true if the specified |index| is checked. Only applies to check
// and radio items.
///
/*--cef()--*/
virtual bool IsCheckedAt(int index) =0;
//
// Check the specified |command_id|. Only applies to check and radio items.
// Returns true on success.
///
/*--cef()--*/
virtual bool SetChecked(int command_id, bool checked) =0;
//
// Check the specified |index|. Only applies to check and radio items. Returns
// true on success.
///
/*--cef()--*/
virtual bool SetCheckedAt(int index, bool checked) =0;
//
// Returns true if the specified |command_id| has a keyboard accelerator
// assigned.
///
/*--cef()--*/
virtual bool HasAccelerator(int command_id) =0;
//
// Returns true if the specified |index| has a keyboard accelerator assigned.
///
/*--cef()--*/
virtual bool HasAcceleratorAt(int index) =0;
//
// Set the keyboard accelerator for the specified |command_id|. |key_code| can
// be any virtual key or character value. Returns true on success.
///
/*--cef()--*/
virtual bool SetAccelerator(int command_id,
int key_code,
bool shift_pressed,
bool ctrl_pressed,
bool alt_pressed) =0;
//
// Set the keyboard accelerator at the specified |index|. |key_code| can be
// any virtual key or character value. Returns true on success.
///
/*--cef()--*/
virtual bool SetAcceleratorAt(int index,
int key_code,
bool shift_pressed,
bool ctrl_pressed,
bool alt_pressed) =0;
//
// Remove the keyboard accelerator for the specified |command_id|. Returns
// true on success.
///
/*--cef()--*/
virtual bool RemoveAccelerator(int command_id) =0;
//
// Remove the keyboard accelerator at the specified |index|. Returns true on
// success.
///
/*--cef()--*/
virtual bool RemoveAcceleratorAt(int index) =0;
//
// Retrieves the keyboard accelerator for the specified |command_id|. Returns
// true on success.
///
/*--cef()--*/
virtual bool GetAccelerator(int command_id,
int& key_code,
bool& shift_pressed,
bool& ctrl_pressed,
bool& alt_pressed) =0;
//
// Retrieves the keyboard accelerator for the specified |index|. Returns true
// on success.
///
/*--cef()--*/
virtual bool GetAcceleratorAt(int index,
int& key_code,
bool& shift_pressed,
bool& ctrl_pressed,
bool& alt_pressed) =0;
};
#endif // CEF_INCLUDE_CEF_MENU_MODEL_H_

View File

@ -51,11 +51,7 @@ class CefResourceBundleHandler : public virtual CefBase {
// Called to retrieve a localized translation for the string specified by
// |message_id|. To provide the translation set |string| to the translation
// string and return true. To use the default translation return false.
//
// WARNING: Be cautious when implementing this method. ID values are auto-
// generated when CEF is built and may change between versions. Existing ID
// values can be discovered by searching for *_strings.h in the
// "obj/global_intermediate" build output directory.
// Supported message IDs are listed in cef_pack_strings.h.
///
/*--cef()--*/
virtual bool GetLocalizedString(int message_id,
@ -66,12 +62,7 @@ class CefResourceBundleHandler : public virtual CefBase {
// provide the resource data set |data| and |data_size| to the data pointer
// and size respectively and return true. To use the default resource data
// return false. The resource data will not be copied and must remain resident
// in memory.
//
// WARNING: Be cautious when implementing this method. ID values are auto-
// generated when CEF is built and may change between versions. Existing ID
// values can be discovered by searching for *_resources.h in the
// "obj/global_intermediate" build output directory.
// in memory. Supported resource IDs are listed in cef_pack_resources.h.
///
/*--cef()--*/
virtual bool GetDataResource(int resource_id,

View File

@ -778,6 +778,165 @@ enum cef_jsdialog_type_t {
JSDIALOGTYPE_PROMPT,
};
///
// Supported menu IDs. Non-English translations can be provided for the
// IDS_MENU_* strings in CefResourceBundleHandler::GetLocalizedString().
///
enum cef_menu_id_t {
// Navigation.
MENU_ID_BACK = 100,
MENU_ID_FORWARD = 101,
MENU_ID_RELOAD = 102,
MENU_ID_RELOAD_NOCACHE = 103,
MENU_ID_STOPLOAD = 104,
// Editing.
MENU_ID_UNDO = 110,
MENU_ID_REDO = 111,
MENU_ID_CUT = 112,
MENU_ID_COPY = 113,
MENU_ID_PASTE = 114,
MENU_ID_DELETE = 115,
MENU_ID_SELECT_ALL = 116,
// Miscellaneous.
MENU_ID_FIND = 130,
MENU_ID_PRINT = 131,
MENU_ID_VIEW_SOURCE = 132,
// All user-defined menu IDs should come between MENU_ID_USER_FIRST and
// MENU_ID_USER_LAST to avoid overlapping the Chromium and CEF ID ranges
// defined in the tools/gritsettings/resource_ids file.
MENU_ID_USER_FIRST = 26500,
MENU_ID_USER_LAST = 28500,
};
///
// Supported event bit flags.
///
enum cef_event_flags_t {
EVENTFLAG_NONE = 0,
EVENTFLAG_CAPS_LOCK_DOWN = 1 << 0,
EVENTFLAG_SHIFT_DOWN = 1 << 1,
EVENTFLAG_CONTROL_DOWN = 1 << 2,
EVENTFLAG_ALT_DOWN = 1 << 3,
EVENTFLAG_LEFT_MOUSE_BUTTON = 1 << 4,
EVENTFLAG_MIDDLE_MOUSE_BUTTON = 1 << 5,
EVENTFLAG_RIGHT_MOUSE_BUTTON = 1 << 6,
// Mac OS-X command key.
EVENTFLAG_COMMAND_DOWN = 1 << 7,
// Windows extended key (see WM_KEYDOWN doc).
EVENTFLAG_EXTENDED = 1 << 8,
};
///
// Supported menu item types.
///
enum cef_menu_item_type_t {
MENUITEMTYPE_NONE,
MENUITEMTYPE_COMMAND,
MENUITEMTYPE_CHECK,
MENUITEMTYPE_RADIO,
MENUITEMTYPE_SEPARATOR,
MENUITEMTYPE_SUBMENU,
};
///
// Supported context menu type flags.
///
enum cef_context_menu_type_flags_t {
///
// No node is selected.
///
CM_TYPEFLAG_NONE = 0,
///
// The top page is selected.
///
CM_TYPEFLAG_PAGE = 1 << 0,
///
// A subframe page is selected.
///
CM_TYPEFLAG_FRAME = 1 << 1,
///
// A link is selected.
///
CM_TYPEFLAG_LINK = 1 << 2,
///
// A media node is selected.
///
CM_TYPEFLAG_MEDIA = 1 << 3,
///
// There is a textual or mixed selection that is selected.
///
CM_TYPEFLAG_SELECTION = 1 << 4,
///
// An editable element is selected.
///
CM_TYPEFLAG_EDITABLE = 1 << 5,
};
///
// Supported context menu media types.
///
enum cef_context_menu_media_type_t {
///
// No special node is in context.
///
CM_MEDIATYPE_NONE,
///
// An image node is selected.
///
CM_MEDIATYPE_IMAGE,
///
// A video node is selected.
///
CM_MEDIATYPE_VIDEO,
///
// An audio node is selected.
///
CM_MEDIATYPE_AUDIO,
///
// A file node is selected.
///
CM_MEDIATYPE_FILE,
///
// A plugin node is selected.
///
CM_MEDIATYPE_PLUGIN,
};
///
// Supported context menu media state bit flags.
///
enum cef_context_menu_media_state_flags_t {
CM_MEDIAFLAG_NONE = 0,
CM_MEDIAFLAG_ERROR = 1 << 0,
CM_MEDIAFLAG_PAUSED = 1 << 1,
CM_MEDIAFLAG_MUTED = 1 << 2,
CM_MEDIAFLAG_LOOP = 1 << 3,
CM_MEDIAFLAG_CAN_SAVE = 1 << 4,
CM_MEDIAFLAG_HAS_AUDIO = 1 << 5,
CM_MEDIAFLAG_HAS_VIDEO = 1 << 6,
CM_MEDIAFLAG_CONTROL_ROOT_ELEMENT = 1 << 7,
CM_MEDIAFLAG_CAN_PRINT = 1 << 8,
CM_MEDIAFLAG_CAN_ROTATE = 1 << 9,
};
///
// Supported context menu edit state bit flags.
///
enum cef_context_menu_edit_state_flags_t {
CM_EDITFLAG_NONE = 0,
CM_EDITFLAG_CAN_UNDO = 1 << 0,
CM_EDITFLAG_CAN_REDO = 1 << 1,
CM_EDITFLAG_CAN_CUT = 1 << 2,
CM_EDITFLAG_CAN_COPY = 1 << 3,
CM_EDITFLAG_CAN_PASTE = 1 << 4,
CM_EDITFLAG_CAN_DELETE = 1 << 5,
CM_EDITFLAG_CAN_SELECT_ALL = 1 << 6,
CM_EDITFLAG_CAN_TRANSLATE = 1 << 7,
};
///
// 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

@ -774,6 +774,13 @@ void CefBrowserHostImpl::LoadingStateChanged(content::WebContents* source) {
}
}
bool CefBrowserHostImpl::HandleContextMenu(
const content::ContextMenuParams& params) {
if (!menu_creator_.get())
menu_creator_.reset(new CefMenuCreator(this));
return menu_creator_->CreateContextMenu(params);
}
bool CefBrowserHostImpl::ShouldCreateWebContents(
content::WebContents* web_contents,
int route_id,

View File

@ -17,6 +17,7 @@
#include "include/cef_frame.h"
#include "libcef/browser/frame_host_impl.h"
#include "libcef/browser/javascript_dialog_creator.h"
#include "libcef/browser/menu_creator.h"
#include "libcef/browser/url_request_context_getter_proxy.h"
#include "libcef/common/response_manager.h"
@ -188,6 +189,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
content::WebContents* source,
const content::OpenURLParams& params) OVERRIDE;
virtual void LoadingStateChanged(content::WebContents* source) OVERRIDE;
virtual bool HandleContextMenu(const content::ContextMenuParams& params)
OVERRIDE;
virtual bool ShouldCreateWebContents(
content::WebContents* web_contents,
int route_id,
@ -357,6 +360,9 @@ class CefBrowserHostImpl : public CefBrowserHost,
// Used for creating and managing JavaScript dialogs.
scoped_ptr<CefJavaScriptDialogCreator> dialog_creator_;
// Used for creating and managing context menus.
scoped_ptr<CefMenuCreator> menu_creator_;
IMPLEMENT_REFCOUNTING(CefBrowserHostImpl);
DISALLOW_EVIL_CONSTRUCTORS(CefBrowserHostImpl);
};

View File

@ -0,0 +1,112 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "libcef/browser/context_menu_params_impl.h"
#include "base/logging.h"
CefContextMenuParamsImpl::CefContextMenuParamsImpl(
content::ContextMenuParams* value)
: CefValueBase<CefContextMenuParams, content::ContextMenuParams>(
value, NULL, kOwnerNoDelete, true,
new CefValueControllerNonThreadSafe()) {
// Indicate that this object owns the controller.
SetOwnsController();
}
int CefContextMenuParamsImpl::GetXCoord() {
CEF_VALUE_VERIFY_RETURN(false, 0);
return const_value().x;
}
int CefContextMenuParamsImpl::GetYCoord() {
CEF_VALUE_VERIFY_RETURN(false, 0);
return const_value().x;
}
CefContextMenuParamsImpl::TypeFlags CefContextMenuParamsImpl::GetTypeFlags() {
CEF_VALUE_VERIFY_RETURN(false, CM_TYPEFLAG_NONE);
const content::ContextMenuParams& params = const_value();
int type_flags = CM_TYPEFLAG_NONE;
if (!params.page_url.is_empty())
type_flags |= CM_TYPEFLAG_PAGE;
if (!params.frame_url.is_empty())
type_flags |= CM_TYPEFLAG_FRAME;
if (!params.link_url.is_empty())
type_flags |= CM_TYPEFLAG_LINK;
if (params.media_type != WebKit::WebContextMenuData::MediaTypeNone)
type_flags |= CM_TYPEFLAG_MEDIA;
if (!params.selection_text.empty())
type_flags |= CM_TYPEFLAG_SELECTION;
if (params.is_editable)
type_flags |= CM_TYPEFLAG_EDITABLE;
return static_cast<TypeFlags>(type_flags);
}
CefString CefContextMenuParamsImpl::GetLinkUrl() {
CEF_VALUE_VERIFY_RETURN(false, CefString());
return const_value().link_url.spec();
}
CefString CefContextMenuParamsImpl::GetUnfilteredLinkUrl() {
CEF_VALUE_VERIFY_RETURN(false, CefString());
return const_value().unfiltered_link_url.spec();
}
CefString CefContextMenuParamsImpl::GetSourceUrl() {
CEF_VALUE_VERIFY_RETURN(false, CefString());
return const_value().src_url.spec();
}
bool CefContextMenuParamsImpl::IsImageBlocked() {
CEF_VALUE_VERIFY_RETURN(false, false);
return const_value().is_image_blocked;
}
CefString CefContextMenuParamsImpl::GetPageUrl() {
CEF_VALUE_VERIFY_RETURN(false, CefString());
return const_value().page_url.spec();
}
CefString CefContextMenuParamsImpl::GetFrameUrl() {
CEF_VALUE_VERIFY_RETURN(false, CefString());
return const_value().frame_url.spec();
}
CefString CefContextMenuParamsImpl::GetFrameCharset() {
CEF_VALUE_VERIFY_RETURN(false, CefString());
return const_value().frame_charset;
}
CefContextMenuParamsImpl::MediaType CefContextMenuParamsImpl::GetMediaType() {
CEF_VALUE_VERIFY_RETURN(false, CM_MEDIATYPE_NONE);
return static_cast<MediaType>(const_value().media_type);
}
CefContextMenuParamsImpl::MediaStateFlags
CefContextMenuParamsImpl::GetMediaStateFlags() {
CEF_VALUE_VERIFY_RETURN(false, CM_MEDIAFLAG_NONE);
return static_cast<MediaStateFlags>(const_value().media_flags);
}
CefString CefContextMenuParamsImpl::GetSelectionText() {
CEF_VALUE_VERIFY_RETURN(false, CefString());
return const_value().selection_text;
}
bool CefContextMenuParamsImpl::IsEditable() {
CEF_VALUE_VERIFY_RETURN(false, false);
return const_value().is_editable;
}
bool CefContextMenuParamsImpl::IsSpeechInputEnabled() {
CEF_VALUE_VERIFY_RETURN(false, false);
return const_value().speech_input_enabled;
}
CefContextMenuParamsImpl::EditStateFlags
CefContextMenuParamsImpl::GetEditStateFlags() {
CEF_VALUE_VERIFY_RETURN(false, CM_EDITFLAG_NONE);
return static_cast<EditStateFlags>(const_value().edit_flags);
}

View File

@ -0,0 +1,41 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_CONTEXT_MENU_PARAMS_IMPL_H_
#define CEF_LIBCEF_BROWSER_CONTEXT_MENU_PARAMS_IMPL_H_
#pragma once
#include "include/cef_context_menu_handler.h"
#include "libcef/common/value_base.h"
#include "content/public/common/context_menu_params.h"
// CefContextMenuParams implementation. This class is not thread safe.
class CefContextMenuParamsImpl
: public CefValueBase<CefContextMenuParams, content::ContextMenuParams> {
public:
explicit CefContextMenuParamsImpl(content::ContextMenuParams* value);
// CefContextMenuParams methods.
virtual int GetXCoord() OVERRIDE;
virtual int GetYCoord() OVERRIDE;
virtual TypeFlags GetTypeFlags() OVERRIDE;
virtual CefString GetLinkUrl() OVERRIDE;
virtual CefString GetUnfilteredLinkUrl() OVERRIDE;
virtual CefString GetSourceUrl() OVERRIDE;
virtual bool IsImageBlocked() OVERRIDE;
virtual CefString GetPageUrl() OVERRIDE;
virtual CefString GetFrameUrl() OVERRIDE;
virtual CefString GetFrameCharset() OVERRIDE;
virtual MediaType GetMediaType() OVERRIDE;
virtual MediaStateFlags GetMediaStateFlags() OVERRIDE;
virtual CefString GetSelectionText() OVERRIDE;
virtual bool IsEditable() OVERRIDE;
virtual bool IsSpeechInputEnabled() OVERRIDE;
virtual EditStateFlags GetEditStateFlags() OVERRIDE;
DISALLOW_COPY_AND_ASSIGN(CefContextMenuParamsImpl);
};
#endif // CEF_LIBCEF_BROWSER_CONTEXT_MENU_PARAMS_IMPL_H_

View File

@ -0,0 +1,36 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <gtk/gtk.h>
#include "ui/base/events.h"
// This file includes a selection of methods copied from
// chrome/browser/ui/gtk/gtk_util.cc.
namespace gtk_util {
void SetAlwaysShowImage(GtkWidget* image_menu_item) {
gtk_image_menu_item_set_always_show_image(
GTK_IMAGE_MENU_ITEM(image_menu_item), TRUE);
}
} // namespace gtk_util
namespace event_utils {
int EventFlagsFromGdkState(guint state) {
int flags = 0;
flags |= (state & GDK_LOCK_MASK) ? ui::EF_CAPS_LOCK_DOWN : 0;
flags |= (state & GDK_CONTROL_MASK) ? ui::EF_CONTROL_DOWN : 0;
flags |= (state & GDK_SHIFT_MASK) ? ui::EF_SHIFT_DOWN : 0;
flags |= (state & GDK_MOD1_MASK) ? ui::EF_ALT_DOWN : 0;
flags |= (state & GDK_BUTTON1_MASK) ? ui::EF_LEFT_MOUSE_BUTTON : 0;
flags |= (state & GDK_BUTTON2_MASK) ? ui::EF_MIDDLE_MOUSE_BUTTON : 0;
flags |= (state & GDK_BUTTON3_MASK) ? ui::EF_RIGHT_MOUSE_BUTTON : 0;
return flags;
}
} // namespace event_utils

View File

@ -0,0 +1,304 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#include "libcef/browser/menu_creator.h"
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/context_menu_params_impl.h"
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/common/content_client.h"
#include "grit/cef_strings.h"
#if defined(OS_WIN)
#include "libcef/browser/menu_creator_runner_win.h"
#elif defined(OS_MACOSX)
#include "libcef/browser/menu_creator_runner_mac.h"
#elif defined(TOOLKIT_GTK)
#include "libcef/browser/menu_creator_runner_gtk.h"
#endif
namespace {
CefString GetLabel(int message_id) {
string16 label = content::GetContentClient()->GetLocalizedString(message_id);
DCHECK(!label.empty());
return label;
}
} // namespace
CefMenuCreator::CefMenuCreator(CefBrowserHostImpl* browser)
: browser_(browser) {
model_ = new CefMenuModelImpl(this);
}
CefMenuCreator::~CefMenuCreator() {
// The model may outlive the delegate if the context menu is visible when the
// application is closed.
model_->set_delegate(NULL);
}
bool CefMenuCreator::IsShowingContextMenu() {
content::RenderWidgetHostView* view =
browser_->GetWebContents()->GetRenderWidgetHostView();
return (view && view->IsShowingContextMenu());
}
bool CefMenuCreator::CreateContextMenu(
const content::ContextMenuParams& params) {
if (!CreateRunner())
return true;
// The renderer may send the "show context menu" message multiple times, one
// for each right click mouse event it receives. Normally, this doesn't happen
// because mouse events are not forwarded once the context menu is showing.
// However, there's a race - the context menu may not yet be showing when
// the second mouse event arrives. In this case, |HandleContextMenu()| will
// get called multiple times - if so, don't create another context menu.
// TODO(asvitkine): Fix the renderer so that it doesn't do this.
if (IsShowingContextMenu())
return true;
params_ = params;
model_->Clear();
// Create the default menu model.
CreateDefaultModel();
// Give the client a chance to modify the model.
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {
CefRefPtr<CefContextMenuHandler> handler =
client->GetContextMenuHandler();
if (handler.get()) {
CefRefPtr<CefFrame> frame;
if (params_.frame_id > 0)
frame = browser_->GetFrame(params_.frame_id);
if (!frame.get())
frame = browser_->GetMainFrame();
CefRefPtr<CefContextMenuParamsImpl> paramsPtr(
new CefContextMenuParamsImpl(&params_));
handler->OnBeforeContextMenu(browser_, frame, paramsPtr.get(),
model_.get());
// Do not keep references to the parameters in the callback.
paramsPtr->Detach(NULL);
DCHECK_EQ(paramsPtr->GetRefCt(), 1);
DCHECK(model_->VerifyRefCount());
// Menu is empty so notify the client and return.
if (model_->GetCount() == 0) {
MenuClosed(model_);
return true;
}
}
}
return runner_->RunContextMenu(this);
}
bool CefMenuCreator::CreateRunner() {
if (!runner_.get()) {
// Create the menu runner.
#if defined(OS_WIN)
runner_.reset(new CefMenuCreatorRunnerWin);
#elif defined(OS_MACOSX)
runner_.reset(new CefMenuCreatorRunnerMac);
#elif defined(TOOLKIT_GTK)
runner_.reset(new CefMenuCreatorRunnerGtk);
#else
// Need an implementation.
NOTREACHED();
#endif
}
return (runner_.get() != NULL);
}
void CefMenuCreator::ExecuteCommand(CefRefPtr<CefMenuModelImpl> source,
int command_id,
cef_event_flags_t event_flags) {
// Give the client a chance to handle the command.
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {
CefRefPtr<CefContextMenuHandler> handler =
client->GetContextMenuHandler();
if (handler.get()) {
CefRefPtr<CefFrame> frame;
if (params_.frame_id > 0)
frame = browser_->GetFrame(params_.frame_id);
if (!frame.get())
frame = browser_->GetMainFrame();
CefRefPtr<CefContextMenuParamsImpl> paramsPtr(
new CefContextMenuParamsImpl(&params_));
bool handled = handler->OnContextMenuCommand(browser_, frame,
paramsPtr.get(), command_id, event_flags);
// Do not keep references to the parameters in the callback.
paramsPtr->Detach(NULL);
DCHECK_EQ(paramsPtr->GetRefCt(), 1);
if (handled)
return;
}
}
// Execute the default command handling.
ExecuteDefaultCommand(command_id);
}
void CefMenuCreator::MenuWillShow(CefRefPtr<CefMenuModelImpl> source) {
// Notify the host before showing the context menu.
content::RenderWidgetHostView* view =
browser_->GetWebContents()->GetRenderWidgetHostView();
if (view)
view->SetShowingContextMenu(true);
}
void CefMenuCreator::MenuClosed(CefRefPtr<CefMenuModelImpl> source) {
// Notify the client.
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {
CefRefPtr<CefContextMenuHandler> handler =
client->GetContextMenuHandler();
if (handler.get()) {
CefRefPtr<CefFrame> frame;
if (params_.frame_id > 0)
frame = browser_->GetFrame(params_.frame_id);
if (!frame.get())
frame = browser_->GetMainFrame();
handler->OnContextMenuDismissed(browser_, frame);
}
}
if (IsShowingContextMenu()) {
// Notify the host after closing the context menu.
content::RenderWidgetHostView* view =
browser_->GetWebContents()->GetRenderWidgetHostView();
if (view)
view->SetShowingContextMenu(false);
content::RenderViewHost* rvh =
browser_->GetWebContents()->GetRenderViewHost();
if (rvh)
rvh->NotifyContextMenuClosed(params_.custom_context);
}
}
void CefMenuCreator::CreateDefaultModel() {
if (params_.is_editable) {
// Editable node.
model_->AddItem(MENU_ID_UNDO, GetLabel(IDS_MENU_UNDO));
model_->AddItem(MENU_ID_REDO, GetLabel(IDS_MENU_REDO));
model_->AddSeparator();
model_->AddItem(MENU_ID_CUT, GetLabel(IDS_MENU_CUT));
model_->AddItem(MENU_ID_COPY, GetLabel(IDS_MENU_COPY));
model_->AddItem(MENU_ID_PASTE, GetLabel(IDS_MENU_PASTE));
model_->AddItem(MENU_ID_DELETE, GetLabel(IDS_MENU_DELETE));
model_->AddSeparator();
model_->AddItem(MENU_ID_SELECT_ALL, GetLabel(IDS_MENU_SELECT_ALL));
if (!(params_.edit_flags & CM_EDITFLAG_CAN_UNDO))
model_->SetEnabled(MENU_ID_UNDO, false);
if (!(params_.edit_flags & CM_EDITFLAG_CAN_REDO))
model_->SetEnabled(MENU_ID_REDO, false);
if (!(params_.edit_flags & CM_EDITFLAG_CAN_CUT))
model_->SetEnabled(MENU_ID_CUT, false);
if (!(params_.edit_flags & CM_EDITFLAG_CAN_COPY))
model_->SetEnabled(MENU_ID_COPY, false);
if (!(params_.edit_flags & CM_EDITFLAG_CAN_PASTE))
model_->SetEnabled(MENU_ID_PASTE, false);
if (!(params_.edit_flags & CM_EDITFLAG_CAN_DELETE))
model_->SetEnabled(MENU_ID_DELETE, false);
if (!(params_.edit_flags & CM_EDITFLAG_CAN_SELECT_ALL))
model_->SetEnabled(MENU_ID_SELECT_ALL, false);
} else if (!params_.selection_text.empty()) {
// Something is selected.
model_->AddItem(MENU_ID_COPY, GetLabel(IDS_MENU_COPY));
} else if (!params_.page_url.is_empty() || !params_.frame_url.is_empty()) {
// Page or frame.
model_->AddItem(MENU_ID_BACK, GetLabel(IDS_MENU_BACK));
model_->AddItem(MENU_ID_FORWARD, GetLabel(IDS_MENU_FORWARD));
model_->AddSeparator();
model_->AddItem(MENU_ID_PRINT, GetLabel(IDS_MENU_PRINT));
model_->AddItem(MENU_ID_VIEW_SOURCE, GetLabel(IDS_MENU_VIEW_SOURCE));
if (!browser_->CanGoBack())
model_->SetEnabled(MENU_ID_BACK, false);
if (!browser_->CanGoForward())
model_->SetEnabled(MENU_ID_FORWARD, false);
// TODO(cef): Enable once printing is supported.
model_->SetEnabled(MENU_ID_PRINT, false);
}
}
void CefMenuCreator::ExecuteDefaultCommand(int command_id) {
switch (command_id) {
// Navigation.
case MENU_ID_BACK:
browser_->GoBack();
break;
case MENU_ID_FORWARD:
browser_->GoForward();
break;
case MENU_ID_RELOAD:
browser_->Reload();
break;
case MENU_ID_RELOAD_NOCACHE:
browser_->ReloadIgnoreCache();
break;
case MENU_ID_STOPLOAD:
browser_->StopLoad();
break;
// Editing.
case MENU_ID_UNDO:
browser_->GetFocusedFrame()->Undo();
break;
case MENU_ID_REDO:
browser_->GetFocusedFrame()->Redo();
break;
case MENU_ID_CUT:
browser_->GetFocusedFrame()->Cut();
break;
case MENU_ID_COPY:
browser_->GetFocusedFrame()->Copy();
break;
case MENU_ID_PASTE:
browser_->GetFocusedFrame()->Paste();
break;
case MENU_ID_DELETE:
browser_->GetFocusedFrame()->Delete();
break;
case MENU_ID_SELECT_ALL:
browser_->GetFocusedFrame()->SelectAll();
break;
// Miscellaneous.
case MENU_ID_FIND:
// TODO(cef): Implement.
NOTIMPLEMENTED();
break;
case MENU_ID_PRINT:
// TODO(cef): Implement.
NOTIMPLEMENTED();
break;
case MENU_ID_VIEW_SOURCE:
browser_->GetFocusedFrame()->ViewSource();
break;
default:
break;
}
}

View File

@ -0,0 +1,63 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_MENU_MANAGER_H_
#define CEF_LIBCEF_BROWSER_MENU_MANAGER_H_
#pragma once
#include "libcef/browser/menu_model_impl.h"
#include "base/memory/scoped_ptr.h"
#include "content/public/common/context_menu_params.h"
class CefBrowserHostImpl;
class CefMenuCreator : public CefMenuModelImpl::Delegate {
public:
// Used for OS-specific menu implementations.
class Runner {
public:
virtual ~Runner() {}
virtual bool RunContextMenu(CefMenuCreator* manager) =0;
};
explicit CefMenuCreator(CefBrowserHostImpl* browser);
virtual ~CefMenuCreator();
// Returns true if the context menu is currently showing.
bool IsShowingContextMenu();
// Create the context menu.
bool CreateContextMenu(const content::ContextMenuParams& params);
CefBrowserHostImpl* browser() { return browser_; }
ui::MenuModel* model() { return model_->model(); }
const content::ContextMenuParams& params() const { return params_; }
private:
// Create the menu runner if it doesn't already exist.
bool CreateRunner();
// CefMenuModelImpl::Delegate methods.
virtual void ExecuteCommand(CefRefPtr<CefMenuModelImpl> source,
int command_id,
cef_event_flags_t event_flags) OVERRIDE;
virtual void MenuWillShow(CefRefPtr<CefMenuModelImpl> source) OVERRIDE;
virtual void MenuClosed(CefRefPtr<CefMenuModelImpl> source) OVERRIDE;
// Create the default menu model.
void CreateDefaultModel();
// Execute the default command handling.
void ExecuteDefaultCommand(int command_id);
// CefBrowserHostImpl pointer is guaranteed to outlive this object.
CefBrowserHostImpl* browser_;
CefRefPtr<CefMenuModelImpl> model_;
content::ContextMenuParams params_;
scoped_ptr<Runner> runner_;
DISALLOW_COPY_AND_ASSIGN(CefMenuCreator);
};
#endif // CEF_LIBCEF_BROWSER_MENU_MANAGER_H_

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.
#include "libcef/browser/menu_creator_runner_gtk.h"
#include "libcef/browser/browser_host_impl.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents_view.h"
#include "ui/gfx/point.h"
namespace {
class CefMenuDelegate : public MenuGtk::Delegate {
public:
CefMenuDelegate() {}
};
} // namespace
CefMenuCreatorRunnerWin::CefMenuCreatorRunnerWin() {
}
bool CefMenuCreatorRunnerWin::RunContextMenu(CefMenuCreator* manager) {
if (!menu_delegate_.get())
menu_delegate_.reset(new CefMenuDelegate);
// Create a menu based on the model.
menu_.reset(new MenuGtk(menu_delegate_.get(), manager->model()));
gfx::Rect bounds;
manager->browser()->GetWebContents()->GetView()->GetContainerBounds(&bounds);
gfx::Point point = bounds.origin();
point.Offset(manager->params().x, manager->params().y);
content::RenderWidgetHostView* view =
manager->browser()->GetWebContents()->GetRenderWidgetHostView();
GdkEventButton* event = view->GetLastMouseDown();
uint32_t triggering_event_time = event ? event->time : GDK_CURRENT_TIME;
// Show the menu. Execution will continue asynchronously.
menu_->PopupAsContext(point, triggering_event_time);
return true;
}

View File

@ -0,0 +1,26 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_MENU_MANAGER_RUNNER_GTK_H_
#define CEF_LIBCEF_BROWSER_MENU_MANAGER_RUNNER_GTK_H_
#pragma once
#include "libcef/browser/menu_creator.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/ui/gtk/menu_gtk.h"
class CefMenuCreatorRunnerGtk: public CefMenuCreator::Runner {
public:
CefMenuCreatorRunnerGtk();
// CefMemoryManager::Runner methods.
virtual bool RunContextMenu(CefMenuCreator* manager) OVERRIDE;
private:
scoped_ptr<MenuGtk> menu_;
scoped_ptr<MenuGtk::Delegate> menu_delegate_;
};
#endif // CEF_LIBCEF_BROWSER_MENU_MANAGER_RUNNER_GTK_H_

View File

@ -0,0 +1,29 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_MENU_MANAGER_RUNNER_MAC_H_
#define CEF_LIBCEF_BROWSER_MENU_MANAGER_RUNNER_MAC_H_
#pragma once
#include "libcef/browser/menu_creator.h"
#if __OBJC__
@class MenuController;
#else
class MenuController;
#endif
class CefMenuCreatorRunnerMac : public CefMenuCreator::Runner {
public:
CefMenuCreatorRunnerMac();
virtual ~CefMenuCreatorRunnerMac();
// CefMemoryManager::Runner methods.
virtual bool RunContextMenu(CefMenuCreator* manager) OVERRIDE;
private:
MenuController* menu_controller_;
};
#endif // CEF_LIBCEF_BROWSER_MENU_MANAGER_RUNNER_MAC_H_

View File

@ -0,0 +1,68 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#include "libcef/browser/menu_creator_runner_mac.h"
#include "libcef/browser/browser_host_impl.h"
#include "base/message_loop.h"
#include "base/compiler_specific.h"
#import "base/mac/scoped_sending_event.h"
#import "chrome/browser/ui/cocoa/menu_controller.h"
#include "content/public/browser/web_contents_view.h"
CefMenuCreatorRunnerWin::CefMenuCreatorRunnerMac()
: menu_controller_(nil) {
}
CefMenuCreatorRunnerWin::~CefMenuCreatorRunnerMac() {
if (menu_controller_ != nil)
[menu_controller_ release];
}
bool CefMenuCreatorRunnerWin::RunContextMenu(CefMenuCreator* manager) {
// Create a menu controller based on the model.
if (menu_controller_ != nil)
[menu_controller_ release];
menu_controller_ =
[[MenuController alloc] initWithModel:manager.model()
useWithPopUpButtonCell:NO]);
NSView* parent_view =
manager->browser()->GetWebContents()->GetContentNativeView();
// Synthesize an event for the click, as there is no certainty that
// [NSApp currentEvent] will return a valid event.
NSEvent* currentEvent = [NSApp currentEvent];
NSWindow* window = [parent_view window];
NSPoint position = [window mouseLocationOutsideOfEventStream];
NSTimeInterval eventTime = [currentEvent timestamp];
NSEvent* clickEvent = [NSEvent mouseEventWithType:NSRightMouseDown
location:position
modifierFlags:NSRightMouseDownMask
timestamp:eventTime
windowNumber:[window windowNumber]
context:nil
eventNumber:0
clickCount:1
pressure:1.0];
{
// Make sure events can be pumped while the menu is up.
MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
// One of the events that could be pumped is |window.close()|.
// User-initiated event-tracking loops protect against this by
// setting flags in -[CrApplication sendEvent:], but since
// web-content menus are initiated by IPC message the setup has to
// be done manually.
base::mac::ScopedSendingEvent sendingEventScoper;
// Show the menu. Blocks until the menu is dismissed.
[NSMenu popUpContextMenu:[menu_controller_ menu]
withEvent:clickEvent
forView:parent_view];
}
return true;
}

View File

@ -0,0 +1,34 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#include "libcef/browser/menu_creator_runner_win.h"
#include "libcef/browser/browser_host_impl.h"
#include "base/message_loop.h"
#include "content/public/browser/web_contents_view.h"
#include "ui/gfx/point.h"
#include "ui/views/controls/menu/menu_2.h"
CefMenuCreatorRunnerWin::CefMenuCreatorRunnerWin() {
}
bool CefMenuCreatorRunnerWin::RunContextMenu(CefMenuCreator* manager) {
// Create a menu based on the model.
menu_.reset(new views::NativeMenuWin(manager->model(), NULL));
menu_->Rebuild();
// Make sure events can be pumped while the menu is up.
MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
gfx::Point screen_point(manager->params().x, manager->params().y);
POINT temp = screen_point.ToPOINT();
HWND hwnd = manager->browser()->GetWebContents()->GetView()->GetNativeView();
ClientToScreen(hwnd, &temp);
screen_point = temp;
// Show the menu. Blocks until the menu is dismissed.
menu_->RunMenuAt(screen_point, views::Menu2::ALIGN_TOPLEFT);
return true;
}

View File

@ -0,0 +1,25 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_MENU_MANAGER_RUNNER_WIN_H_
#define CEF_LIBCEF_BROWSER_MENU_MANAGER_RUNNER_WIN_H_
#pragma once
#include "libcef/browser/menu_creator.h"
#include "base/memory/scoped_ptr.h"
#include "ui/views/controls/menu/native_menu_win.h"
class CefMenuCreatorRunnerWin : public CefMenuCreator::Runner {
public:
CefMenuCreatorRunnerWin();
// CefMemoryManager::Runner methods.
virtual bool RunContextMenu(CefMenuCreator* manager) OVERRIDE;
private:
scoped_ptr<views::NativeMenuWin> menu_;
};
#endif // CEF_LIBCEF_BROWSER_MENU_MANAGER_RUNNER_WIN_H_

View File

@ -0,0 +1,684 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/menu_model_impl.h"
#include <vector>
#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "ui/base/accelerators/accelerator.h"
namespace {
const int kSeparatorId = -1;
// A simple MenuModel implementation that delegates to CefMenuModelImpl.
class CefSimpleMenuModel : public ui::MenuModel {
public:
// The Delegate can be NULL, though if it is items can't be checked or
// disabled.
explicit CefSimpleMenuModel(CefMenuModelImpl* impl)
: impl_(impl),
menu_model_delegate_(NULL) {
}
virtual ~CefSimpleMenuModel() {
}
// MenuModel methods.
virtual bool HasIcons() const OVERRIDE {
return false;
}
virtual int GetItemCount() const OVERRIDE {
return impl_->GetCount();
}
virtual ItemType GetTypeAt(int index) const OVERRIDE {
switch (impl_->GetTypeAt(index)) {
case MENUITEMTYPE_COMMAND:
return TYPE_COMMAND;
case MENUITEMTYPE_CHECK:
return TYPE_CHECK;
case MENUITEMTYPE_RADIO:
return TYPE_RADIO;
case MENUITEMTYPE_SEPARATOR:
return TYPE_SEPARATOR;
case MENUITEMTYPE_SUBMENU:
return TYPE_SUBMENU;
default:
NOTREACHED();
return TYPE_COMMAND;
}
}
virtual int GetCommandIdAt(int index) const OVERRIDE {
return impl_->GetCommandIdAt(index);
}
virtual string16 GetLabelAt(int index) const OVERRIDE {
return impl_->GetLabelAt(index).ToString16();
}
virtual bool IsItemDynamicAt(int index) const OVERRIDE {
return false;
}
virtual bool GetAcceleratorAt(int index,
ui::Accelerator* accelerator) const OVERRIDE {
int key_code = 0;
bool shift_pressed = false;
bool ctrl_pressed = false;
bool alt_pressed = false;
if (impl_->GetAcceleratorAt(index, key_code, shift_pressed, ctrl_pressed,
alt_pressed)) {
*accelerator = ui::Accelerator(static_cast<ui::KeyboardCode>(key_code),
shift_pressed, ctrl_pressed, alt_pressed);
return true;
}
return false;
}
virtual bool IsItemCheckedAt(int index) const OVERRIDE {
return impl_->IsCheckedAt(index);
}
virtual int GetGroupIdAt(int index) const OVERRIDE {
return impl_->GetGroupIdAt(index);
}
virtual bool GetIconAt(int index, SkBitmap* icon) OVERRIDE {
return false;
}
virtual ui::ButtonMenuItemModel* GetButtonMenuItemAt(
int index) const OVERRIDE {
return NULL;
}
virtual bool IsEnabledAt(int index) const OVERRIDE {
return impl_->IsEnabledAt(index);
}
virtual bool IsVisibleAt(int index) const OVERRIDE {
return impl_->IsVisibleAt(index);
}
virtual void HighlightChangedTo(int index) OVERRIDE {
}
virtual void ActivatedAt(int index) OVERRIDE {
ActivatedAt(index, 0);
}
virtual void ActivatedAt(int index, int event_flags) OVERRIDE {
impl_->ActivatedAt(index, static_cast<cef_event_flags_t>(event_flags));
}
virtual MenuModel* GetSubmenuModelAt(int index) const OVERRIDE {
CefRefPtr<CefMenuModel> submenu = impl_->GetSubMenuAt(index);
if (submenu.get())
return static_cast<CefMenuModelImpl*>(submenu.get())->model();
return NULL;
}
virtual void MenuWillShow() OVERRIDE {
impl_->MenuWillShow();
}
virtual void MenuClosed() OVERRIDE {
impl_->MenuClosed();
}
virtual void SetMenuModelDelegate(
ui::MenuModelDelegate* menu_model_delegate) OVERRIDE {
menu_model_delegate_ = menu_model_delegate;
}
private:
CefMenuModelImpl* impl_;
ui::MenuModelDelegate* menu_model_delegate_;
DISALLOW_COPY_AND_ASSIGN(CefSimpleMenuModel);
};
} // namespace
struct CefMenuModelImpl::Item {
Item(cef_menu_item_type_t type,
int command_id,
const CefString& label,
int group_id)
: type_(type),
command_id_(command_id),
label_(label),
group_id_(group_id),
enabled_(true),
visible_(true),
checked_(false),
has_accelerator_(false),
key_code_(0),
shift_pressed_(false),
ctrl_pressed_(false),
alt_pressed_(false) {
}
// Basic information.
cef_menu_item_type_t type_;
int command_id_;
CefString label_;
int group_id_;
CefRefPtr<CefMenuModelImpl> submenu_;
// State information.
bool enabled_;
bool visible_;
bool checked_;
// Accelerator information.
bool has_accelerator_;
int key_code_;
bool shift_pressed_;
bool ctrl_pressed_;
bool alt_pressed_;
};
CefMenuModelImpl::CefMenuModelImpl(Delegate* delegate)
: supported_thread_id_(base::PlatformThread::CurrentId()),
delegate_(delegate) {
model_.reset(new CefSimpleMenuModel(this));
}
CefMenuModelImpl::~CefMenuModelImpl() {
}
bool CefMenuModelImpl::Clear() {
if (!VerifyContext())
return false;
items_.clear();
return true;
}
int CefMenuModelImpl::GetCount() {
if (!VerifyContext())
return 0;
return static_cast<int>(items_.size());
}
bool CefMenuModelImpl::AddSeparator() {
if (!VerifyContext())
return false;
AppendItem(Item(MENUITEMTYPE_SEPARATOR, kSeparatorId, CefString(), -1));
return true;
}
bool CefMenuModelImpl::AddItem(int command_id, const CefString& label) {
if (!VerifyContext())
return false;
AppendItem(Item(MENUITEMTYPE_COMMAND, command_id, label, -1));
return true;
}
bool CefMenuModelImpl::AddCheckItem(int command_id, const CefString& label) {
if (!VerifyContext())
return false;
AppendItem(Item(MENUITEMTYPE_CHECK, command_id, label, -1));
return true;
}
bool CefMenuModelImpl::AddRadioItem(int command_id, const CefString& label,
int group_id) {
if (!VerifyContext())
return false;
AppendItem(Item(MENUITEMTYPE_RADIO, command_id, label, group_id));
return true;
}
CefRefPtr<CefMenuModel> CefMenuModelImpl::AddSubMenu(int command_id,
const CefString& label) {
if (!VerifyContext())
return NULL;
Item item(MENUITEMTYPE_SUBMENU, command_id, label, -1);
item.submenu_ = new CefMenuModelImpl(delegate_);
AppendItem(item);
return item.submenu_.get();
}
bool CefMenuModelImpl::InsertSeparatorAt(int index) {
if (!VerifyContext())
return false;
InsertItemAt(Item(MENUITEMTYPE_SEPARATOR, kSeparatorId, CefString(), -1),
index);
return true;
}
bool CefMenuModelImpl::InsertItemAt(int index, int command_id,
const CefString& label) {
if (!VerifyContext())
return false;
InsertItemAt(Item(MENUITEMTYPE_COMMAND, command_id, label, -1), index);
return true;
}
bool CefMenuModelImpl::InsertCheckItemAt(int index, int command_id,
const CefString& label) {
if (!VerifyContext())
return false;
InsertItemAt(Item(MENUITEMTYPE_CHECK, command_id, label, -1), index);
return true;
}
bool CefMenuModelImpl::InsertRadioItemAt(int index, int command_id,
const CefString& label, int group_id) {
if (!VerifyContext())
return false;
InsertItemAt(Item(MENUITEMTYPE_RADIO, command_id, label, -1), index);
return true;
}
CefRefPtr<CefMenuModel> CefMenuModelImpl::InsertSubMenuAt(
int index, int command_id, const CefString& label) {
if (!VerifyContext())
return NULL;
Item item(MENUITEMTYPE_SUBMENU, command_id, label, -1);
item.submenu_ = new CefMenuModelImpl(delegate_);
InsertItemAt(item, index);
return item.submenu_.get();
}
bool CefMenuModelImpl::Remove(int command_id) {
return RemoveAt(GetIndexOf(command_id));
}
bool CefMenuModelImpl::RemoveAt(int index) {
if (!VerifyContext())
return false;
if (index >= 0 && index < static_cast<int>(items_.size())) {
items_.erase(items_.begin()+index);
return true;
}
return false;
}
int CefMenuModelImpl::GetIndexOf(int command_id) {
if (!VerifyContext())
return -1;
for (ItemVector::iterator i = items_.begin(); i != items_.end(); ++i) {
if ((*i).command_id_ == command_id) {
return static_cast<int>(std::distance(items_.begin(), i));
}
}
return -1;
}
int CefMenuModelImpl::GetCommandIdAt(int index) {
if (!VerifyContext())
return -1;
if (index >= 0 && index < static_cast<int>(items_.size()))
return items_[index].command_id_;
return -1;
}
bool CefMenuModelImpl::SetCommandIdAt(int index, int command_id) {
if (!VerifyContext())
return false;
if (index >= 0 && index < static_cast<int>(items_.size())) {
items_[index].command_id_ = command_id;
return true;
}
return false;
}
CefString CefMenuModelImpl::GetLabel(int command_id) {
return GetLabelAt(GetIndexOf(command_id));
}
CefString CefMenuModelImpl::GetLabelAt(int index) {
if (!VerifyContext())
return CefString();
if (index >= 0 && index < static_cast<int>(items_.size()))
return items_[index].label_;
return CefString();
}
bool CefMenuModelImpl::SetLabel(int command_id, const CefString& label) {
return SetLabelAt(GetIndexOf(command_id), label);
}
bool CefMenuModelImpl::SetLabelAt(int index, const CefString& label) {
if (!VerifyContext())
return false;
if (index >= 0 && index < static_cast<int>(items_.size())) {
items_[index].label_ = label;
return true;
}
return false;
}
CefMenuModelImpl::MenuItemType CefMenuModelImpl::GetType(int command_id) {
return GetTypeAt(GetIndexOf(command_id));
}
CefMenuModelImpl::MenuItemType CefMenuModelImpl::GetTypeAt(int index) {
if (!VerifyContext())
return MENUITEMTYPE_NONE;
if (index >= 0 && index < static_cast<int>(items_.size()))
return items_[index].type_;
return MENUITEMTYPE_NONE;
}
int CefMenuModelImpl::GetGroupId(int command_id) {
return GetGroupIdAt(GetIndexOf(command_id));
}
int CefMenuModelImpl::GetGroupIdAt(int index) {
if (!VerifyContext())
return -1;
if (index >= 0 && index < static_cast<int>(items_.size()))
return items_[index].group_id_;
return -1;
}
bool CefMenuModelImpl::SetGroupId(int command_id, int group_id) {
return SetGroupIdAt(GetIndexOf(command_id), group_id);
}
bool CefMenuModelImpl::SetGroupIdAt(int index, int group_id) {
if (!VerifyContext())
return false;
if (index >= 0 && index < static_cast<int>(items_.size())) {
items_[index].group_id_ = group_id;
return true;
}
return false;
}
CefRefPtr<CefMenuModel> CefMenuModelImpl::GetSubMenu(int command_id) {
return GetSubMenuAt(GetIndexOf(command_id));
}
CefRefPtr<CefMenuModel> CefMenuModelImpl::GetSubMenuAt(int index) {
if (!VerifyContext())
return NULL;
if (index >= 0 && index < static_cast<int>(items_.size()))
return items_[index].submenu_.get();
return NULL;
}
bool CefMenuModelImpl::IsVisible(int command_id) {
return IsVisibleAt(GetIndexOf(command_id));
}
bool CefMenuModelImpl::IsVisibleAt(int index) {
if (!VerifyContext())
return false;
if (index >= 0 && index < static_cast<int>(items_.size()))
return items_[index].visible_;
return false;
}
bool CefMenuModelImpl::SetVisible(int command_id, bool visible) {
return SetVisibleAt(GetIndexOf(command_id), visible);
}
bool CefMenuModelImpl::SetVisibleAt(int index, bool visible) {
if (!VerifyContext())
return false;
if (index >= 0 && index < static_cast<int>(items_.size())) {
items_[index].visible_ = visible;
return true;
}
return false;
}
bool CefMenuModelImpl::IsEnabled(int command_id) {
return IsEnabledAt(GetIndexOf(command_id));
}
bool CefMenuModelImpl::IsEnabledAt(int index) {
if (!VerifyContext())
return false;
if (index >= 0 && index < static_cast<int>(items_.size()))
return items_[index].enabled_;
return false;
}
bool CefMenuModelImpl::SetEnabled(int command_id, bool enabled) {
return SetEnabledAt(GetIndexOf(command_id), enabled);
}
bool CefMenuModelImpl::SetEnabledAt(int index, bool enabled) {
if (!VerifyContext())
return false;
if (index >= 0 && index < static_cast<int>(items_.size())) {
items_[index].enabled_ = enabled;
return true;
}
return false;
}
bool CefMenuModelImpl::IsChecked(int command_id) {
return IsCheckedAt(GetIndexOf(command_id));
}
bool CefMenuModelImpl::IsCheckedAt(int index) {
if (!VerifyContext())
return false;
if (index >= 0 && index < static_cast<int>(items_.size()))
return items_[index].checked_;
return false;
}
bool CefMenuModelImpl::SetChecked(int command_id, bool checked) {
return SetCheckedAt(GetIndexOf(command_id), checked);
}
bool CefMenuModelImpl::SetCheckedAt(int index, bool checked) {
if (!VerifyContext())
return false;
if (index >= 0 && index < static_cast<int>(items_.size())) {
items_[index].checked_ = checked;
return true;
}
return false;
}
bool CefMenuModelImpl::HasAccelerator(int command_id) {
return HasAcceleratorAt(GetIndexOf(command_id));
}
bool CefMenuModelImpl::HasAcceleratorAt(int index) {
if (!VerifyContext())
return false;
if (index >= 0 && index < static_cast<int>(items_.size()))
return items_[index].has_accelerator_;
return false;
}
bool CefMenuModelImpl::SetAccelerator(int command_id, int key_code,
bool shift_pressed, bool ctrl_pressed,
bool alt_pressed) {
return SetAcceleratorAt(GetIndexOf(command_id), key_code, shift_pressed,
ctrl_pressed, alt_pressed);
}
bool CefMenuModelImpl::SetAcceleratorAt(int index, int key_code,
bool shift_pressed, bool ctrl_pressed,
bool alt_pressed) {
if (!VerifyContext())
return false;
if (index >= 0 && index < static_cast<int>(items_.size())) {
Item& item = items_[index];
item.has_accelerator_ = true;
item.key_code_ = key_code;
item.shift_pressed_ = shift_pressed;
item.ctrl_pressed_ = ctrl_pressed;
item.alt_pressed_ = alt_pressed;
return true;
}
return false;
}
bool CefMenuModelImpl::RemoveAccelerator(int command_id) {
return RemoveAcceleratorAt(GetIndexOf(command_id));
}
bool CefMenuModelImpl::RemoveAcceleratorAt(int index) {
if (!VerifyContext())
return false;
if (index >= 0 && index < static_cast<int>(items_.size())) {
Item& item = items_[index];
if (item.has_accelerator_) {
item.has_accelerator_ = false;
item.key_code_ = 0;
item.shift_pressed_ = false;
item.ctrl_pressed_ = false;
item.alt_pressed_ = false;
}
return true;
}
return false;
}
bool CefMenuModelImpl::GetAccelerator(int command_id, int& key_code,
bool& shift_pressed, bool& ctrl_pressed,
bool& alt_pressed) {
return GetAcceleratorAt(GetIndexOf(command_id), key_code, shift_pressed,
ctrl_pressed, alt_pressed);
}
bool CefMenuModelImpl::GetAcceleratorAt(int index, int& key_code,
bool& shift_pressed, bool& ctrl_pressed,
bool& alt_pressed) {
if (!VerifyContext())
return false;
if (index >= 0 && index < static_cast<int>(items_.size())) {
const Item& item = items_[index];
if (item.has_accelerator_) {
key_code = item.key_code_;
shift_pressed = item.shift_pressed_;
ctrl_pressed = item.ctrl_pressed_;
alt_pressed = item.alt_pressed_;
return true;
}
}
return false;
}
void CefMenuModelImpl::ActivatedAt(int index, cef_event_flags_t event_flags) {
if (VerifyContext() && delegate_)
delegate_->ExecuteCommand(this, GetCommandIdAt(index), event_flags);
}
void CefMenuModelImpl::MenuWillShow() {
if (VerifyContext() && delegate_)
delegate_->MenuWillShow(this);
}
void CefMenuModelImpl::MenuClosed() {
if (!VerifyContext())
return;
// Due to how menus work on the different platforms, ActivatedAt will be
// called after this. It's more convenient for the delegate to be called
// afterwards, though, so post a task.
MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&CefMenuModelImpl::OnMenuClosed, this));
}
bool CefMenuModelImpl::VerifyRefCount() {
if (!VerifyContext())
return false;
if (GetRefCt() != 1)
return false;
for (ItemVector::iterator i = items_.begin(); i != items_.end(); ++i) {
if ((*i).submenu_.get()) {
if (!(*i).submenu_->VerifyRefCount())
return false;
}
}
return true;
}
void CefMenuModelImpl::AppendItem(const Item& item) {
ValidateItem(item);
items_.push_back(item);
}
void CefMenuModelImpl::InsertItemAt(const Item& item, int index) {
// Sanitize the index.
if (index < 0)
index = 0;
else if (index > static_cast<int>(items_.size()))
index = items_.size();
ValidateItem(item);
items_.insert(items_.begin() + index, item);
}
void CefMenuModelImpl::ValidateItem(const Item& item) {
#ifndef NDEBUG
if (item.type_ == MENUITEMTYPE_SEPARATOR) {
DCHECK_EQ(item.command_id_, kSeparatorId);
} else {
DCHECK_GE(item.command_id_, 0);
}
#endif // NDEBUG
}
void CefMenuModelImpl::OnMenuClosed() {
if (delegate_)
delegate_->MenuClosed(this);
}
bool CefMenuModelImpl::VerifyContext() {
if (base::PlatformThread::CurrentId() != supported_thread_id_) {
// This object should only be accessed from the thread that created it.
NOTREACHED();
return false;
}
return true;
}

View File

@ -0,0 +1,139 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_MENU_MODEL_IMPL_H_
#define CEF_LIBCEF_BROWSER_MENU_MODEL_IMPL_H_
#pragma once
#include <vector>
#include "include/cef_menu_model.h"
#include "base/threading/platform_thread.h"
#include "ui/base/models/menu_model.h"
class CefMenuModelImpl : public CefMenuModel {
public:
class Delegate {
public:
// Perform the action associated with the specified |command_id| and
// optional |event_flags|.
virtual void ExecuteCommand(CefRefPtr<CefMenuModelImpl> source,
int command_id,
cef_event_flags_t event_flags) =0;
// Notifies the delegate that the menu is about to show.
virtual void MenuWillShow(CefRefPtr<CefMenuModelImpl> source) =0;
// Notifies the delegate that the menu has closed.
virtual void MenuClosed(CefRefPtr<CefMenuModelImpl> source) =0;
protected:
virtual ~Delegate() {}
};
// The delegate must outlive this class.
explicit CefMenuModelImpl(Delegate* delegate);
virtual ~CefMenuModelImpl();
// CefMenuModel methods.
virtual bool Clear() OVERRIDE;
virtual int GetCount() OVERRIDE;
virtual bool AddSeparator() OVERRIDE;
virtual bool AddItem(int command_id, const CefString& label) OVERRIDE;
virtual bool AddCheckItem(int command_id, const CefString& label) OVERRIDE;
virtual bool AddRadioItem(int command_id, const CefString& label,
int group_id) OVERRIDE;
virtual CefRefPtr<CefMenuModel> AddSubMenu(int command_id,
const CefString& label) OVERRIDE;
virtual bool InsertSeparatorAt(int index) OVERRIDE;
virtual bool InsertItemAt(int index, int command_id,
const CefString& label) OVERRIDE;
virtual bool InsertCheckItemAt(int index, int command_id,
const CefString& label) OVERRIDE;
virtual bool InsertRadioItemAt(int index, int command_id,
const CefString& label, int group_id) OVERRIDE;
virtual CefRefPtr<CefMenuModel> InsertSubMenuAt(int index, int command_id,
const CefString& label) OVERRIDE;
virtual bool Remove(int command_id) OVERRIDE;
virtual bool RemoveAt(int index) OVERRIDE;
virtual int GetIndexOf(int command_id) OVERRIDE;
virtual int GetCommandIdAt(int index) OVERRIDE;
virtual bool SetCommandIdAt(int index, int command_id) OVERRIDE;
virtual CefString GetLabel(int command_id) OVERRIDE;
virtual CefString GetLabelAt(int index) OVERRIDE;
virtual bool SetLabel(int command_id, const CefString& label) OVERRIDE;
virtual bool SetLabelAt(int index, const CefString& label) OVERRIDE;
virtual MenuItemType GetType(int command_id) OVERRIDE;
virtual MenuItemType GetTypeAt(int index) OVERRIDE;
virtual int GetGroupId(int command_id) OVERRIDE;
virtual int GetGroupIdAt(int index) OVERRIDE;
virtual bool SetGroupId(int command_id, int group_id) OVERRIDE;
virtual bool SetGroupIdAt(int index, int group_id) OVERRIDE;
virtual CefRefPtr<CefMenuModel> GetSubMenu(int command_id) OVERRIDE;
virtual CefRefPtr<CefMenuModel> GetSubMenuAt(int index) OVERRIDE;
virtual bool IsVisible(int command_id) OVERRIDE;
virtual bool IsVisibleAt(int index) OVERRIDE;
virtual bool SetVisible(int command_id, bool visible) OVERRIDE;
virtual bool SetVisibleAt(int index, bool visible) OVERRIDE;
virtual bool IsEnabled(int command_id) OVERRIDE;
virtual bool IsEnabledAt(int index) OVERRIDE;
virtual bool SetEnabled(int command_id, bool enabled) OVERRIDE;
virtual bool SetEnabledAt(int index, bool enabled) OVERRIDE;
virtual bool IsChecked(int command_id) OVERRIDE;
virtual bool IsCheckedAt(int index) OVERRIDE;
virtual bool SetChecked(int command_id, bool checked) OVERRIDE;
virtual bool SetCheckedAt(int index, bool checked) OVERRIDE;
virtual bool HasAccelerator(int command_id) OVERRIDE;
virtual bool HasAcceleratorAt(int index) OVERRIDE;
virtual bool SetAccelerator(int command_id, int key_code, bool shift_pressed,
bool ctrl_pressed, bool alt_pressed) OVERRIDE;
virtual bool SetAcceleratorAt(int index, int key_code, bool shift_pressed,
bool ctrl_pressed, bool alt_pressed) OVERRIDE;
virtual bool RemoveAccelerator(int command_id) OVERRIDE;
virtual bool RemoveAcceleratorAt(int index) OVERRIDE;
virtual bool GetAccelerator(int command_id, int& key_code,
bool& shift_pressed, bool& ctrl_pressed, bool& alt_pressed) OVERRIDE;
virtual bool GetAcceleratorAt(int index, int& key_code, bool& shift_pressed,
bool& ctrl_pressed, bool& alt_pressed) OVERRIDE;
// Callbacks from the ui::MenuModel implementation.
void ActivatedAt(int index, cef_event_flags_t event_flags);
void MenuWillShow();
void MenuClosed();
// Verify that only a single reference exists to all CefMenuModelImpl objects.
bool VerifyRefCount();
ui::MenuModel* model() { return model_.get(); }
Delegate* delegate() { return delegate_; }
void set_delegate(Delegate* delegate) { delegate_ = NULL; }
private:
struct Item;
typedef std::vector<Item> ItemVector;
// Functions for inserting items into |items_|.
void AppendItem(const Item& item);
void InsertItemAt(const Item& item, int index);
void ValidateItem(const Item& item);
// Notify the delegate that the menu is closed.
void OnMenuClosed();
// Verify that the object is being accessed from the correct thread.
bool VerifyContext();
base::PlatformThreadId supported_thread_id_;
Delegate* delegate_;
ItemVector items_;
scoped_ptr<ui::MenuModel> model_;
IMPLEMENT_REFCOUNTING(CefMenuModelImpl);
DISALLOW_COPY_AND_ASSIGN(CefMenuModelImpl);
};
#endif // CEF_LIBCEF_BROWSER_MENU_MODEL_IMPL_H_

View File

@ -109,7 +109,6 @@ class CefValueController
void TakeFrom(CefValueController* other);
private:
// Owner object.
void* owner_value_;
Object* owner_object_;
@ -242,9 +241,7 @@ class CefValueBase : public CefType, public CefValueController::Object {
if (!reference() && !controller_) {
// For owned values default to using a new multi-threaded controller.
controller_ = new CefValueControllerThreadSafe();
CefValueController::AutoLock lock_scope(controller_);
if (lock_scope.verified())
controller_->SetOwner(value_, this);
SetOwnsController();
}
// A controller is required.
@ -286,7 +283,7 @@ class CefValueBase : public CefType, public CefValueController::Object {
// Remove the object from the controller. If this is the owner object any
// references will be detached.
controller()->Remove(value_, false);
if (will_delete()) {
// Remove any dependencies.
controller()->RemoveDependencies(value_);
@ -313,7 +310,7 @@ class CefValueBase : public CefType, public CefValueController::Object {
// They will be removed from this controller.
new_controller->TakeFrom(controller());
}
// Remove the object from the controller. If this is the owner object any
// references will be detached.
controller()->Remove(value_, false);
@ -378,6 +375,13 @@ class CefValueBase : public CefType, public CefValueController::Object {
return true;
}
// Used to indicate that this object owns the controller.
inline void SetOwnsController() {
CefValueController::AutoLock lock_scope(controller_);
if (lock_scope.verified())
controller_->SetOwner(value_, this);
}
// Encapsulates value locking and verification logic.
class AutoLock {
public:

View File

@ -5,7 +5,6 @@
<emit emit_type='prepend'></emit>
</output>
<output filename="cef_resources.pak" type="data_package" />
<output filename="cef_resources.rc" type="rc_all" />
</outputs>
<translations />
<release seq="1">

View File

@ -0,0 +1,167 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- This file contains definitions of resources that will be translated for
each locale. Specifically, these are UI strings that are used by CEF that
need to be translated for each locale.-->
<grit base_dir="." latest_public_release="0" current_release="1"
source_lang_id="en" enc_check="möl">
<outputs>
<!-- Note that all output references are relative to the output directory
which is specified at build time. -->
<output filename="grit/cef_strings.h" type="rc_header">
<emit emit_type='prepend'></emit>
</output>
<!-- TODO keep the list of output files synchronized with other grd files, e.g.
webkit/glue/webkit_strings.grd -->
<output filename="cef_strings_am.pak" type="data_package" lang="am" />
<output filename="cef_strings_ar.pak" type="data_package" lang="ar" />
<if expr="pp_ifdef('use_third_party_translations')">
<output filename="cef_strings_ast.pak" type="data_package" lang="ast" />
</if>
<output filename="cef_strings_bg.pak" type="data_package" lang="bg" />
<output filename="cef_strings_bn.pak" type="data_package" lang="bn" />
<if expr="pp_ifdef('use_third_party_translations')">
<output filename="cef_strings_bs.pak" type="data_package" lang="bs" />
</if>
<output filename="cef_strings_ca.pak" type="data_package" lang="ca" />
<if expr="pp_ifdef('use_third_party_translations')">
<output filename="cef_strings_ca@valencia.pak" type="data_package" lang="ca@valencia" />
</if>
<output filename="cef_strings_cs.pak" type="data_package" lang="cs" />
<output filename="cef_strings_da.pak" type="data_package" lang="da" />
<output filename="cef_strings_de.pak" type="data_package" lang="de" />
<output filename="cef_strings_el.pak" type="data_package" lang="el" />
<if expr="pp_ifdef('use_third_party_translations')">
<output filename="cef_strings_en-AU.pak" type="data_package" lang="en-AU" />
</if>
<output filename="cef_strings_en-GB.pak" type="data_package" lang="en-GB" />
<output filename="cef_strings_en-US.pak" type="data_package" lang="en" />
<if expr="pp_ifdef('use_third_party_translations')">
<output filename="cef_strings_eo.pak" type="data_package" lang="eo" />
</if>
<output filename="cef_strings_es.pak" type="data_package" lang="es" />
<output filename="cef_strings_es-419.pak" type="data_package" lang="es-419" />
<output filename="cef_strings_et.pak" type="data_package" lang="et" />
<if expr="pp_ifdef('use_third_party_translations')">
<output filename="cef_strings_eu.pak" type="data_package" lang="eu" />
</if>
<output filename="cef_strings_fa.pak" type="data_package" lang="fa" />
<output filename="cef_strings_fake-bidi.pak" type="data_package" lang="fake-bidi" />
<output filename="cef_strings_fi.pak" type="data_package" lang="fi" />
<output filename="cef_strings_fil.pak" type="data_package" lang="fil" />
<output filename="cef_strings_fr.pak" type="data_package" lang="fr" />
<if expr="pp_ifdef('use_third_party_translations')">
<output filename="cef_strings_gl.pak" type="data_package" lang="gl" />
</if>
<output filename="cef_strings_gu.pak" type="data_package" lang="gu" />
<output filename="cef_strings_he.pak" type="data_package" lang="he" />
<output filename="cef_strings_hi.pak" type="data_package" lang="hi" />
<output filename="cef_strings_hr.pak" type="data_package" lang="hr" />
<output filename="cef_strings_hu.pak" type="data_package" lang="hu" />
<if expr="pp_ifdef('use_third_party_translations')">
<output filename="cef_strings_hy.pak" type="data_package" lang="hy" />
<output filename="cef_strings_ia.pak" type="data_package" lang="ia" />
</if>
<output filename="cef_strings_id.pak" type="data_package" lang="id" />
<output filename="cef_strings_it.pak" type="data_package" lang="it" />
<output filename="cef_strings_ja.pak" type="data_package" lang="ja" />
<if expr="pp_ifdef('use_third_party_translations')">
<output filename="cef_strings_ka.pak" type="data_package" lang="ka" />
</if>
<output filename="cef_strings_kn.pak" type="data_package" lang="kn" />
<output filename="cef_strings_ko.pak" type="data_package" lang="ko" />
<if expr="pp_ifdef('use_third_party_translations')">
<output filename="cef_strings_ku.pak" type="data_package" lang="ku" />
<output filename="cef_strings_kw.pak" type="data_package" lang="kw" />
</if>
<output filename="cef_strings_lt.pak" type="data_package" lang="lt" />
<output filename="cef_strings_lv.pak" type="data_package" lang="lv" />
<output filename="cef_strings_ml.pak" type="data_package" lang="ml" />
<output filename="cef_strings_mr.pak" type="data_package" lang="mr" />
<output filename="cef_strings_ms.pak" type="data_package" lang="ms" />
<output filename="cef_strings_nl.pak" type="data_package" lang="nl" />
<!-- The translation console uses 'no' for Norwegian Bokmål. It should
be 'nb'. -->
<output filename="cef_strings_nb.pak" type="data_package" lang="no" />
<output filename="cef_strings_pl.pak" type="data_package" lang="pl" />
<output filename="cef_strings_pt-BR.pak" type="data_package" lang="pt-BR" />
<output filename="cef_strings_pt-PT.pak" type="data_package" lang="pt-PT" />
<output filename="cef_strings_ro.pak" type="data_package" lang="ro" />
<output filename="cef_strings_ru.pak" type="data_package" lang="ru" />
<output filename="cef_strings_sk.pak" type="data_package" lang="sk" />
<output filename="cef_strings_sl.pak" type="data_package" lang="sl" />
<output filename="cef_strings_sr.pak" type="data_package" lang="sr" />
<output filename="cef_strings_sv.pak" type="data_package" lang="sv" />
<output filename="cef_strings_sw.pak" type="data_package" lang="sw" />
<output filename="cef_strings_ta.pak" type="data_package" lang="ta" />
<output filename="cef_strings_te.pak" type="data_package" lang="te" />
<output filename="cef_strings_th.pak" type="data_package" lang="th" />
<output filename="cef_strings_tr.pak" type="data_package" lang="tr" />
<if expr="pp_ifdef('use_third_party_translations')">
<output filename="cef_strings_ug.pak" type="data_package" lang="ug" />
</if>
<output filename="cef_strings_uk.pak" type="data_package" lang="uk" />
<output filename="cef_strings_vi.pak" type="data_package" lang="vi" />
<output filename="cef_strings_zh-CN.pak" type="data_package" lang="zh-CN" />
<output filename="cef_strings_zh-TW.pak" type="data_package" lang="zh-TW" />
</outputs>
<translations>
<!-- TODO figure out a reliable way to generate XMB/XTB files. For more information see:
https://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/ce501a6ee4958c61 -->
</translations>
<release seq="1" allow_pseudo="false">
<messages fallback_to_english="true">
<!-- TODO add all of your "string table" messages here. Remember to
change nontranslateable parts of the messages into placeholders (using the
<ph> element). You can also use the 'grit add' tool to help you identify
nontranslateable parts and create placeholders for them. -->
<message name="IDS_MENU_BACK" desc="The text label of the Back menu item">
&amp;Back
</message>
<message name="IDS_MENU_FORWARD" desc="The text label of the Forward menu item">
&amp;Forward
</message>
<message name="IDS_MENU_RELOAD" desc="The text label of the Reload menu item">
&amp;Reload
</message>
<message name="IDS_MENU_RELOAD_NOCACHE" desc="The text label of the Reload no cache menu item">
Reload no cache
</message>
<message name="IDS_MENU_STOPLOAD" desc="The text label of the Stop menu item">
&amp;Stop
</message>
<message name="IDS_MENU_UNDO" desc="The text label of the Undo menu item">
&amp;Undo
</message>
<message name="IDS_MENU_REDO" desc="The text label of the Redo menu item">
&amp;Redo
</message>
<message name="IDS_MENU_CUT" desc="The text label of the Cut menu item">
Cu&amp;t
</message>
<message name="IDS_MENU_COPY" desc="The text label of the Copy menu item">
&amp;Copy
</message>
<message name="IDS_MENU_PASTE" desc="The text label of the Paste menu item">
&amp;Paste
</message>
<message name="IDS_MENU_DELETE" desc="The text label of the Delete menu item (which deletes selected text without copying to clipboard)">
&amp;Delete
</message>
<message name="IDS_MENU_SELECT_ALL" desc="The text label of the Select All menu item">
Select &amp;all
</message>
<message name="IDS_MENU_FIND" desc="The text label of the Find... menu item">
&amp;Find...
</message>
<message name="IDS_MENU_PRINT" desc="The text label of the Print... menu item. Opens a dialog box to select print settings">
&amp;Print...
</message>
<message name="IDS_MENU_VIEW_SOURCE" desc="The text label for the View Source... menu item.">
View Source...
</message>
</messages>
</release>
</grit>

View File

@ -11,6 +11,7 @@
//
#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/geolocation_handler_cpptoc.h"
#include "libcef_dll/cpptoc/jsdialog_handler_cpptoc.h"
@ -119,6 +120,22 @@ struct _cef_jsdialog_handler_t* CEF_CALLBACK client_get_jsdialog_handler(
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) {
@ -157,6 +174,7 @@ CefClientCppToC::CefClientCppToC(CefClient* cls)
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

@ -0,0 +1,132 @@
// 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/context_menu_handler_cpptoc.h"
#include "libcef_dll/ctocpp/browser_ctocpp.h"
#include "libcef_dll/ctocpp/context_menu_params_ctocpp.h"
#include "libcef_dll/ctocpp/frame_ctocpp.h"
#include "libcef_dll/ctocpp/menu_model_ctocpp.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK context_menu_handler_on_before_context_menu(
struct _cef_context_menu_handler_t* self, cef_browser_t* browser,
struct _cef_frame_t* frame, struct _cef_context_menu_params_t* params,
struct _cef_menu_model_t* model) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return;
// Verify param: frame; type: refptr_diff
DCHECK(frame);
if (!frame)
return;
// Verify param: params; type: refptr_diff
DCHECK(params);
if (!params)
return;
// Verify param: model; type: refptr_diff
DCHECK(model);
if (!model)
return;
// Execute
CefContextMenuHandlerCppToC::Get(self)->OnBeforeContextMenu(
CefBrowserCToCpp::Wrap(browser),
CefFrameCToCpp::Wrap(frame),
CefContextMenuParamsCToCpp::Wrap(params),
CefMenuModelCToCpp::Wrap(model));
}
int CEF_CALLBACK context_menu_handler_on_context_menu_command(
struct _cef_context_menu_handler_t* self, cef_browser_t* browser,
struct _cef_frame_t* frame, struct _cef_context_menu_params_t* params,
int command_id, enum cef_event_flags_t event_flags) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return 0;
// Verify param: frame; type: refptr_diff
DCHECK(frame);
if (!frame)
return 0;
// Verify param: params; type: refptr_diff
DCHECK(params);
if (!params)
return 0;
// Execute
bool _retval = CefContextMenuHandlerCppToC::Get(self)->OnContextMenuCommand(
CefBrowserCToCpp::Wrap(browser),
CefFrameCToCpp::Wrap(frame),
CefContextMenuParamsCToCpp::Wrap(params),
command_id,
event_flags);
// Return type: bool
return _retval;
}
void CEF_CALLBACK context_menu_handler_on_context_menu_dismissed(
struct _cef_context_menu_handler_t* self, cef_browser_t* browser,
struct _cef_frame_t* frame) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return;
// Verify param: frame; type: refptr_diff
DCHECK(frame);
if (!frame)
return;
// Execute
CefContextMenuHandlerCppToC::Get(self)->OnContextMenuDismissed(
CefBrowserCToCpp::Wrap(browser),
CefFrameCToCpp::Wrap(frame));
}
// CONSTRUCTOR - Do not edit by hand.
CefContextMenuHandlerCppToC::CefContextMenuHandlerCppToC(
CefContextMenuHandler* cls)
: CefCppToC<CefContextMenuHandlerCppToC, CefContextMenuHandler,
cef_context_menu_handler_t>(cls) {
struct_.struct_.on_before_context_menu =
context_menu_handler_on_before_context_menu;
struct_.struct_.on_context_menu_command =
context_menu_handler_on_context_menu_command;
struct_.struct_.on_context_menu_dismissed =
context_menu_handler_on_context_menu_dismissed;
}
#ifndef NDEBUG
template<> long CefCppToC<CefContextMenuHandlerCppToC, CefContextMenuHandler,
cef_context_menu_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_CONTEXT_MENU_HANDLER_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_CONTEXT_MENU_HANDLER_CPPTOC_H_
#pragma once
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
#include "include/cef_context_menu_handler.h"
#include "include/capi/cef_context_menu_handler_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed wrapper-side only.
class CefContextMenuHandlerCppToC
: public CefCppToC<CefContextMenuHandlerCppToC, CefContextMenuHandler,
cef_context_menu_handler_t> {
public:
explicit CefContextMenuHandlerCppToC(CefContextMenuHandler* cls);
virtual ~CefContextMenuHandlerCppToC() {}
};
#endif // USING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CPPTOC_CONTEXT_MENU_HANDLER_CPPTOC_H_

View File

@ -0,0 +1,296 @@
// 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/context_menu_params_cpptoc.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK context_menu_params_get_xcoord(
struct _cef_context_menu_params_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
int _retval = CefContextMenuParamsCppToC::Get(self)->GetXCoord();
// Return type: simple
return _retval;
}
int CEF_CALLBACK context_menu_params_get_ycoord(
struct _cef_context_menu_params_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
int _retval = CefContextMenuParamsCppToC::Get(self)->GetYCoord();
// Return type: simple
return _retval;
}
enum cef_context_menu_type_flags_t CEF_CALLBACK context_menu_params_get_type_flags(
struct _cef_context_menu_params_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return CM_TYPEFLAG_NONE;
// Execute
cef_context_menu_type_flags_t _retval = CefContextMenuParamsCppToC::Get(
self)->GetTypeFlags();
// Return type: simple
return _retval;
}
cef_string_userfree_t CEF_CALLBACK context_menu_params_get_link_url(
struct _cef_context_menu_params_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefContextMenuParamsCppToC::Get(self)->GetLinkUrl();
// Return type: string
return _retval.DetachToUserFree();
}
cef_string_userfree_t CEF_CALLBACK context_menu_params_get_unfiltered_link_url(
struct _cef_context_menu_params_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefContextMenuParamsCppToC::Get(
self)->GetUnfilteredLinkUrl();
// Return type: string
return _retval.DetachToUserFree();
}
cef_string_userfree_t CEF_CALLBACK context_menu_params_get_source_url(
struct _cef_context_menu_params_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefContextMenuParamsCppToC::Get(self)->GetSourceUrl();
// Return type: string
return _retval.DetachToUserFree();
}
int CEF_CALLBACK context_menu_params_is_image_blocked(
struct _cef_context_menu_params_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
bool _retval = CefContextMenuParamsCppToC::Get(self)->IsImageBlocked();
// Return type: bool
return _retval;
}
cef_string_userfree_t CEF_CALLBACK context_menu_params_get_page_url(
struct _cef_context_menu_params_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefContextMenuParamsCppToC::Get(self)->GetPageUrl();
// Return type: string
return _retval.DetachToUserFree();
}
cef_string_userfree_t CEF_CALLBACK context_menu_params_get_frame_url(
struct _cef_context_menu_params_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefContextMenuParamsCppToC::Get(self)->GetFrameUrl();
// Return type: string
return _retval.DetachToUserFree();
}
cef_string_userfree_t CEF_CALLBACK context_menu_params_get_frame_charset(
struct _cef_context_menu_params_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefContextMenuParamsCppToC::Get(self)->GetFrameCharset();
// Return type: string
return _retval.DetachToUserFree();
}
enum cef_context_menu_media_type_t CEF_CALLBACK context_menu_params_get_media_type(
struct _cef_context_menu_params_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return CM_MEDIATYPE_NONE;
// Execute
cef_context_menu_media_type_t _retval = CefContextMenuParamsCppToC::Get(
self)->GetMediaType();
// Return type: simple
return _retval;
}
enum cef_context_menu_media_state_flags_t CEF_CALLBACK context_menu_params_get_media_state_flags(
struct _cef_context_menu_params_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return CM_MEDIAFLAG_NONE;
// Execute
cef_context_menu_media_state_flags_t _retval =
CefContextMenuParamsCppToC::Get(self)->GetMediaStateFlags();
// Return type: simple
return _retval;
}
cef_string_userfree_t CEF_CALLBACK context_menu_params_get_selection_text(
struct _cef_context_menu_params_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefContextMenuParamsCppToC::Get(self)->GetSelectionText();
// Return type: string
return _retval.DetachToUserFree();
}
int CEF_CALLBACK context_menu_params_is_editable(
struct _cef_context_menu_params_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
bool _retval = CefContextMenuParamsCppToC::Get(self)->IsEditable();
// Return type: bool
return _retval;
}
int CEF_CALLBACK context_menu_params_is_speech_input_enabled(
struct _cef_context_menu_params_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
bool _retval = CefContextMenuParamsCppToC::Get(self)->IsSpeechInputEnabled();
// Return type: bool
return _retval;
}
enum cef_context_menu_edit_state_flags_t CEF_CALLBACK context_menu_params_get_edit_state_flags(
struct _cef_context_menu_params_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return CM_EDITFLAG_NONE;
// Execute
cef_context_menu_edit_state_flags_t _retval = CefContextMenuParamsCppToC::Get(
self)->GetEditStateFlags();
// Return type: simple
return _retval;
}
// CONSTRUCTOR - Do not edit by hand.
CefContextMenuParamsCppToC::CefContextMenuParamsCppToC(
CefContextMenuParams* cls)
: CefCppToC<CefContextMenuParamsCppToC, CefContextMenuParams,
cef_context_menu_params_t>(cls) {
struct_.struct_.get_xcoord = context_menu_params_get_xcoord;
struct_.struct_.get_ycoord = context_menu_params_get_ycoord;
struct_.struct_.get_type_flags = context_menu_params_get_type_flags;
struct_.struct_.get_link_url = context_menu_params_get_link_url;
struct_.struct_.get_unfiltered_link_url =
context_menu_params_get_unfiltered_link_url;
struct_.struct_.get_source_url = context_menu_params_get_source_url;
struct_.struct_.is_image_blocked = context_menu_params_is_image_blocked;
struct_.struct_.get_page_url = context_menu_params_get_page_url;
struct_.struct_.get_frame_url = context_menu_params_get_frame_url;
struct_.struct_.get_frame_charset = context_menu_params_get_frame_charset;
struct_.struct_.get_media_type = context_menu_params_get_media_type;
struct_.struct_.get_media_state_flags =
context_menu_params_get_media_state_flags;
struct_.struct_.get_selection_text = context_menu_params_get_selection_text;
struct_.struct_.is_editable = context_menu_params_is_editable;
struct_.struct_.is_speech_input_enabled =
context_menu_params_is_speech_input_enabled;
struct_.struct_.get_edit_state_flags =
context_menu_params_get_edit_state_flags;
}
#ifndef NDEBUG
template<> long CefCppToC<CefContextMenuParamsCppToC, CefContextMenuParams,
cef_context_menu_params_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_CONTEXT_MENU_PARAMS_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_CONTEXT_MENU_PARAMS_CPPTOC_H_
#pragma once
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
#include "include/cef_context_menu_handler.h"
#include "include/capi/cef_context_menu_handler_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefContextMenuParamsCppToC
: public CefCppToC<CefContextMenuParamsCppToC, CefContextMenuParams,
cef_context_menu_params_t> {
public:
explicit CefContextMenuParamsCppToC(CefContextMenuParams* cls);
virtual ~CefContextMenuParamsCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CPPTOC_CONTEXT_MENU_PARAMS_CPPTOC_H_

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,36 @@
// 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_MENU_MODEL_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_MENU_MODEL_CPPTOC_H_
#pragma once
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
#include "include/cef_menu_model.h"
#include "include/capi/cef_menu_model_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefMenuModelCppToC
: public CefCppToC<CefMenuModelCppToC, CefMenuModel, cef_menu_model_t> {
public:
explicit CefMenuModelCppToC(CefMenuModel* cls);
virtual ~CefMenuModelCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CPPTOC_MENU_MODEL_CPPTOC_H_

View File

@ -13,6 +13,7 @@
#include "libcef_dll/cpptoc/browser_cpptoc.h"
#include "libcef_dll/cpptoc/process_message_cpptoc.h"
#include "libcef_dll/ctocpp/client_ctocpp.h"
#include "libcef_dll/ctocpp/context_menu_handler_ctocpp.h"
#include "libcef_dll/ctocpp/display_handler_ctocpp.h"
#include "libcef_dll/ctocpp/geolocation_handler_ctocpp.h"
#include "libcef_dll/ctocpp/jsdialog_handler_ctocpp.h"
@ -102,6 +103,20 @@ CefRefPtr<CefJSDialogHandler> CefClientCToCpp::GetJSDialogHandler() {
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

@ -38,6 +38,7 @@ class CefClientCToCpp
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

@ -0,0 +1,116 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "libcef_dll/cpptoc/browser_cpptoc.h"
#include "libcef_dll/cpptoc/context_menu_params_cpptoc.h"
#include "libcef_dll/cpptoc/frame_cpptoc.h"
#include "libcef_dll/cpptoc/menu_model_cpptoc.h"
#include "libcef_dll/ctocpp/context_menu_handler_ctocpp.h"
// VIRTUAL METHODS - Body may be edited by hand.
void CefContextMenuHandlerCToCpp::OnBeforeContextMenu(
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
CefRefPtr<CefContextMenuParams> params, CefRefPtr<CefMenuModel> model) {
if (CEF_MEMBER_MISSING(struct_, on_before_context_menu))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return;
// Verify param: frame; type: refptr_diff
DCHECK(frame.get());
if (!frame.get())
return;
// Verify param: params; type: refptr_diff
DCHECK(params.get());
if (!params.get())
return;
// Verify param: model; type: refptr_diff
DCHECK(model.get());
if (!model.get())
return;
// Execute
struct_->on_before_context_menu(struct_,
CefBrowserCppToC::Wrap(browser),
CefFrameCppToC::Wrap(frame),
CefContextMenuParamsCppToC::Wrap(params),
CefMenuModelCppToC::Wrap(model));
}
bool CefContextMenuHandlerCToCpp::OnContextMenuCommand(
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
CefRefPtr<CefContextMenuParams> params, int command_id,
EventFlags event_flags) {
if (CEF_MEMBER_MISSING(struct_, on_context_menu_command))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return false;
// Verify param: frame; type: refptr_diff
DCHECK(frame.get());
if (!frame.get())
return false;
// Verify param: params; type: refptr_diff
DCHECK(params.get());
if (!params.get())
return false;
// Execute
int _retval = struct_->on_context_menu_command(struct_,
CefBrowserCppToC::Wrap(browser),
CefFrameCppToC::Wrap(frame),
CefContextMenuParamsCppToC::Wrap(params),
command_id,
event_flags);
// Return type: bool
return _retval?true:false;
}
void CefContextMenuHandlerCToCpp::OnContextMenuDismissed(
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame) {
if (CEF_MEMBER_MISSING(struct_, on_context_menu_dismissed))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return;
// Verify param: frame; type: refptr_diff
DCHECK(frame.get());
if (!frame.get())
return;
// Execute
struct_->on_context_menu_dismissed(struct_,
CefBrowserCppToC::Wrap(browser),
CefFrameCppToC::Wrap(frame));
}
#ifndef NDEBUG
template<> long CefCToCpp<CefContextMenuHandlerCToCpp, CefContextMenuHandler,
cef_context_menu_handler_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,49 @@
// 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_CONTEXT_MENU_HANDLER_CTOCPP_H_
#define CEF_LIBCEF_DLL_CTOCPP_CONTEXT_MENU_HANDLER_CTOCPP_H_
#pragma once
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
#include "include/cef_context_menu_handler.h"
#include "include/capi/cef_context_menu_handler_capi.h"
#include "libcef_dll/ctocpp/ctocpp.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed DLL-side only.
class CefContextMenuHandlerCToCpp
: public CefCToCpp<CefContextMenuHandlerCToCpp, CefContextMenuHandler,
cef_context_menu_handler_t> {
public:
explicit CefContextMenuHandlerCToCpp(cef_context_menu_handler_t* str)
: CefCToCpp<CefContextMenuHandlerCToCpp, CefContextMenuHandler,
cef_context_menu_handler_t>(str) {}
virtual ~CefContextMenuHandlerCToCpp() {}
// 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;
virtual void OnContextMenuDismissed(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame) OVERRIDE;
};
#endif // BUILDING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CTOCPP_CONTEXT_MENU_HANDLER_CTOCPP_H_

View File

@ -0,0 +1,249 @@
// 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/ctocpp/context_menu_params_ctocpp.h"
// VIRTUAL METHODS - Body may be edited by hand.
int CefContextMenuParamsCToCpp::GetXCoord() {
if (CEF_MEMBER_MISSING(struct_, get_xcoord))
return 0;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->get_xcoord(struct_);
// Return type: simple
return _retval;
}
int CefContextMenuParamsCToCpp::GetYCoord() {
if (CEF_MEMBER_MISSING(struct_, get_ycoord))
return 0;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->get_ycoord(struct_);
// Return type: simple
return _retval;
}
CefContextMenuParams::TypeFlags CefContextMenuParamsCToCpp::GetTypeFlags() {
if (CEF_MEMBER_MISSING(struct_, get_type_flags))
return CM_TYPEFLAG_NONE;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_context_menu_type_flags_t _retval = struct_->get_type_flags(struct_);
// Return type: simple
return _retval;
}
CefString CefContextMenuParamsCToCpp::GetLinkUrl() {
if (CEF_MEMBER_MISSING(struct_, get_link_url))
return CefString();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_string_userfree_t _retval = struct_->get_link_url(struct_);
// Return type: string
CefString _retvalStr;
_retvalStr.AttachToUserFree(_retval);
return _retvalStr;
}
CefString CefContextMenuParamsCToCpp::GetUnfilteredLinkUrl() {
if (CEF_MEMBER_MISSING(struct_, get_unfiltered_link_url))
return CefString();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_string_userfree_t _retval = struct_->get_unfiltered_link_url(struct_);
// Return type: string
CefString _retvalStr;
_retvalStr.AttachToUserFree(_retval);
return _retvalStr;
}
CefString CefContextMenuParamsCToCpp::GetSourceUrl() {
if (CEF_MEMBER_MISSING(struct_, get_source_url))
return CefString();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_string_userfree_t _retval = struct_->get_source_url(struct_);
// Return type: string
CefString _retvalStr;
_retvalStr.AttachToUserFree(_retval);
return _retvalStr;
}
bool CefContextMenuParamsCToCpp::IsImageBlocked() {
if (CEF_MEMBER_MISSING(struct_, is_image_blocked))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->is_image_blocked(struct_);
// Return type: bool
return _retval?true:false;
}
CefString CefContextMenuParamsCToCpp::GetPageUrl() {
if (CEF_MEMBER_MISSING(struct_, get_page_url))
return CefString();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_string_userfree_t _retval = struct_->get_page_url(struct_);
// Return type: string
CefString _retvalStr;
_retvalStr.AttachToUserFree(_retval);
return _retvalStr;
}
CefString CefContextMenuParamsCToCpp::GetFrameUrl() {
if (CEF_MEMBER_MISSING(struct_, get_frame_url))
return CefString();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_string_userfree_t _retval = struct_->get_frame_url(struct_);
// Return type: string
CefString _retvalStr;
_retvalStr.AttachToUserFree(_retval);
return _retvalStr;
}
CefString CefContextMenuParamsCToCpp::GetFrameCharset() {
if (CEF_MEMBER_MISSING(struct_, get_frame_charset))
return CefString();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_string_userfree_t _retval = struct_->get_frame_charset(struct_);
// Return type: string
CefString _retvalStr;
_retvalStr.AttachToUserFree(_retval);
return _retvalStr;
}
CefContextMenuParams::MediaType CefContextMenuParamsCToCpp::GetMediaType() {
if (CEF_MEMBER_MISSING(struct_, get_media_type))
return CM_MEDIATYPE_NONE;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_context_menu_media_type_t _retval = struct_->get_media_type(struct_);
// Return type: simple
return _retval;
}
CefContextMenuParams::MediaStateFlags CefContextMenuParamsCToCpp::GetMediaStateFlags(
) {
if (CEF_MEMBER_MISSING(struct_, get_media_state_flags))
return CM_MEDIAFLAG_NONE;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_context_menu_media_state_flags_t _retval = struct_->get_media_state_flags(
struct_);
// Return type: simple
return _retval;
}
CefString CefContextMenuParamsCToCpp::GetSelectionText() {
if (CEF_MEMBER_MISSING(struct_, get_selection_text))
return CefString();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_string_userfree_t _retval = struct_->get_selection_text(struct_);
// Return type: string
CefString _retvalStr;
_retvalStr.AttachToUserFree(_retval);
return _retvalStr;
}
bool CefContextMenuParamsCToCpp::IsEditable() {
if (CEF_MEMBER_MISSING(struct_, is_editable))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->is_editable(struct_);
// Return type: bool
return _retval?true:false;
}
bool CefContextMenuParamsCToCpp::IsSpeechInputEnabled() {
if (CEF_MEMBER_MISSING(struct_, is_speech_input_enabled))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->is_speech_input_enabled(struct_);
// Return type: bool
return _retval?true:false;
}
CefContextMenuParams::EditStateFlags CefContextMenuParamsCToCpp::GetEditStateFlags(
) {
if (CEF_MEMBER_MISSING(struct_, get_edit_state_flags))
return CM_EDITFLAG_NONE;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_context_menu_edit_state_flags_t _retval = struct_->get_edit_state_flags(
struct_);
// Return type: simple
return _retval;
}
#ifndef NDEBUG
template<> long CefCToCpp<CefContextMenuParamsCToCpp, CefContextMenuParams,
cef_context_menu_params_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,57 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_CONTEXT_MENU_PARAMS_CTOCPP_H_
#define CEF_LIBCEF_DLL_CTOCPP_CONTEXT_MENU_PARAMS_CTOCPP_H_
#pragma once
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
#include "include/cef_context_menu_handler.h"
#include "include/capi/cef_context_menu_handler_capi.h"
#include "libcef_dll/ctocpp/ctocpp.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed wrapper-side only.
class CefContextMenuParamsCToCpp
: public CefCToCpp<CefContextMenuParamsCToCpp, CefContextMenuParams,
cef_context_menu_params_t> {
public:
explicit CefContextMenuParamsCToCpp(cef_context_menu_params_t* str)
: CefCToCpp<CefContextMenuParamsCToCpp, CefContextMenuParams,
cef_context_menu_params_t>(str) {}
virtual ~CefContextMenuParamsCToCpp() {}
// CefContextMenuParams methods
virtual int GetXCoord() OVERRIDE;
virtual int GetYCoord() OVERRIDE;
virtual TypeFlags GetTypeFlags() OVERRIDE;
virtual CefString GetLinkUrl() OVERRIDE;
virtual CefString GetUnfilteredLinkUrl() OVERRIDE;
virtual CefString GetSourceUrl() OVERRIDE;
virtual bool IsImageBlocked() OVERRIDE;
virtual CefString GetPageUrl() OVERRIDE;
virtual CefString GetFrameUrl() OVERRIDE;
virtual CefString GetFrameCharset() OVERRIDE;
virtual MediaType GetMediaType() OVERRIDE;
virtual MediaStateFlags GetMediaStateFlags() OVERRIDE;
virtual CefString GetSelectionText() OVERRIDE;
virtual bool IsEditable() OVERRIDE;
virtual bool IsSpeechInputEnabled() OVERRIDE;
virtual EditStateFlags GetEditStateFlags() OVERRIDE;
};
#endif // USING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CTOCPP_CONTEXT_MENU_PARAMS_CTOCPP_H_

View File

@ -0,0 +1,839 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "libcef_dll/ctocpp/menu_model_ctocpp.h"
// VIRTUAL METHODS - Body may be edited by hand.
bool CefMenuModelCToCpp::Clear() {
if (CEF_MEMBER_MISSING(struct_, clear))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->clear(struct_);
// Return type: bool
return _retval?true:false;
}
int CefMenuModelCToCpp::GetCount() {
if (CEF_MEMBER_MISSING(struct_, get_count))
return 0;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->get_count(struct_);
// Return type: simple
return _retval;
}
bool CefMenuModelCToCpp::AddSeparator() {
if (CEF_MEMBER_MISSING(struct_, add_separator))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->add_separator(struct_);
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::AddItem(int command_id, const CefString& label) {
if (CEF_MEMBER_MISSING(struct_, add_item))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: label; type: string_byref_const
DCHECK(!label.empty());
if (label.empty())
return false;
// Execute
int _retval = struct_->add_item(struct_,
command_id,
label.GetStruct());
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::AddCheckItem(int command_id, const CefString& label) {
if (CEF_MEMBER_MISSING(struct_, add_check_item))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: label; type: string_byref_const
DCHECK(!label.empty());
if (label.empty())
return false;
// Execute
int _retval = struct_->add_check_item(struct_,
command_id,
label.GetStruct());
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::AddRadioItem(int command_id, const CefString& label,
int group_id) {
if (CEF_MEMBER_MISSING(struct_, add_radio_item))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: label; type: string_byref_const
DCHECK(!label.empty());
if (label.empty())
return false;
// Execute
int _retval = struct_->add_radio_item(struct_,
command_id,
label.GetStruct(),
group_id);
// Return type: bool
return _retval?true:false;
}
CefRefPtr<CefMenuModel> CefMenuModelCToCpp::AddSubMenu(int command_id,
const CefString& label) {
if (CEF_MEMBER_MISSING(struct_, add_sub_menu))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: label; type: string_byref_const
DCHECK(!label.empty());
if (label.empty())
return NULL;
// Execute
cef_menu_model_t* _retval = struct_->add_sub_menu(struct_,
command_id,
label.GetStruct());
// Return type: refptr_same
return CefMenuModelCToCpp::Wrap(_retval);
}
bool CefMenuModelCToCpp::InsertSeparatorAt(int index) {
if (CEF_MEMBER_MISSING(struct_, insert_separator_at))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->insert_separator_at(struct_,
index);
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::InsertItemAt(int index, int command_id,
const CefString& label) {
if (CEF_MEMBER_MISSING(struct_, insert_item_at))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: label; type: string_byref_const
DCHECK(!label.empty());
if (label.empty())
return false;
// Execute
int _retval = struct_->insert_item_at(struct_,
index,
command_id,
label.GetStruct());
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::InsertCheckItemAt(int index, int command_id,
const CefString& label) {
if (CEF_MEMBER_MISSING(struct_, insert_check_item_at))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: label; type: string_byref_const
DCHECK(!label.empty());
if (label.empty())
return false;
// Execute
int _retval = struct_->insert_check_item_at(struct_,
index,
command_id,
label.GetStruct());
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::InsertRadioItemAt(int index, int command_id,
const CefString& label, int group_id) {
if (CEF_MEMBER_MISSING(struct_, insert_radio_item_at))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: label; type: string_byref_const
DCHECK(!label.empty());
if (label.empty())
return false;
// Execute
int _retval = struct_->insert_radio_item_at(struct_,
index,
command_id,
label.GetStruct(),
group_id);
// Return type: bool
return _retval?true:false;
}
CefRefPtr<CefMenuModel> CefMenuModelCToCpp::InsertSubMenuAt(int index,
int command_id, const CefString& label) {
if (CEF_MEMBER_MISSING(struct_, insert_sub_menu_at))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: label; type: string_byref_const
DCHECK(!label.empty());
if (label.empty())
return NULL;
// Execute
cef_menu_model_t* _retval = struct_->insert_sub_menu_at(struct_,
index,
command_id,
label.GetStruct());
// Return type: refptr_same
return CefMenuModelCToCpp::Wrap(_retval);
}
bool CefMenuModelCToCpp::Remove(int command_id) {
if (CEF_MEMBER_MISSING(struct_, remove))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->remove(struct_,
command_id);
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::RemoveAt(int index) {
if (CEF_MEMBER_MISSING(struct_, remove_at))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->remove_at(struct_,
index);
// Return type: bool
return _retval?true:false;
}
int CefMenuModelCToCpp::GetIndexOf(int command_id) {
if (CEF_MEMBER_MISSING(struct_, get_index_of))
return 0;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->get_index_of(struct_,
command_id);
// Return type: simple
return _retval;
}
int CefMenuModelCToCpp::GetCommandIdAt(int index) {
if (CEF_MEMBER_MISSING(struct_, get_command_id_at))
return 0;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->get_command_id_at(struct_,
index);
// Return type: simple
return _retval;
}
bool CefMenuModelCToCpp::SetCommandIdAt(int index, int command_id) {
if (CEF_MEMBER_MISSING(struct_, set_command_id_at))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->set_command_id_at(struct_,
index,
command_id);
// Return type: bool
return _retval?true:false;
}
CefString CefMenuModelCToCpp::GetLabel(int command_id) {
if (CEF_MEMBER_MISSING(struct_, get_label))
return CefString();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_string_userfree_t _retval = struct_->get_label(struct_,
command_id);
// Return type: string
CefString _retvalStr;
_retvalStr.AttachToUserFree(_retval);
return _retvalStr;
}
CefString CefMenuModelCToCpp::GetLabelAt(int index) {
if (CEF_MEMBER_MISSING(struct_, get_label_at))
return CefString();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_string_userfree_t _retval = struct_->get_label_at(struct_,
index);
// Return type: string
CefString _retvalStr;
_retvalStr.AttachToUserFree(_retval);
return _retvalStr;
}
bool CefMenuModelCToCpp::SetLabel(int command_id, const CefString& label) {
if (CEF_MEMBER_MISSING(struct_, set_label))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: label; type: string_byref_const
DCHECK(!label.empty());
if (label.empty())
return false;
// Execute
int _retval = struct_->set_label(struct_,
command_id,
label.GetStruct());
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::SetLabelAt(int index, const CefString& label) {
if (CEF_MEMBER_MISSING(struct_, set_label_at))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: label; type: string_byref_const
DCHECK(!label.empty());
if (label.empty())
return false;
// Execute
int _retval = struct_->set_label_at(struct_,
index,
label.GetStruct());
// Return type: bool
return _retval?true:false;
}
CefMenuModel::MenuItemType CefMenuModelCToCpp::GetType(int command_id) {
if (CEF_MEMBER_MISSING(struct_, get_type))
return MENUITEMTYPE_NONE;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_menu_item_type_t _retval = struct_->get_type(struct_,
command_id);
// Return type: simple
return _retval;
}
CefMenuModel::MenuItemType CefMenuModelCToCpp::GetTypeAt(int index) {
if (CEF_MEMBER_MISSING(struct_, get_type_at))
return MENUITEMTYPE_NONE;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_menu_item_type_t _retval = struct_->get_type_at(struct_,
index);
// Return type: simple
return _retval;
}
int CefMenuModelCToCpp::GetGroupId(int command_id) {
if (CEF_MEMBER_MISSING(struct_, get_group_id))
return 0;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->get_group_id(struct_,
command_id);
// Return type: simple
return _retval;
}
int CefMenuModelCToCpp::GetGroupIdAt(int index) {
if (CEF_MEMBER_MISSING(struct_, get_group_id_at))
return 0;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->get_group_id_at(struct_,
index);
// Return type: simple
return _retval;
}
bool CefMenuModelCToCpp::SetGroupId(int command_id, int group_id) {
if (CEF_MEMBER_MISSING(struct_, set_group_id))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->set_group_id(struct_,
command_id,
group_id);
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::SetGroupIdAt(int index, int group_id) {
if (CEF_MEMBER_MISSING(struct_, set_group_id_at))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->set_group_id_at(struct_,
index,
group_id);
// Return type: bool
return _retval?true:false;
}
CefRefPtr<CefMenuModel> CefMenuModelCToCpp::GetSubMenu(int command_id) {
if (CEF_MEMBER_MISSING(struct_, get_sub_menu))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_menu_model_t* _retval = struct_->get_sub_menu(struct_,
command_id);
// Return type: refptr_same
return CefMenuModelCToCpp::Wrap(_retval);
}
CefRefPtr<CefMenuModel> CefMenuModelCToCpp::GetSubMenuAt(int index) {
if (CEF_MEMBER_MISSING(struct_, get_sub_menu_at))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_menu_model_t* _retval = struct_->get_sub_menu_at(struct_,
index);
// Return type: refptr_same
return CefMenuModelCToCpp::Wrap(_retval);
}
bool CefMenuModelCToCpp::IsVisible(int command_id) {
if (CEF_MEMBER_MISSING(struct_, is_visible))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->is_visible(struct_,
command_id);
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::IsVisibleAt(int index) {
if (CEF_MEMBER_MISSING(struct_, is_visible_at))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->is_visible_at(struct_,
index);
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::SetVisible(int command_id, bool visible) {
if (CEF_MEMBER_MISSING(struct_, set_visible))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->set_visible(struct_,
command_id,
visible);
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::SetVisibleAt(int index, bool visible) {
if (CEF_MEMBER_MISSING(struct_, set_visible_at))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->set_visible_at(struct_,
index,
visible);
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::IsEnabled(int command_id) {
if (CEF_MEMBER_MISSING(struct_, is_enabled))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->is_enabled(struct_,
command_id);
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::IsEnabledAt(int index) {
if (CEF_MEMBER_MISSING(struct_, is_enabled_at))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->is_enabled_at(struct_,
index);
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::SetEnabled(int command_id, bool enabled) {
if (CEF_MEMBER_MISSING(struct_, set_enabled))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->set_enabled(struct_,
command_id,
enabled);
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::SetEnabledAt(int index, bool enabled) {
if (CEF_MEMBER_MISSING(struct_, set_enabled_at))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->set_enabled_at(struct_,
index,
enabled);
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::IsChecked(int command_id) {
if (CEF_MEMBER_MISSING(struct_, is_checked))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->is_checked(struct_,
command_id);
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::IsCheckedAt(int index) {
if (CEF_MEMBER_MISSING(struct_, is_checked_at))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->is_checked_at(struct_,
index);
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::SetChecked(int command_id, bool checked) {
if (CEF_MEMBER_MISSING(struct_, set_checked))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->set_checked(struct_,
command_id,
checked);
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::SetCheckedAt(int index, bool checked) {
if (CEF_MEMBER_MISSING(struct_, set_checked_at))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->set_checked_at(struct_,
index,
checked);
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::HasAccelerator(int command_id) {
if (CEF_MEMBER_MISSING(struct_, has_accelerator))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->has_accelerator(struct_,
command_id);
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::HasAcceleratorAt(int index) {
if (CEF_MEMBER_MISSING(struct_, has_accelerator_at))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->has_accelerator_at(struct_,
index);
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::SetAccelerator(int command_id, int key_code,
bool shift_pressed, bool ctrl_pressed, bool alt_pressed) {
if (CEF_MEMBER_MISSING(struct_, set_accelerator))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->set_accelerator(struct_,
command_id,
key_code,
shift_pressed,
ctrl_pressed,
alt_pressed);
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::SetAcceleratorAt(int index, int key_code,
bool shift_pressed, bool ctrl_pressed, bool alt_pressed) {
if (CEF_MEMBER_MISSING(struct_, set_accelerator_at))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->set_accelerator_at(struct_,
index,
key_code,
shift_pressed,
ctrl_pressed,
alt_pressed);
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::RemoveAccelerator(int command_id) {
if (CEF_MEMBER_MISSING(struct_, remove_accelerator))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->remove_accelerator(struct_,
command_id);
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::RemoveAcceleratorAt(int index) {
if (CEF_MEMBER_MISSING(struct_, remove_accelerator_at))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->remove_accelerator_at(struct_,
index);
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::GetAccelerator(int command_id, int& key_code,
bool& shift_pressed, bool& ctrl_pressed, bool& alt_pressed) {
if (CEF_MEMBER_MISSING(struct_, get_accelerator))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Translate param: shift_pressed; type: bool_byref
int shift_pressedInt = shift_pressed;
// Translate param: ctrl_pressed; type: bool_byref
int ctrl_pressedInt = ctrl_pressed;
// Translate param: alt_pressed; type: bool_byref
int alt_pressedInt = alt_pressed;
// Execute
int _retval = struct_->get_accelerator(struct_,
command_id,
&key_code,
&shift_pressedInt,
&ctrl_pressedInt,
&alt_pressedInt);
// Restore param:shift_pressed; type: bool_byref
shift_pressed = shift_pressedInt?true:false;
// Restore param:ctrl_pressed; type: bool_byref
ctrl_pressed = ctrl_pressedInt?true:false;
// Restore param:alt_pressed; type: bool_byref
alt_pressed = alt_pressedInt?true:false;
// Return type: bool
return _retval?true:false;
}
bool CefMenuModelCToCpp::GetAcceleratorAt(int index, int& key_code,
bool& shift_pressed, bool& ctrl_pressed, bool& alt_pressed) {
if (CEF_MEMBER_MISSING(struct_, get_accelerator_at))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Translate param: shift_pressed; type: bool_byref
int shift_pressedInt = shift_pressed;
// Translate param: ctrl_pressed; type: bool_byref
int ctrl_pressedInt = ctrl_pressed;
// Translate param: alt_pressed; type: bool_byref
int alt_pressedInt = alt_pressed;
// Execute
int _retval = struct_->get_accelerator_at(struct_,
index,
&key_code,
&shift_pressedInt,
&ctrl_pressedInt,
&alt_pressedInt);
// Restore param:shift_pressed; type: bool_byref
shift_pressed = shift_pressedInt?true:false;
// Restore param:ctrl_pressed; type: bool_byref
ctrl_pressed = ctrl_pressedInt?true:false;
// Restore param:alt_pressed; type: bool_byref
alt_pressed = alt_pressedInt?true:false;
// Return type: bool
return _retval?true:false;
}
#ifndef NDEBUG
template<> long CefCToCpp<CefMenuModelCToCpp, CefMenuModel,
cef_menu_model_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,98 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_MENU_MODEL_CTOCPP_H_
#define CEF_LIBCEF_DLL_CTOCPP_MENU_MODEL_CTOCPP_H_
#pragma once
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
#include "include/cef_menu_model.h"
#include "include/capi/cef_menu_model_capi.h"
#include "libcef_dll/ctocpp/ctocpp.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed wrapper-side only.
class CefMenuModelCToCpp
: public CefCToCpp<CefMenuModelCToCpp, CefMenuModel, cef_menu_model_t> {
public:
explicit CefMenuModelCToCpp(cef_menu_model_t* str)
: CefCToCpp<CefMenuModelCToCpp, CefMenuModel, cef_menu_model_t>(str) {}
virtual ~CefMenuModelCToCpp() {}
// CefMenuModel methods
virtual bool Clear() OVERRIDE;
virtual int GetCount() OVERRIDE;
virtual bool AddSeparator() OVERRIDE;
virtual bool AddItem(int command_id, const CefString& label) OVERRIDE;
virtual bool AddCheckItem(int command_id, const CefString& label) OVERRIDE;
virtual bool AddRadioItem(int command_id, const CefString& label,
int group_id) OVERRIDE;
virtual CefRefPtr<CefMenuModel> AddSubMenu(int command_id,
const CefString& label) OVERRIDE;
virtual bool InsertSeparatorAt(int index) OVERRIDE;
virtual bool InsertItemAt(int index, int command_id,
const CefString& label) OVERRIDE;
virtual bool InsertCheckItemAt(int index, int command_id,
const CefString& label) OVERRIDE;
virtual bool InsertRadioItemAt(int index, int command_id,
const CefString& label, int group_id) OVERRIDE;
virtual CefRefPtr<CefMenuModel> InsertSubMenuAt(int index, int command_id,
const CefString& label) OVERRIDE;
virtual bool Remove(int command_id) OVERRIDE;
virtual bool RemoveAt(int index) OVERRIDE;
virtual int GetIndexOf(int command_id) OVERRIDE;
virtual int GetCommandIdAt(int index) OVERRIDE;
virtual bool SetCommandIdAt(int index, int command_id) OVERRIDE;
virtual CefString GetLabel(int command_id) OVERRIDE;
virtual CefString GetLabelAt(int index) OVERRIDE;
virtual bool SetLabel(int command_id, const CefString& label) OVERRIDE;
virtual bool SetLabelAt(int index, const CefString& label) OVERRIDE;
virtual MenuItemType GetType(int command_id) OVERRIDE;
virtual MenuItemType GetTypeAt(int index) OVERRIDE;
virtual int GetGroupId(int command_id) OVERRIDE;
virtual int GetGroupIdAt(int index) OVERRIDE;
virtual bool SetGroupId(int command_id, int group_id) OVERRIDE;
virtual bool SetGroupIdAt(int index, int group_id) OVERRIDE;
virtual CefRefPtr<CefMenuModel> GetSubMenu(int command_id) OVERRIDE;
virtual CefRefPtr<CefMenuModel> GetSubMenuAt(int index) OVERRIDE;
virtual bool IsVisible(int command_id) OVERRIDE;
virtual bool IsVisibleAt(int index) OVERRIDE;
virtual bool SetVisible(int command_id, bool visible) OVERRIDE;
virtual bool SetVisibleAt(int index, bool visible) OVERRIDE;
virtual bool IsEnabled(int command_id) OVERRIDE;
virtual bool IsEnabledAt(int index) OVERRIDE;
virtual bool SetEnabled(int command_id, bool enabled) OVERRIDE;
virtual bool SetEnabledAt(int index, bool enabled) OVERRIDE;
virtual bool IsChecked(int command_id) OVERRIDE;
virtual bool IsCheckedAt(int index) OVERRIDE;
virtual bool SetChecked(int command_id, bool checked) OVERRIDE;
virtual bool SetCheckedAt(int index, bool checked) OVERRIDE;
virtual bool HasAccelerator(int command_id) OVERRIDE;
virtual bool HasAcceleratorAt(int index) OVERRIDE;
virtual bool SetAccelerator(int command_id, int key_code, bool shift_pressed,
bool ctrl_pressed, bool alt_pressed) OVERRIDE;
virtual bool SetAcceleratorAt(int index, int key_code, bool shift_pressed,
bool ctrl_pressed, bool alt_pressed) OVERRIDE;
virtual bool RemoveAccelerator(int command_id) OVERRIDE;
virtual bool RemoveAcceleratorAt(int index) OVERRIDE;
virtual bool GetAccelerator(int command_id, int& key_code,
bool& shift_pressed, bool& ctrl_pressed, bool& alt_pressed) OVERRIDE;
virtual bool GetAcceleratorAt(int index, int& key_code, bool& shift_pressed,
bool& ctrl_pressed, bool& alt_pressed) OVERRIDE;
};
#endif // USING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CTOCPP_MENU_MODEL_CTOCPP_H_

View File

@ -27,12 +27,14 @@
#include "libcef_dll/cpptoc/browser_cpptoc.h"
#include "libcef_dll/cpptoc/browser_host_cpptoc.h"
#include "libcef_dll/cpptoc/callback_cpptoc.h"
#include "libcef_dll/cpptoc/context_menu_params_cpptoc.h"
#include "libcef_dll/cpptoc/cookie_manager_cpptoc.h"
#include "libcef_dll/cpptoc/dictionary_value_cpptoc.h"
#include "libcef_dll/cpptoc/frame_cpptoc.h"
#include "libcef_dll/cpptoc/geolocation_callback_cpptoc.h"
#include "libcef_dll/cpptoc/jsdialog_callback_cpptoc.h"
#include "libcef_dll/cpptoc/list_value_cpptoc.h"
#include "libcef_dll/cpptoc/menu_model_cpptoc.h"
#include "libcef_dll/cpptoc/post_data_cpptoc.h"
#include "libcef_dll/cpptoc/post_data_element_cpptoc.h"
#include "libcef_dll/cpptoc/process_message_cpptoc.h"
@ -46,6 +48,7 @@
#include "libcef_dll/cpptoc/xml_reader_cpptoc.h"
#include "libcef_dll/cpptoc/zip_reader_cpptoc.h"
#include "libcef_dll/ctocpp/app_ctocpp.h"
#include "libcef_dll/ctocpp/context_menu_handler_ctocpp.h"
#include "libcef_dll/ctocpp/cookie_visitor_ctocpp.h"
#include "libcef_dll/ctocpp/display_handler_ctocpp.h"
#include "libcef_dll/ctocpp/geolocation_handler_ctocpp.h"
@ -138,6 +141,8 @@ CEF_EXPORT void cef_shutdown() {
DCHECK_EQ(CefBrowserCppToC::DebugObjCt, 0);
DCHECK_EQ(CefBrowserHostCppToC::DebugObjCt, 0);
DCHECK_EQ(CefCallbackCppToC::DebugObjCt, 0);
DCHECK_EQ(CefContextMenuHandlerCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefContextMenuParamsCppToC::DebugObjCt, 0);
DCHECK_EQ(CefCookieManagerCppToC::DebugObjCt, 0);
DCHECK_EQ(CefCookieVisitorCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefDictionaryValueCppToC::DebugObjCt, 0);
@ -150,6 +155,7 @@ CEF_EXPORT void cef_shutdown() {
DCHECK_EQ(CefLifeSpanHandlerCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefListValueCppToC::DebugObjCt, 0);
DCHECK_EQ(CefLoadHandlerCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefMenuModelCppToC::DebugObjCt, 0);
DCHECK_EQ(CefPostDataCppToC::DebugObjCt, 0);
DCHECK_EQ(CefPostDataElementCppToC::DebugObjCt, 0);
DCHECK_EQ(CefProcessMessageCppToC::DebugObjCt, 0);

View File

@ -24,6 +24,7 @@
#include "include/capi/cef_v8_capi.h"
#include "include/cef_version.h"
#include "libcef_dll/cpptoc/app_cpptoc.h"
#include "libcef_dll/cpptoc/context_menu_handler_cpptoc.h"
#include "libcef_dll/cpptoc/cookie_visitor_cpptoc.h"
#include "libcef_dll/cpptoc/display_handler_cpptoc.h"
#include "libcef_dll/cpptoc/geolocation_handler_cpptoc.h"
@ -47,12 +48,14 @@
#include "libcef_dll/ctocpp/browser_ctocpp.h"
#include "libcef_dll/ctocpp/browser_host_ctocpp.h"
#include "libcef_dll/ctocpp/callback_ctocpp.h"
#include "libcef_dll/ctocpp/context_menu_params_ctocpp.h"
#include "libcef_dll/ctocpp/cookie_manager_ctocpp.h"
#include "libcef_dll/ctocpp/dictionary_value_ctocpp.h"
#include "libcef_dll/ctocpp/frame_ctocpp.h"
#include "libcef_dll/ctocpp/geolocation_callback_ctocpp.h"
#include "libcef_dll/ctocpp/jsdialog_callback_ctocpp.h"
#include "libcef_dll/ctocpp/list_value_ctocpp.h"
#include "libcef_dll/ctocpp/menu_model_ctocpp.h"
#include "libcef_dll/ctocpp/post_data_ctocpp.h"
#include "libcef_dll/ctocpp/post_data_element_ctocpp.h"
#include "libcef_dll/ctocpp/process_message_ctocpp.h"
@ -130,6 +133,8 @@ CEF_GLOBAL void CefShutdown() {
DCHECK_EQ(CefBrowserCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefBrowserHostCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefCallbackCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefContextMenuHandlerCppToC::DebugObjCt, 0);
DCHECK_EQ(CefContextMenuParamsCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefCookieManagerCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefCookieVisitorCppToC::DebugObjCt, 0);
DCHECK_EQ(CefDictionaryValueCToCpp::DebugObjCt, 0);
@ -142,6 +147,7 @@ CEF_GLOBAL void CefShutdown() {
DCHECK_EQ(CefLifeSpanHandlerCppToC::DebugObjCt, 0);
DCHECK_EQ(CefListValueCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefLoadHandlerCppToC::DebugObjCt, 0);
DCHECK_EQ(CefMenuModelCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefPostDataCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefPostDataElementCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefProcessMessageCToCpp::DebugObjCt, 0);

View File

@ -1,13 +1,16 @@
Index: resource_ids
===================================================================
--- resource_ids (revision 119665)
--- resource_ids (revision 131752)
+++ resource_ids (working copy)
@@ -16,6 +16,9 @@
@@ -16,6 +16,12 @@
{
"SRCDIR": "../..",
+ "cef/libcef/browser/resources/cef_resources.grd": {
+ "includes": [25500],
+ "cef/libcef/resources/cef_resources.grd": {
+ "includes": [26000],
+ },
+ "cef/libcef/resources/cef_strings.grd": {
+ "messages": [26500],
+ },
"chrome/browser/browser_resources.grd": {
"includes": [500],

View File

@ -15,6 +15,16 @@
#include "cefclient/string_util.h"
// Custom menu command Ids.
enum client_menu_ids {
CLIENT_ID_SHOW_DEVTOOLS = MENU_ID_USER_FIRST,
CLIENT_ID_TESTMENU_SUBMENU,
CLIENT_ID_TESTMENU_CHECKITEM,
CLIENT_ID_TESTMENU_RADIOITEM1,
CLIENT_ID_TESTMENU_RADIOITEM2,
CLIENT_ID_TESTMENU_RADIOITEM3,
};
ClientHandler::ClientHandler()
: m_MainHwnd(NULL),
m_BrowserId(0),
@ -228,6 +238,42 @@ void ClientHandler::OnRequestGeolocationPermission(
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");
// TODO(cef): Enable once ShowDevTools() is implemented.
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();
return true;
default: // Allow default handling, if any.
return ExecuteTestMenu(command_id);
}
}
void ClientHandler::SetMainHwnd(CefWindowHandle hwnd) {
AutoLock lock_scope(this);
m_MainHwnd = hwnd;
@ -282,3 +328,40 @@ void ClientHandler::CreateRequestDelegates(RequestDelegateSet& delegates) {
// Create the binding test delegates.
binding_test::CreateRequestDelegates(delegates);
}
void ClientHandler::BuildTestMenu(CefRefPtr<CefMenuModel> model) {
if (model->GetCount() > 0)
model->AddSeparator();
// Build the sub menu.
CefRefPtr<CefMenuModel> submenu =
model->AddSubMenu(CLIENT_ID_TESTMENU_SUBMENU, "Context Menu Test");
submenu->AddCheckItem(CLIENT_ID_TESTMENU_CHECKITEM, "Check Item");
submenu->AddRadioItem(CLIENT_ID_TESTMENU_RADIOITEM1, "Radio Item 1", 0);
submenu->AddRadioItem(CLIENT_ID_TESTMENU_RADIOITEM2, "Radio Item 2", 0);
submenu->AddRadioItem(CLIENT_ID_TESTMENU_RADIOITEM3, "Radio Item 3", 0);
// Check the check item.
if (m_TestMenuState.check_item)
submenu->SetChecked(CLIENT_ID_TESTMENU_CHECKITEM, true);
// Check the selected radio item.
submenu->SetChecked(
CLIENT_ID_TESTMENU_RADIOITEM1 + m_TestMenuState.radio_item, true);
}
bool ClientHandler::ExecuteTestMenu(int command_id) {
if (command_id == CLIENT_ID_TESTMENU_CHECKITEM) {
// Toggle the check item.
m_TestMenuState.check_item ^= 1;
return true;
} else if (command_id >= CLIENT_ID_TESTMENU_RADIOITEM1 &&
command_id <= CLIENT_ID_TESTMENU_RADIOITEM3) {
// Store the selected radio item.
m_TestMenuState.radio_item = (command_id - CLIENT_ID_TESTMENU_RADIOITEM1);
return true;
}
// Allow default handling to proceed.
return false;
}

View File

@ -24,7 +24,8 @@ class ClientHandler : public CefClient,
public CefLoadHandler,
public CefRequestHandler,
public CefDisplayHandler,
public CefGeolocationHandler {
public CefGeolocationHandler,
public CefContextMenuHandler {
public:
// Interface for process message delegates. Do not perform work in the
// RenderDelegate constructor.
@ -81,6 +82,9 @@ class ClientHandler : public CefClient,
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)
@ -137,6 +141,17 @@ 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;
void SetMainHwnd(CefWindowHandle hwnd);
CefWindowHandle GetMainHwnd() { return m_MainHwnd; }
void SetEditHwnd(CefWindowHandle hwnd);
@ -177,6 +192,15 @@ class ClientHandler : public CefClient,
// Create all of RequestDelegateSet objects.
static void CreateRequestDelegates(RequestDelegateSet& delegates);
// Test context menu creation.
void BuildTestMenu(CefRefPtr<CefMenuModel> model);
bool ExecuteTestMenu(int command_id);
struct TestMenuState {
TestMenuState() : check_item(true), radio_item(0) {}
bool check_item;
int radio_item;
} m_TestMenuState;
// The child browser window
CefRefPtr<CefBrowser> m_Browser;

117
tools/make_pack_header.py Normal file
View File

@ -0,0 +1,117 @@
#!/usr/bin/env python
# Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file.
"""
A simple utility function to merge pack resource files into a single resource file.
"""
from date_util import *
from file_util import *
import os
import re
import string
import sys
def MakeFileSegment(input):
result = """
// ---------------------------------------------------------------------------
// From $FILE$:
"""
filename = os.path.split(input)[1]
result = result.replace('$FILE$', filename)
contents = read_file(input)
# identify the defines in the file
p = re.compile('#define\s([A-Za-z0-9_]{1,})\s([0-9]{1,})')
list = p.findall(contents)
for name, id in list:
result += "\n#define %s %s" % (name, id)
return result
def MakeFile(output, input):
# header string
result = \
"""// Copyright (c) $YEAR$ Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file is generated by the make_pack_header.py tool.
//
#ifndef $GUARD$
#define $GUARD$
#pragma once"""
# sort the input files by name
input = sorted(input, key=lambda path: os.path.split(path)[1])
# generate the file segments
for file in input:
result += MakeFileSegment(file)
# footer string
result += \
"""
#endif // $GUARD$
"""
# add the copyright year
result = result.replace('$YEAR$', get_year())
# add the guard string
filename = os.path.split(output)[1]
guard = 'CEF_INCLUDE_'+string.upper(filename.replace('.', '_'))+'_'
result = result.replace('$GUARD$', guard)
old_contents = read_file(output)
if (result != old_contents):
write_file(output, result)
sys.stdout.write('File '+output+' updated.\n')
else:
sys.stdout.write('File '+output+' is already up to date.\n')
def main(argv):
if len(argv) < 3:
print ("Usage:\n %s <output_filename> <input_file1> [input_file2] ... " %
argv[0])
sys.exit(-1)
MakeFile(argv[1], argv[2:])
if '__main__' == __name__:
main(sys.argv)

View File

@ -73,6 +73,10 @@ def calc_inputs(locale):
inputs.append(os.path.join(SHARE_INT_DIR, 'ui', 'app_locale_settings',
'app_locale_settings_%s.pak' % locale))
#e.g. '<(SHARED_INTERMEDIATE_DIR)/cef/cef_strings_da.pak'
inputs.append(os.path.join(SHARE_INT_DIR, 'cef',
'cef_strings_%s.pak' % locale))
return inputs