mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-13 02:20:45 +01:00
Linux: Add new CefPrintHandler and CefPrintSettings classes to support printing and a GTK implementation in cefclient (issue #1258).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1762 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
6f63f5d4f8
commit
8313963a27
5
cef.gyp
5
cef.gyp
@ -409,6 +409,7 @@
|
|||||||
'tests/unittests/message_router_unittest.cc',
|
'tests/unittests/message_router_unittest.cc',
|
||||||
'tests/unittests/navigation_unittest.cc',
|
'tests/unittests/navigation_unittest.cc',
|
||||||
'tests/unittests/os_rendering_unittest.cc',
|
'tests/unittests/os_rendering_unittest.cc',
|
||||||
|
'tests/unittests/print_unittest.cc',
|
||||||
'tests/unittests/process_message_unittest.cc',
|
'tests/unittests/process_message_unittest.cc',
|
||||||
'tests/unittests/request_context_unittest.cc',
|
'tests/unittests/request_context_unittest.cc',
|
||||||
'tests/unittests/request_handler_unittest.cc',
|
'tests/unittests/request_handler_unittest.cc',
|
||||||
@ -936,6 +937,8 @@
|
|||||||
'libcef/browser/origin_whitelist_impl.cc',
|
'libcef/browser/origin_whitelist_impl.cc',
|
||||||
'libcef/browser/origin_whitelist_impl.h',
|
'libcef/browser/origin_whitelist_impl.h',
|
||||||
'libcef/browser/path_util_impl.cc',
|
'libcef/browser/path_util_impl.cc',
|
||||||
|
'libcef/browser/print_settings_impl.cc',
|
||||||
|
'libcef/browser/print_settings_impl.h',
|
||||||
'libcef/browser/printing/printing_message_filter.cc',
|
'libcef/browser/printing/printing_message_filter.cc',
|
||||||
'libcef/browser/printing/printing_message_filter.h',
|
'libcef/browser/printing/printing_message_filter.h',
|
||||||
'libcef/browser/printing/print_view_manager.cc',
|
'libcef/browser/printing/print_view_manager.cc',
|
||||||
@ -1171,6 +1174,8 @@
|
|||||||
'libcef/browser/javascript_dialog_linux.cc',
|
'libcef/browser/javascript_dialog_linux.cc',
|
||||||
'libcef/browser/menu_creator_runner_linux.cc',
|
'libcef/browser/menu_creator_runner_linux.cc',
|
||||||
'libcef/browser/menu_creator_runner_linux.h',
|
'libcef/browser/menu_creator_runner_linux.h',
|
||||||
|
'libcef/browser/printing/print_dialog_linux.cc',
|
||||||
|
'libcef/browser/printing/print_dialog_linux.h',
|
||||||
'libcef/browser/render_widget_host_view_osr_linux.cc',
|
'libcef/browser/render_widget_host_view_osr_linux.cc',
|
||||||
'libcef/browser/window_x11.cc',
|
'libcef/browser/window_x11.cc',
|
||||||
'libcef/browser/window_x11.h',
|
'libcef/browser/window_x11.h',
|
||||||
|
@ -39,6 +39,8 @@
|
|||||||
'include/cef_menu_model.h',
|
'include/cef_menu_model.h',
|
||||||
'include/cef_origin_whitelist.h',
|
'include/cef_origin_whitelist.h',
|
||||||
'include/cef_path_util.h',
|
'include/cef_path_util.h',
|
||||||
|
'include/cef_print_handler.h',
|
||||||
|
'include/cef_print_settings.h',
|
||||||
'include/cef_process_message.h',
|
'include/cef_process_message.h',
|
||||||
'include/cef_process_util.h',
|
'include/cef_process_util.h',
|
||||||
'include/cef_render_handler.h',
|
'include/cef_render_handler.h',
|
||||||
@ -91,6 +93,8 @@
|
|||||||
'include/capi/cef_menu_model_capi.h',
|
'include/capi/cef_menu_model_capi.h',
|
||||||
'include/capi/cef_origin_whitelist_capi.h',
|
'include/capi/cef_origin_whitelist_capi.h',
|
||||||
'include/capi/cef_path_util_capi.h',
|
'include/capi/cef_path_util_capi.h',
|
||||||
|
'include/capi/cef_print_handler_capi.h',
|
||||||
|
'include/capi/cef_print_settings_capi.h',
|
||||||
'include/capi/cef_process_message_capi.h',
|
'include/capi/cef_process_message_capi.h',
|
||||||
'include/capi/cef_process_util_capi.h',
|
'include/capi/cef_process_util_capi.h',
|
||||||
'include/capi/cef_render_handler_capi.h',
|
'include/capi/cef_render_handler_capi.h',
|
||||||
@ -206,6 +210,14 @@
|
|||||||
'libcef_dll/cpptoc/post_data_cpptoc.h',
|
'libcef_dll/cpptoc/post_data_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/post_data_element_cpptoc.cc',
|
'libcef_dll/cpptoc/post_data_element_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/post_data_element_cpptoc.h',
|
'libcef_dll/cpptoc/post_data_element_cpptoc.h',
|
||||||
|
'libcef_dll/cpptoc/print_dialog_callback_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/print_dialog_callback_cpptoc.h',
|
||||||
|
'libcef_dll/ctocpp/print_handler_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/print_handler_ctocpp.h',
|
||||||
|
'libcef_dll/cpptoc/print_job_callback_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/print_job_callback_cpptoc.h',
|
||||||
|
'libcef_dll/cpptoc/print_settings_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/print_settings_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/process_message_cpptoc.cc',
|
'libcef_dll/cpptoc/process_message_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/process_message_cpptoc.h',
|
'libcef_dll/cpptoc/process_message_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/quota_callback_cpptoc.cc',
|
'libcef_dll/cpptoc/quota_callback_cpptoc.cc',
|
||||||
@ -368,6 +380,14 @@
|
|||||||
'libcef_dll/ctocpp/post_data_ctocpp.h',
|
'libcef_dll/ctocpp/post_data_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/post_data_element_ctocpp.cc',
|
'libcef_dll/ctocpp/post_data_element_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/post_data_element_ctocpp.h',
|
'libcef_dll/ctocpp/post_data_element_ctocpp.h',
|
||||||
|
'libcef_dll/ctocpp/print_dialog_callback_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/print_dialog_callback_ctocpp.h',
|
||||||
|
'libcef_dll/cpptoc/print_handler_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/print_handler_cpptoc.h',
|
||||||
|
'libcef_dll/ctocpp/print_job_callback_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/print_job_callback_ctocpp.h',
|
||||||
|
'libcef_dll/ctocpp/print_settings_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/print_settings_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/process_message_ctocpp.cc',
|
'libcef_dll/ctocpp/process_message_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/process_message_ctocpp.h',
|
'libcef_dll/ctocpp/process_message_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/quota_callback_ctocpp.cc',
|
'libcef_dll/ctocpp/quota_callback_ctocpp.cc',
|
||||||
|
@ -206,6 +206,8 @@
|
|||||||
'tests/cefclient/cefclient_osr_widget_gtk.h',
|
'tests/cefclient/cefclient_osr_widget_gtk.h',
|
||||||
'tests/cefclient/cefclient_osr_widget_gtk.cpp',
|
'tests/cefclient/cefclient_osr_widget_gtk.cpp',
|
||||||
'tests/cefclient/client_handler_gtk.cpp',
|
'tests/cefclient/client_handler_gtk.cpp',
|
||||||
|
'tests/cefclient/print_handler_gtk.cpp',
|
||||||
|
'tests/cefclient/print_handler_gtk.h',
|
||||||
'tests/cefclient/resource_util_linux.cpp',
|
'tests/cefclient/resource_util_linux.cpp',
|
||||||
'tests/cefclient/resource_util_posix.cpp',
|
'tests/cefclient/resource_util_posix.cpp',
|
||||||
'tests/cefclient/window_test_gtk.cpp',
|
'tests/cefclient/window_test_gtk.cpp',
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
|
|
||||||
#include "include/capi/cef_base_capi.h"
|
#include "include/capi/cef_base_capi.h"
|
||||||
#include "include/capi/cef_command_line_capi.h"
|
#include "include/capi/cef_command_line_capi.h"
|
||||||
|
#include "include/capi/cef_print_handler_capi.h"
|
||||||
#include "include/capi/cef_values_capi.h"
|
#include "include/capi/cef_values_capi.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -86,6 +87,13 @@ typedef struct _cef_browser_process_handler_t {
|
|||||||
void (CEF_CALLBACK *on_render_process_thread_created)(
|
void (CEF_CALLBACK *on_render_process_thread_created)(
|
||||||
struct _cef_browser_process_handler_t* self,
|
struct _cef_browser_process_handler_t* self,
|
||||||
struct _cef_list_value_t* extra_info);
|
struct _cef_list_value_t* extra_info);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Return the handler for printing on Linux. If a print handler is not
|
||||||
|
// provided then printing will not be supported on the Linux platform.
|
||||||
|
///
|
||||||
|
struct _cef_print_handler_t* (CEF_CALLBACK *get_print_handler)(
|
||||||
|
struct _cef_browser_process_handler_t* self);
|
||||||
} cef_browser_process_handler_t;
|
} cef_browser_process_handler_t;
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,9 +114,10 @@ typedef struct _cef_life_span_handler_t {
|
|||||||
// opportunity to process the 'onbeforeunload' event and optionally cancel the
|
// opportunity to process the 'onbeforeunload' event and optionally cancel the
|
||||||
// close before do_close() is called.
|
// close before do_close() is called.
|
||||||
//
|
//
|
||||||
// The cef_life_span_handler_t::OnBeforeclose() function will be called
|
// The cef_life_span_handler_t::on_before_close() function will be called
|
||||||
// immediately before the browser object is destroyed. The application should
|
// immediately before the browser object is destroyed. The application should
|
||||||
// only exit after OnBeforeclose() has been called for all existing browsers.
|
// only exit after on_before_close() has been called for all existing
|
||||||
|
// browsers.
|
||||||
//
|
//
|
||||||
// If the browser represents a modal window and a custom modal loop
|
// If the browser represents a modal window and a custom modal loop
|
||||||
// implementation was provided in cef_life_span_handler_t::run_modal() this
|
// implementation was provided in cef_life_span_handler_t::run_modal() this
|
||||||
@ -141,7 +142,7 @@ typedef struct _cef_life_span_handler_t {
|
|||||||
// receives the OS close notification and
|
// receives the OS close notification and
|
||||||
// allows the window to close based on the flag from #6B.
|
// allows the window to close based on the flag from #6B.
|
||||||
// 9. Browser OS window is destroyed. 10. Application's
|
// 9. Browser OS window is destroyed. 10. Application's
|
||||||
// cef_life_span_handler_t::OnBeforeclose() handler is called and
|
// cef_life_span_handler_t::on_before_close() handler is called and
|
||||||
// the browser object is destroyed.
|
// the browser object is destroyed.
|
||||||
// 11. Application exits by calling cef_quit_message_loop() if no other
|
// 11. Application exits by calling cef_quit_message_loop() if no other
|
||||||
// browsers
|
// browsers
|
||||||
|
134
include/capi/cef_print_handler_capi.h
Normal file
134
include/capi/cef_print_handler_capi.h
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
// Copyright (c) 2014 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_PRINT_HANDLER_CAPI_H_
|
||||||
|
#define CEF_INCLUDE_CAPI_CEF_PRINT_HANDLER_CAPI_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "include/capi/cef_base_capi.h"
|
||||||
|
#include "include/capi/cef_browser_capi.h"
|
||||||
|
#include "include/capi/cef_print_settings_capi.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// Callback structure for asynchronous continuation of print dialog requests.
|
||||||
|
///
|
||||||
|
typedef struct _cef_print_dialog_callback_t {
|
||||||
|
///
|
||||||
|
// Base structure.
|
||||||
|
///
|
||||||
|
cef_base_t base;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Continue printing with the specified |settings|.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *cont)(struct _cef_print_dialog_callback_t* self,
|
||||||
|
struct _cef_print_settings_t* settings);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Cancel the printing.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *cancel)(struct _cef_print_dialog_callback_t* self);
|
||||||
|
} cef_print_dialog_callback_t;
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// Callback structure for asynchronous continuation of print job requests.
|
||||||
|
///
|
||||||
|
typedef struct _cef_print_job_callback_t {
|
||||||
|
///
|
||||||
|
// Base structure.
|
||||||
|
///
|
||||||
|
cef_base_t base;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Indicate completion of the print job.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *cont)(struct _cef_print_job_callback_t* self);
|
||||||
|
} cef_print_job_callback_t;
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// Implement this structure to handle printing on Linux. The functions of this
|
||||||
|
// structure will be called on the browser process UI thread.
|
||||||
|
///
|
||||||
|
typedef struct _cef_print_handler_t {
|
||||||
|
///
|
||||||
|
// Base structure.
|
||||||
|
///
|
||||||
|
cef_base_t base;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Synchronize |settings| with client state. If |get_defaults| is true (1)
|
||||||
|
// then populate |settings| with the default print settings. Do not keep a
|
||||||
|
// reference to |settings| outside of this callback.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *on_print_settings)(struct _cef_print_handler_t* self,
|
||||||
|
struct _cef_print_settings_t* settings, int get_defaults);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Show the print dialog. Execute |callback| once the dialog is dismissed.
|
||||||
|
// Return true (1) if the dialog will be displayed or false (0) to cancel the
|
||||||
|
// printing immediately.
|
||||||
|
///
|
||||||
|
int (CEF_CALLBACK *on_print_dialog)(struct _cef_print_handler_t* self,
|
||||||
|
int has_selection, struct _cef_print_dialog_callback_t* callback);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Send the print job to the printer. Execute |callback| once the job is
|
||||||
|
// completed. Return true (1) if the job will proceed or false (0) to cancel
|
||||||
|
// the job immediately.
|
||||||
|
///
|
||||||
|
int (CEF_CALLBACK *on_print_job)(struct _cef_print_handler_t* self,
|
||||||
|
const cef_string_t* document_name, const cef_string_t* pdf_file_path,
|
||||||
|
struct _cef_print_job_callback_t* callback);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Reset client state related to printing.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *on_print_reset)(struct _cef_print_handler_t* self);
|
||||||
|
} cef_print_handler_t;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_CAPI_CEF_PRINT_HANDLER_CAPI_H_
|
207
include/capi/cef_print_settings_capi.h
Normal file
207
include/capi/cef_print_settings_capi.h
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
// Copyright (c) 2014 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_PRINT_SETTINGS_CAPI_H_
|
||||||
|
#define CEF_INCLUDE_CAPI_CEF_PRINT_SETTINGS_CAPI_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "include/capi/cef_base_capi.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// Structure representing print settings.
|
||||||
|
///
|
||||||
|
typedef struct _cef_print_settings_t {
|
||||||
|
///
|
||||||
|
// Base structure.
|
||||||
|
///
|
||||||
|
cef_base_t base;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns true (1) if this object is valid. Do not call any other functions
|
||||||
|
// if this function returns false (0).
|
||||||
|
///
|
||||||
|
int (CEF_CALLBACK *is_valid)(struct _cef_print_settings_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns true (1) if the values of this object are read-only. Some APIs may
|
||||||
|
// expose read-only objects.
|
||||||
|
///
|
||||||
|
int (CEF_CALLBACK *is_read_only)(struct _cef_print_settings_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns a writable copy of this object.
|
||||||
|
///
|
||||||
|
struct _cef_print_settings_t* (CEF_CALLBACK *copy)(
|
||||||
|
struct _cef_print_settings_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Set the page orientation.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *set_orientation)(struct _cef_print_settings_t* self,
|
||||||
|
int landscape);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns true (1) if the orientation is landscape.
|
||||||
|
///
|
||||||
|
int (CEF_CALLBACK *is_landscape)(struct _cef_print_settings_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Set the printer printable area in device units. Some platforms already
|
||||||
|
// provide flipped area. Set |landscape_needs_flip| to false (0) on those
|
||||||
|
// platforms to avoid double flipping.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *set_printer_printable_area)(
|
||||||
|
struct _cef_print_settings_t* self,
|
||||||
|
const cef_size_t* physical_size_device_units,
|
||||||
|
const cef_rect_t* printable_area_device_units,
|
||||||
|
int landscape_needs_flip);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Set the device name.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *set_device_name)(struct _cef_print_settings_t* self,
|
||||||
|
const cef_string_t* name);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Get the device name.
|
||||||
|
///
|
||||||
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
|
cef_string_userfree_t (CEF_CALLBACK *get_device_name)(
|
||||||
|
struct _cef_print_settings_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Set the DPI (dots per inch).
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *set_dpi)(struct _cef_print_settings_t* self, int dpi);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Get the DPI (dots per inch).
|
||||||
|
///
|
||||||
|
int (CEF_CALLBACK *get_dpi)(struct _cef_print_settings_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Set the page ranges.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *set_page_ranges)(struct _cef_print_settings_t* self,
|
||||||
|
size_t rangesCount, cef_page_range_t const* ranges);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the number of page ranges that currently exist.
|
||||||
|
///
|
||||||
|
size_t (CEF_CALLBACK *get_page_ranges_count)(
|
||||||
|
struct _cef_print_settings_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Retrieve the page ranges.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *get_page_ranges)(struct _cef_print_settings_t* self,
|
||||||
|
size_t* rangesCount, cef_page_range_t* ranges);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Set whether only the selection will be printed.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *set_selection_only)(struct _cef_print_settings_t* self,
|
||||||
|
int selection_only);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns true (1) if only the selection will be printed.
|
||||||
|
///
|
||||||
|
int (CEF_CALLBACK *is_selection_only)(struct _cef_print_settings_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Set whether pages will be collated.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *set_collate)(struct _cef_print_settings_t* self,
|
||||||
|
int collate);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns true (1) if pages will be collated.
|
||||||
|
///
|
||||||
|
int (CEF_CALLBACK *will_collate)(struct _cef_print_settings_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Set the color model.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *set_color_model)(struct _cef_print_settings_t* self,
|
||||||
|
cef_color_model_t model);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Get the color model.
|
||||||
|
///
|
||||||
|
cef_color_model_t (CEF_CALLBACK *get_color_model)(
|
||||||
|
struct _cef_print_settings_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Set the number of copies.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *set_copies)(struct _cef_print_settings_t* self,
|
||||||
|
int copies);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Get the number of copies.
|
||||||
|
///
|
||||||
|
int (CEF_CALLBACK *get_copies)(struct _cef_print_settings_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Set the duplex mode.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *set_duplex_mode)(struct _cef_print_settings_t* self,
|
||||||
|
cef_duplex_mode_t mode);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Get the duplex mode.
|
||||||
|
///
|
||||||
|
cef_duplex_mode_t (CEF_CALLBACK *get_duplex_mode)(
|
||||||
|
struct _cef_print_settings_t* self);
|
||||||
|
} cef_print_settings_t;
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// Create a new cef_print_settings_t object.
|
||||||
|
///
|
||||||
|
CEF_EXPORT cef_print_settings_t* cef_print_settings_create();
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_CAPI_CEF_PRINT_SETTINGS_CAPI_H_
|
@ -40,6 +40,7 @@
|
|||||||
|
|
||||||
#include "include/cef_base.h"
|
#include "include/cef_base.h"
|
||||||
#include "include/cef_command_line.h"
|
#include "include/cef_command_line.h"
|
||||||
|
#include "include/cef_print_handler.h"
|
||||||
#include "include/cef_values.h"
|
#include "include/cef_values.h"
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -77,6 +78,15 @@ class CefBrowserProcessHandler : public virtual CefBase {
|
|||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual void OnRenderProcessThreadCreated(
|
virtual void OnRenderProcessThreadCreated(
|
||||||
CefRefPtr<CefListValue> extra_info) {}
|
CefRefPtr<CefListValue> extra_info) {}
|
||||||
|
|
||||||
|
///
|
||||||
|
// Return the handler for printing on Linux. If a print handler is not
|
||||||
|
// provided then printing will not be supported on the Linux platform.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual CefRefPtr<CefPrintHandler> GetPrintHandler() {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_CEF_BROWSER_PROCESS_HANDLER_H_
|
#endif // CEF_INCLUDE_CEF_BROWSER_PROCESS_HANDLER_H_
|
||||||
|
120
include/cef_print_handler.h
Normal file
120
include/cef_print_handler.h
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
// Copyright (c) 2014 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_PRINT_HANDLER_H_
|
||||||
|
#define CEF_INCLUDE_CEF_PRINT_HANDLER_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "include/cef_base.h"
|
||||||
|
#include "include/cef_browser.h"
|
||||||
|
#include "include/cef_print_settings.h"
|
||||||
|
|
||||||
|
///
|
||||||
|
// Callback interface for asynchronous continuation of print dialog requests.
|
||||||
|
///
|
||||||
|
/*--cef(source=library)--*/
|
||||||
|
class CefPrintDialogCallback : public virtual CefBase {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
// Continue printing with the specified |settings|.
|
||||||
|
///
|
||||||
|
/*--cef(capi_name=cont)--*/
|
||||||
|
virtual void Continue(CefRefPtr<CefPrintSettings> settings) =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Cancel the printing.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual void Cancel() =0;
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
// Callback interface for asynchronous continuation of print job requests.
|
||||||
|
///
|
||||||
|
/*--cef(source=library)--*/
|
||||||
|
class CefPrintJobCallback : public virtual CefBase {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
// Indicate completion of the print job.
|
||||||
|
///
|
||||||
|
/*--cef(capi_name=cont)--*/
|
||||||
|
virtual void Continue() =0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// Implement this interface to handle printing on Linux. The methods of this
|
||||||
|
// class will be called on the browser process UI thread.
|
||||||
|
///
|
||||||
|
/*--cef(source=client)--*/
|
||||||
|
class CefPrintHandler : public virtual CefBase {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
// Synchronize |settings| with client state. If |get_defaults| is true then
|
||||||
|
// populate |settings| with the default print settings. Do not keep a
|
||||||
|
// reference to |settings| outside of this callback.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual void OnPrintSettings(CefRefPtr<CefPrintSettings> settings,
|
||||||
|
bool get_defaults) =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Show the print dialog. Execute |callback| once the dialog is dismissed.
|
||||||
|
// Return true if the dialog will be displayed or false to cancel the
|
||||||
|
// printing immediately.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual bool OnPrintDialog(bool has_selection,
|
||||||
|
CefRefPtr<CefPrintDialogCallback> callback) =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Send the print job to the printer. Execute |callback| once the job is
|
||||||
|
// completed. Return true if the job will proceed or false to cancel the job
|
||||||
|
// immediately.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual bool OnPrintJob(const CefString& document_name,
|
||||||
|
const CefString& pdf_file_path,
|
||||||
|
CefRefPtr<CefPrintJobCallback> callback) =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Reset client state related to printing.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual void OnPrintReset() =0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_CEF_PRINT_HANDLER_H_
|
208
include/cef_print_settings.h
Normal file
208
include/cef_print_settings.h
Normal file
@ -0,0 +1,208 @@
|
|||||||
|
// Copyright (c) 2014 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_PRINT_SETTINGS_H_
|
||||||
|
#define CEF_INCLUDE_CEF_PRINT_SETTINGS_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "include/cef_base.h"
|
||||||
|
|
||||||
|
///
|
||||||
|
// Class representing print settings.
|
||||||
|
///
|
||||||
|
/*--cef(source=library)--*/
|
||||||
|
class CefPrintSettings : public virtual CefBase {
|
||||||
|
public:
|
||||||
|
typedef cef_color_model_t ColorModel;
|
||||||
|
typedef cef_duplex_mode_t DuplexMode;
|
||||||
|
typedef std::vector<CefPageRange> PageRangeList;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Create a new CefPrintSettings object.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
static CefRefPtr<CefPrintSettings> Create();
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns true if this object is valid. Do not call any other methods if this
|
||||||
|
// function returns false.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual bool IsValid() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns true if the values of this object are read-only. Some APIs may
|
||||||
|
// expose read-only objects.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual bool IsReadOnly() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns a writable copy of this object.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual CefRefPtr<CefPrintSettings> Copy() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Set the page orientation.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual void SetOrientation(bool landscape) =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns true if the orientation is landscape.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual bool IsLandscape() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Set the printer printable area in device units.
|
||||||
|
// Some platforms already provide flipped area. Set |landscape_needs_flip|
|
||||||
|
// to false on those platforms to avoid double flipping.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual void SetPrinterPrintableArea(
|
||||||
|
const CefSize& physical_size_device_units,
|
||||||
|
const CefRect& printable_area_device_units,
|
||||||
|
bool landscape_needs_flip) =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Set the device name.
|
||||||
|
///
|
||||||
|
/*--cef(optional_param=name)--*/
|
||||||
|
virtual void SetDeviceName(const CefString& name) =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Get the device name.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual CefString GetDeviceName() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Set the DPI (dots per inch).
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual void SetDPI(int dpi) =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Get the DPI (dots per inch).
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual int GetDPI() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Set the page ranges.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual void SetPageRanges(const PageRangeList& ranges) =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the number of page ranges that currently exist.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual size_t GetPageRangesCount() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Retrieve the page ranges.
|
||||||
|
///
|
||||||
|
/*--cef(count_func=ranges:GetPageRangesCount)--*/
|
||||||
|
virtual void GetPageRanges(PageRangeList& ranges) =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Set whether only the selection will be printed.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual void SetSelectionOnly(bool selection_only) =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns true if only the selection will be printed.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual bool IsSelectionOnly() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Set whether pages will be collated.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual void SetCollate(bool collate) =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns true if pages will be collated.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual bool WillCollate() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Set the color model.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual void SetColorModel(ColorModel model) =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Get the color model.
|
||||||
|
///
|
||||||
|
/*--cef(default_retval=COLOR_MODEL_UNKNOWN)--*/
|
||||||
|
virtual ColorModel GetColorModel() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Set the number of copies.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual void SetCopies(int copies) =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Get the number of copies.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual int GetCopies() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Set the duplex mode.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual void SetDuplexMode(DuplexMode mode) =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Get the duplex mode.
|
||||||
|
///
|
||||||
|
/*--cef(default_retval=DUPLEX_MODE_UNKNOWN)--*/
|
||||||
|
virtual DuplexMode GetDuplexMode() =0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_CEF_PRINT_SETTINGS_H_
|
||||||
|
|
@ -1107,6 +1107,14 @@ typedef struct _cef_rect_t {
|
|||||||
int height;
|
int height;
|
||||||
} cef_rect_t;
|
} cef_rect_t;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Structure representing a size.
|
||||||
|
///
|
||||||
|
typedef struct _cef_size_t {
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
} cef_size_t;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Existing process IDs.
|
// Existing process IDs.
|
||||||
///
|
///
|
||||||
@ -1745,6 +1753,51 @@ typedef struct _cef_geoposition_t {
|
|||||||
cef_string_t error_message;
|
cef_string_t error_message;
|
||||||
} cef_geoposition_t;
|
} cef_geoposition_t;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Print job color mode values.
|
||||||
|
///
|
||||||
|
typedef enum {
|
||||||
|
COLOR_MODEL_UNKNOWN,
|
||||||
|
COLOR_MODEL_GRAY,
|
||||||
|
COLOR_MODEL_COLOR,
|
||||||
|
COLOR_MODEL_CMYK,
|
||||||
|
COLOR_MODEL_CMY,
|
||||||
|
COLOR_MODEL_KCMY,
|
||||||
|
COLOR_MODEL_CMY_K, // CMY_K represents CMY+K.
|
||||||
|
COLOR_MODEL_BLACK,
|
||||||
|
COLOR_MODEL_GRAYSCALE,
|
||||||
|
COLOR_MODEL_RGB,
|
||||||
|
COLOR_MODEL_RGB16,
|
||||||
|
COLOR_MODEL_RGBA,
|
||||||
|
COLOR_MODEL_COLORMODE_COLOR, // Used in samsung printer ppds.
|
||||||
|
COLOR_MODEL_COLORMODE_MONOCHROME, // Used in samsung printer ppds.
|
||||||
|
COLOR_MODEL_HP_COLOR_COLOR, // Used in HP color printer ppds.
|
||||||
|
COLOR_MODEL_HP_COLOR_BLACK, // Used in HP color printer ppds.
|
||||||
|
COLOR_MODEL_PRINTOUTMODE_NORMAL, // Used in foomatic ppds.
|
||||||
|
COLOR_MODEL_PRINTOUTMODE_NORMAL_GRAY, // Used in foomatic ppds.
|
||||||
|
COLOR_MODEL_PROCESSCOLORMODEL_CMYK, // Used in canon printer ppds.
|
||||||
|
COLOR_MODEL_PROCESSCOLORMODEL_GREYSCALE, // Used in canon printer ppds.
|
||||||
|
COLOR_MODEL_PROCESSCOLORMODEL_RGB, // Used in canon printer ppds
|
||||||
|
} cef_color_model_t;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Print job duplex mode values.
|
||||||
|
///
|
||||||
|
typedef enum {
|
||||||
|
DUPLEX_MODE_UNKNOWN = -1,
|
||||||
|
DUPLEX_MODE_SIMPLEX,
|
||||||
|
DUPLEX_MODE_LONG_EDGE,
|
||||||
|
DUPLEX_MODE_SHORT_EDGE,
|
||||||
|
} cef_duplex_mode_t;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Structure representing a print job page range.
|
||||||
|
///
|
||||||
|
typedef struct _cef_page_range_t {
|
||||||
|
int from;
|
||||||
|
int to;
|
||||||
|
} cef_page_range_t;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -174,6 +174,48 @@ inline bool operator!=(const CefRect& a, const CefRect& b) {
|
|||||||
return !(a == b);
|
return !(a == b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct CefSizeTraits {
|
||||||
|
typedef cef_size_t struct_type;
|
||||||
|
|
||||||
|
static inline void init(struct_type* s) {}
|
||||||
|
static inline void clear(struct_type* s) {}
|
||||||
|
|
||||||
|
static inline void set(const struct_type* src, struct_type* target,
|
||||||
|
bool copy) {
|
||||||
|
*target = *src;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
// Class representing a size.
|
||||||
|
///
|
||||||
|
class CefSize : public CefStructBase<CefSizeTraits> {
|
||||||
|
public:
|
||||||
|
typedef CefStructBase<CefSizeTraits> parent;
|
||||||
|
|
||||||
|
CefSize() : parent() {}
|
||||||
|
CefSize(const cef_size_t& r) : parent(r) {} // NOLINT(runtime/explicit)
|
||||||
|
CefSize(const CefSize& r) : parent(r) {} // NOLINT(runtime/explicit)
|
||||||
|
CefSize(int width, int height) : parent() {
|
||||||
|
Set(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsEmpty() const { return width <= 0 || height <= 0; }
|
||||||
|
void Set(int width, int height) {
|
||||||
|
this->width = width, this->height = height;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline bool operator==(const CefSize& a, const CefSize& b) {
|
||||||
|
return a.width == b.width && a.height == b.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator!=(const CefSize& a, const CefSize& b) {
|
||||||
|
return !(a == b);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct CefScreenInfoTraits {
|
struct CefScreenInfoTraits {
|
||||||
typedef cef_screen_info_t struct_type;
|
typedef cef_screen_info_t struct_type;
|
||||||
|
|
||||||
@ -228,6 +270,7 @@ class CefScreenInfo : public CefStructBase<CefScreenInfoTraits> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct CefKeyEventTraits {
|
struct CefKeyEventTraits {
|
||||||
typedef cef_key_event_t struct_type;
|
typedef cef_key_event_t struct_type;
|
||||||
|
|
||||||
@ -253,6 +296,7 @@ struct CefKeyEventTraits {
|
|||||||
///
|
///
|
||||||
typedef CefStructBase<CefKeyEventTraits> CefKeyEvent;
|
typedef CefStructBase<CefKeyEventTraits> CefKeyEvent;
|
||||||
|
|
||||||
|
|
||||||
struct CefMouseEventTraits {
|
struct CefMouseEventTraits {
|
||||||
typedef cef_mouse_event_t struct_type;
|
typedef cef_mouse_event_t struct_type;
|
||||||
|
|
||||||
@ -273,6 +317,7 @@ struct CefMouseEventTraits {
|
|||||||
///
|
///
|
||||||
typedef CefStructBase<CefMouseEventTraits> CefMouseEvent;
|
typedef CefStructBase<CefMouseEventTraits> CefMouseEvent;
|
||||||
|
|
||||||
|
|
||||||
struct CefPopupFeaturesTraits {
|
struct CefPopupFeaturesTraits {
|
||||||
typedef cef_popup_features_t struct_type;
|
typedef cef_popup_features_t struct_type;
|
||||||
|
|
||||||
@ -627,4 +672,47 @@ struct CefGeopositionTraits {
|
|||||||
///
|
///
|
||||||
typedef CefStructBase<CefGeopositionTraits> CefGeoposition;
|
typedef CefStructBase<CefGeopositionTraits> CefGeoposition;
|
||||||
|
|
||||||
|
|
||||||
|
struct CefPageRangeTraits {
|
||||||
|
typedef cef_page_range_t struct_type;
|
||||||
|
|
||||||
|
static inline void init(struct_type* s) {}
|
||||||
|
static inline void clear(struct_type* s) {}
|
||||||
|
|
||||||
|
static inline void set(const struct_type* src, struct_type* target,
|
||||||
|
bool copy) {
|
||||||
|
*target = *src;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
// Class representing a print job page range.
|
||||||
|
///
|
||||||
|
class CefPageRange : public CefStructBase<CefPageRangeTraits> {
|
||||||
|
public:
|
||||||
|
typedef CefStructBase<CefPageRangeTraits> parent;
|
||||||
|
|
||||||
|
CefPageRange() : parent() {}
|
||||||
|
CefPageRange(const cef_page_range_t& r) // NOLINT(runtime/explicit)
|
||||||
|
: parent(r) {}
|
||||||
|
CefPageRange(const CefPageRange& r) // NOLINT(runtime/explicit)
|
||||||
|
: parent(r) {}
|
||||||
|
CefPageRange(int from, int to) : parent() {
|
||||||
|
Set(from, to);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Set(int from, int to) {
|
||||||
|
this->from = from, this->to = to;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline bool operator==(const CefPageRange& a, const CefPageRange& b) {
|
||||||
|
return a.from == b.from && a.to == b.to;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator!=(const CefPageRange& a, const CefPageRange& b) {
|
||||||
|
return !(a == b);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_
|
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_
|
||||||
|
@ -41,6 +41,10 @@
|
|||||||
#include "ui/base/ime/input_method_initializer.h"
|
#include "ui/base/ime/input_method_initializer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(OS_LINUX)
|
||||||
|
#include "libcef/browser/printing/print_dialog_linux.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
CefBrowserMainParts::CefBrowserMainParts(
|
CefBrowserMainParts::CefBrowserMainParts(
|
||||||
const content::MainFunctionParams& parameters)
|
const content::MainFunctionParams& parameters)
|
||||||
: BrowserMainParts(),
|
: BrowserMainParts(),
|
||||||
@ -85,6 +89,11 @@ void CefBrowserMainParts::PostMainMessageLoopStart() {
|
|||||||
// CEF's internal handling of "chrome://tracing".
|
// CEF's internal handling of "chrome://tracing".
|
||||||
content::WebUIControllerFactory::UnregisterFactoryForTesting(
|
content::WebUIControllerFactory::UnregisterFactoryForTesting(
|
||||||
content::ContentWebUIControllerFactory::GetInstance());
|
content::ContentWebUIControllerFactory::GetInstance());
|
||||||
|
|
||||||
|
#if defined(OS_LINUX)
|
||||||
|
printing::PrintingContextLinux::SetCreatePrintDialogFunction(
|
||||||
|
&CefPrintDialogLinux::CreatePrintDialog);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int CefBrowserMainParts::PreCreateThreads() {
|
int CefBrowserMainParts::PreCreateThreads() {
|
||||||
|
165
libcef/browser/print_settings_impl.cc
Normal file
165
libcef/browser/print_settings_impl.cc
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
// Copyright (c) 2014 The Chromium Embedded Framework 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/print_settings_impl.h"
|
||||||
|
|
||||||
|
#include "base/logging.h"
|
||||||
|
|
||||||
|
CefPrintSettingsImpl::CefPrintSettingsImpl(printing::PrintSettings* value,
|
||||||
|
bool will_delete,
|
||||||
|
bool read_only)
|
||||||
|
: CefValueBase<CefPrintSettings, printing::PrintSettings>(
|
||||||
|
value, NULL, will_delete ? kOwnerWillDelete : kOwnerNoDelete,
|
||||||
|
read_only, NULL) {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefPrintSettingsImpl::IsValid() {
|
||||||
|
return !detached();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefPrintSettingsImpl::IsReadOnly() {
|
||||||
|
return read_only();
|
||||||
|
}
|
||||||
|
|
||||||
|
CefRefPtr<CefPrintSettings> CefPrintSettingsImpl::Copy() {
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, NULL);
|
||||||
|
printing::PrintSettings* new_settings = new printing::PrintSettings;
|
||||||
|
*new_settings = const_value();
|
||||||
|
return new CefPrintSettingsImpl(new_settings, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintSettingsImpl::SetOrientation(bool landscape) {
|
||||||
|
CEF_VALUE_VERIFY_RETURN_VOID(true);
|
||||||
|
mutable_value()->SetOrientation(landscape);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefPrintSettingsImpl::IsLandscape() {
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, false);
|
||||||
|
return const_value().landscape();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintSettingsImpl::SetPrinterPrintableArea(
|
||||||
|
const CefSize& physical_size_device_units,
|
||||||
|
const CefRect& printable_area_device_units,
|
||||||
|
bool landscape_needs_flip) {
|
||||||
|
CEF_VALUE_VERIFY_RETURN_VOID(true);
|
||||||
|
gfx::Size size(physical_size_device_units.width,
|
||||||
|
physical_size_device_units.height);
|
||||||
|
gfx::Rect rect(printable_area_device_units.x,
|
||||||
|
printable_area_device_units.y,
|
||||||
|
printable_area_device_units.width,
|
||||||
|
printable_area_device_units.height);
|
||||||
|
mutable_value()->SetPrinterPrintableArea(size, rect, landscape_needs_flip);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintSettingsImpl::SetDeviceName(const CefString& name) {
|
||||||
|
CEF_VALUE_VERIFY_RETURN_VOID(true);
|
||||||
|
mutable_value()->set_device_name(name.ToString16());
|
||||||
|
}
|
||||||
|
|
||||||
|
CefString CefPrintSettingsImpl::GetDeviceName() {
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, CefString());
|
||||||
|
return const_value().device_name();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintSettingsImpl::SetDPI(int dpi) {
|
||||||
|
CEF_VALUE_VERIFY_RETURN_VOID(true);
|
||||||
|
mutable_value()->set_dpi(dpi);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CefPrintSettingsImpl::GetDPI() {
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, 0);
|
||||||
|
return const_value().dpi();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintSettingsImpl::SetPageRanges(const PageRangeList& ranges) {
|
||||||
|
CEF_VALUE_VERIFY_RETURN_VOID(true);
|
||||||
|
printing::PageRanges page_ranges;
|
||||||
|
PageRangeList::const_iterator it = ranges.begin();
|
||||||
|
for(; it != ranges.end(); ++it) {
|
||||||
|
const CefPageRange& cef_range = *it;
|
||||||
|
printing::PageRange range;
|
||||||
|
range.from = cef_range.from;
|
||||||
|
range.to = cef_range.to;
|
||||||
|
page_ranges.push_back(range);
|
||||||
|
}
|
||||||
|
mutable_value()->set_ranges(page_ranges);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t CefPrintSettingsImpl::GetPageRangesCount() {
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, 0);
|
||||||
|
return const_value().ranges().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintSettingsImpl::GetPageRanges(PageRangeList& ranges) {
|
||||||
|
CEF_VALUE_VERIFY_RETURN_VOID(false);
|
||||||
|
if (!ranges.empty())
|
||||||
|
ranges.clear();
|
||||||
|
const printing::PageRanges& page_ranges = const_value().ranges();
|
||||||
|
printing::PageRanges::const_iterator it = page_ranges.begin();
|
||||||
|
for (; it != page_ranges.end(); ++it) {
|
||||||
|
const printing::PageRange& range = *it;
|
||||||
|
ranges.push_back(CefPageRange(range.from, range.to));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintSettingsImpl::SetSelectionOnly(bool selection_only) {
|
||||||
|
CEF_VALUE_VERIFY_RETURN_VOID(true);
|
||||||
|
mutable_value()->set_selection_only(selection_only);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefPrintSettingsImpl::IsSelectionOnly() {
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, false);
|
||||||
|
return const_value().selection_only();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintSettingsImpl::SetCollate(bool collate) {
|
||||||
|
CEF_VALUE_VERIFY_RETURN_VOID(true);
|
||||||
|
mutable_value()->set_collate(collate);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefPrintSettingsImpl::WillCollate() {
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, false);
|
||||||
|
return const_value().collate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintSettingsImpl::SetColorModel(ColorModel model) {
|
||||||
|
CEF_VALUE_VERIFY_RETURN_VOID(true);
|
||||||
|
mutable_value()->set_color(static_cast<printing::ColorModel>(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
CefPrintSettings::ColorModel CefPrintSettingsImpl::GetColorModel() {
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, COLOR_MODEL_UNKNOWN);
|
||||||
|
return static_cast<ColorModel>(const_value().color());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintSettingsImpl::SetCopies(int copies) {
|
||||||
|
CEF_VALUE_VERIFY_RETURN_VOID(true);
|
||||||
|
mutable_value()->set_copies(copies);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CefPrintSettingsImpl::GetCopies() {
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, false);
|
||||||
|
return const_value().copies();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintSettingsImpl::SetDuplexMode(DuplexMode mode) {
|
||||||
|
CEF_VALUE_VERIFY_RETURN_VOID(true);
|
||||||
|
mutable_value()->set_duplex_mode(static_cast<printing::DuplexMode>(mode));
|
||||||
|
}
|
||||||
|
|
||||||
|
CefPrintSettings::DuplexMode CefPrintSettingsImpl::GetDuplexMode() {
|
||||||
|
CEF_VALUE_VERIFY_RETURN(false, DUPLEX_MODE_UNKNOWN);
|
||||||
|
return static_cast<DuplexMode>(const_value().duplex_mode());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// CefPrintSettings implementation.
|
||||||
|
|
||||||
|
// static
|
||||||
|
CefRefPtr<CefPrintSettings> CefPrintSettings::Create() {
|
||||||
|
return new CefPrintSettingsImpl(
|
||||||
|
new printing::PrintSettings(), true, false);
|
||||||
|
}
|
||||||
|
|
56
libcef/browser/print_settings_impl.h
Normal file
56
libcef/browser/print_settings_impl.h
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
// Copyright (c) 2014 The Chromium Embedded Framework 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_PRINT_SETTINGS_IMPL_H_
|
||||||
|
#define CEF_LIBCEF_BROWSER_PRINT_SETTINGS_IMPL_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "include/cef_print_settings.h"
|
||||||
|
#include "libcef/common/value_base.h"
|
||||||
|
|
||||||
|
#include "printing/print_settings.h"
|
||||||
|
|
||||||
|
// CefPrintSettings implementation
|
||||||
|
class CefPrintSettingsImpl
|
||||||
|
: public CefValueBase<CefPrintSettings, printing::PrintSettings> {
|
||||||
|
public:
|
||||||
|
CefPrintSettingsImpl(printing::PrintSettings* value,
|
||||||
|
bool will_delete,
|
||||||
|
bool read_only);
|
||||||
|
|
||||||
|
// CefPrintSettings methods.
|
||||||
|
virtual bool IsValid() OVERRIDE;
|
||||||
|
virtual bool IsReadOnly() OVERRIDE;
|
||||||
|
virtual CefRefPtr<CefPrintSettings> Copy() OVERRIDE;
|
||||||
|
virtual void SetOrientation(bool landscape) OVERRIDE;
|
||||||
|
virtual bool IsLandscape() OVERRIDE;
|
||||||
|
virtual void SetPrinterPrintableArea(
|
||||||
|
const CefSize& physical_size_device_units,
|
||||||
|
const CefRect& printable_area_device_units,
|
||||||
|
bool landscape_needs_flip) OVERRIDE;
|
||||||
|
virtual void SetDeviceName(const CefString& name) OVERRIDE;
|
||||||
|
virtual CefString GetDeviceName() OVERRIDE;
|
||||||
|
virtual void SetDPI(int dpi) OVERRIDE;
|
||||||
|
virtual int GetDPI() OVERRIDE;
|
||||||
|
virtual void SetPageRanges(const PageRangeList& ranges) OVERRIDE;
|
||||||
|
virtual size_t GetPageRangesCount() OVERRIDE;
|
||||||
|
virtual void GetPageRanges(PageRangeList& ranges) OVERRIDE;
|
||||||
|
virtual void SetSelectionOnly(bool selection_only) OVERRIDE;
|
||||||
|
virtual bool IsSelectionOnly() OVERRIDE;
|
||||||
|
virtual void SetCollate(bool collate) OVERRIDE;
|
||||||
|
virtual bool WillCollate() OVERRIDE;
|
||||||
|
virtual void SetColorModel(ColorModel model) OVERRIDE;
|
||||||
|
virtual ColorModel GetColorModel() OVERRIDE;
|
||||||
|
virtual void SetCopies(int copies) OVERRIDE;
|
||||||
|
virtual int GetCopies() OVERRIDE;
|
||||||
|
virtual void SetDuplexMode(DuplexMode mode) OVERRIDE;
|
||||||
|
virtual DuplexMode GetDuplexMode() OVERRIDE;
|
||||||
|
|
||||||
|
// Must hold the controller lock while using this value.
|
||||||
|
const printing::PrintSettings& print_settings() { return const_value(); }
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(CefPrintSettingsImpl);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CEF_LIBCEF_BROWSER_PRINT_SETTINGS_IMPL_H_
|
275
libcef/browser/printing/print_dialog_linux.cc
Normal file
275
libcef/browser/printing/print_dialog_linux.cc
Normal file
@ -0,0 +1,275 @@
|
|||||||
|
// Copyright (c) 2014 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/printing/print_dialog_linux.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "libcef/browser/print_settings_impl.h"
|
||||||
|
#include "libcef/browser/thread_util.h"
|
||||||
|
#include "libcef/common/content_client.h"
|
||||||
|
|
||||||
|
#include "base/bind.h"
|
||||||
|
#include "base/file_util.h"
|
||||||
|
#include "base/files/file_util_proxy.h"
|
||||||
|
#include "base/lazy_instance.h"
|
||||||
|
#include "base/logging.h"
|
||||||
|
#include "base/message_loop/message_loop_proxy.h"
|
||||||
|
#include "base/strings/utf_string_conversions.h"
|
||||||
|
#include "base/values.h"
|
||||||
|
#include "printing/metafile.h"
|
||||||
|
#include "printing/print_job_constants.h"
|
||||||
|
#include "printing/print_settings.h"
|
||||||
|
|
||||||
|
using content::BrowserThread;
|
||||||
|
using printing::PageRanges;
|
||||||
|
using printing::PrintSettings;
|
||||||
|
|
||||||
|
class CefPrintDialogCallbackImpl : public CefPrintDialogCallback {
|
||||||
|
public:
|
||||||
|
explicit CefPrintDialogCallbackImpl(CefRefPtr<CefPrintDialogLinux> dialog)
|
||||||
|
: dialog_(dialog) {
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void Continue(CefRefPtr<CefPrintSettings> settings) OVERRIDE {
|
||||||
|
if (CEF_CURRENTLY_ON_UIT()) {
|
||||||
|
if (dialog_) {
|
||||||
|
dialog_->OnPrintContinue(settings);
|
||||||
|
dialog_ = NULL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
CEF_POST_TASK(CEF_UIT,
|
||||||
|
base::Bind(&CefPrintDialogCallbackImpl::Continue, this, settings));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void Cancel() OVERRIDE {
|
||||||
|
if (CEF_CURRENTLY_ON_UIT()) {
|
||||||
|
if (dialog_) {
|
||||||
|
dialog_->OnPrintCancel();
|
||||||
|
dialog_ = NULL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
CEF_POST_TASK(CEF_UIT,
|
||||||
|
base::Bind(&CefPrintDialogCallbackImpl::Cancel, this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Disconnect() {
|
||||||
|
dialog_ = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CefRefPtr<CefPrintDialogLinux> dialog_;
|
||||||
|
|
||||||
|
IMPLEMENT_REFCOUNTING(CefPrintDialogCallbackImpl);
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(CefPrintDialogCallbackImpl);
|
||||||
|
};
|
||||||
|
|
||||||
|
class CefPrintJobCallbackImpl : public CefPrintJobCallback {
|
||||||
|
public:
|
||||||
|
explicit CefPrintJobCallbackImpl(CefRefPtr<CefPrintDialogLinux> dialog)
|
||||||
|
: dialog_(dialog) {
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void Continue() OVERRIDE {
|
||||||
|
if (CEF_CURRENTLY_ON_UIT()) {
|
||||||
|
if (dialog_) {
|
||||||
|
dialog_->OnJobCompleted();
|
||||||
|
dialog_ = NULL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
CEF_POST_TASK(CEF_UIT,
|
||||||
|
base::Bind(&CefPrintJobCallbackImpl::Continue, this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Disconnect() {
|
||||||
|
dialog_ = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CefRefPtr<CefPrintDialogLinux> dialog_;
|
||||||
|
|
||||||
|
IMPLEMENT_REFCOUNTING(CefPrintJobCallbackImpl);
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(CefPrintJobCallbackImpl);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// static
|
||||||
|
printing::PrintDialogGtkInterface* CefPrintDialogLinux::CreatePrintDialog(
|
||||||
|
PrintingContextLinux* context) {
|
||||||
|
CEF_REQUIRE_UIT();
|
||||||
|
return new CefPrintDialogLinux(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
CefPrintDialogLinux::CefPrintDialogLinux(PrintingContextLinux* context)
|
||||||
|
: context_(context) {
|
||||||
|
}
|
||||||
|
|
||||||
|
CefPrintDialogLinux::~CefPrintDialogLinux() {
|
||||||
|
CEF_REQUIRE_UIT();
|
||||||
|
ReleaseHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintDialogLinux::UseDefaultSettings() {
|
||||||
|
PrintSettings settings;
|
||||||
|
UpdateSettings(&settings, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefPrintDialogLinux::UpdateSettings(printing::PrintSettings* settings) {
|
||||||
|
return UpdateSettings(settings, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintDialogLinux::ShowDialog(
|
||||||
|
gfx::NativeView parent_view,
|
||||||
|
bool has_selection,
|
||||||
|
const PrintingContextLinux::PrintSettingsCallback& callback) {
|
||||||
|
CEF_REQUIRE_UIT();
|
||||||
|
|
||||||
|
SetHandler();
|
||||||
|
if (!handler_) {
|
||||||
|
callback.Run(PrintingContextLinux::CANCEL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback_ = callback;
|
||||||
|
|
||||||
|
CefRefPtr<CefPrintDialogCallbackImpl> callback_impl(
|
||||||
|
new CefPrintDialogCallbackImpl(this));
|
||||||
|
|
||||||
|
if (!handler_->OnPrintDialog(has_selection, callback_impl.get())) {
|
||||||
|
callback_impl->Disconnect();
|
||||||
|
OnPrintCancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintDialogLinux::PrintDocument(const printing::Metafile* metafile,
|
||||||
|
const base::string16& document_name) {
|
||||||
|
// This runs on the print worker thread, does not block the UI thread.
|
||||||
|
DCHECK(!CEF_CURRENTLY_ON_UIT());
|
||||||
|
|
||||||
|
// The document printing tasks can outlive the PrintingContext that created
|
||||||
|
// this dialog.
|
||||||
|
AddRef();
|
||||||
|
|
||||||
|
bool error = false;
|
||||||
|
if (!base::CreateTemporaryFile(&path_to_pdf_)) {
|
||||||
|
LOG(ERROR) << "Creating temporary file failed";
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!error && !metafile->SaveTo(path_to_pdf_)) {
|
||||||
|
LOG(ERROR) << "Saving metafile failed";
|
||||||
|
base::DeleteFile(path_to_pdf_, false);
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
// Matches AddRef() above.
|
||||||
|
Release();
|
||||||
|
} else {
|
||||||
|
// No errors, continue printing.
|
||||||
|
CEF_POST_TASK(
|
||||||
|
CEF_UIT,
|
||||||
|
base::Bind(&CefPrintDialogLinux::SendDocumentToPrinter, this,
|
||||||
|
document_name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintDialogLinux::AddRefToDialog() {
|
||||||
|
AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintDialogLinux::ReleaseDialog() {
|
||||||
|
Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintDialogLinux::SetHandler() {
|
||||||
|
if (handler_)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CefRefPtr<CefApp> app = CefContentClient::Get()->application();
|
||||||
|
if (app.get()) {
|
||||||
|
CefRefPtr<CefBrowserProcessHandler> browser_handler =
|
||||||
|
app->GetBrowserProcessHandler();
|
||||||
|
if (browser_handler)
|
||||||
|
handler_ = browser_handler->GetPrintHandler();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintDialogLinux::ReleaseHandler() {
|
||||||
|
if (handler_) {
|
||||||
|
handler_->OnPrintReset();
|
||||||
|
handler_ = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefPrintDialogLinux::UpdateSettings(printing::PrintSettings* settings,
|
||||||
|
bool get_defaults) {
|
||||||
|
CEF_REQUIRE_UIT();
|
||||||
|
|
||||||
|
SetHandler();
|
||||||
|
if (!handler_)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
CefRefPtr<CefPrintSettingsImpl> settings_impl(
|
||||||
|
new CefPrintSettingsImpl(settings, false, false));
|
||||||
|
handler_->OnPrintSettings(settings_impl.get(), get_defaults);
|
||||||
|
settings_impl->Detach(NULL);
|
||||||
|
|
||||||
|
context_->InitWithSettings(*settings);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintDialogLinux::SendDocumentToPrinter(
|
||||||
|
const base::string16& document_name) {
|
||||||
|
CEF_REQUIRE_UIT();
|
||||||
|
|
||||||
|
if (!handler_) {
|
||||||
|
OnJobCompleted();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefRefPtr<CefPrintJobCallbackImpl> callback_impl(
|
||||||
|
new CefPrintJobCallbackImpl(this));
|
||||||
|
|
||||||
|
if (!handler_->OnPrintJob(document_name, path_to_pdf_.value(),
|
||||||
|
callback_impl.get())) {
|
||||||
|
callback_impl->Disconnect();
|
||||||
|
OnJobCompleted();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintDialogLinux::OnPrintContinue(
|
||||||
|
CefRefPtr<CefPrintSettings> settings) {
|
||||||
|
{
|
||||||
|
CefPrintSettingsImpl* impl =
|
||||||
|
static_cast<CefPrintSettingsImpl*>(settings.get());
|
||||||
|
CefValueController::AutoLock lock_scope(impl->controller());
|
||||||
|
context_->InitWithSettings(impl->print_settings());
|
||||||
|
}
|
||||||
|
callback_.Run(PrintingContextLinux::OK);
|
||||||
|
callback_.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintDialogLinux::OnPrintCancel() {
|
||||||
|
callback_.Run(PrintingContextLinux::CANCEL);
|
||||||
|
callback_.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintDialogLinux::OnJobCompleted() {
|
||||||
|
base::FileUtilProxy::DeleteFile(
|
||||||
|
content::BrowserThread::GetMessageLoopProxyForThread(
|
||||||
|
BrowserThread::FILE).get(),
|
||||||
|
path_to_pdf_,
|
||||||
|
false,
|
||||||
|
base::FileUtilProxy::StatusCallback());
|
||||||
|
|
||||||
|
// Printing finished. Matches AddRef() in PrintDocument();
|
||||||
|
Release();
|
||||||
|
}
|
||||||
|
|
85
libcef/browser/printing/print_dialog_linux.h
Normal file
85
libcef/browser/printing/print_dialog_linux.h
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
// Copyright (c) 2014 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 LIBCEF_BROWSER_PRINTING_PRINT_DIALOG_LINUX_H_
|
||||||
|
#define LIBCEF_BROWSER_PRINTING_PRINT_DIALOG_LINUX_H_
|
||||||
|
|
||||||
|
#include "include/cef_print_handler.h"
|
||||||
|
|
||||||
|
#include "base/compiler_specific.h"
|
||||||
|
#include "base/files/file_path.h"
|
||||||
|
#include "base/memory/ref_counted.h"
|
||||||
|
#include "base/sequenced_task_runner_helpers.h"
|
||||||
|
#include "content/public/browser/browser_thread.h"
|
||||||
|
#include "printing/print_dialog_gtk_interface.h"
|
||||||
|
#include "printing/printing_context_linux.h"
|
||||||
|
|
||||||
|
namespace printing {
|
||||||
|
class Metafile;
|
||||||
|
class PrintSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
using printing::PrintingContextLinux;
|
||||||
|
|
||||||
|
// Needs to be freed on the UI thread to clean up its member variables.
|
||||||
|
class CefPrintDialogLinux
|
||||||
|
: public printing::PrintDialogGtkInterface,
|
||||||
|
public base::RefCountedThreadSafe<
|
||||||
|
CefPrintDialogLinux, content::BrowserThread::DeleteOnUIThread> {
|
||||||
|
public:
|
||||||
|
// Creates and returns a print dialog.
|
||||||
|
static printing::PrintDialogGtkInterface* CreatePrintDialog(
|
||||||
|
PrintingContextLinux* context);
|
||||||
|
|
||||||
|
// printing::CefPrintDialogLinuxInterface implementation.
|
||||||
|
virtual void UseDefaultSettings() OVERRIDE;
|
||||||
|
virtual bool UpdateSettings(printing::PrintSettings* settings) OVERRIDE;
|
||||||
|
virtual void ShowDialog(
|
||||||
|
gfx::NativeView parent_view,
|
||||||
|
bool has_selection,
|
||||||
|
const PrintingContextLinux::PrintSettingsCallback& callback) OVERRIDE;
|
||||||
|
virtual void PrintDocument(const printing::Metafile* metafile,
|
||||||
|
const base::string16& document_name) OVERRIDE;
|
||||||
|
virtual void AddRefToDialog() OVERRIDE;
|
||||||
|
virtual void ReleaseDialog() OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend struct content::BrowserThread::DeleteOnThread<
|
||||||
|
content::BrowserThread::UI>;
|
||||||
|
friend class base::DeleteHelper<CefPrintDialogLinux>;
|
||||||
|
friend class CefPrintDialogCallbackImpl;
|
||||||
|
friend class CefPrintJobCallbackImpl;
|
||||||
|
|
||||||
|
explicit CefPrintDialogLinux(PrintingContextLinux* context);
|
||||||
|
virtual ~CefPrintDialogLinux();
|
||||||
|
|
||||||
|
void SetHandler();
|
||||||
|
void ReleaseHandler();
|
||||||
|
|
||||||
|
bool UpdateSettings(printing::PrintSettings* settings,
|
||||||
|
bool get_defaults);
|
||||||
|
|
||||||
|
// Prints document named |document_name|.
|
||||||
|
void SendDocumentToPrinter(const base::string16& document_name);
|
||||||
|
|
||||||
|
// Handles print dialog response.
|
||||||
|
void OnPrintContinue(CefRefPtr<CefPrintSettings> settings);
|
||||||
|
void OnPrintCancel();
|
||||||
|
|
||||||
|
// Handles print job response.
|
||||||
|
void OnJobCompleted();
|
||||||
|
|
||||||
|
CefRefPtr<CefPrintHandler> handler_;
|
||||||
|
|
||||||
|
// Printing dialog callback.
|
||||||
|
PrintingContextLinux::PrintSettingsCallback callback_;
|
||||||
|
PrintingContextLinux* context_;
|
||||||
|
|
||||||
|
base::FilePath path_to_pdf_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(CefPrintDialogLinux);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LIBCEF_BROWSER_PRINTING_PRINT_DIALOG_LINUX_H_
|
@ -11,6 +11,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "libcef_dll/cpptoc/browser_process_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/browser_process_handler_cpptoc.h"
|
||||||
|
#include "libcef_dll/cpptoc/print_handler_cpptoc.h"
|
||||||
#include "libcef_dll/ctocpp/command_line_ctocpp.h"
|
#include "libcef_dll/ctocpp/command_line_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/list_value_ctocpp.h"
|
#include "libcef_dll/ctocpp/list_value_ctocpp.h"
|
||||||
|
|
||||||
@ -65,6 +66,22 @@ void CEF_CALLBACK browser_process_handler_on_render_process_thread_created(
|
|||||||
CefListValueCToCpp::Wrap(extra_info));
|
CefListValueCToCpp::Wrap(extra_info));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct _cef_print_handler_t* CEF_CALLBACK browser_process_handler_get_print_handler(
|
||||||
|
struct _cef_browser_process_handler_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefRefPtr<CefPrintHandler> _retval = CefBrowserProcessHandlerCppToC::Get(
|
||||||
|
self)->GetPrintHandler();
|
||||||
|
|
||||||
|
// Return type: refptr_same
|
||||||
|
return CefPrintHandlerCppToC::Wrap(_retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// CONSTRUCTOR - Do not edit by hand.
|
// CONSTRUCTOR - Do not edit by hand.
|
||||||
|
|
||||||
@ -78,6 +95,7 @@ CefBrowserProcessHandlerCppToC::CefBrowserProcessHandlerCppToC(
|
|||||||
browser_process_handler_on_before_child_process_launch;
|
browser_process_handler_on_before_child_process_launch;
|
||||||
struct_.struct_.on_render_process_thread_created =
|
struct_.struct_.on_render_process_thread_created =
|
||||||
browser_process_handler_on_render_process_thread_created;
|
browser_process_handler_on_render_process_thread_created;
|
||||||
|
struct_.struct_.get_print_handler = browser_process_handler_get_print_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
64
libcef_dll/cpptoc/print_dialog_callback_cpptoc.cc
Normal file
64
libcef_dll/cpptoc/print_dialog_callback_cpptoc.cc
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool. If making changes by
|
||||||
|
// hand only 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/print_dialog_callback_cpptoc.h"
|
||||||
|
#include "libcef_dll/cpptoc/print_settings_cpptoc.h"
|
||||||
|
|
||||||
|
|
||||||
|
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||||
|
|
||||||
|
void CEF_CALLBACK print_dialog_callback_cont(
|
||||||
|
struct _cef_print_dialog_callback_t* self,
|
||||||
|
struct _cef_print_settings_t* settings) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
// Verify param: settings; type: refptr_same
|
||||||
|
DCHECK(settings);
|
||||||
|
if (!settings)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefPrintDialogCallbackCppToC::Get(self)->Continue(
|
||||||
|
CefPrintSettingsCppToC::Unwrap(settings));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEF_CALLBACK print_dialog_callback_cancel(
|
||||||
|
struct _cef_print_dialog_callback_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefPrintDialogCallbackCppToC::Get(self)->Cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// CONSTRUCTOR - Do not edit by hand.
|
||||||
|
|
||||||
|
CefPrintDialogCallbackCppToC::CefPrintDialogCallbackCppToC(
|
||||||
|
CefPrintDialogCallback* cls)
|
||||||
|
: CefCppToC<CefPrintDialogCallbackCppToC, CefPrintDialogCallback,
|
||||||
|
cef_print_dialog_callback_t>(cls) {
|
||||||
|
struct_.struct_.cont = print_dialog_callback_cont;
|
||||||
|
struct_.struct_.cancel = print_dialog_callback_cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
template<> long CefCppToC<CefPrintDialogCallbackCppToC, CefPrintDialogCallback,
|
||||||
|
cef_print_dialog_callback_t>::DebugObjCt = 0;
|
||||||
|
#endif
|
||||||
|
|
37
libcef_dll/cpptoc/print_dialog_callback_cpptoc.h
Normal file
37
libcef_dll/cpptoc/print_dialog_callback_cpptoc.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool. If making changes by
|
||||||
|
// hand only 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_PRINT_DIALOG_CALLBACK_CPPTOC_H_
|
||||||
|
#define CEF_LIBCEF_DLL_CPPTOC_PRINT_DIALOG_CALLBACK_CPPTOC_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef BUILDING_CEF_SHARED
|
||||||
|
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||||
|
#else // BUILDING_CEF_SHARED
|
||||||
|
|
||||||
|
#include "include/cef_print_handler.h"
|
||||||
|
#include "include/capi/cef_print_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 CefPrintDialogCallbackCppToC
|
||||||
|
: public CefCppToC<CefPrintDialogCallbackCppToC, CefPrintDialogCallback,
|
||||||
|
cef_print_dialog_callback_t> {
|
||||||
|
public:
|
||||||
|
explicit CefPrintDialogCallbackCppToC(CefPrintDialogCallback* cls);
|
||||||
|
virtual ~CefPrintDialogCallbackCppToC() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BUILDING_CEF_SHARED
|
||||||
|
#endif // CEF_LIBCEF_DLL_CPPTOC_PRINT_DIALOG_CALLBACK_CPPTOC_H_
|
||||||
|
|
121
libcef_dll/cpptoc/print_handler_cpptoc.cc
Normal file
121
libcef_dll/cpptoc/print_handler_cpptoc.cc
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool. If making changes by
|
||||||
|
// hand only 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/print_handler_cpptoc.h"
|
||||||
|
#include "libcef_dll/ctocpp/print_dialog_callback_ctocpp.h"
|
||||||
|
#include "libcef_dll/ctocpp/print_job_callback_ctocpp.h"
|
||||||
|
#include "libcef_dll/ctocpp/print_settings_ctocpp.h"
|
||||||
|
|
||||||
|
|
||||||
|
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||||
|
|
||||||
|
void CEF_CALLBACK print_handler_on_print_settings(
|
||||||
|
struct _cef_print_handler_t* self, struct _cef_print_settings_t* settings,
|
||||||
|
int get_defaults) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
// Verify param: settings; type: refptr_diff
|
||||||
|
DCHECK(settings);
|
||||||
|
if (!settings)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefPrintHandlerCppToC::Get(self)->OnPrintSettings(
|
||||||
|
CefPrintSettingsCToCpp::Wrap(settings),
|
||||||
|
get_defaults?true:false);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CEF_CALLBACK print_handler_on_print_dialog(
|
||||||
|
struct _cef_print_handler_t* self, int has_selection,
|
||||||
|
cef_print_dialog_callback_t* callback) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return 0;
|
||||||
|
// Verify param: callback; type: refptr_diff
|
||||||
|
DCHECK(callback);
|
||||||
|
if (!callback)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
bool _retval = CefPrintHandlerCppToC::Get(self)->OnPrintDialog(
|
||||||
|
has_selection?true:false,
|
||||||
|
CefPrintDialogCallbackCToCpp::Wrap(callback));
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CEF_CALLBACK print_handler_on_print_job(struct _cef_print_handler_t* self,
|
||||||
|
const cef_string_t* document_name, const cef_string_t* pdf_file_path,
|
||||||
|
cef_print_job_callback_t* callback) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return 0;
|
||||||
|
// Verify param: document_name; type: string_byref_const
|
||||||
|
DCHECK(document_name);
|
||||||
|
if (!document_name)
|
||||||
|
return 0;
|
||||||
|
// Verify param: pdf_file_path; type: string_byref_const
|
||||||
|
DCHECK(pdf_file_path);
|
||||||
|
if (!pdf_file_path)
|
||||||
|
return 0;
|
||||||
|
// Verify param: callback; type: refptr_diff
|
||||||
|
DCHECK(callback);
|
||||||
|
if (!callback)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
bool _retval = CefPrintHandlerCppToC::Get(self)->OnPrintJob(
|
||||||
|
CefString(document_name),
|
||||||
|
CefString(pdf_file_path),
|
||||||
|
CefPrintJobCallbackCToCpp::Wrap(callback));
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEF_CALLBACK print_handler_on_print_reset(
|
||||||
|
struct _cef_print_handler_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefPrintHandlerCppToC::Get(self)->OnPrintReset();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// CONSTRUCTOR - Do not edit by hand.
|
||||||
|
|
||||||
|
CefPrintHandlerCppToC::CefPrintHandlerCppToC(CefPrintHandler* cls)
|
||||||
|
: CefCppToC<CefPrintHandlerCppToC, CefPrintHandler, cef_print_handler_t>(
|
||||||
|
cls) {
|
||||||
|
struct_.struct_.on_print_settings = print_handler_on_print_settings;
|
||||||
|
struct_.struct_.on_print_dialog = print_handler_on_print_dialog;
|
||||||
|
struct_.struct_.on_print_job = print_handler_on_print_job;
|
||||||
|
struct_.struct_.on_print_reset = print_handler_on_print_reset;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
template<> long CefCppToC<CefPrintHandlerCppToC, CefPrintHandler,
|
||||||
|
cef_print_handler_t>::DebugObjCt = 0;
|
||||||
|
#endif
|
||||||
|
|
37
libcef_dll/cpptoc/print_handler_cpptoc.h
Normal file
37
libcef_dll/cpptoc/print_handler_cpptoc.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool. If making changes by
|
||||||
|
// hand only 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_PRINT_HANDLER_CPPTOC_H_
|
||||||
|
#define CEF_LIBCEF_DLL_CPPTOC_PRINT_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_print_handler.h"
|
||||||
|
#include "include/capi/cef_print_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 CefPrintHandlerCppToC
|
||||||
|
: public CefCppToC<CefPrintHandlerCppToC, CefPrintHandler,
|
||||||
|
cef_print_handler_t> {
|
||||||
|
public:
|
||||||
|
explicit CefPrintHandlerCppToC(CefPrintHandler* cls);
|
||||||
|
virtual ~CefPrintHandlerCppToC() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // USING_CEF_SHARED
|
||||||
|
#endif // CEF_LIBCEF_DLL_CPPTOC_PRINT_HANDLER_CPPTOC_H_
|
||||||
|
|
43
libcef_dll/cpptoc/print_job_callback_cpptoc.cc
Normal file
43
libcef_dll/cpptoc/print_job_callback_cpptoc.cc
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool. If making changes by
|
||||||
|
// hand only 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/print_job_callback_cpptoc.h"
|
||||||
|
|
||||||
|
|
||||||
|
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||||
|
|
||||||
|
void CEF_CALLBACK print_job_callback_cont(
|
||||||
|
struct _cef_print_job_callback_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefPrintJobCallbackCppToC::Get(self)->Continue();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// CONSTRUCTOR - Do not edit by hand.
|
||||||
|
|
||||||
|
CefPrintJobCallbackCppToC::CefPrintJobCallbackCppToC(CefPrintJobCallback* cls)
|
||||||
|
: CefCppToC<CefPrintJobCallbackCppToC, CefPrintJobCallback,
|
||||||
|
cef_print_job_callback_t>(cls) {
|
||||||
|
struct_.struct_.cont = print_job_callback_cont;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
template<> long CefCppToC<CefPrintJobCallbackCppToC, CefPrintJobCallback,
|
||||||
|
cef_print_job_callback_t>::DebugObjCt = 0;
|
||||||
|
#endif
|
||||||
|
|
37
libcef_dll/cpptoc/print_job_callback_cpptoc.h
Normal file
37
libcef_dll/cpptoc/print_job_callback_cpptoc.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool. If making changes by
|
||||||
|
// hand only 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_PRINT_JOB_CALLBACK_CPPTOC_H_
|
||||||
|
#define CEF_LIBCEF_DLL_CPPTOC_PRINT_JOB_CALLBACK_CPPTOC_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef BUILDING_CEF_SHARED
|
||||||
|
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||||
|
#else // BUILDING_CEF_SHARED
|
||||||
|
|
||||||
|
#include "include/cef_print_handler.h"
|
||||||
|
#include "include/capi/cef_print_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 CefPrintJobCallbackCppToC
|
||||||
|
: public CefCppToC<CefPrintJobCallbackCppToC, CefPrintJobCallback,
|
||||||
|
cef_print_job_callback_t> {
|
||||||
|
public:
|
||||||
|
explicit CefPrintJobCallbackCppToC(CefPrintJobCallback* cls);
|
||||||
|
virtual ~CefPrintJobCallbackCppToC() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BUILDING_CEF_SHARED
|
||||||
|
#endif // CEF_LIBCEF_DLL_CPPTOC_PRINT_JOB_CALLBACK_CPPTOC_H_
|
||||||
|
|
447
libcef_dll/cpptoc/print_settings_cpptoc.cc
Normal file
447
libcef_dll/cpptoc/print_settings_cpptoc.cc
Normal file
@ -0,0 +1,447 @@
|
|||||||
|
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool. If making changes by
|
||||||
|
// hand only 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 <algorithm>
|
||||||
|
#include "libcef_dll/cpptoc/print_settings_cpptoc.h"
|
||||||
|
|
||||||
|
|
||||||
|
// GLOBAL FUNCTIONS - Body may be edited by hand.
|
||||||
|
|
||||||
|
CEF_EXPORT cef_print_settings_t* cef_print_settings_create() {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefRefPtr<CefPrintSettings> _retval = CefPrintSettings::Create();
|
||||||
|
|
||||||
|
// Return type: refptr_same
|
||||||
|
return CefPrintSettingsCppToC::Wrap(_retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||||
|
|
||||||
|
int CEF_CALLBACK print_settings_is_valid(struct _cef_print_settings_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
bool _retval = CefPrintSettingsCppToC::Get(self)->IsValid();
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CEF_CALLBACK print_settings_is_read_only(
|
||||||
|
struct _cef_print_settings_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
bool _retval = CefPrintSettingsCppToC::Get(self)->IsReadOnly();
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct _cef_print_settings_t* CEF_CALLBACK print_settings_copy(
|
||||||
|
struct _cef_print_settings_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefRefPtr<CefPrintSettings> _retval = CefPrintSettingsCppToC::Get(self)->Copy(
|
||||||
|
);
|
||||||
|
|
||||||
|
// Return type: refptr_same
|
||||||
|
return CefPrintSettingsCppToC::Wrap(_retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEF_CALLBACK print_settings_set_orientation(
|
||||||
|
struct _cef_print_settings_t* self, int landscape) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefPrintSettingsCppToC::Get(self)->SetOrientation(
|
||||||
|
landscape?true:false);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CEF_CALLBACK print_settings_is_landscape(
|
||||||
|
struct _cef_print_settings_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
bool _retval = CefPrintSettingsCppToC::Get(self)->IsLandscape();
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEF_CALLBACK print_settings_set_printer_printable_area(
|
||||||
|
struct _cef_print_settings_t* self,
|
||||||
|
const cef_size_t* physical_size_device_units,
|
||||||
|
const cef_rect_t* printable_area_device_units, int landscape_needs_flip) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
// Verify param: physical_size_device_units; type: simple_byref_const
|
||||||
|
DCHECK(physical_size_device_units);
|
||||||
|
if (!physical_size_device_units)
|
||||||
|
return;
|
||||||
|
// Verify param: printable_area_device_units; type: simple_byref_const
|
||||||
|
DCHECK(printable_area_device_units);
|
||||||
|
if (!printable_area_device_units)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Translate param: physical_size_device_units; type: simple_byref_const
|
||||||
|
CefSize physical_size_device_unitsVal =
|
||||||
|
physical_size_device_units?*physical_size_device_units:CefSize();
|
||||||
|
// Translate param: printable_area_device_units; type: simple_byref_const
|
||||||
|
CefRect printable_area_device_unitsVal =
|
||||||
|
printable_area_device_units?*printable_area_device_units:CefRect();
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefPrintSettingsCppToC::Get(self)->SetPrinterPrintableArea(
|
||||||
|
physical_size_device_unitsVal,
|
||||||
|
printable_area_device_unitsVal,
|
||||||
|
landscape_needs_flip?true:false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEF_CALLBACK print_settings_set_device_name(
|
||||||
|
struct _cef_print_settings_t* self, const cef_string_t* name) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
// Unverified params: name
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefPrintSettingsCppToC::Get(self)->SetDeviceName(
|
||||||
|
CefString(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
cef_string_userfree_t CEF_CALLBACK print_settings_get_device_name(
|
||||||
|
struct _cef_print_settings_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefString _retval = CefPrintSettingsCppToC::Get(self)->GetDeviceName();
|
||||||
|
|
||||||
|
// Return type: string
|
||||||
|
return _retval.DetachToUserFree();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEF_CALLBACK print_settings_set_dpi(struct _cef_print_settings_t* self,
|
||||||
|
int dpi) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefPrintSettingsCppToC::Get(self)->SetDPI(
|
||||||
|
dpi);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CEF_CALLBACK print_settings_get_dpi(struct _cef_print_settings_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int _retval = CefPrintSettingsCppToC::Get(self)->GetDPI();
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEF_CALLBACK print_settings_set_page_ranges(
|
||||||
|
struct _cef_print_settings_t* self, size_t rangesCount,
|
||||||
|
cef_page_range_t const* ranges) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
// Verify param: ranges; type: simple_vec_byref_const
|
||||||
|
DCHECK(rangesCount == 0 || ranges);
|
||||||
|
if (rangesCount > 0 && !ranges)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Translate param: ranges; type: simple_vec_byref_const
|
||||||
|
std::vector<CefPageRange > rangesList;
|
||||||
|
if (rangesCount > 0) {
|
||||||
|
for (size_t i = 0; i < rangesCount; ++i) {
|
||||||
|
rangesList.push_back(ranges[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefPrintSettingsCppToC::Get(self)->SetPageRanges(
|
||||||
|
rangesList);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t CEF_CALLBACK print_settings_get_page_ranges_count(
|
||||||
|
struct _cef_print_settings_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
size_t _retval = CefPrintSettingsCppToC::Get(self)->GetPageRangesCount();
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEF_CALLBACK print_settings_get_page_ranges(
|
||||||
|
struct _cef_print_settings_t* self, size_t* rangesCount,
|
||||||
|
cef_page_range_t* ranges) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
// Verify param: ranges; type: simple_vec_byref
|
||||||
|
DCHECK(rangesCount && (*rangesCount == 0 || ranges));
|
||||||
|
if (!rangesCount || (*rangesCount > 0 && !ranges))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Translate param: ranges; type: simple_vec_byref
|
||||||
|
std::vector<CefPageRange > rangesList;
|
||||||
|
if (rangesCount && *rangesCount > 0 && ranges) {
|
||||||
|
for (size_t i = 0; i < *rangesCount; ++i) {
|
||||||
|
rangesList.push_back(ranges[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefPrintSettingsCppToC::Get(self)->GetPageRanges(
|
||||||
|
rangesList);
|
||||||
|
|
||||||
|
// Restore param: ranges; type: simple_vec_byref
|
||||||
|
if (rangesCount && ranges) {
|
||||||
|
*rangesCount = std::min(rangesList.size(), *rangesCount);
|
||||||
|
if (*rangesCount > 0) {
|
||||||
|
for (size_t i = 0; i < *rangesCount; ++i) {
|
||||||
|
ranges[i] = rangesList[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEF_CALLBACK print_settings_set_selection_only(
|
||||||
|
struct _cef_print_settings_t* self, int selection_only) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefPrintSettingsCppToC::Get(self)->SetSelectionOnly(
|
||||||
|
selection_only?true:false);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CEF_CALLBACK print_settings_is_selection_only(
|
||||||
|
struct _cef_print_settings_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
bool _retval = CefPrintSettingsCppToC::Get(self)->IsSelectionOnly();
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEF_CALLBACK print_settings_set_collate(struct _cef_print_settings_t* self,
|
||||||
|
int collate) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefPrintSettingsCppToC::Get(self)->SetCollate(
|
||||||
|
collate?true:false);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CEF_CALLBACK print_settings_will_collate(
|
||||||
|
struct _cef_print_settings_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
bool _retval = CefPrintSettingsCppToC::Get(self)->WillCollate();
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEF_CALLBACK print_settings_set_color_model(
|
||||||
|
struct _cef_print_settings_t* self, cef_color_model_t model) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefPrintSettingsCppToC::Get(self)->SetColorModel(
|
||||||
|
model);
|
||||||
|
}
|
||||||
|
|
||||||
|
cef_color_model_t CEF_CALLBACK print_settings_get_color_model(
|
||||||
|
struct _cef_print_settings_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return COLOR_MODEL_UNKNOWN;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
cef_color_model_t _retval = CefPrintSettingsCppToC::Get(self)->GetColorModel(
|
||||||
|
);
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEF_CALLBACK print_settings_set_copies(struct _cef_print_settings_t* self,
|
||||||
|
int copies) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefPrintSettingsCppToC::Get(self)->SetCopies(
|
||||||
|
copies);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CEF_CALLBACK print_settings_get_copies(struct _cef_print_settings_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int _retval = CefPrintSettingsCppToC::Get(self)->GetCopies();
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEF_CALLBACK print_settings_set_duplex_mode(
|
||||||
|
struct _cef_print_settings_t* self, cef_duplex_mode_t mode) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefPrintSettingsCppToC::Get(self)->SetDuplexMode(
|
||||||
|
mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
cef_duplex_mode_t CEF_CALLBACK print_settings_get_duplex_mode(
|
||||||
|
struct _cef_print_settings_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return DUPLEX_MODE_UNKNOWN;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
cef_duplex_mode_t _retval = CefPrintSettingsCppToC::Get(self)->GetDuplexMode(
|
||||||
|
);
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// CONSTRUCTOR - Do not edit by hand.
|
||||||
|
|
||||||
|
CefPrintSettingsCppToC::CefPrintSettingsCppToC(CefPrintSettings* cls)
|
||||||
|
: CefCppToC<CefPrintSettingsCppToC, CefPrintSettings, cef_print_settings_t>(
|
||||||
|
cls) {
|
||||||
|
struct_.struct_.is_valid = print_settings_is_valid;
|
||||||
|
struct_.struct_.is_read_only = print_settings_is_read_only;
|
||||||
|
struct_.struct_.copy = print_settings_copy;
|
||||||
|
struct_.struct_.set_orientation = print_settings_set_orientation;
|
||||||
|
struct_.struct_.is_landscape = print_settings_is_landscape;
|
||||||
|
struct_.struct_.set_printer_printable_area =
|
||||||
|
print_settings_set_printer_printable_area;
|
||||||
|
struct_.struct_.set_device_name = print_settings_set_device_name;
|
||||||
|
struct_.struct_.get_device_name = print_settings_get_device_name;
|
||||||
|
struct_.struct_.set_dpi = print_settings_set_dpi;
|
||||||
|
struct_.struct_.get_dpi = print_settings_get_dpi;
|
||||||
|
struct_.struct_.set_page_ranges = print_settings_set_page_ranges;
|
||||||
|
struct_.struct_.get_page_ranges_count = print_settings_get_page_ranges_count;
|
||||||
|
struct_.struct_.get_page_ranges = print_settings_get_page_ranges;
|
||||||
|
struct_.struct_.set_selection_only = print_settings_set_selection_only;
|
||||||
|
struct_.struct_.is_selection_only = print_settings_is_selection_only;
|
||||||
|
struct_.struct_.set_collate = print_settings_set_collate;
|
||||||
|
struct_.struct_.will_collate = print_settings_will_collate;
|
||||||
|
struct_.struct_.set_color_model = print_settings_set_color_model;
|
||||||
|
struct_.struct_.get_color_model = print_settings_get_color_model;
|
||||||
|
struct_.struct_.set_copies = print_settings_set_copies;
|
||||||
|
struct_.struct_.get_copies = print_settings_get_copies;
|
||||||
|
struct_.struct_.set_duplex_mode = print_settings_set_duplex_mode;
|
||||||
|
struct_.struct_.get_duplex_mode = print_settings_get_duplex_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
template<> long CefCppToC<CefPrintSettingsCppToC, CefPrintSettings,
|
||||||
|
cef_print_settings_t>::DebugObjCt = 0;
|
||||||
|
#endif
|
||||||
|
|
37
libcef_dll/cpptoc/print_settings_cpptoc.h
Normal file
37
libcef_dll/cpptoc/print_settings_cpptoc.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool. If making changes by
|
||||||
|
// hand only 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_PRINT_SETTINGS_CPPTOC_H_
|
||||||
|
#define CEF_LIBCEF_DLL_CPPTOC_PRINT_SETTINGS_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_print_settings.h"
|
||||||
|
#include "include/capi/cef_print_settings_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 CefPrintSettingsCppToC
|
||||||
|
: public CefCppToC<CefPrintSettingsCppToC, CefPrintSettings,
|
||||||
|
cef_print_settings_t> {
|
||||||
|
public:
|
||||||
|
explicit CefPrintSettingsCppToC(CefPrintSettings* cls);
|
||||||
|
virtual ~CefPrintSettingsCppToC() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BUILDING_CEF_SHARED
|
||||||
|
#endif // CEF_LIBCEF_DLL_CPPTOC_PRINT_SETTINGS_CPPTOC_H_
|
||||||
|
|
@ -13,6 +13,7 @@
|
|||||||
#include "libcef_dll/cpptoc/command_line_cpptoc.h"
|
#include "libcef_dll/cpptoc/command_line_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/list_value_cpptoc.h"
|
#include "libcef_dll/cpptoc/list_value_cpptoc.h"
|
||||||
#include "libcef_dll/ctocpp/browser_process_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/browser_process_handler_ctocpp.h"
|
||||||
|
#include "libcef_dll/ctocpp/print_handler_ctocpp.h"
|
||||||
|
|
||||||
|
|
||||||
// VIRTUAL METHODS - Body may be edited by hand.
|
// VIRTUAL METHODS - Body may be edited by hand.
|
||||||
@ -61,6 +62,19 @@ void CefBrowserProcessHandlerCToCpp::OnRenderProcessThreadCreated(
|
|||||||
CefListValueCppToC::Wrap(extra_info));
|
CefListValueCppToC::Wrap(extra_info));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CefRefPtr<CefPrintHandler> CefBrowserProcessHandlerCToCpp::GetPrintHandler() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_print_handler))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
cef_print_handler_t* _retval = struct_->get_print_handler(struct_);
|
||||||
|
|
||||||
|
// Return type: refptr_same
|
||||||
|
return CefPrintHandlerCToCpp::Wrap(_retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
template<> long CefCToCpp<CefBrowserProcessHandlerCToCpp,
|
template<> long CefCToCpp<CefBrowserProcessHandlerCToCpp,
|
||||||
|
@ -39,6 +39,7 @@ class CefBrowserProcessHandlerCToCpp
|
|||||||
CefRefPtr<CefCommandLine> command_line) OVERRIDE;
|
CefRefPtr<CefCommandLine> command_line) OVERRIDE;
|
||||||
virtual void OnRenderProcessThreadCreated(
|
virtual void OnRenderProcessThreadCreated(
|
||||||
CefRefPtr<CefListValue> extra_info) OVERRIDE;
|
CefRefPtr<CefListValue> extra_info) OVERRIDE;
|
||||||
|
virtual CefRefPtr<CefPrintHandler> GetPrintHandler() OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BUILDING_CEF_SHARED
|
#endif // BUILDING_CEF_SHARED
|
||||||
|
51
libcef_dll/ctocpp/print_dialog_callback_ctocpp.cc
Normal file
51
libcef_dll/ctocpp/print_dialog_callback_ctocpp.cc
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool. If making changes by
|
||||||
|
// hand only 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/print_dialog_callback_ctocpp.h"
|
||||||
|
#include "libcef_dll/ctocpp/print_settings_ctocpp.h"
|
||||||
|
|
||||||
|
|
||||||
|
// VIRTUAL METHODS - Body may be edited by hand.
|
||||||
|
|
||||||
|
void CefPrintDialogCallbackCToCpp::Continue(
|
||||||
|
CefRefPtr<CefPrintSettings> settings) {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, cont))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Verify param: settings; type: refptr_same
|
||||||
|
DCHECK(settings.get());
|
||||||
|
if (!settings.get())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
struct_->cont(struct_,
|
||||||
|
CefPrintSettingsCToCpp::Unwrap(settings));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintDialogCallbackCToCpp::Cancel() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, cancel))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
struct_->cancel(struct_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
template<> long CefCToCpp<CefPrintDialogCallbackCToCpp, CefPrintDialogCallback,
|
||||||
|
cef_print_dialog_callback_t>::DebugObjCt = 0;
|
||||||
|
#endif
|
||||||
|
|
43
libcef_dll/ctocpp/print_dialog_callback_ctocpp.h
Normal file
43
libcef_dll/ctocpp/print_dialog_callback_ctocpp.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool. If making changes by
|
||||||
|
// hand only 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_PRINT_DIALOG_CALLBACK_CTOCPP_H_
|
||||||
|
#define CEF_LIBCEF_DLL_CTOCPP_PRINT_DIALOG_CALLBACK_CTOCPP_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef USING_CEF_SHARED
|
||||||
|
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||||
|
#else // USING_CEF_SHARED
|
||||||
|
|
||||||
|
#include "include/cef_print_handler.h"
|
||||||
|
#include "include/capi/cef_print_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 CefPrintDialogCallbackCToCpp
|
||||||
|
: public CefCToCpp<CefPrintDialogCallbackCToCpp, CefPrintDialogCallback,
|
||||||
|
cef_print_dialog_callback_t> {
|
||||||
|
public:
|
||||||
|
explicit CefPrintDialogCallbackCToCpp(cef_print_dialog_callback_t* str)
|
||||||
|
: CefCToCpp<CefPrintDialogCallbackCToCpp, CefPrintDialogCallback,
|
||||||
|
cef_print_dialog_callback_t>(str) {}
|
||||||
|
virtual ~CefPrintDialogCallbackCToCpp() {}
|
||||||
|
|
||||||
|
// CefPrintDialogCallback methods
|
||||||
|
virtual void Continue(CefRefPtr<CefPrintSettings> settings) OVERRIDE;
|
||||||
|
virtual void Cancel() OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // USING_CEF_SHARED
|
||||||
|
#endif // CEF_LIBCEF_DLL_CTOCPP_PRINT_DIALOG_CALLBACK_CTOCPP_H_
|
||||||
|
|
105
libcef_dll/ctocpp/print_handler_ctocpp.cc
Normal file
105
libcef_dll/ctocpp/print_handler_ctocpp.cc
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool. If making changes by
|
||||||
|
// hand only 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/print_dialog_callback_cpptoc.h"
|
||||||
|
#include "libcef_dll/cpptoc/print_job_callback_cpptoc.h"
|
||||||
|
#include "libcef_dll/cpptoc/print_settings_cpptoc.h"
|
||||||
|
#include "libcef_dll/ctocpp/print_handler_ctocpp.h"
|
||||||
|
|
||||||
|
|
||||||
|
// VIRTUAL METHODS - Body may be edited by hand.
|
||||||
|
|
||||||
|
void CefPrintHandlerCToCpp::OnPrintSettings(
|
||||||
|
CefRefPtr<CefPrintSettings> settings, bool get_defaults) {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, on_print_settings))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Verify param: settings; type: refptr_diff
|
||||||
|
DCHECK(settings.get());
|
||||||
|
if (!settings.get())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
struct_->on_print_settings(struct_,
|
||||||
|
CefPrintSettingsCppToC::Wrap(settings),
|
||||||
|
get_defaults);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefPrintHandlerCToCpp::OnPrintDialog(bool has_selection,
|
||||||
|
CefRefPtr<CefPrintDialogCallback> callback) {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, on_print_dialog))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Verify param: callback; type: refptr_diff
|
||||||
|
DCHECK(callback.get());
|
||||||
|
if (!callback.get())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int _retval = struct_->on_print_dialog(struct_,
|
||||||
|
has_selection,
|
||||||
|
CefPrintDialogCallbackCppToC::Wrap(callback));
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval?true:false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefPrintHandlerCToCpp::OnPrintJob(const CefString& document_name,
|
||||||
|
const CefString& pdf_file_path, CefRefPtr<CefPrintJobCallback> callback) {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, on_print_job))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Verify param: document_name; type: string_byref_const
|
||||||
|
DCHECK(!document_name.empty());
|
||||||
|
if (document_name.empty())
|
||||||
|
return false;
|
||||||
|
// Verify param: pdf_file_path; type: string_byref_const
|
||||||
|
DCHECK(!pdf_file_path.empty());
|
||||||
|
if (pdf_file_path.empty())
|
||||||
|
return false;
|
||||||
|
// Verify param: callback; type: refptr_diff
|
||||||
|
DCHECK(callback.get());
|
||||||
|
if (!callback.get())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int _retval = struct_->on_print_job(struct_,
|
||||||
|
document_name.GetStruct(),
|
||||||
|
pdf_file_path.GetStruct(),
|
||||||
|
CefPrintJobCallbackCppToC::Wrap(callback));
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval?true:false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintHandlerCToCpp::OnPrintReset() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, on_print_reset))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
struct_->on_print_reset(struct_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
template<> long CefCToCpp<CefPrintHandlerCToCpp, CefPrintHandler,
|
||||||
|
cef_print_handler_t>::DebugObjCt = 0;
|
||||||
|
#endif
|
||||||
|
|
49
libcef_dll/ctocpp/print_handler_ctocpp.h
Normal file
49
libcef_dll/ctocpp/print_handler_ctocpp.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool. If making changes by
|
||||||
|
// hand only 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_PRINT_HANDLER_CTOCPP_H_
|
||||||
|
#define CEF_LIBCEF_DLL_CTOCPP_PRINT_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_print_handler.h"
|
||||||
|
#include "include/capi/cef_print_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 CefPrintHandlerCToCpp
|
||||||
|
: public CefCToCpp<CefPrintHandlerCToCpp, CefPrintHandler,
|
||||||
|
cef_print_handler_t> {
|
||||||
|
public:
|
||||||
|
explicit CefPrintHandlerCToCpp(cef_print_handler_t* str)
|
||||||
|
: CefCToCpp<CefPrintHandlerCToCpp, CefPrintHandler, cef_print_handler_t>(
|
||||||
|
str) {}
|
||||||
|
virtual ~CefPrintHandlerCToCpp() {}
|
||||||
|
|
||||||
|
// CefPrintHandler methods
|
||||||
|
virtual void OnPrintSettings(CefRefPtr<CefPrintSettings> settings,
|
||||||
|
bool get_defaults) OVERRIDE;
|
||||||
|
virtual bool OnPrintDialog(bool has_selection,
|
||||||
|
CefRefPtr<CefPrintDialogCallback> callback) OVERRIDE;
|
||||||
|
virtual bool OnPrintJob(const CefString& document_name,
|
||||||
|
const CefString& pdf_file_path,
|
||||||
|
CefRefPtr<CefPrintJobCallback> callback) OVERRIDE;
|
||||||
|
virtual void OnPrintReset() OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BUILDING_CEF_SHARED
|
||||||
|
#endif // CEF_LIBCEF_DLL_CTOCPP_PRINT_HANDLER_CTOCPP_H_
|
||||||
|
|
33
libcef_dll/ctocpp/print_job_callback_ctocpp.cc
Normal file
33
libcef_dll/ctocpp/print_job_callback_ctocpp.cc
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool. If making changes by
|
||||||
|
// hand only 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/print_job_callback_ctocpp.h"
|
||||||
|
|
||||||
|
|
||||||
|
// VIRTUAL METHODS - Body may be edited by hand.
|
||||||
|
|
||||||
|
void CefPrintJobCallbackCToCpp::Continue() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, cont))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
struct_->cont(struct_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
template<> long CefCToCpp<CefPrintJobCallbackCToCpp, CefPrintJobCallback,
|
||||||
|
cef_print_job_callback_t>::DebugObjCt = 0;
|
||||||
|
#endif
|
||||||
|
|
42
libcef_dll/ctocpp/print_job_callback_ctocpp.h
Normal file
42
libcef_dll/ctocpp/print_job_callback_ctocpp.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool. If making changes by
|
||||||
|
// hand only 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_PRINT_JOB_CALLBACK_CTOCPP_H_
|
||||||
|
#define CEF_LIBCEF_DLL_CTOCPP_PRINT_JOB_CALLBACK_CTOCPP_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef USING_CEF_SHARED
|
||||||
|
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||||
|
#else // USING_CEF_SHARED
|
||||||
|
|
||||||
|
#include "include/cef_print_handler.h"
|
||||||
|
#include "include/capi/cef_print_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 CefPrintJobCallbackCToCpp
|
||||||
|
: public CefCToCpp<CefPrintJobCallbackCToCpp, CefPrintJobCallback,
|
||||||
|
cef_print_job_callback_t> {
|
||||||
|
public:
|
||||||
|
explicit CefPrintJobCallbackCToCpp(cef_print_job_callback_t* str)
|
||||||
|
: CefCToCpp<CefPrintJobCallbackCToCpp, CefPrintJobCallback,
|
||||||
|
cef_print_job_callback_t>(str) {}
|
||||||
|
virtual ~CefPrintJobCallbackCToCpp() {}
|
||||||
|
|
||||||
|
// CefPrintJobCallback methods
|
||||||
|
virtual void Continue() OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // USING_CEF_SHARED
|
||||||
|
#endif // CEF_LIBCEF_DLL_CTOCPP_PRINT_JOB_CALLBACK_CTOCPP_H_
|
||||||
|
|
367
libcef_dll/ctocpp/print_settings_ctocpp.cc
Normal file
367
libcef_dll/ctocpp/print_settings_ctocpp.cc
Normal file
@ -0,0 +1,367 @@
|
|||||||
|
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool. If making changes by
|
||||||
|
// hand only 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 <algorithm>
|
||||||
|
#include "libcef_dll/ctocpp/print_settings_ctocpp.h"
|
||||||
|
|
||||||
|
|
||||||
|
// STATIC METHODS - Body may be edited by hand.
|
||||||
|
|
||||||
|
CefRefPtr<CefPrintSettings> CefPrintSettings::Create() {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
cef_print_settings_t* _retval = cef_print_settings_create();
|
||||||
|
|
||||||
|
// Return type: refptr_same
|
||||||
|
return CefPrintSettingsCToCpp::Wrap(_retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// VIRTUAL METHODS - Body may be edited by hand.
|
||||||
|
|
||||||
|
bool CefPrintSettingsCToCpp::IsValid() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, is_valid))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int _retval = struct_->is_valid(struct_);
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval?true:false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefPrintSettingsCToCpp::IsReadOnly() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, is_read_only))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int _retval = struct_->is_read_only(struct_);
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval?true:false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefRefPtr<CefPrintSettings> CefPrintSettingsCToCpp::Copy() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, copy))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
cef_print_settings_t* _retval = struct_->copy(struct_);
|
||||||
|
|
||||||
|
// Return type: refptr_same
|
||||||
|
return CefPrintSettingsCToCpp::Wrap(_retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintSettingsCToCpp::SetOrientation(bool landscape) {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, set_orientation))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
struct_->set_orientation(struct_,
|
||||||
|
landscape);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefPrintSettingsCToCpp::IsLandscape() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, is_landscape))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int _retval = struct_->is_landscape(struct_);
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval?true:false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintSettingsCToCpp::SetPrinterPrintableArea(
|
||||||
|
const CefSize& physical_size_device_units,
|
||||||
|
const CefRect& printable_area_device_units, bool landscape_needs_flip) {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, set_printer_printable_area))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
struct_->set_printer_printable_area(struct_,
|
||||||
|
&physical_size_device_units,
|
||||||
|
&printable_area_device_units,
|
||||||
|
landscape_needs_flip);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintSettingsCToCpp::SetDeviceName(const CefString& name) {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, set_device_name))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Unverified params: name
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
struct_->set_device_name(struct_,
|
||||||
|
name.GetStruct());
|
||||||
|
}
|
||||||
|
|
||||||
|
CefString CefPrintSettingsCToCpp::GetDeviceName() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_device_name))
|
||||||
|
return CefString();
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
cef_string_userfree_t _retval = struct_->get_device_name(struct_);
|
||||||
|
|
||||||
|
// Return type: string
|
||||||
|
CefString _retvalStr;
|
||||||
|
_retvalStr.AttachToUserFree(_retval);
|
||||||
|
return _retvalStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintSettingsCToCpp::SetDPI(int dpi) {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, set_dpi))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
struct_->set_dpi(struct_,
|
||||||
|
dpi);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CefPrintSettingsCToCpp::GetDPI() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_dpi))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int _retval = struct_->get_dpi(struct_);
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintSettingsCToCpp::SetPageRanges(const PageRangeList& ranges) {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, set_page_ranges))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Translate param: ranges; type: simple_vec_byref_const
|
||||||
|
const size_t rangesCount = ranges.size();
|
||||||
|
cef_page_range_t* rangesList = NULL;
|
||||||
|
if (rangesCount > 0) {
|
||||||
|
rangesList = new cef_page_range_t[rangesCount];
|
||||||
|
DCHECK(rangesList);
|
||||||
|
if (rangesList) {
|
||||||
|
for (size_t i = 0; i < rangesCount; ++i) {
|
||||||
|
rangesList[i] = ranges[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
struct_->set_page_ranges(struct_,
|
||||||
|
rangesCount,
|
||||||
|
rangesList);
|
||||||
|
|
||||||
|
// Restore param:ranges; type: simple_vec_byref_const
|
||||||
|
if (rangesList)
|
||||||
|
delete [] rangesList;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t CefPrintSettingsCToCpp::GetPageRangesCount() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_page_ranges_count))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
size_t _retval = struct_->get_page_ranges_count(struct_);
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintSettingsCToCpp::GetPageRanges(PageRangeList& ranges) {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_page_ranges))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Translate param: ranges; type: simple_vec_byref
|
||||||
|
size_t rangesSize = ranges.size();
|
||||||
|
size_t rangesCount = std::max(GetPageRangesCount(), rangesSize);
|
||||||
|
cef_page_range_t* rangesList = NULL;
|
||||||
|
if (rangesCount > 0) {
|
||||||
|
rangesList = new cef_page_range_t[rangesCount];
|
||||||
|
DCHECK(rangesList);
|
||||||
|
if (rangesList) {
|
||||||
|
memset(rangesList, 0, sizeof(cef_page_range_t)*rangesCount);
|
||||||
|
}
|
||||||
|
if (rangesList && rangesSize > 0) {
|
||||||
|
for (size_t i = 0; i < rangesSize; ++i) {
|
||||||
|
rangesList[i] = ranges[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
struct_->get_page_ranges(struct_,
|
||||||
|
&rangesCount,
|
||||||
|
rangesList);
|
||||||
|
|
||||||
|
// Restore param:ranges; type: simple_vec_byref
|
||||||
|
ranges.clear();
|
||||||
|
if (rangesCount > 0 && rangesList) {
|
||||||
|
for (size_t i = 0; i < rangesCount; ++i) {
|
||||||
|
ranges.push_back(rangesList[i]);
|
||||||
|
}
|
||||||
|
delete [] rangesList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintSettingsCToCpp::SetSelectionOnly(bool selection_only) {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, set_selection_only))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
struct_->set_selection_only(struct_,
|
||||||
|
selection_only);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefPrintSettingsCToCpp::IsSelectionOnly() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, is_selection_only))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int _retval = struct_->is_selection_only(struct_);
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval?true:false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintSettingsCToCpp::SetCollate(bool collate) {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, set_collate))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
struct_->set_collate(struct_,
|
||||||
|
collate);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefPrintSettingsCToCpp::WillCollate() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, will_collate))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int _retval = struct_->will_collate(struct_);
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval?true:false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintSettingsCToCpp::SetColorModel(ColorModel model) {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, set_color_model))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
struct_->set_color_model(struct_,
|
||||||
|
model);
|
||||||
|
}
|
||||||
|
|
||||||
|
CefPrintSettings::ColorModel CefPrintSettingsCToCpp::GetColorModel() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_color_model))
|
||||||
|
return COLOR_MODEL_UNKNOWN;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
cef_color_model_t _retval = struct_->get_color_model(struct_);
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintSettingsCToCpp::SetCopies(int copies) {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, set_copies))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
struct_->set_copies(struct_,
|
||||||
|
copies);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CefPrintSettingsCToCpp::GetCopies() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_copies))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int _retval = struct_->get_copies(struct_);
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefPrintSettingsCToCpp::SetDuplexMode(DuplexMode mode) {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, set_duplex_mode))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
struct_->set_duplex_mode(struct_,
|
||||||
|
mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
CefPrintSettings::DuplexMode CefPrintSettingsCToCpp::GetDuplexMode() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_duplex_mode))
|
||||||
|
return DUPLEX_MODE_UNKNOWN;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
cef_duplex_mode_t _retval = struct_->get_duplex_mode(struct_);
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
template<> long CefCToCpp<CefPrintSettingsCToCpp, CefPrintSettings,
|
||||||
|
cef_print_settings_t>::DebugObjCt = 0;
|
||||||
|
#endif
|
||||||
|
|
67
libcef_dll/ctocpp/print_settings_ctocpp.h
Normal file
67
libcef_dll/ctocpp/print_settings_ctocpp.h
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool. If making changes by
|
||||||
|
// hand only 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_PRINT_SETTINGS_CTOCPP_H_
|
||||||
|
#define CEF_LIBCEF_DLL_CTOCPP_PRINT_SETTINGS_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_print_settings.h"
|
||||||
|
#include "include/capi/cef_print_settings_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 CefPrintSettingsCToCpp
|
||||||
|
: public CefCToCpp<CefPrintSettingsCToCpp, CefPrintSettings,
|
||||||
|
cef_print_settings_t> {
|
||||||
|
public:
|
||||||
|
explicit CefPrintSettingsCToCpp(cef_print_settings_t* str)
|
||||||
|
: CefCToCpp<CefPrintSettingsCToCpp, CefPrintSettings,
|
||||||
|
cef_print_settings_t>(str) {}
|
||||||
|
virtual ~CefPrintSettingsCToCpp() {}
|
||||||
|
|
||||||
|
// CefPrintSettings methods
|
||||||
|
virtual bool IsValid() OVERRIDE;
|
||||||
|
virtual bool IsReadOnly() OVERRIDE;
|
||||||
|
virtual CefRefPtr<CefPrintSettings> Copy() OVERRIDE;
|
||||||
|
virtual void SetOrientation(bool landscape) OVERRIDE;
|
||||||
|
virtual bool IsLandscape() OVERRIDE;
|
||||||
|
virtual void SetPrinterPrintableArea(
|
||||||
|
const CefSize& physical_size_device_units,
|
||||||
|
const CefRect& printable_area_device_units,
|
||||||
|
bool landscape_needs_flip) OVERRIDE;
|
||||||
|
virtual void SetDeviceName(const CefString& name) OVERRIDE;
|
||||||
|
virtual CefString GetDeviceName() OVERRIDE;
|
||||||
|
virtual void SetDPI(int dpi) OVERRIDE;
|
||||||
|
virtual int GetDPI() OVERRIDE;
|
||||||
|
virtual void SetPageRanges(const PageRangeList& ranges) OVERRIDE;
|
||||||
|
virtual size_t GetPageRangesCount() OVERRIDE;
|
||||||
|
virtual void GetPageRanges(PageRangeList& ranges) OVERRIDE;
|
||||||
|
virtual void SetSelectionOnly(bool selection_only) OVERRIDE;
|
||||||
|
virtual bool IsSelectionOnly() OVERRIDE;
|
||||||
|
virtual void SetCollate(bool collate) OVERRIDE;
|
||||||
|
virtual bool WillCollate() OVERRIDE;
|
||||||
|
virtual void SetColorModel(ColorModel model) OVERRIDE;
|
||||||
|
virtual ColorModel GetColorModel() OVERRIDE;
|
||||||
|
virtual void SetCopies(int copies) OVERRIDE;
|
||||||
|
virtual int GetCopies() OVERRIDE;
|
||||||
|
virtual void SetDuplexMode(DuplexMode mode) OVERRIDE;
|
||||||
|
virtual DuplexMode GetDuplexMode() OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // USING_CEF_SHARED
|
||||||
|
#endif // CEF_LIBCEF_DLL_CTOCPP_PRINT_SETTINGS_CTOCPP_H_
|
||||||
|
|
@ -54,6 +54,9 @@
|
|||||||
#include "libcef_dll/cpptoc/jsdialog_callback_cpptoc.h"
|
#include "libcef_dll/cpptoc/jsdialog_callback_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/list_value_cpptoc.h"
|
#include "libcef_dll/cpptoc/list_value_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/menu_model_cpptoc.h"
|
#include "libcef_dll/cpptoc/menu_model_cpptoc.h"
|
||||||
|
#include "libcef_dll/cpptoc/print_dialog_callback_cpptoc.h"
|
||||||
|
#include "libcef_dll/cpptoc/print_job_callback_cpptoc.h"
|
||||||
|
#include "libcef_dll/cpptoc/print_settings_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/process_message_cpptoc.h"
|
#include "libcef_dll/cpptoc/process_message_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/quota_callback_cpptoc.h"
|
#include "libcef_dll/cpptoc/quota_callback_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/scheme_registrar_cpptoc.h"
|
#include "libcef_dll/cpptoc/scheme_registrar_cpptoc.h"
|
||||||
@ -88,6 +91,7 @@
|
|||||||
#include "libcef_dll/ctocpp/keyboard_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/keyboard_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/life_span_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/life_span_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/load_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/load_handler_ctocpp.h"
|
||||||
|
#include "libcef_dll/ctocpp/print_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/read_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/read_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/render_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/render_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/render_process_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/render_process_handler_ctocpp.h"
|
||||||
@ -216,6 +220,10 @@ CEF_EXPORT void cef_shutdown() {
|
|||||||
DCHECK_EQ(CefListValueCppToC::DebugObjCt, 0);
|
DCHECK_EQ(CefListValueCppToC::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefLoadHandlerCToCpp::DebugObjCt, 0);
|
DCHECK_EQ(CefLoadHandlerCToCpp::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefMenuModelCppToC::DebugObjCt, 0);
|
DCHECK_EQ(CefMenuModelCppToC::DebugObjCt, 0);
|
||||||
|
DCHECK_EQ(CefPrintDialogCallbackCppToC::DebugObjCt, 0);
|
||||||
|
DCHECK_EQ(CefPrintHandlerCToCpp::DebugObjCt, 0);
|
||||||
|
DCHECK_EQ(CefPrintJobCallbackCppToC::DebugObjCt, 0);
|
||||||
|
DCHECK_EQ(CefPrintSettingsCppToC::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefProcessMessageCppToC::DebugObjCt, 0);
|
DCHECK_EQ(CefProcessMessageCppToC::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefQuotaCallbackCppToC::DebugObjCt, 0);
|
DCHECK_EQ(CefQuotaCallbackCppToC::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefReadHandlerCToCpp::DebugObjCt, 0);
|
DCHECK_EQ(CefReadHandlerCToCpp::DebugObjCt, 0);
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
#include "libcef_dll/cpptoc/keyboard_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/keyboard_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/life_span_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/life_span_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/load_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/load_handler_cpptoc.h"
|
||||||
|
#include "libcef_dll/cpptoc/print_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/read_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/read_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/render_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/render_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/render_process_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/render_process_handler_cpptoc.h"
|
||||||
@ -90,6 +91,9 @@
|
|||||||
#include "libcef_dll/ctocpp/jsdialog_callback_ctocpp.h"
|
#include "libcef_dll/ctocpp/jsdialog_callback_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/list_value_ctocpp.h"
|
#include "libcef_dll/ctocpp/list_value_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/menu_model_ctocpp.h"
|
#include "libcef_dll/ctocpp/menu_model_ctocpp.h"
|
||||||
|
#include "libcef_dll/ctocpp/print_dialog_callback_ctocpp.h"
|
||||||
|
#include "libcef_dll/ctocpp/print_job_callback_ctocpp.h"
|
||||||
|
#include "libcef_dll/ctocpp/print_settings_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/process_message_ctocpp.h"
|
#include "libcef_dll/ctocpp/process_message_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/quota_callback_ctocpp.h"
|
#include "libcef_dll/ctocpp/quota_callback_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/scheme_registrar_ctocpp.h"
|
#include "libcef_dll/ctocpp/scheme_registrar_ctocpp.h"
|
||||||
@ -208,6 +212,10 @@ CEF_GLOBAL void CefShutdown() {
|
|||||||
DCHECK_EQ(CefListValueCToCpp::DebugObjCt, 0);
|
DCHECK_EQ(CefListValueCToCpp::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefLoadHandlerCppToC::DebugObjCt, 0);
|
DCHECK_EQ(CefLoadHandlerCppToC::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefMenuModelCToCpp::DebugObjCt, 0);
|
DCHECK_EQ(CefMenuModelCToCpp::DebugObjCt, 0);
|
||||||
|
DCHECK_EQ(CefPrintDialogCallbackCToCpp::DebugObjCt, 0);
|
||||||
|
DCHECK_EQ(CefPrintHandlerCppToC::DebugObjCt, 0);
|
||||||
|
DCHECK_EQ(CefPrintJobCallbackCToCpp::DebugObjCt, 0);
|
||||||
|
DCHECK_EQ(CefPrintSettingsCToCpp::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefProcessMessageCToCpp::DebugObjCt, 0);
|
DCHECK_EQ(CefProcessMessageCToCpp::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefQuotaCallbackCToCpp::DebugObjCt, 0);
|
DCHECK_EQ(CefQuotaCallbackCToCpp::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefReadHandlerCppToC::DebugObjCt, 0);
|
DCHECK_EQ(CefReadHandlerCppToC::DebugObjCt, 0);
|
||||||
|
@ -34,6 +34,8 @@ void ClientApp::OnContextInitialized() {
|
|||||||
ASSERT(manager.get());
|
ASSERT(manager.get());
|
||||||
manager->SetSupportedSchemes(cookieable_schemes_);
|
manager->SetSupportedSchemes(cookieable_schemes_);
|
||||||
|
|
||||||
|
print_handler_ = CreatePrintHandler();
|
||||||
|
|
||||||
BrowserDelegateSet::iterator it = browser_delegates_.begin();
|
BrowserDelegateSet::iterator it = browser_delegates_.begin();
|
||||||
for (; it != browser_delegates_.end(); ++it)
|
for (; it != browser_delegates_.end(); ++it)
|
||||||
(*it)->OnContextInitialized(this);
|
(*it)->OnContextInitialized(this);
|
||||||
|
@ -116,6 +116,9 @@ class ClientApp : public CefApp,
|
|||||||
static void RegisterCustomSchemes(CefRefPtr<CefSchemeRegistrar> registrar,
|
static void RegisterCustomSchemes(CefRefPtr<CefSchemeRegistrar> registrar,
|
||||||
std::vector<CefString>& cookiable_schemes);
|
std::vector<CefString>& cookiable_schemes);
|
||||||
|
|
||||||
|
// Create the Linux print handler. Implemented in client_app_delegates.
|
||||||
|
static CefRefPtr<CefPrintHandler> CreatePrintHandler();
|
||||||
|
|
||||||
// CefApp methods.
|
// CefApp methods.
|
||||||
virtual void OnRegisterCustomSchemes(
|
virtual void OnRegisterCustomSchemes(
|
||||||
CefRefPtr<CefSchemeRegistrar> registrar) OVERRIDE;
|
CefRefPtr<CefSchemeRegistrar> registrar) OVERRIDE;
|
||||||
@ -130,6 +133,9 @@ class ClientApp : public CefApp,
|
|||||||
CefRefPtr<CefCommandLine> command_line) OVERRIDE;
|
CefRefPtr<CefCommandLine> command_line) OVERRIDE;
|
||||||
virtual void OnRenderProcessThreadCreated(CefRefPtr<CefListValue> extra_info)
|
virtual void OnRenderProcessThreadCreated(CefRefPtr<CefListValue> extra_info)
|
||||||
OVERRIDE;
|
OVERRIDE;
|
||||||
|
virtual CefRefPtr<CefPrintHandler> GetPrintHandler() OVERRIDE {
|
||||||
|
return print_handler_;
|
||||||
|
}
|
||||||
|
|
||||||
// CefRenderProcessHandler methods.
|
// CefRenderProcessHandler methods.
|
||||||
virtual void OnRenderThreadCreated(CefRefPtr<CefListValue> extra_info)
|
virtual void OnRenderThreadCreated(CefRefPtr<CefListValue> extra_info)
|
||||||
@ -173,6 +179,8 @@ class ClientApp : public CefApp,
|
|||||||
// both the browser and renderer process.
|
// both the browser and renderer process.
|
||||||
std::vector<CefString> cookieable_schemes_;
|
std::vector<CefString> cookieable_schemes_;
|
||||||
|
|
||||||
|
CefRefPtr<CefPrintHandler> print_handler_;
|
||||||
|
|
||||||
IMPLEMENT_REFCOUNTING(ClientApp);
|
IMPLEMENT_REFCOUNTING(ClientApp);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -8,6 +8,10 @@
|
|||||||
#include "cefclient/performance_test.h"
|
#include "cefclient/performance_test.h"
|
||||||
#include "cefclient/scheme_test.h"
|
#include "cefclient/scheme_test.h"
|
||||||
|
|
||||||
|
#if defined(OS_LINUX)
|
||||||
|
#include "cefclient/print_handler_gtk.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void ClientApp::CreateBrowserDelegates(BrowserDelegateSet& delegates) {
|
void ClientApp::CreateBrowserDelegates(BrowserDelegateSet& delegates) {
|
||||||
}
|
}
|
||||||
@ -25,3 +29,13 @@ void ClientApp::RegisterCustomSchemes(
|
|||||||
std::vector<CefString>& cookiable_schemes) {
|
std::vector<CefString>& cookiable_schemes) {
|
||||||
scheme_test::RegisterCustomSchemes(registrar, cookiable_schemes);
|
scheme_test::RegisterCustomSchemes(registrar, cookiable_schemes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
CefRefPtr<CefPrintHandler> ClientApp::CreatePrintHandler() {
|
||||||
|
#if defined(OS_LINUX)
|
||||||
|
return new ClientPrintHandlerGtk();
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
522
tests/cefclient/print_handler_gtk.cpp
Normal file
522
tests/cefclient/print_handler_gtk.cpp
Normal file
@ -0,0 +1,522 @@
|
|||||||
|
// Copyright (c) 2014 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 "cefclient/print_handler_gtk.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "cefclient/util.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
// CUPS Duplex attribute and values.
|
||||||
|
const char kCUPSDuplex[] = "cups-Duplex";
|
||||||
|
const char kDuplexNone[] = "None";
|
||||||
|
const char kDuplexTumble[] = "DuplexTumble";
|
||||||
|
const char kDuplexNoTumble[] = "DuplexNoTumble";
|
||||||
|
|
||||||
|
// CUPS color mode attribute and values.
|
||||||
|
const char kCUPSColorMode[] = "cups-ColorMode";
|
||||||
|
const char kCUPSColorModel[] = "cups-ColorModel";
|
||||||
|
const char kCUPSPrintoutMode[] = "cups-PrintoutMode";
|
||||||
|
const char kCUPSProcessColorModel[] = "cups-ProcessColorModel";
|
||||||
|
const char kBlack[] = "Black";
|
||||||
|
const char kCMYK[] = "CMYK";
|
||||||
|
const char kKCMY[] = "KCMY";
|
||||||
|
const char kCMY_K[] = "CMY+K";
|
||||||
|
const char kCMY[] = "CMY";
|
||||||
|
const char kColor[] = "Color";
|
||||||
|
const char kGray[] = "Gray";
|
||||||
|
const char kGrayscale[] = "Grayscale";
|
||||||
|
const char kGreyscale[] = "Greyscale";
|
||||||
|
const char kMonochrome[] = "Monochrome";
|
||||||
|
const char kNormal[] = "Normal";
|
||||||
|
const char kNormalGray[] = "Normal.Gray";
|
||||||
|
const char kRGB[] = "RGB";
|
||||||
|
const char kRGBA[] = "RGBA";
|
||||||
|
const char kRGB16[] = "RGB16";
|
||||||
|
|
||||||
|
// Default margin settings.
|
||||||
|
const double kTopMarginInInch = 0.25;
|
||||||
|
const double kBottomMarginInInch = 0.56;
|
||||||
|
const double kLeftMarginInInch = 0.25;
|
||||||
|
const double kRightMarginInInch = 0.25;
|
||||||
|
|
||||||
|
// Length of an inch in CSS's 1px unit.
|
||||||
|
// http://dev.w3.org/csswg/css3-values/#the-px-unit
|
||||||
|
const int kPixelsPerInch = 96;
|
||||||
|
|
||||||
|
// LETTER: 8.5 x 11 inches
|
||||||
|
const float kLetterWidthInch = 8.5f;
|
||||||
|
const float kLetterHeightInch = 11.0f;
|
||||||
|
|
||||||
|
class StickyPrintSettingGtk {
|
||||||
|
public:
|
||||||
|
StickyPrintSettingGtk() : last_used_settings_(gtk_print_settings_new()) {
|
||||||
|
}
|
||||||
|
~StickyPrintSettingGtk() {
|
||||||
|
ASSERT(false); // Not reached; the instance is leaked.
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkPrintSettings* settings() {
|
||||||
|
return last_used_settings_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetLastUsedSettings(GtkPrintSettings* settings) {
|
||||||
|
ASSERT(last_used_settings_);
|
||||||
|
g_object_unref(last_used_settings_);
|
||||||
|
last_used_settings_ = gtk_print_settings_copy(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
GtkPrintSettings* last_used_settings_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(StickyPrintSettingGtk);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Lazily initialize the singleton instance.
|
||||||
|
StickyPrintSettingGtk* GetLastUsedSettings() {
|
||||||
|
static StickyPrintSettingGtk* settings = NULL;
|
||||||
|
if (!settings)
|
||||||
|
settings = new StickyPrintSettingGtk();
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper class to track GTK printers.
|
||||||
|
class GtkPrinterList {
|
||||||
|
public:
|
||||||
|
GtkPrinterList() : default_printer_(NULL) {
|
||||||
|
gtk_enumerate_printers(SetPrinter, this, NULL, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
~GtkPrinterList() {
|
||||||
|
for (std::vector<GtkPrinter*>::iterator it = printers_.begin();
|
||||||
|
it < printers_.end(); ++it) {
|
||||||
|
g_object_unref(*it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Can return NULL if there's no default printer. E.g. Printer on a laptop
|
||||||
|
// is "home_printer", but the laptop is at work.
|
||||||
|
GtkPrinter* default_printer() {
|
||||||
|
return default_printer_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Can return NULL if the printer cannot be found due to:
|
||||||
|
// - Printer list out of sync with printer dialog UI.
|
||||||
|
// - Querying for non-existant printers like 'Print to PDF'.
|
||||||
|
GtkPrinter* GetPrinterWithName(const std::string& name) {
|
||||||
|
if (name.empty())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (std::vector<GtkPrinter*>::iterator it = printers_.begin();
|
||||||
|
it < printers_.end(); ++it) {
|
||||||
|
if (gtk_printer_get_name(*it) == name) {
|
||||||
|
return *it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Callback function used by gtk_enumerate_printers() to get all printer.
|
||||||
|
static gboolean SetPrinter(GtkPrinter* printer, gpointer data) {
|
||||||
|
GtkPrinterList* printer_list = reinterpret_cast<GtkPrinterList*>(data);
|
||||||
|
if (gtk_printer_is_default(printer))
|
||||||
|
printer_list->default_printer_ = printer;
|
||||||
|
|
||||||
|
g_object_ref(printer);
|
||||||
|
printer_list->printers_.push_back(printer);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<GtkPrinter*> printers_;
|
||||||
|
GtkPrinter* default_printer_;
|
||||||
|
};
|
||||||
|
|
||||||
|
void GetColorModelForMode(CefPrintSettings::ColorModel color_mode,
|
||||||
|
std::string* color_setting_name,
|
||||||
|
std::string* color_value) {
|
||||||
|
color_setting_name->assign(kCUPSColorModel);
|
||||||
|
switch (color_mode) {
|
||||||
|
case COLOR_MODEL_COLOR:
|
||||||
|
color_value->assign(kColor);
|
||||||
|
break;
|
||||||
|
case COLOR_MODEL_CMYK:
|
||||||
|
color_value->assign(kCMYK);
|
||||||
|
break;
|
||||||
|
case COLOR_MODEL_PRINTOUTMODE_NORMAL:
|
||||||
|
color_value->assign(kNormal);
|
||||||
|
color_setting_name->assign(kCUPSPrintoutMode);
|
||||||
|
break;
|
||||||
|
case COLOR_MODEL_PRINTOUTMODE_NORMAL_GRAY:
|
||||||
|
color_value->assign(kNormalGray);
|
||||||
|
color_setting_name->assign(kCUPSPrintoutMode);
|
||||||
|
break;
|
||||||
|
case COLOR_MODEL_RGB16:
|
||||||
|
color_value->assign(kRGB16);
|
||||||
|
break;
|
||||||
|
case COLOR_MODEL_RGBA:
|
||||||
|
color_value->assign(kRGBA);
|
||||||
|
break;
|
||||||
|
case COLOR_MODEL_RGB:
|
||||||
|
color_value->assign(kRGB);
|
||||||
|
break;
|
||||||
|
case COLOR_MODEL_CMY:
|
||||||
|
color_value->assign(kCMY);
|
||||||
|
break;
|
||||||
|
case COLOR_MODEL_CMY_K:
|
||||||
|
color_value->assign(kCMY_K);
|
||||||
|
break;
|
||||||
|
case COLOR_MODEL_BLACK:
|
||||||
|
color_value->assign(kBlack);
|
||||||
|
break;
|
||||||
|
case COLOR_MODEL_GRAY:
|
||||||
|
color_value->assign(kGray);
|
||||||
|
break;
|
||||||
|
case COLOR_MODEL_COLORMODE_COLOR:
|
||||||
|
color_setting_name->assign(kCUPSColorMode);
|
||||||
|
color_value->assign(kColor);
|
||||||
|
break;
|
||||||
|
case COLOR_MODEL_COLORMODE_MONOCHROME:
|
||||||
|
color_setting_name->assign(kCUPSColorMode);
|
||||||
|
color_value->assign(kMonochrome);
|
||||||
|
break;
|
||||||
|
case COLOR_MODEL_HP_COLOR_COLOR:
|
||||||
|
color_setting_name->assign(kColor);
|
||||||
|
color_value->assign(kColor);
|
||||||
|
break;
|
||||||
|
case COLOR_MODEL_HP_COLOR_BLACK:
|
||||||
|
color_setting_name->assign(kColor);
|
||||||
|
color_value->assign(kBlack);
|
||||||
|
break;
|
||||||
|
case COLOR_MODEL_PROCESSCOLORMODEL_CMYK:
|
||||||
|
color_setting_name->assign(kCUPSProcessColorModel);
|
||||||
|
color_value->assign(kCMYK);
|
||||||
|
break;
|
||||||
|
case COLOR_MODEL_PROCESSCOLORMODEL_GREYSCALE:
|
||||||
|
color_setting_name->assign(kCUPSProcessColorModel);
|
||||||
|
color_value->assign(kGreyscale);
|
||||||
|
break;
|
||||||
|
case COLOR_MODEL_PROCESSCOLORMODEL_RGB:
|
||||||
|
color_setting_name->assign(kCUPSProcessColorModel);
|
||||||
|
color_value->assign(kRGB);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
color_value->assign(kGrayscale);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitPrintSettings(GtkPrintSettings* settings,
|
||||||
|
GtkPageSetup* page_setup,
|
||||||
|
CefRefPtr<CefPrintSettings> print_settings) {
|
||||||
|
ASSERT(settings);
|
||||||
|
ASSERT(page_setup);
|
||||||
|
|
||||||
|
std::string device_name;
|
||||||
|
const gchar* name = gtk_print_settings_get_printer(settings);
|
||||||
|
if (name)
|
||||||
|
device_name = name;
|
||||||
|
print_settings->SetDeviceName(device_name);
|
||||||
|
|
||||||
|
CefSize physical_size_device_units;
|
||||||
|
CefRect printable_area_device_units;
|
||||||
|
int dpi = gtk_print_settings_get_resolution(settings);
|
||||||
|
if (dpi) {
|
||||||
|
// Initialize page_setup_device_units_.
|
||||||
|
physical_size_device_units.Set(
|
||||||
|
gtk_page_setup_get_paper_width(page_setup, GTK_UNIT_INCH) * dpi,
|
||||||
|
gtk_page_setup_get_paper_height(page_setup, GTK_UNIT_INCH) * dpi);
|
||||||
|
printable_area_device_units.Set(
|
||||||
|
gtk_page_setup_get_left_margin(page_setup, GTK_UNIT_INCH) * dpi,
|
||||||
|
gtk_page_setup_get_top_margin(page_setup, GTK_UNIT_INCH) * dpi,
|
||||||
|
gtk_page_setup_get_page_width(page_setup, GTK_UNIT_INCH) * dpi,
|
||||||
|
gtk_page_setup_get_page_height(page_setup, GTK_UNIT_INCH) * dpi);
|
||||||
|
} else {
|
||||||
|
// Use default values if we cannot get valid values from the print dialog.
|
||||||
|
dpi = kPixelsPerInch;
|
||||||
|
double page_width_in_pixel = kLetterWidthInch * dpi;
|
||||||
|
double page_height_in_pixel = kLetterHeightInch * dpi;
|
||||||
|
physical_size_device_units.Set(
|
||||||
|
static_cast<int>(page_width_in_pixel),
|
||||||
|
static_cast<int>(page_height_in_pixel));
|
||||||
|
printable_area_device_units.Set(
|
||||||
|
static_cast<int>(kLeftMarginInInch * dpi),
|
||||||
|
static_cast<int>(kTopMarginInInch * dpi),
|
||||||
|
page_width_in_pixel - (kLeftMarginInInch + kRightMarginInInch) * dpi,
|
||||||
|
page_height_in_pixel - (kTopMarginInInch + kBottomMarginInInch) * dpi);
|
||||||
|
}
|
||||||
|
|
||||||
|
print_settings->SetDPI(dpi);
|
||||||
|
|
||||||
|
// Note: With the normal GTK print dialog, when the user selects the landscape
|
||||||
|
// orientation, all that does is change the paper size. Which seems to be
|
||||||
|
// enough to render the right output and send it to the printer.
|
||||||
|
// The orientation value stays as portrait and does not actually affect
|
||||||
|
// printing.
|
||||||
|
// Thus this is only useful in print preview mode, where we manually set the
|
||||||
|
// orientation and change the paper size ourselves.
|
||||||
|
GtkPageOrientation orientation = gtk_print_settings_get_orientation(settings);
|
||||||
|
// Set before SetPrinterPrintableArea to make it flip area if necessary.
|
||||||
|
print_settings->SetOrientation(orientation == GTK_PAGE_ORIENTATION_LANDSCAPE);
|
||||||
|
print_settings->SetPrinterPrintableArea(physical_size_device_units,
|
||||||
|
printable_area_device_units,
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
|
ClientPrintHandlerGtk::ClientPrintHandlerGtk()
|
||||||
|
: dialog_(NULL),
|
||||||
|
gtk_settings_(NULL),
|
||||||
|
page_setup_(NULL),
|
||||||
|
printer_(NULL) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClientPrintHandlerGtk::OnPrintSettings(
|
||||||
|
CefRefPtr<CefPrintSettings> settings,
|
||||||
|
bool get_defaults) {
|
||||||
|
if (get_defaults) {
|
||||||
|
ASSERT(!page_setup_);
|
||||||
|
ASSERT(!printer_);
|
||||||
|
|
||||||
|
// |gtk_settings_| is a new copy.
|
||||||
|
gtk_settings_ =
|
||||||
|
gtk_print_settings_copy(GetLastUsedSettings()->settings());
|
||||||
|
page_setup_ = gtk_page_setup_new();
|
||||||
|
} else {
|
||||||
|
if (!gtk_settings_) {
|
||||||
|
gtk_settings_ =
|
||||||
|
gtk_print_settings_copy(GetLastUsedSettings()->settings());
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkPrinterList* printer_list = new GtkPrinterList;
|
||||||
|
printer_ = printer_list->GetPrinterWithName(settings->GetDeviceName());
|
||||||
|
if (printer_) {
|
||||||
|
g_object_ref(printer_);
|
||||||
|
gtk_print_settings_set_printer(gtk_settings_,
|
||||||
|
gtk_printer_get_name(printer_));
|
||||||
|
if (!page_setup_) {
|
||||||
|
page_setup_ = gtk_printer_get_default_page_size(printer_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_print_settings_set_n_copies(gtk_settings_, settings->GetCopies());
|
||||||
|
gtk_print_settings_set_collate(gtk_settings_, settings->WillCollate());
|
||||||
|
|
||||||
|
std::string color_value;
|
||||||
|
std::string color_setting_name;
|
||||||
|
GetColorModelForMode(settings->GetColorModel(), &color_setting_name,
|
||||||
|
&color_value);
|
||||||
|
gtk_print_settings_set(gtk_settings_, color_setting_name.c_str(),
|
||||||
|
color_value.c_str());
|
||||||
|
|
||||||
|
if (settings->GetDuplexMode() != DUPLEX_MODE_UNKNOWN) {
|
||||||
|
const char* cups_duplex_mode = NULL;
|
||||||
|
switch (settings->GetDuplexMode()) {
|
||||||
|
case DUPLEX_MODE_LONG_EDGE:
|
||||||
|
cups_duplex_mode = kDuplexNoTumble;
|
||||||
|
break;
|
||||||
|
case DUPLEX_MODE_SHORT_EDGE:
|
||||||
|
cups_duplex_mode = kDuplexTumble;
|
||||||
|
break;
|
||||||
|
case DUPLEX_MODE_SIMPLEX:
|
||||||
|
cups_duplex_mode = kDuplexNone;
|
||||||
|
break;
|
||||||
|
default: // UNKNOWN_DUPLEX_MODE
|
||||||
|
ASSERT(false); // Not reached
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
gtk_print_settings_set(gtk_settings_, kCUPSDuplex, cups_duplex_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!page_setup_)
|
||||||
|
page_setup_ = gtk_page_setup_new();
|
||||||
|
|
||||||
|
gtk_print_settings_set_orientation(
|
||||||
|
gtk_settings_,
|
||||||
|
settings->IsLandscape() ? GTK_PAGE_ORIENTATION_LANDSCAPE :
|
||||||
|
GTK_PAGE_ORIENTATION_PORTRAIT);
|
||||||
|
|
||||||
|
delete printer_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
InitPrintSettings(gtk_settings_, page_setup_, settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ClientPrintHandlerGtk::OnPrintDialog(
|
||||||
|
bool has_selection,
|
||||||
|
CefRefPtr<CefPrintDialogCallback> callback) {
|
||||||
|
dialog_callback_ = callback;
|
||||||
|
|
||||||
|
// TODO(cef): Identify the correct parent window.
|
||||||
|
GtkWindow* parent = NULL;
|
||||||
|
// TODO(estade): We need a window title here.
|
||||||
|
dialog_ = gtk_print_unix_dialog_new(NULL, parent);
|
||||||
|
g_signal_connect(dialog_, "delete-event",
|
||||||
|
G_CALLBACK(gtk_widget_hide_on_delete), NULL);
|
||||||
|
|
||||||
|
|
||||||
|
// Set modal so user cannot focus the same tab and press print again.
|
||||||
|
gtk_window_set_modal(GTK_WINDOW(dialog_), TRUE);
|
||||||
|
|
||||||
|
// Since we only generate PDF, only show printers that support PDF.
|
||||||
|
// TODO(thestig) Add more capabilities to support?
|
||||||
|
GtkPrintCapabilities cap = static_cast<GtkPrintCapabilities>(
|
||||||
|
GTK_PRINT_CAPABILITY_GENERATE_PDF |
|
||||||
|
GTK_PRINT_CAPABILITY_PAGE_SET |
|
||||||
|
GTK_PRINT_CAPABILITY_COPIES |
|
||||||
|
GTK_PRINT_CAPABILITY_COLLATE |
|
||||||
|
GTK_PRINT_CAPABILITY_REVERSE);
|
||||||
|
gtk_print_unix_dialog_set_manual_capabilities(GTK_PRINT_UNIX_DIALOG(dialog_),
|
||||||
|
cap);
|
||||||
|
gtk_print_unix_dialog_set_embed_page_setup(GTK_PRINT_UNIX_DIALOG(dialog_),
|
||||||
|
TRUE);
|
||||||
|
gtk_print_unix_dialog_set_support_selection(GTK_PRINT_UNIX_DIALOG(dialog_),
|
||||||
|
TRUE);
|
||||||
|
gtk_print_unix_dialog_set_has_selection(GTK_PRINT_UNIX_DIALOG(dialog_),
|
||||||
|
has_selection);
|
||||||
|
gtk_print_unix_dialog_set_settings(GTK_PRINT_UNIX_DIALOG(dialog_),
|
||||||
|
gtk_settings_);
|
||||||
|
g_signal_connect(dialog_, "response", G_CALLBACK(OnDialogResponseThunk),
|
||||||
|
this);
|
||||||
|
gtk_widget_show(dialog_);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ClientPrintHandlerGtk::OnPrintJob(
|
||||||
|
const CefString& document_name,
|
||||||
|
const CefString& pdf_file_path,
|
||||||
|
CefRefPtr<CefPrintJobCallback> callback) {
|
||||||
|
// If |printer_| is NULL then somehow the GTK printer list changed out under
|
||||||
|
// us. In which case, just bail out.
|
||||||
|
if (!printer_)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
job_callback_ = callback;
|
||||||
|
|
||||||
|
// Save the settings for next time.
|
||||||
|
GetLastUsedSettings()->SetLastUsedSettings(gtk_settings_);
|
||||||
|
|
||||||
|
GtkPrintJob* print_job = gtk_print_job_new(
|
||||||
|
document_name.ToString().c_str(),
|
||||||
|
printer_,
|
||||||
|
gtk_settings_,
|
||||||
|
page_setup_);
|
||||||
|
gtk_print_job_set_source_file(print_job,
|
||||||
|
pdf_file_path.ToString().c_str(),
|
||||||
|
NULL);
|
||||||
|
gtk_print_job_send(print_job, OnJobCompletedThunk, this, NULL);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClientPrintHandlerGtk::OnPrintReset() {
|
||||||
|
if (dialog_) {
|
||||||
|
gtk_widget_destroy(dialog_);
|
||||||
|
dialog_ = NULL;
|
||||||
|
}
|
||||||
|
if (gtk_settings_) {
|
||||||
|
g_object_unref(gtk_settings_);
|
||||||
|
gtk_settings_ = NULL;
|
||||||
|
}
|
||||||
|
if (page_setup_) {
|
||||||
|
g_object_unref(page_setup_);
|
||||||
|
page_setup_ = NULL;
|
||||||
|
}
|
||||||
|
if (printer_) {
|
||||||
|
g_object_unref(printer_);
|
||||||
|
printer_ = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClientPrintHandlerGtk::OnDialogResponse(GtkDialog *dialog,
|
||||||
|
gint response_id) {
|
||||||
|
int num_matched_handlers = g_signal_handlers_disconnect_by_func(
|
||||||
|
dialog_, reinterpret_cast<gpointer>(&OnDialogResponseThunk), this);
|
||||||
|
ASSERT(1 == num_matched_handlers);
|
||||||
|
|
||||||
|
gtk_widget_hide(dialog_);
|
||||||
|
|
||||||
|
switch (response_id) {
|
||||||
|
case GTK_RESPONSE_OK: {
|
||||||
|
if (gtk_settings_)
|
||||||
|
g_object_unref(gtk_settings_);
|
||||||
|
gtk_settings_ = gtk_print_unix_dialog_get_settings(
|
||||||
|
GTK_PRINT_UNIX_DIALOG(dialog_));
|
||||||
|
|
||||||
|
if (printer_)
|
||||||
|
g_object_unref(printer_);
|
||||||
|
printer_ = gtk_print_unix_dialog_get_selected_printer(
|
||||||
|
GTK_PRINT_UNIX_DIALOG(dialog_));
|
||||||
|
g_object_ref(printer_);
|
||||||
|
|
||||||
|
if (page_setup_)
|
||||||
|
g_object_unref(page_setup_);
|
||||||
|
page_setup_ = gtk_print_unix_dialog_get_page_setup(
|
||||||
|
GTK_PRINT_UNIX_DIALOG(dialog_));
|
||||||
|
g_object_ref(page_setup_);
|
||||||
|
|
||||||
|
// Handle page ranges.
|
||||||
|
CefPrintSettings::PageRangeList ranges_vector;
|
||||||
|
gint num_ranges;
|
||||||
|
bool print_selection_only = false;
|
||||||
|
switch (gtk_print_settings_get_print_pages(gtk_settings_)) {
|
||||||
|
case GTK_PRINT_PAGES_RANGES: {
|
||||||
|
GtkPageRange* gtk_range =
|
||||||
|
gtk_print_settings_get_page_ranges(gtk_settings_, &num_ranges);
|
||||||
|
if (gtk_range) {
|
||||||
|
for (int i = 0; i < num_ranges; ++i) {
|
||||||
|
ranges_vector.push_back(
|
||||||
|
CefPageRange(gtk_range[i].start, gtk_range[i].end));
|
||||||
|
}
|
||||||
|
g_free(gtk_range);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GTK_PRINT_PAGES_SELECTION:
|
||||||
|
print_selection_only = true;
|
||||||
|
break;
|
||||||
|
case GTK_PRINT_PAGES_ALL:
|
||||||
|
// Leave |ranges_vector| empty to indicate print all pages.
|
||||||
|
break;
|
||||||
|
case GTK_PRINT_PAGES_CURRENT:
|
||||||
|
default:
|
||||||
|
ASSERT(false); // Not reached.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefRefPtr<CefPrintSettings> settings = CefPrintSettings::Create();
|
||||||
|
settings->SetPageRanges(ranges_vector);
|
||||||
|
settings->SetSelectionOnly(print_selection_only);
|
||||||
|
InitPrintSettings(gtk_settings_, page_setup_, settings);
|
||||||
|
dialog_callback_->Continue(settings);
|
||||||
|
dialog_callback_ = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case GTK_RESPONSE_DELETE_EVENT: // Fall through.
|
||||||
|
case GTK_RESPONSE_CANCEL: {
|
||||||
|
dialog_callback_->Cancel();
|
||||||
|
dialog_callback_ = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case GTK_RESPONSE_APPLY:
|
||||||
|
default: {
|
||||||
|
ASSERT(false); // Not reached.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClientPrintHandlerGtk::OnJobCompleted(GtkPrintJob* print_job,
|
||||||
|
GError* error) {
|
||||||
|
job_callback_->Continue();
|
||||||
|
job_callback_ = NULL;
|
||||||
|
}
|
||||||
|
|
62
tests/cefclient/print_handler_gtk.h
Normal file
62
tests/cefclient/print_handler_gtk.h
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
// Copyright (c) 2014 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_TESTS_CEFCLIENT_PRINT_HANDLER_GTK_H_
|
||||||
|
#define CEF_TESTS_CEFCLIENT_PRINT_HANDLER_GTK_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
#include <gtk/gtkunixprint.h>
|
||||||
|
|
||||||
|
#include "include/cef_print_handler.h"
|
||||||
|
|
||||||
|
class ClientPrintHandlerGtk : public CefPrintHandler {
|
||||||
|
public:
|
||||||
|
ClientPrintHandlerGtk();
|
||||||
|
|
||||||
|
// CefPrintHandler methods
|
||||||
|
virtual void OnPrintSettings(CefRefPtr<CefPrintSettings> settings,
|
||||||
|
bool get_defaults) OVERRIDE;
|
||||||
|
virtual bool OnPrintDialog(
|
||||||
|
bool has_selection,
|
||||||
|
CefRefPtr<CefPrintDialogCallback> callback) OVERRIDE;
|
||||||
|
virtual bool OnPrintJob(const CefString& document_name,
|
||||||
|
const CefString& pdf_file_path,
|
||||||
|
CefRefPtr<CefPrintJobCallback> callback) OVERRIDE;
|
||||||
|
virtual void OnPrintReset() OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void OnDialogResponse(GtkDialog *dialog,
|
||||||
|
gint response_id);
|
||||||
|
void OnJobCompleted(GtkPrintJob* print_job,
|
||||||
|
GError* error);
|
||||||
|
|
||||||
|
static void OnDialogResponseThunk(GtkDialog *dialog,
|
||||||
|
gint response_id,
|
||||||
|
ClientPrintHandlerGtk* handler) {
|
||||||
|
handler->OnDialogResponse(dialog, response_id);
|
||||||
|
}
|
||||||
|
static void OnJobCompletedThunk(GtkPrintJob* print_job,
|
||||||
|
void* handler,
|
||||||
|
GError* error) {
|
||||||
|
static_cast<ClientPrintHandlerGtk*>(handler)->
|
||||||
|
OnJobCompleted(print_job, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print dialog settings. ClientPrintHandlerGtk owns |dialog_| and holds
|
||||||
|
// references to the other objects.
|
||||||
|
GtkWidget* dialog_;
|
||||||
|
GtkPrintSettings* gtk_settings_;
|
||||||
|
GtkPageSetup* page_setup_;
|
||||||
|
GtkPrinter* printer_;
|
||||||
|
|
||||||
|
CefRefPtr<CefPrintDialogCallback> dialog_callback_;
|
||||||
|
CefRefPtr<CefPrintJobCallback> job_callback_;
|
||||||
|
|
||||||
|
IMPLEMENT_REFCOUNTING(ClientPrintHandlerGtk);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CEF_TESTS_CEFCLIENT_PRINT_HANDLER_GTK_H_
|
||||||
|
|
@ -90,4 +90,11 @@ char (&ArraySizeHelper(const T (&array)[N]))[N];
|
|||||||
|
|
||||||
#define arraysize(array) (sizeof(ArraySizeHelper(array)))
|
#define arraysize(array) (sizeof(ArraySizeHelper(array)))
|
||||||
|
|
||||||
|
|
||||||
|
// A macro to disallow the copy constructor and operator= functions
|
||||||
|
// This should be used in the private: declarations for a class
|
||||||
|
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||||
|
TypeName(const TypeName&); \
|
||||||
|
void operator=(const TypeName&)
|
||||||
|
|
||||||
#endif // CEF_TESTS_CEFCLIENT_UTIL_H_
|
#endif // CEF_TESTS_CEFCLIENT_UTIL_H_
|
||||||
|
@ -83,3 +83,9 @@ void ClientApp::RegisterCustomSchemes(
|
|||||||
std::vector<CefString>& cookiable_schemes);
|
std::vector<CefString>& cookiable_schemes);
|
||||||
RegisterURLRequestCustomSchemes(registrar, cookiable_schemes);
|
RegisterURLRequestCustomSchemes(registrar, cookiable_schemes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
CefRefPtr<CefPrintHandler> ClientApp::CreatePrintHandler() {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
102
tests/unittests/print_unittest.cc
Normal file
102
tests/unittests/print_unittest.cc
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "include/cef_print_settings.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
bool IsEqual(CefRefPtr<CefPrintSettings> expected,
|
||||||
|
CefRefPtr<CefPrintSettings> actual) {
|
||||||
|
if (expected->IsLandscape() != actual->IsLandscape() ||
|
||||||
|
expected->GetDeviceName() != actual->GetDeviceName() ||
|
||||||
|
expected->GetDPI() != actual->GetDPI() ||
|
||||||
|
expected->GetPageRangesCount() != actual->GetPageRangesCount() ||
|
||||||
|
expected->IsSelectionOnly() != actual->IsSelectionOnly() ||
|
||||||
|
expected->WillCollate() != actual->WillCollate() ||
|
||||||
|
expected->GetColorModel() != actual->GetColorModel() ||
|
||||||
|
expected->GetCopies() != actual->GetCopies() ||
|
||||||
|
expected->GetDuplexMode() != actual->GetDuplexMode()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefPrintSettings::PageRangeList expected_ranges, actual_ranges;
|
||||||
|
expected->GetPageRanges(expected_ranges);
|
||||||
|
actual->GetPageRanges(actual_ranges);
|
||||||
|
return std::equal(expected_ranges.begin(),
|
||||||
|
expected_ranges.begin() + expected_ranges.size(),
|
||||||
|
actual_ranges.begin());
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
// Verify Set/Get methods for CefPrintSettings.
|
||||||
|
TEST(PrintTest, SettingsSetGet) {
|
||||||
|
// CefRequest CreateRequest
|
||||||
|
CefRefPtr<CefPrintSettings> settings(CefPrintSettings::Create());
|
||||||
|
EXPECT_TRUE(settings.get() != NULL);
|
||||||
|
EXPECT_TRUE(settings->IsValid());
|
||||||
|
EXPECT_FALSE(settings->IsReadOnly());
|
||||||
|
|
||||||
|
bool landscape = true;
|
||||||
|
settings->SetOrientation(landscape);
|
||||||
|
EXPECT_EQ(landscape, settings->IsLandscape());
|
||||||
|
landscape = false;
|
||||||
|
settings->SetOrientation(landscape);
|
||||||
|
EXPECT_EQ(landscape, settings->IsLandscape());
|
||||||
|
|
||||||
|
const char device_name[] = "my_device_name";
|
||||||
|
settings->SetDeviceName(device_name);
|
||||||
|
EXPECT_STREQ(device_name, settings->GetDeviceName().ToString().c_str());
|
||||||
|
|
||||||
|
int dpi = 25;
|
||||||
|
settings->SetDPI(dpi);
|
||||||
|
EXPECT_EQ(dpi, settings->GetDPI());
|
||||||
|
|
||||||
|
CefPrintSettings::PageRangeList page_ranges;
|
||||||
|
page_ranges.push_back(CefPageRange(1, 3));
|
||||||
|
page_ranges.push_back(CefPageRange(5, 6));
|
||||||
|
settings->SetPageRanges(page_ranges);
|
||||||
|
EXPECT_EQ(page_ranges.size(), settings->GetPageRangesCount());
|
||||||
|
CefPrintSettings::PageRangeList page_ranges2;
|
||||||
|
settings->GetPageRanges(page_ranges2);
|
||||||
|
EXPECT_EQ(page_ranges.size(), page_ranges2.size());
|
||||||
|
for (size_t i = 0; i < page_ranges.size(); ++i)
|
||||||
|
EXPECT_EQ(page_ranges[i], page_ranges2[i]);
|
||||||
|
|
||||||
|
bool selection_only = true;
|
||||||
|
settings->SetSelectionOnly(selection_only);
|
||||||
|
EXPECT_EQ(selection_only, settings->IsSelectionOnly());
|
||||||
|
selection_only = false;
|
||||||
|
settings->SetSelectionOnly(selection_only);
|
||||||
|
EXPECT_EQ(selection_only, settings->IsSelectionOnly());
|
||||||
|
|
||||||
|
bool collate = true;
|
||||||
|
settings->SetCollate(collate);
|
||||||
|
EXPECT_EQ(collate, settings->WillCollate());
|
||||||
|
collate = false;
|
||||||
|
settings->SetCollate(collate);
|
||||||
|
EXPECT_EQ(collate, settings->WillCollate());
|
||||||
|
|
||||||
|
CefPrintSettings::ColorModel color_model = COLOR_MODEL_CMYK;
|
||||||
|
settings->SetColorModel(color_model);
|
||||||
|
EXPECT_EQ(color_model, settings->GetColorModel());
|
||||||
|
|
||||||
|
int copies = 3;
|
||||||
|
settings->SetCopies(copies);
|
||||||
|
EXPECT_EQ(copies, settings->GetCopies());
|
||||||
|
|
||||||
|
CefPrintSettings::DuplexMode duplex_mode = DUPLEX_MODE_SIMPLEX;
|
||||||
|
settings->SetDuplexMode(duplex_mode);
|
||||||
|
EXPECT_EQ(duplex_mode, settings->GetDuplexMode());
|
||||||
|
|
||||||
|
CefRefPtr<CefPrintSettings> settings2 = settings->Copy();
|
||||||
|
EXPECT_TRUE(IsEqual(settings, settings2));
|
||||||
|
|
||||||
|
settings2->SetOrientation(!landscape);
|
||||||
|
EXPECT_FALSE(IsEqual(settings, settings2));
|
||||||
|
}
|
@ -382,6 +382,8 @@ _simpletypes = {
|
|||||||
'CefWindowHandle' : ['cef_window_handle_t', 'kNullWindowHandle'],
|
'CefWindowHandle' : ['cef_window_handle_t', 'kNullWindowHandle'],
|
||||||
'CefTextInputContext' : ['cef_text_input_context_t' ,'NULL'],
|
'CefTextInputContext' : ['cef_text_input_context_t' ,'NULL'],
|
||||||
'CefRect' : ['cef_rect_t', 'CefRect()'],
|
'CefRect' : ['cef_rect_t', 'CefRect()'],
|
||||||
|
'CefSize' : ['cef_size_t', 'CefSize()'],
|
||||||
|
'CefPageRange' : ['cef_page_range_t', 'CefPageRange()'],
|
||||||
'CefThreadId' : ['cef_thread_id_t', 'TID_UI'],
|
'CefThreadId' : ['cef_thread_id_t', 'TID_UI'],
|
||||||
'CefTime' : ['cef_time_t', 'CefTime()'],
|
'CefTime' : ['cef_time_t', 'CefTime()'],
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user